@powerlines/core 0.48.45 → 0.48.47
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/constants/log-level.d.cts +1 -1
- package/dist/constants/log-level.d.mts +1 -1
- package/dist/context/context.mjs.map +1 -1
- package/dist/context/environment-context.mjs.map +1 -1
- package/dist/context/execution-context.mjs.map +1 -1
- package/dist/context/plugin-context.mjs.map +1 -1
- package/dist/lib/config.mjs.map +1 -1
- package/dist/lib/context-helpers.d.cts +4 -4
- package/dist/lib/context-helpers.d.mts +4 -4
- package/dist/lib/context-helpers.mjs.map +1 -1
- package/dist/lib/entry.mjs.map +1 -1
- package/dist/lib/environment.mjs.map +1 -1
- package/dist/lib/events.mjs.map +1 -1
- package/dist/lib/generate-types.mjs.map +1 -1
- package/dist/lib/hooks.mjs.map +1 -1
- package/dist/lib/install-dependencies.mjs.map +1 -1
- package/dist/lib/plugins.mjs.map +1 -1
- package/dist/lib/typescript/ts-morph.mjs.map +1 -1
- package/dist/lib/typescript/tsconfig.mjs.map +1 -1
- package/dist/lib/utilities/file-header.mjs.map +1 -1
- package/dist/lib/utilities/format.mjs.map +1 -1
- package/dist/lib/vfs.mjs.map +1 -1
- package/dist/plugin-base.mjs.map +1 -1
- package/dist/plugin-utils/build-helpers.mjs.map +1 -1
- package/dist/plugin-utils/combine-plugins.mjs.map +1 -1
- package/dist/plugin-utils/context-helpers.cjs +25 -0
- package/dist/plugin-utils/context-helpers.d.cts +9 -1
- package/dist/plugin-utils/context-helpers.d.cts.map +1 -1
- package/dist/plugin-utils/context-helpers.d.mts +9 -1
- package/dist/plugin-utils/context-helpers.d.mts.map +1 -1
- package/dist/plugin-utils/context-helpers.mjs +25 -1
- package/dist/plugin-utils/context-helpers.mjs.map +1 -1
- package/dist/plugin-utils/enable-plugin.mjs.map +1 -1
- package/dist/plugin-utils/extend.mjs.map +1 -1
- package/dist/plugin-utils/filter.mjs.map +1 -1
- package/dist/plugin-utils/format.mjs.map +1 -1
- package/dist/plugin-utils/helpers.d.cts +1 -1
- package/dist/plugin-utils/helpers.d.mts +1 -1
- package/dist/plugin-utils/helpers.mjs.map +1 -1
- package/dist/plugin-utils/index.cjs +1 -0
- package/dist/plugin-utils/index.d.cts +2 -2
- package/dist/plugin-utils/index.d.mts +2 -2
- package/dist/plugin-utils/index.mjs +2 -2
- package/dist/plugin-utils/logging.cjs +3 -0
- package/dist/plugin-utils/logging.d.cts.map +1 -1
- package/dist/plugin-utils/logging.d.mts.map +1 -1
- package/dist/plugin-utils/logging.mjs +3 -0
- package/dist/plugin-utils/logging.mjs.map +1 -1
- package/dist/plugin-utils/merge.mjs.map +1 -1
- package/dist/plugin-utils/modules.mjs.map +1 -1
- package/dist/plugin-utils/paths.mjs.map +1 -1
- package/dist/storage/base.mjs.map +1 -1
- package/dist/storage/file-system.mjs.map +1 -1
- package/dist/storage/virtual.mjs.map +1 -1
- package/package.json +2 -2
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
2
|
let _storm_software_config_tools_get_config = require("@storm-software/config-tools/get-config");
|
|
3
|
+
let _stryke_fs_exists = require("@stryke/fs/exists");
|
|
4
|
+
let _stryke_fs_json = require("@stryke/fs/json");
|
|
3
5
|
let _stryke_type_checks_is_set_object = require("@stryke/type-checks/is-set-object");
|
|
4
6
|
let _stryke_type_checks_is_set_string = require("@stryke/type-checks/is-set-string");
|
|
7
|
+
let _stryke_path_join = require("@stryke/path/join");
|
|
5
8
|
|
|
6
9
|
//#region src/plugin-utils/context-helpers.ts
|
|
7
10
|
/**
|
|
@@ -81,9 +84,31 @@ async function getWorkspaceName(context) {
|
|
|
81
84
|
function formatExecutionId(projectName, command, configIndex = 0) {
|
|
82
85
|
return `${projectName}:${command}:${String(configIndex + 1).padStart(2, "0")}`;
|
|
83
86
|
}
|
|
87
|
+
/**
|
|
88
|
+
* Retrieves the project name from the context by checking various sources such as `project.json`, `package.json`, workspace configuration, and finally falling back to the context configuration.
|
|
89
|
+
*
|
|
90
|
+
* @param cwd - The current working directory.
|
|
91
|
+
* @param root - The root directory of the project.
|
|
92
|
+
* @returns The project name or undefined if not found.
|
|
93
|
+
*/
|
|
94
|
+
async function getName(cwd, root) {
|
|
95
|
+
const projectRoot = (0, _stryke_path_join.joinPaths)(cwd, root);
|
|
96
|
+
const projectJsonPath = (0, _stryke_path_join.joinPaths)(projectRoot, "project.json");
|
|
97
|
+
if ((0, _stryke_fs_exists.existsSync)(projectJsonPath)) {
|
|
98
|
+
const projectJson = await (0, _stryke_fs_json.readJsonFile)(projectJsonPath);
|
|
99
|
+
if ((0, _stryke_type_checks_is_set_string.isSetString)(projectJson.name)) return projectJson.name;
|
|
100
|
+
}
|
|
101
|
+
const packageJsonPath = (0, _stryke_path_join.joinPaths)(projectRoot, "package.json");
|
|
102
|
+
if ((0, _stryke_fs_exists.existsSync)(packageJsonPath)) {
|
|
103
|
+
const packageJson = await (0, _stryke_fs_json.readJsonFile)(packageJsonPath);
|
|
104
|
+
if ((0, _stryke_type_checks_is_set_string.isSetString)(packageJson.name)) return packageJson.name.replace(/^@[^/]+\//, "");
|
|
105
|
+
}
|
|
106
|
+
return root.replace(/\/*$/, "").replace("/", "-");
|
|
107
|
+
}
|
|
84
108
|
|
|
85
109
|
//#endregion
|
|
86
110
|
exports.formatExecutionId = formatExecutionId;
|
|
111
|
+
exports.getName = getName;
|
|
87
112
|
exports.getOrganizationName = getOrganizationName;
|
|
88
113
|
exports.getPackageJsonOrganization = getPackageJsonOrganization;
|
|
89
114
|
exports.getWorkspaceName = getWorkspaceName;
|
|
@@ -47,6 +47,14 @@ declare function getWorkspaceName(context: UnresolvedContext): Promise<string |
|
|
|
47
47
|
* @returns The formatted execution ID.
|
|
48
48
|
*/
|
|
49
49
|
declare function formatExecutionId(projectName: string, command: string, configIndex?: number): string;
|
|
50
|
+
/**
|
|
51
|
+
* Retrieves the project name from the context by checking various sources such as `project.json`, `package.json`, workspace configuration, and finally falling back to the context configuration.
|
|
52
|
+
*
|
|
53
|
+
* @param cwd - The current working directory.
|
|
54
|
+
* @param root - The root directory of the project.
|
|
55
|
+
* @returns The project name or undefined if not found.
|
|
56
|
+
*/
|
|
57
|
+
declare function getName(cwd: string, root: string): Promise<string>;
|
|
50
58
|
//#endregion
|
|
51
|
-
export { formatExecutionId, getOrganizationName, getPackageJsonOrganization, getWorkspaceName };
|
|
59
|
+
export { formatExecutionId, getName, getOrganizationName, getPackageJsonOrganization, getWorkspaceName };
|
|
52
60
|
//# sourceMappingURL=context-helpers.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context-helpers.d.cts","names":[],"sources":["../../src/plugin-utils/context-helpers.ts"],"mappings":";;;;;;
|
|
1
|
+
{"version":3,"file":"context-helpers.d.cts","names":[],"sources":["../../src/plugin-utils/context-helpers.ts"],"mappings":";;;;;;AAiCA;;;;iBAAsB,mBAAA,CACpB,OAAA,EAAS,iBAAA,GACR,OAAO;;;;AAAA;AAkBV;;iBAAgB,0BAAA,CACd,WAAwB,EAAX,WAAW;;AAAA;AA6D1B;;;;iBAAsB,gBAAA,CACpB,OAAA,EAAS,iBAAA,GACR,OAAO;;;;AAAA;AAgDV;;;;;;;;AAGyB;AAYzB;;;;;;;;AAAiE;;iBAfjD,iBAAA,CACd,WAAA,UACA,OAAA,UACA,WAAA;;;;;;;;iBAYoB,OAAA,CAAQ,GAAA,UAAa,IAAA,WAAe,OAAO"}
|
|
@@ -47,6 +47,14 @@ declare function getWorkspaceName(context: UnresolvedContext): Promise<string |
|
|
|
47
47
|
* @returns The formatted execution ID.
|
|
48
48
|
*/
|
|
49
49
|
declare function formatExecutionId(projectName: string, command: string, configIndex?: number): string;
|
|
50
|
+
/**
|
|
51
|
+
* Retrieves the project name from the context by checking various sources such as `project.json`, `package.json`, workspace configuration, and finally falling back to the context configuration.
|
|
52
|
+
*
|
|
53
|
+
* @param cwd - The current working directory.
|
|
54
|
+
* @param root - The root directory of the project.
|
|
55
|
+
* @returns The project name or undefined if not found.
|
|
56
|
+
*/
|
|
57
|
+
declare function getName(cwd: string, root: string): Promise<string>;
|
|
50
58
|
//#endregion
|
|
51
|
-
export { formatExecutionId, getOrganizationName, getPackageJsonOrganization, getWorkspaceName };
|
|
59
|
+
export { formatExecutionId, getName, getOrganizationName, getPackageJsonOrganization, getWorkspaceName };
|
|
52
60
|
//# sourceMappingURL=context-helpers.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context-helpers.d.mts","names":[],"sources":["../../src/plugin-utils/context-helpers.ts"],"mappings":";;;;;;
|
|
1
|
+
{"version":3,"file":"context-helpers.d.mts","names":[],"sources":["../../src/plugin-utils/context-helpers.ts"],"mappings":";;;;;;AAiCA;;;;iBAAsB,mBAAA,CACpB,OAAA,EAAS,iBAAA,GACR,OAAO;;;;AAAA;AAkBV;;iBAAgB,0BAAA,CACd,WAAwB,EAAX,WAAW;;AAAA;AA6D1B;;;;iBAAsB,gBAAA,CACpB,OAAA,EAAS,iBAAA,GACR,OAAO;;;;AAAA;AAgDV;;;;;;;;AAGyB;AAYzB;;;;;;;;AAAiE;;iBAfjD,iBAAA,CACd,WAAA,UACA,OAAA,UACA,WAAA;;;;;;;;iBAYoB,OAAA,CAAQ,GAAA,UAAa,IAAA,WAAe,OAAO"}
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { tryGetWorkspaceConfig } from "@storm-software/config-tools/get-config";
|
|
2
|
+
import { existsSync } from "@stryke/fs/exists";
|
|
3
|
+
import { readJsonFile } from "@stryke/fs/json";
|
|
2
4
|
import { isSetObject } from "@stryke/type-checks/is-set-object";
|
|
3
5
|
import { isSetString } from "@stryke/type-checks/is-set-string";
|
|
6
|
+
import { joinPaths } from "@stryke/path/join";
|
|
4
7
|
|
|
5
8
|
//#region src/plugin-utils/context-helpers.ts
|
|
6
9
|
/**
|
|
@@ -80,7 +83,28 @@ async function getWorkspaceName(context) {
|
|
|
80
83
|
function formatExecutionId(projectName, command, configIndex = 0) {
|
|
81
84
|
return `${projectName}:${command}:${String(configIndex + 1).padStart(2, "0")}`;
|
|
82
85
|
}
|
|
86
|
+
/**
|
|
87
|
+
* Retrieves the project name from the context by checking various sources such as `project.json`, `package.json`, workspace configuration, and finally falling back to the context configuration.
|
|
88
|
+
*
|
|
89
|
+
* @param cwd - The current working directory.
|
|
90
|
+
* @param root - The root directory of the project.
|
|
91
|
+
* @returns The project name or undefined if not found.
|
|
92
|
+
*/
|
|
93
|
+
async function getName(cwd, root) {
|
|
94
|
+
const projectRoot = joinPaths(cwd, root);
|
|
95
|
+
const projectJsonPath = joinPaths(projectRoot, "project.json");
|
|
96
|
+
if (existsSync(projectJsonPath)) {
|
|
97
|
+
const projectJson = await readJsonFile(projectJsonPath);
|
|
98
|
+
if (isSetString(projectJson.name)) return projectJson.name;
|
|
99
|
+
}
|
|
100
|
+
const packageJsonPath = joinPaths(projectRoot, "package.json");
|
|
101
|
+
if (existsSync(packageJsonPath)) {
|
|
102
|
+
const packageJson = await readJsonFile(packageJsonPath);
|
|
103
|
+
if (isSetString(packageJson.name)) return packageJson.name.replace(/^@[^/]+\//, "");
|
|
104
|
+
}
|
|
105
|
+
return root.replace(/\/*$/, "").replace("/", "-");
|
|
106
|
+
}
|
|
83
107
|
|
|
84
108
|
//#endregion
|
|
85
|
-
export { formatExecutionId, getOrganizationName, getPackageJsonOrganization, getWorkspaceName };
|
|
109
|
+
export { formatExecutionId, getName, getOrganizationName, getPackageJsonOrganization, getWorkspaceName };
|
|
86
110
|
//# sourceMappingURL=context-helpers.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context-helpers.mjs","names":[],"sources":["../../src/plugin-utils/context-helpers.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 { tryGetWorkspaceConfig } from \"@storm-software/config-tools/get-config\";\nimport { isSetObject } from \"@stryke/type-checks/is-set-object\";\nimport { isSetString } from \"@stryke/type-checks/is-set-string\";\nimport { PackageJson } from \"@stryke/types/package-json\";\nimport { UnresolvedContext } from \"../types/context\";\n\n/**\n * Get the organization name from the context\n *\n * @param context - The Powerlines plugin context.\n * @returns The organization name or undefined if not found.\n */\nexport async function getOrganizationName(\n context: UnresolvedContext\n): Promise<string | undefined> {\n if (isSetString(context.config.organization)) {\n return context.config.organization;\n }\n\n return (\n getPackageJsonOrganization(context.packageJson) ||\n (await getWorkspaceName(context)) ||\n context.config.name\n );\n}\n\n/**\n * Get the organization name from the `package.json` file\n *\n * @param packageJson - The `package.json` object to extract the organization name from.\n * @returns The organization name or undefined if not found.\n */\nexport function getPackageJsonOrganization(\n packageJson: PackageJson\n): string | undefined {\n let result: string | undefined;\n if (\n Array.isArray(packageJson.maintainers) &&\n packageJson.maintainers.length > 0\n ) {\n if (isSetObject(packageJson.maintainers[0])) {\n result = (packageJson.maintainers[0] as { name: string }).name;\n }\n\n if (!result && isSetString(packageJson.maintainers[0])) {\n result = packageJson.maintainers[0];\n }\n }\n\n if (\n !result &&\n Array.isArray(packageJson.author) &&\n packageJson.author.length > 0\n ) {\n if (isSetObject(packageJson.author[0])) {\n result = (packageJson.author[0] as { name: string }).name;\n }\n\n if (!result && isSetString(packageJson.author[0])) {\n result = packageJson.author[0];\n }\n }\n\n if (\n !result &&\n Array.isArray(packageJson.contributors) &&\n packageJson.contributors.length > 0\n ) {\n if (isSetObject(packageJson.contributors[0])) {\n result = (packageJson.contributors[0] as { name: string }).name;\n }\n\n if (!result && isSetString(packageJson.contributors[0])) {\n result = packageJson.contributors[0];\n }\n }\n\n if (!result && isSetString(packageJson.namespace)) {\n result = packageJson.namespace?.replace(/^@/, \"\");\n }\n\n if (!result && isSetString(packageJson.name)) {\n result = packageJson.name.replace(/^@/, \"\").replace(/\\/.*$/, \"\");\n }\n\n return result;\n}\n\n/**\n * Get the organization name from the context\n *\n * @param context - The Powerlines plugin context.\n * @returns The organization name or undefined if not found.\n */\nexport async function getWorkspaceName(\n context: UnresolvedContext\n): Promise<string | undefined> {\n let result: string | undefined;\n\n const workspaceConfig = await tryGetWorkspaceConfig(true);\n if (workspaceConfig) {\n if (isSetString(workspaceConfig.name)) {\n result = workspaceConfig.name;\n }\n\n if (!result && isSetString(workspaceConfig.namespace)) {\n result = workspaceConfig.namespace.replace(/^@/, \"\");\n }\n }\n\n if (!result && isSetString(context.packageJson.namespace)) {\n result = context.packageJson.namespace.replace(/^@/, \"\");\n }\n\n if (!result && isSetString(context.packageJson.name)) {\n result = context.packageJson.name.replace(/^@/, \"\").replace(/\\/.*$/, \"\");\n }\n\n return result;\n}\n\n/**\n * Format an execution ID based on the project name, command, and config index.\n *\n * @remarks\n * The execution ID is formatted as `${projectName}:${command}:${index}`, where:\n * - `projectName` is the name of the project.\n * - `command` is the command being executed.\n * - `index` is a zero-padded number representing the execution index (starting from 1).\n *\n * @example\n * ```ts\n * const executionId = formatExecutionId(\"my-project\", \"build\", 0);\n * // This will return \"my-project:build:01\"\n *\n * const executionId2 = formatExecutionId(\"my-project\", \"test\", 5);\n * // This will return \"my-project:test:06\"\n * ```\n *\n * @param projectName - The name of the project.\n * @param command - The command being executed.\n * @param configIndex - The index of the execution (starting from 0).\n * @returns The formatted execution ID.\n */\nexport function formatExecutionId(\n projectName: string,\n command: string,\n configIndex: number = 0\n) {\n return `${projectName}:${command}:${String(configIndex + 1).padStart(2, \"0\")}`;\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"context-helpers.mjs","names":[],"sources":["../../src/plugin-utils/context-helpers.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 { tryGetWorkspaceConfig } from \"@storm-software/config-tools/get-config\";\nimport { existsSync } from \"@stryke/fs/exists\";\nimport { readJsonFile } from \"@stryke/fs/json\";\nimport { joinPaths } from \"@stryke/path/join\";\nimport { isSetObject } from \"@stryke/type-checks/is-set-object\";\nimport { isSetString } from \"@stryke/type-checks/is-set-string\";\nimport { PackageJson } from \"@stryke/types/package-json\";\nimport { UnresolvedContext } from \"../types/context\";\n\n/**\n * Get the organization name from the context\n *\n * @param context - The Powerlines plugin context.\n * @returns The organization name or undefined if not found.\n */\nexport async function getOrganizationName(\n context: UnresolvedContext\n): Promise<string | undefined> {\n if (isSetString(context.config.organization)) {\n return context.config.organization;\n }\n\n return (\n getPackageJsonOrganization(context.packageJson) ||\n (await getWorkspaceName(context)) ||\n context.config.name\n );\n}\n\n/**\n * Get the organization name from the `package.json` file\n *\n * @param packageJson - The `package.json` object to extract the organization name from.\n * @returns The organization name or undefined if not found.\n */\nexport function getPackageJsonOrganization(\n packageJson: PackageJson\n): string | undefined {\n let result: string | undefined;\n if (\n Array.isArray(packageJson.maintainers) &&\n packageJson.maintainers.length > 0\n ) {\n if (isSetObject(packageJson.maintainers[0])) {\n result = (packageJson.maintainers[0] as { name: string }).name;\n }\n\n if (!result && isSetString(packageJson.maintainers[0])) {\n result = packageJson.maintainers[0];\n }\n }\n\n if (\n !result &&\n Array.isArray(packageJson.author) &&\n packageJson.author.length > 0\n ) {\n if (isSetObject(packageJson.author[0])) {\n result = (packageJson.author[0] as { name: string }).name;\n }\n\n if (!result && isSetString(packageJson.author[0])) {\n result = packageJson.author[0];\n }\n }\n\n if (\n !result &&\n Array.isArray(packageJson.contributors) &&\n packageJson.contributors.length > 0\n ) {\n if (isSetObject(packageJson.contributors[0])) {\n result = (packageJson.contributors[0] as { name: string }).name;\n }\n\n if (!result && isSetString(packageJson.contributors[0])) {\n result = packageJson.contributors[0];\n }\n }\n\n if (!result && isSetString(packageJson.namespace)) {\n result = packageJson.namespace?.replace(/^@/, \"\");\n }\n\n if (!result && isSetString(packageJson.name)) {\n result = packageJson.name.replace(/^@/, \"\").replace(/\\/.*$/, \"\");\n }\n\n return result;\n}\n\n/**\n * Get the organization name from the context\n *\n * @param context - The Powerlines plugin context.\n * @returns The organization name or undefined if not found.\n */\nexport async function getWorkspaceName(\n context: UnresolvedContext\n): Promise<string | undefined> {\n let result: string | undefined;\n\n const workspaceConfig = await tryGetWorkspaceConfig(true);\n if (workspaceConfig) {\n if (isSetString(workspaceConfig.name)) {\n result = workspaceConfig.name;\n }\n\n if (!result && isSetString(workspaceConfig.namespace)) {\n result = workspaceConfig.namespace.replace(/^@/, \"\");\n }\n }\n\n if (!result && isSetString(context.packageJson.namespace)) {\n result = context.packageJson.namespace.replace(/^@/, \"\");\n }\n\n if (!result && isSetString(context.packageJson.name)) {\n result = context.packageJson.name.replace(/^@/, \"\").replace(/\\/.*$/, \"\");\n }\n\n return result;\n}\n\n/**\n * Format an execution ID based on the project name, command, and config index.\n *\n * @remarks\n * The execution ID is formatted as `${projectName}:${command}:${index}`, where:\n * - `projectName` is the name of the project.\n * - `command` is the command being executed.\n * - `index` is a zero-padded number representing the execution index (starting from 1).\n *\n * @example\n * ```ts\n * const executionId = formatExecutionId(\"my-project\", \"build\", 0);\n * // This will return \"my-project:build:01\"\n *\n * const executionId2 = formatExecutionId(\"my-project\", \"test\", 5);\n * // This will return \"my-project:test:06\"\n * ```\n *\n * @param projectName - The name of the project.\n * @param command - The command being executed.\n * @param configIndex - The index of the execution (starting from 0).\n * @returns The formatted execution ID.\n */\nexport function formatExecutionId(\n projectName: string,\n command: string,\n configIndex: number = 0\n) {\n return `${projectName}:${command}:${String(configIndex + 1).padStart(2, \"0\")}`;\n}\n\n/**\n * Retrieves the project name from the context by checking various sources such as `project.json`, `package.json`, workspace configuration, and finally falling back to the context configuration.\n *\n * @param cwd - The current working directory.\n * @param root - The root directory of the project.\n * @returns The project name or undefined if not found.\n */\nexport async function getName(cwd: string, root: string): Promise<string> {\n const projectRoot = joinPaths(cwd, root);\n\n const projectJsonPath = joinPaths(projectRoot, \"project.json\");\n if (existsSync(projectJsonPath)) {\n const projectJson = await readJsonFile<{ name: string }>(projectJsonPath);\n if (isSetString(projectJson.name)) {\n return projectJson.name;\n }\n }\n\n const packageJsonPath = joinPaths(projectRoot, \"package.json\");\n if (existsSync(packageJsonPath)) {\n const packageJson = await readJsonFile<PackageJson>(packageJsonPath);\n if (isSetString(packageJson.name)) {\n return packageJson.name.replace(/^@[^/]+\\//, \"\");\n }\n }\n\n return root.replace(/\\/*$/, \"\").replace(\"/\", \"-\");\n}\n"],"mappings":";;;;;;;;;;;;;;AAiCA,eAAsB,oBACpB,SAC6B;CAC7B,IAAI,YAAY,QAAQ,OAAO,YAAY,GACzC,OAAO,QAAQ,OAAO;CAGxB,OACE,2BAA2B,QAAQ,WAAW,KAC7C,MAAM,iBAAiB,OAAO,KAC/B,QAAQ,OAAO;AAEnB;;;;;;;AAQA,SAAgB,2BACd,aACoB;CACpB,IAAI;CACJ,IACE,MAAM,QAAQ,YAAY,WAAW,KACrC,YAAY,YAAY,SAAS,GACjC;EACA,IAAI,YAAY,YAAY,YAAY,EAAE,GACxC,SAAU,YAAY,YAAY,EAAE,CAAsB;EAG5D,IAAI,CAAC,UAAU,YAAY,YAAY,YAAY,EAAE,GACnD,SAAS,YAAY,YAAY;CAErC;CAEA,IACE,CAAC,UACD,MAAM,QAAQ,YAAY,MAAM,KAChC,YAAY,OAAO,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QAAQ,GAAG,OAAO,cAAc,CAAC,CAAC,CAAC,SAAS,GAAG,GAAG;AAC7E;;;;;;;;AASA,eAAsB,QAAQ,KAAa,MAA+B;CACxE,MAAM,cAAc,UAAU,KAAK,IAAI;CAEvC,MAAM,kBAAkB,UAAU,aAAa,cAAc;CAC7D,IAAI,WAAW,eAAe,GAAG;EAC/B,MAAM,cAAc,MAAM,aAA+B,eAAe;EACxE,IAAI,YAAY,YAAY,IAAI,GAC9B,OAAO,YAAY;CAEvB;CAEA,MAAM,kBAAkB,UAAU,aAAa,cAAc;CAC7D,IAAI,WAAW,eAAe,GAAG;EAC/B,MAAM,cAAc,MAAM,aAA0B,eAAe;EACnE,IAAI,YAAY,YAAY,IAAI,GAC9B,OAAO,YAAY,KAAK,QAAQ,aAAa,EAAE;CAEnD;CAEA,OAAO,KAAK,QAAQ,QAAQ,EAAE,CAAC,CAAC,QAAQ,KAAK,GAAG;AAClD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"enable-plugin.mjs","names":[],"sources":["../../src/plugin-utils/enable-plugin.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 { toArray } from \"@stryke/convert/to-array\";\nimport { isFunction } from \"@stryke/type-checks/is-function\";\nimport { Plugin } from \"../types\";\nimport { PluginContext } from \"../types/context\";\n\n/**\n * Utility function to conditionally enable plugins based on a boolean value or a function that returns a boolean. This is useful for scenarios where you want to enable certain plugins only in specific environments (e.g., development vs production) or based on certain conditions (e.g., presence of environment variables).\n *\n * @example\n * ```ts\n * const somePlugin = <TContext extends PluginContext = PluginContext>(options: { enableThirdPlugin: boolean }) => {\n * return [\n * ...enable<TContext>(anotherPlugin, () => process.env.NODE_ENV === \"development\"),\n * ...enable<TContext>(yetAnotherPlugin, process.env.ENABLE_YET_ANOTHER_PLUGIN === \"true\"),\n * ...enable<TContext>(thirdPlugin, options.enableThirdPlugin),\n * {\n * name: \"some-plugin\",\n * ...\n * }\n * ];\n * };\n * ```\n *\n * @param plugin - A single plugin or an array of plugins to conditionally enable.\n * @param condition - A boolean value or a function that returns a boolean. If it's a function, it will be executed to determine whether to enable the plugin(s). If it's a boolean, it will be used directly.\n * @returns An array of plugins that should be enabled based on the provided condition. If the condition is false, an empty array will be returned.\n */\nexport function enable<TContext extends PluginContext = PluginContext>(\n plugin: Plugin<TContext> | Plugin<TContext>[],\n condition: boolean | (() => boolean) = true\n): Plugin<TContext>[] {\n return (isFunction(condition) && condition()) ||\n (!isFunction(condition) && condition)\n ? toArray(plugin).filter(Boolean)\n : [];\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AA6CA,SAAgB,OACd,QACA,YAAuC,MACnB;CACpB,OAAQ,WAAW,SAAS,KAAK,UAAU,KACxC,CAAC,WAAW,SAAS,KAAK,YACzB,QAAQ,MAAM,
|
|
1
|
+
{"version":3,"file":"enable-plugin.mjs","names":[],"sources":["../../src/plugin-utils/enable-plugin.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 { toArray } from \"@stryke/convert/to-array\";\nimport { isFunction } from \"@stryke/type-checks/is-function\";\nimport { Plugin } from \"../types\";\nimport { PluginContext } from \"../types/context\";\n\n/**\n * Utility function to conditionally enable plugins based on a boolean value or a function that returns a boolean. This is useful for scenarios where you want to enable certain plugins only in specific environments (e.g., development vs production) or based on certain conditions (e.g., presence of environment variables).\n *\n * @example\n * ```ts\n * const somePlugin = <TContext extends PluginContext = PluginContext>(options: { enableThirdPlugin: boolean }) => {\n * return [\n * ...enable<TContext>(anotherPlugin, () => process.env.NODE_ENV === \"development\"),\n * ...enable<TContext>(yetAnotherPlugin, process.env.ENABLE_YET_ANOTHER_PLUGIN === \"true\"),\n * ...enable<TContext>(thirdPlugin, options.enableThirdPlugin),\n * {\n * name: \"some-plugin\",\n * ...\n * }\n * ];\n * };\n * ```\n *\n * @param plugin - A single plugin or an array of plugins to conditionally enable.\n * @param condition - A boolean value or a function that returns a boolean. If it's a function, it will be executed to determine whether to enable the plugin(s). If it's a boolean, it will be used directly.\n * @returns An array of plugins that should be enabled based on the provided condition. If the condition is false, an empty array will be returned.\n */\nexport function enable<TContext extends PluginContext = PluginContext>(\n plugin: Plugin<TContext> | Plugin<TContext>[],\n condition: boolean | (() => boolean) = true\n): Plugin<TContext>[] {\n return (isFunction(condition) && condition()) ||\n (!isFunction(condition) && condition)\n ? toArray(plugin).filter(Boolean)\n : [];\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AA6CA,SAAgB,OACd,QACA,YAAuC,MACnB;CACpB,OAAQ,WAAW,SAAS,KAAK,UAAU,KACxC,CAAC,WAAW,SAAS,KAAK,YACzB,QAAQ,MAAM,CAAC,CAAC,OAAO,OAAO,IAC9B,CAAC;AACP"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"extend.mjs","names":[],"sources":["../../src/plugin-utils/extend.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 { toArray } from \"@stryke/convert/to-array\";\nimport { isFunction } from \"@stryke/type-checks/is-function\";\nimport {\n PartialPlugin,\n PartialPluginFactory,\n PluginFactory\n} from \"../types/config\";\nimport { PluginContext } from \"../types/context\";\nimport { Plugin } from \"../types/plugin\";\nimport { merge } from \"./merge\";\n\n/**\n * Adds additional helper functionality to a plugin via a plugin builder function.\n *\n * @param plugin - The base plugin object or factory function to extend.\n * @param extension - The plugin extension object or factory function. This function receives the plugin options and returns a plugin object.\n * @returns A function accepting the plugin options and returning the extended plugin.\n */\nexport function extend<\n TContext extends PluginContext = PluginContext,\n TPluginOptions = unknown,\n TExtensionOptions = unknown\n>(\n plugin: PluginFactory<TContext, TPluginOptions>,\n extension: PartialPluginFactory<TContext, TExtensionOptions>\n): PluginFactory<TContext, TPluginOptions & TExtensionOptions>;\nexport function extend<\n TContext extends PluginContext = PluginContext,\n TPluginOptions = unknown\n>(\n plugin: PluginFactory<TContext, TPluginOptions>,\n extension: PartialPlugin<TContext>\n): PluginFactory<TContext, TPluginOptions>;\nexport function extend<\n TContext extends PluginContext = PluginContext,\n TExtensionOptions = unknown\n>(\n plugin: Plugin<TContext> | Plugin<TContext>[],\n extension: PartialPluginFactory<TContext, TExtensionOptions>\n): PluginFactory<TContext, TExtensionOptions>;\nexport function extend<TContext extends PluginContext = PluginContext>(\n plugin: Plugin<TContext> | Plugin<TContext>[],\n extension: PartialPlugin<TContext>\n): Plugin<TContext>[];\nexport function extend<TContext extends PluginContext = PluginContext>(\n plugin: Plugin<TContext> | Plugin<TContext>[] | PluginFactory<TContext, any>,\n extension: PartialPlugin<TContext> | PartialPluginFactory<TContext, any>\n): PluginFactory<TContext, any> | Plugin<TContext>[] {\n if (isFunction(plugin)) {\n if (isFunction(extension)) {\n return async (options: any) => {\n const pluginResult = toArray(await Promise.resolve(plugin(options)));\n const extensionResult = toArray(\n await Promise.resolve(extension(options))\n );\n\n return pluginResult\n .map(p => extensionResult.map(e => merge(p, e) as Plugin<TContext>))\n .flat();\n };\n }\n\n return async (options: any) => {\n const result = toArray(await Promise.resolve(plugin(options)));\n\n return result.map(p => merge(p, extension) as Plugin<TContext>);\n };\n } else if (isFunction(extension)) {\n return async (options: any) => {\n const result = toArray(await Promise.resolve(extension(options)));\n\n return result\n .map(e => toArray(plugin).map(p => merge(p, e) as Plugin<TContext>))\n .flat();\n };\n }\n\n return toArray(plugin).map(p => merge(p, extension) as Plugin<TContext>);\n}\n"],"mappings":";;;;;AA8DA,SAAgB,OACd,QACA,WACmD;CACnD,IAAI,WAAW,MAAM,GAAG;EACtB,IAAI,WAAW,SAAS,GACtB,OAAO,OAAO,YAAiB;GAC7B,MAAM,eAAe,QAAQ,MAAM,QAAQ,QAAQ,OAAO,OAAO,CAAC,CAAC;GACnE,MAAM,kBAAkB,QACtB,MAAM,QAAQ,QAAQ,UAAU,OAAO,CAAC,CAC1C;GAEA,OAAO,aACJ,KAAI,MAAK,gBAAgB,KAAI,MAAK,MAAM,GAAG,CAAC,CAAqB,CAAC,
|
|
1
|
+
{"version":3,"file":"extend.mjs","names":[],"sources":["../../src/plugin-utils/extend.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 { toArray } from \"@stryke/convert/to-array\";\nimport { isFunction } from \"@stryke/type-checks/is-function\";\nimport {\n PartialPlugin,\n PartialPluginFactory,\n PluginFactory\n} from \"../types/config\";\nimport { PluginContext } from \"../types/context\";\nimport { Plugin } from \"../types/plugin\";\nimport { merge } from \"./merge\";\n\n/**\n * Adds additional helper functionality to a plugin via a plugin builder function.\n *\n * @param plugin - The base plugin object or factory function to extend.\n * @param extension - The plugin extension object or factory function. This function receives the plugin options and returns a plugin object.\n * @returns A function accepting the plugin options and returning the extended plugin.\n */\nexport function extend<\n TContext extends PluginContext = PluginContext,\n TPluginOptions = unknown,\n TExtensionOptions = unknown\n>(\n plugin: PluginFactory<TContext, TPluginOptions>,\n extension: PartialPluginFactory<TContext, TExtensionOptions>\n): PluginFactory<TContext, TPluginOptions & TExtensionOptions>;\nexport function extend<\n TContext extends PluginContext = PluginContext,\n TPluginOptions = unknown\n>(\n plugin: PluginFactory<TContext, TPluginOptions>,\n extension: PartialPlugin<TContext>\n): PluginFactory<TContext, TPluginOptions>;\nexport function extend<\n TContext extends PluginContext = PluginContext,\n TExtensionOptions = unknown\n>(\n plugin: Plugin<TContext> | Plugin<TContext>[],\n extension: PartialPluginFactory<TContext, TExtensionOptions>\n): PluginFactory<TContext, TExtensionOptions>;\nexport function extend<TContext extends PluginContext = PluginContext>(\n plugin: Plugin<TContext> | Plugin<TContext>[],\n extension: PartialPlugin<TContext>\n): Plugin<TContext>[];\nexport function extend<TContext extends PluginContext = PluginContext>(\n plugin: Plugin<TContext> | Plugin<TContext>[] | PluginFactory<TContext, any>,\n extension: PartialPlugin<TContext> | PartialPluginFactory<TContext, any>\n): PluginFactory<TContext, any> | Plugin<TContext>[] {\n if (isFunction(plugin)) {\n if (isFunction(extension)) {\n return async (options: any) => {\n const pluginResult = toArray(await Promise.resolve(plugin(options)));\n const extensionResult = toArray(\n await Promise.resolve(extension(options))\n );\n\n return pluginResult\n .map(p => extensionResult.map(e => merge(p, e) as Plugin<TContext>))\n .flat();\n };\n }\n\n return async (options: any) => {\n const result = toArray(await Promise.resolve(plugin(options)));\n\n return result.map(p => merge(p, extension) as Plugin<TContext>);\n };\n } else if (isFunction(extension)) {\n return async (options: any) => {\n const result = toArray(await Promise.resolve(extension(options)));\n\n return result\n .map(e => toArray(plugin).map(p => merge(p, e) as Plugin<TContext>))\n .flat();\n };\n }\n\n return toArray(plugin).map(p => merge(p, extension) as Plugin<TContext>);\n}\n"],"mappings":";;;;;AA8DA,SAAgB,OACd,QACA,WACmD;CACnD,IAAI,WAAW,MAAM,GAAG;EACtB,IAAI,WAAW,SAAS,GACtB,OAAO,OAAO,YAAiB;GAC7B,MAAM,eAAe,QAAQ,MAAM,QAAQ,QAAQ,OAAO,OAAO,CAAC,CAAC;GACnE,MAAM,kBAAkB,QACtB,MAAM,QAAQ,QAAQ,UAAU,OAAO,CAAC,CAC1C;GAEA,OAAO,aACJ,KAAI,MAAK,gBAAgB,KAAI,MAAK,MAAM,GAAG,CAAC,CAAqB,CAAC,CAAC,CACnE,KAAK;EACV;EAGF,OAAO,OAAO,YAAiB;GAG7B,OAFe,QAAQ,MAAM,QAAQ,QAAQ,OAAO,OAAO,CAAC,CAEhD,CAAC,CAAC,KAAI,MAAK,MAAM,GAAG,SAAS,CAAqB;EAChE;CACF,OAAO,IAAI,WAAW,SAAS,GAC7B,OAAO,OAAO,YAAiB;EAG7B,OAFe,QAAQ,MAAM,QAAQ,QAAQ,UAAU,OAAO,CAAC,CAEnD,CAAC,CACV,KAAI,MAAK,QAAQ,MAAM,CAAC,CAAC,KAAI,MAAK,MAAM,GAAG,CAAC,CAAqB,CAAC,CAAC,CACnE,KAAK;CACV;CAGF,OAAO,QAAQ,MAAM,CAAC,CAAC,KAAI,MAAK,MAAM,GAAG,SAAS,CAAqB;AACzE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"filter.mjs","names":[],"sources":["../../src/plugin-utils/filter.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 { toArray } from \"@stryke/convert/to-array\";\nimport { isAbsolutePath } from \"@stryke/path/is-type\";\nimport { isRegExp } from \"@stryke/type-checks/is-regexp\";\nimport { isSetString } from \"@stryke/type-checks/is-set-string\";\nimport { resolve } from \"node:path\";\nimport picomatch from \"picomatch\";\nimport type { StringFilter, StringOrRegExp } from \"unplugin\";\nimport {\n NormalizedStringFilter,\n PluginFilter,\n TransformHookFilter\n} from \"../types/hooks\";\nimport { removeVirtualPrefix } from \"./virtual\";\n\nconst BACKSLASH_REGEX = /\\\\/g;\nfunction normalize(path: string): string {\n return removeVirtualPrefix(path).replace(BACKSLASH_REGEX, \"/\");\n}\n\nfunction getMatcherString(glob: string, cwd: string) {\n if (glob.startsWith(\"**\") || isAbsolutePath(glob)) {\n return normalize(glob);\n }\n\n const resolved = resolve(cwd, glob);\n\n return normalize(resolved);\n}\n\nexport function patternToIdFilter(pattern: StringOrRegExp): PluginFilter {\n if (pattern instanceof RegExp) {\n return (id: string) => {\n const normalizedId = normalize(id);\n const result = pattern.test(normalizedId);\n pattern.lastIndex = 0;\n return result;\n };\n }\n const cwd = process.cwd();\n const glob = getMatcherString(pattern, cwd);\n const matcher = picomatch(glob, { dot: true });\n\n return (id: string) => {\n const normalizedId = normalize(id);\n\n return matcher(normalizedId);\n };\n}\n\nexport function patternToCodeFilter(pattern: StringOrRegExp): PluginFilter {\n if (pattern instanceof RegExp) {\n return (code: string) => {\n const result = pattern.test(code);\n pattern.lastIndex = 0;\n return result;\n };\n }\n return (code: string) => code.includes(pattern);\n}\n\nexport function createFilter(\n exclude: PluginFilter[] | undefined,\n include: PluginFilter[] | undefined\n): PluginFilter | undefined {\n if (!exclude && !include) {\n return;\n }\n\n return input => {\n if (exclude?.some(filter => filter(input))) {\n return false;\n }\n if (include?.some(filter => filter(input))) {\n return true;\n }\n return !(include && include.length > 0);\n };\n}\n\nexport function normalizeSingleFilter(\n filter: string | RegExp\n): string | RegExp {\n if (isSetString(filter)) {\n return removeVirtualPrefix(filter);\n }\n\n return filter;\n}\n\nexport function normalizeFilter(filter: StringFilter): NormalizedStringFilter {\n if (isSetString(filter) || isRegExp(filter)) {\n return {\n include: [normalizeSingleFilter(filter)]\n };\n }\n\n if (Array.isArray(filter)) {\n return {\n include: filter.map(normalizeSingleFilter)\n };\n }\n\n return {\n exclude: filter.exclude\n ? toArray(filter.exclude).map(normalizeSingleFilter)\n : undefined,\n include: filter.include\n ? toArray(filter.include).map(normalizeSingleFilter)\n : undefined\n };\n}\n\nexport function createIdFilter(\n filter: StringFilter | undefined\n): PluginFilter | undefined {\n if (!filter) return;\n const { exclude, include } = normalizeFilter(filter);\n const excludeFilter = exclude?.map(patternToIdFilter);\n const includeFilter = include?.map(patternToIdFilter);\n\n return createFilter(excludeFilter, includeFilter);\n}\n\nexport function createCodeFilter(\n filter: StringFilter | undefined\n): PluginFilter | undefined {\n if (!filter) return;\n const { exclude, include } = normalizeFilter(filter);\n const excludeFilter = exclude?.map(patternToCodeFilter);\n const includeFilter = include?.map(patternToCodeFilter);\n\n return createFilter(excludeFilter, includeFilter);\n}\n\nexport function createFilterForId(\n filter: StringFilter | undefined\n): PluginFilter | undefined {\n const filterFunction = createIdFilter(filter);\n\n return filterFunction ? id => !!filterFunction(id) : undefined;\n}\n\nexport function createFilterForTransform(\n idFilter: StringFilter | undefined,\n codeFilter: StringFilter | undefined\n): TransformHookFilter | undefined {\n if (!idFilter && !codeFilter) return;\n const idFilterFunction = createIdFilter(idFilter);\n const codeFilterFunction = createCodeFilter(codeFilter);\n\n return (id, code) => {\n let fallback = true;\n if (idFilterFunction) {\n fallback &&= idFilterFunction(id);\n }\n if (!fallback) {\n return false;\n }\n\n if (codeFilterFunction) {\n fallback &&= codeFilterFunction(code);\n }\n return fallback;\n };\n}\n"],"mappings":";;;;;;;;;AAgCA,MAAM,kBAAkB;AACxB,SAAS,UAAU,MAAsB;CACvC,OAAO,oBAAoB,IAAI,
|
|
1
|
+
{"version":3,"file":"filter.mjs","names":[],"sources":["../../src/plugin-utils/filter.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 { toArray } from \"@stryke/convert/to-array\";\nimport { isAbsolutePath } from \"@stryke/path/is-type\";\nimport { isRegExp } from \"@stryke/type-checks/is-regexp\";\nimport { isSetString } from \"@stryke/type-checks/is-set-string\";\nimport { resolve } from \"node:path\";\nimport picomatch from \"picomatch\";\nimport type { StringFilter, StringOrRegExp } from \"unplugin\";\nimport {\n NormalizedStringFilter,\n PluginFilter,\n TransformHookFilter\n} from \"../types/hooks\";\nimport { removeVirtualPrefix } from \"./virtual\";\n\nconst BACKSLASH_REGEX = /\\\\/g;\nfunction normalize(path: string): string {\n return removeVirtualPrefix(path).replace(BACKSLASH_REGEX, \"/\");\n}\n\nfunction getMatcherString(glob: string, cwd: string) {\n if (glob.startsWith(\"**\") || isAbsolutePath(glob)) {\n return normalize(glob);\n }\n\n const resolved = resolve(cwd, glob);\n\n return normalize(resolved);\n}\n\nexport function patternToIdFilter(pattern: StringOrRegExp): PluginFilter {\n if (pattern instanceof RegExp) {\n return (id: string) => {\n const normalizedId = normalize(id);\n const result = pattern.test(normalizedId);\n pattern.lastIndex = 0;\n return result;\n };\n }\n const cwd = process.cwd();\n const glob = getMatcherString(pattern, cwd);\n const matcher = picomatch(glob, { dot: true });\n\n return (id: string) => {\n const normalizedId = normalize(id);\n\n return matcher(normalizedId);\n };\n}\n\nexport function patternToCodeFilter(pattern: StringOrRegExp): PluginFilter {\n if (pattern instanceof RegExp) {\n return (code: string) => {\n const result = pattern.test(code);\n pattern.lastIndex = 0;\n return result;\n };\n }\n return (code: string) => code.includes(pattern);\n}\n\nexport function createFilter(\n exclude: PluginFilter[] | undefined,\n include: PluginFilter[] | undefined\n): PluginFilter | undefined {\n if (!exclude && !include) {\n return;\n }\n\n return input => {\n if (exclude?.some(filter => filter(input))) {\n return false;\n }\n if (include?.some(filter => filter(input))) {\n return true;\n }\n return !(include && include.length > 0);\n };\n}\n\nexport function normalizeSingleFilter(\n filter: string | RegExp\n): string | RegExp {\n if (isSetString(filter)) {\n return removeVirtualPrefix(filter);\n }\n\n return filter;\n}\n\nexport function normalizeFilter(filter: StringFilter): NormalizedStringFilter {\n if (isSetString(filter) || isRegExp(filter)) {\n return {\n include: [normalizeSingleFilter(filter)]\n };\n }\n\n if (Array.isArray(filter)) {\n return {\n include: filter.map(normalizeSingleFilter)\n };\n }\n\n return {\n exclude: filter.exclude\n ? toArray(filter.exclude).map(normalizeSingleFilter)\n : undefined,\n include: filter.include\n ? toArray(filter.include).map(normalizeSingleFilter)\n : undefined\n };\n}\n\nexport function createIdFilter(\n filter: StringFilter | undefined\n): PluginFilter | undefined {\n if (!filter) return;\n const { exclude, include } = normalizeFilter(filter);\n const excludeFilter = exclude?.map(patternToIdFilter);\n const includeFilter = include?.map(patternToIdFilter);\n\n return createFilter(excludeFilter, includeFilter);\n}\n\nexport function createCodeFilter(\n filter: StringFilter | undefined\n): PluginFilter | undefined {\n if (!filter) return;\n const { exclude, include } = normalizeFilter(filter);\n const excludeFilter = exclude?.map(patternToCodeFilter);\n const includeFilter = include?.map(patternToCodeFilter);\n\n return createFilter(excludeFilter, includeFilter);\n}\n\nexport function createFilterForId(\n filter: StringFilter | undefined\n): PluginFilter | undefined {\n const filterFunction = createIdFilter(filter);\n\n return filterFunction ? id => !!filterFunction(id) : undefined;\n}\n\nexport function createFilterForTransform(\n idFilter: StringFilter | undefined,\n codeFilter: StringFilter | undefined\n): TransformHookFilter | undefined {\n if (!idFilter && !codeFilter) return;\n const idFilterFunction = createIdFilter(idFilter);\n const codeFilterFunction = createCodeFilter(codeFilter);\n\n return (id, code) => {\n let fallback = true;\n if (idFilterFunction) {\n fallback &&= idFilterFunction(id);\n }\n if (!fallback) {\n return false;\n }\n\n if (codeFilterFunction) {\n fallback &&= codeFilterFunction(code);\n }\n return fallback;\n };\n}\n"],"mappings":";;;;;;;;;AAgCA,MAAM,kBAAkB;AACxB,SAAS,UAAU,MAAsB;CACvC,OAAO,oBAAoB,IAAI,CAAC,CAAC,QAAQ,iBAAiB,GAAG;AAC/D;AAEA,SAAS,iBAAiB,MAAc,KAAa;CACnD,IAAI,KAAK,WAAW,IAAI,KAAK,eAAe,IAAI,GAC9C,OAAO,UAAU,IAAI;CAKvB,OAAO,UAFU,QAAQ,KAAK,IAEN,CAAC;AAC3B;AAEA,SAAgB,kBAAkB,SAAuC;CACvE,IAAI,mBAAmB,QACrB,QAAQ,OAAe;EACrB,MAAM,eAAe,UAAU,EAAE;EACjC,MAAM,SAAS,QAAQ,KAAK,YAAY;EACxC,QAAQ,YAAY;EACpB,OAAO;CACT;CAIF,MAAM,UAAU,UADH,iBAAiB,SADlB,QAAQ,IACqB,CACZ,GAAG,EAAE,KAAK,KAAK,CAAC;CAE7C,QAAQ,OAAe;EAGrB,OAAO,QAFc,UAAU,EAEL,CAAC;CAC7B;AACF;AAEA,SAAgB,oBAAoB,SAAuC;CACzE,IAAI,mBAAmB,QACrB,QAAQ,SAAiB;EACvB,MAAM,SAAS,QAAQ,KAAK,IAAI;E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;AAEA,SAAgB,kBACd,QAC0B;CAC1B,MAAM,iBAAiB,eAAe,MAAM;CAE5C,OAAO,kBAAiB,OAAM,CAAC,CAAC,eAAe,EAAE,IAAI;AACvD;AAEA,SAAgB,yBACd,UACA,YACiC;CACjC,IAAI,CAAC,YAAY,CAAC,YAAY;CAC9B,MAAM,mBAAmB,eAAe,QAAQ;CAChD,MAAM,qBAAqB,iBAAiB,UAAU;CAEtD,QAAQ,IAAI,SAAS;EACnB,IAAI,WAAW;EACf,IAAI,kBACF,aAAa,iBAAiB,EAAE;EAElC,IAAI,CAAC,UACH,OAAO;EAGT,IAAI,oBACF,aAAa,mBAAmB,IAAI;EAEtC,OAAO;CACT;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"format.mjs","names":[],"sources":["../../src/plugin-utils/format.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 { toArray } from \"@stryke/convert/to-array\";\nimport { omit } from \"@stryke/helpers/omit\";\nimport { isRegExp } from \"@stryke/type-checks/is-regexp\";\nimport { isSetArray } from \"@stryke/type-checks/is-set-array\";\nimport { isSetObject } from \"@stryke/type-checks/is-set-object\";\nimport { isSetString } from \"@stryke/type-checks/is-set-string\";\nimport { ResolveConfig, ResolvedConfig } from \"../types/config\";\n\n/**\n * Formats a configuration object into a human-readable string, omitting certain properties and simplifying others for better readability.\n *\n * @param config - The configuration object to format.\n * @returns A formatted string representation of the configuration.\n */\nexport function formatConfig(config: Record<string, any>): string {\n return JSON.stringify(\n Object.fromEntries(\n Object.entries({\n ...omit(config, [\n \"deps\",\n \"resolve\",\n \"plugins\",\n \"initialConfig\",\n \"userConfig\",\n \"inlineConfig\",\n \"pluginConfig\",\n \"environmentConfig\"\n ]),\n deps: isSetObject(config.deps)\n ? {\n alwaysBundle: isSetArray(\n (config.deps as { alwaysBundle?: unknown[] })?.alwaysBundle\n )\n ? (\n (config.deps as { alwaysBundle?: unknown[] })\n ?.alwaysBundle ?? []\n )\n .filter(Boolean)\n .map(alwaysBundle =>\n isSetString(alwaysBundle)\n ? alwaysBundle\n : isRegExp(alwaysBundle)\n ? alwaysBundle.source\n : \"<unknown-bundle>\"\n )\n : undefined,\n onlyBundle: isSetArray(\n (config.deps as { onlyBundle?: unknown[] })?.onlyBundle\n )\n ? (\n (config.deps as { onlyBundle?: unknown[] })?.onlyBundle ??\n []\n )\n .filter(Boolean)\n .map(onlyBundle =>\n isSetString(onlyBundle)\n ? onlyBundle\n : isRegExp(onlyBundle)\n ? onlyBundle.source\n : \"<unknown-bundle>\"\n )\n : undefined,\n neverBundle: isSetArray(\n (config.deps as { neverBundle?: unknown[] })?.neverBundle\n )\n ? (\n (config.deps as { neverBundle?: unknown[] })?.neverBundle ??\n []\n )\n .filter(Boolean)\n .map(neverBundle =>\n isSetString(neverBundle)\n ? neverBundle\n : isRegExp(neverBundle)\n ? neverBundle.source\n : \"<unknown-bundle>\"\n )\n : undefined\n }\n : undefined,\n\n resolve: isSetObject(config.resolve)\n ? {\n ...config.resolve,\n external: isSetArray((config.resolve as ResolveConfig)?.external)\n ? ((config.resolve as ResolveConfig)?.external ?? [])\n .filter(Boolean)\n .map(external =>\n isSetString(external)\n ? external\n : isRegExp(external)\n ? external.source\n : \"<unknown-bundle>\"\n )\n : undefined,\n noExternal: isSetArray(\n (config.resolve as ResolveConfig)?.noExternal\n )\n ? ((config.resolve as ResolveConfig)?.noExternal ?? [])\n .filter(Boolean)\n .map(noExternal =>\n isSetString(noExternal)\n ? noExternal\n : isRegExp(noExternal)\n ? noExternal.source\n : \"<unknown-bundle>\"\n )\n : undefined\n }\n : undefined,\n plugins: isSetArray(config.plugins)\n ? (toArray(config.plugins) as ResolvedConfig[\"plugins\"])\n ?.flatMap(plugin => toArray(plugin))\n ?.map(plugin =>\n String(\n isSetString(plugin)\n ? plugin\n : isSetObject(plugin) &&\n isSetString((plugin as { name: string }).name)\n ? (plugin as { name: string }).name\n : Array.isArray(plugin) && isSetString(plugin[0])\n ? plugin[0]\n : \"<function-plugin>\"\n )\n )\n : undefined\n }).sort(([key1], [key2]) => key1.localeCompare(key2))\n ),\n null,\n 4\n )\n .replace(/\"([^\"]+)\":/g, \"$1:\")\n .replace(/,\\s*$/g, \"\");\n}\n"],"mappings":";;;;;;;;;;;;;;AAgCA,SAAgB,aAAa,QAAqC;CAChE,OAAO,KAAK,UACV,OAAO,YACL,OAAO,QAAQ;EACb,GAAG,KAAK,QAAQ;GACd;GACA;GACA;GACA;GACA;GACA;GACA;GACA;EACF,CAAC;EACD,MAAM,YAAY,OAAO,IAAI,IACzB;GACE,cAAc,WACX,OAAO,MAAuC,YACjD,KAEO,OAAO,MACJ,gBAAgB,CAAC,
|
|
1
|
+
{"version":3,"file":"format.mjs","names":[],"sources":["../../src/plugin-utils/format.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 { toArray } from \"@stryke/convert/to-array\";\nimport { omit } from \"@stryke/helpers/omit\";\nimport { isRegExp } from \"@stryke/type-checks/is-regexp\";\nimport { isSetArray } from \"@stryke/type-checks/is-set-array\";\nimport { isSetObject } from \"@stryke/type-checks/is-set-object\";\nimport { isSetString } from \"@stryke/type-checks/is-set-string\";\nimport { ResolveConfig, ResolvedConfig } from \"../types/config\";\n\n/**\n * Formats a configuration object into a human-readable string, omitting certain properties and simplifying others for better readability.\n *\n * @param config - The configuration object to format.\n * @returns A formatted string representation of the configuration.\n */\nexport function formatConfig(config: Record<string, any>): string {\n return JSON.stringify(\n Object.fromEntries(\n Object.entries({\n ...omit(config, [\n \"deps\",\n \"resolve\",\n \"plugins\",\n \"initialConfig\",\n \"userConfig\",\n \"inlineConfig\",\n \"pluginConfig\",\n \"environmentConfig\"\n ]),\n deps: isSetObject(config.deps)\n ? {\n alwaysBundle: isSetArray(\n (config.deps as { alwaysBundle?: unknown[] })?.alwaysBundle\n )\n ? (\n (config.deps as { alwaysBundle?: unknown[] })\n ?.alwaysBundle ?? []\n )\n .filter(Boolean)\n .map(alwaysBundle =>\n isSetString(alwaysBundle)\n ? alwaysBundle\n : isRegExp(alwaysBundle)\n ? alwaysBundle.source\n : \"<unknown-bundle>\"\n )\n : undefined,\n onlyBundle: isSetArray(\n (config.deps as { onlyBundle?: unknown[] })?.onlyBundle\n )\n ? (\n (config.deps as { onlyBundle?: unknown[] })?.onlyBundle ??\n []\n )\n .filter(Boolean)\n .map(onlyBundle =>\n isSetString(onlyBundle)\n ? onlyBundle\n : isRegExp(onlyBundle)\n ? onlyBundle.source\n : \"<unknown-bundle>\"\n )\n : undefined,\n neverBundle: isSetArray(\n (config.deps as { neverBundle?: unknown[] })?.neverBundle\n )\n ? (\n (config.deps as { neverBundle?: unknown[] })?.neverBundle ??\n []\n )\n .filter(Boolean)\n .map(neverBundle =>\n isSetString(neverBundle)\n ? neverBundle\n : isRegExp(neverBundle)\n ? neverBundle.source\n : \"<unknown-bundle>\"\n )\n : undefined\n }\n : undefined,\n\n resolve: isSetObject(config.resolve)\n ? {\n ...config.resolve,\n external: isSetArray((config.resolve as ResolveConfig)?.external)\n ? ((config.resolve as ResolveConfig)?.external ?? [])\n .filter(Boolean)\n .map(external =>\n isSetString(external)\n ? external\n : isRegExp(external)\n ? external.source\n : \"<unknown-bundle>\"\n )\n : undefined,\n noExternal: isSetArray(\n (config.resolve as ResolveConfig)?.noExternal\n )\n ? ((config.resolve as ResolveConfig)?.noExternal ?? [])\n .filter(Boolean)\n .map(noExternal =>\n isSetString(noExternal)\n ? noExternal\n : isRegExp(noExternal)\n ? noExternal.source\n : \"<unknown-bundle>\"\n )\n : undefined\n }\n : undefined,\n plugins: isSetArray(config.plugins)\n ? (toArray(config.plugins) as ResolvedConfig[\"plugins\"])\n ?.flatMap(plugin => toArray(plugin))\n ?.map(plugin =>\n String(\n isSetString(plugin)\n ? plugin\n : isSetObject(plugin) &&\n isSetString((plugin as { name: string }).name)\n ? (plugin as { name: string }).name\n : Array.isArray(plugin) && isSetString(plugin[0])\n ? plugin[0]\n : \"<function-plugin>\"\n )\n )\n : undefined\n }).sort(([key1], [key2]) => key1.localeCompare(key2))\n ),\n null,\n 4\n )\n .replace(/\"([^\"]+)\":/g, \"$1:\")\n .replace(/,\\s*$/g, \"\");\n}\n"],"mappings":";;;;;;;;;;;;;;AAgCA,SAAgB,aAAa,QAAqC;CAChE,OAAO,KAAK,UACV,OAAO,YACL,OAAO,QAAQ;EACb,GAAG,KAAK,QAAQ;GACd;GACA;GACA;GACA;GACA;GACA;GACA;GACA;EACF,CAAC;EACD,MAAM,YAAY,OAAO,IAAI,IACzB;GACE,cAAc,WACX,OAAO,MAAuC,YACjD,KAEO,OAAO,MACJ,gBAAgB,CAAC,EAAC,CAErB,OAAO,OAAO,CAAC,CACf,KAAI,iBACH,YAAY,YAAY,IACpB,eACA,SAAS,YAAY,IACnB,aAAa,SACb,kBACR,IACF;GACJ,YAAY,WACT,OAAO,MAAqC,UAC/C,KAEO,OAAO,MAAqC,cAC7C,CAAC,EAAC,CAED,OAAO,OAAO,CAAC,CACf,KAAI,eACH,YAAY,UAAU,IAClB,aACA,SAAS,UAAU,IACjB,WAAW,SACX,kBACR,IACF;GACJ,aAAa,WACV,OAAO,MAAsC,WAChD,KAEO,OAAO,MAAsC,eAC9C,CAAC,EAAC,CAED,OAAO,OAAO,CAAC,CACf,KAAI,gBACH,YAAY,WAAW,IACnB,cACA,SAAS,WAAW,IAClB,YAAY,SACZ,kBACR,IACF;EACN,IACA;EAEJ,SAAS,YAAY,OAAO,OAAO,IAC/B;GACE,GAAG,OAAO;GACV,UAAU,WAAY,OAAO,SAA2B,QAAQ,KAC1D,OAAO,SAA2B,YAAY,CAAC,EAAC,CAC/C,OAAO,OAAO,CAAC,CACf,KAAI,aACH,YAAY,QAAQ,IAChB,WACA,SAAS,QAAQ,IACf,SAAS,SACT,kBACR,IACF;GACJ,YAAY,WACT,OAAO,SAA2B,UACrC,KACM,OAAO,SAA2B,cAAc,CAAC,EAAC,CACjD,OAAO,OAAO,CAAC,CACf,KAAI,eACH,YAAY,UAAU,IAClB,aACA,SAAS,UAAU,IACjB,WAAW,SACX,kBACR,IACF;EACN,IACA;EACJ,SAAS,WAAW,OAAO,OAAO,IAC7B,QAAQ,OAAO,OAAO,CAAC,EACpB,SAAQ,WAAU,QAAQ,MAAM,CAAC,CAAC,EAClC,KAAI,WACJ,OACE,YAAY,MAAM,IACd,SACA,YAAY,MAAM,KAChB,YAAa,OAA4B,IAAI,IAC5C,OAA4B,OAC7B,MAAM,QAAQ,MAAM,KAAK,YAAY,OAAO,EAAE,IAC5C,OAAO,KACP,mBACV,CACF,IACF;CACN,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,UAAU,KAAK,cAAc,IAAI,CAAC,CACtD,GACA,MACA,CACF,CAAC,CACE,QAAQ,eAAe,KAAK,CAAC,CAC7B,QAAQ,UAAU,EAAE;AACzB"}
|
|
@@ -72,7 +72,7 @@ declare function getHookHandler<TContext extends PluginContext = PluginContext,
|
|
|
72
72
|
* @returns The extracted hook, or undefined if the hook does not exist
|
|
73
73
|
*/
|
|
74
74
|
declare function extractPluginHook<TContext extends PluginContext = PluginContext, TPlugin extends Plugin<TContext> = Plugin<TContext>>(context: TContext, plugin: TPlugin, hook: keyof PluginHooks<TContext>): {
|
|
75
|
-
normal: OmitThisParameter<((this: TContext, code: string) => import("@stryke/types/base").MaybePromise<TypesResult | string | undefined | null>) | ((this: import("unplugin").UnpluginBuildContext & PluginContext<TContext["config"], any> & TContext, code: string, id: string) => import("@stryke/types/base").MaybePromise<import("unplugin").TransformResult>) | (((this: import("unplugin").UnpluginBuildContext & PluginContext<TContext["config"], any> & TContext, code: string, id: string) => import("@stryke/types/base").MaybePromise<import("unplugin").TransformResult>) & PluginHookObject<(this: import("unplugin").UnpluginBuildContext & PluginContext<TContext["config"], any> & TContext, code: string, id: string) => import("@stryke/types/base").MaybePromise<import("unplugin").TransformResult>, "
|
|
75
|
+
normal: OmitThisParameter<((this: TContext, code: string) => import("@stryke/types/base").MaybePromise<TypesResult | string | undefined | null>) | ((this: import("unplugin").UnpluginBuildContext & PluginContext<TContext["config"], any> & TContext, code: string, id: string) => import("@stryke/types/base").MaybePromise<import("unplugin").TransformResult>) | (((this: import("unplugin").UnpluginBuildContext & PluginContext<TContext["config"], any> & TContext, code: string, id: string) => import("@stryke/types/base").MaybePromise<import("unplugin").TransformResult>) & PluginHookObject<(this: import("unplugin").UnpluginBuildContext & PluginContext<TContext["config"], any> & TContext, code: string, id: string) => import("@stryke/types/base").MaybePromise<import("unplugin").TransformResult>, "code" | "id">) | (PluginHookObject<(this: import("unplugin").UnpluginBuildContext & PluginContext<TContext["config"], any> & TContext, code: string, id: string) => import("@stryke/types/base").MaybePromise<import("unplugin").TransformResult>, never> & ((this: import("unplugin").UnpluginBuildContext & PluginContext<TContext["config"], any> & TContext, code: string, id: string) => import("@stryke/types/base").MaybePromise<import("unplugin").TransformResult>)) | ((this: import("unplugin").UnpluginBuildContext & PluginContext<TContext["config"], any> & TContext, id: string) => import("@stryke/types/base").MaybePromise<import("rollup").LoadResult>) | (((this: import("unplugin").UnpluginBuildContext & PluginContext<TContext["config"], any> & TContext, id: string) => import("@stryke/types/base").MaybePromise<import("rollup").LoadResult>) & PluginHookObject<(this: import("unplugin").UnpluginBuildContext & PluginContext<TContext["config"], any> & TContext, id: string) => import("@stryke/types/base").MaybePromise<import("rollup").LoadResult>, "id">) | (PluginHookObject<(this: import("unplugin").UnpluginBuildContext & PluginContext<TContext["config"], any> & TContext, id: string) => import("@stryke/types/base").MaybePromise<import("rollup").LoadResult>, never> & ((this: import("unplugin").UnpluginBuildContext & PluginContext<TContext["config"], any> & TContext, id: string) => import("@stryke/types/base").MaybePromise<import("rollup").LoadResult>)) | ((this: import("unplugin").UnpluginBuildContext & PluginContext<TContext["config"], any> & TContext, id: string, importer: string | undefined, options: {
|
|
76
76
|
isEntry: boolean;
|
|
77
77
|
}) => import("@stryke/types/base").MaybePromise<string | ResolveResult | null | undefined>) | (((this: import("unplugin").UnpluginBuildContext & PluginContext<TContext["config"], any> & TContext, id: string, importer: string | undefined, options: {
|
|
78
78
|
isEntry: boolean;
|
|
@@ -72,7 +72,7 @@ declare function getHookHandler<TContext extends PluginContext = PluginContext,
|
|
|
72
72
|
* @returns The extracted hook, or undefined if the hook does not exist
|
|
73
73
|
*/
|
|
74
74
|
declare function extractPluginHook<TContext extends PluginContext = PluginContext, TPlugin extends Plugin<TContext> = Plugin<TContext>>(context: TContext, plugin: TPlugin, hook: keyof PluginHooks<TContext>): {
|
|
75
|
-
normal: OmitThisParameter<((this: TContext, code: string) => import("@stryke/types/base").MaybePromise<TypesResult | string | undefined | null>) | ((this: import("unplugin").UnpluginBuildContext & PluginContext<TContext["config"], any> & TContext, code: string, id: string) => import("@stryke/types/base").MaybePromise<import("unplugin").TransformResult>) | (((this: import("unplugin").UnpluginBuildContext & PluginContext<TContext["config"], any> & TContext, code: string, id: string) => import("@stryke/types/base").MaybePromise<import("unplugin").TransformResult>) & PluginHookObject<(this: import("unplugin").UnpluginBuildContext & PluginContext<TContext["config"], any> & TContext, code: string, id: string) => import("@stryke/types/base").MaybePromise<import("unplugin").TransformResult>, "
|
|
75
|
+
normal: OmitThisParameter<((this: TContext, code: string) => import("@stryke/types/base").MaybePromise<TypesResult | string | undefined | null>) | ((this: import("unplugin").UnpluginBuildContext & PluginContext<TContext["config"], any> & TContext, code: string, id: string) => import("@stryke/types/base").MaybePromise<import("unplugin").TransformResult>) | (((this: import("unplugin").UnpluginBuildContext & PluginContext<TContext["config"], any> & TContext, code: string, id: string) => import("@stryke/types/base").MaybePromise<import("unplugin").TransformResult>) & PluginHookObject<(this: import("unplugin").UnpluginBuildContext & PluginContext<TContext["config"], any> & TContext, code: string, id: string) => import("@stryke/types/base").MaybePromise<import("unplugin").TransformResult>, "code" | "id">) | (PluginHookObject<(this: import("unplugin").UnpluginBuildContext & PluginContext<TContext["config"], any> & TContext, code: string, id: string) => import("@stryke/types/base").MaybePromise<import("unplugin").TransformResult>, never> & ((this: import("unplugin").UnpluginBuildContext & PluginContext<TContext["config"], any> & TContext, code: string, id: string) => import("@stryke/types/base").MaybePromise<import("unplugin").TransformResult>)) | ((this: import("unplugin").UnpluginBuildContext & PluginContext<TContext["config"], any> & TContext, id: string) => import("@stryke/types/base").MaybePromise<import("rollup").LoadResult>) | (((this: import("unplugin").UnpluginBuildContext & PluginContext<TContext["config"], any> & TContext, id: string) => import("@stryke/types/base").MaybePromise<import("rollup").LoadResult>) & PluginHookObject<(this: import("unplugin").UnpluginBuildContext & PluginContext<TContext["config"], any> & TContext, id: string) => import("@stryke/types/base").MaybePromise<import("rollup").LoadResult>, "id">) | (PluginHookObject<(this: import("unplugin").UnpluginBuildContext & PluginContext<TContext["config"], any> & TContext, id: string) => import("@stryke/types/base").MaybePromise<import("rollup").LoadResult>, never> & ((this: import("unplugin").UnpluginBuildContext & PluginContext<TContext["config"], any> & TContext, id: string) => import("@stryke/types/base").MaybePromise<import("rollup").LoadResult>)) | ((this: import("unplugin").UnpluginBuildContext & PluginContext<TContext["config"], any> & TContext, id: string, importer: string | undefined, options: {
|
|
76
76
|
isEntry: boolean;
|
|
77
77
|
}) => import("@stryke/types/base").MaybePromise<string | ResolveResult | null | undefined>) | (((this: import("unplugin").UnpluginBuildContext & PluginContext<TContext["config"], any> & TContext, id: string, importer: string | undefined, options: {
|
|
78
78
|
isEntry: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.mjs","names":[],"sources":["../../src/plugin-utils/helpers.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 { kebabCase } from \"@stryke/string-format/kebab-case\";\nimport { isFunction } from \"@stryke/type-checks/is-function\";\nimport { isSetObject } from \"@stryke/type-checks/is-set-object\";\nimport { isSetString } from \"@stryke/type-checks/is-set-string\";\nimport { isUndefined } from \"@stryke/type-checks/is-undefined\";\nimport type { AnyFunction } from \"@stryke/types/base\";\nimport {\n PLUGIN_HOOKS_FIELDS,\n PLUGIN_NON_HOOK_FIELDS,\n UNPLUGIN_BUILDER_VARIANTS\n} from \"../constants/plugin\";\nimport type {\n PluginConfig,\n PluginConfigObject,\n PluginConfigTuple\n} from \"../types/config\";\nimport type { PluginContext, WithUnpluginBuildContext } from \"../types/context\";\nimport type { HooksListItem } from \"../types/hooks\";\nimport type {\n Plugin,\n PluginHook,\n PluginHookFields,\n PluginHookObject,\n PluginHooks\n} from \"../types/plugin\";\nimport type {\n UnpluginBuilderVariant,\n UnpluginOptions\n} from \"../types/unplugin\";\n\n/**\n * Type guard to check if an object is a {@link Plugin}\n *\n * @param value - The object to check\n * @returns True if the object is a {@link Plugin}, false otherwise\n */\nexport function isPlugin<TContext extends PluginContext = PluginContext>(\n value: unknown\n): value is Plugin<TContext> {\n return (\n isSetObject(value) &&\n \"name\" in value &&\n isSetString(value.name) &&\n (isUndefined((value as Plugin<TContext>).api) ||\n (\"api\" in value && isSetObject(value.api))) &&\n (isUndefined((value as Plugin<TContext>).applyToEnvironment) ||\n (\"applyToEnvironment\" in value &&\n isFunction(value.applyToEnvironment))) &&\n (isUndefined((value as Plugin<TContext>).dedupe) ||\n (\"dedupe\" in value && isFunction(value.dedupe))) &&\n PLUGIN_HOOKS_FIELDS.every(\n hook =>\n isUndefined((value as Record<string, unknown>)[hook]) ||\n (hook in value &&\n (isPluginHookFunction((value as Record<string, unknown>)[hook]) ||\n (hook === \"config\" &&\n isSetObject((value as Plugin<TContext>)[hook]))))\n )\n );\n}\n\n/**\n * Type guard to check if an object is a {@link PluginConfigObject}\n *\n * @param value - The object to check\n * @returns True if the object is a {@link PluginConfigObject}, false otherwise\n */\nexport function isPluginConfigObject<\n TContext extends PluginContext = PluginContext\n>(value: unknown): value is PluginConfigObject<TContext> {\n return (\n isSetObject(value) &&\n \"plugin\" in value &&\n (((isSetString(value.plugin) || isFunction(value.plugin)) &&\n \"options\" in value &&\n isSetObject(value.options)) ||\n isPlugin(value.plugin))\n );\n}\n\n/**\n * Type guard to check if an object is a {@link PluginConfigTuple}\n *\n * @param value - The object to check\n * @returns True if the object is a {@link PluginConfigTuple}, false otherwise\n */\nexport function isPluginConfigTuple<\n TContext extends PluginContext = PluginContext\n>(value: unknown): value is PluginConfigTuple<TContext> {\n return (\n Array.isArray(value) &&\n (value.length === 1 || value.length === 2) &&\n (((isSetString(value[0]) || isFunction(value[0])) &&\n value.length > 1 &&\n isSetObject(value[1])) ||\n isPlugin(value[0]))\n );\n}\n\n/**\n * Type guard to check if an object is a {@link PluginConfig}\n *\n * @param value - The object to check\n * @returns True if the object is a {@link PluginConfig}, false otherwise\n */\nexport function isPluginConfig<TContext extends PluginContext = PluginContext>(\n value: unknown\n): value is PluginConfig<TContext> {\n return (\n isSetString(value) ||\n isFunction(value) ||\n isPlugin(value) ||\n isPluginConfigObject(value) ||\n isPluginConfigTuple(value) ||\n (Array.isArray(value) && value.every(item => isPluginConfig(item)))\n );\n}\n\n/**\n * Type guard to check if an value is a {@link PluginHook} function\n *\n * @param value - The value to check\n * @returns True if the value is a {@link PluginHook} function, false otherwise\n */\nexport function isPluginHookObject(\n value: unknown\n): value is PluginHookObject<AnyFunction> {\n return isSetObject(value) && \"handler\" in value && isFunction(value.handler);\n}\n\n/**\n * Type guard to check if an value is a {@link PluginHook} function\n *\n * @param value - The value to check\n * @returns True if the value is a {@link PluginHook} function, false otherwise\n */\nexport function isPluginHookFunction(value: unknown): value is AnyFunction {\n return isFunction(value) || isPluginHookObject(value);\n}\n\n/**\n * Type guard to check if an object is a {@link PluginHook}\n *\n * @param value - The object to check\n * @returns True if the object is a {@link PluginHook}, false otherwise\n */\nexport function isPluginHook(value: unknown): value is PluginHook<AnyFunction> {\n return isPluginHookFunction(value) || isPluginHookObject(value);\n}\n\nexport type GetHookHandlerReturnType<\n TContext extends PluginContext = PluginContext,\n TField extends string = string\n> = HooksListItem<TContext, TField>[\"handler\"];\n\n/**\n * Extract the hook handler function from a plugin hook\n *\n * @param pluginHook - The plugin hook to extract the handler function from\n * @returns The hook handler function\n */\nexport function getHookHandler<\n TContext extends PluginContext = PluginContext,\n TKey extends string = string\n>(\n pluginHook: PluginHook<AnyFunction>\n): GetHookHandlerReturnType<TContext, TKey> {\n return (\n isFunction(pluginHook) ? pluginHook : pluginHook.handler\n ) as GetHookHandlerReturnType<TContext, TKey>;\n}\n\n/**\n * Extract a plugin hook from a plugin\n *\n * @param context - The build context\n * @param plugin - The plugin to extract the hook from\n * @param hook - The name of the hook to extract\n * @returns The extracted hook, or undefined if the hook does not exist\n */\nexport function extractPluginHook<\n TContext extends PluginContext = PluginContext,\n TPlugin extends Plugin<TContext> = Plugin<TContext>\n>(context: TContext, plugin: TPlugin, hook: keyof PluginHooks<TContext>) {\n const pluginHook = plugin[hook];\n if (!isPluginHook(pluginHook)) {\n return undefined;\n }\n\n return isFunction(pluginHook)\n ? {\n normal: pluginHook.bind(context)\n }\n : {\n [pluginHook.order ? pluginHook.order : \"normal\"]:\n pluginHook.handler.bind(context)\n };\n}\n\n/**\n * Check if a hook is external.\n *\n * @param keys - The name of the hook to check.\n * @returns True if the hook is external, false otherwise.\n */\nexport function isUnpluginHookKey<\n TUnpluginBuilderVariant extends UnpluginBuilderVariant =\n UnpluginBuilderVariant,\n TContext extends PluginContext = PluginContext\n>(\n keys: string\n): keys is `${TUnpluginBuilderVariant}:${keyof UnpluginOptions<TContext>[TUnpluginBuilderVariant] & string}` {\n return UNPLUGIN_BUILDER_VARIANTS.some(variant =>\n keys.startsWith(`${variant}:`)\n );\n}\n\n/**\n * Check if a hook is internal.\n *\n * @param keys - The name of the hook to check.\n * @returns True if the hook is external, false otherwise.\n */\nexport function isPluginHookField<TContext extends PluginContext>(\n keys: string\n) {\n return !PLUGIN_NON_HOOK_FIELDS.includes(keys as PluginHookFields<TContext>);\n}\n\n/**\n * Check if a hook is external.\n *\n * @param field - The name of the hook to check.\n * @returns True if the hook is external, false otherwise.\n */\nexport function isUnpluginHookField<\n TUnpluginBuilderVariant extends UnpluginBuilderVariant =\n UnpluginBuilderVariant\n>(field: string): field is TUnpluginBuilderVariant {\n return (\n !isPluginHookField(field) &&\n UNPLUGIN_BUILDER_VARIANTS.includes(field as UnpluginBuilderVariant)\n );\n}\n\n/**\n * Check if a plugin should be deduplicated.\n *\n * @param plugin - The plugin to check\n * @param plugins - The list of plugins to check against\n * @returns True if the plugin should be deduplicated, false otherwise\n */\nexport function isDuplicate<TContext extends PluginContext = PluginContext>(\n plugin: Plugin<TContext>,\n plugins: Plugin<TContext>[]\n) {\n return (\n plugin.dedupe !== false &&\n plugins.some(\n p =>\n p.dedupe !== false &&\n ((isFunction(p.dedupe) && p.dedupe(plugin)) ||\n kebabCase(p.name) === kebabCase(plugin.name))\n )\n );\n}\n\n/**\n * Remove duplicate hooks from a list of hooks, keeping the first occurrence of each plugin.\n *\n * @param hooksList - The list of hooks to deduplicate.\n * @returns A new list of hooks with duplicates removed.\n */\nexport function dedupeHooklist<\n TContext extends PluginContext = PluginContext,\n TField extends PluginHookFields<TContext> = PluginHookFields<TContext>,\n TList extends HooksListItem<TContext, TField> = HooksListItem<\n TContext,\n TField\n >\n>(hooksList: TList[]): TList[] {\n return hooksList.reduce((ret, hook) => {\n if (\n !isDuplicate(\n hook.plugin,\n ret.map(h => h.plugin)\n )\n ) {\n ret.push(hook);\n }\n return ret;\n }, [] as TList[]);\n}\n\n/**\n * Add a plugin hook to the hooks list.\n *\n * @param context - The plugin context\n * @param plugin - The plugin to add the hook from\n * @param pluginHook - The plugin hook to add\n * @param hooksList - The list of hooks to add to\n */\nexport function addPluginHook<\n TContext extends PluginContext = PluginContext,\n TField extends PluginHookFields<TContext> = PluginHookFields<TContext>,\n TList extends HooksListItem<TContext, TField> = HooksListItem<\n TContext,\n TField\n >\n>(\n context: TContext,\n plugin: Plugin<TContext>,\n pluginHook: PluginHook<AnyFunction>,\n hooksList: TList[]\n): TList[] {\n if (\n !isDuplicate(plugin, hooksList.map(hook => hook.plugin).filter(Boolean))\n ) {\n const handler = ((...args: unknown[]) =>\n (\n getHookHandler<WithUnpluginBuildContext<TContext>, TField>(\n pluginHook\n ) as unknown as (...args: unknown[]) => unknown\n ).apply(context, args)) as GetHookHandlerReturnType<TContext, TField>;\n if (!handler) {\n return hooksList;\n }\n\n hooksList.push({\n plugin,\n handler\n } as any);\n }\n\n return hooksList;\n}\n\n/**\n * Check the provided {@link PluginConfig}, and return a stringified version of the invalid configuration. If an array is provided, check each item in the array.\n *\n * @param config - The plugin configuration to check\n * @returns Null if the configuration is valid, otherwise an array of stringified invalid configurations\n */\nexport function findInvalidPluginConfig<\n TContext extends PluginContext = PluginContext\n>(config: PluginConfig<TContext>): string[] | null {\n if (isPluginConfig<TContext>(config)) {\n return null;\n }\n\n if (Array.isArray(config as PluginConfig<TContext>[])) {\n const invalidItems: string[] = [];\n (config as PluginConfig<TContext>[]).forEach(item => {\n const invalid = findInvalidPluginConfig<TContext>(item);\n if (invalid) {\n invalidItems.push(...invalid.map(i => JSON.stringify(i, null, 2)));\n }\n });\n\n return invalidItems.length > 0 ? invalidItems : null;\n }\n\n return [JSON.stringify(config, null, 2)];\n}\n"],"mappings":";;;;;;;;;;;;;;AAsDA,SAAgB,SACd,OAC2B;CAC3B,OACE,YAAY,KAAK,KACjB,UAAU,SACV,YAAY,MAAM,IAAI,MACrB,YAAa,MAA2B,GAAG,KACzC,SAAS,SAAS,YAAY,MAAM,GAAG,OACzC,YAAa,MAA2B,kBAAkB,KACxD,wBAAwB,SACvB,WAAW,MAAM,kBAAkB,OACtC,YAAa,MAA2B,MAAM,KAC5C,YAAY,SAAS,WAAW,MAAM,MAAM,MAC/C,oBAAoB,OAClB,SACE,YAAa,MAAkC,KAAK,KACnD,QAAQ,UACN,qBAAsB,MAAkC,KAAK,KAC3D,SAAS,YACR,YAAa,MAA2B,KAAK,EACvD;AAEJ;;;;;;;AAQA,SAAgB,qBAEd,OAAuD;CACvD,OACE,YAAY,KAAK,KACjB,YAAY,WACT,YAAY,MAAM,MAAM,KAAK,WAAW,MAAM,MAAM,MACrD,aAAa,SACb,YAAY,MAAM,OAAO,KACzB,SAAS,MAAM,MAAM;AAE3B;;;;;;;AAQA,SAAgB,oBAEd,OAAsD;CACtD,OACE,MAAM,QAAQ,KAAK,MAClB,MAAM,WAAW,KAAK,MAAM,WAAW,QACrC,YAAY,MAAM,EAAE,KAAK,WAAW,MAAM,EAAE,MAC7C,MAAM,SAAS,KACf,YAAY,MAAM,EAAE,KACpB,SAAS,MAAM,EAAE;AAEvB;;;;;;;AAQA,SAAgB,eACd,OACiC;CACjC,OACE,YAAY,KAAK,KACjB,WAAW,KAAK,KAChB,SAAS,KAAK,KACd,qBAAqB,KAAK,KAC1B,oBAAoB,KAAK,KACx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,KAAK,SAAS;EACrC,IACE,CAAC,YACC,KAAK,QACL,IAAI,KAAI,MAAK,EAAE,MAAM,CACvB,GAEA,IAAI,KAAK,IAAI;EAEf,OAAO;CACT,GAAG,CAAC,CAAY;AAClB;;;;;;;;;AAUA,SAAgB,cAQd,SACA,QACA,YACA,WACS;CACT,IACE,CAAC,YAAY,QAAQ,UAAU,KAAI,SAAQ,KAAK,MAAM,EAAE,OAAO,OAAO,CAAC,GACvE;EACA,MAAM,YAAY,GAAG,SAEjB,eACE,UACF,EACA,MAAM,SAAS,IAAI;EACvB,IAAI,CAAC,SACH,OAAO;EAGT,UAAU,KAAK;GACb;GACA;EACF,CAAQ;CACV;CAEA,OAAO;AACT;;;;;;;AAQA,SAAgB,wBAEd,QAAiD;CACjD,IAAI,eAAyB,MAAM,GACjC,OAAO;CAGT,IAAI,MAAM,QAAQ,MAAkC,GAAG;EACrD,MAAM,eAAyB,CAAC;EAChC,AAAC,OAAoC,SAAQ,SAAQ;GACnD,MAAM,UAAU,wBAAkC,IAAI;GACtD,IAAI,SACF,aAAa,KAAK,GAAG,QAAQ,KAAI,MAAK,KAAK,UAAU,GAAG,MAAM,CAAC,CAAC,CAAC;EAErE,CAAC;EAED,OAAO,aAAa,SAAS,IAAI,eAAe;CAClD;CAEA,OAAO,CAAC,KAAK,UAAU,QAAQ,MAAM,CAAC,CAAC;AACzC"}
|
|
1
|
+
{"version":3,"file":"helpers.mjs","names":[],"sources":["../../src/plugin-utils/helpers.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 { kebabCase } from \"@stryke/string-format/kebab-case\";\nimport { isFunction } from \"@stryke/type-checks/is-function\";\nimport { isSetObject } from \"@stryke/type-checks/is-set-object\";\nimport { isSetString } from \"@stryke/type-checks/is-set-string\";\nimport { isUndefined } from \"@stryke/type-checks/is-undefined\";\nimport type { AnyFunction } from \"@stryke/types/base\";\nimport {\n PLUGIN_HOOKS_FIELDS,\n PLUGIN_NON_HOOK_FIELDS,\n UNPLUGIN_BUILDER_VARIANTS\n} from \"../constants/plugin\";\nimport type {\n PluginConfig,\n PluginConfigObject,\n PluginConfigTuple\n} from \"../types/config\";\nimport type { PluginContext, WithUnpluginBuildContext } from \"../types/context\";\nimport type { HooksListItem } from \"../types/hooks\";\nimport type {\n Plugin,\n PluginHook,\n PluginHookFields,\n PluginHookObject,\n PluginHooks\n} from \"../types/plugin\";\nimport type {\n UnpluginBuilderVariant,\n UnpluginOptions\n} from \"../types/unplugin\";\n\n/**\n * Type guard to check if an object is a {@link Plugin}\n *\n * @param value - The object to check\n * @returns True if the object is a {@link Plugin}, false otherwise\n */\nexport function isPlugin<TContext extends PluginContext = PluginContext>(\n value: unknown\n): value is Plugin<TContext> {\n return (\n isSetObject(value) &&\n \"name\" in value &&\n isSetString(value.name) &&\n (isUndefined((value as Plugin<TContext>).api) ||\n (\"api\" in value && isSetObject(value.api))) &&\n (isUndefined((value as Plugin<TContext>).applyToEnvironment) ||\n (\"applyToEnvironment\" in value &&\n isFunction(value.applyToEnvironment))) &&\n (isUndefined((value as Plugin<TContext>).dedupe) ||\n (\"dedupe\" in value && isFunction(value.dedupe))) &&\n PLUGIN_HOOKS_FIELDS.every(\n hook =>\n isUndefined((value as Record<string, unknown>)[hook]) ||\n (hook in value &&\n (isPluginHookFunction((value as Record<string, unknown>)[hook]) ||\n (hook === \"config\" &&\n isSetObject((value as Plugin<TContext>)[hook]))))\n )\n );\n}\n\n/**\n * Type guard to check if an object is a {@link PluginConfigObject}\n *\n * @param value - The object to check\n * @returns True if the object is a {@link PluginConfigObject}, false otherwise\n */\nexport function isPluginConfigObject<\n TContext extends PluginContext = PluginContext\n>(value: unknown): value is PluginConfigObject<TContext> {\n return (\n isSetObject(value) &&\n \"plugin\" in value &&\n (((isSetString(value.plugin) || isFunction(value.plugin)) &&\n \"options\" in value &&\n isSetObject(value.options)) ||\n isPlugin(value.plugin))\n );\n}\n\n/**\n * Type guard to check if an object is a {@link PluginConfigTuple}\n *\n * @param value - The object to check\n * @returns True if the object is a {@link PluginConfigTuple}, false otherwise\n */\nexport function isPluginConfigTuple<\n TContext extends PluginContext = PluginContext\n>(value: unknown): value is PluginConfigTuple<TContext> {\n return (\n Array.isArray(value) &&\n (value.length === 1 || value.length === 2) &&\n (((isSetString(value[0]) || isFunction(value[0])) &&\n value.length > 1 &&\n isSetObject(value[1])) ||\n isPlugin(value[0]))\n );\n}\n\n/**\n * Type guard to check if an object is a {@link PluginConfig}\n *\n * @param value - The object to check\n * @returns True if the object is a {@link PluginConfig}, false otherwise\n */\nexport function isPluginConfig<TContext extends PluginContext = PluginContext>(\n value: unknown\n): value is PluginConfig<TContext> {\n return (\n isSetString(value) ||\n isFunction(value) ||\n isPlugin(value) ||\n isPluginConfigObject(value) ||\n isPluginConfigTuple(value) ||\n (Array.isArray(value) && value.every(item => isPluginConfig(item)))\n );\n}\n\n/**\n * Type guard to check if an value is a {@link PluginHook} function\n *\n * @param value - The value to check\n * @returns True if the value is a {@link PluginHook} function, false otherwise\n */\nexport function isPluginHookObject(\n value: unknown\n): value is PluginHookObject<AnyFunction> {\n return isSetObject(value) && \"handler\" in value && isFunction(value.handler);\n}\n\n/**\n * Type guard to check if an value is a {@link PluginHook} function\n *\n * @param value - The value to check\n * @returns True if the value is a {@link PluginHook} function, false otherwise\n */\nexport function isPluginHookFunction(value: unknown): value is AnyFunction {\n return isFunction(value) || isPluginHookObject(value);\n}\n\n/**\n * Type guard to check if an object is a {@link PluginHook}\n *\n * @param value - The object to check\n * @returns True if the object is a {@link PluginHook}, false otherwise\n */\nexport function isPluginHook(value: unknown): value is PluginHook<AnyFunction> {\n return isPluginHookFunction(value) || isPluginHookObject(value);\n}\n\nexport type GetHookHandlerReturnType<\n TContext extends PluginContext = PluginContext,\n TField extends string = string\n> = HooksListItem<TContext, TField>[\"handler\"];\n\n/**\n * Extract the hook handler function from a plugin hook\n *\n * @param pluginHook - The plugin hook to extract the handler function from\n * @returns The hook handler function\n */\nexport function getHookHandler<\n TContext extends PluginContext = PluginContext,\n TKey extends string = string\n>(\n pluginHook: PluginHook<AnyFunction>\n): GetHookHandlerReturnType<TContext, TKey> {\n return (\n isFunction(pluginHook) ? pluginHook : pluginHook.handler\n ) as GetHookHandlerReturnType<TContext, TKey>;\n}\n\n/**\n * Extract a plugin hook from a plugin\n *\n * @param context - The build context\n * @param plugin - The plugin to extract the hook from\n * @param hook - The name of the hook to extract\n * @returns The extracted hook, or undefined if the hook does not exist\n */\nexport function extractPluginHook<\n TContext extends PluginContext = PluginContext,\n TPlugin extends Plugin<TContext> = Plugin<TContext>\n>(context: TContext, plugin: TPlugin, hook: keyof PluginHooks<TContext>) {\n const pluginHook = plugin[hook];\n if (!isPluginHook(pluginHook)) {\n return undefined;\n }\n\n return isFunction(pluginHook)\n ? {\n normal: pluginHook.bind(context)\n }\n : {\n [pluginHook.order ? pluginHook.order : \"normal\"]:\n pluginHook.handler.bind(context)\n };\n}\n\n/**\n * Check if a hook is external.\n *\n * @param keys - The name of the hook to check.\n * @returns True if the hook is external, false otherwise.\n */\nexport function isUnpluginHookKey<\n TUnpluginBuilderVariant extends UnpluginBuilderVariant =\n UnpluginBuilderVariant,\n TContext extends PluginContext = PluginContext\n>(\n keys: string\n): keys is `${TUnpluginBuilderVariant}:${keyof UnpluginOptions<TContext>[TUnpluginBuilderVariant] & string}` {\n return UNPLUGIN_BUILDER_VARIANTS.some(variant =>\n keys.startsWith(`${variant}:`)\n );\n}\n\n/**\n * Check if a hook is internal.\n *\n * @param keys - The name of the hook to check.\n * @returns True if the hook is external, false otherwise.\n */\nexport function isPluginHookField<TContext extends PluginContext>(\n keys: string\n) {\n return !PLUGIN_NON_HOOK_FIELDS.includes(keys as PluginHookFields<TContext>);\n}\n\n/**\n * Check if a hook is external.\n *\n * @param field - The name of the hook to check.\n * @returns True if the hook is external, false otherwise.\n */\nexport function isUnpluginHookField<\n TUnpluginBuilderVariant extends UnpluginBuilderVariant =\n UnpluginBuilderVariant\n>(field: string): field is TUnpluginBuilderVariant {\n return (\n !isPluginHookField(field) &&\n UNPLUGIN_BUILDER_VARIANTS.includes(field as UnpluginBuilderVariant)\n );\n}\n\n/**\n * Check if a plugin should be deduplicated.\n *\n * @param plugin - The plugin to check\n * @param plugins - The list of plugins to check against\n * @returns True if the plugin should be deduplicated, false otherwise\n */\nexport function isDuplicate<TContext extends PluginContext = PluginContext>(\n plugin: Plugin<TContext>,\n plugins: Plugin<TContext>[]\n) {\n return (\n plugin.dedupe !== false &&\n plugins.some(\n p =>\n p.dedupe !== false &&\n ((isFunction(p.dedupe) && p.dedupe(plugin)) ||\n kebabCase(p.name) === kebabCase(plugin.name))\n )\n );\n}\n\n/**\n * Remove duplicate hooks from a list of hooks, keeping the first occurrence of each plugin.\n *\n * @param hooksList - The list of hooks to deduplicate.\n * @returns A new list of hooks with duplicates removed.\n */\nexport function dedupeHooklist<\n TContext extends PluginContext = PluginContext,\n TField extends PluginHookFields<TContext> = PluginHookFields<TContext>,\n TList extends HooksListItem<TContext, TField> = HooksListItem<\n TContext,\n TField\n >\n>(hooksList: TList[]): TList[] {\n return hooksList.reduce((ret, hook) => {\n if (\n !isDuplicate(\n hook.plugin,\n ret.map(h => h.plugin)\n )\n ) {\n ret.push(hook);\n }\n return ret;\n }, [] as TList[]);\n}\n\n/**\n * Add a plugin hook to the hooks list.\n *\n * @param context - The plugin context\n * @param plugin - The plugin to add the hook from\n * @param pluginHook - The plugin hook to add\n * @param hooksList - The list of hooks to add to\n */\nexport function addPluginHook<\n TContext extends PluginContext = PluginContext,\n TField extends PluginHookFields<TContext> = PluginHookFields<TContext>,\n TList extends HooksListItem<TContext, TField> = HooksListItem<\n TContext,\n TField\n >\n>(\n context: TContext,\n plugin: Plugin<TContext>,\n pluginHook: PluginHook<AnyFunction>,\n hooksList: TList[]\n): TList[] {\n if (\n !isDuplicate(plugin, hooksList.map(hook => hook.plugin).filter(Boolean))\n ) {\n const handler = ((...args: unknown[]) =>\n (\n getHookHandler<WithUnpluginBuildContext<TContext>, TField>(\n pluginHook\n ) as unknown as (...args: unknown[]) => unknown\n ).apply(context, args)) as GetHookHandlerReturnType<TContext, TField>;\n if (!handler) {\n return hooksList;\n }\n\n hooksList.push({\n plugin,\n handler\n } as any);\n }\n\n return hooksList;\n}\n\n/**\n * Check the provided {@link PluginConfig}, and return a stringified version of the invalid configuration. If an array is provided, check each item in the array.\n *\n * @param config - The plugin configuration to check\n * @returns Null if the configuration is valid, otherwise an array of stringified invalid configurations\n */\nexport function findInvalidPluginConfig<\n TContext extends PluginContext = PluginContext\n>(config: PluginConfig<TContext>): string[] | null {\n if (isPluginConfig<TContext>(config)) {\n return null;\n }\n\n if (Array.isArray(config as PluginConfig<TContext>[])) {\n const invalidItems: string[] = [];\n (config as PluginConfig<TContext>[]).forEach(item => {\n const invalid = findInvalidPluginConfig<TContext>(item);\n if (invalid) {\n invalidItems.push(...invalid.map(i => JSON.stringify(i, null, 2)));\n }\n });\n\n return invalidItems.length > 0 ? invalidItems : null;\n }\n\n return [JSON.stringify(config, null, 2)];\n}\n"],"mappings":";;;;;;;;;;;;;;AAsDA,SAAgB,SACd,OAC2B;CAC3B,OACE,YAAY,KAAK,KACjB,UAAU,SACV,YAAY,MAAM,IAAI,MACrB,YAAa,MAA2B,GAAG,KACzC,SAAS,SAAS,YAAY,MAAM,GAAG,OACzC,YAAa,MAA2B,kBAAkB,KACxD,wBAAwB,SACvB,WAAW,MAAM,kBAAkB,OACtC,YAAa,MAA2B,MAAM,KAC5C,YAAY,SAAS,WAAW,MAAM,MAAM,MAC/C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EACrD,MAAM,eAAyB,CAAC;EAChC,AAAC,OAAoC,SAAQ,SAAQ;GACnD,MAAM,UAAU,wBAAkC,IAAI;GACtD,IAAI,SACF,aAAa,KAAK,GAAG,QAAQ,KAAI,MAAK,KAAK,UAAU,GAAG,MAAM,CAAC,CAAC,CAAC;EAErE,CAAC;EAED,OAAO,aAAa,SAAS,IAAI,eAAe;CAClD;CAEA,OAAO,CAAC,KAAK,UAAU,QAAQ,MAAM,CAAC,CAAC;AACzC"}
|
|
@@ -49,6 +49,7 @@ exports.getConfigPath = require_plugin_utils_get_config_path.getConfigPath;
|
|
|
49
49
|
exports.getDependencyConfig = require_plugin_utils_build_helpers.getDependencyConfig;
|
|
50
50
|
exports.getDocsOutputPath = require_plugin_utils_docs_helper.getDocsOutputPath;
|
|
51
51
|
exports.getHookHandler = require_plugin_utils_helpers.getHookHandler;
|
|
52
|
+
exports.getName = require_plugin_utils_context_helpers.getName;
|
|
52
53
|
exports.getOrganizationName = require_plugin_utils_context_helpers.getOrganizationName;
|
|
53
54
|
exports.getPackageJsonOrganization = require_plugin_utils_context_helpers.getPackageJsonOrganization;
|
|
54
55
|
exports.getTextColor = require_plugin_utils_logging.getTextColor;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { GetDependencyConfigResult, getDependencyConfig } from "./build-helpers.cjs";
|
|
2
2
|
import { CombinePluginsOptions, combinePluginOptions, combinePlugins } from "./combine-plugins.cjs";
|
|
3
|
-
import { formatExecutionId, getOrganizationName, getPackageJsonOrganization, getWorkspaceName } from "./context-helpers.cjs";
|
|
3
|
+
import { formatExecutionId, getName, getOrganizationName, getPackageJsonOrganization, getWorkspaceName } from "./context-helpers.cjs";
|
|
4
4
|
import { getDocsOutputPath } from "./docs-helper.cjs";
|
|
5
5
|
import { enable } from "./enable-plugin.cjs";
|
|
6
6
|
import { extend } from "./extend.cjs";
|
|
@@ -15,4 +15,4 @@ import { MergeResult, merge, mergeConfig } from "./merge.cjs";
|
|
|
15
15
|
import { isBuiltinModule } from "./modules.cjs";
|
|
16
16
|
import { replacePathTokens } from "./paths.cjs";
|
|
17
17
|
import { PrefixRegexOptions, VIRTUAL_MODULE_PREFIX, VIRTUAL_MODULE_PREFIX_REGEX, addVirtualPrefix, createVirtualPrefixRegex, isVirtualModule, prefixRegex, removeVirtualPrefix } from "./virtual.cjs";
|
|
18
|
-
export { CombinePluginsOptions, GetDependencyConfigResult, GetHookHandlerReturnType, MergeResult, PrefixRegexOptions, VIRTUAL_MODULE_PREFIX, VIRTUAL_MODULE_PREFIX_REGEX, addPluginHook, addVirtualPrefix, colorBackground, colorText, combinePluginOptions, combinePlugins, consoleLog, consoleLogger, createCodeFilter, createFilter, createFilterForId, createFilterForTransform, createIdFilter, createLogFn, createLogger, createVirtualPrefixRegex, dedupeHooklist, enable, extend, extendLogFn, extendLogger, extractPluginHook, findInvalidPluginConfig, formatConfig, formatExecutionId, formatPackageJson, getConfigPath, getDependencyConfig, getDocsOutputPath, getHookHandler, getOrganizationName, getPackageJsonOrganization, getTextColor, getWorkspaceName, installPackage, installPackages, isBuiltinModule, isDuplicate, isPlugin, isPluginConfig, isPluginConfigObject, isPluginConfigTuple, isPluginHook, isPluginHookField, isPluginHookFunction, isPluginHookObject, isUnpluginHookField, isUnpluginHookKey, isValidLogLevel, isValidLogLevelConfig, isVerbose, isVirtualModule, merge, mergeConfig, normalizeFilter, normalizeSingleFilter, patternToCodeFilter, patternToIdFilter, prefixRegex, removeVirtualPrefix, replacePathTokens, resolveLogLevel, withCustomLogger, withLogFn, withLogger };
|
|
18
|
+
export { CombinePluginsOptions, GetDependencyConfigResult, GetHookHandlerReturnType, MergeResult, PrefixRegexOptions, VIRTUAL_MODULE_PREFIX, VIRTUAL_MODULE_PREFIX_REGEX, addPluginHook, addVirtualPrefix, colorBackground, colorText, combinePluginOptions, combinePlugins, consoleLog, consoleLogger, createCodeFilter, createFilter, createFilterForId, createFilterForTransform, createIdFilter, createLogFn, createLogger, createVirtualPrefixRegex, dedupeHooklist, enable, extend, extendLogFn, extendLogger, extractPluginHook, findInvalidPluginConfig, formatConfig, formatExecutionId, formatPackageJson, getConfigPath, getDependencyConfig, getDocsOutputPath, getHookHandler, getName, getOrganizationName, getPackageJsonOrganization, getTextColor, getWorkspaceName, installPackage, installPackages, isBuiltinModule, isDuplicate, isPlugin, isPluginConfig, isPluginConfigObject, isPluginConfigTuple, isPluginHook, isPluginHookField, isPluginHookFunction, isPluginHookObject, isUnpluginHookField, isUnpluginHookKey, isValidLogLevel, isValidLogLevelConfig, isVerbose, isVirtualModule, merge, mergeConfig, normalizeFilter, normalizeSingleFilter, patternToCodeFilter, patternToIdFilter, prefixRegex, removeVirtualPrefix, replacePathTokens, resolveLogLevel, withCustomLogger, withLogFn, withLogger };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { GetDependencyConfigResult, getDependencyConfig } from "./build-helpers.mjs";
|
|
2
2
|
import { CombinePluginsOptions, combinePluginOptions, combinePlugins } from "./combine-plugins.mjs";
|
|
3
|
-
import { formatExecutionId, getOrganizationName, getPackageJsonOrganization, getWorkspaceName } from "./context-helpers.mjs";
|
|
3
|
+
import { formatExecutionId, getName, getOrganizationName, getPackageJsonOrganization, getWorkspaceName } from "./context-helpers.mjs";
|
|
4
4
|
import { getDocsOutputPath } from "./docs-helper.mjs";
|
|
5
5
|
import { enable } from "./enable-plugin.mjs";
|
|
6
6
|
import { extend } from "./extend.mjs";
|
|
@@ -15,4 +15,4 @@ import { MergeResult, merge, mergeConfig } from "./merge.mjs";
|
|
|
15
15
|
import { isBuiltinModule } from "./modules.mjs";
|
|
16
16
|
import { replacePathTokens } from "./paths.mjs";
|
|
17
17
|
import { PrefixRegexOptions, VIRTUAL_MODULE_PREFIX, VIRTUAL_MODULE_PREFIX_REGEX, addVirtualPrefix, createVirtualPrefixRegex, isVirtualModule, prefixRegex, removeVirtualPrefix } from "./virtual.mjs";
|
|
18
|
-
export { CombinePluginsOptions, GetDependencyConfigResult, GetHookHandlerReturnType, MergeResult, PrefixRegexOptions, VIRTUAL_MODULE_PREFIX, VIRTUAL_MODULE_PREFIX_REGEX, addPluginHook, addVirtualPrefix, colorBackground, colorText, combinePluginOptions, combinePlugins, consoleLog, consoleLogger, createCodeFilter, createFilter, createFilterForId, createFilterForTransform, createIdFilter, createLogFn, createLogger, createVirtualPrefixRegex, dedupeHooklist, enable, extend, extendLogFn, extendLogger, extractPluginHook, findInvalidPluginConfig, formatConfig, formatExecutionId, formatPackageJson, getConfigPath, getDependencyConfig, getDocsOutputPath, getHookHandler, getOrganizationName, getPackageJsonOrganization, getTextColor, getWorkspaceName, installPackage, installPackages, isBuiltinModule, isDuplicate, isPlugin, isPluginConfig, isPluginConfigObject, isPluginConfigTuple, isPluginHook, isPluginHookField, isPluginHookFunction, isPluginHookObject, isUnpluginHookField, isUnpluginHookKey, isValidLogLevel, isValidLogLevelConfig, isVerbose, isVirtualModule, merge, mergeConfig, normalizeFilter, normalizeSingleFilter, patternToCodeFilter, patternToIdFilter, prefixRegex, removeVirtualPrefix, replacePathTokens, resolveLogLevel, withCustomLogger, withLogFn, withLogger };
|
|
18
|
+
export { CombinePluginsOptions, GetDependencyConfigResult, GetHookHandlerReturnType, MergeResult, PrefixRegexOptions, VIRTUAL_MODULE_PREFIX, VIRTUAL_MODULE_PREFIX_REGEX, addPluginHook, addVirtualPrefix, colorBackground, colorText, combinePluginOptions, combinePlugins, consoleLog, consoleLogger, createCodeFilter, createFilter, createFilterForId, createFilterForTransform, createIdFilter, createLogFn, createLogger, createVirtualPrefixRegex, dedupeHooklist, enable, extend, extendLogFn, extendLogger, extractPluginHook, findInvalidPluginConfig, formatConfig, formatExecutionId, formatPackageJson, getConfigPath, getDependencyConfig, getDocsOutputPath, getHookHandler, getName, getOrganizationName, getPackageJsonOrganization, getTextColor, getWorkspaceName, installPackage, installPackages, isBuiltinModule, isDuplicate, isPlugin, isPluginConfig, isPluginConfigObject, isPluginConfigTuple, isPluginHook, isPluginHookField, isPluginHookFunction, isPluginHookObject, isUnpluginHookField, isUnpluginHookKey, isValidLogLevel, isValidLogLevelConfig, isVerbose, isVirtualModule, merge, mergeConfig, normalizeFilter, normalizeSingleFilter, patternToCodeFilter, patternToIdFilter, prefixRegex, removeVirtualPrefix, replacePathTokens, resolveLogLevel, withCustomLogger, withLogFn, withLogger };
|
|
@@ -3,7 +3,7 @@ import { getDependencyConfig } from "./build-helpers.mjs";
|
|
|
3
3
|
import { addPluginHook, dedupeHooklist, extractPluginHook, findInvalidPluginConfig, getHookHandler, isDuplicate, isPlugin, isPluginConfig, isPluginConfigObject, isPluginConfigTuple, isPluginHook, isPluginHookField, isPluginHookFunction, isPluginHookObject, isUnpluginHookField, isUnpluginHookKey } from "./helpers.mjs";
|
|
4
4
|
import { merge, mergeConfig } from "./merge.mjs";
|
|
5
5
|
import { combinePluginOptions, combinePlugins } from "./combine-plugins.mjs";
|
|
6
|
-
import { formatExecutionId, getOrganizationName, getPackageJsonOrganization, getWorkspaceName } from "./context-helpers.mjs";
|
|
6
|
+
import { formatExecutionId, getName, getOrganizationName, getPackageJsonOrganization, getWorkspaceName } from "./context-helpers.mjs";
|
|
7
7
|
import { getDocsOutputPath } from "./docs-helper.mjs";
|
|
8
8
|
import { enable } from "./enable-plugin.mjs";
|
|
9
9
|
import { extend } from "./extend.mjs";
|
|
@@ -16,4 +16,4 @@ import { installPackage, installPackages } from "./install.mjs";
|
|
|
16
16
|
import { isBuiltinModule } from "./modules.mjs";
|
|
17
17
|
import { replacePathTokens } from "./paths.mjs";
|
|
18
18
|
|
|
19
|
-
export { VIRTUAL_MODULE_PREFIX, VIRTUAL_MODULE_PREFIX_REGEX, addPluginHook, addVirtualPrefix, colorBackground, colorText, combinePluginOptions, combinePlugins, consoleLog, consoleLogger, createCodeFilter, createFilter, createFilterForId, createFilterForTransform, createIdFilter, createLogFn, createLogger, createVirtualPrefixRegex, dedupeHooklist, enable, extend, extendLogFn, extendLogger, extractPluginHook, findInvalidPluginConfig, formatConfig, formatExecutionId, formatPackageJson, getConfigPath, getDependencyConfig, getDocsOutputPath, getHookHandler, getOrganizationName, getPackageJsonOrganization, getTextColor, getWorkspaceName, installPackage, installPackages, isBuiltinModule, isDuplicate, isPlugin, isPluginConfig, isPluginConfigObject, isPluginConfigTuple, isPluginHook, isPluginHookField, isPluginHookFunction, isPluginHookObject, isUnpluginHookField, isUnpluginHookKey, isValidLogLevel, isValidLogLevelConfig, isVerbose, isVirtualModule, merge, mergeConfig, normalizeFilter, normalizeSingleFilter, patternToCodeFilter, patternToIdFilter, prefixRegex, removeVirtualPrefix, replacePathTokens, resolveLogLevel, withCustomLogger, withLogFn, withLogger };
|
|
19
|
+
export { VIRTUAL_MODULE_PREFIX, VIRTUAL_MODULE_PREFIX_REGEX, addPluginHook, addVirtualPrefix, colorBackground, colorText, combinePluginOptions, combinePlugins, consoleLog, consoleLogger, createCodeFilter, createFilter, createFilterForId, createFilterForTransform, createIdFilter, createLogFn, createLogger, createVirtualPrefixRegex, dedupeHooklist, enable, extend, extendLogFn, extendLogger, extractPluginHook, findInvalidPluginConfig, formatConfig, formatExecutionId, formatPackageJson, getConfigPath, getDependencyConfig, getDocsOutputPath, getHookHandler, getName, getOrganizationName, getPackageJsonOrganization, getTextColor, getWorkspaceName, installPackage, installPackages, isBuiltinModule, isDuplicate, isPlugin, isPluginConfig, isPluginConfigObject, isPluginConfigTuple, isPluginHook, isPluginHookField, isPluginHookFunction, isPluginHookObject, isUnpluginHookField, isUnpluginHookKey, isValidLogLevel, isValidLogLevelConfig, isVerbose, isVirtualModule, merge, mergeConfig, normalizeFilter, normalizeSingleFilter, patternToCodeFilter, patternToIdFilter, prefixRegex, removeVirtualPrefix, replacePathTokens, resolveLogLevel, withCustomLogger, withLogFn, withLogger };
|
|
@@ -42,6 +42,7 @@ function resolveLogLevel(logLevel, mode) {
|
|
|
42
42
|
hooks: "trace",
|
|
43
43
|
env: "trace",
|
|
44
44
|
rpc: "trace",
|
|
45
|
+
schema: "trace",
|
|
45
46
|
config: "trace",
|
|
46
47
|
babel: "trace"
|
|
47
48
|
};
|
|
@@ -54,6 +55,7 @@ function resolveLogLevel(logLevel, mode) {
|
|
|
54
55
|
hooks: "silent",
|
|
55
56
|
env: "silent",
|
|
56
57
|
rpc: "silent",
|
|
58
|
+
schema: "silent",
|
|
57
59
|
config: "silent",
|
|
58
60
|
babel: "silent"
|
|
59
61
|
};
|
|
@@ -70,6 +72,7 @@ function resolveLogLevel(logLevel, mode) {
|
|
|
70
72
|
hooks: logLevel,
|
|
71
73
|
env: defaultLogLevel.env,
|
|
72
74
|
rpc: defaultLogLevel.rpc,
|
|
75
|
+
schema: defaultLogLevel.schema,
|
|
73
76
|
config: defaultLogLevel.config,
|
|
74
77
|
babel: logLevel
|
|
75
78
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logging.d.cts","names":[],"sources":["../../src/plugin-utils/logging.ts"],"mappings":";;;;;;;;AA+DA;;;;iBAAgB,SAAA,CAAU,QAAgB;AAQ1C;;;;AAAoD;AAyBpD;AAzBA,iBAAgB,SAAA,CAAU,OAA0B,EAAjB,iBAAiB;;;;;;;;iBAyBpC,eAAA,CACd,QAAA,GAAW,kBAAA,EACX,IAAA,GAAO,IAAA,GACN,sBAAA;;;;;AAAsB;
|
|
1
|
+
{"version":3,"file":"logging.d.cts","names":[],"sources":["../../src/plugin-utils/logging.ts"],"mappings":";;;;;;;;AA+DA;;;;iBAAgB,SAAA,CAAU,QAAgB;AAQ1C;;;;AAAoD;AAyBpD;AAzBA,iBAAgB,SAAA,CAAU,OAA0B,EAAjB,iBAAiB;;;;;;;;iBAyBpC,eAAA,CACd,QAAA,GAAW,kBAAA,EACX,IAAA,GAAO,IAAA,GACN,sBAAA;;;;;AAAsB;AAyFzB;cAAa,YAAA,GAAgB,IAAA,aAAe,aAO3C;;;AAAA;AAQD;;;cAAa,SAAA,GAAa,IAAY;AAAA;AAYtC;;;;AAA4C;AAZN,cAYzB,eAAA,GAAmB,IAAY;AAAA,cAM/B,UAAA,GAAc,IAAA,EAAM,OAAO,KAAK,IAAA;AAAA,iBAwC7B,eAAA,CAAgB,QAAA,EAAU,QAAA,EAAU,IAAA,EAAM,QAAQ;AAAA,iBAQlD,qBAAA,CACd,IAAA,EAAM,QAAA,EACN,QAAA,EAAU,sBAAA,EACV,QAAA,GAAU,WAAA;;;;;AAnDiC;AAwC7C;;cAuBa,WAAA,GAAe,IAAA,UAAc,OAAA,EAAS,YAAA,KAAe,KAiCjE;;;;;;;AAxDiE;cAkMrD,UAAA,GAAc,MAAA,EAAQ,MAAA,EAAQ,eAAA,EAAiB,MAAA,KAAS,MAAA;;;;;;;;cAuFxD,SAAA,GAAa,MAAA,EAAQ,MAAA,EAAQ,KAAA,EAAO,KAAA,KAAQ,MAAA;;;;;;;AA9QV;cAqZlC,gBAAA,GACX,MAAA,EAAQ,MAAA,EACR,YAAA,EAAc,YAAA,KACb,MAAA;AAAA,cAoEU,aAAA,EAAe,KAUzB;;;;;;;;cASU,YAAA,GACX,IAAA,sBACA,OAAA,EAAS,aAAA,EACT,QAAA,GAAU,KAAA,KACT,MAAA;AA5TH;;;;;;;AAAA,cAmXa,WAAA,GAAe,KAAA,EAAO,KAAA,EAAO,OAAA,EAAS,YAAA,KAAe,KAAA;;;;;;;AArSjE;cA2TY,YAAA,GACX,MAAA,EAAQ,MAAA,EACR,OAAA,EAAS,aAAA,KACR,MAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logging.d.mts","names":[],"sources":["../../src/plugin-utils/logging.ts"],"mappings":";;;;;;;;AA+DA;;;;iBAAgB,SAAA,CAAU,QAAgB;AAQ1C;;;;AAAoD;AAyBpD;AAzBA,iBAAgB,SAAA,CAAU,OAA0B,EAAjB,iBAAiB;;;;;;;;iBAyBpC,eAAA,CACd,QAAA,GAAW,kBAAA,EACX,IAAA,GAAO,IAAA,GACN,sBAAA;;;;;AAAsB;
|
|
1
|
+
{"version":3,"file":"logging.d.mts","names":[],"sources":["../../src/plugin-ut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,EAAS,aAAA,KACR,MAAA"}
|
|
@@ -39,6 +39,7 @@ function resolveLogLevel(logLevel, mode) {
|
|
|
39
39
|
hooks: "trace",
|
|
40
40
|
env: "trace",
|
|
41
41
|
rpc: "trace",
|
|
42
|
+
schema: "trace",
|
|
42
43
|
config: "trace",
|
|
43
44
|
babel: "trace"
|
|
44
45
|
};
|
|
@@ -51,6 +52,7 @@ function resolveLogLevel(logLevel, mode) {
|
|
|
51
52
|
hooks: "silent",
|
|
52
53
|
env: "silent",
|
|
53
54
|
rpc: "silent",
|
|
55
|
+
schema: "silent",
|
|
54
56
|
config: "silent",
|
|
55
57
|
babel: "silent"
|
|
56
58
|
};
|
|
@@ -67,6 +69,7 @@ function resolveLogLevel(logLevel, mode) {
|
|
|
67
69
|
hooks: logLevel,
|
|
68
70
|
env: defaultLogLevel.env,
|
|
69
71
|
rpc: defaultLogLevel.rpc,
|
|
72
|
+
schema: defaultLogLevel.schema,
|
|
70
73
|
config: defaultLogLevel.config,
|
|
71
74
|
babel: logLevel
|
|
72
75
|
};
|