@abcnews/aunty 16.0.1 → 17.0.0-next.2
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/README.md +1 -160
- package/package.json +39 -82
- package/src/bin/aunty.ts +60 -0
- package/assets/done.mp3 +0 -0
- package/scripts/postinstall.js +0 -44
- package/src/api/index.js +0 -5
- package/src/bin/aunty.js +0 -27
- package/src/cli/build/constants.js +0 -46
- package/src/cli/build/index.js +0 -100
- package/src/cli/clean/constants.js +0 -10
- package/src/cli/clean/index.js +0 -40
- package/src/cli/constants.js +0 -114
- package/src/cli/deploy/constants.js +0 -40
- package/src/cli/deploy/index.js +0 -151
- package/src/cli/generate/constants.js +0 -39
- package/src/cli/generate/index.js +0 -72
- package/src/cli/index.js +0 -154
- package/src/cli/release/constants.js +0 -67
- package/src/cli/release/index.js +0 -162
- package/src/cli/serve/constants.js +0 -33
- package/src/cli/serve/index.js +0 -128
- package/src/cli/sign-cert/constants.js +0 -42
- package/src/cli/sign-cert/index.js +0 -50
- package/src/cli/test/constants.js +0 -15
- package/src/cli/test/index.js +0 -30
- package/src/config/babel.js +0 -75
- package/src/config/build.js +0 -39
- package/src/config/deploy.js +0 -143
- package/src/config/jest/index.js +0 -20
- package/src/config/jest/transformer-default.js +0 -27
- package/src/config/jest/transformer-svelte-preprocess.js +0 -8
- package/src/config/jest/transformer-svelte.js +0 -32
- package/src/config/project.js +0 -57
- package/src/config/serve.js +0 -144
- package/src/config/webpack.js +0 -325
- package/src/config/webpackDevServer.js +0 -46
- package/src/constants.js +0 -7
- package/src/generators/component/index.js +0 -172
- package/src/generators/component/templates/_non_sfc/styles.scss +0 -6
- package/src/generators/component/templates/basic/component-with-d3.test.ts +0 -7
- package/src/generators/component/templates/basic/component-with-d3.ts +0 -30
- package/src/generators/component/templates/basic/component.test.ts +0 -7
- package/src/generators/component/templates/basic/component.ts +0 -11
- package/src/generators/component/templates/preact/component-with-d3.test.tsx +0 -16
- package/src/generators/component/templates/preact/component-with-d3.tsx +0 -45
- package/src/generators/component/templates/preact/component.test.tsx +0 -18
- package/src/generators/component/templates/preact/component.tsx +0 -14
- package/src/generators/component/templates/react/component-with-d3.test.tsx +0 -13
- package/src/generators/component/templates/react/component-with-d3.tsx +0 -44
- package/src/generators/component/templates/react/component.test.tsx +0 -13
- package/src/generators/component/templates/react/component.tsx +0 -14
- package/src/generators/component/templates/svelte/component-with-d3.svelte +0 -46
- package/src/generators/component/templates/svelte/component-with-d3.test.ts +0 -10
- package/src/generators/component/templates/svelte/component.svelte +0 -17
- package/src/generators/component/templates/svelte/component.test.ts +0 -10
- package/src/generators/project/index.js +0 -244
- package/src/generators/project/templates/_common/.editorconfig +0 -12
- package/src/generators/project/templates/_common/.prettierrc +0 -6
- package/src/generators/project/templates/_common/LICENSE +0 -21
- package/src/generators/project/templates/_common/README.md +0 -3
- package/src/generators/project/templates/_common/_.gitignore +0 -12
- package/src/generators/project/templates/_common/package.json +0 -18
- package/src/generators/project/templates/_common/public/index.html +0 -21
- package/src/generators/project/templates/_common/src/components/Worm/worm.svg +0 -4
- package/src/generators/project/templates/_common/tsconfig.json +0 -4
- package/src/generators/project/templates/_non_sfc/src/components/App/styles.scss +0 -23
- package/src/generators/project/templates/_non_sfc/src/components/ErrorBox/styles.scss +0 -16
- package/src/generators/project/templates/_non_sfc/src/components/Worm/styles.scss +0 -4
- package/src/generators/project/templates/basic/src/components/App/index.test.ts +0 -9
- package/src/generators/project/templates/basic/src/components/App/index.ts +0 -22
- package/src/generators/project/templates/basic/src/components/ErrorBox/index.ts +0 -24
- package/src/generators/project/templates/basic/src/components/Worm/index.test.ts +0 -7
- package/src/generators/project/templates/basic/src/components/Worm/index.ts +0 -12
- package/src/generators/project/templates/basic/src/index.ts +0 -50
- package/src/generators/project/templates/preact/src/components/App/index.test.tsx +0 -21
- package/src/generators/project/templates/preact/src/components/App/index.tsx +0 -21
- package/src/generators/project/templates/preact/src/components/ErrorBox/index.tsx +0 -15
- package/src/generators/project/templates/preact/src/components/Worm/index.test.tsx +0 -14
- package/src/generators/project/templates/preact/src/components/Worm/index.tsx +0 -9
- package/src/generators/project/templates/preact/src/index.tsx +0 -42
- package/src/generators/project/templates/react/src/components/App/index.test.tsx +0 -14
- package/src/generators/project/templates/react/src/components/App/index.tsx +0 -21
- package/src/generators/project/templates/react/src/components/ErrorBox/index.tsx +0 -14
- package/src/generators/project/templates/react/src/components/Worm/index.test.tsx +0 -13
- package/src/generators/project/templates/react/src/components/Worm/index.tsx +0 -9
- package/src/generators/project/templates/react/src/index.tsx +0 -40
- package/src/generators/project/templates/svelte/src/components/App/App.svelte +0 -37
- package/src/generators/project/templates/svelte/src/components/App/App.test.ts +0 -18
- package/src/generators/project/templates/svelte/src/components/Worm/Worm.svelte +0 -12
- package/src/generators/project/templates/svelte/src/components/Worm/Worm.test.ts +0 -16
- package/src/generators/project/templates/svelte/src/index.ts +0 -26
- package/src/utils/async.js +0 -13
- package/src/utils/audio.js +0 -30
- package/src/utils/branding.js +0 -57
- package/src/utils/color.js +0 -12
- package/src/utils/ftp.js +0 -80
- package/src/utils/git.js +0 -127
- package/src/utils/logging.js +0 -74
- package/src/utils/npm.js +0 -59
- package/src/utils/remote.js +0 -81
- package/src/utils/structures.js +0 -33
- package/src/utils/text.js +0 -64
- package/ts/config.json +0 -22
- package/ts/custom.d.ts +0 -120
package/src/cli/constants.js
DELETED
|
@@ -1,114 +0,0 @@
|
|
|
1
|
-
// Ours
|
|
2
|
-
const { createLogo } = require('../utils/branding');
|
|
3
|
-
const { cmd, dim, hvy, opt, req, sec } = require('../utils/color');
|
|
4
|
-
|
|
5
|
-
const COMMAND_ALIASES = (module.exports.COMMAND_ALIASES = {
|
|
6
|
-
b: 'build',
|
|
7
|
-
c: 'clean',
|
|
8
|
-
d: 'deploy',
|
|
9
|
-
g: 'generate',
|
|
10
|
-
r: 'release',
|
|
11
|
-
s: 'serve',
|
|
12
|
-
sc: 'sign-cert',
|
|
13
|
-
t: 'test'
|
|
14
|
-
});
|
|
15
|
-
|
|
16
|
-
module.exports.COMMANDS = new Set(Object.values(COMMAND_ALIASES));
|
|
17
|
-
|
|
18
|
-
module.exports.DEFAULTS = {
|
|
19
|
-
name: '__command__',
|
|
20
|
-
options: {
|
|
21
|
-
'--': true,
|
|
22
|
-
boolean: ['dry', 'force', 'help', 'quiet'],
|
|
23
|
-
string: [],
|
|
24
|
-
alias: {
|
|
25
|
-
dry: 'd',
|
|
26
|
-
force: 'f',
|
|
27
|
-
help: 'h',
|
|
28
|
-
quiet: 'q'
|
|
29
|
-
}
|
|
30
|
-
},
|
|
31
|
-
usage: name => `Usage: ${cmd('aunty')} ${cmd(name)} ${opt('[options]')}
|
|
32
|
-
`
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
module.exports.DRY_VARIATIONS = ['--dry', '-d'];
|
|
36
|
-
module.exports.HELP_VARIATIONS = ['--help', '-h', 'h', 'help'];
|
|
37
|
-
module.exports.VERSION_VARIATIONS = ['--version', '-v'];
|
|
38
|
-
|
|
39
|
-
module.exports.MESSAGES = {
|
|
40
|
-
version: versionNumber => `
|
|
41
|
-
${cmd('aunty')} v${versionNumber}`,
|
|
42
|
-
unrecognised: commandName => `Unrecognised command: ${req(commandName)}`,
|
|
43
|
-
usage: isProject => `${createLogo()}
|
|
44
|
-
|
|
45
|
-
Usage: ${cmd('aunty')} ${req('<command>')} ${opt('[options]')} ${opt('[command_options]')}
|
|
46
|
-
|
|
47
|
-
${sec('Options')}
|
|
48
|
-
|
|
49
|
-
${opt('-v')}, ${opt('--version')} Print ${hvy('aunty')}'s version
|
|
50
|
-
|
|
51
|
-
${sec('Project creation commands')}
|
|
52
|
-
|
|
53
|
-
${
|
|
54
|
-
!isProject
|
|
55
|
-
? `${cmd('aunty new')} ${req('<project_name>')}
|
|
56
|
-
Create a project in a new directory
|
|
57
|
-
|
|
58
|
-
${cmd('aunty init')}
|
|
59
|
-
Create a project in the current directory`
|
|
60
|
-
: dim(`[available outside project directory]`)
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
${sec('Development commands')}
|
|
64
|
-
|
|
65
|
-
${
|
|
66
|
-
isProject
|
|
67
|
-
? `${cmd('aunty generate')} ${req('<generator>')}
|
|
68
|
-
Generate code for your project or Core Media
|
|
69
|
-
|
|
70
|
-
${cmd('aunty clean')}
|
|
71
|
-
Delete the current project's build output directories.
|
|
72
|
-
|
|
73
|
-
${cmd('aunty build')}
|
|
74
|
-
Clean & build the current project.
|
|
75
|
-
|
|
76
|
-
${cmd('aunty serve')}
|
|
77
|
-
Build & serve the current project, re-building as files change
|
|
78
|
-
|
|
79
|
-
${cmd('aunty test')}
|
|
80
|
-
Run any tests in the current project.`
|
|
81
|
-
: dim(`[available inside project directory]`)
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
${sec('Deployment commands')}
|
|
85
|
-
|
|
86
|
-
${
|
|
87
|
-
isProject
|
|
88
|
-
? `${cmd('aunty deploy')}
|
|
89
|
-
Deploy the current project.
|
|
90
|
-
|
|
91
|
-
${cmd('aunty release')}
|
|
92
|
-
Build, version bump, then deploy the current project.`
|
|
93
|
-
: dim(`[available inside project directory]`)
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
${sec('Helper commands')}
|
|
97
|
-
|
|
98
|
-
${cmd('aunty help')} ${req('<command>')}
|
|
99
|
-
Display complete help for this ${req('command')}.
|
|
100
|
-
|
|
101
|
-
${cmd('aunty sign-cert')} # Mac OS only (for now)
|
|
102
|
-
Create a consistent SSL certificate for the dev server
|
|
103
|
-
`
|
|
104
|
-
};
|
|
105
|
-
|
|
106
|
-
const NEW_SHORTHAND_EXPANSION = ['generate', 'project', '--'];
|
|
107
|
-
const INIT_SHORTHAND_EXPANSION = NEW_SHORTHAND_EXPANSION.concat(['--here']);
|
|
108
|
-
|
|
109
|
-
module.exports.SHORTHANDS = {
|
|
110
|
-
i: INIT_SHORTHAND_EXPANSION,
|
|
111
|
-
init: INIT_SHORTHAND_EXPANSION,
|
|
112
|
-
n: NEW_SHORTHAND_EXPANSION,
|
|
113
|
-
new: NEW_SHORTHAND_EXPANSION
|
|
114
|
-
};
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
// Ours
|
|
2
|
-
const { cmd, hvy, opt, req, sec } = require('../../utils/color');
|
|
3
|
-
const { styleLastSegment } = require('../../utils/text');
|
|
4
|
-
|
|
5
|
-
const VALID_TYPES = (module.exports.VALID_TYPES = new Map());
|
|
6
|
-
VALID_TYPES.set('ftp', {
|
|
7
|
-
REQUIRED_PROPERTIES: ['from', 'to', 'type', 'username', 'password', 'host']
|
|
8
|
-
});
|
|
9
|
-
VALID_TYPES.set('ssh', {
|
|
10
|
-
REQUIRED_PROPERTIES: ['from', 'to', 'type', 'username', 'host']
|
|
11
|
-
});
|
|
12
|
-
|
|
13
|
-
module.exports.MESSAGES = {
|
|
14
|
-
deploy: ({ from, host, to, type }) => `Deploy (${hvy(type)}):
|
|
15
|
-
┣ ${hvy('from')}: ${styleLastSegment(from, req)}
|
|
16
|
-
┣ ${hvy('to')}: ${styleLastSegment(to, req)}
|
|
17
|
-
┗ ${hvy('host')}: ${req(host)}`,
|
|
18
|
-
deployed: publicPath => `Deployed at ${sec(publicPath)}`,
|
|
19
|
-
deploying: 'Deploying',
|
|
20
|
-
missingProperty: prop => `Missing required property: '${hvy(prop)}'`,
|
|
21
|
-
noDeployConfigFile:
|
|
22
|
-
'No deploy configuration file was found, or its format was unrecognisable. Please re-build the project.',
|
|
23
|
-
noFromDirectory: from => `Directory specified by 'from' property does not exist: ${hvy(from)}`,
|
|
24
|
-
publicURL: url => `Public URL: ${hvy(url)}`,
|
|
25
|
-
unrecognisedType: type =>
|
|
26
|
-
`${type ? 'Unrecognised' : 'No'} deploy type${type ? `: ${hvy(type)}` : ''}. Acceptable types are: ${Array.from(
|
|
27
|
-
VALID_TYPES.keys()
|
|
28
|
-
)
|
|
29
|
-
.map(x => hvy(x))
|
|
30
|
-
.join(', ')}`,
|
|
31
|
-
|
|
32
|
-
// TODO: Add aunty config section to usage
|
|
33
|
-
usage: name => `Usage: ${cmd(`aunty ${name}`)} ${opt('[options]')}
|
|
34
|
-
|
|
35
|
-
${sec('Options')}
|
|
36
|
-
|
|
37
|
-
${opt('-d')}, ${opt('--dry')} Output the deploy configuration, then exit
|
|
38
|
-
${opt('-f')}, ${opt('--force')} Do not prompt to overwrite ftp deploy directory ${opt('[default: false]')}
|
|
39
|
-
`
|
|
40
|
-
};
|
package/src/cli/deploy/index.js
DELETED
|
@@ -1,151 +0,0 @@
|
|
|
1
|
-
// Native
|
|
2
|
-
const { existsSync, statSync } = require('fs');
|
|
3
|
-
const { join } = require('path');
|
|
4
|
-
|
|
5
|
-
// External
|
|
6
|
-
const importLazy = require('import-lazy')(require);
|
|
7
|
-
const loadJsonFile = importLazy('load-json-file');
|
|
8
|
-
const { deploymentExists } = require('../../utils/ftp');
|
|
9
|
-
const { to: wrap } = require('await-to-js');
|
|
10
|
-
const cliSelect = importLazy('cli-select');
|
|
11
|
-
|
|
12
|
-
// Ours
|
|
13
|
-
const { command } = require('../');
|
|
14
|
-
const { addProfileProperties } = require('../../config/deploy');
|
|
15
|
-
const { getProjectConfig } = require('../../config/project');
|
|
16
|
-
const { DEPLOY_FILE_NAME, OUTPUT_DIRECTORY_NAME } = require('../../constants');
|
|
17
|
-
const { throws } = require('../../utils/async');
|
|
18
|
-
const { dry, info, spin, warn, log, error } = require('../../utils/logging');
|
|
19
|
-
const { ftp, rsync } = require('../../utils/remote');
|
|
20
|
-
const { MESSAGES, VALID_TYPES } = require('./constants');
|
|
21
|
-
const { dim, opt, hvy, req } = require('../../utils/color');
|
|
22
|
-
|
|
23
|
-
module.exports = command(
|
|
24
|
-
{
|
|
25
|
-
name: 'deploy',
|
|
26
|
-
usage: MESSAGES.usage
|
|
27
|
-
},
|
|
28
|
-
async argv => {
|
|
29
|
-
const { root } = getProjectConfig();
|
|
30
|
-
let deployConfig;
|
|
31
|
-
|
|
32
|
-
// 1) Load the deploy configuration (created by the build process)
|
|
33
|
-
|
|
34
|
-
try {
|
|
35
|
-
deployConfig = loadJsonFile.sync(join(root, OUTPUT_DIRECTORY_NAME, DEPLOY_FILE_NAME));
|
|
36
|
-
} catch (err) {
|
|
37
|
-
throw new Error(MESSAGES.noDeployConfigFile);
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
let { id, targets } = deployConfig;
|
|
41
|
-
|
|
42
|
-
if (!Array.isArray(targets)) {
|
|
43
|
-
throw new Error(MESSAGES.noDeployConfigFile);
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
// 2) Add profile properties (type, host, port, username, password) to each target
|
|
47
|
-
|
|
48
|
-
targets = targets.map(addProfileProperties);
|
|
49
|
-
|
|
50
|
-
// 3) Validate the deploy configuration
|
|
51
|
-
|
|
52
|
-
for (let target of targets) {
|
|
53
|
-
const { from, type } = target;
|
|
54
|
-
|
|
55
|
-
// 3.1) Check profile's 'type' is valid
|
|
56
|
-
if (!VALID_TYPES.has(type)) {
|
|
57
|
-
throw MESSAGES.unrecognisedType(type);
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
// 3.2) Check all required properties are present
|
|
61
|
-
VALID_TYPES.get(type).REQUIRED_PROPERTIES.forEach(prop => {
|
|
62
|
-
if (target[prop] == null) {
|
|
63
|
-
throw MESSAGES.missingProperty(prop);
|
|
64
|
-
}
|
|
65
|
-
});
|
|
66
|
-
|
|
67
|
-
// 3.3) Check 'from' directory exists
|
|
68
|
-
if (!existsSync(from) || !statSync(from).isDirectory()) {
|
|
69
|
-
throw MESSAGES.noFromDirectory(from);
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
// 3.4) For SSH targets, give the `to` directory a trailing slash
|
|
73
|
-
if (target.type === 'ssh') {
|
|
74
|
-
target.to = target.to.replace(/\/?$/, '/');
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
// 4a) Log config
|
|
79
|
-
|
|
80
|
-
if (argv.dry) {
|
|
81
|
-
return dry({
|
|
82
|
-
'Deploy config': { id, targets }
|
|
83
|
-
});
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
// 4b) Deploy
|
|
87
|
-
|
|
88
|
-
for (let target of targets) {
|
|
89
|
-
const { publicPath, type, to } = target;
|
|
90
|
-
let shouldOverwrite = false;
|
|
91
|
-
|
|
92
|
-
// Check if the deployment already exists
|
|
93
|
-
if (argv.force) shouldOverwrite = true;
|
|
94
|
-
else if (type === 'ftp') {
|
|
95
|
-
const [checkErr] = await wrap(deploymentExists(to));
|
|
96
|
-
|
|
97
|
-
if (checkErr) {
|
|
98
|
-
if (checkErr.code === 550) {
|
|
99
|
-
// Directory doesn't exist. This is actually good though. OK to write.
|
|
100
|
-
shouldOverwrite = true;
|
|
101
|
-
} else {
|
|
102
|
-
error('An FTP error ocurred');
|
|
103
|
-
}
|
|
104
|
-
} else {
|
|
105
|
-
warn('Destination directory exists. OK to overwrite?');
|
|
106
|
-
log(` ┗ ${hvy('dir')}: ${req(to)}`);
|
|
107
|
-
|
|
108
|
-
const overwriteSelection = (
|
|
109
|
-
await cliSelect({
|
|
110
|
-
defaultValue: 1,
|
|
111
|
-
selected: opt('❯'),
|
|
112
|
-
unselected: ' ',
|
|
113
|
-
values: [
|
|
114
|
-
{ label: 'Yes', choice: true },
|
|
115
|
-
{ label: 'No', choice: false }
|
|
116
|
-
],
|
|
117
|
-
valueRenderer: ({ label }, selected) => (selected ? opt(label) : label)
|
|
118
|
-
})
|
|
119
|
-
).value;
|
|
120
|
-
shouldOverwrite = overwriteSelection.choice;
|
|
121
|
-
log(`${dim(`Destination overwrite: ${shouldOverwrite}`)}\n`);
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
// Overwrite by default if ssh for now
|
|
126
|
-
if (type === 'ssh') shouldOverwrite = true;
|
|
127
|
-
|
|
128
|
-
if (shouldOverwrite) {
|
|
129
|
-
info(MESSAGES.deploy(target));
|
|
130
|
-
|
|
131
|
-
const spinner = spin('Deploying');
|
|
132
|
-
|
|
133
|
-
try {
|
|
134
|
-
if (type === 'ftp') {
|
|
135
|
-
throws(await ftp(target, spinner));
|
|
136
|
-
} else if (type === 'ssh') {
|
|
137
|
-
throws(await rsync(target));
|
|
138
|
-
}
|
|
139
|
-
} catch (err) {
|
|
140
|
-
spinner.fail('Deployment failed');
|
|
141
|
-
|
|
142
|
-
throw err;
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
spinner.succeed(MESSAGES.deployed(publicPath));
|
|
146
|
-
} else {
|
|
147
|
-
log('Exiting');
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
);
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
// Ours
|
|
2
|
-
const { cmd, hvy, opt, req, sec } = require('../../utils/color');
|
|
3
|
-
|
|
4
|
-
module.exports.OPTIONS = {
|
|
5
|
-
boolean: ['announce'],
|
|
6
|
-
alias: {
|
|
7
|
-
announce: 'a'
|
|
8
|
-
}
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
const GENERATOR_ALIASES = (module.exports.GENERATOR_ALIASES = {
|
|
12
|
-
c: 'component',
|
|
13
|
-
p: 'project'
|
|
14
|
-
});
|
|
15
|
-
|
|
16
|
-
module.exports.GENERATORS = new Set(Object.values(GENERATOR_ALIASES));
|
|
17
|
-
|
|
18
|
-
module.exports.MESSAGES = {
|
|
19
|
-
generatorDoesNotExist: name => `The generator '${name}' does not exist.`,
|
|
20
|
-
noDryRuns: `Generators don't have dry runs (yet). Please run without the ${opt('--dry')} flag.`,
|
|
21
|
-
usage: `Usage: ${cmd('aunty generate')} ${req('<generator>')} ${opt('[options]')} -- ${opt('[generator_options]')}
|
|
22
|
-
|
|
23
|
-
${sec('Options')}
|
|
24
|
-
|
|
25
|
-
${opt('-h')}, ${opt('--help')} Output the available generators, and exit.
|
|
26
|
-
|
|
27
|
-
${sec('Generators')}
|
|
28
|
-
|
|
29
|
-
${hvy('Project creation')}
|
|
30
|
-
|
|
31
|
-
${req('project')} Create a new project (aliased by ${cmd('aunty new')} and ${cmd('aunty init')}).
|
|
32
|
-
|
|
33
|
-
${hvy('Project additions')}
|
|
34
|
-
|
|
35
|
-
${req('component')} Add a component (and tests) to ${req('src/components/')} for your project type.
|
|
36
|
-
|
|
37
|
-
Run ${cmd('aunty generate')} ${req('<generator>')} ${opt('--help')} for details of each generator's options/arguments.
|
|
38
|
-
`
|
|
39
|
-
};
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
// External
|
|
2
|
-
const importLazy = require('import-lazy')(require);
|
|
3
|
-
const yeoman = importLazy('yeoman-environment');
|
|
4
|
-
|
|
5
|
-
// Ours
|
|
6
|
-
const { pack } = require('../../utils/async');
|
|
7
|
-
const { announce } = require('../../utils/audio');
|
|
8
|
-
const { createCommandLogo } = require('../../utils/branding');
|
|
9
|
-
const { log } = require('../../utils/logging');
|
|
10
|
-
const { command } = require('../');
|
|
11
|
-
const { GENERATOR_ALIASES, GENERATORS, MESSAGES, OPTIONS } = require('./constants');
|
|
12
|
-
|
|
13
|
-
const generate = async argv => {
|
|
14
|
-
if (argv.dry) {
|
|
15
|
-
throw MESSAGES.noDryRuns;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
const generatorName = GENERATOR_ALIASES[argv._[0]] || argv._[0];
|
|
19
|
-
|
|
20
|
-
// If we didn't supply a known generator name, blow up, unless we wanted
|
|
21
|
-
// the generate command's usage message (in which case, print it, then exit).
|
|
22
|
-
|
|
23
|
-
if (!GENERATORS.has(generatorName)) {
|
|
24
|
-
if (!generatorName || generatorName.indexOf('-') === 0 || argv.help) {
|
|
25
|
-
return log(MESSAGES.usage);
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
throw MESSAGES.generatorDoesNotExist(generatorName);
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
log(createCommandLogo(`generate ${generatorName}`));
|
|
32
|
-
|
|
33
|
-
// If we're in a test environment, insert the auto adapter with the provided answers
|
|
34
|
-
const env = global.auntyYeomanAnswers
|
|
35
|
-
? yeoman.createEnv([], {}, new (require('yeoman-automation-adapter').AutoAdapter)(global.auntyYeomanAnswers, true))
|
|
36
|
-
: yeoman.createEnv();
|
|
37
|
-
|
|
38
|
-
// Register the generator
|
|
39
|
-
|
|
40
|
-
const generatorPath = require.resolve(`../../generators/${generatorName}`);
|
|
41
|
-
|
|
42
|
-
env.register(generatorPath, generatorName);
|
|
43
|
-
|
|
44
|
-
// Run the generator, including known arguments
|
|
45
|
-
|
|
46
|
-
const runArgs = [generatorName]
|
|
47
|
-
.concat(argv['--'])
|
|
48
|
-
.concat(argv.help ? ['--help'] : [])
|
|
49
|
-
.join(' ');
|
|
50
|
-
|
|
51
|
-
const [err] = await pack(env.run(runArgs));
|
|
52
|
-
|
|
53
|
-
if (err) {
|
|
54
|
-
throw err;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
if (argv.announce) {
|
|
58
|
-
announce();
|
|
59
|
-
}
|
|
60
|
-
};
|
|
61
|
-
|
|
62
|
-
module.exports = command(
|
|
63
|
-
{
|
|
64
|
-
name: 'generate',
|
|
65
|
-
hasSubcommands: true,
|
|
66
|
-
options: OPTIONS
|
|
67
|
-
},
|
|
68
|
-
generate
|
|
69
|
-
);
|
|
70
|
-
|
|
71
|
-
// Expose this for the tests
|
|
72
|
-
module.exports._testGenerate = generate;
|
package/src/cli/index.js
DELETED
|
@@ -1,154 +0,0 @@
|
|
|
1
|
-
// Env
|
|
2
|
-
require('dotenv').config();
|
|
3
|
-
|
|
4
|
-
// Native
|
|
5
|
-
const { resolve } = require('path');
|
|
6
|
-
|
|
7
|
-
// External
|
|
8
|
-
const importLazy = require('import-lazy')(require);
|
|
9
|
-
const minimist = importLazy('minimist');
|
|
10
|
-
|
|
11
|
-
// Ours
|
|
12
|
-
const pkg = require('../../package');
|
|
13
|
-
const { getProjectConfig } = require('../config/project');
|
|
14
|
-
const { pack, packs, throws } = require('../utils/async');
|
|
15
|
-
const { createCommandLogo } = require('../utils/branding');
|
|
16
|
-
const { log, timer } = require('../utils/logging');
|
|
17
|
-
const { merge } = require('../utils/structures');
|
|
18
|
-
const {
|
|
19
|
-
COMMAND_ALIASES,
|
|
20
|
-
COMMANDS,
|
|
21
|
-
DEFAULTS,
|
|
22
|
-
DRY_VARIATIONS,
|
|
23
|
-
HELP_VARIATIONS,
|
|
24
|
-
MESSAGES,
|
|
25
|
-
SHORTHANDS,
|
|
26
|
-
VERSION_VARIATIONS
|
|
27
|
-
} = require('./constants');
|
|
28
|
-
|
|
29
|
-
module.exports.cli = packs(async args => {
|
|
30
|
-
const __DEBUG__stopTimer = timer('CLI');
|
|
31
|
-
|
|
32
|
-
const updateNotifier = (await import('update-notifier')).default;
|
|
33
|
-
|
|
34
|
-
updateNotifier({ pkg, updateCheckInterval: 36e5 }).notify();
|
|
35
|
-
|
|
36
|
-
// If we just want aunty's version number, print it, then exit
|
|
37
|
-
|
|
38
|
-
if (args.some(arg => VERSION_VARIATIONS.includes(arg))) {
|
|
39
|
-
return log(MESSAGES.version(pkg.version));
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
// Normalise the arguments (see function) and split them
|
|
43
|
-
|
|
44
|
-
args = normalise(args);
|
|
45
|
-
const [commandName, ...commandArgs] = args;
|
|
46
|
-
|
|
47
|
-
// If we didn't supply a known command name, blow up, unless we wanted
|
|
48
|
-
// aunty's usage message (in which case, print it, then exit).
|
|
49
|
-
|
|
50
|
-
if (!COMMANDS.has(commandName)) {
|
|
51
|
-
if (!commandName || args.includes(HELP_VARIATIONS[0])) {
|
|
52
|
-
let isProject = true;
|
|
53
|
-
|
|
54
|
-
try {
|
|
55
|
-
const { type } = getProjectConfig();
|
|
56
|
-
|
|
57
|
-
isProject = !!type;
|
|
58
|
-
} catch (e) {
|
|
59
|
-
isProject = false;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
return log(MESSAGES.usage(isProject));
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
throw MESSAGES.unrecognised(commandName);
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
// Import the command
|
|
69
|
-
|
|
70
|
-
const __DEBUG__stopImportTimer = timer(`CLI.import(${commandName})`);
|
|
71
|
-
|
|
72
|
-
const commandFn = require(resolve(__dirname, `./${commandName}`));
|
|
73
|
-
|
|
74
|
-
if (process.env.AUNTY_DEBUG) {
|
|
75
|
-
__DEBUG__stopImportTimer();
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
// Execute the command with the remaining arguments
|
|
79
|
-
|
|
80
|
-
const __DEBUG__stopExecuteTimer = timer(`CLI.execute(${commandName})`);
|
|
81
|
-
|
|
82
|
-
throws(await commandFn(commandArgs, true));
|
|
83
|
-
|
|
84
|
-
if (process.env.AUNTY_DEBUG) {
|
|
85
|
-
__DEBUG__stopExecuteTimer();
|
|
86
|
-
__DEBUG__stopTimer();
|
|
87
|
-
}
|
|
88
|
-
});
|
|
89
|
-
|
|
90
|
-
const normalise = args => {
|
|
91
|
-
// 1) Move any dry argument variation to second position, as '--dry'
|
|
92
|
-
|
|
93
|
-
const dryArgIndex = args.findIndex(arg => DRY_VARIATIONS.includes(arg));
|
|
94
|
-
|
|
95
|
-
if (dryArgIndex > -1) {
|
|
96
|
-
args.splice(dryArgIndex, 1);
|
|
97
|
-
args.splice(1, 0, DRY_VARIATIONS[0]);
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
// 2) Move any help argument variation to second position, as '--help'
|
|
101
|
-
|
|
102
|
-
const helpArgIndex = args.findIndex(arg => HELP_VARIATIONS.includes(arg));
|
|
103
|
-
|
|
104
|
-
if (helpArgIndex > -1) {
|
|
105
|
-
args.splice(helpArgIndex, 1);
|
|
106
|
-
args.splice(1, 0, HELP_VARIATIONS[0]);
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
// 3) If the first argument is a command alias, expand it
|
|
110
|
-
|
|
111
|
-
args[0] = COMMAND_ALIASES[args[0]] || args[0];
|
|
112
|
-
|
|
113
|
-
// 4) If the first argument is a shorthand, expand it
|
|
114
|
-
|
|
115
|
-
const shorthand = SHORTHANDS[args[0]];
|
|
116
|
-
|
|
117
|
-
if (shorthand) {
|
|
118
|
-
args.splice.apply(args, [0, 1].concat(shorthand));
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
// 5) Return the normalised arguments
|
|
122
|
-
|
|
123
|
-
return args;
|
|
124
|
-
};
|
|
125
|
-
|
|
126
|
-
module.exports.command = ({ name, nodeEnv, options, usage, hasSubcommands }, fn) => {
|
|
127
|
-
name = name || DEFAULTS.name;
|
|
128
|
-
options = merge(DEFAULTS.options, options);
|
|
129
|
-
usage = usage || DEFAULTS.usage;
|
|
130
|
-
|
|
131
|
-
return packs(async (args = [], isEntryCommand) => {
|
|
132
|
-
const argv = minimist(args, options);
|
|
133
|
-
|
|
134
|
-
if (!hasSubcommands) {
|
|
135
|
-
if (argv.help) {
|
|
136
|
-
return log(typeof usage === 'function' ? usage(name) : usage);
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
if (isEntryCommand) {
|
|
140
|
-
log(createCommandLogo(name, argv.dry));
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
if (!process.env.NODE_ENV && nodeEnv) {
|
|
145
|
-
process.env.NODE_ENV = nodeEnv;
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
let [err] = await pack(fn(argv));
|
|
149
|
-
|
|
150
|
-
if (err) {
|
|
151
|
-
throw err;
|
|
152
|
-
}
|
|
153
|
-
});
|
|
154
|
-
};
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
// Ours
|
|
2
|
-
const { cmd, hvy, ok, opt, sec } = require('../../utils/color');
|
|
3
|
-
|
|
4
|
-
const FORCE_REMINDER = `Use the ${opt('--force')} option to ignore warnings or release without tagging.`;
|
|
5
|
-
const VALID_BUMPS = (module.exports.VALID_BUMPS = new Set(['major', 'minor', 'patch', 'prerelease']));
|
|
6
|
-
|
|
7
|
-
const OPTIONS = (module.exports.OPTIONS = {
|
|
8
|
-
string: ['bump', 'git-remote'],
|
|
9
|
-
default: {
|
|
10
|
-
'git-remote': 'origin'
|
|
11
|
-
}
|
|
12
|
-
});
|
|
13
|
-
|
|
14
|
-
module.exports.MESSAGES = {
|
|
15
|
-
bumpQuestion: dry =>
|
|
16
|
-
`${ok('?')} ${hvy(`What package version bump ${dry ? 'would this release have been' : 'is this release'}?`)}`,
|
|
17
|
-
changes: (tag, tags, changelog) =>
|
|
18
|
-
changelog.length
|
|
19
|
-
? `${tags.length ? `Here's what's changed since ${hvy(tag)}` : 'Here are the initial changes'}:
|
|
20
|
-
|
|
21
|
-
${changelog.join('\n')}
|
|
22
|
-
`
|
|
23
|
-
: `${cmd('ℹ')} Nothing has changed since ${hvy(tag)}\n`,
|
|
24
|
-
createCommit: (from, to) => `Bump version ${hvy(from)} → ${hvy(to)}`,
|
|
25
|
-
createTag: tag => `Create tag ${hvy(tag)}`,
|
|
26
|
-
forceReminder: FORCE_REMINDER,
|
|
27
|
-
hasChanges: `You shouldn't release builds which may contain un-committed changes! ${FORCE_REMINDER}`,
|
|
28
|
-
hasTag: (tag, isTagOnHead) =>
|
|
29
|
-
`The tag ${hvy(tag)} already exists${
|
|
30
|
-
isTagOnHead ? '' : ` and your current HEAD doesn't point to it`
|
|
31
|
-
}! ${FORCE_REMINDER}`,
|
|
32
|
-
invalidBump: bump =>
|
|
33
|
-
`You supplied an invalid bump value ${hvy(bump)}. It can be: ${hvy(Array.from(VALID_BUMPS).join('|'))}`,
|
|
34
|
-
notDefaultBranch: (label, defaultBranch) =>
|
|
35
|
-
`You are trying to release from ${hvy(label)}. You should only release from ${hvy(defaultBranch)}`,
|
|
36
|
-
notRepo: `You can't tag a release or deploy using a tag name becase this project isn't a git repo.`,
|
|
37
|
-
pushCommit: remote => `Push version bump to remote ${hvy(remote)}`,
|
|
38
|
-
pushTag: (tag, remote) => `Push tag ${hvy(tag)} to remote ${hvy(remote)}`,
|
|
39
|
-
usage: name => `Usage: ${cmd(`aunty ${name}`)} ${opt('[options]')}
|
|
40
|
-
|
|
41
|
-
${sec('Options')}
|
|
42
|
-
|
|
43
|
-
${opt(`--bump={${Array.from(VALID_BUMPS).join('|')}}`)} Preselect the package version bump for this release ${opt(
|
|
44
|
-
'[default: PROMPT]'
|
|
45
|
-
)}
|
|
46
|
-
${opt('--git-remote')} Git remote to push release tags to (if it exists) ${opt(
|
|
47
|
-
`[default: "${OPTIONS.default['git-remote']}"]`
|
|
48
|
-
)}
|
|
49
|
-
${opt('-d')}, ${opt('--dry')} Output the release version & git remote, then exit
|
|
50
|
-
${opt('-f')}, ${opt('--force')} Ignore warnings & don't bump version ${opt('[default: false]')}
|
|
51
|
-
|
|
52
|
-
${sec('Examples')}
|
|
53
|
-
|
|
54
|
-
${cmd('aunty release')}
|
|
55
|
-
1. Ensure working directory is in a deployable state
|
|
56
|
-
2. Prompt for version bump choice and determine release version
|
|
57
|
-
3. Run \`${cmd('aunty build')} ${opt('--id=<version>')}\`
|
|
58
|
-
4. Commit & tag new version, pushing to existing git remote
|
|
59
|
-
5. Run \`${cmd('aunty deploy')}\`
|
|
60
|
-
|
|
61
|
-
${cmd(`aunty release ${opt('--bump=major')}`)}
|
|
62
|
-
As above, skipping (2).
|
|
63
|
-
|
|
64
|
-
${cmd(`aunty release ${opt('--force')}`)}
|
|
65
|
-
As above, skipping (1, 2 & 4).
|
|
66
|
-
`
|
|
67
|
-
};
|