juisy 2.0.0-beta.0 → 2.0.0-beta.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/cli/cli.js +6 -4
- package/bin/cli/cmds/index.js +10 -10
- package/bin/cli/cmds/private/docs/generate-api.js +31 -0
- package/bin/cli/cmds/{docs → private/docs}/index.js +4 -6
- package/bin/cli/cmds/{print-globals.js → public/print-globals.js} +0 -1
- package/bin/cli/index.js +1 -1
- package/bin/scripts/prepare.js +22 -0
- package/dist/DataExporter.d.ts +6 -0
- package/dist/cli/CLIFactory.d.ts +48 -11
- package/dist/cli/Command.d.ts +23 -13
- package/dist/cli/GlobalSettings.schema.json +1 -0
- package/dist/cli/InterfaceUtils.d.ts +8 -2
- package/dist/cli/OutputUtils.d.ts +3 -3
- package/dist/cli/Plugin.d.ts +21 -0
- package/dist/cli/extract-usage.d.ts +7 -1
- package/dist/cli/index.d.ts +18 -6
- package/dist/cli/index.js +1261 -138
- package/dist/cli/plugins/command-handler-injections/augment.d.ts +29 -0
- package/dist/cli/{command-visitors → plugins/command-handler-injections/command-visitors}/command-handler-injections.d.ts +1 -1
- package/dist/cli/plugins/command-handler-injections/index.d.ts +3 -0
- package/dist/cli/plugins/command-meta/augment.d.ts +23 -0
- package/dist/cli/{command-visitors/get-command-meta.d.ts → plugins/command-meta/command-visitors/command-meta.d.ts} +1 -1
- package/dist/cli/plugins/command-meta/index.d.ts +3 -0
- package/dist/cli/plugins/default-command-fallbacks/augment.d.ts +3 -0
- package/dist/cli/plugins/default-command-fallbacks/command-visitors/default-command-fallbacks.d.ts +10 -0
- package/dist/cli/plugins/default-command-fallbacks/index.d.ts +3 -0
- package/dist/cli/plugins/load-env-file/augment.d.ts +9 -0
- package/dist/cli/plugins/load-env-file/index.d.ts +3 -0
- package/dist/cli/plugins/private-commands/augment.d.ts +6 -0
- package/dist/cli/{command-visitors → plugins/private-commands/command-visitors}/private-command.d.ts +1 -1
- package/dist/cli/plugins/private-commands/index.d.ts +3 -0
- package/dist/cli/plugins/register-bump-version-command/cmds/index.d.ts +3 -0
- package/dist/cli/plugins/register-bump-version-command/index.d.ts +3 -0
- package/dist/cli/plugins/register-changelog-command/augment.d.ts +110 -0
- package/dist/cli/plugins/register-changelog-command/cmds/index.d.ts +3 -0
- package/dist/cli/plugins/register-changelog-command/index.d.ts +3 -0
- package/dist/cli/plugins/register-docs-commands/augment.d.ts +18 -0
- package/dist/cli/plugins/register-docs-commands/cmds/generate-api.d.ts +3 -0
- package/dist/cli/plugins/register-docs-commands/cmds/generate-cli.d.ts +3 -0
- package/dist/cli/plugins/register-docs-commands/cmds/generate-readme.d.ts +3 -0
- package/dist/cli/plugins/register-docs-commands/cmds/index.d.ts +3 -0
- package/dist/cli/plugins/register-docs-commands/index.d.ts +3 -0
- package/dist/cli/plugins/register-git-hooks-commands/augment.d.ts +40 -0
- package/dist/cli/plugins/register-git-hooks-commands/cmds/index.d.ts +3 -0
- package/dist/cli/plugins/register-git-hooks-commands/cmds/reset.d.ts +3 -0
- package/dist/cli/plugins/register-git-hooks-commands/cmds/sync.d.ts +3 -0
- package/dist/cli/plugins/register-git-hooks-commands/index.d.ts +3 -0
- package/dist/cli/plugins/register-lint-commands/augment.d.ts +39 -0
- package/dist/cli/plugins/register-lint-commands/cmds/commit.d.ts +3 -0
- package/dist/cli/plugins/register-lint-commands/cmds/default.d.ts +3 -0
- package/dist/cli/plugins/register-lint-commands/cmds/markdown.d.ts +3 -0
- package/dist/cli/plugins/register-lint-commands/cmds/staged.d.ts +3 -0
- package/dist/cli/plugins/register-lint-commands/index.d.ts +3 -0
- package/dist/cli/plugins/register-lint-commands/settings.d.ts +11 -0
- package/dist/cli/plugins/register-lint-commands/types.d.ts +26 -0
- package/dist/cli/plugins/register-release-command/augment.d.ts +9 -0
- package/dist/cli/plugins/register-release-command/cmds/index.d.ts +3 -0
- package/dist/cli/plugins/register-release-command/index.d.ts +3 -0
- package/dist/cli/plugins/register-test-command/cmds/index.d.ts +3 -0
- package/dist/cli/plugins/register-test-command/index.d.ts +3 -0
- package/dist/cli/types.d.ts +73 -44
- package/dist/cli/utils.d.ts +3 -3
- package/dist/eject.d.ts +11 -4
- package/dist/index.d.ts +8 -2
- package/dist/index.js +80 -76
- package/dist/project-globals.d.ts +9 -0
- package/dist/templater/index.d.ts +6 -1
- package/dist/templater/index.js +27 -40
- package/dist/templater/markdown-templater/ReadmeTemplater.d.ts +28 -28
- package/dist/templater/markdown-templater/index.d.ts +3 -0
- package/dist/templater/types.d.ts +6 -0
- package/dist/utils/misc.d.ts +1 -1
- package/package.json +194 -179
- package/README.md +0 -211
- package/bin/cli/cmds/changelog.js +0 -41
- package/bin/cli/cmds/docs/generate-api.js +0 -22
- package/bin/cli/cmds/docs/generate-cli.js +0 -11
- package/bin/cli/cmds/docs/generate-readme.js +0 -11
- package/bin/cli/cmds/eject.js +0 -28
- package/bin/cli/cmds/git-hooks/index.js +0 -20
- package/bin/cli/cmds/git-hooks/reset.js +0 -48
- package/bin/cli/cmds/git-hooks/sync.js +0 -19
- package/bin/cli/cmds/release.js +0 -231
- package/bin/cli/lib/docs/generate-api-doc.js +0 -78
- package/bin/cli/lib/version/update-version.js +0 -52
- package/bin/scripts/commit-msg.js +0 -32
- package/bin/scripts/pre-commit.js +0 -24
- package/dist/cli/command-visitors/index.d.ts +0 -9
- package/src/index.js +0 -507
- package/template/CHANGELOG.md +0 -0
- package/template/bin/cli/cli.js +0 -27
- package/template/bin/cli/cmds/changelog.js +0 -71
- package/template/bin/cli/cmds/docs.js +0 -30
- package/template/bin/cli/cmds/docs_cmds/generate-api.js +0 -75
- package/template/bin/cli/cmds/docs_cmds/generate-readme.js +0 -51
- package/template/bin/cli/cmds/git-hooks.js +0 -30
- package/template/bin/cli/cmds/git_hooks_cmds/reset.js +0 -76
- package/template/bin/cli/cmds/git_hooks_cmds/sync.js +0 -44
- package/template/bin/cli/cmds/release.js +0 -219
- package/template/bin/cli/index.js +0 -7
- package/template/bin/cli/lib/docs/generate-api-doc.js +0 -33
- package/template/bin/cli/lib/release/generate-release-note.js +0 -3
- package/template/bin/cli/lib/version/update-version.js +0 -51
- package/template/bin/scripts/commit-msg.js +0 -42
- package/template/bin/scripts/pre-commit.js +0 -32
- package/template/docs/api/docs.config.js +0 -10
- package/template/docs/readme/config.js +0 -22
- package/template/docs/readme/readme.js +0 -70
- package/template/docs/readme/template.md +0 -53
- /package/bin/cli/cmds/{docs → private/docs}/lint.js +0 -0
- /package/bin/cli/cmds/{test.js → private/test.js} +0 -0
- /package/bin/cli/cmds/{squeeze.js → public/squeeze.js} +0 -0
package/template/bin/cli/cli.js
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
const { createCli, utils } = require('@hperchec/juisy')
|
|
2
|
-
const path = require('path')
|
|
3
|
-
const {
|
|
4
|
-
rootDir,
|
|
5
|
-
$style
|
|
6
|
-
} = utils
|
|
7
|
-
// Get package.json content
|
|
8
|
-
const packageJson = require(path.resolve(rootDir, './package.json'))
|
|
9
|
-
|
|
10
|
-
function getBanner () {
|
|
11
|
-
let str = ''
|
|
12
|
-
const title = $style.bold('CLI: ') + packageJson.name
|
|
13
|
-
const length = title.length - 9 // removes characters generated by $style.bold from length
|
|
14
|
-
str += $style.cyan('-'.repeat(length) + '\n')
|
|
15
|
-
str += $style.cyan(title + '\n')
|
|
16
|
-
str += $style.cyan('-'.repeat(length) + '\n')
|
|
17
|
-
str += $style.italic('Made with') + ' ' + $style.red('❤') + ' ' + $style.italic('by ') + $style.bold('Hervé Perchec <contact@herve-perchec.com') + '\n'
|
|
18
|
-
return str
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
// CLI
|
|
22
|
-
module.exports = createCli(cli => cli
|
|
23
|
-
.scriptName('./bin/cli')
|
|
24
|
-
.usage(`${getBanner()}\nUsage: $0 <command> [<options>]`)
|
|
25
|
-
.commandDir('cmds')
|
|
26
|
-
.demandCommand(1, ('Command is missing. See help to learn more.').red)
|
|
27
|
-
)
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
const juisy = require('@hperchec/juisy')
|
|
2
|
-
|
|
3
|
-
// Utils
|
|
4
|
-
const {
|
|
5
|
-
$style,
|
|
6
|
-
log,
|
|
7
|
-
step,
|
|
8
|
-
substep,
|
|
9
|
-
run,
|
|
10
|
-
error,
|
|
11
|
-
wait
|
|
12
|
-
} = juisy.utils
|
|
13
|
-
|
|
14
|
-
// Exports command object
|
|
15
|
-
module.exports = {
|
|
16
|
-
/**
|
|
17
|
-
* Command syntax
|
|
18
|
-
*/
|
|
19
|
-
command: 'changelog',
|
|
20
|
-
/**
|
|
21
|
-
* Aliases
|
|
22
|
-
*/
|
|
23
|
-
aliases: [],
|
|
24
|
-
/**
|
|
25
|
-
* Command description
|
|
26
|
-
*/
|
|
27
|
-
describe: 'Generate changelog file with conventional-changelog-cli',
|
|
28
|
-
/**
|
|
29
|
-
* Builder
|
|
30
|
-
* @param {Object} yargs
|
|
31
|
-
* @return {Object}
|
|
32
|
-
*/
|
|
33
|
-
builder: function (yargs) {
|
|
34
|
-
return yargs.option('i', {
|
|
35
|
-
alias: 'infile',
|
|
36
|
-
type: 'string',
|
|
37
|
-
describe: 'Same as conventional-changelog option',
|
|
38
|
-
default: 'CHANGELOG.md',
|
|
39
|
-
requiresArg: true
|
|
40
|
-
})
|
|
41
|
-
},
|
|
42
|
-
/**
|
|
43
|
-
* Handler
|
|
44
|
-
* @param {Object} argv - The argv
|
|
45
|
-
* @return {void}
|
|
46
|
-
*/
|
|
47
|
-
handler: async function (argv) {
|
|
48
|
-
/**
|
|
49
|
-
* Generate changelog file
|
|
50
|
-
*/
|
|
51
|
-
step('Generating changelog')
|
|
52
|
-
await wait('Generating', async () => {
|
|
53
|
-
try {
|
|
54
|
-
await run(
|
|
55
|
-
'npx',
|
|
56
|
-
[
|
|
57
|
-
'conventional-changelog',
|
|
58
|
-
'-p', 'angular',
|
|
59
|
-
'-i', argv.infile,
|
|
60
|
-
'-s' // same file to output
|
|
61
|
-
],
|
|
62
|
-
{ stdio: 'pipe' }
|
|
63
|
-
)
|
|
64
|
-
} catch (e) {
|
|
65
|
-
error('Unable to generate changelog', e)
|
|
66
|
-
}
|
|
67
|
-
})
|
|
68
|
-
substep($style.green('✔ Success'), { last: true })
|
|
69
|
-
log() // Blank line
|
|
70
|
-
}
|
|
71
|
-
}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
// Exports command object
|
|
2
|
-
module.exports = {
|
|
3
|
-
/**
|
|
4
|
-
* Command syntax
|
|
5
|
-
*/
|
|
6
|
-
command: 'docs <command>',
|
|
7
|
-
/**
|
|
8
|
-
* Aliases
|
|
9
|
-
*/
|
|
10
|
-
aliases: [],
|
|
11
|
-
/**
|
|
12
|
-
* Command description
|
|
13
|
-
*/
|
|
14
|
-
describe: 'Manage project documentation',
|
|
15
|
-
/**
|
|
16
|
-
* Builder
|
|
17
|
-
* @param {Object} yargs
|
|
18
|
-
* @return {Object}
|
|
19
|
-
*/
|
|
20
|
-
builder: function (yargs) {
|
|
21
|
-
return yargs.commandDir('docs_cmds')
|
|
22
|
-
.demandCommand(1, ('Command is missing. See help to learn more.').red)
|
|
23
|
-
},
|
|
24
|
-
/**
|
|
25
|
-
* Handler
|
|
26
|
-
* @param {Object} argv - The argv
|
|
27
|
-
* @return {void}
|
|
28
|
-
*/
|
|
29
|
-
handler: async function (argv) {}
|
|
30
|
-
}
|
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
const fs = require('fs-extra')
|
|
2
|
-
const path = require('path')
|
|
3
|
-
const juisy = require('@hperchec/juisy')
|
|
4
|
-
|
|
5
|
-
const {
|
|
6
|
-
rootDir,
|
|
7
|
-
$style,
|
|
8
|
-
log,
|
|
9
|
-
step,
|
|
10
|
-
substep,
|
|
11
|
-
error,
|
|
12
|
-
abort
|
|
13
|
-
} = juisy.utils
|
|
14
|
-
|
|
15
|
-
const generateAPIDoc = require('../../lib/docs/generate-api-doc')
|
|
16
|
-
|
|
17
|
-
// Exports command object
|
|
18
|
-
module.exports = {
|
|
19
|
-
/**
|
|
20
|
-
* Command syntax
|
|
21
|
-
*/
|
|
22
|
-
command: 'generate:api',
|
|
23
|
-
/**
|
|
24
|
-
* Aliases
|
|
25
|
-
*/
|
|
26
|
-
aliases: [],
|
|
27
|
-
/**
|
|
28
|
-
* Command description
|
|
29
|
-
*/
|
|
30
|
-
describe: 'Generate docs from source code',
|
|
31
|
-
/**
|
|
32
|
-
* Builder
|
|
33
|
-
* @param {Object} yargs
|
|
34
|
-
* @return {Object}
|
|
35
|
-
*/
|
|
36
|
-
builder: function (yargs) {
|
|
37
|
-
yargs.option('c', {
|
|
38
|
-
alias: 'config',
|
|
39
|
-
type: 'string',
|
|
40
|
-
default: './docs/api/docs.config.js',
|
|
41
|
-
describe: 'Path to custom config file relative to root folder (default: "./docs/api/docs.config.js")',
|
|
42
|
-
requiresArg: true
|
|
43
|
-
})
|
|
44
|
-
return yargs
|
|
45
|
-
},
|
|
46
|
-
/**
|
|
47
|
-
* Handler
|
|
48
|
-
* @param {Object} argv - The argv
|
|
49
|
-
* @return {void}
|
|
50
|
-
*/
|
|
51
|
-
handler: async function (argv) {
|
|
52
|
-
let options = {}
|
|
53
|
-
|
|
54
|
-
/**
|
|
55
|
-
* Process config option
|
|
56
|
-
*/
|
|
57
|
-
step('Configuration')
|
|
58
|
-
const configPath = path.resolve(rootDir, argv.config)
|
|
59
|
-
// Check if file exist
|
|
60
|
-
if (fs.existsSync(configPath)) {
|
|
61
|
-
options = require(configPath)
|
|
62
|
-
} else {
|
|
63
|
-
// Else log error and exit
|
|
64
|
-
error(`Can't find config file: "${configPath}"`)
|
|
65
|
-
abort(1)
|
|
66
|
-
}
|
|
67
|
-
substep($style.green('✔ Successfuly configured'), { last: true })
|
|
68
|
-
log() // blank line
|
|
69
|
-
|
|
70
|
-
/**
|
|
71
|
-
* Call generateAPIDoc function
|
|
72
|
-
*/
|
|
73
|
-
await generateAPIDoc(options)
|
|
74
|
-
}
|
|
75
|
-
}
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
const juisy = require('@hperchec/juisy')
|
|
2
|
-
|
|
3
|
-
const { run } = juisy.utils
|
|
4
|
-
|
|
5
|
-
// Exports command object
|
|
6
|
-
module.exports = {
|
|
7
|
-
/**
|
|
8
|
-
* Command syntax
|
|
9
|
-
*/
|
|
10
|
-
command: 'generate:readme',
|
|
11
|
-
/**
|
|
12
|
-
* Aliases
|
|
13
|
-
*/
|
|
14
|
-
aliases: [],
|
|
15
|
-
/**
|
|
16
|
-
* Command description
|
|
17
|
-
*/
|
|
18
|
-
describe: 'Generate README.md file based on template with @hperchec/readme-generator package',
|
|
19
|
-
/**
|
|
20
|
-
* Builder
|
|
21
|
-
* @param {Object} yargs
|
|
22
|
-
* @return {Object}
|
|
23
|
-
*/
|
|
24
|
-
builder: function (yargs) {
|
|
25
|
-
yargs.option('c', {
|
|
26
|
-
alias: 'config',
|
|
27
|
-
type: 'string',
|
|
28
|
-
describe: 'Same as @hperchec/readme-generator --config option',
|
|
29
|
-
requiresArg: true
|
|
30
|
-
})
|
|
31
|
-
return yargs
|
|
32
|
-
},
|
|
33
|
-
/**
|
|
34
|
-
* Handler
|
|
35
|
-
* @param {Object} argv - The argv
|
|
36
|
-
* @return {void}
|
|
37
|
-
*/
|
|
38
|
-
handler: async function (argv) {
|
|
39
|
-
/**
|
|
40
|
-
* Call readme-generator command
|
|
41
|
-
*/
|
|
42
|
-
await run(
|
|
43
|
-
'npx',
|
|
44
|
-
[
|
|
45
|
-
'readme-generator',
|
|
46
|
-
...(argv.config ? [ '--config', argv.config ] : [])
|
|
47
|
-
],
|
|
48
|
-
{ stdio: 'inherit' }
|
|
49
|
-
)
|
|
50
|
-
}
|
|
51
|
-
}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
// Exports command object
|
|
2
|
-
module.exports = {
|
|
3
|
-
/**
|
|
4
|
-
* Command syntax
|
|
5
|
-
*/
|
|
6
|
-
command: 'git-hooks <command>',
|
|
7
|
-
/**
|
|
8
|
-
* Aliases
|
|
9
|
-
*/
|
|
10
|
-
aliases: [],
|
|
11
|
-
/**
|
|
12
|
-
* Command description
|
|
13
|
-
*/
|
|
14
|
-
describe: 'Git relative commands',
|
|
15
|
-
/**
|
|
16
|
-
* Builder
|
|
17
|
-
* @param {Object} yargs
|
|
18
|
-
* @return {Object}
|
|
19
|
-
*/
|
|
20
|
-
builder: function (yargs) {
|
|
21
|
-
return yargs.commandDir('git_hooks_cmds')
|
|
22
|
-
.demandCommand(1, ('Command is missing. See help to learn more.').red)
|
|
23
|
-
},
|
|
24
|
-
/**
|
|
25
|
-
* Handler
|
|
26
|
-
* @param {Object} argv - The argv
|
|
27
|
-
* @return {void}
|
|
28
|
-
*/
|
|
29
|
-
handler: async function (argv) {}
|
|
30
|
-
}
|
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
const fs = require('fs-extra')
|
|
2
|
-
const path = require('path')
|
|
3
|
-
const juisy = require('@hperchec/juisy')
|
|
4
|
-
|
|
5
|
-
const {
|
|
6
|
-
$style,
|
|
7
|
-
abort,
|
|
8
|
-
log,
|
|
9
|
-
rootDir,
|
|
10
|
-
step,
|
|
11
|
-
substep,
|
|
12
|
-
run
|
|
13
|
-
} = juisy.utils
|
|
14
|
-
|
|
15
|
-
// Exports command object
|
|
16
|
-
module.exports = {
|
|
17
|
-
/**
|
|
18
|
-
* Command syntax
|
|
19
|
-
*/
|
|
20
|
-
command: 'reset',
|
|
21
|
-
/**
|
|
22
|
-
* Aliases
|
|
23
|
-
*/
|
|
24
|
-
aliases: [],
|
|
25
|
-
/**
|
|
26
|
-
* Command description
|
|
27
|
-
*/
|
|
28
|
-
describe: 'Reset git hooks',
|
|
29
|
-
/**
|
|
30
|
-
* Builder
|
|
31
|
-
* @param {object} yargs - yargs
|
|
32
|
-
* @returns {object} Returns yargs
|
|
33
|
-
*/
|
|
34
|
-
builder: function (yargs) {
|
|
35
|
-
return yargs
|
|
36
|
-
},
|
|
37
|
-
/**
|
|
38
|
-
* Handler
|
|
39
|
-
* @param {object} argv - The argv
|
|
40
|
-
* @returns {void}
|
|
41
|
-
*/
|
|
42
|
-
handler: async function (argv) {
|
|
43
|
-
/**
|
|
44
|
-
* Reset git hooks
|
|
45
|
-
*/
|
|
46
|
-
step('Reset git hooks')
|
|
47
|
-
|
|
48
|
-
// Create temporary empty configuration file
|
|
49
|
-
const tempConfigFilePath = './__TEMP_SIMPLE_GIT_HOOKS_CONFIG__.json' // relative to project root folder
|
|
50
|
-
fs.writeFileSync(path.resolve(rootDir, tempConfigFilePath), '{}')
|
|
51
|
-
|
|
52
|
-
// Run command with empty configuration
|
|
53
|
-
let commandError = false
|
|
54
|
-
try {
|
|
55
|
-
await run('npx', [
|
|
56
|
-
'simple-git-hooks',
|
|
57
|
-
tempConfigFilePath
|
|
58
|
-
], { stdio: 'pipe', cwd: rootDir })
|
|
59
|
-
} catch (e) {
|
|
60
|
-
commandError = e
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
// Don't forget to always remove temporary file
|
|
64
|
-
fs.unlinkSync(path.resolve(rootDir, tempConfigFilePath))
|
|
65
|
-
|
|
66
|
-
// If error
|
|
67
|
-
if (commandError) {
|
|
68
|
-
substep($style.red('❌ Unable to reset git hooks.'), { last: true })
|
|
69
|
-
abort(1) // Abort with error
|
|
70
|
-
} else {
|
|
71
|
-
// Everything is okay
|
|
72
|
-
substep($style.green('✔ Git hooks successfuly reset'), { last: true })
|
|
73
|
-
log() // blank line
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
}
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
const juisy = require('@hperchec/juisy')
|
|
2
|
-
|
|
3
|
-
const {
|
|
4
|
-
rootDir,
|
|
5
|
-
step,
|
|
6
|
-
run
|
|
7
|
-
} = juisy.utils
|
|
8
|
-
|
|
9
|
-
// Exports command object
|
|
10
|
-
module.exports = {
|
|
11
|
-
/**
|
|
12
|
-
* Command syntax
|
|
13
|
-
*/
|
|
14
|
-
command: 'sync',
|
|
15
|
-
/**
|
|
16
|
-
* Aliases
|
|
17
|
-
*/
|
|
18
|
-
aliases: [],
|
|
19
|
-
/**
|
|
20
|
-
* Command description
|
|
21
|
-
*/
|
|
22
|
-
describe: 'Sync git hooks',
|
|
23
|
-
/**
|
|
24
|
-
* Builder
|
|
25
|
-
* @param {object} yargs - yargs
|
|
26
|
-
* @returns {object} Returns yargs
|
|
27
|
-
*/
|
|
28
|
-
builder: function (yargs) {
|
|
29
|
-
return yargs
|
|
30
|
-
},
|
|
31
|
-
/**
|
|
32
|
-
* Handler
|
|
33
|
-
* @param {object} argv - The argv
|
|
34
|
-
* @returns {void}
|
|
35
|
-
*/
|
|
36
|
-
handler: async function (argv) {
|
|
37
|
-
/**
|
|
38
|
-
* Sync git hooks
|
|
39
|
-
*/
|
|
40
|
-
step('Sync git hooks')
|
|
41
|
-
|
|
42
|
-
await run('npx', [ 'simple-git-hooks' ], { cwd: rootDir })
|
|
43
|
-
}
|
|
44
|
-
}
|
|
@@ -1,219 +0,0 @@
|
|
|
1
|
-
const juisy = require('@hperchec/juisy')
|
|
2
|
-
const path = require('path')
|
|
3
|
-
const semver = require('semver')
|
|
4
|
-
|
|
5
|
-
const {
|
|
6
|
-
rootDir,
|
|
7
|
-
$style,
|
|
8
|
-
log,
|
|
9
|
-
step,
|
|
10
|
-
substep,
|
|
11
|
-
run,
|
|
12
|
-
error,
|
|
13
|
-
wait,
|
|
14
|
-
abort,
|
|
15
|
-
prompts
|
|
16
|
-
} = juisy.utils
|
|
17
|
-
|
|
18
|
-
// Get package.json content
|
|
19
|
-
const packageJson = require(path.resolve(rootDir, './package.json'))
|
|
20
|
-
const updateVersion = require('../lib/version/update-version')
|
|
21
|
-
|
|
22
|
-
// Exports command object
|
|
23
|
-
module.exports = {
|
|
24
|
-
/**
|
|
25
|
-
* Command syntax
|
|
26
|
-
*/
|
|
27
|
-
command: 'release',
|
|
28
|
-
/**
|
|
29
|
-
* Aliases
|
|
30
|
-
*/
|
|
31
|
-
aliases: [],
|
|
32
|
-
/**
|
|
33
|
-
* Command description
|
|
34
|
-
*/
|
|
35
|
-
describe: 'Make a release',
|
|
36
|
-
/**
|
|
37
|
-
* Builder
|
|
38
|
-
* @param {Object} yargs
|
|
39
|
-
* @return {Object}
|
|
40
|
-
*/
|
|
41
|
-
builder: function (yargs) {
|
|
42
|
-
return yargs.option('p', {
|
|
43
|
-
alias: 'preid',
|
|
44
|
-
type: 'string',
|
|
45
|
-
describe: 'Pre-release id',
|
|
46
|
-
requiresArg: true
|
|
47
|
-
})
|
|
48
|
-
},
|
|
49
|
-
/**
|
|
50
|
-
* Handler
|
|
51
|
-
* @param {Object} argv - The argv
|
|
52
|
-
* @return {void}
|
|
53
|
-
*/
|
|
54
|
-
handler: async function (argv) {
|
|
55
|
-
let targetVersion
|
|
56
|
-
const currentVersion = packageJson.version
|
|
57
|
-
const packageName = packageJson.name
|
|
58
|
-
const preId = argv.preid || (semver.prerelease(currentVersion) && semver.prerelease(currentVersion)[0])
|
|
59
|
-
const inc = i => semver.inc(currentVersion, i, preId)
|
|
60
|
-
const versionIncrements = [
|
|
61
|
-
'patch',
|
|
62
|
-
'minor',
|
|
63
|
-
'major',
|
|
64
|
-
...(preId ? [ 'prepatch', 'preminor', 'premajor', 'prerelease' ] : [])
|
|
65
|
-
]
|
|
66
|
-
|
|
67
|
-
/**
|
|
68
|
-
* First, check if local repository is clean
|
|
69
|
-
*/
|
|
70
|
-
step('Checking changes to commit')
|
|
71
|
-
const { stdout } = await run('git', [ 'diff' ], { stdio: 'pipe' })
|
|
72
|
-
if (stdout) {
|
|
73
|
-
error('Please commit your changes before creating a new release!', new Error('There are changes to commit'))
|
|
74
|
-
}
|
|
75
|
-
substep($style.green('✔ Local repository is clean'), { last: true })
|
|
76
|
-
log() // Blank line
|
|
77
|
-
|
|
78
|
-
/**
|
|
79
|
-
* Release prompt
|
|
80
|
-
*/
|
|
81
|
-
step('Setup')
|
|
82
|
-
const { release } = await prompts([
|
|
83
|
-
{
|
|
84
|
-
type: 'select',
|
|
85
|
-
name: 'release',
|
|
86
|
-
message: 'Release type:',
|
|
87
|
-
choices: versionIncrements.map(i => ({ title: `${i} (${inc(i)})`, value: inc(i) })).concat([ { title: 'custom', value: 'custom' } ])
|
|
88
|
-
}
|
|
89
|
-
])
|
|
90
|
-
// If custom release
|
|
91
|
-
if (release === 'custom') {
|
|
92
|
-
const { version: customVersion } = await prompts([
|
|
93
|
-
{
|
|
94
|
-
type: 'text',
|
|
95
|
-
name: 'version',
|
|
96
|
-
message: 'New custom version:',
|
|
97
|
-
initial: currentVersion,
|
|
98
|
-
validate: value => Boolean(semver.valid(value))
|
|
99
|
-
}
|
|
100
|
-
])
|
|
101
|
-
targetVersion = customVersion
|
|
102
|
-
} else {
|
|
103
|
-
targetVersion = release
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
/**
|
|
107
|
-
* Demand confirmation
|
|
108
|
-
*/
|
|
109
|
-
const { confirmed } = await prompts([
|
|
110
|
-
{
|
|
111
|
-
type: 'confirm',
|
|
112
|
-
name: 'confirmed',
|
|
113
|
-
message: `Releasing v${targetVersion}. Confirm?`,
|
|
114
|
-
initial: true
|
|
115
|
-
}
|
|
116
|
-
])
|
|
117
|
-
if (!confirmed) {
|
|
118
|
-
abort()
|
|
119
|
-
return // exit if not confirmed
|
|
120
|
-
}
|
|
121
|
-
log() // Blank line
|
|
122
|
-
|
|
123
|
-
/**
|
|
124
|
-
* Run tests
|
|
125
|
-
*/
|
|
126
|
-
step('Running tests')
|
|
127
|
-
await wait('Testing', async () => {
|
|
128
|
-
await run('npm', [ 'run', 'test' ], { stdio: 'pipe' })
|
|
129
|
-
})
|
|
130
|
-
substep($style.green('✔ Success'), { last: true })
|
|
131
|
-
log() // Blank line
|
|
132
|
-
|
|
133
|
-
/**
|
|
134
|
-
* Update version in necessary files
|
|
135
|
-
*/
|
|
136
|
-
await updateVersion(targetVersion)
|
|
137
|
-
log() // Blank line
|
|
138
|
-
|
|
139
|
-
/**
|
|
140
|
-
* Generate changelog file
|
|
141
|
-
*/
|
|
142
|
-
step('Generating changelog')
|
|
143
|
-
await wait('Generating', async () => {
|
|
144
|
-
await run('node', [ './bin/cli', 'changelog' ], { stdio: 'pipe' })
|
|
145
|
-
})
|
|
146
|
-
substep($style.green('✔ Success'), { last: true })
|
|
147
|
-
log() // Blank line
|
|
148
|
-
|
|
149
|
-
/**
|
|
150
|
-
* Publish package
|
|
151
|
-
*/
|
|
152
|
-
step(`Publishing ${packageName}`)
|
|
153
|
-
// Skip by default
|
|
154
|
-
substep($style.yellow('Not configured. Skipping...'), { last: true })
|
|
155
|
-
log()
|
|
156
|
-
// OR: Uncomment to auto-publish package
|
|
157
|
-
//
|
|
158
|
-
// const releaseTag = targetVersion.includes('alpha')
|
|
159
|
-
// ? 'alpha'
|
|
160
|
-
// : targetVersion.includes('beta')
|
|
161
|
-
// ? 'beta'
|
|
162
|
-
// : targetVersion.includes('rc')
|
|
163
|
-
// ? 'rc'
|
|
164
|
-
// : null
|
|
165
|
-
// let alreadyPublished = false
|
|
166
|
-
// await wait('Publishing', async () => {
|
|
167
|
-
// try {
|
|
168
|
-
// await run('npm', [ 'publish', ...(releaseTag ? [ '--tag', releaseTag ] : []) ], { stdio: 'pipe' })
|
|
169
|
-
// } catch (e) {
|
|
170
|
-
// if (e.stderr.match(/previously published/)) {
|
|
171
|
-
// alreadyPublished = true
|
|
172
|
-
// } else {
|
|
173
|
-
// error('Unknown error during publishing', e)
|
|
174
|
-
// }
|
|
175
|
-
// }
|
|
176
|
-
// })
|
|
177
|
-
// substep(
|
|
178
|
-
// alreadyPublished
|
|
179
|
-
// ? $style.yellow(`Skipping already published: ${packageName}`)
|
|
180
|
-
// : $style.green('✔ Success'),
|
|
181
|
-
// { last: true }
|
|
182
|
-
// )
|
|
183
|
-
// log() // Blank line
|
|
184
|
-
|
|
185
|
-
/**
|
|
186
|
-
* Push to git
|
|
187
|
-
*/
|
|
188
|
-
step('Pushing changes')
|
|
189
|
-
await wait('Committing', async () => {
|
|
190
|
-
try {
|
|
191
|
-
await run('git', [ 'add', '.' ], { stdio: 'pipe' })
|
|
192
|
-
await run('git', [ 'commit', '-m', `release: v${targetVersion}` ], { stdio: 'pipe' })
|
|
193
|
-
} catch (e) {
|
|
194
|
-
error('Unable to commit', e)
|
|
195
|
-
}
|
|
196
|
-
})
|
|
197
|
-
substep($style.green('✔ Committed'))
|
|
198
|
-
await wait('Creating tag', async () => {
|
|
199
|
-
try {
|
|
200
|
-
await run('git', [ 'tag', '-a', `v${targetVersion}`, '-m', `v${targetVersion}` ], { stdio: 'pipe' })
|
|
201
|
-
} catch (e) {
|
|
202
|
-
error('Unable to create tag', e)
|
|
203
|
-
}
|
|
204
|
-
})
|
|
205
|
-
substep($style.green('✔ Tagged'))
|
|
206
|
-
await wait('Pushing', async () => {
|
|
207
|
-
try {
|
|
208
|
-
await run('git', [ 'push', 'origin', '--follow-tags' ], { stdio: 'pipe' })
|
|
209
|
-
} catch (e) {
|
|
210
|
-
error('Unable to push', e)
|
|
211
|
-
}
|
|
212
|
-
})
|
|
213
|
-
substep($style.green('✔ Pushed'), { last: true })
|
|
214
|
-
log() // blank line
|
|
215
|
-
|
|
216
|
-
log($style.green(`✔ Release v${targetVersion} successfuly created`))
|
|
217
|
-
log()
|
|
218
|
-
}
|
|
219
|
-
}
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
const fs = require('fs-extra')
|
|
2
|
-
const path = require('path')
|
|
3
|
-
const juisy = require('@hperchec/juisy')
|
|
4
|
-
|
|
5
|
-
const {
|
|
6
|
-
rootDir,
|
|
7
|
-
$style,
|
|
8
|
-
step,
|
|
9
|
-
substep
|
|
10
|
-
} = juisy.utils
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* Generate doc function
|
|
14
|
-
* @param {Object} [options = {}] - The options object
|
|
15
|
-
*/
|
|
16
|
-
module.exports = async function generateAPIDoc (options = {}) {
|
|
17
|
-
// Process options
|
|
18
|
-
const distDir = options.distDir
|
|
19
|
-
const outputDir = options.outputDir
|
|
20
|
-
|
|
21
|
-
const outputFullPath = path.resolve(rootDir, distDir, outputDir)
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* Generate api documentation
|
|
25
|
-
*/
|
|
26
|
-
step('Generating API documentation')
|
|
27
|
-
|
|
28
|
-
// Here do logic to generate your documentation
|
|
29
|
-
// ex: jsdoc
|
|
30
|
-
fs.writeFileSync(path.resolve(outputFullPath, './api.md'), '# Awesome API !', { encoding: 'utf8' })
|
|
31
|
-
|
|
32
|
-
substep($style.yellow('This command just creates an example file. Let\'s write your logic!'), { last: true })
|
|
33
|
-
}
|