@astryxdesign/cli 0.6.3-canary.f839b67 → 0.6.4-canary.06c8fa3
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 +194 -0
- package/README.md +64 -66
- package/api/component/_adapter.d.mts +25 -0
- package/api/component/_adapter.mjs +59 -5
- package/api/component/component.d.mts +6 -3
- package/api/component/component.doc.mjs +23 -10
- package/api/component/component.mjs +249 -9
- package/api/component/component.type.d.mts +25 -0
- package/api/component/component.type.mjs +44 -0
- package/api/discover/_adapter.d.mts +114 -6
- package/api/discover/_adapter.mjs +372 -17
- package/api/discover/_adapter.test.mjs +215 -0
- package/api/discover/_catalog-view.d.mts +115 -0
- package/api/discover/_catalog-view.mjs +203 -0
- package/api/discover/_catalog-view.test.mjs +128 -0
- package/api/discover/detail/detail.d.mts +18 -6
- package/api/discover/detail/detail.mjs +67 -13
- package/api/discover/detail/detail.test.mjs +85 -0
- package/api/discover/detail/item/item.d.mts +26 -0
- package/api/discover/detail/item/item.mjs +78 -0
- package/api/discover/detail/item/item.test.mjs +73 -0
- package/api/discover/discover.d.mts +3 -9
- package/api/discover/discover.doc.mjs +61 -18
- package/api/discover/discover.mjs +220 -36
- package/api/discover/discover.test.mjs +11 -2
- package/api/discover/discover.type.d.mts +147 -8
- package/api/discover/discover.type.mjs +102 -12
- package/api/discover/list/list.d.mts +20 -6
- package/api/discover/list/list.mjs +45 -12
- package/api/discover/list/list.test.mjs +46 -0
- package/api/discover/search/search.d.mts +18 -16
- package/api/discover/search/search.mjs +102 -56
- package/api/discover/search/search.test.mjs +144 -10
- package/api/docs/_adapter.d.mts +49 -7
- package/api/docs/_adapter.mjs +284 -33
- package/api/docs/docs.doc.mjs +4 -3
- package/api/docs/docs.test.mjs +2 -0
- package/api/docs/docs.type.d.mts +21 -5
- package/api/docs/docs.type.mjs +21 -5
- package/api/docs/integration-tree.test.mjs +9 -1
- package/api/docs/reference-blocks.test.mjs +406 -0
- package/api/doctor/doctor.d.mts +8 -3
- package/api/doctor/doctor.mjs +95 -10
- package/api/doctor/doctor.test.mjs +122 -10
- package/api/index.d.mts +1 -2
- package/api/index.mjs +4 -4
- package/api/integration/add-helpers.d.mts +5 -2
- package/api/integration/add-helpers.mjs +36 -9
- package/api/integration/authoring-checks.mjs +14 -1
- package/api/integration/pack-check.lifecycle-output.test.mjs +105 -0
- package/api/integration/pack-check.mjs +28 -3
- package/api/json/index.ts +0 -1
- package/api/search/search.test.mjs +18 -0
- package/api/template/table-floating-bulk-actions.test.mjs +66 -0
- package/api/template/template-integration.test.mjs +1 -65
- package/api/template/template.mjs +1 -1
- package/api/theme/add/add.mjs +17 -25
- package/api/theme/add/add.rollback.test.mjs +158 -0
- package/api/theme/add/add.staging.test.mjs +40 -23
- package/api/theme/build/build.family.test.mjs +7 -12
- package/api/theme/build/build.mjs +8 -18
- package/api/theme/build/build.rollback.test.mjs +148 -0
- package/api/upgrade/run/files-changed.test.mjs +111 -0
- package/api/upgrade/run/run.mjs +6 -4
- package/api/upgrade/upgrade.type.mjs +2 -2
- package/assets/codemods/__tests__/registry.test.mjs +1 -0
- package/assets/codemods/__tests__/runner.test.mjs +3 -1
- package/assets/codemods/file-count.test.mjs +163 -0
- package/assets/codemods/integration-runner.mjs +3 -3
- package/assets/codemods/registry.mjs +1 -0
- package/assets/codemods/runner.mjs +5 -4
- package/assets/codemods/transforms/next/index.mjs +1 -19
- package/assets/codemods/transforms/v0.6.4/index.mjs +31 -0
- package/assets/docs/internationalization.doc.mjs +7 -5
- package/assets/docs/styling-libraries.doc.mjs +1 -1
- package/assets/docs/theme.doc.mjs +1 -1
- package/assets/docs/tree/component-lookups.doc.mjs +149 -0
- package/assets/docs/tree/integrations.doc.mjs +20 -1
- package/assets/templates/blocks/components/CheckboxList/CheckboxListSelectAllPattern.doc.mjs +1 -1
- package/assets/templates/blocks/components/CheckboxList/CheckboxListSelectAllPattern.tsx +1 -3
- package/assets/templates/blocks/components/InternationalizationProvider/InternationalizationProvider01ShippedLocale.tsx +1 -1
- package/assets/templates/blocks/components/Table/TableBulkActionsTable.doc.mjs +14 -0
- package/assets/templates/blocks/components/Table/TableBulkActionsTable.tsx +71 -0
- package/assets/templates/blocks/components/Table/TableFloatingBulkActionsTable.doc.mjs +19 -0
- package/assets/templates/blocks/components/Table/TableFloatingBulkActionsTable.tsx +139 -0
- package/authoring/config/config.doc.mjs +9 -1
- package/authoring/config/parse.d.mts +2 -0
- package/authoring/config/parse.mjs +19 -0
- package/authoring/config/parse.test.mjs +8 -0
- package/authoring/config/type.ts +13 -2
- package/authoring/discover/discover.doc.d.mts +13 -0
- package/authoring/discover/discover.doc.mjs +138 -0
- package/authoring/discover/parse.d.mts +24 -0
- package/authoring/discover/parse.mjs +128 -0
- package/authoring/discover/parse.test.mjs +124 -0
- package/authoring/discover/type.ts +87 -0
- package/authoring/doctypes/_schema.d.mts +72 -0
- package/authoring/doctypes/_schema.mjs +25 -1
- package/authoring/doctypes/command/command.doc.mjs +1 -1
- package/authoring/doctypes/command/type.ts +1 -1
- package/authoring/doctypes/load-contract.test.mjs +25 -0
- package/authoring/doctypes/reference/reference.doc.mjs +31 -4
- package/authoring/doctypes/reference/type.ts +20 -5
- package/authoring/index.d.mts +1 -0
- package/authoring/index.d.ts +10 -0
- package/authoring/index.mjs +1 -0
- package/clients/cli/command-result-coverage.test.mjs +7 -7
- package/clients/cli/commands/component/index.mjs +152 -55
- package/clients/cli/commands/component-batch.test.mjs +341 -0
- package/clients/cli/commands/component-ownership.test.mjs +89 -0
- package/clients/cli/commands/component.doc.mjs +23 -6
- package/clients/cli/commands/debug-result-summary.test.mjs +2 -2
- package/clients/cli/commands/discover.doc.mjs +53 -9
- package/clients/cli/commands/discover.mjs +393 -118
- package/clients/cli/commands/discover.sources.test.mjs +267 -0
- package/clients/cli/commands/docs.mjs +2 -2
- package/clients/cli/commands/docs.test.mjs +29 -0
- package/clients/cli/commands/doctor-integration-docs.doc.mjs +1 -1
- package/clients/cli/commands/text-json-parity.test.mjs +0 -17
- package/clients/cli/index.mjs +0 -4
- package/clients/cli/lib/exit-codes.test.mjs +1 -8
- package/clients/cli/lib/json-shim.mjs +24 -14
- package/clients/cli/lib/json-shim.test.mjs +6 -20
- package/clients/cli/lib/manifest.mjs +3 -8
- package/clients/cli/lib/manifest.test.mjs +5 -2
- package/clients/cli/lib/parse-error-format.test.mjs +81 -0
- package/foundation/discovery/authoring-self-docs.d.mts +12 -0
- package/foundation/discovery/authoring-self-docs.mjs +21 -8
- package/foundation/discovery/authoring-self-docs.test.mjs +7 -2
- package/foundation/discovery/docs-discovery.d.mts +4 -1
- package/foundation/discovery/docs-discovery.mjs +40 -6
- package/foundation/discovery/docs-discovery.test.mjs +40 -0
- package/foundation/discovery/template-adapter.mjs +1 -1
- package/foundation/doc-compiler/doc-loads.test.mjs +0 -12
- package/foundation/doc-compiler/lenses.d.mts +5 -3
- package/foundation/doc-compiler/lenses.mjs +48 -3
- package/foundation/doc-compiler/links.d.mts +30 -3
- package/foundation/doc-compiler/links.mjs +46 -5
- package/foundation/doc-compiler/links.test.mjs +53 -0
- package/foundation/doc-compiler/tree.test.mjs +9 -1
- package/foundation/integrations/cli-requirement.test.mjs +17 -42
- package/foundation/integrations/integrations.d.mts +14 -1
- package/foundation/integrations/integrations.mjs +41 -1
- package/foundation/integrations/integrations.test.mjs +31 -0
- package/foundation/response/batch.type.d.mts +33 -0
- package/foundation/response/batch.type.mjs +34 -0
- package/foundation/response/response-types.doc.mjs +15 -21
- package/foundation/response/response-types.doc.test.mjs +23 -0
- package/foundation/xle/browser.d.mts +3 -3
- package/foundation/xle/browser.mjs +3 -3
- package/foundation/xle/expand.mjs +2 -2
- package/foundation/xle/parse.mjs +1 -1
- package/foundation/xle/print.mjs +2 -2
- package/foundation/xle/splice.mjs +1 -1
- package/package.json +9 -9
- package/api/layout/_adapter.d.mts +0 -34
- package/api/layout/_adapter.mjs +0 -148
- package/api/layout/check/check.d.mts +0 -16
- package/api/layout/check/check.mjs +0 -40
- package/api/layout/expand/expand.d.mts +0 -22
- package/api/layout/expand/expand.mjs +0 -155
- package/api/layout/expand/expand.path-safety.test.mjs +0 -53
- package/api/layout/grammar/grammar.d.mts +0 -13
- package/api/layout/grammar/grammar.mjs +0 -87
- package/api/layout/layout.d.mts +0 -6
- package/api/layout/layout.mjs +0 -17
- package/api/layout/layout.test.mjs +0 -297
- package/api/layout/layout.type.d.mts +0 -89
- package/api/layout/layout.type.mjs +0 -103
- package/api/layout/layoutCheck.doc.d.mts +0 -11
- package/api/layout/layoutCheck.doc.mjs +0 -85
- package/api/layout/layoutExpand.doc.d.mts +0 -11
- package/api/layout/layoutExpand.doc.mjs +0 -107
- package/api/layout/layoutGrammar.doc.d.mts +0 -11
- package/api/layout/layoutGrammar.doc.mjs +0 -57
- package/clients/cli/commands/layout-check.doc.mjs +0 -65
- package/clients/cli/commands/layout-expand.doc.mjs +0 -83
- package/clients/cli/commands/layout-grammar.doc.mjs +0 -30
- package/clients/cli/commands/layout.doc.mjs +0 -34
- package/clients/cli/commands/layout.error-codes.test.mjs +0 -66
- package/clients/cli/commands/layout.exit-parity.test.mjs +0 -41
- package/clients/cli/commands/layout.mjs +0 -275
- package/clients/cli/commands/layout.path-help.test.mjs +0 -33
- package/clients/cli/commands/layout.stdin-cap.test.mjs +0 -47
- package/clients/cli/commands/layout.text-fields.test.mjs +0 -39
- /package/assets/codemods/transforms/{next → v0.6.4}/__tests__/migrate-native-picker-to-presentation.test.mjs +0 -0
- /package/assets/codemods/transforms/{next → v0.6.4}/__tests__/migrate-theme-catalog-to-descriptors.test.mjs +0 -0
- /package/assets/codemods/transforms/{next → v0.6.4}/migrate-native-picker-to-presentation.mjs +0 -0
- /package/assets/codemods/transforms/{next → v0.6.4}/migrate-theme-catalog-to-descriptors.mjs +0 -0
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @file The upgrade receipt counts a file once when a core codemod AND an
|
|
5
|
+
* integration codemod both change it: `filesChanged` is the union of the two
|
|
6
|
+
* runners' files, while `transformsApplied` adds their changes.
|
|
7
|
+
*
|
|
8
|
+
* Uses a real consumer under a repo-local temp dir (Vite blocks dynamic import
|
|
9
|
+
* of config and integration modules from /tmp), the real core registry, and an
|
|
10
|
+
* installed integration whose code codemod stamps the same file.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
import {describe, it, expect, afterEach} from 'vitest';
|
|
14
|
+
import * as fs from 'node:fs';
|
|
15
|
+
import * as path from 'node:path';
|
|
16
|
+
import {upgrade} from '../upgrade.mjs';
|
|
17
|
+
import {
|
|
18
|
+
latestVersion,
|
|
19
|
+
versions,
|
|
20
|
+
getTransformsBetween,
|
|
21
|
+
} from '../../../assets/codemods/registry.mjs';
|
|
22
|
+
|
|
23
|
+
const SLOW = 60_000;
|
|
24
|
+
|
|
25
|
+
/** The registry version whose manifest ships the authoring migration. */
|
|
26
|
+
async function authoringTier() {
|
|
27
|
+
const all = await getTransformsBetween('0.0.0', latestVersion);
|
|
28
|
+
const tier = all.find(({transforms}) =>
|
|
29
|
+
transforms.some(t => t.name === 'migrate-authoring-imports'),
|
|
30
|
+
);
|
|
31
|
+
if (!tier) throw new Error('no registry version ships the authoring migration');
|
|
32
|
+
return tier.version;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* A consumer with installed core at the registry's latest version and one
|
|
37
|
+
* old-surface file that the core authoring codemods rewrite.
|
|
38
|
+
* @param {string} dir
|
|
39
|
+
* @param {{integrationCodemod: boolean}} options
|
|
40
|
+
*/
|
|
41
|
+
function seed(dir, {integrationCodemod}) {
|
|
42
|
+
fs.writeFileSync(
|
|
43
|
+
path.join(dir, 'package.json'),
|
|
44
|
+
JSON.stringify({name: 'consumer', version: '1.0.0'}),
|
|
45
|
+
);
|
|
46
|
+
const core = path.join(dir, 'node_modules', '@astryxdesign', 'core');
|
|
47
|
+
fs.mkdirSync(core, {recursive: true});
|
|
48
|
+
fs.writeFileSync(
|
|
49
|
+
path.join(core, 'package.json'),
|
|
50
|
+
JSON.stringify({name: '@astryxdesign/core', version: latestVersion}),
|
|
51
|
+
);
|
|
52
|
+
fs.mkdirSync(path.join(dir, 'src'), {recursive: true});
|
|
53
|
+
fs.writeFileSync(
|
|
54
|
+
path.join(dir, 'src', 'Button.doc.mjs'),
|
|
55
|
+
[
|
|
56
|
+
"import {createComponentDoc} from '@astryxdesign/core/authoring';",
|
|
57
|
+
"export default createComponentDoc({name: 'Button', props: []});",
|
|
58
|
+
'',
|
|
59
|
+
].join('\n'),
|
|
60
|
+
);
|
|
61
|
+
if (!integrationCodemod) return;
|
|
62
|
+
fs.writeFileSync(
|
|
63
|
+
path.join(dir, 'astryx.config.mjs'),
|
|
64
|
+
"export default {integrations: ['@acme/widgets']};\n",
|
|
65
|
+
);
|
|
66
|
+
const pkg = path.join(dir, 'node_modules', '@acme', 'widgets');
|
|
67
|
+
fs.mkdirSync(path.join(pkg, 'codemods', latestVersion), {recursive: true});
|
|
68
|
+
fs.writeFileSync(
|
|
69
|
+
path.join(pkg, 'package.json'),
|
|
70
|
+
JSON.stringify({name: '@acme/widgets', version: '1.0.0'}),
|
|
71
|
+
);
|
|
72
|
+
fs.writeFileSync(
|
|
73
|
+
path.join(pkg, 'astryx.integration.mjs'),
|
|
74
|
+
"export default {codemods: './codemods'};\n",
|
|
75
|
+
);
|
|
76
|
+
fs.writeFileSync(
|
|
77
|
+
path.join(pkg, 'codemods', latestVersion, 'acme-stamp.mjs'),
|
|
78
|
+
"export default {type: 'code', title: 'Stamp', transform: file => (file.source.includes('// acme') ? null : `${file.source}// acme\\n`)};\n",
|
|
79
|
+
);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
describe('upgrade receipt — filesChanged across core and integration codemods', () => {
|
|
83
|
+
/** @type {string[]} */
|
|
84
|
+
const dirs = [];
|
|
85
|
+
afterEach(() => {
|
|
86
|
+
for (const dir of dirs.splice(0)) fs.rmSync(dir, {recursive: true, force: true});
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
/** @param {{integrationCodemod: boolean}} options */
|
|
90
|
+
async function run(options) {
|
|
91
|
+
const dir = fs.mkdtempSync(path.join(process.cwd(), '.astryx-files-changed-'));
|
|
92
|
+
dirs.push(dir);
|
|
93
|
+
seed(dir, options);
|
|
94
|
+
const tier = await authoringTier();
|
|
95
|
+
const from = versions[versions.indexOf(tier) - 1];
|
|
96
|
+
const res = await upgrade({from, path: 'src'}, {cwd: dir});
|
|
97
|
+
expect(res.type).toBe('upgrade.run');
|
|
98
|
+
return res.data;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
it('counts a file changed by both a core and an integration codemod once', async () => {
|
|
102
|
+
const coreOnly = await run({integrationCodemod: false});
|
|
103
|
+
expect(coreOnly.filesChanged).toBe(1);
|
|
104
|
+
expect(coreOnly.transformsApplied).toBeGreaterThan(0);
|
|
105
|
+
|
|
106
|
+
const both = await run({integrationCodemod: true});
|
|
107
|
+
expect(both.integrations).toEqual(['@acme/widgets']);
|
|
108
|
+
expect(both.filesChanged).toBe(1);
|
|
109
|
+
expect(both.transformsApplied).toBe(coreOnly.transformsApplied + 1);
|
|
110
|
+
}, SLOW);
|
|
111
|
+
});
|
package/api/upgrade/run/run.mjs
CHANGED
|
@@ -114,7 +114,7 @@ export async function run(options = {}, {cwd = process.cwd()} = {}) {
|
|
|
114
114
|
// Resolve the source dir against the API's cwd (not process.cwd()) so a
|
|
115
115
|
// programmatic caller in another directory scans the right tree. Confine it to
|
|
116
116
|
// cwd: --apply rewrites files in place, so a `..`-escaping or out-of-tree
|
|
117
|
-
// absolute --path must be rejected (parity with template/theme/swizzle
|
|
117
|
+
// absolute --path must be rejected (parity with template/theme/swizzle,
|
|
118
118
|
// and this is the most destructive command). allowAbsolute permits an absolute
|
|
119
119
|
// path that still resolves inside cwd.
|
|
120
120
|
let path_;
|
|
@@ -437,9 +437,11 @@ export async function run(options = {}, {cwd = process.cwd()} = {}) {
|
|
|
437
437
|
|
|
438
438
|
const registryResult = await reconcileCompositions();
|
|
439
439
|
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
(
|
|
440
|
+
// A file a core codemod AND an integration codemod both changed is one file.
|
|
441
|
+
const mergedFilesChanged = new Set([
|
|
442
|
+
...(coreResult?.changedFiles ?? []),
|
|
443
|
+
...(integrationResult?.changedFiles ?? []),
|
|
444
|
+
]).size;
|
|
443
445
|
const mergedTransformsApplied =
|
|
444
446
|
(coreResult?.totalTransformsApplied ?? 0) +
|
|
445
447
|
(integrationResult?.totalTransformsApplied ?? 0);
|
|
@@ -119,11 +119,11 @@
|
|
|
119
119
|
* @property {RegistryCompositionSummary} [data.registryCompositions]
|
|
120
120
|
* @property {boolean} [data.complete] False when protected required changes remain.
|
|
121
121
|
* @property {'ERR_CODEMOD_PROTECTED'} [data.errorCode] Stable incomplete-result code when complete is false.
|
|
122
|
-
* @property {number} [data.filesChanged]
|
|
122
|
+
* @property {number} [data.filesChanged] Distinct files changed across core + integration codemods (apply mode). One file that four codemods each changed counts once.
|
|
123
123
|
* @property {string[]} [data.modifiedFiles] Project-relative files changed or previewed.
|
|
124
124
|
* @property {ProtectedCodemodFile[]} [data.protectedFiles] Protected files that still require a codemod change after regeneration.
|
|
125
125
|
* @property {Array<{file: string, location?: string, reason: string}>} [data.declinedCandidates] Candidates left unchanged because proof was insufficient.
|
|
126
|
-
* @property {number} [data.transformsApplied] Total
|
|
126
|
+
* @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.
|
|
127
127
|
* @property {Array<{file: string, codemod: string, error: string}>} [data.errors] Per-codemod errors, when any codemod failed.
|
|
128
128
|
*/
|
|
129
129
|
|
|
@@ -46,7 +46,9 @@ describe('runCodemods — ordered dry-run state', () => {
|
|
|
46
46
|
silent: true,
|
|
47
47
|
});
|
|
48
48
|
|
|
49
|
-
|
|
49
|
+
// One file that two transforms changed is one file and two changes.
|
|
50
|
+
expect(preview.totalFilesChanged).toBe(1);
|
|
51
|
+
expect(preview.totalTransformsApplied).toBe(2);
|
|
50
52
|
expect(preview.changedFiles).toEqual([
|
|
51
53
|
path.join(srcDir, 'a.ts'),
|
|
52
54
|
path.join(srcDir, 'a.ts'),
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @file `filesChanged` counts FILES, not (codemod, file) pairs.
|
|
5
|
+
*
|
|
6
|
+
* One source file that four codemods each changed was reported as four files
|
|
7
|
+
* changed — the total was incremented once per transform per file, so it
|
|
8
|
+
* equalled `transformsApplied` in every run and the documented meaning of the
|
|
9
|
+
* field ("Total files changed") was never true. The two numbers answer
|
|
10
|
+
* different questions and both are in the receipt.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
import {describe, it, expect, beforeEach, afterEach} from 'vitest';
|
|
14
|
+
import * as fs from 'node:fs';
|
|
15
|
+
import * as os from 'node:os';
|
|
16
|
+
import * as path from 'node:path';
|
|
17
|
+
import jscodeshift from 'jscodeshift';
|
|
18
|
+
import {runCodemods} from './runner.mjs';
|
|
19
|
+
import {runIntegrationCodemods} from './integration-runner.mjs';
|
|
20
|
+
|
|
21
|
+
let dir;
|
|
22
|
+
|
|
23
|
+
beforeEach(() => {
|
|
24
|
+
dir = fs.mkdtempSync(path.join(os.tmpdir(), 'astryx-file-count-'));
|
|
25
|
+
});
|
|
26
|
+
afterEach(() => fs.rmSync(dir, {recursive: true, force: true}));
|
|
27
|
+
|
|
28
|
+
/** A transform that rewrites one distinctive token, so several can stack. */
|
|
29
|
+
const renaming = (from, to) => (file) =>
|
|
30
|
+
file.source.includes(from) ? file.source.split(from).join(to) : null;
|
|
31
|
+
|
|
32
|
+
/** @param {string} name @param {string[]} contents */
|
|
33
|
+
function writeSources(...contents) {
|
|
34
|
+
return contents.map((content, i) => {
|
|
35
|
+
const file = path.join(dir, `file${i}.ts`);
|
|
36
|
+
fs.writeFileSync(file, content);
|
|
37
|
+
return file;
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
describe('core codemod runner — filesChanged counts files', () => {
|
|
42
|
+
it('reports 1 file for one file changed by four codemods', async () => {
|
|
43
|
+
writeSources('const a = ONE + TWO + THREE + FOUR;\n');
|
|
44
|
+
|
|
45
|
+
const result = await runCodemods(
|
|
46
|
+
[
|
|
47
|
+
{
|
|
48
|
+
version: '0.0.2',
|
|
49
|
+
transforms: [
|
|
50
|
+
{name: 'one', transform: renaming('ONE', '1'), meta: {title: 'one'}},
|
|
51
|
+
{name: 'two', transform: renaming('TWO', '2'), meta: {title: 'two'}},
|
|
52
|
+
{name: 'three', transform: renaming('THREE', '3'), meta: {title: 'three'}},
|
|
53
|
+
{name: 'four', transform: renaming('FOUR', '4'), meta: {title: 'four'}},
|
|
54
|
+
],
|
|
55
|
+
},
|
|
56
|
+
],
|
|
57
|
+
{apply: true, path: dir, root: dir, codemod: undefined, skipCodemods: new Set(), silent: true},
|
|
58
|
+
);
|
|
59
|
+
|
|
60
|
+
expect(result.totalTransformsApplied).toBe(4);
|
|
61
|
+
expect(result.totalFilesChanged).toBe(1);
|
|
62
|
+
expect(new Set(result.changedFiles).size).toBe(1);
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
it('still counts two files as two', async () => {
|
|
66
|
+
writeSources('const a = ONE;\n', 'const b = ONE;\n');
|
|
67
|
+
|
|
68
|
+
const result = await runCodemods(
|
|
69
|
+
[
|
|
70
|
+
{
|
|
71
|
+
version: '0.0.2',
|
|
72
|
+
transforms: [
|
|
73
|
+
{name: 'one', transform: renaming('ONE', '1'), meta: {title: 'one'}},
|
|
74
|
+
],
|
|
75
|
+
},
|
|
76
|
+
],
|
|
77
|
+
{apply: true, path: dir, root: dir, codemod: undefined, skipCodemods: new Set(), silent: true},
|
|
78
|
+
);
|
|
79
|
+
|
|
80
|
+
expect(result.totalTransformsApplied).toBe(2);
|
|
81
|
+
expect(result.totalFilesChanged).toBe(2);
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
it('reports 0 when nothing matched', async () => {
|
|
85
|
+
writeSources('const a = 1;\n');
|
|
86
|
+
|
|
87
|
+
const result = await runCodemods(
|
|
88
|
+
[
|
|
89
|
+
{
|
|
90
|
+
version: '0.0.2',
|
|
91
|
+
transforms: [
|
|
92
|
+
{name: 'one', transform: renaming('ONE', '1'), meta: {title: 'one'}},
|
|
93
|
+
],
|
|
94
|
+
},
|
|
95
|
+
],
|
|
96
|
+
{apply: true, path: dir, root: dir, codemod: undefined, skipCodemods: new Set(), silent: true},
|
|
97
|
+
);
|
|
98
|
+
|
|
99
|
+
expect(result.totalFilesChanged).toBe(0);
|
|
100
|
+
expect(result.totalTransformsApplied).toBe(0);
|
|
101
|
+
});
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
describe('integration codemod runner — filesChanged counts files', () => {
|
|
105
|
+
it('reports 1 file for one file changed by three integration codemods', () => {
|
|
106
|
+
writeSources('const a = ONE + TWO + THREE;\n');
|
|
107
|
+
|
|
108
|
+
const entry = (id, from, to) => ({
|
|
109
|
+
id,
|
|
110
|
+
package: '@acme/widgets',
|
|
111
|
+
type: 'code',
|
|
112
|
+
codemod: {title: id, transform: renaming(from, to)},
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
const result = runIntegrationCodemods(
|
|
116
|
+
[
|
|
117
|
+
{
|
|
118
|
+
version: '1.0.0',
|
|
119
|
+
codemods: [
|
|
120
|
+
entry('one', 'ONE', '1'),
|
|
121
|
+
entry('two', 'TWO', '2'),
|
|
122
|
+
entry('three', 'THREE', '3'),
|
|
123
|
+
],
|
|
124
|
+
},
|
|
125
|
+
],
|
|
126
|
+
{apply: true, path: dir, root: dir, skipCodemods: new Set(), jscodeshift, silent: true},
|
|
127
|
+
);
|
|
128
|
+
|
|
129
|
+
expect(result.totalTransformsApplied).toBe(3);
|
|
130
|
+
expect(result.totalFilesChanged).toBe(1);
|
|
131
|
+
expect(new Set(result.changedFiles).size).toBe(1);
|
|
132
|
+
});
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
describe('core codemod runner — a project codemod', () => {
|
|
136
|
+
it('counts every file it writes, and one change', async () => {
|
|
137
|
+
const result = await runCodemods(
|
|
138
|
+
[
|
|
139
|
+
{
|
|
140
|
+
version: '0.0.2',
|
|
141
|
+
transforms: [
|
|
142
|
+
{
|
|
143
|
+
name: 'project-plan',
|
|
144
|
+
meta: {title: 'project plan', codemodType: 'project'},
|
|
145
|
+
transform: async root => ({
|
|
146
|
+
writes: [
|
|
147
|
+
{path: path.join(root, 'a.ts'), contents: 'a\n'},
|
|
148
|
+
{path: path.join(root, 'b.ts'), contents: 'b\n'},
|
|
149
|
+
],
|
|
150
|
+
deletes: [],
|
|
151
|
+
problems: [],
|
|
152
|
+
}),
|
|
153
|
+
},
|
|
154
|
+
],
|
|
155
|
+
},
|
|
156
|
+
],
|
|
157
|
+
{apply: true, path: dir, root: dir, codemod: undefined, skipCodemods: new Set(), silent: true},
|
|
158
|
+
);
|
|
159
|
+
|
|
160
|
+
expect(result.totalFilesChanged).toBe(2);
|
|
161
|
+
expect(result.totalTransformsApplied).toBe(1);
|
|
162
|
+
});
|
|
163
|
+
});
|
|
@@ -67,7 +67,6 @@ export function runIntegrationCodemods(
|
|
|
67
67
|
/** In-memory pipeline state keeps ordered dry-runs equivalent to apply. */
|
|
68
68
|
const virtualContents = new Map(providedContents ?? []);
|
|
69
69
|
|
|
70
|
-
let totalFilesChanged = 0;
|
|
71
70
|
let totalTransformsApplied = 0;
|
|
72
71
|
/** @type {string[]} */
|
|
73
72
|
const changedFiles = [];
|
|
@@ -115,7 +114,6 @@ export function runIntegrationCodemods(
|
|
|
115
114
|
protection,
|
|
116
115
|
contents: virtualContents,
|
|
117
116
|
});
|
|
118
|
-
totalFilesChanged += r.filesChanged;
|
|
119
117
|
totalTransformsApplied += r.filesChanged;
|
|
120
118
|
changedFiles.push(...r.changedFiles);
|
|
121
119
|
writtenFiles.push(...r.writtenFiles);
|
|
@@ -145,7 +143,6 @@ export function runIntegrationCodemods(
|
|
|
145
143
|
protection,
|
|
146
144
|
contents: virtualContents,
|
|
147
145
|
});
|
|
148
|
-
totalFilesChanged += r.filesChanged;
|
|
149
146
|
totalTransformsApplied += r.filesChanged;
|
|
150
147
|
changedFiles.push(...r.changedFiles);
|
|
151
148
|
writtenFiles.push(...r.writtenFiles);
|
|
@@ -154,6 +151,9 @@ export function runIntegrationCodemods(
|
|
|
154
151
|
}
|
|
155
152
|
}
|
|
156
153
|
|
|
154
|
+
// A file several codemods changed is one file; transforms count each change.
|
|
155
|
+
const totalFilesChanged = new Set(changedFiles).size;
|
|
156
|
+
|
|
157
157
|
return {
|
|
158
158
|
totalFilesChanged,
|
|
159
159
|
totalTransformsApplied,
|
|
@@ -29,6 +29,7 @@ const registry = new Map([
|
|
|
29
29
|
['0.4.0', () => import('./transforms/v0.4.0/index.mjs')],
|
|
30
30
|
['0.5.0', () => import('./transforms/v0.5.0/index.mjs')],
|
|
31
31
|
['0.6.0', () => import('./transforms/v0.6.0/index.mjs')],
|
|
32
|
+
['0.6.4', () => import('./transforms/v0.6.4/index.mjs')],
|
|
32
33
|
]);
|
|
33
34
|
|
|
34
35
|
// Re-export from the shared utility so registry callers and other consumers
|
|
@@ -486,7 +486,6 @@ export async function runCodemods(
|
|
|
486
486
|
(await import('jscodeshift')).default
|
|
487
487
|
);
|
|
488
488
|
|
|
489
|
-
let totalFilesChanged = 0;
|
|
490
489
|
let totalTransformsApplied = 0;
|
|
491
490
|
let totalValidationBlocked = 0;
|
|
492
491
|
/** @type {Array<{file: string, codemod: string, error: string}>} */
|
|
@@ -554,7 +553,6 @@ export async function runCodemods(
|
|
|
554
553
|
protectionWriteCount = writtenFiles.length;
|
|
555
554
|
}
|
|
556
555
|
if (result.filesChanged > 0) {
|
|
557
|
-
totalFilesChanged += result.filesChanged;
|
|
558
556
|
totalTransformsApplied += 1;
|
|
559
557
|
}
|
|
560
558
|
continue;
|
|
@@ -577,7 +575,6 @@ export async function runCodemods(
|
|
|
577
575
|
changedFiles.push(...result.changedFiles);
|
|
578
576
|
writtenFiles.push(...result.writtenFiles);
|
|
579
577
|
if (result.filesChanged > 0) {
|
|
580
|
-
totalFilesChanged += result.filesChanged;
|
|
581
578
|
totalTransformsApplied += result.filesChanged;
|
|
582
579
|
}
|
|
583
580
|
continue;
|
|
@@ -592,7 +589,6 @@ export async function runCodemods(
|
|
|
592
589
|
protectedFiles.push(...result.protectedFiles);
|
|
593
590
|
changedFiles.push(...result.changedFiles);
|
|
594
591
|
writtenFiles.push(...result.writtenFiles);
|
|
595
|
-
totalFilesChanged += result.filesChanged;
|
|
596
592
|
totalTransformsApplied += result.filesChanged;
|
|
597
593
|
totalValidationBlocked += result.errors.filter(
|
|
598
594
|
error =>
|
|
@@ -630,6 +626,11 @@ export async function runCodemods(
|
|
|
630
626
|
);
|
|
631
627
|
}
|
|
632
628
|
|
|
629
|
+
// A file several codemods changed is one file. `totalTransformsApplied` is
|
|
630
|
+
// unchanged: a code or config codemod counts each file it changed, and a
|
|
631
|
+
// project codemod counts once. The two answer different questions.
|
|
632
|
+
const totalFilesChanged = new Set(changedFiles).size;
|
|
633
|
+
|
|
633
634
|
if (protectedFiles.length > 0) {
|
|
634
635
|
const files = [...new Set(protectedFiles.map(item => item.file))];
|
|
635
636
|
log.warn(
|
|
@@ -7,22 +7,4 @@
|
|
|
7
7
|
* this file into the resolved version folder.
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
meta as migrateThemeCatalogToDescriptorsMeta,
|
|
12
|
-
} from './migrate-theme-catalog-to-descriptors.mjs';
|
|
13
|
-
import migrateNativePickerToPresentation, {
|
|
14
|
-
meta as migrateNativePickerToPresentationMeta,
|
|
15
|
-
} from './migrate-native-picker-to-presentation.mjs';
|
|
16
|
-
|
|
17
|
-
export default [
|
|
18
|
-
{
|
|
19
|
-
name: 'migrate-theme-catalog-to-descriptors',
|
|
20
|
-
transform: migrateThemeCatalogToDescriptors,
|
|
21
|
-
meta: migrateThemeCatalogToDescriptorsMeta,
|
|
22
|
-
},
|
|
23
|
-
{
|
|
24
|
-
name: 'migrate-native-picker-to-presentation',
|
|
25
|
-
transform: migrateNativePickerToPresentation,
|
|
26
|
-
meta: migrateNativePickerToPresentationMeta,
|
|
27
|
-
},
|
|
28
|
-
];
|
|
10
|
+
export default [];
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @file next transform manifest
|
|
5
|
+
*
|
|
6
|
+
* Staged codemods for the next release. The Version Packages PR promotes
|
|
7
|
+
* this file into the resolved version folder.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import migrateThemeCatalogToDescriptors, {
|
|
11
|
+
meta as migrateThemeCatalogToDescriptorsMeta,
|
|
12
|
+
} from './migrate-theme-catalog-to-descriptors.mjs';
|
|
13
|
+
import migrateNativePickerToPresentation, {
|
|
14
|
+
meta as migrateNativePickerToPresentationMeta,
|
|
15
|
+
} from './migrate-native-picker-to-presentation.mjs';
|
|
16
|
+
|
|
17
|
+
export default [
|
|
18
|
+
{
|
|
19
|
+
name: 'migrate-theme-catalog-to-descriptors',
|
|
20
|
+
transform:
|
|
21
|
+
/** @type {import('../../../../authoring/codemod/type').CodemodTransform} */ (
|
|
22
|
+
/** @type {unknown} */ (migrateThemeCatalogToDescriptors)
|
|
23
|
+
),
|
|
24
|
+
meta: migrateThemeCatalogToDescriptorsMeta,
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
name: 'migrate-native-picker-to-presentation',
|
|
28
|
+
transform: migrateNativePickerToPresentation,
|
|
29
|
+
meta: migrateNativePickerToPresentationMeta,
|
|
30
|
+
},
|
|
31
|
+
];
|
|
@@ -41,15 +41,17 @@ function App() {
|
|
|
41
41
|
lang: 'tsx',
|
|
42
42
|
label: 'Load an astryx locale catalog',
|
|
43
43
|
code: `import {InternationalizationProvider} from '@astryxdesign/core/i18n';
|
|
44
|
-
import
|
|
44
|
+
import frFR from '@astryxdesign/core/locales/fr-FR.generated.js';
|
|
45
45
|
|
|
46
|
-
<InternationalizationProvider
|
|
46
|
+
<InternationalizationProvider
|
|
47
|
+
locale="fr-FR"
|
|
48
|
+
messages={{'fr-FR': frFR}}>
|
|
47
49
|
<App />
|
|
48
50
|
</InternationalizationProvider>;`,
|
|
49
51
|
},
|
|
50
52
|
{
|
|
51
53
|
type: 'prose',
|
|
52
|
-
text: 'Astryx ships English
|
|
54
|
+
text: 'Astryx ships English and first-party translations for supported locales. Compact runtime modules from `@astryxdesign/core/locales/*.generated.js` contain only the messages apps need; the existing `@astryxdesign/core/locales/*.json` files retain translator context. Until a locale is available, apps can pass a local catalog in either shape. Missing keys fall back through the locale chain to English (for example, `pt-BR` walks to `pt`, then to shipped `en`).',
|
|
53
55
|
},
|
|
54
56
|
{
|
|
55
57
|
type: 'prose',
|
|
@@ -290,7 +292,7 @@ export default function App() {
|
|
|
290
292
|
},
|
|
291
293
|
{
|
|
292
294
|
type: 'prose',
|
|
293
|
-
text: '`Catalog` types
|
|
295
|
+
text: '`Catalog` types the rich `{defaultMessage, description?}` authoring shape. `RuntimeCatalog` types the generated key-to-message string map. `ProviderMessagesByLocale` accepts either shape for the provider, while `MessagesByLocale` keeps the original rich-only context shape.',
|
|
294
296
|
},
|
|
295
297
|
],
|
|
296
298
|
},
|
|
@@ -307,7 +309,7 @@ export default function App() {
|
|
|
307
309
|
lang: 'tsx',
|
|
308
310
|
label: 'Turn on pseudo-localization',
|
|
309
311
|
code: `import {InternationalizationProvider} from '@astryxdesign/core/i18n';
|
|
310
|
-
import pseudo from '@astryxdesign/core/locales/pseudo.
|
|
312
|
+
import pseudo from '@astryxdesign/core/locales/pseudo.generated.js';
|
|
311
313
|
|
|
312
314
|
<InternationalizationProvider locale="pseudo" messages={{pseudo}}>
|
|
313
315
|
<App />
|
|
@@ -150,7 +150,7 @@ const styles = stylex.create({
|
|
|
150
150
|
content: [
|
|
151
151
|
{
|
|
152
152
|
type: 'prose',
|
|
153
|
-
text: 'The Tailwind v4 bridge at `@astryxdesign/core/tailwind-theme.css` maps Tailwind theme variables to system CSS variables with `@theme inline`, so utility classes like `text-primary`, `bg-surface`, `border-border`, `rounded-lg`, and `shadow-md` stay in sync with the active theme.',
|
|
153
|
+
text: 'The Tailwind v4 bridge at `@astryxdesign/core/tailwind-theme.css` maps Tailwind theme variables to system CSS variables with `@theme reference inline`, so utility classes like `text-primary`, `bg-surface`, `border-border`, `rounded-lg`, and `shadow-md` stay in sync with the active theme without emitting competing runtime declarations.',
|
|
154
154
|
},
|
|
155
155
|
{
|
|
156
156
|
type: 'code',
|
|
@@ -76,7 +76,7 @@ function App() {
|
|
|
76
76
|
[
|
|
77
77
|
'Neutral',
|
|
78
78
|
"import {neutralTheme} from '@astryxdesign/theme-neutral'",
|
|
79
|
-
'Muted, minimal aesthetic with
|
|
79
|
+
'Muted, minimal aesthetic with Figtree typography. A good starting point.',
|
|
80
80
|
],
|
|
81
81
|
[
|
|
82
82
|
'Butter',
|