@stryke/path 0.24.4 → 0.25.1
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/CHANGELOG.md +20 -0
- package/dist/append.cjs +59 -1
- package/dist/append.mjs +57 -1
- package/dist/append.mjs.map +1 -1
- package/dist/asset-extensions.cjs +40 -1
- package/dist/asset-extensions.mjs +39 -1
- package/dist/asset-extensions.mjs.map +1 -1
- package/dist/common.cjs +34 -1
- package/dist/common.mjs +34 -1
- package/dist/common.mjs.map +1 -1
- package/dist/correct-path.cjs +176 -1
- package/dist/correct-path.mjs +169 -1
- package/dist/correct-path.mjs.map +1 -1
- package/dist/cwd.cjs +17 -1
- package/dist/cwd.mjs +16 -1
- package/dist/cwd.mjs.map +1 -1
- package/dist/delimiter.cjs +27 -1
- package/dist/delimiter.mjs +24 -1
- package/dist/delimiter.mjs.map +1 -1
- package/dist/file-path-fns.cjs +332 -1
- package/dist/file-path-fns.mjs +311 -1
- package/dist/file-path-fns.mjs.map +1 -1
- package/dist/find.cjs +24 -1
- package/dist/find.mjs +3 -1
- package/dist/glob-to-regex.cjs +97 -0
- package/dist/glob-to-regex.d.cts +50 -0
- package/dist/glob-to-regex.d.cts.map +1 -0
- package/dist/glob-to-regex.d.mts +50 -0
- package/dist/glob-to-regex.d.mts.map +1 -0
- package/dist/glob-to-regex.mjs +98 -0
- package/dist/glob-to-regex.mjs.map +1 -0
- package/dist/index.cjs +73 -1
- package/dist/index.d.cts +2 -1
- package/dist/index.d.mts +2 -1
- package/dist/index.mjs +17 -1
- package/dist/is-parent-path.cjs +32 -1
- package/dist/is-parent-path.mjs +32 -1
- package/dist/is-parent-path.mjs.map +1 -1
- package/dist/is-root-dir.cjs +14 -1
- package/dist/is-root-dir.mjs +13 -1
- package/dist/is-root-dir.mjs.map +1 -1
- package/dist/is-type.cjs +92 -1
- package/dist/is-type.mjs +87 -1
- package/dist/is-type.mjs.map +1 -1
- package/dist/join-paths.cjs +108 -1
- package/dist/join-paths.mjs +107 -1
- package/dist/join-paths.mjs.map +1 -1
- package/dist/join.cjs +4 -1
- package/dist/join.mjs +3 -1
- package/dist/normalize.cjs +10 -1
- package/dist/normalize.mjs +3 -1
- package/dist/regex.cjs +20 -1
- package/dist/regex.mjs +12 -1
- package/dist/regex.mjs.map +1 -1
- package/dist/replace.cjs +44 -1
- package/dist/replace.mjs +43 -1
- package/dist/replace.mjs.map +1 -1
- package/dist/resolve-parent-path.cjs +18 -1
- package/dist/resolve-parent-path.mjs +18 -1
- package/dist/resolve-parent-path.mjs.map +1 -1
- package/dist/slash.cjs +27 -1
- package/dist/slash.mjs +26 -1
- package/dist/slash.mjs.map +1 -1
- package/dist/type-checks/src/is-empty.cjs +20 -1
- package/dist/type-checks/src/is-empty.mjs +20 -1
- package/dist/type-checks/src/is-empty.mjs.map +1 -1
- package/dist/type-checks/src/is-null.cjs +12 -1
- package/dist/type-checks/src/is-null.mjs +11 -1
- package/dist/type-checks/src/is-null.mjs.map +1 -1
- package/dist/type-checks/src/is-set-string.cjs +20 -1
- package/dist/type-checks/src/is-set-string.mjs +20 -1
- package/dist/type-checks/src/is-set-string.mjs.map +1 -1
- package/dist/type-checks/src/is-set.cjs +19 -1
- package/dist/type-checks/src/is-set.mjs +19 -1
- package/dist/type-checks/src/is-set.mjs.map +1 -1
- package/dist/type-checks/src/is-string.cjs +12 -1
- package/dist/type-checks/src/is-string.mjs +11 -1
- package/dist/type-checks/src/is-string.mjs.map +1 -1
- package/dist/type-checks/src/is-undefined.cjs +8 -1
- package/dist/type-checks/src/is-undefined.mjs +7 -1
- package/dist/type-checks/src/is-undefined.mjs.map +1 -1
- package/dist/types/src/base.cjs +6 -1
- package/dist/types/src/base.mjs +5 -1
- package/dist/types/src/base.mjs.map +1 -1
- package/package.json +9 -5
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,26 @@
|
|
|
2
2
|
|
|
3
3
|
# Changelog for Stryke - Path
|
|
4
4
|
|
|
5
|
+
## [0.25.0](https://github.com/storm-software/stryke/releases/tag/path%400.25.0) (01/16/2026)
|
|
6
|
+
|
|
7
|
+
### Features
|
|
8
|
+
|
|
9
|
+
- **path:** Added the `globToRegex` helper function
|
|
10
|
+
([92a54213](https://github.com/storm-software/stryke/commit/92a54213))
|
|
11
|
+
|
|
12
|
+
## [0.24.4](https://github.com/storm-software/stryke/releases/tag/path%400.24.4) (01/16/2026)
|
|
13
|
+
|
|
14
|
+
### Bug Fixes
|
|
15
|
+
|
|
16
|
+
- **path:** Resolve issue with missing slash in `stripStars` result
|
|
17
|
+
([04b17455](https://github.com/storm-software/stryke/commit/04b17455))
|
|
18
|
+
|
|
19
|
+
### Updated Dependencies
|
|
20
|
+
|
|
21
|
+
- Updated **type-checks** to **v0.5.18**
|
|
22
|
+
- Updated **convert** to **v0.6.33**
|
|
23
|
+
- Updated **types** to **v0.10.32**
|
|
24
|
+
|
|
5
25
|
## [0.24.3](https://github.com/storm-software/stryke/releases/tag/path%400.24.3) (01/15/2026)
|
|
6
26
|
|
|
7
27
|
### Updated Dependencies
|
package/dist/append.cjs
CHANGED
|
@@ -1 +1,59 @@
|
|
|
1
|
-
const
|
|
1
|
+
const require_cwd = require('./cwd.cjs');
|
|
2
|
+
const require_slash = require('./slash.cjs');
|
|
3
|
+
const require_is_parent_path = require('./is-parent-path.cjs');
|
|
4
|
+
const require_join_paths = require('./join-paths.cjs');
|
|
5
|
+
|
|
6
|
+
//#region src/append.ts
|
|
7
|
+
/**
|
|
8
|
+
* If not already a parent path, append the base path from the beginning of the given child path.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```ts
|
|
12
|
+
* appendPath("src/index.ts", "/home/user/project");
|
|
13
|
+
* // returns "/home/user/project/src/index.ts"
|
|
14
|
+
*
|
|
15
|
+
* appendPath("/user/dev/app.ts", "/user/dev");
|
|
16
|
+
* // returns "/user/dev/app.ts"
|
|
17
|
+
*
|
|
18
|
+
* appendPath("docs/readme.md");
|
|
19
|
+
* // returns "<current_working_directory>/docs/readme.md"
|
|
20
|
+
*
|
|
21
|
+
* appendPath("src/index.ts", "/home/user/project", { skipIfAlreadyParent: false });
|
|
22
|
+
* // returns "/home/user/project/src/index.ts"
|
|
23
|
+
*
|
|
24
|
+
* appendPath("/home/user/project/src/index.ts", "/home/user/project", { skipIfAlreadyParent: false });
|
|
25
|
+
* // returns "/home/user/project/src/index.ts"
|
|
26
|
+
* ```
|
|
27
|
+
*
|
|
28
|
+
* @param childPath - The child path to append to the {@link parentPath}
|
|
29
|
+
* @param parentPath - The parent path to add the {@link childPath} to
|
|
30
|
+
* @param options - Options for appending the path
|
|
31
|
+
* @returns The {@link parentPath} with the {@link childPath} appended
|
|
32
|
+
*/
|
|
33
|
+
function appendPath(childPath, parentPath = require_cwd.cwd(), options = {}) {
|
|
34
|
+
return require_slash.slash(options.skipIfAlreadyParent !== false && require_is_parent_path.isParentPath(childPath, parentPath) ? childPath : require_join_paths.joinPaths(parentPath, childPath));
|
|
35
|
+
}
|
|
36
|
+
const append = appendPath;
|
|
37
|
+
/**
|
|
38
|
+
* Append the extension to the given path.
|
|
39
|
+
*
|
|
40
|
+
* @example
|
|
41
|
+
* ```ts
|
|
42
|
+
* appendExtension("/home/user/project/src/index", ".ts");
|
|
43
|
+
* // returns "/home/user/project/src/index.ts"
|
|
44
|
+
* appendExtension("/home/user/project/src/index.ts", ".js");
|
|
45
|
+
* // returns "/home/user/project/src/index.ts.js"
|
|
46
|
+
* ```
|
|
47
|
+
*
|
|
48
|
+
* @param path - The path to append the extension to.
|
|
49
|
+
* @param extension - The extension to append.
|
|
50
|
+
* @returns The path with the appended extension.
|
|
51
|
+
*/
|
|
52
|
+
function appendExtension(path, extension) {
|
|
53
|
+
return `${path}.${extension.replace(/^\./, "")}`;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
//#endregion
|
|
57
|
+
exports.append = append;
|
|
58
|
+
exports.appendExtension = appendExtension;
|
|
59
|
+
exports.appendPath = appendPath;
|
package/dist/append.mjs
CHANGED
|
@@ -1,2 +1,58 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import { cwd } from "./cwd.mjs";
|
|
2
|
+
import { slash } from "./slash.mjs";
|
|
3
|
+
import { isParentPath } from "./is-parent-path.mjs";
|
|
4
|
+
import { joinPaths } from "./join-paths.mjs";
|
|
5
|
+
|
|
6
|
+
//#region src/append.ts
|
|
7
|
+
/**
|
|
8
|
+
* If not already a parent path, append the base path from the beginning of the given child path.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```ts
|
|
12
|
+
* appendPath("src/index.ts", "/home/user/project");
|
|
13
|
+
* // returns "/home/user/project/src/index.ts"
|
|
14
|
+
*
|
|
15
|
+
* appendPath("/user/dev/app.ts", "/user/dev");
|
|
16
|
+
* // returns "/user/dev/app.ts"
|
|
17
|
+
*
|
|
18
|
+
* appendPath("docs/readme.md");
|
|
19
|
+
* // returns "<current_working_directory>/docs/readme.md"
|
|
20
|
+
*
|
|
21
|
+
* appendPath("src/index.ts", "/home/user/project", { skipIfAlreadyParent: false });
|
|
22
|
+
* // returns "/home/user/project/src/index.ts"
|
|
23
|
+
*
|
|
24
|
+
* appendPath("/home/user/project/src/index.ts", "/home/user/project", { skipIfAlreadyParent: false });
|
|
25
|
+
* // returns "/home/user/project/src/index.ts"
|
|
26
|
+
* ```
|
|
27
|
+
*
|
|
28
|
+
* @param childPath - The child path to append to the {@link parentPath}
|
|
29
|
+
* @param parentPath - The parent path to add the {@link childPath} to
|
|
30
|
+
* @param options - Options for appending the path
|
|
31
|
+
* @returns The {@link parentPath} with the {@link childPath} appended
|
|
32
|
+
*/
|
|
33
|
+
function appendPath(childPath, parentPath = cwd(), options = {}) {
|
|
34
|
+
return slash(options.skipIfAlreadyParent !== false && isParentPath(childPath, parentPath) ? childPath : joinPaths(parentPath, childPath));
|
|
35
|
+
}
|
|
36
|
+
const append = appendPath;
|
|
37
|
+
/**
|
|
38
|
+
* Append the extension to the given path.
|
|
39
|
+
*
|
|
40
|
+
* @example
|
|
41
|
+
* ```ts
|
|
42
|
+
* appendExtension("/home/user/project/src/index", ".ts");
|
|
43
|
+
* // returns "/home/user/project/src/index.ts"
|
|
44
|
+
* appendExtension("/home/user/project/src/index.ts", ".js");
|
|
45
|
+
* // returns "/home/user/project/src/index.ts.js"
|
|
46
|
+
* ```
|
|
47
|
+
*
|
|
48
|
+
* @param path - The path to append the extension to.
|
|
49
|
+
* @param extension - The extension to append.
|
|
50
|
+
* @returns The path with the appended extension.
|
|
51
|
+
*/
|
|
52
|
+
function appendExtension(path, extension) {
|
|
53
|
+
return `${path}.${extension.replace(/^\./, "")}`;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
//#endregion
|
|
57
|
+
export { append, appendExtension, appendPath };
|
|
2
58
|
//# sourceMappingURL=append.mjs.map
|
package/dist/append.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"append.mjs","names":[],"sources":["../src/append.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/stryke.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://docs.stormsoftware.com/projects/stryke\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { cwd } from \"./cwd\";\nimport { isParentPath } from \"./is-parent-path\";\nimport { joinPaths } from \"./join-paths\";\nimport { slash } from \"./slash\";\n\nexport interface AppendPathOptions {\n /**\n * If `true`, the function will skip appending if the `childPath` is already a child of the `parentPath`.\n *\n * @defaultValue true\n */\n skipIfAlreadyParent?: boolean;\n}\n\n/**\n * If not already a parent path, append the base path from the beginning of the given child path.\n *\n * @example\n * ```ts\n * appendPath(\"src/index.ts\", \"/home/user/project\");\n * // returns \"/home/user/project/src/index.ts\"\n *\n * appendPath(\"/user/dev/app.ts\", \"/user/dev\");\n * // returns \"/user/dev/app.ts\"\n *\n * appendPath(\"docs/readme.md\");\n * // returns \"<current_working_directory>/docs/readme.md\"\n *\n * appendPath(\"src/index.ts\", \"/home/user/project\", { skipIfAlreadyParent: false });\n * // returns \"/home/user/project/src/index.ts\"\n *\n * appendPath(\"/home/user/project/src/index.ts\", \"/home/user/project\", { skipIfAlreadyParent: false });\n * // returns \"/home/user/project/src/index.ts\"\n * ```\n *\n * @param childPath - The child path to append to the {@link parentPath}\n * @param parentPath - The parent path to add the {@link childPath} to\n * @param options - Options for appending the path\n * @returns The {@link parentPath} with the {@link childPath} appended\n */\nexport function appendPath(\n childPath: string,\n parentPath: string = cwd(),\n options: AppendPathOptions = {}\n): string {\n return slash(\n options.skipIfAlreadyParent !== false && isParentPath(childPath, parentPath)\n ? childPath\n : joinPaths(parentPath, childPath)\n );\n}\n\nexport const append = appendPath;\n\n/**\n * Append the extension to the given path.\n *\n * @example\n * ```ts\n * appendExtension(\"/home/user/project/src/index\", \".ts\");\n * // returns \"/home/user/project/src/index.ts\"\n * appendExtension(\"/home/user/project/src/index.ts\", \".js\");\n * // returns \"/home/user/project/src/index.ts.js\"\n * ```\n *\n * @param path - The path to append the extension to.\n * @param extension - The extension to append.\n * @returns The path with the appended extension.\n */\nexport function appendExtension(path: string, extension: string): string {\n return `${path}.${extension.replace(/^\\./, \"\")}`;\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"append.mjs","names":[],"sources":["../src/append.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/stryke.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://docs.stormsoftware.com/projects/stryke\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { cwd } from \"./cwd\";\nimport { isParentPath } from \"./is-parent-path\";\nimport { joinPaths } from \"./join-paths\";\nimport { slash } from \"./slash\";\n\nexport interface AppendPathOptions {\n /**\n * If `true`, the function will skip appending if the `childPath` is already a child of the `parentPath`.\n *\n * @defaultValue true\n */\n skipIfAlreadyParent?: boolean;\n}\n\n/**\n * If not already a parent path, append the base path from the beginning of the given child path.\n *\n * @example\n * ```ts\n * appendPath(\"src/index.ts\", \"/home/user/project\");\n * // returns \"/home/user/project/src/index.ts\"\n *\n * appendPath(\"/user/dev/app.ts\", \"/user/dev\");\n * // returns \"/user/dev/app.ts\"\n *\n * appendPath(\"docs/readme.md\");\n * // returns \"<current_working_directory>/docs/readme.md\"\n *\n * appendPath(\"src/index.ts\", \"/home/user/project\", { skipIfAlreadyParent: false });\n * // returns \"/home/user/project/src/index.ts\"\n *\n * appendPath(\"/home/user/project/src/index.ts\", \"/home/user/project\", { skipIfAlreadyParent: false });\n * // returns \"/home/user/project/src/index.ts\"\n * ```\n *\n * @param childPath - The child path to append to the {@link parentPath}\n * @param parentPath - The parent path to add the {@link childPath} to\n * @param options - Options for appending the path\n * @returns The {@link parentPath} with the {@link childPath} appended\n */\nexport function appendPath(\n childPath: string,\n parentPath: string = cwd(),\n options: AppendPathOptions = {}\n): string {\n return slash(\n options.skipIfAlreadyParent !== false && isParentPath(childPath, parentPath)\n ? childPath\n : joinPaths(parentPath, childPath)\n );\n}\n\nexport const append = appendPath;\n\n/**\n * Append the extension to the given path.\n *\n * @example\n * ```ts\n * appendExtension(\"/home/user/project/src/index\", \".ts\");\n * // returns \"/home/user/project/src/index.ts\"\n * appendExtension(\"/home/user/project/src/index.ts\", \".js\");\n * // returns \"/home/user/project/src/index.ts.js\"\n * ```\n *\n * @param path - The path to append the extension to.\n * @param extension - The extension to append.\n * @returns The path with the appended extension.\n */\nexport function appendExtension(path: string, extension: string): string {\n return `${path}.${extension.replace(/^\\./, \"\")}`;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0DA,SAAgB,WACd,WACA,aAAqB,KAAK,EAC1B,UAA6B,EAAE,EACvB;AACR,QAAO,MACL,QAAQ,wBAAwB,SAAS,aAAa,WAAW,WAAW,GACxE,YACA,UAAU,YAAY,UAAU,CACrC;;AAGH,MAAa,SAAS;;;;;;;;;;;;;;;;AAiBtB,SAAgB,gBAAgB,MAAc,WAA2B;AACvE,QAAO,GAAG,KAAK,GAAG,UAAU,QAAQ,OAAO,GAAG"}
|
|
@@ -1 +1,40 @@
|
|
|
1
|
-
|
|
1
|
+
|
|
2
|
+
//#region src/asset-extensions.ts
|
|
3
|
+
/**
|
|
4
|
+
* Default asset extensions
|
|
5
|
+
*
|
|
6
|
+
* @remarks
|
|
7
|
+
* For more info please see the {@link https://github.com/facebook/metro/blob/v0.80.10/packages/metro-config/src/defaults/defaults.js#L18-L52 | Metro defaults}
|
|
8
|
+
*/
|
|
9
|
+
const DEFAULT_ASSET_EXTS = [
|
|
10
|
+
"bmp",
|
|
11
|
+
"gif",
|
|
12
|
+
"jpg",
|
|
13
|
+
"jpeg",
|
|
14
|
+
"png",
|
|
15
|
+
"psd",
|
|
16
|
+
"svg",
|
|
17
|
+
"webp",
|
|
18
|
+
"m4v",
|
|
19
|
+
"mov",
|
|
20
|
+
"mp4",
|
|
21
|
+
"mpeg",
|
|
22
|
+
"mpg",
|
|
23
|
+
"webm",
|
|
24
|
+
"aac",
|
|
25
|
+
"aiff",
|
|
26
|
+
"caf",
|
|
27
|
+
"m4a",
|
|
28
|
+
"mp3",
|
|
29
|
+
"wav",
|
|
30
|
+
"html",
|
|
31
|
+
"pdf",
|
|
32
|
+
"yaml",
|
|
33
|
+
"yml",
|
|
34
|
+
"otf",
|
|
35
|
+
"ttf",
|
|
36
|
+
"zip"
|
|
37
|
+
];
|
|
38
|
+
|
|
39
|
+
//#endregion
|
|
40
|
+
exports.DEFAULT_ASSET_EXTS = DEFAULT_ASSET_EXTS;
|
|
@@ -1,2 +1,40 @@
|
|
|
1
|
-
|
|
1
|
+
//#region src/asset-extensions.ts
|
|
2
|
+
/**
|
|
3
|
+
* Default asset extensions
|
|
4
|
+
*
|
|
5
|
+
* @remarks
|
|
6
|
+
* For more info please see the {@link https://github.com/facebook/metro/blob/v0.80.10/packages/metro-config/src/defaults/defaults.js#L18-L52 | Metro defaults}
|
|
7
|
+
*/
|
|
8
|
+
const DEFAULT_ASSET_EXTS = [
|
|
9
|
+
"bmp",
|
|
10
|
+
"gif",
|
|
11
|
+
"jpg",
|
|
12
|
+
"jpeg",
|
|
13
|
+
"png",
|
|
14
|
+
"psd",
|
|
15
|
+
"svg",
|
|
16
|
+
"webp",
|
|
17
|
+
"m4v",
|
|
18
|
+
"mov",
|
|
19
|
+
"mp4",
|
|
20
|
+
"mpeg",
|
|
21
|
+
"mpg",
|
|
22
|
+
"webm",
|
|
23
|
+
"aac",
|
|
24
|
+
"aiff",
|
|
25
|
+
"caf",
|
|
26
|
+
"m4a",
|
|
27
|
+
"mp3",
|
|
28
|
+
"wav",
|
|
29
|
+
"html",
|
|
30
|
+
"pdf",
|
|
31
|
+
"yaml",
|
|
32
|
+
"yml",
|
|
33
|
+
"otf",
|
|
34
|
+
"ttf",
|
|
35
|
+
"zip"
|
|
36
|
+
];
|
|
37
|
+
|
|
38
|
+
//#endregion
|
|
39
|
+
export { DEFAULT_ASSET_EXTS };
|
|
2
40
|
//# sourceMappingURL=asset-extensions.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"asset-extensions.mjs","names":[],"sources":["../src/asset-extensions.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/stryke.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://docs.stormsoftware.com/projects/stryke\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\n/**\n * Default asset extensions\n *\n * @remarks\n * For more info please see the {@link https://github.com/facebook/metro/blob/v0.80.10/packages/metro-config/src/defaults/defaults.js#L18-L52 | Metro defaults}\n */\nexport const DEFAULT_ASSET_EXTS = [\n // Image formats\n \"bmp\",\n \"gif\",\n \"jpg\",\n \"jpeg\",\n \"png\",\n \"psd\",\n \"svg\",\n \"webp\",\n // Video formats\n \"m4v\",\n \"mov\",\n \"mp4\",\n \"mpeg\",\n \"mpg\",\n \"webm\",\n // Audio formats\n \"aac\",\n \"aiff\",\n \"caf\",\n \"m4a\",\n \"mp3\",\n \"wav\",\n // Document formats\n \"html\",\n \"pdf\",\n \"yaml\",\n \"yml\",\n // Font formats\n \"otf\",\n \"ttf\",\n // Archives (virtual files)\n \"zip\"\n];\n"],"mappings":"AAwBA,MAAa,
|
|
1
|
+
{"version":3,"file":"asset-extensions.mjs","names":[],"sources":["../src/asset-extensions.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/stryke.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://docs.stormsoftware.com/projects/stryke\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\n/**\n * Default asset extensions\n *\n * @remarks\n * For more info please see the {@link https://github.com/facebook/metro/blob/v0.80.10/packages/metro-config/src/defaults/defaults.js#L18-L52 | Metro defaults}\n */\nexport const DEFAULT_ASSET_EXTS = [\n // Image formats\n \"bmp\",\n \"gif\",\n \"jpg\",\n \"jpeg\",\n \"png\",\n \"psd\",\n \"svg\",\n \"webp\",\n // Video formats\n \"m4v\",\n \"mov\",\n \"mp4\",\n \"mpeg\",\n \"mpg\",\n \"webm\",\n // Audio formats\n \"aac\",\n \"aiff\",\n \"caf\",\n \"m4a\",\n \"mp3\",\n \"wav\",\n // Document formats\n \"html\",\n \"pdf\",\n \"yaml\",\n \"yml\",\n // Font formats\n \"otf\",\n \"ttf\",\n // Archives (virtual files)\n \"zip\"\n];\n"],"mappings":";;;;;;;AAwBA,MAAa,qBAAqB;CAEhC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CAEA;CACA;CACA;CACA;CACA;CACA;CAEA;CACA;CACA;CACA;CACA;CACA;CAEA;CACA;CACA;CACA;CAEA;CACA;CAEA;CACD"}
|
package/dist/common.cjs
CHANGED
|
@@ -1 +1,34 @@
|
|
|
1
|
-
const
|
|
1
|
+
const require_slash = require('./slash.cjs');
|
|
2
|
+
const require_correct_path = require('./correct-path.cjs');
|
|
3
|
+
|
|
4
|
+
//#region src/common.ts
|
|
5
|
+
/**
|
|
6
|
+
* Get the common path from an array of paths
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```ts
|
|
10
|
+
* commonPath(['/foo/bar/baz', '/foo/bar/qux', '/foo/bar/baz/quux']);
|
|
11
|
+
* // returns '/foo/bar'
|
|
12
|
+
*
|
|
13
|
+
* commonPath(['C:/foo/bar/baz', 'C:/foo/bar/qux', 'C:/foo/bar/baz/quux']);
|
|
14
|
+
* // returns 'C:/foo/bar'
|
|
15
|
+
* ```
|
|
16
|
+
*
|
|
17
|
+
* @param paths - The array of paths
|
|
18
|
+
* @returns The common path
|
|
19
|
+
*/
|
|
20
|
+
function commonPath(paths) {
|
|
21
|
+
const [first = "", ...remaining] = paths.map((path) => require_correct_path.correctPath(require_slash.slash(path)));
|
|
22
|
+
if (!first) return "";
|
|
23
|
+
if (remaining.length === 0) return first;
|
|
24
|
+
let endOfPrefix = first.split("/").length;
|
|
25
|
+
for (const path of remaining) {
|
|
26
|
+
const compare = path.split("/");
|
|
27
|
+
for (let i = 0; i < endOfPrefix; i++) if (compare[i] !== first.split("/")[i]) endOfPrefix = i;
|
|
28
|
+
if (endOfPrefix === 0) return "";
|
|
29
|
+
}
|
|
30
|
+
return require_correct_path.withoutTrailingSlash(first.split("/").slice(0, endOfPrefix).join("/"));
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
//#endregion
|
|
34
|
+
exports.commonPath = commonPath;
|
package/dist/common.mjs
CHANGED
|
@@ -1,2 +1,35 @@
|
|
|
1
|
-
import{slash
|
|
1
|
+
import { slash } from "./slash.mjs";
|
|
2
|
+
import { correctPath, withoutTrailingSlash } from "./correct-path.mjs";
|
|
3
|
+
|
|
4
|
+
//#region src/common.ts
|
|
5
|
+
/**
|
|
6
|
+
* Get the common path from an array of paths
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```ts
|
|
10
|
+
* commonPath(['/foo/bar/baz', '/foo/bar/qux', '/foo/bar/baz/quux']);
|
|
11
|
+
* // returns '/foo/bar'
|
|
12
|
+
*
|
|
13
|
+
* commonPath(['C:/foo/bar/baz', 'C:/foo/bar/qux', 'C:/foo/bar/baz/quux']);
|
|
14
|
+
* // returns 'C:/foo/bar'
|
|
15
|
+
* ```
|
|
16
|
+
*
|
|
17
|
+
* @param paths - The array of paths
|
|
18
|
+
* @returns The common path
|
|
19
|
+
*/
|
|
20
|
+
function commonPath(paths) {
|
|
21
|
+
const [first = "", ...remaining] = paths.map((path) => correctPath(slash(path)));
|
|
22
|
+
if (!first) return "";
|
|
23
|
+
if (remaining.length === 0) return first;
|
|
24
|
+
let endOfPrefix = first.split("/").length;
|
|
25
|
+
for (const path of remaining) {
|
|
26
|
+
const compare = path.split("/");
|
|
27
|
+
for (let i = 0; i < endOfPrefix; i++) if (compare[i] !== first.split("/")[i]) endOfPrefix = i;
|
|
28
|
+
if (endOfPrefix === 0) return "";
|
|
29
|
+
}
|
|
30
|
+
return withoutTrailingSlash(first.split("/").slice(0, endOfPrefix).join("/"));
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
//#endregion
|
|
34
|
+
export { commonPath };
|
|
2
35
|
//# sourceMappingURL=common.mjs.map
|
package/dist/common.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"common.mjs","names":[],"sources":["../src/common.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/stryke.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://docs.stormsoftware.com/projects/stryke\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { correctPath, withoutTrailingSlash } from \"./normalize\";\nimport { slash } from \"./slash\";\n\n/**\n * Get the common path from an array of paths\n *\n * @example\n * ```ts\n * commonPath(['/foo/bar/baz', '/foo/bar/qux', '/foo/bar/baz/quux']);\n * // returns '/foo/bar'\n *\n * commonPath(['C:/foo/bar/baz', 'C:/foo/bar/qux', 'C:/foo/bar/baz/quux']);\n * // returns 'C:/foo/bar'\n * ```\n *\n * @param paths - The array of paths\n * @returns The common path\n */\nexport function commonPath(paths: string[]): string {\n const [first = \"\", ...remaining] = paths.map(path =>\n correctPath(slash(path))\n );\n if (!first) {\n return \"\";\n }\n if (remaining.length === 0) {\n return first;\n }\n\n let endOfPrefix = first.split(\"/\").length;\n for (const path of remaining) {\n const compare = path.split(\"/\");\n for (let i = 0; i < endOfPrefix; i++) {\n if (compare[i] !== first.split(\"/\")[i]) {\n endOfPrefix = i;\n }\n }\n\n if (endOfPrefix === 0) {\n return \"\";\n }\n }\n\n return withoutTrailingSlash(first.split(\"/\").slice(0, endOfPrefix).join(\"/\"));\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"common.mjs","names":[],"sources":["../src/common.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/stryke.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://docs.stormsoftware.com/projects/stryke\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { correctPath, withoutTrailingSlash } from \"./normalize\";\nimport { slash } from \"./slash\";\n\n/**\n * Get the common path from an array of paths\n *\n * @example\n * ```ts\n * commonPath(['/foo/bar/baz', '/foo/bar/qux', '/foo/bar/baz/quux']);\n * // returns '/foo/bar'\n *\n * commonPath(['C:/foo/bar/baz', 'C:/foo/bar/qux', 'C:/foo/bar/baz/quux']);\n * // returns 'C:/foo/bar'\n * ```\n *\n * @param paths - The array of paths\n * @returns The common path\n */\nexport function commonPath(paths: string[]): string {\n const [first = \"\", ...remaining] = paths.map(path =>\n correctPath(slash(path))\n );\n if (!first) {\n return \"\";\n }\n if (remaining.length === 0) {\n return first;\n }\n\n let endOfPrefix = first.split(\"/\").length;\n for (const path of remaining) {\n const compare = path.split(\"/\");\n for (let i = 0; i < endOfPrefix; i++) {\n if (compare[i] !== first.split(\"/\")[i]) {\n endOfPrefix = i;\n }\n }\n\n if (endOfPrefix === 0) {\n return \"\";\n }\n }\n\n return withoutTrailingSlash(first.split(\"/\").slice(0, endOfPrefix).join(\"/\"));\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAoCA,SAAgB,WAAW,OAAyB;CAClD,MAAM,CAAC,QAAQ,IAAI,GAAG,aAAa,MAAM,KAAI,SAC3C,YAAY,MAAM,KAAK,CAAC,CACzB;AACD,KAAI,CAAC,MACH,QAAO;AAET,KAAI,UAAU,WAAW,EACvB,QAAO;CAGT,IAAI,cAAc,MAAM,MAAM,IAAI,CAAC;AACnC,MAAK,MAAM,QAAQ,WAAW;EAC5B,MAAM,UAAU,KAAK,MAAM,IAAI;AAC/B,OAAK,IAAI,IAAI,GAAG,IAAI,aAAa,IAC/B,KAAI,QAAQ,OAAO,MAAM,MAAM,IAAI,CAAC,GAClC,eAAc;AAIlB,MAAI,gBAAgB,EAClB,QAAO;;AAIX,QAAO,qBAAqB,MAAM,MAAM,IAAI,CAAC,MAAM,GAAG,YAAY,CAAC,KAAK,IAAI,CAAC"}
|
package/dist/correct-path.cjs
CHANGED
|
@@ -1 +1,176 @@
|
|
|
1
|
-
const
|
|
1
|
+
const require_cwd = require('./cwd.cjs');
|
|
2
|
+
const require_regex = require('./regex.cjs');
|
|
3
|
+
const require_is_type = require('./is-type.cjs');
|
|
4
|
+
const require_slash = require('./slash.cjs');
|
|
5
|
+
const require_join_paths = require('./join-paths.cjs');
|
|
6
|
+
const require_append = require('./append.cjs');
|
|
7
|
+
|
|
8
|
+
//#region src/correct-path.ts
|
|
9
|
+
function normalizeWindowsPath(input = "") {
|
|
10
|
+
if (!input) return input;
|
|
11
|
+
return require_slash.slash(input).replace(require_regex.DRIVE_LETTER_START_REGEX, (r) => r.toUpperCase());
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Corrects/normalized a file path.
|
|
15
|
+
*
|
|
16
|
+
* @param path - The path to correct.
|
|
17
|
+
* @returns The corrected path.
|
|
18
|
+
*/
|
|
19
|
+
function correctPath(path) {
|
|
20
|
+
if (!path || path.length === 0) return ".";
|
|
21
|
+
path = normalizeWindowsPath(path);
|
|
22
|
+
const isUNCPath = path.match(require_regex.UNC_REGEX);
|
|
23
|
+
const isPathAbsolute = require_is_type.isAbsolutePath(path);
|
|
24
|
+
const trailingSeparator = path.endsWith("/");
|
|
25
|
+
path = normalizeString(path, !isPathAbsolute);
|
|
26
|
+
if (path.length === 0) {
|
|
27
|
+
if (isPathAbsolute) return "/";
|
|
28
|
+
return trailingSeparator ? "./" : ".";
|
|
29
|
+
}
|
|
30
|
+
if (trailingSeparator) path += "/";
|
|
31
|
+
if (require_regex.DRIVE_LETTER_REGEX.test(path)) path += "/";
|
|
32
|
+
if (isUNCPath) {
|
|
33
|
+
if (!isPathAbsolute) return `//./${path}`;
|
|
34
|
+
return `//${path}`;
|
|
35
|
+
}
|
|
36
|
+
return !path.startsWith("/") && isPathAbsolute && !require_regex.DRIVE_LETTER_REGEX.test(path) ? `/${path}` : path;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Remove any star tokens (*) from the end of the file path
|
|
40
|
+
*
|
|
41
|
+
* @example
|
|
42
|
+
* stripStars("src/**") // returns "src"
|
|
43
|
+
* stripStars("src/*") // returns "src"
|
|
44
|
+
* stripStars("src/**\/*") // returns "src"
|
|
45
|
+
* stripStars("src/**\/*.txt") // returns "src"
|
|
46
|
+
* stripStars("src/**\/file.txt") // returns "src"
|
|
47
|
+
* stripStars("src/file.txt") // returns "src/file.txt"
|
|
48
|
+
* stripStars("") // returns "."
|
|
49
|
+
*
|
|
50
|
+
* @param path - The path to correct.
|
|
51
|
+
* @returns The corrected path.
|
|
52
|
+
*/
|
|
53
|
+
function stripStars(path) {
|
|
54
|
+
if (!path || path.length === 0) return ".";
|
|
55
|
+
path = correctPath(path);
|
|
56
|
+
let found = false;
|
|
57
|
+
return `${path.startsWith("/") ? "/" : ""}${path.split("/").reduce((ret, segment) => {
|
|
58
|
+
if (!segment?.trim()) return ret;
|
|
59
|
+
if (found || segment.includes("*")) {
|
|
60
|
+
found = true;
|
|
61
|
+
return ret;
|
|
62
|
+
}
|
|
63
|
+
return ret + (ret ? `/${segment}` : segment);
|
|
64
|
+
}, "")}`;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Resolves a string path, resolving '.' and '.' segments and allowing paths above the root.
|
|
68
|
+
*
|
|
69
|
+
* @param path - The path to normalize.
|
|
70
|
+
* @param allowAboveRoot - Whether to allow the resulting path to be above the root directory.
|
|
71
|
+
* @returns the normalize path string.
|
|
72
|
+
*/
|
|
73
|
+
function normalizeString(path, allowAboveRoot) {
|
|
74
|
+
let res = "";
|
|
75
|
+
let lastSegmentLength = 0;
|
|
76
|
+
let lastSlash = -1;
|
|
77
|
+
let dots = 0;
|
|
78
|
+
let char = null;
|
|
79
|
+
for (let index = 0; index <= path.length; ++index) {
|
|
80
|
+
if (index < path.length) char = path[index];
|
|
81
|
+
else if (char === "/") break;
|
|
82
|
+
else char = "/";
|
|
83
|
+
if (char === "/") {
|
|
84
|
+
if (lastSlash === index - 1 || dots === 1) {} else if (dots === 2) {
|
|
85
|
+
if (res.length < 2 || lastSegmentLength !== 2 || res[res.length - 1] !== "." || res[res.length - 2] !== ".") {
|
|
86
|
+
if (res.length > 2) {
|
|
87
|
+
const lastSlashIndex = res.lastIndexOf("/");
|
|
88
|
+
if (lastSlashIndex === -1) {
|
|
89
|
+
res = "";
|
|
90
|
+
lastSegmentLength = 0;
|
|
91
|
+
} else {
|
|
92
|
+
res = res.slice(0, lastSlashIndex);
|
|
93
|
+
lastSegmentLength = res.length - 1 - res.lastIndexOf("/");
|
|
94
|
+
}
|
|
95
|
+
lastSlash = index;
|
|
96
|
+
dots = 0;
|
|
97
|
+
continue;
|
|
98
|
+
} else if (res.length > 0) {
|
|
99
|
+
res = "";
|
|
100
|
+
lastSegmentLength = 0;
|
|
101
|
+
lastSlash = index;
|
|
102
|
+
dots = 0;
|
|
103
|
+
continue;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
if (allowAboveRoot) {
|
|
107
|
+
res += res.length > 0 ? "/.." : "..";
|
|
108
|
+
lastSegmentLength = 2;
|
|
109
|
+
}
|
|
110
|
+
} else {
|
|
111
|
+
if (res.length > 0) res += `/${path.slice(lastSlash + 1, index)}`;
|
|
112
|
+
else res = path.slice(lastSlash + 1, index);
|
|
113
|
+
lastSegmentLength = index - lastSlash - 1;
|
|
114
|
+
}
|
|
115
|
+
lastSlash = index;
|
|
116
|
+
dots = 0;
|
|
117
|
+
} else if (char === "." && dots !== -1) ++dots;
|
|
118
|
+
else dots = -1;
|
|
119
|
+
}
|
|
120
|
+
return res;
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Converts a given path to an absolute path based on the current working directory.
|
|
124
|
+
*
|
|
125
|
+
* @param path - The path to convert to an absolute path.
|
|
126
|
+
* @param cwd - The current working directory to use as the base path if the path is not absolute.
|
|
127
|
+
* @returns The absolute path.
|
|
128
|
+
*/
|
|
129
|
+
function toAbsolutePath(path, cwd$1 = require_cwd.cwd()) {
|
|
130
|
+
if (require_is_type.isAbsolutePath(path)) return path;
|
|
131
|
+
return require_slash.slash(normalizeString(require_append.appendPath(path, cwd$1), true));
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Converts a given path to a relative path based on the current working directory.
|
|
135
|
+
*
|
|
136
|
+
* @param path - The path to convert to a relative path.
|
|
137
|
+
* @param cwd - The current working directory to use as the base path if the path is not absolute.
|
|
138
|
+
* @returns The relative path.
|
|
139
|
+
*/
|
|
140
|
+
function toRelativePath(path, cwd$1 = require_cwd.cwd()) {
|
|
141
|
+
if (!path || path.length === 0) return ".";
|
|
142
|
+
if (require_is_type.isAbsolutePath(path)) path = require_slash.slash(normalizeString(path, true));
|
|
143
|
+
else path = require_slash.slash(normalizeString(require_join_paths.joinPaths(cwd$1, path), true));
|
|
144
|
+
if (path.startsWith("./")) return path.slice(2);
|
|
145
|
+
return path;
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* Adds a trailing slash to a path if it doesn't already have one.
|
|
149
|
+
*
|
|
150
|
+
* @param path - The path to modify.
|
|
151
|
+
* @returns The modified path with a trailing slash.
|
|
152
|
+
*/
|
|
153
|
+
function withTrailingSlash(path) {
|
|
154
|
+
const result = correctPath(path);
|
|
155
|
+
return result.endsWith("/") ? result : `${result}/`;
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* Removes a trailing slash from a path if it has one.
|
|
159
|
+
*
|
|
160
|
+
* @param path - The path to modify.
|
|
161
|
+
* @returns The modified path without a trailing slash.
|
|
162
|
+
*/
|
|
163
|
+
function withoutTrailingSlash(path) {
|
|
164
|
+
const result = correctPath(path);
|
|
165
|
+
return result.endsWith("/") ? result.slice(0, -1) : result;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
//#endregion
|
|
169
|
+
exports.correctPath = correctPath;
|
|
170
|
+
exports.normalizeString = normalizeString;
|
|
171
|
+
exports.normalizeWindowsPath = normalizeWindowsPath;
|
|
172
|
+
exports.stripStars = stripStars;
|
|
173
|
+
exports.toAbsolutePath = toAbsolutePath;
|
|
174
|
+
exports.toRelativePath = toRelativePath;
|
|
175
|
+
exports.withTrailingSlash = withTrailingSlash;
|
|
176
|
+
exports.withoutTrailingSlash = withoutTrailingSlash;
|