@powerlines/core 0.12.4 → 0.12.6

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.
@@ -22,11 +22,15 @@ prettier_plugin_organize_imports = require_runtime.__toESM(prettier_plugin_organ
22
22
  async function format(context, path, data, force = false) {
23
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.workspaceConfig.workspaceRoot)) || (0, _stryke_path_is_parent_path.isParentPath)(path, (0, _stryke_path_append.appendPath)(context.config.output.path, context.workspaceConfig.workspaceRoot)))) return data;
24
24
  let code = data;
25
- const resolvedConfig = await (0, prettier.resolveConfig)(path);
26
- if (resolvedConfig) code = await (0, prettier.format)(data, (0, defu.defu)({
27
- absolutePath: path,
28
- ...resolvedConfig
29
- }, (0, _stryke_path_file_path_fns.findFileExtension)(path) === "ts" || (0, _stryke_path_file_path_fns.findFileExtension)(path) === "tsx" ? { plugins: [prettier_plugin_organize_imports.default] } : {}));
25
+ try {
26
+ const resolvedConfig = await (0, prettier.resolveConfig)(path);
27
+ if (resolvedConfig) code = await (0, prettier.format)(data, (0, defu.defu)({
28
+ absolutePath: path,
29
+ ...resolvedConfig
30
+ }, (0, _stryke_path_file_path_fns.findFileExtension)(path) === "ts" || (0, _stryke_path_file_path_fns.findFileExtension)(path) === "tsx" ? { plugins: [prettier_plugin_organize_imports.default] } : {}));
31
+ } catch (error) {
32
+ throw new Error(`Failed to format file at ${path} with Prettier: ${error.message}`, { cause: error });
33
+ }
30
34
  return code;
31
35
  }
