@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
|
@@ -19,6 +19,11 @@ import {logger} from '../logger.mjs';
|
|
|
19
19
|
import {AstryxError} from '../error.mjs';
|
|
20
20
|
import {ERROR_CODES} from '../../foundation/response/error-codes.mjs';
|
|
21
21
|
import {generateCompressedIndex} from '../../foundation/agent-docs/agent-docs.mjs';
|
|
22
|
+
import {
|
|
23
|
+
createRegistryReceipt,
|
|
24
|
+
registryReceiptTarget,
|
|
25
|
+
serializeRegistryReceipt,
|
|
26
|
+
} from '../../authoring/shadcn/receipt.mjs';
|
|
22
27
|
|
|
23
28
|
vi.setConfig({testTimeout: 30000});
|
|
24
29
|
|
|
@@ -34,6 +39,7 @@ afterEach(() => {
|
|
|
34
39
|
process.chdir(originalCwd);
|
|
35
40
|
fs.rmSync(tmpDir, {recursive: true, force: true});
|
|
36
41
|
vi.restoreAllMocks();
|
|
42
|
+
vi.unstubAllGlobals();
|
|
37
43
|
logger.setSilent(true);
|
|
38
44
|
});
|
|
39
45
|
|
|
@@ -54,7 +60,87 @@ function writeInstalledCore(dir, version) {
|
|
|
54
60
|
}
|
|
55
61
|
|
|
56
62
|
function writeAgentBlock(dir, rel, version) {
|
|
57
|
-
fs.writeFileSync(
|
|
63
|
+
fs.writeFileSync(
|
|
64
|
+
path.join(dir, rel),
|
|
65
|
+
`# Doc\n\n${generateCompressedIndex(version)}\n`,
|
|
66
|
+
);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
function writeRegistryFixture(
|
|
70
|
+
dir,
|
|
71
|
+
{base = 'old\n', latest = 'new\n', version = '0.6.0'} = {},
|
|
72
|
+
) {
|
|
73
|
+
const sourceTarget = 'components/astryx/examples/Example.tsx';
|
|
74
|
+
const registryPath = 'registry/example-button-basic/Example.tsx';
|
|
75
|
+
const receiptTarget = registryReceiptTarget(
|
|
76
|
+
sourceTarget,
|
|
77
|
+
'example-button-basic',
|
|
78
|
+
);
|
|
79
|
+
const installedReceipt = createRegistryReceipt({
|
|
80
|
+
item: {
|
|
81
|
+
name: 'example-button-basic',
|
|
82
|
+
path: 'examples/button/basic',
|
|
83
|
+
aliases: [],
|
|
84
|
+
kind: 'example',
|
|
85
|
+
},
|
|
86
|
+
sourceVersion: '0.5.0',
|
|
87
|
+
receiptTarget,
|
|
88
|
+
files: [
|
|
89
|
+
{
|
|
90
|
+
id: 'primary',
|
|
91
|
+
target: sourceTarget,
|
|
92
|
+
registryPath,
|
|
93
|
+
content: base,
|
|
94
|
+
},
|
|
95
|
+
],
|
|
96
|
+
});
|
|
97
|
+
const latestReceipt = createRegistryReceipt({
|
|
98
|
+
item: installedReceipt.item,
|
|
99
|
+
sourceVersion: version,
|
|
100
|
+
receiptTarget,
|
|
101
|
+
files: [
|
|
102
|
+
{
|
|
103
|
+
id: 'primary',
|
|
104
|
+
target: sourceTarget,
|
|
105
|
+
registryPath,
|
|
106
|
+
content: latest,
|
|
107
|
+
},
|
|
108
|
+
],
|
|
109
|
+
});
|
|
110
|
+
const sourcePath = path.join(dir, 'src', sourceTarget);
|
|
111
|
+
const receiptPath = path.join(dir, 'src', receiptTarget);
|
|
112
|
+
fs.mkdirSync(path.dirname(sourcePath), {recursive: true});
|
|
113
|
+
fs.mkdirSync(path.dirname(receiptPath), {recursive: true});
|
|
114
|
+
fs.writeFileSync(sourcePath, base);
|
|
115
|
+
fs.writeFileSync(receiptPath, serializeRegistryReceipt(installedReceipt));
|
|
116
|
+
vi.stubGlobal(
|
|
117
|
+
'fetch',
|
|
118
|
+
vi.fn(
|
|
119
|
+
async () =>
|
|
120
|
+
new globalThis.Response(
|
|
121
|
+
JSON.stringify({
|
|
122
|
+
name: latestReceipt.item.name,
|
|
123
|
+
type: 'registry:block',
|
|
124
|
+
files: [
|
|
125
|
+
{
|
|
126
|
+
path: registryPath,
|
|
127
|
+
type: 'registry:block',
|
|
128
|
+
target: sourceTarget,
|
|
129
|
+
content: latest,
|
|
130
|
+
},
|
|
131
|
+
{
|
|
132
|
+
path: 'registry/example-button-basic/astryx-receipt.json',
|
|
133
|
+
type: 'registry:file',
|
|
134
|
+
target: receiptTarget,
|
|
135
|
+
content: serializeRegistryReceipt(latestReceipt),
|
|
136
|
+
},
|
|
137
|
+
],
|
|
138
|
+
}),
|
|
139
|
+
{status: 200},
|
|
140
|
+
),
|
|
141
|
+
),
|
|
142
|
+
);
|
|
143
|
+
return {sourcePath};
|
|
58
144
|
}
|
|
59
145
|
|
|
60
146
|
describe('upgrade() — receipts', () => {
|
|
@@ -72,6 +158,71 @@ describe('upgrade() — receipts', () => {
|
|
|
72
158
|
}
|
|
73
159
|
});
|
|
74
160
|
|
|
161
|
+
it('runs registry-only mode without --from', async () => {
|
|
162
|
+
fs.mkdirSync(path.join(tmpDir, 'src'), {recursive: true});
|
|
163
|
+
|
|
164
|
+
const res = await upgrade({registry: true, apply: false}, {cwd: tmpDir});
|
|
165
|
+
|
|
166
|
+
expect(res).toMatchObject({
|
|
167
|
+
type: 'upgrade.registry',
|
|
168
|
+
data: {applied: false, found: 0, conflicts: 0, failed: 0},
|
|
169
|
+
});
|
|
170
|
+
});
|
|
171
|
+
|
|
172
|
+
it('requires installed Astryx packages when receipts exist', async () => {
|
|
173
|
+
writeRegistryFixture(tmpDir);
|
|
174
|
+
|
|
175
|
+
await expect(
|
|
176
|
+
upgrade({registry: true, apply: true}, {cwd: tmpDir}),
|
|
177
|
+
).rejects.toMatchObject({code: ERROR_CODES.ERR_VERSION_DETECT});
|
|
178
|
+
});
|
|
179
|
+
|
|
180
|
+
it('rejects combining --list with registry-only mode', async () => {
|
|
181
|
+
await expect(
|
|
182
|
+
upgrade({list: true, registry: true}, {cwd: tmpDir}),
|
|
183
|
+
).rejects.toMatchObject({code: ERROR_CODES.ERR_INVALID_ARGUMENT});
|
|
184
|
+
});
|
|
185
|
+
|
|
186
|
+
it('checks receipts on the up-to-date short circuit', async () => {
|
|
187
|
+
writePkg(tmpDir);
|
|
188
|
+
writeInstalledCore(tmpDir, '0.6.0');
|
|
189
|
+
const {sourcePath} = writeRegistryFixture(tmpDir);
|
|
190
|
+
|
|
191
|
+
const res = await upgrade({from: '0.6.0', apply: true}, {cwd: tmpDir});
|
|
192
|
+
|
|
193
|
+
expect(res).toMatchObject({
|
|
194
|
+
type: 'upgrade.status',
|
|
195
|
+
data: {
|
|
196
|
+
status: 'up_to_date',
|
|
197
|
+
registryCompositions: {found: 1, updated: 1, conflicts: 0},
|
|
198
|
+
},
|
|
199
|
+
});
|
|
200
|
+
expect(fs.readFileSync(sourcePath, 'utf8')).toBe('new\n');
|
|
201
|
+
});
|
|
202
|
+
|
|
203
|
+
it('checks receipts on the no-codemods short circuit', async () => {
|
|
204
|
+
writePkg(tmpDir);
|
|
205
|
+
writeInstalledCore(tmpDir, '99.0.0');
|
|
206
|
+
const {sourcePath} = writeRegistryFixture(tmpDir, {version: '99.0.0'});
|
|
207
|
+
|
|
208
|
+
const res = await upgrade({from: '98.0.0', apply: false}, {cwd: tmpDir});
|
|
209
|
+
|
|
210
|
+
expect(res).toMatchObject({
|
|
211
|
+
type: 'upgrade.status',
|
|
212
|
+
data: {
|
|
213
|
+
status: 'no_codemods',
|
|
214
|
+
registryCompositions: {found: 1, wouldUpdate: 1},
|
|
215
|
+
},
|
|
216
|
+
});
|
|
217
|
+
expect(fs.readFileSync(sourcePath, 'utf8')).toBe('old\n');
|
|
218
|
+
});
|
|
219
|
+
|
|
220
|
+
it('rejects migration flags in registry-only mode', async () => {
|
|
221
|
+
await expect(
|
|
222
|
+
upgrade({registry: true, from: '0.5.0', apply: true}, {cwd: tmpDir}),
|
|
223
|
+
).rejects.toMatchObject({code: ERROR_CODES.ERR_INVALID_ARGUMENT});
|
|
224
|
+
});
|
|
225
|
+
|
|
75
226
|
it('honors cwd: refreshes a stale agent-docs block on the up-to-date path (--apply)', async () => {
|
|
76
227
|
// from == installed → up_to_date short-circuit (returns before the codemod
|
|
77
228
|
// runner), so this exercises detection + agent-docs purely via the cwd
|
|
@@ -106,7 +257,9 @@ describe('upgrade() — receipts', () => {
|
|
|
106
257
|
expect(res.data.status).toBe('up_to_date');
|
|
107
258
|
expect(res.data.agentDocs.action).toBe('would-refresh');
|
|
108
259
|
expect(res.data.agentDocs.refreshed).toBe(false);
|
|
109
|
-
expect(fs.readFileSync(path.join(tmpDir, 'AGENTS.md'), 'utf-8')).toBe(
|
|
260
|
+
expect(fs.readFileSync(path.join(tmpDir, 'AGENTS.md'), 'utf-8')).toBe(
|
|
261
|
+
before,
|
|
262
|
+
);
|
|
110
263
|
});
|
|
111
264
|
|
|
112
265
|
it('returns upgrade.run for an applicable range', async () => {
|
|
@@ -117,7 +270,10 @@ describe('upgrade() — receipts', () => {
|
|
|
117
270
|
fs.writeFileSync(path.join(tmpDir, 'src', 'index.ts'), 'const x = 1;\n');
|
|
118
271
|
process.chdir(tmpDir);
|
|
119
272
|
|
|
120
|
-
const res = await upgrade(
|
|
273
|
+
const res = await upgrade(
|
|
274
|
+
{from: '0.0.1', apply: false, path: 'src'},
|
|
275
|
+
{cwd: tmpDir},
|
|
276
|
+
);
|
|
121
277
|
|
|
122
278
|
expect(res.type).toBe('upgrade.run');
|
|
123
279
|
expect(res.data.from).toBe('0.0.1');
|
|
@@ -125,6 +281,29 @@ describe('upgrade() — receipts', () => {
|
|
|
125
281
|
expect(typeof res.data.codemods).toBe('number');
|
|
126
282
|
expect(res.data.agentDocs).toBeDefined();
|
|
127
283
|
});
|
|
284
|
+
|
|
285
|
+
it('checks receipts on a normal codemod run', async () => {
|
|
286
|
+
writePkg(tmpDir);
|
|
287
|
+
writeInstalledCore(tmpDir, '0.0.15');
|
|
288
|
+
const {sourcePath} = writeRegistryFixture(tmpDir, {
|
|
289
|
+
base: "export const value = 'old';\n",
|
|
290
|
+
latest: "export const value = 'new';\n",
|
|
291
|
+
version: '0.0.15',
|
|
292
|
+
});
|
|
293
|
+
|
|
294
|
+
const res = await upgrade(
|
|
295
|
+
{from: '0.0.1', apply: false, path: 'src'},
|
|
296
|
+
{cwd: tmpDir},
|
|
297
|
+
);
|
|
298
|
+
|
|
299
|
+
expect(res).toMatchObject({
|
|
300
|
+
type: 'upgrade.run',
|
|
301
|
+
data: {registryCompositions: {found: 1, wouldUpdate: 1}},
|
|
302
|
+
});
|
|
303
|
+
expect(fs.readFileSync(sourcePath, 'utf8')).toBe(
|
|
304
|
+
"export const value = 'old';\n",
|
|
305
|
+
);
|
|
306
|
+
});
|
|
128
307
|
});
|
|
129
308
|
|
|
130
309
|
describe('upgrade() — honors cwd for codemod scanning (no chdir)', () => {
|
|
@@ -140,14 +319,19 @@ describe('upgrade() — honors cwd for codemod scanning (no chdir)', () => {
|
|
|
140
319
|
// Capture stdout: the runner logs the directory it scans. Enabling the
|
|
141
320
|
// shared logger keeps the runner non-silent so its scan line is emitted.
|
|
142
321
|
const out = [];
|
|
143
|
-
vi.spyOn(console, 'log').mockImplementation((...a) =>
|
|
322
|
+
vi.spyOn(console, 'log').mockImplementation((...a) =>
|
|
323
|
+
out.push(a.join(' ')),
|
|
324
|
+
);
|
|
144
325
|
vi.spyOn(process.stdout, 'write').mockImplementation(c => {
|
|
145
326
|
out.push(typeof c === 'string' ? c : c.toString());
|
|
146
327
|
return true;
|
|
147
328
|
});
|
|
148
329
|
logger.setSilent(false);
|
|
149
330
|
|
|
150
|
-
const res = await upgrade(
|
|
331
|
+
const res = await upgrade(
|
|
332
|
+
{from: '0.0.1', apply: false, path: 'src'},
|
|
333
|
+
{cwd: tmpDir},
|
|
334
|
+
);
|
|
151
335
|
|
|
152
336
|
const joined = out.join('\n');
|
|
153
337
|
expect(res.type).toBe('upgrade.run');
|
|
@@ -167,13 +351,17 @@ describe('upgrade() — errors throw AstryxError', () => {
|
|
|
167
351
|
name: 'AstryxError',
|
|
168
352
|
code: ERROR_CODES.ERR_INVALID_ARGUMENT,
|
|
169
353
|
});
|
|
170
|
-
await expect(upgrade({}, {cwd: tmpDir})).rejects.toThrow(
|
|
354
|
+
await expect(upgrade({}, {cwd: tmpDir})).rejects.toThrow(
|
|
355
|
+
/Missing required --from/,
|
|
356
|
+
);
|
|
171
357
|
});
|
|
172
358
|
|
|
173
359
|
it('invalid --from → ERR_INVALID_VERSION', async () => {
|
|
174
360
|
writePkg(tmpDir);
|
|
175
361
|
writeInstalledCore(tmpDir, '0.0.15');
|
|
176
|
-
await expect(
|
|
362
|
+
await expect(
|
|
363
|
+
upgrade({from: 'not-a-version'}, {cwd: tmpDir}),
|
|
364
|
+
).rejects.toMatchObject({
|
|
177
365
|
code: ERROR_CODES.ERR_INVALID_VERSION,
|
|
178
366
|
});
|
|
179
367
|
});
|
|
@@ -196,7 +384,9 @@ describe('upgrade() — silent by default (noopLogger)', () => {
|
|
|
196
384
|
|
|
197
385
|
const logSpy = vi.spyOn(console, 'log').mockImplementation(() => {});
|
|
198
386
|
const errSpy = vi.spyOn(console, 'error').mockImplementation(() => {});
|
|
199
|
-
const outSpy = vi
|
|
387
|
+
const outSpy = vi
|
|
388
|
+
.spyOn(process.stdout, 'write')
|
|
389
|
+
.mockImplementation(() => true);
|
|
200
390
|
|
|
201
391
|
const res = await upgrade({from: '0.0.15', apply: true}, {cwd: tmpDir});
|
|
202
392
|
|
|
@@ -45,6 +45,88 @@ export type AgentDocsSummary = {
|
|
|
45
45
|
refreshed: boolean;
|
|
46
46
|
action: "refreshed" | "would-refresh" | "nudge-init" | "error" | "none";
|
|
47
47
|
};
|
|
48
|
+
/**
|
|
49
|
+
* One copied file tracked by a ShadCN composition receipt.
|
|
50
|
+
*/
|
|
51
|
+
export type RegistryCompositionFileSummary = {
|
|
52
|
+
path: string;
|
|
53
|
+
action: "current" | "user-modified" | "would-update" | "updated" | "would-merge" | "merged" | "would-refresh-receipt" | "receipt-refreshed" | "conflict" | "missing" | "invalid" | "target-changed";
|
|
54
|
+
message?: string | undefined;
|
|
55
|
+
conflictFile?: string | undefined;
|
|
56
|
+
};
|
|
57
|
+
/**
|
|
58
|
+
* One ShadCN registry item checked during upgrade.
|
|
59
|
+
*/
|
|
60
|
+
export type RegistryCompositionItemSummary = {
|
|
61
|
+
item: string;
|
|
62
|
+
path?: string | undefined;
|
|
63
|
+
action: "current" | "user-modified" | "would-update" | "updated" | "would-merge" | "merged" | "would-refresh-receipt" | "receipt-refreshed" | "conflict" | "invalid" | "fetch-error" | "write-error";
|
|
64
|
+
message?: string | undefined;
|
|
65
|
+
files: RegistryCompositionFileSummary[];
|
|
66
|
+
};
|
|
67
|
+
/**
|
|
68
|
+
* Aggregate receipt for ShadCN-copied composition reconciliation.
|
|
69
|
+
*/
|
|
70
|
+
export type RegistryCompositionSummary = {
|
|
71
|
+
applied: boolean;
|
|
72
|
+
/**
|
|
73
|
+
* False when conflicts, missing files, invalid receipts, or failures remain.
|
|
74
|
+
*/
|
|
75
|
+
ok: boolean;
|
|
76
|
+
found: number;
|
|
77
|
+
/**
|
|
78
|
+
* Item count with no upstream source change.
|
|
79
|
+
*/
|
|
80
|
+
current: number;
|
|
81
|
+
/**
|
|
82
|
+
* Item count with pristine updates in dry-run.
|
|
83
|
+
*/
|
|
84
|
+
wouldUpdate: number;
|
|
85
|
+
/**
|
|
86
|
+
* Item count with pristine updates applied.
|
|
87
|
+
*/
|
|
88
|
+
updated: number;
|
|
89
|
+
/**
|
|
90
|
+
* Item count with clean merges in dry-run.
|
|
91
|
+
*/
|
|
92
|
+
wouldMerge: number;
|
|
93
|
+
/**
|
|
94
|
+
* Item count with clean merges applied.
|
|
95
|
+
*/
|
|
96
|
+
merged: number;
|
|
97
|
+
/**
|
|
98
|
+
* Item count with metadata-only refreshes in dry-run.
|
|
99
|
+
*/
|
|
100
|
+
wouldRefreshReceipt: number;
|
|
101
|
+
/**
|
|
102
|
+
* Item count with metadata-only refreshes applied.
|
|
103
|
+
*/
|
|
104
|
+
receiptsRefreshed: number;
|
|
105
|
+
/**
|
|
106
|
+
* Item count with at least one unresolved source conflict.
|
|
107
|
+
*/
|
|
108
|
+
conflicts: number;
|
|
109
|
+
/**
|
|
110
|
+
* Per-file count of deleted or moved source files.
|
|
111
|
+
*/
|
|
112
|
+
missing: number;
|
|
113
|
+
/**
|
|
114
|
+
* Count of invalid receipts, unreadable sources, or changed targets.
|
|
115
|
+
*/
|
|
116
|
+
invalid: number;
|
|
117
|
+
/**
|
|
118
|
+
* Item count with fetch or write failures.
|
|
119
|
+
*/
|
|
120
|
+
failed: number;
|
|
121
|
+
items: RegistryCompositionItemSummary[];
|
|
122
|
+
};
|
|
123
|
+
/**
|
|
124
|
+
* xds --json upgrade --registry [--apply]
|
|
125
|
+
*/
|
|
126
|
+
export type UpgradeRegistryResponse = {
|
|
127
|
+
type: "upgrade.registry";
|
|
128
|
+
data: RegistryCompositionSummary;
|
|
129
|
+
};
|
|
48
130
|
/**
|
|
49
131
|
* xds --json upgrade [--apply]
|
|
50
132
|
*/
|
|
@@ -57,6 +139,7 @@ export type UpgradeRunResponse = {
|
|
|
57
139
|
integrations: string[];
|
|
58
140
|
agentDocsRefreshed: boolean;
|
|
59
141
|
agentDocs: AgentDocsSummary;
|
|
142
|
+
registryCompositions?: RegistryCompositionSummary | undefined;
|
|
60
143
|
filesChanged?: number | undefined;
|
|
61
144
|
transformsApplied?: number | undefined;
|
|
62
145
|
errors?: {
|
|
@@ -84,11 +167,13 @@ export type UpgradeStatusResponse = {
|
|
|
84
167
|
from: string;
|
|
85
168
|
to: string;
|
|
86
169
|
agentDocs: AgentDocsSummary;
|
|
170
|
+
registryCompositions?: RegistryCompositionSummary;
|
|
87
171
|
} | {
|
|
88
172
|
status: "no_codemods";
|
|
89
173
|
from: string;
|
|
90
174
|
to: string;
|
|
91
175
|
agentDocs: AgentDocsSummary;
|
|
176
|
+
registryCompositions?: RegistryCompositionSummary;
|
|
92
177
|
} | {
|
|
93
178
|
status: "config_fixable";
|
|
94
179
|
from: string;
|
|
@@ -106,7 +191,7 @@ export type UpgradeStatusResponse = {
|
|
|
106
191
|
*/
|
|
107
192
|
export type UpgradeOptions = {
|
|
108
193
|
/**
|
|
109
|
-
* Version before the dependency bump (required unless `list`).
|
|
194
|
+
* Version before the dependency bump (required unless `list` or `registry`).
|
|
110
195
|
*/
|
|
111
196
|
from?: string | undefined;
|
|
112
197
|
/**
|
|
@@ -137,6 +222,10 @@ export type UpgradeOptions = {
|
|
|
137
222
|
* Auto-install jscodeshift without prompting.
|
|
138
223
|
*/
|
|
139
224
|
installDeps?: boolean | undefined;
|
|
225
|
+
/**
|
|
226
|
+
* Reconcile only ShadCN-copied compositions; `from` is not required.
|
|
227
|
+
*/
|
|
228
|
+
registry?: boolean | undefined;
|
|
140
229
|
/**
|
|
141
230
|
* Return the available codemods instead of running.
|
|
142
231
|
*/
|
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
* ------------------------------------------------------------------
|
|
9
9
|
* xds --json upgrade --list -> upgrade.list
|
|
10
10
|
* xds --json upgrade [--apply] -> upgrade.run
|
|
11
|
+
* xds --json upgrade --registry [--apply] -> upgrade.registry
|
|
11
12
|
* xds --json upgrade (status short-circuit) -> upgrade.status
|
|
12
13
|
* (version detection failure) -> CLIError
|
|
13
14
|
*/
|
|
@@ -47,6 +48,52 @@
|
|
|
47
48
|
* @property {'refreshed' | 'would-refresh' | 'nudge-init' | 'error' | 'none'} action
|
|
48
49
|
*/
|
|
49
50
|
|
|
51
|
+
/**
|
|
52
|
+
* One copied file tracked by a ShadCN composition receipt.
|
|
53
|
+
* @typedef {object} RegistryCompositionFileSummary
|
|
54
|
+
* @property {string} path
|
|
55
|
+
* @property {'current'|'user-modified'|'would-update'|'updated'|'would-merge'|'merged'|'would-refresh-receipt'|'receipt-refreshed'|'conflict'|'missing'|'invalid'|'target-changed'} action
|
|
56
|
+
* @property {string} [message]
|
|
57
|
+
* @property {string} [conflictFile]
|
|
58
|
+
*/
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* One ShadCN registry item checked during upgrade.
|
|
62
|
+
* @typedef {object} RegistryCompositionItemSummary
|
|
63
|
+
* @property {string} item
|
|
64
|
+
* @property {string} [path]
|
|
65
|
+
* @property {'current'|'user-modified'|'would-update'|'updated'|'would-merge'|'merged'|'would-refresh-receipt'|'receipt-refreshed'|'conflict'|'invalid'|'fetch-error'|'write-error'} action
|
|
66
|
+
* @property {string} [message]
|
|
67
|
+
* @property {RegistryCompositionFileSummary[]} files
|
|
68
|
+
*/
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Aggregate receipt for ShadCN-copied composition reconciliation.
|
|
72
|
+
* @typedef {object} RegistryCompositionSummary
|
|
73
|
+
* @property {boolean} applied
|
|
74
|
+
* @property {boolean} ok False when conflicts, missing files, invalid receipts, or failures remain.
|
|
75
|
+
* @property {number} found
|
|
76
|
+
* @property {number} current Item count with no upstream source change.
|
|
77
|
+
* @property {number} wouldUpdate Item count with pristine updates in dry-run.
|
|
78
|
+
* @property {number} updated Item count with pristine updates applied.
|
|
79
|
+
* @property {number} wouldMerge Item count with clean merges in dry-run.
|
|
80
|
+
* @property {number} merged Item count with clean merges applied.
|
|
81
|
+
* @property {number} wouldRefreshReceipt Item count with metadata-only refreshes in dry-run.
|
|
82
|
+
* @property {number} receiptsRefreshed Item count with metadata-only refreshes applied.
|
|
83
|
+
* @property {number} conflicts Item count with at least one unresolved source conflict.
|
|
84
|
+
* @property {number} missing Per-file count of deleted or moved source files.
|
|
85
|
+
* @property {number} invalid Count of invalid receipts, unreadable sources, or changed targets.
|
|
86
|
+
* @property {number} failed Item count with fetch or write failures.
|
|
87
|
+
* @property {RegistryCompositionItemSummary[]} items
|
|
88
|
+
*/
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* xds --json upgrade --registry [--apply]
|
|
92
|
+
* @typedef {object} UpgradeRegistryResponse
|
|
93
|
+
* @property {'upgrade.registry'} type
|
|
94
|
+
* @property {RegistryCompositionSummary} data
|
|
95
|
+
*/
|
|
96
|
+
|
|
50
97
|
/**
|
|
51
98
|
* xds --json upgrade [--apply]
|
|
52
99
|
* @typedef {object} UpgradeRunResponse
|
|
@@ -58,6 +105,7 @@
|
|
|
58
105
|
* @property {string[]} data.integrations Integration packages processed in this upgrade (by name/spec).
|
|
59
106
|
* @property {boolean} data.agentDocsRefreshed
|
|
60
107
|
* @property {AgentDocsSummary} data.agentDocs
|
|
108
|
+
* @property {RegistryCompositionSummary} [data.registryCompositions]
|
|
61
109
|
* @property {number} [data.filesChanged] Total files changed across core + integration codemods (apply mode).
|
|
62
110
|
* @property {number} [data.transformsApplied] Total transforms that reported a change.
|
|
63
111
|
* @property {Array<{file: string, codemod: string, error: string}>} [data.errors] Per-codemod errors, when any codemod failed.
|
|
@@ -76,13 +124,13 @@
|
|
|
76
124
|
*
|
|
77
125
|
* @typedef {object} UpgradeStatusResponse
|
|
78
126
|
* @property {'upgrade.status'} type
|
|
79
|
-
* @property {{status: 'up_to_date', from: string, to: string, agentDocs: AgentDocsSummary} | {status: 'no_codemods', from: string, to: string, agentDocs: AgentDocsSummary} | {status: 'config_fixable', from: string, to: string, configError: string, configCodemods: string[], suggestedCommand: string, message: string, note: string, agentDocs: AgentDocsSummary}} data
|
|
127
|
+
* @property {{status: 'up_to_date', from: string, to: string, agentDocs: AgentDocsSummary, registryCompositions?: RegistryCompositionSummary} | {status: 'no_codemods', from: string, to: string, agentDocs: AgentDocsSummary, registryCompositions?: RegistryCompositionSummary} | {status: 'config_fixable', from: string, to: string, configError: string, configCodemods: string[], suggestedCommand: string, message: string, note: string, agentDocs: AgentDocsSummary}} data
|
|
80
128
|
*/
|
|
81
129
|
|
|
82
130
|
/**
|
|
83
131
|
* Options for `upgrade()`.
|
|
84
132
|
* @typedef {object} UpgradeOptions
|
|
85
|
-
* @property {string} [from] Version before the dependency bump (required unless `list`).
|
|
133
|
+
* @property {string} [from] Version before the dependency bump (required unless `list` or `registry`).
|
|
86
134
|
* @property {boolean} [apply] Write changes to disk (default: dry-run).
|
|
87
135
|
* @property {boolean} [force] Run codemods even if `from` >= installed.
|
|
88
136
|
* @property {string} [codemod] Run a single named transform.
|
|
@@ -90,6 +138,7 @@
|
|
|
90
138
|
* @property {string[]} [integration] Explicit integration package names / file paths.
|
|
91
139
|
* @property {string} [path] Source directory to scan (default `./src`).
|
|
92
140
|
* @property {boolean} [installDeps] Auto-install jscodeshift without prompting.
|
|
141
|
+
* @property {boolean} [registry] Reconcile only ShadCN-copied compositions; `from` is not required.
|
|
93
142
|
* @property {boolean} [list] Return the available codemods instead of running.
|
|
94
143
|
*/
|
|
95
144
|
|