@stryke/fs 0.33.78 → 0.33.80
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 +24 -0
- package/dist/_virtual/_rolldown/runtime.cjs +14 -0
- package/dist/_virtual/_rolldown/runtime.mjs +18 -0
- package/dist/buffer.cjs +12 -0
- package/dist/buffer.mjs +8 -1
- package/dist/buffer.mjs.map +1 -1
- package/dist/buffer.test.cjs +13 -0
- package/dist/buffer.test.d.cts +1 -0
- package/dist/buffer.test.d.mts +1 -0
- package/dist/buffer.test.mjs +14 -0
- package/dist/buffer.test.mjs.map +1 -0
- package/dist/chmod-x.cjs +14 -0
- package/dist/chmod-x.mjs +10 -1
- package/dist/chmod-x.mjs.map +1 -1
- package/dist/chmod-x.test.cjs +13 -0
- package/dist/chmod-x.test.d.cts +1 -0
- package/dist/chmod-x.test.d.mts +1 -0
- package/dist/chmod-x.test.mjs +14 -0
- package/dist/chmod-x.test.mjs.map +1 -0
- package/dist/command-exists.cjs +11 -1
- package/dist/command-exists.mjs +6 -1
- package/dist/command-exists.mjs.map +1 -1
- package/dist/command-exists.test.cjs +13 -0
- package/dist/command-exists.test.d.cts +1 -0
- package/dist/command-exists.test.d.mts +1 -0
- package/dist/command-exists.test.mjs +14 -0
- package/dist/command-exists.test.mjs.map +1 -0
- package/dist/compress.cjs +8 -1
- package/dist/compress.mjs +3 -1
- package/dist/compress.mjs.map +1 -1
- package/dist/compress.test.cjs +13 -0
- package/dist/compress.test.d.cts +1 -0
- package/dist/compress.test.d.mts +1 -0
- package/dist/compress.test.mjs +14 -0
- package/dist/compress.test.mjs.map +1 -0
- package/dist/constants.cjs +13 -0
- package/dist/constants.mjs +8 -1
- package/dist/constants.mjs.map +1 -0
- package/dist/constants.test.cjs +13 -0
- package/dist/constants.test.d.cts +1 -0
- package/dist/constants.test.d.mts +1 -0
- package/dist/constants.test.mjs +14 -0
- package/dist/constants.test.mjs.map +1 -0
- package/dist/copy-file.cjs +13 -1
- package/dist/copy-file.mjs +8 -1
- package/dist/copy-file.mjs.map +1 -1
- package/dist/copy-file.test.cjs +13 -0
- package/dist/copy-file.test.d.cts +1 -0
- package/dist/copy-file.test.d.mts +1 -0
- package/dist/copy-file.test.mjs +14 -0
- package/dist/copy-file.test.mjs.map +1 -0
- package/dist/exists.cjs +11 -1
- package/dist/exists.mjs +6 -1
- package/dist/exists.mjs.map +1 -1
- package/dist/exists.test.cjs +13 -0
- package/dist/exists.test.d.cts +1 -0
- package/dist/exists.test.d.mts +1 -0
- package/dist/exists.test.mjs +14 -0
- package/dist/exists.test.mjs.map +1 -0
- package/dist/get-parent-path.cjs +8 -1
- package/dist/get-parent-path.mjs +3 -1
- package/dist/get-parent-path.mjs.map +1 -1
- package/dist/get-parent-path.test.cjs +13 -0
- package/dist/get-parent-path.test.d.cts +1 -0
- package/dist/get-parent-path.test.d.mts +1 -0
- package/dist/get-parent-path.test.mjs +14 -0
- package/dist/get-parent-path.test.mjs.map +1 -0
- package/dist/get-workspace-root.cjs +16 -0
- package/dist/get-workspace-root.mjs +12 -1
- package/dist/get-workspace-root.mjs.map +1 -1
- package/dist/get-workspace-root.test.cjs +13 -0
- package/dist/get-workspace-root.test.d.cts +1 -0
- package/dist/get-workspace-root.test.d.mts +1 -0
- package/dist/get-workspace-root.test.mjs +14 -0
- package/dist/get-workspace-root.test.mjs.map +1 -0
- package/dist/helpers.cjs +14 -0
- package/dist/helpers.mjs +10 -1
- package/dist/helpers.mjs.map +1 -1
- package/dist/helpers.test.cjs +13 -0
- package/dist/helpers.test.d.cts +1 -0
- package/dist/helpers.test.d.mts +1 -0
- package/dist/helpers.test.mjs +14 -0
- package/dist/helpers.test.mjs.map +1 -0
- package/dist/index.cjs +111 -0
- package/dist/index.mjs +107 -1
- package/dist/index.mjs.map +1 -0
- package/dist/index.test.cjs +13 -0
- package/dist/index.test.d.cts +1 -0
- package/dist/index.test.d.mts +1 -0
- package/dist/index.test.mjs +14 -0
- package/dist/index.test.mjs.map +1 -0
- package/dist/install.cjs +10 -0
- package/dist/install.mjs +6 -1
- package/dist/install.mjs.map +1 -1
- package/dist/install.test.cjs +13 -0
- package/dist/install.test.d.cts +1 -0
- package/dist/install.test.d.mts +1 -0
- package/dist/install.test.mjs +14 -0
- package/dist/install.test.mjs.map +1 -0
- package/dist/is-file.cjs +13 -1
- package/dist/is-file.mjs +8 -1
- package/dist/is-file.mjs.map +1 -1
- package/dist/is-file.test.cjs +13 -0
- package/dist/is-file.test.d.cts +1 -0
- package/dist/is-file.test.d.mts +1 -0
- package/dist/is-file.test.mjs +14 -0
- package/dist/is-file.test.mjs.map +1 -0
- package/dist/json.cjs +12 -0
- package/dist/json.mjs +8 -1
- package/dist/json.mjs.map +1 -1
- package/dist/json.test.cjs +13 -0
- package/dist/json.test.d.cts +1 -0
- package/dist/json.test.d.mts +1 -0
- package/dist/json.test.mjs +14 -0
- package/dist/json.test.mjs.map +1 -0
- package/dist/list-files.cjs +15 -1
- package/dist/list-files.mjs +10 -1
- package/dist/list-files.mjs.map +1 -1
- package/dist/list-files.test.cjs +13 -0
- package/dist/list-files.test.d.cts +1 -0
- package/dist/list-files.test.d.mts +1 -0
- package/dist/list-files.test.mjs +14 -0
- package/dist/list-files.test.mjs.map +1 -0
- package/dist/package-fns.cjs +16 -1
- package/dist/package-fns.mjs +11 -1
- package/dist/package-fns.mjs.map +1 -1
- package/dist/package-fns.test.cjs +13 -0
- package/dist/package-fns.test.d.cts +1 -0
- package/dist/package-fns.test.d.mts +1 -0
- package/dist/package-fns.test.mjs +14 -0
- package/dist/package-fns.test.mjs.map +1 -0
- package/dist/read-file.cjs +13 -1
- package/dist/read-file.mjs +8 -1
- package/dist/read-file.mjs.map +1 -1
- package/dist/read-file.test.cjs +13 -0
- package/dist/read-file.test.d.cts +1 -0
- package/dist/read-file.test.d.mts +1 -0
- package/dist/read-file.test.mjs +14 -0
- package/dist/read-file.test.mjs.map +1 -0
- package/dist/registry.cjs +13 -0
- package/dist/registry.mjs +9 -1
- package/dist/registry.mjs.map +1 -1
- package/dist/registry.test.cjs +13 -0
- package/dist/registry.test.d.cts +1 -0
- package/dist/registry.test.d.mts +1 -0
- package/dist/registry.test.mjs +14 -0
- package/dist/registry.test.mjs.map +1 -0
- package/dist/remove-file.cjs +11 -1
- package/dist/remove-file.mjs +6 -1
- package/dist/remove-file.mjs.map +1 -1
- package/dist/remove-file.test.cjs +13 -0
- package/dist/remove-file.test.d.cts +1 -0
- package/dist/remove-file.test.d.mts +1 -0
- package/dist/remove-file.test.mjs +14 -0
- package/dist/remove-file.test.mjs.map +1 -0
- package/dist/resolve.cjs +20 -1
- package/dist/resolve.mjs +15 -1
- package/dist/resolve.mjs.map +1 -1
- package/dist/resolve.test.cjs +13 -0
- package/dist/resolve.test.d.cts +1 -0
- package/dist/resolve.test.d.mts +1 -0
- package/dist/resolve.test.mjs +14 -0
- package/dist/resolve.test.mjs.map +1 -0
- package/dist/semver-fns.cjs +20 -1
- package/dist/semver-fns.mjs +15 -1
- package/dist/semver-fns.mjs.map +1 -1
- package/dist/semver-fns.test.cjs +13 -0
- package/dist/semver-fns.test.d.cts +1 -0
- package/dist/semver-fns.test.d.mts +1 -0
- package/dist/semver-fns.test.mjs +14 -0
- package/dist/semver-fns.test.mjs.map +1 -0
- package/dist/toml.cjs +12 -0
- package/dist/toml.mjs +8 -1
- package/dist/toml.mjs.map +1 -1
- package/dist/toml.test.cjs +13 -0
- package/dist/toml.test.d.cts +1 -0
- package/dist/toml.test.d.mts +1 -0
- package/dist/toml.test.mjs +14 -0
- package/dist/toml.test.mjs.map +1 -0
- package/dist/tsconfig.cjs +8 -1
- package/dist/tsconfig.mjs +3 -1
- package/dist/tsconfig.mjs.map +1 -1
- package/dist/tsconfig.test.cjs +13 -0
- package/dist/tsconfig.test.d.cts +1 -0
- package/dist/tsconfig.test.d.mts +1 -0
- package/dist/tsconfig.test.mjs +14 -0
- package/dist/tsconfig.test.mjs.map +1 -0
- package/dist/write-file.cjs +11 -1
- package/dist/write-file.mjs +6 -1
- package/dist/write-file.mjs.map +1 -1
- package/dist/write-file.test.cjs +13 -0
- package/dist/write-file.test.d.cts +1 -0
- package/dist/write-file.test.d.mts +1 -0
- package/dist/write-file.test.mjs +14 -0
- package/dist/write-file.test.mjs.map +1 -0
- package/dist/yaml.cjs +11 -1
- package/dist/yaml.mjs +6 -1
- package/dist/yaml.mjs.map +1 -1
- package/dist/yaml.test.cjs +13 -0
- package/dist/yaml.test.d.cts +1 -0
- package/dist/yaml.test.d.mts +1 -0
- package/dist/yaml.test.mjs +14 -0
- package/dist/yaml.test.mjs.map +1 -0
- package/package.json +110 -10
package/dist/list-files.cjs
CHANGED
|
@@ -7,6 +7,14 @@ defu = require_runtime.__toESM(defu, 1);
|
|
|
7
7
|
let glob = require("glob");
|
|
8
8
|
|
|
9
9
|
//#region src/list-files.ts
|
|
10
|
+
var list_files_exports = /* @__PURE__ */ require_runtime.__exportAll({
|
|
11
|
+
list: () => list,
|
|
12
|
+
listDirectories: () => listDirectories,
|
|
13
|
+
listDirectoriesSync: () => listDirectoriesSync,
|
|
14
|
+
listFiles: () => listFiles,
|
|
15
|
+
listFilesSync: () => listFilesSync,
|
|
16
|
+
listSync: () => listSync
|
|
17
|
+
});
|
|
10
18
|
const DEFAULT_OPTIONS = { dot: true };
|
|
11
19
|
/**
|
|
12
20
|
* A files and directories listing helper function
|
|
@@ -83,4 +91,10 @@ exports.listDirectories = listDirectories;
|
|
|
83
91
|
exports.listDirectoriesSync = listDirectoriesSync;
|
|
84
92
|
exports.listFiles = listFiles;
|
|
85
93
|
exports.listFilesSync = listFilesSync;
|
|
86
|
-
exports.listSync = listSync;
|
|
94
|
+
exports.listSync = listSync;
|
|
95
|
+
Object.defineProperty(exports, 'list_files_exports', {
|
|
96
|
+
enumerable: true,
|
|
97
|
+
get: function () {
|
|
98
|
+
return list_files_exports;
|
|
99
|
+
}
|
|
100
|
+
});
|
package/dist/list-files.mjs
CHANGED
|
@@ -1,9 +1,18 @@
|
|
|
1
|
+
import { __exportAll } from "./_virtual/_rolldown/runtime.mjs";
|
|
1
2
|
import { joinPaths } from "@stryke/path";
|
|
2
3
|
import { isString } from "@stryke/type-checks";
|
|
3
4
|
import defu from "defu";
|
|
4
5
|
import { glob } from "glob";
|
|
5
6
|
|
|
6
7
|
//#region src/list-files.ts
|
|
8
|
+
var list_files_exports = /* @__PURE__ */ __exportAll({
|
|
9
|
+
list: () => list,
|
|
10
|
+
listDirectories: () => listDirectories,
|
|
11
|
+
listDirectoriesSync: () => listDirectoriesSync,
|
|
12
|
+
listFiles: () => listFiles,
|
|
13
|
+
listFilesSync: () => listFilesSync,
|
|
14
|
+
listSync: () => listSync
|
|
15
|
+
});
|
|
7
16
|
const DEFAULT_OPTIONS = { dot: true };
|
|
8
17
|
/**
|
|
9
18
|
* A files and directories listing helper function
|
|
@@ -75,5 +84,5 @@ function listDirectoriesSync(filesGlob, options) {
|
|
|
75
84
|
}
|
|
76
85
|
|
|
77
86
|
//#endregion
|
|
78
|
-
export { list, listDirectories, listDirectoriesSync, listFiles, listFilesSync, listSync };
|
|
87
|
+
export { list, listDirectories, listDirectoriesSync, listFiles, listFilesSync, listSync, list_files_exports };
|
|
79
88
|
//# sourceMappingURL=list-files.mjs.map
|
package/dist/list-files.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"list-files.mjs","names":[],"sources":["../src/list-files.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 { joinPaths } from \"@stryke/path\";\nimport { isString } from \"@stryke/type-checks\";\nimport type { AssetGlob } from \"@stryke/types/file\";\nimport defu from \"defu\";\nimport type { GlobOptions, GlobOptionsWithFileTypesTrue, Path } from \"glob\";\nimport { glob } from \"glob\";\n\nexport type ListOptions = GlobOptions;\nexport type InferListReturnType<TOptions extends GlobOptions> =\n TOptions[\"withFileTypes\"] extends true ? Path[] : string[];\n\nconst DEFAULT_OPTIONS: ListOptions = {\n dot: true\n};\n\n/**\n * A files and directories listing helper function\n *\n * @param filesGlob - A glob pattern to match files\n * @returns A list of file paths\n */\nexport async function list<TOptions extends ListOptions>(\n filesGlob: string | Omit<AssetGlob, \"output\">,\n options?: TOptions\n): Promise<InferListReturnType<TOptions>> {\n return glob(\n isString(filesGlob)\n ? filesGlob.includes(\"*\")\n ? filesGlob\n : joinPaths(filesGlob, \"**/*\")\n : filesGlob.input\n ? joinPaths(filesGlob.input, filesGlob.glob)\n : filesGlob.glob,\n defu(\n isString(filesGlob)\n ? {}\n : { dot: filesGlob.dot, ignore: filesGlob.ignore },\n options ?? {},\n DEFAULT_OPTIONS\n )\n ) as Promise<InferListReturnType<TOptions>>;\n}\n\n/**\n * A synchronous files and directories listing helper function\n *\n * @param filesGlob - A glob pattern to match files\n * @returns A list of file paths\n */\nexport function listSync<TOptions extends ListOptions>(\n filesGlob: string | Omit<AssetGlob, \"output\">,\n options?: TOptions\n): InferListReturnType<TOptions> {\n return glob.sync(\n isString(filesGlob)\n ? filesGlob.includes(\"*\")\n ? filesGlob\n : joinPaths(filesGlob, \"**/*\")\n : filesGlob.input\n ? joinPaths(filesGlob.input, filesGlob.glob)\n : filesGlob.glob,\n defu(\n isString(filesGlob)\n ? {}\n : { dot: filesGlob.dot, ignore: filesGlob.ignore },\n options ?? {},\n DEFAULT_OPTIONS\n )\n ) as InferListReturnType<TOptions>;\n}\n\n/**\n * A file listing helper function\n *\n * @param filesGlob - A glob pattern to match files\n * @returns A list of file paths\n */\nexport async function listFiles<TOptions extends ListOptions>(\n filesGlob: string | Omit<AssetGlob, \"output\">,\n options?: TOptions\n) {\n const result = (\n await list(\n filesGlob,\n defu(\n { withFileTypes: true },\n options ?? {}\n ) as GlobOptionsWithFileTypesTrue\n )\n ).filter(ret => ret.isFile());\n if (!options?.withFileTypes) {\n return result.map(file => file.fullpath()) as InferListReturnType<TOptions>;\n }\n\n return result as InferListReturnType<TOptions>;\n}\n\n/**\n * A synchronous file listing helper function\n *\n * @param filesGlob - A glob pattern to match files\n * @returns A list of file paths\n */\nexport function listFilesSync<TOptions extends ListOptions>(\n filesGlob: string | Omit<AssetGlob, \"output\">,\n options?: TOptions\n) {\n const result = listSync(\n filesGlob,\n defu({ withFileTypes: true }, options ?? {}) as GlobOptionsWithFileTypesTrue\n ).filter(ret => ret.isFile());\n if (!options?.withFileTypes) {\n return result.map(file => file.fullpath()) as InferListReturnType<TOptions>;\n }\n\n return result as InferListReturnType<TOptions>;\n}\n\n/**\n * A directories listing helper function\n *\n * @param filesGlob - A glob pattern to match files\n * @returns A list of file paths\n */\nexport async function listDirectories<TOptions extends ListOptions>(\n filesGlob: string | Omit<AssetGlob, \"output\">,\n options?: TOptions\n) {\n const result = (\n await list(\n filesGlob,\n defu(\n { withFileTypes: true },\n options ?? {}\n ) as GlobOptionsWithFileTypesTrue\n )\n ).filter(ret => ret.isDirectory());\n if (!options?.withFileTypes) {\n return result.map(file => file.fullpath()) as InferListReturnType<TOptions>;\n }\n\n return result as InferListReturnType<TOptions>;\n}\n\n/**\n * A synchronous directories listing helper function\n *\n * @param filesGlob - A glob pattern to match files\n * @returns A list of file paths\n */\nexport function listDirectoriesSync<TOptions extends ListOptions>(\n filesGlob: string | Omit<AssetGlob, \"output\">,\n options?: TOptions\n) {\n const result = listSync(\n filesGlob,\n defu({ withFileTypes: true }, options ?? {}) as GlobOptionsWithFileTypesTrue\n ).filter(ret => ret.isDirectory());\n if (!options?.withFileTypes) {\n return result.map(file => file.fullpath()) as InferListReturnType<TOptions>;\n }\n\n return result as InferListReturnType<TOptions>;\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"list-files.mjs","names":[],"sources":["../src/list-files.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 { joinPaths } from \"@stryke/path\";\nimport { isString } from \"@stryke/type-checks\";\nimport type { AssetGlob } from \"@stryke/types/file\";\nimport defu from \"defu\";\nimport type { GlobOptions, GlobOptionsWithFileTypesTrue, Path } from \"glob\";\nimport { glob } from \"glob\";\n\nexport type ListOptions = GlobOptions;\nexport type InferListReturnType<TOptions extends GlobOptions> =\n TOptions[\"withFileTypes\"] extends true ? Path[] : string[];\n\nconst DEFAULT_OPTIONS: ListOptions = {\n dot: true\n};\n\n/**\n * A files and directories listing helper function\n *\n * @param filesGlob - A glob pattern to match files\n * @returns A list of file paths\n */\nexport async function list<TOptions extends ListOptions>(\n filesGlob: string | Omit<AssetGlob, \"output\">,\n options?: TOptions\n): Promise<InferListReturnType<TOptions>> {\n return glob(\n isString(filesGlob)\n ? filesGlob.includes(\"*\")\n ? filesGlob\n : joinPaths(filesGlob, \"**/*\")\n : filesGlob.input\n ? joinPaths(filesGlob.input, filesGlob.glob)\n : filesGlob.glob,\n defu(\n isString(filesGlob)\n ? {}\n : { dot: filesGlob.dot, ignore: filesGlob.ignore },\n options ?? {},\n DEFAULT_OPTIONS\n )\n ) as Promise<InferListReturnType<TOptions>>;\n}\n\n/**\n * A synchronous files and directories listing helper function\n *\n * @param filesGlob - A glob pattern to match files\n * @returns A list of file paths\n */\nexport function listSync<TOptions extends ListOptions>(\n filesGlob: string | Omit<AssetGlob, \"output\">,\n options?: TOptions\n): InferListReturnType<TOptions> {\n return glob.sync(\n isString(filesGlob)\n ? filesGlob.includes(\"*\")\n ? filesGlob\n : joinPaths(filesGlob, \"**/*\")\n : filesGlob.input\n ? joinPaths(filesGlob.input, filesGlob.glob)\n : filesGlob.glob,\n defu(\n isString(filesGlob)\n ? {}\n : { dot: filesGlob.dot, ignore: filesGlob.ignore },\n options ?? {},\n DEFAULT_OPTIONS\n )\n ) as InferListReturnType<TOptions>;\n}\n\n/**\n * A file listing helper function\n *\n * @param filesGlob - A glob pattern to match files\n * @returns A list of file paths\n */\nexport async function listFiles<TOptions extends ListOptions>(\n filesGlob: string | Omit<AssetGlob, \"output\">,\n options?: TOptions\n) {\n const result = (\n await list(\n filesGlob,\n defu(\n { withFileTypes: true },\n options ?? {}\n ) as GlobOptionsWithFileTypesTrue\n )\n ).filter(ret => ret.isFile());\n if (!options?.withFileTypes) {\n return result.map(file => file.fullpath()) as InferListReturnType<TOptions>;\n }\n\n return result as InferListReturnType<TOptions>;\n}\n\n/**\n * A synchronous file listing helper function\n *\n * @param filesGlob - A glob pattern to match files\n * @returns A list of file paths\n */\nexport function listFilesSync<TOptions extends ListOptions>(\n filesGlob: string | Omit<AssetGlob, \"output\">,\n options?: TOptions\n) {\n const result = listSync(\n filesGlob,\n defu({ withFileTypes: true }, options ?? {}) as GlobOptionsWithFileTypesTrue\n ).filter(ret => ret.isFile());\n if (!options?.withFileTypes) {\n return result.map(file => file.fullpath()) as InferListReturnType<TOptions>;\n }\n\n return result as InferListReturnType<TOptions>;\n}\n\n/**\n * A directories listing helper function\n *\n * @param filesGlob - A glob pattern to match files\n * @returns A list of file paths\n */\nexport async function listDirectories<TOptions extends ListOptions>(\n filesGlob: string | Omit<AssetGlob, \"output\">,\n options?: TOptions\n) {\n const result = (\n await list(\n filesGlob,\n defu(\n { withFileTypes: true },\n options ?? {}\n ) as GlobOptionsWithFileTypesTrue\n )\n ).filter(ret => ret.isDirectory());\n if (!options?.withFileTypes) {\n return result.map(file => file.fullpath()) as InferListReturnType<TOptions>;\n }\n\n return result as InferListReturnType<TOptions>;\n}\n\n/**\n * A synchronous directories listing helper function\n *\n * @param filesGlob - A glob pattern to match files\n * @returns A list of file paths\n */\nexport function listDirectoriesSync<TOptions extends ListOptions>(\n filesGlob: string | Omit<AssetGlob, \"output\">,\n options?: TOptions\n) {\n const result = listSync(\n filesGlob,\n defu({ withFileTypes: true }, options ?? {}) as GlobOptionsWithFileTypesTrue\n ).filter(ret => ret.isDirectory());\n if (!options?.withFileTypes) {\n return result.map(file => file.fullpath()) as InferListReturnType<TOptions>;\n }\n\n return result as InferListReturnType<TOptions>;\n}\n"],"mappings":";;;;;;;;;;;;;;;AA6BA,MAAM,kBAA+B,EACnC,KAAK,MACN;;;;;;;AAQD,eAAsB,KACpB,WACA,SACwC;AACxC,QAAO,KACL,SAAS,UAAU,GACf,UAAU,SAAS,IAAI,GACrB,YACA,UAAU,WAAW,OAAO,GAC9B,UAAU,QACR,UAAU,UAAU,OAAO,UAAU,KAAK,GAC1C,UAAU,MAChB,KACE,SAAS,UAAU,GACf,EAAE,GACF;EAAE,KAAK,UAAU;EAAK,QAAQ,UAAU;EAAQ,EACpD,WAAW,EAAE,EACb,gBACD,CACF;;;;;;;;AASH,SAAgB,SACd,WACA,SAC+B;AAC/B,QAAO,KAAK,KACV,SAAS,UAAU,GACf,UAAU,SAAS,IAAI,GACrB,YACA,UAAU,WAAW,OAAO,GAC9B,UAAU,QACR,UAAU,UAAU,OAAO,UAAU,KAAK,GAC1C,UAAU,MAChB,KACE,SAAS,UAAU,GACf,EAAE,GACF;EAAE,KAAK,UAAU;EAAK,QAAQ,UAAU;EAAQ,EACpD,WAAW,EAAE,EACb,gBACD,CACF;;;;;;;;AASH,eAAsB,UACpB,WACA,SACA;CACA,MAAM,UACJ,MAAM,KACJ,WACA,KACE,EAAE,eAAe,MAAM,EACvB,WAAW,EAAE,CACd,CACF,EACD,QAAO,QAAO,IAAI,QAAQ,CAAC;AAC7B,KAAI,CAAC,SAAS,cACZ,QAAO,OAAO,KAAI,SAAQ,KAAK,UAAU,CAAC;AAG5C,QAAO;;;;;;;;AAST,SAAgB,cACd,WACA,SACA;CACA,MAAM,SAAS,SACb,WACA,KAAK,EAAE,eAAe,MAAM,EAAE,WAAW,EAAE,CAAC,CAC7C,CAAC,QAAO,QAAO,IAAI,QAAQ,CAAC;AAC7B,KAAI,CAAC,SAAS,cACZ,QAAO,OAAO,KAAI,SAAQ,KAAK,UAAU,CAAC;AAG5C,QAAO;;;;;;;;AAST,eAAsB,gBACpB,WACA,SACA;CACA,MAAM,UACJ,MAAM,KACJ,WACA,KACE,EAAE,eAAe,MAAM,EACvB,WAAW,EAAE,CACd,CACF,EACD,QAAO,QAAO,IAAI,aAAa,CAAC;AAClC,KAAI,CAAC,SAAS,cACZ,QAAO,OAAO,KAAI,SAAQ,KAAK,UAAU,CAAC;AAG5C,QAAO;;;;;;;;AAST,SAAgB,oBACd,WACA,SACA;CACA,MAAM,SAAS,SACb,WACA,KAAK,EAAE,eAAe,MAAM,EAAE,WAAW,EAAE,CAAC,CAC7C,CAAC,QAAO,QAAO,IAAI,aAAa,CAAC;AAClC,KAAI,CAAC,SAAS,cACZ,QAAO,OAAO,KAAI,SAAQ,KAAK,UAAU,CAAC;AAG5C,QAAO"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
const require_runtime = require('./_virtual/_rolldown/runtime.cjs');
|
|
2
|
+
const require_list_files = require('./list-files.cjs');
|
|
3
|
+
let vitest = require("vitest");
|
|
4
|
+
|
|
5
|
+
//#region src/list-files.test.ts
|
|
6
|
+
(0, vitest.describe)("list-files.ts exports", () => {
|
|
7
|
+
(0, vitest.it)("loads module exports", () => {
|
|
8
|
+
(0, vitest.expect)(require_list_files.list_files_exports).toBeDefined();
|
|
9
|
+
(0, vitest.expect)(typeof require_list_files.list_files_exports).toBe("object");
|
|
10
|
+
});
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
//#endregion
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { list_files_exports } from "./list-files.mjs";
|
|
2
|
+
import { describe, expect, it } from "vitest";
|
|
3
|
+
|
|
4
|
+
//#region src/list-files.test.ts
|
|
5
|
+
describe("list-files.ts exports", () => {
|
|
6
|
+
it("loads module exports", () => {
|
|
7
|
+
expect(list_files_exports).toBeDefined();
|
|
8
|
+
expect(typeof list_files_exports).toBe("object");
|
|
9
|
+
});
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
//#endregion
|
|
13
|
+
export { };
|
|
14
|
+
//# sourceMappingURL=list-files.test.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"list-files.test.mjs","names":["moduleExports"],"sources":["../src/list-files.test.ts"],"sourcesContent":["import { describe, expect, it } from \"vitest\";\nimport * as moduleExports from \"./list-files.ts\";\n\ndescribe(\"list-files.ts exports\", () => {\n it(\"loads module exports\", () => {\n expect(moduleExports).toBeDefined();\n expect(typeof moduleExports).toBe(\"object\");\n });\n});\n"],"mappings":";;;;AAGA,SAAS,+BAA+B;AACtC,IAAG,8BAA8B;AAC/B,SAAOA,mBAAc,CAAC,aAAa;AACnC,SAAO,OAAOA,mBAAc,CAAC,KAAK,SAAS;GAC3C;EACF"}
|
package/dist/package-fns.cjs
CHANGED
|
@@ -13,6 +13,15 @@ let _stryke_type_checks_is_string = require("@stryke/type-checks/is-string");
|
|
|
13
13
|
let semver = require("semver");
|
|
14
14
|
|
|
15
15
|
//#region src/package-fns.ts
|
|
16
|
+
var package_fns_exports = /* @__PURE__ */ require_runtime.__exportAll({
|
|
17
|
+
doesPackageMatch: () => doesPackageMatch,
|
|
18
|
+
getPackageInfo: () => getPackageInfo,
|
|
19
|
+
getPackageListing: () => getPackageListing,
|
|
20
|
+
getPackageManager: () => getPackageManager,
|
|
21
|
+
isPackageExists: () => isPackageExists,
|
|
22
|
+
isPackageListed: () => isPackageListed,
|
|
23
|
+
loadPackageJson: () => loadPackageJson
|
|
24
|
+
});
|
|
16
25
|
/**
|
|
17
26
|
* Get the package manager used in the project
|
|
18
27
|
*
|
|
@@ -146,4 +155,10 @@ exports.getPackageListing = getPackageListing;
|
|
|
146
155
|
exports.getPackageManager = getPackageManager;
|
|
147
156
|
exports.isPackageExists = isPackageExists;
|
|
148
157
|
exports.isPackageListed = isPackageListed;
|
|
149
|
-
exports.loadPackageJson = loadPackageJson;
|
|
158
|
+
exports.loadPackageJson = loadPackageJson;
|
|
159
|
+
Object.defineProperty(exports, 'package_fns_exports', {
|
|
160
|
+
enumerable: true,
|
|
161
|
+
get: function () {
|
|
162
|
+
return package_fns_exports;
|
|
163
|
+
}
|
|
164
|
+
});
|
package/dist/package-fns.mjs
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { __exportAll } from "./_virtual/_rolldown/runtime.mjs";
|
|
1
2
|
import { exists } from "./exists.mjs";
|
|
2
3
|
import { getParentPath } from "./get-parent-path.mjs";
|
|
3
4
|
import { getWorkspaceRoot } from "./get-workspace-root.mjs";
|
|
@@ -11,6 +12,15 @@ import { isString } from "@stryke/type-checks/is-string";
|
|
|
11
12
|
import { subset } from "semver";
|
|
12
13
|
|
|
13
14
|
//#region src/package-fns.ts
|
|
15
|
+
var package_fns_exports = /* @__PURE__ */ __exportAll({
|
|
16
|
+
doesPackageMatch: () => doesPackageMatch,
|
|
17
|
+
getPackageInfo: () => getPackageInfo,
|
|
18
|
+
getPackageListing: () => getPackageListing,
|
|
19
|
+
getPackageManager: () => getPackageManager,
|
|
20
|
+
isPackageExists: () => isPackageExists,
|
|
21
|
+
isPackageListed: () => isPackageListed,
|
|
22
|
+
loadPackageJson: () => loadPackageJson
|
|
23
|
+
});
|
|
14
24
|
/**
|
|
15
25
|
* Get the package manager used in the project
|
|
16
26
|
*
|
|
@@ -138,5 +148,5 @@ function isPackageExists(name, options = {}) {
|
|
|
138
148
|
}
|
|
139
149
|
|
|
140
150
|
//#endregion
|
|
141
|
-
export { doesPackageMatch, getPackageInfo, getPackageListing, getPackageManager, isPackageExists, isPackageListed, loadPackageJson };
|
|
151
|
+
export { doesPackageMatch, getPackageInfo, getPackageListing, getPackageManager, isPackageExists, isPackageListed, loadPackageJson, package_fns_exports };
|
|
142
152
|
//# sourceMappingURL=package-fns.mjs.map
|
package/dist/package-fns.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"package-fns.mjs","names":[],"sources":["../src/package-fns.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 { findFileName, findFilePath } from \"@stryke/path/file-path-fns\";\nimport { joinPaths } from \"@stryke/path/join-paths\";\nimport { getPackageName } from \"@stryke/string-format/package\";\nimport { isString } from \"@stryke/type-checks/is-string\";\nimport type { PackageJson } from \"@stryke/types/package-json\";\nimport type { PackageManager } from \"@stryke/types/package-manager\";\nimport { existsSync } from \"node:fs\";\nimport type { Range } from \"semver\";\nimport { subset } from \"semver\";\nimport { exists } from \"./exists\";\nimport { getParentPath } from \"./get-parent-path\";\nimport { getWorkspaceRoot } from \"./get-workspace-root\";\nimport { readJsonFile } from \"./json\";\nimport type { ResolveOptions } from \"./resolve\";\nimport { resolvePackage } from \"./resolve\";\n\n/**\n * Get the package manager used in the project\n *\n * @param dir - The path to the project\n * @returns The package manager used in the project\n */\nexport function getPackageManager(dir = getWorkspaceRoot()): PackageManager {\n const lockFile = getParentPath(\n [\"package-lock.json\", \"yarn.lock\", \"pnpm-lock.yaml\", \"bun.lock\"],\n dir,\n {\n includeNameInResults: true\n }\n );\n\n if (!lockFile) {\n // default use pnpm\n return \"pnpm\";\n }\n\n switch (findFileName(lockFile)) {\n case \"yarn.lock\": {\n return \"yarn\";\n }\n case \"pnpm-lock.yaml\": {\n return \"pnpm\";\n }\n case \"bun.lock\": {\n return \"bun\";\n }\n default: {\n return \"npm\";\n }\n }\n}\n\n// Much of the below code comes from https://github.com/antfu-collective/local-pkg with some modifications\n\nasync function searchPackageJson(dir: string) {\n let packageJsonPath;\n\n while (true) {\n if (!dir) {\n return;\n }\n const newDir = findFilePath(dir);\n\n if (newDir === dir) {\n return;\n }\n\n dir = newDir;\n packageJsonPath = joinPaths(dir, \"package.json\");\n\n if (await exists(packageJsonPath)) {\n break;\n }\n }\n\n return packageJsonPath;\n}\n\nasync function getPackageJsonPath(name: string, options: ResolveOptions = {}) {\n const entry = await resolvePackage(name, options);\n if (!entry) {\n return;\n }\n\n return searchPackageJson(entry);\n}\n\n/**\n * Get package info\n *\n * @param name - The name of the package\n * @param options - The options to use when resolving the package\n * @returns The package info\n */\nexport async function getPackageInfo(\n name: string,\n options: ResolveOptions = {}\n) {\n const packageJsonPath = await getPackageJsonPath(name, options);\n if (!packageJsonPath) {\n return;\n }\n\n const packageJson = await readJsonFile<PackageJson>(packageJsonPath);\n\n return {\n name,\n version: packageJson.version,\n rootPath: findFilePath(packageJsonPath),\n packageJsonPath,\n packageJson\n };\n}\n\n/**\n * Get the package info from the package.json file\n *\n * @param cwd - The current working directory\n * @returns The package info\n */\nexport async function loadPackageJson(\n cwd = getWorkspaceRoot()\n): Promise<PackageJson | null> {\n const path = getParentPath(\"package.json\", cwd, {\n skipCwd: false,\n includeNameInResults: true\n });\n if (!path || !existsSync(path)) {\n return null;\n }\n\n return readJsonFile<PackageJson>(path);\n}\n\nexport interface PackageExistsOptions {\n /**\n * The current working directory\n */\n cwd?: string;\n}\n\nexport interface PackageMatchesOptions extends PackageExistsOptions {\n /**\n * The version range of the package to check\n */\n version?: string | Range;\n}\n\n/**\n * Check if a package is listed in the package.json file\n *\n * @param name - The name of the package\n * @param cwd - The current working directory\n * @returns An indicator specifying if the package is listed\n */\nexport async function isPackageListed(\n name: string,\n cwd?: string\n): Promise<boolean>;\n\n/**\n * Check if a package is listed in the package.json file\n *\n * @param name - The name of the package\n * @param options - The options to use when checking if the package is listed\n * @returns An indicator specifying if the package is listed\n */\nexport async function isPackageListed(\n name: string,\n options?: PackageExistsOptions\n): Promise<boolean>;\n\n/**\n * Check if a package is listed in the package.json file\n *\n * @param name - The name of the package\n * @param cwdOrOptions - The current working directory or options to use when checking if the package is listed\n * @returns An indicator specifying if the package is listed\n */\nexport async function isPackageListed(\n name: string,\n cwdOrOptions?: string | PackageExistsOptions\n): Promise<boolean> {\n const packageName = getPackageName(name);\n const cwd = isString(cwdOrOptions) ? cwdOrOptions : cwdOrOptions?.cwd;\n\n const packageJson = await loadPackageJson(cwd);\n if (!packageJson) {\n return false;\n }\n\n return Boolean(\n (packageJson.dependencies &&\n packageName in packageJson.dependencies &&\n packageJson.dependencies[packageName]) ||\n (packageJson.devDependencies &&\n packageName in packageJson.devDependencies &&\n packageJson.devDependencies[packageName])\n );\n}\n\nexport interface GetPackageListingReturn {\n version: string;\n type: \"dependencies\" | \"devDependencies\";\n}\n\n/**\n * Return the package version and dependency type listed in the package.json file\n *\n * @param name - The name of the package\n * @param cwdOrOptions - The current working directory or options to use when checking if the package is listed\n * @returns The version and type of the package if listed, otherwise undefined\n */\nexport async function getPackageListing(\n name: string,\n cwdOrOptions?: string | PackageExistsOptions\n): Promise<GetPackageListingReturn | undefined> {\n const packageName = getPackageName(name);\n const cwd = isString(cwdOrOptions) ? cwdOrOptions : cwdOrOptions?.cwd;\n\n const packageJson = await loadPackageJson(cwd);\n if (!packageJson) {\n return undefined;\n }\n\n const version =\n packageJson.dependencies && packageName in packageJson.dependencies\n ? packageJson.dependencies[packageName]\n : packageJson.devDependencies &&\n packageName in packageJson.devDependencies\n ? packageJson.devDependencies[packageName]\n : undefined;\n const type =\n (packageJson.dependencies && packageName in packageJson.dependencies\n ? \"dependencies\"\n : packageJson.devDependencies &&\n packageName in packageJson.devDependencies\n ? \"devDependencies\"\n : undefined) || undefined;\n\n return version && type\n ? {\n version,\n type\n }\n : undefined;\n}\n\n/**\n * Check if a package version matches a specific version range\n *\n * @param name - The name of the package\n * @param version - The version to check against\n * @param cwd - The current working directory\n * @returns An indicator specifying if the package version matches the range\n */\nexport async function doesPackageMatch(\n name: string,\n version: string,\n cwd?: string\n): Promise<boolean> {\n const pkg = await getPackageListing(name, { cwd });\n if (!pkg) {\n return false;\n }\n\n return (\n pkg.version.startsWith(\"catalog:\") ||\n pkg.version.startsWith(\"workspace:\") ||\n subset(pkg.version, version)\n );\n}\n\n/**\n * Check if a package exists\n *\n * @param name - The name of the package\n * @param options - The options to use when resolving the package\n * @returns An indicator specifying if the package exists\n */\nexport function isPackageExists(name: string, options: ResolveOptions = {}) {\n return Boolean(resolvePackage(name, options));\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAwCA,SAAgB,kBAAkB,MAAM,kBAAkB,EAAkB;CAC1E,MAAM,WAAW,cACf;EAAC;EAAqB;EAAa;EAAkB;EAAW,EAChE,KACA,EACE,sBAAsB,MACvB,CACF;AAED,KAAI,CAAC,SAEH,QAAO;AAGT,SAAQ,aAAa,SAAS,EAA9B;EACE,KAAK,YACH,QAAO;EAET,KAAK,iBACH,QAAO;EAET,KAAK,WACH,QAAO;EAET,QACE,QAAO;;;AAOb,eAAe,kBAAkB,KAAa;CAC5C,IAAI;AAEJ,QAAO,MAAM;AACX,MAAI,CAAC,IACH;EAEF,MAAM,SAAS,aAAa,IAAI;AAEhC,MAAI,WAAW,IACb;AAGF,QAAM;AACN,oBAAkB,UAAU,KAAK,eAAe;AAEhD,MAAI,MAAM,OAAO,gBAAgB,CAC/B;;AAIJ,QAAO;;AAGT,eAAe,mBAAmB,MAAc,UAA0B,EAAE,EAAE;CAC5E,MAAM,QAAQ,MAAM,eAAe,MAAM,QAAQ;AACjD,KAAI,CAAC,MACH;AAGF,QAAO,kBAAkB,MAAM;;;;;;;;;AAUjC,eAAsB,eACpB,MACA,UAA0B,EAAE,EAC5B;CACA,MAAM,kBAAkB,MAAM,mBAAmB,MAAM,QAAQ;AAC/D,KAAI,CAAC,gBACH;CAGF,MAAM,cAAc,MAAM,aAA0B,gBAAgB;AAEpE,QAAO;EACL;EACA,SAAS,YAAY;EACrB,UAAU,aAAa,gBAAgB;EACvC;EACA;EACD;;;;;;;;AASH,eAAsB,gBACpB,MAAM,kBAAkB,EACK;CAC7B,MAAM,OAAO,cAAc,gBAAgB,KAAK;EAC9C,SAAS;EACT,sBAAsB;EACvB,CAAC;AACF,KAAI,CAAC,QAAQ,CAAC,WAAW,KAAK,CAC5B,QAAO;AAGT,QAAO,aAA0B,KAAK;;;;;;;;;AAgDxC,eAAsB,gBACpB,MACA,cACkB;CAClB,MAAM,cAAc,eAAe,KAAK;CAGxC,MAAM,cAAc,MAAM,gBAFd,SAAS,aAAa,GAAG,eAAe,cAAc,IAEpB;AAC9C,KAAI,CAAC,YACH,QAAO;AAGT,QAAO,QACJ,YAAY,gBACX,eAAe,YAAY,gBAC3B,YAAY,aAAa,gBAC1B,YAAY,mBACX,eAAe,YAAY,mBAC3B,YAAY,gBAAgB,aAC/B;;;;;;;;;AAeH,eAAsB,kBACpB,MACA,cAC8C;CAC9C,MAAM,cAAc,eAAe,KAAK;CAGxC,MAAM,cAAc,MAAM,gBAFd,SAAS,aAAa,GAAG,eAAe,cAAc,IAEpB;AAC9C,KAAI,CAAC,YACH;CAGF,MAAM,UACJ,YAAY,gBAAgB,eAAe,YAAY,eACnD,YAAY,aAAa,eACzB,YAAY,mBACV,eAAe,YAAY,kBAC3B,YAAY,gBAAgB,eAC5B;CACR,MAAM,QACH,YAAY,gBAAgB,eAAe,YAAY,eACpD,iBACA,YAAY,mBACV,eAAe,YAAY,kBAC3B,oBACA,WAAc;AAEtB,QAAO,WAAW,OACd;EACE;EACA;EACD,GACD;;;;;;;;;;AAWN,eAAsB,iBACpB,MACA,SACA,KACkB;CAClB,MAAM,MAAM,MAAM,kBAAkB,MAAM,EAAE,KAAK,CAAC;AAClD,KAAI,CAAC,IACH,QAAO;AAGT,QACE,IAAI,QAAQ,WAAW,WAAW,IAClC,IAAI,QAAQ,WAAW,aAAa,IACpC,OAAO,IAAI,SAAS,QAAQ;;;;;;;;;AAWhC,SAAgB,gBAAgB,MAAc,UAA0B,EAAE,EAAE;AAC1E,QAAO,QAAQ,eAAe,MAAM,QAAQ,CAAC"}
|
|
1
|
+
{"version":3,"file":"package-fns.mjs","names":[],"sources":["../src/package-fns.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 { findFileName, findFilePath } from \"@stryke/path/file-path-fns\";\nimport { joinPaths } from \"@stryke/path/join-paths\";\nimport { getPackageName } from \"@stryke/string-format/package\";\nimport { isString } from \"@stryke/type-checks/is-string\";\nimport type { PackageJson } from \"@stryke/types/package-json\";\nimport type { PackageManager } from \"@stryke/types/package-manager\";\nimport { existsSync } from \"node:fs\";\nimport type { Range } from \"semver\";\nimport { subset } from \"semver\";\nimport { exists } from \"./exists\";\nimport { getParentPath } from \"./get-parent-path\";\nimport { getWorkspaceRoot } from \"./get-workspace-root\";\nimport { readJsonFile } from \"./json\";\nimport type { ResolveOptions } from \"./resolve\";\nimport { resolvePackage } from \"./resolve\";\n\n/**\n * Get the package manager used in the project\n *\n * @param dir - The path to the project\n * @returns The package manager used in the project\n */\nexport function getPackageManager(dir = getWorkspaceRoot()): PackageManager {\n const lockFile = getParentPath(\n [\"package-lock.json\", \"yarn.lock\", \"pnpm-lock.yaml\", \"bun.lock\"],\n dir,\n {\n includeNameInResults: true\n }\n );\n\n if (!lockFile) {\n // default use pnpm\n return \"pnpm\";\n }\n\n switch (findFileName(lockFile)) {\n case \"yarn.lock\": {\n return \"yarn\";\n }\n case \"pnpm-lock.yaml\": {\n return \"pnpm\";\n }\n case \"bun.lock\": {\n return \"bun\";\n }\n default: {\n return \"npm\";\n }\n }\n}\n\n// Much of the below code comes from https://github.com/antfu-collective/local-pkg with some modifications\n\nasync function searchPackageJson(dir: string) {\n let packageJsonPath;\n\n while (true) {\n if (!dir) {\n return;\n }\n const newDir = findFilePath(dir);\n\n if (newDir === dir) {\n return;\n }\n\n dir = newDir;\n packageJsonPath = joinPaths(dir, \"package.json\");\n\n if (await exists(packageJsonPath)) {\n break;\n }\n }\n\n return packageJsonPath;\n}\n\nasync function getPackageJsonPath(name: string, options: ResolveOptions = {}) {\n const entry = await resolvePackage(name, options);\n if (!entry) {\n return;\n }\n\n return searchPackageJson(entry);\n}\n\n/**\n * Get package info\n *\n * @param name - The name of the package\n * @param options - The options to use when resolving the package\n * @returns The package info\n */\nexport async function getPackageInfo(\n name: string,\n options: ResolveOptions = {}\n) {\n const packageJsonPath = await getPackageJsonPath(name, options);\n if (!packageJsonPath) {\n return;\n }\n\n const packageJson = await readJsonFile<PackageJson>(packageJsonPath);\n\n return {\n name,\n version: packageJson.version,\n rootPath: findFilePath(packageJsonPath),\n packageJsonPath,\n packageJson\n };\n}\n\n/**\n * Get the package info from the package.json file\n *\n * @param cwd - The current working directory\n * @returns The package info\n */\nexport async function loadPackageJson(\n cwd = getWorkspaceRoot()\n): Promise<PackageJson | null> {\n const path = getParentPath(\"package.json\", cwd, {\n skipCwd: false,\n includeNameInResults: true\n });\n if (!path || !existsSync(path)) {\n return null;\n }\n\n return readJsonFile<PackageJson>(path);\n}\n\nexport interface PackageExistsOptions {\n /**\n * The current working directory\n */\n cwd?: string;\n}\n\nexport interface PackageMatchesOptions extends PackageExistsOptions {\n /**\n * The version range of the package to check\n */\n version?: string | Range;\n}\n\n/**\n * Check if a package is listed in the package.json file\n *\n * @param name - The name of the package\n * @param cwd - The current working directory\n * @returns An indicator specifying if the package is listed\n */\nexport async function isPackageListed(\n name: string,\n cwd?: string\n): Promise<boolean>;\n\n/**\n * Check if a package is listed in the package.json file\n *\n * @param name - The name of the package\n * @param options - The options to use when checking if the package is listed\n * @returns An indicator specifying if the package is listed\n */\nexport async function isPackageListed(\n name: string,\n options?: PackageExistsOptions\n): Promise<boolean>;\n\n/**\n * Check if a package is listed in the package.json file\n *\n * @param name - The name of the package\n * @param cwdOrOptions - The current working directory or options to use when checking if the package is listed\n * @returns An indicator specifying if the package is listed\n */\nexport async function isPackageListed(\n name: string,\n cwdOrOptions?: string | PackageExistsOptions\n): Promise<boolean> {\n const packageName = getPackageName(name);\n const cwd = isString(cwdOrOptions) ? cwdOrOptions : cwdOrOptions?.cwd;\n\n const packageJson = await loadPackageJson(cwd);\n if (!packageJson) {\n return false;\n }\n\n return Boolean(\n (packageJson.dependencies &&\n packageName in packageJson.dependencies &&\n packageJson.dependencies[packageName]) ||\n (packageJson.devDependencies &&\n packageName in packageJson.devDependencies &&\n packageJson.devDependencies[packageName])\n );\n}\n\nexport interface GetPackageListingReturn {\n version: string;\n type: \"dependencies\" | \"devDependencies\";\n}\n\n/**\n * Return the package version and dependency type listed in the package.json file\n *\n * @param name - The name of the package\n * @param cwdOrOptions - The current working directory or options to use when checking if the package is listed\n * @returns The version and type of the package if listed, otherwise undefined\n */\nexport async function getPackageListing(\n name: string,\n cwdOrOptions?: string | PackageExistsOptions\n): Promise<GetPackageListingReturn | undefined> {\n const packageName = getPackageName(name);\n const cwd = isString(cwdOrOptions) ? cwdOrOptions : cwdOrOptions?.cwd;\n\n const packageJson = await loadPackageJson(cwd);\n if (!packageJson) {\n return undefined;\n }\n\n const version =\n packageJson.dependencies && packageName in packageJson.dependencies\n ? packageJson.dependencies[packageName]\n : packageJson.devDependencies &&\n packageName in packageJson.devDependencies\n ? packageJson.devDependencies[packageName]\n : undefined;\n const type =\n (packageJson.dependencies && packageName in packageJson.dependencies\n ? \"dependencies\"\n : packageJson.devDependencies &&\n packageName in packageJson.devDependencies\n ? \"devDependencies\"\n : undefined) || undefined;\n\n return version && type\n ? {\n version,\n type\n }\n : undefined;\n}\n\n/**\n * Check if a package version matches a specific version range\n *\n * @param name - The name of the package\n * @param version - The version to check against\n * @param cwd - The current working directory\n * @returns An indicator specifying if the package version matches the range\n */\nexport async function doesPackageMatch(\n name: string,\n version: string,\n cwd?: string\n): Promise<boolean> {\n const pkg = await getPackageListing(name, { cwd });\n if (!pkg) {\n return false;\n }\n\n return (\n pkg.version.startsWith(\"catalog:\") ||\n pkg.version.startsWith(\"workspace:\") ||\n subset(pkg.version, version)\n );\n}\n\n/**\n * Check if a package exists\n *\n * @param name - The name of the package\n * @param options - The options to use when resolving the package\n * @returns An indicator specifying if the package exists\n */\nexport function isPackageExists(name: string, options: ResolveOptions = {}) {\n return Boolean(resolvePackage(name, options));\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwCA,SAAgB,kBAAkB,MAAM,kBAAkB,EAAkB;CAC1E,MAAM,WAAW,cACf;EAAC;EAAqB;EAAa;EAAkB;EAAW,EAChE,KACA,EACE,sBAAsB,MACvB,CACF;AAED,KAAI,CAAC,SAEH,QAAO;AAGT,SAAQ,aAAa,SAAS,EAA9B;EACE,KAAK,YACH,QAAO;EAET,KAAK,iBACH,QAAO;EAET,KAAK,WACH,QAAO;EAET,QACE,QAAO;;;AAOb,eAAe,kBAAkB,KAAa;CAC5C,IAAI;AAEJ,QAAO,MAAM;AACX,MAAI,CAAC,IACH;EAEF,MAAM,SAAS,aAAa,IAAI;AAEhC,MAAI,WAAW,IACb;AAGF,QAAM;AACN,oBAAkB,UAAU,KAAK,eAAe;AAEhD,MAAI,MAAM,OAAO,gBAAgB,CAC/B;;AAIJ,QAAO;;AAGT,eAAe,mBAAmB,MAAc,UAA0B,EAAE,EAAE;CAC5E,MAAM,QAAQ,MAAM,eAAe,MAAM,QAAQ;AACjD,KAAI,CAAC,MACH;AAGF,QAAO,kBAAkB,MAAM;;;;;;;;;AAUjC,eAAsB,eACpB,MACA,UAA0B,EAAE,EAC5B;CACA,MAAM,kBAAkB,MAAM,mBAAmB,MAAM,QAAQ;AAC/D,KAAI,CAAC,gBACH;CAGF,MAAM,cAAc,MAAM,aAA0B,gBAAgB;AAEpE,QAAO;EACL;EACA,SAAS,YAAY;EACrB,UAAU,aAAa,gBAAgB;EACvC;EACA;EACD;;;;;;;;AASH,eAAsB,gBACpB,MAAM,kBAAkB,EACK;CAC7B,MAAM,OAAO,cAAc,gBAAgB,KAAK;EAC9C,SAAS;EACT,sBAAsB;EACvB,CAAC;AACF,KAAI,CAAC,QAAQ,CAAC,WAAW,KAAK,CAC5B,QAAO;AAGT,QAAO,aAA0B,KAAK;;;;;;;;;AAgDxC,eAAsB,gBACpB,MACA,cACkB;CAClB,MAAM,cAAc,eAAe,KAAK;CAGxC,MAAM,cAAc,MAAM,gBAFd,SAAS,aAAa,GAAG,eAAe,cAAc,IAEpB;AAC9C,KAAI,CAAC,YACH,QAAO;AAGT,QAAO,QACJ,YAAY,gBACX,eAAe,YAAY,gBAC3B,YAAY,aAAa,gBAC1B,YAAY,mBACX,eAAe,YAAY,mBAC3B,YAAY,gBAAgB,aAC/B;;;;;;;;;AAeH,eAAsB,kBACpB,MACA,cAC8C;CAC9C,MAAM,cAAc,eAAe,KAAK;CAGxC,MAAM,cAAc,MAAM,gBAFd,SAAS,aAAa,GAAG,eAAe,cAAc,IAEpB;AAC9C,KAAI,CAAC,YACH;CAGF,MAAM,UACJ,YAAY,gBAAgB,eAAe,YAAY,eACnD,YAAY,aAAa,eACzB,YAAY,mBACV,eAAe,YAAY,kBAC3B,YAAY,gBAAgB,eAC5B;CACR,MAAM,QACH,YAAY,gBAAgB,eAAe,YAAY,eACpD,iBACA,YAAY,mBACV,eAAe,YAAY,kBAC3B,oBACA,WAAc;AAEtB,QAAO,WAAW,OACd;EACE;EACA;EACD,GACD;;;;;;;;;;AAWN,eAAsB,iBACpB,MACA,SACA,KACkB;CAClB,MAAM,MAAM,MAAM,kBAAkB,MAAM,EAAE,KAAK,CAAC;AAClD,KAAI,CAAC,IACH,QAAO;AAGT,QACE,IAAI,QAAQ,WAAW,WAAW,IAClC,IAAI,QAAQ,WAAW,aAAa,IACpC,OAAO,IAAI,SAAS,QAAQ;;;;;;;;;AAWhC,SAAgB,gBAAgB,MAAc,UAA0B,EAAE,EAAE;AAC1E,QAAO,QAAQ,eAAe,MAAM,QAAQ,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
const require_runtime = require('./_virtual/_rolldown/runtime.cjs');
|
|
2
|
+
const require_package_fns = require('./package-fns.cjs');
|
|
3
|
+
let vitest = require("vitest");
|
|
4
|
+
|
|
5
|
+
//#region src/package-fns.test.ts
|
|
6
|
+
(0, vitest.describe)("package-fns.ts exports", () => {
|
|
7
|
+
(0, vitest.it)("loads module exports", () => {
|
|
8
|
+
(0, vitest.expect)(require_package_fns.package_fns_exports).toBeDefined();
|
|
9
|
+
(0, vitest.expect)(typeof require_package_fns.package_fns_exports).toBe("object");
|
|
10
|
+
});
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
//#endregion
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { package_fns_exports } from "./package-fns.mjs";
|
|
2
|
+
import { describe, expect, it } from "vitest";
|
|
3
|
+
|
|
4
|
+
//#region src/package-fns.test.ts
|
|
5
|
+
describe("package-fns.ts exports", () => {
|
|
6
|
+
it("loads module exports", () => {
|
|
7
|
+
expect(package_fns_exports).toBeDefined();
|
|
8
|
+
expect(typeof package_fns_exports).toBe("object");
|
|
9
|
+
});
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
//#endregion
|
|
13
|
+
export { };
|
|
14
|
+
//# sourceMappingURL=package-fns.test.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"package-fns.test.mjs","names":["moduleExports"],"sources":["../src/package-fns.test.ts"],"sourcesContent":["import { describe, expect, it } from \"vitest\";\nimport * as moduleExports from \"./package-fns.ts\";\n\ndescribe(\"package-fns.ts exports\", () => {\n it(\"loads module exports\", () => {\n expect(moduleExports).toBeDefined();\n expect(typeof moduleExports).toBe(\"object\");\n });\n});\n"],"mappings":";;;;AAGA,SAAS,gCAAgC;AACvC,IAAG,8BAA8B;AAC/B,SAAOA,oBAAc,CAAC,aAAa;AACnC,SAAO,OAAOA,oBAAc,CAAC,KAAK,SAAS;GAC3C;EACF"}
|
package/dist/read-file.cjs
CHANGED
|
@@ -4,6 +4,12 @@ let node_fs = require("node:fs");
|
|
|
4
4
|
let node_fs_promises = require("node:fs/promises");
|
|
5
5
|
|
|
6
6
|
//#region src/read-file.ts
|
|
7
|
+
var read_file_exports = /* @__PURE__ */ require_runtime.__exportAll({
|
|
8
|
+
readFile: () => readFile,
|
|
9
|
+
readFileIfExisting: () => readFileIfExisting,
|
|
10
|
+
readFileIfExistingSync: () => readFileIfExistingSync,
|
|
11
|
+
readFileSync: () => readFileSync
|
|
12
|
+
});
|
|
7
13
|
/**
|
|
8
14
|
* Read the given content to the given file path
|
|
9
15
|
*
|
|
@@ -45,4 +51,10 @@ async function readFileIfExisting(path) {
|
|
|
45
51
|
exports.readFile = readFile;
|
|
46
52
|
exports.readFileIfExisting = readFileIfExisting;
|
|
47
53
|
exports.readFileIfExistingSync = readFileIfExistingSync;
|
|
48
|
-
exports.readFileSync = readFileSync;
|
|
54
|
+
exports.readFileSync = readFileSync;
|
|
55
|
+
Object.defineProperty(exports, 'read_file_exports', {
|
|
56
|
+
enumerable: true,
|
|
57
|
+
get: function () {
|
|
58
|
+
return read_file_exports;
|
|
59
|
+
}
|
|
60
|
+
});
|
package/dist/read-file.mjs
CHANGED
|
@@ -1,7 +1,14 @@
|
|
|
1
|
+
import { __exportAll } from "./_virtual/_rolldown/runtime.mjs";
|
|
1
2
|
import { existsSync, readFileSync as readFileSync$1 } from "node:fs";
|
|
2
3
|
import { readFile as readFile$1 } from "node:fs/promises";
|
|
3
4
|
|
|
4
5
|
//#region src/read-file.ts
|
|
6
|
+
var read_file_exports = /* @__PURE__ */ __exportAll({
|
|
7
|
+
readFile: () => readFile,
|
|
8
|
+
readFileIfExisting: () => readFileIfExisting,
|
|
9
|
+
readFileIfExistingSync: () => readFileIfExistingSync,
|
|
10
|
+
readFileSync: () => readFileSync
|
|
11
|
+
});
|
|
5
12
|
/**
|
|
6
13
|
* Read the given content to the given file path
|
|
7
14
|
*
|
|
@@ -40,5 +47,5 @@ async function readFileIfExisting(path) {
|
|
|
40
47
|
}
|
|
41
48
|
|
|
42
49
|
//#endregion
|
|
43
|
-
export { readFile, readFileIfExisting, readFileIfExistingSync, readFileSync };
|
|
50
|
+
export { readFile, readFileIfExisting, readFileIfExistingSync, readFileSync, read_file_exports };
|
|
44
51
|
//# sourceMappingURL=read-file.mjs.map
|
package/dist/read-file.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"read-file.mjs","names":["readFileSyncFs","readFileFs"],"sources":["../src/read-file.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 { existsSync, readFileSync as readFileSyncFs } from \"node:fs\";\nimport { readFile as readFileFs } from \"node:fs/promises\";\n\n/**\n * Read the given content to the given file path\n *\n * @param filePath - The file path to write to\n */\nexport const readFileSync = (filePath: string): string => {\n if (!filePath) {\n throw new Error(\"No file path provided to read data\");\n }\n\n return readFileSyncFs(filePath, { encoding: \"utf8\" });\n};\n\n/**\n * Read the given content to the given file path\n *\n * @param filePath - The file path to read to\n */\nexport const readFile = async (filePath: string): Promise<string> => {\n if (!filePath) {\n throw new Error(\"No file path provided to read data\");\n }\n\n return readFileFs(filePath, { encoding: \"utf8\" });\n};\n\n/**\n * Reads a file if it exists, otherwise returns an empty string.\n *\n * @param path - The path to the file to read.\n * @returns The content of the file if it exists, otherwise an empty string.\n */\nexport function readFileIfExistingSync(path: string) {\n return existsSync(path) ? readFileSync(path) : \"\";\n}\n\n/**\n * Reads a file if it exists, otherwise returns an empty string.\n *\n * @param path - The path to the file to read.\n * @returns The content of the file if it exists, otherwise an empty string.\n */\nexport async function readFileIfExisting(path: string) {\n return existsSync(path) ? readFile(path) : \"\";\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"read-file.mjs","names":["readFileSyncFs","readFileFs"],"sources":["../src/read-file.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 { existsSync, readFileSync as readFileSyncFs } from \"node:fs\";\nimport { readFile as readFileFs } from \"node:fs/promises\";\n\n/**\n * Read the given content to the given file path\n *\n * @param filePath - The file path to write to\n */\nexport const readFileSync = (filePath: string): string => {\n if (!filePath) {\n throw new Error(\"No file path provided to read data\");\n }\n\n return readFileSyncFs(filePath, { encoding: \"utf8\" });\n};\n\n/**\n * Read the given content to the given file path\n *\n * @param filePath - The file path to read to\n */\nexport const readFile = async (filePath: string): Promise<string> => {\n if (!filePath) {\n throw new Error(\"No file path provided to read data\");\n }\n\n return readFileFs(filePath, { encoding: \"utf8\" });\n};\n\n/**\n * Reads a file if it exists, otherwise returns an empty string.\n *\n * @param path - The path to the file to read.\n * @returns The content of the file if it exists, otherwise an empty string.\n */\nexport function readFileIfExistingSync(path: string) {\n return existsSync(path) ? readFileSync(path) : \"\";\n}\n\n/**\n * Reads a file if it exists, otherwise returns an empty string.\n *\n * @param path - The path to the file to read.\n * @returns The content of the file if it exists, otherwise an empty string.\n */\nexport async function readFileIfExisting(path: string) {\n return existsSync(path) ? readFile(path) : \"\";\n}\n"],"mappings":";;;;;;;;;;;;;;;;AA0BA,MAAa,gBAAgB,aAA6B;AACxD,KAAI,CAAC,SACH,OAAM,IAAI,MAAM,qCAAqC;AAGvD,QAAOA,eAAe,UAAU,EAAE,UAAU,QAAQ,CAAC;;;;;;;AAQvD,MAAa,WAAW,OAAO,aAAsC;AACnE,KAAI,CAAC,SACH,OAAM,IAAI,MAAM,qCAAqC;AAGvD,QAAOC,WAAW,UAAU,EAAE,UAAU,QAAQ,CAAC;;;;;;;;AASnD,SAAgB,uBAAuB,MAAc;AACnD,QAAO,WAAW,KAAK,GAAG,aAAa,KAAK,GAAG;;;;;;;;AASjD,eAAsB,mBAAmB,MAAc;AACrD,QAAO,WAAW,KAAK,GAAG,SAAS,KAAK,GAAG"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
const require_runtime = require('./_virtual/_rolldown/runtime.cjs');
|
|
2
|
+
const require_read_file = require('./read-file.cjs');
|
|
3
|
+
let vitest = require("vitest");
|
|
4
|
+
|
|
5
|
+
//#region src/read-file.test.ts
|
|
6
|
+
(0, vitest.describe)("read-file.ts exports", () => {
|
|
7
|
+
(0, vitest.it)("loads module exports", () => {
|
|
8
|
+
(0, vitest.expect)(require_read_file.read_file_exports).toBeDefined();
|
|
9
|
+
(0, vitest.expect)(typeof require_read_file.read_file_exports).toBe("object");
|
|
10
|
+
});
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
//#endregion
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { read_file_exports } from "./read-file.mjs";
|
|
2
|
+
import { describe, expect, it } from "vitest";
|
|
3
|
+
|
|
4
|
+
//#region src/read-file.test.ts
|
|
5
|
+
describe("read-file.ts exports", () => {
|
|
6
|
+
it("loads module exports", () => {
|
|
7
|
+
expect(read_file_exports).toBeDefined();
|
|
8
|
+
expect(typeof read_file_exports).toBe("object");
|
|
9
|
+
});
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
//#endregion
|
|
13
|
+
export { };
|
|
14
|
+
//# sourceMappingURL=read-file.test.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"read-file.test.mjs","names":["moduleExports"],"sources":["../src/read-file.test.ts"],"sourcesContent":["import { describe, expect, it } from \"vitest\";\nimport * as moduleExports from \"./read-file.ts\";\n\ndescribe(\"read-file.ts exports\", () => {\n it(\"loads module exports\", () => {\n expect(moduleExports).toBeDefined();\n expect(typeof moduleExports).toBe(\"object\");\n });\n});\n"],"mappings":";;;;AAGA,SAAS,8BAA8B;AACrC,IAAG,8BAA8B;AAC/B,SAAOA,kBAAc,CAAC,aAAa;AACnC,SAAO,OAAOA,kBAAc,CAAC,KAAK,SAAS;GAC3C;EACF"}
|
package/dist/registry.cjs
CHANGED
|
@@ -6,6 +6,13 @@ let _antfu_install_pkg = require("@antfu/install-pkg");
|
|
|
6
6
|
let node_util = require("node:util");
|
|
7
7
|
|
|
8
8
|
//#region src/registry.ts
|
|
9
|
+
var registry_exports = /* @__PURE__ */ require_runtime.__exportAll({
|
|
10
|
+
formatNodeOptions: () => formatNodeOptions,
|
|
11
|
+
getFormattedNodeOptionsWithoutInspect: () => getFormattedNodeOptionsWithoutInspect,
|
|
12
|
+
getParsedNodeOptionsWithoutInspect: () => getParsedNodeOptionsWithoutInspect,
|
|
13
|
+
getRegistry: () => getRegistry,
|
|
14
|
+
tokenizeArgs: () => tokenizeArgs
|
|
15
|
+
});
|
|
9
16
|
const parseNodeArgs = (args) => {
|
|
10
17
|
const { values, tokens } = (0, node_util.parseArgs)({
|
|
11
18
|
args,
|
|
@@ -140,4 +147,10 @@ exports.formatNodeOptions = formatNodeOptions;
|
|
|
140
147
|
exports.getFormattedNodeOptionsWithoutInspect = getFormattedNodeOptionsWithoutInspect;
|
|
141
148
|
exports.getParsedNodeOptionsWithoutInspect = getParsedNodeOptionsWithoutInspect;
|
|
142
149
|
exports.getRegistry = getRegistry;
|
|
150
|
+
Object.defineProperty(exports, 'registry_exports', {
|
|
151
|
+
enumerable: true,
|
|
152
|
+
get: function () {
|
|
153
|
+
return registry_exports;
|
|
154
|
+
}
|
|
155
|
+
});
|
|
143
156
|
exports.tokenizeArgs = tokenizeArgs;
|
package/dist/registry.mjs
CHANGED
|
@@ -1,9 +1,17 @@
|
|
|
1
|
+
import { __exportAll } from "./_virtual/_rolldown/runtime.mjs";
|
|
1
2
|
import { getWorkspaceRoot } from "./get-workspace-root.mjs";
|
|
2
3
|
import { execSync } from "node:child_process";
|
|
3
4
|
import { detectPackageManager } from "@antfu/install-pkg";
|
|
4
5
|
import { parseArgs } from "node:util";
|
|
5
6
|
|
|
6
7
|
//#region src/registry.ts
|
|
8
|
+
var registry_exports = /* @__PURE__ */ __exportAll({
|
|
9
|
+
formatNodeOptions: () => formatNodeOptions,
|
|
10
|
+
getFormattedNodeOptionsWithoutInspect: () => getFormattedNodeOptionsWithoutInspect,
|
|
11
|
+
getParsedNodeOptionsWithoutInspect: () => getParsedNodeOptionsWithoutInspect,
|
|
12
|
+
getRegistry: () => getRegistry,
|
|
13
|
+
tokenizeArgs: () => tokenizeArgs
|
|
14
|
+
});
|
|
7
15
|
const parseNodeArgs = (args) => {
|
|
8
16
|
const { values, tokens } = parseArgs({
|
|
9
17
|
args,
|
|
@@ -134,5 +142,5 @@ async function getRegistry(baseDir) {
|
|
|
134
142
|
}
|
|
135
143
|
|
|
136
144
|
//#endregion
|
|
137
|
-
export { formatNodeOptions, getFormattedNodeOptionsWithoutInspect, getParsedNodeOptionsWithoutInspect, getRegistry, tokenizeArgs };
|
|
145
|
+
export { formatNodeOptions, getFormattedNodeOptionsWithoutInspect, getParsedNodeOptionsWithoutInspect, getRegistry, registry_exports, tokenizeArgs };
|
|
138
146
|
//# sourceMappingURL=registry.mjs.map
|
package/dist/registry.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"registry.mjs","names":[],"sources":["../src/registry.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 { detectPackageManager } from \"@antfu/install-pkg\";\nimport { execSync } from \"node:child_process\";\nimport { parseArgs } from \"node:util\";\nimport { getWorkspaceRoot } from \"./get-workspace-root\";\n\nexport interface NodeOptionsToken {\n kind: \"option\";\n index: number;\n name: string;\n rawName: string;\n value: undefined;\n inlineValue: undefined;\n}\n\nconst parseNodeArgs = (args: string[]) => {\n const { values, tokens } = parseArgs({ args, strict: false, tokens: true });\n\n // For the `NODE_OPTIONS`, we support arguments with values without the `=`\n // sign. We need to parse them manually.\n let orphan: NodeOptionsToken | null | undefined = null;\n for (let i = 0; i < tokens.length; i++) {\n const token = tokens[i]!;\n\n if (token.kind === \"option-terminator\") {\n break;\n }\n\n // When we encounter an option, if it's value is undefined, we should check\n // to see if the following tokens are positional parameters. If they are,\n // then the option is orphaned, and we can assign it.\n if (token.kind === \"option\") {\n orphan = typeof token.value === \"undefined\" ? token : null;\n continue;\n }\n\n // If the token isn't a positional one, then we can't assign it to the found\n // orphaned option.\n if (token.kind !== \"positional\") {\n orphan = null;\n continue;\n }\n\n // If we don't have an orphan, then we can skip this token.\n if (!orphan) {\n continue;\n }\n\n // If the token is a positional one, and it has a value, so add it to the\n // values object. If it already exists, append it with a space.\n if (orphan.name in values && typeof values[orphan.name] === \"string\") {\n values[orphan.name] += ` ${token.value}`;\n } else {\n values[orphan.name] = token.value;\n }\n }\n\n return values;\n};\n\n/**\n * Tokenizes the arguments string into an array of strings, supporting quoted\n * values and escaped characters.\n * Converted from: https://github.com/nodejs/node/blob/c29d53c5cfc63c5a876084e788d70c9e87bed880/src/node_options.cc#L1401\n *\n * @param input - The arguments string to be tokenized.\n * @returns An array of strings with the tokenized arguments.\n */\nexport const tokenizeArgs = (input: string): string[] => {\n const args: string[] = [];\n let isInString = false;\n let willStartNewArg = true;\n\n for (let i = 0; i < input.length; i++) {\n let char = input[i]!;\n\n // Skip any escaped characters in strings.\n if (char === \"\\\\\" && isInString) {\n // Ensure we don't have an escape character at the end.\n if (input.length === i + 1) {\n throw new Error(\"Invalid escape character at the end.\");\n }\n\n // Skip the next character.\n char = input[++i]!;\n }\n // If we find a space outside of a string, we should start a new argument.\n else if (char === \" \" && !isInString) {\n willStartNewArg = true;\n continue;\n }\n\n // If we find a quote, we should toggle the string flag.\n else if (char === '\"') {\n isInString = !isInString;\n continue;\n }\n\n // If we're starting a new argument, we should add it to the array.\n if (willStartNewArg) {\n args.push(char);\n willStartNewArg = false;\n }\n // Otherwise, add it to the last argument.\n else {\n args[args.length - 1] += char;\n }\n }\n\n if (isInString) {\n throw new Error(\"Unterminated string\");\n }\n\n return args;\n};\n\n/**\n * Get the node options from the environment variable `NODE_OPTIONS` and returns\n * them as an array of strings.\n *\n * @returns An array of strings with the node options.\n */\nconst getNodeOptionsArgs = () => {\n if (!process.env.NODE_OPTIONS) return [];\n\n return tokenizeArgs(process.env.NODE_OPTIONS);\n};\n\n/**\n * Stringify the arguments to be used in a command line. It will ignore any\n * argument that has a value of `undefined`.\n *\n * @param args - The arguments to be stringified.\n * @returns A string with the arguments.\n */\nexport function formatNodeOptions(\n args: Record<string, string | boolean | undefined>\n): string {\n return Object.entries(args)\n .map(([key, value]) => {\n if (value === true) {\n return `--${key}`;\n }\n\n if (value) {\n return `--${key}=${\n // Values with spaces need to be quoted. We use JSON.stringify to\n // also escape any nested quotes.\n value.includes(\" \") && !value.startsWith('\"')\n ? JSON.stringify(value)\n : value\n }`;\n }\n\n return null;\n })\n .filter(arg => arg !== null)\n .join(\" \");\n}\n\n/**\n * Get the node options from the `NODE_OPTIONS` environment variable and parse\n * them into an object without the inspect options.\n *\n * @returns An object with the parsed node options.\n */\nexport function getParsedNodeOptionsWithoutInspect() {\n const args = getNodeOptionsArgs();\n if (args.length === 0) return {};\n\n const parsed = parseNodeArgs(args);\n\n // Remove inspect options.\n delete parsed.inspect;\n delete parsed[\"inspect-brk\"];\n delete parsed.inspect_brk;\n\n return parsed;\n}\n\n/**\n * Get the node options from the `NODE_OPTIONS` environment variable and format\n * them into a string without the inspect options.\n *\n * @returns A string with the formatted node options.\n */\nexport function getFormattedNodeOptionsWithoutInspect() {\n const args = getParsedNodeOptionsWithoutInspect();\n if (Object.keys(args).length === 0) return \"\";\n\n return formatNodeOptions(args);\n}\n\n/**\n * Returns the package registry using the user's package manager. The URL will have a trailing slash.\n *\n * @param baseDir - The base directory to detect the package manager from.\n * @returns The package registry URL with a trailing slash.\n * @throws Will throw an error if the package manager cannot be detected or if the registry cannot be retrieved.\n */\nexport async function getRegistry(baseDir?: string) {\n const workspaceRoot = getWorkspaceRoot(baseDir);\n const pkgManager = await detectPackageManager(workspaceRoot);\n\n // Since `npm config` command fails in npm workspace to prevent workspace config conflicts,\n // add `--no-workspaces` flag to run under the context of the root project only.\n // Safe for non-workspace projects as it's equivalent to default `--workspaces=false`.\n // x-ref: https://github.com/vercel/next.js/issues/47121#issuecomment-1499044345\n // x-ref: https://github.com/npm/statusboard/issues/371#issue-920669998\n const resolvedFlags = pkgManager === \"npm\" ? \"--no-workspaces\" : \"\";\n let registry = `https://registry.npmjs.org/`;\n\n try {\n const output = execSync(\n `${pkgManager} config get registry ${resolvedFlags}`,\n {\n env: {\n ...process.env,\n NODE_OPTIONS: getFormattedNodeOptionsWithoutInspect()\n }\n }\n )\n .toString()\n .trim();\n\n if (output.startsWith(\"http\")) {\n registry = output.endsWith(\"/\") ? output : `${output}/`;\n }\n } catch (err) {\n throw new Error(`Failed to get registry from \"${pkgManager}\".`, {\n cause: err\n });\n }\n\n return registry;\n}\n"],"mappings":";;;;;;AAgCA,MAAM,iBAAiB,SAAmB;CACxC,MAAM,EAAE,QAAQ,WAAW,UAAU;EAAE;EAAM,QAAQ;EAAO,QAAQ;EAAM,CAAC;CAI3E,IAAI,SAA8C;AAClD,MAAK,IAAI,IAAI,GAAG,IAAI,OAAO,QAAQ,KAAK;EACtC,MAAM,QAAQ,OAAO;AAErB,MAAI,MAAM,SAAS,oBACjB;AAMF,MAAI,MAAM,SAAS,UAAU;AAC3B,YAAS,OAAO,MAAM,UAAU,cAAc,QAAQ;AACtD;;AAKF,MAAI,MAAM,SAAS,cAAc;AAC/B,YAAS;AACT;;AAIF,MAAI,CAAC,OACH;AAKF,MAAI,OAAO,QAAQ,UAAU,OAAO,OAAO,OAAO,UAAU,SAC1D,QAAO,OAAO,SAAS,IAAI,MAAM;MAEjC,QAAO,OAAO,QAAQ,MAAM;;AAIhC,QAAO;;;;;;;;;;AAWT,MAAa,gBAAgB,UAA4B;CACvD,MAAM,OAAiB,EAAE;CACzB,IAAI,aAAa;CACjB,IAAI,kBAAkB;AAEtB,MAAK,IAAI,IAAI,GAAG,IAAI,MAAM,QAAQ,KAAK;EACrC,IAAI,OAAO,MAAM;AAGjB,MAAI,SAAS,QAAQ,YAAY;AAE/B,OAAI,MAAM,WAAW,IAAI,EACvB,OAAM,IAAI,MAAM,uCAAuC;AAIzD,UAAO,MAAM,EAAE;aAGR,SAAS,OAAO,CAAC,YAAY;AACpC,qBAAkB;AAClB;aAIO,SAAS,MAAK;AACrB,gBAAa,CAAC;AACd;;AAIF,MAAI,iBAAiB;AACnB,QAAK,KAAK,KAAK;AACf,qBAAkB;QAIlB,MAAK,KAAK,SAAS,MAAM;;AAI7B,KAAI,WACF,OAAM,IAAI,MAAM,sBAAsB;AAGxC,QAAO;;;;;;;;AAST,MAAM,2BAA2B;AAC/B,KAAI,CAAC,QAAQ,IAAI,aAAc,QAAO,EAAE;AAExC,QAAO,aAAa,QAAQ,IAAI,aAAa;;;;;;;;;AAU/C,SAAgB,kBACd,MACQ;AACR,QAAO,OAAO,QAAQ,KAAK,CACxB,KAAK,CAAC,KAAK,WAAW;AACrB,MAAI,UAAU,KACZ,QAAO,KAAK;AAGd,MAAI,MACF,QAAO,KAAK,IAAI,GAGd,MAAM,SAAS,IAAI,IAAI,CAAC,MAAM,WAAW,KAAI,GACzC,KAAK,UAAU,MAAM,GACrB;AAIR,SAAO;GACP,CACD,QAAO,QAAO,QAAQ,KAAK,CAC3B,KAAK,IAAI;;;;;;;;AASd,SAAgB,qCAAqC;CACnD,MAAM,OAAO,oBAAoB;AACjC,KAAI,KAAK,WAAW,EAAG,QAAO,EAAE;CAEhC,MAAM,SAAS,cAAc,KAAK;AAGlC,QAAO,OAAO;AACd,QAAO,OAAO;AACd,QAAO,OAAO;AAEd,QAAO;;;;;;;;AAST,SAAgB,wCAAwC;CACtD,MAAM,OAAO,oCAAoC;AACjD,KAAI,OAAO,KAAK,KAAK,CAAC,WAAW,EAAG,QAAO;AAE3C,QAAO,kBAAkB,KAAK;;;;;;;;;AAUhC,eAAsB,YAAY,SAAkB;CAElD,MAAM,aAAa,MAAM,qBADH,iBAAiB,QACoB,CAAC;CAO5D,MAAM,gBAAgB,eAAe,QAAQ,oBAAoB;CACjE,IAAI,WAAW;AAEf,KAAI;EACF,MAAM,SAAS,SACb,GAAG,WAAW,uBAAuB,iBACrC,EACE,KAAK;GACH,GAAG,QAAQ;GACX,cAAc,uCAAuC;GACtD,EACF,CACF,CACE,UAAU,CACV,MAAM;AAET,MAAI,OAAO,WAAW,OAAO,CAC3B,YAAW,OAAO,SAAS,IAAI,GAAG,SAAS,GAAG,OAAO;UAEhD,KAAK;AACZ,QAAM,IAAI,MAAM,gCAAgC,WAAW,KAAK,EAC9D,OAAO,KACR,CAAC;;AAGJ,QAAO"}
|
|
1
|
+
{"version":3,"file":"registry.mjs","names":[],"sources":["../src/registry.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 { detectPackageManager } from \"@antfu/install-pkg\";\nimport { execSync } from \"node:child_process\";\nimport { parseArgs } from \"node:util\";\nimport { getWorkspaceRoot } from \"./get-workspace-root\";\n\nexport interface NodeOptionsToken {\n kind: \"option\";\n index: number;\n name: string;\n rawName: string;\n value: undefined;\n inlineValue: undefined;\n}\n\nconst parseNodeArgs = (args: string[]) => {\n const { values, tokens } = parseArgs({ args, strict: false, tokens: true });\n\n // For the `NODE_OPTIONS`, we support arguments with values without the `=`\n // sign. We need to parse them manually.\n let orphan: NodeOptionsToken | null | undefined = null;\n for (let i = 0; i < tokens.length; i++) {\n const token = tokens[i]!;\n\n if (token.kind === \"option-terminator\") {\n break;\n }\n\n // When we encounter an option, if it's value is undefined, we should check\n // to see if the following tokens are positional parameters. If they are,\n // then the option is orphaned, and we can assign it.\n if (token.kind === \"option\") {\n orphan = typeof token.value === \"undefined\" ? token : null;\n continue;\n }\n\n // If the token isn't a positional one, then we can't assign it to the found\n // orphaned option.\n if (token.kind !== \"positional\") {\n orphan = null;\n continue;\n }\n\n // If we don't have an orphan, then we can skip this token.\n if (!orphan) {\n continue;\n }\n\n // If the token is a positional one, and it has a value, so add it to the\n // values object. If it already exists, append it with a space.\n if (orphan.name in values && typeof values[orphan.name] === \"string\") {\n values[orphan.name] += ` ${token.value}`;\n } else {\n values[orphan.name] = token.value;\n }\n }\n\n return values;\n};\n\n/**\n * Tokenizes the arguments string into an array of strings, supporting quoted\n * values and escaped characters.\n * Converted from: https://github.com/nodejs/node/blob/c29d53c5cfc63c5a876084e788d70c9e87bed880/src/node_options.cc#L1401\n *\n * @param input - The arguments string to be tokenized.\n * @returns An array of strings with the tokenized arguments.\n */\nexport const tokenizeArgs = (input: string): string[] => {\n const args: string[] = [];\n let isInString = false;\n let willStartNewArg = true;\n\n for (let i = 0; i < input.length; i++) {\n let char = input[i]!;\n\n // Skip any escaped characters in strings.\n if (char === \"\\\\\" && isInString) {\n // Ensure we don't have an escape character at the end.\n if (input.length === i + 1) {\n throw new Error(\"Invalid escape character at the end.\");\n }\n\n // Skip the next character.\n char = input[++i]!;\n }\n // If we find a space outside of a string, we should start a new argument.\n else if (char === \" \" && !isInString) {\n willStartNewArg = true;\n continue;\n }\n\n // If we find a quote, we should toggle the string flag.\n else if (char === '\"') {\n isInString = !isInString;\n continue;\n }\n\n // If we're starting a new argument, we should add it to the array.\n if (willStartNewArg) {\n args.push(char);\n willStartNewArg = false;\n }\n // Otherwise, add it to the last argument.\n else {\n args[args.length - 1] += char;\n }\n }\n\n if (isInString) {\n throw new Error(\"Unterminated string\");\n }\n\n return args;\n};\n\n/**\n * Get the node options from the environment variable `NODE_OPTIONS` and returns\n * them as an array of strings.\n *\n * @returns An array of strings with the node options.\n */\nconst getNodeOptionsArgs = () => {\n if (!process.env.NODE_OPTIONS) return [];\n\n return tokenizeArgs(process.env.NODE_OPTIONS);\n};\n\n/**\n * Stringify the arguments to be used in a command line. It will ignore any\n * argument that has a value of `undefined`.\n *\n * @param args - The arguments to be stringified.\n * @returns A string with the arguments.\n */\nexport function formatNodeOptions(\n args: Record<string, string | boolean | undefined>\n): string {\n return Object.entries(args)\n .map(([key, value]) => {\n if (value === true) {\n return `--${key}`;\n }\n\n if (value) {\n return `--${key}=${\n // Values with spaces need to be quoted. We use JSON.stringify to\n // also escape any nested quotes.\n value.includes(\" \") && !value.startsWith('\"')\n ? JSON.stringify(value)\n : value\n }`;\n }\n\n return null;\n })\n .filter(arg => arg !== null)\n .join(\" \");\n}\n\n/**\n * Get the node options from the `NODE_OPTIONS` environment variable and parse\n * them into an object without the inspect options.\n *\n * @returns An object with the parsed node options.\n */\nexport function getParsedNodeOptionsWithoutInspect() {\n const args = getNodeOptionsArgs();\n if (args.length === 0) return {};\n\n const parsed = parseNodeArgs(args);\n\n // Remove inspect options.\n delete parsed.inspect;\n delete parsed[\"inspect-brk\"];\n delete parsed.inspect_brk;\n\n return parsed;\n}\n\n/**\n * Get the node options from the `NODE_OPTIONS` environment variable and format\n * them into a string without the inspect options.\n *\n * @returns A string with the formatted node options.\n */\nexport function getFormattedNodeOptionsWithoutInspect() {\n const args = getParsedNodeOptionsWithoutInspect();\n if (Object.keys(args).length === 0) return \"\";\n\n return formatNodeOptions(args);\n}\n\n/**\n * Returns the package registry using the user's package manager. The URL will have a trailing slash.\n *\n * @param baseDir - The base directory to detect the package manager from.\n * @returns The package registry URL with a trailing slash.\n * @throws Will throw an error if the package manager cannot be detected or if the registry cannot be retrieved.\n */\nexport async function getRegistry(baseDir?: string) {\n const workspaceRoot = getWorkspaceRoot(baseDir);\n const pkgManager = await detectPackageManager(workspaceRoot);\n\n // Since `npm config` command fails in npm workspace to prevent workspace config conflicts,\n // add `--no-workspaces` flag to run under the context of the root project only.\n // Safe for non-workspace projects as it's equivalent to default `--workspaces=false`.\n // x-ref: https://github.com/vercel/next.js/issues/47121#issuecomment-1499044345\n // x-ref: https://github.com/npm/statusboard/issues/371#issue-920669998\n const resolvedFlags = pkgManager === \"npm\" ? \"--no-workspaces\" : \"\";\n let registry = `https://registry.npmjs.org/`;\n\n try {\n const output = execSync(\n `${pkgManager} config get registry ${resolvedFlags}`,\n {\n env: {\n ...process.env,\n NODE_OPTIONS: getFormattedNodeOptionsWithoutInspect()\n }\n }\n )\n .toString()\n .trim();\n\n if (output.startsWith(\"http\")) {\n registry = output.endsWith(\"/\") ? output : `${output}/`;\n }\n } catch (err) {\n throw new Error(`Failed to get registry from \"${pkgManager}\".`, {\n cause: err\n });\n }\n\n return registry;\n}\n"],"mappings":";;;;;;;;;;;;;;AAgCA,MAAM,iBAAiB,SAAmB;CACxC,MAAM,EAAE,QAAQ,WAAW,UAAU;EAAE;EAAM,QAAQ;EAAO,QAAQ;EAAM,CAAC;CAI3E,IAAI,SAA8C;AAClD,MAAK,IAAI,IAAI,GAAG,IAAI,OAAO,QAAQ,KAAK;EACtC,MAAM,QAAQ,OAAO;AAErB,MAAI,MAAM,SAAS,oBACjB;AAMF,MAAI,MAAM,SAAS,UAAU;AAC3B,YAAS,OAAO,MAAM,UAAU,cAAc,QAAQ;AACtD;;AAKF,MAAI,MAAM,SAAS,cAAc;AAC/B,YAAS;AACT;;AAIF,MAAI,CAAC,OACH;AAKF,MAAI,OAAO,QAAQ,UAAU,OAAO,OAAO,OAAO,UAAU,SAC1D,QAAO,OAAO,SAAS,IAAI,MAAM;MAEjC,QAAO,OAAO,QAAQ,MAAM;;AAIhC,QAAO;;;;;;;;;;AAWT,MAAa,gBAAgB,UAA4B;CACvD,MAAM,OAAiB,EAAE;CACzB,IAAI,aAAa;CACjB,IAAI,kBAAkB;AAEtB,MAAK,IAAI,IAAI,GAAG,IAAI,MAAM,QAAQ,KAAK;EACrC,IAAI,OAAO,MAAM;AAGjB,MAAI,SAAS,QAAQ,YAAY;AAE/B,OAAI,MAAM,WAAW,IAAI,EACvB,OAAM,IAAI,MAAM,uCAAuC;AAIzD,UAAO,MAAM,EAAE;aAGR,SAAS,OAAO,CAAC,YAAY;AACpC,qBAAkB;AAClB;aAIO,SAAS,MAAK;AACrB,gBAAa,CAAC;AACd;;AAIF,MAAI,iBAAiB;AACnB,QAAK,KAAK,KAAK;AACf,qBAAkB;QAIlB,MAAK,KAAK,SAAS,MAAM;;AAI7B,KAAI,WACF,OAAM,IAAI,MAAM,sBAAsB;AAGxC,QAAO;;;;;;;;AAST,MAAM,2BAA2B;AAC/B,KAAI,CAAC,QAAQ,IAAI,aAAc,QAAO,EAAE;AAExC,QAAO,aAAa,QAAQ,IAAI,aAAa;;;;;;;;;AAU/C,SAAgB,kBACd,MACQ;AACR,QAAO,OAAO,QAAQ,KAAK,CACxB,KAAK,CAAC,KAAK,WAAW;AACrB,MAAI,UAAU,KACZ,QAAO,KAAK;AAGd,MAAI,MACF,QAAO,KAAK,IAAI,GAGd,MAAM,SAAS,IAAI,IAAI,CAAC,MAAM,WAAW,KAAI,GACzC,KAAK,UAAU,MAAM,GACrB;AAIR,SAAO;GACP,CACD,QAAO,QAAO,QAAQ,KAAK,CAC3B,KAAK,IAAI;;;;;;;;AASd,SAAgB,qCAAqC;CACnD,MAAM,OAAO,oBAAoB;AACjC,KAAI,KAAK,WAAW,EAAG,QAAO,EAAE;CAEhC,MAAM,SAAS,cAAc,KAAK;AAGlC,QAAO,OAAO;AACd,QAAO,OAAO;AACd,QAAO,OAAO;AAEd,QAAO;;;;;;;;AAST,SAAgB,wCAAwC;CACtD,MAAM,OAAO,oCAAoC;AACjD,KAAI,OAAO,KAAK,KAAK,CAAC,WAAW,EAAG,QAAO;AAE3C,QAAO,kBAAkB,KAAK;;;;;;;;;AAUhC,eAAsB,YAAY,SAAkB;CAElD,MAAM,aAAa,MAAM,qBADH,iBAAiB,QACoB,CAAC;CAO5D,MAAM,gBAAgB,eAAe,QAAQ,oBAAoB;CACjE,IAAI,WAAW;AAEf,KAAI;EACF,MAAM,SAAS,SACb,GAAG,WAAW,uBAAuB,iBACrC,EACE,KAAK;GACH,GAAG,QAAQ;GACX,cAAc,uCAAuC;GACtD,EACF,CACF,CACE,UAAU,CACV,MAAM;AAET,MAAI,OAAO,WAAW,OAAO,CAC3B,YAAW,OAAO,SAAS,IAAI,GAAG,SAAS,GAAG,OAAO;UAEhD,KAAK;AACZ,QAAM,IAAI,MAAM,gCAAgC,WAAW,KAAK,EAC9D,OAAO,KACR,CAAC;;AAGJ,QAAO"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
const require_runtime = require('./_virtual/_rolldown/runtime.cjs');
|
|
2
|
+
const require_registry = require('./registry.cjs');
|
|
3
|
+
let vitest = require("vitest");
|
|
4
|
+
|
|
5
|
+
//#region src/registry.test.ts
|
|
6
|
+
(0, vitest.describe)("registry.ts exports", () => {
|
|
7
|
+
(0, vitest.it)("loads module exports", () => {
|
|
8
|
+
(0, vitest.expect)(require_registry.registry_exports).toBeDefined();
|
|
9
|
+
(0, vitest.expect)(typeof require_registry.registry_exports).toBe("object");
|
|
10
|
+
});
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
//#endregion
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { registry_exports } from "./registry.mjs";
|
|
2
|
+
import { describe, expect, it } from "vitest";
|
|
3
|
+
|
|
4
|
+
//#region src/registry.test.ts
|
|
5
|
+
describe("registry.ts exports", () => {
|
|
6
|
+
it("loads module exports", () => {
|
|
7
|
+
expect(registry_exports).toBeDefined();
|
|
8
|
+
expect(typeof registry_exports).toBe("object");
|
|
9
|
+
});
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
//#endregion
|
|
13
|
+
export { };
|
|
14
|
+
//# sourceMappingURL=registry.test.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registry.test.mjs","names":["moduleExports"],"sources":["../src/registry.test.ts"],"sourcesContent":["import { describe, expect, it } from \"vitest\";\nimport * as moduleExports from \"./registry.ts\";\n\ndescribe(\"registry.ts exports\", () => {\n it(\"loads module exports\", () => {\n expect(moduleExports).toBeDefined();\n expect(typeof moduleExports).toBe(\"object\");\n });\n});\n"],"mappings":";;;;AAGA,SAAS,6BAA6B;AACpC,IAAG,8BAA8B;AAC/B,SAAOA,iBAAc,CAAC,aAAa;AACnC,SAAO,OAAOA,iBAAc,CAAC,KAAK,SAAS;GAC3C;EACF"}
|
package/dist/remove-file.cjs
CHANGED
|
@@ -4,6 +4,10 @@ let node_fs = require("node:fs");
|
|
|
4
4
|
let node_fs_promises = require("node:fs/promises");
|
|
5
5
|
|
|
6
6
|
//#region src/remove-file.ts
|
|
7
|
+
var remove_file_exports = /* @__PURE__ */ require_runtime.__exportAll({
|
|
8
|
+
removeFile: () => removeFile,
|
|
9
|
+
removeFileSync: () => removeFileSync
|
|
10
|
+
});
|
|
7
11
|
/**
|
|
8
12
|
* Remove the given content to the given file path
|
|
9
13
|
*
|
|
@@ -25,4 +29,10 @@ const removeFile = async (filePath) => {
|
|
|
25
29
|
|
|
26
30
|
//#endregion
|
|
27
31
|
exports.removeFile = removeFile;
|
|
28
|
-
exports.removeFileSync = removeFileSync;
|
|
32
|
+
exports.removeFileSync = removeFileSync;
|
|
33
|
+
Object.defineProperty(exports, 'remove_file_exports', {
|
|
34
|
+
enumerable: true,
|
|
35
|
+
get: function () {
|
|
36
|
+
return remove_file_exports;
|
|
37
|
+
}
|
|
38
|
+
});
|
package/dist/remove-file.mjs
CHANGED
|
@@ -1,7 +1,12 @@
|
|
|
1
|
+
import { __exportAll } from "./_virtual/_rolldown/runtime.mjs";
|
|
1
2
|
import { existsSync, rmSync } from "node:fs";
|
|
2
3
|
import { rm } from "node:fs/promises";
|
|
3
4
|
|
|
4
5
|
//#region src/remove-file.ts
|
|
6
|
+
var remove_file_exports = /* @__PURE__ */ __exportAll({
|
|
7
|
+
removeFile: () => removeFile,
|
|
8
|
+
removeFileSync: () => removeFileSync
|
|
9
|
+
});
|
|
5
10
|
/**
|
|
6
11
|
* Remove the given content to the given file path
|
|
7
12
|
*
|
|
@@ -22,5 +27,5 @@ const removeFile = async (filePath) => {
|
|
|
22
27
|
};
|
|
23
28
|
|
|
24
29
|
//#endregion
|
|
25
|
-
export { removeFile, removeFileSync };
|
|
30
|
+
export { removeFile, removeFileSync, remove_file_exports };
|
|
26
31
|
//# sourceMappingURL=remove-file.mjs.map
|
package/dist/remove-file.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"remove-file.mjs","names":[],"sources":["../src/remove-file.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 { existsSync, rmSync } from \"node:fs\";\nimport { rm } from \"node:fs/promises\";\n\n/**\n * Remove the given content to the given file path\n *\n * @param filePath - The file path to remove to\n */\nexport const removeFileSync = (filePath: string): void => {\n if (!filePath || !existsSync(filePath)) {\n return;\n }\n\n rmSync(filePath);\n};\n\n/**\n * Remove the given content to the given file path\n *\n * @param filePath - The file path to read to\n */\nexport const removeFile = async (filePath: string): Promise<void> => {\n if (!filePath || !existsSync(filePath)) {\n return;\n }\n\n return rm(filePath);\n};\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"remove-file.mjs","names":[],"sources":["../src/remove-file.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 { existsSync, rmSync } from \"node:fs\";\nimport { rm } from \"node:fs/promises\";\n\n/**\n * Remove the given content to the given file path\n *\n * @param filePath - The file path to remove to\n */\nexport const removeFileSync = (filePath: string): void => {\n if (!filePath || !existsSync(filePath)) {\n return;\n }\n\n rmSync(filePath);\n};\n\n/**\n * Remove the given content to the given file path\n *\n * @param filePath - The file path to read to\n */\nexport const removeFile = async (filePath: string): Promise<void> => {\n if (!filePath || !existsSync(filePath)) {\n return;\n }\n\n return rm(filePath);\n};\n"],"mappings":";;;;;;;;;;;;;;AA0BA,MAAa,kBAAkB,aAA2B;AACxD,KAAI,CAAC,YAAY,CAAC,WAAW,SAAS,CACpC;AAGF,QAAO,SAAS;;;;;;;AAQlB,MAAa,aAAa,OAAO,aAAoC;AACnE,KAAI,CAAC,YAAY,CAAC,WAAW,SAAS,CACpC;AAGF,QAAO,GAAG,SAAS"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
const require_runtime = require('./_virtual/_rolldown/runtime.cjs');
|
|
2
|
+
const require_remove_file = require('./remove-file.cjs');
|
|
3
|
+
let vitest = require("vitest");
|
|
4
|
+
|
|
5
|
+
//#region src/remove-file.test.ts
|
|
6
|
+
(0, vitest.describe)("remove-file.ts exports", () => {
|
|
7
|
+
(0, vitest.it)("loads module exports", () => {
|
|
8
|
+
(0, vitest.expect)(require_remove_file.remove_file_exports).toBeDefined();
|
|
9
|
+
(0, vitest.expect)(typeof require_remove_file.remove_file_exports).toBe("object");
|
|
10
|
+
});
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
//#endregion
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|