@brynlabs/fusion-ui-codemod 0.0.0 → 1.0.0-alpha.208

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.
@@ -0,0 +1,7 @@
1
+ [
2
+ {
3
+ "name": "data-table-fixed-height",
4
+ "description": "DataTableCollection: replaces useWindowScroll by fixedHeight, the table scrolls with the page by default",
5
+ "version": "1.0.0-alpha.208"
6
+ }
7
+ ]
package/lib/registry.cjs CHANGED
@@ -1,71 +1,18 @@
1
1
  const fs = require("node:fs");
2
2
  const path = require("node:path");
3
- const {execFileSync} = require("node:child_process");
4
- const codemods = require("./codemods.cjs");
5
-
6
- const PACKAGE_DIR = path.join(__dirname, "..");
7
- const TAG_PREFIX = "fusion-ui-v";
8
- /** Written by the release (scripts/release.cjs), not committed */
9
- const VERSIONS_FILE = path.join(__dirname, "codemod-versions.json");
10
-
11
- const git = (cwd, args) =>
12
- execFileSync("git", args, {cwd, encoding: "utf8", stdio: ["ignore", "pipe", "ignore"]}).trim();
13
-
14
- /**
15
- * The first fusion-ui release containing the commit that added a transform: the oldest
16
- * `fusion-ui-v*` tag containing it, else `nextVersion` (the release being made, `null` in a
17
- * checkout outside of a release).
18
- */
19
- const releasedIn = (name, nextVersion = null, cwd = PACKAGE_DIR) => {
20
- let added = "";
21
- try {
22
- added = git(cwd, [
23
- "log",
24
- "--diff-filter=A",
25
- "--format=%H",
26
- "--",
27
- path.join(PACKAGE_DIR, "transforms", `${name}.cjs`),
28
- ])
29
- .split("\n")
30
- .filter(Boolean)
31
- .pop();
32
- } catch {
33
- return nextVersion;
34
- }
35
- if (!added) return nextVersion;
36
-
37
- // The release job installs no dependencies (no semver): the oldest tag is the first release,
38
- // also across branches (an alpha before the stable release)
39
- const tags = git(cwd, [
40
- "tag",
41
- "--contains",
42
- added,
43
- "--list",
44
- `${TAG_PREFIX}*`,
45
- "--sort=creatordate",
46
- ])
47
- .split("\n")
48
- .filter(Boolean)
49
- .map(tag => tag.slice(TAG_PREFIX.length));
50
- return tags[0] ?? nextVersion;
51
- };
52
3
 
53
4
  /**
54
- * The codemods with the fusion-ui version they belong to. An explicit `version` in codemods.cjs
55
- * wins (for a codemod added after its change was released), then the versions of the release,
56
- * else they are read from git; `null` for a codemod that wasn't released yet.
57
- *
58
- * @returns {{name: string, description: string, version: string | null}[]}
5
+ * All codemods, one transform in `transforms/<name>.cjs` each. `version` is the first fusion-ui
6
+ * version with the change; the release sets and commits it for codemods without one
7
+ * (scripts/release.cjs).
59
8
  */
60
- const loadCodemods = () => {
61
- const released = fs.existsSync(VERSIONS_FILE)
62
- ? JSON.parse(fs.readFileSync(VERSIONS_FILE, "utf8"))
63
- : null;
9
+ const CODEMODS_FILE = path.join(__dirname, "codemods.json");
64
10
 
65
- return codemods.map(codemod => ({
11
+ /** @returns {{name: string, description: string, version: string | null}[]} */
12
+ const loadCodemods = () =>
13
+ JSON.parse(fs.readFileSync(CODEMODS_FILE, "utf8")).map(codemod => ({
66
14
  ...codemod,
67
- version: codemod.version ?? (released ? released[codemod.name] : releasedIn(codemod.name)),
15
+ version: codemod.version ?? null,
68
16
  }));
69
- };
70
17
 
71
- module.exports = {loadCodemods, releasedIn, VERSIONS_FILE};
18
+ module.exports = {loadCodemods, CODEMODS_FILE};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@brynlabs/fusion-ui-codemod",
3
- "version": "0.0.0",
3
+ "version": "1.0.0-alpha.208",
4
4
  "description": "Codemods for upgrading projects that use @brynlabs/fusion-ui",
5
5
  "author": "The brynlabs.com team",
6
6
  "repository": {
@@ -20,7 +20,7 @@
20
20
  "files": [
21
21
  "bin",
22
22
  "lib/*.cjs",
23
- "lib/codemod-versions.json",
23
+ "lib/*.json",
24
24
  "transforms/*.cjs",
25
25
  "!**/*.test.cjs",
26
26
  "README.md"
package/lib/codemods.cjs DELETED
@@ -1,15 +0,0 @@
1
- /**
2
- * All codemods, one transform in `transforms/<name>.cjs` each. The fusion-ui version a codemod
3
- * belongs to is the first release containing it, set by the release (see registry.cjs). Give a
4
- * `version` only to a codemod added after its breaking change was released: the first fusion-ui
5
- * version with that change.
6
- *
7
- * @type {{name: string, description: string, version?: string}[]}
8
- */
9
- module.exports = [
10
- {
11
- name: "data-table-fixed-height",
12
- description:
13
- "DataTableCollection: replaces useWindowScroll by fixedHeight, the table scrolls with the page by default",
14
- },
15
- ];