@brynlabs/fusion-ui-codemod 1.0.0-alpha.208 → 1.0.0-alpha.209
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 +1 -0
- package/lib/git.cjs +24 -1
- package/lib/run.cjs +4 -3
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -40,5 +40,6 @@ The paths default to the current directory; `node_modules`, `.next`, `dist`, `bu
|
|
|
40
40
|
| Codemod | |
|
|
41
41
|
| --- | --- |
|
|
42
42
|
| `data-table-fixed-height` | `DataTableCollection` scrolls with the page by default: adds `fixedHeight` where `useWindowScroll` was missing or `false`, removes `useWindowScroll` where it was set, negates expressions. Reports `useWindowScroll` in objects |
|
|
43
|
+
| `data-table-collection` | Replaces the deprecated `DataTable` by a `Tile` with a `CollectionHeader` (`{...table.header}`, search, filters, `buttons`, `modalText.filterView`) and a `DataTableCollection fixedHeight` (the other props, `modalText.errorMessages` and the columns texts). Reports tables whose props come from other spreads or expressions, `storageId` (visible columns now stored by the hook's `storageId`) and references of `DataTable` / `DataTableProps` outside of JSX |
|
|
43
44
|
|
|
44
45
|
`npx @brynlabs/fusion-ui-codemod list` shows the fusion-ui version of every codemod.
|
package/lib/git.cjs
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
const fs = require("node:fs");
|
|
1
2
|
const path = require("node:path");
|
|
2
3
|
const {execFileSync} = require("node:child_process");
|
|
3
4
|
|
|
@@ -30,4 +31,26 @@ const changedFiles = repositoryRoot =>
|
|
|
30
31
|
// "XY path" or "XY old -> new"
|
|
31
32
|
.map(line => line.slice(3).split(" -> ").pop().replace(/^"|"$/g, ""));
|
|
32
33
|
|
|
33
|
-
|
|
34
|
+
/**
|
|
35
|
+
* The files below `paths` that git doesn't ignore (committed or not), relative to `cwd`; `null`
|
|
36
|
+
* outside of a repository. Git applies the ignore files itself (nested ones, negations like
|
|
37
|
+
* `!.yarn/patches`, `.git/info/exclude`, the global excludes file)
|
|
38
|
+
*/
|
|
39
|
+
const listFiles = (cwd, paths) => {
|
|
40
|
+
if (root(cwd) === null) return null;
|
|
41
|
+
const output = run(cwd, [
|
|
42
|
+
"ls-files",
|
|
43
|
+
"-z",
|
|
44
|
+
"--cached",
|
|
45
|
+
"--others",
|
|
46
|
+
"--exclude-standard",
|
|
47
|
+
"--",
|
|
48
|
+
...paths,
|
|
49
|
+
]);
|
|
50
|
+
// Unmerged files are listed once per stage, deleted ones are still in the index
|
|
51
|
+
return [...new Set(output.split("\0").filter(Boolean))].filter(file =>
|
|
52
|
+
fs.existsSync(path.join(cwd, file)),
|
|
53
|
+
);
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
module.exports = {root, showHead, changedFiles, listFiles};
|
package/lib/run.cjs
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
const path = require("node:path");
|
|
2
2
|
// Not part of the public API of jscodeshift, but the way to run it in-process (as @next/codemod does)
|
|
3
3
|
const Runner = require("jscodeshift/src/Runner");
|
|
4
|
+
const git = require("./git.cjs");
|
|
4
5
|
|
|
5
6
|
const TRANSFORMS = path.join(__dirname, "..", "transforms");
|
|
6
7
|
|
|
@@ -10,12 +11,12 @@ const TRANSFORMS = path.join(__dirname, "..", "transforms");
|
|
|
10
11
|
* @returns {Promise<{ok: number, nochange: number, skip: number, error: number}>}
|
|
11
12
|
*/
|
|
12
13
|
const runCodemod = (name, paths, {dry = false, print = false, verbose = false} = {}) =>
|
|
13
|
-
|
|
14
|
+
// Git selects the files: the gitignore option of jscodeshift reads only the .gitignore of the
|
|
15
|
+
// current directory (and fails without one) and ignores everything after a negated pattern
|
|
16
|
+
Runner.run(path.join(TRANSFORMS, `${name}.cjs`), git.listFiles(process.cwd(), paths) ?? paths, {
|
|
14
17
|
parser: "tsx",
|
|
15
18
|
extensions: "tsx,ts,jsx,js,mjs,cjs",
|
|
16
19
|
ignorePattern: ["**/node_modules/**", "**/.next/**", "**/dist/**", "**/build/**", "**/out/**"],
|
|
17
|
-
// Respect .gitignore like the project's own tools
|
|
18
|
-
gitignore: true,
|
|
19
20
|
// The transforms are plain CommonJS
|
|
20
21
|
babel: false,
|
|
21
22
|
dry,
|
package/package.json
CHANGED