@astryxdesign/cli 0.7.0-canary.f3a2181 → 0.7.0

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.
Files changed (26) hide show
  1. package/CHANGELOG.md +167 -0
  2. package/api/doctor/doctor.d.mts +30 -2
  3. package/api/doctor/doctor.doc.mjs +2 -1
  4. package/api/doctor/doctor.mjs +153 -3
  5. package/api/doctor/doctor.test.mjs +250 -4
  6. package/assets/codemods/__tests__/registry.test.mjs +1 -0
  7. package/assets/codemods/registry.mjs +1 -0
  8. package/assets/codemods/transforms/next/index.mjs +1 -35
  9. package/assets/codemods/transforms/v0.7.0/__tests__/rename-empty-search-results-text.test.mjs +202 -0
  10. package/assets/codemods/transforms/v0.7.0/index.mjs +52 -0
  11. package/assets/codemods/transforms/v0.7.0/rename-empty-search-results-text.mjs +254 -0
  12. package/assets/templates/themes/matcha/matchaTheme.ts +14 -14
  13. package/assets/templates/themes/y2k/y2kTheme.ts +10 -10
  14. package/assets/theme.template.ts +1 -1
  15. package/clients/cli/commands/doctor.doc.mjs +1 -1
  16. package/clients/cli/commands/doctor.test.mjs +33 -0
  17. package/package.json +9 -9
  18. /package/assets/codemods/transforms/{next → v0.7.0}/__tests__/migrate-deprecated-theme-surface.test.mjs +0 -0
  19. /package/assets/codemods/transforms/{next → v0.7.0}/__tests__/migrate-field-input-styling.test.mjs +0 -0
  20. /package/assets/codemods/transforms/{next → v0.7.0}/__tests__/preserve-bottom-sheet-content-padding.test.mjs +0 -0
  21. /package/assets/codemods/transforms/{next → v0.7.0}/__tests__/validate-data-token-ownership.test.mjs +0 -0
  22. /package/assets/codemods/transforms/{next → v0.7.0}/migrate-deprecated-theme-surface-v0.6-data.mjs +0 -0
  23. /package/assets/codemods/transforms/{next → v0.7.0}/migrate-deprecated-theme-surface.mjs +0 -0
  24. /package/assets/codemods/transforms/{next → v0.7.0}/migrate-field-input-styling.mjs +0 -0
  25. /package/assets/codemods/transforms/{next → v0.7.0}/preserve-bottom-sheet-content-padding.mjs +0 -0
  26. /package/assets/codemods/transforms/{next → v0.7.0}/validate-data-token-ownership.mjs +0 -0
