@astryxdesign/cli 0.7.3-canary.e9694dc → 0.7.3-canary.ea68606
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +68 -68
- package/api/build/blocks/blocks.d.mts +6 -4
- package/api/build/blocks/blocks.mjs +103 -20
- package/api/build/blocks/blocks.test.mjs +126 -13
- package/api/build/blocks/blocks.weights.json +1 -1
- package/api/build/kit/answer.d.mts +5 -4
- package/api/build/kit/answer.mjs +114 -12
- package/api/build/kit/answer.test.mjs +73 -3
- package/api/build/kit/signals.d.mts +8 -0
- package/api/build/kit/signals.mjs +10 -0
- package/api/build/tree.test.mjs +19 -11
- package/api/component/component-replacement.test.mjs +1 -0
- package/api/component/component.mjs +17 -3
- package/api/component/component.test.mjs +15 -0
- package/api/component/doc-links.test.mjs +2 -2
- package/api/docs/_adapter.d.mts +2 -2
- package/api/docs/_adapter.mjs +61 -18
- package/api/docs/docs-homes.test.mjs +127 -0
- package/api/docs/docs.doc.mjs +3 -3
- package/api/docs/docs.test.mjs +28 -18
- package/api/docs/integration-tree.test.mjs +20 -20
- package/api/docs/integrationDocs.test.mjs +1 -1
- package/api/docs/namespace-section.test.mjs +6 -6
- package/api/docs/reference-blocks.test.mjs +2 -2
- package/api/doctor/doctor.mjs +16 -12
- package/api/doctor/doctor.test.mjs +37 -12
- package/api/hook/hook.mjs +1 -1
- package/api/integration/_adapter.d.mts +8 -0
- package/api/integration/_adapter.mjs +21 -1
- package/api/integration/authoring-checks.test.mjs +220 -0
- package/api/integration/validate-integration-fixes.test.mjs +6 -5
- package/api/integration/validate-integration-gaps.test.mjs +9 -1
- package/api/integration/validate-integration.d.mts +6 -1
- package/api/integration/validate-integration.mjs +45 -5
- package/api/integration/validate-integration.type.d.mts +33 -3
- package/api/integration/validate-integration.type.mjs +24 -4
- package/api/integration/validateIntegration.doc.mjs +1 -1
- package/api/search/_adapter.d.mts +16 -0
- package/api/search/_adapter.mjs +39 -0
- package/api/search/_adapter.test.mjs +173 -0
- package/api/search/_candidate-score.mjs +1 -1
- package/api/search/_entries.mjs +57 -1
- package/api/search/_gather-docs.mjs +3 -3
- package/api/search/search.doc.mjs +1 -1
- package/api/search/search.mjs +6 -2
- package/api/search/search.test.mjs +14 -14
- package/api/upgrade/_adapter.d.mts +57 -3
- package/api/upgrade/_adapter.mjs +149 -27
- package/api/upgrade/registry/registry.d.mts +10 -4
- package/api/upgrade/registry/registry.mjs +33 -16
- package/api/upgrade/registry/registry.test.mjs +85 -0
- package/api/upgrade/run/run.d.mts +4 -2
- package/api/upgrade/run/run.mjs +13 -2
- package/api/upgrade/run/run.test.mjs +417 -3
- package/api/upgrade/upgrade.doc.mjs +10 -5
- package/api/upgrade/upgrade.mjs +13 -2
- package/api/upgrade/upgrade.type.d.mts +5 -3
- package/api/upgrade/upgrade.type.mjs +8 -6
- package/assets/docs/author-a-theme.doc.mjs +2 -2
- package/assets/docs/tree/add-a-component.doc.mjs +1 -1
- package/assets/docs/tree/add-a-theme.doc.mjs +1 -1
- package/assets/docs/tree/add-a-topic.doc.mjs +2 -2
- package/assets/docs/tree/agent-guidance.doc.mjs +1 -1
- package/assets/docs/tree/{integrations.doc.mjs → authoring.doc.mjs} +15 -6
- package/assets/docs/tree/block-template.doc.mjs +1 -1
- package/assets/docs/tree/build-the-template.doc.mjs +1 -1
- package/assets/docs/tree/building-blocks.doc.mjs +2 -2
- package/assets/docs/tree/check-the-props.doc.mjs +1 -1
- package/assets/docs/tree/check-your-docs.doc.mjs +2 -2
- package/assets/docs/tree/checks.doc.mjs +3 -3
- package/assets/docs/tree/cli-command.doc.mjs +1 -1
- package/assets/docs/tree/cli.doc.mjs +1 -1
- package/assets/docs/tree/codemods.doc.mjs +1 -1
- package/assets/docs/tree/component-family.doc.mjs +1 -1
- package/assets/docs/tree/component-imports.doc.mjs +1 -1
- package/assets/docs/tree/components.doc.mjs +1 -1
- package/assets/docs/tree/configuration.doc.mjs +1 -1
- package/assets/docs/tree/debug-and-gap-reports.doc.mjs +1 -1
- package/assets/docs/tree/define-the-theme.doc.mjs +1 -1
- package/assets/docs/tree/describe-the-component.doc.mjs +1 -1
- package/assets/docs/tree/docs.doc.mjs +1 -1
- package/assets/docs/tree/document-the-template.doc.mjs +1 -1
- package/assets/docs/tree/document-the-theme.doc.mjs +1 -1
- package/assets/docs/tree/export-template-assets.doc.mjs +1 -1
- package/assets/docs/tree/extend-or-replace.doc.mjs +1 -1
- package/assets/docs/{authoring.doc.mjs → tree/field-reference.doc.mjs} +4 -3
- package/assets/docs/tree/fonts-and-assets.doc.mjs +1 -1
- package/assets/docs/tree/generate-a-palette.doc.mjs +1 -1
- package/assets/docs/tree/global-integrations.doc.mjs +2 -2
- package/assets/docs/tree/grade-template-with-agent.doc.mjs +4 -4
- package/assets/docs/tree/help.doc.mjs +2 -2
- package/assets/docs/tree/links.doc.mjs +1 -1
- package/assets/docs/tree/package-and-test.doc.mjs +1 -1
- package/assets/docs/tree/page-template.doc.mjs +1 -1
- package/assets/docs/tree/publishing.doc.mjs +1 -1
- package/assets/docs/tree/quick-start.doc.mjs +1 -1
- package/assets/docs/tree/replace-a-core-component.doc.mjs +1 -1
- package/assets/docs/tree/replace-a-core-template.doc.mjs +1 -1
- package/assets/docs/tree/sections-and-placement.doc.mjs +1 -1
- package/assets/docs/tree/see-it-in-an-app.doc.mjs +1 -1
- package/assets/docs/tree/ship.doc.mjs +2 -2
- package/assets/docs/tree/short-and-findable.doc.mjs +1 -1
- package/assets/docs/tree/single-component.doc.mjs +1 -1
- package/assets/docs/tree/start-a-template.doc.mjs +1 -1
- package/assets/docs/tree/subcomponent.doc.mjs +1 -1
- package/assets/docs/tree/template-assets.doc.mjs +1 -1
- package/assets/docs/tree/template-doc-overview.doc.mjs +2 -2
- package/assets/docs/tree/template-fonts.doc.mjs +1 -1
- package/assets/docs/tree/template-grading-rubric.doc.mjs +1 -1
- package/assets/docs/tree/template-icons.doc.mjs +1 -1
- package/assets/docs/tree/template-images-media.doc.mjs +1 -1
- package/assets/docs/tree/template-styles.doc.mjs +1 -1
- package/assets/docs/tree/templates.doc.mjs +1 -1
- package/assets/docs/tree/test-in-an-app.doc.mjs +1 -1
- package/assets/docs/tree/test-template-in-app.doc.mjs +1 -1
- package/assets/docs/tree/themes.doc.mjs +1 -1
- package/assets/docs/tree/troubleshooting.doc.mjs +1 -1
- package/assets/docs/tree/upgrading.doc.mjs +1 -1
- package/assets/docs/tree/use-a-theme-in-an-app.doc.mjs +1 -1
- package/assets/docs/tree/verify-packed-template.doc.mjs +1 -1
- package/assets/docs/tree/versioning.doc.mjs +1 -1
- package/assets/docs/tree/write-good-templates.doc.mjs +1 -1
- package/assets/docs/tree/write-the-template-file.doc.mjs +1 -1
- package/assets/docs/use-integrations.doc.mjs +120 -0
- package/assets/templates/themes/butter/butterTheme.ts +4 -2
- package/assets/templates/themes/stone/stoneTheme.ts +4 -2
- package/assets/templates/themes/y2k/y2kTheme.ts +4 -2
- package/authoring/doctypes/schema/schema.doc.mjs +1 -1
- package/authoring/integration/integration.doc.mjs +1 -1
- package/authoring/integration/type.ts +1 -1
- package/clients/cli/command-result-coverage.test.mjs +6 -5
- package/clients/cli/commands/build-theme.color-scheme.test.mjs +1 -1
- package/clients/cli/commands/{component/index.mjs → component.mjs} +37 -37
- package/clients/cli/commands/component.test.mjs +6 -6
- package/clients/cli/commands/docs.doc.mjs +2 -2
- package/clients/cli/commands/docs.mjs +1 -1
- package/clients/cli/commands/docs.test.mjs +14 -14
- package/clients/cli/commands/doctor-integration.test.mjs +49 -1
- package/clients/cli/commands/doctor.mjs +10 -0
- package/clients/cli/commands/{hook/index.mjs → hook.mjs} +22 -22
- package/clients/cli/commands/import-hint-correctness.test.mjs +1 -1
- package/clients/cli/commands/integration-check.test.mjs +48 -0
- package/clients/cli/commands/integration.doc.mjs +1 -1
- package/clients/cli/commands/manifest.doc.mjs +1 -1
- package/clients/cli/commands/manifest.mjs +67 -0
- package/clients/cli/commands/postinstall.doc.mjs +23 -0
- package/clients/cli/commands/postinstall.mjs +31 -0
- package/clients/cli/commands/{build-theme.mjs → theme.mjs} +1 -1
- package/clients/cli/commands/upgrade.doc.mjs +4 -2
- package/clients/cli/commands/upgrade.mjs +9 -2
- package/clients/cli/commands/upgrade.subfolder-path.test.mjs +97 -0
- package/clients/cli/index.mjs +10 -85
- package/clients/cli/lib/component-format.mjs +1 -1
- package/clients/cli/lib/define-command.mjs +12 -7
- package/clients/cli/lib/exit-codes.test.mjs +5 -0
- package/clients/cli/lib/manifest.test.mjs +12 -0
- package/clients/cli/lib/welcome-box.mjs +50 -0
- package/foundation/agent-docs/agent-docs.mjs +2 -1
- package/foundation/agent-docs/agent-docs.test.mjs +5 -4
- package/foundation/config/project.mjs +5 -20
- package/foundation/config/project.test.mjs +30 -0
- package/foundation/discovery/authoring-self-docs.d.mts +7 -0
- package/foundation/discovery/authoring-self-docs.mjs +16 -4
- package/foundation/discovery/authoring-self-docs.test.mjs +15 -3
- package/foundation/discovery/authoring-surface.d.mts +1 -1
- package/foundation/discovery/authoring-surface.mjs +2 -2
- package/foundation/discovery/authoring-surface.test.mjs +1 -1
- package/foundation/discovery/cli-self-docs.d.mts +2 -1
- package/foundation/discovery/cli-self-docs.mjs +4 -3
- package/foundation/discovery/cli-self-docs.test.mjs +2 -2
- package/foundation/discovery/runner-allowlist.d.mts +2 -4
- package/foundation/discovery/runner-allowlist.mjs +2 -4
- package/foundation/discovery/runner-commands.d.mts +77 -0
- package/foundation/discovery/runner-commands.mjs +294 -0
- package/foundation/discovery/runner-commands.test.mjs +128 -0
- package/foundation/discovery/stray-pointers.test.mjs +1 -1
- package/foundation/discovery/template-needs.mjs +1 -44
- package/foundation/doc-compiler/doc-loads.test.mjs +25 -9
- package/foundation/doc-compiler/split-topic-keywords.test.mjs +3 -2
- package/foundation/doc-compiler/tree.d.mts +32 -6
- package/foundation/doc-compiler/tree.mjs +77 -43
- package/foundation/doc-compiler/tree.test.mjs +7 -7
- package/foundation/fs/paths.d.mts +70 -8
- package/foundation/fs/paths.mjs +526 -35
- package/foundation/fs/paths.test.mjs +430 -54
- package/foundation/fs/read-record.d.mts +18 -0
- package/foundation/fs/read-record.mjs +131 -0
- package/foundation/fs/read-record.test.mjs +77 -0
- package/foundation/integrations/autolink.d.mts +2 -1
- package/foundation/integrations/autolink.mjs +4 -13
- package/foundation/integrations/exports-subpaths.d.mts +57 -0
- package/foundation/integrations/exports-subpaths.mjs +113 -0
- package/foundation/integrations/integrations.d.mts +11 -0
- package/foundation/integrations/integrations.mjs +21 -1
- package/foundation/integrations/public-imports.d.mts +81 -0
- package/foundation/integrations/public-imports.mjs +976 -0
- package/foundation/integrations/public-imports.test.mjs +868 -0
- package/foundation/response/response-types.doc.mjs +1 -1
- package/package.json +9 -9
|
@@ -3,18 +3,41 @@
|
|
|
3
3
|
/**
|
|
4
4
|
* @file Colocated tests for the upgrade.run leaf — the --path scan dir must be
|
|
5
5
|
* confined to cwd (upgrade rewrites source in place with --apply, so an escaping
|
|
6
|
-
* or out-of-tree path must be rejected),
|
|
7
|
-
* dir existed at all
|
|
6
|
+
* or out-of-tree path must be rejected), the receipt must say whether that
|
|
7
|
+
* dir existed at all, a run from any folder in a project upgrades that
|
|
8
|
+
* project (the nearest folder whose package.json declares Astryx, never the
|
|
9
|
+
* home folder) and names files relative to the folder it ran in, and the
|
|
10
|
+
* target Core is the project's own.
|
|
8
11
|
*/
|
|
9
12
|
|
|
10
|
-
import {describe, it, expect, beforeEach, afterEach} from 'vitest';
|
|
13
|
+
import {describe, it, expect, beforeEach, afterEach, vi} from 'vitest';
|
|
11
14
|
import * as fs from 'node:fs';
|
|
12
15
|
import * as os from 'node:os';
|
|
13
16
|
import * as path from 'node:path';
|
|
14
17
|
import {upgrade} from '../upgrade.mjs';
|
|
18
|
+
import {relativeToOrigin} from '../_adapter.mjs';
|
|
19
|
+
import {logger} from '../../logger.mjs';
|
|
20
|
+
import {generateCompressedIndex} from '../../../foundation/agent-docs/agent-docs.mjs';
|
|
15
21
|
|
|
16
22
|
const SLOW = 30_000;
|
|
17
23
|
|
|
24
|
+
/**
|
|
25
|
+
* Run `fn` with `home` as the home folder.
|
|
26
|
+
* @template T
|
|
27
|
+
* @param {string} home @param {() => Promise<T>} fn
|
|
28
|
+
* @returns {Promise<T>}
|
|
29
|
+
*/
|
|
30
|
+
async function withHome(home, fn) {
|
|
31
|
+
const previous = process.env.HOME;
|
|
32
|
+
process.env.HOME = home;
|
|
33
|
+
try {
|
|
34
|
+
return await fn();
|
|
35
|
+
} finally {
|
|
36
|
+
if (previous === undefined) delete process.env.HOME;
|
|
37
|
+
else process.env.HOME = previous;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
18
41
|
function seedProject(dir) {
|
|
19
42
|
fs.writeFileSync(
|
|
20
43
|
path.join(dir, 'package.json'),
|
|
@@ -95,3 +118,394 @@ describe('upgrade.run — sourcePathFound', () => {
|
|
|
95
118
|
expect(res.data.sourcePathFound).toBe(true);
|
|
96
119
|
}, SLOW);
|
|
97
120
|
});
|
|
121
|
+
|
|
122
|
+
/** Core 0.7.0 renamed this prop; its codemod renames it on Typeahead. */
|
|
123
|
+
const OLD_PROP_SOURCE =
|
|
124
|
+
"import {Typeahead} from '@astryxdesign/core';\n" +
|
|
125
|
+
'export const App = () => <Typeahead label="Fruit" emptySearchResultsText="None" />;\n';
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* A project with Core 0.7.0 installed and src/App.tsx using a prop that 0.7.0
|
|
129
|
+
* renamed.
|
|
130
|
+
* @param {string} dir
|
|
131
|
+
*/
|
|
132
|
+
function seedOldPropProject(dir) {
|
|
133
|
+
fs.writeFileSync(
|
|
134
|
+
path.join(dir, 'package.json'),
|
|
135
|
+
JSON.stringify({name: 'app', dependencies: {'@astryxdesign/core': '0.7.0'}}),
|
|
136
|
+
);
|
|
137
|
+
const core = path.join(dir, 'node_modules', '@astryxdesign', 'core');
|
|
138
|
+
fs.mkdirSync(core, {recursive: true});
|
|
139
|
+
fs.writeFileSync(path.join(core, 'package.json'), JSON.stringify({name: '@astryxdesign/core', version: '0.7.0'}));
|
|
140
|
+
fs.mkdirSync(path.join(dir, 'src', 'l1', 'l2'), {recursive: true});
|
|
141
|
+
fs.writeFileSync(path.join(dir, 'src', 'App.tsx'), OLD_PROP_SOURCE);
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
describe('upgrade.run — a run from a subfolder upgrades the project', () => {
|
|
145
|
+
let dir;
|
|
146
|
+
beforeEach(() => {
|
|
147
|
+
dir = fs.mkdtempSync(path.join(os.tmpdir(), 'upg-scope-'));
|
|
148
|
+
seedOldPropProject(dir);
|
|
149
|
+
});
|
|
150
|
+
afterEach(() => fs.rmSync(dir, {recursive: true, force: true}));
|
|
151
|
+
|
|
152
|
+
const appSource = () => fs.readFileSync(path.join(dir, 'src', 'App.tsx'), 'utf-8');
|
|
153
|
+
|
|
154
|
+
it.each([['src', 'App.tsx'], ['src/l1/l2', '../../App.tsx']])(
|
|
155
|
+
'scans the project src by default when run from %s',
|
|
156
|
+
async (folder, reported) => {
|
|
157
|
+
const res = await upgrade({from: '0.6.8', apply: true}, {cwd: path.join(dir, folder)});
|
|
158
|
+
|
|
159
|
+
expect(res.type).toBe('upgrade.run');
|
|
160
|
+
expect(res.data.sourcePathFound).toBe(true);
|
|
161
|
+
expect(res.data.filesChanged).toBe(1);
|
|
162
|
+
expect(res.data.modifiedFiles).toEqual([reported]);
|
|
163
|
+
expect(appSource()).toContain('emptySearchText="None"');
|
|
164
|
+
},
|
|
165
|
+
SLOW,
|
|
166
|
+
);
|
|
167
|
+
|
|
168
|
+
it('reads a path you name relative to the folder you ran in', async () => {
|
|
169
|
+
const res = await upgrade({from: '0.6.8', path: '../..', apply: true}, {cwd: path.join(dir, 'src', 'l1', 'l2')});
|
|
170
|
+
|
|
171
|
+
expect(res.type).toBe('upgrade.run');
|
|
172
|
+
expect(res.data.filesChanged).toBe(1);
|
|
173
|
+
expect(appSource()).toContain('emptySearchText="None"');
|
|
174
|
+
}, SLOW);
|
|
175
|
+
|
|
176
|
+
it('still rejects a path outside the project', async () => {
|
|
177
|
+
await expect(
|
|
178
|
+
upgrade({from: '0.6.8', path: '../../..'}, {cwd: path.join(dir, 'src', 'l1')}),
|
|
179
|
+
).rejects.toMatchObject({code: 'ERR_PATH_TRAVERSAL'});
|
|
180
|
+
expect(appSource()).toBe(OLD_PROP_SOURCE);
|
|
181
|
+
}, SLOW);
|
|
182
|
+
|
|
183
|
+
it("refreshes the agent docs at the project root, not the folder it ran in", async () => {
|
|
184
|
+
fs.writeFileSync(
|
|
185
|
+
path.join(dir, 'AGENTS.md'),
|
|
186
|
+
`# Agents\n\n${generateCompressedIndex('0.6.8')}\n`,
|
|
187
|
+
);
|
|
188
|
+
|
|
189
|
+
const res = await upgrade({from: '0.6.8', apply: true}, {cwd: path.join(dir, 'src', 'l1')});
|
|
190
|
+
|
|
191
|
+
expect(res.type).toBe('upgrade.run');
|
|
192
|
+
expect(res.data.agentDocs.action).toBe('refreshed');
|
|
193
|
+
expect(res.data.agentDocs.files).toEqual(['../../AGENTS.md']);
|
|
194
|
+
expect(fs.existsSync(path.join(dir, 'src', 'l1', 'AGENTS.md'))).toBe(false);
|
|
195
|
+
}, SLOW);
|
|
196
|
+
});
|
|
197
|
+
|
|
198
|
+
describe('upgrade.run — the result names files relative to the folder it ran in', () => {
|
|
199
|
+
let dir;
|
|
200
|
+
beforeEach(() => {
|
|
201
|
+
dir = fs.mkdtempSync(path.join(os.tmpdir(), 'upg-receipt-'));
|
|
202
|
+
seedOldPropProject(dir);
|
|
203
|
+
fs.writeFileSync(path.join(dir, 'src', 'Generated.tsx'), `// @generated\n${OLD_PROP_SOURCE}`);
|
|
204
|
+
fs.writeFileSync(path.join(dir, 'src', 'Vendored.tsx'), OLD_PROP_SOURCE);
|
|
205
|
+
fs.writeFileSync(path.join(dir, '.gitattributes'), 'src/Vendored.tsx linguist-generated\n');
|
|
206
|
+
fs.writeFileSync(path.join(dir, 'AGENTS.md'), `# Agents\n\n${generateCompressedIndex('0.6.8')}\n`);
|
|
207
|
+
fs.mkdirSync(path.join(dir, 'frontend'), {recursive: true});
|
|
208
|
+
});
|
|
209
|
+
afterEach(() => fs.rmSync(dir, {recursive: true, force: true}));
|
|
210
|
+
|
|
211
|
+
it.each([
|
|
212
|
+
['frontend', '../'],
|
|
213
|
+
['.', ''],
|
|
214
|
+
])('from %s, every file path resolves from that folder', async (folder, up) => {
|
|
215
|
+
const cwd = path.join(dir, folder);
|
|
216
|
+
|
|
217
|
+
const res = await upgrade({from: '0.6.8'}, {cwd});
|
|
218
|
+
|
|
219
|
+
expect(res.type).toBe('upgrade.run');
|
|
220
|
+
expect(res.data.modifiedFiles).toEqual([`${up}src/App.tsx`]);
|
|
221
|
+
expect(res.data.protectedFiles.map(item => item.file)).toEqual([
|
|
222
|
+
`${up}src/Generated.tsx`,
|
|
223
|
+
`${up}src/Vendored.tsx`,
|
|
224
|
+
]);
|
|
225
|
+
for (const file of [...res.data.modifiedFiles, ...res.data.protectedFiles.map(item => item.file)]) {
|
|
226
|
+
expect(fs.existsSync(path.join(cwd, file))).toBe(true);
|
|
227
|
+
}
|
|
228
|
+
// The file a declaration names resolves from that folder too.
|
|
229
|
+
const vendored = res.data.protectedFiles.find(item => item.file.endsWith('Vendored.tsx'));
|
|
230
|
+
expect(vendored?.declarations).toEqual([`linguist-generated in ${up}.gitattributes:1`]);
|
|
231
|
+
expect(fs.existsSync(path.join(cwd, `${up}.gitattributes`))).toBe(true);
|
|
232
|
+
}, SLOW);
|
|
233
|
+
|
|
234
|
+
it('leaves a result from a run at the project root as it is', () => {
|
|
235
|
+
const result = {type: 'upgrade.run', data: {modifiedFiles: ['src/App.tsx']}};
|
|
236
|
+
|
|
237
|
+
expect(relativeToOrigin(result, {cwd: dir})).toBe(result);
|
|
238
|
+
});
|
|
239
|
+
|
|
240
|
+
it('rewrites every project-relative path and passes the copied-composition summary through', () => {
|
|
241
|
+
const registryCompositions = {items: [{item: 'example', path: 'components/Example.tsx', files: []}]};
|
|
242
|
+
const result = relativeToOrigin(
|
|
243
|
+
{
|
|
244
|
+
type: 'upgrade.run',
|
|
245
|
+
data: {
|
|
246
|
+
agentDocs: {status: 'stale', files: ['AGENTS.md']},
|
|
247
|
+
modifiedFiles: ['src/App.tsx'],
|
|
248
|
+
protectedFiles: [
|
|
249
|
+
{
|
|
250
|
+
file: 'src/Generated.tsx',
|
|
251
|
+
codemods: ['a'],
|
|
252
|
+
declarations: [
|
|
253
|
+
'@generated marker',
|
|
254
|
+
'excluded by .gitignore',
|
|
255
|
+
'excluded by src/.hgignore:3',
|
|
256
|
+
'linguist-generated in .gitattributes:1',
|
|
257
|
+
'symbolic link at src/linked',
|
|
258
|
+
'installed dependency metadata node_modules/x',
|
|
259
|
+
],
|
|
260
|
+
},
|
|
261
|
+
],
|
|
262
|
+
declinedCandidates: [{file: 'src/Loose.tsx', reason: 'unproven'}],
|
|
263
|
+
errors: [{file: '.', codemod: 'post-codemod-hook', error: 'failed'}],
|
|
264
|
+
registryCompositions,
|
|
265
|
+
},
|
|
266
|
+
},
|
|
267
|
+
{cwd: dir, origin: path.join(dir, 'apps', 'web')},
|
|
268
|
+
);
|
|
269
|
+
|
|
270
|
+
expect(result.data).toEqual({
|
|
271
|
+
agentDocs: {status: 'stale', files: ['../../AGENTS.md']},
|
|
272
|
+
modifiedFiles: ['../../src/App.tsx'],
|
|
273
|
+
protectedFiles: [
|
|
274
|
+
{
|
|
275
|
+
file: '../../src/Generated.tsx',
|
|
276
|
+
codemods: ['a'],
|
|
277
|
+
declarations: [
|
|
278
|
+
'@generated marker',
|
|
279
|
+
'excluded by ../../.gitignore',
|
|
280
|
+
'excluded by ../../src/.hgignore:3',
|
|
281
|
+
'linguist-generated in ../../.gitattributes:1',
|
|
282
|
+
'symbolic link at ../../src/linked',
|
|
283
|
+
'installed dependency metadata node_modules/x',
|
|
284
|
+
],
|
|
285
|
+
},
|
|
286
|
+
],
|
|
287
|
+
declinedCandidates: [{file: '../../src/Loose.tsx', reason: 'unproven'}],
|
|
288
|
+
errors: [{file: '../..', codemod: 'post-codemod-hook', error: 'failed'}],
|
|
289
|
+
registryCompositions,
|
|
290
|
+
});
|
|
291
|
+
});
|
|
292
|
+
});
|
|
293
|
+
|
|
294
|
+
describe("upgrade.run — the target Core is the project's own", () => {
|
|
295
|
+
let dir;
|
|
296
|
+
beforeEach(() => {
|
|
297
|
+
dir = fs.mkdtempSync(path.join(os.tmpdir(), 'upg-own-core-'));
|
|
298
|
+
seedOldPropProject(dir);
|
|
299
|
+
});
|
|
300
|
+
afterEach(() => fs.rmSync(dir, {recursive: true, force: true}));
|
|
301
|
+
|
|
302
|
+
/**
|
|
303
|
+
* A project nested in `dir`, with src/App.tsx using the renamed prop.
|
|
304
|
+
* @param {Record<string, string>} dependencies
|
|
305
|
+
*/
|
|
306
|
+
function nestedProject(dependencies) {
|
|
307
|
+
const nested = path.join(dir, 'apps', 'web');
|
|
308
|
+
fs.mkdirSync(path.join(nested, 'src'), {recursive: true});
|
|
309
|
+
fs.writeFileSync(path.join(nested, 'package.json'), JSON.stringify({name: 'web', dependencies}));
|
|
310
|
+
fs.writeFileSync(path.join(nested, 'src', 'App.tsx'), OLD_PROP_SOURCE);
|
|
311
|
+
return nested;
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
it.each([
|
|
315
|
+
['declares no Astryx package', {}],
|
|
316
|
+
['declares a Core it has not installed', {'@astryxdesign/core': '0.6.8'}],
|
|
317
|
+
])(
|
|
318
|
+
'does not upgrade a project that %s to the Core of the home folder above it',
|
|
319
|
+
async (_label, dependencies) => {
|
|
320
|
+
const nested = nestedProject(dependencies);
|
|
321
|
+
|
|
322
|
+
await withHome(dir, () =>
|
|
323
|
+
expect(
|
|
324
|
+
upgrade({from: '0.6.8', apply: true}, {cwd: nested}),
|
|
325
|
+
).rejects.toMatchObject({code: 'ERR_VERSION_DETECT'}),
|
|
326
|
+
);
|
|
327
|
+
expect(fs.readFileSync(path.join(nested, 'src', 'App.tsx'), 'utf-8')).toBe(OLD_PROP_SOURCE);
|
|
328
|
+
expect(fs.readFileSync(path.join(dir, 'src', 'App.tsx'), 'utf-8')).toBe(OLD_PROP_SOURCE);
|
|
329
|
+
},
|
|
330
|
+
SLOW,
|
|
331
|
+
);
|
|
332
|
+
|
|
333
|
+
it('names the folder it searched before stopping on a missing Core, from a subfolder (AST-040 FR12)', async () => {
|
|
334
|
+
fs.rmSync(path.join(dir, 'node_modules'), {recursive: true, force: true});
|
|
335
|
+
const sub = path.join(dir, 'src', 'l1');
|
|
336
|
+
const log = vi.spyOn(logger, 'log');
|
|
337
|
+
try {
|
|
338
|
+
await expect(upgrade({from: '0.6.8'}, {cwd: sub})).rejects.toMatchObject({
|
|
339
|
+
code: 'ERR_VERSION_DETECT',
|
|
340
|
+
});
|
|
341
|
+
const lines = log.mock.calls.map(([line]) => String(line));
|
|
342
|
+
expect(lines).toContain('Project root: ../..');
|
|
343
|
+
expect(lines.indexOf('Project root: ../..')).toBeLessThan(
|
|
344
|
+
lines.indexOf('Aborted\n'),
|
|
345
|
+
);
|
|
346
|
+
} finally {
|
|
347
|
+
log.mockRestore();
|
|
348
|
+
}
|
|
349
|
+
}, SLOW);
|
|
350
|
+
|
|
351
|
+
it('does not upgrade a nested project that declares a Core it has not installed to the Core above it', async () => {
|
|
352
|
+
const nested = nestedProject({'@astryxdesign/core': '0.6.8'});
|
|
353
|
+
|
|
354
|
+
await expect(
|
|
355
|
+
upgrade({from: '0.6.8', apply: true}, {cwd: nested}),
|
|
356
|
+
).rejects.toMatchObject({code: 'ERR_VERSION_DETECT'});
|
|
357
|
+
expect(fs.readFileSync(path.join(nested, 'src', 'App.tsx'), 'utf-8')).toBe(OLD_PROP_SOURCE);
|
|
358
|
+
}, SLOW);
|
|
359
|
+
|
|
360
|
+
it.each([
|
|
361
|
+
['an override at the workspace root forces', {overrides: {'@astryxdesign/core': '0.7.0'}}, {'@astryxdesign/core': '~0.6.8'}],
|
|
362
|
+
['a resolution at the workspace root forces', {resolutions: {'@astryxdesign/core': '0.7.0'}}, {'@astryxdesign/core': '0.6.8'}],
|
|
363
|
+
['only a stale peer range names', {}, null],
|
|
364
|
+
['the member declares another version of, not yet installed', {}, {'@astryxdesign/core': '0.9.0'}],
|
|
365
|
+
])(
|
|
366
|
+
'upgrades a workspace member to a hoisted Core that %s',
|
|
367
|
+
async (_label, rootFields, dependencies) => {
|
|
368
|
+
fs.writeFileSync(
|
|
369
|
+
path.join(dir, 'package.json'),
|
|
370
|
+
JSON.stringify({name: 'root', private: true, workspaces: ['apps/*'], ...rootFields}),
|
|
371
|
+
);
|
|
372
|
+
const member = dependencies
|
|
373
|
+
? nestedProject(dependencies)
|
|
374
|
+
: nestedProject({});
|
|
375
|
+
if (!dependencies) {
|
|
376
|
+
fs.writeFileSync(
|
|
377
|
+
path.join(member, 'package.json'),
|
|
378
|
+
JSON.stringify({name: 'web', peerDependencies: {'@astryxdesign/core': '^0.6.8'}}),
|
|
379
|
+
);
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
const res = await upgrade({from: '0.6.8', apply: true}, {cwd: member});
|
|
383
|
+
|
|
384
|
+
expect(res.type).toBe('upgrade.run');
|
|
385
|
+
expect(res.data.to).toBe('0.7.0');
|
|
386
|
+
expect(res.data.modifiedFiles).toEqual(['src/App.tsx']);
|
|
387
|
+
expect(fs.readFileSync(path.join(member, 'src', 'App.tsx'), 'utf-8')).toContain('emptySearchText="None"');
|
|
388
|
+
},
|
|
389
|
+
SLOW,
|
|
390
|
+
);
|
|
391
|
+
|
|
392
|
+
it('does not upgrade a project its workspace does not list to the hoisted Core', async () => {
|
|
393
|
+
fs.writeFileSync(
|
|
394
|
+
path.join(dir, 'package.json'),
|
|
395
|
+
JSON.stringify({name: 'root', private: true, workspaces: ['packages/*']}),
|
|
396
|
+
);
|
|
397
|
+
const project = nestedProject({'@astryxdesign/core': '0.9.0'});
|
|
398
|
+
|
|
399
|
+
await expect(
|
|
400
|
+
upgrade({from: '0.6.8', apply: true}, {cwd: project}),
|
|
401
|
+
).rejects.toMatchObject({code: 'ERR_VERSION_DETECT'});
|
|
402
|
+
expect(fs.readFileSync(path.join(project, 'src', 'App.tsx'), 'utf-8')).toBe(OLD_PROP_SOURCE);
|
|
403
|
+
}, SLOW);
|
|
404
|
+
|
|
405
|
+
it.each([[['apps/*']], [['{apps/*,tools/*}']]])('upgrades a member that declares no Astryx package, in its own src, when the workspace lists %j', async workspaces => {
|
|
406
|
+
fs.writeFileSync(
|
|
407
|
+
path.join(dir, 'package.json'),
|
|
408
|
+
JSON.stringify({name: 'root', private: true, workspaces, dependencies: {'@astryxdesign/core': '0.7.0'}}),
|
|
409
|
+
);
|
|
410
|
+
const member = nestedProject({});
|
|
411
|
+
|
|
412
|
+
const res = await upgrade({from: '0.6.8', apply: true}, {cwd: path.join(member, 'src')});
|
|
413
|
+
|
|
414
|
+
expect(res.type).toBe('upgrade.run');
|
|
415
|
+
expect(res.data.modifiedFiles).toEqual(['App.tsx']);
|
|
416
|
+
expect(fs.readFileSync(path.join(member, 'src', 'App.tsx'), 'utf-8')).toContain('emptySearchText="None"');
|
|
417
|
+
expect(fs.readFileSync(path.join(dir, 'src', 'App.tsx'), 'utf-8')).toBe(OLD_PROP_SOURCE);
|
|
418
|
+
}, SLOW);
|
|
419
|
+
});
|
|
420
|
+
|
|
421
|
+
describe('upgrade.run — the project is the nearest folder that declares Astryx', () => {
|
|
422
|
+
let home;
|
|
423
|
+
beforeEach(() => {
|
|
424
|
+
home = fs.mkdtempSync(path.join(os.tmpdir(), 'upg-home-'));
|
|
425
|
+
});
|
|
426
|
+
afterEach(() => fs.rmSync(home, {recursive: true, force: true}));
|
|
427
|
+
|
|
428
|
+
// Astryx installed in a home folder whose src holds loose files and another
|
|
429
|
+
// project, run from a folder with no package.json.
|
|
430
|
+
it('does not upgrade the home folder from a folder inside it', async () => {
|
|
431
|
+
seedOldPropProject(home);
|
|
432
|
+
fs.mkdirSync(path.join(home, 'src', 'repoA', 'src'), {recursive: true});
|
|
433
|
+
fs.writeFileSync(
|
|
434
|
+
path.join(home, 'src', 'repoA', 'package.json'),
|
|
435
|
+
JSON.stringify({name: 'repoA', dependencies: {'@astryxdesign/core': '0.6.8'}}),
|
|
436
|
+
);
|
|
437
|
+
fs.writeFileSync(path.join(home, 'src', 'repoA', 'src', 'a.tsx'), OLD_PROP_SOURCE);
|
|
438
|
+
const desktop = path.join(home, 'Desktop');
|
|
439
|
+
fs.mkdirSync(desktop, {recursive: true});
|
|
440
|
+
|
|
441
|
+
await withHome(home, () =>
|
|
442
|
+
expect(
|
|
443
|
+
upgrade({from: '0.6.8', apply: true}, {cwd: desktop}),
|
|
444
|
+
).rejects.toMatchObject({code: 'ERR_VERSION_DETECT'}),
|
|
445
|
+
);
|
|
446
|
+
expect(fs.readFileSync(path.join(home, 'src', 'App.tsx'), 'utf-8')).toBe(OLD_PROP_SOURCE);
|
|
447
|
+
expect(fs.readFileSync(path.join(home, 'src', 'repoA', 'src', 'a.tsx'), 'utf-8')).toBe(OLD_PROP_SOURCE);
|
|
448
|
+
}, SLOW);
|
|
449
|
+
|
|
450
|
+
// Installing Core does not make a folder a project.
|
|
451
|
+
it('treats a folder that installs Core without declaring it as part of the project above it', async () => {
|
|
452
|
+
seedOldPropProject(home);
|
|
453
|
+
const tool = path.join(home, 'tools', 'codegen');
|
|
454
|
+
const core = path.join(tool, 'node_modules', '@astryxdesign', 'core');
|
|
455
|
+
fs.mkdirSync(core, {recursive: true});
|
|
456
|
+
fs.writeFileSync(path.join(tool, 'package.json'), JSON.stringify({name: 'codegen'}));
|
|
457
|
+
fs.writeFileSync(path.join(core, 'package.json'), JSON.stringify({name: '@astryxdesign/core', version: '0.9.0'}));
|
|
458
|
+
|
|
459
|
+
const res = await upgrade({from: '0.6.8', apply: true}, {cwd: tool});
|
|
460
|
+
|
|
461
|
+
expect(res.type).toBe('upgrade.run');
|
|
462
|
+
expect(res.data.to).toBe('0.7.0');
|
|
463
|
+
expect(res.data.modifiedFiles).toEqual(['../../src/App.tsx']);
|
|
464
|
+
}, SLOW);
|
|
465
|
+
|
|
466
|
+
it('names the project root and the folder it scans before a dry run in a folder that installs Core without declaring it', async () => {
|
|
467
|
+
seedOldPropProject(home);
|
|
468
|
+
const tool = path.join(home, 'tools', 'codegen');
|
|
469
|
+
const core = path.join(tool, 'node_modules', '@astryxdesign', 'core');
|
|
470
|
+
fs.mkdirSync(core, {recursive: true});
|
|
471
|
+
fs.writeFileSync(path.join(tool, 'package.json'), JSON.stringify({name: 'codegen'}));
|
|
472
|
+
fs.writeFileSync(path.join(core, 'package.json'), JSON.stringify({name: '@astryxdesign/core', version: '0.9.0'}));
|
|
473
|
+
const log = vi.spyOn(logger, 'log');
|
|
474
|
+
try {
|
|
475
|
+
const res = await upgrade({from: '0.6.8'}, {cwd: tool});
|
|
476
|
+
|
|
477
|
+
expect(res.type).toBe('upgrade.run');
|
|
478
|
+
const lines = log.mock.calls.map(([line]) => String(line));
|
|
479
|
+
expect(lines).toContain('Project root: ../..');
|
|
480
|
+
expect(lines).toContain(`Source folder: ${path.join('..', '..', 'src')}`);
|
|
481
|
+
expect(fs.readFileSync(path.join(home, 'src', 'App.tsx'), 'utf-8')).toBe(OLD_PROP_SOURCE);
|
|
482
|
+
} finally {
|
|
483
|
+
log.mockRestore();
|
|
484
|
+
}
|
|
485
|
+
}, SLOW);
|
|
486
|
+
|
|
487
|
+
it('upgrades the home folder as a folder outside any project, when run there', async () => {
|
|
488
|
+
seedOldPropProject(home);
|
|
489
|
+
|
|
490
|
+
const res = await withHome(home, () => upgrade({from: '0.6.8', apply: true}, {cwd: home}));
|
|
491
|
+
|
|
492
|
+
expect(res.type).toBe('upgrade.run');
|
|
493
|
+
expect(res.data.modifiedFiles).toEqual(['src/App.tsx']);
|
|
494
|
+
expect(fs.readFileSync(path.join(home, 'src', 'App.tsx'), 'utf-8')).toContain('emptySearchText="None"');
|
|
495
|
+
}, SLOW);
|
|
496
|
+
|
|
497
|
+
it('does not leave a repository for the project around it', async () => {
|
|
498
|
+
seedOldPropProject(home);
|
|
499
|
+
const repo = path.join(home, 'vendor', 'repo');
|
|
500
|
+
fs.mkdirSync(path.join(repo, '.git'), {recursive: true});
|
|
501
|
+
fs.mkdirSync(path.join(repo, 'src'), {recursive: true});
|
|
502
|
+
fs.writeFileSync(path.join(repo, 'package.json'), JSON.stringify({name: 'repo'}));
|
|
503
|
+
fs.writeFileSync(path.join(repo, 'src', 'App.tsx'), OLD_PROP_SOURCE);
|
|
504
|
+
|
|
505
|
+
await expect(
|
|
506
|
+
upgrade({from: '0.6.8', apply: true}, {cwd: repo}),
|
|
507
|
+
).rejects.toMatchObject({code: 'ERR_VERSION_DETECT'});
|
|
508
|
+
expect(fs.readFileSync(path.join(repo, 'src', 'App.tsx'), 'utf-8')).toBe(OLD_PROP_SOURCE);
|
|
509
|
+
expect(fs.readFileSync(path.join(home, 'src', 'App.tsx'), 'utf-8')).toBe(OLD_PROP_SOURCE);
|
|
510
|
+
}, SLOW);
|
|
511
|
+
});
|
|
@@ -77,8 +77,9 @@ export const doc = {
|
|
|
77
77
|
{
|
|
78
78
|
name: 'options.path',
|
|
79
79
|
type: 'string',
|
|
80
|
-
description:
|
|
81
|
-
|
|
80
|
+
description:
|
|
81
|
+
'Source directory to scan. A path you name, in any spelling, is relative to `ctx.cwd`. When it is omitted, the upgrade scans `./src` at the project root.',
|
|
82
|
+
default: './src at the project root',
|
|
82
83
|
},
|
|
83
84
|
{
|
|
84
85
|
name: 'options.installDeps',
|
|
@@ -103,7 +104,8 @@ export const doc = {
|
|
|
103
104
|
{
|
|
104
105
|
name: 'ctx.cwd',
|
|
105
106
|
type: 'string',
|
|
106
|
-
description:
|
|
107
|
+
description:
|
|
108
|
+
'Any folder in the project to upgrade. The upgrade runs at the project root: the nearest folder at or above it whose package.json declares an Astryx package, or that a workspace whose root declares one lists, found without passing a repository root or counting the home folder. With no such folder, it runs in `ctx.cwd`. File paths in the result are relative to `ctx.cwd`, except that a run at the project root names copied-composition paths relative to the scanned source directory.',
|
|
107
109
|
default: 'process.cwd()',
|
|
108
110
|
},
|
|
109
111
|
],
|
|
@@ -135,10 +137,13 @@ export const doc = {
|
|
|
135
137
|
when: '`from` is missing (and neither `list` nor `registry` is set); `list` and `registry` are both set; `list` is combined with `from`, `force`, `apply`, `path` (non-default), `codemod`, `skipCodemod`, `integration` or `installDeps`; `registry` is combined with `from`, `force`, `codemod`, `skipCodemod`, `integration` or `installDeps`; an `integration` specifier is invalid or not installed; or astryx.config fails to load or validate and no pending config codemod repairs it',
|
|
136
138
|
},
|
|
137
139
|
{code: 'ERR_INVALID_VERSION', when: '`from` is not a valid semver string'},
|
|
138
|
-
{
|
|
140
|
+
{
|
|
141
|
+
code: 'ERR_PATH_TRAVERSAL',
|
|
142
|
+
when: '`path` resolves outside the project root',
|
|
143
|
+
},
|
|
139
144
|
{
|
|
140
145
|
code: 'ERR_VERSION_DETECT',
|
|
141
|
-
when:
|
|
146
|
+
when: "the project has installed neither @astryxdesign/core nor legacy @xds/core in its own node_modules, nor, for a member its workspace lists, in a folder up to the workspace root (with no Astryx project, in `ctx.cwd`'s own node_modules); with `registry`, only when copied-composition receipts exist and @astryxdesign/core is not installed",
|
|
142
147
|
},
|
|
143
148
|
{
|
|
144
149
|
code: 'ERR_DEP_MISSING',
|
package/api/upgrade/upgrade.mjs
CHANGED
|
@@ -24,6 +24,7 @@
|
|
|
24
24
|
import {list} from './list/list.mjs';
|
|
25
25
|
import {registryUpgrade} from './registry/registry.mjs';
|
|
26
26
|
import {run} from './run/run.mjs';
|
|
27
|
+
import {relativeToOrigin, scopeToProject} from './_adapter.mjs';
|
|
27
28
|
import {isValidSemver} from '../../foundation/env/semver.mjs';
|
|
28
29
|
import {getCliInvocation} from '../../foundation/env/package-manager.mjs';
|
|
29
30
|
import {isOutsideProject} from '../../foundation/env/project-scope.mjs';
|
|
@@ -88,7 +89,11 @@ export async function upgrade(options = {}, {cwd = process.cwd()} = {}) {
|
|
|
88
89
|
logger.log('Aborted\n');
|
|
89
90
|
throw new AstryxError(msg, undefined, ERROR_CODES.ERR_INVALID_ARGUMENT);
|
|
90
91
|
}
|
|
91
|
-
|
|
92
|
+
const scoped = scopeToProject(options, cwd);
|
|
93
|
+
return registryUpgrade(scoped.options, {
|
|
94
|
+
cwd: scoped.cwd,
|
|
95
|
+
origin: scoped.origin,
|
|
96
|
+
});
|
|
92
97
|
}
|
|
93
98
|
|
|
94
99
|
if (!options.list && !options.from) {
|
|
@@ -112,5 +117,11 @@ export async function upgrade(options = {}, {cwd = process.cwd()} = {}) {
|
|
|
112
117
|
return list();
|
|
113
118
|
}
|
|
114
119
|
|
|
115
|
-
|
|
120
|
+
// A run from a subfolder upgrades the project the folder belongs to, and
|
|
121
|
+
// names files relative to the folder it ran in.
|
|
122
|
+
const scoped = scopeToProject(options, cwd);
|
|
123
|
+
return relativeToOrigin(
|
|
124
|
+
await run(scoped.options, {cwd: scoped.cwd, origin: scoped.origin}),
|
|
125
|
+
scoped,
|
|
126
|
+
);
|
|
116
127
|
}
|
|
@@ -44,7 +44,7 @@ export type AgentDocsSummary = {
|
|
|
44
44
|
*/
|
|
45
45
|
fromVersions: string[];
|
|
46
46
|
/**
|
|
47
|
-
* Files rewritten (apply) or that would be rewritten (dry-run).
|
|
47
|
+
* Files rewritten (apply) or that would be rewritten (dry-run), relative to the folder the command ran in.
|
|
48
48
|
*/
|
|
49
49
|
files: string[];
|
|
50
50
|
/**
|
|
@@ -73,7 +73,9 @@ export type RegistryCompositionItemSummary = {
|
|
|
73
73
|
files: RegistryCompositionFileSummary[];
|
|
74
74
|
};
|
|
75
75
|
/**
|
|
76
|
-
* Aggregate receipt for ShadCN-copied composition reconciliation.
|
|
76
|
+
* Aggregate receipt for ShadCN-copied composition reconciliation. File paths
|
|
77
|
+
* are relative to the scanned source directory, or, when the upgrade ran in a
|
|
78
|
+
* folder below the project root, to that folder.
|
|
77
79
|
*/
|
|
78
80
|
export type RegistryCompositionSummary = {
|
|
79
81
|
applied: boolean;
|
|
@@ -140,7 +142,7 @@ export type UpgradeRegistryResponse = {
|
|
|
140
142
|
*/
|
|
141
143
|
export type ProtectedCodemodFile = {
|
|
142
144
|
/**
|
|
143
|
-
*
|
|
145
|
+
* Path relative to the folder the command ran in.
|
|
144
146
|
*/
|
|
145
147
|
file: string;
|
|
146
148
|
/**
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
* @property {'missing' | 'stale' | 'current'} status
|
|
46
46
|
* @property {string} installedVersion Installed core version the block should reflect.
|
|
47
47
|
* @property {string[]} fromVersions Distinct stale block versions found (the "from" side of the refresh).
|
|
48
|
-
* @property {string[]} files Files rewritten (apply) or that would be rewritten (dry-run).
|
|
48
|
+
* @property {string[]} files Files rewritten (apply) or that would be rewritten (dry-run), relative to the folder the command ran in.
|
|
49
49
|
* @property {boolean} refreshed True only when a block was actually rewritten (apply mode).
|
|
50
50
|
* @property {'refreshed' | 'would-refresh' | 'nudge-init' | 'error' | 'none'} action
|
|
51
51
|
*/
|
|
@@ -70,7 +70,9 @@
|
|
|
70
70
|
*/
|
|
71
71
|
|
|
72
72
|
/**
|
|
73
|
-
* Aggregate receipt for ShadCN-copied composition reconciliation.
|
|
73
|
+
* Aggregate receipt for ShadCN-copied composition reconciliation. File paths
|
|
74
|
+
* are relative to the scanned source directory, or, when the upgrade ran in a
|
|
75
|
+
* folder below the project root, to that folder.
|
|
74
76
|
* @typedef {object} RegistryCompositionSummary
|
|
75
77
|
* @property {boolean} applied
|
|
76
78
|
* @property {boolean} ok False when conflicts, missing files, invalid receipts, or failures remain.
|
|
@@ -99,7 +101,7 @@
|
|
|
99
101
|
/**
|
|
100
102
|
* A required codemod change blocked by effective working-tree protection.
|
|
101
103
|
* @typedef {object} ProtectedCodemodFile
|
|
102
|
-
* @property {string} file
|
|
104
|
+
* @property {string} file Path relative to the folder the command ran in.
|
|
103
105
|
* @property {string[]} codemods Codemods that still require a change.
|
|
104
106
|
* @property {string[]} reasons Protection categories (generated, vendored, ignored, and hard boundaries).
|
|
105
107
|
* @property {string[]} declarations Effective declarations that protect the file.
|
|
@@ -132,11 +134,11 @@
|
|
|
132
134
|
* @property {boolean} [data.complete] False when protected required changes remain.
|
|
133
135
|
* @property {'ERR_CODEMOD_PROTECTED'} [data.errorCode] Stable incomplete-result code when complete is false.
|
|
134
136
|
* @property {number} [data.filesChanged] Distinct files changed across core + integration codemods (apply mode). One file that four codemods each changed counts once.
|
|
135
|
-
* @property {string[]} [data.modifiedFiles]
|
|
137
|
+
* @property {string[]} [data.modifiedFiles] Files changed or previewed, relative to the folder the command ran in.
|
|
136
138
|
* @property {ProtectedCodemodFile[]} [data.protectedFiles] Protected files that still require a codemod change after regeneration.
|
|
137
|
-
* @property {Array<{file: string, location?: string, reason: string}>} [data.declinedCandidates] Candidates left unchanged because proof was insufficient.
|
|
139
|
+
* @property {Array<{file: string, location?: string, reason: string}>} [data.declinedCandidates] Candidates left unchanged because proof was insufficient. Each `file` is relative to the folder the command ran in.
|
|
138
140
|
* @property {number} [data.transformsApplied] Total codemod changes. A code or config codemod counts once for each file it changed, so one file changed by four of them counts four times; a project codemod counts once, however many files it writes.
|
|
139
|
-
* @property {Array<{file: string, codemod: string, error: string}>} [data.errors] Per-codemod errors, when any codemod failed.
|
|
141
|
+
* @property {Array<{file: string, codemod: string, error: string}>} [data.errors] Per-codemod errors, when any codemod failed. Each `file` is relative to the folder the command ran in.
|
|
140
142
|
* @property {CliBehindCore} [data.cliBehindCore] Present only when the installed Core is newer than this CLI: codemods for the releases after `cliBehindCore.cliVersion` did not run.
|
|
141
143
|
*/
|
|
142
144
|
|
|
@@ -28,7 +28,7 @@ export const docs = {
|
|
|
28
28
|
{type: 'code', lang: 'json', label: 'Minimal palette config (palette.config.json)', code: '{"families": [{"id": "ocean", "seed": "#0074e2"}]}'},
|
|
29
29
|
{type: 'code', lang: 'bash', label: 'Generate and preview', code: '# Print the palette without writing files\nastryx theme palette generate palette.config.json\n\n# Write palette + receipt, and open a visual preview\nastryx theme palette generate palette.config.json \\\n --out src/themes/ocean/tokens/ocean.palette.ts \\\n --preview preview.html'},
|
|
30
30
|
{type: 'prose', text: "The command writes a `.ts` file exporting 21 shades (stops 0–100) for both light and dark, plus a `.receipt.json` to regenerate later. Point your theme's tokens at the palette, then run defineTheme (see below)."},
|
|
31
|
-
{type: 'prose', text: 'For the full palette config fields and CLI flags, run `astryx docs cli/commands/theme-palette-generate`. For the integration-authoring walkthrough of connecting a palette to theme tokens, run `astryx docs
|
|
31
|
+
{type: 'prose', text: 'For the full palette config fields and CLI flags, run `astryx docs cli/commands/theme-palette-generate`. For the integration-authoring walkthrough of connecting a palette to theme tokens, run `astryx docs authoring/building-blocks/themes/generate-a-palette`.'},
|
|
32
32
|
],
|
|
33
33
|
},
|
|
34
34
|
{
|
|
@@ -61,7 +61,7 @@ export const docs = {
|
|
|
61
61
|
['adaptations', 'Width-breakpoint overrides merge by fixed name. Inherited ordered rules keep their relative order; child rules append and re-resolve against the child root axes.'],
|
|
62
62
|
]},
|
|
63
63
|
{type: 'prose', text: "Inheritance is resolved when the theme is defined, so an extended theme is flat: `astryx theme build` emits one self-contained stylesheet holding everything the child inherited, and the base theme's CSS does not need to be loaded next to it. A base that is not a theme (most often an import that missed) throws when `defineTheme` runs, rather than producing a theme that silently inherits nothing."},
|
|
64
|
-
{type: 'prose', text: 'For the integration-specific guidance on mapping a palette to tokens when extending, see `astryx docs
|
|
64
|
+
{type: 'prose', text: 'For the integration-specific guidance on mapping a palette to tokens when extending, see `astryx docs authoring/building-blocks/themes/define-the-theme`.'},
|
|
65
65
|
],
|
|
66
66
|
},
|
|
67
67
|
{
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
* @file `astryx docs
|
|
4
|
+
* @file `astryx docs authoring/building-blocks/components/add-a-component`: choose a
|
|
5
5
|
* component name and generate its first source and doc files.
|
|
6
6
|
*/
|
|
7
7
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
* @file `astryx docs
|
|
4
|
+
* @file `astryx docs authoring/building-blocks/themes/add-a-theme`:
|
|
5
5
|
* scaffold a theme in a package — blank, or forked from an existing theme.
|
|
6
6
|
*/
|
|
7
7
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
* @file `astryx docs
|
|
4
|
+
* @file `astryx docs authoring/building-blocks/docs/add-a-topic`: add a
|
|
5
5
|
* doc topic to an integration package, write its sections, and pick the doc
|
|
6
6
|
* kind for each thing the package ships.
|
|
7
7
|
*/
|
|
@@ -79,7 +79,7 @@ export const docs = {
|
|
|
79
79
|
content: [
|
|
80
80
|
{
|
|
81
81
|
type: 'prose',
|
|
82
|
-
text: 'Start every CLI command in a doc with the word astryx alone, with no runner such as npx or pnpm exec in front. The CLI prefixes each one when it prints the doc, with the command the reader runs: `pnpm exec astryx` or `yarn astryx` from their package manager, or the `cliCommand` an integration sets. See {@link generic:cli-command}.',
|
|
82
|
+
text: 'Start every CLI command in a doc with the word astryx alone, with no runner such as npx or pnpm exec in front. The CLI prefixes each one when it prints the doc, with the command the reader runs: `pnpm exec astryx` or `yarn astryx` from their package manager, or the `cliCommand` an integration sets. See {@link generic:cli-command}. `doctor integration validate` (and so `integration check`) lists each command written with a runner as a `runner_command` note, with its file, line and the bare command to write. A note fails nothing. An install step, which runs before the CLI is installed, is the one exception: write the scoped package name, `@astryxdesign/cli`, after the download runner. The unscoped name after a download runner is always listed, because it fetches an unrelated package.',
|
|
83
83
|
},
|
|
84
84
|
{
|
|
85
85
|
type: 'code',
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
* @file `astryx docs
|
|
4
|
+
* @file `astryx docs authoring/building-blocks/configuration/agent-guidance`: add short lines of
|
|
5
5
|
* guidance that apps put in front of their AI agents, within the limits.
|
|
6
6
|
*/
|
|
7
7
|
|