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
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import { n as FileSystemStorageAdapter, t as VirtualStorageAdapter } from "./virtual-B9imjOqe.mjs";
|
|
1
|
+
import { n as __reExport, t as __exportAll } from "./chunk-CtajNgzt.mjs";
|
|
2
|
+
import { a as isIncludeMatchFound, i as getTsconfigFilePath, l as createProgram, r as getParsedTypeScriptConfig } from "./tsconfig-D9GCB2I9.mjs";
|
|
3
|
+
import { t as plugin_utils_exports } from "./plugin-utils.mjs";
|
|
4
|
+
import { t as constants_exports } from "./constants.mjs";
|
|
5
|
+
import { t as config_exports } from "./config.mjs";
|
|
6
|
+
import { t as utils_exports } from "./utils.mjs";
|
|
7
|
+
import { n as FileSystemStorageAdapter, t as VirtualStorageAdapter } from "./virtual-DvkJm7gK.mjs";
|
|
9
8
|
import { getWorkspaceRoot, relativeToWorkspaceRoot } from "@stryke/fs/get-workspace-root";
|
|
10
9
|
import { formatLogMessage } from "@storm-software/config-tools/logger/console";
|
|
11
10
|
import { toArray } from "@stryke/convert/to-array";
|
|
@@ -33,10 +32,7 @@ import { findFileDotExtensionSafe, findFileExtensionSafe, findFileName, findFile
|
|
|
33
32
|
import { isParentPath } from "@stryke/path/is-parent-path";
|
|
34
33
|
import { prettyBytes } from "@stryke/string-format/pretty-bytes";
|
|
35
34
|
import { DiagnosticCategory } from "ts-morph";
|
|
36
|
-
import defu, { createDefu, defu
|
|
37
|
-
import { getUnique, getUniqueBy } from "@stryke/helpers/get-unique";
|
|
38
|
-
import { isRegExp } from "@stryke/type-checks/is-regexp";
|
|
39
|
-
import { joinPaths as joinPaths$1 } from "@stryke/path/join";
|
|
35
|
+
import defu$1, { createDefu, defu } from "defu";
|
|
40
36
|
import { getPackageName, getPackageVersion, hasPackageVersion } from "@stryke/string-format/package";
|
|
41
37
|
import { existsSync } from "@stryke/fs/exists";
|
|
42
38
|
import { readJsonFile } from "@stryke/fs/json";
|
|
@@ -49,8 +45,11 @@ import { LogLevelLabel } from "@storm-software/config-tools/types";
|
|
|
49
45
|
import { getEnvPaths } from "@stryke/env/get-env-paths";
|
|
50
46
|
import { murmurhash } from "@stryke/hash";
|
|
51
47
|
import { hashDirectory } from "@stryke/hash/node";
|
|
48
|
+
import { getUnique, getUniqueBy } from "@stryke/helpers/get-unique";
|
|
52
49
|
import { fetchRequest } from "@stryke/http/fetch";
|
|
50
|
+
import { joinPaths as joinPaths$1 } from "@stryke/path/join";
|
|
53
51
|
import { isNull } from "@stryke/type-checks/is-null";
|
|
52
|
+
import { isRegExp } from "@stryke/type-checks/is-regexp";
|
|
54
53
|
import { uuid } from "@stryke/unique-id/uuid";
|
|
55
54
|
import { match, tsconfigPathsToRegExp } from "bundle-require";
|
|
56
55
|
import { resolveCompatibilityDates } from "compatx";
|
|
@@ -67,15 +66,17 @@ import { slash } from "@stryke/path/slash";
|
|
|
67
66
|
import { Blob as Blob$1 } from "node:buffer";
|
|
68
67
|
import { fileURLToPath } from "node:url";
|
|
69
68
|
import { ResolverFactory } from "oxc-resolver";
|
|
69
|
+
import { createLog } from "@powerlines/core/lib/logger";
|
|
70
|
+
import { getString } from "@powerlines/core/lib/utilities/source-file";
|
|
70
71
|
import { setParseImpl } from "unplugin";
|
|
71
72
|
|
|
72
73
|
//#region package.json
|
|
73
74
|
var name = "powerlines";
|
|
74
|
-
var version = "0.41.
|
|
75
|
+
var version = "0.41.7";
|
|
75
76
|
|
|
76
77
|
//#endregion
|
|
77
78
|
//#region src/_internal/helpers/generate-types.ts
|
|
78
|
-
const getModuleCommentBlockRegex = (moduleId) =>
|
|
79
|
+
const getModuleCommentBlockRegex = (moduleId) => new RegExp(`\\/\\*\\*(?s:.)*?@module\\s+${moduleId}(?s:.)*?\\*\\/\\s+`);
|
|
79
80
|
/**
|
|
80
81
|
* Formats the generated TypeScript types source code.
|
|
81
82
|
*
|
|
@@ -168,7 +169,7 @@ function mergeResults(currentResult, previousResults) {
|
|
|
168
169
|
*/
|
|
169
170
|
function mergeConfigs(currentResult, previousResults) {
|
|
170
171
|
if (isString(currentResult)) previousResults = [`${isString(previousResults[0]) ? previousResults[0] || "" : ""}\n${currentResult || ""}`.trim()];
|
|
171
|
-
else if (isObject(currentResult)) previousResults = [mergeConfig(currentResult, previousResults[0] ?? {})];
|
|
172
|
+
else if (isObject(currentResult)) previousResults = [(0, plugin_utils_exports.mergeConfig)(currentResult, previousResults[0] ?? {})];
|
|
172
173
|
return previousResults;
|
|
173
174
|
}
|
|
174
175
|
/**
|
|
@@ -209,7 +210,7 @@ async function callHook(context, key, options, ...args) {
|
|
|
209
210
|
const definedResults = results.filter((result) => isSet(result));
|
|
210
211
|
if (definedResults.length > 0) {
|
|
211
212
|
let mergedResult = void 0;
|
|
212
|
-
for (const result of definedResults) mergedResult = defu
|
|
213
|
+
for (const result of definedResults) mergedResult = defu(result, mergedResult ?? {});
|
|
213
214
|
return mergedResult;
|
|
214
215
|
}
|
|
215
216
|
}
|
|
@@ -259,8 +260,8 @@ async function installDependencies(context) {
|
|
|
259
260
|
context.debug(`No dependencies or devDependencies to install. Skipping installation step.`);
|
|
260
261
|
return;
|
|
261
262
|
}
|
|
262
|
-
context.debug(`The following packages are required: \nDependencies: \n${Object.entries(context.dependencies).map(([name
|
|
263
|
-
await Promise.all([Promise.all(Object.entries(context.dependencies).map(async ([name
|
|
263
|
+
context.debug(`The following packages are required: \nDependencies: \n${Object.entries(context.dependencies).map(([name, version]) => `- ${name}@${String(version)}`).join(" \n")}\n\nDevDependencies: \n${Object.entries(context.devDependencies).map(([name, version]) => `- ${name}@${String(version)}`).join(" \n")}`);
|
|
264
|
+
await Promise.all([Promise.all(Object.entries(context.dependencies).map(async ([name, version]) => installPackage(context, `${getPackageName(name)}@${String(version)}`, false))), Promise.all(Object.entries(context.devDependencies).map(async ([name, version]) => installPackage(context, `${getPackageName(name)}@${String(version)}`, true)))]);
|
|
264
265
|
}
|
|
265
266
|
|
|
266
267
|
//#endregion
|
|
@@ -275,9 +276,9 @@ async function installDependencies(context) {
|
|
|
275
276
|
* @param rootHash - The hash of the project root.
|
|
276
277
|
* @returns An object containing the name and project root hash.
|
|
277
278
|
*/
|
|
278
|
-
function getPrefixedRootHash(name
|
|
279
|
-
const combined = `${kebabCase(name
|
|
280
|
-
return combined.length > ROOT_HASH_LENGTH ? combined.slice(0, ROOT_HASH_LENGTH) : combined;
|
|
279
|
+
function getPrefixedRootHash(name, rootHash) {
|
|
280
|
+
const combined = `${kebabCase(name)}_${rootHash}`;
|
|
281
|
+
return combined.length > constants_exports.ROOT_HASH_LENGTH ? combined.slice(0, constants_exports.ROOT_HASH_LENGTH) : combined;
|
|
281
282
|
}
|
|
282
283
|
/**
|
|
283
284
|
* Writes the meta file for the context.
|
|
@@ -375,9 +376,9 @@ async function resolveTsconfig(context) {
|
|
|
375
376
|
|
|
376
377
|
//#endregion
|
|
377
378
|
//#region src/_internal/helpers/environment.ts
|
|
378
|
-
function createEnvironment(name
|
|
379
|
-
return defu(userConfig.environments?.[name
|
|
380
|
-
name
|
|
379
|
+
function createEnvironment(name, userConfig) {
|
|
380
|
+
return defu$1(userConfig.environments?.[name] ?? {}, {
|
|
381
|
+
name,
|
|
381
382
|
title: userConfig.title || titleCase(userConfig.name),
|
|
382
383
|
ssr: false,
|
|
383
384
|
mainFields: userConfig?.platform === "browser" ? [
|
|
@@ -412,7 +413,7 @@ function createEnvironment(name$1, userConfig) {
|
|
|
412
413
|
}, userConfig);
|
|
413
414
|
}
|
|
414
415
|
function createDefaultEnvironment(userConfig) {
|
|
415
|
-
return createEnvironment(DEFAULT_ENVIRONMENT, userConfig);
|
|
416
|
+
return createEnvironment(constants_exports.DEFAULT_ENVIRONMENT, userConfig);
|
|
416
417
|
}
|
|
417
418
|
|
|
418
419
|
//#endregion
|
|
@@ -424,7 +425,7 @@ function createDefaultEnvironment(userConfig) {
|
|
|
424
425
|
* @returns A Jiti instance configured for the specified workspace and project root.
|
|
425
426
|
*/
|
|
426
427
|
function resolveOptions(options) {
|
|
427
|
-
return defu(options, {
|
|
428
|
+
return defu$1(options, {
|
|
428
429
|
interopDefault: true,
|
|
429
430
|
fsCache: options.mode !== "development" ? joinPaths(options.cacheDir, "jiti") : false,
|
|
430
431
|
moduleCache: options.mode !== "development"
|
|
@@ -705,7 +706,7 @@ function isValidId(id, prefix = "powerlines") {
|
|
|
705
706
|
* @returns The formatted file ID.
|
|
706
707
|
*/
|
|
707
708
|
function normalizeId(id, prefix = "powerlines") {
|
|
708
|
-
return replaceExtension(toFilePath(id)).replace(/^\\0/, "").replace(/^powerlines:/, "").replace(
|
|
709
|
+
return replaceExtension(toFilePath(id)).replace(/^\\0/, "").replace(/^powerlines:/, "").replace(new RegExp(`^${prefix.replace(/:$/, "")}:`), "");
|
|
709
710
|
}
|
|
710
711
|
/**
|
|
711
712
|
* Normalizes a given path by resolving it against the project root, workspace root, and built-ins path.
|
|
@@ -716,7 +717,7 @@ function normalizeId(id, prefix = "powerlines") {
|
|
|
716
717
|
* @returns The normalized path.
|
|
717
718
|
*/
|
|
718
719
|
function normalizePath(path, builtinsPath, prefix = "powerlines") {
|
|
719
|
-
return isAbsolutePath(path) ? path : isValidId(toFilePath(path), prefix) ? normalizeId(toFilePath(path), prefix).replace(
|
|
720
|
+
return isAbsolutePath(path) ? path : isValidId(toFilePath(path), prefix) ? normalizeId(toFilePath(path), prefix).replace(new RegExp(`^${prefix.replace(/:$/, "")}:`), builtinsPath) : toFilePath(path);
|
|
720
721
|
}
|
|
721
722
|
/**
|
|
722
723
|
* Normalizes glob patterns by resolving them against the workspace root.
|
|
@@ -798,7 +799,7 @@ var VirtualFileSystem = class VirtualFileSystem {
|
|
|
798
799
|
* @returns The normalized path.
|
|
799
800
|
*/
|
|
800
801
|
#normalizePath(path) {
|
|
801
|
-
return normalizePath(path.includes("{") || path.includes("}") ? replacePathTokens(this.#context, path) : path, this.#context.builtinsPath, this.#context.config.framework);
|
|
802
|
+
return normalizePath(path.includes("{") || path.includes("}") ? (0, plugin_utils_exports.replacePathTokens)(this.#context, path) : path, this.#context.builtinsPath, this.#context.config.framework);
|
|
802
803
|
}
|
|
803
804
|
/**
|
|
804
805
|
* Gets the storage adapter and relative key for a given key.
|
|
@@ -861,7 +862,7 @@ var VirtualFileSystem = class VirtualFileSystem {
|
|
|
861
862
|
*/
|
|
862
863
|
#innerResolve = async (id, importer, options = {}) => {
|
|
863
864
|
let path = id;
|
|
864
|
-
if (path.includes("{") || path.includes("}")) path = replacePathTokens(this.#context, path);
|
|
865
|
+
if (path.includes("{") || path.includes("}")) path = (0, plugin_utils_exports.replacePathTokens)(this.#context, path);
|
|
865
866
|
if (options.skipAlias !== true) path = this.resolveAlias(path);
|
|
866
867
|
if (isAbsolutePath(path) && (!options.isFile || !await this.isDirectory(path))) return path;
|
|
867
868
|
const resolverCacheKey = murmurhash({
|
|
@@ -929,7 +930,7 @@ var VirtualFileSystem = class VirtualFileSystem {
|
|
|
929
930
|
*/
|
|
930
931
|
#innerResolveSync = (id, importer, options = {}) => {
|
|
931
932
|
let path = id;
|
|
932
|
-
if (path.includes("{") || path.includes("}")) path = replacePathTokens(this.#context, path);
|
|
933
|
+
if (path.includes("{") || path.includes("}")) path = (0, plugin_utils_exports.replacePathTokens)(this.#context, path);
|
|
933
934
|
if (options.skipAlias !== true) path = this.resolveAlias(path);
|
|
934
935
|
if (isAbsolutePath(path) && (!options.isFile || !this.isDirectorySync(path))) return path;
|
|
935
936
|
let result;
|
|
@@ -1178,9 +1179,9 @@ var VirtualFileSystem = class VirtualFileSystem {
|
|
|
1178
1179
|
id: metadata.id,
|
|
1179
1180
|
type: metadata.type,
|
|
1180
1181
|
timestamp: metadata.timestamp ?? Date.now(),
|
|
1181
|
-
properties: metadata._hasProperties() ? metadata.properties.values().reduce((ret
|
|
1182
|
-
ret
|
|
1183
|
-
return ret
|
|
1182
|
+
properties: metadata._hasProperties() ? metadata.properties.values().reduce((ret, item) => {
|
|
1183
|
+
ret[item.key] = item.value;
|
|
1184
|
+
return ret;
|
|
1184
1185
|
}, {}) : {}
|
|
1185
1186
|
};
|
|
1186
1187
|
return ret;
|
|
@@ -1197,7 +1198,7 @@ var VirtualFileSystem = class VirtualFileSystem {
|
|
|
1197
1198
|
return ret;
|
|
1198
1199
|
}, {});
|
|
1199
1200
|
}
|
|
1200
|
-
this.#log = extendLog(this.#context.log, "file-system");
|
|
1201
|
+
this.#log = (0, utils_exports.extendLog)(this.#context.log, "file-system");
|
|
1201
1202
|
}
|
|
1202
1203
|
/**
|
|
1203
1204
|
* Asynchronously checks if a file exists in the virtual file system (VFS).
|
|
@@ -1504,7 +1505,7 @@ var VirtualFileSystem = class VirtualFileSystem {
|
|
|
1504
1505
|
this.#log(LogLevelLabel.TRACE, `Writing ${resolvedPath} to ${adapter.name === "virtual" ? "the virtual file system" : adapter.name === "file-system" ? "the local file system" : adapter.name} (size: ${prettyBytes(new Blob$1(toArray(data)).size)})`);
|
|
1505
1506
|
let code = data;
|
|
1506
1507
|
try {
|
|
1507
|
-
if (!options.skipFormat) code = await format(this.#context, resolvedPath, data);
|
|
1508
|
+
if (!options.skipFormat) code = await (0, utils_exports.format)(this.#context, resolvedPath, data);
|
|
1508
1509
|
} catch (err) {
|
|
1509
1510
|
if (DEFAULT_EXTENSIONS.includes(findFileExtensionSafe(resolvedPath, { fullExtension: true }))) this.#log(LogLevelLabel.WARN, `Failed to format file ${resolvedPath} before writing: ${err.message}`);
|
|
1510
1511
|
code = data;
|
|
@@ -1588,7 +1589,7 @@ var VirtualFileSystem = class VirtualFileSystem {
|
|
|
1588
1589
|
const alias = found.reduce((ret, current) => {
|
|
1589
1590
|
return (isSetString(ret.find) ? ret.find.length : isRegExp(ret.find) ? ret.find.source.length : 0) > (isSetString(current.find) ? current.find.length : isRegExp(current.find) ? current.find.source.length : 0) ? ret : current;
|
|
1590
1591
|
});
|
|
1591
|
-
if (isSetString(alias.find)) path = path.replace(
|
|
1592
|
+
if (isSetString(alias.find)) path = path.replace(new RegExp(`^${alias.find}`), alias.replacement);
|
|
1592
1593
|
else if (isRegExp(alias.find)) path = path.replace(alias.find, alias.replacement);
|
|
1593
1594
|
}
|
|
1594
1595
|
} else if (isSetObject(this.#context.config.resolve.alias)) {
|
|
@@ -1597,7 +1598,7 @@ var VirtualFileSystem = class VirtualFileSystem {
|
|
|
1597
1598
|
const alias = found.reduce((ret, current) => {
|
|
1598
1599
|
return ret.length > current.length ? ret : current;
|
|
1599
1600
|
});
|
|
1600
|
-
path = path.replace(
|
|
1601
|
+
path = path.replace(new RegExp(`^${alias}`), this.#context.config.resolve.alias[alias]);
|
|
1601
1602
|
}
|
|
1602
1603
|
}
|
|
1603
1604
|
}
|
|
@@ -1692,8 +1693,8 @@ var VirtualFileSystem = class VirtualFileSystem {
|
|
|
1692
1693
|
fileMetadata.timestamp = value.timestamp ?? Date.now();
|
|
1693
1694
|
if (value.properties) {
|
|
1694
1695
|
const props = fileMetadata._initProperties(Object.keys(value.properties).length);
|
|
1695
|
-
Object.entries(value.properties).filter(([, val]) => isSetString(val)).forEach(([key, val], index
|
|
1696
|
-
const prop = props.get(index
|
|
1696
|
+
Object.entries(value.properties).filter(([, val]) => isSetString(val)).forEach(([key, val], index) => {
|
|
1697
|
+
const prop = props.get(index);
|
|
1697
1698
|
prop.key = key;
|
|
1698
1699
|
prop.value = val;
|
|
1699
1700
|
});
|
|
@@ -1701,7 +1702,7 @@ var VirtualFileSystem = class VirtualFileSystem {
|
|
|
1701
1702
|
});
|
|
1702
1703
|
await writeFileBuffer(joinPaths$1(this.#context.dataPath, "fs.bin"), message.toArrayBuffer());
|
|
1703
1704
|
if (!this.#context.config.skipCache) this.#resolverCache.save(true);
|
|
1704
|
-
await Promise.all(this.#getStorages().map(async (storage
|
|
1705
|
+
await Promise.all(this.#getStorages().map(async (storage) => storage.adapter.dispose()));
|
|
1705
1706
|
this.#log(LogLevelLabel.TRACE, "Virtual file system has been disposed.");
|
|
1706
1707
|
}
|
|
1707
1708
|
}
|
|
@@ -1741,7 +1742,7 @@ var PowerlinesContext = class PowerlinesContext {
|
|
|
1741
1742
|
#parserCache;
|
|
1742
1743
|
#requestCache;
|
|
1743
1744
|
#getConfigProps(config = {}) {
|
|
1744
|
-
return mergeConfig({
|
|
1745
|
+
return (0, plugin_utils_exports.mergeConfig)({
|
|
1745
1746
|
root: config.root,
|
|
1746
1747
|
name: config.name,
|
|
1747
1748
|
title: config.title,
|
|
@@ -1776,7 +1777,7 @@ var PowerlinesContext = class PowerlinesContext {
|
|
|
1776
1777
|
* @returns A promise that resolves to the new context.
|
|
1777
1778
|
*/
|
|
1778
1779
|
static async from(workspaceRoot, config) {
|
|
1779
|
-
const context = new PowerlinesContext(await loadWorkspaceConfig(workspaceRoot, config.root));
|
|
1780
|
+
const context = new PowerlinesContext(await (0, config_exports.loadWorkspaceConfig)(workspaceRoot, config.root));
|
|
1780
1781
|
await context.withUserConfig(config);
|
|
1781
1782
|
const powerlinesPath = await resolvePackage("powerlines");
|
|
1782
1783
|
if (!powerlinesPath) throw new Error("Could not resolve `powerlines` package location.");
|
|
@@ -1842,7 +1843,7 @@ var PowerlinesContext = class PowerlinesContext {
|
|
|
1842
1843
|
*/
|
|
1843
1844
|
get entry() {
|
|
1844
1845
|
const entry = this.resolvedEntry;
|
|
1845
|
-
return resolveInputsSync(this, entry && entry.length > 0 ? entry : Array.isArray(this.config.input) || isSetObject(this.config.input) && !isTypeDefinition(this.config.input) ? this.config.input : toArray(this.config.input).flat());
|
|
1846
|
+
return (0, utils_exports.resolveInputsSync)(this, entry && entry.length > 0 ? entry : Array.isArray(this.config.input) || isSetObject(this.config.input) && !(0, utils_exports.isTypeDefinition)(this.config.input) ? this.config.input : toArray(this.config.input).flat());
|
|
1846
1847
|
}
|
|
1847
1848
|
/**
|
|
1848
1849
|
* The TypeScript configuration parsed from the tsconfig file
|
|
@@ -1883,8 +1884,8 @@ var PowerlinesContext = class PowerlinesContext {
|
|
|
1883
1884
|
rootHash: murmurhash({
|
|
1884
1885
|
workspaceRoot: this.workspaceConfig?.workspaceRoot,
|
|
1885
1886
|
root: this.config?.root
|
|
1886
|
-
}, { maxLength: ROOT_HASH_LENGTH }),
|
|
1887
|
-
configHash: murmurhash(this.config, { maxLength: CACHE_HASH_LENGTH })
|
|
1887
|
+
}, { maxLength: constants_exports.ROOT_HASH_LENGTH }),
|
|
1888
|
+
configHash: murmurhash(this.config, { maxLength: constants_exports.CACHE_HASH_LENGTH })
|
|
1888
1889
|
};
|
|
1889
1890
|
}
|
|
1890
1891
|
/**
|
|
@@ -1965,7 +1966,7 @@ var PowerlinesContext = class PowerlinesContext {
|
|
|
1965
1966
|
return joinPaths$1(this.envPaths.cache, "projects", murmurhash({
|
|
1966
1967
|
checksum: this.#checksum,
|
|
1967
1968
|
config: this.meta.configHash
|
|
1968
|
-
}, { maxLength: CACHE_HASH_LENGTH }));
|
|
1969
|
+
}, { maxLength: constants_exports.CACHE_HASH_LENGTH }));
|
|
1969
1970
|
}
|
|
1970
1971
|
/**
|
|
1971
1972
|
* Get the path to the generated declaration file for the project
|
|
@@ -2282,7 +2283,7 @@ var PowerlinesContext = class PowerlinesContext {
|
|
|
2282
2283
|
* @param options - Optional write file options
|
|
2283
2284
|
*/
|
|
2284
2285
|
async emitEntry(code, path, options = {}) {
|
|
2285
|
-
return this.emit(code, appendPath(path, this.entryPath), defu({ meta: {
|
|
2286
|
+
return this.emit(code, appendPath(path, this.entryPath), defu$1({ meta: {
|
|
2286
2287
|
type: "entry",
|
|
2287
2288
|
properties: {
|
|
2288
2289
|
file: appendPath(path, this.entryPath),
|
|
@@ -2301,7 +2302,7 @@ var PowerlinesContext = class PowerlinesContext {
|
|
|
2301
2302
|
* @param options - Optional write file options
|
|
2302
2303
|
*/
|
|
2303
2304
|
emitEntrySync(code, path, options = {}) {
|
|
2304
|
-
return this.emitSync(code, appendPath(path, this.entryPath), defu({ meta: {
|
|
2305
|
+
return this.emitSync(code, appendPath(path, this.entryPath), defu$1({ meta: {
|
|
2305
2306
|
type: "entry",
|
|
2306
2307
|
properties: {
|
|
2307
2308
|
file: appendPath(path, this.entryPath),
|
|
@@ -2322,7 +2323,7 @@ var PowerlinesContext = class PowerlinesContext {
|
|
|
2322
2323
|
async emitBuiltin(code, id, options = {}) {
|
|
2323
2324
|
if (!this.builtinsPath) throw new Error(`The builtins path is not set. Cannot emit builtin file with id "${id}".`);
|
|
2324
2325
|
if (!isSetString(id)) throw new Error(`The builtin id must be a non-empty string. Received: ${String(id)}`);
|
|
2325
|
-
return this.emit(code, appendPath(id, this.builtinsPath), defu(options, { meta: {
|
|
2326
|
+
return this.emit(code, appendPath(id, this.builtinsPath), defu$1(options, { meta: {
|
|
2326
2327
|
type: "builtin",
|
|
2327
2328
|
id
|
|
2328
2329
|
} }));
|
|
@@ -2337,7 +2338,7 @@ var PowerlinesContext = class PowerlinesContext {
|
|
|
2337
2338
|
emitBuiltinSync(code, id, options = {}) {
|
|
2338
2339
|
if (!this.builtinsPath) throw new Error(`The builtins path is not set. Cannot emit builtin file with id "${id}".`);
|
|
2339
2340
|
if (!isSetString(id)) throw new Error(`The builtin id must be a non-empty string. Received: ${String(id)}`);
|
|
2340
|
-
return this.emitSync(code, appendPath(id, this.builtinsPath), defu(options, { meta: {
|
|
2341
|
+
return this.emitSync(code, appendPath(id, this.builtinsPath), defu$1(options, { meta: {
|
|
2341
2342
|
type: "builtin",
|
|
2342
2343
|
id
|
|
2343
2344
|
} }));
|
|
@@ -2352,7 +2353,7 @@ var PowerlinesContext = class PowerlinesContext {
|
|
|
2352
2353
|
async emitInfrastructure(code, id, options = {}) {
|
|
2353
2354
|
if (!this.infrastructurePath) throw new Error(`The infrastructure path is not set. Cannot emit infrastructure file with id "${id}".`);
|
|
2354
2355
|
if (!isSetString(id)) throw new Error(`The infrastructure id must be a non-empty string. Received: ${String(id)}`);
|
|
2355
|
-
return this.emit(code, appendPath(id, this.infrastructurePath), defu(options, { meta: {
|
|
2356
|
+
return this.emit(code, appendPath(id, this.infrastructurePath), defu$1(options, { meta: {
|
|
2356
2357
|
type: "infrastructure",
|
|
2357
2358
|
id
|
|
2358
2359
|
} }));
|
|
@@ -2367,7 +2368,7 @@ var PowerlinesContext = class PowerlinesContext {
|
|
|
2367
2368
|
emitInfrastructureSync(code, id, options = {}) {
|
|
2368
2369
|
if (!this.infrastructurePath) throw new Error(`The infrastructure path is not set. Cannot emit infrastructure file with id "${id}".`);
|
|
2369
2370
|
if (!isSetString(id)) throw new Error(`The infrastructure id must be a non-empty string. Received: ${String(id)}`);
|
|
2370
|
-
return this.emitSync(code, appendPath(id, this.infrastructurePath), defu(options, { meta: {
|
|
2371
|
+
return this.emitSync(code, appendPath(id, this.infrastructurePath), defu$1(options, { meta: {
|
|
2371
2372
|
type: "infrastructure",
|
|
2372
2373
|
id
|
|
2373
2374
|
} }));
|
|
@@ -2450,8 +2451,8 @@ var PowerlinesContext = class PowerlinesContext {
|
|
|
2450
2451
|
* @param name - The name to use for the logger instance
|
|
2451
2452
|
* @returns A logger function
|
|
2452
2453
|
*/
|
|
2453
|
-
createLog(name
|
|
2454
|
-
return createLog(name
|
|
2454
|
+
createLog(name = null) {
|
|
2455
|
+
return (0, utils_exports.createLog)(name, {
|
|
2455
2456
|
...this.config,
|
|
2456
2457
|
logLevel: isNull(this.config.logLevel) ? "silent" : this.config.logLevel
|
|
2457
2458
|
});
|
|
@@ -2462,8 +2463,8 @@ var PowerlinesContext = class PowerlinesContext {
|
|
|
2462
2463
|
* @param name - The name to use for the extended logger instance
|
|
2463
2464
|
* @returns A logger function
|
|
2464
2465
|
*/
|
|
2465
|
-
extendLog(name
|
|
2466
|
-
return extendLog(this.log, name
|
|
2466
|
+
extendLog(name) {
|
|
2467
|
+
return (0, utils_exports.extendLog)(this.log, name);
|
|
2467
2468
|
}
|
|
2468
2469
|
/**
|
|
2469
2470
|
* Generates a checksum representing the current context state
|
|
@@ -2546,7 +2547,7 @@ var PowerlinesContext = class PowerlinesContext {
|
|
|
2546
2547
|
return ret;
|
|
2547
2548
|
}, {}) : this.config.resolve.alias : {}
|
|
2548
2549
|
});
|
|
2549
|
-
const userConfig = await loadUserConfigFile(cacheKey.root, this.workspaceConfig.workspaceRoot, this.resolver, cacheKey.command, cacheKey.mode, cacheKey.configFile, cacheKey.framework);
|
|
2550
|
+
const userConfig = await (0, config_exports.loadUserConfigFile)(cacheKey.root, this.workspaceConfig.workspaceRoot, this.resolver, cacheKey.command, cacheKey.mode, cacheKey.configFile, cacheKey.framework);
|
|
2550
2551
|
this.mergeUserConfig(userConfig.config);
|
|
2551
2552
|
configCache.set(cacheKey, {
|
|
2552
2553
|
projectJson: this.projectJson,
|
|
@@ -2557,7 +2558,7 @@ var PowerlinesContext = class PowerlinesContext {
|
|
|
2557
2558
|
});
|
|
2558
2559
|
}
|
|
2559
2560
|
config.tsconfig ??= getTsconfigFilePath(this.workspaceConfig.workspaceRoot, cacheKey.root, config.tsconfig);
|
|
2560
|
-
if (isSetObject(config)) this.resolvedConfig = mergeConfig({
|
|
2561
|
+
if (isSetObject(config)) this.resolvedConfig = (0, plugin_utils_exports.mergeConfig)({
|
|
2561
2562
|
inlineConfig: this.config.inlineConfig,
|
|
2562
2563
|
userConfig: this.config.userConfig
|
|
2563
2564
|
}, options.isHighPriority ? this.#getConfigProps(config) : {}, {
|
|
@@ -2571,7 +2572,7 @@ var PowerlinesContext = class PowerlinesContext {
|
|
|
2571
2572
|
name: this.projectJson?.name || this.packageJson?.name,
|
|
2572
2573
|
version: this.packageJson?.version,
|
|
2573
2574
|
description: this.packageJson?.description,
|
|
2574
|
-
output: mergeConfig(config.output ?? {}, {
|
|
2575
|
+
output: (0, plugin_utils_exports.mergeConfig)(config.output ?? {}, {
|
|
2575
2576
|
outputPath: cacheKey.root ? joinPaths$1(this.workspaceConfig?.directories?.build || "dist", cacheKey.root) : this.workspaceConfig?.directories?.build || "dist",
|
|
2576
2577
|
artifactsPath: `.${config.framework ?? "powerlines"}`,
|
|
2577
2578
|
dts: joinPaths$1(cacheKey.root, `${config.framework ?? "powerlines"}.d.ts`),
|
|
@@ -2599,7 +2600,7 @@ var PowerlinesContext = class PowerlinesContext {
|
|
|
2599
2600
|
environments: {},
|
|
2600
2601
|
resolve: {}
|
|
2601
2602
|
});
|
|
2602
|
-
this.config.input = getUniqueInputs(this.config.input);
|
|
2603
|
+
this.config.input = (0, utils_exports.getUniqueInputs)(this.config.input);
|
|
2603
2604
|
if (this.config.name?.startsWith("@") && this.config.name.split("/").filter(Boolean).length > 1) this.config.name = this.config.name.split("/").filter(Boolean)[1];
|
|
2604
2605
|
this.config.title ??= titleCase(this.config.name);
|
|
2605
2606
|
this.config.organization ??= (isSetObject(this.workspaceConfig.organization) ? this.workspaceConfig.organization.name : this.workspaceConfig.organization) || (isSetObject(this.packageJson?.author) ? this.packageJson?.author?.name : this.packageJson?.author) || this.config.name;
|
|
@@ -2624,231 +2625,39 @@ var PowerlinesContext = class PowerlinesContext {
|
|
|
2624
2625
|
};
|
|
2625
2626
|
}), (a) => `${a.input}-${a.glob}-${a.output}`);
|
|
2626
2627
|
this.config.plugins = (this.config.plugins ?? []).filter(Boolean).reduce((ret, plugin) => {
|
|
2627
|
-
if (isPlugin(plugin) && checkDedupe(plugin, ret.filter((p) => isPlugin(p)))) return ret;
|
|
2628
|
+
if ((0, plugin_utils_exports.isPlugin)(plugin) && (0, plugin_utils_exports.checkDedupe)(plugin, ret.filter((p) => (0, plugin_utils_exports.isPlugin)(p)))) return ret;
|
|
2628
2629
|
ret.push(plugin);
|
|
2629
2630
|
return ret;
|
|
2630
2631
|
}, []);
|
|
2631
|
-
if (this.config.tsconfig) this.config.tsconfig = replacePathTokens(this, this.config.tsconfig);
|
|
2632
|
-
if (this.config.output.dts) if (isSetString(this.config.output.dts)) this.config.output.dts = replacePathTokens(this, this.config.output.dts);
|
|
2632
|
+
if (this.config.tsconfig) this.config.tsconfig = (0, plugin_utils_exports.replacePathTokens)(this, this.config.tsconfig);
|
|
2633
|
+
if (this.config.output.dts) if (isSetString(this.config.output.dts)) this.config.output.dts = (0, plugin_utils_exports.replacePathTokens)(this, this.config.output.dts);
|
|
2633
2634
|
else this.config.output.dts = joinPaths$1(this.config.root, `${this.config.framework ?? "powerlines"}.d.ts`);
|
|
2634
2635
|
if (this.config.output.assets) this.config.output.assets = this.config.output.assets.map((asset) => ({
|
|
2635
2636
|
...asset,
|
|
2636
|
-
glob: replacePathTokens(this, asset.glob),
|
|
2637
|
-
ignore: asset.ignore ? asset.ignore.map((ignore) => replacePathTokens(this, ignore)) : void 0,
|
|
2638
|
-
input: replacePathTokens(this, asset.input),
|
|
2639
|
-
output: replacePathTokens(this, asset.output)
|
|
2637
|
+
glob: (0, plugin_utils_exports.replacePathTokens)(this, asset.glob),
|
|
2638
|
+
ignore: asset.ignore ? asset.ignore.map((ignore) => (0, plugin_utils_exports.replacePathTokens)(this, ignore)) : void 0,
|
|
2639
|
+
input: (0, plugin_utils_exports.replacePathTokens)(this, asset.input),
|
|
2640
|
+
output: (0, plugin_utils_exports.replacePathTokens)(this, asset.output)
|
|
2640
2641
|
}));
|
|
2641
2642
|
if (isSetString(config.output?.storage) && config.output.storage === "virtual" || isSetObject(config.output?.storage) && Object.values(config.output.storage).every((adapter) => adapter.preset === "virtual")) this.config.output.overwrite = true;
|
|
2642
2643
|
this.#fs ??= await VirtualFileSystem.create(this);
|
|
2643
2644
|
}
|
|
2644
2645
|
mergeUserConfig(from = {}, into = this.config.userConfig ?? {}) {
|
|
2645
|
-
this.config.userConfig = mergeConfig({ input: isSetObject(from.input) && !isRegExp(from.input) && !Array.isArray(from.input) && from.input.file ? from.input.file : isSetObject(into?.input) && !isRegExp(into.input) && !Array.isArray(into.input) && into.input.file ? into.input.file : Array.isArray(from.input) && from.input.length > 0 ? from.input : Array.isArray(into?.input) && into.input.length > 0 ? into.input : [] }, omit(from ?? {}, ["input"]), omit(into ?? {}, ["input"]));
|
|
2646
|
+
this.config.userConfig = (0, plugin_utils_exports.mergeConfig)({ input: isSetObject(from.input) && !isRegExp(from.input) && !Array.isArray(from.input) && from.input.file ? from.input.file : isSetObject(into?.input) && !isRegExp(into.input) && !Array.isArray(into.input) && into.input.file ? into.input.file : Array.isArray(from.input) && from.input.length > 0 ? from.input : Array.isArray(into?.input) && into.input.length > 0 ? into.input : [] }, omit(from ?? {}, ["input"]), omit(into ?? {}, ["input"]));
|
|
2646
2647
|
if (this.config.userConfig.output?.format) this.config.userConfig.output.format = getUnique(toArray(this.config.userConfig.output?.format));
|
|
2647
2648
|
this.config.userConfig.plugins = (this.config.userConfig.plugins ?? []).filter(Boolean).reduce((ret, plugin) => {
|
|
2648
|
-
if (isPlugin(plugin) && checkDedupe(plugin, ret.filter((p) => isPlugin(p)))) return ret;
|
|
2649
|
+
if ((0, plugin_utils_exports.isPlugin)(plugin) && (0, plugin_utils_exports.checkDedupe)(plugin, ret.filter((p) => (0, plugin_utils_exports.isPlugin)(p)))) return ret;
|
|
2649
2650
|
ret.push(plugin);
|
|
2650
2651
|
return ret;
|
|
2651
2652
|
}, []);
|
|
2652
2653
|
}
|
|
2653
2654
|
};
|
|
2654
2655
|
|
|
2655
|
-
//#endregion
|
|
2656
|
-
//#region ../core/src/lib/unplugin/helpers.ts
|
|
2657
|
-
/**
|
|
2658
|
-
* Merges a base plugin context with an unplugin context, combining their properties.
|
|
2659
|
-
*
|
|
2660
|
-
* @param contextA - The base plugin context to merge into.
|
|
2661
|
-
* @param contextB - The unplugin context to merge from.
|
|
2662
|
-
* @returns The merged context.
|
|
2663
|
-
*/
|
|
2664
|
-
function combineContexts(contextA, contextB) {
|
|
2665
|
-
return defu$1(contextA, contextB);
|
|
2666
|
-
}
|
|
2667
|
-
/**
|
|
2668
|
-
* Checks if a value is a valid UnpluginBuilderVariant.
|
|
2669
|
-
*
|
|
2670
|
-
* @param str - The value to check.
|
|
2671
|
-
* @returns True if the value is a UnpluginBuilderVariant, false otherwise.
|
|
2672
|
-
*/
|
|
2673
|
-
function isUnpluginBuilderVariant(str) {
|
|
2674
|
-
return isSetString(str) && UNPLUGIN_BUILDER_VARIANTS.includes(str);
|
|
2675
|
-
}
|
|
2676
|
-
|
|
2677
|
-
//#endregion
|
|
2678
|
-
//#region ../core/src/lib/unplugin/module-resolution.ts
|
|
2679
|
-
const VIRTUAL_MODULE_PREFIX = "__powerlines-virtual:";
|
|
2680
|
-
const VIRTUAL_MODULE_PREFIX_REGEX = /^__powerlines-virtual:/;
|
|
2681
|
-
/**
|
|
2682
|
-
* Creates the module resolution hook functions for a Powerlines unplugin plugin instance.
|
|
2683
|
-
*
|
|
2684
|
-
* @remarks
|
|
2685
|
-
* This includes the `resolveId` and `load` hooks.
|
|
2686
|
-
*
|
|
2687
|
-
* @see https://rollupjs.org/plugin-development/#resolveid
|
|
2688
|
-
* @see https://rollupjs.org/plugin-development/#load
|
|
2689
|
-
*
|
|
2690
|
-
* @param context - The plugin context.
|
|
2691
|
-
* @param options - Options for creating the module resolution functions.
|
|
2692
|
-
* @returns The module resolution hooks (`resolveId` and `load`).
|
|
2693
|
-
*/
|
|
2694
|
-
function createUnpluginModuleResolutionFunctions(context, options = {}) {
|
|
2695
|
-
const ctx = context;
|
|
2696
|
-
return {
|
|
2697
|
-
async resolveId(id, importer, opts = { isEntry: false }) {
|
|
2698
|
-
const normalizedId = id.replace(VIRTUAL_MODULE_PREFIX_REGEX, "");
|
|
2699
|
-
const normalizedImporter = importer ? importer.replace(VIRTUAL_MODULE_PREFIX_REGEX, "") : void 0;
|
|
2700
|
-
let result = await ctx.$$internal.callHook("resolveId", {
|
|
2701
|
-
sequential: true,
|
|
2702
|
-
result: "first",
|
|
2703
|
-
order: "pre"
|
|
2704
|
-
}, normalizedId, normalizedImporter, opts);
|
|
2705
|
-
if (isSetString(result)) return result;
|
|
2706
|
-
else if (isSetObject(result)) return {
|
|
2707
|
-
...result,
|
|
2708
|
-
id: result.virtual && options.prefix !== false ? `${VIRTUAL_MODULE_PREFIX}${result.id}` : result.id
|
|
2709
|
-
};
|
|
2710
|
-
result = await ctx.$$internal.callHook("resolveId", {
|
|
2711
|
-
sequential: true,
|
|
2712
|
-
result: "first",
|
|
2713
|
-
order: "normal"
|
|
2714
|
-
}, normalizedId, normalizedImporter, opts);
|
|
2715
|
-
if (isSetString(result)) return result;
|
|
2716
|
-
else if (isSetObject(result)) return {
|
|
2717
|
-
...result,
|
|
2718
|
-
id: result.virtual && options.prefix !== false ? `${VIRTUAL_MODULE_PREFIX}${result.id}` : result.id
|
|
2719
|
-
};
|
|
2720
|
-
result = await ctx.resolve(normalizedId, normalizedImporter, {
|
|
2721
|
-
isFile: true,
|
|
2722
|
-
...opts
|
|
2723
|
-
});
|
|
2724
|
-
if (isSetObject(result)) return {
|
|
2725
|
-
...result,
|
|
2726
|
-
id: result.virtual && options.prefix !== false ? `${VIRTUAL_MODULE_PREFIX}${result.id}` : result.id
|
|
2727
|
-
};
|
|
2728
|
-
result = await ctx.$$internal.callHook("resolveId", {
|
|
2729
|
-
sequential: true,
|
|
2730
|
-
result: "first",
|
|
2731
|
-
order: "post"
|
|
2732
|
-
}, normalizedId, normalizedImporter, opts);
|
|
2733
|
-
if (isSetString(result)) return result;
|
|
2734
|
-
else if (isSetObject(result)) return {
|
|
2735
|
-
...result,
|
|
2736
|
-
id: result.virtual && options.prefix !== false ? `${VIRTUAL_MODULE_PREFIX}${result.id}` : result.id
|
|
2737
|
-
};
|
|
2738
|
-
return null;
|
|
2739
|
-
},
|
|
2740
|
-
load: {
|
|
2741
|
-
filter: options.prefix !== false ? { id: { include: [VIRTUAL_MODULE_PREFIX_REGEX] } } : void 0,
|
|
2742
|
-
async handler(id) {
|
|
2743
|
-
const normalizedId = id.replace(VIRTUAL_MODULE_PREFIX_REGEX, "");
|
|
2744
|
-
let result = await ctx.$$internal.callHook("load", {
|
|
2745
|
-
sequential: true,
|
|
2746
|
-
result: "first",
|
|
2747
|
-
order: "pre"
|
|
2748
|
-
}, normalizedId);
|
|
2749
|
-
if (result) return result;
|
|
2750
|
-
result = await ctx.$$internal.callHook("load", {
|
|
2751
|
-
sequential: true,
|
|
2752
|
-
result: "first",
|
|
2753
|
-
order: "normal"
|
|
2754
|
-
}, normalizedId);
|
|
2755
|
-
if (result) return result;
|
|
2756
|
-
result = await ctx.load(normalizedId);
|
|
2757
|
-
if (result) return result;
|
|
2758
|
-
return ctx.$$internal.callHook("load", {
|
|
2759
|
-
sequential: true,
|
|
2760
|
-
result: "first",
|
|
2761
|
-
order: "post"
|
|
2762
|
-
}, normalizedId);
|
|
2763
|
-
}
|
|
2764
|
-
}
|
|
2765
|
-
};
|
|
2766
|
-
}
|
|
2767
|
-
|
|
2768
|
-
//#endregion
|
|
2769
|
-
//#region ../core/src/lib/unplugin/plugin.ts
|
|
2770
|
-
/**
|
|
2771
|
-
* Creates a Powerlines unplugin instance.
|
|
2772
|
-
*
|
|
2773
|
-
* @param context - The plugin context.
|
|
2774
|
-
* @returns The unplugin instance.
|
|
2775
|
-
*/
|
|
2776
|
-
function createUnpluginResolver(context, options = {}) {
|
|
2777
|
-
const ctx = context;
|
|
2778
|
-
setParseImpl(ctx.parse);
|
|
2779
|
-
const name$1 = options.name || "unplugin";
|
|
2780
|
-
return () => {
|
|
2781
|
-
const log = extendLog(ctx.log, name$1);
|
|
2782
|
-
log(LogLevelLabel.DEBUG, `Initializing ${name$1.toLowerCase() === "unplugin" ? "Unplugin" : `${titleCase(name$1)} - Unplugin`} plugin`);
|
|
2783
|
-
try {
|
|
2784
|
-
const { resolveId, load } = createUnpluginModuleResolutionFunctions(context, options);
|
|
2785
|
-
return {
|
|
2786
|
-
name: name$1.toLowerCase() === "unplugin" ? "powerlines" : `powerlines:${kebabCase(name$1)}`,
|
|
2787
|
-
api: ctx.$$internal.api,
|
|
2788
|
-
resolveId,
|
|
2789
|
-
load
|
|
2790
|
-
};
|
|
2791
|
-
} catch (error) {
|
|
2792
|
-
log(LogLevelLabel.FATAL, error?.message);
|
|
2793
|
-
throw error;
|
|
2794
|
-
}
|
|
2795
|
-
};
|
|
2796
|
-
}
|
|
2797
|
-
/**
|
|
2798
|
-
* Creates a Powerlines unplugin instance.
|
|
2799
|
-
*
|
|
2800
|
-
* @param context - The plugin context.
|
|
2801
|
-
* @returns The unplugin instance.
|
|
2802
|
-
*/
|
|
2803
|
-
function createUnplugin(context, options = {}) {
|
|
2804
|
-
const ctx = context;
|
|
2805
|
-
setParseImpl(ctx.parse);
|
|
2806
|
-
const name$1 = options.name || "unplugin";
|
|
2807
|
-
return () => {
|
|
2808
|
-
const log = extendLog(ctx.log, name$1);
|
|
2809
|
-
log(LogLevelLabel.DEBUG, `Initializing ${name$1.toLowerCase() === "unplugin" ? "Unplugin" : `${titleCase(name$1)} - Unplugin`} plugin`);
|
|
2810
|
-
try {
|
|
2811
|
-
const { resolveId, load } = createUnpluginModuleResolutionFunctions(context, options);
|
|
2812
|
-
async function buildStart() {
|
|
2813
|
-
log(LogLevelLabel.DEBUG, "Powerlines build plugin starting...");
|
|
2814
|
-
await ctx.$$internal.callHook("buildStart", { sequential: true });
|
|
2815
|
-
}
|
|
2816
|
-
async function transform(code, id) {
|
|
2817
|
-
let transformed = code;
|
|
2818
|
-
for (const hook of ctx.$$internal.environment.selectHooks("transform")) {
|
|
2819
|
-
const result = await hook.handler.apply(combineContexts(ctx, this), [getString(transformed), id]);
|
|
2820
|
-
if (result) transformed = result;
|
|
2821
|
-
}
|
|
2822
|
-
return transformed;
|
|
2823
|
-
}
|
|
2824
|
-
async function buildEnd() {
|
|
2825
|
-
log(LogLevelLabel.DEBUG, "Powerlines build plugin finishing...");
|
|
2826
|
-
return ctx.$$internal.callHook("buildEnd", { sequential: true });
|
|
2827
|
-
}
|
|
2828
|
-
async function writeBundle() {
|
|
2829
|
-
log(LogLevelLabel.DEBUG, "Finalizing Powerlines project output...");
|
|
2830
|
-
return ctx.$$internal.callHook("writeBundle", { sequential: true });
|
|
2831
|
-
}
|
|
2832
|
-
return {
|
|
2833
|
-
name: name$1.toLowerCase() === "unplugin" ? "powerlines" : `powerlines:${kebabCase(name$1)}`,
|
|
2834
|
-
api: ctx.$$internal.api,
|
|
2835
|
-
resolveId,
|
|
2836
|
-
load,
|
|
2837
|
-
transform,
|
|
2838
|
-
buildStart,
|
|
2839
|
-
buildEnd,
|
|
2840
|
-
writeBundle,
|
|
2841
|
-
vite: { sharedDuringBuild: true }
|
|
2842
|
-
};
|
|
2843
|
-
} catch (error) {
|
|
2844
|
-
log(LogLevelLabel.FATAL, error?.message);
|
|
2845
|
-
throw error;
|
|
2846
|
-
}
|
|
2847
|
-
};
|
|
2848
|
-
}
|
|
2849
|
-
|
|
2850
2656
|
//#endregion
|
|
2851
2657
|
//#region src/unplugin.ts
|
|
2658
|
+
var unplugin_exports = /* @__PURE__ */ __exportAll({ createUnpluginFactory: () => createUnpluginFactory });
|
|
2659
|
+
import * as import__powerlines_core_lib_unplugin from "@powerlines/core/lib/unplugin";
|
|
2660
|
+
__reExport(unplugin_exports, import__powerlines_core_lib_unplugin);
|
|
2852
2661
|
/**
|
|
2853
2662
|
* Creates a Powerlines unplugin factory that generates a plugin instance.
|
|
2854
2663
|
*
|
|
@@ -2874,23 +2683,23 @@ function createUnpluginFactory(variant, decorate) {
|
|
|
2874
2683
|
log(LogLevelLabel.DEBUG, "Preparing build artifacts for the Powerlines project...");
|
|
2875
2684
|
await api.prepare({ command: "build" });
|
|
2876
2685
|
}
|
|
2877
|
-
async function resolveId(id, importer, options
|
|
2878
|
-
return api.context.resolve(id, importer, options
|
|
2686
|
+
async function resolveId(id, importer, options = { isEntry: false }) {
|
|
2687
|
+
return api.context.resolve(id, importer, options);
|
|
2879
2688
|
}
|
|
2880
2689
|
async function load(id) {
|
|
2881
2690
|
const environment = await api.context.getEnvironment();
|
|
2882
|
-
let result
|
|
2691
|
+
let result = await api.callHook("load", {
|
|
2883
2692
|
environment,
|
|
2884
2693
|
order: "pre"
|
|
2885
2694
|
}, id);
|
|
2886
|
-
if (result
|
|
2887
|
-
result
|
|
2695
|
+
if (result) return result;
|
|
2696
|
+
result = await api.callHook("load", {
|
|
2888
2697
|
environment,
|
|
2889
2698
|
order: "normal"
|
|
2890
2699
|
}, id);
|
|
2891
|
-
if (result
|
|
2892
|
-
result
|
|
2893
|
-
if (result
|
|
2700
|
+
if (result) return result;
|
|
2701
|
+
result = await environment.load(id);
|
|
2702
|
+
if (result) return result;
|
|
2894
2703
|
return api.callHook("load", {
|
|
2895
2704
|
environment,
|
|
2896
2705
|
order: "post"
|
|
@@ -3054,19 +2863,19 @@ var PowerlinesEnvironmentContext = class PowerlinesEnvironmentContext extends Po
|
|
|
3054
2863
|
if (isFunction(plugin.applyToEnvironment)) {
|
|
3055
2864
|
const result = await Promise.resolve(plugin.applyToEnvironment(this.environment));
|
|
3056
2865
|
if (!result || isObject(result) && Object.keys(result).length === 0) return;
|
|
3057
|
-
if (isPluginConfig(result)) return this.$$internal.addPlugin(result);
|
|
3058
|
-
resolvedPlugin = isPlugin(result) ? result : plugin;
|
|
2866
|
+
if ((0, plugin_utils_exports.isPluginConfig)(result)) return this.$$internal.addPlugin(result);
|
|
2867
|
+
resolvedPlugin = (0, plugin_utils_exports.isPlugin)(result) ? result : plugin;
|
|
3059
2868
|
}
|
|
3060
2869
|
const context = createPluginContext(resolvedPlugin, this);
|
|
3061
2870
|
this.plugins.push({
|
|
3062
2871
|
plugin: resolvedPlugin,
|
|
3063
2872
|
context
|
|
3064
2873
|
});
|
|
3065
|
-
this.#hooks = Object.keys(resolvedPlugin).filter((key) => !PLUGIN_NON_HOOK_FIELDS.includes(key)).reduce((ret, key) => {
|
|
2874
|
+
this.#hooks = Object.keys(resolvedPlugin).filter((key) => !constants_exports.PLUGIN_NON_HOOK_FIELDS.includes(key)).reduce((ret, key) => {
|
|
3066
2875
|
const hook = key;
|
|
3067
|
-
if (isPluginHookField(hook)) {
|
|
2876
|
+
if ((0, plugin_utils_exports.isPluginHookField)(hook)) {
|
|
3068
2877
|
const pluginHook = resolvedPlugin[hook];
|
|
3069
|
-
if (!isPluginHook(pluginHook)) return ret;
|
|
2878
|
+
if (!(0, plugin_utils_exports.isPluginHook)(pluginHook)) return ret;
|
|
3070
2879
|
ret[hook] ??= {
|
|
3071
2880
|
preEnforced: [],
|
|
3072
2881
|
preOrdered: [],
|
|
@@ -3075,29 +2884,29 @@ var PowerlinesEnvironmentContext = class PowerlinesEnvironmentContext extends Po
|
|
|
3075
2884
|
postOrdered: []
|
|
3076
2885
|
};
|
|
3077
2886
|
if (resolvedPlugin.enforce) {
|
|
3078
|
-
const hookListOrder
|
|
3079
|
-
ret[hook][hookListOrder
|
|
3080
|
-
const bucket = ret[hook][hookListOrder
|
|
3081
|
-
addPluginHook(context, resolvedPlugin, pluginHook, bucket);
|
|
2887
|
+
const hookListOrder = `${resolvedPlugin.enforce}Enforced`;
|
|
2888
|
+
ret[hook][hookListOrder] ??= [];
|
|
2889
|
+
const bucket = ret[hook][hookListOrder];
|
|
2890
|
+
(0, plugin_utils_exports.addPluginHook)(context, resolvedPlugin, pluginHook, bucket);
|
|
3082
2891
|
return ret;
|
|
3083
2892
|
}
|
|
3084
2893
|
if (isFunction(pluginHook) || !pluginHook.order) {
|
|
3085
2894
|
ret[hook].normal ??= [];
|
|
3086
2895
|
const bucket = ret[hook].normal;
|
|
3087
|
-
addPluginHook(context, resolvedPlugin, pluginHook, bucket);
|
|
2896
|
+
(0, plugin_utils_exports.addPluginHook)(context, resolvedPlugin, pluginHook, bucket);
|
|
3088
2897
|
return ret;
|
|
3089
2898
|
}
|
|
3090
2899
|
const hookListOrder = `${pluginHook.order}Ordered`;
|
|
3091
2900
|
ret[hook][hookListOrder] ??= [];
|
|
3092
|
-
addPluginHook(context, resolvedPlugin, pluginHook, ret[hook][hookListOrder]);
|
|
2901
|
+
(0, plugin_utils_exports.addPluginHook)(context, resolvedPlugin, pluginHook, ret[hook][hookListOrder]);
|
|
3093
2902
|
return ret;
|
|
3094
|
-
} else if (isUnpluginHookField(hook)) {
|
|
2903
|
+
} else if ((0, plugin_utils_exports.isUnpluginHookField)(hook)) {
|
|
3095
2904
|
const unpluginPlugin = resolvedPlugin[hook];
|
|
3096
2905
|
if (!isSetObject(unpluginPlugin)) return ret;
|
|
3097
2906
|
for (const field of Object.keys(unpluginPlugin)) {
|
|
3098
2907
|
const variantField = field;
|
|
3099
2908
|
const pluginHook = unpluginPlugin[variantField];
|
|
3100
|
-
if (!isPluginHook(pluginHook)) continue;
|
|
2909
|
+
if (!(0, plugin_utils_exports.isPluginHook)(pluginHook)) continue;
|
|
3101
2910
|
ret[hook] ??= {};
|
|
3102
2911
|
ret[hook][variantField] ??= {
|
|
3103
2912
|
preEnforced: [],
|
|
@@ -3107,14 +2916,14 @@ var PowerlinesEnvironmentContext = class PowerlinesEnvironmentContext extends Po
|
|
|
3107
2916
|
postOrdered: []
|
|
3108
2917
|
};
|
|
3109
2918
|
if (resolvedPlugin.enforce) {
|
|
3110
|
-
addPluginHook(context, resolvedPlugin, pluginHook, ret[hook][variantField][`${resolvedPlugin.enforce}Enforced`]);
|
|
2919
|
+
(0, plugin_utils_exports.addPluginHook)(context, resolvedPlugin, pluginHook, ret[hook][variantField][`${resolvedPlugin.enforce}Enforced`]);
|
|
3111
2920
|
return ret;
|
|
3112
2921
|
}
|
|
3113
2922
|
if (isFunction(pluginHook) || !pluginHook.order) {
|
|
3114
|
-
addPluginHook(context, resolvedPlugin, pluginHook, ret[hook][variantField].normal);
|
|
2923
|
+
(0, plugin_utils_exports.addPluginHook)(context, resolvedPlugin, pluginHook, ret[hook][variantField].normal);
|
|
3115
2924
|
return ret;
|
|
3116
2925
|
}
|
|
3117
|
-
addPluginHook(context, resolvedPlugin, pluginHook, ret[hook][variantField][`${pluginHook.order}Ordered`]);
|
|
2926
|
+
(0, plugin_utils_exports.addPluginHook)(context, resolvedPlugin, pluginHook, ret[hook][variantField][`${pluginHook.order}Ordered`]);
|
|
3118
2927
|
}
|
|
3119
2928
|
} else this.warn(`Unknown plugin hook field: ${String(hook)}`);
|
|
3120
2929
|
return ret;
|
|
@@ -3125,9 +2934,9 @@ var PowerlinesEnvironmentContext = class PowerlinesEnvironmentContext extends Po
|
|
|
3125
2934
|
*/
|
|
3126
2935
|
selectHooks(key, options) {
|
|
3127
2936
|
const result = [];
|
|
3128
|
-
if (isUnpluginHookKey(key)) {
|
|
2937
|
+
if ((0, plugin_utils_exports.isUnpluginHookKey)(key)) {
|
|
3129
2938
|
const variant = String(key).split(":")[0];
|
|
3130
|
-
if (isUnpluginBuilderVariant(variant)) {
|
|
2939
|
+
if ((0, unplugin_exports.isUnpluginBuilderVariant)(variant)) {
|
|
3131
2940
|
const hooks = this.hooks[variant];
|
|
3132
2941
|
if (hooks) {
|
|
3133
2942
|
const field = String(key).split(":")[1];
|
|
@@ -3158,7 +2967,7 @@ var PowerlinesEnvironmentContext = class PowerlinesEnvironmentContext extends Po
|
|
|
3158
2967
|
}
|
|
3159
2968
|
}
|
|
3160
2969
|
}
|
|
3161
|
-
} else if (isPluginHookField(key)) {
|
|
2970
|
+
} else if ((0, plugin_utils_exports.isPluginHookField)(key)) {
|
|
3162
2971
|
if (this.hooks[key]) {
|
|
3163
2972
|
const fieldHooks = this.hooks[key];
|
|
3164
2973
|
if (options?.order) {
|
|
@@ -3207,7 +3016,7 @@ var PowerlinesAPIContext = class PowerlinesAPIContext extends PowerlinesContext
|
|
|
3207
3016
|
* @returns A promise that resolves to the new context.
|
|
3208
3017
|
*/
|
|
3209
3018
|
static async from(workspaceRoot, config) {
|
|
3210
|
-
const context = new PowerlinesAPIContext(await loadWorkspaceConfig(workspaceRoot, config.root));
|
|
3019
|
+
const context = new PowerlinesAPIContext(await (0, config_exports.loadWorkspaceConfig)(workspaceRoot, config.root));
|
|
3211
3020
|
await context.withUserConfig(config);
|
|
3212
3021
|
const powerlinesPath = await resolvePackage("powerlines");
|
|
3213
3022
|
if (!powerlinesPath) throw new Error("Could not resolve `powerlines` package location.");
|
|
@@ -3260,7 +3069,7 @@ var PowerlinesAPIContext = class PowerlinesAPIContext extends PowerlinesContext
|
|
|
3260
3069
|
*/
|
|
3261
3070
|
async init(config = {}) {
|
|
3262
3071
|
await super.init(config);
|
|
3263
|
-
await Promise.all(toArray(this.config.userConfig.environments && Object.keys(this.config.userConfig.environments).length > 0 ? Object.keys(this.config.userConfig.environments).map((name
|
|
3072
|
+
await Promise.all(toArray(this.config.userConfig.environments && Object.keys(this.config.userConfig.environments).length > 0 ? Object.keys(this.config.userConfig.environments).map((name) => createEnvironment(name, this.config.userConfig)) : createDefaultEnvironment(this.config.userConfig)).map(async (env) => {
|
|
3264
3073
|
this.#environments[env.name] = await this.in(env);
|
|
3265
3074
|
}));
|
|
3266
3075
|
}
|
|
@@ -3287,8 +3096,8 @@ var PowerlinesAPIContext = class PowerlinesAPIContext extends PowerlinesContext
|
|
|
3287
3096
|
*/
|
|
3288
3097
|
async withUserConfig(userConfig, options = { isHighPriority: true }) {
|
|
3289
3098
|
await super.withUserConfig(userConfig, options);
|
|
3290
|
-
await Promise.all(Object.keys(this.#environments).map(async (name
|
|
3291
|
-
await this.#environments[name
|
|
3099
|
+
await Promise.all(Object.keys(this.#environments).map(async (name) => {
|
|
3100
|
+
await this.#environments[name].withUserConfig(userConfig, options);
|
|
3292
3101
|
}));
|
|
3293
3102
|
}
|
|
3294
3103
|
/**
|
|
@@ -3298,8 +3107,8 @@ var PowerlinesAPIContext = class PowerlinesAPIContext extends PowerlinesContext
|
|
|
3298
3107
|
*/
|
|
3299
3108
|
async withInlineConfig(inlineConfig, options = { isHighPriority: true }) {
|
|
3300
3109
|
await super.withInlineConfig(inlineConfig, options);
|
|
3301
|
-
await Promise.all(Object.keys(this.#environments).map(async (name
|
|
3302
|
-
await this.#environments[name
|
|
3110
|
+
await Promise.all(Object.keys(this.#environments).map(async (name) => {
|
|
3111
|
+
await this.#environments[name].withInlineConfig(inlineConfig, options);
|
|
3303
3112
|
}));
|
|
3304
3113
|
}
|
|
3305
3114
|
/**
|
|
@@ -3309,8 +3118,8 @@ var PowerlinesAPIContext = class PowerlinesAPIContext extends PowerlinesContext
|
|
|
3309
3118
|
*/
|
|
3310
3119
|
async addPlugin(plugin) {
|
|
3311
3120
|
this.plugins.push(plugin);
|
|
3312
|
-
await Promise.all(Object.keys(this.environments).map(async (name
|
|
3313
|
-
await this.environments[name
|
|
3121
|
+
await Promise.all(Object.keys(this.environments).map(async (name) => {
|
|
3122
|
+
await this.environments[name].addPlugin(plugin);
|
|
3314
3123
|
}));
|
|
3315
3124
|
}
|
|
3316
3125
|
/**
|
|
@@ -3319,15 +3128,15 @@ var PowerlinesAPIContext = class PowerlinesAPIContext extends PowerlinesContext
|
|
|
3319
3128
|
* @param name - The name of the environment to retrieve.
|
|
3320
3129
|
* @returns The requested environment context.
|
|
3321
3130
|
*/
|
|
3322
|
-
async getEnvironment(name
|
|
3131
|
+
async getEnvironment(name) {
|
|
3323
3132
|
let environment;
|
|
3324
|
-
if (name
|
|
3133
|
+
if (name) environment = this.environments[name];
|
|
3325
3134
|
if (Object.keys(this.environments).length === 1) {
|
|
3326
3135
|
environment = this.environments[Object.keys(this.environments)[0]];
|
|
3327
3136
|
this.debug(`Applying the only configured environment: ${chalk.bold.cyanBright(environment?.environment.name)}`);
|
|
3328
3137
|
}
|
|
3329
3138
|
if (!environment) {
|
|
3330
|
-
if (name
|
|
3139
|
+
if (name) throw new Error(`Environment "${name}" not found.`);
|
|
3331
3140
|
environment = await this.in(createDefaultEnvironment(this.config.userConfig));
|
|
3332
3141
|
this.warn(`No environment specified, and no default environment found. Using a temporary default environment: ${chalk.bold.cyanBright(environment?.environment.name)}`);
|
|
3333
3142
|
}
|
|
@@ -3339,9 +3148,9 @@ var PowerlinesAPIContext = class PowerlinesAPIContext extends PowerlinesContext
|
|
|
3339
3148
|
* @param name - The name of the environment to retrieve.
|
|
3340
3149
|
* @returns The requested environment context or `undefined` if not found.
|
|
3341
3150
|
*/
|
|
3342
|
-
async getEnvironmentSafe(name
|
|
3151
|
+
async getEnvironmentSafe(name) {
|
|
3343
3152
|
try {
|
|
3344
|
-
return await this.getEnvironment(name
|
|
3153
|
+
return await this.getEnvironment(name);
|
|
3345
3154
|
} catch {
|
|
3346
3155
|
return;
|
|
3347
3156
|
}
|
|
@@ -3357,7 +3166,7 @@ var PowerlinesAPIContext = class PowerlinesAPIContext extends PowerlinesContext
|
|
|
3357
3166
|
async toEnvironment() {
|
|
3358
3167
|
let environment;
|
|
3359
3168
|
if (Object.keys(this.environments).length > 1) {
|
|
3360
|
-
environment = await this.in(createEnvironment(GLOBAL_ENVIRONMENT, this.config.userConfig));
|
|
3169
|
+
environment = await this.in(createEnvironment(constants_exports.GLOBAL_ENVIRONMENT, this.config.userConfig));
|
|
3361
3170
|
this.debug(`Combined all ${Object.keys(this.environments).length} environments into a single global context.`);
|
|
3362
3171
|
} else environment = await this.getEnvironment();
|
|
3363
3172
|
return environment;
|
|
@@ -3523,7 +3332,7 @@ var PowerlinesAPI = class PowerlinesAPI {
|
|
|
3523
3332
|
}
|
|
3524
3333
|
if (isSetString(types?.trim()) || directives.length > 0) await context.fs.write(context.dtsPath, `${directives.length > 0 ? `${directives.map((directive) => `/// <reference types="${directive}" />`).join("\n")}
|
|
3525
3334
|
|
|
3526
|
-
` : ""}${getTypescriptFileHeader(context, {
|
|
3335
|
+
` : ""}${(0, utils_exports.getTypescriptFileHeader)(context, {
|
|
3527
3336
|
directive: null,
|
|
3528
3337
|
prettierIgnore: false
|
|
3529
3338
|
})}
|
|
@@ -3542,7 +3351,7 @@ ${formatTypes(types)}
|
|
|
3542
3351
|
context.tsconfig = getParsedTypeScriptConfig(context.workspaceConfig.workspaceRoot, context.config.root, context.config.tsconfig);
|
|
3543
3352
|
if (!context.tsconfig) throw new Error("Failed to parse the TypeScript configuration file.");
|
|
3544
3353
|
this.context.debug("Formatting files generated during the prepare step.");
|
|
3545
|
-
await Promise.all([formatFolder(context, context.builtinsPath), formatFolder(context, context.entryPath)]);
|
|
3354
|
+
await Promise.all([(0, utils_exports.formatFolder)(context, context.builtinsPath), (0, utils_exports.formatFolder)(context, context.entryPath)]);
|
|
3546
3355
|
await writeMetaFile(context);
|
|
3547
3356
|
context.persistedMeta = context.meta;
|
|
3548
3357
|
});
|
|
@@ -3577,15 +3386,15 @@ ${formatTypes(types)}
|
|
|
3577
3386
|
order: "normal"
|
|
3578
3387
|
});
|
|
3579
3388
|
if (context.config.projectType === "application") {
|
|
3580
|
-
const files
|
|
3581
|
-
for (const file of files
|
|
3389
|
+
const files = await listFiles(joinPaths(context.powerlinesPath, "files/application/**/*.hbs"));
|
|
3390
|
+
for (const file of files) {
|
|
3582
3391
|
context.trace(`Adding application template file: ${file}`);
|
|
3583
3392
|
const template = Handlebars.compile(file);
|
|
3584
3393
|
await context.fs.write(joinPaths(context.config.root, file.replace(".hbs", "")), template(context));
|
|
3585
3394
|
}
|
|
3586
3395
|
} else {
|
|
3587
|
-
const files
|
|
3588
|
-
for (const file of files
|
|
3396
|
+
const files = await listFiles(joinPaths(context.powerlinesPath, "files/library/**/*.hbs"));
|
|
3397
|
+
for (const file of files) {
|
|
3589
3398
|
context.trace(`Adding library template file: ${file}`);
|
|
3590
3399
|
const template = Handlebars.compile(file);
|
|
3591
3400
|
await context.fs.write(joinPaths(context.config.root, file.replace(".hbs", "")), template(context));
|
|
@@ -3672,8 +3481,8 @@ ${formatTypes(types)}
|
|
|
3672
3481
|
await this.#executeEnvironments(async (context) => {
|
|
3673
3482
|
context.debug("Writing documentation for the Powerlines project artifacts.");
|
|
3674
3483
|
await this.prepare(inlineConfig);
|
|
3675
|
-
await this.#executeEnvironments(async (context
|
|
3676
|
-
await this.callHook("docs", { environment: context
|
|
3484
|
+
await this.#executeEnvironments(async (context) => {
|
|
3485
|
+
await this.callHook("docs", { environment: context });
|
|
3677
3486
|
});
|
|
3678
3487
|
});
|
|
3679
3488
|
this.context.debug("✔ Powerlines documentation generation completed successfully");
|
|
@@ -3742,7 +3551,7 @@ ${formatTypes(types)}
|
|
|
3742
3551
|
order: "pre"
|
|
3743
3552
|
});
|
|
3744
3553
|
context.debug("Formatting the generated entry files before the build process starts.");
|
|
3745
|
-
await formatFolder(context, context.entryPath);
|
|
3554
|
+
await (0, utils_exports.formatFolder)(context, context.entryPath);
|
|
3746
3555
|
await this.callHook("build", {
|
|
3747
3556
|
environment: context,
|
|
3748
3557
|
order: "normal"
|
|
@@ -3775,12 +3584,12 @@ ${formatTypes(types)}
|
|
|
3775
3584
|
return [await this.context.getEnvironment()];
|
|
3776
3585
|
}
|
|
3777
3586
|
this.context.debug(`Found ${Object.keys(this.context.config.environments).length} configured environment(s) for this Powerlines project.`);
|
|
3778
|
-
return (await Promise.all(Object.entries(this.context.config.environments).map(async ([name
|
|
3779
|
-
if (!await this.context.getEnvironmentSafe(name
|
|
3780
|
-
const resolvedEnvironment = await this.callHook("configEnvironment", { environment: name
|
|
3781
|
-
if (resolvedEnvironment) this.context.environments[name
|
|
3587
|
+
return (await Promise.all(Object.entries(this.context.config.environments).map(async ([name, config]) => {
|
|
3588
|
+
if (!await this.context.getEnvironmentSafe(name)) {
|
|
3589
|
+
const resolvedEnvironment = await this.callHook("configEnvironment", { environment: name }, name, config);
|
|
3590
|
+
if (resolvedEnvironment) this.context.environments[name] = await this.context.in(resolvedEnvironment);
|
|
3782
3591
|
}
|
|
3783
|
-
return this.context.environments[name
|
|
3592
|
+
return this.context.environments[name];
|
|
3784
3593
|
}))).filter((context) => isSet(context));
|
|
3785
3594
|
}
|
|
3786
3595
|
/**
|
|
@@ -3818,28 +3627,28 @@ ${formatTypes(types)}
|
|
|
3818
3627
|
async #initPlugin(config) {
|
|
3819
3628
|
let awaited = config;
|
|
3820
3629
|
if (isPromiseLike(config)) awaited = await Promise.resolve(config);
|
|
3821
|
-
if (!isPluginConfig(awaited)) {
|
|
3822
|
-
const invalid = findInvalidPluginConfig(awaited);
|
|
3630
|
+
if (!(0, plugin_utils_exports.isPluginConfig)(awaited)) {
|
|
3631
|
+
const invalid = (0, plugin_utils_exports.findInvalidPluginConfig)(awaited);
|
|
3823
3632
|
throw new Error(`Invalid ${invalid && invalid.length > 1 ? "plugins" : "plugin"} specified in the configuration - ${invalid && invalid.length > 0 ? JSON.stringify(awaited) : invalid?.join("\n\n")} \n\nPlease ensure the value is one of the following: \n - an instance of \`Plugin\` \n - a plugin name \n - an object with the \`plugin\` and \`options\` properties \n - a tuple array with the plugin and options \n - a factory function that returns a plugin or array of plugins \n - an array of plugins or plugin configurations`);
|
|
3824
3633
|
}
|
|
3825
3634
|
let plugins;
|
|
3826
|
-
if (isPlugin(awaited)) plugins = [awaited];
|
|
3635
|
+
if ((0, plugin_utils_exports.isPlugin)(awaited)) plugins = [awaited];
|
|
3827
3636
|
else if (isFunction(awaited)) plugins = toArray(await Promise.resolve(awaited()));
|
|
3828
3637
|
else if (isString(awaited)) {
|
|
3829
3638
|
const resolved = await this.#resolvePlugin(awaited);
|
|
3830
3639
|
if (isFunction(resolved)) plugins = toArray(await Promise.resolve(resolved()));
|
|
3831
3640
|
else plugins = toArray(resolved);
|
|
3832
|
-
} else if (Array.isArray(awaited) && awaited.every(isPlugin)) plugins = awaited;
|
|
3833
|
-
else if (Array.isArray(awaited) && awaited.every(isPluginConfig)) {
|
|
3641
|
+
} else if (Array.isArray(awaited) && awaited.every(plugin_utils_exports.isPlugin)) plugins = awaited;
|
|
3642
|
+
else if (Array.isArray(awaited) && awaited.every(plugin_utils_exports.isPluginConfig)) {
|
|
3834
3643
|
plugins = [];
|
|
3835
3644
|
for (const pluginConfig of awaited) {
|
|
3836
3645
|
const initialized = await this.#initPlugin(pluginConfig);
|
|
3837
3646
|
if (initialized) plugins.push(...initialized);
|
|
3838
3647
|
}
|
|
3839
|
-
} else if (isPluginConfigTuple(awaited) || isPluginConfigObject(awaited)) {
|
|
3648
|
+
} else if ((0, plugin_utils_exports.isPluginConfigTuple)(awaited) || (0, plugin_utils_exports.isPluginConfigObject)(awaited)) {
|
|
3840
3649
|
let pluginConfig;
|
|
3841
3650
|
let pluginOptions;
|
|
3842
|
-
if (isPluginConfigTuple(awaited)) {
|
|
3651
|
+
if ((0, plugin_utils_exports.isPluginConfigTuple)(awaited)) {
|
|
3843
3652
|
pluginConfig = awaited[0];
|
|
3844
3653
|
pluginOptions = awaited?.length === 2 ? awaited[1] : void 0;
|
|
3845
3654
|
} else {
|
|
@@ -3851,13 +3660,13 @@ ${formatTypes(types)}
|
|
|
3851
3660
|
if (isFunction(resolved)) plugins = toArray(await Promise.resolve(pluginOptions ? resolved(pluginOptions) : resolved()));
|
|
3852
3661
|
else plugins = toArray(resolved);
|
|
3853
3662
|
} else if (isFunction(pluginConfig)) plugins = toArray(await Promise.resolve(pluginConfig(pluginOptions)));
|
|
3854
|
-
else if (Array.isArray(pluginConfig) && pluginConfig.every(isPlugin)) plugins = pluginConfig;
|
|
3855
|
-
else if (isPlugin(pluginConfig)) plugins = toArray(pluginConfig);
|
|
3663
|
+
else if (Array.isArray(pluginConfig) && pluginConfig.every(plugin_utils_exports.isPlugin)) plugins = pluginConfig;
|
|
3664
|
+
else if ((0, plugin_utils_exports.isPlugin)(pluginConfig)) plugins = toArray(pluginConfig);
|
|
3856
3665
|
}
|
|
3857
3666
|
if (!plugins) throw new Error(`The plugin configuration ${JSON.stringify(awaited)} is invalid. This configuration must point to a valid Powerlines plugin module.`);
|
|
3858
|
-
if (plugins.length > 0 && !plugins.every(isPlugin)) throw new Error(`The plugin option ${JSON.stringify(plugins)} does not export a valid module. This configuration must point to a valid Powerlines plugin module.`);
|
|
3667
|
+
if (plugins.length > 0 && !plugins.every(plugin_utils_exports.isPlugin)) throw new Error(`The plugin option ${JSON.stringify(plugins)} does not export a valid module. This configuration must point to a valid Powerlines plugin module.`);
|
|
3859
3668
|
const result = [];
|
|
3860
|
-
for (const plugin of plugins) if (checkDedupe(plugin, this.context.plugins)) this.context.trace(`Duplicate ${chalk.bold.cyanBright(plugin.name)} plugin dependency detected - Skipping initialization.`);
|
|
3669
|
+
for (const plugin of plugins) if ((0, plugin_utils_exports.checkDedupe)(plugin, this.context.plugins)) this.context.trace(`Duplicate ${chalk.bold.cyanBright(plugin.name)} plugin dependency detected - Skipping initialization.`);
|
|
3861
3670
|
else {
|
|
3862
3671
|
result.push(plugin);
|
|
3863
3672
|
this.context.trace(`Initializing the ${chalk.bold.cyanBright(plugin.name)} plugin...`);
|
|
@@ -3901,5 +3710,5 @@ Note: Please ensure the plugin package's default export is a class that extends
|
|
|
3901
3710
|
};
|
|
3902
3711
|
|
|
3903
3712
|
//#endregion
|
|
3904
|
-
export {
|
|
3905
|
-
//# sourceMappingURL=api-
|
|
3713
|
+
export { createUnpluginFactory as a, FileMetadata as c, FileSystem as d, _capnpFileId as f, createPluginContext as i, FileMetadata_KeyValuePair as l, version as m, PowerlinesAPIContext as n, PowerlinesContext as o, name as p, PowerlinesEnvironmentContext as r, FileId as s, PowerlinesAPI as t, FileStorage as u };
|
|
3714
|
+
//# sourceMappingURL=api-6f2oVwGy.mjs.map
|