@abcnews/aunty 13.1.1 → 13.2.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 +43 -38
- package/package.json +3 -1
- package/src/cli/clean/index.js +0 -2
- package/src/cli/constants.js +3 -3
- package/src/cli/deploy/constants.js +2 -5
- package/src/cli/deploy/index.js +12 -9
- package/src/cli/generate/constants.js +1 -1
- package/src/cli/generate/index.js +0 -1
- package/src/cli/index.js +3 -0
- package/src/cli/serve/constants.js +2 -2
- package/src/cli/serve/index.js +0 -1
- package/src/cli/sign-cert/index.js +0 -1
- package/src/config/jest/index.js +1 -1
- package/src/config/jest/transformer-svelte.js +0 -1
- package/src/config/serve.js +2 -1
- package/src/config/webpack.js +5 -5
- package/src/config/webpackDevServer.js +3 -3
- package/src/constants.js +2 -1
- package/src/generators/project/index.js +10 -9
- package/src/generators/project/templates/_common/_.gitignore +3 -0
- package/src/utils/ftp.js +7 -2
package/README.md
CHANGED
|
@@ -59,7 +59,7 @@ module.exports = {
|
|
|
59
59
|
// aunty command configuration
|
|
60
60
|
build: {…},
|
|
61
61
|
serve: {…},
|
|
62
|
-
deploy: {…},
|
|
62
|
+
deploy: [{…}],
|
|
63
63
|
// internal tools configuration
|
|
64
64
|
babel: {…},
|
|
65
65
|
jest: {…},
|
|
@@ -75,7 +75,7 @@ module.exports = {
|
|
|
75
75
|
"type": "<project_type>",
|
|
76
76
|
"build": {…},
|
|
77
77
|
"serve": {…},
|
|
78
|
-
"deploy": {…},
|
|
78
|
+
"deploy": [{…}],
|
|
79
79
|
"babel": {…},
|
|
80
80
|
"jest": {…},
|
|
81
81
|
"webpack": {…},
|
|
@@ -85,7 +85,7 @@ module.exports = {
|
|
|
85
85
|
|
|
86
86
|
Supported project `type`s (currently: `basic`, `preact`, `react` & `svelte`) have their own default build configuration, but you can override it by extending your project configuration.
|
|
87
87
|
|
|
88
|
-
The `build`, `serve` and `deploy` properties allow you to override the default settings for those respective commands.
|
|
88
|
+
The `build`, `serve` and `deploy` properties allow you to override the default settings for those respective commands. Their respective properties (and default values) are documented below.
|
|
89
89
|
|
|
90
90
|
Aunty uses some tools internally, which you can also provide custom configuration for. If you supply an object for the `babel`, `jest`, `webpack`, and/or `webpackDevServer` properties, that object will be merged into the default configuration. Optionally, you can supply a function (for any property), which will be passed the default configuration for you to manually modify and return.
|
|
91
91
|
|
|
@@ -99,6 +99,45 @@ Overrides should be used sparingly, as the advantages of using a single-dependen
|
|
|
99
99
|
|
|
100
100
|
If you don't need to override any of the project defaults, your entire aunty configuration can be a string containing the project type, as a shorthand for `{type: "<project_type>"}`. `type` is the only required property in your aunty configuration.
|
|
101
101
|
|
|
102
|
+
#### `build` config properties
|
|
103
|
+
|
|
104
|
+
| property | default | description |
|
|
105
|
+
| ---------------------- | ---------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
106
|
+
| `entry` | `"index"` | The entry file for your project (extension should be unspecified). You can optionally supply an array for multiple entry points, which will result in multiple outputs. |
|
|
107
|
+
| `from` | `"src"` | The source directory that aunty will look for your entry file(s) in. |
|
|
108
|
+
| `to` | `".aunty/build"` | The destination directory for your compiled and static assets. |
|
|
109
|
+
| `staticDir` | `"public"` | The directory you store static assets in. You can optionally supply an array of directories, which will be merged at build time. |
|
|
110
|
+
| `addModernJS` | `false` | Setting this to true will enable a 2nd output file for each entry file named `{name}.modern.js`, which is skips browserlist-based feature polyfilling |
|
|
111
|
+
| `includedDependencies` | `[]` | Any packages (defined by name string or name-matching `RegExp`s) you add to this array will be transpiled in the same manner as the project source. |
|
|
112
|
+
| `extractCSS` | `false` | Setting this to true will create a separate `{name}.css` output for each input, rather than bundling it with the JS (for dynamic `<style>` insertion). |
|
|
113
|
+
| `useCSSModules` | `true` | Setting this to false will turn off CSS module compilation. All styles written will be 'global', and importing CSS files will not give you an object of `className` references. |
|
|
114
|
+
| `showDeprecations` | `false` | Setting this to true will allow NodeJS to output stack traces of deprecation warnings. |
|
|
115
|
+
|
|
116
|
+
#### `serve` config properties
|
|
117
|
+
|
|
118
|
+
| property | default | description |
|
|
119
|
+
| ------------------- | ------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
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
|
+
| `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
|
+
| `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. |
|
|
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
|
+
|
|
126
|
+
#### `deploy` config properties
|
|
127
|
+
|
|
128
|
+
`deploy` should be an array of config objects, one for each deployment target (e.g. ContentFTP)
|
|
129
|
+
|
|
130
|
+
| property | default | description |
|
|
131
|
+
| ------------------- | ----------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
132
|
+
| `from` | build config `to` value | The directory to deploy files from (if you haven't overridden the build `to` value, it should be ".aunty/build") |
|
|
133
|
+
| `files` | `"**"` | A glob matching the files under your `from` directory to deploy |
|
|
134
|
+
| `profile` | `"contentftp"` | This should be the name of a key in your `~/.abc-credentials` file, which will be consulted to populate login credentials. If this is `"contentftp"` it will also populate the config's `to` and `resolvePublicPath` properties. |
|
|
135
|
+
| `publicPath` | `"/"` | If `resolvePublicPath` is defined, `publicPath` will be overwritten by the return value of that function. |
|
|
136
|
+
| `resolvePublicPath` | `undefined` | A function which takes the initial config as an object, and returns an updated `publicPath`. If `profile="contentftp"`, this will be a function that knows how ContentFTP directories map onto ABC URLs. |
|
|
137
|
+
| `to` | `undefined` | The directory on your target to deploy files to. If `profile="contentftp"` , this will be a versioned directory where we deploy News projects to. If you set this to a string, the patterns `<name>` and `<id>` will be replaced by the project name, and the current deployment ID, respectively. During releases, `id` is the current version; during development, it's the current git branch name. You can also specify a custom deployment ID by using the `--id` flag when running `aunty build`. |
|
|
138
|
+
|
|
139
|
+
You _could_ also specify `type` (`"ftp"`/`"ssh"`), `host`, `port`, `username` & `password`, but these are best left inside your `.abc-credentials` file.
|
|
140
|
+
|
|
102
141
|
### Generators
|
|
103
142
|
|
|
104
143
|
Aunty comes with a few basic generators. Run `aunty generate --help` for the full list, or `aunty generate <generator> --help` for further details.
|
|
@@ -115,46 +154,12 @@ import 'regenerator-runtime/runtime';
|
|
|
115
154
|
|
|
116
155
|
Note: You may also need a `Promise` polyfill for IE11.
|
|
117
156
|
|
|
118
|
-
### Multiple entry points
|
|
119
|
-
|
|
120
|
-
By default Aunty looks for `index.js` in `src/`. Enable multiple entry points by adding a `build::entry` config to `aunty.config.js`.
|
|
121
|
-
|
|
122
|
-
#### Replace 'index' with 'story'
|
|
123
|
-
|
|
124
|
-
```js
|
|
125
|
-
module.exports = {
|
|
126
|
-
build: {
|
|
127
|
-
entry: 'story' // will now also support `['story']`
|
|
128
|
-
}
|
|
129
|
-
};
|
|
130
|
-
```
|
|
131
|
-
|
|
132
|
-
#### Replace 'index' with 'story', 'editor', 'graphic' & 'polyfills'
|
|
133
|
-
|
|
134
|
-
```js
|
|
135
|
-
module.exports = {
|
|
136
|
-
build: {
|
|
137
|
-
entry: ['story', 'editor', 'graphic', 'polyfills']
|
|
138
|
-
}
|
|
139
|
-
};
|
|
140
|
-
```
|
|
141
|
-
|
|
142
|
-
#### Retain 'index'; add 'editor', 'graphic' & 'polyfills'
|
|
143
|
-
|
|
144
|
-
```js
|
|
145
|
-
module.exports = {
|
|
146
|
-
build: {
|
|
147
|
-
entry: ['index', 'editor', 'graphic', 'polyfills']
|
|
148
|
-
}
|
|
149
|
-
};
|
|
150
|
-
```
|
|
151
|
-
|
|
152
157
|
## Authors
|
|
153
158
|
|
|
154
159
|
- Colin Gourlay ([gourlay.colin@abc.net.au](mailto:gourlay.colin@abc.net.au))
|
|
155
|
-
- Nathan Hoad ([hoad.nathan@abc.net.au](mailto:hoad.nathan@abc.net.au))
|
|
156
160
|
- Simon Elvery ([elvery.simon@abc.net.au](mailto:elvery.simon@abc.net.au))
|
|
157
161
|
- Joshua Byrd ([byrd.joshua@abc.net.au](mailto:byrd.joshua@abc.net.au))
|
|
162
|
+
- Nathan Hoad
|
|
158
163
|
|
|
159
164
|
## Thanks
|
|
160
165
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@abcnews/aunty",
|
|
3
|
-
"version": "13.
|
|
3
|
+
"version": "13.2.0",
|
|
4
4
|
"description": "A toolkit for working with ABC News projects",
|
|
5
5
|
"repository": "abcnews/aunty",
|
|
6
6
|
"license": "MIT",
|
|
@@ -50,6 +50,8 @@
|
|
|
50
50
|
"csv-loader": "^3.0.3",
|
|
51
51
|
"deepmerge": "^4.0.0",
|
|
52
52
|
"del": "^6.0.0",
|
|
53
|
+
"dotenv": "^16.0.3",
|
|
54
|
+
"dotenv-webpack": "^8.0.1",
|
|
53
55
|
"execa": "^5.0.0",
|
|
54
56
|
"fork-ts-checker-webpack-plugin": "^6.2.1",
|
|
55
57
|
"ftp-deploy": "^2.3.8",
|
package/src/cli/clean/index.js
CHANGED
|
@@ -5,9 +5,7 @@ const del = importLazy('del');
|
|
|
5
5
|
// Ours
|
|
6
6
|
const { getProjectConfig } = require('../../config/project');
|
|
7
7
|
const { OUTPUT_DIRECTORY_NAME } = require('../../constants');
|
|
8
|
-
const { hvy } = require('../../utils/color');
|
|
9
8
|
const { dry, info, spin } = require('../../utils/logging');
|
|
10
|
-
const { inlineList } = require('../../utils/text');
|
|
11
9
|
const { command } = require('../');
|
|
12
10
|
const { MESSAGES } = require('./constants');
|
|
13
11
|
|
package/src/cli/constants.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// Ours
|
|
2
2
|
const { createLogo } = require('../utils/branding');
|
|
3
3
|
const { cmd, dim, hvy, opt, req, sec } = require('../utils/color');
|
|
4
|
-
const {
|
|
4
|
+
const { setOfValues } = require('../utils/structures');
|
|
5
5
|
|
|
6
6
|
const COMMAND_ALIASES = (module.exports.COMMAND_ALIASES = {
|
|
7
7
|
b: 'build',
|
|
@@ -66,7 +66,7 @@ ${sec('Development commands')}
|
|
|
66
66
|
${
|
|
67
67
|
isProject
|
|
68
68
|
? `${cmd('aunty generate')} ${req('<generator>')}
|
|
69
|
-
Generate code for your project or Core Media
|
|
69
|
+
Generate code for your project or Core Media
|
|
70
70
|
|
|
71
71
|
${cmd('aunty clean')}
|
|
72
72
|
Delete the current project's build output directories.
|
|
@@ -98,7 +98,7 @@ ${sec('Helper commands')}
|
|
|
98
98
|
|
|
99
99
|
${cmd('aunty help')} ${req('<command>')}
|
|
100
100
|
Display complete help for this ${req('command')}.
|
|
101
|
-
|
|
101
|
+
|
|
102
102
|
${cmd('aunty sign-cert')} # Mac OS only (for now)
|
|
103
103
|
Create a consistent SSL certificate for the dev server
|
|
104
104
|
`
|
|
@@ -1,8 +1,4 @@
|
|
|
1
|
-
// Native
|
|
2
|
-
const { join } = require('path');
|
|
3
|
-
|
|
4
1
|
// Ours
|
|
5
|
-
const { DEPLOY_FILE_NAME } = require('../../constants');
|
|
6
2
|
const { cmd, hvy, opt, req, sec } = require('../../utils/color');
|
|
7
3
|
const { styleLastSegment } = require('../../utils/text');
|
|
8
4
|
|
|
@@ -38,6 +34,7 @@ module.exports.MESSAGES = {
|
|
|
38
34
|
|
|
39
35
|
${sec('Options')}
|
|
40
36
|
|
|
41
|
-
${opt('-d')}, ${opt('--dry')}
|
|
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]')}
|
|
42
39
|
`
|
|
43
40
|
};
|
package/src/cli/deploy/index.js
CHANGED
|
@@ -14,13 +14,11 @@ const { command } = require('../');
|
|
|
14
14
|
const { addProfileProperties } = require('../../config/deploy');
|
|
15
15
|
const { getProjectConfig } = require('../../config/project');
|
|
16
16
|
const { DEPLOY_FILE_NAME, OUTPUT_DIRECTORY_NAME } = require('../../constants');
|
|
17
|
-
const {
|
|
17
|
+
const { throws } = require('../../utils/async');
|
|
18
18
|
const { dry, info, spin, warn, log, error } = require('../../utils/logging');
|
|
19
19
|
const { ftp, rsync } = require('../../utils/remote');
|
|
20
|
-
const {
|
|
21
|
-
const {
|
|
22
|
-
const { dim, opt } = require('../../utils/color');
|
|
23
|
-
const { check } = require('prettier');
|
|
20
|
+
const { MESSAGES, VALID_TYPES } = require('./constants');
|
|
21
|
+
const { dim, opt, hvy, req } = require('../../utils/color');
|
|
24
22
|
|
|
25
23
|
module.exports = command(
|
|
26
24
|
{
|
|
@@ -91,8 +89,9 @@ module.exports = command(
|
|
|
91
89
|
const { publicPath, type, to } = target;
|
|
92
90
|
let shouldOverwrite = false;
|
|
93
91
|
|
|
94
|
-
//
|
|
95
|
-
if (
|
|
92
|
+
// Check if the deployment already exists
|
|
93
|
+
if (argv.force) shouldOverwrite = true;
|
|
94
|
+
else if (type === 'ftp') {
|
|
96
95
|
const [checkErr] = await wrap(deploymentExists(to));
|
|
97
96
|
|
|
98
97
|
if (checkErr) {
|
|
@@ -103,7 +102,8 @@ module.exports = command(
|
|
|
103
102
|
error('An FTP error ocurred');
|
|
104
103
|
}
|
|
105
104
|
} else {
|
|
106
|
-
warn('Destination directory exists
|
|
105
|
+
warn('Destination directory exists. OK to overwrite?');
|
|
106
|
+
log(` ┗ ${hvy('dir')}: ${req(to)}`);
|
|
107
107
|
|
|
108
108
|
const overwriteSelection = (
|
|
109
109
|
await cliSelect({
|
|
@@ -122,7 +122,10 @@ module.exports = command(
|
|
|
122
122
|
}
|
|
123
123
|
}
|
|
124
124
|
|
|
125
|
-
|
|
125
|
+
// Overwrite by default if ssh for now
|
|
126
|
+
if (type === 'ssh') shouldOverwrite = true;
|
|
127
|
+
|
|
128
|
+
if (shouldOverwrite) {
|
|
126
129
|
info(MESSAGES.deploy(target));
|
|
127
130
|
|
|
128
131
|
const spinner = spin('Deploying');
|
|
@@ -22,7 +22,6 @@ module.exports = command(
|
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
const generatorName = GENERATOR_ALIASES[argv._[0]] || argv._[0];
|
|
25
|
-
const generatorArgs = argv['--'];
|
|
26
25
|
|
|
27
26
|
// If we didn't supply a known generator name, blow up, unless we wanted
|
|
28
27
|
// the generate command's usage message (in which case, print it, then exit).
|
package/src/cli/index.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
// Ours
|
|
2
2
|
const { cmd, hvy, opt, sec } = require('../../utils/color');
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
module.exports.BUNDLE_ANALYZER_CONFIG = {
|
|
5
5
|
analyzerHost: '127.0.0.1',
|
|
6
6
|
logLevel: 'error',
|
|
7
7
|
openAnalyzer: false
|
|
8
|
-
}
|
|
8
|
+
};
|
|
9
9
|
|
|
10
10
|
module.exports.MESSAGES = {
|
|
11
11
|
port: port => `Port ${port} already in use attempting to use port ${port + 1}`,
|
package/src/cli/serve/index.js
CHANGED
|
@@ -9,7 +9,6 @@ const { getServeConfig } = require('../../config/serve');
|
|
|
9
9
|
const { getWebpackConfig } = require('../../config/webpack');
|
|
10
10
|
const { getWebpackDevServerConfig } = require('../../config/webpackDevServer');
|
|
11
11
|
const { throws } = require('../../utils/async');
|
|
12
|
-
const { cmd } = require('../../utils/color');
|
|
13
12
|
const { dry, info, spin } = require('../../utils/logging');
|
|
14
13
|
const { combine } = require('../../utils/structures');
|
|
15
14
|
const { command } = require('../');
|
|
@@ -7,7 +7,6 @@ const makeDir = importLazy('make-dir');
|
|
|
7
7
|
|
|
8
8
|
// Ours
|
|
9
9
|
const { DEFAULT_HOST, SERVER_CERT_FILENAME, SERVER_KEY_FILENAME, getSSLPath } = require('../../config/serve');
|
|
10
|
-
const { hvy } = require('../../utils/color');
|
|
11
10
|
const { dry, info, spin } = require('../../utils/logging');
|
|
12
11
|
const { command } = require('../');
|
|
13
12
|
const { MESSAGES } = require('./constants');
|
package/src/config/jest/index.js
CHANGED
|
@@ -3,7 +3,7 @@ const { merge } = require('../../utils/structures');
|
|
|
3
3
|
const { getProjectConfig } = require('../project');
|
|
4
4
|
|
|
5
5
|
module.exports.getJestConfig = () => {
|
|
6
|
-
const { jest: projectJestConfig, root
|
|
6
|
+
const { jest: projectJestConfig, root } = getProjectConfig();
|
|
7
7
|
const defaultTransformerPath = require.resolve('./transformer-default');
|
|
8
8
|
|
|
9
9
|
return merge(
|
package/src/config/serve.js
CHANGED
|
@@ -12,13 +12,14 @@ const { combine } = require('../utils/structures');
|
|
|
12
12
|
const { getProjectConfig } = require('./project');
|
|
13
13
|
const { info } = require('../utils/logging');
|
|
14
14
|
const { MESSAGES } = require('../cli/serve/constants');
|
|
15
|
+
const {INTERNAL_TEST_HOST} = require('../constants')
|
|
15
16
|
|
|
16
17
|
const HOME_DIR = homedir();
|
|
17
18
|
const SSL_DIR = '.aunty/ssl';
|
|
18
19
|
const SERVER_CERT_FILENAME = (module.exports.SERVER_CERT_FILENAME = 'server.crt');
|
|
19
20
|
const SERVER_KEY_FILENAME = (module.exports.SERVER_KEY_FILENAME = 'server.key');
|
|
20
21
|
const INTERNAL_SUFFIX = '.aus.aunty.abc.net.au';
|
|
21
|
-
const DEFAULT_HOST = (module.exports.DEFAULT_HOST = probe(
|
|
22
|
+
const DEFAULT_HOST = (module.exports.DEFAULT_HOST = probe(INTERNAL_TEST_HOST)
|
|
22
23
|
? `${hostname().toLowerCase().split('.')[0]}${INTERNAL_SUFFIX}` // hostname _may_ include INTERNAL_SUFFIX
|
|
23
24
|
: 'localhost');
|
|
24
25
|
const DEFAULT_PORT = 8000;
|
package/src/config/webpack.js
CHANGED
|
@@ -6,6 +6,7 @@ const { join, resolve } = require('path');
|
|
|
6
6
|
const importLazy = require('import-lazy')(require);
|
|
7
7
|
const getContext = importLazy('@abcaustralia/postcss-config/getContext'); // optional dependency
|
|
8
8
|
const CopyPlugin = importLazy('copy-webpack-plugin');
|
|
9
|
+
const Dotenv = importLazy('dotenv-webpack');
|
|
9
10
|
const ForkTsCheckerWebpackPlugin = importLazy('fork-ts-checker-webpack-plugin');
|
|
10
11
|
const MiniCssExtractPlugin = importLazy('mini-css-extract-plugin');
|
|
11
12
|
const sveltePreprocess = importLazy('svelte-preprocess');
|
|
@@ -231,6 +232,7 @@ function createWebpackConfig({ isModernJS } = {}) {
|
|
|
231
232
|
},
|
|
232
233
|
plugins: [
|
|
233
234
|
new EnvironmentPlugin(Object.keys(process.env)),
|
|
235
|
+
new Dotenv(),
|
|
234
236
|
hasTS
|
|
235
237
|
? new ForkTsCheckerWebpackPlugin({
|
|
236
238
|
logger: { infrastructure: 'silent', issues: 'silent' },
|
|
@@ -248,11 +250,9 @@ function createWebpackConfig({ isModernJS } = {}) {
|
|
|
248
250
|
})
|
|
249
251
|
: null,
|
|
250
252
|
new CopyPlugin({
|
|
251
|
-
patterns: [
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
}
|
|
255
|
-
]
|
|
253
|
+
patterns: (Array.isArray(staticDir) ? staticDir : [staticDir]).map(dirName => ({
|
|
254
|
+
from: join(root, dirName)
|
|
255
|
+
}))
|
|
256
256
|
})
|
|
257
257
|
].filter(x => x),
|
|
258
258
|
optimization: {
|
|
@@ -36,9 +36,9 @@ module.exports.getWebpackDevServerConfig = async () => {
|
|
|
36
36
|
}
|
|
37
37
|
: 'https'
|
|
38
38
|
: 'http',
|
|
39
|
-
static: {
|
|
40
|
-
directory: join(root,
|
|
41
|
-
}
|
|
39
|
+
static: (Array.isArray(staticDir) ? staticDir : [staticDir]).map(dirName => ({
|
|
40
|
+
directory: join(root, dirName)
|
|
41
|
+
}))
|
|
42
42
|
},
|
|
43
43
|
projectWebpackDevServerConfig
|
|
44
44
|
);
|
package/src/constants.js
CHANGED
|
@@ -2,5 +2,6 @@ module.exports = {
|
|
|
2
2
|
OUTPUT_DIRECTORY_NAME: '.aunty',
|
|
3
3
|
BUILD_DIRECTORY_NAME: 'build',
|
|
4
4
|
DEPLOY_FILE_NAME: 'deploy.json',
|
|
5
|
-
PROJECT_CONFIG_FILE_NAME: 'aunty.config.js'
|
|
5
|
+
PROJECT_CONFIG_FILE_NAME: 'aunty.config.js',
|
|
6
|
+
INTERNAL_TEST_HOST: 'master-news-web.news-web-developer.presentation-layer.abc-prod.net.au'
|
|
6
7
|
};
|
|
@@ -11,13 +11,13 @@ const importLazy = require('import-lazy')(require);
|
|
|
11
11
|
|
|
12
12
|
// Ours
|
|
13
13
|
const { OUTPUT_DIRECTORY_NAME } = require('../../constants');
|
|
14
|
-
const { cmd, hvy, opt
|
|
14
|
+
const { cmd, hvy, opt } = require('../../utils/color');
|
|
15
15
|
const { success } = require('../../utils/logging');
|
|
16
16
|
const { installDependencies } = require('../../utils/npm');
|
|
17
17
|
const { combine } = require('../../utils/structures');
|
|
18
18
|
const { sluggify } = require('../../utils/text');
|
|
19
19
|
const { projectExists } = require('../../utils/ftp');
|
|
20
|
-
const { warn, info
|
|
20
|
+
const { log, warn, info } = importLazy('../../utils/logging');
|
|
21
21
|
|
|
22
22
|
module.exports = class extends Generator {
|
|
23
23
|
constructor(args, opts) {
|
|
@@ -30,8 +30,8 @@ module.exports = class extends Generator {
|
|
|
30
30
|
description: `Project name. Create this directory if ${opt('--here')} is not specified`,
|
|
31
31
|
required: false
|
|
32
32
|
});
|
|
33
|
-
this.option('here', { description: `Assume ${opt('<name>')} is current working directory
|
|
34
|
-
this.option('template', { description: 'Type of project [basic|preact|react|svelte]' });
|
|
33
|
+
this.option('here', { description: `Assume ${opt('<name>')} is current working directory`, type: Boolean });
|
|
34
|
+
this.option('template', { description: 'Type of project [basic|preact|react|svelte]', type: String });
|
|
35
35
|
}
|
|
36
36
|
|
|
37
37
|
usage() {
|
|
@@ -53,7 +53,8 @@ Shorthand examples (assuming xyz is your project name):
|
|
|
53
53
|
if (this.options.here) {
|
|
54
54
|
const currentDirectory = path.basename(process.cwd());
|
|
55
55
|
|
|
56
|
-
info(`Info: Using currect directory name as project name:`, currentDirectory
|
|
56
|
+
info(`Info: Using currect directory name as project name:`, currentDirectory);
|
|
57
|
+
log('Checking project name. This may take a few seconds...');
|
|
57
58
|
|
|
58
59
|
const [err, exists] = await wrap(projectExists(sluggify(currentDirectory)));
|
|
59
60
|
|
|
@@ -64,12 +65,11 @@ Shorthand examples (assuming xyz is your project name):
|
|
|
64
65
|
'Press ctrl+c to exit and rename project directory.'
|
|
65
66
|
);
|
|
66
67
|
|
|
67
|
-
if (err)
|
|
68
|
+
if (err)
|
|
68
69
|
warn(
|
|
69
70
|
'Warning: Unable to check if project name already exists, most likely ' +
|
|
70
71
|
'due to a connection or credentials error. Please check manually before deploying.\n'
|
|
71
72
|
);
|
|
72
|
-
}
|
|
73
73
|
|
|
74
74
|
this.options.projectName = currentDirectory;
|
|
75
75
|
} else {
|
|
@@ -79,6 +79,8 @@ Shorthand examples (assuming xyz is your project name):
|
|
|
79
79
|
message: 'What is your project called?',
|
|
80
80
|
default: this.options.projectName || 'New Project',
|
|
81
81
|
validate: async input => {
|
|
82
|
+
log('\nChecking project name. This may take a few seconds...');
|
|
83
|
+
|
|
82
84
|
const [err, exists] = await wrap(projectExists(sluggify(input)));
|
|
83
85
|
|
|
84
86
|
if (exists)
|
|
@@ -87,12 +89,11 @@ Shorthand examples (assuming xyz is your project name):
|
|
|
87
89
|
'danger of being overwritten. Please try a different name.'
|
|
88
90
|
);
|
|
89
91
|
|
|
90
|
-
if (err)
|
|
92
|
+
if (err)
|
|
91
93
|
warn(
|
|
92
94
|
'Warning: Unable to check if project name already exists, most likely ' +
|
|
93
95
|
'due to a connection or credentials error. Please check manually before deploying.\n'
|
|
94
96
|
);
|
|
95
|
-
}
|
|
96
97
|
|
|
97
98
|
return true;
|
|
98
99
|
}
|
package/src/utils/ftp.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
//
|
|
2
|
-
|
|
1
|
+
// External
|
|
3
2
|
const ftp = require('basic-ftp');
|
|
4
3
|
const { to: wrap } = require('await-to-js');
|
|
4
|
+
const { probe } = require('tcp-ping-sync');
|
|
5
5
|
|
|
6
6
|
const { addProfileProperties, addKnownProfileProperties } = require('../config/deploy');
|
|
7
|
+
const { INTERNAL_TEST_HOST } = require('../constants');
|
|
7
8
|
|
|
8
9
|
/**
|
|
9
10
|
* Check if a project exists on FTP
|
|
@@ -11,6 +12,10 @@ const { addProfileProperties, addKnownProfileProperties } = require('../config/d
|
|
|
11
12
|
* @returns {Promise<boolean>}
|
|
12
13
|
*/
|
|
13
14
|
const projectExists = async projectNameSlug => {
|
|
15
|
+
// If not on internal network FTP won't connect, so bail out
|
|
16
|
+
const isOnInternalNetwork = probe(INTERNAL_TEST_HOST);
|
|
17
|
+
if (!isOnInternalNetwork) throw new Error('Not on internal network');
|
|
18
|
+
|
|
14
19
|
const config = addProfileProperties(addKnownProfileProperties({}));
|
|
15
20
|
const { host, username: user, password, to } = config;
|
|
16
21
|
const [baseDir] = to.split('<name>');
|