@powerlines/plugin-rolldown 0.7.138 → 0.7.139

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 (86) 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.mjs +3 -3
  5. package/dist/powerlines/src/types/babel.d.mts +1 -3
  6. package/dist/powerlines/src/types/config.d.mts +1 -3
  7. package/dist/powerlines/src/types/context.d.mts +5 -5
  8. package/dist/powerlines/src/types/fs.d.mts +1 -1
  9. package/dist/powerlines/src/types/tsconfig.d.mts +1 -1
  10. package/package.json +4 -5
  11. package/dist/powerlines/schemas/fs.cjs +0 -226
  12. package/dist/powerlines/schemas/fs.mjs +0 -224
  13. package/dist/powerlines/src/api.cjs +0 -580
  14. package/dist/powerlines/src/api.mjs +0 -578
  15. package/dist/powerlines/src/internal/babel/module-resolver-plugin.cjs +0 -86
  16. package/dist/powerlines/src/internal/babel/module-resolver-plugin.mjs +0 -84
  17. package/dist/powerlines/src/internal/helpers/environment.cjs +0 -52
  18. package/dist/powerlines/src/internal/helpers/environment.mjs +0 -48
  19. package/dist/powerlines/src/internal/helpers/generate-types.cjs +0 -51
  20. package/dist/powerlines/src/internal/helpers/generate-types.mjs +0 -49
  21. package/dist/powerlines/src/internal/helpers/hooks.cjs +0 -66
  22. package/dist/powerlines/src/internal/helpers/hooks.mjs +0 -64
  23. package/dist/powerlines/src/internal/helpers/install-dependencies.cjs +0 -25
  24. package/dist/powerlines/src/internal/helpers/install-dependencies.mjs +0 -24
  25. package/dist/powerlines/src/internal/helpers/install.cjs +0 -37
  26. package/dist/powerlines/src/internal/helpers/install.mjs +0 -36
  27. package/dist/powerlines/src/internal/helpers/resolve-tsconfig.cjs +0 -98
  28. package/dist/powerlines/src/internal/helpers/resolve-tsconfig.mjs +0 -94
  29. package/dist/powerlines/src/internal/helpers/resolver.cjs +0 -43
  30. package/dist/powerlines/src/internal/helpers/resolver.mjs +0 -41
  31. package/dist/powerlines/src/lib/build/rolldown.cjs +0 -125
  32. package/dist/powerlines/src/lib/build/rolldown.mjs +0 -119
  33. package/dist/powerlines/src/lib/build/rollup.cjs +0 -45
  34. package/dist/powerlines/src/lib/build/rollup.mjs +0 -39
  35. package/dist/powerlines/src/lib/config-file.cjs +0 -79
  36. package/dist/powerlines/src/lib/config-file.mjs +0 -76
  37. package/dist/powerlines/src/lib/contexts/api-context.cjs +0 -184
  38. package/dist/powerlines/src/lib/contexts/api-context.mjs +0 -182
  39. package/dist/powerlines/src/lib/contexts/context.cjs +0 -933
  40. package/dist/powerlines/src/lib/contexts/context.mjs +0 -931
  41. package/dist/powerlines/src/lib/contexts/environment-context.cjs +0 -195
  42. package/dist/powerlines/src/lib/contexts/environment-context.mjs +0 -194
  43. package/dist/powerlines/src/lib/contexts/plugin-context.cjs +0 -75
  44. package/dist/powerlines/src/lib/contexts/plugin-context.mjs +0 -74
  45. package/dist/powerlines/src/lib/entry.cjs +0 -69
  46. package/dist/powerlines/src/lib/entry.mjs +0 -67
  47. package/dist/powerlines/src/lib/fs/helpers.cjs +0 -85
  48. package/dist/powerlines/src/lib/fs/helpers.mjs +0 -81
  49. package/dist/powerlines/src/lib/fs/storage/base.cjs +0 -196
  50. package/dist/powerlines/src/lib/fs/storage/base.mjs +0 -195
  51. package/dist/powerlines/src/lib/fs/storage/file-system.cjs +0 -170
  52. package/dist/powerlines/src/lib/fs/storage/file-system.mjs +0 -169
  53. package/dist/powerlines/src/lib/fs/storage/virtual.cjs +0 -88
  54. package/dist/powerlines/src/lib/fs/storage/virtual.mjs +0 -87
  55. package/dist/powerlines/src/lib/fs/vfs.cjs +0 -830
  56. package/dist/powerlines/src/lib/fs/vfs.mjs +0 -828
  57. package/dist/powerlines/src/lib/logger.cjs +0 -58
  58. package/dist/powerlines/src/lib/logger.mjs +0 -55
  59. package/dist/powerlines/src/lib/typescript/ts-morph.cjs +0 -104
  60. package/dist/powerlines/src/lib/typescript/ts-morph.mjs +0 -102
  61. package/dist/powerlines/src/lib/typescript/tsconfig.cjs +0 -149
  62. package/dist/powerlines/src/lib/typescript/tsconfig.mjs +0 -144
  63. package/dist/powerlines/src/lib/unplugin/factory.cjs +0 -6
  64. package/dist/powerlines/src/lib/unplugin/factory.mjs +0 -8
  65. package/dist/powerlines/src/lib/unplugin/helpers.cjs +0 -29
  66. package/dist/powerlines/src/lib/unplugin/helpers.mjs +0 -27
  67. package/dist/powerlines/src/lib/unplugin/index.cjs +0 -3
  68. package/dist/powerlines/src/lib/unplugin/index.mjs +0 -5
  69. package/dist/powerlines/src/lib/unplugin/plugin.cjs +0 -128
  70. package/dist/powerlines/src/lib/unplugin/plugin.mjs +0 -127
  71. package/dist/powerlines/src/lib/utilities/file-header.cjs +0 -22
  72. package/dist/powerlines/src/lib/utilities/file-header.mjs +0 -21
  73. package/dist/powerlines/src/lib/utilities/meta.cjs +0 -45
  74. package/dist/powerlines/src/lib/utilities/meta.mjs +0 -41
  75. package/dist/powerlines/src/lib/utilities/source-file.cjs +0 -22
  76. package/dist/powerlines/src/lib/utilities/source-file.mjs +0 -21
  77. package/dist/powerlines/src/plugin-utils/helpers.cjs +0 -167
  78. package/dist/powerlines/src/plugin-utils/helpers.mjs +0 -156
  79. package/dist/powerlines/src/plugin-utils/paths.cjs +0 -36
  80. package/dist/powerlines/src/plugin-utils/paths.mjs +0 -35
  81. package/dist/powerlines/src/types/build.cjs +0 -23
  82. package/dist/powerlines/src/types/build.mjs +0 -21
  83. package/dist/powerlines/src/types/commands.cjs +0 -16
  84. package/dist/powerlines/src/types/commands.mjs +0 -15
  85. package/dist/powerlines/src/types/plugin.cjs +0 -33
  86. package/dist/powerlines/src/types/plugin.mjs +0 -32
