@astryxdesign/cli 0.7.0-canary.450c68d → 0.7.0-canary.4ec1f4e
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 +30 -33
- package/api/doctor/doctor.doc.mjs +1 -1
- package/api/doctor/doctor.test.mjs +28 -0
- package/api/doctor/theme-checks.mjs +10 -10
- package/api/doctor/theme-checks.test.mjs +5 -4
- package/api/gap-report/gap-report.doc.mjs +1 -1
- package/api/gap-report/gap-report.mjs +15 -0
- package/api/gap-report/gap-report.test.mjs +1 -1
- package/api/index.d.mts +0 -2
- package/api/index.mjs +0 -2
- package/api/init/init.doc.mjs +5 -1
- package/api/init/init.mjs +22 -0
- package/api/init/init.type.d.mts +4 -1
- package/api/init/init.type.mjs +1 -1
- package/api/init/remove/remove.mjs +8 -3
- package/api/init/remove/remove.test.mjs +12 -0
- package/api/init/run/run.d.mts +1 -1
- package/api/init/run/run.mjs +3 -3
- package/api/integration/validate-integration.d.mts +4 -0
- package/api/integration/validate-integration.mjs +5 -2
- package/api/integration/validateIntegration.doc.mjs +1 -1
- package/api/json/index.ts +0 -1
- package/api/search/search.doc.mjs +1 -1
- package/api/search/search.mjs +1 -1
- package/api/search/search.test.mjs +1 -1
- package/api/search/search.type.d.mts +1 -1
- package/api/search/search.type.mjs +1 -1
- package/api/template/template-integration.test.mjs +37 -100
- package/api/template/template.doc.mjs +5 -1
- package/api/template/template.mjs +45 -0
- package/api/theme/_adapter.mjs +3 -3
- package/api/theme/add/add.d.mts +11 -5
- package/api/theme/add/add.mjs +19 -192
- package/api/theme/add/add.test.mjs +68 -258
- package/api/theme/add/add.types.test.mjs +0 -1
- package/api/theme/build/build.d.mts +3 -3
- package/api/theme/build/build.mjs +22 -36
- package/api/theme/build/build.test.mjs +11 -24
- package/api/theme/eject/eject.copy-compat.test.mjs +168 -0
- package/api/theme/integration-themes.test.mjs +3 -3
- package/api/theme/remove/remove.test.mjs +1 -1
- package/api/theme/targets/targets.test.mjs +0 -4
- package/api/theme/template/template.mjs +1 -1
- package/api/theme/theme.type.d.mts +1 -30
- package/api/theme/theme.type.mjs +3 -13
- package/api/theme/themeAdd.doc.mjs +19 -27
- package/api/theme/themeTargets.doc.mjs +3 -4
- package/api/theme/themeTemplate.doc.mjs +1 -1
- package/api/theme/use/use.test.mjs +1 -1
- package/api/upgrade/upgrade.doc.mjs +1 -1
- package/api/upgrade/upgrade.mjs +19 -0
- package/assets/codemods/transforms/next/README.md +15 -17
- package/assets/codemods/transforms/next/__tests__/migrate-deprecated-theme-surface.test.mjs +322 -0
- package/assets/codemods/transforms/next/index.mjs +11 -1
- package/assets/codemods/transforms/next/migrate-deprecated-theme-surface-v0.6-data.mjs +229 -0
- package/assets/codemods/transforms/next/migrate-deprecated-theme-surface.mjs +624 -0
- package/assets/codemods/transforms/v0.6.0/migrate-astryx-theme-selectors-to-data-attrs.mjs +38 -18
- package/assets/docs/author-a-theme.doc.mjs +1 -1
- package/assets/docs/getting-started.doc.mjs +2 -2
- package/assets/docs/theme.doc.dense.mjs +1 -1
- package/assets/docs/theme.doc.mjs +2 -2
- package/assets/docs/tree/add-a-theme.doc.mjs +1 -1
- package/assets/docs/tree/document-the-theme.doc.mjs +2 -2
- package/assets/docs/tree/fonts-and-assets.doc.mjs +3 -3
- package/assets/docs/tree/styling-advanced.doc.mjs +21 -14
- package/assets/docs/tree/themes.doc.mjs +1 -1
- package/assets/docs/tree/use-a-theme-in-an-app.doc.mjs +2 -2
- package/assets/docs/tree/versioning.doc.mjs +1 -4
- package/assets/docs/use-a-theme.doc.mjs +16 -16
- package/authoring/debug/type.ts +2 -2
- package/authoring/doctypes/base/type.ts +0 -9
- package/authoring/integration/integration.doc.mjs +1 -1
- package/clients/cli/command-result-coverage.test.mjs +1 -1
- package/clients/cli/commands/build-theme.adaptations.test.mjs +4 -0
- package/clients/cli/commands/build-theme.ascii-output.test.mjs +35 -8
- package/clients/cli/commands/build-theme.mjs +31 -67
- package/clients/cli/commands/build-theme.registry.test.mjs +0 -10
- package/clients/cli/commands/debug-result-summary.test.mjs +0 -16
- package/clients/cli/commands/discover.mjs +2 -1
- package/clients/cli/commands/doctor.mjs +5 -2
- package/clients/cli/commands/empty-argument.test.mjs +16 -0
- package/clients/cli/commands/gap-report.doc.mjs +1 -1
- package/clients/cli/commands/gap-report.test.mjs +2 -2
- package/clients/cli/commands/init.doc.mjs +4 -4
- package/clients/cli/commands/init.flag-help.test.mjs +7 -10
- package/clients/cli/commands/init.next-steps.test.mjs +1 -1
- package/clients/cli/commands/option-pair-refusals.test.mjs +37 -0
- package/clients/cli/commands/search.test.mjs +1 -1
- package/clients/cli/commands/swizzle.mjs +4 -1
- package/clients/cli/commands/template.doc.mjs +3 -3
- package/clients/cli/commands/template.flag-help.test.mjs +18 -11
- package/clients/cli/commands/template.mjs +7 -1
- package/clients/cli/commands/text-json-parity.test.mjs +0 -17
- package/clients/cli/commands/theme-add-lifecycle.test.mjs +142 -49
- package/clients/cli/commands/theme-add.doc.mjs +10 -17
- package/clients/cli/commands/theme-list.behavior.test.mjs +2 -1
- package/clients/cli/commands/theme-targets.behavior.test.mjs +8 -6
- package/clients/cli/commands/theme-template.doc.mjs +1 -1
- package/clients/cli/commands/theme.doc.mjs +2 -2
- package/clients/cli/commands/upgrade.doc.mjs +1 -1
- package/clients/cli/commands/upgrade.flag-help.test.mjs +7 -11
- package/clients/cli/commands/validate-nothing-exits-nonzero.test.mjs +67 -0
- package/clients/cli/index.mjs +0 -4
- package/clients/cli/lib/cli-error.mjs +19 -0
- package/clients/cli/lib/component-format.mjs +111 -57
- package/clients/cli/lib/component-format.test.mjs +28 -39
- package/clients/cli/lib/doc-text-ascii.test.mjs +5 -2
- package/clients/cli/lib/exit-codes.test.mjs +0 -7
- package/clients/cli/lib/json-shim.test.mjs +0 -24
- package/foundation/agent-docs/agent-docs.d.mts +2 -1
- package/foundation/agent-docs/agent-docs.mjs +6 -1
- package/foundation/agent-docs/app-theme-workflow.test.mjs +3 -0
- package/foundation/config/theme-state.mjs +3 -3
- package/foundation/debug/debug-fields.test.mjs +13 -35
- package/foundation/debug/event.mjs +13 -78
- package/foundation/debug/privacy-contract.test.mjs +20 -12
- package/foundation/debug/redact.d.mts +2 -2
- package/foundation/debug/redact.mjs +2 -2
- package/foundation/discovery/theme-imports.mjs +1 -1
- package/foundation/discovery/theming-targets.d.mts +1 -20
- package/foundation/discovery/theming-targets.mjs +1 -38
- package/foundation/discovery/theming-targets.test.mjs +9 -175
- package/foundation/doc-compiler/doc-loads.test.mjs +0 -12
- package/foundation/response/error-codes.doc.mjs +1 -1
- package/foundation/response/response-types.doc.mjs +11 -30
- package/foundation/response/response-types.doc.test.mjs +36 -14
- package/foundation/response/response.doc.mjs +1 -1
- package/foundation/xle/browser.d.mts +2 -2
- package/foundation/xle/browser.mjs +2 -2
- package/foundation/xle/expand.mjs +1 -1
- package/foundation/xle/print.mjs +1 -1
- package/package.json +9 -9
- package/api/layout/_adapter.d.mts +0 -34
- package/api/layout/_adapter.mjs +0 -148
- package/api/layout/check/check.d.mts +0 -17
- package/api/layout/check/check.mjs +0 -41
- package/api/layout/expand/expand.d.mts +0 -23
- package/api/layout/expand/expand.mjs +0 -161
- package/api/layout/expand/expand.path-safety.test.mjs +0 -53
- package/api/layout/expand/expand.receipt.test.mjs +0 -74
- package/api/layout/grammar/grammar.d.mts +0 -14
- package/api/layout/grammar/grammar.mjs +0 -88
- package/api/layout/layout.d.mts +0 -6
- package/api/layout/layout.mjs +0 -17
- package/api/layout/layout.test.mjs +0 -297
- package/api/layout/layout.type.d.mts +0 -90
- package/api/layout/layout.type.mjs +0 -104
- package/api/layout/layoutCheck.doc.d.mts +0 -11
- package/api/layout/layoutCheck.doc.mjs +0 -85
- package/api/layout/layoutExpand.doc.d.mts +0 -11
- package/api/layout/layoutExpand.doc.mjs +0 -107
- package/api/layout/layoutGrammar.doc.d.mts +0 -11
- package/api/layout/layoutGrammar.doc.mjs +0 -57
- package/api/theme/add/add.binary.test.mjs +0 -157
- package/api/theme/add/add.rollback.test.mjs +0 -158
- package/api/theme/add/add.staging.test.mjs +0 -83
- package/clients/cli/commands/layout-check.doc.mjs +0 -67
- package/clients/cli/commands/layout-expand.doc.mjs +0 -87
- package/clients/cli/commands/layout-grammar.doc.mjs +0 -32
- package/clients/cli/commands/layout.deprecation-lifecycle.test.mjs +0 -140
- package/clients/cli/commands/layout.doc.mjs +0 -36
- package/clients/cli/commands/layout.error-codes.test.mjs +0 -66
- package/clients/cli/commands/layout.exit-parity.test.mjs +0 -41
- package/clients/cli/commands/layout.expand-receipt.test.mjs +0 -94
- package/clients/cli/commands/layout.mjs +0 -327
- package/clients/cli/commands/layout.path-help.test.mjs +0 -33
- package/clients/cli/commands/layout.stdin-cap.test.mjs +0 -47
- package/clients/cli/commands/layout.text-fields.test.mjs +0 -39
|
@@ -6,9 +6,11 @@
|
|
|
6
6
|
* Thin CLI wrapper. The `build` compiler lives in the programmatic API
|
|
7
7
|
* (../../api/theme/build/build.mjs); `list`/`add` delegate to the
|
|
8
8
|
* ../../api/theme/list/list.mjs and ../../api/theme/add/add.mjs leaves. This
|
|
9
|
-
* file only parses options, injects a logger, renders human output,
|
|
10
|
-
* AstryxError → cliError
|
|
11
|
-
*
|
|
9
|
+
* file only parses options, injects a logger, renders human output, maps
|
|
10
|
+
* AstryxError → cliError, and turns reported private-variable errors into exit 1
|
|
11
|
+
* after preserving the build output. Watch mode (a human-interactive,
|
|
12
|
+
* long-running loop) stays here because it re-invokes `theme build` as a child
|
|
13
|
+
* process.
|
|
12
14
|
*
|
|
13
15
|
* The command surface (group + subcommand descriptions, args, flags) is sourced
|
|
14
16
|
* from the colocated CommandDocs via `defineCommand`; this file supplies only
|
|
@@ -62,7 +64,6 @@ import {
|
|
|
62
64
|
themePaletteGenerate,
|
|
63
65
|
} from '../../../api/theme/palette/generate/generate.mjs';
|
|
64
66
|
import {
|
|
65
|
-
importSpecifier,
|
|
66
67
|
printBatchTrailer,
|
|
67
68
|
printCompactTrailer,
|
|
68
69
|
themeBuild,
|
|
@@ -230,8 +231,8 @@ async function warnOnThemeIntegrationIssues(json) {
|
|
|
230
231
|
}
|
|
231
232
|
|
|
232
233
|
/**
|
|
233
|
-
* Print `theme add --list`. Its JSON stays the released
|
|
234
|
-
*
|
|
234
|
+
* Print cleanup-stage `theme add --list`. Its JSON stays the released
|
|
235
|
+
* `theme.list`; its text names the cleanup commands (AST-050 FR12).
|
|
235
236
|
* @param {import('../../../api/theme/theme.type.mjs').ThemeListEntry[]} themes
|
|
236
237
|
*/
|
|
237
238
|
function printThemeAddList(themes) {
|
|
@@ -255,7 +256,7 @@ function printThemeAddList(themes) {
|
|
|
255
256
|
}),
|
|
256
257
|
),
|
|
257
258
|
text(
|
|
258
|
-
`Import one: ${run} theme add <slug>
|
|
259
|
+
`Import one: ${run} theme add <slug> [--package <package>]\n` +
|
|
259
260
|
`Fork source: ${run} theme eject <slug> [target-path]`,
|
|
260
261
|
),
|
|
261
262
|
more,
|
|
@@ -297,7 +298,7 @@ function printThemeList(themes, unmigratedCopies = []) {
|
|
|
297
298
|
},
|
|
298
299
|
}),
|
|
299
300
|
text(
|
|
300
|
-
`Import one: ${run} theme add <slug>
|
|
301
|
+
`Import one: ${run} theme add <slug> [--package <package>]\n` +
|
|
301
302
|
`Fork source: ${run} theme eject <slug> [target-path]`,
|
|
302
303
|
),
|
|
303
304
|
more,
|
|
@@ -633,6 +634,10 @@ export function registerTheme(program) {
|
|
|
633
634
|
// [ok]/[warn] lines, and the install instructions are all emitted from
|
|
634
635
|
// inside themeBuild via the shared logger.
|
|
635
636
|
logger.setSilent(json);
|
|
637
|
+
let privateVarError = false;
|
|
638
|
+
const onPrivateVarError = () => {
|
|
639
|
+
privateVarError = true;
|
|
640
|
+
};
|
|
636
641
|
|
|
637
642
|
if (options.family) {
|
|
638
643
|
try {
|
|
@@ -642,11 +647,15 @@ export function registerTheme(program) {
|
|
|
642
647
|
familyKey: /** @type {string} */ (options.familyKey),
|
|
643
648
|
check: options.check,
|
|
644
649
|
iconsSpecifier: options.iconsSpecifier,
|
|
650
|
+
__onPrivateVarError: onPrivateVarError,
|
|
645
651
|
},
|
|
646
652
|
{cwd: process.cwd()},
|
|
647
653
|
);
|
|
648
654
|
if (json) jsonOut(result);
|
|
649
|
-
if (
|
|
655
|
+
if (
|
|
656
|
+
privateVarError ||
|
|
657
|
+
(result.type === 'theme.build.check' && !result.data.upToDate)
|
|
658
|
+
) {
|
|
650
659
|
process.exitCode = 1;
|
|
651
660
|
}
|
|
652
661
|
return NO_RESULT_SET;
|
|
@@ -674,6 +683,7 @@ export function registerTheme(program) {
|
|
|
674
683
|
out: options.out,
|
|
675
684
|
check: options.check,
|
|
676
685
|
iconsSpecifier: options.iconsSpecifier,
|
|
686
|
+
__onPrivateVarError: onPrivateVarError,
|
|
677
687
|
};
|
|
678
688
|
let result;
|
|
679
689
|
if (report) {
|
|
@@ -753,10 +763,10 @@ export function registerTheme(program) {
|
|
|
753
763
|
);
|
|
754
764
|
}
|
|
755
765
|
|
|
756
|
-
//
|
|
757
|
-
//
|
|
758
|
-
//
|
|
759
|
-
if (options.check && stale) {
|
|
766
|
+
// Private-variable diagnostics are build failures even though the released
|
|
767
|
+
// output and generated files stay unchanged. Stale --check output is also
|
|
768
|
+
// a failure after its receipt has been emitted.
|
|
769
|
+
if (privateVarError || (options.check && stale)) {
|
|
760
770
|
process.exitCode = 1;
|
|
761
771
|
}
|
|
762
772
|
|
|
@@ -801,15 +811,14 @@ export function registerTheme(program) {
|
|
|
801
811
|
},
|
|
802
812
|
});
|
|
803
813
|
|
|
804
|
-
defineCommand(theme, themeAddCommand, {
|
|
814
|
+
const themeAddCli = defineCommand(theme, themeAddCommand, {
|
|
805
815
|
fn: themeAddFn,
|
|
806
816
|
action: async (
|
|
807
817
|
/** @type {string | undefined} */ slug,
|
|
808
|
-
/** @type {
|
|
809
|
-
/** @type {{list?: boolean, overwrite?: boolean, import?: boolean, package?: string}} */ options,
|
|
818
|
+
/** @type {{list?: boolean, import?: boolean, package?: string}} */ options,
|
|
810
819
|
) => {
|
|
811
820
|
const json = program.opts().json || false;
|
|
812
|
-
/** @type {import('../../../api/theme/theme.type.mjs').ThemeListResponse | import('../../../api/theme/theme.type.mjs').
|
|
821
|
+
/** @type {import('../../../api/theme/theme.type.mjs').ThemeListResponse | import('../../../api/theme/theme.type.mjs').ThemeAppResponse} */
|
|
813
822
|
let result;
|
|
814
823
|
try {
|
|
815
824
|
result =
|
|
@@ -819,8 +828,6 @@ export function registerTheme(program) {
|
|
|
819
828
|
package: options.package,
|
|
820
829
|
})
|
|
821
830
|
: await themeAdd(slug, {
|
|
822
|
-
targetPath,
|
|
823
|
-
overwrite: options.overwrite,
|
|
824
831
|
import: options.import,
|
|
825
832
|
cwd: process.cwd(),
|
|
826
833
|
package: options.package,
|
|
@@ -848,44 +855,12 @@ export function registerTheme(program) {
|
|
|
848
855
|
printThemeAddList(result.data);
|
|
849
856
|
return answered;
|
|
850
857
|
}
|
|
851
|
-
|
|
852
|
-
printThemeApp(result);
|
|
853
|
-
return answered;
|
|
854
|
-
}
|
|
855
|
-
|
|
856
|
-
const {
|
|
857
|
-
displayName,
|
|
858
|
-
outputDir,
|
|
859
|
-
entry,
|
|
860
|
-
exportName,
|
|
861
|
-
files,
|
|
862
|
-
package: owner,
|
|
863
|
-
} = result.data;
|
|
864
|
-
const entryModule = importSpecifier(
|
|
865
|
-
outputDir,
|
|
866
|
-
entry.replace(/\.tsx?$/, ''),
|
|
867
|
-
);
|
|
868
|
-
emit(
|
|
869
|
-
text(`[ok] Added ${displayName} theme from ${owner} to ${outputDir}/`),
|
|
870
|
-
list(files.map(file => `${outputDir}/${file}`)),
|
|
871
|
-
text(
|
|
872
|
-
'Use it in your app (import path is relative to a file in src/ — adjust if yours lives elsewhere):',
|
|
873
|
-
),
|
|
874
|
-
code(
|
|
875
|
-
"import { Theme } from '@astryxdesign/core';\n" +
|
|
876
|
-
`import { ${exportName} } from '${entryModule}';\n\n` +
|
|
877
|
-
`<Theme theme={${exportName}}>\n <App />\n</Theme>`,
|
|
878
|
-
),
|
|
879
|
-
text(
|
|
880
|
-
`This is your copy of the ${displayName} theme — edit ${entry} to make it your own.`,
|
|
881
|
-
),
|
|
882
|
-
);
|
|
883
|
-
console.error(
|
|
884
|
-
`Warning: \`theme add\` source copying is deprecated (DEP-0005). Run \`${getCliInvocation()} theme eject ${result.data.slug}\` to fork source or \`${getCliInvocation()} theme add ${result.data.slug} --import\` to use the built theme.`,
|
|
885
|
-
);
|
|
858
|
+
printThemeApp(result);
|
|
886
859
|
return answered;
|
|
887
860
|
},
|
|
888
861
|
});
|
|
862
|
+
// Reject the removed target-path argument in Commander's standard parse path.
|
|
863
|
+
themeAddCli.allowExcessArguments(false);
|
|
889
864
|
|
|
890
865
|
defineCommand(theme, themeRemoveCommand, {
|
|
891
866
|
fn: themeRemoveFn,
|
|
@@ -1062,22 +1037,11 @@ export function registerTheme(program) {
|
|
|
1062
1037
|
emit(
|
|
1063
1038
|
section(
|
|
1064
1039
|
'Theming targets',
|
|
1065
|
-
`${targets.length} across ${componentCount} component${componentCount === 1 ? '' : 's'}\n(key - component - props - states - className
|
|
1040
|
+
`${targets.length} across ${componentCount} component${componentCount === 1 ? '' : 's'}\n(key - component - props - states - className)`,
|
|
1066
1041
|
),
|
|
1067
1042
|
records(targets, {
|
|
1068
|
-
fields: [
|
|
1069
|
-
'key',
|
|
1070
|
-
'component',
|
|
1071
|
-
'props',
|
|
1072
|
-
'states',
|
|
1073
|
-
'className',
|
|
1074
|
-
'deprecatedFor',
|
|
1075
|
-
],
|
|
1043
|
+
fields: ['key', 'component', 'props', 'states', 'className'],
|
|
1076
1044
|
layout: 'inline',
|
|
1077
|
-
format: {
|
|
1078
|
-
deprecatedFor: (/** @type {string|null} */ v) =>
|
|
1079
|
-
v ? `deprecated; use ${v}` : '',
|
|
1080
|
-
},
|
|
1081
1045
|
}),
|
|
1082
1046
|
text(
|
|
1083
1047
|
[
|
|
@@ -83,16 +83,6 @@ function renderedClassLiterals() {
|
|
|
83
83
|
while ((sm = surfaceRe.exec(text)) !== null) {
|
|
84
84
|
classes.add(sm[1]);
|
|
85
85
|
}
|
|
86
|
-
// Renamed targets emit their old name too, via themeProps'
|
|
87
|
-
// `legacyNames`. Those classes are just as rendered as the primary
|
|
88
|
-
// one, so a doc entry for the old name is still backed by real output.
|
|
89
|
-
const legacyRe = /legacyNames:\s*\[([^\]]*)\]/g;
|
|
90
|
-
let lm;
|
|
91
|
-
while ((lm = legacyRe.exec(text)) !== null) {
|
|
92
|
-
for (const nm of lm[1].matchAll(/'([^']+)'/g)) {
|
|
93
|
-
classes.add(nm[1]);
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
86
|
}
|
|
97
87
|
}
|
|
98
88
|
};
|
|
@@ -176,22 +176,6 @@ describe('DebugEvent result summary', () => {
|
|
|
176
176
|
SLOW,
|
|
177
177
|
);
|
|
178
178
|
|
|
179
|
-
it(
|
|
180
|
-
'says so explicitly when a command has no result set',
|
|
181
|
-
async () => {
|
|
182
|
-
// `layout check` returns a verdict on one expression: nothing was looked
|
|
183
|
-
// up, and the run says that rather than leaving four ambiguous nulls.
|
|
184
|
-
const {event} = await runWithDebug(['layout', 'check', 'VStack>Text']);
|
|
185
|
-
expect(event.output).toMatchObject({
|
|
186
|
-
resultKind: 'none',
|
|
187
|
-
resultCount: null,
|
|
188
|
-
emptyResult: null,
|
|
189
|
-
directMatch: null,
|
|
190
|
-
});
|
|
191
|
-
},
|
|
192
|
-
SLOW,
|
|
193
|
-
);
|
|
194
|
-
|
|
195
179
|
it(
|
|
196
180
|
'only claims a direct match when the filter resolved one component',
|
|
197
181
|
async () => {
|
|
@@ -26,7 +26,7 @@ import {
|
|
|
26
26
|
list,
|
|
27
27
|
code,
|
|
28
28
|
} from '../formatters/index.mjs';
|
|
29
|
-
import {cliError} from '../lib/cli-error.mjs';
|
|
29
|
+
import {cliError, rejectEmptyArgument} from '../lib/cli-error.mjs';
|
|
30
30
|
import {discover as discoverApi} from '../../../api/discover/discover.mjs';
|
|
31
31
|
import {Project} from '../../../foundation/config/project.mjs';
|
|
32
32
|
import {warnOnIntegrationIssues} from '../../../foundation/integrations/integration-warnings.mjs';
|
|
@@ -212,6 +212,7 @@ export function registerDiscover(program) {
|
|
|
212
212
|
* @param {{components?: boolean, type?: string, installed?: boolean, available?: boolean, limit?: string}} options
|
|
213
213
|
*/
|
|
214
214
|
async (query, options) => {
|
|
215
|
+
rejectEmptyArgument('query', query, 'astryx discover');
|
|
215
216
|
const detail = program.opts().detail || 'full';
|
|
216
217
|
const json = program.opts().json || false;
|
|
217
218
|
const lang = program.opts().lang || null;
|
|
@@ -259,10 +259,13 @@ async function runIntegrationValidation(program, pkg) {
|
|
|
259
259
|
const result = await validateIntegration(pkg);
|
|
260
260
|
if (program.opts().json) jsonOut(result);
|
|
261
261
|
else if (!result.data.validated) {
|
|
262
|
+
const noPackage = result.data.issues.some(i => i.code === 'no_package');
|
|
262
263
|
emit(
|
|
263
264
|
text(
|
|
264
|
-
|
|
265
|
-
'
|
|
265
|
+
noPackage
|
|
266
|
+
? 'Nothing was validated: no package.json found. Run this command inside a package directory.'
|
|
267
|
+
: 'Nothing was validated: no astryx.integration.* found next to package.json. ' +
|
|
268
|
+
'To validate an installed integration: astryx doctor integration validate <package>',
|
|
266
269
|
),
|
|
267
270
|
);
|
|
268
271
|
} else printIntegrationValidation(result.data);
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
import {describe, it, expect, beforeEach, afterEach} from 'vitest';
|
|
3
|
+
import * as fs from 'node:fs'; import * as os from 'node:os'; import * as path from 'node:path';
|
|
4
|
+
import {runCli} from '../../../test-utils/run-cli.mjs';
|
|
5
|
+
let dir;
|
|
6
|
+
beforeEach(() => { dir = fs.mkdtempSync(path.join(os.tmpdir(), 'astryx-ea-')); fs.writeFileSync(path.join(dir, 'package.json'), JSON.stringify({name:'s',version:'1.0.0',dependencies:{'@astryxdesign/core':'0.6.3'}})); fs.mkdirSync(path.join(dir,'src'),{recursive:true}); const c=path.join(dir,'node_modules','@astryxdesign','core'); fs.mkdirSync(c,{recursive:true}); fs.writeFileSync(path.join(c,'package.json'),JSON.stringify({name:'@astryxdesign/core',version:'0.6.3'})); });
|
|
7
|
+
afterEach(() => fs.rmSync(dir, {recursive:true,force:true}));
|
|
8
|
+
const json = async a => { const {status,stdout}=await runCli(['--json',...a],{cwd:dir}); return {status,body:JSON.parse(stdout)}; };
|
|
9
|
+
describe('an empty-string argument is rejected, not ignored', () => {
|
|
10
|
+
it.each([['template',['template','','src/z.tsx'],'name'],['template path',['template','ai-chat',''],'path'],['swizzle',['swizzle',''],'component'],['discover',['discover',''],'query']])('%s', async (_,args,an) => { const {status,body}=await json(args); expect(status).toBe(1); expect(body.code).toBe('ERR_INVALID_ARGUMENT'); expect(body.error).toContain(`<${an}>`); });
|
|
11
|
+
it('writes nothing', async () => { const b=fs.readdirSync(path.join(dir,'src')); await json(['template','ai-chat','']); expect(fs.readdirSync(path.join(dir,'src'))).toEqual(b); });
|
|
12
|
+
it('exits same without --json', async () => { const {status,stderr}=await runCli(['template','','src/z.tsx'],{cwd:dir}); expect(status).toBe(1); expect(stderr).toContain('<name>'); });
|
|
13
|
+
it('ignoring modes pass', async () => { for (const [a,t] of [[['template','','--list'],'template.list'],[['template','','--cdn'],'template.cdn'],[['template','ai-chat','','--skeleton'],'template.skeleton'],[['swizzle','','--list'],'swizzle.list']]) { const {status,body}=await json(a); expect(status).toBe(0); expect(body.type).toBe(t); } });
|
|
14
|
+
it('bare --cdn empty path rejected', async () => { const {status,body}=await json(['template','ai-chat','','--cdn']); expect(status).toBe(1); expect(body.code).toBe('ERR_INVALID_ARGUMENT'); });
|
|
15
|
+
it('omitted lists', async () => { for (const [a,t] of [[['template','--list'],'template.list'],[['discover'],'discover.list'],[['swizzle','--list'],'swizzle.list']]) { const {status,body}=await json(a); expect(status).toBe(0); expect(body.type).toBe(t); } });
|
|
16
|
+
});
|
|
@@ -61,7 +61,7 @@ export const doc = {
|
|
|
61
61
|
flag: '--list-categories',
|
|
62
62
|
param: 'options.listCategories',
|
|
63
63
|
description:
|
|
64
|
-
'List valid report categories without filing; the component and the other gap-report options are
|
|
64
|
+
'List valid report categories without filing; the component and the other gap-report options are refused with ERR_INVALID_ARGUMENT',
|
|
65
65
|
},
|
|
66
66
|
],
|
|
67
67
|
examples: [
|
|
@@ -282,7 +282,7 @@ describe('gap-report control docs', () => {
|
|
|
282
282
|
expect(help.stdout).toContain(text);
|
|
283
283
|
}
|
|
284
284
|
expect(option('--list-categories')).toContain(
|
|
285
|
-
'the component and the other gap-report options are
|
|
285
|
+
'the component and the other gap-report options are refused with ERR_INVALID_ARGUMENT',
|
|
286
286
|
);
|
|
287
287
|
|
|
288
288
|
const cwd = fs.mkdtempSync(path.join(os.tmpdir(), 'astryx-gap-limits-'));
|
|
@@ -328,6 +328,6 @@ describe('gap-report control docs', () => {
|
|
|
328
328
|
}
|
|
329
329
|
await expect(
|
|
330
330
|
gapReport(undefined, {listCategories: true, category: 'not_real', package: 'nope'}),
|
|
331
|
-
).
|
|
331
|
+
).rejects.toMatchObject({code: 'ERR_INVALID_ARGUMENT'});
|
|
332
332
|
});
|
|
333
333
|
});
|
|
@@ -27,13 +27,13 @@ export const doc = {
|
|
|
27
27
|
param: 'options.features',
|
|
28
28
|
description:
|
|
29
29
|
'Comma-separated features: agents (agent docs), theme (writes theme.template.ts), template (prints the page-building commands; writes no file). ' +
|
|
30
|
-
'An unknown feature exits 1 with ERR_UNKNOWN_FEATURE.
|
|
30
|
+
'An unknown feature exits 1 with ERR_UNKNOWN_FEATURE. Refused with --all or --remove-agents',
|
|
31
31
|
},
|
|
32
32
|
{
|
|
33
33
|
flag: '--all',
|
|
34
34
|
param: 'options.all',
|
|
35
35
|
description:
|
|
36
|
-
'Install all features (agents, theme, template);
|
|
36
|
+
'Install all features (agents, theme, template); refused with --features. Prints their guidance instead of the getting-started steps',
|
|
37
37
|
},
|
|
38
38
|
{
|
|
39
39
|
flag: '--remove-agents',
|
|
@@ -41,7 +41,7 @@ export const doc = {
|
|
|
41
41
|
description:
|
|
42
42
|
'Remove the managed block from AGENTS.md, CLAUDE.md, .claude/CLAUDE.md, .cursorrules, .hermes.md and HERMES.md ' +
|
|
43
43
|
"(deleting AGENTS.md or .claude/CLAUDE.md when only init's heading is left) and do nothing else. " +
|
|
44
|
-
'--features, --all, --agent and --agent-docs-path are
|
|
44
|
+
'--features, --all, --agent and --agent-docs-path are refused; a file written with --agent-docs-path keeps its block',
|
|
45
45
|
},
|
|
46
46
|
{
|
|
47
47
|
flag: '--agent <tool>',
|
|
@@ -74,7 +74,7 @@ export const doc = {
|
|
|
74
74
|
},
|
|
75
75
|
{
|
|
76
76
|
code: 1,
|
|
77
|
-
when: 'an unknown --agent or feature,
|
|
77
|
+
when: 'an unknown --agent or feature, an --agent-docs-path outside the project, --remove-agents combined with install options, or --all with --features (ERR_INVALID_ARGUMENT)',
|
|
78
78
|
},
|
|
79
79
|
],
|
|
80
80
|
related: ['doctor', 'upgrade', 'build', 'theme'],
|
|
@@ -66,7 +66,7 @@ describe('astryx init flag interactions', () => {
|
|
|
66
66
|
for (const file of ['AGENTS.md', '.claude/CLAUDE.md', '.cursorrules', '.hermes.md', 'HERMES.md']) {
|
|
67
67
|
expect(help).toContain(file);
|
|
68
68
|
}
|
|
69
|
-
expect(help).toMatch(/--agent-docs-path
|
|
69
|
+
expect(help).toMatch(/--agent-docs-path are refused/);
|
|
70
70
|
|
|
71
71
|
await initJson(['--agent-docs-path', 'docs/AI.md']);
|
|
72
72
|
await initJson([]);
|
|
@@ -82,22 +82,19 @@ describe('astryx init flag interactions', () => {
|
|
|
82
82
|
'--agent-docs-path',
|
|
83
83
|
'docs/AI.md',
|
|
84
84
|
]);
|
|
85
|
-
expect(removed.status).toBe(
|
|
86
|
-
expect(removed.envelope.
|
|
87
|
-
expect(exists('AGENTS.md')).toBe(false);
|
|
88
|
-
expect(exists('theme.template.ts')).toBe(false);
|
|
89
|
-
expect(read('docs/AI.md')).toContain(MARKER_START);
|
|
85
|
+
expect(removed.status).toBe(1);
|
|
86
|
+
expect(removed.envelope.code).toBe('ERR_INVALID_ARGUMENT');
|
|
90
87
|
});
|
|
91
88
|
|
|
92
89
|
it('--all: help says it overrides --features, and an unknown feature beside it is not checked', async () => {
|
|
93
90
|
const options = await initOptions();
|
|
94
|
-
expect(options['--all']).toMatch(/
|
|
95
|
-
expect(options['--features']).toMatch(/
|
|
91
|
+
expect(options['--all']).toMatch(/refused with --features/);
|
|
92
|
+
expect(options['--features']).toMatch(/Refused with --all or --remove-agents/);
|
|
96
93
|
expect(options['--features']).toContain('ERR_UNKNOWN_FEATURE');
|
|
97
94
|
|
|
98
95
|
const {status, envelope} = await initJson(['--all', '--features', 'bogus']);
|
|
99
|
-
expect(status).toBe(
|
|
100
|
-
expect(envelope.
|
|
96
|
+
expect(status).toBe(1);
|
|
97
|
+
expect(envelope.code).toBe('ERR_INVALID_ARGUMENT');
|
|
101
98
|
});
|
|
102
99
|
|
|
103
100
|
it('--agent and --agent-docs-path: help states their scope and precedence, and the CLI follows it', async () => {
|
|
@@ -21,7 +21,7 @@ describe('init Next steps theme guidance', () => {
|
|
|
21
21
|
|
|
22
22
|
it('adds an installed theme through the CLI', () => {
|
|
23
23
|
expect(text).toContain('npm install @astryxdesign/theme-neutral');
|
|
24
|
-
expect(text).toContain('npx astryx theme add neutral
|
|
24
|
+
expect(text).toContain('npx astryx theme add neutral');
|
|
25
25
|
});
|
|
26
26
|
|
|
27
27
|
it('wires the generated theme record once', () => {
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
import {describe, it, expect, beforeEach, afterEach} from 'vitest';
|
|
3
|
+
import * as fs from 'node:fs'; import * as os from 'node:os'; import * as path from 'node:path';
|
|
4
|
+
import {runCli} from '../../../test-utils/run-cli.mjs';
|
|
5
|
+
let dir;
|
|
6
|
+
beforeEach(() => { dir = fs.mkdtempSync(path.join(os.tmpdir(),'astryx-op-')); fs.writeFileSync(path.join(dir,'package.json'),JSON.stringify({name:'s',version:'1.0.0',dependencies:{'@astryxdesign/core':'0.6.3'}})); const c=path.join(dir,'node_modules','@astryxdesign','core'); fs.mkdirSync(c,{recursive:true}); fs.writeFileSync(path.join(c,'package.json'),JSON.stringify({name:'@astryxdesign/core',version:'0.6.3'})); });
|
|
7
|
+
afterEach(() => fs.rmSync(dir, {recursive:true,force:true}));
|
|
8
|
+
const json = async a => { const {status,stdout}=await runCli(['--json',...a],{cwd:dir}); return {status,body:JSON.parse(stdout)}; };
|
|
9
|
+
describe('option-pair refusals (AST-042 FR5)', () => {
|
|
10
|
+
it('template --list + name', async () => { const {status,body}=await json(['template','ai-chat','--list']); expect(status).toBe(1); expect(body.code).toBe('ERR_INVALID_ARGUMENT'); });
|
|
11
|
+
it('template --list + path', async () => { const {status,body}=await json(['template','ai-chat','src/p.tsx','--list']); expect(status).toBe(1); expect(body.code).toBe('ERR_INVALID_ARGUMENT'); });
|
|
12
|
+
it('template --list + --skeleton', async () => { const {status,body}=await json(['template','--list','--skeleton']); expect(status).toBe(1); expect(body.code).toBe('ERR_INVALID_ARGUMENT'); });
|
|
13
|
+
it('template --cdn + --list', async () => { const {status,body}=await json(['template','--cdn','--list']); expect(status).toBe(1); expect(body.code).toBe('ERR_INVALID_ARGUMENT'); });
|
|
14
|
+
it('template --cdn + name', async () => { const {status,body}=await json(['template','ai-chat','--cdn']); expect(status).toBe(1); expect(body.code).toBe('ERR_INVALID_ARGUMENT'); });
|
|
15
|
+
it('template --cdn + --type', async () => { const {status,body}=await json(['template','--cdn','--type','page']); expect(status).toBe(1); expect(body.code).toBe('ERR_INVALID_ARGUMENT'); });
|
|
16
|
+
it('template --cdn + --package', async () => { const {status,body}=await json(['template','--cdn','--package','@astryxdesign/core']); expect(status).toBe(1); expect(body.code).toBe('ERR_INVALID_ARGUMENT'); });
|
|
17
|
+
it('template --skeleton + --overwrite', async () => { const {status,body}=await json(['template','ai-chat','--skeleton','--overwrite']); expect(status).toBe(1); expect(body.code).toBe('ERR_INVALID_ARGUMENT'); });
|
|
18
|
+
it('upgrade --list + --from', async () => { const {status,body}=await json(['upgrade','--list','--from','0.5.0']); expect(status).toBe(1); expect(body.code).toBe('ERR_INVALID_ARGUMENT'); });
|
|
19
|
+
it('upgrade --list + --force', async () => { const {status,body}=await json(['upgrade','--list','--force']); expect(status).toBe(1); expect(body.code).toBe('ERR_INVALID_ARGUMENT'); });
|
|
20
|
+
it('upgrade --list + --apply', async () => { const {status,body}=await json(['upgrade','--list','--apply']); expect(status).toBe(1); expect(body.code).toBe('ERR_INVALID_ARGUMENT'); });
|
|
21
|
+
it('upgrade --list + --path', async () => { const {status,body}=await json(['upgrade','--list','--path','../x']); expect(status).toBe(1); expect(body.code).toBe('ERR_INVALID_ARGUMENT'); });
|
|
22
|
+
it('upgrade --list + --codemod', async () => { const {status,body}=await json(['upgrade','--list','--codemod','x']); expect(status).toBe(1); expect(body.code).toBe('ERR_INVALID_ARGUMENT'); });
|
|
23
|
+
it('upgrade --list + --skip-codemod', async () => { const {status,body}=await json(['upgrade','--list','--skip-codemod','x']); expect(status).toBe(1); expect(body.code).toBe('ERR_INVALID_ARGUMENT'); });
|
|
24
|
+
it('upgrade --list + --integration', async () => { const {status,body}=await json(['upgrade','--list','--integration','@acme/x']); expect(status).toBe(1); expect(body.code).toBe('ERR_INVALID_ARGUMENT'); });
|
|
25
|
+
it('upgrade --list + --install-deps', async () => { const {status,body}=await json(['upgrade','--list','--install-deps']); expect(status).toBe(1); expect(body.code).toBe('ERR_INVALID_ARGUMENT'); });
|
|
26
|
+
it('init --remove-agents + --features', async () => { const {status,body}=await json(['init','--remove-agents','--features','agents']); expect(status).toBe(1); expect(body.code).toBe('ERR_INVALID_ARGUMENT'); });
|
|
27
|
+
it('init --remove-agents + --all', async () => { const {status,body}=await json(['init','--remove-agents','--all']); expect(status).toBe(1); expect(body.code).toBe('ERR_INVALID_ARGUMENT'); });
|
|
28
|
+
it('init --remove-agents + --agent', async () => { const {status,body}=await json(['init','--remove-agents','--agent','claude']); expect(status).toBe(1); expect(body.code).toBe('ERR_INVALID_ARGUMENT'); });
|
|
29
|
+
it('init --remove-agents + --agent-docs-path', async () => { const {status,body}=await json(['init','--remove-agents','--agent-docs-path','docs/AI.md']); expect(status).toBe(1); expect(body.code).toBe('ERR_INVALID_ARGUMENT'); });
|
|
30
|
+
it('init --all + --features', async () => { const {status,body}=await json(['init','--all','--features','agents']); expect(status).toBe(1); expect(body.code).toBe('ERR_INVALID_ARGUMENT'); });
|
|
31
|
+
it('gap-report --list-categories + component', async () => { const {status,body}=await json(['gap-report','Button','--list-categories']); expect(status).toBe(1); expect(body.code).toBe('ERR_INVALID_ARGUMENT'); });
|
|
32
|
+
it('gap-report --list-categories + --category', async () => { const {status,body}=await json(['gap-report','--list-categories','--category','docs_gap']); expect(status).toBe(1); expect(body.code).toBe('ERR_INVALID_ARGUMENT'); });
|
|
33
|
+
it('gap-report --list-categories + --reason', async () => { const {status,body}=await json(['gap-report','--list-categories','--reason','test']); expect(status).toBe(1); expect(body.code).toBe('ERR_INVALID_ARGUMENT'); });
|
|
34
|
+
it('gap-report --list-categories + --package', async () => { const {status,body}=await json(['gap-report','--list-categories','--package','@acme/x']); expect(status).toBe(1); expect(body.code).toBe('ERR_INVALID_ARGUMENT'); });
|
|
35
|
+
it('gap-report --list-categories + --additional-context', async () => { const {status,body}=await json(['gap-report','--list-categories','--additional-context','extra']); expect(status).toBe(1); expect(body.code).toBe('ERR_INVALID_ARGUMENT'); });
|
|
36
|
+
it('gap-report --list-categories + --confirm-public', async () => { const {status,body}=await json(['gap-report','--list-categories','--confirm-public']); expect(status).toBe(1); expect(body.code).toBe('ERR_INVALID_ARGUMENT'); });
|
|
37
|
+
});
|
|
@@ -127,7 +127,7 @@ describe('search() API — filters', () => {
|
|
|
127
127
|
expect(data.results.map(r => r.name)).toContain('neutral');
|
|
128
128
|
for (const r of data.results) {
|
|
129
129
|
expect(r.domain).toBe('theme');
|
|
130
|
-
expect(r.command).toBe(`astryx theme add
|
|
130
|
+
expect(r.command).toBe(`astryx theme add ${r.name}`);
|
|
131
131
|
}
|
|
132
132
|
});
|
|
133
133
|
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
|
|
13
13
|
import {jsonOut} from '../../../foundation/response/json.mjs';
|
|
14
14
|
import {emit, section, list, text, WARN, record} from '../formatters/index.mjs';
|
|
15
|
-
import {cliError} from '../lib/cli-error.mjs';
|
|
15
|
+
import {cliError, rejectEmptyArgument} from '../lib/cli-error.mjs';
|
|
16
16
|
import {getCliInvocation} from '../../../foundation/env/package-manager.mjs';
|
|
17
17
|
import {swizzle as swizzleApi} from '../../../api/swizzle/swizzle.mjs';
|
|
18
18
|
import {defineCommand} from '../lib/define-command.mjs';
|
|
@@ -27,6 +27,9 @@ export function registerSwizzle(program) {
|
|
|
27
27
|
defineCommand(program, swizzleCommand, {
|
|
28
28
|
fn: swizzleFn,
|
|
29
29
|
action: async (/** @type {string | undefined} */ component, /** @type {{output: string, package?: string, list?: boolean, overwrite?: boolean}} */ options) => {
|
|
30
|
+
if (!options.list) {
|
|
31
|
+
rejectEmptyArgument('component', component, 'astryx swizzle');
|
|
32
|
+
}
|
|
30
33
|
const json = program.opts().json || false;
|
|
31
34
|
const run = getCliInvocation();
|
|
32
35
|
|
|
@@ -46,7 +46,7 @@ export const doc = {
|
|
|
46
46
|
flag: '--list',
|
|
47
47
|
param: 'options.list',
|
|
48
48
|
description:
|
|
49
|
-
'List available templates (narrow with --type and --package) and do nothing else: <name>, <path>, --skeleton and --overwrite are
|
|
49
|
+
'List available templates (narrow with --type and --package) and do nothing else: <name>, <path>, --skeleton and --overwrite are refused',
|
|
50
50
|
},
|
|
51
51
|
{
|
|
52
52
|
flag: '--type <type>',
|
|
@@ -65,13 +65,13 @@ export const doc = {
|
|
|
65
65
|
param: 'options.skeleton',
|
|
66
66
|
description:
|
|
67
67
|
'Show layout skeleton with spatial annotations (padding, gap, nesting) instead of the source. Needs <name>. ' +
|
|
68
|
-
'It writes nothing, so <path> and --overwrite are
|
|
68
|
+
'It writes nothing, so <path> and --overwrite are refused with ERR_INVALID_ARGUMENT',
|
|
69
69
|
},
|
|
70
70
|
{
|
|
71
71
|
flag: '--cdn [path]',
|
|
72
72
|
param: 'options.cdn',
|
|
73
73
|
description:
|
|
74
|
-
'Write the no-build-step CDN starter page and do nothing else: <name>, --list, --skeleton, --type and --package are
|
|
74
|
+
'Write the no-build-step CDN starter page and do nothing else: <name>, --list, --skeleton, --type and --package are refused. ' +
|
|
75
75
|
'The page goes to the --cdn value, else to <path>, else cdn.template.html, and that path is always the file itself. ' +
|
|
76
76
|
'A value right after --cdn (anything not starting with -) is taken as that path',
|
|
77
77
|
},
|
|
@@ -56,12 +56,12 @@ async function templateJson(args) {
|
|
|
56
56
|
}
|
|
57
57
|
|
|
58
58
|
describe('astryx template flag precedence', () => {
|
|
59
|
-
it('--list: help says <name>, <path>, --skeleton and --overwrite are
|
|
59
|
+
it('--list: help says <name>, <path>, --skeleton and --overwrite are refused, and they are', async () => {
|
|
60
60
|
const help = (await templateOptions())['--list'];
|
|
61
61
|
for (const ignored of ['<name>', '<path>', '--skeleton', '--overwrite']) {
|
|
62
62
|
expect(help).toContain(ignored);
|
|
63
63
|
}
|
|
64
|
-
expect(help).toMatch(/are
|
|
64
|
+
expect(help).toMatch(/are refused/);
|
|
65
65
|
|
|
66
66
|
const {status, envelope} = await templateJson([
|
|
67
67
|
'dashboard',
|
|
@@ -70,22 +70,25 @@ describe('astryx template flag precedence', () => {
|
|
|
70
70
|
'--skeleton',
|
|
71
71
|
'--overwrite',
|
|
72
72
|
]);
|
|
73
|
-
expect(status).toBe(
|
|
74
|
-
expect(envelope.
|
|
75
|
-
expect(written()).toEqual([]);
|
|
73
|
+
expect(status).toBe(1);
|
|
74
|
+
expect(envelope.code).toBe('ERR_INVALID_ARGUMENT');
|
|
76
75
|
}, SLOW);
|
|
77
76
|
|
|
78
77
|
it('--skeleton: help says it needs <name> and writes nothing, and it does', async () => {
|
|
79
78
|
const help = (await templateOptions())['--skeleton'];
|
|
80
79
|
expect(help).toMatch(/Needs <name>/);
|
|
81
|
-
expect(help).toMatch(/writes nothing, so <path> and --overwrite are
|
|
82
|
-
|
|
80
|
+
expect(help).toMatch(/writes nothing, so <path> and --overwrite are refused/);
|
|
81
|
+
// --list and --cdn are now refused, not precedence
|
|
83
82
|
|
|
84
|
-
const shown = await templateJson(['dashboard', '
|
|
83
|
+
const shown = await templateJson(['dashboard', '--skeleton']);
|
|
85
84
|
expect(shown.status).toBe(0);
|
|
86
85
|
expect(shown.envelope.type).toBe('template.skeleton');
|
|
87
86
|
expect(written()).toEqual([]);
|
|
88
87
|
|
|
88
|
+
const refused = await templateJson(['dashboard', './src/page.tsx', '--skeleton', '--overwrite']);
|
|
89
|
+
expect(refused.status).toBe(1);
|
|
90
|
+
expect(refused.envelope.code).toBe('ERR_INVALID_ARGUMENT');
|
|
91
|
+
|
|
89
92
|
const nameless = await templateJson(['--skeleton']);
|
|
90
93
|
expect(nameless.status).toBe(1);
|
|
91
94
|
expect(nameless.envelope.code).toBe('ERR_UNKNOWN_TEMPLATE');
|
|
@@ -101,11 +104,15 @@ describe('astryx template flag precedence', () => {
|
|
|
101
104
|
expect(help).toMatch(/value right after --cdn/);
|
|
102
105
|
|
|
103
106
|
const everything = await templateJson(['dashboard', '--list', '--skeleton', '--type', 'bogus', '--cdn']);
|
|
104
|
-
expect(everything.
|
|
105
|
-
expect(everything.envelope.
|
|
107
|
+
expect(everything.status).toBe(1);
|
|
108
|
+
expect(everything.envelope.code).toBe('ERR_INVALID_ARGUMENT');
|
|
109
|
+
|
|
110
|
+
const bare = await templateJson(['--cdn']);
|
|
111
|
+
expect(bare.envelope.type).toBe('template.cdn');
|
|
112
|
+
expect(bare.envelope.data.path).toBe('cdn.template.html');
|
|
106
113
|
|
|
107
114
|
// A bare --cdn writes to <path>, and a path with no extension is still the file.
|
|
108
|
-
const positional = await templateJson(['
|
|
115
|
+
const positional = await templateJson(['--cdn', 'demo']);
|
|
109
116
|
expect(positional.envelope.data.path).toBe('demo');
|
|
110
117
|
expect(fs.statSync(path.join(tmpDir, 'demo')).isFile()).toBe(true);
|
|
111
118
|
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
import {jsonOut} from '../../../foundation/response/json.mjs';
|
|
8
8
|
import {emit, section, text, records, code, record} from '../formatters/index.mjs';
|
|
9
|
-
import {cliError} from '../lib/cli-error.mjs';
|
|
9
|
+
import {cliError, rejectEmptyArgument} from '../lib/cli-error.mjs';
|
|
10
10
|
import {template as templateApi} from '../../../api/template/template.mjs';
|
|
11
11
|
import {Project} from '../../../foundation/config/project.mjs';
|
|
12
12
|
import {warnOnIntegrationIssues} from '../../../foundation/integrations/integration-warnings.mjs';
|
|
@@ -66,6 +66,12 @@ export function registerTemplate(program) {
|
|
|
66
66
|
* @param {{list?: boolean, type?: string, package?: string, skeleton?: boolean, cdn?: boolean | string, overwrite?: boolean}} options
|
|
67
67
|
*/
|
|
68
68
|
async (name, targetPath, options) => {
|
|
69
|
+
const usesName = !options.cdn && !options.list;
|
|
70
|
+
const usesPath = options.cdn
|
|
71
|
+
? typeof options.cdn !== 'string'
|
|
72
|
+
: !options.list && !options.skeleton;
|
|
73
|
+
if (usesName) rejectEmptyArgument('name', name, 'astryx template');
|
|
74
|
+
if (usesPath) rejectEmptyArgument('path', targetPath, 'astryx template');
|
|
69
75
|
const json = program.opts().json || false;
|
|
70
76
|
const run = getCliInvocation();
|
|
71
77
|
|
|
@@ -394,23 +394,6 @@ const CASES = [
|
|
|
394
394
|
args: ['integration', 'pack', '--check'],
|
|
395
395
|
skipFieldChecks: true,
|
|
396
396
|
},
|
|
397
|
-
// ── Layout command: remove these cases when the layout command is deleted ──
|
|
398
|
-
{
|
|
399
|
-
name: 'layout check',
|
|
400
|
-
args: ['layout', 'check', 'Button'],
|
|
401
|
-
skipFieldChecks: true,
|
|
402
|
-
},
|
|
403
|
-
{
|
|
404
|
-
name: 'layout expand',
|
|
405
|
-
args: ['layout', 'expand', 'Button'],
|
|
406
|
-
skipFieldChecks: true,
|
|
407
|
-
},
|
|
408
|
-
{
|
|
409
|
-
name: 'layout grammar',
|
|
410
|
-
args: ['layout', 'grammar'],
|
|
411
|
-
skipFieldChecks: true,
|
|
412
|
-
},
|
|
413
|
-
// ── End layout cases ──
|
|
414
397
|
{
|
|
415
398
|
name: 'manifest',
|
|
416
399
|
args: ['manifest'],
|