@abcnews/aunty 12.0.1 → 12.1.1

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 CHANGED
@@ -115,6 +115,40 @@ import 'regenerator-runtime/runtime';
115
115
 
116
116
  Note: You may also need a `Promise` polyfill for IE11.
117
117
 
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
+
118
152
  ## Authors
119
153
 
120
154
  - Colin Gourlay ([gourlay.colin@abc.net.au](mailto:gourlay.colin@abc.net.au))
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abcnews/aunty",
3
- "version": "12.0.1",
3
+ "version": "12.1.1",
4
4
  "description": "A toolkit for working with ABC News projects",
5
5
  "repository": "abcnews/aunty",
6
6
  "license": "MIT",
@@ -39,7 +39,7 @@
39
39
  "babel-core": "^7.0.0-bridge.0",
40
40
  "babel-jest": "^26.1.0",
41
41
  "babel-loader": "^8.2.2",
42
- "chalk": "^4.1.0",
42
+ "chalk": "^4.1.2",
43
43
  "cli-select": "^1.1.0",
44
44
  "copy-webpack-plugin": "^8.1.1",
45
45
  "css-loader": "^5.2.1",
@@ -49,7 +49,7 @@
49
49
  "execa": "^5.0.0",
50
50
  "file-loader": "^6.2.0",
51
51
  "fork-ts-checker-webpack-plugin": "^6.2.1",
52
- "ftp-deploy": "^2.3.3",
52
+ "ftp-deploy": "^2.3.8",
53
53
  "get-all-paths": "^1.0.1",
54
54
  "guess-root-path": "^1.0.0",
55
55
  "html-loader": "^2.1.2",
@@ -66,8 +66,8 @@
66
66
  "node-fetch": "^2.6.0",
67
67
  "ora": "^5.0.0",
68
68
  "pify": "^5.0.0",
69
- "postcss": "^8.2.4",
70
- "postcss-loader": "^4.1.0",
69
+ "postcss": "^8.3.6",
70
+ "postcss-loader": "^6.1.1",
71
71
  "prettier": "^2.0.5",
72
72
  "requireg": "^0.2.2",
73
73
  "rsyncwrapper": "^3.0.1",
@@ -83,14 +83,14 @@
83
83
  "update-notifier": "^5.1.0",
84
84
  "url-loader": "^4.1.1",
85
85
  "webpack": "^5.33.2",
86
- "webpack-bundle-analyzer": "^4.4.1",
87
- "webpack-dev-server": "^3.11.2",
86
+ "webpack-bundle-analyzer": "^4.5.0",
87
+ "webpack-dev-server": "^4.6.0",
88
88
  "write-json-file": "^4.2.0",
89
89
  "yeoman-environment": "^3.2.0",
90
90
  "yeoman-generator": "^5.2.0"
91
91
  },
92
92
  "optionalDependencies": {
93
- "@abcaustralia/postcss-config": "^4.1.0"
93
+ "@abcaustralia/postcss-config": "^11.2.5"
94
94
  },
