@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,361 @@
|
|
|
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 path from 'node:path';
|
|
6
|
+
import {
|
|
7
|
+
computeRequiredFiles,
|
|
8
|
+
compareIdentities,
|
|
9
|
+
findSourceOnlyCandidates,
|
|
10
|
+
} from './contribution-inventory.mjs';
|
|
11
|
+
|
|
12
|
+
let tmpDir;
|
|
13
|
+
|
|
14
|
+
beforeEach(() => {
|
|
15
|
+
tmpDir = fs.mkdtempSync(path.join(process.cwd(), '.astryx-ci-'));
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
afterEach(() => {
|
|
19
|
+
fs.rmSync(tmpDir, {recursive: true, force: true});
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
/** Build a minimal LoadedIntegration-shaped object from fixture contents. */
|
|
23
|
+
function loaded(overrides = {}) {
|
|
24
|
+
const manifestFile = path.join(tmpDir, 'astryx.integration.mjs');
|
|
25
|
+
if (!fs.existsSync(manifestFile)) {
|
|
26
|
+
fs.writeFileSync(manifestFile, 'export default {};\n');
|
|
27
|
+
}
|
|
28
|
+
return {
|
|
29
|
+
name: '@acme/widgets',
|
|
30
|
+
version: '1.0.0',
|
|
31
|
+
__spec: '@acme/widgets',
|
|
32
|
+
__packageDir: tmpDir,
|
|
33
|
+
__manifestFile: manifestFile,
|
|
34
|
+
...overrides,
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
function writeTheme(slug, files = [`${slug}Theme.ts`]) {
|
|
39
|
+
const root = path.join(tmpDir, 'themes');
|
|
40
|
+
fs.mkdirSync(path.join(root, slug), {recursive: true});
|
|
41
|
+
for (const f of files) {
|
|
42
|
+
fs.writeFileSync(path.join(root, slug, f), `// ${f}\n`);
|
|
43
|
+
}
|
|
44
|
+
const catalogPath = path.join(root, 'manifest.json');
|
|
45
|
+
let catalog = {version: 1, themes: []};
|
|
46
|
+
if (fs.existsSync(catalogPath)) {
|
|
47
|
+
catalog = JSON.parse(fs.readFileSync(catalogPath, 'utf-8'));
|
|
48
|
+
}
|
|
49
|
+
catalog.themes.push({
|
|
50
|
+
slug,
|
|
51
|
+
displayName: slug,
|
|
52
|
+
description: `${slug} theme.`,
|
|
53
|
+
maintained: true,
|
|
54
|
+
entry: files[0],
|
|
55
|
+
exportName: `${slug}Theme`,
|
|
56
|
+
files,
|
|
57
|
+
});
|
|
58
|
+
fs.writeFileSync(catalogPath, JSON.stringify(catalog, null, 2) + '\n');
|
|
59
|
+
return root;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
describe('computeRequiredFiles', () => {
|
|
63
|
+
it('enumerates manifest + theme catalog files', () => {
|
|
64
|
+
const root = writeTheme('ocean', ['oceanTheme.ts', 'tokens.ts']);
|
|
65
|
+
const inv = computeRequiredFiles(loaded({themes: root}));
|
|
66
|
+
|
|
67
|
+
expect(inv.manifest).toBe('astryx.integration.mjs');
|
|
68
|
+
expect(inv.roots).toHaveLength(1);
|
|
69
|
+
expect(inv.roots[0].kind).toBe('themes');
|
|
70
|
+
expect(inv.roots[0].files).toEqual(
|
|
71
|
+
expect.arrayContaining([
|
|
72
|
+
'themes/manifest.json',
|
|
73
|
+
'themes/ocean/oceanTheme.ts',
|
|
74
|
+
'themes/ocean/tokens.ts',
|
|
75
|
+
]),
|
|
76
|
+
);
|
|
77
|
+
expect(inv.allFiles).toContain('astryx.integration.mjs');
|
|
78
|
+
expect(inv.allFiles).toContain('themes/manifest.json');
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
it('enumerates paired component metadata and source files', () => {
|
|
82
|
+
const root = path.join(tmpDir, 'components');
|
|
83
|
+
fs.mkdirSync(root, {recursive: true});
|
|
84
|
+
for (const name of ['Card', 'Button']) {
|
|
85
|
+
fs.writeFileSync(path.join(root, `${name}.tsx`), `// ${name}\n`);
|
|
86
|
+
fs.writeFileSync(
|
|
87
|
+
path.join(root, `${name}.doc.mjs`),
|
|
88
|
+
`export default {type: 'component', name: '${name}', props: []};\n`,
|
|
89
|
+
);
|
|
90
|
+
}
|
|
91
|
+
fs.writeFileSync(path.join(root, 'PrivateHelper.tsx'), '// unpaired\n');
|
|
92
|
+
fs.writeFileSync(path.join(root, 'utils.ts'), '// not a component\n');
|
|
93
|
+
const inv = computeRequiredFiles(loaded({components: root}));
|
|
94
|
+
|
|
95
|
+
expect(inv.roots[0].kind).toBe('components');
|
|
96
|
+
expect(inv.roots[0].files).toEqual(
|
|
97
|
+
expect.arrayContaining([
|
|
98
|
+
'components/Button.doc.mjs',
|
|
99
|
+
'components/Button.tsx',
|
|
100
|
+
'components/Card.doc.mjs',
|
|
101
|
+
'components/Card.tsx',
|
|
102
|
+
]),
|
|
103
|
+
);
|
|
104
|
+
expect(inv.roots[0].files).not.toContain('components/PrivateHelper.tsx');
|
|
105
|
+
expect(inv.roots[0].files).not.toContain('components/utils.ts');
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
it('includes symlinked component metadata and source paths', () => {
|
|
109
|
+
const root = path.join(tmpDir, 'components');
|
|
110
|
+
const shared = path.join(tmpDir, 'shared');
|
|
111
|
+
fs.mkdirSync(root);
|
|
112
|
+
fs.mkdirSync(shared);
|
|
113
|
+
fs.writeFileSync(
|
|
114
|
+
path.join(shared, 'LinkedWidget.doc.mjs'),
|
|
115
|
+
"export default {type: 'component', name: 'LinkedWidget', props: []};\n",
|
|
116
|
+
);
|
|
117
|
+
fs.writeFileSync(
|
|
118
|
+
path.join(shared, 'LinkedWidget.tsx'),
|
|
119
|
+
'export function LinkedWidget() { return null; }\n',
|
|
120
|
+
);
|
|
121
|
+
fs.symlinkSync(
|
|
122
|
+
path.relative(root, path.join(shared, 'LinkedWidget.doc.mjs')),
|
|
123
|
+
path.join(root, 'LinkedWidget.doc.mjs'),
|
|
124
|
+
);
|
|
125
|
+
fs.symlinkSync(
|
|
126
|
+
path.relative(root, path.join(shared, 'LinkedWidget.tsx')),
|
|
127
|
+
path.join(root, 'LinkedWidget.tsx'),
|
|
128
|
+
);
|
|
129
|
+
|
|
130
|
+
const inventory = computeRequiredFiles(loaded({components: root}));
|
|
131
|
+
|
|
132
|
+
expect(inventory.roots[0].files).toEqual([
|
|
133
|
+
'components/LinkedWidget.doc.mjs',
|
|
134
|
+
'components/LinkedWidget.tsx',
|
|
135
|
+
]);
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
it('enumerates template files with paired sources', () => {
|
|
139
|
+
const root = path.join(tmpDir, 'templates');
|
|
140
|
+
fs.mkdirSync(path.join(root, 'dashboard'), {recursive: true});
|
|
141
|
+
fs.writeFileSync(
|
|
142
|
+
path.join(root, 'dashboard', 'dashboard.template.mjs'),
|
|
143
|
+
'// tmpl\n',
|
|
144
|
+
);
|
|
145
|
+
fs.writeFileSync(path.join(root, 'dashboard', 'dashboard.tsx'), '// src\n');
|
|
146
|
+
const inv = computeRequiredFiles(loaded({templates: root}));
|
|
147
|
+
|
|
148
|
+
expect(inv.roots[0].files).toContain(
|
|
149
|
+
'templates/dashboard/dashboard.template.mjs',
|
|
150
|
+
);
|
|
151
|
+
expect(inv.roots[0].files).toContain('templates/dashboard/dashboard.tsx');
|
|
152
|
+
});
|
|
153
|
+
|
|
154
|
+
it('enumerates legacy .doc template metadata with paired sources', () => {
|
|
155
|
+
const root = path.join(tmpDir, 'templates');
|
|
156
|
+
fs.mkdirSync(path.join(root, 'dashboard'), {recursive: true});
|
|
157
|
+
fs.writeFileSync(
|
|
158
|
+
path.join(root, 'dashboard', 'dashboard.doc.mjs'),
|
|
159
|
+
'// legacy template\n',
|
|
160
|
+
);
|
|
161
|
+
fs.writeFileSync(path.join(root, 'dashboard', 'dashboard.tsx'), '// src\n');
|
|
162
|
+
|
|
163
|
+
const inv = computeRequiredFiles(loaded({templates: root}));
|
|
164
|
+
|
|
165
|
+
expect(inv.roots[0].files).toEqual([
|
|
166
|
+
'templates/dashboard/dashboard.doc.mjs',
|
|
167
|
+
'templates/dashboard/dashboard.tsx',
|
|
168
|
+
]);
|
|
169
|
+
});
|
|
170
|
+
|
|
171
|
+
it('enumerates codemod files under version dirs', () => {
|
|
172
|
+
const root = path.join(tmpDir, 'codemods');
|
|
173
|
+
fs.mkdirSync(path.join(root, '0.2.0'), {recursive: true});
|
|
174
|
+
fs.writeFileSync(path.join(root, '0.2.0', 'rename-prop.mjs'), '// cm\n');
|
|
175
|
+
const inv = computeRequiredFiles(loaded({codemods: root}));
|
|
176
|
+
|
|
177
|
+
expect(inv.roots[0].files).toContain('codemods/0.2.0/rename-prop.mjs');
|
|
178
|
+
});
|
|
179
|
+
|
|
180
|
+
it('enumerates doc files', () => {
|
|
181
|
+
const root = path.join(tmpDir, 'docs');
|
|
182
|
+
fs.mkdirSync(root, {recursive: true});
|
|
183
|
+
fs.writeFileSync(path.join(root, 'theming.doc.mjs'), '// doc\n');
|
|
184
|
+
const inv = computeRequiredFiles(loaded({docs: root}));
|
|
185
|
+
|
|
186
|
+
expect(inv.roots[0].files).toContain('docs/theming.doc.mjs');
|
|
187
|
+
});
|
|
188
|
+
|
|
189
|
+
it('returns empty contributions for a bare manifest', () => {
|
|
190
|
+
const inv = computeRequiredFiles(loaded());
|
|
191
|
+
expect(inv.roots).toEqual([]);
|
|
192
|
+
expect(inv.allFiles).toEqual(['astryx.integration.mjs']);
|
|
193
|
+
});
|
|
194
|
+
|
|
195
|
+
it('handles missing root directories gracefully', () => {
|
|
196
|
+
const inv = computeRequiredFiles(
|
|
197
|
+
loaded({themes: path.join(tmpDir, 'nonexistent')}),
|
|
198
|
+
);
|
|
199
|
+
expect(inv.roots[0].files).toEqual([]);
|
|
200
|
+
});
|
|
201
|
+
});
|
|
202
|
+
|
|
203
|
+
describe('compareIdentities', () => {
|
|
204
|
+
const base = () => ({
|
|
205
|
+
themes: [],
|
|
206
|
+
components: [],
|
|
207
|
+
templates: [],
|
|
208
|
+
codemods: [],
|
|
209
|
+
docs: [],
|
|
210
|
+
agentDocsAppend: [],
|
|
211
|
+
});
|
|
212
|
+
|
|
213
|
+
it('returns no issues when identities match exactly', () => {
|
|
214
|
+
const local = {
|
|
215
|
+
...base(),
|
|
216
|
+
themes: [{slug: 'ocean', exportName: 'oceanTheme'}],
|
|
217
|
+
components: ['Card'],
|
|
218
|
+
};
|
|
219
|
+
const packed = {
|
|
220
|
+
...base(),
|
|
221
|
+
themes: [{slug: 'ocean', exportName: 'oceanTheme'}],
|
|
222
|
+
components: ['Card'],
|
|
223
|
+
};
|
|
224
|
+
expect(compareIdentities(local, packed)).toEqual([]);
|
|
225
|
+
});
|
|
226
|
+
|
|
227
|
+
it('errors when a theme slug is missing from packed', () => {
|
|
228
|
+
const local = {
|
|
229
|
+
...base(),
|
|
230
|
+
themes: [
|
|
231
|
+
{slug: 'ocean', exportName: 'oceanTheme'},
|
|
232
|
+
{slug: 'forest', exportName: 'forestTheme'},
|
|
233
|
+
],
|
|
234
|
+
};
|
|
235
|
+
const packed = {
|
|
236
|
+
...base(),
|
|
237
|
+
themes: [{slug: 'ocean', exportName: 'oceanTheme'}],
|
|
238
|
+
};
|
|
239
|
+
const issues = compareIdentities(local, packed);
|
|
240
|
+
expect(issues).toHaveLength(1);
|
|
241
|
+
expect(issues[0]).toMatchObject({
|
|
242
|
+
code: 'identity_not_packed',
|
|
243
|
+
severity: 'error',
|
|
244
|
+
});
|
|
245
|
+
expect(issues[0].message).toContain('forest');
|
|
246
|
+
});
|
|
247
|
+
|
|
248
|
+
it('errors when a component name is missing from packed', () => {
|
|
249
|
+
const local = {...base(), components: ['Card', 'Button']};
|
|
250
|
+
const packed = {...base(), components: ['Card']};
|
|
251
|
+
const issues = compareIdentities(local, packed);
|
|
252
|
+
expect(issues).toHaveLength(1);
|
|
253
|
+
expect(issues[0].message).toContain('Button');
|
|
254
|
+
});
|
|
255
|
+
|
|
256
|
+
it('errors when a template id is missing from packed', () => {
|
|
257
|
+
const local = {
|
|
258
|
+
...base(),
|
|
259
|
+
templates: [{id: 'dash', type: 'page', name: 'Dashboard'}],
|
|
260
|
+
};
|
|
261
|
+
const packed = {...base()};
|
|
262
|
+
const issues = compareIdentities(local, packed);
|
|
263
|
+
expect(issues).toHaveLength(1);
|
|
264
|
+
expect(issues[0].message).toContain('dash');
|
|
265
|
+
});
|
|
266
|
+
|
|
267
|
+
it('errors when a codemod is missing from packed', () => {
|
|
268
|
+
const local = {
|
|
269
|
+
...base(),
|
|
270
|
+
codemods: [{version: '0.2.0', id: 'rename-prop'}],
|
|
271
|
+
};
|
|
272
|
+
const packed = {...base()};
|
|
273
|
+
const issues = compareIdentities(local, packed);
|
|
274
|
+
expect(issues).toHaveLength(1);
|
|
275
|
+
expect(issues[0].message).toContain('rename-prop');
|
|
276
|
+
});
|
|
277
|
+
|
|
278
|
+
it('errors when a doc topic is missing from packed', () => {
|
|
279
|
+
const local = {...base(), docs: ['theming']};
|
|
280
|
+
const packed = {...base()};
|
|
281
|
+
const issues = compareIdentities(local, packed);
|
|
282
|
+
expect(issues).toHaveLength(1);
|
|
283
|
+
expect(issues[0].message).toContain('theming');
|
|
284
|
+
});
|
|
285
|
+
|
|
286
|
+
it('errors when packed contains an identity absent locally', () => {
|
|
287
|
+
const local = {...base()};
|
|
288
|
+
const packed = {...base(), docs: ['surprise']};
|
|
289
|
+
const issues = compareIdentities(local, packed);
|
|
290
|
+
expect(issues).toEqual([
|
|
291
|
+
expect.objectContaining({
|
|
292
|
+
code: 'packed_identity_unexpected',
|
|
293
|
+
message: expect.stringContaining('surprise'),
|
|
294
|
+
}),
|
|
295
|
+
]);
|
|
296
|
+
});
|
|
297
|
+
|
|
298
|
+
it('errors when a matching identity resolves to different metadata', () => {
|
|
299
|
+
const local = {
|
|
300
|
+
...base(),
|
|
301
|
+
templates: [{id: 'dash', type: 'page', name: 'Dashboard'}],
|
|
302
|
+
};
|
|
303
|
+
const packed = {
|
|
304
|
+
...base(),
|
|
305
|
+
templates: [{id: 'dash', type: 'block', name: 'Dashboard'}],
|
|
306
|
+
};
|
|
307
|
+
const issues = compareIdentities(local, packed);
|
|
308
|
+
expect(issues).toEqual([
|
|
309
|
+
expect.objectContaining({
|
|
310
|
+
code: 'identity_mismatch',
|
|
311
|
+
message: expect.stringContaining('dash'),
|
|
312
|
+
}),
|
|
313
|
+
]);
|
|
314
|
+
});
|
|
315
|
+
|
|
316
|
+
it('errors when agentDocs lines differ', () => {
|
|
317
|
+
const local = {...base(), agentDocsAppend: ['Install via npm.']};
|
|
318
|
+
const packed = {...base(), agentDocsAppend: []};
|
|
319
|
+
const issues = compareIdentities(local, packed);
|
|
320
|
+
expect(issues).toHaveLength(1);
|
|
321
|
+
expect(issues[0].code).toBe('agent_docs_mismatch');
|
|
322
|
+
});
|
|
323
|
+
});
|
|
324
|
+
|
|
325
|
+
describe('findSourceOnlyCandidates', () => {
|
|
326
|
+
it('finds PascalCase .tsx without metadata', () => {
|
|
327
|
+
const root = path.join(tmpDir, 'components');
|
|
328
|
+
fs.mkdirSync(root);
|
|
329
|
+
fs.writeFileSync(path.join(root, 'Card.tsx'), '// Card\n');
|
|
330
|
+
fs.writeFileSync(path.join(root, 'Button.tsx'), '// Button\n');
|
|
331
|
+
fs.writeFileSync(path.join(root, 'helper.tsx'), '// lowercase\n');
|
|
332
|
+
const candidates = findSourceOnlyCandidates(root, ['Card']);
|
|
333
|
+
expect(candidates).toEqual(['Button']);
|
|
334
|
+
});
|
|
335
|
+
|
|
336
|
+
it('includes a symlinked PascalCase source candidate', () => {
|
|
337
|
+
const root = path.join(tmpDir, 'components');
|
|
338
|
+
fs.mkdirSync(root);
|
|
339
|
+
fs.writeFileSync(path.join(root, 'source.tsx'), '// source\n');
|
|
340
|
+
fs.symlinkSync('source.tsx', path.join(root, 'LinkedWidget.tsx'));
|
|
341
|
+
expect(findSourceOnlyCandidates(root, [])).toEqual(['LinkedWidget']);
|
|
342
|
+
});
|
|
343
|
+
|
|
344
|
+
it('returns empty when all are registered', () => {
|
|
345
|
+
const root = path.join(tmpDir, 'components');
|
|
346
|
+
fs.mkdirSync(root);
|
|
347
|
+
fs.writeFileSync(path.join(root, 'Card.tsx'), '// Card\n');
|
|
348
|
+
expect(findSourceOnlyCandidates(root, ['Card'])).toEqual([]);
|
|
349
|
+
});
|
|
350
|
+
|
|
351
|
+
it('returns empty for missing root', () => {
|
|
352
|
+
expect(findSourceOnlyCandidates(undefined, [])).toEqual([]);
|
|
353
|
+
});
|
|
354
|
+
|
|
355
|
+
it('ignores nested directories', () => {
|
|
356
|
+
const root = path.join(tmpDir, 'components');
|
|
357
|
+
fs.mkdirSync(path.join(root, 'sub'), {recursive: true});
|
|
358
|
+
fs.writeFileSync(path.join(root, 'sub', 'Deep.tsx'), '// nested\n');
|
|
359
|
+
expect(findSourceOnlyCandidates(root, [])).toEqual([]);
|
|
360
|
+
});
|
|
361
|
+
});
|
|
@@ -19,13 +19,13 @@ export function findManifestPaths(dir: string): string[];
|
|
|
19
19
|
* The raw object is also inspected before parsing so unknown-key warnings retain
|
|
20
20
|
* forward compatibility.
|
|
21
21
|
*
|
|
22
|
-
* `debug`
|
|
23
|
-
*
|
|
22
|
+
* `debug` and `gapReport` come back separately because they are named exports,
|
|
23
|
+
* not manifest keys. A CLI that does not know them simply does not read them.
|
|
24
24
|
*
|
|
25
25
|
* @param {string} file absolute manifest path
|
|
26
26
|
* @param {string} [label] used in error messages
|
|
27
27
|
* @param {{fresh?: boolean}} [options]
|
|
28
|
-
* @returns {Promise<{manifest: import('../../authoring/integration/type').AstryxIntegration, unknownKeys: string[], debug?: import('../../authoring/debug/type').DebugEventHandler, agentDocsError?: string}>}
|
|
28
|
+
* @returns {Promise<{manifest: import('../../authoring/integration/type').AstryxIntegration, unknownKeys: string[], debug?: import('../../authoring/debug/type').DebugEventHandler, gapReport?: import('../../authoring/gap-report/type').GapReportHandler, gapReportError?: string, agentDocsError?: string}>}
|
|
29
29
|
*/
|
|
30
30
|
export function loadManifest(file: string, label?: string, { fresh }?: {
|
|
31
31
|
fresh?: boolean;
|
|
@@ -33,6 +33,8 @@ export function loadManifest(file: string, label?: string, { fresh }?: {
|
|
|
33
33
|
manifest: import("../../authoring/integration/type").AstryxIntegration;
|
|
34
34
|
unknownKeys: string[];
|
|
35
35
|
debug?: import("../../authoring/debug/type").DebugEventHandler;
|
|
36
|
+
gapReport?: import("../../authoring/gap-report/type").GapReportHandler;
|
|
37
|
+
gapReportError?: string;
|
|
36
38
|
agentDocsError?: string;
|
|
37
39
|
}>;
|
|
38
40
|
/**
|
|
@@ -54,6 +56,21 @@ export function loadManifestObject(file: string, label?: string, options?: {
|
|
|
54
56
|
* @param {string} [cwd]
|
|
55
57
|
*/
|
|
56
58
|
export function resolvePackageDir(packageName: string, cwd?: string): string;
|
|
59
|
+
/**
|
|
60
|
+
* Load the integration package rooted at `packageDir` directly, without first
|
|
61
|
+
* installing or publishing it. This is the self-resolution seam: an author in
|
|
62
|
+
* a package with a manifest sees the same contributions a consumer installs.
|
|
63
|
+
*
|
|
64
|
+
* A missing manifest returns null. A broken manifest returns the same load-error
|
|
65
|
+
* marker as an installed integration, so Project issues stay truthful.
|
|
66
|
+
*
|
|
67
|
+
* @param {string} packageDir
|
|
68
|
+
* @param {{fresh?: boolean}} [options]
|
|
69
|
+
* @returns {Promise<LoadedIntegration|null>}
|
|
70
|
+
*/
|
|
71
|
+
export function loadLocalIntegration(packageDir: string, { fresh }?: {
|
|
72
|
+
fresh?: boolean;
|
|
73
|
+
}): Promise<LoadedIntegration | null>;
|
|
57
74
|
/**
|
|
58
75
|
* Load configured integrations.
|
|
59
76
|
*
|
|
@@ -67,8 +84,8 @@ export function loadIntegrations(specs?: string[], { cwd, fresh }?: {
|
|
|
67
84
|
}): Promise<LoadedIntegration[]>;
|
|
68
85
|
/**
|
|
69
86
|
* A fully-resolved, loaded integration. Identity (`name`, `version`) comes from
|
|
70
|
-
* the package's package.json; the `components`/`templates`/`codemods`/`docs
|
|
71
|
-
* roots are absolute paths resolved from the manifest. The `__`-prefixed fields
|
|
87
|
+
* the package's package.json; the `components`/`templates`/`codemods`/`docs`/
|
|
88
|
+
* `themes` roots are absolute paths resolved from the manifest. The `__`-prefixed fields
|
|
72
89
|
* are internal bookkeeping used by Doctor integration validation and Project.
|
|
73
90
|
* @typedef {object} LoadedIntegration
|
|
74
91
|
* @property {string} name
|
|
@@ -77,27 +94,42 @@ export function loadIntegrations(specs?: string[], { cwd, fresh }?: {
|
|
|
77
94
|
* @property {string} [templates]
|
|
78
95
|
* @property {string} [codemods]
|
|
79
96
|
* @property {string} [docs]
|
|
97
|
+
* @property {string} [themes]
|
|
80
98
|
* @property {string} [issuesUrl]
|
|
81
99
|
* @property {{append?: readonly string[]}} [agentDocs]
|
|
82
100
|
* @property {string} [__agentDocsError] contribution-specific validation
|
|
83
101
|
* failure; other manifest contributions remain available
|
|
84
102
|
* @property {string} __spec
|
|
85
103
|
* @property {string} __packageDir
|
|
104
|
+
* @property {Record<string, unknown>|null} [__packageExports] the owning
|
|
105
|
+
* package's `exports` map, kept from the package.json this loader already
|
|
106
|
+
* parsed so import resolution does not read it a second time
|
|
86
107
|
* @property {string} __manifestFile
|
|
87
108
|
* @property {string} [__loadError] set when the manifest failed to load/validate;
|
|
88
109
|
* such an integration contributes nothing and is surfaced via Project.issues()
|
|
89
110
|
* @property {string[]} [__unknownKeys] manifest keys this CLI does not know —
|
|
90
111
|
* surfaced as a warning; the rest of the manifest still contributes
|
|
112
|
+
* @property {boolean} [__autolinked] loaded because the project declares the
|
|
113
|
+
* package as a dependency and it ships a manifest, with no astryx.config
|
|
114
|
+
* entry naming it — see foundation/integrations/autolink.mjs
|
|
115
|
+
* @property {boolean} [__local] loaded from the package containing the current
|
|
116
|
+
* working directory, so an author sees the exact bytes they are editing
|
|
117
|
+
* @property {string} [__dependencyField] for an autolinked integration, the
|
|
118
|
+
* package.json field that declared it (`dependencies`, `devDependencies`,
|
|
119
|
+
* `optionalDependencies`)
|
|
91
120
|
* @property {import('../../authoring/debug/type').DebugEventHandler} [__debug]
|
|
92
121
|
* the manifest module's `debug` NAMED export, when it exported a function.
|
|
93
|
-
*
|
|
122
|
+
* @property {import('../../authoring/gap-report/type').GapReportHandler} [__gapReport]
|
|
123
|
+
* validated package-owned handler from the `gapReport` NAMED export.
|
|
124
|
+
* @property {string} [__gapReportError] isolated named-handler validation error.
|
|
125
|
+
* Named exports are not manifest keys — see {@link loadManifest}.
|
|
94
126
|
*/
|
|
95
127
|
/** Conventional manifest basenames, in load-precedence order. */
|
|
96
128
|
export const MANIFEST_BASENAMES: string[];
|
|
97
129
|
/**
|
|
98
130
|
* A fully-resolved, loaded integration. Identity (`name`, `version`) comes from
|
|
99
|
-
* the package's package.json; the `components`/`templates`/`codemods`/`docs
|
|
100
|
-
* roots are absolute paths resolved from the manifest. The `__`-prefixed fields
|
|
131
|
+
* the package's package.json; the `components`/`templates`/`codemods`/`docs`/
|
|
132
|
+
* `themes` roots are absolute paths resolved from the manifest. The `__`-prefixed fields
|
|
101
133
|
* are internal bookkeeping used by Doctor integration validation and Project.
|
|
102
134
|
*/
|
|
103
135
|
export type LoadedIntegration = {
|
|
@@ -107,6 +139,7 @@ export type LoadedIntegration = {
|
|
|
107
139
|
templates?: string | undefined;
|
|
108
140
|
codemods?: string | undefined;
|
|
109
141
|
docs?: string | undefined;
|
|
142
|
+
themes?: string | undefined;
|
|
110
143
|
issuesUrl?: string | undefined;
|
|
111
144
|
agentDocs?: {
|
|
112
145
|
append?: readonly string[];
|
|
@@ -118,6 +151,12 @@ export type LoadedIntegration = {
|
|
|
118
151
|
__agentDocsError?: string | undefined;
|
|
119
152
|
__spec: string;
|
|
120
153
|
__packageDir: string;
|
|
154
|
+
/**
|
|
155
|
+
* the owning
|
|
156
|
+
* package's `exports` map, kept from the package.json this loader already
|
|
157
|
+
* parsed so import resolution does not read it a second time
|
|
158
|
+
*/
|
|
159
|
+
__packageExports?: Record<string, unknown> | null | undefined;
|
|
121
160
|
__manifestFile: string;
|
|
122
161
|
/**
|
|
123
162
|
* set when the manifest failed to load/validate;
|
|
@@ -129,9 +168,34 @@ export type LoadedIntegration = {
|
|
|
129
168
|
* surfaced as a warning; the rest of the manifest still contributes
|
|
130
169
|
*/
|
|
131
170
|
__unknownKeys?: string[] | undefined;
|
|
171
|
+
/**
|
|
172
|
+
* loaded because the project declares the
|
|
173
|
+
* package as a dependency and it ships a manifest, with no astryx.config
|
|
174
|
+
* entry naming it — see foundation/integrations/autolink.mjs
|
|
175
|
+
*/
|
|
176
|
+
__autolinked?: boolean | undefined;
|
|
177
|
+
/**
|
|
178
|
+
* loaded from the package containing the current
|
|
179
|
+
* working directory, so an author sees the exact bytes they are editing
|
|
180
|
+
*/
|
|
181
|
+
__local?: boolean | undefined;
|
|
182
|
+
/**
|
|
183
|
+
* for an autolinked integration, the
|
|
184
|
+
* package.json field that declared it (`dependencies`, `devDependencies`,
|
|
185
|
+
* `optionalDependencies`)
|
|
186
|
+
*/
|
|
187
|
+
__dependencyField?: string | undefined;
|
|
132
188
|
/**
|
|
133
189
|
* the manifest module's `debug` NAMED export, when it exported a function.
|
|
134
|
-
* Not a manifest key — see {@link loadManifest}.
|
|
135
190
|
*/
|
|
136
191
|
__debug?: import("../../authoring/debug/type").DebugEventHandler | undefined;
|
|
192
|
+
/**
|
|
193
|
+
* validated package-owned handler from the `gapReport` NAMED export.
|
|
194
|
+
*/
|
|
195
|
+
__gapReport?: import("../../authoring/gap-report/type").GapReportHandler | undefined;
|
|
196
|
+
/**
|
|
197
|
+
* isolated named-handler validation error.
|
|
198
|
+
* Named exports are not manifest keys — see {@link loadManifest}.
|
|
199
|
+
*/
|
|
200
|
+
__gapReportError?: string | undefined;
|
|
137
201
|
};
|