@astryxdesign/cli 0.1.2-canary.03536f1 → 0.1.2-canary.043f3fd

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@astryxdesign/cli",
3
- "version": "0.1.2-canary.03536f1",
3
+ "version": "0.1.2-canary.043f3fd",
4
4
  "displayName": "CLI",
5
5
  "description": "Scaffold projects, browse templates, generate themes, and get agent-ready docs from the command line.",
6
6
  "author": "Meta Open Source",
@@ -75,9 +75,9 @@
75
75
  "zod": "^4.4.3"
76
76
  },
77
77
  "peerDependencies": {
78
- "@astryxdesign/core": "0.1.2-canary.03536f1",
79
- "@astryxdesign/lab": "0.1.2-canary.03536f1",
80
- "@astryxdesign/theme-neutral": "0.1.2-canary.03536f1",
78
+ "@astryxdesign/core": "0.1.2-canary.043f3fd",
79
+ "@astryxdesign/lab": "0.1.2-canary.043f3fd",
80
+ "@astryxdesign/theme-neutral": "0.1.2-canary.043f3fd",
81
81
  "gpt-tokenizer": "^2.0.0"
82
82
  },
83
83
  "peerDependenciesMeta": {
@@ -92,9 +92,9 @@
92
92
  }
93
93
  },
94
94
  "devDependencies": {
95
- "@astryxdesign/core": "0.1.2-canary.03536f1",
96
- "@astryxdesign/lab": "0.1.2-canary.03536f1",
97
- "@astryxdesign/theme-neutral": "0.1.2-canary.03536f1",
95
+ "@astryxdesign/core": "0.1.2-canary.043f3fd",
96
+ "@astryxdesign/lab": "0.1.2-canary.043f3fd",
97
+ "@astryxdesign/theme-neutral": "0.1.2-canary.043f3fd",
98
98
  "gpt-tokenizer": "^2.0.0"
99
99
  },
