sb-mig 5.8.0 → 6.0.0-beta.2

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 CHANGED
@@ -13,7 +13,7 @@ If you've found an issue or you have feature request - <a href="https://github.c
13
13
 
14
14
  | | |
15
15
  | ---- | ------------ |
16
- | Node | LTS (18.x.x) |
16
+ | Node | 22.x.x or >=24.x.x |
17
17
 
18
18
  # 5.x.x version released!
19
19
 
@@ -32,7 +32,7 @@ If you've found an issue or you have feature request - <a href="https://github.c
32
32
 
33
33
  ## Breaking changes
34
34
 
35
- - Please note that sb-mig no longer extends support for Node versions older than 18.x.x, as part of its adoption of native ESM support.
35
+ - Please note that sb-mig no longer extends support for Node versions older than 22.x.x, as part of its adoption of native ESM support.
36
36
  - The sb-mig backup command has now been aligned with all other commands, causing minor changes in its execution (although functionalities have been preserved).
37
37
 
38
38
  Do not hesitate to get in touch if you encounter any issues or require further clarification on any points.
@@ -1,5 +1,5 @@
1
1
  import { readdir, stat, readFile, realpath } from "fs/promises";
2
- import { join, resolve } from "path";
2
+ import { join, resolve, sep } from "path";
3
3
  import { pathToFileURL } from "url";
4
4
  /**
5
5
  * Load the content of a resource file (.sb.js, .datasource.js, etc.)
@@ -81,8 +81,8 @@ async function isWithinProject(targetPath, projectRoot) {
81
81
  // Resolve both paths to handle symlinks
82
82
  const resolvedTarget = await realpath(targetPath);
83
83
  const resolvedRoot = await realpath(projectRoot);
84
- // Check if target is within project root
85
- return (resolvedTarget.startsWith(resolvedRoot + "/") ||
84
+ // Use the platform separator so this works on Windows (`\`) and POSIX (`/`).
85
+ return (resolvedTarget.startsWith(resolvedRoot + sep) ||
86
86
  resolvedTarget === resolvedRoot);
87
87
  }
88
88
  catch {
@@ -26,8 +26,12 @@ export interface PrecompileResult {
26
26
  }>;
27
27
  }
28
28
  /**
29
- * Extract the component name from a file path
29
+ * Extract the component name from a file path.
30
+ * Handles both POSIX (`/`) and Windows (`\`) separators because glob v11
31
+ * and node's `fs` APIs return native paths on Windows.
32
+ *
30
33
  * e.g., "/path/to/my-component.sb.ts" -> "my-component.sb"
34
+ * "C:\\path\\to\\my-component.sb.ts" -> "my-component.sb"
31
35
  */
32
36
  export declare const extractComponentName: (filePath: string) => string;
33
37
  /**
@@ -1,15 +1,18 @@
1
1
  import { mkdir, rm } from "fs/promises";
2
2
  import path from "path";
3
+ import rollupSwc from "@rollup/plugin-swc";
3
4
  import { rollup } from "rollup";
4
- import ts from "rollup-plugin-ts";
5
5
  /**
6
- * Extract the component name from a file path
6
+ * Extract the component name from a file path.
7
+ * Handles both POSIX (`/`) and Windows (`\`) separators because glob v11
8
+ * and node's `fs` APIs return native paths on Windows.
9
+ *
7
10
  * e.g., "/path/to/my-component.sb.ts" -> "my-component.sb"
11
+ * "C:\\path\\to\\my-component.sb.ts" -> "my-component.sb"
8
12
  */
9
13
  export const extractComponentName = (filePath) => {
10
- const separator = "/";
11
- const parts = filePath.split(separator);
12
- const lastElement = parts[parts.length - 1];
14
+ const normalized = filePath.replace(/\\/g, "/");
15
+ const lastElement = normalized.substring(normalized.lastIndexOf("/") + 1);
13
16
  return lastElement.replace(/\.ts$/, "");
14
17
  };
