@powerlines/plugin-webpack 0.5.129 → 0.5.131
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/helpers/index.cjs +3 -2
- package/dist/helpers/index.d.cts +3 -1
- package/dist/helpers/index.d.mts +3 -1
- package/dist/helpers/index.mjs +2 -1
- package/dist/helpers/unplugin.cjs +2 -11
- package/dist/helpers/unplugin.d.cts +2 -6
- package/dist/helpers/unplugin.d.mts +2 -6
- package/dist/helpers/unplugin.mjs +1 -9
- package/dist/helpers-B15z10jN.mjs +1 -0
- package/dist/helpers-LF26RHol.cjs +0 -0
- package/dist/index-9iG2qHLe.d.mts +1 -0
- package/dist/index-D4ELpJXS.d.cts +1 -0
- package/dist/index-D6CnpA_r.d.cts +1 -0
- package/dist/index-DL0uimUT.d.mts +1 -0
- package/dist/index.cjs +50 -8
- package/dist/index.d.cts +4 -3
- package/dist/index.d.mts +5 -5
- package/dist/index.mjs +46 -3
- package/dist/plugin-CsQFPhIt.d.cts +1762 -0
- package/dist/plugin-ifZVa20V.mjs +1 -0
- package/dist/plugin-pBKbb5K9.cjs +0 -0
- package/dist/plugin-wiaZGMv0.d.mts +1764 -0
- package/dist/types/index.cjs +2 -0
- package/dist/types/index.d.cts +2 -1
- package/dist/types/index.d.mts +2 -1
- package/dist/types/index.mjs +3 -0
- package/dist/types/plugin.cjs +1 -0
- package/dist/types/plugin.d.cts +1 -12
- package/dist/types/plugin.d.mts +1 -12
- package/dist/types/plugin.mjs +2 -0
- package/dist/types-U3zd8PTP.mjs +1 -0
- package/dist/types-o3zWarRp.cjs +0 -0
- package/dist/unplugin-BVSyqmCe.d.cts +7 -0
- package/dist/unplugin-CVrlqRhX.mjs +4615 -0
- package/dist/unplugin-Cemsz8kP.cjs +4659 -0
- package/dist/unplugin-vRGq3odL.d.mts +7 -0
- package/package.json +5 -5
- package/dist/_virtual/rolldown_runtime.cjs +0 -29
- package/dist/powerlines/schemas/fs.cjs +0 -226
- package/dist/powerlines/schemas/fs.mjs +0 -224
- package/dist/powerlines/src/api.cjs +0 -580
- package/dist/powerlines/src/api.mjs +0 -578
- package/dist/powerlines/src/internal/babel/module-resolver-plugin.cjs +0 -86
- package/dist/powerlines/src/internal/babel/module-resolver-plugin.mjs +0 -84
- package/dist/powerlines/src/internal/helpers/environment.cjs +0 -52
- package/dist/powerlines/src/internal/helpers/environment.mjs +0 -48
- package/dist/powerlines/src/internal/helpers/generate-types.cjs +0 -51
- package/dist/powerlines/src/internal/helpers/generate-types.mjs +0 -49
- package/dist/powerlines/src/internal/helpers/hooks.cjs +0 -63
- package/dist/powerlines/src/internal/helpers/hooks.mjs +0 -61
- package/dist/powerlines/src/internal/helpers/install-dependencies.cjs +0 -25
- package/dist/powerlines/src/internal/helpers/install-dependencies.mjs +0 -24
- package/dist/powerlines/src/internal/helpers/install.cjs +0 -37
- package/dist/powerlines/src/internal/helpers/install.mjs +0 -36
- package/dist/powerlines/src/internal/helpers/resolve-tsconfig.cjs +0 -98
- package/dist/powerlines/src/internal/helpers/resolve-tsconfig.mjs +0 -94
- package/dist/powerlines/src/internal/helpers/resolver.cjs +0 -43
- package/dist/powerlines/src/internal/helpers/resolver.mjs +0 -41
- package/dist/powerlines/src/lib/build/webpack.cjs +0 -47
- package/dist/powerlines/src/lib/build/webpack.mjs +0 -45
- package/dist/powerlines/src/lib/config-file.cjs +0 -79
- package/dist/powerlines/src/lib/config-file.mjs +0 -76
- package/dist/powerlines/src/lib/contexts/api-context.cjs +0 -184
- package/dist/powerlines/src/lib/contexts/api-context.mjs +0 -182
- package/dist/powerlines/src/lib/contexts/context.cjs +0 -931
- package/dist/powerlines/src/lib/contexts/context.mjs +0 -929
- package/dist/powerlines/src/lib/contexts/environment-context.cjs +0 -160
- package/dist/powerlines/src/lib/contexts/environment-context.mjs +0 -159
- package/dist/powerlines/src/lib/contexts/plugin-context.cjs +0 -75
- package/dist/powerlines/src/lib/contexts/plugin-context.mjs +0 -74
- package/dist/powerlines/src/lib/entry.cjs +0 -69
- package/dist/powerlines/src/lib/entry.mjs +0 -67
- package/dist/powerlines/src/lib/fs/helpers.cjs +0 -85
- package/dist/powerlines/src/lib/fs/helpers.mjs +0 -81
- package/dist/powerlines/src/lib/fs/storage/base.cjs +0 -196
- package/dist/powerlines/src/lib/fs/storage/base.mjs +0 -195
- package/dist/powerlines/src/lib/fs/storage/file-system.cjs +0 -170
- package/dist/powerlines/src/lib/fs/storage/file-system.mjs +0 -169
- package/dist/powerlines/src/lib/fs/storage/virtual.cjs +0 -88
- package/dist/powerlines/src/lib/fs/storage/virtual.mjs +0 -87
- package/dist/powerlines/src/lib/fs/vfs.cjs +0 -830
- package/dist/powerlines/src/lib/fs/vfs.mjs +0 -828
- package/dist/powerlines/src/lib/logger.cjs +0 -58
- package/dist/powerlines/src/lib/logger.mjs +0 -55
- package/dist/powerlines/src/lib/typescript/ts-morph.cjs +0 -104
- package/dist/powerlines/src/lib/typescript/ts-morph.mjs +0 -102
- package/dist/powerlines/src/lib/typescript/tsconfig.cjs +0 -149
- package/dist/powerlines/src/lib/typescript/tsconfig.mjs +0 -144
- package/dist/powerlines/src/lib/unplugin/factory.cjs +0 -6
- package/dist/powerlines/src/lib/unplugin/factory.mjs +0 -8
- package/dist/powerlines/src/lib/unplugin/helpers.cjs +0 -17
- package/dist/powerlines/src/lib/unplugin/helpers.mjs +0 -16
- package/dist/powerlines/src/lib/unplugin/index.cjs +0 -3
- package/dist/powerlines/src/lib/unplugin/index.mjs +0 -5
- package/dist/powerlines/src/lib/unplugin/plugin.cjs +0 -128
- package/dist/powerlines/src/lib/unplugin/plugin.mjs +0 -127
- package/dist/powerlines/src/lib/utilities/file-header.cjs +0 -22
- package/dist/powerlines/src/lib/utilities/file-header.mjs +0 -21
- package/dist/powerlines/src/lib/utilities/meta.cjs +0 -45
- package/dist/powerlines/src/lib/utilities/meta.mjs +0 -41
- package/dist/powerlines/src/lib/utilities/source-file.cjs +0 -22
- package/dist/powerlines/src/lib/utilities/source-file.mjs +0 -21
- package/dist/powerlines/src/plugin-utils/helpers.cjs +0 -148
- package/dist/powerlines/src/plugin-utils/helpers.mjs +0 -138
- package/dist/powerlines/src/plugin-utils/paths.cjs +0 -36
- package/dist/powerlines/src/plugin-utils/paths.mjs +0 -35
- package/dist/powerlines/src/types/babel.d.mts +0 -4
- package/dist/powerlines/src/types/build.cjs +0 -15
- package/dist/powerlines/src/types/build.d.cts +0 -149
- package/dist/powerlines/src/types/build.d.mts +0 -149
- package/dist/powerlines/src/types/build.mjs +0 -14
- package/dist/powerlines/src/types/commands.cjs +0 -16
- package/dist/powerlines/src/types/commands.d.cts +0 -8
- package/dist/powerlines/src/types/commands.d.mts +0 -9
- package/dist/powerlines/src/types/commands.mjs +0 -15
- package/dist/powerlines/src/types/config.d.cts +0 -370
- package/dist/powerlines/src/types/config.d.mts +0 -372
- package/dist/powerlines/src/types/context.d.cts +0 -403
- package/dist/powerlines/src/types/context.d.mts +0 -405
- package/dist/powerlines/src/types/fs.d.cts +0 -486
- package/dist/powerlines/src/types/fs.d.mts +0 -486
- package/dist/powerlines/src/types/hooks.d.mts +0 -2
- package/dist/powerlines/src/types/plugin.cjs +0 -32
- package/dist/powerlines/src/types/plugin.d.cts +0 -231
- package/dist/powerlines/src/types/plugin.d.mts +0 -231
- package/dist/powerlines/src/types/plugin.mjs +0 -31
- package/dist/powerlines/src/types/resolved.d.cts +0 -82
- package/dist/powerlines/src/types/resolved.d.mts +0 -83
- package/dist/powerlines/src/types/tsconfig.d.cts +0 -69
- package/dist/powerlines/src/types/tsconfig.d.mts +0 -69
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
const require_rolldown_runtime = require('../../../../_virtual/rolldown_runtime.cjs');
|
|
2
|
-
let __stryke_convert_to_array = require("@stryke/convert/to-array");
|
|
3
|
-
let __stryke_type_checks_is_error = require("@stryke/type-checks/is-error");
|
|
4
|
-
let __stryke_type_checks_is_set_object = require("@stryke/type-checks/is-set-object");
|
|
5
|
-
let __stryke_type_checks_is_set_string = require("@stryke/type-checks/is-set-string");
|
|
6
|
-
let __stryke_path_file_path_fns = require("@stryke/path/file-path-fns");
|
|
7
|
-
let __stryke_helpers_get_unique = require("@stryke/helpers/get-unique");
|
|
8
|
-
let __stryke_path_is_type = require("@stryke/path/is-type");
|
|
9
|
-
let __stryke_path_join = require("@stryke/path/join");
|
|
10
|
-
let __stryke_path_correct_path = require("@stryke/path/correct-path");
|
|
11
|
-
let __stryke_path_slash = require("@stryke/path/slash");
|
|
12
|
-
|
|
13
|
-
//#region ../powerlines/src/lib/fs/helpers.ts
|
|
14
|
-
/**
|
|
15
|
-
* Checks if an error is a file system error.
|
|
16
|
-
*
|
|
17
|
-
* @param err - The error to check.
|
|
18
|
-
* @returns `true` if the error is a file system error, otherwise `false`.
|
|
19
|
-
*/
|
|
20
|
-
function isFileError(err) {
|
|
21
|
-
return (0, __stryke_type_checks_is_error.isError)(err) && "code" in err && err.code;
|
|
22
|
-
}
|
|
23
|
-
/**
|
|
24
|
-
* Ignores file not found errors.
|
|
25
|
-
*
|
|
26
|
-
* @param err - The error to check.
|
|
27
|
-
* @returns `null` if the error is a file not found error, otherwise returns the error.
|
|
28
|
-
*/
|
|
29
|
-
function ignoreNotfound(err) {
|
|
30
|
-
return isFileError(err) && (err.code === "ENOENT" || err.code === "EISDIR" ? null : err);
|
|
31
|
-
}
|
|
32
|
-
function toFilePath(path) {
|
|
33
|
-
return (0, __stryke_path_correct_path.correctPath)((0, __stryke_path_slash.slash)(path?.toString() || ".").replace(/^file:\/\//, ""));
|
|
34
|
-
}
|
|
35
|
-
/**
|
|
36
|
-
* Checks if a given file id is valid based on the specified prefix.
|
|
37
|
-
*
|
|
38
|
-
* @param id - The file ID to check.
|
|
39
|
-
* @param prefix - The prefix to use for built-in files. Default is "powerlines".
|
|
40
|
-
* @returns `true` if the file ID is valid, otherwise `false`.
|
|
41
|
-
*/
|
|
42
|
-
function isValidId(id, prefix = "powerlines") {
|
|
43
|
-
return id.replace(/^\\0/, "").startsWith(`${prefix.replace(/:$/, "")}`);
|
|
44
|
-
}
|
|
45
|
-
/**
|
|
46
|
-
* Formats a file id by removing the file extension and prepending the runtime prefix.
|
|
47
|
-
*
|
|
48
|
-
* @param id - The file ID to format.
|
|
49
|
-
* @param prefix - The prefix to use for built-in files. Default is "powerlines".
|
|
50
|
-
* @returns The formatted file ID.
|
|
51
|
-
*/
|
|
52
|
-
function normalizeId(id, prefix = "powerlines") {
|
|
53
|
-
return `${prefix.replace(/:$/, "")}:${toFilePath(id).replace(/* @__PURE__ */ new RegExp(`^${prefix.replace(/:$/, "")}:`), "").replace(/^\\0/, "").replace((0, __stryke_path_file_path_fns.findFileDotExtensionSafe)(toFilePath(id)), "")}`;
|
|
54
|
-
}
|
|
55
|
-
/**
|
|
56
|
-
* Normalizes a given path by resolving it against the project root, workspace root, and built-ins path.
|
|
57
|
-
*
|
|
58
|
-
* @param path - The path to normalize.
|
|
59
|
-
* @param builtinsPath - The path to built-in files.
|
|
60
|
-
* @param prefix - The prefix to use for built-in files. Default is "powerlines".
|
|
61
|
-
* @returns The normalized path.
|
|
62
|
-
*/
|
|
63
|
-
function normalizePath(path, builtinsPath, prefix = "powerlines") {
|
|
64
|
-
return (0, __stryke_path_is_type.isAbsolutePath)(path) ? path : isValidId(toFilePath(path), prefix) ? normalizeId(toFilePath(path), prefix).replace(/* @__PURE__ */ new RegExp(`^${prefix.replace(/:$/, "")}:`), builtinsPath) : toFilePath(path);
|
|
65
|
-
}
|
|
66
|
-
/**
|
|
67
|
-
* Normalizes glob patterns by resolving them against the workspace root.
|
|
68
|
-
*
|
|
69
|
-
* @param workspaceRoot - The root directory of the workspace.
|
|
70
|
-
* @param patterns - The glob patterns to normalize.
|
|
71
|
-
* @returns An array of normalized glob patterns.
|
|
72
|
-
*/
|
|
73
|
-
function normalizeGlobPatterns(workspaceRoot, patterns) {
|
|
74
|
-
return (0, __stryke_helpers_get_unique.getUnique)((0, __stryke_convert_to_array.toArray)(patterns).map((pattern) => {
|
|
75
|
-
if ((0, __stryke_type_checks_is_set_object.isSetObject)(pattern) && ((0, __stryke_type_checks_is_set_string.isSetString)(pattern.input) || (0, __stryke_type_checks_is_set_string.isSetString)(pattern.glob))) return (0, __stryke_path_join.joinPaths)(pattern.input || workspaceRoot, pattern.glob || "**/*");
|
|
76
|
-
else if (!(0, __stryke_type_checks_is_set_string.isSetString)(pattern)) return;
|
|
77
|
-
return pattern;
|
|
78
|
-
}).filter(__stryke_type_checks_is_set_string.isSetString));
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
//#endregion
|
|
82
|
-
exports.ignoreNotfound = ignoreNotfound;
|
|
83
|
-
exports.normalizeGlobPatterns = normalizeGlobPatterns;
|
|
84
|
-
exports.normalizeId = normalizeId;
|
|
85
|
-
exports.normalizePath = normalizePath;
|
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
import { toArray } from "@stryke/convert/to-array";
|
|
2
|
-
import { isError } from "@stryke/type-checks/is-error";
|
|
3
|
-
import { isSetObject } from "@stryke/type-checks/is-set-object";
|
|
4
|
-
import { isSetString } from "@stryke/type-checks/is-set-string";
|
|
5
|
-
import { findFileDotExtensionSafe } from "@stryke/path/file-path-fns";
|
|
6
|
-
import { getUnique } from "@stryke/helpers/get-unique";
|
|
7
|
-
import { isAbsolutePath } from "@stryke/path/is-type";
|
|
8
|
-
import { joinPaths } from "@stryke/path/join";
|
|
9
|
-
import { correctPath } from "@stryke/path/correct-path";
|
|
10
|
-
import { slash } from "@stryke/path/slash";
|
|
11
|
-
|
|
12
|
-
//#region ../powerlines/src/lib/fs/helpers.ts
|
|
13
|
-
/**
|
|
14
|
-
* Checks if an error is a file system error.
|
|
15
|
-
*
|
|
16
|
-
* @param err - The error to check.
|
|
17
|
-
* @returns `true` if the error is a file system error, otherwise `false`.
|
|
18
|
-
*/
|
|
19
|
-
function isFileError(err) {
|
|
20
|
-
return isError(err) && "code" in err && err.code;
|
|
21
|
-
}
|
|
22
|
-
/**
|
|
23
|
-
* Ignores file not found errors.
|
|
24
|
-
*
|
|
25
|
-
* @param err - The error to check.
|
|
26
|
-
* @returns `null` if the error is a file not found error, otherwise returns the error.
|
|
27
|
-
*/
|
|
28
|
-
function ignoreNotfound(err) {
|
|
29
|
-
return isFileError(err) && (err.code === "ENOENT" || err.code === "EISDIR" ? null : err);
|
|
30
|
-
}
|
|
31
|
-
function toFilePath(path) {
|
|
32
|
-
return correctPath(slash(path?.toString() || ".").replace(/^file:\/\//, ""));
|
|
33
|
-
}
|
|
34
|
-
/**
|
|
35
|
-
* Checks if a given file id is valid based on the specified prefix.
|
|
36
|
-
*
|
|
37
|
-
* @param id - The file ID to check.
|
|
38
|
-
* @param prefix - The prefix to use for built-in files. Default is "powerlines".
|
|
39
|
-
* @returns `true` if the file ID is valid, otherwise `false`.
|
|
40
|
-
*/
|
|
41
|
-
function isValidId(id, prefix = "powerlines") {
|
|
42
|
-
return id.replace(/^\\0/, "").startsWith(`${prefix.replace(/:$/, "")}`);
|
|
43
|
-
}
|
|
44
|
-
/**
|
|
45
|
-
* Formats a file id by removing the file extension and prepending the runtime prefix.
|
|
46
|
-
*
|
|
47
|
-
* @param id - The file ID to format.
|
|
48
|
-
* @param prefix - The prefix to use for built-in files. Default is "powerlines".
|
|
49
|
-
* @returns The formatted file ID.
|
|
50
|
-
*/
|
|
51
|
-
function normalizeId(id, prefix = "powerlines") {
|
|
52
|
-
return `${prefix.replace(/:$/, "")}:${toFilePath(id).replace(/* @__PURE__ */ new RegExp(`^${prefix.replace(/:$/, "")}:`), "").replace(/^\\0/, "").replace(findFileDotExtensionSafe(toFilePath(id)), "")}`;
|
|
53
|
-
}
|
|
54
|
-
/**
|
|
55
|
-
* Normalizes a given path by resolving it against the project root, workspace root, and built-ins path.
|
|
56
|
-
*
|
|
57
|
-
* @param path - The path to normalize.
|
|
58
|
-
* @param builtinsPath - The path to built-in files.
|
|
59
|
-
* @param prefix - The prefix to use for built-in files. Default is "powerlines".
|
|
60
|
-
* @returns The normalized path.
|
|
61
|
-
*/
|
|
62
|
-
function normalizePath(path, builtinsPath, prefix = "powerlines") {
|
|
63
|
-
return isAbsolutePath(path) ? path : isValidId(toFilePath(path), prefix) ? normalizeId(toFilePath(path), prefix).replace(/* @__PURE__ */ new RegExp(`^${prefix.replace(/:$/, "")}:`), builtinsPath) : toFilePath(path);
|
|
64
|
-
}
|
|
65
|
-
/**
|
|
66
|
-
* Normalizes glob patterns by resolving them against the workspace root.
|
|
67
|
-
*
|
|
68
|
-
* @param workspaceRoot - The root directory of the workspace.
|
|
69
|
-
* @param patterns - The glob patterns to normalize.
|
|
70
|
-
* @returns An array of normalized glob patterns.
|
|
71
|
-
*/
|
|
72
|
-
function normalizeGlobPatterns(workspaceRoot, patterns) {
|
|
73
|
-
return getUnique(toArray(patterns).map((pattern) => {
|
|
74
|
-
if (isSetObject(pattern) && (isSetString(pattern.input) || isSetString(pattern.glob))) return joinPaths(pattern.input || workspaceRoot, pattern.glob || "**/*");
|
|
75
|
-
else if (!isSetString(pattern)) return;
|
|
76
|
-
return pattern;
|
|
77
|
-
}).filter(isSetString));
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
//#endregion
|
|
81
|
-
export { ignoreNotfound, normalizeGlobPatterns, normalizeId, normalizePath };
|
|
@@ -1,196 +0,0 @@
|
|
|
1
|
-
const require_rolldown_runtime = require('../../../../../_virtual/rolldown_runtime.cjs');
|
|
2
|
-
let __stryke_path_append = require("@stryke/path/append");
|
|
3
|
-
let __stryke_path_join = require("@stryke/path/join");
|
|
4
|
-
let __stryke_path_correct_path = require("@stryke/path/correct-path");
|
|
5
|
-
let node_path = require("node:path");
|
|
6
|
-
|
|
7
|
-
//#region ../powerlines/src/lib/fs/storage/base.ts
|
|
8
|
-
/**
|
|
9
|
-
* Abstract base class for storage adapters, providing a template for storage operations.
|
|
10
|
-
*/
|
|
11
|
-
var BaseStorageAdapter = class {
|
|
12
|
-
/**
|
|
13
|
-
* Indicates whether the storage adapter has been disposed.
|
|
14
|
-
*/
|
|
15
|
-
#isDisposed = false;
|
|
16
|
-
/**
|
|
17
|
-
* Configuration options for the storage adapter.
|
|
18
|
-
*/
|
|
19
|
-
options;
|
|
20
|
-
/**
|
|
21
|
-
* The storage preset for the adapter.
|
|
22
|
-
*
|
|
23
|
-
* @remarks
|
|
24
|
-
* This can be used as an alternate way to identify the type of storage being used.
|
|
25
|
-
*/
|
|
26
|
-
preset = null;
|
|
27
|
-
/**
|
|
28
|
-
* Constructor for the BaseStorageAdapter.
|
|
29
|
-
*
|
|
30
|
-
* @param options - Configuration options for the storage adapter.
|
|
31
|
-
*/
|
|
32
|
-
constructor(options = { base: "/" }) {
|
|
33
|
-
this.options = options;
|
|
34
|
-
this.options.base = (0, node_path.resolve)(options.base);
|
|
35
|
-
this.options.isReadOnly = !!options.isReadOnly;
|
|
36
|
-
}
|
|
37
|
-
/**
|
|
38
|
-
* Asynchronously checks if a key exists in the storage.
|
|
39
|
-
*
|
|
40
|
-
* @param key - The key to check for existence.
|
|
41
|
-
* @returns A promise that resolves to `true` if the key exists, otherwise `false`.
|
|
42
|
-
*/
|
|
43
|
-
async exists(key) {
|
|
44
|
-
return this.existsSync(key);
|
|
45
|
-
}
|
|
46
|
-
/**
|
|
47
|
-
* Asynchronously retrieves the value associated with a given key.
|
|
48
|
-
*
|
|
49
|
-
* @param key - The key whose value is to be retrieved.
|
|
50
|
-
* @returns A promise that resolves to the value associated with the key, or `null` if the key does not exist.
|
|
51
|
-
*/
|
|
52
|
-
async get(key) {
|
|
53
|
-
return this.getSync(key);
|
|
54
|
-
}
|
|
55
|
-
/**
|
|
56
|
-
* Asynchronously sets the value for a given key.
|
|
57
|
-
*
|
|
58
|
-
* @param key - The key to set the value for.
|
|
59
|
-
* @param value - The value to set.
|
|
60
|
-
*/
|
|
61
|
-
async set(key, value) {
|
|
62
|
-
if (!this.options.isReadOnly) this.setSync(key, value);
|
|
63
|
-
}
|
|
64
|
-
/**
|
|
65
|
-
* Synchronously creates a directory at the specified path.
|
|
66
|
-
*
|
|
67
|
-
* @param _ - The path of the directory to create.
|
|
68
|
-
*/
|
|
69
|
-
mkdirSync(_) {}
|
|
70
|
-
/**
|
|
71
|
-
* Creates a directory at the specified path.
|
|
72
|
-
*
|
|
73
|
-
* @param dirPath - The path of the directory to create.
|
|
74
|
-
*/
|
|
75
|
-
async mkdir(dirPath) {
|
|
76
|
-
return Promise.resolve(this.mkdirSync(dirPath));
|
|
77
|
-
}
|
|
78
|
-
/**
|
|
79
|
-
* Asynchronously removes a key from the storage.
|
|
80
|
-
*
|
|
81
|
-
* @param key - The key to remove.
|
|
82
|
-
*/
|
|
83
|
-
async remove(key) {
|
|
84
|
-
if (!this.options.isReadOnly) this.removeSync(key);
|
|
85
|
-
}
|
|
86
|
-
/**
|
|
87
|
-
* Synchronously removes all entries from the storage that match the provided base path.
|
|
88
|
-
*
|
|
89
|
-
* @param base - The base path to clear keys from.
|
|
90
|
-
*/
|
|
91
|
-
clearSync(base) {
|
|
92
|
-
if (!this.options.isReadOnly) {
|
|
93
|
-
const keys = this.listSync(base || this.options.base);
|
|
94
|
-
if (!keys.length) return;
|
|
95
|
-
keys.map((key) => this.removeSync(base && !key.startsWith(base) ? (0, __stryke_path_join.joinPaths)(base, key) : key));
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
/**
|
|
99
|
-
* Asynchronously removes all entries from the storage that match the provided base path.
|
|
100
|
-
*
|
|
101
|
-
* @param base - The base path to clear keys from.
|
|
102
|
-
* @returns A promise that resolves when the operation is complete.
|
|
103
|
-
*/
|
|
104
|
-
async clear(base) {
|
|
105
|
-
if (!this.options.isReadOnly) {
|
|
106
|
-
const keys = await this.list(base || this.options.base);
|
|
107
|
-
if (!keys.length) return;
|
|
108
|
-
await Promise.all(keys.map(async (key) => this.remove(base && !key.startsWith(base) ? (0, __stryke_path_join.joinPaths)(base, key) : key)));
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
/**
|
|
112
|
-
* Asynchronously lists all keys under a given base path.
|
|
113
|
-
*
|
|
114
|
-
* @param base - The base path to list keys from.
|
|
115
|
-
* @returns A promise that resolves to an array of keys under the specified base path.
|
|
116
|
-
*/
|
|
117
|
-
async list(base) {
|
|
118
|
-
return this.listSync(base);
|
|
119
|
-
}
|
|
120
|
-
/**
|
|
121
|
-
* Synchronously checks if the given key is a directory.
|
|
122
|
-
*
|
|
123
|
-
* @param _ - The key to check.
|
|
124
|
-
* @returns `true` if the key is a directory, otherwise `false`.
|
|
125
|
-
*/
|
|
126
|
-
isDirectorySync(_) {
|
|
127
|
-
return false;
|
|
128
|
-
}
|
|
129
|
-
/**
|
|
130
|
-
* Checks if the given key is a directory.
|
|
131
|
-
*
|
|
132
|
-
* @param key - The key to check.
|
|
133
|
-
* @returns A promise that resolves to `true` if the key is a directory, otherwise `false`.
|
|
134
|
-
*/
|
|
135
|
-
async isDirectory(key) {
|
|
136
|
-
return Promise.resolve(this.isDirectorySync(key));
|
|
137
|
-
}
|
|
138
|
-
/**
|
|
139
|
-
* Synchronously checks if the given key is a file.
|
|
140
|
-
*
|
|
141
|
-
* @param key - The key to check.
|
|
142
|
-
* @returns `true` if the key is a file, otherwise `false`.
|
|
143
|
-
*/
|
|
144
|
-
isFileSync(key) {
|
|
145
|
-
return this.existsSync(key) && !this.isDirectorySync(key);
|
|
146
|
-
}
|
|
147
|
-
/**
|
|
148
|
-
* Checks if the given key is a file.
|
|
149
|
-
*
|
|
150
|
-
* @param key - The key to check.
|
|
151
|
-
* @returns A promise that resolves to `true` if the key is a file, otherwise `false`.
|
|
152
|
-
*/
|
|
153
|
-
async isFile(key) {
|
|
154
|
-
return Promise.resolve(this.isFileSync(key));
|
|
155
|
-
}
|
|
156
|
-
/**
|
|
157
|
-
* Disposes of the storage adapter, releasing any held resources.
|
|
158
|
-
*
|
|
159
|
-
* @returns A promise that resolves when the disposal is complete.
|
|
160
|
-
*/
|
|
161
|
-
dispose() {
|
|
162
|
-
return Promise.resolve();
|
|
163
|
-
}
|
|
164
|
-
/**
|
|
165
|
-
* Async dispose method to clean up resources.
|
|
166
|
-
*
|
|
167
|
-
* @returns A promise that resolves when disposal is complete.
|
|
168
|
-
*/
|
|
169
|
-
async [Symbol.asyncDispose]() {
|
|
170
|
-
return this._dispose();
|
|
171
|
-
}
|
|
172
|
-
/**
|
|
173
|
-
* Resolves a given key to its full path within the storage adapter.
|
|
174
|
-
*
|
|
175
|
-
* @param key - The key to resolve.
|
|
176
|
-
* @returns The resolved full path for the key.
|
|
177
|
-
*/
|
|
178
|
-
resolve(key = this.options.base) {
|
|
179
|
-
if (/\.\.:|\.\.$/.test(key)) throw new Error(`[${this.name}]: Invalid key: ${JSON.stringify(key)} provided to storage adapter.`);
|
|
180
|
-
return (0, __stryke_path_append.appendPath)((0, __stryke_path_correct_path.correctPath)(key).replace(/:/g, "/"), this.options.base);
|
|
181
|
-
}
|
|
182
|
-
/**
|
|
183
|
-
* Disposes of the storage adapter, releasing any held resources.
|
|
184
|
-
*
|
|
185
|
-
* @returns A promise that resolves when the disposal is complete.
|
|
186
|
-
*/
|
|
187
|
-
async _dispose() {
|
|
188
|
-
if (!this.#isDisposed) {
|
|
189
|
-
await Promise.resolve(this.dispose());
|
|
190
|
-
this.#isDisposed = true;
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
|
-
};
|
|
194
|
-
|
|
195
|
-
//#endregion
|
|
196
|
-
exports.BaseStorageAdapter = BaseStorageAdapter;
|
|
@@ -1,195 +0,0 @@
|
|
|
1
|
-
import { appendPath } from "@stryke/path/append";
|
|
2
|
-
import { joinPaths } from "@stryke/path/join";
|
|
3
|
-
import { correctPath } from "@stryke/path/correct-path";
|
|
4
|
-
import { resolve } from "node:path";
|
|
5
|
-
|
|
6
|
-
//#region ../powerlines/src/lib/fs/storage/base.ts
|
|
7
|
-
/**
|
|
8
|
-
* Abstract base class for storage adapters, providing a template for storage operations.
|
|
9
|
-
*/
|
|
10
|
-
var BaseStorageAdapter = class {
|
|
11
|
-
/**
|
|
12
|
-
* Indicates whether the storage adapter has been disposed.
|
|
13
|
-
*/
|
|
14
|
-
#isDisposed = false;
|
|
15
|
-
/**
|
|
16
|
-
* Configuration options for the storage adapter.
|
|
17
|
-
*/
|
|
18
|
-
options;
|
|
19
|
-
/**
|
|
20
|
-
* The storage preset for the adapter.
|
|
21
|
-
*
|
|
22
|
-
* @remarks
|
|
23
|
-
* This can be used as an alternate way to identify the type of storage being used.
|
|
24
|
-
*/
|
|
25
|
-
preset = null;
|
|
26
|
-
/**
|
|
27
|
-
* Constructor for the BaseStorageAdapter.
|
|
28
|
-
*
|
|
29
|
-
* @param options - Configuration options for the storage adapter.
|
|
30
|
-
*/
|
|
31
|
-
constructor(options = { base: "/" }) {
|
|
32
|
-
this.options = options;
|
|
33
|
-
this.options.base = resolve(options.base);
|
|
34
|
-
this.options.isReadOnly = !!options.isReadOnly;
|
|
35
|
-
}
|
|
36
|
-
/**
|
|
37
|
-
* Asynchronously checks if a key exists in the storage.
|
|
38
|
-
*
|
|
39
|
-
* @param key - The key to check for existence.
|
|
40
|
-
* @returns A promise that resolves to `true` if the key exists, otherwise `false`.
|
|
41
|
-
*/
|
|
42
|
-
async exists(key) {
|
|
43
|
-
return this.existsSync(key);
|
|
44
|
-
}
|
|
45
|
-
/**
|
|
46
|
-
* Asynchronously retrieves the value associated with a given key.
|
|
47
|
-
*
|
|
48
|
-
* @param key - The key whose value is to be retrieved.
|
|
49
|
-
* @returns A promise that resolves to the value associated with the key, or `null` if the key does not exist.
|
|
50
|
-
*/
|
|
51
|
-
async get(key) {
|
|
52
|
-
return this.getSync(key);
|
|
53
|
-
}
|
|
54
|
-
/**
|
|
55
|
-
* Asynchronously sets the value for a given key.
|
|
56
|
-
*
|
|
57
|
-
* @param key - The key to set the value for.
|
|
58
|
-
* @param value - The value to set.
|
|
59
|
-
*/
|
|
60
|
-
async set(key, value) {
|
|
61
|
-
if (!this.options.isReadOnly) this.setSync(key, value);
|
|
62
|
-
}
|
|
63
|
-
/**
|
|
64
|
-
* Synchronously creates a directory at the specified path.
|
|
65
|
-
*
|
|
66
|
-
* @param _ - The path of the directory to create.
|
|
67
|
-
*/
|
|
68
|
-
mkdirSync(_) {}
|
|
69
|
-
/**
|
|
70
|
-
* Creates a directory at the specified path.
|
|
71
|
-
*
|
|
72
|
-
* @param dirPath - The path of the directory to create.
|
|
73
|
-
*/
|
|
74
|
-
async mkdir(dirPath) {
|
|
75
|
-
return Promise.resolve(this.mkdirSync(dirPath));
|
|
76
|
-
}
|
|
77
|
-
/**
|
|
78
|
-
* Asynchronously removes a key from the storage.
|
|
79
|
-
*
|
|
80
|
-
* @param key - The key to remove.
|
|
81
|
-
*/
|
|
82
|
-
async remove(key) {
|
|
83
|
-
if (!this.options.isReadOnly) this.removeSync(key);
|
|
84
|
-
}
|
|
85
|
-
/**
|
|
86
|
-
* Synchronously removes all entries from the storage that match the provided base path.
|
|
87
|
-
*
|
|
88
|
-
* @param base - The base path to clear keys from.
|
|
89
|
-
*/
|
|
90
|
-
clearSync(base) {
|
|
91
|
-
if (!this.options.isReadOnly) {
|
|
92
|
-
const keys = this.listSync(base || this.options.base);
|
|
93
|
-
if (!keys.length) return;
|
|
94
|
-
keys.map((key) => this.removeSync(base && !key.startsWith(base) ? joinPaths(base, key) : key));
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
/**
|
|
98
|
-
* Asynchronously removes all entries from the storage that match the provided base path.
|
|
99
|
-
*
|
|
100
|
-
* @param base - The base path to clear keys from.
|
|
101
|
-
* @returns A promise that resolves when the operation is complete.
|
|
102
|
-
*/
|
|
103
|
-
async clear(base) {
|
|
104
|
-
if (!this.options.isReadOnly) {
|
|
105
|
-
const keys = await this.list(base || this.options.base);
|
|
106
|
-
if (!keys.length) return;
|
|
107
|
-
await Promise.all(keys.map(async (key) => this.remove(base && !key.startsWith(base) ? joinPaths(base, key) : key)));
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
/**
|
|
111
|
-
* Asynchronously lists all keys under a given base path.
|
|
112
|
-
*
|
|
113
|
-
* @param base - The base path to list keys from.
|
|
114
|
-
* @returns A promise that resolves to an array of keys under the specified base path.
|
|
115
|
-
*/
|
|
116
|
-
async list(base) {
|
|
117
|
-
return this.listSync(base);
|
|
118
|
-
}
|
|
119
|
-
/**
|
|
120
|
-
* Synchronously checks if the given key is a directory.
|
|
121
|
-
*
|
|
122
|
-
* @param _ - The key to check.
|
|
123
|
-
* @returns `true` if the key is a directory, otherwise `false`.
|
|
124
|
-
*/
|
|
125
|
-
isDirectorySync(_) {
|
|
126
|
-
return false;
|
|
127
|
-
}
|
|
128
|
-
/**
|
|
129
|
-
* Checks if the given key is a directory.
|
|
130
|
-
*
|
|
131
|
-
* @param key - The key to check.
|
|
132
|
-
* @returns A promise that resolves to `true` if the key is a directory, otherwise `false`.
|
|
133
|
-
*/
|
|
134
|
-
async isDirectory(key) {
|
|
135
|
-
return Promise.resolve(this.isDirectorySync(key));
|
|
136
|
-
}
|
|
137
|
-
/**
|
|
138
|
-
* Synchronously checks if the given key is a file.
|
|
139
|
-
*
|
|
140
|
-
* @param key - The key to check.
|
|
141
|
-
* @returns `true` if the key is a file, otherwise `false`.
|
|
142
|
-
*/
|
|
143
|
-
isFileSync(key) {
|
|
144
|
-
return this.existsSync(key) && !this.isDirectorySync(key);
|
|
145
|
-
}
|
|
146
|
-
/**
|
|
147
|
-
* Checks if the given key is a file.
|
|
148
|
-
*
|
|
149
|
-
* @param key - The key to check.
|
|
150
|
-
* @returns A promise that resolves to `true` if the key is a file, otherwise `false`.
|
|
151
|
-
*/
|
|
152
|
-
async isFile(key) {
|
|
153
|
-
return Promise.resolve(this.isFileSync(key));
|
|
154
|
-
}
|
|
155
|
-
/**
|
|
156
|
-
* Disposes of the storage adapter, releasing any held resources.
|
|
157
|
-
*
|
|
158
|
-
* @returns A promise that resolves when the disposal is complete.
|
|
159
|
-
*/
|
|
160
|
-
dispose() {
|
|
161
|
-
return Promise.resolve();
|
|
162
|
-
}
|
|
163
|
-
/**
|
|
164
|
-
* Async dispose method to clean up resources.
|
|
165
|
-
*
|
|
166
|
-
* @returns A promise that resolves when disposal is complete.
|
|
167
|
-
*/
|
|
168
|
-
async [Symbol.asyncDispose]() {
|
|
169
|
-
return this._dispose();
|
|
170
|
-
}
|
|
171
|
-
/**
|
|
172
|
-
* Resolves a given key to its full path within the storage adapter.
|
|
173
|
-
*
|
|
174
|
-
* @param key - The key to resolve.
|
|
175
|
-
* @returns The resolved full path for the key.
|
|
176
|
-
*/
|
|
177
|
-
resolve(key = this.options.base) {
|
|
178
|
-
if (/\.\.:|\.\.$/.test(key)) throw new Error(`[${this.name}]: Invalid key: ${JSON.stringify(key)} provided to storage adapter.`);
|
|
179
|
-
return appendPath(correctPath(key).replace(/:/g, "/"), this.options.base);
|
|
180
|
-
}
|
|
181
|
-
/**
|
|
182
|
-
* Disposes of the storage adapter, releasing any held resources.
|
|
183
|
-
*
|
|
184
|
-
* @returns A promise that resolves when the disposal is complete.
|
|
185
|
-
*/
|
|
186
|
-
async _dispose() {
|
|
187
|
-
if (!this.#isDisposed) {
|
|
188
|
-
await Promise.resolve(this.dispose());
|
|
189
|
-
this.#isDisposed = true;
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
};
|
|
193
|
-
|
|
194
|
-
//#endregion
|
|
195
|
-
export { BaseStorageAdapter };
|