@powerlines/plugin-webpack 0.5.241 → 0.5.243

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.
Files changed (114) hide show
  1. package/dist/helpers/unplugin.cjs +2 -3
  2. package/dist/helpers/unplugin.mjs +1 -2
  3. package/dist/index.cjs +2 -2
  4. package/dist/index.d.cts +3 -2
  5. package/dist/index.d.mts +1 -1
  6. package/dist/index.mjs +3 -3
  7. package/dist/types/plugin.d.cts +3 -3
  8. package/dist/types/plugin.d.mts +3 -3
  9. package/package.json +96 -15
  10. package/dist/powerlines/package.cjs +0 -11
  11. package/dist/powerlines/package.mjs +0 -5
  12. package/dist/powerlines/schemas/fs.cjs +0 -226
  13. package/dist/powerlines/schemas/fs.mjs +0 -224
  14. package/dist/powerlines/src/api.cjs +0 -568
  15. package/dist/powerlines/src/api.mjs +0 -566
  16. package/dist/powerlines/src/internal/helpers/environment.cjs +0 -50
  17. package/dist/powerlines/src/internal/helpers/environment.mjs +0 -47
  18. package/dist/powerlines/src/internal/helpers/generate-types.cjs +0 -78
  19. package/dist/powerlines/src/internal/helpers/generate-types.mjs +0 -76
  20. package/dist/powerlines/src/internal/helpers/hooks.cjs +0 -65
  21. package/dist/powerlines/src/internal/helpers/hooks.d.cts +0 -47
  22. package/dist/powerlines/src/internal/helpers/hooks.d.mts +0 -49
  23. package/dist/powerlines/src/internal/helpers/hooks.mjs +0 -63
  24. package/dist/powerlines/src/internal/helpers/install-dependencies.cjs +0 -24
  25. package/dist/powerlines/src/internal/helpers/install-dependencies.mjs +0 -23
  26. package/dist/powerlines/src/internal/helpers/install.cjs +0 -36
  27. package/dist/powerlines/src/internal/helpers/install.mjs +0 -35
  28. package/dist/powerlines/src/internal/helpers/resolve-tsconfig.cjs +0 -97
  29. package/dist/powerlines/src/internal/helpers/resolve-tsconfig.mjs +0 -93
  30. package/dist/powerlines/src/internal/helpers/resolver.cjs +0 -43
  31. package/dist/powerlines/src/internal/helpers/resolver.mjs +0 -41
  32. package/dist/powerlines/src/lib/build/webpack.cjs +0 -38
  33. package/dist/powerlines/src/lib/build/webpack.mjs +0 -36
  34. package/dist/powerlines/src/lib/config-file.cjs +0 -79
  35. package/dist/powerlines/src/lib/config-file.mjs +0 -76
  36. package/dist/powerlines/src/lib/constants/environments.cjs +0 -8
  37. package/dist/powerlines/src/lib/constants/environments.mjs +0 -6
  38. package/dist/powerlines/src/lib/contexts/api-context.cjs +0 -184
  39. package/dist/powerlines/src/lib/contexts/api-context.mjs +0 -182
  40. package/dist/powerlines/src/lib/contexts/context.cjs +0 -951
  41. package/dist/powerlines/src/lib/contexts/context.mjs +0 -949
  42. package/dist/powerlines/src/lib/contexts/environment-context.cjs +0 -195
  43. package/dist/powerlines/src/lib/contexts/environment-context.mjs +0 -194
  44. package/dist/powerlines/src/lib/contexts/plugin-context.cjs +0 -78
  45. package/dist/powerlines/src/lib/contexts/plugin-context.mjs +0 -77
  46. package/dist/powerlines/src/lib/entry.cjs +0 -85
  47. package/dist/powerlines/src/lib/entry.mjs +0 -83
  48. package/dist/powerlines/src/lib/fs/helpers.cjs +0 -85
  49. package/dist/powerlines/src/lib/fs/helpers.mjs +0 -81
  50. package/dist/powerlines/src/lib/fs/storage/base.cjs +0 -196
  51. package/dist/powerlines/src/lib/fs/storage/base.mjs +0 -195
  52. package/dist/powerlines/src/lib/fs/storage/file-system.cjs +0 -170
  53. package/dist/powerlines/src/lib/fs/storage/file-system.mjs +0 -169
  54. package/dist/powerlines/src/lib/fs/storage/virtual.cjs +0 -88
  55. package/dist/powerlines/src/lib/fs/storage/virtual.mjs +0 -87
  56. package/dist/powerlines/src/lib/fs/vfs.cjs +0 -912
  57. package/dist/powerlines/src/lib/fs/vfs.mjs +0 -910
  58. package/dist/powerlines/src/lib/logger.cjs +0 -58
  59. package/dist/powerlines/src/lib/logger.mjs +0 -55
  60. package/dist/powerlines/src/lib/typescript/ts-morph.cjs +0 -103
  61. package/dist/powerlines/src/lib/typescript/ts-morph.mjs +0 -101
  62. package/dist/powerlines/src/lib/typescript/tsconfig.cjs +0 -149
  63. package/dist/powerlines/src/lib/typescript/tsconfig.mjs +0 -144
  64. package/dist/powerlines/src/lib/unplugin/factory.cjs +0 -6
  65. package/dist/powerlines/src/lib/unplugin/factory.mjs +0 -8
  66. package/dist/powerlines/src/lib/unplugin/helpers.cjs +0 -29
  67. package/dist/powerlines/src/lib/unplugin/helpers.mjs +0 -27
  68. package/dist/powerlines/src/lib/unplugin/index.cjs +0 -4
  69. package/dist/powerlines/src/lib/unplugin/index.mjs +0 -6
  70. package/dist/powerlines/src/lib/unplugin/module-resolution.cjs +0 -66
  71. package/dist/powerlines/src/lib/unplugin/module-resolution.mjs +0 -65
  72. package/dist/powerlines/src/lib/unplugin/plugin.cjs +0 -71
  73. package/dist/powerlines/src/lib/unplugin/plugin.mjs +0 -70
  74. package/dist/powerlines/src/lib/utilities/file-header.cjs +0 -22
  75. package/dist/powerlines/src/lib/utilities/file-header.mjs +0 -21
  76. package/dist/powerlines/src/lib/utilities/format.cjs +0 -48
  77. package/dist/powerlines/src/lib/utilities/format.mjs +0 -46
  78. package/dist/powerlines/src/lib/utilities/meta.cjs +0 -44
  79. package/dist/powerlines/src/lib/utilities/meta.mjs +0 -40
  80. package/dist/powerlines/src/lib/utilities/source-file.cjs +0 -22
  81. package/dist/powerlines/src/lib/utilities/source-file.mjs +0 -21
  82. package/dist/powerlines/src/plugin-utils/helpers.cjs +0 -167
  83. package/dist/powerlines/src/plugin-utils/helpers.mjs +0 -156
  84. package/dist/powerlines/src/plugin-utils/paths.cjs +0 -36
  85. package/dist/powerlines/src/plugin-utils/paths.mjs +0 -35
  86. package/dist/powerlines/src/types/api.d.cts +0 -104
  87. package/dist/powerlines/src/types/api.d.mts +0 -104
  88. package/dist/powerlines/src/types/babel.d.mts +0 -2
  89. package/dist/powerlines/src/types/build.cjs +0 -23
  90. package/dist/powerlines/src/types/build.d.cts +0 -185
  91. package/dist/powerlines/src/types/build.d.mts +0 -185
  92. package/dist/powerlines/src/types/build.mjs +0 -21
  93. package/dist/powerlines/src/types/commands.cjs +0 -16
  94. package/dist/powerlines/src/types/commands.d.cts +0 -8
  95. package/dist/powerlines/src/types/commands.d.mts +0 -9
  96. package/dist/powerlines/src/types/commands.mjs +0 -15
  97. package/dist/powerlines/src/types/config.d.cts +0 -424
  98. package/dist/powerlines/src/types/config.d.mts +0 -425
  99. package/dist/powerlines/src/types/context.d.cts +0 -514
  100. package/dist/powerlines/src/types/context.d.mts +0 -514
  101. package/dist/powerlines/src/types/fs.d.cts +0 -486
  102. package/dist/powerlines/src/types/fs.d.mts +0 -486
  103. package/dist/powerlines/src/types/hooks.d.cts +0 -32
  104. package/dist/powerlines/src/types/hooks.d.mts +0 -32
  105. package/dist/powerlines/src/types/plugin.cjs +0 -33
  106. package/dist/powerlines/src/types/plugin.d.cts +0 -205
  107. package/dist/powerlines/src/types/plugin.d.mts +0 -205
  108. package/dist/powerlines/src/types/plugin.mjs +0 -32
  109. package/dist/powerlines/src/types/resolved.d.cts +0 -93
  110. package/dist/powerlines/src/types/resolved.d.mts +0 -93
  111. package/dist/powerlines/src/types/tsconfig.d.cts +0 -69
  112. package/dist/powerlines/src/types/tsconfig.d.mts +0 -69
  113. package/dist/powerlines/src/types/unplugin.d.cts +0 -22
  114. package/dist/powerlines/src/types/unplugin.d.mts +0 -23
