@powerlines/core 0.13.12 → 0.13.13
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/api.cjs +16 -0
- package/dist/constants/api.d.cts +5 -0
- package/dist/constants/api.d.cts.map +1 -0
- package/dist/constants/api.d.mts +5 -0
- package/dist/constants/api.d.mts.map +1 -0
- package/dist/constants/api.mjs +16 -0
- package/dist/constants/api.mjs.map +1 -0
- package/dist/constants/commands.cjs +2 -11
- package/dist/constants/commands.d.cts +1 -1
- package/dist/constants/commands.d.cts.map +1 -1
- package/dist/constants/commands.d.mts +1 -1
- package/dist/constants/commands.d.mts.map +1 -1
- package/dist/constants/commands.mjs +3 -11
- package/dist/constants/commands.mjs.map +1 -1
- package/dist/constants/index.cjs +2 -0
- package/dist/constants/index.d.cts +2 -1
- package/dist/constants/index.d.mts +2 -1
- package/dist/constants/index.mjs +2 -1
- package/dist/constants/plugin.d.cts +2 -2
- package/dist/constants/plugin.d.mts +2 -2
- package/dist/index.d.cts +5 -4
- package/dist/index.d.mts +5 -4
- package/dist/lib/config.cjs +17 -28
- package/dist/lib/config.d.cts +6 -11
- package/dist/lib/config.d.cts.map +1 -1
- package/dist/lib/config.d.mts +6 -11
- package/dist/lib/config.d.mts.map +1 -1
- package/dist/lib/config.mjs +17 -28
- package/dist/lib/config.mjs.map +1 -1
- package/dist/lib/entry.cjs +4 -4
- package/dist/lib/entry.d.cts.map +1 -1
- package/dist/lib/entry.d.mts.map +1 -1
- package/dist/lib/entry.mjs +4 -4
- package/dist/lib/entry.mjs.map +1 -1
- package/dist/lib/logger.cjs +1 -1
- package/dist/lib/logger.d.cts.map +1 -1
- package/dist/lib/logger.d.mts.map +1 -1
- package/dist/lib/logger.mjs +1 -1
- package/dist/lib/logger.mjs.map +1 -1
- package/dist/lib/unplugin/plugin.cjs +1 -1
- package/dist/lib/unplugin/plugin.mjs +1 -1
- package/dist/lib/unplugin/plugin.mjs.map +1 -1
- package/dist/lib/utilities/format.cjs +3 -3
- package/dist/lib/utilities/format.d.cts.map +1 -1
- package/dist/lib/utilities/format.d.mts.map +1 -1
- package/dist/lib/utilities/format.mjs +3 -3
- package/dist/lib/utilities/format.mjs.map +1 -1
- package/dist/plugin-base.cjs +2 -2
- package/dist/plugin-base.mjs +2 -2
- package/dist/plugin-base.mjs.map +1 -1
- package/dist/plugin-utils/context-helpers.cjs +8 -5
- package/dist/plugin-utils/context-helpers.d.cts +1 -1
- package/dist/plugin-utils/context-helpers.d.cts.map +1 -1
- package/dist/plugin-utils/context-helpers.d.mts +1 -1
- package/dist/plugin-utils/context-helpers.d.mts.map +1 -1
- package/dist/plugin-utils/context-helpers.mjs +8 -5
- package/dist/plugin-utils/context-helpers.mjs.map +1 -1
- package/dist/plugin-utils/format-package-json.cjs +1 -1
- package/dist/plugin-utils/format-package-json.mjs +1 -1
- package/dist/plugin-utils/format-package-json.mjs.map +1 -1
- package/dist/plugin-utils/get-config-path.cjs +32 -32
- package/dist/plugin-utils/get-config-path.mjs +32 -32
- package/dist/plugin-utils/get-config-path.mjs.map +1 -1
- package/dist/plugin-utils/helpers.d.cts +4 -4
- package/dist/plugin-utils/helpers.d.cts.map +1 -1
- package/dist/plugin-utils/helpers.d.mts +4 -4
- package/dist/plugin-utils/helpers.d.mts.map +1 -1
- package/dist/plugin-utils/paths.cjs +1 -1
- package/dist/plugin-utils/paths.mjs +1 -1
- package/dist/plugin-utils/paths.mjs.map +1 -1
- package/dist/types/_internal.d.cts +6 -6
- package/dist/types/_internal.d.cts.map +1 -1
- package/dist/types/_internal.d.mts +6 -6
- package/dist/types/_internal.d.mts.map +1 -1
- package/dist/types/api.d.cts +62 -9
- package/dist/types/api.d.cts.map +1 -1
- package/dist/types/api.d.mts +62 -9
- package/dist/types/api.d.mts.map +1 -1
- package/dist/types/config.d.cts +89 -56
- package/dist/types/config.d.cts.map +1 -1
- package/dist/types/config.d.mts +89 -56
- package/dist/types/config.d.mts.map +1 -1
- package/dist/types/context.d.cts +101 -62
- package/dist/types/context.d.cts.map +1 -1
- package/dist/types/context.d.mts +101 -62
- package/dist/types/context.d.mts.map +1 -1
- package/dist/types/index.d.cts +4 -3
- package/dist/types/index.d.mts +4 -3
- package/dist/types/utils.d.cts +9 -0
- package/dist/types/utils.d.cts.map +1 -0
- package/dist/types/utils.d.mts +9 -0
- package/dist/types/utils.d.mts.map +1 -0
- package/package.json +3 -3
package/dist/lib/config.mjs
CHANGED
|
@@ -13,47 +13,36 @@ import defu from "defu";
|
|
|
13
13
|
/**
|
|
14
14
|
* Loads the workspace configuration.
|
|
15
15
|
*
|
|
16
|
-
* @param
|
|
17
|
-
* @param
|
|
16
|
+
* @param cwd - The root directory of the workspace.
|
|
17
|
+
* @param root - The current working directory to start searching from.
|
|
18
18
|
* @returns A promise that resolves to the loaded workspace configuration.
|
|
19
19
|
*/
|
|
20
|
-
async function loadWorkspaceConfig(
|
|
21
|
-
return defu({ workspaceRoot }, await getWorkspaceConfig(true, {
|
|
22
|
-
cwd,
|
|
23
|
-
workspaceRoot,
|
|
20
|
+
async function loadWorkspaceConfig(cwd, root) {
|
|
21
|
+
return defu({ workspaceRoot: cwd }, await getWorkspaceConfig(true, {
|
|
22
|
+
cwd: root,
|
|
23
|
+
workspaceRoot: cwd,
|
|
24
24
|
useDefault: true
|
|
25
25
|
}));
|
|
26
26
|
}
|
|
27
27
|
/**
|
|
28
28
|
* Loads the user configuration file for the project.
|
|
29
29
|
*
|
|
30
|
-
* @param
|
|
31
|
-
* @param workspaceRoot - The root directory of the workspace.
|
|
30
|
+
* @param options - The engine options containing the root, cwd, mode, framework, and organization.
|
|
32
31
|
* @param jiti - An instance of Jiti to resolve modules from
|
|
33
|
-
* @param command - The {@link PowerlinesCommand} string associated with the current running process
|
|
34
|
-
* @param mode - The mode in which the project is running (default is "production").
|
|
35
|
-
* @param configFile - An optional path to a specific configuration file.
|
|
36
|
-
* @param framework - The framework name to use for default configuration file names.
|
|
37
32
|
* @returns A promise that resolves to the resolved user configuration.
|
|
38
33
|
*/
|
|
39
|
-
async function loadUserConfigFile(
|
|
34
|
+
async function loadUserConfigFile(options, jiti) {
|
|
40
35
|
let resolvedUserConfig = {};
|
|
41
36
|
let resolvedUserConfigFile;
|
|
42
|
-
if (configFile) resolvedUserConfigFile = existsSync(replacePath(configFile,
|
|
43
|
-
if (!resolvedUserConfigFile) resolvedUserConfigFile = existsSync(joinPaths(appendPath(
|
|
37
|
+
if (options.configFile) resolvedUserConfigFile = existsSync(replacePath(options.configFile, options.root)) ? replacePath(options.configFile, options.root) : existsSync(joinPaths(appendPath(options.root, options.cwd), replacePath(options.configFile, options.root))) ? joinPaths(appendPath(options.root, options.cwd), replacePath(options.configFile, options.root)) : existsSync(joinPaths(appendPath(options.root, options.cwd), options.configFile)) ? joinPaths(appendPath(options.root, options.cwd), options.configFile) : void 0;
|
|
38
|
+
if (!resolvedUserConfigFile) resolvedUserConfigFile = existsSync(joinPaths(appendPath(options.root, options.cwd), `${options.framework}.${options.mode}.config.ts`)) ? joinPaths(appendPath(options.root, options.cwd), `${options.framework}.${options.mode}.config.ts`) : existsSync(joinPaths(appendPath(options.root, options.cwd), `${options.framework}.${options.mode}.config.js`)) ? joinPaths(appendPath(options.root, options.cwd), `${options.framework}.${options.mode}.config.js`) : existsSync(joinPaths(appendPath(options.root, options.cwd), `${options.framework}.${options.mode}.config.mts`)) ? joinPaths(appendPath(options.root, options.cwd), `${options.framework}.${options.mode}.config.mts`) : existsSync(joinPaths(appendPath(options.root, options.cwd), `${options.framework}.${options.mode}.config.mjs`)) ? joinPaths(appendPath(options.root, options.cwd), `${options.framework}.${options.mode}.config.mjs`) : existsSync(joinPaths(appendPath(options.root, options.cwd), `${options.framework}.config.ts`)) ? joinPaths(appendPath(options.root, options.cwd), `${options.framework}.config.ts`) : existsSync(joinPaths(appendPath(options.root, options.cwd), `${options.framework}.config.js`)) ? joinPaths(appendPath(options.root, options.cwd), `${options.framework}.config.js`) : existsSync(joinPaths(appendPath(options.root, options.cwd), `${options.framework}.config.mts`)) ? joinPaths(appendPath(options.root, options.cwd), `${options.framework}.config.mts`) : existsSync(joinPaths(appendPath(options.root, options.cwd), `${options.framework}.config.mjs`)) ? joinPaths(appendPath(options.root, options.cwd), `${options.framework}.config.mjs`) : void 0;
|
|
44
39
|
if (resolvedUserConfigFile) {
|
|
45
40
|
const resolved = await jiti.import(jiti.esmResolve(resolvedUserConfigFile));
|
|
46
41
|
if (resolved?.default) {
|
|
47
42
|
let config = {};
|
|
48
|
-
if (isFunction(resolved.default)) config = await Promise.resolve(resolved.default(
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
framework,
|
|
52
|
-
projectRoot,
|
|
53
|
-
workspaceRoot
|
|
54
|
-
}));
|
|
55
|
-
else if (isSetObject(resolved.default)) config = resolved.default;
|
|
56
|
-
if (isSetObject(config)) resolvedUserConfig = {
|
|
43
|
+
if (isFunction(resolved.default)) config = await Promise.resolve(resolved.default(options));
|
|
44
|
+
else if (isSetObject(resolved.default) || Array.isArray(resolved.default)) config = resolved.default;
|
|
45
|
+
if (isSetObject(config) || Array.isArray(config)) resolvedUserConfig = {
|
|
57
46
|
...config,
|
|
58
47
|
config,
|
|
59
48
|
configFile: resolvedUserConfigFile
|
|
@@ -61,11 +50,11 @@ async function loadUserConfigFile(projectRoot, workspaceRoot, jiti, command, mod
|
|
|
61
50
|
}
|
|
62
51
|
}
|
|
63
52
|
const result = await loadConfig({
|
|
64
|
-
cwd:
|
|
65
|
-
name: framework,
|
|
66
|
-
envName: mode,
|
|
53
|
+
cwd: options.root,
|
|
54
|
+
name: options.framework,
|
|
55
|
+
envName: options.mode,
|
|
67
56
|
globalRc: true,
|
|
68
|
-
packageJson: camelCase(framework),
|
|
57
|
+
packageJson: camelCase(options.framework),
|
|
69
58
|
dotenv: true,
|
|
70
59
|
jiti
|
|
71
60
|
});
|
package/dist/lib/config.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.mjs","names":["loadConfigC12"],"sources":["../../src/lib/config.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 { getWorkspaceConfig } from \"@storm-software/config-tools/get-config\";\nimport { existsSync } from \"@stryke/fs/exists\";\nimport { appendPath } from \"@stryke/path/append\";\nimport { joinPaths } from \"@stryke/path/join-paths\";\nimport { replacePath } from \"@stryke/path/replace\";\nimport { camelCase } from \"@stryke/string-format/camel-case\";\nimport { isFunction } from \"@stryke/type-checks/is-function\";\nimport { isSetObject } from \"@stryke/type-checks/is-set-object\";\nimport { loadConfig as loadConfigC12 } from \"c12\";\nimport defu from \"defu\";\nimport type { Jiti } from \"jiti\";\nimport type {\n ParsedUserConfig,\n PowerlinesCommand,\n UserConfig,\n UserConfigFn,\n WorkspaceConfig\n} from \"../types/config\";\nimport { AnyUserConfig } from \"../types/config\";\nimport { Context } from \"../types/context\";\n\nexport type PartiallyResolvedContext<TContext extends Context = Context> = Omit<\n TContext,\n \"config\" | \"tsconfig\" | \"entry\" | \"fs\" | \"compiler\" | \"unimport\"\n> &\n Partial<TContext> & {\n config: TContext[\"config\"];\n };\n\n/**\n * Loads the workspace configuration.\n *\n * @param workspaceRoot - The root directory of the workspace.\n * @param cwd - The current working directory to start searching from.\n * @returns A promise that resolves to the loaded workspace configuration.\n */\nexport async function loadWorkspaceConfig(\n workspaceRoot: string,\n cwd: string\n): Promise<WorkspaceConfig> {\n return defu(\n {\n workspaceRoot\n },\n await getWorkspaceConfig(true, {\n cwd,\n workspaceRoot,\n useDefault: true\n })\n );\n}\n\n/**\n * Loads the user configuration file for the project.\n *\n * @param projectRoot - The root directory of the project.\n * @param workspaceRoot - The root directory of the workspace.\n * @param jiti - An instance of Jiti to resolve modules from\n * @param command - The {@link PowerlinesCommand} string associated with the current running process\n * @param mode - The mode in which the project is running (default is \"production\").\n * @param configFile - An optional path to a specific configuration file.\n * @param framework - The framework name to use for default configuration file names.\n * @returns A promise that resolves to the resolved user configuration.\n */\nexport async function loadUserConfigFile(\n projectRoot: string,\n workspaceRoot: string,\n jiti: Jiti,\n command?: PowerlinesCommand,\n mode = \"production\",\n configFile?: string,\n framework = \"powerlines\"\n): Promise<ParsedUserConfig> {\n let resolvedUserConfig: Partial<ParsedUserConfig> = {};\n\n let resolvedUserConfigFile: string | undefined;\n if (configFile) {\n resolvedUserConfigFile = existsSync(replacePath(configFile, projectRoot))\n ? replacePath(configFile, projectRoot)\n : existsSync(\n joinPaths(\n appendPath(projectRoot, workspaceRoot),\n replacePath(configFile, projectRoot)\n )\n )\n ? joinPaths(\n appendPath(projectRoot, workspaceRoot),\n replacePath(configFile, projectRoot)\n )\n : existsSync(\n joinPaths(appendPath(projectRoot, workspaceRoot), configFile)\n )\n ? joinPaths(appendPath(projectRoot, workspaceRoot), configFile)\n : undefined;\n }\n\n if (!resolvedUserConfigFile) {\n resolvedUserConfigFile = existsSync(\n joinPaths(\n appendPath(projectRoot, workspaceRoot),\n `${framework}.${mode}.config.ts`\n )\n )\n ? joinPaths(\n appendPath(projectRoot, workspaceRoot),\n `${framework}.${mode}.config.ts`\n )\n : existsSync(\n joinPaths(\n appendPath(projectRoot, workspaceRoot),\n `${framework}.${mode}.config.js`\n )\n )\n ? joinPaths(\n appendPath(projectRoot, workspaceRoot),\n `${framework}.${mode}.config.js`\n )\n : existsSync(\n joinPaths(\n appendPath(projectRoot, workspaceRoot),\n `${framework}.${mode}.config.mts`\n )\n )\n ? joinPaths(\n appendPath(projectRoot, workspaceRoot),\n `${framework}.${mode}.config.mts`\n )\n : existsSync(\n joinPaths(\n appendPath(projectRoot, workspaceRoot),\n `${framework}.${mode}.config.mjs`\n )\n )\n ? joinPaths(\n appendPath(projectRoot, workspaceRoot),\n `${framework}.${mode}.config.mjs`\n )\n : existsSync(\n joinPaths(\n appendPath(projectRoot, workspaceRoot),\n `${framework}.config.ts`\n )\n )\n ? joinPaths(\n appendPath(projectRoot, workspaceRoot),\n `${framework}.config.ts`\n )\n : existsSync(\n joinPaths(\n appendPath(projectRoot, workspaceRoot),\n `${framework}.config.js`\n )\n )\n ? joinPaths(\n appendPath(projectRoot, workspaceRoot),\n `${framework}.config.js`\n )\n : existsSync(\n joinPaths(\n appendPath(projectRoot, workspaceRoot),\n `${framework}.config.mts`\n )\n )\n ? joinPaths(\n appendPath(projectRoot, workspaceRoot),\n `${framework}.config.mts`\n )\n : existsSync(\n joinPaths(\n appendPath(projectRoot, workspaceRoot),\n `${framework}.config.mjs`\n )\n )\n ? joinPaths(\n appendPath(projectRoot, workspaceRoot),\n `${framework}.config.mjs`\n )\n : undefined;\n }\n\n if (resolvedUserConfigFile) {\n const resolved = await jiti.import<{ default: UserConfig | UserConfigFn }>(\n jiti.esmResolve(resolvedUserConfigFile)\n );\n if (resolved?.default) {\n let config = {};\n if (isFunction(resolved.default)) {\n config = await Promise.resolve(\n resolved.default({\n command,\n mode,\n framework,\n projectRoot,\n workspaceRoot\n })\n );\n } else if (isSetObject(resolved.default)) {\n config = resolved.default;\n }\n\n if (isSetObject(config)) {\n resolvedUserConfig = {\n ...config,\n config: config as UserConfig,\n configFile: resolvedUserConfigFile\n };\n }\n }\n }\n\n const result = await loadConfigC12({\n cwd: projectRoot,\n name: framework,\n envName: mode,\n globalRc: true,\n packageJson: camelCase(framework),\n dotenv: true,\n jiti\n });\n\n return defu(\n resolvedUserConfig,\n isSetObject(result?.config) ? { ...result.config, ...result } : {}\n ) as ParsedUserConfig;\n}\n\n/**\n * A type helper to make it easier to use `powerlines.config.ts` files.\n *\n * @remarks\n * The function accepts a direct {@link AnyUserConfig} object/function and returns it typed as a {@link UserConfig} object.\n */\nexport function defineConfig(config: AnyUserConfig): UserConfig {\n return config as any;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAsDA,eAAsB,oBACpB,eACA,KAC0B;AAC1B,QAAO,KACL,EACE,eACD,EACD,MAAM,mBAAmB,MAAM;EAC7B;EACA;EACA,YAAY;EACb,CAAC,CACH;;;;;;;;;;;;;;AAeH,eAAsB,mBACpB,aACA,eACA,MACA,SACA,OAAO,cACP,YACA,YAAY,cACe;CAC3B,IAAI,qBAAgD,EAAE;CAEtD,IAAI;AACJ,KAAI,WACF,0BAAyB,WAAW,YAAY,YAAY,YAAY,CAAC,GACrE,YAAY,YAAY,YAAY,GACpC,WACI,UACE,WAAW,aAAa,cAAc,EACtC,YAAY,YAAY,YAAY,CACrC,CACF,GACD,UACE,WAAW,aAAa,cAAc,EACtC,YAAY,YAAY,YAAY,CACrC,GACD,WACI,UAAU,WAAW,aAAa,cAAc,EAAE,WAAW,CAC9D,GACD,UAAU,WAAW,aAAa,cAAc,EAAE,WAAW,GAC7D;AAGV,KAAI,CAAC,uBACH,0BAAyB,WACvB,UACE,WAAW,aAAa,cAAc,EACtC,GAAG,UAAU,GAAG,KAAK,YACtB,CACF,GACG,UACE,WAAW,aAAa,cAAc,EACtC,GAAG,UAAU,GAAG,KAAK,YACtB,GACD,WACI,UACE,WAAW,aAAa,cAAc,EACtC,GAAG,UAAU,GAAG,KAAK,YACtB,CACF,GACD,UACE,WAAW,aAAa,cAAc,EACtC,GAAG,UAAU,GAAG,KAAK,YACtB,GACD,WACI,UACE,WAAW,aAAa,cAAc,EACtC,GAAG,UAAU,GAAG,KAAK,aACtB,CACF,GACD,UACE,WAAW,aAAa,cAAc,EACtC,GAAG,UAAU,GAAG,KAAK,aACtB,GACD,WACI,UACE,WAAW,aAAa,cAAc,EACtC,GAAG,UAAU,GAAG,KAAK,aACtB,CACF,GACD,UACE,WAAW,aAAa,cAAc,EACtC,GAAG,UAAU,GAAG,KAAK,aACtB,GACD,WACI,UACE,WAAW,aAAa,cAAc,EACtC,GAAG,UAAU,YACd,CACF,GACD,UACE,WAAW,aAAa,cAAc,EACtC,GAAG,UAAU,YACd,GACD,WACI,UACE,WAAW,aAAa,cAAc,EACtC,GAAG,UAAU,YACd,CACF,GACD,UACE,WAAW,aAAa,cAAc,EACtC,GAAG,UAAU,YACd,GACD,WACI,UACE,WAAW,aAAa,cAAc,EACtC,GAAG,UAAU,aACd,CACF,GACD,UACE,WAAW,aAAa,cAAc,EACtC,GAAG,UAAU,aACd,GACD,WACI,UACE,WAAW,aAAa,cAAc,EACtC,GAAG,UAAU,aACd,CACF,GACD,UACE,WAAW,aAAa,cAAc,EACtC,GAAG,UAAU,aACd,GACD;AAGpB,KAAI,wBAAwB;EAC1B,MAAM,WAAW,MAAM,KAAK,OAC1B,KAAK,WAAW,uBAAuB,CACxC;AACD,MAAI,UAAU,SAAS;GACrB,IAAI,SAAS,EAAE;AACf,OAAI,WAAW,SAAS,QAAQ,CAC9B,UAAS,MAAM,QAAQ,QACrB,SAAS,QAAQ;IACf;IACA;IACA;IACA;IACA;IACD,CAAC,CACH;YACQ,YAAY,SAAS,QAAQ,CACtC,UAAS,SAAS;AAGpB,OAAI,YAAY,OAAO,CACrB,sBAAqB;IACnB,GAAG;IACK;IACR,YAAY;IACb;;;CAKP,MAAM,SAAS,MAAMA,WAAc;EACjC,KAAK;EACL,MAAM;EACN,SAAS;EACT,UAAU;EACV,aAAa,UAAU,UAAU;EACjC,QAAQ;EACR;EACD,CAAC;AAEF,QAAO,KACL,oBACA,YAAY,QAAQ,OAAO,GAAG;EAAE,GAAG,OAAO;EAAQ,GAAG;EAAQ,GAAG,EAAE,CACnE;;;;;;;;AASH,SAAgB,aAAa,QAAmC;AAC9D,QAAO"}
|
|
1
|
+
{"version":3,"file":"config.mjs","names":["loadConfigC12"],"sources":["../../src/lib/config.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 { getWorkspaceConfig } from \"@storm-software/config-tools/get-config\";\nimport { existsSync } from \"@stryke/fs/exists\";\nimport { appendPath } from \"@stryke/path/append\";\nimport { joinPaths } from \"@stryke/path/join-paths\";\nimport { replacePath } from \"@stryke/path/replace\";\nimport { camelCase } from \"@stryke/string-format/camel-case\";\nimport { isFunction } from \"@stryke/type-checks/is-function\";\nimport { isSetObject } from \"@stryke/type-checks/is-set-object\";\nimport { loadConfig as loadConfigC12 } from \"c12\";\nimport defu from \"defu\";\nimport type { Jiti } from \"jiti\";\nimport type {\n ParsedUserConfig,\n ResolvedEngineOptions,\n UserConfig,\n WorkspaceConfig\n} from \"../types/config\";\nimport { AnyUserConfig } from \"../types/config\";\nimport { Context } from \"../types/context\";\n\nexport type PartiallyResolvedContext<TContext extends Context = Context> = Omit<\n TContext,\n \"config\" | \"tsconfig\" | \"entry\" | \"fs\" | \"compiler\" | \"unimport\"\n> &\n Partial<TContext> & {\n config: TContext[\"config\"];\n };\n\n/**\n * Loads the workspace configuration.\n *\n * @param cwd - The root directory of the workspace.\n * @param root - The current working directory to start searching from.\n * @returns A promise that resolves to the loaded workspace configuration.\n */\nexport async function loadWorkspaceConfig(\n cwd: string,\n root: string\n): Promise<WorkspaceConfig> {\n return defu(\n {\n workspaceRoot: cwd\n },\n await getWorkspaceConfig(true, {\n cwd: root,\n workspaceRoot: cwd,\n useDefault: true\n })\n );\n}\n\n/**\n * Loads the user configuration file for the project.\n *\n * @param options - The engine options containing the root, cwd, mode, framework, and organization.\n * @param jiti - An instance of Jiti to resolve modules from\n * @returns A promise that resolves to the resolved user configuration.\n */\nexport async function loadUserConfigFile(\n options: ResolvedEngineOptions,\n jiti: Jiti\n): Promise<ParsedUserConfig> {\n let resolvedUserConfig: Partial<ParsedUserConfig> = {};\n\n let resolvedUserConfigFile: string | undefined;\n if (options.configFile) {\n resolvedUserConfigFile = existsSync(\n replacePath(options.configFile, options.root)\n )\n ? replacePath(options.configFile, options.root)\n : existsSync(\n joinPaths(\n appendPath(options.root, options.cwd),\n replacePath(options.configFile, options.root)\n )\n )\n ? joinPaths(\n appendPath(options.root, options.cwd),\n replacePath(options.configFile, options.root)\n )\n : existsSync(\n joinPaths(\n appendPath(options.root, options.cwd),\n options.configFile\n )\n )\n ? joinPaths(appendPath(options.root, options.cwd), options.configFile)\n : undefined;\n }\n\n if (!resolvedUserConfigFile) {\n resolvedUserConfigFile = existsSync(\n joinPaths(\n appendPath(options.root, options.cwd),\n `${options.framework}.${options.mode}.config.ts`\n )\n )\n ? joinPaths(\n appendPath(options.root, options.cwd),\n `${options.framework}.${options.mode}.config.ts`\n )\n : existsSync(\n joinPaths(\n appendPath(options.root, options.cwd),\n `${options.framework}.${options.mode}.config.js`\n )\n )\n ? joinPaths(\n appendPath(options.root, options.cwd),\n `${options.framework}.${options.mode}.config.js`\n )\n : existsSync(\n joinPaths(\n appendPath(options.root, options.cwd),\n `${options.framework}.${options.mode}.config.mts`\n )\n )\n ? joinPaths(\n appendPath(options.root, options.cwd),\n `${options.framework}.${options.mode}.config.mts`\n )\n : existsSync(\n joinPaths(\n appendPath(options.root, options.cwd),\n `${options.framework}.${options.mode}.config.mjs`\n )\n )\n ? joinPaths(\n appendPath(options.root, options.cwd),\n `${options.framework}.${options.mode}.config.mjs`\n )\n : existsSync(\n joinPaths(\n appendPath(options.root, options.cwd),\n `${options.framework}.config.ts`\n )\n )\n ? joinPaths(\n appendPath(options.root, options.cwd),\n `${options.framework}.config.ts`\n )\n : existsSync(\n joinPaths(\n appendPath(options.root, options.cwd),\n `${options.framework}.config.js`\n )\n )\n ? joinPaths(\n appendPath(options.root, options.cwd),\n `${options.framework}.config.js`\n )\n : existsSync(\n joinPaths(\n appendPath(options.root, options.cwd),\n `${options.framework}.config.mts`\n )\n )\n ? joinPaths(\n appendPath(options.root, options.cwd),\n `${options.framework}.config.mts`\n )\n : existsSync(\n joinPaths(\n appendPath(options.root, options.cwd),\n `${options.framework}.config.mjs`\n )\n )\n ? joinPaths(\n appendPath(options.root, options.cwd),\n `${options.framework}.config.mjs`\n )\n : undefined;\n }\n\n if (resolvedUserConfigFile) {\n const resolved = await jiti.import<{ default: AnyUserConfig }>(\n jiti.esmResolve(resolvedUserConfigFile)\n );\n if (resolved?.default) {\n let config = {};\n if (isFunction(resolved.default)) {\n config = await Promise.resolve(resolved.default(options));\n } else if (\n isSetObject(resolved.default) ||\n Array.isArray(resolved.default)\n ) {\n config = resolved.default;\n }\n\n if (isSetObject(config) || Array.isArray(config)) {\n resolvedUserConfig = {\n ...config,\n config,\n configFile: resolvedUserConfigFile\n };\n }\n }\n }\n\n const result = await loadConfigC12({\n cwd: options.root,\n name: options.framework,\n envName: options.mode,\n globalRc: true,\n packageJson: camelCase(options.framework),\n dotenv: true,\n jiti\n });\n\n return defu(\n resolvedUserConfig,\n isSetObject(result?.config) ? { ...result.config, ...result } : {}\n ) as ParsedUserConfig;\n}\n\n/**\n * A type helper to make it easier to use `powerlines.config.ts` files.\n *\n * @remarks\n * The function accepts a direct {@link AnyUserConfig} object/function and returns it typed as a {@link UserConfig} object.\n */\nexport function defineConfig(config: AnyUserConfig): UserConfig {\n return config as any;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAqDA,eAAsB,oBACpB,KACA,MAC0B;AAC1B,QAAO,KACL,EACE,eAAe,KAChB,EACD,MAAM,mBAAmB,MAAM;EAC7B,KAAK;EACL,eAAe;EACf,YAAY;EACb,CAAC,CACH;;;;;;;;;AAUH,eAAsB,mBACpB,SACA,MAC2B;CAC3B,IAAI,qBAAgD,EAAE;CAEtD,IAA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ACA,YAAY,QAAQ,OAAO,GAAG;EAAE,GAAG,OAAO;EAAQ,GAAG;EAAQ,GAAG,EAAE,CACnE;;;;;;;;AASH,SAAgB,aAAa,QAAmC;AAC9D,QAAO"}
|
package/dist/lib/entry.cjs
CHANGED
|
@@ -15,7 +15,7 @@ let _stryke_type_checks_is_string = require("@stryke/type-checks/is-string");
|
|
|
15
15
|
|
|
16
16
|
//#region src/lib/entry.ts
|
|
17
17
|
function resolveEntryOutput(context, typeDefinition) {
|
|
18
|
-
return (0, _stryke_path_replace.replaceExtension)((0, _stryke_path_replace.replacePath)((0, _stryke_path_replace.replacePath)((0, _stryke_path_replace.replacePath)((0, _stryke_path_replace.replacePath)((0, _stryke_path_replace.replacePath)(typeDefinition.file, (0, _stryke_path_join_paths.joinPaths)(context.
|
|
18
|
+
return (0, _stryke_path_replace.replaceExtension)((0, _stryke_path_replace.replacePath)((0, _stryke_path_replace.replacePath)((0, _stryke_path_replace.replacePath)((0, _stryke_path_replace.replacePath)((0, _stryke_path_replace.replacePath)(typeDefinition.file, (0, _stryke_path_join_paths.joinPaths)(context.config.cwd, context.config.root, "src")), (0, _stryke_path_join_paths.joinPaths)(context.config.cwd, context.config.root)), (0, _stryke_path_join_paths.joinPaths)(context.config.root, "src")), context.config.root), "src"));
|
|
19
19
|
}
|
|
20
20
|
function resolveInput(context, typeDefinition, input, output) {
|
|
21
21
|
return {
|
|
@@ -49,7 +49,7 @@ async function resolveInputs(context, typeDefinitions) {
|
|
|
49
49
|
file: (0, _stryke_path_replace.replacePath)(filePath, context.config.root),
|
|
50
50
|
name: typeDefinition.name
|
|
51
51
|
}, entry.input, entry.output);
|
|
52
|
-
return (await context.fs.glob((0, _stryke_path_append.appendPath)(filePath, context.
|
|
52
|
+
return (await context.fs.glob((0, _stryke_path_append.appendPath)(filePath, context.config.cwd))).map((file) => resolveInput(context, {
|
|
53
53
|
file: (0, _stryke_path_replace.replacePath)(file, context.config.root),
|
|
54
54
|
name: typeDefinition.name
|
|
55
55
|
}, entry.input, entry.output));
|
|
@@ -77,10 +77,10 @@ function resolveInputsSync(context, typeDefinitions) {
|
|
|
77
77
|
}
|
|
78
78
|
const filePath = (0, _stryke_path_is_type.isAbsolutePath)(typeDefinition.file) ? typeDefinition.file : (0, _stryke_path_append.appendPath)(typeDefinition.file, context.config.root);
|
|
79
79
|
if (context.fs.isFileSync(filePath)) return resolveInput(context, {
|
|
80
|
-
file: (0, _stryke_path_append.appendPath)(filePath, context.
|
|
80
|
+
file: (0, _stryke_path_append.appendPath)(filePath, context.config.cwd),
|
|
81
81
|
name: typeDefinition.name
|
|
82
82
|
});
|
|
83
|
-
return context.fs.globSync((0, _stryke_path_append.appendPath)(filePath, context.
|
|
83
|
+
return context.fs.globSync((0, _stryke_path_append.appendPath)(filePath, context.config.cwd)).map((file) => resolveInput(context, {
|
|
84
84
|
file,
|
|
85
85
|
name: typeDefinition.name
|
|
86
86
|
}));
|
package/dist/lib/entry.d.cts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"entry.d.cts","names":[],"sources":["../../src/lib/entry.ts"],"mappings":";;;;;iBAsCgB,kBAAA,CACd,OAAA,EAAS,OAAA,EACT,cAAA,EAAgB,cAAA;AAAA,
|
|
1
|
+
{"version":3,"file":"entry.d.cts","names":[],"sources":["../../src/lib/entry.ts"],"mappings":";;;;;iBAsCgB,kBAAA,CACd,OAAA,EAAS,OAAA,EACT,cAAA,EAAgB,cAAA;AAAA,iBAsBF,YAAA,CACd,OAAA,EAAS,OAAA,EACT,cAAA,EAAgB,cAAA,EAChB,KAAA,GAAQ,uBAAA,EACR,MAAA,YACC,2BAAA;AA7BH;;;;;;;AAAA,iBA4CsB,aAAA,CACpB,OAAA,EAAS,OAAA,EACT,eAAA,EACI,uBAAA,GACA,uBAAA,KACA,MAAA,SAAe,uBAAA,GAA0B,uBAAA,MAC5C,OAAA,CAAQ,2BAAA;;;AA1BX;;;;;iBAmGgB,iBAAA,CACd,OAAA,EAAS,OAAA,EACT,eAAA,EACI,uBAAA,GACA,uBAAA,KACA,MAAA,SAAe,uBAAA,GAA0B,uBAAA,MAC5C,2BAAA;;;;;;;iBAwDa,gBAAA,CAAiB,KAAA,QAAa,KAAA,IAAS,cAAA;;;;;;;iBAUvC,6BAAA,CACd,KAAA,EAAO,uBAAA,GAA0B,2BAAA,GAChC,KAAA,IAAS,2BAAA;;;;;;;iBAaI,eAAA,CAAgB,MAAA,GAAQ,MAAA,YAAuB,MAAA"}
|
package/dist/lib/entry.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"entry.d.mts","names":[],"sources":["../../src/lib/entry.ts"],"mappings":";;;;;iBAsCgB,kBAAA,CACd,OAAA,EAAS,OAAA,EACT,cAAA,EAAgB,cAAA;AAAA,
|
|
1
|
+
{"version":3,"file":"entry.d.mts","names":[],"sources":["../../src/lib/entry.ts"],"mappings":";;;;;iBAsCgB,kBAAA,CACd,OAAA,EAAS,OAAA,EACT,cAAA,EAAgB,cAAA;AAAA,iBAsBF,YAAA,CACd,OAAA,EAAS,OAAA,EACT,cAAA,EAAgB,cAAA,EAChB,KAAA,GAAQ,uBAAA,EACR,MAAA,YACC,2BAAA;AA7BH;;;;;;;AAAA,iBA4CsB,aAAA,CACpB,OAAA,EAAS,OAAA,EACT,eAAA,EACI,uBAAA,GACA,uBAAA,KACA,MAAA,SAAe,uBAAA,GAA0B,uBAAA,MAC5C,OAAA,CAAQ,2BAAA;;;AA1BX;;;;;iBAmGgB,iBAAA,CACd,OAAA,EAAS,OAAA,EACT,eAAA,EACI,uBAAA,GACA,uBAAA,KACA,MAAA,SAAe,uBAAA,GAA0B,uBAAA,MAC5C,2BAAA;;;;;;;iBAwDa,gBAAA,CAAiB,KAAA,QAAa,KAAA,IAAS,cAAA;;;;;;;iBAUvC,6BAAA,CACd,KAAA,EAAO,uBAAA,GAA0B,2BAAA,GAChC,KAAA,IAAS,2BAAA;;;;;;;iBAaI,eAAA,CAAgB,MAAA,GAAQ,MAAA,YAAuB,MAAA"}
|
package/dist/lib/entry.mjs
CHANGED
|
@@ -13,7 +13,7 @@ import { isString } from "@stryke/type-checks/is-string";
|
|
|
13
13
|
|
|
14
14
|
//#region src/lib/entry.ts
|
|
15
15
|
function resolveEntryOutput(context, typeDefinition) {
|
|
16
|
-
return replaceExtension(replacePath(replacePath(replacePath(replacePath(replacePath(typeDefinition.file, joinPaths(context.
|
|
16
|
+
return replaceExtension(replacePath(replacePath(replacePath(replacePath(replacePath(typeDefinition.file, joinPaths(context.config.cwd, context.config.root, "src")), joinPaths(context.config.cwd, context.config.root)), joinPaths(context.config.root, "src")), context.config.root), "src"));
|
|
17
17
|
}
|
|
18
18
|
function resolveInput(context, typeDefinition, input, output) {
|
|
19
19
|
return {
|
|
@@ -47,7 +47,7 @@ async function resolveInputs(context, typeDefinitions) {
|
|
|
47
47
|
file: replacePath(filePath, context.config.root),
|
|
48
48
|
name: typeDefinition.name
|
|
49
49
|
}, entry.input, entry.output);
|
|
50
|
-
return (await context.fs.glob(appendPath(filePath, context.
|
|
50
|
+
return (await context.fs.glob(appendPath(filePath, context.config.cwd))).map((file) => resolveInput(context, {
|
|
51
51
|
file: replacePath(file, context.config.root),
|
|
52
52
|
name: typeDefinition.name
|
|
53
53
|
}, entry.input, entry.output));
|
|
@@ -75,10 +75,10 @@ function resolveInputsSync(context, typeDefinitions) {
|
|
|
75
75
|
}
|
|
76
76
|
const filePath = isAbsolutePath(typeDefinition.file) ? typeDefinition.file : appendPath(typeDefinition.file, context.config.root);
|
|
77
77
|
if (context.fs.isFileSync(filePath)) return resolveInput(context, {
|
|
78
|
-
file: appendPath(filePath, context.
|
|
78
|
+
file: appendPath(filePath, context.config.cwd),
|
|
79
79
|
name: typeDefinition.name
|
|
80
80
|
});
|
|
81
|
-
return context.fs.globSync(appendPath(filePath, context.
|
|
81
|
+
return context.fs.globSync(appendPath(filePath, context.config.cwd)).map((file) => resolveInput(context, {
|
|
82
82
|
file,
|
|
83
83
|
name: typeDefinition.name
|
|
84
84
|
}));
|
package/dist/lib/entry.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"entry.mjs","names":[],"sources":["../../src/lib/entry.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { parseTypeDefinition } from \"@stryke/convert/parse-type-definition\";\nimport { toArray } from \"@stryke/convert/to-array\";\nimport { murmurhash } from \"@stryke/hash\";\nimport { getUniqueBy } from \"@stryke/helpers/get-unique\";\nimport { appendPath } from \"@stryke/path/append\";\nimport { isAbsolutePath } from \"@stryke/path/is-type\";\nimport { joinPaths } from \"@stryke/path/join-paths\";\nimport { replaceExtension, replacePath } from \"@stryke/path/replace\";\nimport { isObject } from \"@stryke/type-checks/is-object\";\nimport { isSetString } from \"@stryke/type-checks/is-set-string\";\nimport { isString } from \"@stryke/type-checks/is-string\";\nimport type {\n TypeDefinition,\n TypeDefinitionParameter\n} from \"@stryke/types/configuration\";\nimport { replacePathTokens } from \"../plugin-utils/paths\";\nimport { Config } from \"../types\";\nimport { ResolvedEntryTypeDefinition } from \"../types/config\";\nimport type { Context } from \"../types/context\";\n\nexport function resolveEntryOutput(\n context: Context,\n typeDefinition: TypeDefinition\n): string {\n return replaceExtension(\n replacePath(\n replacePath(\n replacePath(\n replacePath(\n replacePath(\n typeDefinition.file,\n joinPaths(\n context.workspaceConfig.workspaceRoot,\n context.config.root,\n \"src\"\n )\n ),\n joinPaths(\n context.workspaceConfig.workspaceRoot,\n context.config.root\n )\n ),\n joinPaths(context.config.root, \"src\")\n ),\n context.config.root\n ),\n \"src\"\n )\n );\n}\n\nexport function resolveInput(\n context: Context,\n typeDefinition: TypeDefinition,\n input?: TypeDefinitionParameter,\n output?: string\n): ResolvedEntryTypeDefinition {\n return {\n ...typeDefinition,\n input: isSetString(input) ? { file: String(input) } : typeDefinition,\n output: output || resolveEntryOutput(context, typeDefinition)\n };\n}\n\n/**\n * Resolves multiple type definitions into their corresponding resolved entry type definitions.\n *\n * @param context - The current context\n * @param typeDefinitions - The type definitions to resolve.\n * @returns A promise that resolves to an array of resolved entry type definitions.\n */\nexport async function resolveInputs(\n context: Context,\n typeDefinitions:\n | TypeDefinitionParameter\n | TypeDefinitionParameter[]\n | Record<string, TypeDefinitionParameter | TypeDefinitionParameter[]>\n): Promise<ResolvedEntryTypeDefinition[]> {\n return (\n await Promise.all(\n (isObject(typeDefinitions) && !isTypeDefinition(typeDefinitions)\n ? Object.values(typeDefinitions).flat()\n : toArray(typeDefinitions)\n )\n .map(async entry => {\n if (isResolvedEntryTypeDefinition(entry)) {\n return {\n ...entry,\n output: entry.output\n ? replacePathTokens(context, entry.output)\n : undefined,\n file: replacePathTokens(context, entry.file)\n };\n }\n\n let typeDefinition: TypeDefinition;\n if (isString(entry)) {\n typeDefinition = parseTypeDefinition(\n replacePathTokens(context, entry)\n )!;\n } else {\n typeDefinition = entry;\n typeDefinition.file = replacePathTokens(\n context,\n typeDefinition.file\n );\n }\n\n const filePath = isAbsolutePath(typeDefinition.file)\n ? typeDefinition.file\n : appendPath(typeDefinition.file, context.config.root);\n if (await context.fs.isFile(filePath)) {\n return resolveInput(\n context,\n {\n file: replacePath(filePath, context.config.root),\n name: typeDefinition.name\n },\n (entry as ResolvedEntryTypeDefinition).input,\n (entry as ResolvedEntryTypeDefinition).output\n );\n }\n\n return (\n await context.fs.glob(\n appendPath(filePath, context.workspaceConfig.workspaceRoot)\n )\n ).map(file =>\n resolveInput(\n context,\n {\n file: replacePath(file, context.config.root),\n name: typeDefinition.name\n },\n (entry as ResolvedEntryTypeDefinition).input,\n (entry as ResolvedEntryTypeDefinition).output\n )\n );\n })\n .flat()\n .filter(Boolean)\n )\n ).flat();\n}\n\n/**\n * Resolves multiple type definitions into their corresponding resolved entry type definitions.\n *\n * @param context - The current context\n * @param typeDefinitions - The type definitions to resolve.\n * @returns A promise that resolves to an array of resolved entry type definitions.\n */\nexport function resolveInputsSync(\n context: Context,\n typeDefinitions:\n | TypeDefinitionParameter\n | TypeDefinitionParameter[]\n | Record<string, TypeDefinitionParameter | TypeDefinitionParameter[]>\n): ResolvedEntryTypeDefinition[] {\n return (\n isObject(typeDefinitions) && !isTypeDefinition(typeDefinitions)\n ? Object.values(typeDefinitions).flat()\n : toArray(typeDefinitions)\n )\n .map(entry => {\n if (isResolvedEntryTypeDefinition(entry)) {\n return {\n ...entry,\n output: entry.output\n ? replacePathTokens(context, entry.output)\n : undefined,\n file: replacePathTokens(context, entry.file)\n };\n }\n\n let typeDefinition: TypeDefinition;\n if (isString(entry)) {\n typeDefinition = parseTypeDefinition(\n replacePathTokens(context, entry)\n )!;\n } else {\n typeDefinition = entry;\n typeDefinition.file = replacePathTokens(context, typeDefinition.file);\n }\n\n const filePath = isAbsolutePath(typeDefinition.file)\n ? typeDefinition.file\n : appendPath(typeDefinition.file, context.config.root);\n if (context.fs.isFileSync(filePath)) {\n return resolveInput(context, {\n file: appendPath(filePath, context.workspaceConfig.workspaceRoot),\n name: typeDefinition.name\n });\n }\n\n return context.fs\n .globSync(appendPath(filePath, context.workspaceConfig.workspaceRoot))\n .map(file =>\n resolveInput(context, {\n file,\n name: typeDefinition.name\n })\n );\n })\n .flat()\n .filter(Boolean);\n}\n\n/**\n * Checks if the provided entry is a type definition.\n *\n * @param entry - The entry to check.\n * @returns True if the entry is a type definition, false otherwise.\n */\nexport function isTypeDefinition(entry: any): entry is TypeDefinition {\n return !isString(entry) && entry.file !== undefined;\n}\n\n/**\n * Checks if the provided entry is a resolved entry type definition.\n *\n * @param entry - The entry to check.\n * @returns True if the entry is a resolved entry type definition, false otherwise.\n */\nexport function isResolvedEntryTypeDefinition(\n entry: TypeDefinitionParameter | ResolvedEntryTypeDefinition\n): entry is ResolvedEntryTypeDefinition {\n return (\n isTypeDefinition(entry) &&\n (entry as ResolvedEntryTypeDefinition).output !== undefined\n );\n}\n\n/**\n * Get unique inputs from the provided list.\n *\n * @param inputs - The entry points to process.\n * @returns An array of unique inputs (by file path or content hash).\n */\nexport function getUniqueInputs(inputs: Config[\"input\"] = []): Config[\"input\"] {\n return isObject(inputs)\n ? inputs\n : getUniqueBy(toArray(inputs), (item: TypeDefinitionParameter) =>\n isSetString(item) ? item : murmurhash(item ?? {}, { maxLength: 24 })\n );\n}\n"],"mappings":";;;;;;;;;;;;;;AAsCA,SAAgB,mBACd,SACA,gBACQ;AACR,QAAO,iBACL,YACE,YACE,YACE,YACE,YACE,eAAe,MACf,UACE,QAAQ,gBAAgB,eACxB,QAAQ,OAAO,MACf,MACD,CACF,EACD,UACE,QAAQ,gBAAgB,eACxB,QAAQ,OAAO,KAChB,CACF,EACD,UAAU,QAAQ,OAAO,MAAM,MAAM,CACtC,EACD,QAAQ,OAAO,KAChB,EACD,MACD,CACF;;AAGH,SAAgB,aACd,SACA,gBACA,OACA,QAC6B;AAC7B,QAAO;EACL,GAAG;EACH,OAAO,YAAY,MAAM,GAAG,EAAE,MAAM,OAAO,MAAM,EAAE,GAAG;EACtD,QAAQ,UAAU,mBAAmB,SAAS,eAAe;EAC9D;;;;;;;;;AAUH,eAAsB,cACpB,SACA,iBAIwC;AACxC,SACE,MAAM,QAAQ,KACX,SAAS,gBAAgB,IAAI,CAAC,iBAAiB,gBAAgB,GAC5D,OAAO,OAAO,gBAAgB,CAAC,MAAM,GACrC,QAAQ,gBAAgB,EAEzB,IAAI,OAAM,UAAS;AAClB,MAAI,8BAA8B,MAAM,CACtC,QAAO;GACL,GAAG;GACH,QAAQ,MAAM,SACV,kBAAkB,SAAS,MAAM,OAAO,GACxC;GAC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W,eAAe,MAAM,QAAQ,OAAO,KAAK;AACxD,MAAI,QAAQ,GAAG,WAAW,SAAS,CACjC,QAAO,aAAa,SAAS;GAC3B,MAAM,WAAW,UAAU,QAAQ,gBAAgB,cAAc;GACjE,MAAM,eAAe;GACtB,CAAC;AAGJ,SAAO,QAAQ,GACZ,SAAS,WAAW,UAAU,QAAQ,gBAAgB,cAAc,CAAC,CACrE,KAAI,SACH,aAAa,SAAS;GACpB;GACA,MAAM,eAAe;GACtB,CAAC,CACH;GACH,CACD,MAAM,CACN,OAAO,QAAQ;;;;;;;;AASpB,SAAgB,iBAAiB,OAAqC;AACpE,QAAO,CAAC,SAAS,MAAM,IAAI,MAAM,SAAS;;;;;;;;AAS5C,SAAgB,8BACd,OACsC;AACtC,QACE,iBAAiB,MAAM,IACtB,MAAsC,WAAW;;;;;;;;AAUtD,SAAgB,gBAAgB,SAA0B,EAAE,EAAmB;AAC7E,QAAO,SAAS,OAAO,GACnB,SACA,YAAY,QAAQ,OAAO,GAAG,SAC5B,YAAY,KAAK,GAAG,OAAO,WAAW,QAAQ,EAAE,EAAE,EAAE,WAAW,IAAI,CAAC,CACrE"}
|
|
1
|
+
{"version":3,"file":"entry.mjs","names":[],"sources":["../../src/lib/entry.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { parseTypeDefinition } from \"@stryke/convert/parse-type-definition\";\nimport { toArray } from \"@stryke/convert/to-array\";\nimport { murmurhash } from \"@stryke/hash\";\nimport { getUniqueBy } from \"@stryke/helpers/get-unique\";\nimport { appendPath } from \"@stryke/path/append\";\nimport { isAbsolutePath } from \"@stryke/path/is-type\";\nimport { joinPaths } from \"@stryke/path/join-paths\";\nimport { replaceExtension, replacePath } from \"@stryke/path/replace\";\nimport { isObject } from \"@stryke/type-checks/is-object\";\nimport { isSetString } from \"@stryke/type-checks/is-set-string\";\nimport { isString } from \"@stryke/type-checks/is-string\";\nimport type {\n TypeDefinition,\n TypeDefinitionParameter\n} from \"@stryke/types/configuration\";\nimport { replacePathTokens } from \"../plugin-utils/paths\";\nimport { Config } from \"../types\";\nimport { ResolvedEntryTypeDefinition } from \"../types/config\";\nimport type { Context } from \"../types/context\";\n\nexport function resolveEntryOutput(\n context: Context,\n typeDefinition: TypeDefinition\n): string {\n return replaceExtension(\n replacePath(\n replacePath(\n replacePath(\n replacePath(\n replacePath(\n typeDefinition.file,\n joinPaths(context.config.cwd, context.config.root, \"src\")\n ),\n joinPaths(context.config.cwd, context.config.root)\n ),\n joinPaths(context.config.root, \"src\")\n ),\n context.config.root\n ),\n \"src\"\n )\n );\n}\n\nexport function resolveInput(\n context: Context,\n typeDefinition: TypeDefinition,\n input?: TypeDefinitionParameter,\n output?: string\n): ResolvedEntryTypeDefinition {\n return {\n ...typeDefinition,\n input: isSetString(input) ? { file: String(input) } : typeDefinition,\n output: output || resolveEntryOutput(context, typeDefinition)\n };\n}\n\n/**\n * Resolves multiple type definitions into their corresponding resolved entry type definitions.\n *\n * @param context - The current context\n * @param typeDefinitions - The type definitions to resolve.\n * @returns A promise that resolves to an array of resolved entry type definitions.\n */\nexport async function resolveInputs(\n context: Context,\n typeDefinitions:\n | TypeDefinitionParameter\n | TypeDefinitionParameter[]\n | Record<string, TypeDefinitionParameter | TypeDefinitionParameter[]>\n): Promise<ResolvedEntryTypeDefinition[]> {\n return (\n await Promise.all(\n (isObject(typeDefinitions) && !isTypeDefinition(typeDefinitions)\n ? Object.values(typeDefinitions).flat()\n : toArray(typeDefinitions)\n )\n .map(async entry => {\n if (isResolvedEntryTypeDefinition(entry)) {\n return {\n ...entry,\n output: entry.output\n ? replacePathTokens(context, entry.output)\n : undefined,\n file: replacePathTokens(context, entry.file)\n };\n }\n\n let typeDefinition: TypeDefinition;\n if (isString(entry)) {\n typeDefinition = parseTypeDefinition(\n replacePathTokens(context, entry)\n )!;\n } else {\n typeDefinition = entry;\n typeDefinition.file = replacePathTokens(\n context,\n typeDefinition.file\n );\n }\n\n const filePath = isAbsolutePath(typeDefinition.file)\n ? typeDefinition.file\n : appendPath(typeDefinition.file, context.config.root);\n if (await context.fs.isFile(filePath)) {\n return resolveInput(\n context,\n {\n file: replacePath(filePath, context.config.root),\n name: typeDefinition.name\n },\n (entry as ResolvedEntryTypeDefinition).input,\n (entry as ResolvedEntryTypeDefinition).output\n );\n }\n\n return (\n await context.fs.glob(appendPath(filePath, context.config.cwd))\n ).map(file =>\n resolveInput(\n context,\n {\n file: replacePath(file, context.config.root),\n name: typeDefinition.name\n },\n (entry as ResolvedEntryTypeDefinition).input,\n (entry as ResolvedEntryTypeDefinition).output\n )\n );\n })\n .flat()\n .filter(Boolean)\n )\n ).flat();\n}\n\n/**\n * Resolves multiple type definitions into their corresponding resolved entry type definitions.\n *\n * @param context - The current context\n * @param typeDefinitions - The type definitions to resolve.\n * @returns A promise that resolves to an array of resolved entry type definitions.\n */\nexport function resolveInputsSync(\n context: Context,\n typeDefinitions:\n | TypeDefinitionParameter\n | TypeDefinitionParameter[]\n | Record<string, TypeDefinitionParameter | TypeDefinitionParameter[]>\n): ResolvedEntryTypeDefinition[] {\n return (\n isObject(typeDefinitions) && !isTypeDefinition(typeDefinitions)\n ? Object.values(typeDefinitions).flat()\n : toArray(typeDefinitions)\n )\n .map(entry => {\n if (isResolvedEntryTypeDefinition(entry)) {\n return {\n ...entry,\n output: entry.output\n ? replacePathTokens(context, entry.output)\n : undefined,\n file: replacePathTokens(context, entry.file)\n };\n }\n\n let typeDefinition: TypeDefinition;\n if (isString(entry)) {\n typeDefinition = parseTypeDefinition(\n replacePathTokens(context, entry)\n )!;\n } else {\n typeDefinition = entry;\n typeDefinition.file = replacePathTokens(context, typeDefinition.file);\n }\n\n const filePath = isAbsolutePath(typeDefinition.file)\n ? typeDefinition.file\n : appendPath(typeDefinition.file, context.config.root);\n if (context.fs.isFileSync(filePath)) {\n return resolveInput(context, {\n file: appendPath(filePath, context.config.cwd),\n name: typeDefinition.name\n });\n }\n\n return context.fs\n .globSync(appendPath(filePath, context.config.cwd))\n .map(file =>\n resolveInput(context, {\n file,\n name: typeDefinition.name\n })\n );\n })\n .flat()\n .filter(Boolean);\n}\n\n/**\n * Checks if the provided entry is a type definition.\n *\n * @param entry - The entry to check.\n * @returns True if the entry is a type definition, false otherwise.\n */\nexport function isTypeDefinition(entry: any): entry is TypeDefinition {\n return !isString(entry) && entry.file !== undefined;\n}\n\n/**\n * Checks if the provided entry is a resolved entry type definition.\n *\n * @param entry - The entry to check.\n * @returns True if the entry is a resolved entry type definition, false otherwise.\n */\nexport function isResolvedEntryTypeDefinition(\n entry: TypeDefinitionParameter | ResolvedEntryTypeDefinition\n): entry is ResolvedEntryTypeDefinition {\n return (\n isTypeDefinition(entry) &&\n (entry as ResolvedEntryTypeDefinition).output !== undefined\n );\n}\n\n/**\n * Get unique inputs from the provided list.\n *\n * @param inputs - The entry points to process.\n * @returns An array of unique inputs (by file path or content hash).\n */\nexport function getUniqueInputs(inputs: Config[\"input\"] = []): Config[\"input\"] {\n return isObject(inputs)\n ? inputs\n : getUniqueBy(toArray(inputs), (item: TypeDefinitionParameter) =>\n isSetString(item) ? item : murmurhash(item ?? {}, { maxLength: 24 })\n );\n}\n"],"mappings":";;;;;;;;;;;;;;AAsCA,SAAgB,mBACd,SACA,gBACQ;AACR,QAAO,iBACL,YACE,YACE,YACE,YACE,YACE,eAAe,MACf,UAAU,QAAQ,OAAO,KAAK,QAAQ,OAAO,MAAM,MAAM,CAC1D,EACD,UAAU,QAAQ,OAAO,KAAK,QAAQ,OAAO,KAAK,CACnD,EACD,UAAU,Q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EAAE,WAAW,IAAI,CAAC,CACrE"}
|
package/dist/lib/logger.cjs
CHANGED
|
@@ -25,7 +25,7 @@ const createLog = (name, options = {}) => {
|
|
|
25
25
|
return (type, ...args) => (0, _storm_software_config_tools_logger.getLogFn)((0, _storm_software_config_tools_logger.getLogLevel)(type), {
|
|
26
26
|
...options,
|
|
27
27
|
logLevel
|
|
28
|
-
})(`${chalk.default.bold.hex((0, _storm_software_config_tools_utilities_colors.getColor)("brand", options))(
|
|
28
|
+
})(`${name ? chalk.default.bold.hex((0, _storm_software_config_tools_utilities_colors.getColor)("brand", options))((0, _stryke_string_format_kebab_case.kebabCase)(name)) : ""}${options.command ? chalk.default.hex((0, _storm_software_config_tools_utilities_colors.getColor)("brand", options))(` (${options.command})`) : ""}${name ? chalk.default.grey(" > ") : ""}${options.name && (!name || (0, _stryke_string_format_kebab_case.kebabCase)(options.name) !== (0, _stryke_string_format_kebab_case.kebabCase)(name)) ? `${chalk.default.bold.hex((0, _storm_software_config_tools_utilities_colors.getColor)("brand", options))((0, _stryke_string_format_kebab_case.kebabCase)(options.name))}${chalk.default.grey(" > ")}` : ""}${options.environment && options.environment !== "default" ? `${chalk.default.bold.hex((0, _storm_software_config_tools_utilities_colors.getColor)("brand", options))((0, _stryke_string_format_kebab_case.kebabCase)(options.environment))}${chalk.default.grey(" > ")}` : ""}${args.join(" ")} `.trim());
|
|
29
29
|
};
|
|
30
30
|
const BADGE_COLORS = [
|
|
31
31
|
"#00A0DD",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logger.d.cts","names":[],"sources":["../../src/lib/logger.ts"],"mappings":";;;;UA4BiB,gBAAA;EACf,IAAA;EACA,OAAA;EACA,WAAA;EACA,QAAA,GAAW,aAAA;EACX,YAAA,GAAe,KAAA;EACf,MAAA,GAAS,eAAA;AAAA;;;;;;;;cAUE,SAAA,GACX,IAAA,iBACA,OAAA,GAAS,gBAAA,KACR,KAAA;;;;;;;
|
|
1
|
+
{"version":3,"file":"logger.d.cts","names":[],"sources":["../../src/lib/logger.ts"],"mappings":";;;;UA4BiB,gBAAA;EACf,IAAA;EACA,OAAA;EACA,WAAA;EACA,QAAA,GAAW,aAAA;EACX,YAAA,GAAe,KAAA;EACf,MAAA,GAAS,eAAA;AAAA;;;;;;;;cAUE,SAAA,GACX,IAAA,iBACA,OAAA,GAAS,gBAAA,KACR,KAAA;;;;;;;cAuEU,YAAA,GAAgB,IAAA;;;;;;;cAiBhB,SAAA,GAAa,IAAA;;;AAjB1B;;;;cA6Ba,eAAA,GAAmB,IAAA;AAZhC;;;;;AAYA;;AAZA,cAyBa,SAAA,GAAa,KAAA,EAAO,KAAA,EAAO,IAAA,aAAe,KAAA;AAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logger.d.mts","names":[],"sources":["../../src/lib/logger.ts"],"mappings":";;;;UA4BiB,gBAAA;EACf,IAAA;EACA,OAAA;EACA,WAAA;EACA,QAAA,GAAW,aAAA;EACX,YAAA,GAAe,KAAA;EACf,MAAA,GAAS,eAAA;AAAA;;;;;;;;cAUE,SAAA,GACX,IAAA,iBACA,OAAA,GAAS,gBAAA,KACR,KAAA;;;;;;;
|
|
1
|
+
{"version":3,"file":"logger.d.mts","names":[],"sources":["../../src/lib/logger.ts"],"mappings":";;;;UA4BiB,gBAAA;EACf,IAAA;EACA,OAAA;EACA,WAAA;EACA,QAAA,GAAW,aAAA;EACX,YAAA,GAAe,KAAA;EACf,MAAA,GAAS,eAAA;AAAA;;;;;;;;cAUE,SAAA,GACX,IAAA,iBACA,OAAA,GAAS,gBAAA,KACR,KAAA;;;;;;;cAuEU,YAAA,GAAgB,IAAA;;;;;;;cAiBhB,SAAA,GAAa,IAAA;;;AAjB1B;;;;cA6Ba,eAAA,GAAmB,IAAA;AAZhC;;;;;AAYA;;AAZA,cAyBa,SAAA,GAAa,KAAA,EAAO,KAAA,EAAO,IAAA,aAAe,KAAA;AAAA"}
|
package/dist/lib/logger.mjs
CHANGED
|
@@ -22,7 +22,7 @@ const createLog = (name, options = {}) => {
|
|
|
22
22
|
return (type, ...args) => getLogFn(getLogLevel(type), {
|
|
23
23
|
...options,
|
|
24
24
|
logLevel
|
|
25
|
-
})(`${chalk.bold.hex(getColor("brand", options))(
|
|
25
|
+
})(`${name ? chalk.bold.hex(getColor("brand", options))(kebabCase(name)) : ""}${options.command ? chalk.hex(getColor("brand", options))(` (${options.command})`) : ""}${name ? chalk.grey(" > ") : ""}${options.name && (!name || kebabCase(options.name) !== kebabCase(name)) ? `${chalk.bold.hex(getColor("brand", options))(kebabCase(options.name))}${chalk.grey(" > ")}` : ""}${options.environment && options.environment !== "default" ? `${chalk.bold.hex(getColor("brand", options))(kebabCase(options.environment))}${chalk.grey(" > ")}` : ""}${args.join(" ")} `.trim());
|
|
26
26
|
};
|
|
27
27
|
const BADGE_COLORS = [
|
|
28
28
|
"#00A0DD",
|
package/dist/lib/logger.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logger.mjs","names":[],"sources":["../../src/lib/logger.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 { getLogFn, getLogLevel } from \"@storm-software/config-tools/logger\";\nimport { LogLevelLabel } from \"@storm-software/config-tools/types\";\nimport { getColor } from \"@storm-software/config-tools/utilities/colors\";\nimport { noop } from \"@stryke/helpers/noop\";\nimport { kebabCase } from \"@stryke/string-format/kebab-case\";\nimport { titleCase } from \"@stryke/string-format/title-case\";\nimport chalk from \"chalk\";\nimport { DEFAULT_ENVIRONMENT } from \"../constants/environments\";\nimport type { LogFn, WorkspaceConfig } from \"../types\";\n\nexport interface CreateLogOptions {\n name?: string;\n command?: string;\n environment?: string;\n logLevel?: LogLevelLabel | null;\n customLogger?: LogFn;\n colors?: WorkspaceConfig[\"colors\"];\n}\n\n/**\n * Create a logging function with a specific name and options.\n *\n * @param name - The name of the logging function.\n * @param options - The options to configure the logging function.\n * @returns A logging function.\n */\nexport const createLog = (\n name: string | null,\n options: CreateLogOptions = {}\n): LogFn => {\n const logLevel =\n options.logLevel === null\n ? LogLevelLabel.SILENT\n : options.logLevel || LogLevelLabel.INFO;\n if (logLevel === LogLevelLabel.SILENT) {\n return noop;\n }\n\n if (options.customLogger) {\n return options.customLogger;\n }\n\n return (type: LogLevelLabel, ...args: string[]) =>\n getLogFn(getLogLevel(type), {\n ...options,\n logLevel\n })(\n `${chalk.bold.hex(
|
|
1
|
+
{"version":3,"file":"logger.mjs","names":[],"sources":["../../src/lib/logger.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 { getLogFn, getLogLevel } from \"@storm-software/config-tools/logger\";\nimport { LogLevelLabel } from \"@storm-software/config-tools/types\";\nimport { getColor } from \"@storm-software/config-tools/utilities/colors\";\nimport { noop } from \"@stryke/helpers/noop\";\nimport { kebabCase } from \"@stryke/string-format/kebab-case\";\nimport { titleCase } from \"@stryke/string-format/title-case\";\nimport chalk from \"chalk\";\nimport { DEFAULT_ENVIRONMENT } from \"../constants/environments\";\nimport type { LogFn, WorkspaceConfig } from \"../types\";\n\nexport interface CreateLogOptions {\n name?: string;\n command?: string;\n environment?: string;\n logLevel?: LogLevelLabel | null;\n customLogger?: LogFn;\n colors?: WorkspaceConfig[\"colors\"];\n}\n\n/**\n * Create a logging function with a specific name and options.\n *\n * @param name - The name of the logging function.\n * @param options - The options to configure the logging function.\n * @returns A logging function.\n */\nexport const createLog = (\n name: string | null,\n options: CreateLogOptions = {}\n): LogFn => {\n const logLevel =\n options.logLevel === null\n ? LogLevelLabel.SILENT\n : options.logLevel || LogLevelLabel.INFO;\n if (logLevel === LogLevelLabel.SILENT) {\n return noop;\n }\n\n if (options.customLogger) {\n return options.customLogger;\n }\n\n return (type: LogLevelLabel, ...args: string[]) =>\n getLogFn(getLogLevel(type), {\n ...options,\n logLevel\n })(\n `${\n name ? chalk.bold.hex(getColor(\"brand\", options))(kebabCase(name)) : \"\"\n }${\n options.command\n ? chalk.hex(getColor(\"brand\", options))(` (${options.command})`)\n : \"\"\n }${name ? chalk.grey(\" > \") : \"\"}${\n options.name && (!name || kebabCase(options.name) !== kebabCase(name))\n ? `${chalk.bold.hex(getColor(\"brand\", options))(\n kebabCase(options.name)\n )}${chalk.grey(\" > \")}`\n : \"\"\n }${\n options.environment && options.environment !== DEFAULT_ENVIRONMENT\n ? `${chalk.bold.hex(getColor(\"brand\", options))(\n kebabCase(options.environment)\n )}${chalk.grey(\" > \")}`\n : \"\"\n }${args.join(\" \")} `.trim()\n );\n};\n\nconst BADGE_COLORS = [\n \"#00A0DD\",\n \"#6FCE4E\",\n \"#FBBF24\",\n \"#F43F5E\",\n \"#3B82F6\",\n \"#A855F7\",\n \"#469592\",\n \"#288EDF\",\n \"#D8B4FE\",\n \"#10B981\",\n \"#EF4444\",\n \"#F0EC56\",\n \"#F472B6\",\n \"#22D3EE\",\n \"#EAB308\",\n \"#84CC16\",\n \"#F87171\",\n \"#0EA5E9\",\n \"#D946EF\",\n \"#FACC15\",\n \"#34D399\",\n \"#8B5CF6\"\n] as const;\n\n/**\n * Generate a consistent color based on the input text.\n *\n * @param text - The input text to generate the color from.\n * @return A hexadecimal color string.\n */\nexport const getTextColor = (text: string): string => {\n return (\n BADGE_COLORS[\n text\n .split(\"\")\n .map(char => char.charCodeAt(0))\n .reduce((ret, charCode) => ret + charCode, 0) % BADGE_COLORS.length\n ] || BADGE_COLORS[0]\n );\n};\n\n/**\n * Generate a consistent color based on the input text.\n *\n * @param text - The input text to generate the color from.\n * @return A hexadecimal color string.\n */\nexport const colorText = (text: string): string => {\n const title = titleCase(text);\n\n return chalk.hex(getTextColor(title))(title);\n};\n\n/**\n * Generate a consistent color based on the input text.\n *\n * @param text - The input text to generate the color from.\n * @return A hexadecimal color string.\n */\nexport const colorBackground = (text: string): string => {\n const title = titleCase(text);\n\n return chalk.inverse.hex(getTextColor(title))(` ${title} `);\n};\n\n/**\n * Extend a logging function with a specific name, adding a colored badge to the log output.\n *\n * @param logFn - The original logging function to extend.\n * @param name - The name to use for the badge in the log output.\n * @returns A new logging function that includes the badge in its output.\n */\nexport const extendLog = (logFn: LogFn, name: string): LogFn => {\n return (type: LogLevelLabel, ...args: string[]) =>\n logFn(\n type,\n `${colorBackground(name)} ${args\n .filter(Boolean)\n .map(arg => String(arg).trim())\n .join(\" \")} `\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;AA4CA,MAAa,aACX,MACA,UAA4B,EAAE,KACpB;CACV,MAAM,WACJ,QAAQ,aAAa,OACjB,cAAc,SACd,QAAQ,YAAY,cAAc;AACxC,KAAI,aAAa,cAAc,OAC7B,QAAO;AAGT,KAAI,QAAQ,aACV,QAAO,QAAQ;AAGjB,SAAQ,MAAqB,GAAG,SAC9B,SAAS,YAAY,KAAK,EAAE;EAC1B,GAAG;EACH;EACD,CAAC,CACA,GACE,OAAO,MAAM,KAAK,IAAI,SAAS,SAAS,QAAQ,CAAC,CAAC,UAAU,KAAK,CAAC,GAAG,KAErE,QAAQ,UACJ,MAAM,IAAI,SAAS,SAAS,QAAQ,CAAC,CAAC,KAAK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AC,GACd"}
|
|
@@ -48,7 +48,7 @@ function createUnplugin(context, options = {}) {
|
|
|
48
48
|
(0, unplugin.setParseImpl)(ctx.parse);
|
|
49
49
|
const name = options.name || "powerlines";
|
|
50
50
|
return () => {
|
|
51
|
-
const log = require_lib_logger.extendLog(ctx.log, name);
|
|
51
|
+
const log = options.name ? require_lib_logger.extendLog(ctx.log, name) : ctx.log;
|
|
52
52
|
log(_storm_software_config_tools_types.LogLevelLabel.DEBUG, `Initializing ${(0, _stryke_string_format_title_case.titleCase)(name)} plugin`);
|
|
53
53
|
try {
|
|
54
54
|
const { resolveId, load } = require_lib_unplugin_module_resolution.createUnpluginModuleResolutionFunctions(context, options);
|
|
@@ -46,7 +46,7 @@ function createUnplugin(context, options = {}) {
|
|
|
46
46
|
setParseImpl(ctx.parse);
|
|
47
47
|
const name = options.name || "powerlines";
|
|
48
48
|
return () => {
|
|
49
|
-
const log = extendLog(ctx.log, name);
|
|
49
|
+
const log = options.name ? extendLog(ctx.log, name) : ctx.log;
|
|
50
50
|
log(LogLevelLabel.DEBUG, `Initializing ${titleCase(name)} plugin`);
|
|
51
51
|
try {
|
|
52
52
|
const { resolveId, load } = createUnpluginModuleResolutionFunctions(context, options);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.mjs","names":[],"sources":["../../../src/lib/unplugin/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 { Unstable_PluginContext } from \"@powerlines/core/types/_internal\";\nimport { LogLevelLabel } from \"@storm-software/config-tools/types\";\nimport { kebabCase } from \"@stryke/string-format/kebab-case\";\nimport { titleCase } from \"@stryke/string-format/title-case\";\nimport type {\n TransformResult,\n UnpluginBuildContext,\n UnpluginContext\n} from \"unplugin\";\nimport { setParseImpl } from \"unplugin\";\nimport { PluginContext } from \"../../types/context\";\nimport { UnpluginFactory } from \"../../types/unplugin\";\nimport { extendLog } from \"../logger\";\nimport { getString } from \"../utilities/source-file\";\nimport { combineContexts } from \"./helpers\";\nimport {\n createUnpluginModuleResolutionFunctions,\n CreateUnpluginModuleResolutionFunctionsOptions\n} from \"./module-resolution\";\n\nexport interface CreateUnpluginResolverOptions extends CreateUnpluginModuleResolutionFunctionsOptions {\n /**\n * A name to use for the unplugin instance. This is used for logging and to generate the plugin name. It does not affect the functionality of the plugin.\n *\n * @remarks\n * If not provided, the plugin will be named \"powerlines\". If provided, the plugin will be named `${name} - Powerlines` (e.g., \"MyPlugin - Powerlines\").\n *\n * @defaultValue \"powerlines\"\n */\n name?: string;\n}\n\n/**\n * Creates a Powerlines unplugin instance.\n *\n * @param context - The plugin context.\n * @returns The unplugin instance.\n */\nexport function createUnpluginResolver<\n TContext extends PluginContext = PluginContext\n>(\n context: TContext,\n options: CreateUnpluginResolverOptions = {}\n): UnpluginFactory<TContext> {\n const ctx = context as unknown as Unstable_PluginContext;\n setParseImpl(ctx.parse);\n\n const name = options.name || \"powerlines\";\n\n return () => {\n const log = extendLog(ctx.log, name);\n log(LogLevelLabel.DEBUG, `Initializing ${titleCase(name)} plugin`);\n\n try {\n const { resolveId, load } =\n createUnpluginModuleResolutionFunctions<TContext>(context, options);\n\n return {\n name:\n name.toLowerCase() === \"powerlines\"\n ? \"powerlines\"\n : `powerlines:${kebabCase(name)}`,\n api: ctx.$$internal.api,\n resolveId,\n load\n };\n } catch (error) {\n log(LogLevelLabel.FATAL, (error as Error)?.message);\n\n throw error;\n }\n };\n}\n\nexport interface CreateUnpluginOptions extends CreateUnpluginResolverOptions {\n /**\n * Whether to silence logging for the plugin hooks. This can be useful for plugins that run frequently or have hooks that are called often, to reduce noise in the logs. When set to `true`, the plugin will not log any messages for its hooks. When set to `false` (the default), the plugin will log messages for its hooks as normal.\n *\n * @defaultValue false\n */\n silenceHookLogging?: boolean;\n}\n\n/**\n * Creates a Powerlines unplugin instance.\n *\n * @param context - The plugin context.\n * @returns The unplugin instance.\n */\nexport function createUnplugin<TContext extends PluginContext = PluginContext>(\n context: TContext,\n options: CreateUnpluginOptions = {}\n): UnpluginFactory<TContext> {\n const ctx = context as unknown as Unstable_PluginContext;\n setParseImpl(ctx.parse);\n\n const name = options.name || \"powerlines\";\n\n return () => {\n const log = extendLog(ctx.log, name);\n log(LogLevelLabel.DEBUG, `Initializing ${titleCase(name)} plugin`);\n\n try {\n const { resolveId, load } =\n createUnpluginModuleResolutionFunctions<TContext>(context, options);\n\n async function buildStart(this: UnpluginBuildContext) {\n if (!options.silenceHookLogging) {\n log(LogLevelLabel.DEBUG, \"Powerlines build plugin starting...\");\n }\n\n await ctx.$$internal.callHook(\"buildStart\", {\n sequential: true\n });\n }\n\n async function transform(\n this: UnpluginBuildContext & UnpluginContext,\n code: string,\n id: string\n ): Promise<TransformResult | null | undefined> {\n let transformed: TransformResult | string = code;\n\n for (const hook of ctx.$$internal.environment.selectHooks(\n \"transform\"\n )) {\n const result: TransformResult | string | undefined =\n await hook.handler.apply(combineContexts(ctx, this), [\n getString(transformed),\n id\n ]);\n if (result) {\n transformed = result;\n }\n }\n\n return transformed;\n }\n\n async function buildEnd(this: UnpluginBuildContext): Promise<void> {\n if (!options.silenceHookLogging) {\n log(LogLevelLabel.DEBUG, \"Powerlines build plugin finishing...\");\n }\n\n return ctx.$$internal.callHook(\"buildEnd\", {\n sequential: true\n });\n }\n\n async function writeBundle(): Promise<void> {\n if (!options.silenceHookLogging) {\n log(LogLevelLabel.DEBUG, \"Finalizing Powerlines project output...\");\n }\n\n return ctx.$$internal.callHook(\"writeBundle\", {\n sequential: true\n });\n }\n\n return {\n name:\n name.toLowerCase() === \"powerlines\"\n ? \"powerlines\"\n : `powerlines:${kebabCase(name)}`,\n api: ctx.$$internal.api,\n resolveId,\n load,\n transform,\n buildStart,\n buildEnd,\n writeBundle,\n vite: {\n sharedDuringBuild: true\n }\n };\n } catch (error) {\n log(LogLevelLabel.FATAL, (error as Error)?.message);\n\n throw error;\n }\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAwDA,SAAgB,uBAGd,SACA,UAAyC,EAAE,EAChB;CAC3B,MAAM,MAAM;AACZ,cAAa,IAAI,MAAM;CAEvB,MAAM,OAAO,QAAQ,QAAQ;AAE7B,cAAa;EACX,MAAM,MAAM,UAAU,IAAI,KAAK,KAAK;AACpC,MAAI,cAAc,OAAO,gBAAgB,UAAU,KAAK,CAAC,SAAS;AAElE,MAAI;GACF,MAAM,EAAE,WAAW,SACjB,wCAAkD,SAAS,QAAQ;AAErE,UAAO;IACL,MACE,KAAK,aAAa,KAAK,eACnB,eACA,cAAc,UAAU,KAAK;IACnC,KAAK,IAAI,WAAW;IACpB;IACA;IACD;WACM,OAAO;AACd,OAAI,cAAc,OAAQ,OAAiB,QAAQ;AAEnD,SAAM;;;;;;;;;;AAoBZ,SAAgB,eACd,SACA,UAAiC,EAAE,EACR;CAC3B,MAAM,MAAM;AACZ,cAAa,IAAI,MAAM;CAEvB,MAAM,OAAO,QAAQ,QAAQ;AAE7B,cAAa;EACX,MAAM,MAAM,UAAU,IAAI,KAAK,KAAK;
|
|
1
|
+
{"version":3,"file":"plugin.mjs","names":[],"sources":["../../../src/lib/unplugin/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 { Unstable_PluginContext } from \"@powerlines/core/types/_internal\";\nimport { LogLevelLabel } from \"@storm-software/config-tools/types\";\nimport { kebabCase } from \"@stryke/string-format/kebab-case\";\nimport { titleCase } from \"@stryke/string-format/title-case\";\nimport type {\n TransformResult,\n UnpluginBuildContext,\n UnpluginContext\n} from \"unplugin\";\nimport { setParseImpl } from \"unplugin\";\nimport { PluginContext } from \"../../types/context\";\nimport { UnpluginFactory } from \"../../types/unplugin\";\nimport { extendLog } from \"../logger\";\nimport { getString } from \"../utilities/source-file\";\nimport { combineContexts } from \"./helpers\";\nimport {\n createUnpluginModuleResolutionFunctions,\n CreateUnpluginModuleResolutionFunctionsOptions\n} from \"./module-resolution\";\n\nexport interface CreateUnpluginResolverOptions extends CreateUnpluginModuleResolutionFunctionsOptions {\n /**\n * A name to use for the unplugin instance. This is used for logging and to generate the plugin name. It does not affect the functionality of the plugin.\n *\n * @remarks\n * If not provided, the plugin will be named \"powerlines\". If provided, the plugin will be named `${name} - Powerlines` (e.g., \"MyPlugin - Powerlines\").\n *\n * @defaultValue \"powerlines\"\n */\n name?: string;\n}\n\n/**\n * Creates a Powerlines unplugin instance.\n *\n * @param context - The plugin context.\n * @returns The unplugin instance.\n */\nexport function createUnpluginResolver<\n TContext extends PluginContext = PluginContext\n>(\n context: TContext,\n options: CreateUnpluginResolverOptions = {}\n): UnpluginFactory<TContext> {\n const ctx = context as unknown as Unstable_PluginContext;\n setParseImpl(ctx.parse);\n\n const name = options.name || \"powerlines\";\n\n return () => {\n const log = extendLog(ctx.log, name);\n log(LogLevelLabel.DEBUG, `Initializing ${titleCase(name)} plugin`);\n\n try {\n const { resolveId, load } =\n createUnpluginModuleResolutionFunctions<TContext>(context, options);\n\n return {\n name:\n name.toLowerCase() === \"powerlines\"\n ? \"powerlines\"\n : `powerlines:${kebabCase(name)}`,\n api: ctx.$$internal.api,\n resolveId,\n load\n };\n } catch (error) {\n log(LogLevelLabel.FATAL, (error as Error)?.message);\n\n throw error;\n }\n };\n}\n\nexport interface CreateUnpluginOptions extends CreateUnpluginResolverOptions {\n /**\n * Whether to silence logging for the plugin hooks. This can be useful for plugins that run frequently or have hooks that are called often, to reduce noise in the logs. When set to `true`, the plugin will not log any messages for its hooks. When set to `false` (the default), the plugin will log messages for its hooks as normal.\n *\n * @defaultValue false\n */\n silenceHookLogging?: boolean;\n}\n\n/**\n * Creates a Powerlines unplugin instance.\n *\n * @param context - The plugin context.\n * @returns The unplugin instance.\n */\nexport function createUnplugin<TContext extends PluginContext = PluginContext>(\n context: TContext,\n options: CreateUnpluginOptions = {}\n): UnpluginFactory<TContext> {\n const ctx = context as unknown as Unstable_PluginContext;\n setParseImpl(ctx.parse);\n\n const name = options.name || \"powerlines\";\n\n return () => {\n const log = options.name ? extendLog(ctx.log, name) : ctx.log;\n log(LogLevelLabel.DEBUG, `Initializing ${titleCase(name)} plugin`);\n\n try {\n const { resolveId, load } =\n createUnpluginModuleResolutionFunctions<TContext>(context, options);\n\n async function buildStart(this: UnpluginBuildContext) {\n if (!options.silenceHookLogging) {\n log(LogLevelLabel.DEBUG, \"Powerlines build plugin starting...\");\n }\n\n await ctx.$$internal.callHook(\"buildStart\", {\n sequential: true\n });\n }\n\n async function transform(\n this: UnpluginBuildContext & UnpluginContext,\n code: string,\n id: string\n ): Promise<TransformResult | null | undefined> {\n let transformed: TransformResult | string = code;\n\n for (const hook of ctx.$$internal.environment.selectHooks(\n \"transform\"\n )) {\n const result: TransformResult | string | undefined =\n await hook.handler.apply(combineContexts(ctx, this), [\n getString(transformed),\n id\n ]);\n if (result) {\n transformed = result;\n }\n }\n\n return transformed;\n }\n\n async function buildEnd(this: UnpluginBuildContext): Promise<void> {\n if (!options.silenceHookLogging) {\n log(LogLevelLabel.DEBUG, \"Powerlines build plugin finishing...\");\n }\n\n return ctx.$$internal.callHook(\"buildEnd\", {\n sequential: true\n });\n }\n\n async function writeBundle(): Promise<void> {\n if (!options.silenceHookLogging) {\n log(LogLevelLabel.DEBUG, \"Finalizing Powerlines project output...\");\n }\n\n return ctx.$$internal.callHook(\"writeBundle\", {\n sequential: true\n });\n }\n\n return {\n name:\n name.toLowerCase() === \"powerlines\"\n ? \"powerlines\"\n : `powerlines:${kebabCase(name)}`,\n api: ctx.$$internal.api,\n resolveId,\n load,\n transform,\n buildStart,\n buildEnd,\n writeBundle,\n vite: {\n sharedDuringBuild: true\n }\n };\n } catch (error) {\n log(LogLevelLabel.FATAL, (error as Error)?.message);\n\n throw error;\n }\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAwDA,SAAgB,uBAGd,SACA,UAAyC,EAAE,EAChB;CAC3B,MAAM,MAAM;AACZ,cAAa,IAAI,MAAM;CAEvB,MAAM,OAAO,QAAQ,QAAQ;AAE7B,cAAa;EACX,MAAM,MAAM,UAAU,IAAI,KAAK,KAAK;AACpC,MAAI,cAAc,OAAO,gBAAgB,UAAU,KAAK,CAAC,SAAS;AAElE,MAAI;GACF,MAAM,EAAE,WAAW,SACjB,wCAAkD,SAAS,QAAQ;AAErE,UAAO;IACL,MACE,KAAK,aAAa,KAAK,eACnB,eACA,cAAc,UAAU,KAAK;IACnC,KAAK,IAAI,WAAW;IACpB;IACA;IACD;WACM,OAAO;AACd,OAAI,cAAc,OAAQ,OAAiB,QAAQ;AAEnD,SAAM;;;;;;;;;;AAoBZ,SAAgB,eACd,SACA,UAAiC,EAAE,EACR;CAC3B,MAAM,MAAM;AACZ,cAAa,IAAI,MAAM;CAEvB,MAAM,OAAO,QAAQ,QAAQ;AAE7B,cAAa;EACX,MAAM,MAAM,QAAQ,OAAO,UAAU,IAAI,KAAK,KAAK,GAAG,IAAI;AAC1D,MAAI,cAAc,OAAO,gBAAgB,UAAU,KAAK,CAAC,SAAS;AAElE,MAAI;GACF,MAAM,EAAE,WAAW,SACjB,wCAAkD,SAAS,QAAQ;GAErE,eAAe,aAAuC;AACpD,QAAI,CAAC,QAAQ,mBACX,KAAI,cAAc,OAAO,sCAAsC;AAGjE,UAAM,IAAI,WAAW,SAAS,cAAc,EAC1C,YAAY,MACb,CAAC;;GAGJ,eAAe,UAEb,MACA,IAC6C;IAC7C,IAAI,cAAwC;AAE5C,SAAK,MAAM,QAAQ,IAAI,WAAW,YAAY,YAC5C,YACD,EAAE;KACD,MAAM,SACJ,MAAM,KAAK,QAAQ,MAAM,gBAAgB,KAAK,KAAK,EAAE,CACnD,UAAU,YAAY,EACtB,GACD,CAAC;AACJ,SAAI,OACF,eAAc;;AAIlB,WAAO;;GAGT,eAAe,WAAoD;AACjE,QAAI,CAAC,QAAQ,mBACX,KAAI,cAAc,OAAO,uCAAuC;AAGlE,WAAO,IAAI,WAAW,SAAS,YAAY,EACzC,YAAY,MACb,CAAC;;GAGJ,eAAe,cAA6B;AAC1C,QAAI,CAAC,QAAQ,mBACX,KAAI,cAAc,OAAO,0CAA0C;AAGrE,WAAO,IAAI,WAAW,SAAS,eAAe,EAC5C,YAAY,MACb,CAAC;;AAGJ,UAAO;IACL,MACE,KAAK,aAAa,KAAK,eACnB,eACA,cAAc,UAAU,KAAK;IACnC,KAAK,IAAI,WAAW;IACpB;IACA;IACA;IACA;IACA;IACA;IACA,MAAM,EACJ,mBAAmB,MACpB;IACF;WACM,OAAO;AACd,OAAI,cAAc,OAAQ,OAAiB,QAAQ;AAEnD,SAAM"}
|
|
@@ -20,7 +20,7 @@ prettier_plugin_organize_imports = require_runtime.__toESM(prettier_plugin_organ
|
|
|
20
20
|
* @returns A promise that resolves to the formatted code string.
|
|
21
21
|
*/
|
|
22
22
|
async function format(context, path, data, force = false) {
|
|
23
|
-
if (!force && (context.config.output.copy && (0, _stryke_path_is_parent_path.isParentPath)(path, (0, _stryke_path_append.appendPath)(context.config.output.copy.path, context.
|
|
23
|
+
if (!force && (context.config.output.copy && (0, _stryke_path_is_parent_path.isParentPath)(path, (0, _stryke_path_append.appendPath)(context.config.output.copy.path, context.config.cwd)) || (0, _stryke_path_is_parent_path.isParentPath)(path, (0, _stryke_path_append.appendPath)(context.config.output.path, context.config.cwd)))) return data;
|
|
24
24
|
let code = data;
|
|
25
25
|
try {
|
|
26
26
|
const resolvedConfig = await (0, prettier.resolveConfig)(path);
|
|
@@ -41,8 +41,8 @@ async function format(context, path, data, force = false) {
|
|
|
41
41
|
* @returns A promise that resolves when all files have been formatted.
|
|
42
42
|
*/
|
|
43
43
|
async function formatFolder(context, path) {
|
|
44
|
-
if (!context.config.output.copy || !(0, _stryke_path_is_parent_path.isParentPath)(path, (0, _stryke_path_append.appendPath)(context.config.output.copy.path, context.
|
|
45
|
-
if ((!context.config.output.copy || !(0, _stryke_path_is_parent_path.isParentPath)(file, (0, _stryke_path_append.appendPath)(context.config.output.copy.path, context.
|
|
44
|
+
if (!context.config.output.copy || !(0, _stryke_path_is_parent_path.isParentPath)(path, (0, _stryke_path_append.appendPath)(context.config.output.copy.path, context.config.cwd)) && !(0, _stryke_path_is_parent_path.isParentPath)(path, (0, _stryke_path_append.appendPath)(context.config.output.path, context.config.cwd))) await Promise.allSettled((await (0, _stryke_fs_list_files.listFiles)(path)).map(async (file) => {
|
|
45
|
+
if ((!context.config.output.copy || !(0, _stryke_path_is_parent_path.isParentPath)(file, (0, _stryke_path_append.appendPath)(context.config.output.copy.path, context.config.cwd))) && !(0, _stryke_path_is_parent_path.isParentPath)(file, (0, _stryke_path_append.appendPath)(context.config.output.path, context.config.cwd))) {
|
|
46
46
|
const data = await context.fs.read(file);
|
|
47
47
|
if (data) {
|
|
48
48
|
const formatted = await format(context, file, data);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"format.d.cts","names":[],"sources":["../../../src/lib/utilities/format.ts"],"mappings":";;;;;AAoCA;;;;;;;iBAAsB,MAAA,CACpB,OAAA,EAAS,OAAA,EACT,IAAA,UACA,IAAA,UACA,KAAA,aACC,OAAA;;;;;
|
|
1
|
+
{"version":3,"file":"format.d.cts","names":[],"sources":["../../../src/lib/utilities/format.ts"],"mappings":";;;;;AAoCA;;;;;;;iBAAsB,MAAA,CACpB,OAAA,EAAS,OAAA,EACT,IAAA,UACA,IAAA,UACA,KAAA,aACC,OAAA;;;;;AAoDH;;;iBAAsB,YAAA,CAAa,OAAA,EAAS,OAAA,EAAS,IAAA,WAAY,OAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"format.d.mts","names":[],"sources":["../../../src/lib/utilities/format.ts"],"mappings":";;;;;AAoCA;;;;;;;iBAAsB,MAAA,CACpB,OAAA,EAAS,OAAA,EACT,IAAA,UACA,IAAA,UACA,KAAA,aACC,OAAA;;;;;
|
|
1
|
+
{"version":3,"file":"format.d.mts","names":[],"sources":["../../../src/lib/utilities/format.ts"],"mappings":";;;;;AAoCA;;;;;;;iBAAsB,MAAA,CACpB,OAAA,EAAS,OAAA,EACT,IAAA,UACA,IAAA,UACA,KAAA,aACC,OAAA;;;;;AAoDH;;;iBAAsB,YAAA,CAAa,OAAA,EAAS,OAAA,EAAS,IAAA,WAAY,OAAA"}
|
|
@@ -17,7 +17,7 @@ import importsPlugin from "prettier-plugin-organize-imports";
|
|
|
17
17
|
* @returns A promise that resolves to the formatted code string.
|
|
18
18
|
*/
|
|
19
19
|
async function format(context, path, data, force = false) {
|
|
20
|
-
if (!force && (context.config.output.copy && isParentPath(path, appendPath(context.config.output.copy.path, context.
|
|
20
|
+
if (!force && (context.config.output.copy && isParentPath(path, appendPath(context.config.output.copy.path, context.config.cwd)) || isParentPath(path, appendPath(context.config.output.path, context.config.cwd)))) return data;
|
|
21
21
|
let code = data;
|
|
22
22
|
try {
|
|
23
23
|
const resolvedConfig = await resolveConfig(path);
|
|
@@ -38,8 +38,8 @@ async function format(context, path, data, force = false) {
|
|
|
38
38
|
* @returns A promise that resolves when all files have been formatted.
|
|
39
39
|
*/
|
|
40
40
|
async function formatFolder(context, path) {
|
|
41
|
-
if (!context.config.output.copy || !isParentPath(path, appendPath(context.config.output.copy.path, context.
|
|
42
|
-
if ((!context.config.output.copy || !isParentPath(file, appendPath(context.config.output.copy.path, context.
|
|
41
|
+
if (!context.config.output.copy || !isParentPath(path, appendPath(context.config.output.copy.path, context.config.cwd)) && !isParentPath(path, appendPath(context.config.output.path, context.config.cwd))) await Promise.allSettled((await listFiles(path)).map(async (file) => {
|
|
42
|
+
if ((!context.config.output.copy || !isParentPath(file, appendPath(context.config.output.copy.path, context.config.cwd))) && !isParentPath(file, appendPath(context.config.output.path, context.config.cwd))) {
|
|
43
43
|
const data = await context.fs.read(file);
|
|
44
44
|
if (data) {
|
|
45
45
|
const formatted = await format(context, file, data);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"format.mjs","names":["prettier","defu"],"sources":["../../../src/lib/utilities/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 { listFiles } from \"@stryke/fs/list-files\";\nimport { appendPath } from \"@stryke/path/append\";\nimport { findFileExtension } from \"@stryke/path/file-path-fns\";\nimport { isParentPath } from \"@stryke/path/is-parent-path\";\nimport { defu } from \"defu\";\nimport { format as prettier, resolveConfig } from \"prettier\";\nimport importsPlugin from \"prettier-plugin-organize-imports\";\nimport { Context } from \"../../types/context\";\n\n/**\n * Formats code using Prettier based on the file path.\n *\n * @param context - The Powerlines context.\n * @param path - The file path to use for resolving Prettier configuration.\n * @param data - The code string to format.\n * @param force - Whether to force formatting even for output/build paths.\n * @returns A promise that resolves to the formatted code string.\n */\nexport async function format(\n context: Context,\n path: string,\n data: string,\n force = false\n): Promise<string> {\n if (\n !force &&\n ((context.config.output.copy &&\n isParentPath(\n path,\n appendPath(
|
|
1
|
+
{"version":3,"file":"format.mjs","names":["prettier","defu"],"sources":["../../../src/lib/utilities/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 { listFiles } from \"@stryke/fs/list-files\";\nimport { appendPath } from \"@stryke/path/append\";\nimport { findFileExtension } from \"@stryke/path/file-path-fns\";\nimport { isParentPath } from \"@stryke/path/is-parent-path\";\nimport { defu } from \"defu\";\nimport { format as prettier, resolveConfig } from \"prettier\";\nimport importsPlugin from \"prettier-plugin-organize-imports\";\nimport { Context } from \"../../types/context\";\n\n/**\n * Formats code using Prettier based on the file path.\n *\n * @param context - The Powerlines context.\n * @param path - The file path to use for resolving Prettier configuration.\n * @param data - The code string to format.\n * @param force - Whether to force formatting even for output/build paths.\n * @returns A promise that resolves to the formatted code string.\n */\nexport async function format(\n context: Context,\n path: string,\n data: string,\n force = false\n): Promise<string> {\n if (\n !force &&\n ((context.config.output.copy &&\n isParentPath(\n path,\n appendPath(context.config.output.copy.path, context.config.cwd)\n )) ||\n isParentPath(\n path,\n appendPath(context.config.output.path, context.config.cwd)\n ))\n ) {\n return data;\n }\n\n let code = data;\n try {\n const resolvedConfig = await resolveConfig(path);\n if (resolvedConfig) {\n code = await prettier(\n data,\n defu(\n {\n absolutePath: path,\n ...resolvedConfig\n },\n findFileExtension(path) === \"ts\" || findFileExtension(path) === \"tsx\"\n ? { plugins: [importsPlugin] }\n : {}\n )\n );\n }\n } catch (error) {\n throw new Error(\n `Failed to format file at ${path} with Prettier: ${\n (error as Error).message\n }`,\n { cause: error }\n );\n }\n\n return code;\n}\n\n/**\n * Formats all files in a folder using Prettier based on their file paths.\n *\n * @param context - The Powerlines context.\n * @param path - The folder path containing files to format.\n * @returns A promise that resolves when all files have been formatted.\n */\nexport async function formatFolder(context: Context, path: string) {\n if (\n !context.config.output.copy ||\n (!isParentPath(\n path,\n appendPath(context.config.output.copy.path, context.config.cwd)\n ) &&\n !isParentPath(\n path,\n appendPath(context.config.output.path, context.config.cwd)\n ))\n ) {\n await Promise.allSettled(\n (await listFiles(path)).map(async file => {\n if (\n (!context.config.output.copy ||\n !isParentPath(\n file,\n appendPath(context.config.output.copy.path, context.config.cwd)\n )) &&\n !isParentPath(\n file,\n appendPath(context.config.output.path, context.config.cwd)\n )\n ) {\n const data = await context.fs.read(file);\n if (data) {\n const formatted = await format(context, file, data);\n\n return context.fs.write(file, formatted);\n }\n }\n })\n );\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAoCA,eAAsB,OACpB,SACA,MACA,MACA,QAAQ,OACS;AACjB,KACE,CAAC,UACC,QAAQ,OAAO,OAAO,QACtB,aACE,MACA,WAAW,QAAQ,OAAO,OAAO,KAAK,MAAM,QAAQ,OAAO,IAAI,CAChE,IACD,aACE,MACA,WAAW,QAAQ,OAAO,OAAO,MAAM,QAAQ,OAAO,IAAI,CAC3D,EAEH,QAAO;CAGT,IAAI,OAAO;AACX,KAAI;EACF,MAAM,iBAAiB,MAAM,cAAc,KAAK;AAChD,MAAI,eACF,QAAO,MAAMA,SACX,MACAC,OACE;GACE,cAAc;GACd,GAAG;GACJ,EACD,kBAAkB,KAAK,KAAK,QAAQ,kBAAkB,KAAK,KAAK,QAC5D,EAAE,SAAS,CAAC,cAAc,EAAE,GAC5B,EAAE,CACP,CACF;UAEI,OAAO;AACd,QAAM,IAAI,MACR,4BAA4B,KAAK,kBAC9B,MAAgB,WAEnB,EAAE,OAAO,OAAO,CACjB;;AAGH,QAAO;;;;;;;;;AAUT,eAAsB,aAAa,SAAkB,MAAc;AACjE,KACE,CAAC,QAAQ,OAAO,OAAO,QACtB,CAAC,aACA,MACA,WAAW,QAAQ,OAAO,OAAO,KAAK,MAAM,QAAQ,OAAO,IAAI,CAChE,IACC,CAAC,aACC,MACA,WAAW,QAAQ,OAAO,OAAO,MAAM,QAAQ,OAAO,IAAI,CAC3D,CAEH,OAAM,QAAQ,YACX,MAAM,UAAU,KAAK,EAAE,IAAI,OAAM,SAAQ;AACxC,OACG,CAAC,QAAQ,OAAO,OAAO,QACtB,CAAC,aACC,MACA,WAAW,QAAQ,OAAO,OAAO,KAAK,MAAM,QAAQ,OAAO,IAAI,CAChE,KACH,CAAC,aACC,MACA,WAAW,QAAQ,OAAO,OAAO,MAAM,QAAQ,OAAO,IAAI,CAC3D,EACD;GACA,MAAM,OAAO,MAAM,QAAQ,GAAG,KAAK,KAAK;AACxC,OAAI,MAAM;IACR,MAAM,YAAY,MAAM,OAAO,SAAS,MAAM,KAAK;AAEnD,WAAO,QAAQ,GAAG,MAAM,MAAM,UAAU;;;GAG5C,CACH"}
|
package/dist/plugin-base.cjs
CHANGED
|
@@ -56,8 +56,8 @@ const plugin = (options = {}) => {
|
|
|
56
56
|
async build() {
|
|
57
57
|
await (0, tsdown.build)({
|
|
58
58
|
name: this.config.name,
|
|
59
|
-
cwd: (0, _stryke_path_append.appendPath)(this.config.root, this.
|
|
60
|
-
entry: this.entry.filter((entry) => entry?.file).length > 0 ? Object.fromEntries(this.entry.filter((entry) => entry?.file).map((entry) => [entry.output || (0, _stryke_path_replace.replaceExtension)((0, _stryke_path_replace.replacePath)((0, _stryke_path_replace.replacePath)(entry.file, (0, _stryke_path_join.joinPaths)(this.config.root, "src")), this.entryPath)), entry.file])) : [(0, _stryke_path_join.joinPaths)(this.
|
|
59
|
+
cwd: (0, _stryke_path_append.appendPath)(this.config.root, this.config.cwd),
|
|
60
|
+
entry: this.entry.filter((entry) => entry?.file).length > 0 ? Object.fromEntries(this.entry.filter((entry) => entry?.file).map((entry) => [entry.output || (0, _stryke_path_replace.replaceExtension)((0, _stryke_path_replace.replacePath)((0, _stryke_path_replace.replacePath)(entry.file, (0, _stryke_path_join.joinPaths)(this.config.root, "src")), this.entryPath)), entry.file])) : [(0, _stryke_path_join.joinPaths)(this.config.cwd, this.config.root, "src", "**/*.ts"), (0, _stryke_path_join.joinPaths)(this.config.cwd, this.config.root, "src", "**/*.tsx")],
|
|
61
61
|
platform: this.config.platform,
|
|
62
62
|
tsconfig: this.tsconfig.tsconfigFilePath,
|
|
63
63
|
outDir: this.config.output.path,
|
package/dist/plugin-base.mjs
CHANGED
|
@@ -54,8 +54,8 @@ const plugin = (options = {}) => {
|
|
|
54
54
|
async build() {
|
|
55
55
|
await build({
|
|
56
56
|
name: this.config.name,
|
|
57
|
-
cwd: appendPath(this.config.root, this.
|
|
58
|
-
entry: this.entry.filter((entry) => entry?.file).length > 0 ? Object.fromEntries(this.entry.filter((entry) => entry?.file).map((entry) => [entry.output || replaceExtension(replacePath(replacePath(entry.file, joinPaths(this.config.root, "src")), this.entryPath)), entry.file])) : [joinPaths(this.
|
|
57
|
+
cwd: appendPath(this.config.root, this.config.cwd),
|
|
58
|
+
entry: this.entry.filter((entry) => entry?.file).length > 0 ? Object.fromEntries(this.entry.filter((entry) => entry?.file).map((entry) => [entry.output || replaceExtension(replacePath(replacePath(entry.file, joinPaths(this.config.root, "src")), this.entryPath)), entry.file])) : [joinPaths(this.config.cwd, this.config.root, "src", "**/*.ts"), joinPaths(this.config.cwd, this.config.root, "src", "**/*.tsx")],
|
|
59
59
|
platform: this.config.platform,
|
|
60
60
|
tsconfig: this.tsconfig.tsconfigFilePath,
|
|
61
61
|
outDir: this.config.output.path,
|
package/dist/plugin-base.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin-base.mjs","names":[],"sources":["../src/plugin-base.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { appendPath } from \"@stryke/path/append\";\nimport { joinPaths } from \"@stryke/path/join\";\nimport { replaceExtension, replacePath } from \"@stryke/path/replace\";\nimport { build, UserConfig as BuildOptions } from \"tsdown\";\nimport { formatPackageJson } from \"./plugin-utils/format-package-json\";\nimport { ResolvedConfig, UserConfig } from \"./types/config\";\nimport { PluginContext } from \"./types/context\";\nimport { Plugin } from \"./types/plugin\";\n\nexport interface BasePluginOptions {\n tsdown?: Partial<BuildOptions>;\n}\n\nexport type BasePluginUserConfig = UserConfig & {\n tsdown: BasePluginOptions;\n};\n\nexport type BasePluginResolvedConfig = ResolvedConfig & {\n tsdown: Required<BasePluginOptions>;\n};\n\nexport type BasePluginContext<\n TResolvedConfig extends BasePluginResolvedConfig = BasePluginResolvedConfig\n> = PluginContext<TResolvedConfig>;\n\n/**\n * A Powerlines plugin to assist in developing other Powerlines plugins.\n */\nexport const plugin = <TContext extends BasePluginContext = BasePluginContext>(\n options: BasePluginOptions = {}\n): Plugin<TContext> => {\n return {\n name: \"base\",\n config() {\n return {\n projectType: \"library\",\n input: [\"src/index.ts\", \"src/types/*.ts\", \"src/helpers/*.ts\"],\n output: {\n format: [\"cjs\", \"esm\"],\n dts: false\n },\n platform: \"node\",\n tsdown: {\n format: [\"cjs\", \"esm\"],\n logLevel: \"silent\",\n target: \"esnext\",\n cjsDefault: true,\n treeshake: true,\n exports: true,\n fixedExtension: true,\n nodeProtocol: true,\n minify: false,\n dts: true,\n shims: true,\n outDir: \"dist\",\n clean: true,\n deps: {\n neverBundle: [\"powerlines\", /^powerlines\\/.*$/, /^@powerlines\\//],\n skipNodeModulesBundle: true\n },\n unbundle: true,\n ...options.tsdown\n }\n };\n },\n async build() {\n await build({\n name: this.config.name,\n cwd: appendPath(this.config.root, this.
|
|
1
|
+
{"version":3,"file":"plugin-base.mjs","names":[],"sources":["../src/plugin-base.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { appendPath } from \"@stryke/path/append\";\nimport { joinPaths } from \"@stryke/path/join\";\nimport { replaceExtension, replacePath } from \"@stryke/path/replace\";\nimport { build, UserConfig as BuildOptions } from \"tsdown\";\nimport { formatPackageJson } from \"./plugin-utils/format-package-json\";\nimport { ResolvedConfig, UserConfig } from \"./types/config\";\nimport { PluginContext } from \"./types/context\";\nimport { Plugin } from \"./types/plugin\";\n\nexport interface BasePluginOptions {\n tsdown?: Partial<BuildOptions>;\n}\n\nexport type BasePluginUserConfig = UserConfig & {\n tsdown: BasePluginOptions;\n};\n\nexport type BasePluginResolvedConfig = ResolvedConfig & {\n tsdown: Required<BasePluginOptions>;\n};\n\nexport type BasePluginContext<\n TResolvedConfig extends BasePluginResolvedConfig = BasePluginResolvedConfig\n> = PluginContext<TResolvedConfig>;\n\n/**\n * A Powerlines plugin to assist in developing other Powerlines plugins.\n */\nexport const plugin = <TContext extends BasePluginContext = BasePluginContext>(\n options: BasePluginOptions = {}\n): Plugin<TContext> => {\n return {\n name: \"base\",\n config() {\n return {\n projectType: \"library\",\n input: [\"src/index.ts\", \"src/types/*.ts\", \"src/helpers/*.ts\"],\n output: {\n format: [\"cjs\", \"esm\"],\n dts: false\n },\n platform: \"node\",\n tsdown: {\n format: [\"cjs\", \"esm\"],\n logLevel: \"silent\",\n target: \"esnext\",\n cjsDefault: true,\n treeshake: true,\n exports: true,\n fixedExtension: true,\n nodeProtocol: true,\n minify: false,\n dts: true,\n shims: true,\n outDir: \"dist\",\n clean: true,\n deps: {\n neverBundle: [\"powerlines\", /^powerlines\\/.*$/, /^@powerlines\\//],\n skipNodeModulesBundle: true\n },\n unbundle: true,\n ...options.tsdown\n }\n };\n },\n async build() {\n await build({\n name: this.config.name,\n cwd: appendPath(this.config.root, this.config.cwd),\n entry:\n this.entry.filter(entry => entry?.file).length > 0\n ? Object.fromEntries(\n this.entry\n .filter(entry => entry?.file)\n .map(entry => [\n entry.output ||\n replaceExtension(\n replacePath(\n replacePath(\n entry.file,\n joinPaths(this.config.root, \"src\")\n ),\n this.entryPath\n )\n ),\n entry.file\n ])\n )\n : [\n joinPaths(this.config.cwd, this.config.root, \"src\", \"**/*.ts\"),\n joinPaths(this.config.cwd, this.config.root, \"src\", \"**/*.tsx\")\n ],\n platform: this.config.platform,\n tsconfig: this.tsconfig.tsconfigFilePath,\n outDir: this.config.output.path,\n ...this.config.tsdown\n });\n\n await formatPackageJson(this);\n }\n };\n};\n\nexport default plugin;\n"],"mappings":";;;;;;;;;;AA8CA,MAAa,UACX,UAA6B,EAAE,KACV;AACrB,QAAO;EACL,MAAM;EACN,SAAS;AACP,UAAO;IACL,aAAa;IACb,OAAO;KAAC;KAAgB;KAAkB;KAAmB;IAC7D,QAAQ;KACN,QAAQ,CAAC,OAAO,MAAM;KACtB,KAAK;KACN;IACD,UAAU;IACV,QAAQ;KACN,QAAQ,CAAC,OAAO,MAAM;KACtB,UAAU;KACV,QAAQ;KACR,YAAY;KACZ,WAAW;KACX,SAAS;KACT,gBAAgB;KAChB,cAAc;KACd,QAAQ;KACR,KAAK;KACL,OAAO;KACP,QAAQ;KACR,OAAO;KACP,MAAM;MACJ,aAAa;OAAC;OAAc;OAAoB;OAAiB;MACjE,uBAAuB;MACxB;KACD,UAAU;KACV,GAAG,QAAQ;KACZ;IACF;;EAEH,MAAM,QAAQ;AACZ,SAAM,MAAM;IACV,MAAM,KAAK,OAAO;IAClB,KAAK,WAAW,KAAK,OAAO,MAAM,KAAK,OAAO,IAAI;IAClD,OACE,KAAK,MAAM,QAAO,UAAS,OAAO,KAAK,CAAC,SAAS,IAC7C,OAAO,YACL,KAAK,MACF,QAAO,UAAS,OAAO,KAAK,CAC5B,KAAI,UAAS,CACZ,MAAM,UACJ,iBACE,YACE,YACE,MAAM,MACN,UAAU,KAAK,OAAO,MAAM,MAAM,CACnC,EACD,KAAK,UACN,CACF,EACH,MAAM,KACP,CAAC,CACL,GACD,CACE,UAAU,KAAK,OAAO,KAAK,KAAK,OAAO,MAAM,OAAO,UAAU,EAC9D,UAAU,KAAK,OAAO,KAAK,KAAK,OAAO,MAAM,OAAO,WAAW,CAChE;IACP,UAAU,KAAK,OAAO;IACtB,UAAU,KAAK,SAAS;IACxB,QAAQ,KAAK,OAAO,OAAO;IAC3B,GAAG,KAAK,OAAO;IAChB,CAAC;AAEF,SAAM,kBAAkB,KAAK;;EAEhC"}
|