@astryxdesign/cli 0.7.5-canary.cd53c2d → 0.7.5-canary.cdd75ae
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 +2 -2
- package/api/upgrade/_adapter.d.mts +47 -2
- package/api/upgrade/_adapter.mjs +58 -2
- package/api/upgrade/run/failure-receipt.test.mjs +212 -0
- package/api/upgrade/run/outcomes.test.mjs +646 -0
- package/api/upgrade/run/run.d.mts +36 -0
- package/api/upgrade/run/run.mjs +670 -44
- package/api/upgrade/upgrade.doc.mjs +4 -4
- package/api/upgrade/upgrade.mjs +19 -4
- package/api/upgrade/upgrade.type.d.mts +36 -1
- package/api/upgrade/upgrade.type.mjs +29 -4
- package/assets/codemods/__tests__/runner.symlinks.test.mjs +205 -0
- package/assets/codemods/__tests__/runner.unparseable.test.mjs +457 -0
- package/assets/codemods/integration-runner.mjs +8 -2
- package/assets/codemods/integration-runner.protection.test.mjs +53 -0
- package/assets/codemods/outcome.mjs +79 -0
- package/assets/codemods/outcome.test.mjs +40 -0
- package/assets/codemods/parse.mjs +94 -0
- package/assets/codemods/run-codemod.mjs +109 -5
- package/assets/codemods/runner.mjs +119 -13
- package/assets/codemods/transform-prop.mjs +99 -49
- package/assets/codemods/transform-prop.test.mjs +36 -1
- package/assets/codemods/transforms/v0.1.3/__tests__/migrate-layout-components-to-experimental.test.mjs +216 -2
- package/assets/codemods/transforms/v0.1.3/migrate-layout-components-to-experimental.mjs +88 -6
- package/assets/codemods/transforms/v0.6.0/migrate-astryx-theme-selectors-to-data-attrs.mjs +4 -3
- package/assets/codemods/transforms/v0.7.0/__tests__/migrate-deprecated-theme-surface.test.mjs +207 -6
- package/assets/codemods/transforms/v0.7.0/__tests__/validate-data-token-ownership.test.mjs +24 -4
- package/assets/codemods/transforms/v0.7.0/migrate-deprecated-theme-surface-v0.6-data.mjs +6 -1
- package/assets/codemods/transforms/v0.7.0/migrate-deprecated-theme-surface.mjs +244 -42
- package/assets/codemods/transforms/v0.7.0/validate-data-token-ownership.mjs +6 -3
- package/assets/docs/tree/styling-advanced.doc.mjs +1 -1
- package/assets/templates/blocks/components/CodeBlock/CodeBlockBashCommand.doc.mjs +1 -1
- package/assets/templates/blocks/components/CodeBlock/CodeBlockBashCommand.tsx +10 -2
- package/assets/templates/pages/library/page.tsx +1 -2
- package/authoring/codemod/type.ts +10 -0
- package/clients/cli/commands/upgrade.doc.mjs +47 -2
- package/clients/cli/commands/upgrade.file-protection.test.mjs +175 -0
- package/clients/cli/commands/upgrade.flag-help.test.mjs +37 -0
- package/clients/cli/commands/upgrade.integration-policy.test.mjs +103 -0
- package/clients/cli/commands/upgrade.mjs +9 -2
- package/clients/cli/commands/upgrade.outcomes.test.mjs +350 -0
- package/foundation/response/base.d.ts +7 -0
- package/foundation/response/error-codes.doc.mjs +3 -2
- package/foundation/response/error-codes.mjs +1 -1
- package/foundation/response/json.d.mts +10 -3
- package/foundation/response/json.mjs +16 -4
- package/foundation/response/response-types.doc.mjs +1 -1
- package/package.json +10 -9
|
@@ -2,7 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
import {describe, expect, it} from 'vitest';
|
|
4
4
|
import jscodeshift from 'jscodeshift';
|
|
5
|
-
import {
|
|
5
|
+
import {
|
|
6
|
+
importedComponents,
|
|
7
|
+
resolveImportedComponent,
|
|
8
|
+
transformProp,
|
|
9
|
+
} from './transform-prop.mjs';
|
|
6
10
|
|
|
7
11
|
const j = jscodeshift.withParser('tsx');
|
|
8
12
|
const components = new Map([
|
|
@@ -92,4 +96,35 @@ const b = <Group tone="old" size="old" />;`);
|
|
|
92
96
|
expect(output).toContain('<Widget size="old" migratedtone="old"');
|
|
93
97
|
expect(output).toContain('<Group tone="old" migratedsize="old"');
|
|
94
98
|
});
|
|
99
|
+
|
|
100
|
+
it('resolves non-JSX references through the same import and shadow rules', () => {
|
|
101
|
+
const root = j(`import {Widget as Card} from '@example/core';
|
|
102
|
+
import * as Lib from '@example/core';
|
|
103
|
+
const a = Card;
|
|
104
|
+
const b = Lib.Group;
|
|
105
|
+
function shadow(Card, Lib) {
|
|
106
|
+
return [Card, Lib.Group];
|
|
107
|
+
}`);
|
|
108
|
+
const imports = importedComponents(root, j, {
|
|
109
|
+
matchesImport: value => /^@example\/core(?:\/|$)/.test(value),
|
|
110
|
+
components,
|
|
111
|
+
});
|
|
112
|
+
const resolved = root
|
|
113
|
+
.find(j.VariableDeclarator)
|
|
114
|
+
.paths()
|
|
115
|
+
.map(
|
|
116
|
+
path =>
|
|
117
|
+
resolveImportedComponent(path.node.init, path, imports)?.component,
|
|
118
|
+
);
|
|
119
|
+
expect(resolved).toEqual(['Widget', 'Group']);
|
|
120
|
+
const shadowed = root
|
|
121
|
+
.find(j.ArrayExpression)
|
|
122
|
+
.paths()
|
|
123
|
+
.flatMap(path =>
|
|
124
|
+
path.node.elements.map(element =>
|
|
125
|
+
resolveImportedComponent(element, path, imports),
|
|
126
|
+
),
|
|
127
|
+
);
|
|
128
|
+
expect(shadowed).toEqual([null, null]);
|
|
129
|
+
});
|
|
95
130
|
});
|
|
@@ -162,6 +162,52 @@ export default createConfig({
|
|
|
162
162
|
});
|
|
163
163
|
});
|
|
164
164
|
|
|
165
|
+
describe('migrate-layout-components-to-experimental — default export by const reference', () => {
|
|
166
|
+
it('returns null for a generated config with no layout key', async () => {
|
|
167
|
+
const input = `// Generated Astryx config.
|
|
168
|
+
const config = {
|
|
169
|
+
integrations: ["@acme/ui"],
|
|
170
|
+
issuesUrl: "https://example.com/issues",
|
|
171
|
+
};
|
|
172
|
+
|
|
173
|
+
export default config;
|
|
174
|
+
`;
|
|
175
|
+
const output = await applyTransform(input);
|
|
176
|
+
expect(output).toBeNull();
|
|
177
|
+
});
|
|
178
|
+
|
|
179
|
+
it('migrates layout.components in a const-bound object literal', async () => {
|
|
180
|
+
const input = `const config = {
|
|
181
|
+
layout: { components: { KpiCard: '@/components/KpiCard' } },
|
|
182
|
+
};
|
|
183
|
+
|
|
184
|
+
export default config;
|
|
185
|
+
`;
|
|
186
|
+
const output = await applyTransform(input);
|
|
187
|
+
expect(output).not.toBeNull();
|
|
188
|
+
expect(output).toMatch(/const config = \{/);
|
|
189
|
+
expect(output).toContain('export default config;');
|
|
190
|
+
expect(output).toMatch(/experimental:\s*\{\s*xle:\s*\{\s*components:\s*\{\s*KpiCard:\s*\{\s*from:\s*['"]@\/components\/KpiCard['"]/);
|
|
191
|
+
expect(output).not.toMatch(/layout\s*:/);
|
|
192
|
+
});
|
|
193
|
+
|
|
194
|
+
it('migrates layout.components in a const-bound createConfig({ ... }) call', async () => {
|
|
195
|
+
const input = `import { createConfig } from '@astryxdesign/cli';
|
|
196
|
+
|
|
197
|
+
const config = createConfig({
|
|
198
|
+
layout: { components: { KpiCard: '@/components/KpiCard' } },
|
|
199
|
+
});
|
|
200
|
+
|
|
201
|
+
export default config;
|
|
202
|
+
`;
|
|
203
|
+
const output = await applyTransform(input);
|
|
204
|
+
expect(output).not.toBeNull();
|
|
205
|
+
expect(output).toContain('createConfig(');
|
|
206
|
+
expect(output).toMatch(/KpiCard:\s*\{\s*from:\s*['"]@\/components\/KpiCard['"]/);
|
|
207
|
+
expect(output).not.toMatch(/layout\s*:/);
|
|
208
|
+
});
|
|
209
|
+
});
|
|
210
|
+
|
|
165
211
|
describe('migrate-layout-components-to-experimental — placement', () => {
|
|
166
212
|
it('adds xle to a pre-existing experimental (no xle)', async () => {
|
|
167
213
|
const input = `export default {
|
|
@@ -239,8 +285,69 @@ export default {
|
|
|
239
285
|
await expect(applyTransform(input)).rejects.toThrow(/cannot be safely migrated/);
|
|
240
286
|
});
|
|
241
287
|
|
|
242
|
-
it('throws
|
|
243
|
-
const input = `
|
|
288
|
+
it('throws when the default export is an identifier with no top-level const binding', async () => {
|
|
289
|
+
const input = `import config from './base-config.mjs';
|
|
290
|
+
export default config;
|
|
291
|
+
`;
|
|
292
|
+
await expect(applyTransform(input)).rejects.toThrow(/statically analyze/);
|
|
293
|
+
});
|
|
294
|
+
|
|
295
|
+
it('throws when a const-bound config is mutated after its declaration', async () => {
|
|
296
|
+
const input = `const config = {};
|
|
297
|
+
config.layout = { components: { KpiCard: '@/components/KpiCard' } };
|
|
298
|
+
export default config;
|
|
299
|
+
`;
|
|
300
|
+
await expect(applyTransform(input)).rejects.toThrow(/statically analyze/);
|
|
301
|
+
});
|
|
302
|
+
|
|
303
|
+
it('throws when a const-bound config is passed to another call', async () => {
|
|
304
|
+
const input = `const config = {};
|
|
305
|
+
Object.assign(config, { layout: { components: { KpiCard: '@/components/KpiCard' } } });
|
|
306
|
+
export default config;
|
|
307
|
+
`;
|
|
308
|
+
await expect(applyTransform(input)).rejects.toThrow(/statically analyze/);
|
|
309
|
+
});
|
|
310
|
+
|
|
311
|
+
it('throws when a const-bound config is aliased', async () => {
|
|
312
|
+
const input = `const config = {};
|
|
313
|
+
const alias = config;
|
|
314
|
+
alias.layout = { components: { KpiCard: '@/components/KpiCard' } };
|
|
315
|
+
export default config;
|
|
316
|
+
`;
|
|
317
|
+
await expect(applyTransform(input)).rejects.toThrow(/statically analyze/);
|
|
318
|
+
});
|
|
319
|
+
|
|
320
|
+
it('throws when the const-bound config is also exported with export const', async () => {
|
|
321
|
+
const input = `export const config = {
|
|
322
|
+
layout: { components: { KpiCard: '@/components/KpiCard' } },
|
|
323
|
+
};
|
|
324
|
+
export default config;
|
|
325
|
+
`;
|
|
326
|
+
await expect(applyTransform(input)).rejects.toThrow(/statically analyze/);
|
|
327
|
+
});
|
|
328
|
+
|
|
329
|
+
it('throws when the const-bound config is also exported by name', async () => {
|
|
330
|
+
const input = `const config = {
|
|
331
|
+
layout: { components: { KpiCard: '@/components/KpiCard' } },
|
|
332
|
+
};
|
|
333
|
+
export { config };
|
|
334
|
+
export default config;
|
|
335
|
+
`;
|
|
336
|
+
await expect(applyTransform(input)).rejects.toThrow(/statically analyze/);
|
|
337
|
+
});
|
|
338
|
+
|
|
339
|
+
it('throws when the const-bound config is also exported under another name', async () => {
|
|
340
|
+
const input = `const config = {
|
|
341
|
+
layout: { components: { KpiCard: '@/components/KpiCard' } },
|
|
342
|
+
};
|
|
343
|
+
export { config as baseConfig };
|
|
344
|
+
export default config;
|
|
345
|
+
`;
|
|
346
|
+
await expect(applyTransform(input)).rejects.toThrow(/statically analyze/);
|
|
347
|
+
});
|
|
348
|
+
|
|
349
|
+
it('throws when the default export is bound by a reassignable let', async () => {
|
|
350
|
+
const input = `let config = { layout: { components: { KpiCard: '@/components/KpiCard' } } };
|
|
244
351
|
export default config;
|
|
245
352
|
`;
|
|
246
353
|
await expect(applyTransform(input)).rejects.toThrow(/statically analyze/);
|
|
@@ -306,6 +413,113 @@ describe('migrate-layout-components-to-experimental — end-to-end via runConfig
|
|
|
306
413
|
}
|
|
307
414
|
});
|
|
308
415
|
|
|
416
|
+
it('leaves a generated const-bound config with no layout untouched and reports no error', async () => {
|
|
417
|
+
const {runConfigCodemod} = await import('../../../run-codemod.mjs');
|
|
418
|
+
const {default: transform, meta} = await import(
|
|
419
|
+
'../migrate-layout-components-to-experimental.mjs'
|
|
420
|
+
);
|
|
421
|
+
const jscodeshift = (await import('jscodeshift')).default;
|
|
422
|
+
|
|
423
|
+
const originalCwd = process.cwd();
|
|
424
|
+
const tmpDir = fs.mkdtempSync(
|
|
425
|
+
path.join(process.cwd(), '.astryx-v013-codemod-test-'),
|
|
426
|
+
);
|
|
427
|
+
const configSource = `// Generated Astryx config.
|
|
428
|
+
const config = {
|
|
429
|
+
integrations: ["@acme/ui"],
|
|
430
|
+
issuesUrl: "https://example.com/issues",
|
|
431
|
+
};
|
|
432
|
+
|
|
433
|
+
export default config;
|
|
434
|
+
`;
|
|
435
|
+
try {
|
|
436
|
+
process.chdir(tmpDir);
|
|
437
|
+
fs.writeFileSync(
|
|
438
|
+
path.join(tmpDir, 'package.json'),
|
|
439
|
+
JSON.stringify({name: 'consumer'}),
|
|
440
|
+
);
|
|
441
|
+
fs.writeFileSync(path.join(tmpDir, 'astryx.config.mjs'), configSource);
|
|
442
|
+
|
|
443
|
+
const entry = {
|
|
444
|
+
id: 'migrate-layout-components-to-experimental',
|
|
445
|
+
type: 'config',
|
|
446
|
+
codemod: {title: meta.title, transform},
|
|
447
|
+
package: 'core',
|
|
448
|
+
version: '0.1.3',
|
|
449
|
+
};
|
|
450
|
+
const log = {
|
|
451
|
+
step() {},
|
|
452
|
+
info() {},
|
|
453
|
+
success() {},
|
|
454
|
+
warn() {},
|
|
455
|
+
error() {},
|
|
456
|
+
message() {},
|
|
457
|
+
};
|
|
458
|
+
const result = runConfigCodemod(entry, {apply: true, log, jscodeshift});
|
|
459
|
+
|
|
460
|
+
expect(result.errors).toHaveLength(0);
|
|
461
|
+
expect(result.filesChanged).toBe(0);
|
|
462
|
+
expect(
|
|
463
|
+
fs.readFileSync(path.join(tmpDir, 'astryx.config.mjs'), 'utf-8'),
|
|
464
|
+
).toBe(configSource);
|
|
465
|
+
} finally {
|
|
466
|
+
process.chdir(originalCwd);
|
|
467
|
+
fs.rmSync(tmpDir, {recursive: true, force: true});
|
|
468
|
+
}
|
|
469
|
+
});
|
|
470
|
+
|
|
471
|
+
it('reports an error, not success, for a mutated const-bound config', async () => {
|
|
472
|
+
const {runConfigCodemod} = await import('../../../run-codemod.mjs');
|
|
473
|
+
const {default: transform, meta} = await import(
|
|
474
|
+
'../migrate-layout-components-to-experimental.mjs'
|
|
475
|
+
);
|
|
476
|
+
const jscodeshift = (await import('jscodeshift')).default;
|
|
477
|
+
|
|
478
|
+
const originalCwd = process.cwd();
|
|
479
|
+
const tmpDir = fs.mkdtempSync(
|
|
480
|
+
path.join(process.cwd(), '.astryx-v013-codemod-test-'),
|
|
481
|
+
);
|
|
482
|
+
const configSource = `const config = {};
|
|
483
|
+
config.layout = { components: { KpiCard: '@/components/KpiCard' } };
|
|
484
|
+
export default config;
|
|
485
|
+
`;
|
|
486
|
+
try {
|
|
487
|
+
process.chdir(tmpDir);
|
|
488
|
+
fs.writeFileSync(
|
|
489
|
+
path.join(tmpDir, 'package.json'),
|
|
490
|
+
JSON.stringify({name: 'consumer'}),
|
|
491
|
+
);
|
|
492
|
+
fs.writeFileSync(path.join(tmpDir, 'astryx.config.mjs'), configSource);
|
|
493
|
+
|
|
494
|
+
const entry = {
|
|
495
|
+
id: 'migrate-layout-components-to-experimental',
|
|
496
|
+
type: 'config',
|
|
497
|
+
codemod: {title: meta.title, transform},
|
|
498
|
+
package: 'core',
|
|
499
|
+
version: '0.1.3',
|
|
500
|
+
};
|
|
501
|
+
const log = {
|
|
502
|
+
step() {},
|
|
503
|
+
info() {},
|
|
504
|
+
success() {},
|
|
505
|
+
warn() {},
|
|
506
|
+
error() {},
|
|
507
|
+
message() {},
|
|
508
|
+
};
|
|
509
|
+
const result = runConfigCodemod(entry, {apply: true, log, jscodeshift});
|
|
510
|
+
|
|
511
|
+
expect(result.filesChanged).toBe(0);
|
|
512
|
+
expect(result.errors).toHaveLength(1);
|
|
513
|
+
expect(result.errors[0].error).toMatch(/statically analyze/);
|
|
514
|
+
expect(
|
|
515
|
+
fs.readFileSync(path.join(tmpDir, 'astryx.config.mjs'), 'utf-8'),
|
|
516
|
+
).toBe(configSource);
|
|
517
|
+
} finally {
|
|
518
|
+
process.chdir(originalCwd);
|
|
519
|
+
fs.rmSync(tmpDir, {recursive: true, force: true});
|
|
520
|
+
}
|
|
521
|
+
});
|
|
522
|
+
|
|
309
523
|
it('surfaces a thrown bail as a structured error through runConfigCodemod', async () => {
|
|
310
524
|
const {runConfigCodemod} = await import('../../../run-codemod.mjs');
|
|
311
525
|
const {default: transform, meta} = await import(
|
|
@@ -28,10 +28,14 @@
|
|
|
28
28
|
* - object `{ from, description?, default? }` → carried over UNCHANGED
|
|
29
29
|
* (from/description/default preserved, key order preserved).
|
|
30
30
|
*
|
|
31
|
-
* The transform recognizes the config default export as
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
*
|
|
31
|
+
* The transform recognizes the config default export as a bare object literal
|
|
32
|
+
* (`export default { ... }`), a `createConfig({ ... })` call wrapping an object
|
|
33
|
+
* literal (`export default createConfig({ ... })`), or an identifier bound by a
|
|
34
|
+
* top-level `const` to either form (`const config = { ... }; export default
|
|
35
|
+
* config;`, the shape generated configs use) when the binding is not
|
|
36
|
+
* exported any other way and the default export is its only reference, so
|
|
37
|
+
* nothing can mutate the object after its declaration. Anything else is not statically analyzable and the transform
|
|
38
|
+
* THROWS with a clear
|
|
35
39
|
* migrate-manually message (the unified config-codemod contract has no
|
|
36
40
|
* structured-error return — `runConfigCodemod` surfaces a thrown `err.message`
|
|
37
41
|
* as `{file, codemod, error}`).
|
|
@@ -76,10 +80,16 @@ export default function transformer(file, api) {
|
|
|
76
80
|
|
|
77
81
|
const declaration = defaultExports.paths()[0].node.declaration;
|
|
78
82
|
|
|
79
|
-
// Resolve the config object literal from
|
|
83
|
+
// Resolve the config object literal from any supported form:
|
|
80
84
|
// export default { ... }
|
|
81
85
|
// export default createConfig({ ... })
|
|
82
|
-
const
|
|
86
|
+
// const config = { ... } | createConfig({ ... }); export default config;
|
|
87
|
+
const configObject = resolveConfigObject(
|
|
88
|
+
j,
|
|
89
|
+
j.Identifier.check(declaration)
|
|
90
|
+
? findTopLevelConstInit(j, root, declaration)
|
|
91
|
+
: declaration,
|
|
92
|
+
);
|
|
83
93
|
if (!configObject) {
|
|
84
94
|
throw new Error(
|
|
85
95
|
`could not statically analyze astryx config; ${MANUAL}`,
|
|
@@ -179,6 +189,78 @@ function resolveConfigObject(/** @type {any} */ j, /** @type {any} */ declaratio
|
|
|
179
189
|
return null;
|
|
180
190
|
}
|
|
181
191
|
|
|
192
|
+
/**
|
|
193
|
+
* Find the initializer of the top-level, non-exported `const <name> = <init>`
|
|
194
|
+
* declaration that the default-exported identifier refers to. `let`/`var`
|
|
195
|
+
* bindings can be reassigned, so they are not treated as statically
|
|
196
|
+
* analyzable. Neither is a binding exported any other way (`export const`,
|
|
197
|
+
* `export { name }`, `export { name as other }`), since another module could
|
|
198
|
+
* import and mutate it, nor one referenced anywhere besides its declaration
|
|
199
|
+
* and the default export: a member write, an alias or a call argument could
|
|
200
|
+
* change the object after its initializer. A named export specifier is such a
|
|
201
|
+
* reference, so `hasOtherReference` rejects it.
|
|
202
|
+
* @returns {any} the initializer node, or null if there is no such binding
|
|
203
|
+
*/
|
|
204
|
+
function findTopLevelConstInit(/** @type {any} */ j, /** @type {any} */ root, /** @type {any} */ exported) {
|
|
205
|
+
const name = exported.name;
|
|
206
|
+
for (const statement of root.get().node.program.body) {
|
|
207
|
+
// `export const` is skipped on purpose: another module can import the
|
|
208
|
+
// binding and mutate the object.
|
|
209
|
+
if (
|
|
210
|
+
!j.VariableDeclaration.check(statement) ||
|
|
211
|
+
statement.kind !== 'const'
|
|
212
|
+
) {
|
|
213
|
+
continue;
|
|
214
|
+
}
|
|
215
|
+
for (const declarator of statement.declarations) {
|
|
216
|
+
if (
|
|
217
|
+
j.VariableDeclarator.check(declarator) &&
|
|
218
|
+
j.Identifier.check(declarator.id) &&
|
|
219
|
+
declarator.id.name === name
|
|
220
|
+
) {
|
|
221
|
+
return hasOtherReference(j, root, name, [declarator.id, exported])
|
|
222
|
+
? null
|
|
223
|
+
: declarator.init ?? null;
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
return null;
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
/**
|
|
231
|
+
* Whether any identifier named `name`, other than the `allowed` nodes, could
|
|
232
|
+
* refer to the binding. Non-computed member properties (`x.name`) and object
|
|
233
|
+
* keys (`{ name: 1 }`) name a property, not the binding, so they don't count;
|
|
234
|
+
* every other occurrence (including a shadowing one) does.
|
|
235
|
+
* @returns {boolean}
|
|
236
|
+
*/
|
|
237
|
+
function hasOtherReference(/** @type {any} */ j, /** @type {any} */ root, /** @type {string} */ name, /** @type {any[]} */ allowed) {
|
|
238
|
+
return root
|
|
239
|
+
.find(j.Identifier, {name})
|
|
240
|
+
.some((/** @type {any} */ path) => {
|
|
241
|
+
const node = path.node;
|
|
242
|
+
if (allowed.includes(node)) return false;
|
|
243
|
+
const parent = path.parent?.node;
|
|
244
|
+
if (
|
|
245
|
+
(j.MemberExpression.check(parent) ||
|
|
246
|
+
j.OptionalMemberExpression.check(parent)) &&
|
|
247
|
+
parent.property === node &&
|
|
248
|
+
!parent.computed
|
|
249
|
+
) {
|
|
250
|
+
return false;
|
|
251
|
+
}
|
|
252
|
+
if (
|
|
253
|
+
(j.ObjectProperty.check(parent) || j.Property.check(parent)) &&
|
|
254
|
+
parent.key === node &&
|
|
255
|
+
!parent.computed &&
|
|
256
|
+
!parent.shorthand
|
|
257
|
+
) {
|
|
258
|
+
return false;
|
|
259
|
+
}
|
|
260
|
+
return true;
|
|
261
|
+
});
|
|
262
|
+
}
|
|
263
|
+
|
|
182
264
|
/**
|
|
183
265
|
* Find a (non-computed, non-spread) property on an object literal by key name.
|
|
184
266
|
* Supports Identifier and string-literal keys.
|
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
import path from 'node:path';
|
|
16
16
|
import postcss from 'postcss';
|
|
17
17
|
import selectorParser from 'postcss-selector-parser';
|
|
18
|
+
import {parseCss, processSelector} from '../../parse.mjs';
|
|
18
19
|
import {
|
|
19
20
|
V054_THEME_SELECTOR_DYNAMIC_AXES,
|
|
20
21
|
V054_THEME_SELECTOR_TARGETS,
|
|
@@ -555,7 +556,7 @@ function migrateSelectorTextWithContext(
|
|
|
555
556
|
) {
|
|
556
557
|
/** @type {TargetContext} */
|
|
557
558
|
let context = {guaranteed: [], possible: []};
|
|
558
|
-
const text =
|
|
559
|
+
const text = processSelector(selector, selectors => {
|
|
559
560
|
/** @type {TargetContext[]} */
|
|
560
561
|
const branchContexts = [];
|
|
561
562
|
selectors.each(selectorNode => {
|
|
@@ -593,7 +594,7 @@ function migrateSelectorTextWithContext(
|
|
|
593
594
|
});
|
|
594
595
|
});
|
|
595
596
|
context = combineSelectorListContexts(branchContexts);
|
|
596
|
-
})
|
|
597
|
+
});
|
|
597
598
|
return {text, context};
|
|
598
599
|
}
|
|
599
600
|
|
|
@@ -677,7 +678,7 @@ export function migrateAstryxThemeSelectors(source, from = 'styles.css', data) {
|
|
|
677
678
|
|
|
678
679
|
/** @param {string} source @param {string} from @returns {string} */
|
|
679
680
|
function migrateWithActiveTables(source, from) {
|
|
680
|
-
const root =
|
|
681
|
+
const root = parseCss(source, {from});
|
|
681
682
|
const existingComments = new Set();
|
|
682
683
|
root.walkComments(comment => {
|
|
683
684
|
existingComments.add(comment.text.trim());
|