@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.
- package/README.md +10 -0
- package/dist/bin/aunty.js +3 -0
- package/dist/lib/constants.js +8 -0
- package/package.json +25 -82
- package/assets/done.mp3 +0 -0
- package/scripts/postinstall.js +0 -44
- package/src/api/index.js +0 -5
- package/src/bin/aunty.js +0 -27
- package/src/cli/build/constants.js +0 -46
- package/src/cli/build/index.js +0 -100
- package/src/cli/clean/constants.js +0 -10
- package/src/cli/clean/index.js +0 -40
- package/src/cli/constants.js +0 -114
- package/src/cli/deploy/constants.js +0 -40
- package/src/cli/deploy/index.js +0 -151
- package/src/cli/generate/constants.js +0 -39
- package/src/cli/generate/index.js +0 -72
- package/src/cli/index.js +0 -154
- package/src/cli/release/constants.js +0 -67
- package/src/cli/release/index.js +0 -162
- package/src/cli/serve/constants.js +0 -33
- package/src/cli/serve/index.js +0 -128
- package/src/cli/sign-cert/constants.js +0 -42
- package/src/cli/sign-cert/index.js +0 -50
- package/src/cli/test/constants.js +0 -15
- package/src/cli/test/index.js +0 -30
- package/src/config/babel.js +0 -75
- package/src/config/build.js +0 -39
- package/src/config/deploy.js +0 -143
- package/src/config/jest/index.js +0 -20
- package/src/config/jest/transformer-default.js +0 -27
- package/src/config/jest/transformer-svelte-preprocess.js +0 -8
- package/src/config/jest/transformer-svelte.js +0 -32
- package/src/config/project.js +0 -57
- package/src/config/serve.js +0 -144
- package/src/config/webpack.js +0 -325
- package/src/config/webpackDevServer.js +0 -46
- package/src/constants.js +0 -7
- package/src/generators/component/index.js +0 -172
- package/src/generators/component/templates/_non_sfc/styles.scss +0 -6
- package/src/generators/component/templates/basic/component-with-d3.test.ts +0 -7
- package/src/generators/component/templates/basic/component-with-d3.ts +0 -30
- package/src/generators/component/templates/basic/component.test.ts +0 -7
- package/src/generators/component/templates/basic/component.ts +0 -11
- package/src/generators/component/templates/preact/component-with-d3.test.tsx +0 -16
- package/src/generators/component/templates/preact/component-with-d3.tsx +0 -45
- package/src/generators/component/templates/preact/component.test.tsx +0 -18
- package/src/generators/component/templates/preact/component.tsx +0 -14
- package/src/generators/component/templates/react/component-with-d3.test.tsx +0 -13
- package/src/generators/component/templates/react/component-with-d3.tsx +0 -44
- package/src/generators/component/templates/react/component.test.tsx +0 -13
- package/src/generators/component/templates/react/component.tsx +0 -14
- package/src/generators/component/templates/svelte/component-with-d3.svelte +0 -46
- package/src/generators/component/templates/svelte/component-with-d3.test.ts +0 -10
- package/src/generators/component/templates/svelte/component.svelte +0 -17
- package/src/generators/component/templates/svelte/component.test.ts +0 -10
- package/src/generators/project/index.js +0 -244
- package/src/generators/project/templates/_common/.editorconfig +0 -12
- package/src/generators/project/templates/_common/.prettierrc +0 -6
- package/src/generators/project/templates/_common/LICENSE +0 -21
- package/src/generators/project/templates/_common/README.md +0 -3
- package/src/generators/project/templates/_common/_.gitignore +0 -12
- package/src/generators/project/templates/_common/package.json +0 -18
- package/src/generators/project/templates/_common/public/index.html +0 -21
- package/src/generators/project/templates/_common/src/components/Worm/worm.svg +0 -4
- package/src/generators/project/templates/_common/tsconfig.json +0 -4
- package/src/generators/project/templates/_non_sfc/src/components/App/styles.scss +0 -23
- package/src/generators/project/templates/_non_sfc/src/components/ErrorBox/styles.scss +0 -16
- package/src/generators/project/templates/_non_sfc/src/components/Worm/styles.scss +0 -4
- package/src/generators/project/templates/basic/src/components/App/index.test.ts +0 -9
- package/src/generators/project/templates/basic/src/components/App/index.ts +0 -22
- package/src/generators/project/templates/basic/src/components/ErrorBox/index.ts +0 -24
- package/src/generators/project/templates/basic/src/components/Worm/index.test.ts +0 -7
- package/src/generators/project/templates/basic/src/components/Worm/index.ts +0 -12
- package/src/generators/project/templates/basic/src/index.ts +0 -50
- package/src/generators/project/templates/preact/src/components/App/index.test.tsx +0 -21
- package/src/generators/project/templates/preact/src/components/App/index.tsx +0 -21
- package/src/generators/project/templates/preact/src/components/ErrorBox/index.tsx +0 -15
- package/src/generators/project/templates/preact/src/components/Worm/index.test.tsx +0 -14
- package/src/generators/project/templates/preact/src/components/Worm/index.tsx +0 -9
- package/src/generators/project/templates/preact/src/index.tsx +0 -42
- package/src/generators/project/templates/react/src/components/App/index.test.tsx +0 -14
- package/src/generators/project/templates/react/src/components/App/index.tsx +0 -21
- package/src/generators/project/templates/react/src/components/ErrorBox/index.tsx +0 -14
- package/src/generators/project/templates/react/src/components/Worm/index.test.tsx +0 -13
- package/src/generators/project/templates/react/src/components/Worm/index.tsx +0 -9
- package/src/generators/project/templates/react/src/index.tsx +0 -40
- package/src/generators/project/templates/svelte/src/components/App/App.svelte +0 -37
- package/src/generators/project/templates/svelte/src/components/App/App.test.ts +0 -18
- package/src/generators/project/templates/svelte/src/components/Worm/Worm.svelte +0 -12
- package/src/generators/project/templates/svelte/src/components/Worm/Worm.test.ts +0 -16
- package/src/generators/project/templates/svelte/src/index.ts +0 -26
- package/src/utils/async.js +0 -13
- package/src/utils/audio.js +0 -30
- package/src/utils/branding.js +0 -57
- package/src/utils/color.js +0 -12
- package/src/utils/ftp.js +0 -80
- package/src/utils/git.js +0 -127
- package/src/utils/logging.js +0 -74
- package/src/utils/npm.js +0 -59
- package/src/utils/remote.js +0 -81
- package/src/utils/structures.js +0 -33
- package/src/utils/text.js +0 -64
- package/ts/config.json +0 -22
- package/ts/custom.d.ts +0 -120
package/src/cli/serve/index.js
DELETED
|
@@ -1,128 +0,0 @@
|
|
|
1
|
-
// External
|
|
2
|
-
const importLazy = require('import-lazy')(require);
|
|
3
|
-
const webpack = importLazy('webpack');
|
|
4
|
-
const WebpackDevServer = importLazy('webpack-dev-server');
|
|
5
|
-
const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer');
|
|
6
|
-
|
|
7
|
-
// Ours
|
|
8
|
-
const { getServeConfig } = require('../../config/serve');
|
|
9
|
-
const { getWebpackConfig } = require('../../config/webpack');
|
|
10
|
-
const { getWebpackDevServerConfig } = require('../../config/webpackDevServer');
|
|
11
|
-
const { throws } = require('../../utils/async');
|
|
12
|
-
const { dry, info, spin } = require('../../utils/logging');
|
|
13
|
-
const { combine } = require('../../utils/structures');
|
|
14
|
-
const { command } = require('../');
|
|
15
|
-
const cleanCommand = require('../clean');
|
|
16
|
-
const { BUNDLE_ANALYZER_CONFIG, MESSAGES } = require('./constants');
|
|
17
|
-
|
|
18
|
-
module.exports = command(
|
|
19
|
-
{
|
|
20
|
-
name: 'serve',
|
|
21
|
-
nodeEnv: 'development',
|
|
22
|
-
usage: MESSAGES.usage
|
|
23
|
-
},
|
|
24
|
-
async argv => {
|
|
25
|
-
const { hasBundleAnalysis, port } = await getServeConfig();
|
|
26
|
-
const webpackConfig = getWebpackConfig();
|
|
27
|
-
const webpackDevServerConfig = await getWebpackDevServerConfig();
|
|
28
|
-
const { hot, devMiddleware } = webpackDevServerConfig;
|
|
29
|
-
const { publicPath } = devMiddleware;
|
|
30
|
-
const bundleAnalyzerConfig = hasBundleAnalysis
|
|
31
|
-
? combine(BUNDLE_ANALYZER_CONFIG, {
|
|
32
|
-
analyzerPort: +port + Math.floor(port / 1000) * 100 // e.g. 8000 -> 8800
|
|
33
|
-
})
|
|
34
|
-
: null;
|
|
35
|
-
|
|
36
|
-
webpackConfig.forEach((config, index) => {
|
|
37
|
-
config.output.publicPath = publicPath;
|
|
38
|
-
|
|
39
|
-
config.infrastructureLogging = {
|
|
40
|
-
level: 'warn'
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
if (bundleAnalyzerConfig) {
|
|
44
|
-
config.plugins.push(
|
|
45
|
-
new BundleAnalyzerPlugin(
|
|
46
|
-
combine(bundleAnalyzerConfig, {
|
|
47
|
-
analyzerPort: bundleAnalyzerConfig.analyzerPort + index * 10 // e.g. 8800, 8810...
|
|
48
|
-
})
|
|
49
|
-
)
|
|
50
|
-
);
|
|
51
|
-
}
|
|
52
|
-
});
|
|
53
|
-
|
|
54
|
-
if (argv.dry) {
|
|
55
|
-
return dry({
|
|
56
|
-
'Webpack config': webpackConfig,
|
|
57
|
-
'WebpackDevServer config': webpackDevServerConfig,
|
|
58
|
-
...(bundleAnalyzerConfig
|
|
59
|
-
? {
|
|
60
|
-
'BundleAnalyzerPlugin config': bundleAnalyzerConfig
|
|
61
|
-
}
|
|
62
|
-
: {})
|
|
63
|
-
});
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
throws(await cleanCommand(['--quiet']));
|
|
67
|
-
|
|
68
|
-
info(
|
|
69
|
-
MESSAGES.serve({
|
|
70
|
-
bundleAnalysisPath: bundleAnalyzerConfig ? MESSAGES.analysis(bundleAnalyzerConfig) : null,
|
|
71
|
-
hot,
|
|
72
|
-
publicPath
|
|
73
|
-
})
|
|
74
|
-
);
|
|
75
|
-
|
|
76
|
-
const compiler = webpack(webpackConfig);
|
|
77
|
-
const server = new WebpackDevServer(webpackDevServerConfig, compiler);
|
|
78
|
-
const [gracefullyInterrupt, restore] = gracefullyHandleLogging();
|
|
79
|
-
|
|
80
|
-
return new Promise((resolve, reject) => {
|
|
81
|
-
server.startCallback(err => {
|
|
82
|
-
if (err) {
|
|
83
|
-
return reject(err);
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
spinner = spin('Server running');
|
|
87
|
-
gracefullyInterrupt(spinner);
|
|
88
|
-
});
|
|
89
|
-
|
|
90
|
-
process.on('SIGINT', () => {
|
|
91
|
-
spinner.clear();
|
|
92
|
-
server.stopCallback(() => {
|
|
93
|
-
if (spinner) {
|
|
94
|
-
spinner.succeed('Server closed');
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
resolve();
|
|
98
|
-
});
|
|
99
|
-
});
|
|
100
|
-
}).finally(() => restore());
|
|
101
|
-
}
|
|
102
|
-
);
|
|
103
|
-
|
|
104
|
-
const gracefullyHandleLogging = () => {
|
|
105
|
-
const METHODS = ['debug', 'error', 'info', 'log', 'warn'];
|
|
106
|
-
const reference = {};
|
|
107
|
-
|
|
108
|
-
for (let method of METHODS) {
|
|
109
|
-
reference[method] = console[method];
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
return [
|
|
113
|
-
spinner => {
|
|
114
|
-
for (let method of METHODS) {
|
|
115
|
-
console[method] = (...args) => {
|
|
116
|
-
spinner.clear();
|
|
117
|
-
reference[method](...args);
|
|
118
|
-
spinner.start();
|
|
119
|
-
};
|
|
120
|
-
}
|
|
121
|
-
},
|
|
122
|
-
() => {
|
|
123
|
-
for (let method of METHODS) {
|
|
124
|
-
console[method] = reference[method];
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
];
|
|
128
|
-
};
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
// Ours
|
|
2
|
-
const { cmd, opt, sec } = require('../../utils/color');
|
|
3
|
-
|
|
4
|
-
module.exports.MESSAGES = {
|
|
5
|
-
opensslArgs: (host, keyout, out) => [
|
|
6
|
-
'req',
|
|
7
|
-
'-newkey',
|
|
8
|
-
'rsa:2048',
|
|
9
|
-
'-x509',
|
|
10
|
-
'-nodes',
|
|
11
|
-
'-keyout',
|
|
12
|
-
keyout,
|
|
13
|
-
'-new',
|
|
14
|
-
'-out',
|
|
15
|
-
out,
|
|
16
|
-
'-subj',
|
|
17
|
-
`/CN=${host}`,
|
|
18
|
-
'-reqexts',
|
|
19
|
-
'SAN',
|
|
20
|
-
'-extensions',
|
|
21
|
-
'SAN',
|
|
22
|
-
'-config',
|
|
23
|
-
`<(cat /System/Library/OpenSSL/openssl.cnf <(printf '[SAN]\nsubjectAltName=DNS:${host}'))`,
|
|
24
|
-
'-sha256',
|
|
25
|
-
'-days',
|
|
26
|
-
'3650'
|
|
27
|
-
],
|
|
28
|
-
manual: path => `You should install this certificate in your Mac OS Keychain:
|
|
29
|
-
${path}
|
|
30
|
-
`,
|
|
31
|
-
platform: `Sorry, this command is only supported on MacOS (for now)`,
|
|
32
|
-
usage: name => `Usage: ${cmd(`aunty ${name}`)} ${opt('[options]')}
|
|
33
|
-
|
|
34
|
-
${sec('Options')}
|
|
35
|
-
|
|
36
|
-
${opt('-d')}, ${opt('--dry')} Output the assumed host, file paths & openssl command that would have run, then exit
|
|
37
|
-
|
|
38
|
-
${sec('Environment variables')}
|
|
39
|
-
|
|
40
|
-
• You can override the host the certificate would be generated for by setting ${cmd('AUNTY_HOST')}
|
|
41
|
-
`
|
|
42
|
-
};
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
// Native
|
|
2
|
-
const { spawnSync } = require('child_process');
|
|
3
|
-
|
|
4
|
-
// External
|
|
5
|
-
const importLazy = require('import-lazy')(require);
|
|
6
|
-
const makeDir = importLazy('make-dir');
|
|
7
|
-
|
|
8
|
-
// Ours
|
|
9
|
-
const { DEFAULT_HOST, SERVER_CERT_FILENAME, SERVER_KEY_FILENAME, getSSLPath } = require('../../config/serve');
|
|
10
|
-
const { dry, info, spin } = require('../../utils/logging');
|
|
11
|
-
const { command } = require('../');
|
|
12
|
-
const { MESSAGES } = require('./constants');
|
|
13
|
-
|
|
14
|
-
module.exports = command(
|
|
15
|
-
{
|
|
16
|
-
name: 'sign-cert',
|
|
17
|
-
usage: MESSAGES.usage
|
|
18
|
-
},
|
|
19
|
-
async argv => {
|
|
20
|
-
if (process.platform !== 'darwin') {
|
|
21
|
-
throw new Error(MESSAGES.platform);
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
const host = process.env.AUNTY_HOST || DEFAULT_HOST;
|
|
25
|
-
const files = {
|
|
26
|
-
cert: getSSLPath(host, SERVER_CERT_FILENAME),
|
|
27
|
-
key: getSSLPath(host, SERVER_KEY_FILENAME)
|
|
28
|
-
};
|
|
29
|
-
const opensslArgs = MESSAGES.opensslArgs(host, files.key, files.cert);
|
|
30
|
-
const cmd = `openssl ${opensslArgs.join(' ')}`;
|
|
31
|
-
|
|
32
|
-
if (argv.dry) {
|
|
33
|
-
return dry({
|
|
34
|
-
'OpenSSL config': {
|
|
35
|
-
host,
|
|
36
|
-
files,
|
|
37
|
-
cmd
|
|
38
|
-
}
|
|
39
|
-
});
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
let spinner = spin(`Creating SSL certificate`);
|
|
43
|
-
|
|
44
|
-
await makeDir(getSSLPath(host));
|
|
45
|
-
spawnSync('bash', ['-c', cmd]);
|
|
46
|
-
|
|
47
|
-
spinner.succeed('SSL certificate created');
|
|
48
|
-
info(MESSAGES.manual(files.cert));
|
|
49
|
-
}
|
|
50
|
-
);
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
// Ours
|
|
2
|
-
const { cmd, opt, sec } = require('../../utils/color');
|
|
3
|
-
|
|
4
|
-
module.exports.MESSAGES = {
|
|
5
|
-
usage: name => `Usage: ${cmd(`aunty ${name}`)} ${opt('[options]')} -- ${opt('[jest_options]')}
|
|
6
|
-
|
|
7
|
-
${sec('Options')}
|
|
8
|
-
|
|
9
|
-
${opt('-d')}, ${opt('--dry')} Output the generated jest configuration, then exit
|
|
10
|
-
|
|
11
|
-
${sec('Environment variables')}
|
|
12
|
-
|
|
13
|
-
• Tests will assume you have set ${cmd('NODE_ENV=test')}, unless you specify otherwise.
|
|
14
|
-
`
|
|
15
|
-
};
|
package/src/cli/test/index.js
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
// External
|
|
2
|
-
const importLazy = require('import-lazy')(require);
|
|
3
|
-
const jest = importLazy('jest');
|
|
4
|
-
|
|
5
|
-
// Ours
|
|
6
|
-
const { command } = require('../');
|
|
7
|
-
const { getJestConfig } = require('../../config/jest');
|
|
8
|
-
const { dry } = require('../../utils/logging');
|
|
9
|
-
const { MESSAGES } = require('./constants');
|
|
10
|
-
|
|
11
|
-
module.exports = command(
|
|
12
|
-
{
|
|
13
|
-
name: 'test',
|
|
14
|
-
nodeEnv: 'test',
|
|
15
|
-
usage: MESSAGES.usage
|
|
16
|
-
},
|
|
17
|
-
async argv => {
|
|
18
|
-
const config = getJestConfig();
|
|
19
|
-
const jestArgs = ['--config', JSON.stringify(config)].concat(argv['--']);
|
|
20
|
-
|
|
21
|
-
if (argv.dry) {
|
|
22
|
-
return dry({
|
|
23
|
-
'Jest config': config,
|
|
24
|
-
'Jest args': jestArgs
|
|
25
|
-
});
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
await jest.run(jestArgs);
|
|
29
|
-
}
|
|
30
|
-
);
|
package/src/config/babel.js
DELETED
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
// External
|
|
2
|
-
const importLazy = require('import-lazy')(require);
|
|
3
|
-
const mem = require('mem');
|
|
4
|
-
const semver = importLazy('semver');
|
|
5
|
-
|
|
6
|
-
// Ours
|
|
7
|
-
const { merge } = require('../utils/structures');
|
|
8
|
-
const { getProjectConfig } = require('./project');
|
|
9
|
-
|
|
10
|
-
const PROJECT_TYPES_CONFIG = {
|
|
11
|
-
preact: {
|
|
12
|
-
plugins: [
|
|
13
|
-
[
|
|
14
|
-
require.resolve('@babel/plugin-transform-react-jsx'),
|
|
15
|
-
{
|
|
16
|
-
pragma: 'h'
|
|
17
|
-
}
|
|
18
|
-
]
|
|
19
|
-
]
|
|
20
|
-
},
|
|
21
|
-
react: {
|
|
22
|
-
presets: [require.resolve('@babel/preset-react')]
|
|
23
|
-
}
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
module.exports.getBabelConfig = mem(
|
|
27
|
-
({ isModernJS } = {}) => {
|
|
28
|
-
const { babel: projectBabelConfig, pkg, hasTS, type } = getProjectConfig();
|
|
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
|
-
|
|
40
|
-
return merge(
|
|
41
|
-
{
|
|
42
|
-
presets: [
|
|
43
|
-
[
|
|
44
|
-
require.resolve('@babel/preset-env'),
|
|
45
|
-
{
|
|
46
|
-
targets: {
|
|
47
|
-
browsers: isModernJS
|
|
48
|
-
? ['Chrome >= 80', 'Safari >= 12.1', 'iOS >= 12.3', 'Firefox >= 72', 'Edge >= 18']
|
|
49
|
-
: pkg.browserslist || ['> 1% in AU', 'Firefox ESR', 'IE 11']
|
|
50
|
-
},
|
|
51
|
-
useBuiltIns: 'entry',
|
|
52
|
-
corejs,
|
|
53
|
-
modules: process.env.NODE_ENV === 'test' ? 'commonjs' : false
|
|
54
|
-
}
|
|
55
|
-
]
|
|
56
|
-
].concat(
|
|
57
|
-
hasTS
|
|
58
|
-
? [
|
|
59
|
-
[
|
|
60
|
-
require.resolve('@babel/preset-typescript'),
|
|
61
|
-
{
|
|
62
|
-
onlyRemoveTypeImports: true
|
|
63
|
-
}
|
|
64
|
-
]
|
|
65
|
-
]
|
|
66
|
-
: []
|
|
67
|
-
),
|
|
68
|
-
plugins: [require.resolve('@babel/plugin-syntax-dynamic-import')]
|
|
69
|
-
},
|
|
70
|
-
PROJECT_TYPES_CONFIG[type],
|
|
71
|
-
projectBabelConfig
|
|
72
|
-
);
|
|
73
|
-
},
|
|
74
|
-
{ cacheKey: ({ isModernJS }) => isModernJS }
|
|
75
|
-
);
|
package/src/config/build.js
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
// Native
|
|
2
|
-
const { join } = require('path');
|
|
3
|
-
|
|
4
|
-
// External
|
|
5
|
-
const mem = require('mem');
|
|
6
|
-
|
|
7
|
-
// Ours
|
|
8
|
-
const { BUILD_DIRECTORY_NAME, OUTPUT_DIRECTORY_NAME } = require('../constants');
|
|
9
|
-
const { combine } = require('../utils/structures');
|
|
10
|
-
const { getProjectConfig } = require('./project');
|
|
11
|
-
|
|
12
|
-
const PROJECT_TYPES_CONFIG = {
|
|
13
|
-
svelte: {
|
|
14
|
-
useCSSModules: false
|
|
15
|
-
}
|
|
16
|
-
};
|
|
17
|
-
const DEFAULT_ENTRY_FILE_NAME = 'index';
|
|
18
|
-
const DEFAULT_SOURCE_DIRECTORY_NAME = 'src';
|
|
19
|
-
const DEFAULT_STATIC_DIRECTORY_NAME = 'public';
|
|
20
|
-
|
|
21
|
-
module.exports.getBuildConfig = mem(() => {
|
|
22
|
-
const { build: projectBuildConfig, type } = getProjectConfig();
|
|
23
|
-
|
|
24
|
-
return combine(
|
|
25
|
-
{
|
|
26
|
-
entry: DEFAULT_ENTRY_FILE_NAME,
|
|
27
|
-
from: DEFAULT_SOURCE_DIRECTORY_NAME,
|
|
28
|
-
to: join(OUTPUT_DIRECTORY_NAME, BUILD_DIRECTORY_NAME),
|
|
29
|
-
staticDir: DEFAULT_STATIC_DIRECTORY_NAME,
|
|
30
|
-
addModernJS: false,
|
|
31
|
-
includedDependencies: [],
|
|
32
|
-
extractCSS: false,
|
|
33
|
-
useCSSModules: true,
|
|
34
|
-
showDeprecations: false
|
|
35
|
-
},
|
|
36
|
-
PROJECT_TYPES_CONFIG[type],
|
|
37
|
-
projectBuildConfig
|
|
38
|
-
);
|
|
39
|
-
});
|
package/src/config/deploy.js
DELETED
|
@@ -1,143 +0,0 @@
|
|
|
1
|
-
// Native
|
|
2
|
-
const { join } = require('path');
|
|
3
|
-
|
|
4
|
-
// External
|
|
5
|
-
const importLazy = require('import-lazy')(require);
|
|
6
|
-
const loadJsonFile = importLazy('load-json-file');
|
|
7
|
-
|
|
8
|
-
// Ours
|
|
9
|
-
const { VALID_TYPES } = require('../cli/deploy/constants');
|
|
10
|
-
const { isRepoSync, getCurrentLabelSync } = require('../utils/git');
|
|
11
|
-
const { warn } = require('../utils/logging');
|
|
12
|
-
const { combine } = require('../utils/structures');
|
|
13
|
-
const { getBuildConfig } = require('./build');
|
|
14
|
-
const { getProjectConfig } = require('./project');
|
|
15
|
-
|
|
16
|
-
const DEFAULT_PROFILES_FILE_PATH = join(
|
|
17
|
-
process.env.HOME || process.env.HOMEPATH || process.env.USERPROFILE,
|
|
18
|
-
'.abc-credentials'
|
|
19
|
-
);
|
|
20
|
-
|
|
21
|
-
const KNOWN_PROFILES_CONFIG = {
|
|
22
|
-
contentftp: {
|
|
23
|
-
to: '/www/res/sites/news-projects/<name>/<id>',
|
|
24
|
-
resolvePublicPath: config => `${config.to.replace('/www', 'https://www.abc.net.au')}/`
|
|
25
|
-
}
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
const MESSAGES = {
|
|
29
|
-
incomplete: 'Your deploy configuration may be missing required properties.',
|
|
30
|
-
noProfile: () => `Your profiles file doesn't contain a "${profile}" profile. ${MESSAGES.incomplete}`,
|
|
31
|
-
noProfilesFile: path => `Could not load a profiles file from "${path}". ${MESSAGES.incomplete}`
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
module.exports.getDeployConfig = ({ id } = {}) => {
|
|
35
|
-
let { deploy: projectDeployTargetsConfigs } = getProjectConfig();
|
|
36
|
-
const { to } = getBuildConfig();
|
|
37
|
-
|
|
38
|
-
id = id || (isRepoSync() && getCurrentLabelSync()) || 'unversioned';
|
|
39
|
-
|
|
40
|
-
// Ensure projectDeployTargetsConfigs is not a primitive
|
|
41
|
-
if (typeof projectDeployTargetsConfigs !== 'object') {
|
|
42
|
-
projectDeployTargetsConfigs = {};
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
// ## DEPRECATED ##
|
|
46
|
-
// Convert old profile key-based config objects to array
|
|
47
|
-
else if (!Array.isArray(projectDeployTargetsConfigs)) {
|
|
48
|
-
const projectDeployTargetsConfigsKeys = Object.keys(projectDeployTargetsConfigs);
|
|
49
|
-
const expectedProps = VALID_TYPES.get('ftp').REQUIRED_PROPERTIES;
|
|
50
|
-
// We assume that if we find an prop that references an object and
|
|
51
|
-
// isn't in the expected props for an FTP target, it was a profile name
|
|
52
|
-
if (
|
|
53
|
-
projectDeployTargetsConfigsKeys.filter(
|
|
54
|
-
key => typeof projectDeployTargetsConfigs[key] === 'object' && !expectedProps.includes(key)
|
|
55
|
-
).length > 0
|
|
56
|
-
) {
|
|
57
|
-
projectDeployTargetsConfigs = projectDeployTargetsConfigsKeys.map(profile =>
|
|
58
|
-
combine({ profile }, projectDeployTargetsConfigs[profile])
|
|
59
|
-
);
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
// ## END DEPRECATED ##
|
|
63
|
-
|
|
64
|
-
// Ensure projectDeployConfig is an array
|
|
65
|
-
if (!Array.isArray(projectDeployTargetsConfigs)) {
|
|
66
|
-
projectDeployTargetsConfigs = [projectDeployTargetsConfigs];
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
const deployTargetConfigInputProperties = {
|
|
70
|
-
id,
|
|
71
|
-
from: to,
|
|
72
|
-
files: '**'
|
|
73
|
-
};
|
|
74
|
-
|
|
75
|
-
return {
|
|
76
|
-
id,
|
|
77
|
-
targets: projectDeployTargetsConfigs.map(projectDeployTargetConfig =>
|
|
78
|
-
combine(
|
|
79
|
-
deployTargetConfigInputProperties,
|
|
80
|
-
addKnownProfileProperties,
|
|
81
|
-
projectDeployTargetConfig,
|
|
82
|
-
resolveProperties,
|
|
83
|
-
removeExtraneousProperties
|
|
84
|
-
)
|
|
85
|
-
)
|
|
86
|
-
};
|
|
87
|
-
};
|
|
88
|
-
|
|
89
|
-
const addKnownProfileProperties = config => {
|
|
90
|
-
const profile = config.profile || 'contentftp'; // default
|
|
91
|
-
|
|
92
|
-
return combine(config, { profile }, KNOWN_PROFILES_CONFIG[profile]);
|
|
93
|
-
};
|
|
94
|
-
|
|
95
|
-
function resolveProperties(config) {
|
|
96
|
-
const { pkg, root } = getProjectConfig();
|
|
97
|
-
const { name } = pkg;
|
|
98
|
-
// Package name may be in `@scope/name` format
|
|
99
|
-
const unscopedName = name.split('/').reverse()[0];
|
|
100
|
-
|
|
101
|
-
config.from = join(root, config.from);
|
|
102
|
-
config.to = config.to.replace('<name>', unscopedName).replace('<id>', config.id);
|
|
103
|
-
config.publicPath = typeof config.resolvePublicPath === 'function' ? config.resolvePublicPath(config) : '/';
|
|
104
|
-
|
|
105
|
-
return config;
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
function removeExtraneousProperties(config) {
|
|
109
|
-
delete config.id;
|
|
110
|
-
delete config.resolvePublicPath;
|
|
111
|
-
|
|
112
|
-
return Object.keys(config)
|
|
113
|
-
.sort()
|
|
114
|
-
.reduce((memo, prop) => {
|
|
115
|
-
memo[prop] = config[prop];
|
|
116
|
-
|
|
117
|
-
return memo;
|
|
118
|
-
}, {});
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
module.exports.addProfileProperties = config => {
|
|
122
|
-
const { profile } = config;
|
|
123
|
-
const profilesFilePath = config.profilesFilePath || DEFAULT_PROFILES_FILE_PATH;
|
|
124
|
-
let profiles;
|
|
125
|
-
|
|
126
|
-
try {
|
|
127
|
-
profiles = loadJsonFile.sync(profilesFilePath);
|
|
128
|
-
} catch (err) {
|
|
129
|
-
warn(MESSAGES.noProfilesFile(profilesFilePath));
|
|
130
|
-
|
|
131
|
-
return config;
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
const profileProps = profiles[profile];
|
|
135
|
-
|
|
136
|
-
if (!profileProps) {
|
|
137
|
-
warn(MESSAGES.noProfile(profile));
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
return combine(config, profileProps);
|
|
141
|
-
};
|
|
142
|
-
|
|
143
|
-
module.exports.addKnownProfileProperties = addKnownProfileProperties;
|
package/src/config/jest/index.js
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
// Ours
|
|
2
|
-
const { merge } = require('../../utils/structures');
|
|
3
|
-
const { getProjectConfig } = require('../project');
|
|
4
|
-
|
|
5
|
-
module.exports.getJestConfig = () => {
|
|
6
|
-
const { jest: projectJestConfig, root } = getProjectConfig();
|
|
7
|
-
const defaultTransformerPath = require.resolve('./transformer-default');
|
|
8
|
-
|
|
9
|
-
return merge(
|
|
10
|
-
{
|
|
11
|
-
rootDir: root,
|
|
12
|
-
verbose: true,
|
|
13
|
-
transform: {
|
|
14
|
-
'^.+\\.svelte$': require.resolve('./transformer-svelte'),
|
|
15
|
-
'.*': defaultTransformerPath
|
|
16
|
-
}
|
|
17
|
-
},
|
|
18
|
-
projectJestConfig
|
|
19
|
-
);
|
|
20
|
-
};
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
// Native
|
|
2
|
-
const path = require('path');
|
|
3
|
-
|
|
4
|
-
// External
|
|
5
|
-
const importLazy = require('import-lazy')(require);
|
|
6
|
-
const babelJest = importLazy('babel-jest');
|
|
7
|
-
|
|
8
|
-
// Ours
|
|
9
|
-
const { getBabelConfig } = require('../babel');
|
|
10
|
-
|
|
11
|
-
const MEDIA_RESOURCE_PATTERN = /\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$/;
|
|
12
|
-
const STYLE_RESOURCE_PATTERN = /\.s?css$/;
|
|
13
|
-
const STYLE_RESOURCE_REPLACEMENT = 'module.exports = new Proxy({}, { get: (styles, method) => method });';
|
|
14
|
-
|
|
15
|
-
module.exports = {
|
|
16
|
-
process(src, filename, config) {
|
|
17
|
-
// Mock media & style resources
|
|
18
|
-
if (filename.match(MEDIA_RESOURCE_PATTERN)) {
|
|
19
|
-
return 'module.exports = ' + JSON.stringify(path.basename(filename)) + ';';
|
|
20
|
-
} else if (filename.match(STYLE_RESOURCE_PATTERN)) {
|
|
21
|
-
return STYLE_RESOURCE_REPLACEMENT;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
// Run everything else through babel
|
|
25
|
-
return babelJest.createTransformer(getBabelConfig()).process(src, filename, config, { sourceMaps: false });
|
|
26
|
-
}
|
|
27
|
-
};
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
// Native
|
|
2
|
-
const { execSync } = require('child_process');
|
|
3
|
-
const { basename } = require('path');
|
|
4
|
-
|
|
5
|
-
// External
|
|
6
|
-
const importLazy = require('import-lazy')(require);
|
|
7
|
-
const svelte = importLazy('svelte/compiler');
|
|
8
|
-
|
|
9
|
-
module.exports = {
|
|
10
|
-
process(src, filename) {
|
|
11
|
-
const preprocessor = require.resolve('./transformer-svelte-preprocess.js');
|
|
12
|
-
|
|
13
|
-
const processed = execSync(`node --unhandled-rejections=strict --abort-on-uncaught-exception ${preprocessor}`, {
|
|
14
|
-
env: { PATH: process.env.PATH, src, filename }
|
|
15
|
-
}).toString();
|
|
16
|
-
|
|
17
|
-
const result = svelte.compile(processed, {
|
|
18
|
-
filename: basename(filename),
|
|
19
|
-
css: true,
|
|
20
|
-
accessors: true,
|
|
21
|
-
dev: true,
|
|
22
|
-
format: 'cjs'
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
const esInterop = 'Object.defineProperty(exports, "__esModule", { value: true });';
|
|
26
|
-
|
|
27
|
-
return {
|
|
28
|
-
code: result.js.code + esInterop,
|
|
29
|
-
map: result.js.map
|
|
30
|
-
};
|
|
31
|
-
}
|
|
32
|
-
};
|
package/src/config/project.js
DELETED
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
// Global
|
|
2
|
-
const { existsSync } = require('fs');
|
|
3
|
-
const { join } = require('path');
|
|
4
|
-
|
|
5
|
-
// External
|
|
6
|
-
const importLazy = require('import-lazy')(require);
|
|
7
|
-
const guessRootPath = importLazy('guess-root-path');
|
|
8
|
-
const mem = require('mem');
|
|
9
|
-
|
|
10
|
-
// Ours
|
|
11
|
-
const { hvy } = require('../utils/color');
|
|
12
|
-
const { pretty } = require('../utils/logging');
|
|
13
|
-
const { combine } = require('../utils/structures');
|
|
14
|
-
const { PROJECT_CONFIG_FILE_NAME } = require('../constants');
|
|
15
|
-
|
|
16
|
-
function ensureProjectConfigShape(x) {
|
|
17
|
-
return typeof x === 'object' ? x : typeof x === 'string' ? { type: x } : {};
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
module.exports.getProjectConfig = mem(() => {
|
|
21
|
-
const root = guessRootPath();
|
|
22
|
-
|
|
23
|
-
if (root === null) {
|
|
24
|
-
throw new Error(`Aunty doesn't work if your project doesn't have a ${hvy('package.json')} file.`);
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
let pkg;
|
|
28
|
-
|
|
29
|
-
try {
|
|
30
|
-
pkg = require(`${root}/package.json`);
|
|
31
|
-
} catch (err) {
|
|
32
|
-
throw pretty(err);
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
let projectConfigModule;
|
|
36
|
-
|
|
37
|
-
try {
|
|
38
|
-
projectConfigModule = require(`${root}/${PROJECT_CONFIG_FILE_NAME}`);
|
|
39
|
-
} catch (err) {
|
|
40
|
-
// The standalone config file is optional, but it may have syntax problems
|
|
41
|
-
if (err.code !== 'MODULE_NOT_FOUND') {
|
|
42
|
-
throw pretty(err);
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
const hasTS = existsSync(join(root, 'tsconfig.json'));
|
|
47
|
-
|
|
48
|
-
return combine(
|
|
49
|
-
{
|
|
50
|
-
root,
|
|
51
|
-
pkg,
|
|
52
|
-
hasTS
|
|
53
|
-
},
|
|
54
|
-
ensureProjectConfigShape(pkg.aunty),
|
|
55
|
-
ensureProjectConfigShape(projectConfigModule)
|
|
56
|
-
);
|
|
57
|
-
});
|