95
95
  "devDependencies": {
96
96
  "eslint": "^7.7.0",
@@ -3,15 +3,20 @@ const { cmd, hvy, opt, sec } = require('../../utils/color');
3
3
 
4
4
  const BUNDLE_ANALYZER_CONFIG = (module.exports.BUNDLE_ANALYZER_CONFIG = {
5
5
  analyzerHost: '127.0.0.1',
6
- logLevel: 'warn',
6
+ logLevel: 'error',
7
7
  openAnalyzer: false
8
8
  });
9
9
 
10
10
  module.exports.MESSAGES = {
11
11
  analysis: ({ analyzerHost, analyzerPort }) => `http://${analyzerHost}:${analyzerPort}`,
12
- serve: ({ hot, bundleAnalysisPath }) => `Serve (${hvy(process.env.NODE_ENV)}):
12
+ serve: ({ bundleAnalysisPath, hot, publicPath }) => `Serve (${hvy(process.env.NODE_ENV)}):${
13
+ bundleAnalysisPath
14
+ ? `
15
+ ┣ ${hvy('bundle analysis')}: ${bundleAnalysisPath}`
16
+ : ''
17
+ }
13
18
  ┣ ${hvy('hot')}: ${cmd(hot ? 'yes' : 'no')}
14
- ┗ ${hvy('bundle analysis')}: ${bundleAnalysisPath}`,
19
+ ┗ ${hvy('publicPath')}: ${publicPath}`,
15
20
  // TODO: Add aunty config section to usage
16
21
  usage: name => `Usage: ${cmd(`aunty ${name}`)} ${opt('[options]')}
17
22
 
@@ -23,69 +23,74 @@ module.exports = command(
23
23
  usage: MESSAGES.usage
24
24
  },
25
25
  async argv => {
26
- const { port } = getServeConfig();
26
+ const { hasBundleAnalysis, port } = getServeConfig();
27
27
  const webpackConfig = getWebpackConfig();
28
28
  const webpackDevServerConfig = getWebpackDevServerConfig();
29
- const { hot, publicPath } = webpackDevServerConfig;
30
- const bundleAnalyzerConfig = combine(BUNDLE_ANALYZER_CONFIG, {
31
- analyzerPort: +port + Math.floor(port / 1000) * 100 // e.g. 8000 -> 8800
32
- });
29
+ const { hot, devMiddleware } = webpackDevServerConfig;
30
+ const { publicPath } = devMiddleware;
31
+ const bundleAnalyzerConfig = hasBundleAnalysis
32
+ ? combine(BUNDLE_ANALYZER_CONFIG, {
33
+ analyzerPort: +port + Math.floor(port / 1000) * 100 // e.g. 8000 -> 8800
34
+ })
35
+ : null;
33
36
 
34
37
  webpackConfig.forEach((config, index) => {
35
38
  config.output.publicPath = publicPath;
36
39
 
37
- if (hot) {
38
- config.entry = upgradeEntryToHot(config.entry, config.output.publicPath);
39
- config.plugins.push(new webpack.HotModuleReplacementPlugin());
40
+ config.infrastructureLogging = {
41
+ level: 'warn'
42
+ };
43
+
44
+ if (bundleAnalyzerConfig) {
45
+ config.plugins.push(
46
+ new BundleAnalyzerPlugin(
47
+ combine(bundleAnalyzerConfig, {
48
+ analyzerPort: bundleAnalyzerConfig.analyzerPort + index * 10 // e.g. 8800, 8810...
49
+ })
50
+ )
51
+ );
40
52
  }
41
-
42
- config.plugins.push(
43
- new BundleAnalyzerPlugin(
44
- combine(bundleAnalyzerConfig, {
45
- analyzerPort: bundleAnalyzerConfig.analyzerPort + index * 10 // e.g. 8800, 8810...
46
- })
47
- )
48
- );
49
53
  });
50
54
 
51
55
  if (argv.dry) {
52
56
  return dry({
53
57
  'Webpack config': webpackConfig,
54
58
  'WebpackDevServer config': webpackDevServerConfig,
55
- 'BundleAnalyzerPlugin config': bundleAnalyzerConfig
59
+ ...(bundleAnalyzerConfig
60
+ ? {
61
+ 'BundleAnalyzerPlugin config': bundleAnalyzerConfig
62
+ }
63
+ : {})
56
64
  });
57
65
  }
58
66
 
59
67
  throws(await cleanCommand(['--quiet']));
60
68
 
61
- info(MESSAGES.serve({ hot, bundleAnalysisPath: MESSAGES.analysis(bundleAnalyzerConfig) }));
69
+ info(
70
+ MESSAGES.serve({
71
+ bundleAnalysisPath: bundleAnalyzerConfig ? MESSAGES.analysis(bundleAnalyzerConfig) : null,
72
+ hot,
73
+ publicPath
74
+ })
75
+ );
62
76
 
63
77
  const compiler = webpack(webpackConfig);
64
- const server = new WebpackDevServer(compiler, webpackDevServerConfig);
65
-
66
- // Grab reference to native info logger
67
- const _info = console.info;
68
- let spinner;
78
+ const server = new WebpackDevServer(webpackDevServerConfig, compiler);
79
+ const [gracefullyInterrupt, restore] = gracefullyHandleLogging();
69
80
 
70
81
  return new Promise((resolve, reject) => {
71
- server.listen(port, '0.0.0.0', err => {
82
+ server.startCallback(err => {
72
83
  if (err) {
73
84
  return reject(err);
74
85
  }
75
86
 
76
- // Start spinner
77
87
  spinner = spin('Server running');
78
-
79
- // Gracefully interrupt spinner to log info
80
- console.info = msg => {
81
- spinner.clear();
82
- _info(msg);
83
- spinner.start();
84
- };
88
+ gracefullyInterrupt(spinner);
85
89
  });
86
90
 
87
- process.on('SIGINT', function() {
88
- server.close(function() {
91
+ process.on('SIGINT', () => {
92
+ spinner.clear();
93
+ server.stopCallback(() => {
89
94
  if (spinner) {
90
95
  spinner.succeed('Server closed');
91
96
  }
@@ -93,28 +98,32 @@ module.exports = command(
93
98
  resolve();
94
99
  });
95
100
  });
96
- }).finally(() => {
97
- // Always restore native info logger
98
- console.info = _info;
99
- });
101
+ }).finally(() => restore());
100
102
  }
101
103
  );
102
104
 
103
- function upgradeEntryToHot(entry, publicPath) {
104
- const heat = [
105
- `${require.resolve('webpack-dev-server/client')}?${publicPath}`,
106
- require.resolve('webpack/hot/dev-server')
107
- ];
105
+ const gracefullyHandleLogging = () => {
106
+ const METHODS = ['debug', 'error', 'info', 'log', 'warn'];
107
+ const reference = {};
108
108
 
109
- if (Array.isArray(entry) || typeof entry === 'string') {
110
- return heat.concat(Array.isArray(entry) ? entry : [entry]);
109
+ for (let method of METHODS) {
110
+ reference[method] = console[method];
111
111
  }
112
112
 
113
- return Object.keys(entry).reduce((memo, key) => {
114
- const value = entry[key];
115
-
116
- memo[key] = heat.concat(Array.isArray(value) ? value : [value]);
117
-
118
- return memo;
119
- }, {});
120
- }
113
+ return [
114
+ spinner => {
115
+ for (let method of METHODS) {
116
+ console[method] = (...args) => {
117
+ spinner.clear();
118
+ reference[method](...args);
119
+ spinner.start();
120
+ };
121
+ }
122
+ },
123
+ () => {
124
+ for (let method of METHODS) {
125
+ console[method] = reference[method];
126
+ }
127
+ }
128
+ ];
129
+ };
@@ -16,11 +16,7 @@ const SERVER_CERT_FILENAME = (module.exports.SERVER_CERT_FILENAME = 'server.crt'
16
16
  const SERVER_KEY_FILENAME = (module.exports.SERVER_KEY_FILENAME = 'server.key');
17
17
  const INTERNAL_SUFFIX = '.aus.aunty.abc.net.au';
18
18
  const DEFAULT_HOST = (module.exports.DEFAULT_HOST = probe(`nucwed${INTERNAL_SUFFIX}`)
19
- ? `${
20
- hostname()
21
- .toLowerCase()
22
- .split('.')[0]
23
- }${INTERNAL_SUFFIX}` // hostname _may_ include INTERNAL_SUFFIX
19
+ ? `${hostname().toLowerCase().split('.')[0]}${INTERNAL_SUFFIX}` // hostname _may_ include INTERNAL_SUFFIX
24
20
  : 'localhost');
25
21
  const DEFAULT_PORT = 8000;
26
22
 
@@ -29,6 +25,7 @@ module.exports.getServeConfig = () => {
29
25
 
30
26
  return combine(
31
27
  {
28
+ hasBundleAnalysis: false,
32
29
  host: DEFAULT_HOST,
33
30
  hot: process.env.NODE_ENV === 'development',
34
31
  https: true,
@@ -159,12 +159,7 @@ function createWebpackConfig({ isModernJS } = {}) {
159
159
  output: {
160
160
  path: join(root, to),
161
161
  publicPath: '/',
162
- filename: isModernJS ? '[name]_modern.js' : '[name].js',
163
- // The update file hash was causing 404s and full page reloads.
164
- // This will make the file name more predictable.
165
- // See https://github.com/webpack/webpack-dev-server/issues/79#issuecomment-244596129
166
- hotUpdateChunkFilename: 'hot/hot-update.js',
167
- hotUpdateMainFilename: 'hot/hot-update.json'
162
+ filename: isModernJS ? '[name]_modern.js' : '[name].js'
168
163
  },
169
164
  resolve: {
170
165
  extensions: ['.mjs', '.js', '.json', '.ts']
@@ -184,10 +179,7 @@ function createWebpackConfig({ isModernJS } = {}) {
184
179
  use: [
185
180
  extractCSS
186
181
  ? {
187
- loader: MiniCssExtractPlugin.loader,
188
- options: {
189
- hmr: !isProd
190
- }
182
+ loader: MiniCssExtractPlugin.loader
191
183
  }
192
184
  : {
193
185
  loader: require.resolve('style-loader')
@@ -14,20 +14,30 @@ module.exports.getWebpackDevServerConfig = () => {
14
14
 
15
15
  return combine(
16
16
  {
17
- contentBase: join(root, staticDir),
18
- disableHostCheck: true,
17
+ allowedHosts: 'all',
18
+ client: {
19
+ logging: 'warn',
20
+ overlay: true
21
+ },
22
+ devMiddleware: {
23
+ publicPath: `http${https ? 's' : ''}://${host}:${port}/`
24
+ },
19
25
  headers: {
20
26
  'Access-Control-Allow-Origin': '*'
21
27
  },
22
- host,
28
+ host: '0.0.0.0',
23
29
  hot,
24
- https,
25
- noInfo: true,
26
- overlay: true,
27
- publicPath: `http${https ? 's' : ''}://${host}:${port}/`,
28
- quiet: true,
29
- watchOptions: {
30
- ignored: /node_modules/
30
+ port,
31
+ server: https
32
+ ? typeof https === 'object'
33
+ ? {
34
+ type: 'https',
35
+ options: https
36
+ }
37
+ : 'https'
38
+ : 'http',
39
+ static: {
40
+ directory: join(root, staticDir)
31
41
  }
32
42
  },
33
43
  projectWebpackDevServerConfig
@@ -74,7 +74,7 @@ Shorthand examples (assuming xyz is your project name):
74
74
  type: 'confirm',
75
75
  name: 'typescript',
76
76
  message: 'Will you be authoring your project in TypeScript?',
77
- default: false
77
+ default: true
78
78
  });
79
79
 
80
80
  prompts.push({
package/src/.DS_Store DELETED
Binary file
Binary file