@magmonium/cli 0.8.18 → 0.8.19
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/commands/assets.js +32 -1
- package/bin/commands/config-ci.js +10 -11
- package/bin/commands/configure-wc.js +14 -11
- package/bin/commands/connect.js +11 -8
- package/bin/commands/deploy.js +38 -7
- package/codegen/index.js +1428 -647
- package/package.json +1 -1
- package/src/compilers/web-component/lib/installed-pins.d.ts +13 -0
- package/src/compilers/web-component/lib/installed-pins.d.ts.map +1 -0
- package/src/compilers/web-component/lib/installed-pins.js +49 -0
- package/src/compilers/web-component/lib/installed-pins.js.map +1 -0
- package/src/compilers/web-component/lib/ng-build.d.ts.map +1 -1
- package/src/compilers/web-component/lib/ng-build.js +5 -0
- package/src/compilers/web-component/lib/ng-build.js.map +1 -1
- package/src/compilers/worker-compiler.d.ts.map +1 -1
- package/src/compilers/worker-compiler.js +9 -2
- package/src/compilers/worker-compiler.js.map +1 -1
- package/src/core/config.d.ts +44 -0
- package/src/core/config.d.ts.map +1 -1
- package/src/core/config.js +34 -1
- package/src/core/config.js.map +1 -1
- package/src/utils/i18n-gate.d.ts +2 -0
- package/src/utils/i18n-gate.d.ts.map +1 -1
- package/src/utils/i18n-gate.js +12 -2
- package/src/utils/i18n-gate.js.map +1 -1
package/bin/commands/assets.js
CHANGED
|
@@ -35,7 +35,12 @@ const I18N_GATE_WHY = {
|
|
|
35
35
|
* good assets in place for a running app.
|
|
36
36
|
*/
|
|
37
37
|
async function assertI18nComplete(root, verbose) {
|
|
38
|
-
const { failures, tightenable } = await runI18nGate(root, verbose);
|
|
38
|
+
const { failures, tightenable, enOnly } = await runI18nGate(root, verbose);
|
|
39
|
+
if (enOnly.length > 0) {
|
|
40
|
+
console.log(
|
|
41
|
+
`ℹ️ ${enOnly.length} i18n key(s) in en only — npm run translate:fix -- --key ${enOnly.join(' ')}`
|
|
42
|
+
);
|
|
43
|
+
}
|
|
39
44
|
if (tightenable > 0) {
|
|
40
45
|
console.log(
|
|
41
46
|
`ℹ️ ${tightenable} baseline key(s) translated further — npm run i18n:baseline to tighten ${I18N_BASELINE_FILE}`
|
|
@@ -465,6 +470,11 @@ function assetsCommand(program) {
|
|
|
465
470
|
outputPaths: PATHS.forms.output,
|
|
466
471
|
...config.forms,
|
|
467
472
|
},
|
|
473
|
+
effects: {
|
|
474
|
+
inputPaths: PATHS.effects.input,
|
|
475
|
+
outputPaths: PATHS.effects.output,
|
|
476
|
+
...config.effects,
|
|
477
|
+
},
|
|
468
478
|
buttons: {
|
|
469
479
|
inputPaths: PATHS.buttons.input,
|
|
470
480
|
outputPaths: PATHS.buttons.output,
|
|
@@ -550,6 +560,15 @@ function assetsCommand(program) {
|
|
|
550
560
|
format: 'iife',
|
|
551
561
|
...config.workers,
|
|
552
562
|
},
|
|
563
|
+
// Model binaries (ADR 0017) — copied verbatim, so a `.wasm` denoiser
|
|
564
|
+
// and a network's weights reach the bake Worker exactly as vendored.
|
|
565
|
+
models: {
|
|
566
|
+
inputPaths: PATHS.models.input,
|
|
567
|
+
outputPaths: PATHS.models.output,
|
|
568
|
+
preserveStructure: true,
|
|
569
|
+
overwrite: true,
|
|
570
|
+
...config.models,
|
|
571
|
+
},
|
|
553
572
|
cards: {
|
|
554
573
|
inputPaths: PATHS.cards.input,
|
|
555
574
|
outputPaths: PATHS.cards.output,
|
|
@@ -796,6 +815,12 @@ function assetsCommand(program) {
|
|
|
796
815
|
);
|
|
797
816
|
}
|
|
798
817
|
|
|
818
|
+
// The Effect Preset catalogue: a list asset Studio's Look group reads
|
|
819
|
+
// and the compositor resolves a Clip's preset against by name.
|
|
820
|
+
if (buildConfig.effects) {
|
|
821
|
+
compilers.push(createYamlCompiler('Effect', buildConfig.effects));
|
|
822
|
+
}
|
|
823
|
+
|
|
799
824
|
if (buildConfig.buttonGroups) {
|
|
800
825
|
compilers.push(new ButtonGroupCompiler(buildConfig.buttonGroups));
|
|
801
826
|
}
|
|
@@ -906,6 +931,12 @@ function assetsCommand(program) {
|
|
|
906
931
|
}
|
|
907
932
|
}
|
|
908
933
|
|
|
934
|
+
// Model binaries, before the catch-all copy: the generic pass skips
|
|
935
|
+
// `.json`, which a weight file is.
|
|
936
|
+
if (buildConfig.models) {
|
|
937
|
+
compilers.push(new CopyCompiler(buildConfig.models));
|
|
938
|
+
}
|
|
939
|
+
|
|
909
940
|
// Always add copy compiler for remaining files
|
|
910
941
|
compilers.push(new CopyCompiler(buildConfig.copy));
|
|
911
942
|
|
|
@@ -8,7 +8,6 @@ function configCiCommand(program) {
|
|
|
8
8
|
'Generate a GitHub Actions CI/CD pipeline: CI builds assets & web component, CD deploys to Magmonium'
|
|
9
9
|
)
|
|
10
10
|
.requiredOption('--app-id <id>', 'Magmonium app ID')
|
|
11
|
-
.requiredOption('--token <token>', 'Magmonium deploy token')
|
|
12
11
|
.option(
|
|
13
12
|
'--endpoint <url>',
|
|
14
13
|
'Magmonium API endpoint',
|
|
@@ -41,6 +40,7 @@ function configCiCommand(program) {
|
|
|
41
40
|
deployBranch: options.branch,
|
|
42
41
|
nodeVersion: detected.nodeVersion,
|
|
43
42
|
wcDistPath: detected.wcDistPath,
|
|
43
|
+
appId: options.appId,
|
|
44
44
|
endpoint: options.endpoint,
|
|
45
45
|
remoteYmlPath,
|
|
46
46
|
});
|
|
@@ -49,10 +49,10 @@ function configCiCommand(program) {
|
|
|
49
49
|
|
|
50
50
|
console.log(`Generated: ${workflowFile}`);
|
|
51
51
|
console.log('');
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
console.log(
|
|
55
|
-
console.log(
|
|
52
|
+
// The app id and endpoint are written into the workflow; neither is
|
|
53
|
+
// secret. The Deploy Token is the one secret, and is never printed.
|
|
54
|
+
console.log('Add this GitHub Secret to your repository:');
|
|
55
|
+
console.log(' MAG_DEPLOY_TOKEN = your personal deploy token');
|
|
56
56
|
console.log('');
|
|
57
57
|
console.log(
|
|
58
58
|
'Settings > Secrets and variables > Actions > New repository secret'
|
|
@@ -183,6 +183,8 @@ function buildCiWorkflow({
|
|
|
183
183
|
deployBranch,
|
|
184
184
|
nodeVersion,
|
|
185
185
|
wcDistPath,
|
|
186
|
+
appId,
|
|
187
|
+
endpoint,
|
|
186
188
|
remoteYmlPath,
|
|
187
189
|
}) {
|
|
188
190
|
const hasVersionCheck = Boolean(remoteYmlPath);
|
|
@@ -251,14 +253,11 @@ ${buildNeeds} runs-on: ubuntu-latest
|
|
|
251
253
|
- name: Install Magmonium CLI
|
|
252
254
|
run: npm install -g @magmonium/cli
|
|
253
255
|
- name: Deploy to Magmonium
|
|
254
|
-
run:
|
|
255
|
-
MAG_ENDPOINT="\${{ secrets.MAG_ENDPOINT }}"
|
|
256
|
-
MAG_ENDPOINT="\${MAG_ENDPOINT%/}"
|
|
257
|
-
mag-build deploy
|
|
256
|
+
run: mag-cli deploy
|
|
258
257
|
env:
|
|
259
|
-
MAG_APP_ID:
|
|
258
|
+
MAG_APP_ID: '${appId}'
|
|
260
259
|
MAG_DEPLOY_TOKEN: \${{ secrets.MAG_DEPLOY_TOKEN }}
|
|
261
|
-
MAG_ENDPOINT:
|
|
260
|
+
MAG_ENDPOINT: '${endpoint.replace(/\/+$/, '')}'
|
|
262
261
|
MAG_DIST_PATH: ${wcDistPath}
|
|
263
262
|
`;
|
|
264
263
|
}
|
|
@@ -13,12 +13,17 @@ function configureWcCommand(program) {
|
|
|
13
13
|
'--app-path <path>',
|
|
14
14
|
'Path to the app (e.g., apps/m-comics)'
|
|
15
15
|
)
|
|
16
|
+
.requiredOption('--app-id <id>', 'Magmonium app ID')
|
|
17
|
+
.option(
|
|
18
|
+
'--endpoint <url>',
|
|
19
|
+
'Magmonium API endpoint',
|
|
20
|
+
'https://api.magmonium.com'
|
|
21
|
+
)
|
|
16
22
|
.option('--force', 'Overwrite existing files')
|
|
17
23
|
.action((options) => {
|
|
18
24
|
try {
|
|
19
25
|
const appPath = options.appPath.replace(/\/$/, '');
|
|
20
26
|
const appName = path.basename(appPath);
|
|
21
|
-
const appNameUpper = appName.toUpperCase().replace(/-/g, '_');
|
|
22
27
|
|
|
23
28
|
console.log(`Configuring web component for: ${appName}`);
|
|
24
29
|
|
|
@@ -26,7 +31,7 @@ function configureWcCommand(program) {
|
|
|
26
31
|
createAppWcYaml(appPath, appName, options.force);
|
|
27
32
|
|
|
28
33
|
// 2. Create GitHub Actions CI/CD workflow
|
|
29
|
-
createWorkflow(appName,
|
|
34
|
+
createWorkflow(appName, options.appId, options.endpoint, options.force);
|
|
30
35
|
|
|
31
36
|
console.log('');
|
|
32
37
|
console.log('Done! Next steps:');
|
|
@@ -39,12 +44,10 @@ function configureWcCommand(program) {
|
|
|
39
44
|
);
|
|
40
45
|
console.log(` 3. Build & preview locally:`);
|
|
41
46
|
console.log(` npm run assets:compile`);
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
console.log(`
|
|
45
|
-
console.log(
|
|
46
|
-
` MAG_ENDPOINT (default: https://api.magmonium.com)`
|
|
47
|
-
);
|
|
47
|
+
// The app id and endpoint are written into the workflow; neither is
|
|
48
|
+
// secret. One Deploy Token serves every app the User deploys.
|
|
49
|
+
console.log(` 4. Add the GitHub Secret, once per repository:`);
|
|
50
|
+
console.log(` MAG_DEPLOY_TOKEN (your personal deploy token)`);
|
|
48
51
|
} catch (err) {
|
|
49
52
|
console.error(`configure-wc failed: ${err.message}`);
|
|
50
53
|
process.exit(1);
|
|
@@ -78,7 +81,7 @@ appConfigPath: ${appPath}/src/app/app.config
|
|
|
78
81
|
console.log(` [created] ${dest}`);
|
|
79
82
|
}
|
|
80
83
|
|
|
81
|
-
function createWorkflow(appName,
|
|
84
|
+
function createWorkflow(appName, appId, endpoint, force) {
|
|
82
85
|
const workflowDir = '.github/workflows';
|
|
83
86
|
const workflowFile = path.join(workflowDir, `${appName}-wc.yml`);
|
|
84
87
|
|
|
@@ -138,9 +141,9 @@ jobs:
|
|
|
138
141
|
- name: Deploy to Magmonium
|
|
139
142
|
run: |
|
|
140
143
|
mag-cli deploy \\
|
|
141
|
-
--app-id
|
|
144
|
+
--app-id ${appId} \\
|
|
142
145
|
--token \${{ secrets.MAG_DEPLOY_TOKEN }} \\
|
|
143
|
-
--endpoint
|
|
146
|
+
--endpoint ${endpoint.replace(/\/+$/, '')} \\
|
|
144
147
|
--dist-path ${wcDistPath}
|
|
145
148
|
`;
|
|
146
149
|
|
package/bin/commands/connect.js
CHANGED
|
@@ -8,7 +8,6 @@ function connectCommand(program) {
|
|
|
8
8
|
'Connect your Angular repository to Magmonium for automated deployment via GitHub Actions'
|
|
9
9
|
)
|
|
10
10
|
.requiredOption('--app-id <id>', 'Magmonium app ID')
|
|
11
|
-
.requiredOption('--token <token>', 'Magmonium deploy token')
|
|
12
11
|
.option(
|
|
13
12
|
'--endpoint <url>',
|
|
14
13
|
'Magmonium API endpoint',
|
|
@@ -39,16 +38,18 @@ function connectCommand(program) {
|
|
|
39
38
|
distPath: detected.distPath,
|
|
40
39
|
appRoot: detected.appRoot,
|
|
41
40
|
isNx: detected.isNx,
|
|
41
|
+
appId: options.appId,
|
|
42
|
+
endpoint: options.endpoint,
|
|
42
43
|
});
|
|
43
44
|
|
|
44
45
|
fs.writeFileSync(workflowFile, workflow, 'utf-8');
|
|
45
46
|
|
|
46
47
|
console.log(`Generated: ${workflowFile}`);
|
|
47
48
|
console.log('');
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
console.log(
|
|
51
|
-
console.log(
|
|
49
|
+
// The app id and endpoint are written into the workflow; neither is
|
|
50
|
+
// secret. The Deploy Token is the one secret, and is never printed.
|
|
51
|
+
console.log('Add this GitHub Secret to your repository:');
|
|
52
|
+
console.log(' MAG_DEPLOY_TOKEN = your personal deploy token');
|
|
52
53
|
console.log('');
|
|
53
54
|
console.log(
|
|
54
55
|
'Settings > Secrets and variables > Actions > New repository secret'
|
|
@@ -152,6 +153,8 @@ function buildWorkflow({
|
|
|
152
153
|
distPath,
|
|
153
154
|
appRoot,
|
|
154
155
|
isNx,
|
|
156
|
+
appId,
|
|
157
|
+
endpoint,
|
|
155
158
|
}) {
|
|
156
159
|
const appRootLine = appRoot ? ` working-directory: ${appRoot}\n` : '';
|
|
157
160
|
|
|
@@ -176,11 +179,11 @@ jobs:
|
|
|
176
179
|
${buildSteps} - name: Install Magmonium CLI
|
|
177
180
|
run: npm install -g @magmonium/cli
|
|
178
181
|
- name: Deploy to Magmonium
|
|
179
|
-
run: mag-
|
|
182
|
+
run: mag-cli deploy
|
|
180
183
|
env:
|
|
181
|
-
MAG_APP_ID:
|
|
184
|
+
MAG_APP_ID: '${appId}'
|
|
182
185
|
MAG_DEPLOY_TOKEN: \${{ secrets.MAG_DEPLOY_TOKEN }}
|
|
183
|
-
MAG_ENDPOINT:
|
|
186
|
+
MAG_ENDPOINT: '${endpoint.replace(/\/+$/, '')}'
|
|
184
187
|
MAG_DIST_PATH: ${distPath}
|
|
185
188
|
`;
|
|
186
189
|
}
|
package/bin/commands/deploy.js
CHANGED
|
@@ -3,38 +3,69 @@ const fs = require('fs');
|
|
|
3
3
|
const path = require('path');
|
|
4
4
|
const os = require('os');
|
|
5
5
|
|
|
6
|
+
const DEFAULT_ENDPOINT = 'https://api.magmonium.com';
|
|
7
|
+
const DESIGN_SOURCE_INDEX = '.magmonium/index.json';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* The Linked App's id and its Environment's Backend URL, as One UI wrote them
|
|
11
|
+
* into the design source — what a scaffold's `cd.yml` deploys with, so the
|
|
12
|
+
* Deploy Token is the one value left to supply.
|
|
13
|
+
*/
|
|
14
|
+
function readDesignSource() {
|
|
15
|
+
try {
|
|
16
|
+
const { appTarget } = JSON.parse(
|
|
17
|
+
fs.readFileSync(DESIGN_SOURCE_INDEX, 'utf-8')
|
|
18
|
+
);
|
|
19
|
+
return {
|
|
20
|
+
appId: appTarget?.appId,
|
|
21
|
+
endpoint: appTarget?.environment?.hosts?.backendUrl,
|
|
22
|
+
};
|
|
23
|
+
} catch {
|
|
24
|
+
return {};
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
6
28
|
function deployCommand(program) {
|
|
7
29
|
program
|
|
8
30
|
.command('deploy')
|
|
9
31
|
.description(
|
|
10
32
|
'Upload the built Angular bundle to Magmonium (run after build in CI/CD)'
|
|
11
33
|
)
|
|
12
|
-
.option(
|
|
34
|
+
.option(
|
|
35
|
+
'--app-id <id>',
|
|
36
|
+
`Magmonium app ID (overrides MAG_APP_ID env var, then ${DESIGN_SOURCE_INDEX})`
|
|
37
|
+
)
|
|
13
38
|
.option(
|
|
14
39
|
'--token <token>',
|
|
15
40
|
'Deploy token (overrides MAG_DEPLOY_TOKEN env var)'
|
|
16
41
|
)
|
|
17
42
|
.option(
|
|
18
43
|
'--endpoint <url>',
|
|
19
|
-
|
|
20
|
-
'https://api.magmonium.com'
|
|
44
|
+
`API endpoint (overrides MAG_ENDPOINT env var, then ${DESIGN_SOURCE_INDEX}; default ${DEFAULT_ENDPOINT})`
|
|
21
45
|
)
|
|
22
46
|
.option(
|
|
23
47
|
'--dist-path <path>',
|
|
24
48
|
'Built dist directory (overrides MAG_DIST_PATH env var)'
|
|
25
49
|
)
|
|
26
50
|
.action(async (options) => {
|
|
27
|
-
const
|
|
51
|
+
const designSource = readDesignSource();
|
|
52
|
+
const appId =
|
|
53
|
+
options.appId || process.env.MAG_APP_ID || designSource.appId;
|
|
28
54
|
const token = options.token || process.env.MAG_DEPLOY_TOKEN;
|
|
29
55
|
const endpoint = (
|
|
30
56
|
options.endpoint ||
|
|
31
57
|
process.env.MAG_ENDPOINT ||
|
|
32
|
-
|
|
33
|
-
|
|
58
|
+
designSource.endpoint ||
|
|
59
|
+
DEFAULT_ENDPOINT
|
|
60
|
+
)
|
|
61
|
+
.replace(/\/+$/, '')
|
|
62
|
+
.replace(/\/swagger\.json$/, '');
|
|
34
63
|
const distPath = options.distPath || process.env.MAG_DIST_PATH;
|
|
35
64
|
|
|
36
65
|
if (!appId) {
|
|
37
|
-
console.error(
|
|
66
|
+
console.error(
|
|
67
|
+
`Missing app ID. Set MAG_APP_ID, pass --app-id, or link the app in One UI and Push (${DESIGN_SOURCE_INDEX}).`
|
|
68
|
+
);
|
|
38
69
|
process.exit(1);
|
|
39
70
|
}
|
|
40
71
|
if (!token) {
|