@astryxdesign/cli 0.6.0 → 0.6.1
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/CHANGELOG.md +48 -1
- package/README.md +76 -67
- package/api/build/build.test.mjs +37 -0
- package/api/build/build.type.mjs +1 -1
- package/api/build/kit/kit.mjs +31 -1
- package/api/component/_adapter.mjs +14 -28
- package/api/component/integration-import-agreement.test.mjs +318 -0
- package/api/doctor/doctor.d.mts +32 -3
- package/api/doctor/doctor.doc.mjs +2 -1
- package/api/doctor/doctor.mjs +97 -4
- package/api/doctor/doctor.test.mjs +90 -1
- package/api/gap-report/gap-report-worker.d.mts +4 -0
- package/api/gap-report/gap-report-worker.mjs +73 -0
- package/api/gap-report/gap-report.d.mts +81 -0
- package/api/gap-report/gap-report.doc.d.mts +9 -0
- package/api/gap-report/gap-report.doc.mjs +127 -0
- package/api/gap-report/gap-report.mjs +707 -0
- package/api/gap-report/gap-report.test.mjs +1210 -0
- package/api/gap-report/gap-report.type.d.mts +88 -0
- package/api/gap-report/gap-report.type.mjs +69 -0
- package/api/index.d.mts +8 -1
- package/api/index.mjs +24 -1
- package/api/integration/add-contribution.d.mts +44 -0
- package/api/integration/add-contribution.mjs +1160 -0
- package/api/integration/add-contribution.test.mjs +733 -0
- package/api/integration/add-helpers.d.mts +80 -0
- package/api/integration/add-helpers.mjs +333 -0
- package/api/integration/add-helpers.test.mjs +161 -0
- package/api/integration/add-theme.d.mts +10 -0
- package/api/integration/add-theme.mjs +332 -0
- package/api/integration/add-theme.test.mjs +194 -0
- package/api/integration/integration-authoring.type.d.mts +55 -0
- package/api/integration/integration-authoring.type.mjs +76 -0
- package/api/integration/integration-block-exports.test.mjs +4 -0
- package/api/integration/integrationAdd.doc.d.mts +5 -0
- package/api/integration/integrationAdd.doc.mjs +100 -0
- package/api/integration/integrationAddAgentDoc.doc.d.mts +5 -0
- package/api/integration/integrationAddAgentDoc.doc.mjs +49 -0
- package/api/integration/integrationAddCodemod.doc.d.mts +5 -0
- package/api/integration/integrationAddCodemod.doc.mjs +55 -0
- package/api/integration/integrationAddComponent.doc.d.mts +5 -0
- package/api/integration/integrationAddComponent.doc.mjs +49 -0
- package/api/integration/integrationAddDoc.doc.d.mts +5 -0
- package/api/integration/integrationAddDoc.doc.mjs +59 -0
- package/api/integration/integrationAddTemplate.doc.d.mts +5 -0
- package/api/integration/integrationAddTemplate.doc.mjs +55 -0
- package/api/integration/integrationAddTheme.doc.d.mts +5 -0
- package/api/integration/integrationAddTheme.doc.mjs +85 -0
- package/api/integration/integrationPackCheck.doc.d.mts +5 -0
- package/api/integration/integrationPackCheck.doc.mjs +35 -0
- package/api/integration/pack-check.d.mts +27 -0
- package/api/integration/pack-check.mjs +795 -0
- package/api/integration/pack-check.test.mjs +569 -0
- package/api/integration/pack-check.type.d.mts +45 -0
- package/api/integration/pack-check.type.mjs +56 -0
- package/api/integration/public-api.test.mjs +21 -0
- package/api/integration/validate-integration.mjs +221 -11
- package/api/integration/validate-integration.test.mjs +189 -5
- package/api/integration/validateIntegration.doc.mjs +2 -2
- package/api/json/index.ts +1 -0
- package/api/search/search.mjs +19 -1
- package/api/theme/_adapter.d.mts +26 -28
- package/api/theme/_adapter.mjs +101 -38
- package/api/theme/add/add.d.mts +2 -1
- package/api/theme/add/add.mjs +56 -20
- package/api/theme/add/add.test.mjs +1 -0
- package/api/theme/build/build.d.mts +25 -0
- package/api/theme/build/build.mjs +101 -70
- package/api/theme/build/build.test.mjs +77 -44
- package/api/theme/integration-themes.test.mjs +183 -0
- package/api/theme/list/list.d.mts +10 -2
- package/api/theme/list/list.mjs +31 -10
- package/api/theme/list/list.test.mjs +102 -23
- package/api/theme/listThemes.doc.d.mts +1 -5
- package/api/theme/listThemes.doc.mjs +6 -13
- package/api/theme/targets/targets.test.mjs +22 -8
- package/api/theme/theme.d.mts +1 -1
- package/api/theme/theme.mjs +1 -1
- package/api/theme/theme.type.d.mts +9 -0
- package/api/theme/theme.type.mjs +3 -1
- package/api/theme/themeAdd.doc.d.mts +1 -4
- package/api/theme/themeAdd.doc.mjs +31 -31
- package/api/theme/themeBuild.doc.mjs +1 -1
- package/api/theme/themeList.doc.d.mts +1 -4
- package/api/theme/themeList.doc.mjs +7 -15
- package/api/theme/themeListAvailable.doc.d.mts +8 -0
- package/api/theme/themeListAvailable.doc.mjs +57 -0
- package/api/theme/themeTargets.doc.mjs +21 -7
- package/api/upgrade/_adapter.d.mts +2 -0
- package/api/upgrade/_adapter.mjs +1 -0
- package/api/upgrade/registry/registry.d.mts +40 -0
- package/api/upgrade/registry/registry.mjs +1154 -0
- package/api/upgrade/registry/registry.test.mjs +826 -0
- package/api/upgrade/run/run.mjs +49 -8
- package/api/upgrade/status/status.d.mts +6 -4
- package/api/upgrade/status/status.mjs +26 -8
- package/api/upgrade/upgrade.d.mts +2 -2
- package/api/upgrade/upgrade.doc.mjs +33 -9
- package/api/upgrade/upgrade.mjs +34 -7
- package/api/upgrade/upgrade.test.mjs +198 -8
- package/api/upgrade/upgrade.type.d.mts +90 -1
- package/api/upgrade/upgrade.type.mjs +51 -2
- package/assets/docs/cli-integrations.doc.mjs +152 -28
- package/assets/docs/getting-started.doc.mjs +1 -1
- package/assets/docs/{shadcn-compatibility.doc.mjs → shadcn-compatibility.doc.draft.mjs} +23 -13
- package/assets/docs/styling.doc.mjs +3 -3
- package/assets/docs/theme.doc.dense.mjs +2 -2
- package/assets/docs/theme.doc.mjs +23 -13
- package/assets/docs/theme.doc.zh.mjs +1 -1
- package/assets/templates/blocks/components/BaseTypeahead/BaseTypeaheadCustomSearch.doc.mjs +2 -1
- package/assets/templates/blocks/components/BaseTypeahead/BaseTypeaheadCustomSearch.tsx +38 -12
- package/assets/templates/blocks/components/BaseTypeahead/BaseTypeaheadShowcase.doc.mjs +15 -0
- package/assets/templates/blocks/components/BaseTypeahead/BaseTypeaheadShowcase.tsx +87 -0
- package/assets/templates/blocks/components/BottomSheet/BottomSheetSwitcherReviewFlow.doc.mjs +23 -0
- package/assets/templates/blocks/components/BottomSheet/BottomSheetSwitcherReviewFlow.tsx +75 -0
- package/assets/templates/blocks/components/BreadcrumbItem/BreadcrumbItemShowcase.tsx +5 -19
- package/assets/templates/blocks/components/Center/CenterHorizontal.doc.mjs +3 -2
- package/assets/templates/blocks/components/Center/CenterHorizontal.tsx +4 -5
- package/assets/templates/blocks/components/Toast/ToastAction.tsx +2 -1
- package/assets/templates/blocks/components/Toast/ToastDeduplication.tsx +2 -1
- package/assets/templates/blocks/components/Toast/ToastDismiss.tsx +2 -1
- package/assets/templates/blocks/components/Toast/ToastShowcase.tsx +2 -1
- package/assets/templates/blocks/components/Toast/ToastStacking.tsx +2 -1
- package/assets/templates/blocks/components/Toast/ToastTypes.tsx +2 -1
- package/assets/templates/pages/dashboard/template.doc.mjs +2 -2
- package/assets/templates/pages/dashboard-alert-rail/template.doc.mjs +3 -2
- package/assets/templates/pages/dashboard-cohort-funnel/template.doc.mjs +3 -2
- package/assets/templates/pages/dashboard-comparison/template.doc.mjs +3 -3
- package/assets/templates/pages/dashboard-composition/template.doc.mjs +2 -2
- package/assets/templates/pages/dashboard-progress/template.doc.mjs +2 -2
- package/assets/templates/pages/dashboard-scorecard/template.doc.mjs +2 -2
- package/assets/templates/themes/butter/butterTheme.ts +3 -3
- package/assets/templates/themes/neutral/neutralTheme.ts +2 -2
- package/assets/templates/themes/stone/stoneTheme.ts +3 -3
- package/assets/theme.template.ts +4 -7
- package/authoring/config/config.doc.mjs +9 -1
- package/authoring/config/parse.d.mts +2 -0
- package/authoring/config/parse.mjs +28 -3
- package/authoring/config/parse.test.mjs +25 -3
- package/authoring/config/type.ts +3 -0
- package/authoring/doctypes/_schema.d.mts +3 -0
- package/authoring/doctypes/_schema.mjs +6 -1
- package/authoring/doctypes/base/type.ts +6 -6
- package/authoring/doctypes/component/component.doc.mjs +6 -0
- package/authoring/doctypes/component/type.ts +2 -0
- package/authoring/gap-report/parse.d.mts +63 -0
- package/authoring/gap-report/parse.mjs +121 -0
- package/authoring/gap-report/parse.test.mjs +172 -0
- package/authoring/gap-report/type.ts +107 -0
- package/authoring/index.d.mts +1 -0
- package/authoring/index.d.ts +12 -0
- package/authoring/index.mjs +4 -0
- package/authoring/integration/integration.doc.mjs +14 -2
- package/authoring/integration/parse.test.mjs +9 -4
- package/authoring/integration/schema.d.mts +2 -0
- package/authoring/integration/schema.mjs +1 -0
- package/authoring/integration/type.ts +23 -6
- package/authoring/shadcn/receipt.d.mts +219 -0
- package/authoring/shadcn/receipt.mjs +248 -0
- package/authoring/shadcn/receipt.test.mjs +187 -0
- package/authoring/shadcn/source-variants.d.mts +28 -0
- package/authoring/shadcn/source-variants.mjs +176 -0
- package/authoring/shadcn/source-variants.test.mjs +120 -0
- package/clients/cli/commands/build-theme.mjs +54 -19
- package/clients/cli/commands/build-theme.variants.test.mjs +15 -12
- package/clients/cli/commands/component/index.mjs +1 -1
- package/clients/cli/commands/docs.test.mjs +1 -0
- package/clients/cli/commands/doctor-integration.doc.mjs +1 -1
- package/clients/cli/commands/gap-report.doc.mjs +73 -0
- package/clients/cli/commands/gap-report.mjs +114 -0
- package/clients/cli/commands/gap-report.test.mjs +198 -0
- package/clients/cli/commands/import-hint-correctness.test.mjs +88 -0
- package/clients/cli/commands/integration-add.doc.mjs +88 -0
- package/clients/cli/commands/integration-authoring.test.mjs +177 -0
- package/clients/cli/commands/integration-pack.doc.mjs +34 -0
- package/clients/cli/commands/integration-real-world.test.mjs +618 -0
- package/clients/cli/commands/integration.doc.mjs +28 -0
- package/clients/cli/commands/integration.mjs +153 -0
- package/clients/cli/commands/theme-add.doc.mjs +11 -6
- package/clients/cli/commands/theme-list.doc.mjs +21 -5
- package/clients/cli/commands/theme-targets.behavior.test.mjs +19 -2
- package/clients/cli/commands/theme.doc.mjs +2 -2
- package/clients/cli/commands/upgrade.doc.mjs +17 -4
- package/clients/cli/commands/upgrade.mjs +12 -1
- package/clients/cli/commands/upgrade.test.mjs +41 -0
- package/clients/cli/index.mjs +5 -0
- package/clients/cli/lib/component-format.mjs +42 -26
- package/clients/cli/lib/component-format.test.mjs +34 -3
- package/clients/cli/lib/manifest.mjs +12 -0
- package/foundation/config/project-themes.test.mjs +127 -0
- package/foundation/config/project.d.mts +23 -4
- package/foundation/config/project.mjs +96 -9
- package/foundation/config/project.test.mjs +132 -6
- package/foundation/discovery/component-discovery.d.mts +36 -0
- package/foundation/discovery/component-discovery.mjs +96 -0
- package/foundation/discovery/theme-discovery.d.mts +39 -0
- package/foundation/discovery/theme-discovery.mjs +650 -0
- package/foundation/discovery/theme-discovery.test.mjs +375 -0
- package/foundation/discovery/theming-targets.d.mts +16 -0
- package/foundation/discovery/theming-targets.mjs +39 -3
- package/foundation/discovery/theming-targets.test.mjs +139 -0
- package/foundation/integrations/autolink.d.mts +96 -0
- package/foundation/integrations/autolink.mjs +265 -0
- package/foundation/integrations/autolink.test.mjs +430 -0
- package/foundation/integrations/contribution-inventory.d.mts +152 -0
- package/foundation/integrations/contribution-inventory.mjs +497 -0
- package/foundation/integrations/contribution-inventory.test.mjs +361 -0
- package/foundation/integrations/integrations.d.mts +73 -9
- package/foundation/integrations/integrations.mjs +158 -8
- package/foundation/integrations/integrations.test.mjs +152 -29
- package/foundation/integrations/manifest-writer.d.mts +56 -0
- package/foundation/integrations/manifest-writer.mjs +328 -0
- package/foundation/integrations/manifest-writer.test.mjs +229 -0
- package/foundation/integrations/validate-contributions.mjs +81 -6
- package/foundation/response/error-codes.d.mts +4 -1
- package/foundation/response/error-codes.doc.mjs +16 -1
- package/foundation/response/error-codes.mjs +10 -1
- package/foundation/response/response-types.doc.mjs +23 -2
- package/package.json +8 -1
|
@@ -0,0 +1,375 @@
|
|
|
1
|
+
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
|
|
3
|
+
import {afterEach, beforeEach, describe, expect, it} from 'vitest';
|
|
4
|
+
import * as fs from 'node:fs';
|
|
5
|
+
import * as os from 'node:os';
|
|
6
|
+
import * as path from 'node:path';
|
|
7
|
+
import {
|
|
8
|
+
BUNDLED_THEME_PACKAGE,
|
|
9
|
+
discoverBundledThemes,
|
|
10
|
+
discoverIntegrationThemes,
|
|
11
|
+
discoverThemeCatalog,
|
|
12
|
+
} from './theme-discovery.mjs';
|
|
13
|
+
|
|
14
|
+
let tmpDir;
|
|
15
|
+
|
|
16
|
+
function writeCatalog(entries) {
|
|
17
|
+
fs.mkdirSync(tmpDir, {recursive: true});
|
|
18
|
+
for (const entry of entries) {
|
|
19
|
+
const themeDir = path.join(tmpDir, entry.slug);
|
|
20
|
+
fs.mkdirSync(themeDir, {recursive: true});
|
|
21
|
+
for (const file of entry.files) {
|
|
22
|
+
const target = path.join(themeDir, file);
|
|
23
|
+
fs.mkdirSync(path.dirname(target), {recursive: true});
|
|
24
|
+
fs.writeFileSync(target, `export const ${entry.exportName} = {};\n`);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
fs.writeFileSync(
|
|
28
|
+
path.join(tmpDir, 'manifest.json'),
|
|
29
|
+
JSON.stringify({version: 1, themes: entries}),
|
|
30
|
+
);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const ocean = {
|
|
34
|
+
slug: 'ocean',
|
|
35
|
+
displayName: 'Ocean',
|
|
36
|
+
description: 'Blue and calm.',
|
|
37
|
+
maintained: true,
|
|
38
|
+
entry: 'oceanTheme.ts',
|
|
39
|
+
exportName: 'oceanTheme',
|
|
40
|
+
files: ['oceanTheme.ts'],
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
beforeEach(() => {
|
|
44
|
+
tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'astryx-theme-catalog-'));
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
afterEach(() => {
|
|
48
|
+
fs.rmSync(tmpDir, {recursive: true, force: true});
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
describe('theme catalog discovery', () => {
|
|
52
|
+
it('reads the existing bundled catalog with package ownership', () => {
|
|
53
|
+
const themes = discoverBundledThemes();
|
|
54
|
+
expect(themes.length).toBeGreaterThan(0);
|
|
55
|
+
expect(themes.every(theme => theme.package === BUNDLED_THEME_PACKAGE)).toBe(
|
|
56
|
+
true,
|
|
57
|
+
);
|
|
58
|
+
expect(themes.every(theme => theme.bundled)).toBe(true);
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
it('reads the canonical manifest-plus-slug-directory shape', () => {
|
|
62
|
+
writeCatalog([ocean]);
|
|
63
|
+
expect(discoverThemeCatalog(tmpDir, '@acme/themes')).toEqual([
|
|
64
|
+
expect.objectContaining({
|
|
65
|
+
...ocean,
|
|
66
|
+
package: '@acme/themes',
|
|
67
|
+
sourceDir: path.join(tmpDir, 'ocean'),
|
|
68
|
+
bundled: false,
|
|
69
|
+
}),
|
|
70
|
+
]);
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
it('parses a named runtime export without executing the entry', async () => {
|
|
74
|
+
writeCatalog([ocean]);
|
|
75
|
+
fs.writeFileSync(
|
|
76
|
+
path.join(tmpDir, 'ocean', 'oceanTheme.ts'),
|
|
77
|
+
"throw new Error('theme source executed');\nexport const oceanTheme = {};\n",
|
|
78
|
+
);
|
|
79
|
+
|
|
80
|
+
await expect(
|
|
81
|
+
discoverIntegrationThemes({name: '@acme/themes', themes: tmpDir}),
|
|
82
|
+
).resolves.toEqual([
|
|
83
|
+
expect.objectContaining({slug: 'ocean', exportName: 'oceanTheme'}),
|
|
84
|
+
]);
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
it('rejects an entry that does not export the catalog name', async () => {
|
|
88
|
+
writeCatalog([ocean]);
|
|
89
|
+
fs.writeFileSync(
|
|
90
|
+
path.join(tmpDir, 'ocean', 'oceanTheme.ts'),
|
|
91
|
+
'export const anotherTheme = {};\n',
|
|
92
|
+
);
|
|
93
|
+
|
|
94
|
+
await expect(
|
|
95
|
+
discoverIntegrationThemes({name: '@acme/themes', themes: tmpDir}),
|
|
96
|
+
).rejects.toThrow(
|
|
97
|
+
'Theme catalog for @acme/themes entry "oceanTheme.ts" does not export "oceanTheme".',
|
|
98
|
+
);
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
it('rejects a type-only export of the catalog name', async () => {
|
|
102
|
+
writeCatalog([ocean]);
|
|
103
|
+
fs.writeFileSync(
|
|
104
|
+
path.join(tmpDir, 'ocean', 'oceanTheme.ts'),
|
|
105
|
+
'export type oceanTheme = {};\n',
|
|
106
|
+
);
|
|
107
|
+
|
|
108
|
+
await expect(
|
|
109
|
+
discoverIntegrationThemes({name: '@acme/themes', themes: tmpDir}),
|
|
110
|
+
).rejects.toThrow(/does not export "oceanTheme"/u);
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
it('rejects an unbound source-less export specifier', async () => {
|
|
114
|
+
writeCatalog([ocean]);
|
|
115
|
+
fs.writeFileSync(
|
|
116
|
+
path.join(tmpDir, 'ocean', 'oceanTheme.ts'),
|
|
117
|
+
'export {oceanTheme};\n',
|
|
118
|
+
);
|
|
119
|
+
|
|
120
|
+
await expect(
|
|
121
|
+
discoverIntegrationThemes({name: '@acme/themes', themes: tmpDir}),
|
|
122
|
+
).rejects.toThrow(
|
|
123
|
+
/could not be parsed: Export 'oceanTheme' is not defined/u,
|
|
124
|
+
);
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
it('accepts a source-less export backed by a local runtime declaration', async () => {
|
|
128
|
+
writeCatalog([ocean]);
|
|
129
|
+
fs.writeFileSync(
|
|
130
|
+
path.join(tmpDir, 'ocean', 'oceanTheme.ts'),
|
|
131
|
+
'const oceanTheme = {};\nexport {oceanTheme};\n',
|
|
132
|
+
);
|
|
133
|
+
|
|
134
|
+
await expect(
|
|
135
|
+
discoverIntegrationThemes({name: '@acme/themes', themes: tmpDir}),
|
|
136
|
+
).resolves.toEqual([
|
|
137
|
+
expect.objectContaining({slug: 'ocean', exportName: 'oceanTheme'}),
|
|
138
|
+
]);
|
|
139
|
+
});
|
|
140
|
+
|
|
141
|
+
it('accepts a source-less export backed by a listed imported alias', async () => {
|
|
142
|
+
writeCatalog([{...ocean, files: ['oceanTheme.ts', 'theme.ts']}]);
|
|
143
|
+
fs.writeFileSync(
|
|
144
|
+
path.join(tmpDir, 'ocean', 'oceanTheme.ts'),
|
|
145
|
+
"import {theme as oceanTheme} from './theme';\nexport {oceanTheme};\n",
|
|
146
|
+
);
|
|
147
|
+
fs.writeFileSync(
|
|
148
|
+
path.join(tmpDir, 'ocean', 'theme.ts'),
|
|
149
|
+
'export const theme = {};\n',
|
|
150
|
+
);
|
|
151
|
+
|
|
152
|
+
await expect(
|
|
153
|
+
discoverIntegrationThemes({name: '@acme/themes', themes: tmpDir}),
|
|
154
|
+
).resolves.toEqual([
|
|
155
|
+
expect.objectContaining({slug: 'ocean', exportName: 'oceanTheme'}),
|
|
156
|
+
]);
|
|
157
|
+
});
|
|
158
|
+
|
|
159
|
+
it('accepts a source-less export backed by a bare package import', async () => {
|
|
160
|
+
writeCatalog([ocean]);
|
|
161
|
+
fs.writeFileSync(
|
|
162
|
+
path.join(tmpDir, 'ocean', 'oceanTheme.ts'),
|
|
163
|
+
"import {defineTheme as oceanTheme} from '@astryxdesign/core/theme';\nexport {oceanTheme};\n",
|
|
164
|
+
);
|
|
165
|
+
|
|
166
|
+
await expect(
|
|
167
|
+
discoverIntegrationThemes({name: '@acme/themes', themes: tmpDir}),
|
|
168
|
+
).resolves.toEqual([
|
|
169
|
+
expect.objectContaining({slug: 'ocean', exportName: 'oceanTheme'}),
|
|
170
|
+
]);
|
|
171
|
+
});
|
|
172
|
+
|
|
173
|
+
it('follows a listed default re-export', async () => {
|
|
174
|
+
writeCatalog([{...ocean, files: ['oceanTheme.ts', 'theme.ts']}]);
|
|
175
|
+
fs.writeFileSync(
|
|
176
|
+
path.join(tmpDir, 'ocean', 'oceanTheme.ts'),
|
|
177
|
+
"export {default as oceanTheme} from './theme';\n",
|
|
178
|
+
);
|
|
179
|
+
fs.writeFileSync(
|
|
180
|
+
path.join(tmpDir, 'ocean', 'theme.ts'),
|
|
181
|
+
'export default {};\n',
|
|
182
|
+
);
|
|
183
|
+
|
|
184
|
+
await expect(
|
|
185
|
+
discoverIntegrationThemes({name: '@acme/themes', themes: tmpDir}),
|
|
186
|
+
).resolves.toEqual([
|
|
187
|
+
expect.objectContaining({slug: 'ocean', exportName: 'oceanTheme'}),
|
|
188
|
+
]);
|
|
189
|
+
});
|
|
190
|
+
|
|
191
|
+
it('follows local export-all barrels without executing them', async () => {
|
|
192
|
+
writeCatalog([{...ocean, files: ['oceanTheme.ts', 'theme.ts']}]);
|
|
193
|
+
fs.writeFileSync(
|
|
194
|
+
path.join(tmpDir, 'ocean', 'oceanTheme.ts'),
|
|
195
|
+
"export * from './theme';\n",
|
|
196
|
+
);
|
|
197
|
+
fs.writeFileSync(
|
|
198
|
+
path.join(tmpDir, 'ocean', 'theme.ts'),
|
|
199
|
+
"throw new Error('theme source executed');\nexport const oceanTheme = {};\n",
|
|
200
|
+
);
|
|
201
|
+
|
|
202
|
+
await expect(
|
|
203
|
+
discoverIntegrationThemes({name: '@acme/themes', themes: tmpDir}),
|
|
204
|
+
).resolves.toEqual([
|
|
205
|
+
expect.objectContaining({slug: 'ocean', exportName: 'oceanTheme'}),
|
|
206
|
+
]);
|
|
207
|
+
});
|
|
208
|
+
|
|
209
|
+
it('accepts a listed nested palette import without executing it', async () => {
|
|
210
|
+
writeCatalog([
|
|
211
|
+
{...ocean, files: ['oceanTheme.ts', 'tokens/ocean.palette.ts']},
|
|
212
|
+
]);
|
|
213
|
+
fs.writeFileSync(
|
|
214
|
+
path.join(tmpDir, 'ocean', 'oceanTheme.ts'),
|
|
215
|
+
"import {oceanPalette} from './tokens/ocean.palette';\nexport const oceanTheme = {oceanPalette};\n",
|
|
216
|
+
);
|
|
217
|
+
fs.writeFileSync(
|
|
218
|
+
path.join(tmpDir, 'ocean', 'tokens', 'ocean.palette.ts'),
|
|
219
|
+
"throw new Error('palette source executed');\nexport const oceanPalette = {};\n",
|
|
220
|
+
);
|
|
221
|
+
|
|
222
|
+
await expect(
|
|
223
|
+
discoverIntegrationThemes({name: '@acme/themes', themes: tmpDir}),
|
|
224
|
+
).resolves.toEqual([
|
|
225
|
+
expect.objectContaining({slug: 'ocean', exportName: 'oceanTheme'}),
|
|
226
|
+
]);
|
|
227
|
+
});
|
|
228
|
+
|
|
229
|
+
it('rejects a direct import from an unlisted theme file', async () => {
|
|
230
|
+
writeCatalog([ocean]);
|
|
231
|
+
fs.mkdirSync(path.join(tmpDir, 'ocean', 'tokens'), {recursive: true});
|
|
232
|
+
fs.writeFileSync(
|
|
233
|
+
path.join(tmpDir, 'ocean', 'oceanTheme.ts'),
|
|
234
|
+
"import {oceanPalette} from './tokens/ocean.palette';\nexport const oceanTheme = {oceanPalette};\n",
|
|
235
|
+
);
|
|
236
|
+
fs.writeFileSync(
|
|
237
|
+
path.join(tmpDir, 'ocean', 'tokens', 'ocean.palette.ts'),
|
|
238
|
+
'export const oceanPalette = {};\n',
|
|
239
|
+
);
|
|
240
|
+
|
|
241
|
+
await expect(
|
|
242
|
+
discoverIntegrationThemes({name: '@acme/themes', themes: tmpDir}),
|
|
243
|
+
).rejects.toThrow(
|
|
244
|
+
/must resolve to a listed file inside the theme directory/u,
|
|
245
|
+
);
|
|
246
|
+
});
|
|
247
|
+
|
|
248
|
+
it('rejects a direct import outside the theme directory', async () => {
|
|
249
|
+
writeCatalog([ocean]);
|
|
250
|
+
fs.writeFileSync(
|
|
251
|
+
path.join(tmpDir, 'ocean', 'oceanTheme.ts'),
|
|
252
|
+
"import {oceanPalette} from '../outside';\nexport const oceanTheme = {oceanPalette};\n",
|
|
253
|
+
);
|
|
254
|
+
fs.writeFileSync(
|
|
255
|
+
path.join(tmpDir, 'outside.ts'),
|
|
256
|
+
'export const oceanPalette = {};\n',
|
|
257
|
+
);
|
|
258
|
+
|
|
259
|
+
await expect(
|
|
260
|
+
discoverIntegrationThemes({name: '@acme/themes', themes: tmpDir}),
|
|
261
|
+
).rejects.toThrow(
|
|
262
|
+
/must resolve to a listed file inside the theme directory/u,
|
|
263
|
+
);
|
|
264
|
+
});
|
|
265
|
+
|
|
266
|
+
it('rejects a literal dynamic import from an unlisted file', async () => {
|
|
267
|
+
const mjsTheme = {
|
|
268
|
+
...ocean,
|
|
269
|
+
entry: 'oceanTheme.mjs',
|
|
270
|
+
files: ['oceanTheme.mjs'],
|
|
271
|
+
};
|
|
272
|
+
writeCatalog([mjsTheme]);
|
|
273
|
+
fs.writeFileSync(
|
|
274
|
+
path.join(tmpDir, 'ocean', 'oceanTheme.mjs'),
|
|
275
|
+
"void import('./extra.mjs');\nexport const oceanTheme = {};\n",
|
|
276
|
+
);
|
|
277
|
+
fs.writeFileSync(
|
|
278
|
+
path.join(tmpDir, 'ocean', 'extra.mjs'),
|
|
279
|
+
'export const extra = {};\n',
|
|
280
|
+
);
|
|
281
|
+
|
|
282
|
+
await expect(
|
|
283
|
+
discoverIntegrationThemes({name: '@acme/themes', themes: tmpDir}),
|
|
284
|
+
).rejects.toThrow(
|
|
285
|
+
/must resolve to a listed file inside the theme directory/u,
|
|
286
|
+
);
|
|
287
|
+
});
|
|
288
|
+
|
|
289
|
+
it('rejects a re-export outside the theme directory', async () => {
|
|
290
|
+
writeCatalog([ocean]);
|
|
291
|
+
fs.writeFileSync(
|
|
292
|
+
path.join(tmpDir, 'ocean', 'oceanTheme.ts'),
|
|
293
|
+
"export * from '../outside';\n",
|
|
294
|
+
);
|
|
295
|
+
fs.writeFileSync(
|
|
296
|
+
path.join(tmpDir, 'outside.ts'),
|
|
297
|
+
'export const oceanTheme = {};\n',
|
|
298
|
+
);
|
|
299
|
+
|
|
300
|
+
await expect(
|
|
301
|
+
discoverIntegrationThemes({name: '@acme/themes', themes: tmpDir}),
|
|
302
|
+
).rejects.toThrow(
|
|
303
|
+
/must resolve to a listed file inside the theme directory/u,
|
|
304
|
+
);
|
|
305
|
+
});
|
|
306
|
+
|
|
307
|
+
it('rejects a re-export from an unlisted theme file', async () => {
|
|
308
|
+
writeCatalog([ocean]);
|
|
309
|
+
fs.writeFileSync(
|
|
310
|
+
path.join(tmpDir, 'ocean', 'oceanTheme.ts'),
|
|
311
|
+
"export * from './theme';\n",
|
|
312
|
+
);
|
|
313
|
+
fs.writeFileSync(
|
|
314
|
+
path.join(tmpDir, 'ocean', 'theme.ts'),
|
|
315
|
+
'export const oceanTheme = {};\n',
|
|
316
|
+
);
|
|
317
|
+
|
|
318
|
+
await expect(
|
|
319
|
+
discoverIntegrationThemes({name: '@acme/themes', themes: tmpDir}),
|
|
320
|
+
).rejects.toThrow(
|
|
321
|
+
/must resolve to a listed file inside the theme directory/u,
|
|
322
|
+
);
|
|
323
|
+
});
|
|
324
|
+
|
|
325
|
+
it('rejects duplicate slugs case-insensitively', () => {
|
|
326
|
+
writeCatalog([ocean, {...ocean, slug: 'OCEAN'}]);
|
|
327
|
+
expect(() => discoverThemeCatalog(tmpDir, '@acme/themes')).toThrow(
|
|
328
|
+
/invalid slug|duplicate slug/u,
|
|
329
|
+
);
|
|
330
|
+
});
|
|
331
|
+
|
|
332
|
+
it('rejects files that escape the theme directory', () => {
|
|
333
|
+
fs.mkdirSync(path.join(tmpDir, 'ocean'), {recursive: true});
|
|
334
|
+
fs.writeFileSync(
|
|
335
|
+
path.join(tmpDir, 'outside.ts'),
|
|
336
|
+
'export const oceanTheme = {};\n',
|
|
337
|
+
);
|
|
338
|
+
fs.writeFileSync(
|
|
339
|
+
path.join(tmpDir, 'manifest.json'),
|
|
340
|
+
JSON.stringify({
|
|
341
|
+
version: 1,
|
|
342
|
+
themes: [
|
|
343
|
+
{
|
|
344
|
+
...ocean,
|
|
345
|
+
entry: '../outside.ts',
|
|
346
|
+
files: ['../outside.ts'],
|
|
347
|
+
},
|
|
348
|
+
],
|
|
349
|
+
}),
|
|
350
|
+
);
|
|
351
|
+
expect(() => discoverThemeCatalog(tmpDir, '@acme/themes')).toThrow(
|
|
352
|
+
/must stay inside/u,
|
|
353
|
+
);
|
|
354
|
+
});
|
|
355
|
+
|
|
356
|
+
it('rejects a missing catalog file and a missing listed source', () => {
|
|
357
|
+
expect(() => discoverThemeCatalog(tmpDir, '@acme/themes')).toThrow(
|
|
358
|
+
/must contain manifest\.json/u,
|
|
359
|
+
);
|
|
360
|
+
fs.writeFileSync(
|
|
361
|
+
path.join(tmpDir, 'manifest.json'),
|
|
362
|
+
JSON.stringify({version: 1, themes: [ocean]}),
|
|
363
|
+
);
|
|
364
|
+
expect(() => discoverThemeCatalog(tmpDir, '@acme/themes')).toThrow(
|
|
365
|
+
/missing directory "ocean"/u,
|
|
366
|
+
);
|
|
367
|
+
});
|
|
368
|
+
|
|
369
|
+
it('requires the named entry to be one of the copied files', () => {
|
|
370
|
+
writeCatalog([{...ocean, files: ['other.ts']}]);
|
|
371
|
+
expect(() => discoverThemeCatalog(tmpDir, '@acme/themes')).toThrow(
|
|
372
|
+
/must include entry/u,
|
|
373
|
+
);
|
|
374
|
+
});
|
|
375
|
+
});
|
|
@@ -43,6 +43,18 @@ export function collectThemingVars(coreSrc: string): Promise<ThemingVar[]>;
|
|
|
43
43
|
* @returns {Record<string, string[]>}
|
|
44
44
|
*/
|
|
45
45
|
export function targetsByKey(targets: ThemingTarget[]): Record<string, string[]>;
|
|
46
|
+
/**
|
|
47
|
+
* Build the component-validation registry from the same target rows used by
|
|
48
|
+
* `theme targets`. Deprecated keys stay accepted during their compatibility
|
|
49
|
+
* window, while the replacement map lets theme build issue exact guidance.
|
|
50
|
+
*
|
|
51
|
+
* @param {ThemingTarget[]} targets
|
|
52
|
+
* @returns {{propsByKey: Record<string, string[]>, deprecatedByKey: Record<string, string>}}
|
|
53
|
+
*/
|
|
54
|
+
export function targetValidationRegistry(targets: ThemingTarget[]): {
|
|
55
|
+
propsByKey: Record<string, string[]>;
|
|
56
|
+
deprecatedByKey: Record<string, string>;
|
|
57
|
+
};
|
|
46
58
|
/**
|
|
47
59
|
* One theming target, as a theme author has to write it.
|
|
48
60
|
*/
|
|
@@ -67,6 +79,10 @@ export type ThemingTarget = {
|
|
|
67
79
|
* - runtime states the target reflects (bare-name keys)
|
|
68
80
|
*/
|
|
69
81
|
states: string[];
|
|
82
|
+
/**
|
|
83
|
+
* - canonical replacement key for a deprecated target
|
|
84
|
+
*/
|
|
85
|
+
deprecatedFor?: string | undefined;
|
|
70
86
|
};
|
|
71
87
|
/**
|
|
72
88
|
* One public custom property a theme may set on a component's target.
|
|
@@ -28,6 +28,7 @@ const SKIP_DIRS = new Set(['node_modules', '__tests__']);
|
|
|
28
28
|
* @property {string} component - the component whose doc declares it
|
|
29
29
|
* @property {string[]} props - visual props the target reflects (`variant:value` keys)
|
|
30
30
|
* @property {string[]} states - runtime states the target reflects (bare-name keys)
|
|
31
|
+
* @property {string} [deprecatedFor] - canonical replacement key for a deprecated target
|
|
31
32
|
*/
|
|
32
33
|
|
|
33
34
|
/**
|
|
@@ -104,6 +105,9 @@ export async function collectThemingTargets(
|
|
|
104
105
|
typeof doc?.subComponentOf === 'string' ? doc.subComponentOf : null,
|
|
105
106
|
props: stringList(target.visualProps),
|
|
106
107
|
states: stringList(target.states),
|
|
108
|
+
...(typeof target.deprecatedFor === 'string'
|
|
109
|
+
? {deprecatedFor: target.deprecatedFor}
|
|
110
|
+
: {}),
|
|
107
111
|
});
|
|
108
112
|
}
|
|
109
113
|
}
|
|
@@ -113,7 +117,8 @@ export async function collectThemingTargets(
|
|
|
113
117
|
|
|
114
118
|
const canonical = canonicalizeParentTargets(targets);
|
|
115
119
|
canonical.sort(
|
|
116
|
-
(a, b) =>
|
|
120
|
+
(a, b) =>
|
|
121
|
+
a.key.localeCompare(b.key) || a.component.localeCompare(b.component),
|
|
117
122
|
);
|
|
118
123
|
return canonical;
|
|
119
124
|
}
|
|
@@ -146,12 +151,14 @@ function canonicalizeParentTargets(targets) {
|
|
|
146
151
|
for (const target of targets) {
|
|
147
152
|
if (target.parent == null) continue;
|
|
148
153
|
const roots =
|
|
149
|
-
rootsByComponentAndClass.get(`${target.parent}\0${target.className}`) ??
|
|
154
|
+
rootsByComponentAndClass.get(`${target.parent}\0${target.className}`) ??
|
|
155
|
+
[];
|
|
150
156
|
if (roots.length !== 1) continue;
|
|
151
157
|
|
|
152
158
|
const canonical = roots[0];
|
|
153
159
|
canonical.props = [...new Set([...canonical.props, ...target.props])];
|
|
154
160
|
canonical.states = [...new Set([...canonical.states, ...target.states])];
|
|
161
|
+
canonical.deprecatedFor ??= target.deprecatedFor;
|
|
155
162
|
duplicates.add(target);
|
|
156
163
|
}
|
|
157
164
|
|
|
@@ -238,11 +245,40 @@ export function targetsByKey(targets) {
|
|
|
238
245
|
/** @type {Record<string, string[]>} */
|
|
239
246
|
const byKey = {};
|
|
240
247
|
for (const t of targets) {
|
|
241
|
-
byKey[t.key] = [
|
|
248
|
+
byKey[t.key] = [
|
|
249
|
+
...new Set([...(byKey[t.key] || []), ...t.props, ...t.states]),
|
|
250
|
+
];
|
|
242
251
|
}
|
|
243
252
|
return byKey;
|
|
244
253
|
}
|
|
245
254
|
|
|
255
|
+
/**
|
|
256
|
+
* Build the component-validation registry from the same target rows used by
|
|
257
|
+
* `theme targets`. Deprecated keys stay accepted during their compatibility
|
|
258
|
+
* window, while the replacement map lets theme build issue exact guidance.
|
|
259
|
+
*
|
|
260
|
+
* @param {ThemingTarget[]} targets
|
|
261
|
+
* @returns {{propsByKey: Record<string, string[]>, deprecatedByKey: Record<string, string>}}
|
|
262
|
+
*/
|
|
263
|
+
export function targetValidationRegistry(targets) {
|
|
264
|
+
const propsByKey = targetsByKey(targets);
|
|
265
|
+
/** @type {Record<string, string>} */
|
|
266
|
+
const deprecatedByKey = {};
|
|
267
|
+
|
|
268
|
+
for (const target of targets) {
|
|
269
|
+
if (target.deprecatedFor == null) continue;
|
|
270
|
+
const existing = deprecatedByKey[target.key];
|
|
271
|
+
if (existing != null && existing !== target.deprecatedFor) {
|
|
272
|
+
throw new Error(
|
|
273
|
+
`Deprecated theme target "${target.key}" has conflicting replacements: "${existing}" and "${target.deprecatedFor}".`,
|
|
274
|
+
);
|
|
275
|
+
}
|
|
276
|
+
deprecatedByKey[target.key] = target.deprecatedFor;
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
return {propsByKey, deprecatedByKey};
|
|
280
|
+
}
|
|
281
|
+
|
|
246
282
|
/**
|
|
247
283
|
* @param {unknown} value
|
|
248
284
|
* @returns {string[]}
|
|
@@ -34,10 +34,62 @@ import {
|
|
|
34
34
|
collectThemingTargets,
|
|
35
35
|
collectThemingVars,
|
|
36
36
|
targetsByKey,
|
|
37
|
+
targetValidationRegistry,
|
|
37
38
|
} from './theming-targets.mjs';
|
|
38
39
|
|
|
39
40
|
const coreDir = /** @type {string} */ (findCoreDir(process.cwd()));
|
|
40
41
|
const coreSrc = path.join(coreDir, 'src');
|
|
42
|
+
const repoRoot = path.resolve(coreDir, '../..');
|
|
43
|
+
|
|
44
|
+
const DEPRECATED_TARGETS = {
|
|
45
|
+
'base-table': 'table',
|
|
46
|
+
checkbox: 'checkbox-indicator',
|
|
47
|
+
codeblock: 'code-block',
|
|
48
|
+
'codeblock-copy-button': 'code-block-copy-button',
|
|
49
|
+
'codeblock-header': 'code-block-header',
|
|
50
|
+
'codeblock-title': 'code-block-title',
|
|
51
|
+
'date-input-clear-icon': 'input-clear-icon',
|
|
52
|
+
'date-range-input-clear-icon': 'input-clear-icon',
|
|
53
|
+
hovercard: 'hover-card',
|
|
54
|
+
'multi-selector-clear-icon': 'input-clear-icon',
|
|
55
|
+
navicon: 'nav-icon',
|
|
56
|
+
'popover-surface': 'popover',
|
|
57
|
+
progressbar: 'progress-bar',
|
|
58
|
+
'progressbar-fill': 'progress-bar-fill',
|
|
59
|
+
'progressbar-mark': 'progress-bar-mark',
|
|
60
|
+
'progressbar-track': 'progress-bar-track',
|
|
61
|
+
radio: 'radio-indicator',
|
|
62
|
+
'radio-dot': 'radio-indicator-dot',
|
|
63
|
+
'selector-clear-icon': 'input-clear-icon',
|
|
64
|
+
statusdot: 'status-dot',
|
|
65
|
+
textarea: 'text-area',
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
/** Return the source text inside a static `components: {…}` object. */
|
|
69
|
+
function componentsObjectSource(source) {
|
|
70
|
+
const match = /\bcomponents\s*:\s*\{/.exec(source);
|
|
71
|
+
if (match == null) return '';
|
|
72
|
+
const start = match.index + match[0].length - 1;
|
|
73
|
+
let depth = 0;
|
|
74
|
+
let quote = null;
|
|
75
|
+
let escaped = false;
|
|
76
|
+
for (let index = start; index < source.length; index++) {
|
|
77
|
+
const char = source[index];
|
|
78
|
+
if (quote != null) {
|
|
79
|
+
if (escaped) escaped = false;
|
|
80
|
+
else if (char === '\\') escaped = true;
|
|
81
|
+
else if (char === quote) quote = null;
|
|
82
|
+
continue;
|
|
83
|
+
}
|
|
84
|
+
if (char === "'" || char === '"' || char === '`') {
|
|
85
|
+
quote = char;
|
|
86
|
+
continue;
|
|
87
|
+
}
|
|
88
|
+
if (char === '{') depth++;
|
|
89
|
+
if (char === '}' && --depth === 0) return source.slice(start + 1, index);
|
|
90
|
+
}
|
|
91
|
+
return '';
|
|
92
|
+
}
|
|
41
93
|
|
|
42
94
|
/** @type {Promise<import('./theming-targets.mjs').ThemingTarget[]>} */
|
|
43
95
|
const enumerated = collectThemingTargets(coreSrc);
|
|
@@ -93,6 +145,93 @@ describe('collectThemingTargets', () => {
|
|
|
93
145
|
});
|
|
94
146
|
});
|
|
95
147
|
|
|
148
|
+
it('keeps every deprecated target discoverable with its exact replacement', async () => {
|
|
149
|
+
const targets = await enumerated;
|
|
150
|
+
for (const [key, deprecatedFor] of Object.entries(DEPRECATED_TARGETS)) {
|
|
151
|
+
expect(
|
|
152
|
+
targets.some(
|
|
153
|
+
target =>
|
|
154
|
+
target.key === key && target.deprecatedFor === deprecatedFor,
|
|
155
|
+
),
|
|
156
|
+
`${key} should remain discoverable as deprecated for ${deprecatedFor}`,
|
|
157
|
+
).toBe(true);
|
|
158
|
+
}
|
|
159
|
+
});
|
|
160
|
+
|
|
161
|
+
it('keeps maintained themes and copyable sources on canonical keys', () => {
|
|
162
|
+
const themeFiles = [
|
|
163
|
+
'packages/themes/butter/src/butterTheme.ts',
|
|
164
|
+
'packages/themes/chocolate/src/chocolateTheme.ts',
|
|
165
|
+
'packages/themes/gothic/src/gothicTheme.ts',
|
|
166
|
+
'packages/themes/matcha/src/matchaTheme.ts',
|
|
167
|
+
'packages/themes/neutral/src/neutralTheme.ts',
|
|
168
|
+
'packages/themes/stone/src/stoneTheme.ts',
|
|
169
|
+
'packages/themes/y2k/src/y2kTheme.ts',
|
|
170
|
+
'packages/cli/assets/templates/themes/butter/butterTheme.ts',
|
|
171
|
+
'packages/cli/assets/templates/themes/chocolate/chocolateTheme.ts',
|
|
172
|
+
'packages/cli/assets/templates/themes/gothic/gothicTheme.ts',
|
|
173
|
+
'packages/cli/assets/templates/themes/matcha/matchaTheme.ts',
|
|
174
|
+
'packages/cli/assets/templates/themes/neutral/neutralTheme.ts',
|
|
175
|
+
'packages/cli/assets/templates/themes/stone/stoneTheme.ts',
|
|
176
|
+
'packages/cli/assets/templates/themes/y2k/y2kTheme.ts',
|
|
177
|
+
];
|
|
178
|
+
for (const relativePath of themeFiles) {
|
|
179
|
+
const components = componentsObjectSource(
|
|
180
|
+
fs.readFileSync(path.join(repoRoot, relativePath), 'utf8'),
|
|
181
|
+
);
|
|
182
|
+
for (const key of Object.keys(DEPRECATED_TARGETS)) {
|
|
183
|
+
const escaped = key.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
184
|
+
expect(components, `${relativePath} still uses ${key}`).not.toMatch(
|
|
185
|
+
new RegExp(`(?:^|[,\\n]\\s*)(?:['"]${escaped}['"]|${escaped})\\s*:`),
|
|
186
|
+
);
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
const editorSource = fs.readFileSync(
|
|
191
|
+
path.join(
|
|
192
|
+
repoRoot,
|
|
193
|
+
'apps/docsite/src/app/playground/themeEditor/constants.ts',
|
|
194
|
+
),
|
|
195
|
+
'utf8',
|
|
196
|
+
);
|
|
197
|
+
for (const key of Object.keys(DEPRECATED_TARGETS)) {
|
|
198
|
+
expect(editorSource, `theme editor still exposes ${key}`).not.toContain(
|
|
199
|
+
`'${key}'`,
|
|
200
|
+
);
|
|
201
|
+
}
|
|
202
|
+
});
|
|
203
|
+
|
|
204
|
+
it('keeps deprecated replacements in the validation registry', async () => {
|
|
205
|
+
const registry = targetValidationRegistry(await enumerated);
|
|
206
|
+
for (const [key, replacement] of Object.entries(DEPRECATED_TARGETS)) {
|
|
207
|
+
expect(registry.propsByKey).toHaveProperty(key);
|
|
208
|
+
expect(registry.deprecatedByKey[key]).toBe(replacement);
|
|
209
|
+
}
|
|
210
|
+
});
|
|
211
|
+
|
|
212
|
+
it('rejects conflicting canonical replacements for one deprecated key', () => {
|
|
213
|
+
expect(() =>
|
|
214
|
+
targetValidationRegistry([
|
|
215
|
+
{
|
|
216
|
+
key: 'old-target',
|
|
217
|
+
className: 'astryx-old-target',
|
|
218
|
+
component: 'One',
|
|
219
|
+
props: [],
|
|
220
|
+
states: [],
|
|
221
|
+
deprecatedFor: 'first-target',
|
|
222
|
+
},
|
|
223
|
+
{
|
|
224
|
+
key: 'old-target',
|
|
225
|
+
className: 'astryx-old-target',
|
|
226
|
+
component: 'Two',
|
|
227
|
+
props: [],
|
|
228
|
+
states: [],
|
|
229
|
+
deprecatedFor: 'second-target',
|
|
230
|
+
},
|
|
231
|
+
]),
|
|
232
|
+
).toThrow(/conflicting replacements/);
|
|
233
|
+
});
|
|
234
|
+
|
|
96
235
|
it('carries the props and states a target reflects', async () => {
|
|
97
236
|
const targets = await enumerated;
|
|
98
237
|
expect(targets.find(t => t.key === 'switch-thumb')).toEqual({
|