@abcnews/aunty 14.0.1 → 15.0.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.
- package/README.md +1 -13
- package/package.json +11 -9
- package/src/cli/build/index.js +66 -61
- package/src/cli/constants.js +1 -2
- package/src/cli/generate/constants.js +1 -2
- package/src/cli/generate/index.js +44 -36
- package/src/config/serve.js +10 -0
- package/src/config/webpack.js +1 -1
- package/src/generators/project/index.js +1 -1
- package/src/generators/project/templates/preact/src/index.tsx +1 -1
- package/src/utils/structures.js +0 -2
- package/ts/config.json +1 -1
package/README.md
CHANGED
|
@@ -120,7 +120,7 @@ If you don't need to override any of the project defaults, your entire aunty con
|
|
|
120
120
|
| `hasBundleAnalysis` | `false` | Setting this to true will spin up a second server on another port, allowing you to inspect your bundle. The address will be logged to the console when the dev server starts. |
|
|
121
121
|
| `host` | `"localhost"` | The hostname of your dev server. If you're on the ABC internal network, the default will change to your machine's hostname (`ws<number>.aus.aunty.abc.net.au`). The `AUNTY_HOST` environment variable, if present, will override this setting. |
|
|
122
122
|
| `hot` | `true` | Should the dev server enable hot reloading. If `NODE_ENV !== "development"`, the default will change to `false`. |
|
|
123
|
-
| `https` | `true` | Should the dev server use SSL (with a self-signed certificate matching the `host`). You can alternatively supply your own `{cert: string, key: string}` object if you've generated your certificate some other way.
|
|
123
|
+
| `https` | `true` | Should the dev server use SSL (with a self-signed certificate matching the `host`). You can alternatively supply your own `{cert: string, key: string}` object if you've generated your certificate some other way. |
|
|
124
124
|
| `port` | `8000` | The port number of your dev server. If the port specified is unavailable, **aunty** will try incrementing the port number until it finds an available one. The `AUNTY_PORT` environment variable, if present, will override this setting. |
|
|
125
125
|
|
|
126
126
|
#### `deploy` config properties
|
|
@@ -142,18 +142,6 @@ You _could_ also specify `type` (`"ftp"`/`"ssh"`), `host`, `port`, `username` &
|
|
|
142
142
|
|
|
143
143
|
Aunty comes with a few basic generators. Run `aunty generate --help` for the full list, or `aunty generate <generator> --help` for further details.
|
|
144
144
|
|
|
145
|
-
### Async/await
|
|
146
|
-
|
|
147
|
-
One way to add `async`/`await` and generators/`yield` to your project is with the [`regenerator-runtime`](https://www.npmjs.com/package/regenerator-runtime) package.
|
|
148
|
-
|
|
149
|
-
`npm install regenerator-runtime` and then:
|
|
150
|
-
|
|
151
|
-
```js
|
|
152
|
-
import 'regenerator-runtime/runtime';
|
|
153
|
-
```
|
|
154
|
-
|
|
155
|
-
Note: You may also need a `Promise` polyfill for IE11.
|
|
156
|
-
|
|
157
145
|
## Authors
|
|
158
146
|
|
|
159
147
|
- Colin Gourlay
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@abcnews/aunty",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "15.0.0",
|
|
4
4
|
"description": "A toolkit for working with ABC News projects",
|
|
5
5
|
"repository": "abcnews/aunty",
|
|
6
6
|
"license": "MIT",
|
|
@@ -12,7 +12,8 @@
|
|
|
12
12
|
],
|
|
13
13
|
"scripts": {
|
|
14
14
|
"postinstall": "node scripts/postinstall.js",
|
|
15
|
-
"release": "release-it"
|
|
15
|
+
"release": "release-it",
|
|
16
|
+
"test": "jest test/test.js"
|
|
16
17
|
},
|
|
17
18
|
"files": [
|
|
18
19
|
"assets",
|
|
@@ -29,7 +30,7 @@
|
|
|
29
30
|
},
|
|
30
31
|
"main": "src/api",
|
|
31
32
|
"engines": {
|
|
32
|
-
"node": ">=
|
|
33
|
+
"node": ">=16"
|
|
33
34
|
},
|
|
34
35
|
"dependencies": {
|
|
35
36
|
"@babel/core": "^7.11.4",
|
|
@@ -45,7 +46,7 @@
|
|
|
45
46
|
"basic-ftp": "^5.0.2",
|
|
46
47
|
"chalk": "^4.1.2",
|
|
47
48
|
"cli-select": "^1.1.2",
|
|
48
|
-
"copy-webpack-plugin": "^
|
|
49
|
+
"copy-webpack-plugin": "^11.0.0",
|
|
49
50
|
"css-loader": "^6.7.1",
|
|
50
51
|
"csv-loader": "^3.0.3",
|
|
51
52
|
"deepmerge": "^4.0.0",
|
|
@@ -77,11 +78,11 @@
|
|
|
77
78
|
"sass-loader": "^11.0.1",
|
|
78
79
|
"semver": "^7.3.2",
|
|
79
80
|
"style-loader": "^2.0.0",
|
|
80
|
-
"svelte": "^
|
|
81
|
-
"svelte-loader": "^3.1.
|
|
82
|
-
"svelte-preprocess": "^
|
|
81
|
+
"svelte": "^4.2.8",
|
|
82
|
+
"svelte-loader": "^3.1.9",
|
|
83
|
+
"svelte-preprocess": "^5.1.1",
|
|
83
84
|
"tcp-ping-sync": "^1.0.0",
|
|
84
|
-
"typescript": "^
|
|
85
|
+
"typescript": "^5.3.2",
|
|
85
86
|
"update-notifier": "^6.0.2",
|
|
86
87
|
"webpack": "^5.33.2",
|
|
87
88
|
"webpack-bundle-analyzer": "^4.5.0",
|
|
@@ -94,6 +95,7 @@
|
|
|
94
95
|
"babel-eslint": "^10.1.0",
|
|
95
96
|
"eslint": "^7.7.0",
|
|
96
97
|
"eslint-config-prettier": "^8.2.0",
|
|
97
|
-
"release-it": "^15.1.4"
|
|
98
|
+
"release-it": "^15.1.4",
|
|
99
|
+
"yeoman-automation-adapter": "^2.0.0"
|
|
98
100
|
}
|
|
99
101
|
}
|
package/src/cli/build/index.js
CHANGED
|
@@ -19,77 +19,82 @@ const { command } = require('../');
|
|
|
19
19
|
const cleanCommand = require('../clean');
|
|
20
20
|
const { MESSAGES, OPTIONS } = require('./constants');
|
|
21
21
|
|
|
22
|
-
|
|
23
|
-
{
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
options: OPTIONS,
|
|
27
|
-
usage: MESSAGES.usage
|
|
28
|
-
},
|
|
29
|
-
async argv => {
|
|
30
|
-
const { root } = getProjectConfig();
|
|
31
|
-
const webpackConfig = getWebpackConfig();
|
|
32
|
-
let deployConfig;
|
|
33
|
-
|
|
34
|
-
if (!argv.local) {
|
|
35
|
-
deployConfig = getDeployConfig({ id: argv.id });
|
|
36
|
-
webpackConfig.forEach(config => {
|
|
37
|
-
config.output.publicPath = deployConfig.targets[0].publicPath;
|
|
38
|
-
});
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
if (argv.dry) {
|
|
42
|
-
return dry(
|
|
43
|
-
combine(
|
|
44
|
-
{
|
|
45
|
-
'Webpack config': webpackConfig
|
|
46
|
-
},
|
|
47
|
-
deployConfig
|
|
48
|
-
? {
|
|
49
|
-
'Deploy config': deployConfig
|
|
50
|
-
}
|
|
51
|
-
: {}
|
|
52
|
-
)
|
|
53
|
-
);
|
|
54
|
-
}
|
|
22
|
+
const build = async argv => {
|
|
23
|
+
const { root } = getProjectConfig();
|
|
24
|
+
const webpackConfig = getWebpackConfig();
|
|
25
|
+
let deployConfig;
|
|
55
26
|
|
|
56
|
-
|
|
27
|
+
if (!argv.local) {
|
|
28
|
+
deployConfig = getDeployConfig({ id: argv.id });
|
|
29
|
+
webpackConfig.forEach(config => {
|
|
30
|
+
config.output.publicPath = deployConfig.targets[0].publicPath;
|
|
31
|
+
});
|
|
32
|
+
}
|
|
57
33
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
34
|
+
if (argv.dry) {
|
|
35
|
+
return dry(
|
|
36
|
+
combine(
|
|
37
|
+
{
|
|
38
|
+
'Webpack config': webpackConfig
|
|
39
|
+
},
|
|
40
|
+
deployConfig
|
|
41
|
+
? {
|
|
42
|
+
'Deploy config': deployConfig
|
|
43
|
+
}
|
|
44
|
+
: {}
|
|
45
|
+
)
|
|
63
46
|
);
|
|
47
|
+
}
|
|
64
48
|
|
|
65
|
-
|
|
66
|
-
const startTime = Date.now();
|
|
67
|
-
const compiler = webpack(webpackConfig);
|
|
68
|
-
const stats = unpack(await packs(pify(compiler.run.bind(compiler)))());
|
|
49
|
+
throws(await cleanCommand(['--quiet']));
|
|
69
50
|
|
|
70
|
-
|
|
71
|
-
|
|
51
|
+
info(
|
|
52
|
+
MESSAGES.build({
|
|
53
|
+
id: deployConfig ? deployConfig.id : null,
|
|
54
|
+
publicPaths: deployConfig ? deployConfig.targets.map(x => x.publicPath) : [webpackConfig[0].output.publicPath]
|
|
55
|
+
})
|
|
56
|
+
);
|
|
72
57
|
|
|
73
|
-
|
|
58
|
+
let spinner = spin('Building');
|
|
59
|
+
const startTime = Date.now();
|
|
60
|
+
const compiler = webpack(webpackConfig);
|
|
61
|
+
const stats = unpack(await packs(pify(compiler.run.bind(compiler)))());
|
|
74
62
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
}
|
|
63
|
+
if (stats.hasErrors()) {
|
|
64
|
+
const errors = stats.toJson({}, true).errors;
|
|
78
65
|
|
|
79
|
-
|
|
80
|
-
}
|
|
66
|
+
spinner.fail();
|
|
81
67
|
|
|
82
|
-
if (
|
|
83
|
-
|
|
84
|
-
stats.toJson({}, true).warnings.forEach(warning => warn(warning.message));
|
|
85
|
-
} else {
|
|
86
|
-
spinner.succeed(`Built in ${((Date.now() - startTime) / 1000).toFixed(2)}s`);
|
|
68
|
+
if (errors.length > 1) {
|
|
69
|
+
throw MESSAGES.multipleErrors(errors.map(error => error.message));
|
|
87
70
|
}
|
|
88
71
|
|
|
89
|
-
|
|
90
|
-
spinner = spin('Creating deploy configuration');
|
|
91
|
-
writeJsonFile.sync(join(root, OUTPUT_DIRECTORY_NAME, DEPLOY_FILE_NAME), deployConfig);
|
|
92
|
-
spinner.succeed('Created deploy configuration');
|
|
93
|
-
}
|
|
72
|
+
throw errors[0];
|
|
94
73
|
}
|
|
74
|
+
|
|
75
|
+
if (stats.hasWarnings()) {
|
|
76
|
+
spinner.warn();
|
|
77
|
+
stats.toJson({}, true).warnings.forEach(warning => warn(warning.message));
|
|
78
|
+
} else {
|
|
79
|
+
spinner.succeed(`Built in ${((Date.now() - startTime) / 1000).toFixed(2)}s`);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
if (deployConfig) {
|
|
83
|
+
spinner = spin('Creating deploy configuration');
|
|
84
|
+
writeJsonFile.sync(join(root, OUTPUT_DIRECTORY_NAME, DEPLOY_FILE_NAME), deployConfig);
|
|
85
|
+
spinner.succeed('Created deploy configuration');
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
module.exports = command(
|
|
90
|
+
{
|
|
91
|
+
name: 'build',
|
|
92
|
+
nodeEnv: 'production',
|
|
93
|
+
options: OPTIONS,
|
|
94
|
+
usage: MESSAGES.usage
|
|
95
|
+
},
|
|
96
|
+
build
|
|
95
97
|
);
|
|
98
|
+
|
|
99
|
+
// Expose this for the tests
|
|
100
|
+
module.exports._testBuild = build;
|
package/src/cli/constants.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
// Ours
|
|
2
2
|
const { createLogo } = require('../utils/branding');
|
|
3
3
|
const { cmd, dim, hvy, opt, req, sec } = require('../utils/color');
|
|
4
|
-
const { setOfValues } = require('../utils/structures');
|
|
5
4
|
|
|
6
5
|
const COMMAND_ALIASES = (module.exports.COMMAND_ALIASES = {
|
|
7
6
|
b: 'build',
|
|
@@ -14,7 +13,7 @@ const COMMAND_ALIASES = (module.exports.COMMAND_ALIASES = {
|
|
|
14
13
|
t: 'test'
|
|
15
14
|
});
|
|
16
15
|
|
|
17
|
-
module.exports.COMMANDS =
|
|
16
|
+
module.exports.COMMANDS = new Set(Object.values(COMMAND_ALIASES));
|
|
18
17
|
|
|
19
18
|
module.exports.DEFAULTS = {
|
|
20
19
|
name: '__command__',
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
// Ours
|
|
2
2
|
const { cmd, hvy, opt, req, sec } = require('../../utils/color');
|
|
3
|
-
const { setOfValues } = require('../../utils/structures');
|
|
4
3
|
|
|
5
4
|
module.exports.OPTIONS = {
|
|
6
5
|
boolean: ['announce'],
|
|
@@ -14,7 +13,7 @@ const GENERATOR_ALIASES = (module.exports.GENERATOR_ALIASES = {
|
|
|
14
13
|
p: 'project'
|
|
15
14
|
});
|
|
16
15
|
|
|
17
|
-
module.exports.GENERATORS =
|
|
16
|
+
module.exports.GENERATORS = new Set(Object.values(GENERATOR_ALIASES));
|
|
18
17
|
|
|
19
18
|
module.exports.MESSAGES = {
|
|
20
19
|
generatorDoesNotExist: name => `The generator '${name}' does not exist.`,
|
|
@@ -10,55 +10,63 @@ const { log } = require('../../utils/logging');
|
|
|
10
10
|
const { command } = require('../');
|
|
11
11
|
const { GENERATOR_ALIASES, GENERATORS, MESSAGES, OPTIONS } = require('./constants');
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
{
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
options: OPTIONS
|
|
18
|
-
},
|
|
19
|
-
async argv => {
|
|
20
|
-
if (argv.dry) {
|
|
21
|
-
throw MESSAGES.noDryRuns;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
const generatorName = GENERATOR_ALIASES[argv._[0]] || argv._[0];
|
|
13
|
+
const generate = async argv => {
|
|
14
|
+
if (argv.dry) {
|
|
15
|
+
throw MESSAGES.noDryRuns;
|
|
16
|
+
}
|
|
25
17
|
|
|
26
|
-
|
|
27
|
-
// the generate command's usage message (in which case, print it, then exit).
|
|
18
|
+
const generatorName = GENERATOR_ALIASES[argv._[0]] || argv._[0];
|
|
28
19
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
return log(MESSAGES.usage);
|
|
32
|
-
}
|
|
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).
|
|
33
22
|
|
|
34
|
-
|
|
23
|
+
if (!GENERATORS.has(generatorName)) {
|
|
24
|
+
if (!generatorName || generatorName.indexOf('-') === 0 || argv.help) {
|
|
25
|
+
return log(MESSAGES.usage);
|
|
35
26
|
}
|
|
36
27
|
|
|
37
|
-
|
|
28
|
+
throw MESSAGES.generatorDoesNotExist(generatorName);
|
|
29
|
+
}
|
|
38
30
|
|
|
39
|
-
|
|
31
|
+
log(createCommandLogo(`generate ${generatorName}`));
|
|
40
32
|
|
|
41
|
-
|
|
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();
|
|
42
37
|
|
|
43
|
-
|
|
38
|
+
// Register the generator
|
|
44
39
|
|
|
45
|
-
|
|
40
|
+
const generatorPath = require.resolve(`../../generators/${generatorName}`);
|
|
46
41
|
|
|
47
|
-
|
|
42
|
+
env.register(generatorPath, generatorName);
|
|
48
43
|
|
|
49
|
-
|
|
50
|
-
.concat(argv['--'])
|
|
51
|
-
.concat(argv.help ? ['--help'] : [])
|
|
52
|
-
.join(' ');
|
|
44
|
+
// Run the generator, including known arguments
|
|
53
45
|
|
|
54
|
-
|
|
46
|
+
const runArgs = [generatorName]
|
|
47
|
+
.concat(argv['--'])
|
|
48
|
+
.concat(argv.help ? ['--help'] : [])
|
|
49
|
+
.join(' ');
|
|
55
50
|
|
|
56
|
-
|
|
57
|
-
throw err;
|
|
58
|
-
}
|
|
51
|
+
const [err] = await pack(env.run(runArgs));
|
|
59
52
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
53
|
+
if (err) {
|
|
54
|
+
throw err;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
if (argv.announce) {
|
|
58
|
+
announce();
|
|
63
59
|
}
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
module.exports = command(
|
|
63
|
+
{
|
|
64
|
+
name: 'generate',
|
|
65
|
+
hasSubcommands: true,
|
|
66
|
+
options: OPTIONS
|
|
67
|
+
},
|
|
68
|
+
generate
|
|
64
69
|
);
|
|
70
|
+
|
|
71
|
+
// Expose this for the tests
|
|
72
|
+
module.exports._testGenerate = generate;
|
package/src/config/serve.js
CHANGED
|
@@ -86,6 +86,16 @@ const findPort = async (port, max = port + 100, host = '0.0.0.0') => {
|
|
|
86
86
|
// If the connection is refused, it's assumed nothing is listening and the port is available.
|
|
87
87
|
if (e.code === 'ECONNREFUSED') {
|
|
88
88
|
found();
|
|
89
|
+
} else if (e.code === 'ENOTFOUND' && e.syscall === 'getaddrinfo' && e.hostname?.includes(INTERNAL_SUFFIX)) {
|
|
90
|
+
console.error(
|
|
91
|
+
[
|
|
92
|
+
'Could not resolve hostname ' + e.hostname,
|
|
93
|
+
'You appear to be on the ABC network without a hostname attached to your computer.',
|
|
94
|
+
"Aunty can't continue. Consider reconnecting, or add your hostname to your hosts file.",
|
|
95
|
+
''
|
|
96
|
+
].join('\n')
|
|
97
|
+
);
|
|
98
|
+
process.exit(1);
|
|
89
99
|
} else {
|
|
90
100
|
// Not sure what to do with other errors. Log the code & keep seeking a free port.
|
|
91
101
|
next(`error code ${e.code}`);
|
package/src/config/webpack.js
CHANGED
|
@@ -47,7 +47,7 @@ const PROJECT_TYPES_CONFIG = {
|
|
|
47
47
|
config.resolve = {
|
|
48
48
|
// Make sure that only one copy of the Svelte runtime is bundled in the app
|
|
49
49
|
alias: {
|
|
50
|
-
svelte: resolve('node_modules', 'svelte')
|
|
50
|
+
svelte: resolve('node_modules', 'svelte/src/runtime')
|
|
51
51
|
},
|
|
52
52
|
// Recognise .svelte files
|
|
53
53
|
extensions: [...config.resolve.extensions, '.svelte'],
|
|
@@ -26,7 +26,7 @@ if (module.hot) {
|
|
|
26
26
|
module.hot.accept('./components/App', () => {
|
|
27
27
|
try {
|
|
28
28
|
renderApp();
|
|
29
|
-
} catch (err) {
|
|
29
|
+
} catch (err<% if (isTS) { %>: any<% } %>) {
|
|
30
30
|
import('./components/ErrorBox').then(({ default: ErrorBox }) => {
|
|
31
31
|
if (appMountEl) {
|
|
32
32
|
render(<ErrorBox error={err} />, appMountEl);
|
package/src/utils/structures.js
CHANGED
package/ts/config.json
CHANGED
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
"esModuleInterop": true,
|
|
15
15
|
"forceConsistentCasingInFileNames": true,
|
|
16
16
|
"allowSyntheticDefaultImports": true,
|
|
17
|
-
"
|
|
17
|
+
"verbatimModuleSyntax": true,
|
|
18
18
|
"resolveJsonModule": true,
|
|
19
19
|
"isolatedModules": true,
|
|
20
20
|
"strictNullChecks": true
|