@madgex/fert 6.0.0 → 6.0.2
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/bin/cli.js +19 -14
- package/bin/commands/_service-command-bootstrap.js +12 -14
- package/bin/commands/build-tasks/build-external-assets.js +5 -5
- package/bin/commands/build-tasks/build-tokens.js +7 -7
- package/bin/commands/build-tasks/bundle-entry.js +13 -10
- package/bin/commands/build.js +19 -23
- package/bin/commands/configs.js +18 -22
- package/bin/commands/dev-server.js +17 -14
- package/bin/commands/init.js +13 -14
- package/bin/commands/publish-tasks/asset-store-uploader.js +12 -12
- package/bin/commands/publish-tasks/get-aws-parameter.js +4 -6
- package/bin/commands/publish.js +12 -12
- package/bin/utils/configs.js +39 -47
- package/bin/utils/cpid-lookup.js +12 -12
- package/bin/utils/cpid-matches-git-remote.js +7 -7
- package/bin/utils/getSchemaMeta.js +2 -4
- package/bin/utils/index.js +53 -54
- package/bin/utils/logging.js +4 -3
- package/bin/utils/lookup-cf-distribution-ids.js +15 -15
- package/bin/utils/persistent-cache-with-ttl.js +18 -18
- package/bin/utils/resolve-external-assets.js +3 -9
- package/bin/utils/slug.js +2 -2
- package/constants.js +50 -54
- package/eslint.config.js +19 -0
- package/package.json +11 -11
- package/server/extensions/error-logging.js +1 -1
- package/server/index.js +5 -101
- package/server/plugins/hapi-vite.js +8 -5
- package/server/routes/public.js +4 -2
- package/server/routes/views.js +5 -7
- package/server/server.js +104 -0
- package/server/view-manager.js +5 -5
- package/vite.config.js +4 -4
package/bin/cli.js
CHANGED
|
@@ -1,12 +1,17 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
3
|
+
import path from 'node:path';
|
|
4
|
+
import fs from 'node:fs';
|
|
5
|
+
import chalk from 'chalk';
|
|
6
|
+
import cac from 'cac';
|
|
7
|
+
import simpleUpdateNotifier from 'simple-update-notifier';
|
|
8
|
+
import { VERSION } from '../constants.js';
|
|
9
|
+
import { printBanner } from './utils/index.js';
|
|
10
|
+
import { serviceCommandBootstrap } from './commands/_service-command-bootstrap.js';
|
|
11
|
+
import { configsCommand } from './commands/configs.js';
|
|
12
|
+
import { initCommand } from './commands/init.js';
|
|
8
13
|
|
|
9
|
-
const
|
|
14
|
+
const cli = cac('fert');
|
|
10
15
|
|
|
11
16
|
const run = () => {
|
|
12
17
|
printBanner();
|
|
@@ -18,21 +23,21 @@ const run = () => {
|
|
|
18
23
|
.option('--host [host]', '[string] specify hostname')
|
|
19
24
|
.option('--port <port>', '[number] specify port')
|
|
20
25
|
.option('--service-name <serviceName>', '[string] run a single service')
|
|
21
|
-
.action((...args) =>
|
|
26
|
+
.action((...args) => serviceCommandBootstrap('dev', ...args));
|
|
22
27
|
|
|
23
28
|
cli
|
|
24
29
|
.command('build', 'Build project. Can supply a branding directory if running FERT standalone')
|
|
25
30
|
.option('--only <task>', `Only run part of the build [ 'assets', 'tokens']`)
|
|
26
31
|
.option('--config [dir]', 'Use custom rollup config file')
|
|
27
32
|
.option('--service-name <serviceName>', '[string] run a single service')
|
|
28
|
-
.action((...args) =>
|
|
33
|
+
.action((...args) => serviceCommandBootstrap('build', ...args));
|
|
29
34
|
|
|
30
35
|
cli
|
|
31
36
|
.command('publish', 'Publish the project')
|
|
32
37
|
.option('--target <env>', 'Environment to publish to, "dev" or "production"')
|
|
33
38
|
.option('--service-name <serviceName>', '[string] run a single service')
|
|
34
39
|
.option('--dry-run', 'Dry run, dont actually upload anything')
|
|
35
|
-
.action((...args) =>
|
|
40
|
+
.action((...args) => serviceCommandBootstrap('publish', ...args));
|
|
36
41
|
|
|
37
42
|
cli
|
|
38
43
|
.command('configs', 'Query/Publish project configs')
|
|
@@ -42,12 +47,12 @@ const run = () => {
|
|
|
42
47
|
'Download known configs from the Configuration API for environment "dev" or "production"',
|
|
43
48
|
)
|
|
44
49
|
.option('--query [configName]', 'Describe known keys for a config, omit to list all known configs')
|
|
45
|
-
.action((...args) =>
|
|
50
|
+
.action((...args) => configsCommand(...args));
|
|
46
51
|
|
|
47
52
|
cli
|
|
48
53
|
.command('init [root]', 'Create a new branding project')
|
|
49
54
|
.option('--cpid <cpid>', 'Specify the clientPropertyId to use in the new project')
|
|
50
|
-
.action((...args) =>
|
|
55
|
+
.action((...args) => initCommand(...args));
|
|
51
56
|
|
|
52
57
|
cli.option('--no-cache', 'Do not use cache');
|
|
53
58
|
cli.option('--purge-cache', 'Purge all caches');
|
|
@@ -56,10 +61,10 @@ const run = () => {
|
|
|
56
61
|
cli.parse();
|
|
57
62
|
|
|
58
63
|
// checks for available update
|
|
59
|
-
const pkg = JSON.parse(fs.readFileSync(
|
|
64
|
+
const pkg = JSON.parse(fs.readFileSync(path.join(import.meta.dirname, '..', 'package.json')));
|
|
60
65
|
|
|
61
66
|
if (pkg.version.indexOf('0.0.0') !== 0) {
|
|
62
|
-
|
|
67
|
+
simpleUpdateNotifier({ pkg });
|
|
63
68
|
}
|
|
64
69
|
};
|
|
65
70
|
|
|
@@ -67,7 +72,7 @@ try {
|
|
|
67
72
|
run();
|
|
68
73
|
} catch (error) {
|
|
69
74
|
if (error.name === 'CACError') {
|
|
70
|
-
console.error(chalk`\n
|
|
75
|
+
console.error(chalk.red(`\n${error.message}`));
|
|
71
76
|
} else {
|
|
72
77
|
console.error(error);
|
|
73
78
|
}
|
|
@@ -1,24 +1,22 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
const { FERT_SERVICE_CONFIG_FILENAME } = require('../../constants.js');
|
|
9
|
-
const { log } = require('../utils/logging.js');
|
|
1
|
+
import chalk from 'chalk';
|
|
2
|
+
import { loadServiceConfigFiles, loadConfigFromFile } from '../utils/index.js';
|
|
3
|
+
import { createDevServer } from './dev-server.js';
|
|
4
|
+
import { build } from './build.js';
|
|
5
|
+
import { publish } from './publish.js';
|
|
6
|
+
import { FERT_SERVICE_CONFIG_FILENAME } from '../../constants.js';
|
|
7
|
+
import { log } from '../utils/logging.js';
|
|
10
8
|
|
|
11
9
|
const commandMap = {
|
|
12
|
-
dev:
|
|
13
|
-
build
|
|
14
|
-
publish
|
|
10
|
+
dev: createDevServer,
|
|
11
|
+
build,
|
|
12
|
+
publish,
|
|
15
13
|
};
|
|
16
14
|
|
|
17
15
|
/**
|
|
18
16
|
* determine if we are running a single service, otherwise search for all services
|
|
19
17
|
* Then run command
|
|
20
18
|
*/
|
|
21
|
-
|
|
19
|
+
export async function serviceCommandBootstrap(command, options) {
|
|
22
20
|
// explicitly run a single service - via CLI option
|
|
23
21
|
if (options.serviceName) {
|
|
24
22
|
console.log(`🔦 ${chalk.green('Running single service mode')}`);
|
|
@@ -71,4 +69,4 @@ module.exports.serivceCommandBootstrap = async function serivceCommandBootstrap(
|
|
|
71
69
|
});
|
|
72
70
|
}
|
|
73
71
|
}
|
|
74
|
-
}
|
|
72
|
+
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import Path from 'node:path';
|
|
2
|
+
import fs from 'node:fs/promises';
|
|
3
|
+
import { log } from '../../utils/logging.js';
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
export async function buildExternalAssets(fertConfig) {
|
|
6
6
|
const { externalAssets, workingDir } = fertConfig;
|
|
7
7
|
const destination = Path.join(workingDir, `/dist/external-assets.json`);
|
|
8
8
|
|
|
@@ -13,4 +13,4 @@ module.exports = async function buildExternalAssets(fertConfig) {
|
|
|
13
13
|
log.error(err);
|
|
14
14
|
throw err;
|
|
15
15
|
}
|
|
16
|
-
}
|
|
16
|
+
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import Path from 'node:path';
|
|
2
|
+
import fs from 'node:fs/promises';
|
|
3
|
+
import { createStyleDictionary } from '@madgex/design-system/style-dictionary';
|
|
4
|
+
import { ensureTrailingSlash, exists } from '../../utils/index.js';
|
|
5
|
+
import { log } from '../../utils/logging.js';
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
export async function buildCssFromTokens(_srcTokensPath, _buildPath) {
|
|
8
8
|
const srcTokensPath = ensureTrailingSlash(Path.resolve(_srcTokensPath));
|
|
9
9
|
const buildPath = ensureTrailingSlash(Path.resolve(_buildPath));
|
|
10
10
|
|
|
@@ -33,4 +33,4 @@ module.exports = async function buildCssFromTokens(_srcTokensPath, _buildPath) {
|
|
|
33
33
|
await cleanTempFiles();
|
|
34
34
|
|
|
35
35
|
log.success('Token build complete (CSS & JSON).');
|
|
36
|
-
}
|
|
36
|
+
}
|
|
@@ -1,17 +1,20 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import path from 'node:path';
|
|
2
|
+
import { pathToFileURL } from 'node:url';
|
|
3
|
+
import merge from 'lodash/merge.js';
|
|
4
|
+
import * as vite from 'vite';
|
|
5
|
+
import { buildExternalAssets } from './build-external-assets.js';
|
|
6
|
+
import { log } from '../../utils/logging.js';
|
|
6
7
|
|
|
7
|
-
|
|
8
|
+
export async function bundleEntry(fertConfig, options = {}) {
|
|
8
9
|
let dynamicOptions = {};
|
|
9
10
|
let viteConfig = {};
|
|
10
11
|
|
|
11
12
|
if (options.config) {
|
|
12
|
-
|
|
13
|
+
const viteConfigPkg = await import(pathToFileURL(path.resolve(fertConfig.workingDir, options.config)));
|
|
14
|
+
viteConfig = viteConfigPkg.default;
|
|
13
15
|
} else {
|
|
14
|
-
|
|
16
|
+
const viteConfigPkg = await import('../../../vite.config.js');
|
|
17
|
+
viteConfig = viteConfigPkg.default;
|
|
15
18
|
}
|
|
16
19
|
|
|
17
20
|
dynamicOptions = {
|
|
@@ -26,11 +29,11 @@ module.exports = async (fertConfig, options = {}) => {
|
|
|
26
29
|
},
|
|
27
30
|
};
|
|
28
31
|
|
|
29
|
-
|
|
32
|
+
merge(viteConfig, dynamicOptions);
|
|
30
33
|
|
|
31
34
|
await vite.build(viteConfig);
|
|
32
35
|
|
|
33
36
|
await buildExternalAssets(fertConfig);
|
|
34
37
|
|
|
35
38
|
log.success('Assets built.');
|
|
36
|
-
}
|
|
39
|
+
}
|
package/bin/commands/build.js
CHANGED
|
@@ -1,13 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
1
|
+
import path from 'node:path';
|
|
2
|
+
import { rimraf } from 'rimraf';
|
|
3
|
+
import { resolveConfig } from '../utils/index.js';
|
|
4
|
+
import { log } from '../utils/logging.js';
|
|
5
|
+
import { bundleEntry } from './build-tasks/bundle-entry.js';
|
|
6
|
+
import { buildCssFromTokens } from './build-tasks/build-tokens.js';
|
|
7
|
+
import { buildExternalAssets } from './build-tasks/build-external-assets.js';
|
|
8
|
+
import { validateLocalConfigs } from '../utils/configs.js';
|
|
9
|
+
|
|
10
|
+
export { bundleEntry, buildExternalAssets };
|
|
11
|
+
|
|
12
|
+
export async function build(options = {}) {
|
|
11
13
|
const fertConfig = await resolveConfig(options);
|
|
12
14
|
await validateLocalConfigs({
|
|
13
15
|
workingDir: fertConfig.rootDir,
|
|
@@ -16,34 +18,28 @@ module.exports = async (options = {}) => {
|
|
|
16
18
|
|
|
17
19
|
if (!options.only) {
|
|
18
20
|
await rimraf(path.resolve(fertConfig.workingDir, 'dist'));
|
|
19
|
-
await
|
|
20
|
-
await
|
|
21
|
+
await buildTokens(fertConfig, options);
|
|
22
|
+
await bundleEntry(fertConfig, options);
|
|
21
23
|
|
|
22
24
|
return;
|
|
23
25
|
}
|
|
24
26
|
|
|
25
27
|
switch (options.only) {
|
|
26
28
|
case 'tokens':
|
|
27
|
-
await
|
|
29
|
+
await buildTokens(fertConfig, options);
|
|
28
30
|
break;
|
|
29
31
|
case 'assets':
|
|
30
|
-
await
|
|
32
|
+
await bundleEntry(fertConfig, options);
|
|
31
33
|
break;
|
|
32
34
|
default:
|
|
33
35
|
log.error('"--only param" not recognixed. Not building.');
|
|
34
36
|
}
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
// eslint-disable-next-line n/no-exports-assign
|
|
38
|
-
exports = module.exports; // allow default export & { named } exports
|
|
37
|
+
}
|
|
39
38
|
|
|
40
39
|
// eslint-disable-next-line no-unused-vars
|
|
41
|
-
|
|
40
|
+
export async function buildTokens(fertConfig, options = {}) {
|
|
42
41
|
const { workingDir } = fertConfig;
|
|
43
42
|
const tokenDist = path.join(workingDir, `/public/tokens/`);
|
|
44
43
|
|
|
45
44
|
buildCssFromTokens(workingDir, tokenDist);
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
exports.bundleEntry = bundleEntry;
|
|
49
|
-
exports.buildExternalAssets = buildExternalAssets;
|
|
45
|
+
}
|
package/bin/commands/configs.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
1
|
+
import { loadConfigFromFile, findFertConfigDir } from '../utils/index.js';
|
|
2
|
+
import { getConfigAPI, updateProjectConfigs } from '../utils/configs.js';
|
|
3
|
+
import chalk from 'chalk';
|
|
4
|
+
import { log } from '../utils/logging.js';
|
|
5
|
+
import { getSchemaMeta } from '../utils/getSchemaMeta.js';
|
|
6
|
+
import ora from 'ora';
|
|
7
|
+
import { mkdir, writeFile } from 'node:fs/promises';
|
|
8
|
+
import Path from 'node:path';
|
|
9
|
+
import { CONFIG_DIR } from '../../constants.js';
|
|
10
|
+
|
|
11
|
+
export async function handleDownload({ workingDir }, api, options) {
|
|
12
12
|
const validTargets = ['dev', 'production'];
|
|
13
13
|
|
|
14
14
|
if (!validTargets.includes(options.download)) {
|
|
@@ -79,9 +79,9 @@ const handleDownload = async ({ workingDir }, api, options) => {
|
|
|
79
79
|
await writeFile(filePath, JSON.stringify(data, null, 2));
|
|
80
80
|
console.log(` - ${schemaName}.json`);
|
|
81
81
|
}
|
|
82
|
-
}
|
|
82
|
+
}
|
|
83
83
|
|
|
84
|
-
|
|
84
|
+
export async function handlePublish({ workingDir, clientPropertyId }, api, options) {
|
|
85
85
|
const validTargets = ['dev', 'production'];
|
|
86
86
|
|
|
87
87
|
if (!validTargets.includes(options.publish)) {
|
|
@@ -99,9 +99,9 @@ const handlePublish = async ({ workingDir, clientPropertyId }, api, options) =>
|
|
|
99
99
|
// eslint-disable-next-line n/no-process-exit
|
|
100
100
|
process.exit(1);
|
|
101
101
|
}
|
|
102
|
-
}
|
|
102
|
+
}
|
|
103
103
|
|
|
104
|
-
|
|
104
|
+
export async function handleQuery(/* { workingDir, clientPropertyId } */ _, api, options) {
|
|
105
105
|
try {
|
|
106
106
|
if (options.query !== true) {
|
|
107
107
|
console.log(chalk.cyan(`\nGetting schema description for config: ${chalk.bold(options.query)}...`));
|
|
@@ -131,9 +131,9 @@ const handleQuery = async (/* { workingDir, clientPropertyId } */ _, api, option
|
|
|
131
131
|
// eslint-disable-next-line n/no-process-exit
|
|
132
132
|
process.exit(1);
|
|
133
133
|
}
|
|
134
|
-
}
|
|
134
|
+
}
|
|
135
135
|
|
|
136
|
-
|
|
136
|
+
export async function configsCommand(options) {
|
|
137
137
|
const fertConfigDir = await findFertConfigDir();
|
|
138
138
|
|
|
139
139
|
const { clientPropertyId } = await loadConfigFromFile({
|
|
@@ -156,8 +156,4 @@ module.exports = async (options) => {
|
|
|
156
156
|
} else if (options.query) {
|
|
157
157
|
await handleQuery({ clientPropertyId, workingDir: fertConfigDir }, api, options);
|
|
158
158
|
}
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
module.exports.handleDownload = handleDownload;
|
|
162
|
-
module.exports.handlePublish = handlePublish;
|
|
163
|
-
module.exports.handleQuery = handleQuery;
|
|
159
|
+
}
|
|
@@ -1,15 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
1
|
+
import path from 'node:path';
|
|
2
|
+
// eslint-disable-next-line n/no-unsupported-features/node-builtins
|
|
3
|
+
import { glob } from 'node:fs/promises';
|
|
4
|
+
import chalk from 'chalk';
|
|
5
|
+
import open from 'open';
|
|
6
|
+
import chokidar from 'chokidar4';
|
|
7
|
+
import { resolveConfig, findFertConfigDir } from '../utils/index.js';
|
|
8
|
+
import { log } from '../utils/logging.js';
|
|
9
|
+
import { validateLocalConfigs } from '../utils/configs.js';
|
|
10
|
+
import { devServer } from '../../server/server.js';
|
|
11
|
+
import { buildTokens, buildExternalAssets } from './build.js';
|
|
12
|
+
import { BRAND_JSON_FILENAME, FERT_CONFIG_FILENAME, FERT_SERVICE_CONFIG_FILENAME } from '../../constants.js';
|
|
11
13
|
|
|
12
|
-
|
|
14
|
+
export async function createDevServer(options = {}) {
|
|
13
15
|
let fertConfig = await resolveConfig(options);
|
|
14
16
|
|
|
15
17
|
console.log(
|
|
@@ -28,8 +30,8 @@ module.exports = async (options = {}) => {
|
|
|
28
30
|
const fertConfigDir = await findFertConfigDir();
|
|
29
31
|
|
|
30
32
|
// watch local configs - revalidate on change
|
|
31
|
-
const
|
|
32
|
-
chokidar.watch(
|
|
33
|
+
const configPaths = await Array.fromAsync(glob(path.resolve(fertConfigDir, './config/*.json')));
|
|
34
|
+
chokidar.watch(configPaths, { ignoreInitial: true }).on('all', async () => {
|
|
33
35
|
await validateLocalConfigs({
|
|
34
36
|
workingDir: fertConfig.rootDir,
|
|
35
37
|
clientPropertyId: fertConfig.clientPropertyId,
|
|
@@ -39,6 +41,7 @@ module.exports = async (options = {}) => {
|
|
|
39
41
|
|
|
40
42
|
// watch brand.json & fert.config.js - refresh on change
|
|
41
43
|
const brandPath = path.resolve(fertConfig.workingDir, BRAND_JSON_FILENAME);
|
|
44
|
+
|
|
42
45
|
chokidar.watch(brandPath, { ignoreInitial: true }).on('all', async () => {
|
|
43
46
|
await buildTokens(fertConfig);
|
|
44
47
|
});
|
|
@@ -66,4 +69,4 @@ module.exports = async (options = {}) => {
|
|
|
66
69
|
if (options.open) {
|
|
67
70
|
await open(server.info.uri);
|
|
68
71
|
}
|
|
69
|
-
}
|
|
72
|
+
}
|
package/bin/commands/init.js
CHANGED
|
@@ -1,18 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
const { FERT_CONFIG_FILENAME } = require('../../constants');
|
|
1
|
+
import path from 'node:path';
|
|
2
|
+
import fs from 'node:fs';
|
|
3
|
+
import chalk from 'chalk';
|
|
4
|
+
import prompts from 'prompts';
|
|
5
|
+
import uuidValidator from 'uuid-validate';
|
|
6
|
+
import ora from 'ora';
|
|
7
|
+
import { cpidLookup } from '../utils/cpid-lookup.js';
|
|
8
|
+
import fertPackageJSON from '../../package.json' with { type: 'json' };
|
|
9
|
+
import { isEmptyDir, formatTargetDir, emptyDir } from '../utils/index.js';
|
|
10
|
+
import { FERT_CONFIG_FILENAME } from '../../constants.js';
|
|
12
11
|
|
|
13
12
|
const cwd = process.cwd();
|
|
14
13
|
|
|
15
|
-
|
|
14
|
+
export async function initCommand(root, options = {}) {
|
|
16
15
|
const defaultProjectName = 'madgex-{cpid}';
|
|
17
16
|
const argTargetDir = root ? formatTargetDir(root) : null;
|
|
18
17
|
const argClientPropertyId = options.cpid && uuidValidator(options.cpid) ? options.cpid : false;
|
|
@@ -91,7 +90,7 @@ module.exports = async (root, options = {}) => {
|
|
|
91
90
|
console.log(`\nScaffolding project in ${chalk.bold(outDir)}…`);
|
|
92
91
|
|
|
93
92
|
// copy boilerplate to output dir
|
|
94
|
-
const templateDir = path.resolve(
|
|
93
|
+
const templateDir = path.resolve(import.meta.dirname, '../../repo-template');
|
|
95
94
|
fs.cpSync(templateDir, outDir, { recursive: true });
|
|
96
95
|
|
|
97
96
|
// Update new package.json
|
|
@@ -119,4 +118,4 @@ module.exports = async (root, options = {}) => {
|
|
|
119
118
|
console.log(` npm install`);
|
|
120
119
|
console.log(` npm run dev`);
|
|
121
120
|
console.log();
|
|
122
|
-
}
|
|
121
|
+
}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import * as Hoek from '@hapi/hoek';
|
|
4
|
+
import axios from 'axios';
|
|
5
|
+
import FormData from 'form-data';
|
|
6
|
+
import ora from 'ora';
|
|
7
|
+
import chalk from 'chalk';
|
|
8
|
+
import { log } from '../../utils/logging.js';
|
|
9
|
+
import { ASSET_STORE_USER_GUID } from '../../../constants.js';
|
|
10
|
+
|
|
11
|
+
export class AssetStoreUploader {
|
|
12
12
|
constructor(options = {}) {
|
|
13
13
|
Hoek.assert(options.apiUrl, 'apiUrl required');
|
|
14
14
|
Hoek.assert(options.apiKey, 'apiKey required');
|
|
@@ -120,4 +120,4 @@ module.exports = class AssetStoreUploader {
|
|
|
120
120
|
|
|
121
121
|
return files;
|
|
122
122
|
};
|
|
123
|
-
}
|
|
123
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import { SSMClient, GetParameterCommand } from '@aws-sdk/client-ssm';
|
|
2
|
+
import { AWS_REGION } from '../../../constants.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Gets AWS parameter from the parameter store
|
|
@@ -13,7 +13,7 @@ const { AWS_REGION } = require('../../../constants');
|
|
|
13
13
|
* @returns {Promise<{ value: string | undefined }>} the value of the requested AWS parameter
|
|
14
14
|
*
|
|
15
15
|
*/
|
|
16
|
-
|
|
16
|
+
export async function getAwsParam(paramName) {
|
|
17
17
|
const client = new SSMClient({
|
|
18
18
|
region: AWS_REGION,
|
|
19
19
|
});
|
|
@@ -34,6 +34,4 @@ const getAwsParam = async (paramName) => {
|
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
return result;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
module.exports = getAwsParam;
|
|
37
|
+
}
|
package/bin/commands/publish.js
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
import path from 'node:path';
|
|
2
|
+
import * as Hoek from '@hapi/hoek';
|
|
3
|
+
import chalk from 'chalk';
|
|
4
|
+
import { resolveConfig } from '../utils/index.js';
|
|
5
|
+
import { log } from '../utils/logging.js';
|
|
6
|
+
import { getAwsParam } from './publish-tasks/get-aws-parameter.js';
|
|
7
|
+
import { AssetStoreUploader } from './publish-tasks/asset-store-uploader.js';
|
|
8
|
+
import { getCloudFrontDistributionsForDomain } from '../utils/lookup-cf-distribution-ids.js';
|
|
9
|
+
import {
|
|
10
10
|
ASSET_STORE_API,
|
|
11
11
|
AWS_PARAM_NAME,
|
|
12
12
|
REMOTE_UPLOAD_BASE,
|
|
13
13
|
UPLOAD_DIR,
|
|
14
14
|
ASSET_STORE_INVALIDATION_PATH,
|
|
15
15
|
BRANDED_SITE_INVALIDATION_PATH,
|
|
16
|
-
}
|
|
16
|
+
} from '../../constants.js';
|
|
17
17
|
|
|
18
|
-
|
|
18
|
+
export async function publish(options) {
|
|
19
19
|
const fertConfig = await resolveConfig(options);
|
|
20
20
|
const validTargets = ['dev', 'prod', 'production'];
|
|
21
21
|
|
|
@@ -83,4 +83,4 @@ module.exports = async (options) => {
|
|
|
83
83
|
} catch (error) {
|
|
84
84
|
log.error('An error occurred during the publish process', error);
|
|
85
85
|
}
|
|
86
|
-
}
|
|
86
|
+
}
|