powerlines 0.41.6 → 0.41.7
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/README.md +14 -16
- package/dist/{api-CY668wMZ.mjs → api-6f2oVwGy.mjs} +142 -333
- package/dist/api-6f2oVwGy.mjs.map +1 -0
- package/dist/{api-GPlMYw0d.cjs → api-CFXLaAxU.cjs} +505 -722
- package/dist/astro.cjs +8 -18
- package/dist/astro.d.cts +1 -2
- package/dist/astro.d.cts.map +1 -1
- package/dist/astro.d.mts +1 -6
- package/dist/astro.d.mts.map +1 -1
- package/dist/astro.mjs +6 -16
- package/dist/astro.mjs.map +1 -1
- package/dist/{chunk-CbDLau6x.cjs → chunk-AIJqnxB6.cjs} +27 -1
- package/dist/chunk-CtajNgzt.mjs +36 -0
- package/dist/config.cjs +20 -4
- package/dist/config.d.cts +1 -2
- package/dist/config.d.mts +1 -3
- package/dist/config.mjs +11 -2
- package/dist/config.mjs.map +1 -0
- package/dist/constants.cjs +20 -20
- package/dist/constants.d.cts +1 -24
- package/dist/constants.d.mts +1 -24
- package/dist/constants.mjs +11 -3
- package/dist/constants.mjs.map +1 -0
- package/dist/context/index.cjs +4 -9
- package/dist/context/index.d.cts +56 -132
- package/dist/context/index.d.cts.map +1 -1
- package/dist/context/index.d.mts +55 -135
- package/dist/context/index.d.mts.map +1 -1
- package/dist/context/index.mjs +3 -9
- package/dist/esbuild.cjs +60 -17
- package/dist/esbuild.d.cts +5 -29
- package/dist/esbuild.d.cts.map +1 -1
- package/dist/esbuild.d.mts +5 -33
- package/dist/esbuild.d.mts.map +1 -1
- package/dist/esbuild.mjs +44 -12
- package/dist/esbuild.mjs.map +1 -0
- package/dist/farm.cjs +6 -13
- package/dist/farm.d.cts +2 -3
- package/dist/farm.d.cts.map +1 -1
- package/dist/farm.d.mts +2 -6
- package/dist/farm.d.mts.map +1 -1
- package/dist/farm.mjs +4 -11
- package/dist/farm.mjs.map +1 -1
- package/dist/index.cjs +7 -13
- package/dist/index.d.cts +263 -6
- package/dist/index.d.cts.map +1 -0
- package/dist/index.d.mts +263 -7
- package/dist/index.d.mts.map +1 -0
- package/dist/index.mjs +3 -9
- package/dist/index.mjs.map +1 -1
- package/dist/next.cjs +7 -14
- package/dist/next.d.cts +0 -1
- package/dist/next.d.cts.map +1 -1
- package/dist/next.d.mts +0 -1
- package/dist/next.d.mts.map +1 -1
- package/dist/next.mjs +6 -13
- package/dist/next.mjs.map +1 -1
- package/dist/nuxt.cjs +12 -22
- package/dist/nuxt.d.cts +2 -3
- package/dist/nuxt.d.cts.map +1 -1
- package/dist/nuxt.d.mts +2 -7
- package/dist/nuxt.d.mts.map +1 -1
- package/dist/nuxt.mjs +8 -18
- package/dist/nuxt.mjs.map +1 -1
- package/dist/plugin-utils.cjs +20 -28
- package/dist/plugin-utils.d.cts +1 -267
- package/dist/plugin-utils.d.mts +1 -272
- package/dist/plugin-utils.mjs +11 -4
- package/dist/plugin-utils.mjs.map +1 -0
- package/dist/rolldown.cjs +52 -18
- package/dist/rolldown.d.cts +5 -29
- package/dist/rolldown.d.cts.map +1 -1
- package/dist/rolldown.d.mts +5 -32
- package/dist/rolldown.d.mts.map +1 -1
- package/dist/rolldown.mjs +36 -13
- package/dist/rolldown.mjs.map +1 -0
- package/dist/rollup.cjs +20 -48
- package/dist/rollup.d.cts +5 -29
- package/dist/rollup.d.cts.map +1 -1
- package/dist/rollup.d.mts +5 -32
- package/dist/rollup.d.mts.map +1 -1
- package/dist/rollup.mjs +6 -44
- package/dist/rollup.mjs.map +1 -1
- package/dist/rspack.cjs +20 -82
- package/dist/rspack.d.cts +4 -24
- package/dist/rspack.d.cts.map +1 -1
- package/dist/rspack.d.mts +4 -27
- package/dist/rspack.d.mts.map +1 -1
- package/dist/rspack.mjs +5 -77
- package/dist/rspack.mjs.map +1 -1
- package/dist/storage/index.cjs +2 -3
- package/dist/storage/index.d.cts +7 -7
- package/dist/storage/index.d.cts.map +1 -1
- package/dist/storage/index.d.mts +7 -11
- package/dist/storage/index.d.mts.map +1 -1
- package/dist/storage/index.mjs +1 -3
- package/dist/{tsconfig-C8M8X6U0.cjs → tsconfig-BJrUrPC_.cjs} +13 -13
- package/dist/{tsconfig-B92heKit.mjs → tsconfig-D9GCB2I9.mjs} +5 -5
- package/dist/tsconfig-D9GCB2I9.mjs.map +1 -0
- package/dist/tsdown.cjs +38 -187
- package/dist/tsdown.d.cts +2 -24
- package/dist/tsdown.d.cts.map +1 -1
- package/dist/tsdown.d.mts +4 -30
- package/dist/tsdown.d.mts.map +1 -1
- package/dist/tsdown.mjs +8 -167
- package/dist/tsdown.mjs.map +1 -1
- package/dist/tsup.cjs +29 -134
- package/dist/tsup.d.cts +2 -24
- package/dist/tsup.d.cts.map +1 -1
- package/dist/tsup.d.mts +2 -28
- package/dist/tsup.d.mts.map +1 -1
- package/dist/tsup.mjs +7 -122
- package/dist/tsup.mjs.map +1 -1
- package/dist/types-DerAvFjs.d.cts +4 -0
- package/dist/types-DerAvFjs.d.cts.map +1 -0
- package/dist/types-ro7jWCtL.d.mts +4 -0
- package/dist/types-ro7jWCtL.d.mts.map +1 -0
- package/dist/typescript/index.cjs +2 -1
- package/dist/typescript/index.d.cts +2 -2
- package/dist/typescript/index.d.cts.map +1 -1
- package/dist/typescript/index.d.mts +1 -4
- package/dist/typescript/index.d.mts.map +1 -1
- package/dist/typescript/index.mjs +1 -1
- package/dist/unloader.cjs +6 -13
- package/dist/unloader.d.cts +2 -4
- package/dist/unloader.d.cts.map +1 -1
- package/dist/unloader.d.mts +2 -7
- package/dist/unloader.d.mts.map +1 -1
- package/dist/unloader.mjs +4 -11
- package/dist/unloader.mjs.map +1 -1
- package/dist/unplugin.cjs +11 -14
- package/dist/unplugin.d.cts +5 -6
- package/dist/unplugin.d.cts.map +1 -1
- package/dist/unplugin.d.mts +3 -6
- package/dist/unplugin.d.mts.map +1 -1
- package/dist/unplugin.mjs +6 -10
- package/dist/utils.cjs +38 -22
- package/dist/utils.d.cts +3 -2
- package/dist/utils.d.mts +3 -3
- package/dist/utils.mjs +19 -3
- package/dist/utils.mjs.map +1 -0
- package/dist/{virtual-B1MLgqnQ.cjs → virtual-Cbvj12lU.cjs} +33 -33
- package/dist/{virtual-B9imjOqe.mjs → virtual-DvkJm7gK.mjs} +7 -7
- package/dist/virtual-DvkJm7gK.mjs.map +1 -0
- package/dist/vite.cjs +84 -19
- package/dist/vite.d.cts +5 -16
- package/dist/vite.d.cts.map +1 -1
- package/dist/vite.d.mts +5 -19
- package/dist/vite.d.mts.map +1 -1
- package/dist/vite.mjs +67 -14
- package/dist/vite.mjs.map +1 -0
- package/dist/webpack.cjs +42 -16
- package/dist/webpack.d.cts +5 -29
- package/dist/webpack.d.cts.map +1 -1
- package/dist/webpack.d.mts +5 -32
- package/dist/webpack.d.mts.map +1 -1
- package/dist/webpack.mjs +26 -11
- package/dist/webpack.mjs.map +1 -0
- package/package.json +15 -15
- package/dist/api-CY668wMZ.mjs.map +0 -1
- package/dist/commands-7TWNqTU1.d.cts +0 -12
- package/dist/commands-7TWNqTU1.d.cts.map +0 -1
- package/dist/commands-yacLkOi0.d.mts +0 -12
- package/dist/commands-yacLkOi0.d.mts.map +0 -1
- package/dist/config-CK756s0L.d.mts +0 -2232
- package/dist/config-CK756s0L.d.mts.map +0 -1
- package/dist/config-CiPXgwzt.d.mts +0 -39
- package/dist/config-CiPXgwzt.d.mts.map +0 -1
- package/dist/config-D4Fh2gQL.mjs +0 -87
- package/dist/config-D4Fh2gQL.mjs.map +0 -1
- package/dist/config-D86Vw7SC.cjs +0 -105
- package/dist/config-J74ORCFY.d.cts +0 -39
- package/dist/config-J74ORCFY.d.cts.map +0 -1
- package/dist/config-vnrrSxEB.d.cts +0 -2232
- package/dist/config-vnrrSxEB.d.cts.map +0 -1
- package/dist/constants-CZh5rsgh.cjs +0 -103
- package/dist/constants-cXxSHhNp.mjs +0 -32
- package/dist/constants-cXxSHhNp.mjs.map +0 -1
- package/dist/constants.d.cts.map +0 -1
- package/dist/constants.d.mts.map +0 -1
- package/dist/esbuild-B3NuCco0.cjs +0 -100
- package/dist/esbuild-DWiE0pYc.mjs +0 -82
- package/dist/esbuild-DWiE0pYc.mjs.map +0 -1
- package/dist/index-2JXW-b2-.d.mts +0 -82
- package/dist/index-2JXW-b2-.d.mts.map +0 -1
- package/dist/index-6BLROVtJ.d.mts +0 -261
- package/dist/index-6BLROVtJ.d.mts.map +0 -1
- package/dist/index-C7W0kmm7.d.mts +0 -171
- package/dist/index-C7W0kmm7.d.mts.map +0 -1
- package/dist/index-DJ-k0GOX.d.cts +0 -261
- package/dist/index-DJ-k0GOX.d.cts.map +0 -1
- package/dist/paths-CS8ecCnW.mjs +0 -81
- package/dist/paths-CS8ecCnW.mjs.map +0 -1
- package/dist/paths-YmyIGEVo.cjs +0 -98
- package/dist/plugin-B9TQt-p0.d.cts +0 -82
- package/dist/plugin-B9TQt-p0.d.cts.map +0 -1
- package/dist/plugin-BE3wmhoU.d.cts +0 -26
- package/dist/plugin-BE3wmhoU.d.cts.map +0 -1
- package/dist/plugin-CZ_PJPpQ.cjs +0 -96
- package/dist/plugin-C_8RhG5V.d.mts +0 -26
- package/dist/plugin-C_8RhG5V.d.mts.map +0 -1
- package/dist/plugin-E5foRD0k.mjs +0 -61
- package/dist/plugin-E5foRD0k.mjs.map +0 -1
- package/dist/plugin-utils-C3HnZJl1.mjs +0 -387
- package/dist/plugin-utils-C3HnZJl1.mjs.map +0 -1
- package/dist/plugin-utils-Ck3cx3w6.cjs +0 -531
- package/dist/plugin-utils.d.cts.map +0 -1
- package/dist/plugin-utils.d.mts.map +0 -1
- package/dist/resolve-options-6sXFqzEA.mjs +0 -116
- package/dist/resolve-options-6sXFqzEA.mjs.map +0 -1
- package/dist/resolve-options-BQnTgg3V.cjs +0 -105
- package/dist/resolve-options-D-RGs8j8.mjs +0 -117
- package/dist/resolve-options-D-RGs8j8.mjs.map +0 -1
- package/dist/resolve-options-DHL3RM8F.mjs +0 -87
- package/dist/resolve-options-DHL3RM8F.mjs.map +0 -1
- package/dist/resolve-options-lxQ2pm0W.cjs +0 -127
- package/dist/resolve-options-vyFhhkLp.cjs +0 -133
- package/dist/rolldown-CQI8ps6f.cjs +0 -83
- package/dist/rolldown-DsXEFXyP.mjs +0 -65
- package/dist/rolldown-DsXEFXyP.mjs.map +0 -1
- package/dist/tsconfig-B92heKit.mjs.map +0 -1
- package/dist/types-Bh_vLuQ0.d.mts +0 -1
- package/dist/utils-BbDma_5Y.cjs +0 -449
- package/dist/utils-DoQcX7Sk.mjs +0 -339
- package/dist/utils-DoQcX7Sk.mjs.map +0 -1
- package/dist/virtual-B9imjOqe.mjs.map +0 -1
- package/dist/vite-Bx1gbbj3.mjs +0 -171
- package/dist/vite-Bx1gbbj3.mjs.map +0 -1
- package/dist/vite-XV170zx6.cjs +0 -189
- package/dist/webpack-9G4xJBfz.cjs +0 -107
- package/dist/webpack-BkTkELre.mjs +0 -88
- package/dist/webpack-BkTkELre.mjs.map +0 -1
- package/dist/write-file-CpNWY8SV.d.cts +0 -171
- package/dist/write-file-CpNWY8SV.d.cts.map +0 -1
package/dist/utils-DoQcX7Sk.mjs
DELETED
|
@@ -1,339 +0,0 @@
|
|
|
1
|
-
import { t as replacePathTokens } from "./paths-CS8ecCnW.mjs";
|
|
2
|
-
import { toArray } from "@stryke/convert/to-array";
|
|
3
|
-
import { appendPath } from "@stryke/path/append";
|
|
4
|
-
import { joinPaths } from "@stryke/path/join-paths";
|
|
5
|
-
import { replaceExtension, replacePath } from "@stryke/path/replace";
|
|
6
|
-
import { isObject } from "@stryke/type-checks/is-object";
|
|
7
|
-
import { isSetObject } from "@stryke/type-checks/is-set-object";
|
|
8
|
-
import { isSetString } from "@stryke/type-checks/is-set-string";
|
|
9
|
-
import { isString } from "@stryke/type-checks/is-string";
|
|
10
|
-
import chalk from "chalk";
|
|
11
|
-
import { getUniqueBy } from "@stryke/helpers/get-unique";
|
|
12
|
-
import { format, resolveConfig } from "prettier";
|
|
13
|
-
import { kebabCase } from "@stryke/string-format/kebab-case";
|
|
14
|
-
import { titleCase } from "@stryke/string-format/title-case";
|
|
15
|
-
import { LogLevelLabel } from "@storm-software/config-tools/types";
|
|
16
|
-
import { murmurhash } from "@stryke/hash";
|
|
17
|
-
import { isAbsolutePath } from "@stryke/path/is-type";
|
|
18
|
-
import { readFileIfExistingSync } from "@stryke/fs/read-file";
|
|
19
|
-
import { writeFile } from "@stryke/fs/write-file";
|
|
20
|
-
import { parseTypeDefinition } from "@stryke/convert/parse-type-definition";
|
|
21
|
-
import { getLogFn, getLogLevel } from "@storm-software/config-tools/logger";
|
|
22
|
-
import { getColor } from "@storm-software/config-tools/utilities/colors";
|
|
23
|
-
import { noop } from "@stryke/helpers/noop";
|
|
24
|
-
import MagicString from "magic-string";
|
|
25
|
-
import Diff from "diff-match-patch";
|
|
26
|
-
|
|
27
|
-
//#region ../core/src/lib/entry.ts
|
|
28
|
-
function resolveEntryOutput(context, typeDefinition) {
|
|
29
|
-
return replaceExtension(replacePath(replacePath(replacePath(replacePath(replacePath(typeDefinition.file, joinPaths(context.workspaceConfig.workspaceRoot, context.config.root, "src")), joinPaths(context.workspaceConfig.workspaceRoot, context.config.root)), joinPaths(context.config.root, "src")), context.config.root), "src"));
|
|
30
|
-
}
|
|
31
|
-
function resolveInput(context, typeDefinition, input, output) {
|
|
32
|
-
return {
|
|
33
|
-
...typeDefinition,
|
|
34
|
-
input: isSetString(input) ? { file: String(input) } : typeDefinition,
|
|
35
|
-
output: output || resolveEntryOutput(context, typeDefinition)
|
|
36
|
-
};
|
|
37
|
-
}
|
|
38
|
-
/**
|
|
39
|
-
* Resolves multiple type definitions into their corresponding resolved entry type definitions.
|
|
40
|
-
*
|
|
41
|
-
* @param context - The current context
|
|
42
|
-
* @param typeDefinitions - The type definitions to resolve.
|
|
43
|
-
* @returns A promise that resolves to an array of resolved entry type definitions.
|
|
44
|
-
*/
|
|
45
|
-
async function resolveInputs(context, typeDefinitions) {
|
|
46
|
-
return (await Promise.all((isObject(typeDefinitions) && !isTypeDefinition(typeDefinitions) ? Object.values(typeDefinitions).flat() : toArray(typeDefinitions)).map(async (entry) => {
|
|
47
|
-
if (isResolvedEntryTypeDefinition(entry)) return {
|
|
48
|
-
...entry,
|
|
49
|
-
output: entry.output ? replacePathTokens(context, entry.output) : void 0,
|
|
50
|
-
file: replacePathTokens(context, entry.file)
|
|
51
|
-
};
|
|
52
|
-
let typeDefinition;
|
|
53
|
-
if (isString(entry)) typeDefinition = parseTypeDefinition(replacePathTokens(context, entry));
|
|
54
|
-
else {
|
|
55
|
-
typeDefinition = entry;
|
|
56
|
-
typeDefinition.file = replacePathTokens(context, typeDefinition.file);
|
|
57
|
-
}
|
|
58
|
-
const filePath = isAbsolutePath(typeDefinition.file) ? typeDefinition.file : appendPath(typeDefinition.file, context.config.root);
|
|
59
|
-
if (await context.fs.isFile(filePath)) return resolveInput(context, {
|
|
60
|
-
file: replacePath(filePath, context.config.root),
|
|
61
|
-
name: typeDefinition.name
|
|
62
|
-
}, entry.input, entry.output);
|
|
63
|
-
return (await context.fs.glob(appendPath(filePath, context.workspaceConfig.workspaceRoot))).map((file) => resolveInput(context, {
|
|
64
|
-
file: replacePath(file, context.config.root),
|
|
65
|
-
name: typeDefinition.name
|
|
66
|
-
}, entry.input, entry.output));
|
|
67
|
-
}).flat().filter(Boolean))).flat();
|
|
68
|
-
}
|
|
69
|
-
/**
|
|
70
|
-
* Resolves multiple type definitions into their corresponding resolved entry type definitions.
|
|
71
|
-
*
|
|
72
|
-
* @param context - The current context
|
|
73
|
-
* @param typeDefinitions - The type definitions to resolve.
|
|
74
|
-
* @returns A promise that resolves to an array of resolved entry type definitions.
|
|
75
|
-
*/
|
|
76
|
-
function resolveInputsSync(context, typeDefinitions) {
|
|
77
|
-
return (isObject(typeDefinitions) && !isTypeDefinition(typeDefinitions) ? Object.values(typeDefinitions).flat() : toArray(typeDefinitions)).map((entry) => {
|
|
78
|
-
if (isResolvedEntryTypeDefinition(entry)) return {
|
|
79
|
-
...entry,
|
|
80
|
-
output: entry.output ? replacePathTokens(context, entry.output) : void 0,
|
|
81
|
-
file: replacePathTokens(context, entry.file)
|
|
82
|
-
};
|
|
83
|
-
let typeDefinition;
|
|
84
|
-
if (isString(entry)) typeDefinition = parseTypeDefinition(replacePathTokens(context, entry));
|
|
85
|
-
else {
|
|
86
|
-
typeDefinition = entry;
|
|
87
|
-
typeDefinition.file = replacePathTokens(context, typeDefinition.file);
|
|
88
|
-
}
|
|
89
|
-
const filePath = isAbsolutePath(typeDefinition.file) ? typeDefinition.file : appendPath(typeDefinition.file, context.config.root);
|
|
90
|
-
if (context.fs.isFileSync(filePath)) return resolveInput(context, {
|
|
91
|
-
file: appendPath(filePath, context.workspaceConfig.workspaceRoot),
|
|
92
|
-
name: typeDefinition.name
|
|
93
|
-
});
|
|
94
|
-
return context.fs.globSync(appendPath(filePath, context.workspaceConfig.workspaceRoot)).map((file) => resolveInput(context, {
|
|
95
|
-
file,
|
|
96
|
-
name: typeDefinition.name
|
|
97
|
-
}));
|
|
98
|
-
}).flat().filter(Boolean);
|
|
99
|
-
}
|
|
100
|
-
/**
|
|
101
|
-
* Checks if the provided entry is a type definition.
|
|
102
|
-
*
|
|
103
|
-
* @param entry - The entry to check.
|
|
104
|
-
* @returns True if the entry is a type definition, false otherwise.
|
|
105
|
-
*/
|
|
106
|
-
function isTypeDefinition(entry) {
|
|
107
|
-
return !isString(entry) && entry.file !== void 0;
|
|
108
|
-
}
|
|
109
|
-
/**
|
|
110
|
-
* Checks if the provided entry is a resolved entry type definition.
|
|
111
|
-
*
|
|
112
|
-
* @param entry - The entry to check.
|
|
113
|
-
* @returns True if the entry is a resolved entry type definition, false otherwise.
|
|
114
|
-
*/
|
|
115
|
-
function isResolvedEntryTypeDefinition(entry) {
|
|
116
|
-
return isTypeDefinition(entry) && entry.output !== void 0;
|
|
117
|
-
}
|
|
118
|
-
/**
|
|
119
|
-
* Get unique inputs from the provided list.
|
|
120
|
-
*
|
|
121
|
-
* @param inputs - The entry points to process.
|
|
122
|
-
* @returns An array of unique inputs (by file path or content hash).
|
|
123
|
-
*/
|
|
124
|
-
function getUniqueInputs(inputs = []) {
|
|
125
|
-
return isObject(inputs) ? inputs : getUniqueBy(toArray(inputs), (item) => isSetString(item) ? item : murmurhash(item ?? {}, { maxLength: 24 }));
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
//#endregion
|
|
129
|
-
//#region ../core/src/lib/logger.ts
|
|
130
|
-
/**
|
|
131
|
-
* Create a logging function with a specific name and options.
|
|
132
|
-
*
|
|
133
|
-
* @param name - The name of the logging function.
|
|
134
|
-
* @param options - The options to configure the logging function.
|
|
135
|
-
* @returns A logging function.
|
|
136
|
-
*/
|
|
137
|
-
const createLog = (name, options = {}) => {
|
|
138
|
-
const logLevel = options.logLevel === null ? LogLevelLabel.SILENT : options.logLevel || LogLevelLabel.INFO;
|
|
139
|
-
if (logLevel === LogLevelLabel.SILENT) return noop;
|
|
140
|
-
if (options.customLogger) return options.customLogger;
|
|
141
|
-
return (type, ...args) => getLogFn(getLogLevel(type), {
|
|
142
|
-
...options,
|
|
143
|
-
logLevel
|
|
144
|
-
})(`${chalk.bold.hex(getColor("brand", options))(`${name ? kebabCase(name) : ""}${options.name ? `${name ? chalk.gray(" > ") : ""}${kebabCase(options.name)}` : ""}${chalk.gray(" > ")}`)}${args.join(" ")} `.trim());
|
|
145
|
-
};
|
|
146
|
-
const BADGE_COLORS = [
|
|
147
|
-
"#00A0DD",
|
|
148
|
-
"#6FCE4E",
|
|
149
|
-
"#FBBF24",
|
|
150
|
-
"#F43F5E",
|
|
151
|
-
"#3B82F6",
|
|
152
|
-
"#A855F7",
|
|
153
|
-
"#469592",
|
|
154
|
-
"#288EDF",
|
|
155
|
-
"#D8B4FE",
|
|
156
|
-
"#10B981",
|
|
157
|
-
"#EF4444",
|
|
158
|
-
"#F0EC56",
|
|
159
|
-
"#F472B6",
|
|
160
|
-
"#22D3EE",
|
|
161
|
-
"#EAB308",
|
|
162
|
-
"#84CC16",
|
|
163
|
-
"#F87171",
|
|
164
|
-
"#0EA5E9",
|
|
165
|
-
"#D946EF",
|
|
166
|
-
"#FACC15",
|
|
167
|
-
"#34D399",
|
|
168
|
-
"#8B5CF6"
|
|
169
|
-
];
|
|
170
|
-
const extendLog = (logFn, name) => {
|
|
171
|
-
return (type, ...args) => logFn(type, ` ${chalk.inverse.hex(BADGE_COLORS[name.split("").map((char) => char.charCodeAt(0)).reduce((ret, charCode) => ret + charCode, 0) % BADGE_COLORS.length] || BADGE_COLORS[0])(` ${titleCase(name)} `)} ${args.join(" ")} `);
|
|
172
|
-
};
|
|
173
|
-
|
|
174
|
-
//#endregion
|
|
175
|
-
//#region ../core/src/lib/utilities/file-header.ts
|
|
176
|
-
/**
|
|
177
|
-
* Generates a file header comment with a warning about automatic overwriting.
|
|
178
|
-
*
|
|
179
|
-
* @param overwrite - Whether the file will be automatically overwritten. If `false`, the warning will indicate that the file will not be overwritten. If `true` or omitted, the warning will indicate that the file will be overwritten.
|
|
180
|
-
* @param framework - The name of the framework to include in the warning message. Defaults to "powerlines".
|
|
181
|
-
* @returns A string containing the file header warning message.
|
|
182
|
-
*/
|
|
183
|
-
function getFileHeaderWarningText(overwrite = true, framework = "powerlines") {
|
|
184
|
-
return overwrite !== false ? `Do not edit this file manually - it will be overwritten automatically. Automatic overwrites can be disabled by using the \`output.overwrite\` option.` : `This file was generated on ${(/* @__PURE__ */ new Date()).toLocaleString()} - it will not be overwritten by ${titleCase(framework)} while the \`output.overwrite\` option is set to \`true\`.`;
|
|
185
|
-
}
|
|
186
|
-
/**
|
|
187
|
-
* Generates a file header warning message based on the provided context.
|
|
188
|
-
*
|
|
189
|
-
* @param context - The Powerlines context.
|
|
190
|
-
* @returns A string containing the file header warning message.
|
|
191
|
-
*/
|
|
192
|
-
function getFileHeaderWarning(context) {
|
|
193
|
-
return getFileHeaderWarningText(context.config.output?.overwrite, context.config.framework);
|
|
194
|
-
}
|
|
195
|
-
/**
|
|
196
|
-
* Generates a file header comment for a generated source file, including a warning about automatic overwriting.
|
|
197
|
-
*
|
|
198
|
-
* @param context - The Powerlines context.
|
|
199
|
-
* @param comment - The comment syntax to use for the header (e.g., `//` for JavaScript/TypeScript, `#` for Python). Defaults to `//`.
|
|
200
|
-
* @returns A string containing the file header comment.
|
|
201
|
-
*/
|
|
202
|
-
function getFileHeader(context, comment = "//") {
|
|
203
|
-
return `
|
|
204
|
-
${comment} Generated by ${titleCase(context.config.framework) || "Powerlines"}
|
|
205
|
-
${comment} ${getFileHeaderWarning(context)}
|
|
206
|
-
`;
|
|
207
|
-
}
|
|
208
|
-
/**
|
|
209
|
-
* Generates a file header comment for a generated TypeScript source file, including a warning about automatic overwriting.
|
|
210
|
-
*
|
|
211
|
-
* @param context - The Powerlines context.
|
|
212
|
-
* @param options - Additional options for generating the file header, such as a directive to include and whether to add a Prettier ignore comment.
|
|
213
|
-
* @returns A string containing the file header comment for a TypeScript file.
|
|
214
|
-
*/
|
|
215
|
-
function getTypescriptFileHeader(context, options = {}) {
|
|
216
|
-
const { directive = null, prettierIgnore = false } = options;
|
|
217
|
-
return `/* eslint-disable */
|
|
218
|
-
// biome-ignore lint: disable
|
|
219
|
-
${prettierIgnore ? `// prettier-ignore` : ""}${directive ? `\n\n${directive}\n` : "\n"}
|
|
220
|
-
${getFileHeader(context)}
|
|
221
|
-
|
|
222
|
-
`;
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
//#endregion
|
|
226
|
-
//#region ../core/src/lib/utilities/source-file.ts
|
|
227
|
-
/**
|
|
228
|
-
* Get the string from the source.
|
|
229
|
-
*
|
|
230
|
-
* @param code - The source string or magic string.
|
|
231
|
-
* @returns The source string.
|
|
232
|
-
*/
|
|
233
|
-
function getString(code) {
|
|
234
|
-
if (!code) return "";
|
|
235
|
-
if (isString(code)) return code;
|
|
236
|
-
if (isSetObject(code) && "code" in code) return code.code;
|
|
237
|
-
return code.toString();
|
|
238
|
-
}
|
|
239
|
-
/**
|
|
240
|
-
* Get the magic string.
|
|
241
|
-
*
|
|
242
|
-
* @param code - The source string or magic string.
|
|
243
|
-
* @returns The magic string.
|
|
244
|
-
*/
|
|
245
|
-
function getMagicString(code) {
|
|
246
|
-
if (isString(code)) return new MagicString(code);
|
|
247
|
-
return code;
|
|
248
|
-
}
|
|
249
|
-
/**
|
|
250
|
-
* Get the source file.
|
|
251
|
-
*
|
|
252
|
-
* @param code - The source code.
|
|
253
|
-
* @param id - The name of the file.
|
|
254
|
-
* @returns The source file.
|
|
255
|
-
*/
|
|
256
|
-
function getSourceFile(code, id) {
|
|
257
|
-
return {
|
|
258
|
-
id,
|
|
259
|
-
code: getMagicString(code ?? readFileIfExistingSync(id)),
|
|
260
|
-
env: []
|
|
261
|
-
};
|
|
262
|
-
}
|
|
263
|
-
|
|
264
|
-
//#endregion
|
|
265
|
-
//#region ../core/src/lib/utilities/source-map.ts
|
|
266
|
-
const dmp = new Diff();
|
|
267
|
-
/**
|
|
268
|
-
* Generate code with source map.
|
|
269
|
-
*
|
|
270
|
-
* @param code - The source code.
|
|
271
|
-
* @param id - The file name.
|
|
272
|
-
* @param transpiled - The transpiled code.
|
|
273
|
-
* @returns The compiler result.
|
|
274
|
-
*/
|
|
275
|
-
function generateSourceMap(code, id, transpiled) {
|
|
276
|
-
if (!transpiled) return;
|
|
277
|
-
const diff = dmp.diff_main(code.toString(), transpiled);
|
|
278
|
-
dmp.diff_cleanupSemantic(diff);
|
|
279
|
-
let offset = 0;
|
|
280
|
-
for (let index = 0; index < diff.length; index++) if (diff[index]) {
|
|
281
|
-
const [type, text] = diff[index];
|
|
282
|
-
const textLength = text.length;
|
|
283
|
-
switch (type) {
|
|
284
|
-
case 0:
|
|
285
|
-
offset += textLength;
|
|
286
|
-
break;
|
|
287
|
-
case 1:
|
|
288
|
-
code.prependLeft(offset, text);
|
|
289
|
-
break;
|
|
290
|
-
case -1: {
|
|
291
|
-
const next = diff.at(index + 1);
|
|
292
|
-
if (next && next[0] === 1) {
|
|
293
|
-
const replaceText = next[1];
|
|
294
|
-
const firstNonWhitespaceIndexOfText = text.search(/\S/);
|
|
295
|
-
const offsetStart = offset + Math.max(firstNonWhitespaceIndexOfText, 0);
|
|
296
|
-
code.update(offsetStart, offset + textLength, replaceText);
|
|
297
|
-
index += 1;
|
|
298
|
-
} else code.remove(offset, offset + textLength);
|
|
299
|
-
offset += textLength;
|
|
300
|
-
break;
|
|
301
|
-
}
|
|
302
|
-
}
|
|
303
|
-
}
|
|
304
|
-
if (!code.hasChanged()) return;
|
|
305
|
-
return {
|
|
306
|
-
code: code.toString(),
|
|
307
|
-
map: code.generateMap({
|
|
308
|
-
source: id,
|
|
309
|
-
file: `${id}.map`,
|
|
310
|
-
includeContent: true
|
|
311
|
-
})
|
|
312
|
-
};
|
|
313
|
-
}
|
|
314
|
-
|
|
315
|
-
//#endregion
|
|
316
|
-
//#region ../core/src/lib/utilities/write-file.ts
|
|
317
|
-
/**
|
|
318
|
-
* Writes and formats a file to the file system
|
|
319
|
-
*
|
|
320
|
-
* @param log - The logging function to use for logging errors
|
|
321
|
-
* @param filepath - The file path to write the file
|
|
322
|
-
* @param content - The content to write to the file
|
|
323
|
-
* @param skipFormat - Should the plugin skip formatting the `content` string with Prettier
|
|
324
|
-
*/
|
|
325
|
-
async function writeFile$1(log, filepath, content, skipFormat = false) {
|
|
326
|
-
try {
|
|
327
|
-
if (skipFormat) await writeFile(filepath, content);
|
|
328
|
-
else await writeFile(filepath, await format(content, {
|
|
329
|
-
...await resolveConfig(filepath) ?? {},
|
|
330
|
-
filepath
|
|
331
|
-
}) || "");
|
|
332
|
-
} catch (error) {
|
|
333
|
-
log(LogLevelLabel.ERROR, `Failed to write file ${filepath} to disk \n${error?.message ? error.message : ""}`);
|
|
334
|
-
}
|
|
335
|
-
}
|
|
336
|
-
|
|
337
|
-
//#endregion
|
|
338
|
-
export { resolveInputs as _, getString as a, getFileHeaderWarningText as c, extendLog as d, getUniqueInputs as f, resolveInput as g, resolveEntryOutput as h, getSourceFile as i, getTypescriptFileHeader as l, isTypeDefinition as m, generateSourceMap as n, getFileHeader as o, isResolvedEntryTypeDefinition as p, getMagicString as r, getFileHeaderWarning as s, writeFile$1 as t, createLog as u, resolveInputsSync as v };
|
|
339
|
-
//# sourceMappingURL=utils-DoQcX7Sk.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"utils-DoQcX7Sk.mjs","names":["typeDefinition: TypeDefinition","writeFile","writeFileBase"],"sources":["../../core/src/lib/entry.ts","../../core/src/lib/logger.ts","../../core/src/lib/utilities/file-header.ts","../../core/src/lib/utilities/source-file.ts","../../core/src/lib/utilities/source-map.ts","../../core/src/lib/utilities/write-file.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\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/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { parseTypeDefinition } from \"@stryke/convert/parse-type-definition\";\nimport { toArray } from \"@stryke/convert/to-array\";\nimport { murmurhash } from \"@stryke/hash\";\nimport { getUniqueBy } from \"@stryke/helpers/get-unique\";\nimport { appendPath } from \"@stryke/path/append\";\nimport { isAbsolutePath } from \"@stryke/path/is-type\";\nimport { joinPaths } from \"@stryke/path/join-paths\";\nimport { replaceExtension, replacePath } from \"@stryke/path/replace\";\nimport { isObject } from \"@stryke/type-checks/is-object\";\nimport { isSetString } from \"@stryke/type-checks/is-set-string\";\nimport { isString } from \"@stryke/type-checks/is-string\";\nimport type {\n TypeDefinition,\n TypeDefinitionParameter\n} from \"@stryke/types/configuration\";\nimport { replacePathTokens } from \"../plugin-utils/paths\";\nimport { Config } from \"../types\";\nimport { ResolvedEntryTypeDefinition } from \"../types/config\";\nimport type { Context } from \"../types/context\";\n\nexport function resolveEntryOutput(\n context: Context,\n typeDefinition: TypeDefinition\n): string {\n return replaceExtension(\n replacePath(\n replacePath(\n replacePath(\n replacePath(\n replacePath(\n typeDefinition.file,\n joinPaths(\n context.workspaceConfig.workspaceRoot,\n context.config.root,\n \"src\"\n )\n ),\n joinPaths(\n context.workspaceConfig.workspaceRoot,\n context.config.root\n )\n ),\n joinPaths(context.config.root, \"src\")\n ),\n context.config.root\n ),\n \"src\"\n )\n );\n}\n\nexport function resolveInput(\n context: Context,\n typeDefinition: TypeDefinition,\n input?: TypeDefinitionParameter,\n output?: string\n): ResolvedEntryTypeDefinition {\n return {\n ...typeDefinition,\n input: isSetString(input) ? { file: String(input) } : typeDefinition,\n output: output || resolveEntryOutput(context, typeDefinition)\n };\n}\n\n/**\n * Resolves multiple type definitions into their corresponding resolved entry type definitions.\n *\n * @param context - The current context\n * @param typeDefinitions - The type definitions to resolve.\n * @returns A promise that resolves to an array of resolved entry type definitions.\n */\nexport async function resolveInputs(\n context: Context,\n typeDefinitions:\n | TypeDefinitionParameter\n | TypeDefinitionParameter[]\n | Record<string, TypeDefinitionParameter | TypeDefinitionParameter[]>\n): Promise<ResolvedEntryTypeDefinition[]> {\n return (\n await Promise.all(\n (isObject(typeDefinitions) && !isTypeDefinition(typeDefinitions)\n ? Object.values(typeDefinitions).flat()\n : toArray(typeDefinitions)\n )\n .map(async entry => {\n if (isResolvedEntryTypeDefinition(entry)) {\n return {\n ...entry,\n output: entry.output\n ? replacePathTokens(context, entry.output)\n : undefined,\n file: replacePathTokens(context, entry.file)\n };\n }\n\n let typeDefinition: TypeDefinition;\n if (isString(entry)) {\n typeDefinition = parseTypeDefinition(\n replacePathTokens(context, entry)\n )!;\n } else {\n typeDefinition = entry;\n typeDefinition.file = replacePathTokens(\n context,\n typeDefinition.file\n );\n }\n\n const filePath = isAbsolutePath(typeDefinition.file)\n ? typeDefinition.file\n : appendPath(typeDefinition.file, context.config.root);\n if (await context.fs.isFile(filePath)) {\n return resolveInput(\n context,\n {\n file: replacePath(filePath, context.config.root),\n name: typeDefinition.name\n },\n (entry as ResolvedEntryTypeDefinition).input,\n (entry as ResolvedEntryTypeDefinition).output\n );\n }\n\n return (\n await context.fs.glob(\n appendPath(filePath, context.workspaceConfig.workspaceRoot)\n )\n ).map(file =>\n resolveInput(\n context,\n {\n file: replacePath(file, context.config.root),\n name: typeDefinition.name\n },\n (entry as ResolvedEntryTypeDefinition).input,\n (entry as ResolvedEntryTypeDefinition).output\n )\n );\n })\n .flat()\n .filter(Boolean)\n )\n ).flat();\n}\n\n/**\n * Resolves multiple type definitions into their corresponding resolved entry type definitions.\n *\n * @param context - The current context\n * @param typeDefinitions - The type definitions to resolve.\n * @returns A promise that resolves to an array of resolved entry type definitions.\n */\nexport function resolveInputsSync(\n context: Context,\n typeDefinitions:\n | TypeDefinitionParameter\n | TypeDefinitionParameter[]\n | Record<string, TypeDefinitionParameter | TypeDefinitionParameter[]>\n): ResolvedEntryTypeDefinition[] {\n return (\n isObject(typeDefinitions) && !isTypeDefinition(typeDefinitions)\n ? Object.values(typeDefinitions).flat()\n : toArray(typeDefinitions)\n )\n .map(entry => {\n if (isResolvedEntryTypeDefinition(entry)) {\n return {\n ...entry,\n output: entry.output\n ? replacePathTokens(context, entry.output)\n : undefined,\n file: replacePathTokens(context, entry.file)\n };\n }\n\n let typeDefinition: TypeDefinition;\n if (isString(entry)) {\n typeDefinition = parseTypeDefinition(\n replacePathTokens(context, entry)\n )!;\n } else {\n typeDefinition = entry;\n typeDefinition.file = replacePathTokens(context, typeDefinition.file);\n }\n\n const filePath = isAbsolutePath(typeDefinition.file)\n ? typeDefinition.file\n : appendPath(typeDefinition.file, context.config.root);\n if (context.fs.isFileSync(filePath)) {\n return resolveInput(context, {\n file: appendPath(filePath, context.workspaceConfig.workspaceRoot),\n name: typeDefinition.name\n });\n }\n\n return context.fs\n .globSync(appendPath(filePath, context.workspaceConfig.workspaceRoot))\n .map(file =>\n resolveInput(context, {\n file,\n name: typeDefinition.name\n })\n );\n })\n .flat()\n .filter(Boolean);\n}\n\n/**\n * Checks if the provided entry is a type definition.\n *\n * @param entry - The entry to check.\n * @returns True if the entry is a type definition, false otherwise.\n */\nexport function isTypeDefinition(entry: any): entry is TypeDefinition {\n return !isString(entry) && entry.file !== undefined;\n}\n\n/**\n * Checks if the provided entry is a resolved entry type definition.\n *\n * @param entry - The entry to check.\n * @returns True if the entry is a resolved entry type definition, false otherwise.\n */\nexport function isResolvedEntryTypeDefinition(\n entry: TypeDefinitionParameter | ResolvedEntryTypeDefinition\n): entry is ResolvedEntryTypeDefinition {\n return (\n isTypeDefinition(entry) &&\n (entry as ResolvedEntryTypeDefinition).output !== undefined\n );\n}\n\n/**\n * Get unique inputs from the provided list.\n *\n * @param inputs - The entry points to process.\n * @returns An array of unique inputs (by file path or content hash).\n */\nexport function getUniqueInputs(inputs: Config[\"input\"] = []): Config[\"input\"] {\n return isObject(inputs)\n ? inputs\n : getUniqueBy(toArray(inputs), (item: TypeDefinitionParameter) =>\n isSetString(item) ? item : murmurhash(item ?? {}, { maxLength: 24 })\n );\n}\n","/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\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/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { getLogFn, getLogLevel } from \"@storm-software/config-tools/logger\";\nimport { LogLevelLabel } from \"@storm-software/config-tools/types\";\nimport { getColor } from \"@storm-software/config-tools/utilities/colors\";\nimport { noop } from \"@stryke/helpers/noop\";\nimport { kebabCase } from \"@stryke/string-format/kebab-case\";\nimport { titleCase } from \"@stryke/string-format/title-case\";\nimport chalk from \"chalk\";\nimport type { LogFn, WorkspaceConfig } from \"../types\";\n\nexport interface CreateLogOptions {\n name?: string;\n logLevel?: LogLevelLabel | null;\n customLogger?: LogFn;\n colors?: WorkspaceConfig[\"colors\"];\n}\n\n/**\n * Create a logging function with a specific name and options.\n *\n * @param name - The name of the logging function.\n * @param options - The options to configure the logging function.\n * @returns A logging function.\n */\nexport const createLog = (\n name: string | null,\n options: CreateLogOptions = {}\n): LogFn => {\n const logLevel =\n options.logLevel === null\n ? LogLevelLabel.SILENT\n : options.logLevel || LogLevelLabel.INFO;\n if (logLevel === LogLevelLabel.SILENT) {\n return noop;\n }\n\n if (options.customLogger) {\n return options.customLogger;\n }\n\n return (type: LogLevelLabel, ...args: string[]) =>\n getLogFn(getLogLevel(type), {\n ...options,\n logLevel\n })(\n `${chalk.bold.hex(\n getColor(\"brand\", options as Parameters<typeof getColor>[1])\n )(\n `${name ? kebabCase(name) : \"\"}${options.name ? `${name ? chalk.gray(\" > \") : \"\"}${kebabCase(options.name)}` : \"\"}${chalk.gray(\" > \")}`\n )}${args.join(\" \")} `.trim()\n );\n};\n\nconst BADGE_COLORS = [\n \"#00A0DD\",\n \"#6FCE4E\",\n \"#FBBF24\",\n \"#F43F5E\",\n \"#3B82F6\",\n \"#A855F7\",\n \"#469592\",\n \"#288EDF\",\n \"#D8B4FE\",\n \"#10B981\",\n \"#EF4444\",\n \"#F0EC56\",\n \"#F472B6\",\n \"#22D3EE\",\n \"#EAB308\",\n \"#84CC16\",\n \"#F87171\",\n \"#0EA5E9\",\n \"#D946EF\",\n \"#FACC15\",\n \"#34D399\",\n \"#8B5CF6\"\n] as const;\n\nexport const extendLog = (logFn: LogFn, name: string): LogFn => {\n return (type: LogLevelLabel, ...args: string[]) =>\n logFn(\n type,\n ` ${chalk.inverse.hex(\n BADGE_COLORS[\n name\n .split(\"\")\n .map(char => char.charCodeAt(0))\n .reduce((ret, charCode) => ret + charCode, 0) % BADGE_COLORS.length\n ] || BADGE_COLORS[0]\n )(` ${titleCase(name)} `)} ${args.join(\" \")} `\n );\n};\n","/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\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/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { titleCase } from \"@stryke/string-format/title-case\";\nimport { Context } from \"../../types/context\";\n\nexport interface FileHeaderOptions {\n directive?: string | null;\n prettierIgnore?: boolean;\n}\n\n/**\n * Generates a file header comment with a warning about automatic overwriting.\n *\n * @param overwrite - Whether the file will be automatically overwritten. If `false`, the warning will indicate that the file will not be overwritten. If `true` or omitted, the warning will indicate that the file will be overwritten.\n * @param framework - The name of the framework to include in the warning message. Defaults to \"powerlines\".\n * @returns A string containing the file header warning message.\n */\nexport function getFileHeaderWarningText(\n overwrite = true,\n framework = \"powerlines\"\n): string {\n return overwrite !== false\n ? `Do not edit this file manually - it will be overwritten automatically. Automatic overwrites can be disabled by using the \\`output.overwrite\\` option.`\n : `This file was generated on ${new Date().toLocaleString()} - it will not be overwritten by ${titleCase(framework)} while the \\`output.overwrite\\` option is set to \\`true\\`.`;\n}\n\n/**\n * Generates a file header warning message based on the provided context.\n *\n * @param context - The Powerlines context.\n * @returns A string containing the file header warning message.\n */\nexport function getFileHeaderWarning(context: Context): string {\n return getFileHeaderWarningText(\n context.config.output?.overwrite,\n context.config.framework\n );\n}\n\n/**\n * Generates a file header comment for a generated source file, including a warning about automatic overwriting.\n *\n * @param context - The Powerlines context.\n * @param comment - The comment syntax to use for the header (e.g., `//` for JavaScript/TypeScript, `#` for Python). Defaults to `//`.\n * @returns A string containing the file header comment.\n */\nexport function getFileHeader(context: Context, comment = \"//\"): string {\n return `\n${comment} Generated by ${titleCase(context.config.framework) || \"Powerlines\"}\n${comment} ${getFileHeaderWarning(context)}\n`;\n}\n\n/**\n * Generates a file header comment for a generated TypeScript source file, including a warning about automatic overwriting.\n *\n * @param context - The Powerlines context.\n * @param options - Additional options for generating the file header, such as a directive to include and whether to add a Prettier ignore comment.\n * @returns A string containing the file header comment for a TypeScript file.\n */\nexport function getTypescriptFileHeader(\n context: Context,\n options: FileHeaderOptions = {}\n): string {\n const { directive = null, prettierIgnore = false } = options;\n\n return `/* eslint-disable */\n// biome-ignore lint: disable\n${prettierIgnore ? `// prettier-ignore` : \"\"}${directive ? `\\n\\n${directive}\\n` : \"\\n\"}\n${getFileHeader(context)}\n\n`;\n}\n","/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\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/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { readFileIfExistingSync } from \"@stryke/fs/read-file\";\nimport { isSetObject } from \"@stryke/type-checks/is-set-object\";\nimport { isString } from \"@stryke/type-checks/is-string\";\nimport MagicString from \"magic-string\";\nimport { TransformResult } from \"unplugin\";\nimport { SourceFile } from \"../../types/context\";\n\n/**\n * Get the string from the source.\n *\n * @param code - The source string or magic string.\n * @returns The source string.\n */\nexport function getString(\n code: string | MagicString | TransformResult\n): string {\n if (!code) {\n return \"\";\n }\n\n if (isString(code)) {\n return code;\n }\n\n if (isSetObject(code) && \"code\" in code) {\n return code.code;\n }\n\n return code.toString();\n}\n\n/**\n * Get the magic string.\n *\n * @param code - The source string or magic string.\n * @returns The magic string.\n */\nexport function getMagicString(code: string | MagicString): MagicString {\n if (isString(code)) {\n return new MagicString(code);\n }\n\n return code;\n}\n\n/**\n * Get the source file.\n *\n * @param code - The source code.\n * @param id - The name of the file.\n * @returns The source file.\n */\nexport function getSourceFile(\n code: string | MagicString,\n id: string\n): SourceFile {\n const content = code ?? readFileIfExistingSync(id);\n\n return {\n id,\n code: getMagicString(content),\n env: []\n };\n}\n","/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\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/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport Diff from \"diff-match-patch\";\nimport type MagicString from \"magic-string\";\nimport type { TransformResult } from \"../../types/context\";\n\nconst dmp = new Diff();\n\n/**\n * Generate code with source map.\n *\n * @param code - The source code.\n * @param id - The file name.\n * @param transpiled - The transpiled code.\n * @returns The compiler result.\n */\nexport function generateSourceMap(\n code: MagicString,\n id: string,\n transpiled?: string\n): TransformResult | undefined {\n if (!transpiled) {\n return;\n }\n\n const diff = dmp.diff_main(code.toString(), transpiled);\n dmp.diff_cleanupSemantic(diff);\n\n let offset = 0;\n\n for (let index = 0; index < diff.length; index++) {\n if (diff[index]) {\n const [type, text] = diff[index]!;\n const textLength = text.length;\n\n switch (type) {\n case 0: {\n offset += textLength;\n break;\n }\n case 1: {\n code.prependLeft(offset, text);\n break;\n }\n case -1: {\n const next = diff.at(index + 1);\n\n if (next && next[0] === 1) {\n const replaceText = next[1];\n\n const firstNonWhitespaceIndexOfText = text.search(/\\S/);\n const offsetStart =\n offset + Math.max(firstNonWhitespaceIndexOfText, 0);\n\n code.update(offsetStart, offset + textLength, replaceText);\n index += 1;\n } else {\n code.remove(offset, offset + textLength);\n }\n\n offset += textLength;\n\n break;\n }\n }\n }\n }\n\n if (!code.hasChanged()) {\n return;\n }\n\n return {\n code: code.toString(),\n map: code.generateMap({\n source: id,\n file: `${id}.map`,\n includeContent: true\n })\n };\n}\n","/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\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/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { LogLevelLabel } from \"@storm-software/config-tools/types\";\nimport { writeFile as writeFileBase } from \"@stryke/fs/write-file\";\nimport { format, resolveConfig } from \"prettier\";\nimport type { LogFn } from \"../../types/config\";\n\n/**\n * Writes and formats a file to the file system\n *\n * @param log - The logging function to use for logging errors\n * @param filepath - The file path to write the file\n * @param content - The content to write to the file\n * @param skipFormat - Should the plugin skip formatting the `content` string with Prettier\n */\nexport async function writeFile(\n log: LogFn,\n filepath: string,\n content: string,\n skipFormat = false\n) {\n try {\n if (skipFormat) {\n await writeFileBase(filepath, content);\n } else {\n const config = await resolveConfig(filepath);\n const formatted = await format(content, {\n ...(config ?? {}),\n filepath\n });\n\n await writeFileBase(filepath, formatted || \"\");\n }\n } catch (error) {\n log(\n LogLevelLabel.ERROR,\n `Failed to write file ${filepath} to disk \\n${(error as Error)?.message ? (error as Error).message : \"\"}`\n );\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAsCA,SAAgB,mBACd,SACA,gBACQ;AACR,QAAO,iBACL,YACE,YACE,YACE,YACE,YACE,eAAe,MACf,UACE,QAAQ,gBAAgB,eACxB,QAAQ,OAAO,MACf,MACD,CAC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AAExB,UAAQ,MAAR;GACE,KAAK;AACH,cAAU;AACV;GAEF,KAAK;AACH,SAAK,YAAY,QAAQ,KAAK;AAC9B;GAEF,KAAK,IAAI;IACP,MAAM,OAAO,KAAK,GAAG,QAAQ,EAAE;AAE/B,QAAI,QAAQ,KAAK,OAAO,GAAG;KACzB,MAAM,cAAc,KAAK;KAEzB,MAAM,gCAAgC,KAAK,OAAO,KAAK;KACvD,MAAM,cACJ,SAAS,KAAK,IAAI,+BAA+B,EAAE;AAErD,UAAK,OAAO,aAAa,SAAS,YAAY,YAAY;AAC1D,cAAS;UAET,MAAK,OAAO,QAAQ,SAAS,WAAW;AAG1C,cAAU;AAEV;;;;AAMR,KAAI,CAAC,KAAK,YAAY,CACpB;AAGF,QAAO;EACL,MAAM,KAAK,UAAU;EACrB,KAAK,KAAK,YAAY;GACpB,QAAQ;GACR,MAAM,GAAG,GAAG;GACZ,gBAAgB;GACjB,CAAC;EACH;;;;;;;;;;;;;AChEH,eAAsBC,YACpB,KACA,UACA,SACA,aAAa,OACb;AACA,KAAI;AACF,MAAI,WACF,OAAMC,UAAc,UAAU,QAAQ;MAQtC,OAAMA,UAAc,UALF,MAAM,OAAO,SAAS;GACtC,GAFa,MAAM,cAAc,SAAS,IAE5B,EAAE;GAChB;GACD,CAAC,IAEyC,GAAG;UAEzC,OAAO;AACd,MACE,cAAc,OACd,wBAAwB,SAAS,aAAc,OAAiB,UAAW,MAAgB,UAAU,KACtG"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"virtual-B9imjOqe.mjs","names":["context: Context","#isDisposed","existsSync"],"sources":["../src/storage/base.ts","../src/storage/helpers.ts","../src/storage/file-system.ts","../src/storage/virtual.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\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/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { appendPath } from \"@stryke/path/append\";\nimport { correctPath } from \"@stryke/path/correct-path\";\nimport { joinPaths } from \"@stryke/path/join\";\nimport { MaybePromise } from \"@stryke/types/base\";\nimport { resolve } from \"node:path\";\nimport type { Context, StorageAdapter, StoragePreset } from \"../types\";\n\nexport interface StorageAdapterOptions {\n base: string;\n isReadOnly?: boolean;\n ignore?: string | string[];\n}\n\n/**\n * Abstract base class for storage adapters, providing a template for storage operations.\n */\nexport abstract class BaseStorageAdapter<\n TOptions extends StorageAdapterOptions = StorageAdapterOptions\n> implements StorageAdapter {\n /**\n * Indicates whether the storage adapter has been disposed.\n */\n #isDisposed = false;\n\n /**\n * A name identifying the storage adapter type.\n */\n public abstract name: string;\n\n /**\n * Configuration options for the storage adapter.\n */\n public options: TOptions;\n\n /**\n * The storage preset for the adapter.\n *\n * @remarks\n * This can be used as an alternate way to identify the type of storage being used.\n */\n public readonly preset?: StoragePreset | null = null;\n\n /**\n * Constructor for the BaseStorageAdapter.\n *\n * @param context - The Powerlines context.\n * @param options - Configuration options for the storage adapter.\n */\n public constructor(\n protected context: Context,\n options: TOptions = { base: \"/\" } as TOptions\n ) {\n this.options = options;\n this.options.base = resolve(options.base);\n this.options.isReadOnly = !!options.isReadOnly;\n }\n\n /**\n * Synchronously checks if a key exists in the storage.\n *\n * @param key - The key to check for existence.\n * @returns Returns `true` if the key exists, otherwise `false`.\n */\n public abstract existsSync(key: string): boolean;\n\n /**\n * Asynchronously checks if a key exists in the storage.\n *\n * @param key - The key to check for existence.\n * @returns A promise that resolves to `true` if the key exists, otherwise `false`.\n */\n public async exists(key: string): Promise<boolean> {\n return this.existsSync(key);\n }\n\n /**\n * Synchronously retrieves the value associated with a given key.\n *\n * @param key - The key whose value is to be retrieved.\n * @returns The value associated with the key, or `null` if the key does not exist.\n */\n public abstract getSync(key: string): string | null;\n\n /**\n * Asynchronously retrieves the value associated with a given key.\n *\n * @param key - The key whose value is to be retrieved.\n * @returns A promise that resolves to the value associated with the key, or `null` if the key does not exist.\n */\n public async get(key: string): Promise<string | null> {\n return this.getSync(key);\n }\n\n /**\n * Synchronously sets the value for a given key.\n *\n * @param key - The key to set the value for.\n * @param value - The value to set.\n */\n public abstract setSync(key: string, value: string): void;\n\n /**\n * Asynchronously sets the value for a given key.\n *\n * @param key - The key to set the value for.\n * @param value - The value to set.\n */\n public async set(key: string, value: string): Promise<void> {\n if (!this.isReadOnly && (!this.existsSync(key) || this.overwrite)) {\n this.setSync(key, value);\n }\n }\n\n /**\n * Synchronously creates a directory at the specified path.\n *\n * @param _ - The path of the directory to create.\n */\n public mkdirSync(_: string) {}\n\n /**\n * Creates a directory at the specified path.\n *\n * @param dirPath - The path of the directory to create.\n */\n public async mkdir(dirPath: string): Promise<void> {\n return Promise.resolve(this.mkdirSync(dirPath));\n }\n\n /**\n * Synchronously removes a key from the storage.\n *\n * @param key - The key to remove.\n */\n public abstract removeSync(key: string): void;\n\n /**\n * Asynchronously removes a key from the storage.\n *\n * @param key - The key to remove.\n */\n public async remove(key: string): Promise<void> {\n if (!this.isReadOnly && this.overwrite) {\n this.removeSync(key);\n }\n }\n\n /**\n * Synchronously removes all entries from the storage that match the provided base path.\n *\n * @param base - The base path to clear keys from.\n */\n public clearSync(base?: string) {\n if (!this.isReadOnly && this.overwrite) {\n const keys = this.listSync(base || this.options.base);\n if (!keys.length) {\n return;\n }\n\n keys.map(key =>\n this.removeSync(\n base && !key.startsWith(base) ? joinPaths(base, key) : key\n )\n );\n }\n }\n\n /**\n * Asynchronously removes all entries from the storage that match the provided base path.\n *\n * @param base - The base path to clear keys from.\n * @returns A promise that resolves when the operation is complete.\n */\n public async clear(base?: string): Promise<void> {\n if (!this.isReadOnly && this.overwrite) {\n const keys = await this.list(base || this.options.base);\n if (!keys.length) {\n return;\n }\n\n await Promise.all(\n keys.map(async key =>\n this.remove(\n base && !key.startsWith(base) ? joinPaths(base, key) : key\n )\n )\n );\n }\n }\n\n /**\n * Lists all keys under a given base path synchronously.\n *\n * @param base - The base path to list keys from.\n * @returns An array of keys under the specified base path.\n */\n public abstract listSync(base?: string): string[];\n\n /**\n * Asynchronously lists all keys under a given base path.\n *\n * @param base - The base path to list keys from.\n * @returns A promise that resolves to an array of keys under the specified base path.\n */\n public async list(base?: string): Promise<string[]> {\n return this.listSync(base);\n }\n\n /**\n * Synchronously checks if the given key is a directory.\n *\n * @param _ - The key to check.\n * @returns `true` if the key is a directory, otherwise `false`.\n */\n public isDirectorySync(_: string): boolean {\n return false;\n }\n\n /**\n * Checks if the given key is a directory.\n *\n * @param key - The key to check.\n * @returns A promise that resolves to `true` if the key is a directory, otherwise `false`.\n */\n public async isDirectory(key: string) {\n return Promise.resolve(this.isDirectorySync(key));\n }\n\n /**\n * Synchronously checks if the given key is a file.\n *\n * @param key - The key to check.\n * @returns `true` if the key is a file, otherwise `false`.\n */\n public isFileSync(key: string): boolean {\n return this.existsSync(key) && !this.isDirectorySync(key);\n }\n\n /**\n * Checks if the given key is a file.\n *\n * @param key - The key to check.\n * @returns A promise that resolves to `true` if the key is a file, otherwise `false`.\n */\n public async isFile(key: string) {\n return Promise.resolve(this.isFileSync(key));\n }\n\n /**\n * Disposes of the storage adapter, releasing any held resources.\n *\n * @returns A promise that resolves when the disposal is complete.\n */\n public dispose(): MaybePromise<void> {\n return Promise.resolve();\n }\n\n /**\n * Async dispose method to clean up resources.\n *\n * @returns A promise that resolves when disposal is complete.\n */\n public async [Symbol.asyncDispose]() {\n return this._dispose();\n }\n\n /**\n * Determines if the storage adapter is read-only based on the provided options.\n *\n * @returns `true` if the storage adapter is read-only, otherwise `false`.\n */\n protected get isReadOnly() {\n return !!this.options.isReadOnly;\n }\n\n /**\n * Determines if the storage adapter should overwrite existing keys based on the provided options and context configuration.\n *\n * @returns `true` if the storage adapter should overwrite existing keys, otherwise `false`.\n */\n protected get overwrite() {\n return !this.isReadOnly && this.context.config.output.overwrite !== false;\n }\n\n /**\n * Resolves a given key to its full path within the storage adapter.\n *\n * @param key - The key to resolve.\n * @returns The resolved full path for the key.\n */\n protected resolve(key?: string) {\n if (!key) {\n return this.options.base;\n }\n\n if (/\\.\\.:|\\.\\.$/.test(key)) {\n throw new Error(\n `[${this.name}]: Invalid key: ${JSON.stringify(key)} provided to storage adapter.`\n );\n }\n\n return appendPath(correctPath(key).replace(/:/g, \"/\"), this.options.base);\n }\n\n /**\n * Disposes of the storage adapter, releasing any held resources.\n *\n * @returns A promise that resolves when the disposal is complete.\n */\n protected async _dispose(): Promise<void> {\n if (!this.#isDisposed) {\n await Promise.resolve(this.dispose());\n this.#isDisposed = true;\n }\n }\n}\n","/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\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/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { isError } from \"@stryke/type-checks/is-error\";\n\n/**\n * Checks if an error is a file system error.\n *\n * @param err - The error to check.\n * @returns `true` if the error is a file system error, otherwise `false`.\n */\nexport function isFileError(err: any) {\n return isError(err) && \"code\" in err && err.code;\n}\n\n/**\n * Ignores file not found errors.\n *\n * @param err - The error to check.\n * @returns `null` if the error is a file not found error, otherwise returns the error.\n */\nexport function ignoreNotfound(err: any) {\n return (\n isFileError(err) &&\n (err.code === \"ENOENT\" || err.code === \"EISDIR\" ? null : err)\n );\n}\n\n/**\n * Ignores file exists errors.\n *\n * @param err - The error to check.\n * @returns `null` if the error is a file exists error, otherwise returns the error.\n */\nexport function ignoreExists(err: any) {\n return isFileError(err) && err.code === \"EEXIST\" ? null : err;\n}\n","/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\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/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { exists, existsSync } from \"@stryke/fs/exists\";\nimport { createDirectory, createDirectorySync } from \"@stryke/fs/helpers\";\nimport { isDirectory, isFile } from \"@stryke/fs/is-file\";\nimport { listFiles, listFilesSync } from \"@stryke/fs/list-files\";\nimport { readFile, readFileSync } from \"@stryke/fs/read-file\";\nimport { writeFile, writeFileSync } from \"@stryke/fs/write-file\";\nimport { isSetString } from \"@stryke/type-checks/is-set-string\";\nimport { unlinkSync } from \"node:fs\";\nimport { unlink } from \"node:fs/promises\";\nimport type { Context } from \"../types\";\nimport { getFileHeaderWarningText } from \"../utils\";\nimport { BaseStorageAdapter, StorageAdapterOptions } from \"./base\";\nimport { ignoreNotfound } from \"./helpers\";\n\nexport type SetSyncOptions = Parameters<typeof writeFileSync>[2];\nexport type SetOptions = Parameters<typeof writeFile>[2];\n\n/**\n * File system storage adapter implementation.\n */\nexport class FileSystemStorageAdapter extends BaseStorageAdapter {\n /**\n * A name identifying the storage adapter type.\n */\n public name = \"file-system\";\n\n /**\n * The storage preset for the adapter.\n *\n * @remarks\n * This can be used as an alternate way to identify the type of storage being used.\n */\n public override readonly preset = \"fs\";\n\n /**\n * Constructor for the FileSystemStorageAdapter.\n *\n * @param context - The Powerlines context.\n * @param options - Configuration options for the storage adapter.\n */\n public constructor(context: Context, options?: StorageAdapterOptions) {\n super(context, options);\n }\n\n /**\n * Synchronously checks if a key exists in the storage.\n *\n * @param key - The key to check for existence.\n * @returns Returns `true` if the key exists, otherwise `false`.\n */\n public existsSync(key: string): boolean {\n return existsSync(this.resolve(key));\n }\n\n /**\n * Asynchronously checks if a key exists in the storage.\n *\n * @param key - The key to check for existence.\n * @returns A promise that resolves to `true` if the key exists, otherwise `false`.\n */\n public override async exists(key: string): Promise<boolean> {\n return exists(this.resolve(key));\n }\n\n /**\n * Synchronously retrieves the value associated with a given key.\n *\n * @param key - The key whose value is to be retrieved.\n * @returns The value associated with the key, or `null` if the key does not exist.\n */\n public getSync(key: string): string | null {\n return readFileSync(this.resolve(key));\n }\n\n /**\n * Asynchronously retrieves the value associated with a given key.\n *\n * @param key - The key whose value is to be retrieved.\n * @returns A promise that resolves to the value associated with the key, or `null` if the key does not exist.\n */\n public override async get(key: string): Promise<string | null> {\n return readFile(this.resolve(key));\n }\n\n /**\n * Synchronously sets the value for a given key.\n *\n * @param key - The key to set the value for.\n * @param value - The value to set.\n */\n public setSync(key: string, value: string) {\n if (!this.isReadOnly) {\n if (this.existsSync(this.resolve(key)) && !this.overwrite) {\n const existingValue = this.getSync(this.resolve(key));\n if (\n isSetString(existingValue) &&\n existingValue.includes(\n getFileHeaderWarningText(true, this.context.config.framework)\n )\n ) {\n return writeFileSync(\n this.resolve(key),\n existingValue.replace(\n getFileHeaderWarningText(true, this.context.config.framework),\n getFileHeaderWarningText(false, this.context.config.framework)\n )\n );\n }\n } else {\n return writeFileSync(this.resolve(key), value);\n }\n }\n }\n\n /**\n * Asynchronously sets the value for a given key.\n *\n * @param key - The key to set the value for.\n * @param value - The value to set.\n */\n public override async set(key: string, value: string): Promise<void> {\n if (!this.isReadOnly) {\n if (this.existsSync(this.resolve(key)) && !this.overwrite) {\n const existingValue = await this.get(this.resolve(key));\n if (\n isSetString(existingValue) &&\n existingValue.includes(\n getFileHeaderWarningText(true, this.context.config.framework)\n )\n ) {\n return writeFile(\n this.resolve(key),\n existingValue.replace(\n getFileHeaderWarningText(true, this.context.config.framework),\n getFileHeaderWarningText(false, this.context.config.framework)\n )\n );\n }\n } else {\n return writeFile(this.resolve(key), value);\n }\n }\n }\n\n /**\n * Synchronously removes a key from the storage.\n *\n * @param key - The key to remove.\n */\n public removeSync(key: string) {\n if (!this.isReadOnly && this.overwrite) {\n try {\n return unlinkSync(this.resolve(key));\n } catch (err) {\n return ignoreNotfound(err);\n }\n }\n }\n\n /**\n * Asynchronously removes a key from the storage.\n *\n * @param key - The key to remove.\n */\n public override async remove(key: string): Promise<void> {\n if (!this.isReadOnly && this.overwrite) {\n return unlink(this.resolve(key)).catch(ignoreNotfound);\n }\n }\n\n /**\n * Synchronously creates a directory at the specified path.\n *\n * @param dirPath - The path of the directory to create.\n */\n public override mkdirSync(dirPath: string) {\n createDirectorySync(this.resolve(dirPath));\n }\n\n /**\n * Creates a directory at the specified path.\n *\n * @param dirPath - The path of the directory to create.\n */\n public override async mkdir(dirPath: string): Promise<void> {\n await createDirectory(this.resolve(dirPath));\n }\n\n /**\n * Lists all keys under a given base path synchronously.\n *\n * @param base - The base path to list keys from.\n * @returns An array of keys under the specified base path.\n */\n public listSync(base?: string): string[] {\n try {\n return listFilesSync(this.resolve(base), {\n ignore: this.options.ignore\n });\n } catch (err) {\n return ignoreNotfound(err) ?? [];\n }\n }\n\n /**\n * Asynchronously lists all keys under a given base path.\n *\n * @param base - The base path to list keys from.\n * @returns A promise that resolves to an array of keys under the specified base path.\n */\n public override async list(base?: string): Promise<string[]> {\n return listFiles(this.resolve(base), {\n ignore: this.options.ignore\n })\n .catch(ignoreNotfound)\n .then(r => r || []);\n }\n\n /**\n * Synchronously checks if the given key is a directory.\n *\n * @param key - The key to check.\n * @returns `true` if the key is a directory, otherwise `false`.\n */\n public override isDirectorySync(key: string): boolean {\n return isDirectory(this.resolve(key));\n }\n\n /**\n * Synchronously checks if the given key is a file.\n *\n * @param key - The key to check.\n * @returns `true` if the key is a file, otherwise `false`.\n */\n public override isFileSync(key: string): boolean {\n return isFile(this.resolve(key));\n }\n}\n","/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\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/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { isParentPath } from \"@stryke/path/is-parent-path\";\nimport type { Context } from \"../types\";\nimport { BaseStorageAdapter, StorageAdapterOptions } from \"./base\";\n\n/**\n * Virtual/in-memory storage adapter implementation.\n */\nexport class VirtualStorageAdapter extends BaseStorageAdapter {\n /**\n * A name identifying the storage adapter type.\n */\n public name = \"virtual\";\n\n /**\n * The storage preset for the adapter.\n *\n * @remarks\n * This can be used as an alternate way to identify the type of storage being used.\n */\n public override readonly preset = \"virtual\";\n\n /**\n * In-memory data storage.\n */\n protected data = new Map<string, any>();\n\n /**\n * Constructor for the VirtualStorageAdapter.\n *\n * @param context - The Powerlines context.\n * @param options - Configuration options for the storage adapter.\n */\n public constructor(context: Context, options?: StorageAdapterOptions) {\n super(context, options);\n }\n\n /**\n * Synchronously checks if a key exists in the storage.\n *\n * @param key - The key to check for existence.\n * @returns Returns `true` if the key exists, otherwise `false`.\n */\n public existsSync(key: string): boolean {\n return this.data.has(this.resolve(key));\n }\n\n /**\n * Synchronously retrieves the value associated with a given key.\n *\n * @param key - The key whose value is to be retrieved.\n * @returns The value associated with the key, or `null` if the key does not exist.\n */\n public getSync(key: string): string | null {\n return this.data.get(this.resolve(key)) ?? null;\n }\n\n /**\n * Synchronously sets the value for a given key.\n *\n * @param key - The key to set the value for.\n * @param value - The value to set.\n */\n public setSync(key: string, value: string) {\n if (!this.isReadOnly && (!this.existsSync(key) || this.overwrite)) {\n this.data.set(this.resolve(key), value);\n }\n }\n\n /**\n * Synchronously removes a key from the storage.\n *\n * @param key - The key to remove.\n */\n public removeSync(key: string) {\n if (!this.isReadOnly && this.overwrite) {\n this.data.delete(this.resolve(key));\n }\n }\n\n /**\n * Lists all keys under a given base path synchronously.\n *\n * @param base - The base path to list keys from.\n * @returns An array of keys under the specified base path.\n */\n public listSync(base?: string): string[] {\n return [\n ...this.data\n .keys()\n .filter(key => (!base ? true : isParentPath(key, this.resolve(base))))\n ];\n }\n\n /**\n * Disposes of the storage adapter, releasing any held resources.\n *\n * @returns A promise that resolves when the disposal is complete.\n */\n public override async dispose(): Promise<void> {\n return this.clear();\n }\n\n /**\n * Determines if the storage adapter should overwrite existing keys based on the provided options and context configuration.\n *\n * @returns `true` if the storage adapter should overwrite existing keys, otherwise `false`.\n */\n protected override get overwrite() {\n return !this.isReadOnly;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAkCA,IAAsB,qBAAtB,MAE4B;;;;CAI1B,cAAc;;;;CAUd,AAAO;;;;;;;CAQP,AAAgB,SAAgC;;;;;;;CAQhD,AAAO,YACL,AAAUA,SACV,UAAoB,EAAE,MAAM,KAAK,EACjC;EAFU;AAGV,OAAK,UAAU;AACf,OAAK,QAAQ,OAAO,QAAQ,QAAQ,KAAK;AACzC,OAAK,QAAQ,aAAa,CAAC,CAAC,QAAQ;;;;;;;;CAiBtC,MAAa,OAAO,KAA+B;AACjD,SAAO,KAAK,WAAW,IAAI;;;;;;;;CAiB7B,MAAa,IAAI,KAAqC;AACpD,SAAO,KAAK,QAAQ,IAAI;;;;;;;;CAiB1B,MAAa,IAAI,KAAa,OAA8B;AAC1D,MAAI,CAAC,KAAK,eAAe,CAAC,KAAK,WAAW,IAAI,IAAI,KAAK,WACrD,MAAK,QAAQ,KAAK,MAAM;;;;;;;CAS5B,AAAO,UAAU,GAAW;;;;;;CAO5B,MAAa,MAAM,SAAgC;AACjD,SAAO,QAAQ,QAAQ,KAAK,UAAU,QAAQ,CAAC;;;;;;;CAejD,MAA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,EAAE,MAAM;;;;;;;CAS3C,AAAO,WAAW,KAAa;AAC7B,MAAI,CAAC,KAAK,cAAc,KAAK,UAC3B,MAAK,KAAK,OAAO,KAAK,QAAQ,IAAI,CAAC;;;;;;;;CAUvC,AAAO,SAAS,MAAyB;AACvC,SAAO,CACL,GAAG,KAAK,KACL,MAAM,CACN,QAAO,QAAQ,CAAC,OAAO,OAAO,aAAa,KAAK,KAAK,QAAQ,KAAK,CAAC,CAAE,CACzE;;;;;;;CAQH,MAAsB,UAAyB;AAC7C,SAAO,KAAK,OAAO;;;;;;;CAQrB,IAAuB,YAAY;AACjC,SAAO,CAAC,KAAK"}
|
package/dist/vite-Bx1gbbj3.mjs
DELETED
|
@@ -1,171 +0,0 @@
|
|
|
1
|
-
import { a as createUnpluginFactory, o as createUnplugin } from "./api-CY668wMZ.mjs";
|
|
2
|
-
import { r as resolveOptions$1 } from "./resolve-options-DHL3RM8F.mjs";
|
|
3
|
-
import { n as resolveOptions$3 } from "./resolve-options-6sXFqzEA.mjs";
|
|
4
|
-
import { t as resolveOptions$2 } from "./resolve-options-D-RGs8j8.mjs";
|
|
5
|
-
import { joinPaths } from "@stryke/path/join-paths";
|
|
6
|
-
import defu from "defu";
|
|
7
|
-
import { createVitePlugin } from "unplugin";
|
|
8
|
-
import { isDevelopmentMode, isTestMode } from "@stryke/env/environment-checks";
|
|
9
|
-
import { build } from "vite";
|
|
10
|
-
|
|
11
|
-
//#region ../plugin-vite/src/helpers/resolve-options.ts
|
|
12
|
-
const DEFAULT_VITE_CONFIG = {
|
|
13
|
-
resolve: { extensions: [
|
|
14
|
-
".mjs",
|
|
15
|
-
".js",
|
|
16
|
-
".mts",
|
|
17
|
-
".ts",
|
|
18
|
-
".jsx",
|
|
19
|
-
".tsx",
|
|
20
|
-
".json"
|
|
21
|
-
] },
|
|
22
|
-
json: { stringify: true },
|
|
23
|
-
logLevel: "silent",
|
|
24
|
-
clearScreen: true
|
|
25
|
-
};
|
|
26
|
-
/**
|
|
27
|
-
* Resolves the options for [vite](https://vitejs.dev/).
|
|
28
|
-
*
|
|
29
|
-
* @param context - The build context.
|
|
30
|
-
* @returns The resolved options.
|
|
31
|
-
*/
|
|
32
|
-
function resolveOptions(context) {
|
|
33
|
-
return defu({ resolve: {
|
|
34
|
-
alias: Object.entries(context.alias).reduce((ret, [id, path]) => {
|
|
35
|
-
if (!ret.find((e) => e.find === id)) ret.push({
|
|
36
|
-
find: id,
|
|
37
|
-
replacement: path
|
|
38
|
-
});
|
|
39
|
-
else context.warn(`Duplicate alias entry for '${id}' detected. The first entry will be used.`);
|
|
40
|
-
return ret;
|
|
41
|
-
}, []),
|
|
42
|
-
dedupe: context.config.resolve.dedupe,
|
|
43
|
-
mainFields: context.config.resolve.mainFields,
|
|
44
|
-
conditions: context.config.resolve.conditions,
|
|
45
|
-
extensions: context.config.resolve.extensions
|
|
46
|
-
} }, context.config.vite ? defu(context.config.vite, { optimizeDeps: context.config.vite?.optimizeDeps ?? {} }, { optimizeDeps: { extensions: context.config.resolve.extensions } }) : {}, {
|
|
47
|
-
define: context.config.define,
|
|
48
|
-
rootDir: context.fs.existsSync(joinPaths(context.config.root, "src")) ? joinPaths(context.config.root, "src") : context.config.root,
|
|
49
|
-
platform: context.config.platform,
|
|
50
|
-
mode: context.config.mode === "development" ? "development" : "production",
|
|
51
|
-
cacheDir: joinPaths(context.cachePath, "vite"),
|
|
52
|
-
build: {
|
|
53
|
-
minify: context.config.mode !== "development",
|
|
54
|
-
metafile: context.config.mode === "development",
|
|
55
|
-
sourcemap: context.config.mode === "development",
|
|
56
|
-
outDir: context.config.output.buildPath,
|
|
57
|
-
tsconfig: context.tsconfig.tsconfigFilePath,
|
|
58
|
-
tsconfigRaw: context.tsconfig.tsconfigJson
|
|
59
|
-
},
|
|
60
|
-
esbuild: resolveOptions$1(context),
|
|
61
|
-
optimizeDeps: {
|
|
62
|
-
rolldownOptions: resolveOptions$2(context),
|
|
63
|
-
rollupOptions: resolveOptions$3(context),
|
|
64
|
-
esbuildOptions: resolveOptions$1(context)
|
|
65
|
-
},
|
|
66
|
-
logLevel: context.config.logLevel ?? void 0,
|
|
67
|
-
envDir: context.config.root
|
|
68
|
-
}, DEFAULT_VITE_CONFIG);
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
//#endregion
|
|
72
|
-
//#region ../plugin-vite/src/helpers/unplugin.ts
|
|
73
|
-
function createVitePlugin$1(context) {
|
|
74
|
-
return createVitePlugin(createUnplugin(context))({});
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
//#endregion
|
|
78
|
-
//#region ../plugin-vite/src/index.ts
|
|
79
|
-
/**
|
|
80
|
-
* A Powerlines plugin to assist in developing other Powerlines plugins.
|
|
81
|
-
*/
|
|
82
|
-
const plugin = (options = {}) => {
|
|
83
|
-
return {
|
|
84
|
-
name: "vite",
|
|
85
|
-
config() {
|
|
86
|
-
this.trace("Providing default configuration for the Powerlines `vite` build plugin.");
|
|
87
|
-
return {
|
|
88
|
-
output: { format: ["cjs", "esm"] },
|
|
89
|
-
vite: {
|
|
90
|
-
...DEFAULT_VITE_CONFIG,
|
|
91
|
-
...options
|
|
92
|
-
},
|
|
93
|
-
singleBuild: true
|
|
94
|
-
};
|
|
95
|
-
},
|
|
96
|
-
async build() {
|
|
97
|
-
this.trace(`Building the Powerlines plugin.`);
|
|
98
|
-
const environments = this?.$$internal?.api?.context?.environments;
|
|
99
|
-
if (!environments || Object.keys(environments).length === 0) throw new Error(`No environments found in the Powerlines context. At least one environment should have been generated - please report this issue to https://github.com/storm-software/powerlines/issues.`);
|
|
100
|
-
this.trace(`Running Vite for ${Object.keys(environments).length} environments.`);
|
|
101
|
-
await build(defu({
|
|
102
|
-
config: false,
|
|
103
|
-
entry: this.entry,
|
|
104
|
-
environments: Object.fromEntries(Object.entries(environments).map(([name, env]) => [name, resolveOptions(env)]))
|
|
105
|
-
}, resolveOptions(this), { plugins: [createVitePlugin$1(this)] }));
|
|
106
|
-
}
|
|
107
|
-
};
|
|
108
|
-
};
|
|
109
|
-
var src_default = plugin;
|
|
110
|
-
|
|
111
|
-
//#endregion
|
|
112
|
-
//#region src/vite.ts
|
|
113
|
-
/**
|
|
114
|
-
* A Vite plugin that will invoke the Powerlines API hooks during the build process.
|
|
115
|
-
*
|
|
116
|
-
* @see https://vitejs.dev/guide/api-plugin.html#plugin-api
|
|
117
|
-
*
|
|
118
|
-
* @example
|
|
119
|
-
* ```ts
|
|
120
|
-
* // vite.config.ts
|
|
121
|
-
* import powerlines from "powerlines/vite";
|
|
122
|
-
*
|
|
123
|
-
* export default defineConfig({
|
|
124
|
-
* plugins: [powerlines({ name: "example-app", ... })],
|
|
125
|
-
* });
|
|
126
|
-
*
|
|
127
|
-
* ```
|
|
128
|
-
*/
|
|
129
|
-
const unplugin = createVitePlugin(createUnpluginFactory("vite", (api, plugin$1) => {
|
|
130
|
-
return {
|
|
131
|
-
...plugin$1,
|
|
132
|
-
vite: {
|
|
133
|
-
sharedDuringBuild: true,
|
|
134
|
-
async hotUpdate(options) {
|
|
135
|
-
const environment = await api.context.getEnvironment();
|
|
136
|
-
return api.callHook("vite:hotUpdate", { environment }, options);
|
|
137
|
-
},
|
|
138
|
-
async config(config, env) {
|
|
139
|
-
api.context.config.mode = isDevelopmentMode(env.mode) ? "development" : isTestMode(env.mode) ? "test" : "production";
|
|
140
|
-
const environment = await api.context.getEnvironment();
|
|
141
|
-
const result = await api.callHook("vite:config", { environment }, config, env);
|
|
142
|
-
return defu(resolveOptions(api.context), result?.build ?? {}, config);
|
|
143
|
-
},
|
|
144
|
-
async configResolved(_config) {
|
|
145
|
-
const environment = await api.context.getEnvironment();
|
|
146
|
-
await api.callHook("configResolved", { environment });
|
|
147
|
-
},
|
|
148
|
-
async configureServer(server) {
|
|
149
|
-
const environment = await api.context.getEnvironment();
|
|
150
|
-
return api.callHook("vite:configureServer", { environment }, server);
|
|
151
|
-
},
|
|
152
|
-
async configurePreviewServer(server) {
|
|
153
|
-
const environment = await api.context.getEnvironment();
|
|
154
|
-
return api.callHook("vite:configurePreviewServer", { environment }, server);
|
|
155
|
-
},
|
|
156
|
-
async transformIndexHtml(html, ctx) {
|
|
157
|
-
const environment = await api.context.getEnvironment();
|
|
158
|
-
return api.callHook("vite:transformIndexHtml", { environment }, html, ctx);
|
|
159
|
-
},
|
|
160
|
-
async handleHotUpdate(ctx) {
|
|
161
|
-
const environment = await api.context.getEnvironment();
|
|
162
|
-
return api.callHook("vite:handleHotUpdate", { environment }, ctx);
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
};
|
|
166
|
-
}));
|
|
167
|
-
var vite_default = unplugin;
|
|
168
|
-
|
|
169
|
-
//#endregion
|
|
170
|
-
export { vite_default as n, src_default as r, unplugin as t };
|
|
171
|
-
//# sourceMappingURL=vite-Bx1gbbj3.mjs.map
|