@react-spectrum/codemods 3.0.0-nightly-e60fb427c-240930 → 3.0.0-nightly-4818630a7-241002

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.
@@ -33,6 +33,7 @@ const changes_1 = require("./changes");
33
33
  const transforms_1 = require("./transforms");
34
34
  const getComponents_1 = require("../getComponents");
35
35
  const iconMap_1 = require("../iconMap");
36
+ const recast_1 = require("recast");
36
37
  const t = __importStar(require("@babel/types"));
37
38
  const styleProps_1 = require("./styleProps");
38
39
  const traverse_1 = __importDefault(require("@babel/traverse"));
@@ -49,7 +50,13 @@ availableComponents.add('Section');
49
50
  // Don't update v3 Provider
50
51
  availableComponents.delete('Provider');
51
52
  function transformer(file, api, options) {
52
- let j = api.jscodeshift;
53
+ let j = api.jscodeshift.withParser({
54
+ parse(source) {
55
+ return (0, recast_1.parse)(source, {
56
+ parser: require('recast/parsers/babel')
57
+ });
58
+ }
59
+ });
53
60
  let root = j(file.source);
54
61
  let componentsToTransform = options.components ? new Set(options.components.split(',').filter(s => availableComponents.has(s))) : availableComponents;
55
62
  let bindings = [];
@@ -60,7 +67,7 @@ function transformer(file, api, options) {
60
67
  const leadingComments = root.find(j.Program).get('body', 0).node.leadingComments;
61
68
  (0, traverse_1.default)(root.paths()[0].node, {
62
69
  ImportDeclaration(path) {
63
- if (path.node.source.value === '@adobe/react-spectrum' || path.node.source.value.startsWith('@react-spectrum/')) {
70
+ if (path.node.source.value === '@adobe/react-spectrum' || (path.node.source.value.startsWith('@react-spectrum/') && path.node.source.value !== '@react-spectrum/s2')) {
64
71
  lastImportPath = path;
65
72
  for (let specifier of path.node.specifiers) {
66
73
  if (specifier.type === 'ImportNamespaceSpecifier') {
@@ -267,4 +274,3 @@ function transformer(file, api, options) {
267
274
  root.find(j.Program).get('body', 0).node.comments = leadingComments;
268
275
  return root.toSource().replace(/assert\s*\{\s*type:\s*"macro"\s*\}/g, 'with { type: "macro" }');
269
276
  }
270
- transformer.parser = 'tsx';
@@ -8,6 +8,19 @@ const parser_1 = require("@babel/parser");
8
8
  const path = require('path');
9
9
  const fs_1 = require("fs");
10
10
  const traverse_1 = __importDefault(require("@babel/traverse"));
11
+ // These are exported but there are no codemods written for them yet.
12
+ // Don't replace imports yet.
13
+ const skipped = new Set([
14
+ 'Accordion',
15
+ 'Card',
16
+ 'CardView',
17
+ 'TableView',
18
+ 'TableHeader',
19
+ 'Column',
20
+ 'TableBody',
21
+ 'Row',
22
+ 'Cell'
23
+ ]);
11
24
  function getComponents() {
12
25
  // Determine list of available components in S2 from index.ts
13
26
  let availableComponents = new Set();
@@ -18,7 +31,10 @@ function getComponents() {
18
31
  ExportNamedDeclaration(path) {
19
32
  if (path.node.exportKind === 'value') {
20
33
  for (let specifier of path.node.specifiers) {
21
- availableComponents.add(specifier.exported.type === 'Identifier' ? specifier.exported.name : specifier.exported.value);
34
+ let name = specifier.exported.type === 'Identifier' ? specifier.exported.name : specifier.exported.value;
35
+ if (!skipped.has(name)) {
36
+ availableComponents.add(name);
37
+ }
22
38
  }
23
39
  }
24
40
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@react-spectrum/codemods",
3
- "version": "3.0.0-nightly-e60fb427c-240930",
3
+ "version": "3.0.0-nightly-4818630a7-241002",
4
4
  "main": "dist/index.js",
5
5
  "source": "src/index.ts",
6
6
  "bin": "dist/index.js",
@@ -24,8 +24,8 @@
24
24
  "@babel/parser": "^7.24.5",
25
25
  "@babel/traverse": "^7.24.5",
26
26
  "@babel/types": "^7.24.5",
27
- "@react-spectrum/s2": "^3.0.0-nightly-e60fb427c-240930",
28
- "@react-types/shared": "^3.0.0-nightly-e60fb427c-240930",
27
+ "@react-spectrum/s2": "^3.0.0-nightly-4818630a7-241002",
28
+ "@react-types/shared": "^3.0.0-nightly-4818630a7-241002",
29
29
  "@types/node": "^20",
30
30
  "boxen": "^5.1.2",
31
31
  "build": "^0.1.4",
@@ -33,6 +33,7 @@
33
33
  "execa": "^5.1.1",
34
34
  "jscodeshift": "^0.15.2",
35
35
  "react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0",
36
+ "recast": "^0.23.9",
36
37
  "ts-node": "^10.9.2",
37
38
  "uuid": "^9.0.1"
38
39
  },
@@ -47,5 +48,5 @@
47
48
  "publishConfig": {
48
49
  "access": "public"
49
50
  },
50
- "stableVersion": "0.1.1"
51
+ "stableVersion": "0.2.0"
51
52
  }