@abcnews/aunty 12.2.0 → 13.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abcnews/aunty",
3
- "version": "12.2.0",
3
+ "version": "13.0.0",
4
4
  "description": "A toolkit for working with ABC News projects",
5
5
  "repository": "abcnews/aunty",
6
6
  "license": "MIT",
@@ -11,10 +11,12 @@
11
11
  "Joshua Byrd <byrd.joshua@abc.net.au>"
12
12
  ],
13
13
  "scripts": {
14
+ "postinstall": "node scripts/postinstall.js",
14
15
  "release": "release-it"
15
16
  },
16
17
  "files": [
17
18
  "assets",
19
+ "scripts",
18
20
  "src",
19
21
  "ts"
20
22
  ],
@@ -80,7 +82,7 @@
80
82
  "svelte-preprocess": "^4.1.1",
81
83
  "tcp-ping-sync": "^1.0.0",
82
84
  "typescript": "^4.0.2",
83
- "update-notifier": "^5.1.0",
85
+ "update-notifier": "^6.0.2",
84
86
  "url-loader": "^4.1.1",
85
87
  "webpack": "^5.33.2",
86
88
  "webpack-bundle-analyzer": "^4.5.0",
@@ -95,6 +97,6 @@
95
97
  "devDependencies": {
96
98
  "eslint": "^7.7.0",
97
99
  "eslint-config-prettier": "^8.2.0",
98
- "release-it": "^14.6.1"
100
+ "release-it": "^15.1.4"
99
101
  }
100
102
  }
@@ -0,0 +1,44 @@
1
+ /*
2
+ Aunty v13 changes how build artefacts are created. When building a project,
3
+ pre-v13, a .build folder and .deploy files were created inside your project
4
+ directory. In v13, this was changed to a single .aunty directory, which
5
+ contains a build filder and deploy.json file.
6
+
7
+ This script runs after aunty is installed inside a project directory, and
8
+ if the project was upgraded from a pre-v13 aunty, it will delete any old
9
+ build artefacts, and update the .gitignore file to make sure the .aunty
10
+ directory isn't committed, and remove the .build & .deploy references.
11
+ */
12
+
13
+ const { existsSync, readFileSync, rmSync, rmdirSync, writeFileSync } = require('fs');
14
+ const { join } = require('path');
15
+
16
+ const INSTALLATION_DIRECTORY = process.env.INIT_CWD || '.';
17
+
18
+ const PRE_AUNTY_13_GITIGNORE_PATTERN = /\/\.build\n\/\.deploy/;
19
+ const POST_AUNTY_13_GITIGNORE_REPLACEMENT = `/.aunty`;
20
+
21
+ const PRE_AUNTY_13_BUILD_DIR_PATH = join(INSTALLATION_DIRECTORY, '.build');
22
+ const PRE_AUNTY_13_DEPLOY_CONFIG_FILE_PATH = join(INSTALLATION_DIRECTORY, '.deploy');
23
+ const GITIGNORE_PATH = join(INSTALLATION_DIRECTORY, '.gitignore');
24
+
25
+ if (existsSync(PRE_AUNTY_13_BUILD_DIR_PATH)) {
26
+ rmdirSync(PRE_AUNTY_13_BUILD_DIR_PATH, { recursive: true });
27
+ }
28
+
29
+ if (existsSync(PRE_AUNTY_13_DEPLOY_CONFIG_FILE_PATH)) {
30
+ rmSync(PRE_AUNTY_13_DEPLOY_CONFIG_FILE_PATH);
31
+ }
32
+
33
+ if (existsSync(GITIGNORE_PATH)) {
34
+ const fileContents = readFileSync(GITIGNORE_PATH, 'utf8');
35
+
36
+ if (PRE_AUNTY_13_GITIGNORE_PATTERN.test(fileContents)) {
37
+ const updatedFileContents = fileContents.replace(
38
+ PRE_AUNTY_13_GITIGNORE_PATTERN,
39
+ POST_AUNTY_13_GITIGNORE_REPLACEMENT
40
+ );
41
+
42
+ writeFileSync(GITIGNORE_PATH, updatedFileContents);
43
+ }
44
+ }
@@ -11,7 +11,7 @@ const writeJsonFile = importLazy('write-json-file');
11
11
  const { getDeployConfig } = require('../../config/deploy');
12
12
  const { getProjectConfig } = require('../../config/project');
13
13
  const { getWebpackConfig } = require('../../config/webpack');