100
100
  "scripts": {
@@ -34,10 +34,6 @@ import migrateSelectorChildrenToRenderOption, {
34
34
  meta as migrateSelectorChildrenToRenderOptionMeta,
35
35
  } from './migrate-selector-children-to-render-option.mjs';
36
36
 
37
- import dropXdsPrefixImports, {
38
- meta as dropXdsPrefixImportsMeta,
39
- } from './drop-xds-prefix-imports.mjs';
40
-
41
37
  export default [
42
38
  {
43
39
  name: 'rename-date-picker-to-input',
@@ -75,13 +71,4 @@ export default [
75
71
  transform: migrateSelectorChildrenToRenderOption,
76
72
  meta: migrateSelectorChildrenToRenderOptionMeta,
77
73
  },
78
- {
79
- // XDS-prefix migration (P2380608025). Optional + not tied to a version
80
- // bump: consumers run it explicitly during their migration, e.g.
81
- // astryx upgrade --codemod drop-xds-prefix-imports --codemod-only --apply
82
- name: 'drop-xds-prefix-imports',
83
- transform: dropXdsPrefixImports,
84
- meta: dropXdsPrefixImportsMeta,
85
- optional: true,
86
- },
87
74
  ];
@@ -0,0 +1,81 @@
1
+ // Copyright (c) Meta Platforms, Inc. and affiliates.
2
+
3
+ import {describe, it, expect} from 'vitest';
4
+
5
+ /**
6
+ * End-to-end test proving the v0.1.0 manifest ordering: the prefix-drop
7
+ * codemod runs BEFORE migrate-xds-module-specifiers, so a prefixed identifier
8
+ * imported from `@xds/core` is un-prefixed AND the module path is rewritten to
9
+ * `@astryxdesign/core` in a single upgrade pass.
10
+ */
11
+ async function applyManifestInOrder(source, filePath = 'test.tsx') {
12
+ const {default: manifest} = await import('../index.mjs');
13
+ const jscodeshift = (await import('jscodeshift')).default;
14
+ const j = jscodeshift.withParser('tsx');
15
+ const api = {jscodeshift: j, stats: () => {}, report: () => {}};
16
+
17
+ let current = source;
18
+ for (const {transform} of manifest) {
19
+ const file = {source: current, path: filePath};
20
+ const result = transform(file, api);
21
+ current = result ?? current;
22
+ }
23
+ return current;
24
+ }
25
+
26
+ describe('v0.1.0 codemod manifest ordering', () => {
27
+ it('runs drop-xds-prefix-imports before migrate-xds-module-specifiers', async () => {
28
+ const {default: manifest} = await import('../index.mjs');
29
+ const names = manifest.map(entry => entry.name);
30
+ const prefixDropIdx = names.indexOf('drop-xds-prefix-imports');
31
+ const specifierIdx = names.indexOf('migrate-xds-module-specifiers');
32
+ expect(prefixDropIdx).toBeGreaterThanOrEqual(0);
33
+ expect(specifierIdx).toBeGreaterThanOrEqual(0);
34
+ expect(prefixDropIdx).toBeLessThan(specifierIdx);
35
+ });
36
+
37
+ it('drop-xds-prefix-imports is mandatory (not optional) in v0.1.0', async () => {
38
+ const {default: manifest} = await import('../index.mjs');
39
+ const entry = manifest.find(e => e.name === 'drop-xds-prefix-imports');
40
+ expect(entry).toBeDefined();
41
+ expect(entry.optional).toBeFalsy();
42
+ });
43
+
44
+ it('un-prefixes useXDSTheme from @xds/core/theme AND renames the scope to @astryxdesign', async () => {
45
+ const input = [
46
+ "import {useXDSTheme} from '@xds/core/theme';",
47
+ '',
48
+ 'function App() {',
49
+ ' const theme = useXDSTheme();',
50
+ ' return theme;',
51
+ '}',
52
+ ].join('\n');
53
+
54
+ const output = await applyManifestInOrder(input);
55
+
56
+ expect(output).toMatch(/import\s*\{useTheme\}\s*from\s*['"]@astryxdesign\/core\/theme['"]/);
57
+ expect(output).toContain('const theme = useTheme();');
58
+ // The prefixed name and old scope must be fully gone.
59
+ expect(output).not.toContain('useXDSTheme');
60
+ expect(output).not.toContain('@xds/core');
61
+ });
62
+
63
+ it('un-prefixes XDSButton and XDSIconRegistry alongside the scope rename', async () => {
64
+ const input = [
65
+ "import {XDSButton, XDSIconRegistry} from '@xds/core';",
66
+ '',
67
+ 'const registry = new XDSIconRegistry();',
68
+ 'const el = <XDSButton />;',
69
+ ].join('\n');
70
+
71
+ const output = await applyManifestInOrder(input);
72
+
73
+ expect(output).toMatch(/from\s*['"]@astryxdesign\/core['"]/);
74
+ expect(output).toContain('Button');
75
+ expect(output).toContain('IconRegistry');
76
+ expect(output).toContain('new IconRegistry()');
77
+ expect(output).not.toContain('XDSButton');
78
+ expect(output).not.toContain('XDSIconRegistry');
79
+ expect(output).not.toContain('@xds/core');
80
+ });
81
+ });
@@ -4,12 +4,23 @@
4
4
  * @file Codemod: Drop the `XDS` prefix from @xds/core imports and their usages
5
5
  *
6
6
  * Part of the XDS-prefix migration (P2380608025). Rewrites consumer code from
7
- * the prefixed names to the bare compatibility aliases shipped in P1:
7
+ * the prefixed names to their bare equivalents:
8
8
  *
9
9
  * XDSButton -> Button
10
10
  * XDSButtonProps -> ButtonProps
11
11
  * useXDSTheme -> useTheme
12
12
  * useXDSToast -> useToast
13
+ * XDSIconRegistry-> IconRegistry
14
+ *
15
+ * Mandatory in v0.1.0: the prefixed compatibility aliases (which made both
16
+ * prefixed and bare names valid during the 0.0.x compat window) were dropped
17
+ * in v0.1.0, so the un-prefixing is now required for code to keep type-
18
+ * checking against @astryxdesign/core.
19
+ *
20
+ * Ordering: within the v0.1.0 manifest this runs BEFORE
21
+ * migrate-xds-module-specifiers so it still matches `@xds/core` imports (its
22
+ * source matcher) and un-prefixes the identifiers first; the specifier codemod
23
+ * then rewrites the module paths `@xds/*` -> `@astryxdesign/*`.
13
24
  *
14
25
  * Safety: this codemod ONLY renames identifiers that are imported from
15
26
  * `@xds/core` (bare or subpath, e.g. `@xds/core/Button`). It tracks the local
@@ -36,9 +47,9 @@ export const meta = {
36
47
  title: 'Drop XDS prefix from @xds/core imports (XDSButton -> Button)',
37
48
  description:
38
49
  'Rewrites @xds/core imports and their usages from the prefixed names ' +
39
- '(XDSButton, useXDSTheme, XDSButtonProps) to the bare compatibility ' +
40
- 'aliases (Button, useTheme, ButtonProps). Only renames bindings imported ' +
41
- 'from @xds/core, leaving unrelated identifiers untouched.',
50
+ '(XDSButton, useXDSTheme, XDSIconRegistry, XDSButtonProps) to their bare ' +
51
+ 'names (Button, useTheme, IconRegistry, ButtonProps). Only renames ' +
52
+ 'bindings imported from @xds/core, leaving unrelated identifiers untouched.',
42
53
  pr: '#2880',
43
54
  };
44
55
 
@@ -6,11 +6,29 @@
6
6
  * Lists all codemods for the v0.1.0 release in the order they should run.
7
7
  */
8
8
 
9
+ import dropXdsPrefixImports, {
10
+ meta as dropXdsPrefixImportsMeta,
11
+ } from './drop-xds-prefix-imports.mjs';
12
+
9
13
  import migrateXdsModuleSpecifiers, {
10
14
  meta as migrateXdsModuleSpecifiersMeta,
11
15
  } from './migrate-xds-module-specifiers.mjs';
12
16
 
13
17
  export default [
18
+ {
19
+ // XDS-prefix migration (P2380608025). Mandatory in v0.1.0: the release
20
+ // dropped the prefixed compatibility aliases (useXDSTheme, XDSButton,
21
+ // XDSIconRegistry, ...), so consumers upgrading from 0.0.x MUST rewrite
22
+ // prefixed imports to their bare names.
23
+ //
24
+ // Ordered BEFORE migrate-xds-module-specifiers so it sees `@xds/core`
25
+ // imports (its source matcher) and un-prefixes the identifiers first;
26
+ // the specifier codemod then rewrites the paths to `@astryxdesign/core`.
27
+ // The runner preserves this array order (see runner.mjs).
28
+ name: 'drop-xds-prefix-imports',
29
+ transform: dropXdsPrefixImports,
30
+ meta: dropXdsPrefixImportsMeta,
31
+ },
14
32
  {
15
33
  name: 'migrate-xds-module-specifiers',
16
34
  transform: migrateXdsModuleSpecifiers,