@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
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
2
|
|
|
3
|
-
/** @file Compatibility
|
|
3
|
+
/** @file Compatibility coverage for the cleanup stage of the theme-add lifecycle. */
|
|
4
4
|
|
|
5
5
|
import {afterEach, beforeEach, describe, expect, it} from 'vitest';
|
|
6
6
|
import * as fs from 'node:fs';
|
|
@@ -14,9 +14,50 @@ let tmpDir;
|
|
|
14
14
|
beforeEach(() => {
|
|
15
15
|
tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'astryx-theme-add-cli-'));
|
|
16
16
|
fs.mkdirSync(path.join(tmpDir, 'src'));
|
|
17
|
+
fs.writeFileSync(path.join(tmpDir, 'tsconfig.json'), '{}\n');
|
|
17
18
|
fs.writeFileSync(
|
|
18
19
|
path.join(tmpDir, 'package.json'),
|
|
19
|
-
JSON.stringify({
|
|
20
|
+
JSON.stringify({
|
|
21
|
+
name: 'app',
|
|
22
|
+
private: true,
|
|
23
|
+
dependencies: {'@acme/themes': '^1.0.0'},
|
|
24
|
+
}),
|
|
25
|
+
);
|
|
26
|
+
const packageDir = path.join(tmpDir, 'node_modules', '@acme', 'themes');
|
|
27
|
+
const themeDir = path.join(packageDir, 'themes', 'ocean');
|
|
28
|
+
fs.mkdirSync(themeDir, {recursive: true});
|
|
29
|
+
fs.mkdirSync(path.join(packageDir, 'dist'), {recursive: true});
|
|
30
|
+
fs.writeFileSync(
|
|
31
|
+
path.join(packageDir, 'package.json'),
|
|
32
|
+
JSON.stringify({
|
|
33
|
+
name: '@acme/themes',
|
|
34
|
+
version: '1.0.0',
|
|
35
|
+
type: 'module',
|
|
36
|
+
exports: {
|
|
37
|
+
'./themes/ocean': './dist/ocean.js',
|
|
38
|
+
'./themes/ocean.css': './dist/ocean.css',
|
|
39
|
+
},
|
|
40
|
+
}),
|
|
41
|
+
);
|
|
42
|
+
fs.writeFileSync(
|
|
43
|
+
path.join(packageDir, 'astryx.integration.mjs'),
|
|
44
|
+
"export default {themes: './themes'};\n",
|
|
45
|
+
);
|
|
46
|
+
fs.writeFileSync(
|
|
47
|
+
path.join(themeDir, 'oceanTheme.doc.mjs'),
|
|
48
|
+
"/** @type {import('@astryxdesign/cli/authoring').ThemeDoc} */\nexport default {type: 'theme', name: 'ocean', displayName: 'Ocean', description: 'Ocean theme.', maintained: true};\n",
|
|
49
|
+
);
|
|
50
|
+
fs.writeFileSync(
|
|
51
|
+
path.join(themeDir, 'oceanTheme.ts'),
|
|
52
|
+
'export const oceanTheme = {};\n',
|
|
53
|
+
);
|
|
54
|
+
fs.writeFileSync(
|
|
55
|
+
path.join(packageDir, 'dist/ocean.js'),
|
|
56
|
+
"export const oceanTheme = {name: 'ocean', __built: true};\n",
|
|
57
|
+
);
|
|
58
|
+
fs.writeFileSync(
|
|
59
|
+
path.join(packageDir, 'dist/ocean.css'),
|
|
60
|
+
'[data-astryx-theme="ocean"] {}\n',
|
|
20
61
|
);
|
|
21
62
|
});
|
|
22
63
|
|
|
@@ -24,53 +65,66 @@ afterEach(() => {
|
|
|
24
65
|
fs.rmSync(tmpDir, {recursive: true, force: true});
|
|
25
66
|
});
|
|
26
67
|
|
|
27
|
-
describe('theme add
|
|
28
|
-
it('
|
|
29
|
-
const result = await runCli(
|
|
68
|
+
describe('theme add cleanup lifecycle', () => {
|
|
69
|
+
it('plain theme add imports built output and prints no deprecation warning', async () => {
|
|
70
|
+
const result = await runCli(
|
|
71
|
+
['theme', 'add', 'ocean', '--package', '@acme/themes'],
|
|
72
|
+
tmpDir,
|
|
73
|
+
);
|
|
30
74
|
|
|
31
75
|
expect(result.status, result.stderr).toBe(0);
|
|
32
|
-
expect(result.stdout).
|
|
33
|
-
|
|
34
|
-
);
|
|
35
|
-
expect(result.
|
|
36
|
-
expect(result.stderr.
|
|
37
|
-
|
|
38
|
-
);
|
|
39
|
-
// The app has no CLI installed, so the commands name the scoped package.
|
|
40
|
-
const run = getCliInvocation(tmpDir);
|
|
41
|
-
expect(run).toMatch(/ @astryxdesign\/cli$/);
|
|
42
|
-
expect(result.stderr).toContain(`${run} theme eject neutral`);
|
|
43
|
-
expect(result.stderr).toContain(`${run} theme add neutral --import`);
|
|
44
|
-
expect(fs.existsSync(path.join(tmpDir, 'src/themes/neutral'))).toBe(true);
|
|
45
|
-
expect(fs.existsSync(path.join(tmpDir, 'src/astryx-themes.ts'))).toBe(
|
|
46
|
-
false,
|
|
47
|
-
);
|
|
76
|
+
expect(result.stdout).toMatch(/^owner:\s+@acme\/themes$/m);
|
|
77
|
+
expect(result.stdout).toMatch(/^module:\s+@acme\/themes\/themes\/ocean$/m);
|
|
78
|
+
expect(result.stdout).toMatch(/^action:\s+add$/m);
|
|
79
|
+
expect(result.stderr).not.toContain('DEP-0005');
|
|
80
|
+
expect(result.stderr).not.toContain('deprecated');
|
|
81
|
+
expect(fs.existsSync(path.join(tmpDir, 'src/astryx-themes.ts'))).toBe(true);
|
|
82
|
+
expect(fs.existsSync(path.join(tmpDir, 'src/themes/ocean'))).toBe(false);
|
|
48
83
|
});
|
|
49
84
|
|
|
50
|
-
it('
|
|
51
|
-
const result = await runCli(
|
|
85
|
+
it('plain theme add returns theme.app with no deprecation metadata', async () => {
|
|
86
|
+
const result = await runCli(
|
|
87
|
+
['theme', 'add', 'ocean', '--package', '@acme/themes', '--json'],
|
|
88
|
+
tmpDir,
|
|
89
|
+
);
|
|
52
90
|
|
|
53
91
|
expect(result.status, result.stderr).toBe(0);
|
|
54
|
-
expect(result.stderr).
|
|
55
|
-
|
|
56
|
-
|
|
92
|
+
expect(result.stderr).toBe('');
|
|
93
|
+
const payload = JSON.parse(result.stdout);
|
|
94
|
+
expect(payload).toMatchObject({
|
|
95
|
+
type: 'theme.app',
|
|
57
96
|
data: {
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
},
|
|
62
|
-
meta: {
|
|
63
|
-
deprecations: [
|
|
64
|
-
{
|
|
65
|
-
id: 'DEP-0005',
|
|
66
|
-
replacements: ['theme eject', 'theme add --import'],
|
|
67
|
-
},
|
|
68
|
-
],
|
|
97
|
+
default: 'ocean',
|
|
98
|
+
modulePath: 'src/astryx-themes.ts',
|
|
99
|
+
change: {action: 'add', slug: 'ocean', changed: true},
|
|
69
100
|
},
|
|
70
101
|
});
|
|
102
|
+
expect(payload.meta).toBeUndefined();
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
it('keeps --import as an accepted no-op with the same response', async () => {
|
|
106
|
+
const result = await runCli(
|
|
107
|
+
[
|
|
108
|
+
'theme',
|
|
109
|
+
'add',
|
|
110
|
+
'ocean',
|
|
111
|
+
'--import',
|
|
112
|
+
'--package',
|
|
113
|
+
'@acme/themes',
|
|
114
|
+
'--json',
|
|
115
|
+
],
|
|
116
|
+
tmpDir,
|
|
117
|
+
);
|
|
118
|
+
|
|
119
|
+
expect(result.status, result.stderr).toBe(0);
|
|
120
|
+
expect(JSON.parse(result.stdout)).toMatchObject({
|
|
121
|
+
type: 'theme.app',
|
|
122
|
+
data: {default: 'ocean', change: {action: 'add', slug: 'ocean'}},
|
|
123
|
+
});
|
|
124
|
+
expect(fs.existsSync(path.join(tmpDir, 'src/themes/ocean'))).toBe(false);
|
|
71
125
|
});
|
|
72
126
|
|
|
73
|
-
it('keeps
|
|
127
|
+
it('keeps list JSON byte-compatible and names cleanup commands in text', async () => {
|
|
74
128
|
fs.mkdirSync(path.join(tmpDir, 'src/themes/broken'), {recursive: true});
|
|
75
129
|
fs.writeFileSync(
|
|
76
130
|
path.join(tmpDir, 'src/themes/broken/brokenTheme.ts'),
|
|
@@ -81,16 +135,19 @@ describe('theme add compatibility lifecycle', () => {
|
|
|
81
135
|
expect(textResult.status, textResult.stderr).toBe(0);
|
|
82
136
|
const run = getCliInvocation(tmpDir);
|
|
83
137
|
expect(textResult.stdout).toContain(
|
|
84
|
-
`Import one: ${run} theme add <slug>
|
|
138
|
+
`Import one: ${run} theme add <slug> [--package <package>]`,
|
|
85
139
|
);
|
|
86
140
|
expect(textResult.stdout).toContain(
|
|
87
141
|
`Fork source: ${run} theme eject <slug> [target-path]`,
|
|
88
142
|
);
|
|
143
|
+
expect(textResult.stdout).toMatch(
|
|
144
|
+
/More themes in packages you could add: .*discover theme$/m,
|
|
145
|
+
);
|
|
89
146
|
expect(textResult.stdout).not.toContain('theme add <slug> [target-path]');
|
|
147
|
+
expect(textResult.stdout).not.toContain('theme add <slug> --import');
|
|
90
148
|
expect(textResult.stderr).not.toContain('deprecated');
|
|
91
149
|
|
|
92
150
|
const result = await runCli(['theme', 'add', '--list', '--json'], tmpDir);
|
|
93
|
-
|
|
94
151
|
expect(result.status, result.stderr).toBe(0);
|
|
95
152
|
const payload = JSON.parse(result.stdout);
|
|
96
153
|
expect(payload).toMatchObject({type: 'theme.list'});
|
|
@@ -107,29 +164,65 @@ describe('theme add compatibility lifecycle', () => {
|
|
|
107
164
|
});
|
|
108
165
|
|
|
109
166
|
it.each([
|
|
110
|
-
['target path', ['src/brand']],
|
|
111
|
-
['overwrite', ['--overwrite']],
|
|
112
|
-
|
|
167
|
+
['target path', ['src/brand'], 'ERR_INVALID_ARGUMENT'],
|
|
168
|
+
['overwrite', ['--overwrite'], 'ERR_INVALID_OPTION'],
|
|
169
|
+
[
|
|
170
|
+
'target path with --import',
|
|
171
|
+
['--import', 'src/brand'],
|
|
172
|
+
'ERR_INVALID_ARGUMENT',
|
|
173
|
+
],
|
|
174
|
+
[
|
|
175
|
+
'overwrite with --import',
|
|
176
|
+
['--import', '--overwrite'],
|
|
177
|
+
'ERR_INVALID_OPTION',
|
|
178
|
+
],
|
|
179
|
+
])(
|
|
180
|
+
'rejects removed %s before writing with the standard parser code',
|
|
181
|
+
async (_label, extra, code) => {
|
|
182
|
+
const result = await runCli(
|
|
183
|
+
[
|
|
184
|
+
'theme',
|
|
185
|
+
'add',
|
|
186
|
+
'ocean',
|
|
187
|
+
...extra,
|
|
188
|
+
'--package',
|
|
189
|
+
'@acme/themes',
|
|
190
|
+
'--json',
|
|
191
|
+
],
|
|
192
|
+
tmpDir,
|
|
193
|
+
);
|
|
194
|
+
|
|
195
|
+
expect(result.status).toBe(1);
|
|
196
|
+
expect(JSON.parse(result.stdout)).toMatchObject({code});
|
|
197
|
+
expect(fs.existsSync(path.join(tmpDir, 'src/astryx-themes.ts'))).toBe(
|
|
198
|
+
false,
|
|
199
|
+
);
|
|
200
|
+
expect(fs.existsSync(path.join(tmpDir, 'src/brand'))).toBe(false);
|
|
201
|
+
},
|
|
202
|
+
);
|
|
203
|
+
|
|
204
|
+
it('rejects --overwrite without a slug as an invalid option', async () => {
|
|
113
205
|
const result = await runCli(
|
|
114
|
-
['theme', 'add', '
|
|
206
|
+
['theme', 'add', '--overwrite', '--json'],
|
|
115
207
|
tmpDir,
|
|
116
208
|
);
|
|
117
209
|
|
|
118
|
-
expect(result.status).
|
|
210
|
+
expect(result.status).toBe(1);
|
|
119
211
|
expect(JSON.parse(result.stdout)).toMatchObject({
|
|
120
|
-
code: '
|
|
121
|
-
error: expect.stringContaining('cannot be combined'),
|
|
212
|
+
code: 'ERR_INVALID_OPTION',
|
|
122
213
|
});
|
|
123
214
|
expect(fs.existsSync(path.join(tmpDir, 'src/astryx-themes.ts'))).toBe(
|
|
124
215
|
false,
|
|
125
216
|
);
|
|
126
|
-
expect(fs.existsSync(path.join(tmpDir, 'src/brand'))).toBe(false);
|
|
127
217
|
});
|
|
128
218
|
|
|
129
|
-
it('
|
|
219
|
+
it('shows --import and the visible eject replacement without a hidden option', async () => {
|
|
130
220
|
const result = await runCli(['theme', 'add', '--help'], tmpDir);
|
|
131
221
|
|
|
132
222
|
expect(result.status, result.stderr).toBe(0);
|
|
133
223
|
expect(result.stdout).toContain('--import');
|
|
224
|
+
expect(result.stdout).toMatch(/compatibility no-op/i);
|
|
225
|
+
expect(result.stdout).toContain('theme eject <slug> [path] [--overwrite]');
|
|
226
|
+
expect(result.stdout).not.toMatch(/^\s+-f, --overwrite/m);
|
|
134
227
|
});
|
|
135
228
|
});
|
|
@@ -8,26 +8,19 @@ export const doc = {
|
|
|
8
8
|
name: 'theme add',
|
|
9
9
|
displayName: 'astryx theme add',
|
|
10
10
|
namespace: 'cli/commands',
|
|
11
|
-
summary:
|
|
11
|
+
summary:
|
|
12
|
+
"Add a built theme to the app. To copy a theme's source as an editable fork, run `theme eject <slug> [path] [--overwrite]`.",
|
|
12
13
|
description:
|
|
13
|
-
|
|
14
|
+
"Records the theme in the generated app module and imports its built module and stylesheets. --import remains accepted as a compatibility no-op. To copy a theme's source as an editable fork, run `theme eject <slug> [path] [--overwrite]`. A bare command or --list delegates to themeListCopySources(), whose released JSON bytes stay unchanged while its text names the current add and eject commands; use --package when owners share a slug.",
|
|
14
15
|
fn: 'themeAdd',
|
|
15
|
-
args: [
|
|
16
|
-
{name: 'slug', param: 'slug', required: false},
|
|
17
|
-
{name: 'path', param: 'options.targetPath', required: false},
|
|
18
|
-
],
|
|
16
|
+
args: [{name: 'slug', param: 'slug', required: false}],
|
|
19
17
|
options: [
|
|
20
|
-
{
|
|
21
|
-
flag: '-f, --overwrite',
|
|
22
|
-
param: 'options.overwrite',
|
|
23
|
-
description: 'Replace copied files. Cannot be combined with --import',
|
|
24
|
-
},
|
|
25
18
|
{flag: '--list', description: 'List available themes'},
|
|
26
19
|
{
|
|
27
20
|
flag: '--import',
|
|
28
21
|
param: 'options.import',
|
|
29
22
|
description:
|
|
30
|
-
'
|
|
23
|
+
'Compatibility no-op; the built theme is added with or without this flag',
|
|
31
24
|
},
|
|
32
25
|
{
|
|
33
26
|
flag: '--package <package>',
|
|
@@ -37,19 +30,19 @@ export const doc = {
|
|
|
37
30
|
],
|
|
38
31
|
examples: [
|
|
39
32
|
{
|
|
40
|
-
label: '
|
|
41
|
-
cli: 'astryx theme add ocean
|
|
33
|
+
label: 'Add a built theme to the app',
|
|
34
|
+
cli: 'astryx theme add ocean',
|
|
42
35
|
},
|
|
43
36
|
{
|
|
44
37
|
label: 'Select a package theme over a local theme',
|
|
45
|
-
cli: 'astryx theme add ocean --
|
|
38
|
+
cli: 'astryx theme add ocean --package @acme/themes',
|
|
46
39
|
},
|
|
47
40
|
],
|
|
48
41
|
exitCodes: [
|
|
49
|
-
{code: 0, when: 'the theme is listed
|
|
42
|
+
{code: 0, when: 'the theme is listed or added'},
|
|
50
43
|
{
|
|
51
44
|
code: 1,
|
|
52
|
-
when: 'the theme, its
|
|
45
|
+
when: 'the theme, its built imports, its record, or the option combination is invalid',
|
|
53
46
|
},
|
|
54
47
|
],
|
|
55
48
|
related: ['theme list', 'theme remove', 'theme use', 'theme eject'],
|
|
@@ -29,7 +29,8 @@ describe('astryx theme list', () => {
|
|
|
29
29
|
expect(status).toBe(0);
|
|
30
30
|
expect(stdout).toMatch(/^slug:\s+neutral$/m);
|
|
31
31
|
expect(stdout).toMatch(/^package:\s+@astryxdesign\/cli$/m);
|
|
32
|
-
expect(stdout).toMatch(/Import one: .*theme add <slug
|
|
32
|
+
expect(stdout).toMatch(/Import one: .*theme add <slug>/m);
|
|
33
|
+
expect(stdout).not.toContain('theme add <slug> --import');
|
|
33
34
|
expect(stdout).toMatch(/Fork source: .*theme eject <slug>/m);
|
|
34
35
|
expect(stdout).toMatch(/More themes in packages you could add: .*discover theme$/m);
|
|
35
36
|
});
|
|
@@ -18,19 +18,21 @@ describe('astryx theme targets', () => {
|
|
|
18
18
|
|
|
19
19
|
expect(status).toBe(0);
|
|
20
20
|
// Inline layout: key component - props - states - className
|
|
21
|
-
expect(stdout).toMatch(
|
|
22
|
-
|
|
21
|
+
expect(stdout).toMatch(
|
|
22
|
+
/^switch\s+Switch - size - checked, disabled - astryx-switch$/m,
|
|
23
|
+
);
|
|
24
|
+
expect(stdout).toMatch(
|
|
25
|
+
/^switch-thumb\s+Switch - size - checked - astryx-switch-thumb$/m,
|
|
26
|
+
);
|
|
23
27
|
expect(stdout).toMatch(/4 across 1 component/);
|
|
24
28
|
});
|
|
25
29
|
|
|
26
|
-
it('
|
|
30
|
+
it('omits removed aliases from the target list', async () => {
|
|
27
31
|
const {status, stdout} = await runCli(['theme', 'targets', 'Popover']);
|
|
28
32
|
|
|
29
33
|
expect(status).toBe(0);
|
|
30
34
|
expect(stdout).toMatch(/^popover\s{2,}Popover/m);
|
|
31
|
-
expect(stdout).
|
|
32
|
-
/^popover-surface\s{2,}Popover - astryx-popover-surface - deprecated; use popover$/m,
|
|
33
|
-
);
|
|
35
|
+
expect(stdout).not.toContain('popover-surface');
|
|
34
36
|
});
|
|
35
37
|
|
|
36
38
|
it('lists the whole surface when unfiltered', async () => {
|
|
@@ -19,7 +19,7 @@ export const doc = {
|
|
|
19
19
|
'Writes theme.template.ts: the annotated reference for the whole theme surface, covering every ' +
|
|
20
20
|
'defineTheme field, the token families, the component override syntax, and how a theme is ' +
|
|
21
21
|
'consumed, naming the CLI command that prints the authoritative reference for each. Read ' +
|
|
22
|
-
'it, copy what you need into your own theme file, delete it. Use `theme add <slug
|
|
22
|
+
'it, copy what you need into your own theme file, delete it. Use `theme add <slug>` to ' +
|
|
23
23
|
'use an installed built theme, extend that theme for ordinary customization, or use ' +
|
|
24
24
|
'`theme eject <slug>` for a complete source fork. Leaves an existing file untouched unless --overwrite.',
|
|
25
25
|
fn: 'themeTemplate',
|
|
@@ -13,7 +13,7 @@ export const doc = {
|
|
|
13
13
|
namespace: 'cli/commands',
|
|
14
14
|
summary: 'Add, switch, build, and author themes',
|
|
15
15
|
description:
|
|
16
|
-
'The theme command group.
|
|
16
|
+
'The theme command group. Add built themes to an app, choose its default, remove them, list available and added themes, or eject source to make a local fork. The authoring commands build themes, generate palettes, write the annotated template, and list component theme targets.',
|
|
17
17
|
subcommands: [
|
|
18
18
|
'build',
|
|
19
19
|
'list',
|
|
@@ -27,7 +27,7 @@ export const doc = {
|
|
|
27
27
|
],
|
|
28
28
|
examples: [
|
|
29
29
|
{label: 'List available and added themes', cli: 'astryx theme list'},
|
|
30
|
-
{label: 'Import a theme into the app', cli: 'astryx theme add ocean
|
|
30
|
+
{label: 'Import a theme into the app', cli: 'astryx theme add ocean'},
|
|
31
31
|
{label: 'Choose the default', cli: 'astryx theme use ocean'},
|
|
32
32
|
{label: 'Fork source to customize', cli: 'astryx theme eject ocean'},
|
|
33
33
|
{
|
|
@@ -90,7 +90,7 @@ export const doc = {
|
|
|
90
90
|
flag: '--list',
|
|
91
91
|
param: 'options.list',
|
|
92
92
|
description:
|
|
93
|
-
'List available codemods and do nothing else. Every other flag is
|
|
93
|
+
'List available codemods and do nothing else. Every other flag is refused, as is --registry (exit 1)',
|
|
94
94
|
default: false,
|
|
95
95
|
},
|
|
96
96
|
],
|
|
@@ -79,22 +79,18 @@ const MIGRATION_FLAGS = [
|
|
|
79
79
|
describe('astryx upgrade flag interactions', () => {
|
|
80
80
|
it('--list: help says it ignores every other flag but --registry, and it does', async () => {
|
|
81
81
|
const options = await upgradeOptions();
|
|
82
|
-
expect(options['--list']).toMatch(/Every other flag is
|
|
82
|
+
expect(options['--list']).toMatch(/Every other flag is refused, as is --registry/);
|
|
83
83
|
|
|
84
84
|
installPackage('@astryxdesign/core', '0.6.0');
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
'--from',
|
|
88
|
-
'bogus',
|
|
89
|
-
'--codemod',
|
|
90
|
-
'bogus',
|
|
91
|
-
'--apply',
|
|
92
|
-
'--path',
|
|
93
|
-
'../outside',
|
|
94
|
-
]);
|
|
85
|
+
|
|
86
|
+
const listed = await upgradeJson(['--list']);
|
|
95
87
|
expect(listed.status).toBe(0);
|
|
96
88
|
expect(listed.envelope.type).toBe('upgrade.list');
|
|
97
89
|
|
|
90
|
+
const withFlags = await upgradeJson(['--list', '--from', 'bogus']);
|
|
91
|
+
expect(withFlags.status).toBe(1);
|
|
92
|
+
expect(withFlags.envelope.code).toBe('ERR_INVALID_ARGUMENT');
|
|
93
|
+
|
|
98
94
|
const refused = await upgradeJson(['--list', '--registry']);
|
|
99
95
|
expect(refused.status).toBe(1);
|
|
100
96
|
expect(refused.envelope.code).toBe('ERR_INVALID_ARGUMENT');
|
|
@@ -0,0 +1,67 @@
|
|
|
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
|
+
import {validateIntegration} from '../../../api/integration/validate-integration.mjs';
|
|
6
|
+
import {integrationTemplateConflicts, integrationComponentConflicts, integrationDocConflicts} from '../../../api/integration/authoring-checks.mjs';
|
|
7
|
+
let dir;
|
|
8
|
+
beforeEach(() => { dir = fs.mkdtempSync(path.join(os.tmpdir(),'astryx-val-')); });
|
|
9
|
+
afterEach(() => fs.rmSync(dir, {recursive:true,force:true}));
|
|
10
|
+
const json = async a => { const {status,stdout}=await runCli(['--json',...a],{cwd:dir}); return {status,body:JSON.parse(stdout)}; };
|
|
11
|
+
const text = async a => runCli(a, {cwd: dir});
|
|
12
|
+
|
|
13
|
+
describe('doctor integration validate exit codes (IFIX-0008)', () => {
|
|
14
|
+
it('exits 1 with no package.json (JSON has no_package issue)', async () => {
|
|
15
|
+
const {status, body} = await json(['doctor','integration','validate']);
|
|
16
|
+
expect(status).toBe(1);
|
|
17
|
+
expect(body.data.validated).toBe(false);
|
|
18
|
+
expect(body.data.issues).toEqual([
|
|
19
|
+
expect.objectContaining({code: 'no_package', severity: 'error'}),
|
|
20
|
+
]);
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
it('text mode says no package.json when there is none', async () => {
|
|
24
|
+
const {status, stdout} = await text(['doctor','integration','validate']);
|
|
25
|
+
expect(status).toBe(1);
|
|
26
|
+
expect(stdout).toContain('no package.json found');
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
it('exits 0 with package.json but no manifest (byte-identical to published)', async () => {
|
|
30
|
+
fs.writeFileSync(path.join(dir,'package.json'), JSON.stringify({name:'myapp',version:'1.0.0'}));
|
|
31
|
+
const {status, body} = await json(['doctor','integration','validate']);
|
|
32
|
+
expect(status).toBe(0);
|
|
33
|
+
expect(body.data).toEqual({validated: false, name: null, version: null, issues: []});
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
it('text mode says no manifest when package.json exists', async () => {
|
|
37
|
+
fs.writeFileSync(path.join(dir,'package.json'), JSON.stringify({name:'myapp',version:'1.0.0'}));
|
|
38
|
+
const {status, stdout} = await text(['doctor','integration','validate']);
|
|
39
|
+
expect(status).toBe(0);
|
|
40
|
+
expect(stdout).toContain('no astryx.integration');
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
it('exported API returns the no_package issue', async () => {
|
|
44
|
+
const result = await validateIntegration(undefined, {cwd: dir});
|
|
45
|
+
expect(result.type).toBe('integration.validate');
|
|
46
|
+
expect(result.data.validated).toBe(false);
|
|
47
|
+
expect(result.data.issues).toEqual([
|
|
48
|
+
expect.objectContaining({code: 'no_package', severity: 'error'}),
|
|
49
|
+
]);
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
it('integration verify exits 1 with a data envelope', async () => {
|
|
53
|
+
const {status, body} = await json(['integration','verify']);
|
|
54
|
+
expect(status).toBe(1);
|
|
55
|
+
expect(body.type).toBe('integration.pack-check');
|
|
56
|
+
expect(body.data.issues.some(i => i.code === 'no_package')).toBe(true);
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
it('sibling commands stay unchanged with no package.json', async () => {
|
|
60
|
+
for (const sub of ['templates', 'components', 'docs']) {
|
|
61
|
+
const {status, body} = await json(['doctor','integration', sub]);
|
|
62
|
+
expect(status, `doctor integration ${sub}`).toBe(0);
|
|
63
|
+
expect(body.data.validated).toBe(false);
|
|
64
|
+
expect(body.data.issues).toEqual([]);
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
});
|
package/clients/cli/index.mjs
CHANGED
|
@@ -107,9 +107,6 @@ export const JSON_SUPPORTED = new Set([
|
|
|
107
107
|
'doctor integration templates',
|
|
108
108
|
'doctor integration components',
|
|
109
109
|
'doctor integration docs',
|
|
110
|
-
'layout expand',
|
|
111
|
-
'layout check',
|
|
112
|
-
'layout grammar',
|
|
113
110
|
]);
|
|
114
111
|
|
|
115
112
|
/**
|
|
@@ -268,7 +265,6 @@ const commands = [
|
|
|
268
265
|
{name: 'gap-report', path: './commands/gap-report.mjs', register: 'registerGapReport'},
|
|
269
266
|
// agent-docs folded into init — functions still importable from agent-docs.mjs
|
|
270
267
|
{name: 'template', path: './commands/template.mjs', register: 'registerTemplate'},
|
|
271
|
-
{name: 'layout', path: './commands/layout.mjs', register: 'registerLayout'},
|
|
272
268
|
{name: 'upgrade', path: './commands/upgrade.mjs', register: 'registerUpgrade'},
|
|
273
269
|
{name: 'theme', path: './commands/build-theme.mjs', register: 'registerTheme'},
|
|
274
270
|
{name: 'integration', path: './commands/integration.mjs', register: 'registerIntegration'},
|
|
@@ -135,6 +135,25 @@ export function cliError(message, options = {}) {
|
|
|
135
135
|
return /** @type {never} */ (undefined);
|
|
136
136
|
}
|
|
137
137
|
|
|
138
|
+
/**
|
|
139
|
+
* Reject a positional argument the user typed as `""`.
|
|
140
|
+
*
|
|
141
|
+
* @param {string} name the argument as the help spells it, without brackets
|
|
142
|
+
* @param {unknown} value what Commander passed
|
|
143
|
+
* @param {string} command the command as a user types it, e.g. `astryx template`
|
|
144
|
+
* @returns {void} returns only when the argument is not an empty string
|
|
145
|
+
*/
|
|
146
|
+
export function rejectEmptyArgument(name, value, command) {
|
|
147
|
+
if (typeof value !== 'string' || value.length > 0) return;
|
|
148
|
+
cliError(
|
|
149
|
+
`Argument <${name}> is an empty string. ` +
|
|
150
|
+
'An empty argument is not the same as an omitted one, and ignoring it ' +
|
|
151
|
+
'would silently discard the rest of the command: pass a value, or leave ' +
|
|
152
|
+
`<${name}> out of \`${command}\` entirely.`,
|
|
153
|
+
{code: ERROR_CODES.ERR_INVALID_ARGUMENT},
|
|
154
|
+
);
|
|
155
|
+
}
|
|
156
|
+
|
|
138
157
|
/**
|
|
139
158
|
* Clean exit. Mostly a marker for intent — `process.exit(0)` works fine,
|
|
140
159
|
* but using cliExit at success boundaries makes greps for "exit policy"
|