15
18
  /**
@@ -19,9 +22,14 @@ async function buildFile(inputPath, outputCjs, outputEsm) {
19
22
  const inputOptions = {
20
23
  input: inputPath,
21
24
  plugins: [
22
- ts({
23
- transpileOnly: true,
24
- transpiler: "swc",
25
+ rollupSwc({
26
+ swc: {
27
+ jsc: {
28
+ parser: {
29
+ syntax: "typescript",
30
+ },
31
+ },
32
+ },
25
33
  }),
26
34
  ],
27
35
  };
package/dist/cli/index.js CHANGED
File without changes
@@ -1,6 +1,6 @@
1
1
  import path from "path";
2
+ import rollupSwc from "@rollup/plugin-swc";
2
3
  import { remove } from "fs-extra";
3
- import ts from "rollup-plugin-ts";
4
4
  import storyblokConfig from "../config/config.js";
5
5
  import Logger from "../utils/logger.js";
6
6
  import { extractComponentName } from "../utils/path-utils.js";
@@ -24,9 +24,14 @@ export const buildOnTheFly = async ({ files }) => {
24
24
  const inputOptions = {
25
25
  input: filePath,
26
26
  plugins: [
27
- ts({
28
- transpileOnly: true,
29
- transpiler: "swc",
27
+ rollupSwc({
28
+ swc: {
29
+ jsc: {
30
+ parser: {
31
+ syntax: "typescript",
32
+ },
33
+ },
34
+ },
30
35
  }),
31
36
  ],
32
37
  };
@@ -5,12 +5,15 @@
5
5
  * Extracts the component name from a file path.
6
6
  * Used for naming compiled output files from TypeScript sources.
7
7
  *
8
- * @param filePath - Full path to the component file (always uses Unix-style separators from glob)
9
- * @returns Component name without the .ts extension
8
+ * Handles both POSIX (`/`) and Windows (`\`) separators because glob v11
9
+ * returns native paths on Windows.
10
+ *
11
+ * @param filePath - Full path to the component file
12
+ * @returns Component name without the trailing .ts extension
10
13
  *
11
14
  * @example
12
- * _extractComponentName("/Users/project/src/hero.sb.ts") // => "hero.sb"
13
- * _extractComponentName("C:/Users/project/src/card.sb.ts") // => "card.sb"
15
+ * extractComponentName("/Users/project/src/hero.sb.ts") // => "hero.sb"
16
+ * extractComponentName("C:\\Users\\project\\src\\card.sb.ts") // => "card.sb"
14
17
  */
15
18
  export declare const extractComponentName: (filePath: string) => string;
16
19
  /**
@@ -6,18 +6,21 @@ import path from "path";
6
6
  * Extracts the component name from a file path.
7
7
  * Used for naming compiled output files from TypeScript sources.
8
8
  *
9
- * @param filePath - Full path to the component file (always uses Unix-style separators from glob)
10
- * @returns Component name without the .ts extension
9
+ * Handles both POSIX (`/`) and Windows (`\`) separators because glob v11
10
+ * returns native paths on Windows.
11
+ *
12
+ * @param filePath - Full path to the component file
13
+ * @returns Component name without the trailing .ts extension
11
14
  *
12
15
  * @example
13
- * _extractComponentName("/Users/project/src/hero.sb.ts") // => "hero.sb"
14
- * _extractComponentName("C:/Users/project/src/card.sb.ts") // => "card.sb"
16
+ * extractComponentName("/Users/project/src/hero.sb.ts") // => "hero.sb"
17
+ * extractComponentName("C:\\Users\\project\\src\\card.sb.ts") // => "card.sb"
15
18
  */
16
19
  export const extractComponentName = (filePath) => {
17
- const separator = "/"; // glob always returns unix-style paths
18
- const sP = filePath.split(separator);
19
- const lastElement = sP[sP.length - 1];
20
- return lastElement.replaceAll(".ts", "");
20
+ // Normalize to forward slashes so basename works regardless of platform.
21
+ const normalized = filePath.replace(/\\/g, "/");
22
+ const lastElement = normalized.substring(normalized.lastIndexOf("/") + 1);
23
+ return lastElement.replace(/\.ts$/, "");
21
24
  };
22
25
  /**
23
26
  * Normalizes an array of directory segments for glob pattern usage.
@@ -121,8 +121,8 @@ async function isWithinProject(targetPath, projectRoot) {
121
121
  // Resolve both paths to handle symlinks
122
122
  const resolvedTarget = await (0, promises_1.realpath)(targetPath);
123
123
  const resolvedRoot = await (0, promises_1.realpath)(projectRoot);
124
- // Check if target is within project root
125
- return (resolvedTarget.startsWith(resolvedRoot + "/") ||
124
+ // Use the platform separator so this works on Windows (`\`) and POSIX (`/`).
125
+ return (resolvedTarget.startsWith(resolvedRoot + path_1.sep) ||
126
126
  resolvedTarget === resolvedRoot);
127
127
  }
128
128
  catch {
@@ -8,16 +8,19 @@ exports.precompile = precompile;
8
8
  exports.getCompiledPath = getCompiledPath;
9
9
  const promises_1 = require("fs/promises");
10
10
  const path_1 = __importDefault(require("path"));
11
+ const plugin_swc_1 = __importDefault(require("@rollup/plugin-swc"));
11
12
  const rollup_1 = require("rollup");
12
- const rollup_plugin_ts_1 = __importDefault(require("rollup-plugin-ts"));
13
13
  /**
14
- * Extract the component name from a file path
14
+ * Extract the component name from a file path.
15
+ * Handles both POSIX (`/`) and Windows (`\`) separators because glob v11
16
+ * and node's `fs` APIs return native paths on Windows.
17
+ *
15
18
  * e.g., "/path/to/my-component.sb.ts" -> "my-component.sb"
19
+ * "C:\\path\\to\\my-component.sb.ts" -> "my-component.sb"
16
20
  */
