@stryke/fs 0.33.32 → 0.33.33
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 +6 -0
- package/dist/_virtual/rolldown_runtime.cjs +29 -1
- package/dist/buffer.cjs +60 -1
- package/dist/buffer.mjs +56 -1
- package/dist/buffer.mjs.map +1 -1
- package/dist/chmod-x.cjs +93 -1
- package/dist/chmod-x.d.cts.map +1 -1
- package/dist/chmod-x.mjs +87 -1
- package/dist/chmod-x.mjs.map +1 -1
- package/dist/command-exists.cjs +102 -1
- package/dist/command-exists.mjs +100 -1
- package/dist/command-exists.mjs.map +1 -1
- package/dist/compress.cjs +29 -1
- package/dist/compress.mjs +28 -1
- package/dist/compress.mjs.map +1 -1
- package/dist/constants.mjs +1 -1
- package/dist/convert/src/array-buffer-to-string.cjs +19 -1
- package/dist/convert/src/array-buffer-to-string.mjs +18 -1
- package/dist/convert/src/array-buffer-to-string.mjs.map +1 -1
- package/dist/convert/src/to-array.cjs +15 -1
- package/dist/convert/src/to-array.mjs +14 -1
- package/dist/convert/src/to-array.mjs.map +1 -1
- package/dist/convert/src/uint8-array-to-string.cjs +15 -1
- package/dist/convert/src/uint8-array-to-string.mjs +15 -1
- package/dist/convert/src/uint8-array-to-string.mjs.map +1 -1
- package/dist/copy-file.cjs +87 -1
- package/dist/copy-file.mjs +83 -1
- package/dist/copy-file.mjs.map +1 -1
- package/dist/exists.cjs +27 -1
- package/dist/exists.mjs +25 -1
- package/dist/exists.mjs.map +1 -1
- package/dist/get-parent-path.cjs +35 -1
- package/dist/get-parent-path.mjs +34 -1
- package/dist/get-parent-path.mjs.map +1 -1
- package/dist/get-workspace-root.cjs +158 -1
- package/dist/get-workspace-root.mjs +150 -1
- package/dist/get-workspace-root.mjs.map +1 -1
- package/dist/helpers/src/get-unique.cjs +14 -1
- package/dist/helpers/src/get-unique.mjs +13 -1
- package/dist/helpers/src/get-unique.mjs.map +1 -1
- package/dist/helpers.cjs +83 -1
- package/dist/helpers.mjs +77 -1
- package/dist/helpers.mjs.map +1 -1
- package/dist/index.cjs +122 -1
- package/dist/index.mjs +25 -1
- package/dist/install.cjs +35 -1
- package/dist/install.mjs +33 -1
- package/dist/install.mjs.map +1 -1
- package/dist/is-file.cjs +51 -1
- package/dist/is-file.mjs +47 -1
- package/dist/is-file.mjs.map +1 -1
- package/dist/json/src/storm-json.cjs +117 -1
- package/dist/json/src/storm-json.mjs +115 -1
- package/dist/json/src/storm-json.mjs.map +1 -1
- package/dist/json/src/utils/code-frames.cjs +77 -3
- package/dist/json/src/utils/code-frames.mjs +76 -3
- package/dist/json/src/utils/code-frames.mjs.map +1 -1
- package/dist/json/src/utils/parse-error.cjs +34 -1
- package/dist/json/src/utils/parse-error.mjs +33 -1
- package/dist/json/src/utils/parse-error.mjs.map +1 -1
- package/dist/json/src/utils/parse.cjs +45 -1
- package/dist/json/src/utils/parse.mjs +45 -1
- package/dist/json/src/utils/parse.mjs.map +1 -1
- package/dist/json/src/utils/stringify.cjs +67 -1
- package/dist/json/src/utils/stringify.mjs +67 -1
- package/dist/json/src/utils/stringify.mjs.map +1 -1
- package/dist/json/src/utils/strip-comments.cjs +86 -4
- package/dist/json/src/utils/strip-comments.mjs +86 -4
- package/dist/json/src/utils/strip-comments.mjs.map +1 -1
- package/dist/json.cjs +74 -1
- package/dist/json.mjs +71 -1
- package/dist/json.mjs.map +1 -1
- package/dist/list-files.cjs +86 -1
- package/dist/list-files.mjs +79 -1
- package/dist/list-files.mjs.map +1 -1
- package/dist/package-fns.cjs +148 -1
- package/dist/package-fns.mjs +141 -1
- package/dist/package-fns.mjs.map +1 -1
- package/dist/path/src/append.cjs +57 -1
- package/dist/path/src/append.mjs +56 -1
- package/dist/path/src/append.mjs.map +1 -1
- package/dist/path/src/correct-path.cjs +138 -1
- package/dist/path/src/correct-path.mjs +134 -1
- package/dist/path/src/correct-path.mjs.map +1 -1
- package/dist/path/src/cwd.cjs +17 -1
- package/dist/path/src/cwd.mjs +16 -1
- package/dist/path/src/cwd.mjs.map +1 -1
- package/dist/path/src/file-path-fns.cjs +169 -1
- package/dist/path/src/file-path-fns.mjs +164 -1
- package/dist/path/src/file-path-fns.mjs.map +1 -1
- package/dist/path/src/is-parent-path.cjs +32 -1
- package/dist/path/src/is-parent-path.mjs +32 -1
- package/dist/path/src/is-parent-path.mjs.map +1 -1
- package/dist/path/src/is-root-dir.cjs +14 -1
- package/dist/path/src/is-root-dir.mjs +13 -1
- package/dist/path/src/is-root-dir.mjs.map +1 -1
- package/dist/path/src/is-type.cjs +68 -1
- package/dist/path/src/is-type.mjs +66 -1
- package/dist/path/src/is-type.mjs.map +1 -1
- package/dist/path/src/join-paths.cjs +106 -1
- package/dist/path/src/join-paths.mjs +106 -1
- package/dist/path/src/join-paths.mjs.map +1 -1
- package/dist/path/src/regex.cjs +18 -1
- package/dist/path/src/regex.mjs +11 -1
- package/dist/path/src/regex.mjs.map +1 -1
- package/dist/path/src/replace.cjs +24 -1
- package/dist/path/src/replace.mjs +24 -1
- package/dist/path/src/replace.mjs.map +1 -1
- package/dist/path/src/resolve-parent-path.cjs +18 -1
- package/dist/path/src/resolve-parent-path.mjs +18 -1
- package/dist/path/src/resolve-parent-path.mjs.map +1 -1
- package/dist/path/src/slash.cjs +15 -1
- package/dist/path/src/slash.mjs +14 -1
- package/dist/path/src/slash.mjs.map +1 -1
- package/dist/read-file.cjs +47 -1
- package/dist/read-file.mjs +43 -1
- package/dist/read-file.mjs.map +1 -1
- package/dist/registry.cjs +142 -1
- package/dist/registry.mjs +137 -1
- package/dist/registry.mjs.map +1 -1
- package/dist/remove-file.cjs +27 -1
- package/dist/remove-file.mjs +25 -1
- package/dist/remove-file.mjs.map +1 -1
- package/dist/resolve.cjs +228 -3
- package/dist/resolve.mjs +217 -3
- package/dist/resolve.mjs.map +1 -1
- package/dist/semver-fns.cjs +129 -1
- package/dist/semver-fns.mjs +119 -1
- package/dist/semver-fns.mjs.map +1 -1
- package/dist/string-format/src/package.cjs +92 -1
- package/dist/string-format/src/package.mjs +91 -1
- package/dist/string-format/src/package.mjs.map +1 -1
- package/dist/toml.cjs +66 -3
- package/dist/toml.mjs +61 -3
- package/dist/toml.mjs.map +1 -1
- package/dist/tsconfig.cjs +37 -1
- package/dist/tsconfig.mjs +35 -1
- package/dist/tsconfig.mjs.map +1 -1
- package/dist/type-checks/src/get-object-tag.cjs +15 -1
- package/dist/type-checks/src/get-object-tag.mjs +14 -1
- package/dist/type-checks/src/get-object-tag.mjs.map +1 -1
- package/dist/type-checks/src/index.cjs +14 -1
- package/dist/type-checks/src/index.mjs +16 -1
- package/dist/type-checks/src/is-buffer.cjs +12 -1
- package/dist/type-checks/src/is-buffer.mjs +11 -1
- package/dist/type-checks/src/is-buffer.mjs.map +1 -1
- package/dist/type-checks/src/is-collection.cjs +1 -1
- package/dist/type-checks/src/is-collection.mjs +3 -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-error.cjs +29 -1
- package/dist/type-checks/src/is-error.mjs +29 -1
- package/dist/type-checks/src/is-error.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-number.cjs +18 -1
- package/dist/type-checks/src/is-number.mjs +17 -1
- package/dist/type-checks/src/is-number.mjs.map +1 -1
- package/dist/type-checks/src/is-object.cjs +19 -1
- package/dist/type-checks/src/is-object.mjs +19 -1
- package/dist/type-checks/src/is-object.mjs.map +1 -1
- package/dist/type-checks/src/is-plain-object.cjs +64 -1
- package/dist/type-checks/src/is-plain-object.mjs +63 -1
- package/dist/type-checks/src/is-plain-object.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/type-checks/src/type-detect.cjs +15 -1
- package/dist/type-checks/src/type-detect.mjs +16 -1
- package/dist/type-checks/src/type-detect.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/dist/write-file.cjs +40 -1
- package/dist/write-file.mjs +38 -1
- package/dist/write-file.mjs.map +1 -1
- package/dist/yaml.cjs +29 -1
- package/dist/yaml.mjs +27 -1
- package/dist/yaml.mjs.map +1 -1
- package/package.json +6 -6
package/dist/helpers.mjs
CHANGED
|
@@ -1,2 +1,78 @@
|
|
|
1
|
-
import{exists as
|
|
1
|
+
import { exists, existsSync as existsSync$1 } from "./exists.mjs";
|
|
2
|
+
import { createWriteStream, mkdirSync, rmSync } from "node:fs";
|
|
3
|
+
import { mkdir, readFile, rm } from "node:fs/promises";
|
|
4
|
+
import { parseTar, parseTarGzip } from "nanotar";
|
|
5
|
+
|
|
6
|
+
//#region src/helpers.ts
|
|
7
|
+
/**
|
|
8
|
+
* Create a directory if it does not exist.
|
|
9
|
+
*
|
|
10
|
+
* @param path - The directory path to check
|
|
11
|
+
* @returns An indicator specifying if the directory exists
|
|
12
|
+
*/
|
|
13
|
+
function createDirectorySync(path) {
|
|
14
|
+
if (existsSync$1(path)) return;
|
|
15
|
+
return mkdirSync(path, { recursive: true });
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Create a directory if it does not exist.
|
|
19
|
+
*
|
|
20
|
+
* @param path - The directory path to check
|
|
21
|
+
* @returns An indicator specifying if the directory exists
|
|
22
|
+
*/
|
|
23
|
+
async function createDirectory(path) {
|
|
24
|
+
if (await exists(path)) return;
|
|
25
|
+
return mkdir(path, { recursive: true });
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Remove a directory if it exists.
|
|
29
|
+
*
|
|
30
|
+
* @param path - The directory path to check
|
|
31
|
+
* @returns An indicator specifying if the directory exists
|
|
32
|
+
*/
|
|
33
|
+
function removeDirectorySync(path) {
|
|
34
|
+
if (!existsSync$1(path)) return;
|
|
35
|
+
return rmSync(path, { recursive: true });
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Remove a directory if it exists.
|
|
39
|
+
*
|
|
40
|
+
* @param path - The directory path to check
|
|
41
|
+
* @returns An indicator specifying if the directory exists
|
|
42
|
+
*/
|
|
43
|
+
async function removeDirectory(path) {
|
|
44
|
+
if (!existsSync$1(path)) return;
|
|
45
|
+
return rm(path, { recursive: true });
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Extracts a file from a given tarball to the specified destination.
|
|
49
|
+
*
|
|
50
|
+
* @param tarballPath - The path to the tarball from where the file should be extracted.
|
|
51
|
+
* @param file - The path to the file inside the tarball.
|
|
52
|
+
* @param destinationFilePath - The destination file path.
|
|
53
|
+
* @returns True if the file was extracted successfully, false otherwise.
|
|
54
|
+
*/
|
|
55
|
+
async function extractFileFromTar(tarballPath, file, destinationFilePath) {
|
|
56
|
+
const entry = parseTar(await readFile(tarballPath)).find((e) => e.name === file);
|
|
57
|
+
if (!entry?.data) return;
|
|
58
|
+
if (!await exists(destinationFilePath)) await mkdir(destinationFilePath, { recursive: true });
|
|
59
|
+
createWriteStream(destinationFilePath).write(entry.data);
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Extracts a file from a given TarGzip to the specified destination.
|
|
63
|
+
*
|
|
64
|
+
* @param tarballPath - The path to the tarball from where the file should be extracted.
|
|
65
|
+
* @param file - The path to the file inside the tarball.
|
|
66
|
+
* @param destinationFilePath - The destination file path.
|
|
67
|
+
* @returns True if the file was extracted successfully, false otherwise.
|
|
68
|
+
*/
|
|
69
|
+
async function extractFileFromTarGzip(tarballPath, file, destinationFilePath) {
|
|
70
|
+
const entry = (await parseTarGzip(await readFile(tarballPath))).find((e) => e.name === file);
|
|
71
|
+
if (!entry?.data) return;
|
|
72
|
+
if (!await exists(destinationFilePath)) await mkdir(destinationFilePath, { recursive: true });
|
|
73
|
+
createWriteStream(destinationFilePath).write(entry.data);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
//#endregion
|
|
77
|
+
export { createDirectory, createDirectorySync, extractFileFromTar, extractFileFromTarGzip, removeDirectory, removeDirectorySync };
|
|
2
78
|
//# sourceMappingURL=helpers.mjs.map
|
package/dist/helpers.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.mjs","names":["existsSync"],"sources":["../src/helpers.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 { parseTar, parseTarGzip } from \"nanotar\";\nimport { createWriteStream, mkdirSync, rmSync } from \"node:fs\";\nimport { mkdir, readFile, rm } from \"node:fs/promises\";\nimport { exists, existsSync } from \"./exists\";\n\n/**\n * Create a directory if it does not exist.\n *\n * @param path - The directory path to check\n * @returns An indicator specifying if the directory exists\n */\nexport function createDirectorySync(path: string) {\n if (existsSync(path)) {\n return;\n }\n\n return mkdirSync(path, { recursive: true });\n}\n\n/**\n * Create a directory if it does not exist.\n *\n * @param path - The directory path to check\n * @returns An indicator specifying if the directory exists\n */\nexport async function createDirectory(path: string) {\n if (await exists(path)) {\n return;\n }\n\n return mkdir(path, { recursive: true });\n}\n\n/**\n * Remove a directory if it exists.\n *\n * @param path - The directory path to check\n * @returns An indicator specifying if the directory exists\n */\nexport function removeDirectorySync(path: string) {\n if (!existsSync(path)) {\n return;\n }\n\n return rmSync(path, { recursive: true });\n}\n\n/**\n * Remove a directory if it exists.\n *\n * @param path - The directory path to check\n * @returns An indicator specifying if the directory exists\n */\nexport async function removeDirectory(path: string) {\n if (!existsSync(path)) {\n return;\n }\n\n return rm(path, { recursive: true });\n}\n\n/**\n * Extracts a file from a given tarball to the specified destination.\n *\n * @param tarballPath - The path to the tarball from where the file should be extracted.\n * @param file - The path to the file inside the tarball.\n * @param destinationFilePath - The destination file path.\n * @returns True if the file was extracted successfully, false otherwise.\n */\nexport async function extractFileFromTar(\n tarballPath: string,\n file: string,\n destinationFilePath: string\n) {\n const result = parseTar(await readFile(tarballPath));\n\n const entry = result.find(e => e.name === file);\n if (!entry?.data) {\n return;\n }\n\n if (!(await exists(destinationFilePath))) {\n await mkdir(destinationFilePath, { recursive: true });\n }\n\n const stream = createWriteStream(destinationFilePath);\n stream.write(entry.data);\n}\n\n/**\n * Extracts a file from a given TarGzip to the specified destination.\n *\n * @param tarballPath - The path to the tarball from where the file should be extracted.\n * @param file - The path to the file inside the tarball.\n * @param destinationFilePath - The destination file path.\n * @returns True if the file was extracted successfully, false otherwise.\n */\nexport async function extractFileFromTarGzip(\n tarballPath: string,\n file: string,\n destinationFilePath: string\n) {\n const result = await parseTarGzip(await readFile(tarballPath));\n\n const entry = result.find(e => e.name === file);\n if (!entry?.data) {\n return;\n }\n\n if (!(await exists(destinationFilePath))) {\n await mkdir(destinationFilePath, { recursive: true });\n }\n\n const stream = createWriteStream(destinationFilePath);\n stream.write(entry.data);\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"helpers.mjs","names":["existsSync"],"sources":["../src/helpers.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 { parseTar, parseTarGzip } from \"nanotar\";\nimport { createWriteStream, mkdirSync, rmSync } from \"node:fs\";\nimport { mkdir, readFile, rm } from \"node:fs/promises\";\nimport { exists, existsSync } from \"./exists\";\n\n/**\n * Create a directory if it does not exist.\n *\n * @param path - The directory path to check\n * @returns An indicator specifying if the directory exists\n */\nexport function createDirectorySync(path: string) {\n if (existsSync(path)) {\n return;\n }\n\n return mkdirSync(path, { recursive: true });\n}\n\n/**\n * Create a directory if it does not exist.\n *\n * @param path - The directory path to check\n * @returns An indicator specifying if the directory exists\n */\nexport async function createDirectory(path: string) {\n if (await exists(path)) {\n return;\n }\n\n return mkdir(path, { recursive: true });\n}\n\n/**\n * Remove a directory if it exists.\n *\n * @param path - The directory path to check\n * @returns An indicator specifying if the directory exists\n */\nexport function removeDirectorySync(path: string) {\n if (!existsSync(path)) {\n return;\n }\n\n return rmSync(path, { recursive: true });\n}\n\n/**\n * Remove a directory if it exists.\n *\n * @param path - The directory path to check\n * @returns An indicator specifying if the directory exists\n */\nexport async function removeDirectory(path: string) {\n if (!existsSync(path)) {\n return;\n }\n\n return rm(path, { recursive: true });\n}\n\n/**\n * Extracts a file from a given tarball to the specified destination.\n *\n * @param tarballPath - The path to the tarball from where the file should be extracted.\n * @param file - The path to the file inside the tarball.\n * @param destinationFilePath - The destination file path.\n * @returns True if the file was extracted successfully, false otherwise.\n */\nexport async function extractFileFromTar(\n tarballPath: string,\n file: string,\n destinationFilePath: string\n) {\n const result = parseTar(await readFile(tarballPath));\n\n const entry = result.find(e => e.name === file);\n if (!entry?.data) {\n return;\n }\n\n if (!(await exists(destinationFilePath))) {\n await mkdir(destinationFilePath, { recursive: true });\n }\n\n const stream = createWriteStream(destinationFilePath);\n stream.write(entry.data);\n}\n\n/**\n * Extracts a file from a given TarGzip to the specified destination.\n *\n * @param tarballPath - The path to the tarball from where the file should be extracted.\n * @param file - The path to the file inside the tarball.\n * @param destinationFilePath - The destination file path.\n * @returns True if the file was extracted successfully, false otherwise.\n */\nexport async function extractFileFromTarGzip(\n tarballPath: string,\n file: string,\n destinationFilePath: string\n) {\n const result = await parseTarGzip(await readFile(tarballPath));\n\n const entry = result.find(e => e.name === file);\n if (!entry?.data) {\n return;\n }\n\n if (!(await exists(destinationFilePath))) {\n await mkdir(destinationFilePath, { recursive: true });\n }\n\n const stream = createWriteStream(destinationFilePath);\n stream.write(entry.data);\n}\n"],"mappings":";;;;;;;;;;;;AA6BA,SAAgB,oBAAoB,MAAc;AAChD,KAAIA,aAAW,KAAK,CAClB;AAGF,QAAO,UAAU,MAAM,EAAE,WAAW,MAAM,CAAC;;;;;;;;AAS7C,eAAsB,gBAAgB,MAAc;AAClD,KAAI,MAAM,OAAO,KAAK,CACpB;AAGF,QAAO,MAAM,MAAM,EAAE,WAAW,MAAM,CAAC;;;;;;;;AASzC,SAAgB,oBAAoB,MAAc;AAChD,KAAI,CAACA,aAAW,KAAK,CACnB;AAGF,QAAO,OAAO,MAAM,EAAE,WAAW,MAAM,CAAC;;;;;;;;AAS1C,eAAsB,gBAAgB,MAAc;AAClD,KAAI,CAACA,aAAW,KAAK,CACnB;AAGF,QAAO,GAAG,MAAM,EAAE,WAAW,MAAM,CAAC;;;;;;;;;;AAWtC,eAAsB,mBACpB,aACA,MACA,qBACA;CAGA,MAAM,QAFS,SAAS,MAAM,SAAS,YAAY,CAAC,CAE/B,MAAK,MAAK,EAAE,SAAS,KAAK;AAC/C,KAAI,CAAC,OAAO,KACV;AAGF,KAAI,CAAE,MAAM,OAAO,oBAAoB,CACrC,OAAM,MAAM,qBAAqB,EAAE,WAAW,MAAM,CAAC;AAIvD,CADe,kBAAkB,oBAAoB,CAC9C,MAAM,MAAM,KAAK;;;;;;;;;;AAW1B,eAAsB,uBACpB,aACA,MACA,qBACA;CAGA,MAAM,SAFS,MAAM,aAAa,MAAM,SAAS,YAAY,CAAC,EAEzC,MAAK,MAAK,EAAE,SAAS,KAAK;AAC/C,KAAI,CAAC,OAAO,KACV;AAGF,KAAI,CAAE,MAAM,OAAO,oBAAoB,CACrC,OAAM,MAAM,qBAAqB,EAAE,WAAW,MAAM,CAAC;AAIvD,CADe,kBAAkB,oBAAoB,CAC9C,MAAM,MAAM,KAAK"}
|
package/dist/index.cjs
CHANGED
|
@@ -1 +1,122 @@
|
|
|
1
|
-
const
|
|
1
|
+
const require_exists = require('./exists.cjs');
|
|
2
|
+
const require_helpers = require('./helpers.cjs');
|
|
3
|
+
const require_buffer = require('./buffer.cjs');
|
|
4
|
+
const require_chmod_x = require('./chmod-x.cjs');
|
|
5
|
+
const require_command_exists = require('./command-exists.cjs');
|
|
6
|
+
const require_is_file = require('./is-file.cjs');
|
|
7
|
+
const require_list_files = require('./list-files.cjs');
|
|
8
|
+
const require_read_file = require('./read-file.cjs');
|
|
9
|
+
const require_write_file = require('./write-file.cjs');
|
|
10
|
+
const require_compress = require('./compress.cjs');
|
|
11
|
+
const require_copy_file = require('./copy-file.cjs');
|
|
12
|
+
const require_get_parent_path = require('./get-parent-path.cjs');
|
|
13
|
+
const require_get_workspace_root = require('./get-workspace-root.cjs');
|
|
14
|
+
const require_resolve = require('./resolve.cjs');
|
|
15
|
+
const require_install = require('./install.cjs');
|
|
16
|
+
const require_json = require('./json.cjs');
|
|
17
|
+
const require_package_fns = require('./package-fns.cjs');
|
|
18
|
+
const require_registry = require('./registry.cjs');
|
|
19
|
+
const require_remove_file = require('./remove-file.cjs');
|
|
20
|
+
const require_semver_fns = require('./semver-fns.cjs');
|
|
21
|
+
const require_toml = require('./toml.cjs');
|
|
22
|
+
const require_tsconfig = require('./tsconfig.cjs');
|
|
23
|
+
const require_yaml = require('./yaml.cjs');
|
|
24
|
+
|
|
25
|
+
exports.DEFAULT_EXTENSIONS = require_resolve.DEFAULT_EXTENSIONS;
|
|
26
|
+
exports.PROJECT_ROOT_CONTENT = require_get_workspace_root.PROJECT_ROOT_CONTENT;
|
|
27
|
+
exports.WORKSPACE_ROOT_CONTENT = require_get_workspace_root.WORKSPACE_ROOT_CONTENT;
|
|
28
|
+
exports.chmodX = require_chmod_x.chmodX;
|
|
29
|
+
exports.chmodXSync = require_chmod_x.chmodXSync;
|
|
30
|
+
exports.coerceVersion = require_semver_fns.coerceVersion;
|
|
31
|
+
exports.commandExists = require_command_exists.commandExists;
|
|
32
|
+
exports.commandExistsSync = require_command_exists.commandExistsSync;
|
|
33
|
+
exports.compressDirectory = require_compress.compressDirectory;
|
|
34
|
+
exports.copyFile = require_copy_file.copyFile;
|
|
35
|
+
exports.copyFileSync = require_copy_file.copyFileSync;
|
|
36
|
+
exports.copyFiles = require_copy_file.copyFiles;
|
|
37
|
+
exports.copyFilesSync = require_copy_file.copyFilesSync;
|
|
38
|
+
exports.createDirectory = require_helpers.createDirectory;
|
|
39
|
+
exports.createDirectorySync = require_helpers.createDirectorySync;
|
|
40
|
+
exports.deriveNewSemverVersion = require_semver_fns.deriveNewSemverVersion;
|
|
41
|
+
exports.doesPackageMatch = require_package_fns.doesPackageMatch;
|
|
42
|
+
exports.exists = require_exists.exists;
|
|
43
|
+
exports.existsSync = require_exists.existsSync;
|
|
44
|
+
exports.extractFileFromTar = require_helpers.extractFileFromTar;
|
|
45
|
+
exports.extractFileFromTarGzip = require_helpers.extractFileFromTarGzip;
|
|
46
|
+
exports.formatNodeOptions = require_registry.formatNodeOptions;
|
|
47
|
+
exports.getFormattedNodeOptionsWithoutInspect = require_registry.getFormattedNodeOptionsWithoutInspect;
|
|
48
|
+
exports.getNodeModulesPaths = require_resolve.getNodeModulesPaths;
|
|
49
|
+
exports.getPackageInfo = require_package_fns.getPackageInfo;
|
|
50
|
+
exports.getPackageListing = require_package_fns.getPackageListing;
|
|
51
|
+
exports.getPackageManager = require_package_fns.getPackageManager;
|
|
52
|
+
exports.getParentPath = require_get_parent_path.getParentPath;
|
|
53
|
+
exports.getParsedNodeOptionsWithoutInspect = require_registry.getParsedNodeOptionsWithoutInspect;
|
|
54
|
+
exports.getProjectRoot = require_get_workspace_root.getProjectRoot;
|
|
55
|
+
exports.getRegistry = require_registry.getRegistry;
|
|
56
|
+
exports.getResolutionCombinations = require_resolve.getResolutionCombinations;
|
|
57
|
+
exports.getResolutionPaths = require_resolve.getResolutionPaths;
|
|
58
|
+
exports.getWorkspaceRoot = require_get_workspace_root.getWorkspaceRoot;
|
|
59
|
+
exports.importModule = require_resolve.importModule;
|
|
60
|
+
exports.install = require_install.install;
|
|
61
|
+
exports.isDirectory = require_is_file.isDirectory;
|
|
62
|
+
exports.isDirectorySymlink = require_is_file.isDirectorySymlink;
|
|
63
|
+
exports.isExecutable = require_chmod_x.isExecutable;
|
|
64
|
+
exports.isExecutableSync = require_chmod_x.isExecutableSync;
|
|
65
|
+
exports.isFile = require_is_file.isFile;
|
|
66
|
+
exports.isFileSymlink = require_is_file.isFileSymlink;
|
|
67
|
+
exports.isPackageExists = require_package_fns.isPackageExists;
|
|
68
|
+
exports.isPackageListed = require_package_fns.isPackageListed;
|
|
69
|
+
exports.isProjectRoot = require_get_workspace_root.isProjectRoot;
|
|
70
|
+
exports.isRange = require_semver_fns.isRange;
|
|
71
|
+
exports.isRelativeVersionKeyword = require_semver_fns.isRelativeVersionKeyword;
|
|
72
|
+
exports.isSemver = require_semver_fns.isSemver;
|
|
73
|
+
exports.isValidRange = require_semver_fns.isValidRange;
|
|
74
|
+
exports.isValidSemver = require_semver_fns.isValidSemver;
|
|
75
|
+
exports.isValidVersion = require_semver_fns.isValidVersion;
|
|
76
|
+
exports.isWorkspaceRoot = require_get_workspace_root.isWorkspaceRoot;
|
|
77
|
+
exports.isWritable = require_chmod_x.isWritable;
|
|
78
|
+
exports.isWritableSync = require_chmod_x.isWritableSync;
|
|
79
|
+
exports.list = require_list_files.list;
|
|
80
|
+
exports.listDirectories = require_list_files.listDirectories;
|
|
81
|
+
exports.listDirectoriesSync = require_list_files.listDirectoriesSync;
|
|
82
|
+
exports.listFiles = require_list_files.listFiles;
|
|
83
|
+
exports.listFilesSync = require_list_files.listFilesSync;
|
|
84
|
+
exports.listSync = require_list_files.listSync;
|
|
85
|
+
exports.loadPackageJson = require_package_fns.loadPackageJson;
|
|
86
|
+
exports.loadTsConfig = require_tsconfig.loadTsConfig;
|
|
87
|
+
exports.packageExists = require_install.packageExists;
|
|
88
|
+
exports.parseVersion = require_semver_fns.parseVersion;
|
|
89
|
+
exports.readFile = require_read_file.readFile;
|
|
90
|
+
exports.readFileBuffer = require_buffer.readFileBuffer;
|
|
91
|
+
exports.readFileBufferSync = require_buffer.readFileBufferSync;
|
|
92
|
+
exports.readFileIfExisting = require_read_file.readFileIfExisting;
|
|
93
|
+
exports.readFileIfExistingSync = require_read_file.readFileIfExistingSync;
|
|
94
|
+
exports.readFileSync = require_read_file.readFileSync;
|
|
95
|
+
exports.readJsonFile = require_json.readJsonFile;
|
|
96
|
+
exports.readJsonFileSync = require_json.readJsonFileSync;
|
|
97
|
+
exports.readTomlFile = require_toml.readTomlFile;
|
|
98
|
+
exports.readTomlFileSync = require_toml.readTomlFileSync;
|
|
99
|
+
exports.readYamlFile = require_yaml.readYamlFile;
|
|
100
|
+
exports.readYamlFileSync = require_yaml.readYamlFileSync;
|
|
101
|
+
exports.relativeToProjectRoot = require_get_workspace_root.relativeToProjectRoot;
|
|
102
|
+
exports.relativeToWorkspaceRoot = require_get_workspace_root.relativeToWorkspaceRoot;
|
|
103
|
+
exports.removeDirectory = require_helpers.removeDirectory;
|
|
104
|
+
exports.removeDirectorySync = require_helpers.removeDirectorySync;
|
|
105
|
+
exports.removeFile = require_remove_file.removeFile;
|
|
106
|
+
exports.removeFileSync = require_remove_file.removeFileSync;
|
|
107
|
+
exports.resolve = require_resolve.resolve;
|
|
108
|
+
exports.resolvePackage = require_resolve.resolvePackage;
|
|
109
|
+
exports.resolvePackageSync = require_resolve.resolvePackageSync;
|
|
110
|
+
exports.resolveSafe = require_resolve.resolveSafe;
|
|
111
|
+
exports.resolveSafeSync = require_resolve.resolveSafeSync;
|
|
112
|
+
exports.resolveSync = require_resolve.resolveSync;
|
|
113
|
+
exports.satisfiesVersion = require_semver_fns.satisfiesVersion;
|
|
114
|
+
exports.tokenizeArgs = require_registry.tokenizeArgs;
|
|
115
|
+
exports.writeFile = require_write_file.writeFile;
|
|
116
|
+
exports.writeFileBuffer = require_buffer.writeFileBuffer;
|
|
117
|
+
exports.writeFileBufferSync = require_buffer.writeFileBufferSync;
|
|
118
|
+
exports.writeFileSync = require_write_file.writeFileSync;
|
|
119
|
+
exports.writeJsonFile = require_json.writeJsonFile;
|
|
120
|
+
exports.writeJsonFileSync = require_json.writeJsonFileSync;
|
|
121
|
+
exports.writeTomlFile = require_toml.writeTomlFile;
|
|
122
|
+
exports.writeTomlFileSync = require_toml.writeTomlFileSync;
|
package/dist/index.mjs
CHANGED
|
@@ -1 +1,25 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import { exists, existsSync } from "./exists.mjs";
|
|
2
|
+
import { createDirectory, createDirectorySync, extractFileFromTar, extractFileFromTarGzip, removeDirectory, removeDirectorySync } from "./helpers.mjs";
|
|
3
|
+
import { readFileBuffer, readFileBufferSync, writeFileBuffer, writeFileBufferSync } from "./buffer.mjs";
|
|
4
|
+
import { chmodX, chmodXSync, isExecutable, isExecutableSync, isWritable, isWritableSync } from "./chmod-x.mjs";
|
|
5
|
+
import { commandExists, commandExistsSync } from "./command-exists.mjs";
|
|
6
|
+
import { isDirectory, isDirectorySymlink, isFile, isFileSymlink } from "./is-file.mjs";
|
|
7
|
+
import { list, listDirectories, listDirectoriesSync, listFiles, listFilesSync, listSync } from "./list-files.mjs";
|
|
8
|
+
import { readFile, readFileIfExisting, readFileIfExistingSync, readFileSync } from "./read-file.mjs";
|
|
9
|
+
import { writeFile, writeFileSync } from "./write-file.mjs";
|
|
10
|
+
import { compressDirectory } from "./compress.mjs";
|
|
11
|
+
import { copyFile, copyFileSync, copyFiles, copyFilesSync } from "./copy-file.mjs";
|
|
12
|
+
import { getParentPath } from "./get-parent-path.mjs";
|
|
13
|
+
import { PROJECT_ROOT_CONTENT, WORKSPACE_ROOT_CONTENT, getProjectRoot, getWorkspaceRoot, isProjectRoot, isWorkspaceRoot, relativeToProjectRoot, relativeToWorkspaceRoot } from "./get-workspace-root.mjs";
|
|
14
|
+
import { DEFAULT_EXTENSIONS, getNodeModulesPaths, getResolutionCombinations, getResolutionPaths, importModule, resolve, resolvePackage, resolvePackageSync, resolveSafe, resolveSafeSync, resolveSync } from "./resolve.mjs";
|
|
15
|
+
import { install, packageExists } from "./install.mjs";
|
|
16
|
+
import { readJsonFile, readJsonFileSync, writeJsonFile, writeJsonFileSync } from "./json.mjs";
|
|
17
|
+
import { doesPackageMatch, getPackageInfo, getPackageListing, getPackageManager, isPackageExists, isPackageListed, loadPackageJson } from "./package-fns.mjs";
|
|
18
|
+
import { formatNodeOptions, getFormattedNodeOptionsWithoutInspect, getParsedNodeOptionsWithoutInspect, getRegistry, tokenizeArgs } from "./registry.mjs";
|
|
19
|
+
import { removeFile, removeFileSync } from "./remove-file.mjs";
|
|
20
|
+
import { coerceVersion, deriveNewSemverVersion, isRange, isRelativeVersionKeyword, isSemver, isValidRange, isValidSemver, isValidVersion, parseVersion, satisfiesVersion } from "./semver-fns.mjs";
|
|
21
|
+
import { readTomlFile, readTomlFileSync, writeTomlFile, writeTomlFileSync } from "./toml.mjs";
|
|
22
|
+
import { loadTsConfig } from "./tsconfig.mjs";
|
|
23
|
+
import { readYamlFile, readYamlFileSync } from "./yaml.mjs";
|
|
24
|
+
|
|
25
|
+
export { DEFAULT_EXTENSIONS, PROJECT_ROOT_CONTENT, WORKSPACE_ROOT_CONTENT, chmodX, chmodXSync, coerceVersion, commandExists, commandExistsSync, compressDirectory, copyFile, copyFileSync, copyFiles, copyFilesSync, createDirectory, createDirectorySync, deriveNewSemverVersion, doesPackageMatch, exists, existsSync, extractFileFromTar, extractFileFromTarGzip, formatNodeOptions, getFormattedNodeOptionsWithoutInspect, getNodeModulesPaths, getPackageInfo, getPackageListing, getPackageManager, getParentPath, getParsedNodeOptionsWithoutInspect, getProjectRoot, getRegistry, getResolutionCombinations, getResolutionPaths, getWorkspaceRoot, importModule, install, isDirectory, isDirectorySymlink, isExecutable, isExecutableSync, isFile, isFileSymlink, isPackageExists, isPackageListed, isProjectRoot, isRange, isRelativeVersionKeyword, isSemver, isValidRange, isValidSemver, isValidVersion, isWorkspaceRoot, isWritable, isWritableSync, list, listDirectories, listDirectoriesSync, listFiles, listFilesSync, listSync, loadPackageJson, loadTsConfig, packageExists, parseVersion, readFile, readFileBuffer, readFileBufferSync, readFileIfExisting, readFileIfExistingSync, readFileSync, readJsonFile, readJsonFileSync, readTomlFile, readTomlFileSync, readYamlFile, readYamlFileSync, relativeToProjectRoot, relativeToWorkspaceRoot, removeDirectory, removeDirectorySync, removeFile, removeFileSync, resolve, resolvePackage, resolvePackageSync, resolveSafe, resolveSafeSync, resolveSync, satisfiesVersion, tokenizeArgs, writeFile, writeFileBuffer, writeFileBufferSync, writeFileSync, writeJsonFile, writeJsonFileSync, writeTomlFile, writeTomlFileSync };
|
package/dist/install.cjs
CHANGED
|
@@ -1 +1,35 @@
|
|
|
1
|
-
const
|
|
1
|
+
const require_rolldown_runtime = require('./_virtual/rolldown_runtime.cjs');
|
|
2
|
+
const require_cwd = require('./path/src/cwd.cjs');
|
|
3
|
+
const require_resolve = require('./resolve.cjs');
|
|
4
|
+
let __antfu_install_pkg = require("@antfu/install-pkg");
|
|
5
|
+
require("tinyexec");
|
|
6
|
+
|
|
7
|
+
//#region src/install.ts
|
|
8
|
+
/**
|
|
9
|
+
* Install a specific or list of packages
|
|
10
|
+
*
|
|
11
|
+
* @param nameOrNames - The name or names of packages to install
|
|
12
|
+
* @param options - The options to use when installing the package
|
|
13
|
+
* @returns The result of the command or an exception
|
|
14
|
+
*/
|
|
15
|
+
async function install(nameOrNames, options) {
|
|
16
|
+
return (0, __antfu_install_pkg.installPackage)(nameOrNames, options);
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Check if a package exists and install it if it does not
|
|
20
|
+
*
|
|
21
|
+
* @param name - The name of the package to check
|
|
22
|
+
* @param options - The options to use when installing the package
|
|
23
|
+
*/
|
|
24
|
+
const packageExists = async (name, options) => {
|
|
25
|
+
const resolvePath = await require_resolve.resolve(options?.cwd || require_cwd.cwd());
|
|
26
|
+
try {
|
|
27
|
+
await require_resolve.resolve(name, { paths: [resolvePath] });
|
|
28
|
+
} catch {
|
|
29
|
+
await install(name, options);
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
//#endregion
|
|
34
|
+
exports.install = install;
|
|
35
|
+
exports.packageExists = packageExists;
|
package/dist/install.mjs
CHANGED
|
@@ -1,2 +1,34 @@
|
|
|
1
|
-
import{cwd
|
|
1
|
+
import { cwd } from "./path/src/cwd.mjs";
|
|
2
|
+
import { resolve } from "./resolve.mjs";
|
|
3
|
+
import { installPackage } from "@antfu/install-pkg";
|
|
4
|
+
import "tinyexec";
|
|
5
|
+
|
|
6
|
+
//#region src/install.ts
|
|
7
|
+
/**
|
|
8
|
+
* Install a specific or list of packages
|
|
9
|
+
*
|
|
10
|
+
* @param nameOrNames - The name or names of packages to install
|
|
11
|
+
* @param options - The options to use when installing the package
|
|
12
|
+
* @returns The result of the command or an exception
|
|
13
|
+
*/
|
|
14
|
+
async function install(nameOrNames, options) {
|
|
15
|
+
return installPackage(nameOrNames, options);
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Check if a package exists and install it if it does not
|
|
19
|
+
*
|
|
20
|
+
* @param name - The name of the package to check
|
|
21
|
+
* @param options - The options to use when installing the package
|
|
22
|
+
*/
|
|
23
|
+
const packageExists = async (name, options) => {
|
|
24
|
+
const resolvePath = await resolve(options?.cwd || cwd());
|
|
25
|
+
try {
|
|
26
|
+
await resolve(name, { paths: [resolvePath] });
|
|
27
|
+
} catch {
|
|
28
|
+
await install(name, options);
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
//#endregion
|
|
33
|
+
export { install, packageExists };
|
|
2
34
|
//# sourceMappingURL=install.mjs.map
|
package/dist/install.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"install.mjs","names":[],"sources":["../src/install.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 type { InstallPackageOptions } from \"@antfu/install-pkg\";\nimport { installPackage } from \"@antfu/install-pkg\";\nimport { cwd } from \"@stryke/path/cwd\";\nimport \"tinyexec\";\nimport { resolve } from \"./resolve\";\n\n/**\n * Install a specific package\n *\n * @param name - The name of the package to install\n * @param options - The options to use when installing the package\n */\nexport async function install(\n name: string,\n options?: InstallPackageOptions\n): Promise<ReturnType<typeof installPackage>>;\n\n/**\n * Install a list of packages\n *\n * @param names - The list of package names to install\n * @param options - The options to use when installing the package\n */\nexport async function install(\n names: string[],\n options?: InstallPackageOptions\n): Promise<ReturnType<typeof installPackage>>;\n\n/**\n * Install a specific or list of packages\n *\n * @param nameOrNames - The name or names of packages to install\n * @param options - The options to use when installing the package\n * @returns The result of the command or an exception\n */\nexport async function install(\n nameOrNames: string | string[],\n options?: InstallPackageOptions\n): Promise<ReturnType<typeof installPackage>> {\n return installPackage(nameOrNames, options);\n}\n\n/**\n * Check if a package exists and install it if it does not\n *\n * @param name - The name of the package to check\n * @param options - The options to use when installing the package\n */\nexport const packageExists = async (\n name: string,\n options?: InstallPackageOptions\n) => {\n const resolvePath = await resolve(options?.cwd || cwd());\n try {\n await resolve(name, { paths: [resolvePath] });\n } catch {\n await install(name, options);\n }\n};\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"install.mjs","names":[],"sources":["../src/install.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 type { InstallPackageOptions } from \"@antfu/install-pkg\";\nimport { installPackage } from \"@antfu/install-pkg\";\nimport { cwd } from \"@stryke/path/cwd\";\nimport \"tinyexec\";\nimport { resolve } from \"./resolve\";\n\n/**\n * Install a specific package\n *\n * @param name - The name of the package to install\n * @param options - The options to use when installing the package\n */\nexport async function install(\n name: string,\n options?: InstallPackageOptions\n): Promise<ReturnType<typeof installPackage>>;\n\n/**\n * Install a list of packages\n *\n * @param names - The list of package names to install\n * @param options - The options to use when installing the package\n */\nexport async function install(\n names: string[],\n options?: InstallPackageOptions\n): Promise<ReturnType<typeof installPackage>>;\n\n/**\n * Install a specific or list of packages\n *\n * @param nameOrNames - The name or names of packages to install\n * @param options - The options to use when installing the package\n * @returns The result of the command or an exception\n */\nexport async function install(\n nameOrNames: string | string[],\n options?: InstallPackageOptions\n): Promise<ReturnType<typeof installPackage>> {\n return installPackage(nameOrNames, options);\n}\n\n/**\n * Check if a package exists and install it if it does not\n *\n * @param name - The name of the package to check\n * @param options - The options to use when installing the package\n */\nexport const packageExists = async (\n name: string,\n options?: InstallPackageOptions\n) => {\n const resolvePath = await resolve(options?.cwd || cwd());\n try {\n await resolve(name, { paths: [resolvePath] });\n } catch {\n await install(name, options);\n }\n};\n"],"mappings":";;;;;;;;;;;;;AAqDA,eAAsB,QACpB,aACA,SAC4C;AAC5C,QAAO,eAAe,aAAa,QAAQ;;;;;;;;AAS7C,MAAa,gBAAgB,OAC3B,MACA,YACG;CACH,MAAM,cAAc,MAAM,QAAQ,SAAS,OAAO,KAAK,CAAC;AACxD,KAAI;AACF,QAAM,QAAQ,MAAM,EAAE,OAAO,CAAC,YAAY,EAAE,CAAC;SACvC;AACN,QAAM,QAAQ,MAAM,QAAQ"}
|
package/dist/is-file.cjs
CHANGED
|
@@ -1 +1,51 @@
|
|
|
1
|
-
const
|
|
1
|
+
const require_rolldown_runtime = require('./_virtual/rolldown_runtime.cjs');
|
|
2
|
+
const require_join_paths = require('./path/src/join-paths.cjs');
|
|
3
|
+
let node_fs = require("node:fs");
|
|
4
|
+
|
|
5
|
+
//#region src/is-file.ts
|
|
6
|
+
/**
|
|
7
|
+
* Check if the given path is a file.
|
|
8
|
+
*
|
|
9
|
+
* @param path - The location to check
|
|
10
|
+
* @param additionalPath - An optional additional path to add to the start of the path
|
|
11
|
+
* @returns An indicator specifying if the path is a file
|
|
12
|
+
*/
|
|
13
|
+
function isFile(path, additionalPath) {
|
|
14
|
+
return Boolean((0, node_fs.statSync)(additionalPath ? require_join_paths.joinPaths(additionalPath, path) : path, { throwIfNoEntry: false })?.isFile());
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Check if the given path is a directory.
|
|
18
|
+
*
|
|
19
|
+
* @param path - The location to check
|
|
20
|
+
* @param additionalPath - An optional additional path to add to the start of the path
|
|
21
|
+
* @returns An indicator specifying if the path is a directory
|
|
22
|
+
*/
|
|
23
|
+
function isDirectory(path, additionalPath) {
|
|
24
|
+
return Boolean((0, node_fs.statSync)(additionalPath ? require_join_paths.joinPaths(additionalPath, path) : path, { throwIfNoEntry: false })?.isDirectory());
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Check if the given path is a file . Does not dereference symbolic links.
|
|
28
|
+
*
|
|
29
|
+
* @param path - The location to check
|
|
30
|
+
* @param additionalPath - An optional additional path to add to the start of the path
|
|
31
|
+
* @returns An indicator specifying if the path is a file
|
|
32
|
+
*/
|
|
33
|
+
const isFileSymlink = (path, additionalPath) => {
|
|
34
|
+
return Boolean((0, node_fs.lstatSync)(additionalPath ? require_join_paths.joinPaths(additionalPath, path) : path, { throwIfNoEntry: false })?.isFile());
|
|
35
|
+
};
|
|
36
|
+
/**
|
|
37
|
+
* Check if the given path is a directory. Does not dereference symbolic links.
|
|
38
|
+
*
|
|
39
|
+
* @param path - The location to check
|
|
40
|
+
* @param additionalPath - An optional additional path to add to the start of the path
|
|
41
|
+
* @returns An indicator specifying if the path is a directory
|
|
42
|
+
*/
|
|
43
|
+
const isDirectorySymlink = (path, additionalPath) => {
|
|
44
|
+
return Boolean((0, node_fs.lstatSync)(additionalPath ? require_join_paths.joinPaths(additionalPath, path) : path, { throwIfNoEntry: false })?.isDirectory());
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
//#endregion
|
|
48
|
+
exports.isDirectory = isDirectory;
|
|
49
|
+
exports.isDirectorySymlink = isDirectorySymlink;
|
|
50
|
+
exports.isFile = isFile;
|
|
51
|
+
exports.isFileSymlink = isFileSymlink;
|
package/dist/is-file.mjs
CHANGED
|
@@ -1,2 +1,48 @@
|
|
|
1
|
-
import{joinPaths
|
|
1
|
+
import { joinPaths } from "./path/src/join-paths.mjs";
|
|
2
|
+
import { lstatSync, statSync } from "node:fs";
|
|
3
|
+
|
|
4
|
+
//#region src/is-file.ts
|
|
5
|
+
/**
|
|
6
|
+
* Check if the given path is a file.
|
|
7
|
+
*
|
|
8
|
+
* @param path - The location to check
|
|
9
|
+
* @param additionalPath - An optional additional path to add to the start of the path
|
|
10
|
+
* @returns An indicator specifying if the path is a file
|
|
11
|
+
*/
|
|
12
|
+
function isFile(path, additionalPath) {
|
|
13
|
+
return Boolean(statSync(additionalPath ? joinPaths(additionalPath, path) : path, { throwIfNoEntry: false })?.isFile());
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Check if the given path is a directory.
|
|
17
|
+
*
|
|
18
|
+
* @param path - The location to check
|
|
19
|
+
* @param additionalPath - An optional additional path to add to the start of the path
|
|
20
|
+
* @returns An indicator specifying if the path is a directory
|
|
21
|
+
*/
|
|
22
|
+
function isDirectory(path, additionalPath) {
|
|
23
|
+
return Boolean(statSync(additionalPath ? joinPaths(additionalPath, path) : path, { throwIfNoEntry: false })?.isDirectory());
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Check if the given path is a file . Does not dereference symbolic links.
|
|
27
|
+
*
|
|
28
|
+
* @param path - The location to check
|
|
29
|
+
* @param additionalPath - An optional additional path to add to the start of the path
|
|
30
|
+
* @returns An indicator specifying if the path is a file
|
|
31
|
+
*/
|
|
32
|
+
const isFileSymlink = (path, additionalPath) => {
|
|
33
|
+
return Boolean(lstatSync(additionalPath ? joinPaths(additionalPath, path) : path, { throwIfNoEntry: false })?.isFile());
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* Check if the given path is a directory. Does not dereference symbolic links.
|
|
37
|
+
*
|
|
38
|
+
* @param path - The location to check
|
|
39
|
+
* @param additionalPath - An optional additional path to add to the start of the path
|
|
40
|
+
* @returns An indicator specifying if the path is a directory
|
|
41
|
+
*/
|
|
42
|
+
const isDirectorySymlink = (path, additionalPath) => {
|
|
43
|
+
return Boolean(lstatSync(additionalPath ? joinPaths(additionalPath, path) : path, { throwIfNoEntry: false })?.isDirectory());
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
//#endregion
|
|
47
|
+
export { isDirectory, isDirectorySymlink, isFile, isFileSymlink };
|
|
2
48
|
//# sourceMappingURL=is-file.mjs.map
|
package/dist/is-file.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"is-file.mjs","names":[],"sources":["../src/is-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 { joinPaths } from \"@stryke/path/join-paths\";\nimport { lstatSync, statSync } from \"node:fs\";\n\n/**\n * Check if the given path is a file.\n *\n * @param path - The location to check\n * @param additionalPath - An optional additional path to add to the start of the path\n * @returns An indicator specifying if the path is a file\n */\nexport function isFile(path: string, additionalPath?: string): boolean {\n return Boolean(\n statSync(additionalPath ? joinPaths(additionalPath, path) : path, {\n throwIfNoEntry: false\n })?.isFile()\n );\n}\n\n/**\n * Check if the given path is a directory.\n *\n * @param path - The location to check\n * @param additionalPath - An optional additional path to add to the start of the path\n * @returns An indicator specifying if the path is a directory\n */\nexport function isDirectory(path: string, additionalPath?: string): boolean {\n return Boolean(\n statSync(additionalPath ? joinPaths(additionalPath, path) : path, {\n throwIfNoEntry: false\n })?.isDirectory()\n );\n}\n\n/**\n * Check if the given path is a file . Does not dereference symbolic links.\n *\n * @param path - The location to check\n * @param additionalPath - An optional additional path to add to the start of the path\n * @returns An indicator specifying if the path is a file\n */\nexport const isFileSymlink = (\n path: string,\n additionalPath?: string\n): boolean => {\n return Boolean(\n lstatSync(additionalPath ? joinPaths(additionalPath, path) : path, {\n throwIfNoEntry: false\n })?.isFile()\n );\n};\n\n/**\n * Check if the given path is a directory. Does not dereference symbolic links.\n *\n * @param path - The location to check\n * @param additionalPath - An optional additional path to add to the start of the path\n * @returns An indicator specifying if the path is a directory\n */\nexport const isDirectorySymlink = (\n path: string,\n additionalPath?: string\n): boolean => {\n return Boolean(\n lstatSync(additionalPath ? joinPaths(additionalPath, path) : path, {\n throwIfNoEntry: false\n })?.isDirectory()\n );\n};\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"is-file.mjs","names":[],"sources":["../src/is-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 { joinPaths } from \"@stryke/path/join-paths\";\nimport { lstatSync, statSync } from \"node:fs\";\n\n/**\n * Check if the given path is a file.\n *\n * @param path - The location to check\n * @param additionalPath - An optional additional path to add to the start of the path\n * @returns An indicator specifying if the path is a file\n */\nexport function isFile(path: string, additionalPath?: string): boolean {\n return Boolean(\n statSync(additionalPath ? joinPaths(additionalPath, path) : path, {\n throwIfNoEntry: false\n })?.isFile()\n );\n}\n\n/**\n * Check if the given path is a directory.\n *\n * @param path - The location to check\n * @param additionalPath - An optional additional path to add to the start of the path\n * @returns An indicator specifying if the path is a directory\n */\nexport function isDirectory(path: string, additionalPath?: string): boolean {\n return Boolean(\n statSync(additionalPath ? joinPaths(additionalPath, path) : path, {\n throwIfNoEntry: false\n })?.isDirectory()\n );\n}\n\n/**\n * Check if the given path is a file . Does not dereference symbolic links.\n *\n * @param path - The location to check\n * @param additionalPath - An optional additional path to add to the start of the path\n * @returns An indicator specifying if the path is a file\n */\nexport const isFileSymlink = (\n path: string,\n additionalPath?: string\n): boolean => {\n return Boolean(\n lstatSync(additionalPath ? joinPaths(additionalPath, path) : path, {\n throwIfNoEntry: false\n })?.isFile()\n );\n};\n\n/**\n * Check if the given path is a directory. Does not dereference symbolic links.\n *\n * @param path - The location to check\n * @param additionalPath - An optional additional path to add to the start of the path\n * @returns An indicator specifying if the path is a directory\n */\nexport const isDirectorySymlink = (\n path: string,\n additionalPath?: string\n): boolean => {\n return Boolean(\n lstatSync(additionalPath ? joinPaths(additionalPath, path) : path, {\n throwIfNoEntry: false\n })?.isDirectory()\n );\n};\n"],"mappings":";;;;;;;;;;;AA4BA,SAAgB,OAAO,MAAc,gBAAkC;AACrE,QAAO,QACL,SAAS,iBAAiB,UAAU,gBAAgB,KAAK,GAAG,MAAM,EAChE,gBAAgB,OACjB,CAAC,EAAE,QAAQ,CACb;;;;;;;;;AAUH,SAAgB,YAAY,MAAc,gBAAkC;AAC1E,QAAO,QACL,SAAS,iBAAiB,UAAU,gBAAgB,KAAK,GAAG,MAAM,EAChE,gBAAgB,OACjB,CAAC,EAAE,aAAa,CAClB;;;;;;;;;AAUH,MAAa,iBACX,MACA,mBACY;AACZ,QAAO,QACL,UAAU,iBAAiB,UAAU,gBAAgB,KAAK,GAAG,MAAM,EACjE,gBAAgB,OACjB,CAAC,EAAE,QAAQ,CACb;;;;;;;;;AAUH,MAAa,sBACX,MACA,mBACY;AACZ,QAAO,QACL,UAAU,iBAAiB,UAAU,gBAAgB,KAAK,GAAG,MAAM,EACjE,gBAAgB,OACjB,CAAC,EAAE,aAAa,CAClB"}
|
|
@@ -1 +1,117 @@
|
|
|
1
|
-
const
|
|
1
|
+
const require_rolldown_runtime = require('../../_virtual/rolldown_runtime.cjs');
|
|
2
|
+
const require_is_string = require('../../type-checks/src/is-string.cjs');
|
|
3
|
+
const require_is_object = require('../../type-checks/src/is-object.cjs');
|
|
4
|
+
const require_parse = require('./utils/parse.cjs');
|
|
5
|
+
const require_parse_error = require('./utils/parse-error.cjs');
|
|
6
|
+
const require_stringify = require('./utils/stringify.cjs');
|
|
7
|
+
let node_buffer = require("node:buffer");
|
|
8
|
+
let jsonc_parser = require("jsonc-parser");
|
|
9
|
+
let superjson = require("superjson");
|
|
10
|
+
superjson = require_rolldown_runtime.__toESM(superjson);
|
|
11
|
+
|
|
12
|
+
//#region ../json/src/storm-json.ts
|
|
13
|
+
/**
|
|
14
|
+
* A static JSON parser class used by Storm Software to serialize and deserialize JSON data
|
|
15
|
+
*
|
|
16
|
+
* @remarks
|
|
17
|
+
* This class uses the [SuperJSON](https://github.com/blitz-js/superjson) library under the hood.
|
|
18
|
+
*/
|
|
19
|
+
var StormJSON = class StormJSON extends superjson.default {
|
|
20
|
+
static #instance;
|
|
21
|
+
static get instance() {
|
|
22
|
+
if (!StormJSON.#instance) StormJSON.#instance = new StormJSON();
|
|
23
|
+
return StormJSON.#instance;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Deserialize the given value with superjson using the given metadata
|
|
27
|
+
*/
|
|
28
|
+
static deserialize(payload) {
|
|
29
|
+
return StormJSON.instance.deserialize(payload);
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Serialize the given value with superjson
|
|
33
|
+
*/
|
|
34
|
+
static serialize(object) {
|
|
35
|
+
return StormJSON.instance.serialize(object);
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Parse the given string value with superjson using the given metadata
|
|
39
|
+
*
|
|
40
|
+
* @param value - The string value to parse
|
|
41
|
+
* @returns The parsed data
|
|
42
|
+
*/
|
|
43
|
+
static parse(value) {
|
|
44
|
+
return require_parse.parse(value);
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Serializes the given data to a JSON string.
|
|
48
|
+
* By default the JSON string is formatted with a 2 space indentation to be easy readable.
|
|
49
|
+
*
|
|
50
|
+
* @param value - Object which should be serialized to JSON
|
|
51
|
+
* @param _options - JSON serialize options
|
|
52
|
+
* @returns the formatted JSON representation of the object
|
|
53
|
+
*/
|
|
54
|
+
static stringify(value, _options) {
|
|
55
|
+
const customTransformer = StormJSON.instance.customTransformerRegistry.findApplicable(value);
|
|
56
|
+
let result = value;
|
|
57
|
+
if (customTransformer && customTransformer.isApplicable(value)) result = customTransformer.serialize(result);
|
|
58
|
+
return require_stringify.stringify(result);
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Parses the given JSON string and returns the object the JSON content represents.
|
|
62
|
+
* By default javascript-style comments and trailing commas are allowed.
|
|
63
|
+
*
|
|
64
|
+
* @param strData - JSON content as string
|
|
65
|
+
* @param options - JSON parse options
|
|
66
|
+
* @returns Object the JSON content represents
|
|
67
|
+
*/
|
|
68
|
+
static parseJson(strData, options) {
|
|
69
|
+
try {
|
|
70
|
+
if (options?.expectComments === false) return StormJSON.instance.parse(strData);
|
|
71
|
+
} catch {}
|
|
72
|
+
const errors = [];
|
|
73
|
+
const result = (0, jsonc_parser.parse)(strData, errors, {
|
|
74
|
+
allowTrailingComma: true,
|
|
75
|
+
...options
|
|
76
|
+
});
|
|
77
|
+
if (errors.length > 0 && errors[0]) throw new Error(require_parse_error.formatParseError(strData, errors[0]));
|
|
78
|
+
return result;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Register a custom schema with superjson
|
|
82
|
+
*
|
|
83
|
+
* @param name - The name of the schema
|
|
84
|
+
* @param serialize - The function to serialize the schema
|
|
85
|
+
* @param deserialize - The function to deserialize the schema
|
|
86
|
+
* @param isApplicable - The function to check if the schema is applicable
|
|
87
|
+
*/
|
|
88
|
+
static register(name, serialize, deserialize, isApplicable) {
|
|
89
|
+
StormJSON.instance.registerCustom({
|
|
90
|
+
isApplicable,
|
|
91
|
+
serialize,
|
|
92
|
+
deserialize
|
|
93
|
+
}, name);
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Register a class with superjson
|
|
97
|
+
*
|
|
98
|
+
* @param classConstructor - The class constructor to register
|
|
99
|
+
*/
|
|
100
|
+
static registerClass(classConstructor, options) {
|
|
101
|
+
StormJSON.instance.registerClass(classConstructor, {
|
|
102
|
+
identifier: require_is_string.isString(options) ? options : options?.identifier || classConstructor.name,
|
|
103
|
+
allowProps: options && require_is_object.isObject(options) && options?.allowProps && Array.isArray(options.allowProps) ? options.allowProps : ["__typename"]
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
constructor() {
|
|
107
|
+
super({ dedupe: true });
|
|
108
|
+
}
|
|
109
|
+
};
|
|
110
|
+
StormJSON.instance.registerCustom({
|
|
111
|
+
isApplicable: (v) => node_buffer.Buffer.isBuffer(v),
|
|
112
|
+
serialize: (v) => v.toString("base64"),
|
|
113
|
+
deserialize: (v) => node_buffer.Buffer.from(v, "base64")
|
|
114
|
+
}, "Bytes");
|
|
115
|
+
|
|
116
|
+
//#endregion
|
|
117
|
+
exports.StormJSON = StormJSON;
|