32
36
  /**
@@ -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;;;;;AAiDH;;;iBAAsB,YAAA,CAAa,OAAA,EAAS,OAAA,EAAS,IAAA,WAAY,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;;;;;AA0DH;;;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;;;;;AAiDH;;;iBAAsB,YAAA,CAAa,OAAA,EAAS,OAAA,EAAS,IAAA,WAAY,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;;;;;AA0DH;;;iBAAsB,YAAA,CAAa,OAAA,EAAS,OAAA,EAAS,IAAA,WAAY,OAAA"}
@@ -19,11 +19,15 @@ import importsPlugin from "prettier-plugin-organize-imports";
19
19
  async function format(context, path, data, force = false) {
20
20
  if (!force && (context.config.output.copy && isParentPath(path, appendPath(context.config.output.copy.path, context.workspaceConfig.workspaceRoot)) || isParentPath(path, appendPath(context.config.output.path, context.workspaceConfig.workspaceRoot)))) return data;
21
21
  let code = data;
22
- const resolvedConfig = await resolveConfig(path);
23
- if (resolvedConfig) code = await format$1(data, defu$1({
24
- absolutePath: path,
25
- ...resolvedConfig
26
- }, findFileExtension(path) === "ts" || findFileExtension(path) === "tsx" ? { plugins: [importsPlugin] } : {}));
22
+ try {
23
+ const resolvedConfig = await resolveConfig(path);
24
+ if (resolvedConfig) code = await format$1(data, defu$1({
25
+ absolutePath: path,
26
+ ...resolvedConfig
27
+ }, findFileExtension(path) === "ts" || findFileExtension(path) === "tsx" ? { plugins: [importsPlugin] } : {}));
28
+ } catch (error) {
29
+ throw new Error(`Failed to format file at ${path} with Prettier: ${error.message}`, { cause: error });
30
+ }
27
31
  return code;
28
32
  }
29
33
  /**
@@ -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(\n context.config.output.copy.path,\n context.workspaceConfig.workspaceRoot\n )\n )) ||\n isParentPath(\n path,\n appendPath(\n context.config.output.path,\n context.workspaceConfig.workspaceRoot\n )\n ))\n ) {\n return data;\n }\n\n let code = data;\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\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(\n context.config.output.copy.path,\n context.workspaceConfig.workspaceRoot\n )\n ) &&\n !isParentPath(\n path,\n appendPath(\n context.config.output.path,\n context.workspaceConfig.workspaceRoot\n )\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(\n context.config.output.copy.path,\n context.workspaceConfig.workspaceRoot\n )\n )) &&\n !isParentPath(\n file,\n appendPath(\n context.config.output.path,\n context.workspaceConfig.workspaceRoot\n )\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,WACE,QAAQ,OAAO,OAAO,KAAK,MAC3B,QAAQ,gBAAgB,cACzB,CACF,IACD,aACE,MACA,WACE,QAAQ,OAAO,OAAO,MACtB,QAAQ,gBAAgB,cACzB,CACF,EAEH,QAAO;CAGT,IAAI,OAAO;CACX,MAAM,iBAAiB,MAAM,cAAc,KAAK;AAChD,KAAI,eACF,QAAO,MAAMA,SACX,MACAC,OACE;EACE,cAAc;EACd,GAAG;EACJ,EACD,kBAAkB,KAAK,KAAK,QAAQ,kBAAkB,KAAK,KAAK,QAC5D,EAAE,SAAS,CAAC,cAAc,EAAE,GAC5B,EAAE,CACP,CACF;AAGH,QAAO;;;;;;;;;AAUT,eAAsB,aAAa,SAAkB,MAAc;AACjE,KACE,CAAC,QAAQ,OAAO,OAAO,QACtB,CAAC,aACA,MACA,WACE,QAAQ,OAAO,OAAO,KAAK,MAC3B,QAAQ,gBAAgB,cACzB,CACF,IACC,CAAC,aACC,MACA,WACE,QAAQ,OAAO,OAAO,MACtB,QAAQ,gBAAgB,cACzB,CACF,CAEH,OAAM,QAAQ,YACX,MAAM,UAAU,KAAK,EAAE,IAAI,OAAM,SAAQ;AACxC,OACG,CAAC,QAAQ,OAAO,OAAO,QACtB,CAAC,aACC,MACA,WACE,QAAQ,OAAO,OAAO,KAAK,MAC3B,QAAQ,gBAAgB,cACzB,CACF,KACH,CAAC,aACC,MACA,WACE,QAAQ,OAAO,OAAO,MACtB,QAAQ,gBAAgB,cACzB,CACF,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"}
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(\n context.config.output.copy.path,\n context.workspaceConfig.workspaceRoot\n )\n )) ||\n isParentPath(\n path,\n appendPath(\n context.config.output.path,\n context.workspaceConfig.workspaceRoot\n )\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(\n context.config.output.copy.path,\n context.workspaceConfig.workspaceRoot\n )\n ) &&\n !isParentPath(\n path,\n appendPath(\n context.config.output.path,\n context.workspaceConfig.workspaceRoot\n )\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(\n context.config.output.copy.path,\n context.workspaceConfig.workspaceRoot\n )\n )) &&\n !isParentPath(\n file,\n appendPath(\n context.config.output.path,\n context.workspaceConfig.workspaceRoot\n )\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,WACE,QAAQ,OAAO,OAAO,KAAK,MAC3B,QAAQ,gBAAgB,cACzB,CACF,IACD,aACE,MACA,WACE,QAAQ,OAAO,OAAO,MACtB,QAAQ,gBAAgB,cACzB,CACF,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,WACE,QAAQ,OAAO,OAAO,KAAK,MAC3B,QAAQ,gBAAgB,cACzB,CACF,IACC,CAAC,aACC,MACA,WACE,QAAQ,OAAO,OAAO,MACtB,QAAQ,gBAAgB,cACzB,CACF,CAEH,OAAM,QAAQ,YACX,MAAM,UAAU,KAAK,EAAE,IAAI,OAAM,SAAQ;AACxC,OACG,CAAC,QAAQ,OAAO,OAAO,QACtB,CAAC,aACC,MACA,WACE,QAAQ,OAAO,OAAO,KAAK,MAC3B,QAAQ,gBAAgB,cACzB,CACF,KACH,CAAC,aACC,MACA,WACE,QAAQ,OAAO,OAAO,MACtB,QAAQ,gBAAgB,cACzB,CACF,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"}
@@ -34,7 +34,7 @@ let _stryke_path_join = require("@stryke/path/join");
34
34
  */