17
21
  const extractComponentName = (filePath) => {
18
- const separator = "/";
19
- const parts = filePath.split(separator);
20
- const lastElement = parts[parts.length - 1];
22
+ const normalized = filePath.replace(/\\/g, "/");
23
+ const lastElement = normalized.substring(normalized.lastIndexOf("/") + 1);
21
24
  return lastElement.replace(/\.ts$/, "");
22
25
  };
23
26
  exports.extractComponentName = extractComponentName;
@@ -28,9 +31,14 @@ async function buildFile(inputPath, outputCjs, outputEsm) {
28
31
  const inputOptions = {
29
32
  input: inputPath,
30
33
  plugins: [
31
- (0, rollup_plugin_ts_1.default)({
32
- transpileOnly: true,
33
- transpiler: "swc",
34
+ (0, plugin_swc_1.default)({
35
+ swc: {
36
+ jsc: {
37
+ parser: {
38
+ syntax: "typescript",
39
+ },
40
+ },
41
+ },
34
42
  }),
35
43
  ],
36
44
  };
@@ -12,18 +12,21 @@ const path_1 = __importDefault(require("path"));
12
12
  * Extracts the component name from a file path.
13
13
  * Used for naming compiled output files from TypeScript sources.
14
14
  *
15
- * @param filePath - Full path to the component file (always uses Unix-style separators from glob)
16
- * @returns Component name without the .ts extension
15
+ * Handles both POSIX (`/`) and Windows (`\`) separators because glob v11
16
+ * returns native paths on Windows.
17
+ *
18
+ * @param filePath - Full path to the component file
19
+ * @returns Component name without the trailing .ts extension
17
20
  *
18
21
  * @example
19
- * _extractComponentName("/Users/project/src/hero.sb.ts") // => "hero.sb"
20
- * _extractComponentName("C:/Users/project/src/card.sb.ts") // => "card.sb"
22
+ * extractComponentName("/Users/project/src/hero.sb.ts") // => "hero.sb"
23
+ * extractComponentName("C:\\Users\\project\\src\\card.sb.ts") // => "card.sb"
21
24
  */
22
25
  const extractComponentName = (filePath) => {
23
- const separator = "/"; // glob always returns unix-style paths
24
- const sP = filePath.split(separator);
25
- const lastElement = sP[sP.length - 1];
26
- return lastElement.replaceAll(".ts", "");
26
+ // Normalize to forward slashes so basename works regardless of platform.
27
+ const normalized = filePath.replace(/\\/g, "/");
28
+ const lastElement = normalized.substring(normalized.lastIndexOf("/") + 1);
29
+ return lastElement.replace(/\.ts$/, "");
27
30
  };
28
31
  exports.extractComponentName = extractComponentName;
29
32
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sb-mig",
3
- "version": "5.8.0",
3
+ "version": "6.0.0-beta.2",
4
4
  "description": "CLI to rule the world. (and handle stuff related to Storyblok CMS)",
5
5
  "author": "Marcin Krawczyk <marckraw@icloud.com>",
6
6
  "license": "MIT",
@@ -33,7 +33,7 @@
33
33
  "./dist/*": "./dist/*"
34
34
  },
35
35
  "engines": {
36
- "node": ">=20.0.0"
36
+ "node": "^22.0.0 || >=24.0.0"
37
37
  },
38
38
  "files": [
39
39
  "/dist",
@@ -73,6 +73,7 @@
73
73
  "test:all": "npm run test:unit && npm run test:api-live && npm run test:e2e"
74
74
  },
75
75
  "dependencies": {
76
+ "@rollup/plugin-swc": "^0.4.0",
76
77
  "@swc/core": "1.3.41",
77
78
  "@swc/helpers": "^0.5.18",
78
79
  "chalk": "^4.1.2",
@@ -84,11 +85,10 @@
84
85
  "ncp": "^2.0.0",
85
86
  "node-fetch": "^3.3.2",
86
87
  "rollup": "^3.28.0",
87
- "rollup-plugin-ts": "^3.4.4",
88
88
  "semver": "^7.6.2",
89
89
  "storyblok-js-client": "^7.2.1",
90
90
  "storyblok-schema-types": "^1.2.4",
91
- "typescript": "^5.1.6",
91
+ "typescript": "^5.9.3",
92
92
  "uuid": "^9.0.0"
93
93
  },
94
94
  "devDependencies": {
@@ -103,7 +103,7 @@
103
103
  "@storyblok/react": "^3.0.10",
104
104
  "@types/fs-extra": "^11.0.4",
105
105
  "@types/ncp": "^2.0.8",
106
- "@types/node": "^22.15.0",
106
+ "@types/node": "^24.12.2",
107
107
  "@types/uuid": "^10.0.0",
108
108
  "@typescript-eslint/eslint-plugin": "^6.4.1",
109
109
  "@typescript-eslint/parser": "^6.4.1",