@abcnews/aunty 16.0.0 → 17.0.0-next.0

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.
Files changed (105) hide show
  1. package/README.md +10 -0
  2. package/dist/bin/aunty.js +3 -0
  3. package/dist/lib/constants.js +8 -0
  4. package/package.json +25 -82
  5. package/assets/done.mp3 +0 -0
  6. package/scripts/postinstall.js +0 -44
  7. package/src/api/index.js +0 -5
  8. package/src/bin/aunty.js +0 -27
  9. package/src/cli/build/constants.js +0 -46
  10. package/src/cli/build/index.js +0 -100
  11. package/src/cli/clean/constants.js +0 -10
  12. package/src/cli/clean/index.js +0 -40
  13. package/src/cli/constants.js +0 -114
  14. package/src/cli/deploy/constants.js +0 -40
  15. package/src/cli/deploy/index.js +0 -151
  16. package/src/cli/generate/constants.js +0 -39
  17. package/src/cli/generate/index.js +0 -72
  18. package/src/cli/index.js +0 -154
  19. package/src/cli/release/constants.js +0 -67
  20. package/src/cli/release/index.js +0 -162
  21. package/src/cli/serve/constants.js +0 -33
  22. package/src/cli/serve/index.js +0 -128
  23. package/src/cli/sign-cert/constants.js +0 -42
  24. package/src/cli/sign-cert/index.js +0 -50
  25. package/src/cli/test/constants.js +0 -15
  26. package/src/cli/test/index.js +0 -30
  27. package/src/config/babel.js +0 -75
  28. package/src/config/build.js +0 -39
  29. package/src/config/deploy.js +0 -143
  30. package/src/config/jest/index.js +0 -20
  31. package/src/config/jest/transformer-default.js +0 -27
  32. package/src/config/jest/transformer-svelte-preprocess.js +0 -8
  33. package/src/config/jest/transformer-svelte.js +0 -32
  34. package/src/config/project.js +0 -57
  35. package/src/config/serve.js +0 -144
  36. package/src/config/webpack.js +0 -325
  37. package/src/config/webpackDevServer.js +0 -46
  38. package/src/constants.js +0 -7
  39. package/src/generators/component/index.js +0 -172
  40. package/src/generators/component/templates/_non_sfc/styles.scss +0 -6
  41. package/src/generators/component/templates/basic/component-with-d3.test.ts +0 -7
  42. package/src/generators/component/templates/basic/component-with-d3.ts +0 -30
  43. package/src/generators/component/templates/basic/component.test.ts +0 -7
  44. package/src/generators/component/templates/basic/component.ts +0 -11
  45. package/src/generators/component/templates/preact/component-with-d3.test.tsx +0 -16
  46. package/src/generators/component/templates/preact/component-with-d3.tsx +0 -45
  47. package/src/generators/component/templates/preact/component.test.tsx +0 -18
  48. package/src/generators/component/templates/preact/component.tsx +0 -14
  49. package/src/generators/component/templates/react/component-with-d3.test.tsx +0 -13
  50. package/src/generators/component/templates/react/component-with-d3.tsx +0 -44
  51. package/src/generators/component/templates/react/component.test.tsx +0 -13
  52. package/src/generators/component/templates/react/component.tsx +0 -14
  53. package/src/generators/component/templates/svelte/component-with-d3.svelte +0 -46
  54. package/src/generators/component/templates/svelte/component-with-d3.test.ts +0 -10
  55. package/src/generators/component/templates/svelte/component.svelte +0 -17
  56. package/src/generators/component/templates/svelte/component.test.ts +0 -10
  57. package/src/generators/project/index.js +0 -244
  58. package/src/generators/project/templates/_common/.editorconfig +0 -12
  59. package/src/generators/project/templates/_common/.prettierrc +0 -6
  60. package/src/generators/project/templates/_common/LICENSE +0 -21
  61. package/src/generators/project/templates/_common/README.md +0 -3
  62. package/src/generators/project/templates/_common/_.gitignore +0 -12
  63. package/src/generators/project/templates/_common/package.json +0 -18
  64. package/src/generators/project/templates/_common/public/index.html +0 -21
  65. package/src/generators/project/templates/_common/src/components/Worm/worm.svg +0 -4
  66. package/src/generators/project/templates/_common/tsconfig.json +0 -4
  67. package/src/generators/project/templates/_non_sfc/src/components/App/styles.scss +0 -23
  68. package/src/generators/project/templates/_non_sfc/src/components/ErrorBox/styles.scss +0 -16
  69. package/src/generators/project/templates/_non_sfc/src/components/Worm/styles.scss +0 -4
  70. package/src/generators/project/templates/basic/src/components/App/index.test.ts +0 -9
  71. package/src/generators/project/templates/basic/src/components/App/index.ts +0 -22
  72. package/src/generators/project/templates/basic/src/components/ErrorBox/index.ts +0 -24
  73. package/src/generators/project/templates/basic/src/components/Worm/index.test.ts +0 -7
  74. package/src/generators/project/templates/basic/src/components/Worm/index.ts +0 -12
  75. package/src/generators/project/templates/basic/src/index.ts +0 -50
  76. package/src/generators/project/templates/preact/src/components/App/index.test.tsx +0 -21
  77. package/src/generators/project/templates/preact/src/components/App/index.tsx +0 -21
  78. package/src/generators/project/templates/preact/src/components/ErrorBox/index.tsx +0 -15
  79. package/src/generators/project/templates/preact/src/components/Worm/index.test.tsx +0 -14
  80. package/src/generators/project/templates/preact/src/components/Worm/index.tsx +0 -9
  81. package/src/generators/project/templates/preact/src/index.tsx +0 -42
  82. package/src/generators/project/templates/react/src/components/App/index.test.tsx +0 -14
  83. package/src/generators/project/templates/react/src/components/App/index.tsx +0 -21
  84. package/src/generators/project/templates/react/src/components/ErrorBox/index.tsx +0 -14
  85. package/src/generators/project/templates/react/src/components/Worm/index.test.tsx +0 -13
  86. package/src/generators/project/templates/react/src/components/Worm/index.tsx +0 -9
  87. package/src/generators/project/templates/react/src/index.tsx +0 -40
  88. package/src/generators/project/templates/svelte/src/components/App/App.svelte +0 -37
  89. package/src/generators/project/templates/svelte/src/components/App/App.test.ts +0 -18
  90. package/src/generators/project/templates/svelte/src/components/Worm/Worm.svelte +0 -12
  91. package/src/generators/project/templates/svelte/src/components/Worm/Worm.test.ts +0 -16
  92. package/src/generators/project/templates/svelte/src/index.ts +0 -26
  93. package/src/utils/async.js +0 -13
  94. package/src/utils/audio.js +0 -30
  95. package/src/utils/branding.js +0 -57
  96. package/src/utils/color.js +0 -12
  97. package/src/utils/ftp.js +0 -80
  98. package/src/utils/git.js +0 -127
  99. package/src/utils/logging.js +0 -74
  100. package/src/utils/npm.js +0 -59
  101. package/src/utils/remote.js +0 -81
  102. package/src/utils/structures.js +0 -33
  103. package/src/utils/text.js +0 -64
  104. package/ts/config.json +0 -22
  105. package/ts/custom.d.ts +0 -120