@@ -1,27 +0,0 @@
1
- import { UNPLUGIN_BUILDER_VARIANTS } from "../../types/build.mjs";
2
- import { defu } from "defu";
3
- import { isSetString } from "@stryke/type-checks/is-set-string";
4
-
5
- //#region ../powerlines/src/lib/unplugin/helpers.ts
6
- /**
7
- * Merges a base plugin context with an unplugin context, combining their properties.
8
- *
9
- * @param context - The base plugin context to merge into.
10
- * @param unplugin - The unplugin context to merge from.
11
- * @returns The merged context.
12
- */
13
- function combineContexts(context, unplugin) {
14
- return defu(context, unplugin);
15
- }
16
- /**
17
- * Checks if a value is a valid UnpluginBuilderVariant.
18
- *
19
- * @param str - The value to check.
20
- * @returns True if the value is a UnpluginBuilderVariant, false otherwise.
21
- */
22
- function isUnpluginBuilderVariant(str) {
23
- return isSetString(str) && UNPLUGIN_BUILDER_VARIANTS.includes(str);
24
- }
25
-
26
- //#endregion
27
- export { combineContexts, isUnpluginBuilderVariant };
@@ -1,4 +0,0 @@
1
- const require_helpers = require('./helpers.cjs');
2
- require('./factory.cjs');
3
- const require_module_resolution = require('./module-resolution.cjs');
4
- const require_plugin = require('./plugin.cjs');
@@ -1,6 +0,0 @@
1
- import { combineContexts, isUnpluginBuilderVariant } from "./helpers.mjs";
2
- import "./factory.mjs";
3
- import { createUnpluginModuleResolutionFunctions } from "./module-resolution.mjs";
4
- import { createUnplugin } from "./plugin.mjs";
5
-
6
- export { };
@@ -1,66 +0,0 @@
1
-
2
- //#region ../powerlines/src/lib/unplugin/module-resolution.ts
3
- /**
4
- * Creates the module resolution hook functions for a Powerlines unplugin plugin instance.
5
- *
6
- * @remarks
7
- * This includes the `resolveId` and `load` hooks.
8
- *
9
- * @see https://rollupjs.org/plugin-development/#resolveid
10
- * @see https://rollupjs.org/plugin-development/#load
11
- *
12
- * @param context - The plugin context.
13
- * @returns The module resolution hooks (`resolveId` and `load`).
14
- */
15
- function createUnpluginModuleResolutionFunctions(context) {
16
- const ctx = context;
17
- async function resolveId(id, importer, opts = { isEntry: false }) {
18
- let result = await ctx.$$internal.callHook("resolveId", {
19
- sequential: true,
20
- result: "first",
21
- order: "pre"
22
- }, id, importer, opts);
23
- if (result) return result;
24
- result = await ctx.$$internal.callHook("resolveId", {
25
- sequential: true,
26
- result: "first",
27
- order: "normal"
28
- }, id, importer, opts);
29
- if (result) return result;
30
- result = await ctx.resolve(id, importer, opts);
31
- if (result) return result;
32
- return ctx.$$internal.callHook("resolveId", {
33
- sequential: true,
34
- result: "first",
35
- order: "post"
36
- }, id, importer, opts);
37
- }
38
- async function load(id) {
39
- let result = await ctx.$$internal.callHook("load", {
40
- sequential: true,
41
- result: "first",
42
- order: "pre"
43
- }, id);
44
- if (result) return result;
45
- result = await ctx.$$internal.callHook("load", {
46
- sequential: true,
47
- result: "first",
48
- order: "normal"
49
- }, id);
50
- if (result) return result;
51
- result = await ctx.load(id);
52
- if (result) return result;
53
- return ctx.$$internal.callHook("load", {
54
- sequential: true,
55
- result: "first",
56
- order: "post"
57
- }, id);
58
- }
59
- return {
60
- resolveId,
61
- load
62
- };
63
- }
64
-
65
- //#endregion
66
- exports.createUnpluginModuleResolutionFunctions = createUnpluginModuleResolutionFunctions;
@@ -1,65 +0,0 @@
1
- //#region ../powerlines/src/lib/unplugin/module-resolution.ts
2
- /**
3
- * Creates the module resolution hook functions for a Powerlines unplugin plugin instance.
4
- *
5
- * @remarks
6
- * This includes the `resolveId` and `load` hooks.
7
- *
8
- * @see https://rollupjs.org/plugin-development/#resolveid
9
- * @see https://rollupjs.org/plugin-development/#load
10
- *
11
- * @param context - The plugin context.
12
- * @returns The module resolution hooks (`resolveId` and `load`).
13
- */
14
- function createUnpluginModuleResolutionFunctions(context) {
15
- const ctx = context;
16
- async function resolveId(id, importer, opts = { isEntry: false }) {
17
- let result = await ctx.$$internal.callHook("resolveId", {
18
- sequential: true,
19
- result: "first",
20
- order: "pre"
21
- }, id, importer, opts);
22
- if (result) return result;
23
- result = await ctx.$$internal.callHook("resolveId", {
24
- sequential: true,
25
- result: "first",
26
- order: "normal"
27
- }, id, importer, opts);
28
- if (result) return result;
29
- result = await ctx.resolve(id, importer, opts);
30
- if (result) return result;
31
- return ctx.$$internal.callHook("resolveId", {
32
- sequential: true,
33
- result: "first",
34
- order: "post"
35
- }, id, importer, opts);
36
- }
37
- async function load(id) {
38
- let result = await ctx.$$internal.callHook("load", {
39
- sequential: true,
40
- result: "first",
41
- order: "pre"
42
- }, id);
43
- if (result) return result;
44
- result = await ctx.$$internal.callHook("load", {
45
- sequential: true,
46
- result: "first",
47
- order: "normal"
48
- }, id);
49
- if (result) return result;
50
- result = await ctx.load(id);
51
- if (result) return result;
52
- return ctx.$$internal.callHook("load", {
53
- sequential: true,
54
- result: "first",
55
- order: "post"
56
- }, id);
57
- }
58
- return {
59
- resolveId,
60
- load
61
- };
62
- }
63
-
64
- //#endregion
65
- export { createUnpluginModuleResolutionFunctions };
@@ -1,71 +0,0 @@
1
- const require_rolldown_runtime = require('../../../../_virtual/rolldown_runtime.cjs');
2
- const require_logger = require('../logger.cjs');
3
- const require_helpers = require('./helpers.cjs');
4
- const require_source_file = require('../utilities/source-file.cjs');
5
- const require_module_resolution = require('./module-resolution.cjs');
6
- let __storm_software_config_tools_types = require("@storm-software/config-tools/types");
7
- let unplugin = require("unplugin");
8
- let __stryke_string_format_title_case = require("@stryke/string-format/title-case");
9
- let __stryke_string_format_kebab_case = require("@stryke/string-format/kebab-case");
10
-
11
- //#region ../powerlines/src/lib/unplugin/plugin.ts
12
- /**
13
- * Creates a Powerlines unplugin instance.
14
- *
15
- * @param context - The plugin context.
16
- * @returns The unplugin instance.
17
- */
18
- function createUnplugin(context, name = "unplugin") {
19
- const ctx = context;
20
- (0, unplugin.setParseImpl)(ctx.parse);
21
- return () => {
22
- const log = require_logger.extendLog(ctx.log, name);
23
- log(__storm_software_config_tools_types.LogLevelLabel.DEBUG, `Initializing ${name.toLowerCase() === "unplugin" ? "Unplugin" : `${(0, __stryke_string_format_title_case.titleCase)(name)} - Unplugin`} plugin`);
24
- try {
25
- const { resolveId, load } = require_module_resolution.createUnpluginModuleResolutionFunctions(context);
26
- async function buildStart() {
27
- log(__storm_software_config_tools_types.LogLevelLabel.DEBUG, "Powerlines build plugin starting...");
28
- await ctx.$$internal.callHook("buildStart", { sequential: true });
29
- }
30
- async function transform(code, id) {
31
- let transformed = code;
32
- for (const hook of ctx.$$internal.environment.selectHooks("transform")) {
33
- const result = await hook.handler.apply(require_helpers.combineContexts(ctx, this), [require_source_file.getString(transformed), id]);
34
- if (result) transformed = result;
35
- }
36
- return transformed;
37
- }
38
- async function buildEnd() {
39
- log(__storm_software_config_tools_types.LogLevelLabel.DEBUG, "Powerlines build plugin finishing...");
40
- return ctx.$$internal.callHook("buildEnd", { sequential: true });
41
- }
42
- async function writeBundle() {
43
- log(__storm_software_config_tools_types.LogLevelLabel.DEBUG, "Finalizing Powerlines project output...");
44
- return ctx.$$internal.callHook("writeBundle", { sequential: true });
45
- }
46
- return {
47
- name: name.toLowerCase() === "unplugin" ? "powerlines" : `powerlines:${(0, __stryke_string_format_kebab_case.kebabCase)(name)}`,
48
- api: ctx.$$internal.api,
49
- resolveId: {
50
- filter: { id: { include: [/.*/] } },
51
- handler: resolveId
52
- },
53
- load: {
54
- filter: { id: { include: [/.*/] } },
55
- handler: load
56
- },
57
- transform,
58
- buildStart,
59
- buildEnd,
60
- writeBundle,
61
- vite: { sharedDuringBuild: true }
62
- };
63
- } catch (error) {
64
- log(__storm_software_config_tools_types.LogLevelLabel.FATAL, error?.message);
65
- throw error;
66
- }
67
- };
68
- }
69
-
70
- //#endregion
71
- exports.createUnplugin = createUnplugin;
@@ -1,70 +0,0 @@
1
- import { extendLog } from "../logger.mjs";
2
- import { combineContexts } from "./helpers.mjs";
3
- import { getString } from "../utilities/source-file.mjs";
4
- import { createUnpluginModuleResolutionFunctions } from "./module-resolution.mjs";
5
- import { LogLevelLabel } from "@storm-software/config-tools/types";
6
- import { setParseImpl } from "unplugin";
7
- import { titleCase } from "@stryke/string-format/title-case";
8
- import { kebabCase } from "@stryke/string-format/kebab-case";
9
-
10
- //#region ../powerlines/src/lib/unplugin/plugin.ts
11
- /**
12
- * Creates a Powerlines unplugin instance.
13
- *
14
- * @param context - The plugin context.
15
- * @returns The unplugin instance.
16
- */
17
- function createUnplugin(context, name = "unplugin") {
18
- const ctx = context;
19
- setParseImpl(ctx.parse);
20
- return () => {
21
- const log = extendLog(ctx.log, name);
22
- log(LogLevelLabel.DEBUG, `Initializing ${name.toLowerCase() === "unplugin" ? "Unplugin" : `${titleCase(name)} - Unplugin`} plugin`);
23
- try {
24
- const { resolveId, load } = createUnpluginModuleResolutionFunctions(context);
25
- async function buildStart() {
26
- log(LogLevelLabel.DEBUG, "Powerlines build plugin starting...");
27
- await ctx.$$internal.callHook("buildStart", { sequential: true });
28
- }
29
- async function transform(code, id) {
30
- let transformed = code;
31
- for (const hook of ctx.$$internal.environment.selectHooks("transform")) {
32
- const result = await hook.handler.apply(combineContexts(ctx, this), [getString(transformed), id]);
33
- if (result) transformed = result;
34
- }
35
- return transformed;
36
- }
37
- async function buildEnd() {
38
- log(LogLevelLabel.DEBUG, "Powerlines build plugin finishing...");
39
- return ctx.$$internal.callHook("buildEnd", { sequential: true });
40
- }
41
- async function writeBundle() {
42
- log(LogLevelLabel.DEBUG, "Finalizing Powerlines project output...");
43
- return ctx.$$internal.callHook("writeBundle", { sequential: true });
44
- }
45
- return {
46
- name: name.toLowerCase() === "unplugin" ? "powerlines" : `powerlines:${kebabCase(name)}`,
47
- api: ctx.$$internal.api,
48
- resolveId: {
49
- filter: { id: { include: [/.*/] } },
50
- handler: resolveId
51
- },
52
- load: {
53
- filter: { id: { include: [/.*/] } },
54
- handler: load
55
- },
56
- transform,
57
- buildStart,
58
- buildEnd,
59
- writeBundle,
60
- vite: { sharedDuringBuild: true }
61
- };
62
- } catch (error) {
63
- log(LogLevelLabel.FATAL, error?.message);
64
- throw error;
65
- }
66
- };
67
- }
68
-
69
- //#endregion
70
- export { createUnplugin };
@@ -1,22 +0,0 @@
1
- const require_rolldown_runtime = require('../../../../_virtual/rolldown_runtime.cjs');
2
- let __stryke_string_format_title_case = require("@stryke/string-format/title-case");
3
-
4
- //#region ../powerlines/src/lib/utilities/file-header.ts
5
- function getBaseFileHeader(context) {
6
- return `
7
- // Generated with ${(0, __stryke_string_format_title_case.titleCase)(context.config.framework)}
8
- // Note: Do not edit this file manually - it will be overwritten automatically
9
- `;
10
- }
11
- function getFileHeader(context, options = {}) {
12
- const { directive = null, prettierIgnore = false } = options;
13
- return `/* eslint-disable */
14
- // biome-ignore lint: disable
15
- ${prettierIgnore ? `// prettier-ignore` : ""}${directive ? `\n\n${directive}\n` : "\n"}
16
- ${getBaseFileHeader(context)}
17
-
18
- `;
19
- }
20
-
21
- //#endregion
22
- exports.getFileHeader = getFileHeader;
@@ -1,21 +0,0 @@
1
- import { titleCase } from "@stryke/string-format/title-case";
2
-
3
- //#region ../powerlines/src/lib/utilities/file-header.ts
4
- function getBaseFileHeader(context) {
5
- return `
6
- // Generated with ${titleCase(context.config.framework)}
7
- // Note: Do not edit this file manually - it will be overwritten automatically
8
- `;
9
- }
10
- function getFileHeader(context, options = {}) {
11
- const { directive = null, prettierIgnore = false } = options;
12
- return `/* eslint-disable */
13
- // biome-ignore lint: disable
14
- ${prettierIgnore ? `// prettier-ignore` : ""}${directive ? `\n\n${directive}\n` : "\n"}
15
- ${getBaseFileHeader(context)}
16
-
17
- `;
18
- }
19
-
20
- //#endregion
21
- export { getFileHeader };
@@ -1,48 +0,0 @@
1
- const require_rolldown_runtime = require('../../../../_virtual/rolldown_runtime.cjs');
2
- let __stryke_fs_list_files = require("@stryke/fs/list-files");
3
- let __stryke_path_append = require("@stryke/path/append");
4
- let __stryke_path_is_parent_path = require("@stryke/path/is-parent-path");
5
- let prettier = require("prettier");
6
-
7
- //#region ../powerlines/src/lib/utilities/format.ts
8
- /**
9
- * Formats code using Prettier based on the file path.
10
- *
11
- * @param context - The Powerlines context.
12
- * @param path - The file path to use for resolving Prettier configuration.
13
- * @param data - The code string to format.
14
- * @param force - Whether to force formatting even for output/build paths.
15
- * @returns A promise that resolves to the formatted code string.
16
- */
17
- async function format(context, path, data, force = false) {
18
- if (!force && ((0, __stryke_path_is_parent_path.isParentPath)(path, (0, __stryke_path_append.appendPath)(context.config.output.outputPath, context.workspaceConfig.workspaceRoot)) || (0, __stryke_path_is_parent_path.isParentPath)(path, (0, __stryke_path_append.appendPath)(context.config.output.buildPath, context.workspaceConfig.workspaceRoot)))) return data;
19
- let code = data;
20
- const resolvedConfig = await (0, prettier.resolveConfig)(path);
21
- if (resolvedConfig) code = await (0, prettier.format)(data, {
22
- absolutePath: path,
23
- ...resolvedConfig
24
- });
25
- return code;
26
- }
27
- /**
28
- * Formats all files in a folder using Prettier based on their file paths.
29
- *
30
- * @param context - The Powerlines context.
31
- * @param path - The folder path containing files to format.
32
- * @returns A promise that resolves when all files have been formatted.
33
- */
34
- async function formatFolder(context, path) {
35
- if (!(0, __stryke_path_is_parent_path.isParentPath)(path, (0, __stryke_path_append.appendPath)(context.config.output.outputPath, context.workspaceConfig.workspaceRoot)) && !(0, __stryke_path_is_parent_path.isParentPath)(path, (0, __stryke_path_append.appendPath)(context.config.output.buildPath, context.workspaceConfig.workspaceRoot))) await Promise.allSettled((await (0, __stryke_fs_list_files.listFiles)(path)).map(async (file) => {
36
- if (!(0, __stryke_path_is_parent_path.isParentPath)(file, (0, __stryke_path_append.appendPath)(context.config.output.outputPath, context.workspaceConfig.workspaceRoot)) && !(0, __stryke_path_is_parent_path.isParentPath)(file, (0, __stryke_path_append.appendPath)(context.config.output.buildPath, context.workspaceConfig.workspaceRoot))) {
37
- const data = await context.fs.read(file);
38
- if (data) {
39
- const formatted = await format(context, file, data);
40
- return context.fs.write(file, formatted);
41
- }
42
- }
43
- }));
44
- }
45
-
46
- //#endregion
47
- exports.format = format;
48
- exports.formatFolder = formatFolder;
@@ -1,46 +0,0 @@
1
- import { listFiles } from "@stryke/fs/list-files";
2
- import { appendPath } from "@stryke/path/append";
3
- import { isParentPath } from "@stryke/path/is-parent-path";
4
- import { format, resolveConfig } from "prettier";
5
-
6
- //#region ../powerlines/src/lib/utilities/format.ts
7
- /**
8
- * Formats code using Prettier based on the file path.
9
- *
10
- * @param context - The Powerlines context.
11
- * @param path - The file path to use for resolving Prettier configuration.
12
- * @param data - The code string to format.
13
- * @param force - Whether to force formatting even for output/build paths.
14
- * @returns A promise that resolves to the formatted code string.
15
- */
16
- async function format$1(context, path, data, force = false) {
17
- if (!force && (isParentPath(path, appendPath(context.config.output.outputPath, context.workspaceConfig.workspaceRoot)) || isParentPath(path, appendPath(context.config.output.buildPath, context.workspaceConfig.workspaceRoot)))) return data;
18
- let code = data;
19
- const resolvedConfig = await resolveConfig(path);
20
- if (resolvedConfig) code = await format(data, {
21
- absolutePath: path,
22
- ...resolvedConfig
23
- });
24
- return code;
25
- }
26
- /**
27
- * Formats all files in a folder using Prettier based on their file paths.
28
- *
29
- * @param context - The Powerlines context.
30
- * @param path - The folder path containing files to format.
31
- * @returns A promise that resolves when all files have been formatted.
32
- */
33
- async function formatFolder(context, path) {
34
- if (!isParentPath(path, appendPath(context.config.output.outputPath, context.workspaceConfig.workspaceRoot)) && !isParentPath(path, appendPath(context.config.output.buildPath, context.workspaceConfig.workspaceRoot))) await Promise.allSettled((await listFiles(path)).map(async (file) => {
35
- if (!isParentPath(file, appendPath(context.config.output.outputPath, context.workspaceConfig.workspaceRoot)) && !isParentPath(file, appendPath(context.config.output.buildPath, context.workspaceConfig.workspaceRoot))) {
36
- const data = await context.fs.read(file);
37
- if (data) {
38
- const formatted = await format$1(context, file, data);
39
- return context.fs.write(file, formatted);
40
- }
41
- }
42
- }));
43
- }
44
-
45
- //#endregion
46
- export { format$1 as format, formatFolder };
@@ -1,44 +0,0 @@
1
- const require_rolldown_runtime = require('../../../../_virtual/rolldown_runtime.cjs');
2
- let __stryke_path_join_paths = require("@stryke/path/join-paths");
3
- let __stryke_fs_list_files = require("@stryke/fs/list-files");
4
- let __stryke_path_file_path_fns = require("@stryke/path/file-path-fns");
5
- let __stryke_fs_json = require("@stryke/fs/json");
6
- let __stryke_fs_exists = require("@stryke/fs/exists");
7
- let __stryke_helpers_get_unique = require("@stryke/helpers/get-unique");
8
- let __stryke_string_format_kebab_case = require("@stryke/string-format/kebab-case");
9
- require("@stryke/fs/remove-file");
10
-
11
- //#region ../powerlines/src/lib/utilities/meta.ts
12
- const PROJECT_ROOT_HASH_LENGTH = 45;
13
- const CACHE_HASH_LENGTH = 62;
14
- /**
15
- * Generates a prefixed project root hash object.
16
- *
17
- * @remarks
18
- * This function returns a string where the project root hash is prefixed with the project name plus a hyphen. If the total length of this string combination exceeds 45 characters, it will truncate the hash.
19
- *
20
- * @param name - The name of the project.
21
- * @param projectRootHash - The hash of the project root.
22
- * @returns An object containing the name and project root hash.
23
- */
24
- function getPrefixedProjectRootHash(name, projectRootHash) {
25
- const combined = `${(0, __stryke_string_format_kebab_case.kebabCase)(name)}_${projectRootHash}`;
26
- return combined.length > PROJECT_ROOT_HASH_LENGTH ? combined.slice(0, PROJECT_ROOT_HASH_LENGTH) : combined;
27
- }
28
- /**
29
- * Writes the meta file for the context.
30
- *
31
- * @param context - The context to write the meta file for.
32
- * @returns A promise that resolves when the meta file has been written.
33
- */
34
- async function writeMetaFile(context) {
35
- const metaFilePath = (0, __stryke_path_join_paths.joinPaths)(context.dataPath, "meta.json");
36
- context.debug(`Writing runtime metadata to ${metaFilePath}`);
37
- await context.fs.write(metaFilePath, JSON.stringify(context.meta, null, 2));
38
- }
39
-
40
- //#endregion
41
- exports.CACHE_HASH_LENGTH = CACHE_HASH_LENGTH;
42
- exports.PROJECT_ROOT_HASH_LENGTH = PROJECT_ROOT_HASH_LENGTH;
43
- exports.getPrefixedProjectRootHash = getPrefixedProjectRootHash;
44
- exports.writeMetaFile = writeMetaFile;
@@ -1,40 +0,0 @@
1
- import { joinPaths } from "@stryke/path/join-paths";
2
- import { listFiles } from "@stryke/fs/list-files";
3
- import { hasFileExtension } from "@stryke/path/file-path-fns";
4
- import { readJsonFile } from "@stryke/fs/json";
5
- import { existsSync } from "@stryke/fs/exists";
6
- import { getUnique } from "@stryke/helpers/get-unique";
7
- import { kebabCase } from "@stryke/string-format/kebab-case";
8
- import "@stryke/fs/remove-file";
9
-
10
- //#region ../powerlines/src/lib/utilities/meta.ts
11
- const PROJECT_ROOT_HASH_LENGTH = 45;
12
- const CACHE_HASH_LENGTH = 62;
13
- /**
14
- * Generates a prefixed project root hash object.
15
- *
16
- * @remarks
17
- * This function returns a string where the project root hash is prefixed with the project name plus a hyphen. If the total length of this string combination exceeds 45 characters, it will truncate the hash.
18
- *
19
- * @param name - The name of the project.
20
- * @param projectRootHash - The hash of the project root.
21
- * @returns An object containing the name and project root hash.
22
- */
23
- function getPrefixedProjectRootHash(name, projectRootHash) {
24
- const combined = `${kebabCase(name)}_${projectRootHash}`;
25
- return combined.length > PROJECT_ROOT_HASH_LENGTH ? combined.slice(0, PROJECT_ROOT_HASH_LENGTH) : combined;
26
- }
27
- /**
28
- * Writes the meta file for the context.
29
- *
30
- * @param context - The context to write the meta file for.
31
- * @returns A promise that resolves when the meta file has been written.
32
- */
33
- async function writeMetaFile(context) {
34
- const metaFilePath = joinPaths(context.dataPath, "meta.json");
35
- context.debug(`Writing runtime metadata to ${metaFilePath}`);
36
- await context.fs.write(metaFilePath, JSON.stringify(context.meta, null, 2));
37
- }
38
-
39
- //#endregion
40
- export { CACHE_HASH_LENGTH, PROJECT_ROOT_HASH_LENGTH, getPrefixedProjectRootHash, writeMetaFile };
@@ -1,22 +0,0 @@
1
- const require_rolldown_runtime = require('../../../../_virtual/rolldown_runtime.cjs');
2
- let __stryke_type_checks_is_set_object = require("@stryke/type-checks/is-set-object");
3
- let __stryke_type_checks_is_string = require("@stryke/type-checks/is-string");
4
- let __stryke_fs_read_file = require("@stryke/fs/read-file");
5
- require("magic-string");
6
-
7
- //#region ../powerlines/src/lib/utilities/source-file.ts
8
- /**
9
- * Get the string from the source.
10
- *
11
- * @param code - The source string or magic string.
12
- * @returns The source string.
13
- */
14
- function getString(code) {
15
- if (!code) return "";
16
- if ((0, __stryke_type_checks_is_string.isString)(code)) return code;
17
- if ((0, __stryke_type_checks_is_set_object.isSetObject)(code) && "code" in code) return code.code;
18
- return code.toString();
19
- }
20
-
21
- //#endregion
22
- exports.getString = getString;
@@ -1,21 +0,0 @@
1
- import { isSetObject } from "@stryke/type-checks/is-set-object";
2
- import { isString } from "@stryke/type-checks/is-string";
3
- import "@stryke/fs/read-file";
4
- import "magic-string";
5
-
6
- //#region ../powerlines/src/lib/utilities/source-file.ts
7
- /**
8
- * Get the string from the source.
9
- *
10
- * @param code - The source string or magic string.
11
- * @returns The source string.
12
- */
13
- function getString(code) {
14
- if (!code) return "";
15
- if (isString(code)) return code;
16
- if (isSetObject(code) && "code" in code) return code.code;
17
- return code.toString();
18
- }
19
-
20
- //#endregion
21
- export { getString };