@@ -1,58 +0,0 @@
1
- const require_rolldown_runtime = require('../../../_virtual/rolldown_runtime.cjs');
2
- let __storm_software_config_tools_types = require("@storm-software/config-tools/types");
3
- let chalk = require("chalk");
4
- chalk = require_rolldown_runtime.__toESM(chalk);
5
- let __stryke_string_format_title_case = require("@stryke/string-format/title-case");
6
- let __storm_software_config_tools_logger = require("@storm-software/config-tools/logger");
7
- let __storm_software_config_tools_utilities_colors = require("@storm-software/config-tools/utilities/colors");
8
- let __stryke_helpers_noop = require("@stryke/helpers/noop");
9
- let __stryke_string_format_kebab_case = require("@stryke/string-format/kebab-case");
10
-
11
- //#region ../powerlines/src/lib/logger.ts
12
- /**
13
- * Create a logging function with a specific name and options.
14
- *
15
- * @param name - The name of the logging function.
16
- * @param options - The options to configure the logging function.
17
- * @returns A logging function.
18
- */
19
- const createLog = (name, options = {}) => {
20
- const logLevel = options.logLevel === null ? __storm_software_config_tools_types.LogLevelLabel.SILENT : options.logLevel || __storm_software_config_tools_types.LogLevelLabel.INFO;
21
- if (logLevel === __storm_software_config_tools_types.LogLevelLabel.SILENT) return __stryke_helpers_noop.noop;
22
- if (options.customLogger) return options.customLogger;
23
- return (type, ...args) => (0, __storm_software_config_tools_logger.getLogFn)((0, __storm_software_config_tools_logger.getLogLevel)(type), {
24
- ...options,
25
- logLevel
26
- })(`${chalk.default.bold.hex((0, __storm_software_config_tools_utilities_colors.getColor)("brand", options))(`${name ? (0, __stryke_string_format_kebab_case.kebabCase)(name) : ""}${options.name ? `${name ? chalk.default.gray(" > ") : ""}${(0, __stryke_string_format_kebab_case.kebabCase)(options.name)}` : ""}${chalk.default.gray(" > ")}`)}${args.join(" ")} `.trim());
27
- };
28
- const BADGE_COLORS = [
29
- "#00A0DD",
30
- "#6FCE4E",
31
- "#FBBF24",
32
- "#F43F5E",
33
- "#3B82F6",
34
- "#A855F7",
35
- "#469592",
36
- "#288EDF",
37
- "#D8B4FE",
38
- "#10B981",
39
- "#EF4444",
40
- "#F0EC56",
41
- "#F472B6",
42
- "#22D3EE",
43
- "#EAB308",
44
- "#84CC16",
45
- "#F87171",
46
- "#0EA5E9",
47
- "#D946EF",
48
- "#FACC15",
49
- "#34D399",
50
- "#8B5CF6"
51
- ];
52
- const extendLog = (logFn, name) => {
53
- return (type, ...args) => logFn(type, ` ${chalk.default.inverse.hex(BADGE_COLORS[name.split("").map((char) => char.charCodeAt(0)).reduce((ret, charCode) => ret + charCode, 0) % BADGE_COLORS.length] || BADGE_COLORS[0])(` ${(0, __stryke_string_format_title_case.titleCase)(name)} `)} ${args.join(" ")} `);
54
- };
55
-
56
- //#endregion
57
- exports.createLog = createLog;
58
- exports.extendLog = extendLog;
@@ -1,55 +0,0 @@
1
- import { LogLevelLabel } from "@storm-software/config-tools/types";
2
- import chalk from "chalk";
3
- import { titleCase } from "@stryke/string-format/title-case";
4
- import { getLogFn, getLogLevel } from "@storm-software/config-tools/logger";
5
- import { getColor } from "@storm-software/config-tools/utilities/colors";
6
- import { noop } from "@stryke/helpers/noop";
7
- import { kebabCase } from "@stryke/string-format/kebab-case";
8
-
9
- //#region ../powerlines/src/lib/logger.ts
10
- /**
11
- * Create a logging function with a specific name and options.
12
- *
13
- * @param name - The name of the logging function.
14
- * @param options - The options to configure the logging function.
15
- * @returns A logging function.
16
- */
17
- const createLog = (name, options = {}) => {
18
- const logLevel = options.logLevel === null ? LogLevelLabel.SILENT : options.logLevel || LogLevelLabel.INFO;
19
- if (logLevel === LogLevelLabel.SILENT) return noop;
20
- if (options.customLogger) return options.customLogger;
21
- return (type, ...args) => getLogFn(getLogLevel(type), {
22
- ...options,
23
- logLevel
24
- })(`${chalk.bold.hex(getColor("brand", options))(`${name ? kebabCase(name) : ""}${options.name ? `${name ? chalk.gray(" > ") : ""}${kebabCase(options.name)}` : ""}${chalk.gray(" > ")}`)}${args.join(" ")} `.trim());
25
- };
26
- const BADGE_COLORS = [
27
- "#00A0DD",
28
- "#6FCE4E",
29
- "#FBBF24",
30
- "#F43F5E",
31
- "#3B82F6",
32
- "#A855F7",
33
- "#469592",
34
- "#288EDF",
35
- "#D8B4FE",
36
- "#10B981",
37
- "#EF4444",
38
- "#F0EC56",
39
- "#F472B6",
40
- "#22D3EE",
41
- "#EAB308",
42
- "#84CC16",
43
- "#F87171",
44
- "#0EA5E9",
45
- "#D946EF",
46
- "#FACC15",
47
- "#34D399",
48
- "#8B5CF6"
49
- ];
50
- const extendLog = (logFn, name) => {
51
- return (type, ...args) => logFn(type, ` ${chalk.inverse.hex(BADGE_COLORS[name.split("").map((char) => char.charCodeAt(0)).reduce((ret, charCode) => ret + charCode, 0) % BADGE_COLORS.length] || BADGE_COLORS[0])(` ${titleCase(name)} `)} ${args.join(" ")} `);
52
- };
53
-
54
- //#endregion
55
- export { createLog, extendLog };
@@ -1,104 +0,0 @@
1
- const require_rolldown_runtime = require('../../../../_virtual/rolldown_runtime.cjs');
2
- let defu = require("defu");
3
- defu = require_rolldown_runtime.__toESM(defu);
4
- let __storm_software_config_tools_types = require("@storm-software/config-tools/types");
5
- let ts_morph = require("ts-morph");
6
-
7
- //#region ../powerlines/src/lib/typescript/ts-morph.ts
8
- var VirtualFileSystemHost = class extends ts_morph.InMemoryFileSystemHost {
9
- #context;
10
- constructor(context) {
11
- super();
12
- this.#context = context;
13
- }
14
- deleteSync(path) {
15
- this.#context.fs.removeSync(path);
16
- }
17
- readDirSync(dirPath) {
18
- if (!this.#context.fs.isDirectorySync(dirPath)) return [];
19
- return this.#context.fs.listSync(dirPath).reduce((ret, entry) => {
20
- const fullPath = this.#context.fs.resolveSync(entry);
21
- if (fullPath) ret.push({
22
- name: entry,
23
- isDirectory: this.#context.fs.isDirectorySync(fullPath),
24
- isFile: this.#context.fs.isFileSync(fullPath),
25
- isSymlink: false
26
- });
27
- return ret;
28
- }, []);
29
- }
30
- async readFile(filePath) {
31
- if (!this.#context.fs.isFileSync(filePath)) return "";
32
- return await this.#context.fs.read(filePath);
33
- }
34
- readFileSync(filePath) {
35
- if (!this.#context.fs.isFileSync(filePath)) return "";
36
- return this.#context.fs.readSync(filePath);
37
- }
38
- async writeFile(filePath, fileText) {
39
- return this.#context.fs.write(filePath, fileText);
40
- }
41
- writeFileSync(filePath, fileText) {
42
- this.#context.fs.writeSync(filePath, fileText);
43
- }
44
- async mkdir(dirPath) {
45
- await this.#context.fs.mkdir(dirPath);
46
- }
47
- mkdirSync(dirPath) {
48
- this.#context.fs.mkdirSync(dirPath);
49
- }
50
- async move(srcPath, destPath) {
51
- await this.#context.fs.move(srcPath, destPath);
52
- }
53
- moveSync(srcPath, destPath) {
54
- this.#context.fs.moveSync(srcPath, destPath);
55
- }
56
- async copy(srcPath, destPath) {
57
- await this.#context.fs.copy(srcPath, destPath);
58
- }
59
- copySync(srcPath, destPath) {
60
- this.#context.fs.copySync(srcPath, destPath);
61
- }
62
- async fileExists(filePath) {
63
- return this.#context.fs.isFile(filePath);
64
- }
65
- fileExistsSync(filePath) {
66
- return this.#context.fs.isFileSync(filePath);
67
- }
68
- async directoryExists(dirPath) {
69
- return this.#context.fs.isDirectory(dirPath);
70
- }
71
- directoryExistsSync(dirPath) {
72
- return this.#context.fs.isDirectorySync(dirPath);
73
- }
74
- realpathSync(path) {
75
- return this.#context.fs.resolveSync(path) || path;
76
- }
77
- getCurrentDirectory() {
78
- return this.#context.workspaceConfig.workspaceRoot;
79
- }
80
- async glob(patterns) {
81
- return this.#context.fs.glob(patterns);
82
- }
83
- globSync(patterns) {
84
- return this.#context.fs.globSync(patterns);
85
- }
86
- };
87
- /**
88
- * Create a ts-morph {@link Project} instance used for type reflection and module manipulation during processing
89
- *
90
- * @param context - The Powerlines context
91
- * @returns A ts-morph {@link Project} instance
92
- */
93
- function createProgram(context, override) {
94
- context.log(__storm_software_config_tools_types.LogLevelLabel.TRACE, `Creating ts-morph Project instance with configuration from: ${context.tsconfig.tsconfigFilePath}.`);
95
- return new ts_morph.Project((0, defu.default)(override ?? {}, {
96
- skipAddingFilesFromTsConfig: false,
97
- tsConfigFilePath: context.tsconfig.tsconfigFilePath,
98
- fileSystem: new VirtualFileSystemHost(context),
99
- compilerOptions: (0, defu.default)(context.tsconfig.options ?? {}, { lib: ["lib.esnext.full.d.ts"] })
100
- }));
101
- }
102
-
103
- //#endregion
104
- exports.createProgram = createProgram;
@@ -1,102 +0,0 @@
1
- import defu$1 from "defu";
2
- import { LogLevelLabel } from "@storm-software/config-tools/types";
3
- import { InMemoryFileSystemHost, Project } from "ts-morph";
4
-
5
- //#region ../powerlines/src/lib/typescript/ts-morph.ts
6
- var VirtualFileSystemHost = class extends InMemoryFileSystemHost {
7
- #context;
8
- constructor(context) {
9
- super();
10
- this.#context = context;
11
- }
12
- deleteSync(path) {
13
- this.#context.fs.removeSync(path);
14
- }
15
- readDirSync(dirPath) {
16
- if (!this.#context.fs.isDirectorySync(dirPath)) return [];
17
- return this.#context.fs.listSync(dirPath).reduce((ret, entry) => {
18
- const fullPath = this.#context.fs.resolveSync(entry);
19
- if (fullPath) ret.push({
20
- name: entry,
21
- isDirectory: this.#context.fs.isDirectorySync(fullPath),
22
- isFile: this.#context.fs.isFileSync(fullPath),
23
- isSymlink: false
24
- });
25
- return ret;
26
- }, []);
27
- }
28
- async readFile(filePath) {
29
- if (!this.#context.fs.isFileSync(filePath)) return "";
30
- return await this.#context.fs.read(filePath);
31
- }
32
- readFileSync(filePath) {
33
- if (!this.#context.fs.isFileSync(filePath)) return "";
34
- return this.#context.fs.readSync(filePath);
35
- }
36
- async writeFile(filePath, fileText) {
37
- return this.#context.fs.write(filePath, fileText);
38
- }
39
- writeFileSync(filePath, fileText) {
40
- this.#context.fs.writeSync(filePath, fileText);
41
- }
42
- async mkdir(dirPath) {
43
- await this.#context.fs.mkdir(dirPath);
44
- }
45
- mkdirSync(dirPath) {
46
- this.#context.fs.mkdirSync(dirPath);
47
- }
48
- async move(srcPath, destPath) {
49
- await this.#context.fs.move(srcPath, destPath);
50
- }
51
- moveSync(srcPath, destPath) {
52
- this.#context.fs.moveSync(srcPath, destPath);
53
- }
54
- async copy(srcPath, destPath) {
55
- await this.#context.fs.copy(srcPath, destPath);
56
- }
57
- copySync(srcPath, destPath) {
58
- this.#context.fs.copySync(srcPath, destPath);
59
- }
60
- async fileExists(filePath) {
61
- return this.#context.fs.isFile(filePath);
62
- }
63
- fileExistsSync(filePath) {
64
- return this.#context.fs.isFileSync(filePath);
65
- }
66
- async directoryExists(dirPath) {
67
- return this.#context.fs.isDirectory(dirPath);
68
- }
69
- directoryExistsSync(dirPath) {
70
- return this.#context.fs.isDirectorySync(dirPath);
71
- }
72
- realpathSync(path) {
73
- return this.#context.fs.resolveSync(path) || path;
74
- }
75
- getCurrentDirectory() {
76
- return this.#context.workspaceConfig.workspaceRoot;
77
- }
78
- async glob(patterns) {
79
- return this.#context.fs.glob(patterns);
80
- }
81
- globSync(patterns) {
82
- return this.#context.fs.globSync(patterns);
83
- }
84
- };
85
- /**
86
- * Create a ts-morph {@link Project} instance used for type reflection and module manipulation during processing
87
- *
88
- * @param context - The Powerlines context
89
- * @returns A ts-morph {@link Project} instance
90
- */
91
- function createProgram(context, override) {
92
- context.log(LogLevelLabel.TRACE, `Creating ts-morph Project instance with configuration from: ${context.tsconfig.tsconfigFilePath}.`);
93
- return new Project(defu$1(override ?? {}, {
94
- skipAddingFilesFromTsConfig: false,
95
- tsConfigFilePath: context.tsconfig.tsconfigFilePath,
96
- fileSystem: new VirtualFileSystemHost(context),
97
- compilerOptions: defu$1(context.tsconfig.options ?? {}, { lib: ["lib.esnext.full.d.ts"] })
98
- }));
99
- }
100
-
101
- //#endregion
102
- export { createProgram };
@@ -1,149 +0,0 @@
1
- const require_rolldown_runtime = require('../../../../_virtual/rolldown_runtime.cjs');
2
- let defu = require("defu");
3
- defu = require_rolldown_runtime.__toESM(defu);
4
- let __stryke_path_join_paths = require("@stryke/path/join-paths");
5
- let __stryke_path_append = require("@stryke/path/append");
6
- let typescript = require("typescript");
7
- typescript = require_rolldown_runtime.__toESM(typescript);
8
- let __stryke_fs_json = require("@stryke/fs/json");
9
- let __stryke_fs_exists = require("@stryke/fs/exists");
10
-
11
- //#region ../powerlines/src/lib/typescript/tsconfig.ts
12
- /**
13
- * Get the path to the tsconfig.json file.
14
- *
15
- * @param workspaceRoot - The root directory of the workspace.
16
- * @param projectRoot - The root directory of the project.
17
- * @param tsconfig - The path to the tsconfig.json file.
18
- * @returns The absolute path to the tsconfig.json file.
19
- * @throws If the tsconfig.json file does not exist.
20
- */
21
- function getTsconfigFilePath(workspaceRoot, projectRoot, tsconfig) {
22
- let tsconfigFilePath;
23
- if (tsconfig) tsconfigFilePath = tryTsconfigFilePath(workspaceRoot, projectRoot, tsconfig);
24
- else {
25
- tsconfigFilePath = tryTsconfigFilePath(workspaceRoot, projectRoot, "tsconfig.app.json");
26
- if (!tsconfigFilePath) {
27
- tsconfigFilePath = tryTsconfigFilePath(workspaceRoot, projectRoot, "tsconfig.lib.json");
28
- if (!tsconfigFilePath) tsconfigFilePath = tryTsconfigFilePath(workspaceRoot, projectRoot, "tsconfig.json");
29
- }
30
- }
31
- if (!tsconfigFilePath) throw new Error(`Cannot find the \`tsconfig.json\` configuration file for the project at ${projectRoot}.`);
32
- return tsconfigFilePath;
33
- }
34
- /**
35
- * Get the path to the tsconfig.json file.
36
- *
37
- * @param workspaceRoot - The root directory of the workspace.
38
- * @param projectRoot - The root directory of the project.
39
- * @param tsconfig - The path to the tsconfig.json file.
40
- * @returns The absolute path to the tsconfig.json file.
41
- * @throws If the tsconfig.json file does not exist.
42
- */
43
- function tryTsconfigFilePath(workspaceRoot, projectRoot, tsconfig) {
44
- let tsconfigFilePath = tsconfig;
45
- if (!(0, __stryke_fs_exists.existsSync)(tsconfigFilePath)) {
46
- tsconfigFilePath = (0, __stryke_path_append.appendPath)(tsconfig, projectRoot);
47
- if (!(0, __stryke_fs_exists.existsSync)(tsconfigFilePath)) {
48
- tsconfigFilePath = (0, __stryke_path_append.appendPath)(tsconfig, (0, __stryke_path_append.appendPath)(projectRoot, workspaceRoot));
49
- if (!(0, __stryke_fs_exists.existsSync)(tsconfigFilePath)) return;
50
- }
51
- }
52
- return tsconfigFilePath;
53
- }
54
- /**
55
- * Check if the TypeScript configuration type matches any of the provided types.
56
- *
57
- * @param tsconfigType - The type from the TypeScript configuration.
58
- * @param types - An array of type names to check against.
59
- * @returns True if the TypeScript configuration type matches any of the provided types, false otherwise.
60
- */
61
- function findMatch(tsconfigType, types, extensions = [
62
- ".ts",
63
- ".tsx",
64
- ".d.ts"
65
- ]) {
66
- return types.find((type) => tsconfigType?.toString().toLowerCase() === type?.toString().toLowerCase() || tsconfigType?.toString().toLowerCase() === `./${type?.toString().toLowerCase()}` || `./${tsconfigType?.toString().toLowerCase()}` === type?.toString().toLowerCase() || extensions.some((ext) => `${tsconfigType?.toString().toLowerCase()}${ext}` === type?.toString().toLowerCase() || `${tsconfigType?.toString().toLowerCase()}${ext}` === `./${type?.toString().toLowerCase()}` || `${type?.toString().toLowerCase()}${ext}` === `./${tsconfigType?.toString().toLowerCase()}` || tsconfigType?.toString().toLowerCase() === `${type?.toString().toLowerCase()}${ext}` || tsconfigType?.toString().toLowerCase() === `./${type?.toString().toLowerCase()}${ext}` || type?.toString().toLowerCase() === `./${tsconfigType?.toString().toLowerCase()}${ext}`));
67
- }
68
- /**
69
- * Check if the TypeScript configuration type matches any of the provided types.
70
- *
71
- * @param tsconfigType - The type from the TypeScript configuration.
72
- * @param types - An array of type names to check against.
73
- * @returns True if the TypeScript configuration type matches any of the provided types, false otherwise.
74
- */
75
- function findIncludeMatch(tsconfigType, types) {
76
- return findMatch(tsconfigType, types, [
77
- ".ts",
78
- ".tsx",
79
- ".d.ts",
80
- ".js",
81
- ".jsx",
82
- ".mjs",
83
- ".cjs",
84
- ".mts",
85
- ".cts",
86
- "/*.ts",
87
- "/*.tsx",
88
- "/*.d.ts",
89
- "/*.js",
90
- "/*.jsx",
91
- "/*.mjs",
92
- "/*.cjs",
93
- "/*.mts",
94
- "/*.cts",
95
- "/**/*.ts",
96
- "/**/*.tsx",
97
- "/**/*.d.ts",
98
- "/**/*.js",
99
- "/**/*.jsx",
100
- "/**/*.mjs",
101
- "/**/*.cjs",
102
- "/**/*.mts",
103
- "/**/*.cts"
104
- ]);
105
- }
106
- /**
107
- * Check if the TypeScript configuration type matches any of the provided types.
108
- *
109
- * @param tsconfigType - The type from the TypeScript configuration.
110
- * @param types - An array of type names to check against.
111
- * @returns True if the TypeScript configuration type matches any of the provided types, false otherwise.
112
- */
113
- function isIncludeMatchFound(tsconfigType, types) {
114
- return findIncludeMatch(tsconfigType, types) !== void 0;
115
- }
116
- /**
117
- * Get the parsed TypeScript configuration.
118
- *
119
- * @param workspaceRoot - The root directory of the workspace.
120
- * @param projectRoot - The root directory of the project.
121
- * @param tsconfig - The path to the tsconfig.json file.
122
- * @param tsconfigRaw - The raw tsconfig.json content.
123
- * @param originalTsconfigJson - The original tsconfig.json content.
124
- * @param host - The TypeScript parse config host.
125
- * @returns The resolved TypeScript configuration.
126
- */
127
- function getParsedTypeScriptConfig(workspaceRoot, projectRoot, tsconfig, tsconfigRaw = {}, originalTsconfigJson, host = typescript.default.sys) {
128
- const tsconfigFilePath = getTsconfigFilePath(workspaceRoot, projectRoot, tsconfig);
129
- const tsconfigJson = (0, __stryke_fs_json.readJsonFileSync)(tsconfigFilePath);
130
- if (!tsconfigJson) throw new Error(`Cannot find the \`tsconfig.json\` configuration file at ${(0, __stryke_path_join_paths.joinPaths)(projectRoot, tsconfig ?? "tsconfig.json")}`);
131
- const parsedCommandLine = typescript.default.parseJsonConfigFileContent((0, defu.default)(tsconfigRaw ?? {}, tsconfigJson), host, (0, __stryke_path_append.appendPath)(projectRoot, workspaceRoot));
132
- if (parsedCommandLine.errors.length > 0) {
133
- const errorMessage = `Cannot parse the TypeScript compiler options. Please investigate the following issues:
134
- ${parsedCommandLine.errors.map((error) => `- ${(error.category !== void 0 && error.code ? `[${error.category}-${error.code}]: ` : "") + error.messageText.toString()}`).join("\n")}
135
- `;
136
- throw new Error(errorMessage);
137
- }
138
- return {
139
- ...parsedCommandLine,
140
- originalTsconfigJson: originalTsconfigJson ?? tsconfigJson,
141
- tsconfigJson,
142
- tsconfigFilePath
143
- };
144
- }
145
-
146
- //#endregion
147
- exports.getParsedTypeScriptConfig = getParsedTypeScriptConfig;
148
- exports.getTsconfigFilePath = getTsconfigFilePath;
149
- exports.isIncludeMatchFound = isIncludeMatchFound;
@@ -1,144 +0,0 @@
1
- import defu$1 from "defu";
2
- import { joinPaths } from "@stryke/path/join-paths";
3
- import { appendPath } from "@stryke/path/append";
4
- import ts from "typescript";
5
- import { readJsonFileSync } from "@stryke/fs/json";
6
- import { existsSync } from "@stryke/fs/exists";
7
-
8
- //#region ../powerlines/src/lib/typescript/tsconfig.ts
9
- /**
10
- * Get the path to the tsconfig.json file.
11
- *
12
- * @param workspaceRoot - The root directory of the workspace.
13
- * @param projectRoot - The root directory of the project.
14
- * @param tsconfig - The path to the tsconfig.json file.
15
- * @returns The absolute path to the tsconfig.json file.
16
- * @throws If the tsconfig.json file does not exist.
17
- */
18
- function getTsconfigFilePath(workspaceRoot, projectRoot, tsconfig) {
19
- let tsconfigFilePath;
20
- if (tsconfig) tsconfigFilePath = tryTsconfigFilePath(workspaceRoot, projectRoot, tsconfig);
21
- else {
22
- tsconfigFilePath = tryTsconfigFilePath(workspaceRoot, projectRoot, "tsconfig.app.json");
23
- if (!tsconfigFilePath) {
24
- tsconfigFilePath = tryTsconfigFilePath(workspaceRoot, projectRoot, "tsconfig.lib.json");
25
- if (!tsconfigFilePath) tsconfigFilePath = tryTsconfigFilePath(workspaceRoot, projectRoot, "tsconfig.json");
26
- }
27
- }
28
- if (!tsconfigFilePath) throw new Error(`Cannot find the \`tsconfig.json\` configuration file for the project at ${projectRoot}.`);
29
- return tsconfigFilePath;
30
- }
31
- /**
32
- * Get the path to the tsconfig.json file.
33
- *
34
- * @param workspaceRoot - The root directory of the workspace.
35
- * @param projectRoot - The root directory of the project.
36
- * @param tsconfig - The path to the tsconfig.json file.
37
- * @returns The absolute path to the tsconfig.json file.
38
- * @throws If the tsconfig.json file does not exist.
39
- */
40
- function tryTsconfigFilePath(workspaceRoot, projectRoot, tsconfig) {
41
- let tsconfigFilePath = tsconfig;
42
- if (!existsSync(tsconfigFilePath)) {
43
- tsconfigFilePath = appendPath(tsconfig, projectRoot);
44
- if (!existsSync(tsconfigFilePath)) {
45
- tsconfigFilePath = appendPath(tsconfig, appendPath(projectRoot, workspaceRoot));
46
- if (!existsSync(tsconfigFilePath)) return;
47
- }
48
- }
49
- return tsconfigFilePath;
50
- }
51
- /**
52
- * Check if the TypeScript configuration type matches any of the provided types.
53
- *
54
- * @param tsconfigType - The type from the TypeScript configuration.
55
- * @param types - An array of type names to check against.
56
- * @returns True if the TypeScript configuration type matches any of the provided types, false otherwise.
57
- */
58
- function findMatch(tsconfigType, types, extensions = [
59
- ".ts",
60
- ".tsx",
61
- ".d.ts"
62
- ]) {
63
- return types.find((type) => tsconfigType?.toString().toLowerCase() === type?.toString().toLowerCase() || tsconfigType?.toString().toLowerCase() === `./${type?.toString().toLowerCase()}` || `./${tsconfigType?.toString().toLowerCase()}` === type?.toString().toLowerCase() || extensions.some((ext) => `${tsconfigType?.toString().toLowerCase()}${ext}` === type?.toString().toLowerCase() || `${tsconfigType?.toString().toLowerCase()}${ext}` === `./${type?.toString().toLowerCase()}` || `${type?.toString().toLowerCase()}${ext}` === `./${tsconfigType?.toString().toLowerCase()}` || tsconfigType?.toString().toLowerCase() === `${type?.toString().toLowerCase()}${ext}` || tsconfigType?.toString().toLowerCase() === `./${type?.toString().toLowerCase()}${ext}` || type?.toString().toLowerCase() === `./${tsconfigType?.toString().toLowerCase()}${ext}`));
64
- }
65
- /**
66
- * Check if the TypeScript configuration type matches any of the provided types.
67
- *
68
- * @param tsconfigType - The type from the TypeScript configuration.
69
- * @param types - An array of type names to check against.
70
- * @returns True if the TypeScript configuration type matches any of the provided types, false otherwise.
71
- */
72
- function findIncludeMatch(tsconfigType, types) {
73
- return findMatch(tsconfigType, types, [
74
- ".ts",
75
- ".tsx",
76
- ".d.ts",
77
- ".js",
78
- ".jsx",
79
- ".mjs",
80
- ".cjs",
81
- ".mts",
82
- ".cts",
83
- "/*.ts",
84
- "/*.tsx",
85
- "/*.d.ts",
86
- "/*.js",
87
- "/*.jsx",
88
- "/*.mjs",
89
- "/*.cjs",
90
- "/*.mts",
91
- "/*.cts",
92
- "/**/*.ts",
93
- "/**/*.tsx",
94
- "/**/*.d.ts",
95
- "/**/*.js",
96
- "/**/*.jsx",
97
- "/**/*.mjs",
98
- "/**/*.cjs",
99
- "/**/*.mts",
100
- "/**/*.cts"
101
- ]);
102
- }
103
- /**
104
- * Check if the TypeScript configuration type matches any of the provided types.
105
- *
106
- * @param tsconfigType - The type from the TypeScript configuration.
107
- * @param types - An array of type names to check against.
108
- * @returns True if the TypeScript configuration type matches any of the provided types, false otherwise.
109
- */
110
- function isIncludeMatchFound(tsconfigType, types) {
111
- return findIncludeMatch(tsconfigType, types) !== void 0;
112
- }
113
- /**
114
- * Get the parsed TypeScript configuration.
115
- *
116
- * @param workspaceRoot - The root directory of the workspace.
117
- * @param projectRoot - The root directory of the project.
118
- * @param tsconfig - The path to the tsconfig.json file.
119
- * @param tsconfigRaw - The raw tsconfig.json content.
120
- * @param originalTsconfigJson - The original tsconfig.json content.
121
- * @param host - The TypeScript parse config host.
122
- * @returns The resolved TypeScript configuration.
123
- */
124
- function getParsedTypeScriptConfig(workspaceRoot, projectRoot, tsconfig, tsconfigRaw = {}, originalTsconfigJson, host = ts.sys) {
125
- const tsconfigFilePath = getTsconfigFilePath(workspaceRoot, projectRoot, tsconfig);
126
- const tsconfigJson = readJsonFileSync(tsconfigFilePath);
127
- if (!tsconfigJson) throw new Error(`Cannot find the \`tsconfig.json\` configuration file at ${joinPaths(projectRoot, tsconfig ?? "tsconfig.json")}`);
128
- const parsedCommandLine = ts.parseJsonConfigFileContent(defu$1(tsconfigRaw ?? {}, tsconfigJson), host, appendPath(projectRoot, workspaceRoot));
129
- if (parsedCommandLine.errors.length > 0) {
130
- const errorMessage = `Cannot parse the TypeScript compiler options. Please investigate the following issues:
131
- ${parsedCommandLine.errors.map((error) => `- ${(error.category !== void 0 && error.code ? `[${error.category}-${error.code}]: ` : "") + error.messageText.toString()}`).join("\n")}
132
- `;
133
- throw new Error(errorMessage);
134
- }
135
- return {
136
- ...parsedCommandLine,
137
- originalTsconfigJson: originalTsconfigJson ?? tsconfigJson,
138
- tsconfigJson,
139
- tsconfigFilePath
140
- };
141
- }
142
-
143
- //#endregion
144
- export { getParsedTypeScriptConfig, getTsconfigFilePath, isIncludeMatchFound };
@@ -1,6 +0,0 @@
1
- require('../logger.cjs');
2
- require('../../api.cjs');
3
- require('../utilities/source-file.cjs');
4
- let __storm_software_config_tools_types = require("@storm-software/config-tools/types");
5
- let __stryke_fs_get_workspace_root = require("@stryke/fs/get-workspace-root");
6
- let unplugin = require("unplugin");
@@ -1,8 +0,0 @@
1
- import "../logger.mjs";
2
- import "../../api.mjs";
3
- import "../utilities/source-file.mjs";
4
- import { LogLevelLabel } from "@storm-software/config-tools/types";
5
- import "@stryke/fs/get-workspace-root";
6
- import { setParseImpl } from "unplugin";
7
-
8
- export { };
@@ -1,29 +0,0 @@
1
- const require_rolldown_runtime = require('../../../../_virtual/rolldown_runtime.cjs');
2
- const require_build = require('../../types/build.cjs');
3
- let defu = require("defu");
4
- let __stryke_type_checks_is_set_string = require("@stryke/type-checks/is-set-string");
5
-
6
- //#region ../powerlines/src/lib/unplugin/helpers.ts
7
- /**
8
- * Merges a base plugin context with an unplugin context, combining their properties.
9
- *
10
- * @param context - The base plugin context to merge into.
11
- * @param unplugin - The unplugin context to merge from.
12
- * @returns The merged context.
13
- */
14
- function combineContexts(context, unplugin) {
15
- return (0, defu.defu)(context, unplugin);
16
- }
17
- /**
18
- * Checks if a value is a valid UnpluginBuilderVariant.
19
- *
20
- * @param str - The value to check.
21
- * @returns True if the value is a UnpluginBuilderVariant, false otherwise.
22
- */
23
- function isUnpluginBuilderVariant(str) {
24
- return (0, __stryke_type_checks_is_set_string.isSetString)(str) && require_build.UNPLUGIN_BUILDER_VARIANTS.includes(str);
25
- }
26
-
27
- //#endregion
28
- exports.combineContexts = combineContexts;
29
- exports.isUnpluginBuilderVariant = isUnpluginBuilderVariant;