35
35
  function replacePathTokens(context, path) {
36
36
  if (!path) return path;
37
- const result = path.replaceAll("{workspaceRoot}", context.workspaceConfig.workspaceRoot).replaceAll("{root}", context.config.root).replaceAll("{projectRoot}", context.config.root).replaceAll("{sourceRoot}", (0, _stryke_path_join.joinPaths)(context.config.root, "src")).replaceAll("{powerlinesPath}", context.powerlinesPath).replaceAll("{cachePath}", context.cachePath).replaceAll("{dataPath}", context.dataPath).replaceAll("{logPath}", context.envPaths.log).replaceAll("{tempPath}", context.envPaths.temp).replaceAll("{configPath}", context.envPaths.config).replaceAll("{outputPath}", context.config.output.path).replaceAll("{output}", context.config.output.path).replaceAll("{artifactsPath}", (0, _stryke_path_replace.replacePath)(context.artifactsPath, context.workspaceConfig.workspaceRoot)).replaceAll("{builtinPath}", (0, _stryke_path_replace.replacePath)(context.builtinsPath, context.workspaceConfig.workspaceRoot)).replaceAll("{entryPath}", (0, _stryke_path_replace.replacePath)(context.entryPath, context.workspaceConfig.workspaceRoot));
37
+ const result = path.replaceAll("{workspaceRoot}", context.workspaceConfig.workspaceRoot).replaceAll("{root}", context.config.root).replaceAll("{projectRoot}", context.config.root).replaceAll("{sourceRoot}", (0, _stryke_path_join.joinPaths)(context.config.root, "src")).replaceAll("{powerlinesPath}", context.powerlinesPath).replaceAll("{cachePath}", context.cachePath).replaceAll("{dataPath}", context.dataPath).replaceAll("{logPath}", context.envPaths.log).replaceAll("{tempPath}", context.envPaths.temp).replaceAll("{configPath}", context.envPaths.config).replaceAll("{outputPath}", context.config.output.path).replaceAll("{output}", context.config.output.path).replaceAll("{artifactsPath}", (0, _stryke_path_replace.replacePath)(context.artifactsPath, context.workspaceConfig.workspaceRoot)).replaceAll("{builtinPath}", (0, _stryke_path_replace.replacePath)(context.builtinsPath, context.workspaceConfig.workspaceRoot)).replaceAll("{builtinsPath}", (0, _stryke_path_replace.replacePath)(context.builtinsPath, context.workspaceConfig.workspaceRoot)).replaceAll("{entryPath}", (0, _stryke_path_replace.replacePath)(context.entryPath, context.workspaceConfig.workspaceRoot));
38
38
  return context.config.output.copy && (0, _stryke_type_checks_is_set_string.isSetString)(context.config.output.copy.path) ? result.replaceAll("{copyPath}", context.config.output.copy.path).replaceAll("{copy}", context.config.output.copy.path) : result;
39
39
  }
40
40
 
@@ -32,7 +32,7 @@ import { joinPaths } from "@stryke/path/join";
32
32
  */