14
- const { DEPLOY_FILE_NAME } = require('../../constants');
14
+ const { DEPLOY_FILE_NAME, OUTPUT_DIRECTORY_NAME } = require('../../constants');
15
15
  const { packs, throws, unpack } = require('../../utils/async');
16
16
  const { dry, info, spin, warn } = require('../../utils/logging');
17
17
  const { combine } = require('../../utils/structures');
@@ -71,7 +71,7 @@ module.exports = command(
71
71
  const errors = stats.toJson({}, true).errors;
72
72
 
73
73
  spinner.fail();
74
-
74
+
75
75
  if (errors.length > 1) {
76
76
  throw MESSAGES.multipleErrors(errors.map(error => error.message));
77
77
  }
@@ -88,7 +88,7 @@ module.exports = command(
88
88
 
89
89
  if (deployConfig) {
90
90
  spinner = spin('Creating deploy configuration');
91
- writeJsonFile.sync(join(root, DEPLOY_FILE_NAME), deployConfig);
91
+ writeJsonFile.sync(join(root, OUTPUT_DIRECTORY_NAME, DEPLOY_FILE_NAME), deployConfig);
92
92
  spinner.succeed('Created deploy configuration');
93
93
  }
94
94
  }
@@ -3,9 +3,8 @@ const importLazy = require('import-lazy')(require);
3
3
  const del = importLazy('del');
4
4
 
5
5
  // Ours
6
- const { getBuildConfig } = require('../../config/build');
7
6
  const { getProjectConfig } = require('../../config/project');
8
- const { DEPLOY_FILE_NAME } = require('../../constants');
7
+ const { OUTPUT_DIRECTORY_NAME } = require('../../constants');
9
8
  const { hvy } = require('../../utils/color');
10
9
  const { dry, info, spin } = require('../../utils/logging');
11
10
  const { inlineList } = require('../../utils/text');
@@ -19,8 +18,7 @@ module.exports = command(
19
18
  },
20
19
  async argv => {
21
20
  const { root } = getProjectConfig();
22
- const { to } = getBuildConfig();
23
- const globs = [to, DEPLOY_FILE_NAME];
21
+ const globs = [OUTPUT_DIRECTORY_NAME];
24
22
 
25
23
  if (argv.dry) {
26
24
  return dry({
@@ -10,7 +10,7 @@ const loadJsonFile = importLazy('load-json-file');
10
10
  const { command } = require('../');
11
11
  const { addProfileProperties } = require('../../config/deploy');
12
12
  const { getProjectConfig } = require('../../config/project');
13
- const { DEPLOY_FILE_NAME } = require('../../constants');
13
+ const { DEPLOY_FILE_NAME, OUTPUT_DIRECTORY_NAME } = require('../../constants');
14
14
  const { packs, throws, unpack } = require('../../utils/async');
15
15
  const { dry, info, spin, warn } = require('../../utils/logging');
16
16
  const { ftp, rsync } = require('../../utils/remote');
@@ -29,7 +29,7 @@ module.exports = command(
29
29
  // 1) Load the deploy configuration (created by the build process)
30
30
 
31
31
  try {
32
- deployConfig = loadJsonFile.sync(join(root, DEPLOY_FILE_NAME));
32
+ deployConfig = loadJsonFile.sync(join(root, OUTPUT_DIRECTORY_NAME, DEPLOY_FILE_NAME));
33
33
  } catch (err) {
34
34
  throw new Error(MESSAGES.noDeployConfigFile);
35
35
  }
package/src/cli/index.js CHANGED
@@ -4,7 +4,6 @@ const { resolve } = require('path');
4
4
  // External
5
5
  const importLazy = require('import-lazy')(require);
6
6
  const minimist = importLazy('minimist');
7
- const updateNotifier = importLazy('update-notifier');
8
7
 
9
8
  // Ours
10
9
  const pkg = require('../../package');
@@ -27,6 +26,8 @@ const {
27
26
  module.exports.cli = packs(async args => {
28
27
  const __DEBUG__stopTimer = timer('CLI');
29
28
 
29
+ const updateNotifier = (await import('update-notifier')).default;
30
+
30
31
  updateNotifier({ pkg, updateCheckInterval: 36e5 }).notify();
31
32
 
32
33
  // If we just want aunty's version number, print it, then exit
@@ -1,5 +1,7 @@
1
1
  // External
2
+ const importLazy = require('import-lazy')(require);
2
3
  const mem = require('mem');
4
+ const semver = importLazy('semver');
3
5
 
4
6
  // Ours
5
7
  const { merge } = require('../utils/structures');
@@ -25,6 +27,16 @@ module.exports.getBabelConfig = mem(
25
27
  ({ isModernJS } = {}) => {
26
28
  const { babel: projectBabelConfig, pkg, hasTS, type } = getProjectConfig();
27
29
 
30
+ let corejs = '3';
31
+
32
+ // Minor version should be specified, if possible
33
+ // https://babeljs.io/docs/en/babel-preset-env#corejs
34
+ if (pkg.dependencies && pkg.dependencies['core-js']) {
35
+ const corejsSemVer = semver.coerce(pkg.dependencies['core-js']);
36
+
37
+ corejs = `${corejsSemVer.major}.${corejsSemVer.minor}`;
38
+ }
39
+
28
40
  return merge(
29
41
  {
30
42
  presets: [
@@ -37,7 +49,7 @@ module.exports.getBabelConfig = mem(
37
49
  : pkg.browserslist || ['> 1% in AU', 'Firefox ESR', 'IE 11']
38
50
  },
39
51
  useBuiltIns: 'entry',
40
- corejs: 3,
52
+ corejs,
41
53
  modules: process.env.NODE_ENV === 'test' ? 'commonjs' : false
42
54
  }
43
55
  ]
@@ -1,8 +1,11 @@
1
+ // Native
2
+ const { join } = require('path');
3
+
1
4
  // External
2
5
  const mem = require('mem');
3
6
 
4
7
  // Ours
5
- const { BUILD_DIRECTORY_NAME } = require('../constants');
8
+ const { BUILD_DIRECTORY_NAME, OUTPUT_DIRECTORY_NAME } = require('../constants');
6
9
  const { combine } = require('../utils/structures');
7
10
  const { getProjectConfig } = require('./project');
8
11
 
@@ -22,7 +25,7 @@ module.exports.getBuildConfig = mem(() => {
22
25
  {
23
26
  entry: DEFAULT_ENTRY_FILE_NAME,
24
27
  from: DEFAULT_SOURCE_DIRECTORY_NAME,
25
- to: BUILD_DIRECTORY_NAME,
28
+ to: join(OUTPUT_DIRECTORY_NAME, BUILD_DIRECTORY_NAME),
26
29
  staticDir: DEFAULT_STATIC_DIRECTORY_NAME,
27
30
  addModernJS: false,
28
31
  includedDependencies: [],
package/src/constants.js CHANGED
@@ -1,5 +1,6 @@
1
1
  module.exports = {
2
- BUILD_DIRECTORY_NAME: '.build',
3
- DEPLOY_FILE_NAME: '.deploy',
2
+ OUTPUT_DIRECTORY_NAME: '.aunty',
3
+ BUILD_DIRECTORY_NAME: 'build',
4
+ DEPLOY_FILE_NAME: 'deploy.json',
4
5
  PROJECT_CONFIG_FILE_NAME: 'aunty.config.js'
5
6
  };
@@ -8,7 +8,7 @@ const requireg = require('requireg');
8
8
  const Generator = require('yeoman-generator');
9
9
 
10
10
  // Ours
11
- const { BUILD_DIRECTORY_NAME, DEPLOY_FILE_NAME } = require('../../constants');
11
+ const { OUTPUT_DIRECTORY_NAME } = require('../../constants');
12
12
  const { cmd, hvy, opt, sec } = require('../../utils/color');
13
13
  const { success } = require('../../utils/logging');
14
14
  const { installDependencies } = require('../../utils/npm');
@@ -114,8 +114,7 @@ Shorthand examples (assuming xyz is your project name):
114
114
 
115
115
  writing() {
116
116
  const context = {
117
- BUILD_DIRECTORY_NAME,
118
- DEPLOY_FILE_NAME,
117
+ OUTPUT_DIRECTORY_NAME,
119
118
  projectName: this.options.projectName,
120
119
  projectNameSlug: this.options.projectNameSlug,
121
120
  projectNameFlat: this.options.projectNameFlat,
@@ -2,8 +2,7 @@
2
2
  /node_modules
3
3
 
4
4
  # output
5
- /<%= BUILD_DIRECTORY_NAME %>
6
- /<%= DEPLOY_FILE_NAME %>
5
+ /<%= OUTPUT_DIRECTORY_NAME %>
7
6
 
8
7
  # misc
9
8
  .DS_Store