sb-mig 6.0.0-beta.1 → 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/dist/api-v2/discover/discover.js +3 -3
- package/dist/api-v2/precompile/precompile.d.ts +5 -1
- package/dist/api-v2/precompile/precompile.js +7 -4
- package/dist/utils/path-utils.d.ts +7 -4
- package/dist/utils/path-utils.js +11 -8
- package/dist-cjs/api-v2/discover/discover.js +2 -2
- package/dist-cjs/api-v2/precompile/precompile.js +7 -4
- package/dist-cjs/utils/path-utils.js +11 -8
- package/package.json +1 -1
|
@@ -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
|
-
//
|
|
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
|
/**
|
|
@@ -3,13 +3,16 @@ import path from "path";
|
|
|
3
3
|
import rollupSwc from "@rollup/plugin-swc";
|
|
4
4
|
import { rollup } from "rollup";
|
|
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
|
|
11
|
-
const
|
|
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
|
/**
|
|
@@ -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
|
-
*
|
|
9
|
-
*
|
|
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
|
-
*
|
|
13
|
-
*
|
|
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
|
/**
|
package/dist/utils/path-utils.js
CHANGED
|
@@ -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
|
-
*
|
|
10
|
-
*
|
|
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
|
-
*
|
|
14
|
-
*
|
|
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
|
-
|
|
18
|
-
const
|
|
19
|
-
const lastElement =
|
|
20
|
-
return lastElement.
|
|
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
|
-
//
|
|
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 {
|
|
@@ -11,13 +11,16 @@ const path_1 = __importDefault(require("path"));
|
|
|
11
11
|
const plugin_swc_1 = __importDefault(require("@rollup/plugin-swc"));
|
|
12
12
|
const rollup_1 = require("rollup");
|
|
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
|
|
19
|
-
const
|
|
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;
|
|
@@ -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
|
-
*
|
|
16
|
-
*
|
|
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
|
-
*
|
|
20
|
-
*
|
|
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
|
-
|
|
24
|
-
const
|
|
25
|
-
const lastElement =
|
|
26
|
-
return lastElement.
|
|
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