33
33
  function replacePathTokens(context, path) {
34
34
  if (!path) return path;
35
- const result = path.replaceAll("{workspaceRoot}", context.workspaceConfig.workspaceRoot).replaceAll("{root}", context.config.root).replaceAll("{projectRoot}", context.config.root).replaceAll("{sourceRoot}", joinPaths(context.config.root, "src")).replaceAll("{powerlinesPath}", context.powerlinesPath).replaceAll("{cachePath}", context.cachePath).replaceAll("{dataPath}", context.dataPath).replaceAll("{logPath}", context.envPaths.log).replaceAll("{tempPath}", context.envPaths.temp).replaceAll("{configPath}", context.envPaths.config).replaceAll("{outputPath}", context.config.output.path).replaceAll("{output}", context.config.output.path).replaceAll("{artifactsPath}", replacePath(context.artifactsPath, context.workspaceConfig.workspaceRoot)).replaceAll("{builtinPath}", replacePath(context.builtinsPath, context.workspaceConfig.workspaceRoot)).replaceAll("{entryPath}", replacePath(context.entryPath, context.workspaceConfig.workspaceRoot));
35
+ const result = path.replaceAll("{workspaceRoot}", context.workspaceConfig.workspaceRoot).replaceAll("{root}", context.config.root).replaceAll("{projectRoot}", context.config.root).replaceAll("{sourceRoot}", joinPaths(context.config.root, "src")).replaceAll("{powerlinesPath}", context.powerlinesPath).replaceAll("{cachePath}", context.cachePath).replaceAll("{dataPath}", context.dataPath).replaceAll("{logPath}", context.envPaths.log).replaceAll("{tempPath}", context.envPaths.temp).replaceAll("{configPath}", context.envPaths.config).replaceAll("{outputPath}", context.config.output.path).replaceAll("{output}", context.config.output.path).replaceAll("{artifactsPath}", replacePath(context.artifactsPath, context.workspaceConfig.workspaceRoot)).replaceAll("{builtinPath}", replacePath(context.builtinsPath, context.workspaceConfig.workspaceRoot)).replaceAll("{builtinsPath}", replacePath(context.builtinsPath, context.workspaceConfig.workspaceRoot)).replaceAll("{entryPath}", replacePath(context.entryPath, context.workspaceConfig.workspaceRoot));
36
36
  return context.config.output.copy && isSetString(context.config.output.copy.path) ? result.replaceAll("{copyPath}", context.config.output.copy.path).replaceAll("{copy}", context.config.output.copy.path) : result;
37
37
  }
38
38
 