@@ -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
- };
@@ -1,162 +0,0 @@
1
- // Native
2
- const { existsSync } = require('fs');
3
- const { join } = require('path');
4
-
5
- // External
6
- const importLazy = require('import-lazy')(require);
7
- const cliSelect = importLazy('cli-select');
8
- const loadJsonFile = importLazy('load-json-file');
9
- const semver = importLazy('semver');
10
- const writeJsonFile = importLazy('write-json-file');
11
-
12
- // Ours
13
- const { getProjectConfig } = require('../../config/project');
14
- const { throws } = require('../../utils/async');
15
- const { dim, opt } = require('../../utils/color');
16
- const {
17
- commitAll,
18
- createTag,
19
- getChangelog,
20
- getCurrentLabel,
21
- getDefaultBranch,
22
- getRemotes,
23
- getSemverTags,
24
- hasChanges,
25
- isRepo,
26
- push,
27
- pushTag
28
- } = require('../../utils/git');
29
- const { dry, log, spin } = require('../../utils/logging');
30
- const { combine } = require('../../utils/structures');
31
- const { command } = require('../');
32
- const buildCommand = require('../build');
33
- const deployCommand = require('../deploy');
34
- const { MESSAGES, OPTIONS, VALID_BUMPS } = require('./constants');
35
-
36
- module.exports = command(
37
- {
38
- name: 'release',
39
- options: OPTIONS,
40
- usage: MESSAGES.usage
41
- },
42
- async argv => {
43
- const { pkg, root } = getProjectConfig();
44
-
45
- // 1) Ensure the project is a git repo and determine remotes
46
-
47
- if (!(await isRepo())) {
48
- throw MESSAGES.notRepo;
49
- }
50
-
51
- const remotes = await getRemotes();
52
- const remote = argv['git-remote'];
53
-
54
- // 2) Ensure the default branch is checked out (skippable)
55
-
56
- const label = await getCurrentLabel();
57
- const defaultBranch = await getDefaultBranch(remote);
58
-
59
- if (!argv.force && label !== defaultBranch) {
60
- throw MESSAGES.notDefaultBranch(label, defaultBranch);
61
- }
62
-
63
- // 3) Ensure the project no un-committed changes (skippable)
64
-
65
- if (!argv.force && (await hasChanges())) {
66
- throw MESSAGES.hasChanges;
67
- }
68
-
69
- // 4) Determine the release version
70
-
71
- if (argv.bump && !VALID_BUMPS.has(argv.bump)) {
72
- throw MESSAGES.invalidBump(argv.bump);
73
- }
74
-
75
- const pkgVersion = pkg.version;
76
- const isPrerelease = semver.prerelease(pkgVersion);
77
- let bump = !argv.force && VALID_BUMPS.has(argv.bump) && argv.bump;
78
-
79
- if (!argv.force && !isPrerelease && !bump) {
80
- log(MESSAGES.changes(pkgVersion, await getSemverTags(), await getChangelog(pkgVersion)));
81
- log(MESSAGES.bumpQuestion(argv.dry));
82
-
83
- const bumpSelection = (
84
- await cliSelect({
85
- defaultValue: 0,
86
- selected: opt('❯'),
87
- unselected: ' ',
88
- values: [...VALID_BUMPS].reverse().map(bump => ({
89
- bump,
90
- label: `${bump.replace(/^\w/, c => c.toUpperCase())} (${semver.inc(pkgVersion, bump)})`
91
- })),
92
- valueRenderer: ({ label }, selected) => (selected ? opt(label) : label)
93
- })
94
- ).value;
95
- bump = bumpSelection.bump;
96
- log(`${dim(bumpSelection.label)}\n`);
97
- }
98
-
99
- const version =
100
- (isPrerelease || bump) && semver.valid(pkgVersion)
101
- ? isPrerelease
102
- ? pkgVersion.split('-')[0]
103
- : semver.inc(pkgVersion, bump)
104
- : pkgVersion;
105
-
106
- if (argv.dry) {
107
- return dry({
108
- Release: {
109
- bump,
110
- version,
111
- 'git-remote': remote
112
- }
113
- });
114
- }
115
-
116
- // 5) Build with the new version to ensure there are no errors
117
-
118
- throws(await buildCommand(['--id', version]));
119
-
120
- // 6) Bump the project's version number (optional, skippable)
121
-
122
- let spinner;
123
-
124
- if (!argv.force && version !== pkgVersion) {
125
- spinner = spin(MESSAGES.createCommit(pkgVersion, version));
126
- updateJsonFile(join(root, 'package.json'), { version });
127
- updateJsonFile(join(root, 'package-lock.json'), { version });
128
- await commitAll(version);
129
- spinner.succeed();
130
-
131
- if (remotes.has(remote)) {
132
- spinner = spin(MESSAGES.pushCommit(remote));
133
- await push();
134
- spinner.succeed();
135
- }
136
- }
137
-
138
- // 7) Tag a new release (skippable)
139
-
140
- if (!argv.force) {
141
- spinner = spin(MESSAGES.createTag(version));
142
- await createTag(version);
143
- spinner.succeed();
144
-
145
- if (remotes.has(remote)) {
146
- spinner = spin(MESSAGES.pushTag(version, remote));
147
- await pushTag(remote, version);
148
- spinner.succeed();
149
- }
150
- }
151
-
152
- // 8) Deploy
153
-
154
- throws(await deployCommand());
155
- }
156
- );
157
-
158
- const updateJsonFile = (path, source) => {
159
- if (existsSync(path)) {
160
- writeJsonFile.sync(path, combine(loadJsonFile.sync(path), source));
161
- }
162
- };
@@ -1,33 +0,0 @@
1
- // Ours
2
- const { cmd, hvy, opt, sec } = require('../../utils/color');
3
-
4
- module.exports.BUNDLE_ANALYZER_CONFIG = {
5
- analyzerHost: '127.0.0.1',
6
- logLevel: 'error',
7
- openAnalyzer: false
8
- };
9
-
10
- module.exports.MESSAGES = {
11
- port: ({ port, errorType }) => `Port ${port} could not be used (${errorType}). Attempting to use port ${port + 1}`,
12
- analysis: ({ analyzerHost, analyzerPort }) => `http://${analyzerHost}:${analyzerPort}`,
13
- serve: ({ bundleAnalysisPath, hot, publicPath }) => `Serve (${hvy(process.env.NODE_ENV)}):${
14
- bundleAnalysisPath
15
- ? `
16
- ┣ ${hvy('bundle analysis')}: ${bundleAnalysisPath}`
17
- : ''
18
- }
19
- ┣ ${hvy('hot')}: ${cmd(hot ? 'yes' : 'no')}
20
- ┗ ${hvy('publicPath')}: ${publicPath}`,
21
- // TODO: Add aunty config section to usage
22
- usage: name => `Usage: ${cmd(`aunty ${name}`)} ${opt('[options]')}
23
-
24
- ${sec('Options')}
25
-
26
- ${opt('-d')}, ${opt('--dry')} Output the generated webpack & dev server configuration, then exit
27
-
28
- ${sec('Environment variables')}
29
-
30
- • Builds will assume you have set ${cmd('NODE_ENV=development')}, unless you specify otherwise.
31
- • You can override the host and port the server listens on by setting ${cmd('AUNTY_HOST')} and ${cmd('AUNTY_PORT')}.
32
- `
33
- };