Skip to content

Commit

Permalink
major(v2): rewrite from the ground up (#1)
Browse files Browse the repository at this point in the history
* major: complete refactor
* fix: yea, Verb does not understand scoped packages
* fix: cleanup fixtures dir after tests end
* fix: move to latest charlike
* fix: sync version too
* fix: prepare release and publish

Signed-off-by: Charlike Mike Reagent <mameto2011@gmail.com>
  • Loading branch information
Charlike Mike Reagent authored Nov 6, 2018
1 parent e1b0592 commit 1ea2699
Show file tree
Hide file tree
Showing 10 changed files with 400 additions and 313 deletions.
6 changes: 5 additions & 1 deletion .nycrc.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
{
"extends": "./node_modules/@tunnckocore/config/nyc.json"
"extends": "./node_modules/@tunnckocore/config/nyc.json",
"statements": 88,
"branches": 57,
"functions": 100,
"lines": 87
}
13 changes: 4 additions & 9 deletions .verb.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,7 @@ _Generated using [docks](http://npm.im/docks)._

## See Also

Some of these projects are used here or were inspiration for this one, others are just related. So, thanks for your
existance!
Some of these projects are used here or were inspiration for this one, others are just related. So, thanks for your existance!
{%= related(verb.related.list, { words: 10 }) %}

**[back to top](#thetop)**
Expand Down Expand Up @@ -118,12 +117,8 @@ Consider showing your [support](#support-the-project) to them. :sparkling_heart:

## License

Copyright (c) {%= licenseStart %}-present, [Charlike Mike Reagent](https://tunnckocore.com) `<mameto2011@gmail.com>` & [contributors](#wonderful-contributors).
Released under the [{%= license %} License][license-url].

---

{%= include('footer') %}
Copyright (c) 2018-present, [Charlike Mike Reagent](https://tunnckocore.com) `<mameto2011@gmail.com>` & [contributors](#wonderful-contributors).
Released under the [Apache-2.0 License][license-url].

<!-- Heading badges -->

Expand Down Expand Up @@ -169,6 +164,6 @@ Released under the [{%= license %} License][license-url].
[patreon-img]: https://badgen.net/badge/patreon/tunnckoCore/F96854?icon=patreon
[patreon-sponsor-img]: https://badgen.net/badge/become/a%20sponsor/F96854?icon=patreon

[shareu]: https://twitter.com/intent/tweet?text=https://github.com/tunnckoCoreLabs/update&via=tunnckoCore
[shareu]: https://twitter.com/intent/tweet?text=https://github.com/{%=repository%}&via=tunnckoCore
[shareb]: https://badgen.net/badge/twitter/share/1da1f2?icon=twitter
[open-issue-url]: https://github.com/tunnckoCoreLabs/update/issues/new
19 changes: 10 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# @tunnckocore/update [![npm version][npmv-img]][npmv-url] [![github release][ghrelease-img]][ghrelease-url] [![License][license-img]][license-url]

> Update a repository with latest templates from `charlike`.
> Update to latest project files and templates, based on `charlike` scaffolder
Please consider following this project's author, [Charlike Mike Reagent](https://github.com/tunnckoCore), and :star: the project to show your :heart: and support.

Expand Down Expand Up @@ -72,12 +72,16 @@ _Generated using [docks](http://npm.im/docks)._

## See Also

Some of these projects are used here or were inspiration for this one, others are just related. So, thanks for your
existance!
Some of these projects are used here or were inspiration for this one, others are just related. So, thanks for your existance!
- [@tunnckocore/config](https://www.npmjs.com/package/@tunnckocore/config): All the configs for all the tools, in one place | [homepage](https://github.com/tunnckoCoreLabs/config "All the configs for all the tools, in one place")
- [@tunnckocore/create-project](https://www.npmjs.com/package/@tunnckocore/create-project): Create and scaffold a new project, its GitHub repository and… [more](https://github.com/tunnckoCoreLabs/create-project) | [homepage](https://github.com/tunnckoCoreLabs/create-project "Create and scaffold a new project, its GitHub repository and contents")
- [@tunnckocore/execa](https://www.npmjs.com/package/@tunnckocore/execa): Thin layer on top of [execa][] that allows executing multiple… [more](https://github.com/tunnckoCoreLabs/execa) | [homepage](https://github.com/tunnckoCoreLabs/execa "Thin layer on top of [execa][] that allows executing multiple commands in parallel or in sequence")
- [@tunnckocore/scripts](https://www.npmjs.com/package/@tunnckocore/scripts): Universal and minimalist scripts & tasks runner. | [homepage](https://github.com/tunnckoCoreLabs/scripts "Universal and minimalist scripts & tasks runner.")
- [@tunnckocore/update](https://www.npmjs.com/package/@tunnckocore/update): Update a repository with latest templates from `charlike`. | [homepage](https://github.com/tunnckoCoreLabs/update "Update a repository with latest templates from `charlike`.")
- [asia](https://www.npmjs.com/package/asia): Blazingly fast, magical and minimalist testing framework, for Today and… [more](https://github.com/olstenlarck/asia#readme) | [homepage](https://github.com/olstenlarck/asia#readme "Blazingly fast, magical and minimalist testing framework, for Today and Tomorrow")
- [charlike](https://www.npmjs.com/package/charlike): Small & fast project scaffolder with sane defaults. Supports hundreds… [more](https://github.com/tunnckoCoreLabs/charlike) | [homepage](https://github.com/tunnckoCoreLabs/charlike "Small & fast project scaffolder with sane defaults. Supports hundreds of template engines through the @JSTransformers API or if you want custom `render` function passed through options")
- [docks](https://www.npmjs.com/package/docks): Extensible system for parsing and generating documentation. It just freaking… [more](https://github.com/tunnckoCore/docks) | [homepage](https://github.com/tunnckoCore/docks "Extensible system for parsing and generating documentation. It just freaking works!")
- [execa](https://www.npmjs.com/package/execa): A better `child_process` | [homepage](https://github.com/sindresorhus/execa#readme "A better `child_process`")
- [gitcommit](https://www.npmjs.com/package/gitcommit): Lightweight and joyful `git commit` replacement. Conventional Commits compliant. | [homepage](https://github.com/tunnckoCore/gitcommit "Lightweight and joyful `git commit` replacement. Conventional Commits compliant.")

**[back to top](#thetop)**

Expand Down Expand Up @@ -129,10 +133,6 @@ Consider showing your [support](#support-the-project) to them. :sparkling_heart:
Copyright (c) 2018-present, [Charlike Mike Reagent](https://tunnckocore.com) `<mameto2011@gmail.com>` & [contributors](#wonderful-contributors).
Released under the [Apache-2.0 License][license-url].

---

_This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.8.0, on November 02, 2018._

<!-- Heading badges -->

[npmv-url]: https://www.npmjs.com/package/@tunnckocore/update
Expand Down Expand Up @@ -177,9 +177,10 @@ _This file was generated by [verb-generate-readme](https://github.com/verbose/ve
[patreon-img]: https://badgen.net/badge/patreon/tunnckoCore/F96854?icon=patreon
[patreon-sponsor-img]: https://badgen.net/badge/become/a%20sponsor/F96854?icon=patreon

[shareu]: https://twitter.com/intent/tweet?text=https://github.com/tunnckoCoreLabs/update&via=tunnckoCore
[shareu]: https://twitter.com/intent/tweet?text=https://github.com/tunnckoCoreLabs/tunnckocore&via=tunnckoCore
[shareb]: https://badgen.net/badge/twitter/share/1da1f2?icon=twitter
[open-issue-url]: https://github.com/tunnckoCoreLabs/update/issues/new

[execa]: https://github.com/sindresorhus/execa
[new-release]: https://github.com/tunnckoCore/new-release
[semantic-release]: https://github.com/semantic-release/semantic-release
117 changes: 57 additions & 60 deletions cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,74 +2,71 @@

'use strict';

const path = require('path');
/* eslint-disable promise/always-return */

const proc = require('process');
const charlike = require('charlike');
// const { exec } = require('@tunnckocore/execa');
const getPkg = require('@tunnckocore/package-json').default;
const fs = require('fs-extra');

const get = async (name, field) => (await getPkg(name))[field];

const cwd = proc.cwd();
const name = path.basename(cwd);
const upDir = path.dirname(cwd);
const update = require('./index');
const pkg = require('./package.json');

// eslint-disable-next-line import/no-dynamic-require
const pkg = require(path.join(cwd, 'package.json'));
(async function main() {
const argv = await charlike.cli(showHelp, proc.argv.slice(2), {
pkg,
isUpdate: true,
});

async function main() {
proc.chdir(upDir);
try {
const { ranInCwd, cwd } = await update(argv._[0], argv);
console.log('Updating your project has finished.');

const oldCwd = path.join(upDir, `old-${name}`);
if (await fs.pathExists(oldCwd)) {
await fs.remove(oldCwd);
} else {
await fs.move(cwd, oldCwd);
if (ranInCwd) {
console.log('Make sure to open current folder again: cd', cwd);
}
} catch (err) {
console.error(';( Oooh, crap! Some error happened.');
console.error(argv.verbose ? err.stack : err.message);
proc.exit(1);
}
})();

const deps = JSON.stringify(
Object.assign({}, pkg.dependencies, {
esm: `^${await get('esm', 'version')}`,
}),
);

const devDeps = JSON.stringify(
Object.assign({}, pkg.devDependencies, {
'@tunnckocore/config': `^${await get('@tunnckocore/config', 'version')}`,
'@tunnckocore/scripts': `^${await get(
'@tunnckocore/scripts',
'version',
)}`,
asia: `^${await get('asia', 'version')}`,
}),
);

await charlike(pkg.name, pkg.description, {
cwd: upDir,
owner: 'tunnckoCoreLabs',
licenseStart: pkg.licenseStart,
locals: {
pkg: await getPkg(pkg.name),
deps,
devDeps,
},
});
function showHelp(exitCode = 0) {
const log = exitCode === 0 ? console.log : console.error;

await fs.move(path.join(oldCwd, 'src'), path.join(cwd, 'src'), {
overwrite: true,
});
await fs.move(path.join(oldCwd, 'test'), path.join(cwd, 'test'), {
overwrite: true,
});
await fs.move(path.join(oldCwd, '.git'), path.join(cwd, '.git'), {
overwrite: true,
});
log(` update v${pkg.version}
${pkg.description}
console.log('Make sure to `cd` again to', cwd);
}
Usage: update [dirName] [flags]
Common Flags:
-h, --help Display this help.
-v, --version Display current version.
Flags:
-d, --desc Project description, short for "--project.description".
-o, --owner Usually your GitHub username or organization.
-t, --templates Source templates directory.
--engine Engine to be used in the template files.
--locals Locals for the template files. Support dot notation.
--locals.author.name Project's author name.
--locals.author.email Project's author email. And so on.
--project Project metadata like name, description
--project.name Project name.
--project.description Project description.
--cwd Folder to be used as current working dir.
--ly Shortcut for --locals.license.year (license start year).
--ln Set --locals.license.name.
Examples:
update foobar --locals.author.name 'John Snow'
update foobar --locals.license 'Apache-2.0' --locals.foo bar
main().catch((err) => {
console.log(err.stack);
proc.exit(1);
});
Useful when transferring to another org or user:
update foobar --owner tunnckoCoreLabs
Useful when switching license:
update my-project-dir --ly 2015 --ln MIT
`);

proc.exit(exitCode);
}
27 changes: 19 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,21 +1,26 @@
{
"name": "@tunnckocore/update",
"description": "Update a repository with latest templates from `charlike`.",
"description": "Update to latest project files and templates, based on `charlike` scaffolder",
"license": "Apache-2.0",
"licenseStart": "2018",
"scripts": {
"start": "tunnckocore-scripts",
"extends": "@tunnckocore/config/scripts"
"extends": "@tunnckocore/config/scripts",
"docs": "tunnckocore-scripts docs",
"lint": "tunnckocore-scripts lint",
"test": "tunnckocore-scripts test",
"commit": "tunnckocore-scripts commit"
},
"engines": {
"node": "^8.11.0 || >=10.13.0"
},
"dependencies": {
"@tunnckocore/execa": "^2.1.1",
"@tunnckocore/package-json": "^0.3.1",
"charlike": "latest",
"esm": "^3.0.84",
"fs-extra": "^7.0.0"
"fs-extra": "^7.0.0",
"mixin-deep": "^2.0.0",
"mri": "^1.1.1"
},
"devDependencies": {
"@tunnckocore/config": "^0.5.1",
Expand All @@ -24,8 +29,8 @@
},
"files": [
"src",
"cli.js",
"index.js"
"index.js",
"cli.js"
],
"bin": {
"update": "cli.js",
Expand All @@ -34,7 +39,7 @@
"main": "index.js",
"module": "src/index.js",
"typings": "src/index.d.ts",
"version": "0.0.0-semantically-released",
"version": "2.0.0",
"repository": "tunnckoCoreLabs/update",
"homepage": "https://github.com/tunnckoCoreLabs/update",
"author": "Charlike Mike Reagent (https://tunnckocore.com)",
Expand All @@ -61,7 +66,13 @@
"asia",
"charlike",
"docks",
"execa"
"gitcommit",
"@tunnckocore/execa",
"@tunnckocore/package-json",
"@tunnckocore/create-project",
"@tunnckocore/update",
"@tunnckocore/config",
"@tunnckocore/scripts"
]
},
"lint": {
Expand Down
Loading

0 comments on commit 1ea2699

Please sign in to comment.