@@ -1 +1 @@
1
- {"version":3,"file":"paths.mjs","names":[],"sources":["../../src/plugin-utils/paths.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 { joinPaths } from \"@stryke/path/join\";\nimport { replacePath } from \"@stryke/path/replace\";\nimport { isSetString } from \"@stryke/type-checks/is-set-string\";\nimport { IsUndefined } from \"@stryke/types/base\";\nimport { UnresolvedContext } from \"../types/context\";\n\n/**\n * Replaces tokens in the given path string with their corresponding values from the context.\n *\n * @remarks\n * The following tokens are supported:\n * - `{workspaceRoot}` - The root directory of the workspace.\n * - `{root}` - The root directory of the project (same as `{projectRoot}`).\n * - `{projectRoot}` - The root directory of the project (same as `{root}`).\n * - `{sourceRoot}` - The source root directory of the project (usually `./src`).\n * - `{powerlinesPath}` - The directory where Powerlines is installed.\n * - `{cachePath}` - The environment's directory for cached files.\n * - `{dataPath}` - The environment's directory for data files.\n * - `{logPath}` - The environment's directory for log files.\n * - `{tempPath}` - The environment's directory for temporary files.\n * - `{configPath}` - The environment's directory for configuration files.\n * - `{output}` - The configured output directory for the project.\n * - `{outputPath}` - The configured output directory for the project.\n * - `{copy}` - The configured final/copied distribution directory for the project.\n * - `{copyPath}` - The configured final/copied distribution directory for the project.\n * - `{artifactsPath}` - The configured directory for build artifacts.\n * - `{builtinPath}` - The configured directory for generated built-in plugins.\n * - `{entryPath}` - The configured directory for generated entry files.\n *\n * @param context - The context containing the values for the path tokens.\n * @param path - The path string with tokens to replace.\n * @returns The path string with tokens replaced by their corresponding values from the context.\n */\nexport function replacePathTokens(\n context: UnresolvedContext,\n path?: string\n): IsUndefined<typeof path> extends true ? undefined : string {\n if (!path) {\n return path as IsUndefined<typeof path> extends true ? undefined : string;\n }\n\n const result = path\n .replaceAll(\"{workspaceRoot}\", context.workspaceConfig.workspaceRoot)\n .replaceAll(\"{root}\", context.config.root)\n .replaceAll(\"{projectRoot}\", context.config.root)\n .replaceAll(\"{sourceRoot}\", joinPaths(context.config.root, \"src\"))\n .replaceAll(\"{powerlinesPath}\", context.powerlinesPath)\n .replaceAll(\"{cachePath}\", context.cachePath)\n .replaceAll(\"{dataPath}\", context.dataPath)\n .replaceAll(\"{logPath}\", context.envPaths.log)\n .replaceAll(\"{tempPath}\", context.envPaths.temp)\n .replaceAll(\"{configPath}\", context.envPaths.config)\n .replaceAll(\"{outputPath}\", context.config.output.path)\n .replaceAll(\"{output}\", context.config.output.path)\n\n .replaceAll(\n \"{artifactsPath}\",\n replacePath(context.artifactsPath, context.workspaceConfig.workspaceRoot)\n )\n .replaceAll(\n \"{builtinPath}\",\n replacePath(context.builtinsPath, context.workspaceConfig.workspaceRoot)\n )\n .replaceAll(\n \"{entryPath}\",\n replacePath(context.entryPath, context.workspaceConfig.workspaceRoot)\n );\n\n return context.config.output.copy &&\n isSetString(context.config.output.copy.path)\n ? result\n .replaceAll(\"{copyPath}\", context.config.output.copy.path)\n .replaceAll(\"{copy}\", context.config.output.copy.path)\n : result;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmDA,SAAgB,kBACd,SACA,MAC4D;AAC5D,KAAI,CAAC,KACH,QAAO;CAGT,MAAM,SAAS,KACZ,WAAW,mBAAmB,QAAQ,gBAAgB,cAAc,CACpE,WAAW,UAAU,QAAQ,OAAO,KAAK,CACzC,WAAW,iBAAiB,QAAQ,OAAO,KAAK,CAChD,WAAW,gBAAgB,UAAU,QAAQ,OAAO,MAAM,MAAM,CAAC,CACjE,WAAW,oBAAoB,QAAQ,eAAe,CACtD,WAAW,eAAe,QAAQ,UAAU,CAC5C,WAAW,cAAc,QAAQ,SAAS,CAC1C,WAAW,aAAa,QAAQ,SAAS,IAAI,CAC7C,WAAW,cAAc,QAAQ,SAAS,KAAK,CAC/C,WAAW,gBAAgB,QAAQ,SAAS,OAAO,CACnD,WAAW,gBAAgB,QAAQ,OAAO,OAAO,KAAK,CACtD,WAAW,YAAY,QAAQ,OAAO,OAAO,KAAK,CAElD,WACC,mBACA,YAAY,QAAQ,eAAe,QAAQ,gBAAgB,cAAc,CAC1E,CACA,WACC,iBACA,YAAY,QAAQ,cAAc,QAAQ,gBAAgB,cAAc,CACzE,CACA,WACC,eACA,YAAY,QAAQ,WAAW,QAAQ,gBAAgB,cAAc,CACtE;AAEH,QAAO,QAAQ,OAAO,OAAO,QAC3B,YAAY,QAAQ,OAAO,OAAO,KAAK,KAAK,GAC1C,OACG,WAAW,cAAc,QAAQ,OAAO,OAAO,KAAK,KAAK,CACzD,WAAW,UAAU,QAAQ,OAAO,OAAO,KAAK,KAAK,GACxD"}
1
+ {"version":3,"file":"paths.mjs","names":[],"sources":["../../src/plugin-utils/paths.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 { joinPaths } from \"@stryke/path/join\";\nimport { replacePath } from \"@stryke/path/replace\";\nimport { isSetString } from \"@stryke/type-checks/is-set-string\";\nimport { IsUndefined } from \"@stryke/types/base\";\nimport { UnresolvedContext } from \"../types/context\";\n\n/**\n * Replaces tokens in the given path string with their corresponding values from the context.\n *\n * @remarks\n * The following tokens are supported:\n * - `{workspaceRoot}` - The root directory of the workspace.\n * - `{root}` - The root directory of the project (same as `{projectRoot}`).\n * - `{projectRoot}` - The root directory of the project (same as `{root}`).\n * - `{sourceRoot}` - The source root directory of the project (usually `./src`).\n * - `{powerlinesPath}` - The directory where Powerlines is installed.\n * - `{cachePath}` - The environment's directory for cached files.\n * - `{dataPath}` - The environment's directory for data files.\n * - `{logPath}` - The environment's directory for log files.\n * - `{tempPath}` - The environment's directory for temporary files.\n * - `{configPath}` - The environment's directory for configuration files.\n * - `{output}` - The configured output directory for the project.\n * - `{outputPath}` - The configured output directory for the project.\n * - `{copy}` - The configured final/copied distribution directory for the project.\n * - `{copyPath}` - The configured final/copied distribution directory for the project.\n * - `{artifactsPath}` - The configured directory for build artifacts.\n * - `{builtinPath}` - The configured directory for generated built-in plugins.\n * - `{entryPath}` - The configured directory for generated entry files.\n *\n * @param context - The context containing the values for the path tokens.\n * @param path - The path string with tokens to replace.\n * @returns The path string with tokens replaced by their corresponding values from the context.\n */\nexport function replacePathTokens(\n context: UnresolvedContext,\n path?: string\n): IsUndefined<typeof path> extends true ? undefined : string {\n if (!path) {\n return path as IsUndefined<typeof path> extends true ? undefined : string;\n }\n\n const result = path\n .replaceAll(\"{workspaceRoot}\", context.workspaceConfig.workspaceRoot)\n .replaceAll(\"{root}\", context.config.root)\n .replaceAll(\"{projectRoot}\", context.config.root)\n .replaceAll(\"{sourceRoot}\", joinPaths(context.config.root, \"src\"))\n .replaceAll(\"{powerlinesPath}\", context.powerlinesPath)\n .replaceAll(\"{cachePath}\", context.cachePath)\n .replaceAll(\"{dataPath}\", context.dataPath)\n .replaceAll(\"{logPath}\", context.envPaths.log)\n .replaceAll(\"{tempPath}\", context.envPaths.temp)\n .replaceAll(\"{configPath}\", context.envPaths.config)\n .replaceAll(\"{outputPath}\", context.config.output.path)\n .replaceAll(\"{output}\", context.config.output.path)\n\n .replaceAll(\n \"{artifactsPath}\",\n replacePath(context.artifactsPath, context.workspaceConfig.workspaceRoot)\n )\n .replaceAll(\n \"{builtinPath}\",\n replacePath(context.builtinsPath, context.workspaceConfig.workspaceRoot)\n )\n .replaceAll(\n \"{builtinsPath}\",\n replacePath(context.builtinsPath, context.workspaceConfig.workspaceRoot)\n )\n .replaceAll(\n \"{entryPath}\",\n replacePath(context.entryPath, context.workspaceConfig.workspaceRoot)\n );\n\n return context.config.output.copy &&\n isSetString(context.config.output.copy.path)\n ? result\n .replaceAll(\"{copyPath}\", context.config.output.copy.path)\n .replaceAll(\"{copy}\", context.config.output.copy.path)\n : result;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmDA,SAAgB,kBACd,SACA,MAC4D;AAC5D,KAAI,CAAC,KACH,QAAO;CAGT,MAAM,SAAS,KACZ,WAAW,mBAAmB,QAAQ,gBAAgB,cAAc,CACpE,WAAW,UAAU,QAAQ,OAAO,KAAK,CACzC,WAAW,iBAAiB,QAAQ,OAAO,KAAK,CAChD,WAAW,gBAAgB,UAAU,QAAQ,OAAO,MAAM,MAAM,CAAC,CACjE,WAAW,oBAAoB,QAAQ,eAAe,CACtD,WAAW,eAAe,QAAQ,UAAU,CAC5C,WAAW,cAAc,QAAQ,SAAS,CAC1C,WAAW,aAAa,QAAQ,SAAS,IAAI,CAC7C,WAAW,cAAc,QAAQ,SAAS,KAAK,CAC/C,WAAW,gBAAgB,QAAQ,SAAS,OAAO,CACnD,WAAW,gBAAgB,QAAQ,OAAO,OAAO,KAAK,CACtD,WAAW,YAAY,QAAQ,OAAO,OAAO,KAAK,CAElD,WACC,mBACA,YAAY,QAAQ,eAAe,QAAQ,gBAAgB,cAAc,CAC1E,CACA,WACC,iBACA,YAAY,QAAQ,cAAc,QAAQ,gBAAgB,cAAc,CACzE,CACA,WACC,kBACA,YAAY,QAAQ,cAAc,QAAQ,gBAAgB,cAAc,CACzE,CACA,WACC,eACA,YAAY,QAAQ,WAAW,QAAQ,gBAAgB,cAAc,CACtE;AAEH,QAAO,QAAQ,OAAO,OAAO,QAC3B,YAAY,QAAQ,OAAO,OAAO,KAAK,KAAK,GAC1C,OACG,WAAW,cAAc,QAAQ,OAAO,OAAO,KAAK,KAAK,CACzD,WAAW,UAAU,QAAQ,OAAO,OAAO,KAAK,KAAK,GACxD"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@powerlines/core",
3
- "version": "0.12.4",
3
+ "version": "0.12.6",
4
4
  "private": false,
5
5
  "description": "An internal core package for Powerlines - please use the `powerlines` package for public usage.",
6
6
  "homepage": "https://stormsoftware.com",
@@ -493,8 +493,8 @@
493
493
  "types": "./dist/index.d.cts",
494
494
  "files": ["dist/**/*", "files/**/*", "schemas/**/*"],
495
495
  "dependencies": {
496
- "@storm-software/config": "^1.137.14",
497
- "@storm-software/config-tools": "^1.189.60",
496
+ "@storm-software/config": "^1.137.26",
497
+ "@storm-software/config-tools": "^1.189.72",
498
498
  "@stryke/convert": "^0.6.57",
499
499
  "@stryke/env": "^0.20.81",
500
500
  "@stryke/fs": "^0.33.64",
@@ -505,10 +505,10 @@
505
505
  "@stryke/string-format": "^0.17.7",
506
506
  "@stryke/type-checks": "^0.6.0",
507
507
  "@stryke/unique-id": "^0.3.75",
508
- "c12": "^3.3.3",
508
+ "c12": "^3.3.4",
509
509
  "chalk": "5.6.2",
510
510
  "compatx": "^0.2.0",
511
- "defu": "^6.1.4",
511
+ "defu": "^6.1.6",
512
512
  "diff-match-patch": "^1.0.5",
513
513
  "jiti": "^2.6.1",
514
514
  "magic-string": "^0.30.21",
@@ -517,15 +517,15 @@
517
517
  "unplugin-combine": "^2.3.0"
518
518
  },
519
519
  "devDependencies": {
520
- "@storm-software/testing-tools": "^1.119.135",
520
+ "@storm-software/testing-tools": "^1.119.147",
521
521
  "@stryke/types": "^0.11.2",
522
522
  "@types/diff-match-patch": "^1.0.36",
523
523
  "@types/node": "^25.5.0",
524
524
  "@types/semver": "^7.7.1",
525
525
  "prettier-plugin-organize-imports": "^4.3.0",
526
- "tsdown": "^0.21.6",
526
+ "tsdown": "^0.21.7",
527
527
  "typescript": "^5.9.3"
528
528
  },
529
529
  "publishConfig": { "access": "public" },
530
- "gitHead": "fdfc30e0bc726abf8e14067cbd334da51070d5a6"
530
+ "gitHead": "36659bb9272f4247dca475613e45451f0adedcfa"
531
531
  }