@astryxdesign/cli 0.6.3-canary.60b419f → 0.6.3-canary.6ef7b74
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.
|
@@ -3,8 +3,7 @@
|
|
|
3
3
|
import {describe, it, expect} from 'vitest';
|
|
4
4
|
|
|
5
5
|
async function applyTransform(source, path = 'test.ts') {
|
|
6
|
-
const {default: transform} =
|
|
7
|
-
await import('../unwrap-authoring-factories.mjs');
|
|
6
|
+
const {default: transform} = await import('../unwrap-authoring-factories.mjs');
|
|
8
7
|
const jscodeshift = (await import('jscodeshift')).default;
|
|
9
8
|
const j = jscodeshift.withParser('tsx');
|
|
10
9
|
const api = {jscodeshift: j, stats: () => {}, report: () => {}};
|
|
@@ -19,7 +18,7 @@ export default createConfig({integrations: ['@acme/widgets']});
|
|
|
19
18
|
`;
|
|
20
19
|
const output = await applyTransform(input);
|
|
21
20
|
expect(output).not.toContain('createConfig');
|
|
22
|
-
expect(output).toContain(
|
|
21
|
+
expect(output).toContain("export default {");
|
|
23
22
|
expect(output).toContain("integrations: ['@acme/widgets']");
|
|
24
23
|
expect(output).not.toContain('type:');
|
|
25
24
|
});
|
|
@@ -133,34 +132,13 @@ export default createComponentDoc();
|
|
|
133
132
|
expect(output).toContain("type: 'component'");
|
|
134
133
|
});
|
|
135
134
|
|
|
136
|
-
it('leaves same-named factories from unrelated packages unchanged', async () => {
|
|
137
|
-
const input = `import {createConfig} from '@acme/eslint';
|
|
138
|
-
export default createConfig({strict: true});
|
|
139
|
-
`;
|
|
140
|
-
expect(await applyTransform(input)).toBe(input);
|
|
141
|
-
});
|
|
142
|
-
|
|
143
|
-
it('keeps an unrelated same-named import when another factory is migrated', async () => {
|
|
144
|
-
const input = `import {createConfig as createLintConfig} from '@acme/eslint';
|
|
145
|
-
import {createDoc} from '@astryxdesign/cli/doc';
|
|
146
|
-
export const lintConfig = createLintConfig({strict: true});
|
|
147
|
-
export const doc = createDoc({name: 'Theming', description: 'How theming works.'});
|
|
148
|
-
`;
|
|
149
|
-
const output = await applyTransform(input);
|
|
150
|
-
expect(output).toContain(
|
|
151
|
-
"import {createConfig as createLintConfig} from '@acme/eslint'",
|
|
152
|
-
);
|
|
153
|
-
expect(output).toContain('createLintConfig({strict: true})');
|
|
154
|
-
expect(output).not.toContain('createDoc');
|
|
155
|
-
expect(output).toContain("type: 'generic'");
|
|
156
|
-
});
|
|
157
|
-
|
|
158
135
|
it('is a no-op when no authoring factory is imported', async () => {
|
|
159
136
|
const input = `import {Button} from '@astryxdesign/core';
|
|
160
137
|
export default Button;
|
|
161
138
|
`;
|
|
162
|
-
const {default: transform} =
|
|
163
|
-
|
|
139
|
+
const {default: transform} = await import(
|
|
140
|
+
'../unwrap-authoring-factories.mjs'
|
|
141
|
+
);
|
|
164
142
|
const jscodeshift = (await import('jscodeshift')).default;
|
|
165
143
|
const j = jscodeshift.withParser('tsx');
|
|
166
144
|
const api = {jscodeshift: j, stats: () => {}, report: () => {}};
|
|
@@ -5,9 +5,8 @@
|
|
|
5
5
|
*
|
|
6
6
|
* v0.3.0 removes the authoring factories. Authoring is now types + parsers: an
|
|
7
7
|
* author writes a plain object and stamps its `type` directly. This transform
|
|
8
|
-
* rewrites factory
|
|
9
|
-
*
|
|
10
|
-
* factory imports:
|
|
8
|
+
* rewrites every factory call to the plain object the factory used to return,
|
|
9
|
+
* then drops the now-dead factory imports:
|
|
11
10
|
*
|
|
12
11
|
* createConfig(o) / createIntegration(o) -> o (no discriminant)
|
|
13
12
|
* createComponentDoc(o) -> { ...o, type: 'component' }
|
|
@@ -26,9 +25,8 @@
|
|
|
26
25
|
*
|
|
27
26
|
* Import aliases are followed (`import {createDoc as mk}` → calls to `mk`), and
|
|
28
27
|
* the factory specifiers are removed afterward (the whole import statement goes
|
|
29
|
-
* if nothing else was imported from it).
|
|
30
|
-
*
|
|
31
|
-
* the surviving type imports.
|
|
28
|
+
* if nothing else was imported from it). Run this BEFORE
|
|
29
|
+
* `migrate-authoring-imports`, which repoints the surviving type imports.
|
|
32
30
|
*/
|
|
33
31
|
|
|
34
32
|
export const meta = {
|
|
@@ -37,24 +35,13 @@ export const meta = {
|
|
|
37
35
|
'Rewrites createConfig/createIntegration/createComponentDoc/' +
|
|
38
36
|
'createFunctionDoc/createDoc/createPageTemplate/createBlockTemplate/' +
|
|
39
37
|
'createCodemod/createConfigCodemod calls to the plain object they returned ' +
|
|
40
|
-
|
|
38
|
+
"(stamping the doc/template/codemod `type` discriminant), and removes the " +
|
|
41
39
|
'now-dead factory imports. Authoring is types + parsers in v0.3.0 — there ' +
|
|
42
40
|
'are no factories.',
|
|
43
41
|
pr: '#4612',
|
|
44
42
|
fileExtensions: ['.js', '.jsx', '.ts', '.tsx', '.mjs', '.cjs'],
|
|
45
43
|
};
|
|
46
44
|
|
|
47
|
-
/** Legacy Astryx authoring entrypoints that exported the removed factories. */
|
|
48
|
-
const AUTHORING_SOURCES = new Set([
|
|
49
|
-
'@astryxdesign/cli/config',
|
|
50
|
-
'@astryxdesign/cli/doc',
|
|
51
|
-
'@astryxdesign/cli/integration',
|
|
52
|
-
'@astryxdesign/cli/template',
|
|
53
|
-
'@astryxdesign/cli/codemod',
|
|
54
|
-
'@astryxdesign/core/authoring',
|
|
55
|
-
'@astryxdesign/core/config',
|
|
56
|
-
]);
|
|
57
|
-
|
|
58
45
|
/**
|
|
59
46
|
* Factory name → the `type` discriminant it stamped, or `null` for the config /
|
|
60
47
|
* integration factories, which were pure typed-identity (no discriminant).
|
|
@@ -121,7 +108,6 @@ export default function transformer(file, api) {
|
|
|
121
108
|
/** @type {Map<string, string>} */
|
|
122
109
|
const localToFactory = new Map();
|
|
123
110
|
root.find(j.ImportDeclaration).forEach((/** @type {any} */ path) => {
|
|
124
|
-
if (!AUTHORING_SOURCES.has(path.node.source.value)) return;
|
|
125
111
|
for (const spec of path.node.specifiers ?? []) {
|
|
126
112
|
if (spec.type !== 'ImportSpecifier') continue;
|
|
127
113
|
const importedName = spec.imported?.name;
|
|
@@ -177,7 +163,6 @@ export default function transformer(file, api) {
|
|
|
177
163
|
// Drop the now-dead factory import specifiers; remove any import statement
|
|
178
164
|
// left empty.
|
|
179
165
|
root.find(j.ImportDeclaration).forEach((/** @type {any} */ path) => {
|
|
180
|
-
if (!AUTHORING_SOURCES.has(path.node.source.value)) return;
|
|
181
166
|
const specs = path.node.specifiers ?? [];
|
|
182
167
|
const kept = specs.filter(
|
|
183
168
|
(/** @type {any} */ spec) =>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@astryxdesign/cli",
|
|
3
|
-
"version": "0.6.3-canary.
|
|
3
|
+
"version": "0.6.3-canary.6ef7b74",
|
|
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",
|
|
@@ -100,10 +100,10 @@
|
|
|
100
100
|
"zod": "^4.4.3"
|
|
101
101
|
},
|
|
102
102
|
"peerDependencies": {
|
|
103
|
-
"@astryxdesign/charts": "0.6.3-canary.
|
|
104
|
-
"@astryxdesign/core": "0.6.3-canary.
|
|
105
|
-
"@astryxdesign/lab": "0.6.3-canary.
|
|
106
|
-
"@astryxdesign/theme-neutral": "0.6.3-canary.
|
|
103
|
+
"@astryxdesign/charts": "0.6.3-canary.6ef7b74",
|
|
104
|
+
"@astryxdesign/core": "0.6.3-canary.6ef7b74",
|
|
105
|
+
"@astryxdesign/lab": "0.6.3-canary.6ef7b74",
|
|
106
|
+
"@astryxdesign/theme-neutral": "0.6.3-canary.6ef7b74",
|
|
107
107
|
"gpt-tokenizer": "^3.4.0"
|
|
108
108
|
},
|
|
109
109
|
"peerDependenciesMeta": {
|
|
@@ -121,10 +121,10 @@
|
|
|
121
121
|
}
|
|
122
122
|
},
|
|
123
123
|
"devDependencies": {
|
|
124
|
-
"@astryxdesign/charts": "0.6.3-canary.
|
|
125
|
-
"@astryxdesign/core": "0.6.3-canary.
|
|
126
|
-
"@astryxdesign/lab": "0.6.3-canary.
|
|
127
|
-
"@astryxdesign/theme-neutral": "0.6.3-canary.
|
|
124
|
+
"@astryxdesign/charts": "0.6.3-canary.6ef7b74",
|
|
125
|
+
"@astryxdesign/core": "0.6.3-canary.6ef7b74",
|
|
126
|
+
"@astryxdesign/lab": "0.6.3-canary.6ef7b74",
|
|
127
|
+
"@astryxdesign/theme-neutral": "0.6.3-canary.6ef7b74",
|
|
128
128
|
"@heroicons/react": "^2.2.0",
|
|
129
129
|
"@stylexjs/stylex": "^0.19.0",
|
|
130
130
|
"@types/babel__core": "^7.20.5",
|