@@ -1042,7 +1042,7 @@ describe('doctor says why it skipped and what it checked', () => {
1042
1042
  }
1043
1043
 
1044
1044
  it(
1045
- 'warns, and quotes the reason, when the CLI cannot load the project from a config that imports',
1045
+ 'fails, and quotes the reason, when the CLI cannot load the project from a config that imports',
1046
1046
  async () => {
1047
1047
  const dir = cwdProject({
1048
1048
  'package.json': '{"name":"app"}',
@@ -1051,7 +1051,7 @@ describe('doctor says why it skipped and what it checked', () => {
1051
1051
  });
1052
1052
  const {checks, summary} = (await doctor({cwd: dir})).data;
1053
1053
  const by = Object.fromEntries(checks.map(c => [c.id, c]));
1054
- expect(by.config.status).toBe('warn');
1054
+ expect(by.config.status).toBe('fail');
1055
1055
  expect(by.config.message).toMatch(
1056
1056
  /^astryx\.config\.mjs loads, but the CLI could not load the project from it: .*integrations/,
1057
1057
  );
@@ -1064,8 +1064,8 @@ describe('doctor says why it skipped and what it checked', () => {
1064
1064
  expect(by['integration-issues'].message).toMatch(
1065
1065
  /^Skipped — the project integration graph could not be loaded: .*integrations/,
1066
1066
  );
1067
- // A warning: the exit code a released CLI gave this project is unchanged.
1068
- expect(summary.fail).toBe(0);
1067
+ // The config check is the one failure; the skipped checks stay info.
1068
+ expect(summary.fail).toBe(1);
1069
1069
  },
1070
1070
  SLOW,
1071
1071
  );
@@ -1123,6 +1123,252 @@ describe('doctor says why it skipped and what it checked', () => {
1123
1123
  });
1124
1124
  });
1125
1125
 
1126
+ describe('a configured integration that cannot load fails the gate', () => {
1127
+ const CORE_STUB = {
1128
+ 'node_modules/@astryxdesign/core/package.json': JSON.stringify({
1129
+ name: '@astryxdesign/core',
1130
+ version: '0.6.3',
1131
+ }),
1132
+ };
1133
+ const WIDGETS = 'node_modules/@acme/widgets';
1134
+ /** @param {string} [manifest] */
1135
+ const widgets = (
1136
+ manifest = "export default {components: './components'};\n",
1137
+ ) => ({
1138
+ [`${WIDGETS}/package.json`]: JSON.stringify({
1139
+ name: '@acme/widgets',
1140
+ version: '1.0.0',
1141
+ }),
1142
+ [`${WIDGETS}/astryx.integration.mjs`]: manifest,
1143
+ [`${WIDGETS}/components/AcmeCard.doc.mjs`]:
1144
+ "export default {type: 'component', name: 'AcmeCard', displayName: 'AcmeCard', description: 'Fixture.', props: []};\n",
1145
+ [`${WIDGETS}/components/AcmeCard.tsx`]:
1146
+ 'export default function AcmeCard() { return null; }\n',
1147
+ });
1148
+ const APP = {
1149
+ 'package.json': '{"name":"app"}',
1150
+ ...CORE_STUB,
1151
+ 'astryx.config.mjs': "export default { integrations: ['@acme/widgets'] };\n",
1152
+ };
1153
+
1154
+ /** Run doctor on a project under the working directory. */
1155
+ async function report(files) {
1156
+ const dir = fs.mkdtempSync(path.join(process.cwd(), '.astryx-doctor-gate-'));
1157
+ tmpDirs.push(dir);
1158
+ for (const [rel, content] of Object.entries(files)) {
1159
+ const abs = path.join(dir, rel);
1160
+ fs.mkdirSync(path.dirname(abs), {recursive: true});
1161
+ fs.writeFileSync(abs, content);
1162
+ }
1163
+ const {checks, summary} = (await doctor({cwd: dir})).data;
1164
+ return {by: Object.fromEntries(checks.map(c => [c.id, c])), summary};
1165
+ }
1166
+
1167
+ it.each([
1168
+ ['not installed', {}, /Could not find installed integration package "@acme\/widgets"/],
1169
+ [
1170
+ 'installed without a manifest',
1171
+ {[`${WIDGETS}/package.json`]: JSON.stringify({name: '@acme/widgets', version: '1.0.0'})},
1172
+ /no conventional root manifest/,
1173
+ ],
1174
+ ['installed with a manifest that throws', widgets('export default { not valid ((\n'), /Unexpected/],
1175
+ ])(
1176
+ 'fails when a configured integration is %s, and names it',
1177
+ async (_shape, extra, reason) => {
1178
+ const {by, summary} = await report({...APP, ...extra});
1179
+ const check = by['configured-integrations'];
1180
+ expect(check.status).toBe('fail');
1181
+ expect(check.message).toMatch(
1182
+ /^1 of 1 integration named in astryx\.config could not be loaded, so it contributes nothing: @acme\/widgets \(/,
1183
+ );
1184
+ expect(check.message).toMatch(reason);
1185
+ expect(check.fix).toContain('astryx doctor integration validate <package>');
1186
+ expect(summary.fail).toBe(1);
1187
+ },
1188
+ SLOW,
1189
+ );
1190
+
1191
+ it(
1192
+ 'counts the package being authored when its own config names it',
1193
+ async () => {
1194
+ const {by} = await report({
1195
+ ...CORE_STUB,
1196
+ 'package.json': JSON.stringify({name: '@acme/widgets', version: '1.0.0'}),
1197
+ 'astryx.integration.mjs': "export default {components: './components'};\n",
1198
+ 'components/AcmeCard.doc.mjs':
1199
+ "export default {type: 'component', name: 'AcmeCard', displayName: 'AcmeCard', description: 'Fixture.', props: []};\n",
1200
+ 'components/AcmeCard.tsx': 'export default function AcmeCard() { return null; }\n',
1201
+ 'astryx.config.mjs': "export default { integrations: ['@acme/widgets'] };\n",
1202
+ });
1203
+ expect(by['configured-integrations'].status).toBe('pass');
1204
+ expect(by['configured-integrations'].message).toBe(
1205
+ '1 integration named in astryx.config loaded: @acme/widgets.',
1206
+ );
1207
+ },
1208
+ SLOW,
1209
+ );
1210
+
1211
+ it(
1212
+ 'fails when the package being authored is named by its own config and its manifest throws',
1213
+ async () => {
1214
+ const {by, summary} = await report({
1215
+ ...CORE_STUB,
1216
+ 'package.json': JSON.stringify({name: '@acme/widgets', version: '1.0.0'}),
1217
+ 'astryx.integration.mjs': 'export default { not valid ((\n',
1218
+ 'astryx.config.mjs': "export default { integrations: ['@acme/widgets'] };\n",
1219
+ });
1220
+ const check = by['configured-integrations'];
1221
+ expect(check.status).toBe('fail');
1222
+ expect(check.message).toMatch(
1223
+ /^1 of 1 integration named in astryx\.config could not be loaded, so it contributes nothing: @acme\/widgets \(/,
1224
+ );
1225
+ expect(summary.fail).toBe(1);
1226
+ },
1227
+ SLOW,
1228
+ );
1229
+
1230
+ it(
1231
+ 'fails when node_modules links the configured name back to the authored package and its manifest throws',
1232
+ async () => {
1233
+ const dir = fs.mkdtempSync(path.join(process.cwd(), '.astryx-doctor-gate-'));
1234
+ tmpDirs.push(dir);
1235
+ const files = {
1236
+ ...CORE_STUB,
1237
+ 'package.json': JSON.stringify({name: '@acme/widgets', version: '1.0.0'}),
1238
+ 'astryx.integration.mjs': 'export default { not valid ((\n',
1239
+ 'astryx.config.mjs': "export default { integrations: ['@acme/widgets'] };\n",
1240
+ };
1241
+ for (const [rel, content] of Object.entries(files)) {
1242
+ const abs = path.join(dir, rel);
1243
+ fs.mkdirSync(path.dirname(abs), {recursive: true});
1244
+ fs.writeFileSync(abs, content);
1245
+ }
1246
+ fs.mkdirSync(path.join(dir, 'node_modules/@acme'), {recursive: true});
1247
+ fs.symlinkSync(dir, path.join(dir, 'node_modules/@acme/widgets'), 'dir');
1248
+ const {checks, summary} = (await doctor({cwd: dir})).data;
1249
+ const by = Object.fromEntries(checks.map(c => [c.id, c]));
1250
+ expect(by['configured-integrations'].status).toBe('fail');
1251
+ expect(by['configured-integrations'].message).toMatch(
1252
+ /^1 of 1 integration named in astryx\.config could not be loaded/,
1253
+ );
1254
+ expect(summary.fail).toBe(1);
1255
+ },
1256
+ SLOW,
1257
+ );
1258
+
1259
+ it(
1260
+ 'fails for the self-linked authored package when the working directory is itself a symlink',
1261
+ async () => {
1262
+ const real = fs.mkdtempSync(path.join(process.cwd(), '.astryx-doctor-gate-'));
1263
+ tmpDirs.push(real);
1264
+ const linkParent = fs.mkdtempSync(path.join(process.cwd(), '.astryx-doctor-gate-'));
1265
+ tmpDirs.push(linkParent);
1266
+ const cwd = path.join(linkParent, 'link');
1267
+ fs.symlinkSync(real, cwd, 'dir');
1268
+ const files = {
1269
+ ...CORE_STUB,
1270
+ 'package.json': JSON.stringify({name: '@acme/widgets', version: '1.0.0'}),
1271
+ 'astryx.integration.mjs': 'export default { not valid ((\n',
1272
+ 'astryx.config.mjs': "export default { integrations: ['@acme/widgets'] };\n",
1273
+ };
1274
+ for (const [rel, content] of Object.entries(files)) {
1275
+ const abs = path.join(real, rel);
1276
+ fs.mkdirSync(path.dirname(abs), {recursive: true});
1277
+ fs.writeFileSync(abs, content);
1278
+ }
1279
+ fs.mkdirSync(path.join(real, 'node_modules/@acme'), {recursive: true});
1280
+ fs.symlinkSync(real, path.join(real, 'node_modules/@acme/widgets'), 'dir');
1281
+ const {checks, summary} = (await doctor({cwd})).data;
1282
+ const by = Object.fromEntries(checks.map(c => [c.id, c]));
1283
+ expect(by['configured-integrations'].status).toBe('fail');
1284
+ expect(summary.fail).toBe(1);
1285
+ },
1286
+ SLOW,
1287
+ );
1288
+
1289
+ it(
1290
+ 'still counts a configured package that was set aside for a provider conflict',
1291
+ async () => {
1292
+ const CHARTS = 'node_modules/@acme/charts';
1293
+ const {by} = await report({
1294
+ ...APP,
1295
+ 'astryx.config.mjs':
1296
+ "export default { integrations: ['@acme/widgets', '@acme/charts'] };\n",
1297
+ ...widgets("export default {providerId: 'acme', components: './components'};\n"),
1298
+ [`${CHARTS}/package.json`]: JSON.stringify({name: '@acme/charts', version: '1.0.0'}),
1299
+ [`${CHARTS}/astryx.integration.mjs`]:
1300
+ "export default {providerId: 'acme', components: './components'};\n",
1301
+ [`${CHARTS}/components/AcmeChart.doc.mjs`]:
1302
+ "export default {type: 'component', name: 'AcmeChart', displayName: 'AcmeChart', description: 'Fixture.', props: []};\n",
1303
+ [`${CHARTS}/components/AcmeChart.tsx`]: 'export default function AcmeChart() { return null; }\n',
1304
+ });
1305
+ expect(by['configured-integrations'].status).toBe('pass');
1306
+ expect(by['configured-integrations'].message).toMatch(/^2 integrations named in astryx\.config loaded: /);
1307
+ expect(by['configured-integrations'].message).toContain('@acme/charts');
1308
+ },
1309
+ SLOW,
1310
+ );
1311
+
1312
+ it(
1313
+ 'passes, naming each one, when every configured integration loads',
1314
+ async () => {
1315
+ const {by, summary} = await report({...APP, ...widgets()});
1316
+ expect(by['configured-integrations']).toEqual({
1317
+ id: 'configured-integrations',
1318
+ label: 'Configured integrations',
1319
+ status: 'pass',
1320
+ message: '1 integration named in astryx.config loaded: @acme/widgets.',
1321
+ });
1322
+ expect(summary.fail).toBe(0);
1323
+ },
1324
+ SLOW,
1325
+ );
1326
+
1327
+ it.each([
1328
+ [
1329
+ 'an invalid component doc',
1330
+ {[`${WIDGETS}/components/AcmeCard.doc.mjs`]: 'export default {;\n'},
1331
+ ],
1332
+ [
1333
+ 'a declared root missing on disk',
1334
+ {
1335
+ [`${WIDGETS}/astryx.integration.mjs`]:
1336
+ "export default {components: './components', templates: './templates'};\n",
1337
+ },
1338
+ ],
1339
+ ])(
1340
+ 'keeps %s a warning, because the rest of the integration still loads (spec:AST-035 FR9)',
1341
+ async (_shape, extra) => {
1342
+ const {by, summary} = await report({...APP, ...widgets(), ...extra});
1343
+ expect(by['configured-integrations'].status).toBe('pass');
1344
+ expect(by['integration-issues'].status).toBe('warn');
1345
+ expect(summary.fail).toBe(0);
1346
+ },
1347
+ SLOW,
1348
+ );
1349
+
1350
+ it(
1351
+ 'leaves an autolinked dependency that cannot load informational',
1352
+ async () => {
1353
+ const {by, summary} = await report({
1354
+ 'package.json': JSON.stringify({
1355
+ name: 'app',
1356
+ dependencies: {'@acme/widgets': '1.0.0'},
1357
+ }),
1358
+ ...CORE_STUB,
1359
+ ...widgets('export default { not valid ((\n'),
1360
+ });
1361
+ expect(by['configured-integrations']).toMatchObject({
1362
+ status: 'info',
1363
+ message: 'No integration is named in astryx.config.',
1364
+ });
1365
+ expect(by['implicit-integrations'].status).toBe('info');
1366
+ expect(summary.fail).toBe(0);
1367
+ },
1368
+ SLOW,
1369
+ );
1370
+ });
1371
+
1126
1372
  describe('no Astryx-owned environment variables (spec:AST-017 FR14)', () => {
1127
1373
  it('no source file reads an ASTRYX_* env var', () => {
1128
1374
  const cliDir = path.resolve(REPO, 'packages/cli');
@@ -30,6 +30,7 @@ describe('registry', () => {
30
30
  '0.6.0',
31
31
  '0.6.4',
32
32
  '0.6.7',
33
+ '0.7.0',
33
34
  ]);
34
35
  });
35
36
  });
@@ -31,6 +31,7 @@ const registry = new Map([
31
31
  ['0.6.0', () => import('./transforms/v0.6.0/index.mjs')],
32
32
  ['0.6.4', () => import('./transforms/v0.6.4/index.mjs')],
33
33
  ['0.6.7', () => import('./transforms/v0.6.7/index.mjs')],
34
+ ['0.7.0', () => import('./transforms/v0.7.0/index.mjs')],
34
35
  ]);
35
36
 
36
37
  // Re-export from the shared utility so registry callers and other consumers
@@ -7,38 +7,4 @@
7
7
  * this file into the resolved version folder.
8
8
  */
9
9
 
10
- import migrateDeprecatedThemeSurface, {
11
- meta as migrateDeprecatedThemeSurfaceMeta,
12
- } from './migrate-deprecated-theme-surface.mjs';
13
- import migrateFieldInputStyling, {
14
- meta as migrateFieldInputStylingMeta,
15
- } from './migrate-field-input-styling.mjs';
16
- import preserveBottomSheetContentPadding, {
17
- meta as preserveBottomSheetContentPaddingMeta,
18
- } from './preserve-bottom-sheet-content-padding.mjs';
19
- import validateDataTokenOwnership, {
20
- meta as validateDataTokenOwnershipMeta,
21
- } from './validate-data-token-ownership.mjs';
22
-
23
- export default [
24
- {
25
- name: 'migrate-deprecated-theme-surface',
26
- transform: migrateDeprecatedThemeSurface,
27
- meta: migrateDeprecatedThemeSurfaceMeta,
28
- },
29
- {
30
- name: 'validate-data-token-ownership',
31
- transform: validateDataTokenOwnership,
32
- meta: validateDataTokenOwnershipMeta,
33
- },
34
- {
35
- name: 'migrate-field-input-styling',
36
- transform: migrateFieldInputStyling,
37
- meta: migrateFieldInputStylingMeta,
38
- },
39
- {
40
- name: 'preserve-bottom-sheet-content-padding',
41
- transform: preserveBottomSheetContentPadding,
42
- meta: preserveBottomSheetContentPaddingMeta,
43
- },
44
- ];
10
+ export default [];
@@ -0,0 +1,202 @@
1
+ // Copyright (c) Meta Platforms, Inc. and affiliates.
2
+
3
+ import {describe, expect, it} from 'vitest';
4
+ import transform from '../rename-empty-search-results-text.mjs';
5
+ import manifest from '../index.mjs';
6
+
7
+ async function applyTransform(source) {
8
+ const jscodeshift = (await import('jscodeshift')).default;
9
+ const j = jscodeshift.withParser('tsx');
10
+ const api = {jscodeshift: j, stats: () => {}, report: () => {}};
11
+ return transform({source, path: 'test.tsx'}, api) ?? source;
12
+ }
13
+
14
+ describe('rename-empty-search-results-text', () => {
15
+ it('is staged in the next-release manifest', () => {
16
+ expect(manifest.map(entry => entry.name)).toContain(
17
+ 'rename-empty-search-results-text',
18
+ );
19
+ });
20
+
21
+ describe('JSX props', () => {
22
+ it('renames the prop on Tokenizer, Typeahead, and BaseTypeahead', async () => {
23
+ const output =
24
+ await applyTransform(`import {BaseTypeahead, Tokenizer, Typeahead} from '@astryxdesign/core';
25
+ const a = <Tokenizer label="People" emptySearchResultsText="Nobody found" />;
26
+ const b = <Typeahead label="Fruit" emptySearchResultsText={copy.empty} />;
27
+ const c = <BaseTypeahead emptySearchResultsText={'None'} />;`);
28
+
29
+ expect(output).toContain(
30
+ '<Tokenizer label="People" emptySearchText="Nobody found" />',
31
+ );
32
+ expect(output).toContain(
33
+ '<Typeahead label="Fruit" emptySearchText={copy.empty} />',
34
+ );
35
+ expect(output).toContain("<BaseTypeahead emptySearchText={'None'} />");
36
+ expect(output).not.toContain('emptySearchResultsText');
37
+ });
38
+
39
+ it('follows aliases, namespaces, and subpath default imports', async () => {
40
+ const output =
41
+ await applyTransform(`import {Tokenizer as People} from '@astryxdesign/core';
42
+ import * as Astryx from '@astryxdesign/core';
43
+ import Typeahead from '@astryxdesign/core/Typeahead';
44
+ const a = <People emptySearchResultsText="x" />;
45
+ const b = <Astryx.BaseTypeahead emptySearchResultsText="y" />;
46
+ const c = <Typeahead emptySearchResultsText="z" />;`);
47
+
48
+ expect(output).not.toContain('emptySearchResultsText');
49
+ expect(output.match(/emptySearchText=/g)).toHaveLength(3);
50
+ });
51
+
52
+ it('renames the value as written, whatever shape it has', async () => {
53
+ const output =
54
+ await applyTransform(`import {Tokenizer} from '@astryxdesign/core';
55
+ const a = <Tokenizer emptySearchResultsText={compact ? 'None' : 'No matches'} />;
56
+ const b = <Tokenizer emptySearchResultsText={props.text ?? null} />;
57
+ const c = <Tokenizer {...props} emptySearchResultsText="After a spread" />;`);
58
+
59
+ expect(output).toContain(
60
+ "emptySearchText={compact ? 'None' : 'No matches'}",
61
+ );
62
+ expect(output).toContain('emptySearchText={props.text ?? null}');
63
+ // A spread may carry either name, so the element gets a TODO instead.
64
+ expect(output).toContain('{...props} /* TODO(astryx upgrade)');
65
+ expect(output).toContain('emptySearchResultsText="After a spread"');
66
+ expect(output).toContain('spreads props that may carry either name');
67
+ expect(output.match(/emptySearchResultsText/g)).toHaveLength(2);
68
+ });
69
+
70
+ it('leaves a TODO instead of choosing when emptySearchText is already set', async () => {
71
+ const output =
72
+ await applyTransform(`import {Typeahead} from '@astryxdesign/core';
73
+ const a = <Typeahead emptySearchResultsText="Old copy" emptySearchText="New copy" />;`);
74
+
75
+ expect(output).toContain('TODO(astryx upgrade)');
76
+ expect(output).toContain('emptySearchResultsText="Old copy"');
77
+ expect(output).toContain('emptySearchText="New copy"');
78
+ expect(await applyTransform(output)).toBe(output);
79
+ });
80
+
81
+ it('leaves other packages, other components, and shadowed names alone', async () => {
82
+ const source = `import {MobileTokenizer} from '@astryxdesign/lab';
83
+ import {Selector} from '@astryxdesign/core';
84
+ import {Tokenizer} from './my-tokenizer';
85
+ const a = <MobileTokenizer emptySearchResultsText="kept" />;
86
+ const b = <Selector emptySearchResultsText="kept" />;
87
+ const c = <Tokenizer emptySearchResultsText="kept" />;`;
88
+ expect(await applyTransform(source)).toBe(source);
89
+ });
90
+
91
+ it('is idempotent', async () => {
92
+ const once =
93
+ await applyTransform(`import {Tokenizer} from '@astryxdesign/core';
94
+ const a = <Tokenizer emptySearchResultsText="Nobody found" />;`);
95
+ expect(await applyTransform(once)).toBe(once);
96
+ });
97
+ });
98
+
99
+ describe('ChatComposerInput trigger objects', () => {
100
+ it('renames the key on triggers written inline, in an array or alone', async () => {
101
+ const output =
102
+ await applyTransform(`import {ChatComposerInput} from '@astryxdesign/core';
103
+ const a = (
104
+ <ChatComposerInput
105
+ triggers={[
106
+ {char: '@', searchSource, onSelect, emptySearchResultsText: 'Nobody found'},
107
+ {char: '#', emptySearchResultsText: 'No tags'} as ChatComposerTrigger,
108
+ ]}
109
+ />
110
+ );
111
+ const b = <ChatComposerInput triggers={{char: '/', emptySearchResultsText: 'No commands'}} />;`);
112
+
113
+ expect(output).toContain("emptySearchText: 'Nobody found'");
114
+ expect(output).toContain("emptySearchText: 'No tags'");
115
+ expect(output).toContain("emptySearchText: 'No commands'");
116
+ expect(output).not.toContain('emptySearchResultsText');
117
+ });
118
+
119
+ it('leaves a TODO on a trigger with a spread or computed key, or one that already sets the new name', async () => {
120
+ const output =
121
+ await applyTransform(`import {ChatComposerInput} from '@astryxdesign/core';
122
+ const a = (
123
+ <ChatComposerInput
124
+ triggers={[
125
+ {...base, emptySearchResultsText: 'Nobody'},
126
+ {[key]: 1, emptySearchResultsText: 'Nobody'},
127
+ {char: '@', emptySearchText: 'New', emptySearchResultsText: 'Old'},
128
+ ]}
129
+ />
130
+ );`);
131
+
132
+ expect(output.match(/TODO\(astryx upgrade\)/g)).toHaveLength(3);
133
+ expect(output.match(/emptySearchResultsText:/g)).toHaveLength(3);
134
+ expect(await applyTransform(output)).toBe(output);
135
+ });
136
+
137
+ it('leaves a TODO on triggers it cannot read instead of following them', async () => {
138
+ const output =
139
+ await applyTransform(`import {ChatComposerInput} from '@astryxdesign/core';
140
+ import {mentionTrigger} from './triggers';
141
+ const local = {char: '@', emptySearchResultsText: 'Nobody'};
142
+ const a = <ChatComposerInput triggers={[local, mentionTrigger]} />;
143
+ const b = <ChatComposerInput triggers={buildTriggers()} />;
144
+ const c = <ChatComposerInput triggers={useMemo(() => [t], [t])} />;
145
+ const d = <ChatComposerInput {...props} triggers={[{char: '#', emptySearchResultsText: 'No tags'}]} />;`);
146
+
147
+ expect(output.match(/These triggers are built elsewhere/g)).toHaveLength(
148
+ 4,
149
+ );
150
+ // The inline object beside a spread is still renamed; the spread is flagged.
151
+ expect(output).toContain("emptySearchText: 'No tags'");
152
+ expect(output).toContain("emptySearchResultsText: 'Nobody'");
153
+ expect(await applyTransform(output)).toBe(output);
154
+ });
155
+
156
+ it('marks every spread onto these elements, even when the element writes neither name', async () => {
157
+ const output =
158
+ await applyTransform(`import {Tokenizer, Typeahead, ChatComposerInput} from '@astryxdesign/core';
159
+ import {Selector} from '@astryxdesign/core';
160
+ const people = {emptySearchResultsText: 'No people match'};
161
+ export function Wrappers(props) {
162
+ return (
163
+ <>
164
+ <Tokenizer {...people} />
165
+ <Typeahead {...{emptySearchResultsText: 'Inline'}} />
166
+ <Tokenizer {...props} label="x" />
167
+ <ChatComposerInput {...props} />
168
+ <Selector {...props} />
169
+ <Tokenizer {...props} emptySearchText="already new" />
170
+ </>
171
+ );
172
+ }`);
173
+
174
+ expect(
175
+ output.match(/spreads props that may carry either name/g),
176
+ ).toHaveLength(4);
177
+ expect(output.match(/These triggers are built elsewhere/g)).toHaveLength(
178
+ 1,
179
+ );
180
+ expect(output).toContain('<Selector {...props} />');
181
+ expect(await applyTransform(output)).toBe(output);
182
+ });
183
+
184
+ it('marks an inline trigger object whose keys come only from a spread, once across runs', async () => {
185
+ const once =
186
+ await applyTransform(`import {ChatComposerInput} from '@astryxdesign/core';
187
+ const a = <ChatComposerInput triggers={[{...baseMention, onSelect}, {[key]: 1, onSelect}]} />;`);
188
+
189
+ expect(once.match(/has a spread or computed key/g)).toHaveLength(2);
190
+ const twice = await applyTransform(once);
191
+ expect(twice).toBe(once);
192
+ expect(twice.match(/TODO\(astryx upgrade\)/g)).toHaveLength(2);
193
+ });
194
+
195
+ it('leaves a file with no runtime core import alone', async () => {
196
+ const source = `import {MobileTokenizer} from '@astryxdesign/lab';
197
+ const copy = {emptySearchResultsText: 'kept'};
198
+ const a = <MobileTokenizer {...copy} />;`;
199
+ expect(await applyTransform(source)).toBe(source);
200
+ });
201
+ });
202
+ });
@@ -0,0 +1,52 @@
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 migrateDeprecatedThemeSurface, {
11
+ meta as migrateDeprecatedThemeSurfaceMeta,
12
+ } from './migrate-deprecated-theme-surface.mjs';
13
+ import migrateFieldInputStyling, {
14
+ meta as migrateFieldInputStylingMeta,
15
+ } from './migrate-field-input-styling.mjs';
16
+ import preserveBottomSheetContentPadding, {
17
+ meta as preserveBottomSheetContentPaddingMeta,
18
+ } from './preserve-bottom-sheet-content-padding.mjs';
19
+ import renameEmptySearchResultsText, {
20
+ meta as renameEmptySearchResultsTextMeta,
21
+ } from './rename-empty-search-results-text.mjs';
22
+ import validateDataTokenOwnership, {
23
+ meta as validateDataTokenOwnershipMeta,
24
+ } from './validate-data-token-ownership.mjs';
25
+
26
+ export default [
27
+ {
28
+ name: 'migrate-deprecated-theme-surface',
29
+ transform: migrateDeprecatedThemeSurface,
30
+ meta: migrateDeprecatedThemeSurfaceMeta,
31
+ },
32
+ {
33
+ name: 'validate-data-token-ownership',
34
+ transform: validateDataTokenOwnership,
35
+ meta: validateDataTokenOwnershipMeta,
36
+ },
37
+ {
38
+ name: 'migrate-field-input-styling',
39
+ transform: migrateFieldInputStyling,
40
+ meta: migrateFieldInputStylingMeta,
41
+ },
42
+ {
43
+ name: 'preserve-bottom-sheet-content-padding',
44
+ transform: preserveBottomSheetContentPadding,
45
+ meta: preserveBottomSheetContentPaddingMeta,
46
+ },
47
+ {
48
+ name: 'rename-empty-search-results-text',
49
+ transform: renameEmptySearchResultsText,
50
+ meta: renameEmptySearchResultsTextMeta,
51
+ },
52
+ ];