powerlines 0.42.26 → 0.42.28

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 (77) hide show
  1. package/dist/api-C4dPy8XP.mjs +901 -0
  2. package/dist/api-C4dPy8XP.mjs.map +1 -0
  3. package/dist/api-LEq5A1pG.cjs +922 -0
  4. package/dist/api-LEq5A1pG.cjs.map +1 -0
  5. package/dist/{api-CvAosB7E.cjs → api-context-BSrRdlnu.cjs} +103 -1070
  6. package/dist/api-context-BSrRdlnu.cjs.map +1 -0
  7. package/dist/{api-Dtr_u8iv.mjs → api-context-p1enWkF-.mjs} +102 -1058
  8. package/dist/api-context-p1enWkF-.mjs.map +1 -0
  9. package/dist/context/index.cjs +5 -5
  10. package/dist/context/index.d.cts +3 -3
  11. package/dist/context/index.d.cts.map +1 -1
  12. package/dist/context/index.d.mts +4 -4
  13. package/dist/context/index.d.mts.map +1 -1
  14. package/dist/context/index.mjs +1 -1
  15. package/dist/esbuild.cjs +2 -2
  16. package/dist/esbuild.cjs.map +1 -1
  17. package/dist/esbuild.mjs +1 -1
  18. package/dist/farm.cjs +2 -2
  19. package/dist/farm.cjs.map +1 -1
  20. package/dist/farm.mjs +1 -1
  21. package/dist/index.cjs +8 -7
  22. package/dist/index.cjs.map +1 -1
  23. package/dist/index.d.cts.map +1 -1
  24. package/dist/index.d.mts +1 -1
  25. package/dist/index.d.mts.map +1 -1
  26. package/dist/index.mjs +2 -1
  27. package/dist/index.mjs.map +1 -1
  28. package/dist/nuxt.cjs +1 -1
  29. package/dist/nuxt.d.mts +1 -1
  30. package/dist/nuxt.mjs +1 -1
  31. package/dist/rolldown.cjs +2 -2
  32. package/dist/rolldown.cjs.map +1 -1
  33. package/dist/rolldown.mjs +1 -1
  34. package/dist/rollup.cjs +2 -2
  35. package/dist/rollup.cjs.map +1 -1
  36. package/dist/rollup.mjs +1 -1
  37. package/dist/rspack.cjs +2 -2
  38. package/dist/rspack.cjs.map +1 -1
  39. package/dist/rspack.mjs +1 -1
  40. package/dist/storage/index.cjs +1 -1
  41. package/dist/storage/index.d.mts +1 -1
  42. package/dist/storage/index.mjs +1 -1
  43. package/dist/ts-morph-B85ZbV1Q.mjs +102 -0
  44. package/dist/ts-morph-B85ZbV1Q.mjs.map +1 -0
  45. package/dist/ts-morph-Cf4wz3E0.cjs +115 -0
  46. package/dist/ts-morph-Cf4wz3E0.cjs.map +1 -0
  47. package/dist/{tsconfig-BC3TZxD4.cjs → tsconfig-ChmbpAO7.cjs} +1 -111
  48. package/dist/tsconfig-ChmbpAO7.cjs.map +1 -0
  49. package/dist/{tsconfig-CXwGIrfR.mjs → tsconfig-DoV1dUYg.mjs} +2 -100
  50. package/dist/tsconfig-DoV1dUYg.mjs.map +1 -0
  51. package/dist/{types-ro7jWCtL.d.mts → types-9O-s0Fpu.d.mts} +1 -1
  52. package/dist/types-9O-s0Fpu.d.mts.map +1 -0
  53. package/dist/typescript/index.cjs +4 -3
  54. package/dist/typescript/index.mjs +2 -1
  55. package/dist/unloader.cjs +2 -2
  56. package/dist/unloader.cjs.map +1 -1
  57. package/dist/unloader.mjs +1 -1
  58. package/dist/unplugin.cjs +98 -2
  59. package/dist/unplugin.cjs.map +1 -0
  60. package/dist/unplugin.mjs +96 -2
  61. package/dist/unplugin.mjs.map +1 -0
  62. package/dist/{virtual-BvouNuwf.cjs → virtual-BNy8T32w.cjs} +1 -1
  63. package/dist/{virtual-BvouNuwf.cjs.map → virtual-BNy8T32w.cjs.map} +1 -1
  64. package/dist/{virtual-B0n7dKeA.mjs → virtual-PaZGNIrj.mjs} +1 -1
  65. package/dist/{virtual-B0n7dKeA.mjs.map → virtual-PaZGNIrj.mjs.map} +1 -1
  66. package/dist/vite.cjs +3 -3
  67. package/dist/vite.cjs.map +1 -1
  68. package/dist/vite.mjs +2 -2
  69. package/dist/webpack.cjs +2 -2
  70. package/dist/webpack.cjs.map +1 -1
  71. package/dist/webpack.mjs +1 -1
  72. package/package.json +19 -19
  73. package/dist/api-CvAosB7E.cjs.map +0 -1
  74. package/dist/api-Dtr_u8iv.mjs.map +0 -1
  75. package/dist/tsconfig-BC3TZxD4.cjs.map +0 -1
  76. package/dist/tsconfig-CXwGIrfR.mjs.map +0 -1
  77. package/dist/types-ro7jWCtL.d.mts.map +0 -1
@@ -0,0 +1,115 @@
1
+ const require_chunk = require('./chunk-AIJqnxB6.cjs');
2
+ let defu = require("defu");
3
+ defu = require_chunk.__toESM(defu);
4
+ let ts_morph = require("ts-morph");
5
+
6
+ //#region src/typescript/ts-morph.ts
7
+ var VirtualFileSystemHost = class extends ts_morph.InMemoryFileSystemHost {
8
+ #context;
9
+ constructor(context) {
10
+ super();
11
+ this.#context = context;
12
+ }
13
+ deleteSync(path) {
14
+ this.#context.fs.removeSync(path);
15
+ }
16
+ readDirSync(dirPath) {
17
+ if (!this.#context.fs.isDirectorySync(dirPath)) return [];
18
+ return this.#context.fs.listSync(dirPath).reduce((ret, entry) => {
19
+ const fullPath = this.#context.fs.resolveSync(entry);
20
+ if (fullPath) ret.push({
21
+ name: entry,
22
+ isDirectory: this.#context.fs.isDirectorySync(fullPath),
23
+ isFile: this.#context.fs.isFileSync(fullPath),
24
+ isSymlink: false
25
+ });
26
+ return ret;
27
+ }, []);
28
+ }
29
+ async readFile(filePath) {
30
+ if (!this.#context.fs.isFileSync(filePath)) return "";
31
+ return await this.#context.fs.read(filePath);
32
+ }
33
+ readFileSync(filePath) {
34
+ if (!this.#context.fs.isFileSync(filePath)) return "";
35
+ return this.#context.fs.readSync(filePath);
36
+ }
37
+ async writeFile(filePath, fileText) {
38
+ return this.#context.fs.write(filePath, fileText);
39
+ }
40
+ writeFileSync(filePath, fileText) {
41
+ this.#context.fs.writeSync(filePath, fileText);
42
+ }
43
+ async mkdir(dirPath) {
44
+ await this.#context.fs.mkdir(dirPath);
45
+ }
46
+ mkdirSync(dirPath) {
47
+ this.#context.fs.mkdirSync(dirPath);
48
+ }
49
+ async move(srcPath, destPath) {
50
+ await this.#context.fs.move(srcPath, destPath);
51
+ }
52
+ moveSync(srcPath, destPath) {
53
+ this.#context.fs.moveSync(srcPath, destPath);
54
+ }
55
+ async copy(srcPath, destPath) {
56
+ await this.#context.fs.copy(srcPath, destPath);
57
+ }
58
+ copySync(srcPath, destPath) {
59
+ this.#context.fs.copySync(srcPath, destPath);
60
+ }
61
+ async fileExists(filePath) {
62
+ return this.#context.fs.isFile(filePath);
63
+ }
64
+ fileExistsSync(filePath) {
65
+ return this.#context.fs.isFileSync(filePath);
66
+ }
67
+ async directoryExists(dirPath) {
68
+ return this.#context.fs.isDirectory(dirPath);
69
+ }
70
+ directoryExistsSync(dirPath) {
71
+ return this.#context.fs.isDirectorySync(dirPath);
72
+ }
73
+ realpathSync(path) {
74
+ return this.#context.fs.resolveSync(path) || path;
75
+ }
76
+ getCurrentDirectory() {
77
+ return this.#context.workspaceConfig.workspaceRoot;
78
+ }
79
+ async glob(patterns) {
80
+ return this.#context.fs.glob(patterns);
81
+ }
82
+ globSync(patterns) {
83
+ return this.#context.fs.globSync(patterns);
84
+ }
85
+ };
86
+ /**
87
+ * Create a ts-morph {@link Project} instance used for type reflection and module manipulation during processing
88
+ *
89
+ * @param context - The Powerlines context
90
+ * @returns A ts-morph {@link Project} instance
91
+ */
92
+ function createProgram(context, override) {
93
+ context.debug(`Creating ts-morph Project instance with configuration from: ${context.tsconfig.tsconfigFilePath}.`);
94
+ return new ts_morph.Project((0, defu.default)(override ?? {}, {
95
+ skipAddingFilesFromTsConfig: false,
96
+ tsConfigFilePath: context.tsconfig.tsconfigFilePath,
97
+ fileSystem: new VirtualFileSystemHost(context),
98
+ compilerOptions: (0, defu.default)(context.tsconfig.options ?? {}, { lib: ["lib.esnext.full.d.ts"] })
99
+ }));
100
+ }
101
+
102
+ //#endregion
103
+ Object.defineProperty(exports, 'VirtualFileSystemHost', {
104
+ enumerable: true,
105
+ get: function () {
106
+ return VirtualFileSystemHost;
107
+ }
108
+ });
109
+ Object.defineProperty(exports, 'createProgram', {
110
+ enumerable: true,
111
+ get: function () {
112
+ return createProgram;
113
+ }
114
+ });
115
+ //# sourceMappingURL=ts-morph-Cf4wz3E0.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ts-morph-Cf4wz3E0.cjs","names":["InMemoryFileSystemHost","#context","Project"],"sources":["../src/typescript/ts-morph.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 type { Context } from \"@powerlines/core\";\nimport defu from \"defu\";\nimport {\n CompilerOptions,\n FileSystemHost,\n InMemoryFileSystemHost,\n Project,\n ProjectOptions,\n RuntimeDirEntry\n} from \"ts-morph\";\n\nexport class VirtualFileSystemHost\n extends InMemoryFileSystemHost\n implements FileSystemHost\n{\n #context: Context;\n\n public constructor(context: Context) {\n super();\n\n this.#context = context;\n }\n\n public override deleteSync(path: string) {\n this.#context.fs.removeSync(path);\n }\n\n public override readDirSync(dirPath: string): RuntimeDirEntry[] {\n if (!this.#context.fs.isDirectorySync(dirPath)) {\n return [];\n }\n\n return this.#context.fs.listSync(dirPath).reduce((ret, entry) => {\n const fullPath = this.#context.fs.resolveSync(entry);\n if (fullPath) {\n ret.push({\n name: entry,\n isDirectory: this.#context.fs.isDirectorySync(fullPath),\n isFile: this.#context.fs.isFileSync(fullPath),\n isSymlink: false\n });\n }\n\n return ret;\n }, [] as RuntimeDirEntry[]);\n }\n\n public override async readFile(filePath: string) {\n if (!this.#context.fs.isFileSync(filePath)) {\n return \"\";\n }\n\n return (await this.#context.fs.read(filePath))!;\n }\n\n public override readFileSync(filePath: string) {\n if (!this.#context.fs.isFileSync(filePath)) {\n return \"\";\n }\n\n return this.#context.fs.readSync(filePath)!;\n }\n\n public override async writeFile(filePath: string, fileText: string) {\n return this.#context.fs.write(filePath, fileText);\n }\n\n public override writeFileSync(filePath: string, fileText: string) {\n this.#context.fs.writeSync(filePath, fileText);\n }\n\n public override async mkdir(dirPath: string) {\n await this.#context.fs.mkdir(dirPath);\n }\n\n public override mkdirSync(dirPath: string) {\n this.#context.fs.mkdirSync(dirPath);\n }\n\n public override async move(srcPath: string, destPath: string) {\n await this.#context.fs.move(srcPath, destPath);\n }\n\n public override moveSync(srcPath: string, destPath: string) {\n this.#context.fs.moveSync(srcPath, destPath);\n }\n\n public override async copy(srcPath: string, destPath: string) {\n await this.#context.fs.copy(srcPath, destPath);\n }\n\n public override copySync(srcPath: string, destPath: string) {\n this.#context.fs.copySync(srcPath, destPath);\n }\n\n public override async fileExists(filePath: string) {\n return this.#context.fs.isFile(filePath);\n }\n\n public override fileExistsSync(filePath: string) {\n return this.#context.fs.isFileSync(filePath);\n }\n\n public override async directoryExists(dirPath: string) {\n return this.#context.fs.isDirectory(dirPath);\n }\n\n public override directoryExistsSync(dirPath: string): boolean {\n return this.#context.fs.isDirectorySync(dirPath);\n }\n\n public override realpathSync(path: string) {\n return this.#context.fs.resolveSync(path) || path;\n }\n\n public override getCurrentDirectory() {\n return this.#context.workspaceConfig.workspaceRoot;\n }\n\n public override async glob(\n patterns: ReadonlyArray<string>\n ): Promise<string[]> {\n return this.#context.fs.glob(patterns as string[]);\n }\n\n public override globSync(patterns: ReadonlyArray<string>): string[] {\n return this.#context.fs.globSync(patterns as string[]);\n }\n}\n\n/**\n * Create a ts-morph {@link Project} instance used for type reflection and module manipulation during processing\n *\n * @param context - The Powerlines context\n * @returns A ts-morph {@link Project} instance\n */\nexport function createProgram(\n context: Context,\n override: Partial<ProjectOptions>\n): Project {\n context.debug(\n `Creating ts-morph Project instance with configuration from: ${\n context.tsconfig.tsconfigFilePath\n }.`\n );\n\n const project = new Project(\n defu(override ?? {}, {\n skipAddingFilesFromTsConfig: false,\n tsConfigFilePath: context.tsconfig.tsconfigFilePath,\n fileSystem: new VirtualFileSystemHost(context),\n compilerOptions: defu(context.tsconfig.options ?? {}, {\n lib: [\"lib.esnext.full.d.ts\"]\n }) as CompilerOptions\n })\n );\n\n return project;\n}\n"],"mappings":";;;;;;AA6BA,IAAa,wBAAb,cACUA,gCAEV;CACE;CAEA,AAAO,YAAY,SAAkB;AACnC,SAAO;AAEP,QAAKC,UAAW;;CAGlB,AAAgB,WAAW,MAAc;AACvC,QAAKA,QAAS,GAAG,WAAW,KAAK;;CAGnC,AAAgB,YAAY,SAAoC;AAC9D,MAAI,CAAC,MAAKA,QAAS,GAAG,gBAAgB,QAAQ,CAC5C,QAAO,EAAE;AAGX,SAAO,MAAKA,QAAS,GAAG,SAAS,QAAQ,CAAC,QAAQ,KAAK,UAAU;GAC/D,MAAM,WAAW,MAAKA,QAAS,GAAG,YAAY,MAAM;AACpD,OAAI,SACF,KAAI,KAAK;IACP,MAAM;IACN,aAAa,MAAKA,QAAS,GAAG,gBAAgB,SAAS;IACvD,QAAQ,MAAKA,QAAS,GAAG,WAAW,SAAS;IAC7C,WAAW;IACZ,CAAC;AAGJ,UAAO;KACN,EAAE,CAAsB;;CAG7B,MAAsB,SAAS,UAAkB;AAC/C,MAAI,CAAC,MAAKA,QAAS,GAAG,WAAW,SAAS,CACxC,QAAO;AAGT,SAAQ,MAAM,MAAKA,QAAS,GAAG,KAAK,SAAS;;CAG/C,AAAgB,aAAa,UAAkB;AAC7C,MAAI,CAAC,MAAKA,QAAS,GAAG,WAAW,SAAS,CACxC,QAAO;AAGT,SAAO,MAAKA,QAAS,GAAG,SAAS,SAAS;;CAG5C,MAAsB,UAAU,UAAkB,UAAkB;AAClE,SAAO,MAAKA,QAAS,GAAG,MAAM,UAAU,SAAS;;CAGnD,AAAgB,cAAc,UAAkB,UAAkB;AAChE,QAAKA,QAAS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7B,kBAAkB,QAAQ,SAAS;EACnC,YAAY,IAAI,sBAAsB,QAAQ;EAC9C,mCAAsB,QAAQ,SAAS,WAAW,EAAE,EAAE,EACpD,KAAK,CAAC,uBAAuB,EAC9B,CAAC;EACH,CAAC,CACH"}
@@ -4,108 +4,10 @@ let _stryke_path_append = require("@stryke/path/append");
4
4
  let _stryke_path_join_paths = require("@stryke/path/join-paths");
5
5
  let defu = require("defu");
6
6
  defu = require_chunk.__toESM(defu);
7
- let ts_morph = require("ts-morph");
8
7
  let _stryke_fs_json = require("@stryke/fs/json");
9
8
  let typescript = require("typescript");
10
9
  typescript = require_chunk.__toESM(typescript);
11
10
 
12
- //#region src/typescript/ts-morph.ts
13
- var VirtualFileSystemHost = class extends ts_morph.InMemoryFileSystemHost {
14
- #context;
15
- constructor(context) {
16
- super();
17
- this.#context = context;
18
- }
19
- deleteSync(path) {
20
- this.#context.fs.removeSync(path);
21
- }
22
- readDirSync(dirPath) {
23
- if (!this.#context.fs.isDirectorySync(dirPath)) return [];
24
- return this.#context.fs.listSync(dirPath).reduce((ret, entry) => {
25
- const fullPath = this.#context.fs.resolveSync(entry);
26
- if (fullPath) ret.push({
27
- name: entry,
28
- isDirectory: this.#context.fs.isDirectorySync(fullPath),
29
- isFile: this.#context.fs.isFileSync(fullPath),
30
- isSymlink: false
31
- });
32
- return ret;
33
- }, []);
34
- }
35
- async readFile(filePath) {
36
- if (!this.#context.fs.isFileSync(filePath)) return "";
37
- return await this.#context.fs.read(filePath);
38
- }
39
- readFileSync(filePath) {
40
- if (!this.#context.fs.isFileSync(filePath)) return "";
41
- return this.#context.fs.readSync(filePath);
42
- }
43
- async writeFile(filePath, fileText) {
44
- return this.#context.fs.write(filePath, fileText);
45
- }
46
- writeFileSync(filePath, fileText) {
47
- this.#context.fs.writeSync(filePath, fileText);
48
- }
49
- async mkdir(dirPath) {
50
- await this.#context.fs.mkdir(dirPath);
51
- }
52
- mkdirSync(dirPath) {
53
- this.#context.fs.mkdirSync(dirPath);
54
- }
55
- async move(srcPath, destPath) {
56
- await this.#context.fs.move(srcPath, destPath);
57
- }
58
- moveSync(srcPath, destPath) {
59
- this.#context.fs.moveSync(srcPath, destPath);
60
- }
61
- async copy(srcPath, destPath) {
62
- await this.#context.fs.copy(srcPath, destPath);
63
- }
64
- copySync(srcPath, destPath) {
65
- this.#context.fs.copySync(srcPath, destPath);
66
- }
67
- async fileExists(filePath) {
68
- return this.#context.fs.isFile(filePath);
69
- }
70
- fileExistsSync(filePath) {
71
- return this.#context.fs.isFileSync(filePath);
72
- }
73
- async directoryExists(dirPath) {
74
- return this.#context.fs.isDirectory(dirPath);
75
- }
76
- directoryExistsSync(dirPath) {
77
- return this.#context.fs.isDirectorySync(dirPath);
78
- }
79
- realpathSync(path) {
80
- return this.#context.fs.resolveSync(path) || path;
81
- }
82
- getCurrentDirectory() {
83
- return this.#context.workspaceConfig.workspaceRoot;
84
- }
85
- async glob(patterns) {
86
- return this.#context.fs.glob(patterns);
87
- }
88
- globSync(patterns) {
89
- return this.#context.fs.globSync(patterns);
90
- }
91
- };
92
- /**
93
- * Create a ts-morph {@link Project} instance used for type reflection and module manipulation during processing
94
- *
95
- * @param context - The Powerlines context
96
- * @returns A ts-morph {@link Project} instance
97
- */
98
- function createProgram(context, override) {
99
- context.debug(`Creating ts-morph Project instance with configuration from: ${context.tsconfig.tsconfigFilePath}.`);
100
- return new ts_morph.Project((0, defu.default)(override ?? {}, {
101
- skipAddingFilesFromTsConfig: false,
102
- tsConfigFilePath: context.tsconfig.tsconfigFilePath,
103
- fileSystem: new VirtualFileSystemHost(context),
104
- compilerOptions: (0, defu.default)(context.tsconfig.options ?? {}, { lib: ["lib.esnext.full.d.ts"] })
105
- }));
106
- }
107
-
108
- //#endregion
109
11
  //#region src/typescript/tsconfig.ts
110
12
  /**
111
13
  * Get the path to the tsconfig.json file.
@@ -252,18 +154,6 @@ ${parsedCommandLine.errors.map((error) => `- ${(error.category !== void 0 && err
252
154
  }
253
155
 
254
156
  //#endregion
255
- Object.defineProperty(exports, 'VirtualFileSystemHost', {
256
- enumerable: true,
257
- get: function () {
258
- return VirtualFileSystemHost;
259
- }
260
- });
261
- Object.defineProperty(exports, 'createProgram', {
262
- enumerable: true,
263
- get: function () {
264
- return createProgram;
265
- }
266
- });
267
157
  Object.defineProperty(exports, 'findIncludeMatch', {
268
158
  enumerable: true,
269
159
  get: function () {
@@ -306,4 +196,4 @@ Object.defineProperty(exports, 'tryTsconfigFilePath', {
306
196
  return tryTsconfigFilePath;
307
197
  }
308
198
  });
309
- //# sourceMappingURL=tsconfig-BC3TZxD4.cjs.map
199
+ //# sourceMappingURL=tsconfig-ChmbpAO7.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tsconfig-ChmbpAO7.cjs","names":["ts"],"sources":["../src/typescript/tsconfig.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 type { ParsedTypeScriptConfig, TSConfig } from \"@powerlines/core\";\nimport { existsSync } from \"@stryke/fs/exists\";\nimport { readJsonFileSync } from \"@stryke/fs/json\";\nimport { appendPath } from \"@stryke/path/append\";\nimport { joinPaths } from \"@stryke/path/join-paths\";\nimport { FilterPattern } from \"@stryke/types/file\";\nimport { TsConfigJson } from \"@stryke/types/tsconfig\";\nimport defu from \"defu\";\nimport ts from \"typescript\";\n\n/**\n * Get the path to the tsconfig.json file.\n *\n * @param workspaceRoot - The root directory of the workspace.\n * @param projectRoot - The root directory of the project.\n * @param tsconfig - The path to the tsconfig.json file.\n * @returns The absolute path to the tsconfig.json file.\n * @throws If the tsconfig.json file does not exist.\n */\nexport function getTsconfigFilePath(\n workspaceRoot: string,\n projectRoot: string,\n tsconfig?: string\n): string {\n let tsconfigFilePath: string | undefined;\n if (tsconfig) {\n tsconfigFilePath = tryTsconfigFilePath(\n workspaceRoot,\n projectRoot,\n tsconfig\n );\n } else {\n tsconfigFilePath = tryTsconfigFilePath(\n workspaceRoot,\n projectRoot,\n \"tsconfig.app.json\"\n );\n if (!tsconfigFilePath) {\n tsconfigFilePath = tryTsconfigFilePath(\n workspaceRoot,\n projectRoot,\n \"tsconfig.lib.json\"\n );\n if (!tsconfigFilePath) {\n tsconfigFilePath = tryTsconfigFilePath(\n workspaceRoot,\n projectRoot,\n \"tsconfig.json\"\n );\n }\n }\n }\n\n if (!tsconfigFilePath) {\n throw new Error(\n `Cannot find the \\`tsconfig.json\\` configuration file for the project at ${\n projectRoot\n }.`\n );\n }\n\n return tsconfigFilePath;\n}\n\n/**\n * Get the path to the tsconfig.json file.\n *\n * @param workspaceRoot - The root directory of the workspace.\n * @param projectRoot - The root directory of the project.\n * @param tsconfig - The path to the tsconfig.json file.\n * @returns The absolute path to the tsconfig.json file.\n * @throws If the tsconfig.json file does not exist.\n */\nexport function tryTsconfigFilePath(\n workspaceRoot: string,\n projectRoot: string,\n tsconfig: string\n): string | undefined {\n let tsconfigFilePath = tsconfig;\n if (!existsSync(tsconfigFilePath)) {\n tsconfigFilePath = appendPath(tsconfig, projectRoot);\n if (!existsSync(tsconfigFilePath)) {\n tsconfigFilePath = appendPath(\n tsconfig,\n appendPath(projectRoot, workspaceRoot)\n );\n if (!existsSync(tsconfigFilePath)) {\n return undefined;\n }\n }\n }\n\n return tsconfigFilePath;\n}\n\n/**\n * Check if the TypeScript configuration type matches any of the provided types.\n *\n * @param tsconfigType - The type from the TypeScript configuration.\n * @param types - An array of type names to check against.\n * @returns True if the TypeScript configuration type matches any of the provided types, false otherwise.\n */\nexport function findMatch(\n tsconfigType: string | RegExp | null,\n types: (string | RegExp | null)[],\n extensions: string[] = [\".ts\", \".tsx\", \".d.ts\"]\n): string | RegExp | null | undefined {\n return types.find(\n type =>\n tsconfigType?.toString().toLowerCase() ===\n type?.toString().toLowerCase() ||\n tsconfigType?.toString().toLowerCase() ===\n `./${type?.toString().toLowerCase()}` ||\n `./${tsconfigType?.toString().toLowerCase()}` ===\n type?.toString().toLowerCase() ||\n extensions.some(\n ext =>\n `${tsconfigType?.toString().toLowerCase()}${ext}` ===\n type?.toString().toLowerCase() ||\n `${tsconfigType?.toString().toLowerCase()}${ext}` ===\n `./${type?.toString().toLowerCase()}` ||\n `${type?.toString().toLowerCase()}${ext}` ===\n `./${tsconfigType?.toString().toLowerCase()}` ||\n tsconfigType?.toString().toLowerCase() ===\n `${type?.toString().toLowerCase()}${ext}` ||\n tsconfigType?.toString().toLowerCase() ===\n `./${type?.toString().toLowerCase()}${ext}` ||\n type?.toString().toLowerCase() ===\n `./${tsconfigType?.toString().toLowerCase()}${ext}`\n )\n );\n}\n\n/**\n * Check if the TypeScript configuration type matches any of the provided types.\n *\n * @param tsconfigType - The type from the TypeScript configuration.\n * @param types - An array of type names to check against.\n * @returns True if the TypeScript configuration type matches any of the provided types, false otherwise.\n */\nexport function findIncludeMatch(\n tsconfigType: string | RegExp | null,\n types: (string | RegExp | null)[]\n): string | RegExp | null | undefined {\n return findMatch(tsconfigType, types, [\n \".ts\",\n \".tsx\",\n \".d.ts\",\n \".js\",\n \".jsx\",\n \".mjs\",\n \".cjs\",\n \".mts\",\n \".cts\",\n \"/*.ts\",\n \"/*.tsx\",\n \"/*.d.ts\",\n \"/*.js\",\n \"/*.jsx\",\n \"/*.mjs\",\n \"/*.cjs\",\n \"/*.mts\",\n \"/*.cts\",\n \"/**/*.ts\",\n \"/**/*.tsx\",\n \"/**/*.d.ts\",\n \"/**/*.js\",\n \"/**/*.jsx\",\n \"/**/*.mjs\",\n \"/**/*.cjs\",\n \"/**/*.mts\",\n \"/**/*.cts\"\n ]);\n}\n\n/**\n * Check if the TypeScript configuration type matches any of the provided types.\n *\n * @param tsconfigType - The type from the TypeScript configuration.\n * @param types - An array of type names to check against.\n * @returns True if the TypeScript configuration type matches any of the provided types, false otherwise.\n */\nexport function isMatchFound(\n tsconfigType: string | RegExp | null,\n types: (string | RegExp | null)[]\n): boolean {\n return findMatch(tsconfigType, types) !== undefined;\n}\n\n/**\n * Check if the TypeScript configuration type matches any of the provided types.\n *\n * @param tsconfigType - The type from the TypeScript configuration.\n * @param types - An array of type names to check against.\n * @returns True if the TypeScript configuration type matches any of the provided types, false otherwise.\n */\nexport function isIncludeMatchFound(\n tsconfigType: FilterPattern,\n types: FilterPattern[]\n): boolean {\n return (\n findIncludeMatch(\n tsconfigType as string | RegExp | null,\n types as (string | RegExp | null)[]\n ) !== undefined\n );\n}\n\n/**\n * Get the parsed TypeScript configuration.\n *\n * @param workspaceRoot - The root directory of the workspace.\n * @param projectRoot - The root directory of the project.\n * @param tsconfig - The path to the tsconfig.json file.\n * @param tsconfigRaw - The raw tsconfig.json content.\n * @param originalTsconfigJson - The original tsconfig.json content.\n * @param host - The TypeScript parse config host.\n * @returns The resolved TypeScript configuration.\n */\nexport function getParsedTypeScriptConfig(\n workspaceRoot: string,\n projectRoot: string,\n tsconfig?: string,\n tsconfigRaw: TSConfig = {},\n originalTsconfigJson?: TSConfig,\n host: ts.ParseConfigHost = ts.sys\n): ParsedTypeScriptConfig {\n const tsconfigFilePath = getTsconfigFilePath(\n workspaceRoot,\n projectRoot,\n tsconfig\n );\n const tsconfigJson = readJsonFileSync<TSConfig>(tsconfigFilePath);\n if (!tsconfigJson) {\n throw new Error(\n `Cannot find the \\`tsconfig.json\\` configuration file at ${joinPaths(\n projectRoot,\n tsconfig ?? \"tsconfig.json\"\n )}`\n );\n }\n\n const parsedCommandLine = ts.parseJsonConfigFileContent(\n defu(tsconfigRaw ?? {}, tsconfigJson),\n host,\n appendPath(projectRoot, workspaceRoot)\n );\n if (parsedCommandLine.errors.length > 0) {\n const errorMessage = `Cannot parse the TypeScript compiler options. Please investigate the following issues:\n${parsedCommandLine.errors\n .map(\n error =>\n `- ${\n (error.category !== undefined && error.code\n ? `[${error.category}-${error.code}]: `\n : \"\") + error.messageText.toString()\n }`\n )\n .join(\"\\n\")}\n `;\n\n throw new Error(errorMessage);\n }\n\n return {\n ...parsedCommandLine,\n originalTsconfigJson: (originalTsconfigJson ??\n tsconfigJson) as TsConfigJson,\n tsconfigJson,\n tsconfigFilePath\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAqCA,SAAgB,oBACd,eACA,aACA,UACQ;CACR,IAAI;AACJ,KAAI,SACF,oBAAmB,oBACjB,eACA,aACA,SACD;MACI;AACL,qBAAmB,oBACjB,eACA,aACA,oBACD;AACD,MAAI,CAAC,kBAAkB;AACrB,sBAAmB,oBACjB,eACA,aACA,oBACD;AACD,OAAI,CAAC,iBACH,oBAAmB,oBACjB,eACA,aACA,gBACD;;;AAKP,KAAI,CAAC,iBACH,OAAM,IAAI,MACR,2EACE,YACD,GACF;AAGH,QAAO;;;;;;;;;;;AAYT,SAAgB,oBACd,eACA,aACA,UACoB;CACpB,IAAI,mBAAmB;AACvB,KAAI,mCAAY,iBAAiB,EAAE;AACjC,yDAA8B,UAAU,YAAY;AACpD,MAAI,mCAAY,iBAAiB,EAAE;AACjC,0DACE,8CACW,aAAa,cAAc,CACvC;AACD,OAAI,mCAAY,iBAAiB,CAC/B;;;AAKN,QAAO;;;;;;;;;AAUT,SAAgB,UACd,cACA,OACA,aAAuB;CAAC;CAAO;CAAQ;CAAQ,EACX;AACpC,QAAO,MAAM,MACX,SACE,cAAc,UAAU,CAAC,aAAa,KACpC,MAAM,UAAU,CAAC,aAAa,IAChC,cAAc,UAAU,CAAC,aAAa,KACpC,KAAK,MAAM,UAAU,CAAC,aAAa,MACrC,KAAK,cAAc,UAAU,CAAC,aAAa,OACzC,MAAM,UAAU,CAAC,aAAa,IAChC,WAAW,MACT,QACE,GAAG,cAAc,UAAU,CAAC,aA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I,MAAM,SAAS,GAAG,MAAM,KAAK,OACjC,MAAM,MAAM,YAAY,UAAU,GAE3C,CACA,KAAK,KAAK,CAAC;;AAGV,QAAM,IAAI,MAAM,aAAa;;AAG/B,QAAO;EACL,GAAG;EACH,sBAAuB,wBACrB;EACF;EACA;EACD"}
@@ -2,107 +2,9 @@ import { existsSync } from "@stryke/fs/exists";
2
2
  import { appendPath } from "@stryke/path/append";
3
3
  import { joinPaths } from "@stryke/path/join-paths";
4
4
  import defu$1 from "defu";
5
- import { InMemoryFileSystemHost, Project } from "ts-morph";
6
5
  import { readJsonFileSync } from "@stryke/fs/json";
7
6
  import ts from "typescript";
8
7
 
9
- //#region src/typescript/ts-morph.ts
10
- var VirtualFileSystemHost = class extends InMemoryFileSystemHost {
11
- #context;
12
- constructor(context) {
13
- super();
14
- this.#context = context;
15
- }
16
- deleteSync(path) {
17
- this.#context.fs.removeSync(path);
18
- }
19
- readDirSync(dirPath) {
20
- if (!this.#context.fs.isDirectorySync(dirPath)) return [];
21
- return this.#context.fs.listSync(dirPath).reduce((ret, entry) => {
22
- const fullPath = this.#context.fs.resolveSync(entry);
23
- if (fullPath) ret.push({
24
- name: entry,
25
- isDirectory: this.#context.fs.isDirectorySync(fullPath),
26
- isFile: this.#context.fs.isFileSync(fullPath),
27
- isSymlink: false
28
- });
29
- return ret;
30
- }, []);
31
- }
32
- async readFile(filePath) {
33
- if (!this.#context.fs.isFileSync(filePath)) return "";
34
- return await this.#context.fs.read(filePath);
35
- }
36
- readFileSync(filePath) {
37
- if (!this.#context.fs.isFileSync(filePath)) return "";
38
- return this.#context.fs.readSync(filePath);
39
- }
40
- async writeFile(filePath, fileText) {
41
- return this.#context.fs.write(filePath, fileText);
42
- }
43
- writeFileSync(filePath, fileText) {
44
- this.#context.fs.writeSync(filePath, fileText);
45
- }
46
- async mkdir(dirPath) {
47
- await this.#context.fs.mkdir(dirPath);
48
- }
49
- mkdirSync(dirPath) {
50
- this.#context.fs.mkdirSync(dirPath);
51
- }
52
- async move(srcPath, destPath) {
53
- await this.#context.fs.move(srcPath, destPath);
54
- }
55
- moveSync(srcPath, destPath) {
56
- this.#context.fs.moveSync(srcPath, destPath);
57
- }
58
- async copy(srcPath, destPath) {
59
- await this.#context.fs.copy(srcPath, destPath);
60
- }
61
- copySync(srcPath, destPath) {
62
- this.#context.fs.copySync(srcPath, destPath);
63
- }
64
- async fileExists(filePath) {
65
- return this.#context.fs.isFile(filePath);
66
- }
67
- fileExistsSync(filePath) {
68
- return this.#context.fs.isFileSync(filePath);
69
- }
70
- async directoryExists(dirPath) {
71
- return this.#context.fs.isDirectory(dirPath);
72
- }
73
- directoryExistsSync(dirPath) {
74
- return this.#context.fs.isDirectorySync(dirPath);
75
- }
76
- realpathSync(path) {
77
- return this.#context.fs.resolveSync(path) || path;
78
- }
79
- getCurrentDirectory() {
80
- return this.#context.workspaceConfig.workspaceRoot;
81
- }
82
- async glob(patterns) {
83
- return this.#context.fs.glob(patterns);
84
- }
85
- globSync(patterns) {
86
- return this.#context.fs.globSync(patterns);
87
- }
88
- };
89
- /**
90
- * Create a ts-morph {@link Project} instance used for type reflection and module manipulation during processing
91
- *
92
- * @param context - The Powerlines context
93
- * @returns A ts-morph {@link Project} instance
94
- */
95
- function createProgram(context, override) {
96
- context.debug(`Creating ts-morph Project instance with configuration from: ${context.tsconfig.tsconfigFilePath}.`);
97
- return new Project(defu$1(override ?? {}, {
98
- skipAddingFilesFromTsConfig: false,
99
- tsConfigFilePath: context.tsconfig.tsconfigFilePath,
100
- fileSystem: new VirtualFileSystemHost(context),
101
- compilerOptions: defu$1(context.tsconfig.options ?? {}, { lib: ["lib.esnext.full.d.ts"] })
102
- }));
103
- }
104
-
105
- //#endregion
106
8
  //#region src/typescript/tsconfig.ts
107
9
  /**
108
10
  * Get the path to the tsconfig.json file.
@@ -249,5 +151,5 @@ ${parsedCommandLine.errors.map((error) => `- ${(error.category !== void 0 && err
249
151
  }
250
152
 
251
153
  //#endregion
252
- export { isIncludeMatchFound as a, VirtualFileSystemHost as c, getTsconfigFilePath as i, createProgram as l, findMatch as n, isMatchFound as o, getParsedTypeScriptConfig as r, tryTsconfigFilePath as s, findIncludeMatch as t };
253
- //# sourceMappingURL=tsconfig-CXwGIrfR.mjs.map
154
+ export { isIncludeMatchFound as a, getTsconfigFilePath as i, findMatch as n, isMatchFound as o, getParsedTypeScriptConfig as r, tryTsconfigFilePath as s, findIncludeMatch as t };
155
+ //# sourceMappingURL=tsconfig-DoV1dUYg.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tsconfig-DoV1dUYg.mjs","names":["defu"],"sources":["../src/typescript/tsconfig.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 type { ParsedTypeScriptConfig, TSConfig } from \"@powerlines/core\";\nimport { existsSync } from \"@stryke/fs/exists\";\nimport { readJsonFileSync } from \"@stryke/fs/json\";\nimport { appendPath } from \"@stryke/path/append\";\nimport { joinPaths } from \"@stryke/path/join-paths\";\nimport { FilterPattern } from \"@stryke/types/file\";\nimport { TsConfigJson } from \"@stryke/types/tsconfig\";\nimport defu from \"defu\";\nimport ts from \"typescript\";\n\n/**\n * Get the path to the tsconfig.json file.\n *\n * @param workspaceRoot - The root directory of the workspace.\n * @param projectRoot - The root directory of the project.\n * @param tsconfig - The path to the tsconfig.json file.\n * @returns The absolute path to the tsconfig.json file.\n * @throws If the tsconfig.json file does not exist.\n */\nexport function getTsconfigFilePath(\n workspaceRoot: string,\n projectRoot: string,\n tsconfig?: string\n): string {\n let tsconfigFilePath: string | undefined;\n if (tsconfig) {\n tsconfigFilePath = tryTsconfigFilePath(\n workspaceRoot,\n projectRoot,\n tsconfig\n );\n } else {\n tsconfigFilePath = tryTsconfigFilePath(\n workspaceRoot,\n projectRoot,\n \"tsconfig.app.json\"\n );\n if (!tsconfigFilePath) {\n tsconfigFilePath = tryTsconfigFilePath(\n workspaceRoot,\n projectRoot,\n \"tsconfig.lib.json\"\n );\n if (!tsconfigFilePath) {\n tsconfigFilePath = tryTsconfigFilePath(\n workspaceRoot,\n projectRoot,\n \"tsconfig.json\"\n );\n }\n }\n }\n\n if (!tsconfigFilePath) {\n throw new Error(\n `Cannot find the \\`tsconfig.json\\` configuration file for the project at ${\n projectRoot\n }.`\n );\n }\n\n return tsconfigFilePath;\n}\n\n/**\n * Get the path to the tsconfig.json file.\n *\n * @param workspaceRoot - The root directory of the workspace.\n * @param projectRoot - The root directory of the project.\n * @param tsconfig - The path to the tsconfig.json file.\n * @returns The absolute path to the tsconfig.json file.\n * @throws If the tsconfig.json file does not exist.\n */\nexport function tryTsconfigFilePath(\n workspaceRoot: string,\n projectRoot: string,\n tsconfig: string\n): string | undefined {\n let tsconfigFilePath = tsconfig;\n if (!existsSync(tsconfigFilePath)) {\n tsconfigFilePath = appendPath(tsconfig, projectRoot);\n if (!existsSync(tsconfigFilePath)) {\n tsconfigFilePath = appendPath(\n tsconfig,\n appendPath(projectRoot, workspaceRoot)\n );\n if (!existsSync(tsconfigFilePath)) {\n return undefined;\n }\n }\n }\n\n return tsconfigFilePath;\n}\n\n/**\n * Check if the TypeScript configuration type matches any of the provided types.\n *\n * @param tsconfigType - The type from the TypeScript configuration.\n * @param types - An array of type names to check against.\n * @returns True if the TypeScript configuration type matches any of the provided types, false otherwise.\n */\nexport function findMatch(\n tsconfigType: string | RegExp | null,\n types: (string | RegExp | null)[],\n extensions: string[] = [\".ts\", \".tsx\", \".d.ts\"]\n): string | RegExp | null | undefined {\n return types.find(\n type =>\n tsconfigType?.toString().toLowerCase() ===\n type?.toString().toLowerCase() ||\n tsconfigType?.toString().toLowerCase() ===\n `./${type?.toString().toLowerCase()}` ||\n `./${tsconfigType?.toString().toLowerCase()}` ===\n type?.toString().toLowerCase() ||\n extensions.some(\n ext =>\n `${tsconfigType?.toString().toLowerCase()}${ext}` ===\n type?.toString().toLowerCase() ||\n `${tsconfigType?.toString().toLowerCase()}${ext}` ===\n `./${type?.toString().toLowerCase()}` ||\n `${type?.toString().toLowerCase()}${ext}` ===\n `./${tsconfigType?.toString().toLowerCase()}` ||\n tsconfigType?.toString().toLowerCase() ===\n `${type?.toString().toLowerCase()}${ext}` ||\n tsconfigType?.toString().toLowerCase() ===\n `./${type?.toString().toLowerCase()}${ext}` ||\n type?.toString().toLowerCase() ===\n `./${tsconfigType?.toString().toLowerCase()}${ext}`\n )\n );\n}\n\n/**\n * Check if the TypeScript configuration type matches any of the provided types.\n *\n * @param tsconfigType - The type from the TypeScript configuration.\n * @param types - An array of type names to check against.\n * @returns True if the TypeScript configuration type matches any of the provided types, false otherwise.\n */\nexport function findIncludeMatch(\n tsconfigType: string | RegExp | null,\n types: (string | RegExp | null)[]\n): string | RegExp | null | undefined {\n return findMatch(tsconfigType, types, [\n \".ts\",\n \".tsx\",\n \".d.ts\",\n \".js\",\n \".jsx\",\n \".mjs\",\n \".cjs\",\n \".mts\",\n \".cts\",\n \"/*.ts\",\n \"/*.tsx\",\n \"/*.d.ts\",\n \"/*.js\",\n \"/*.jsx\",\n \"/*.mjs\",\n \"/*.cjs\",\n \"/*.mts\",\n \"/*.cts\",\n \"/**/*.ts\",\n \"/**/*.tsx\",\n \"/**/*.d.ts\",\n \"/**/*.js\",\n \"/**/*.jsx\",\n \"/**/*.mjs\",\n \"/**/*.cjs\",\n \"/**/*.mts\",\n \"/**/*.cts\"\n ]);\n}\n\n/**\n * Check if the TypeScript configuration type matches any of the provided types.\n *\n * @param tsconfigType - The type from the TypeScript configuration.\n * @param types - An array of type names to check against.\n * @returns True if the TypeScript configuration type matches any of the provided types, false otherwise.\n */\nexport function isMatchFound(\n tsconfigType: string | RegExp | null,\n types: (string | RegExp | null)[]\n): boolean {\n return findMatch(tsconfigType, types) !== undefined;\n}\n\n/**\n * Check if the TypeScript configuration type matches any of the provided types.\n *\n * @param tsconfigType - The type from the TypeScript configuration.\n * @param types - An array of type names to check against.\n * @returns True if the TypeScript configuration type matches any of the provided types, false otherwise.\n */\nexport function isIncludeMatchFound(\n tsconfigType: FilterPattern,\n types: FilterPattern[]\n): boolean {\n return (\n findIncludeMatch(\n tsconfigType as string | RegExp | null,\n types as (string | RegExp | null)[]\n ) !== undefined\n );\n}\n\n/**\n * Get the parsed TypeScript configuration.\n *\n * @param workspaceRoot - The root directory of the workspace.\n * @param projectRoot - The root directory of the project.\n * @param tsconfig - The path to the tsconfig.json file.\n * @param tsconfigRaw - The raw tsconfig.json content.\n * @param originalTsconfigJson - The original tsconfig.json content.\n * @param host - The TypeScript parse config host.\n * @returns The resolved TypeScript configuration.\n */\nexport function getParsedTypeScriptConfig(\n workspaceRoot: string,\n projectRoot: string,\n tsconfig?: string,\n tsconfigRaw: TSConfig = {},\n originalTsconfigJson?: TSConfig,\n host: ts.ParseConfigHost = ts.sys\n): ParsedTypeScriptConfig {\n const tsconfigFilePath = getTsconfigFilePath(\n workspaceRoot,\n projectRoot,\n tsconfig\n );\n const tsconfigJson = readJsonFileSync<TSConfig>(tsconfigFilePath);\n if (!tsconfigJson) {\n throw new Error(\n `Cannot find the \\`tsconfig.json\\` configuration file at ${joinPaths(\n projectRoot,\n tsconfig ?? \"tsconfig.json\"\n )}`\n );\n }\n\n const parsedCommandLine = ts.parseJsonConfigFileContent(\n defu(tsconfigRaw ?? {}, tsconfigJson),\n host,\n appendPath(projectRoot, workspaceRoot)\n );\n if (parsedCommandLine.errors.length > 0) {\n const errorMessage = `Cannot parse the TypeScript compiler options. Please investigate the following issues:\n${parsedCommandLine.errors\n .map(\n error =>\n `- ${\n (error.category !== undefined && error.code\n ? `[${error.category}-${error.code}]: `\n : \"\") + error.messageText.toString()\n }`\n )\n .join(\"\\n\")}\n `;\n\n throw new Error(errorMessage);\n }\n\n return {\n ...parsedCommandLine,\n originalTsconfigJson: (originalTsconfigJson ??\n tsconfigJson) as TsConfigJson,\n tsconfigJson,\n tsconfigFilePath\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAqCA,SAAgB,oBACd,eACA,aACA,UACQ;CACR,IAAI;AACJ,KAAI,SACF,oBAAmB,oBACjB,eACA,aACA,SACD;MACI;AACL,qBAAmB,oBACjB,eACA,aACA,oBACD;AACD,MAAI,CAAC,kBAAkB;AACrB,sBAAmB,oBACjB,eACA,aACA,oBACD;AACD,OAAI,CAAC,iBACH,oBAAmB,oBACjB,eACA,aACA,gBACD;;;AAKP,KAAI,CAAC,iBACH,OAAM,IAAI,MACR,2EACE,YACD,GACF;AAGH,QAAO;;;;;;;;;;;AAYT,SAAgB,oBACd,eACA,aACA,UACoB;CACpB,IAAI,mBAAmB;AACvB,KAAI,CAAC,WAAW,iBAAiB,EAAE;AACjC,qBAAmB,WAAW,UAAU,YAAY;AACpD,MAAI,CAAC,WAAW,iBAAiB,EAAE;AACjC,sBAAmB,WACjB,UACA,WAAW,aAAa,cAAc,CACvC;AACD,OAAI,CAAC,WAAW,iBAAiB,CAC/B;;;AAKN,QAAO;;;;;;;;;AAUT,SAAgB,UACd,cACA,OACA,aAAuB;CAAC;CAAO;CAAQ;CAAQ,EACX;AACpC,QAAO,MAAM,MACX,SACE,cAAc,UAAU,CAAC,aAAa,KACpC,MAAM,UAAU,CAAC,aAAa,IAChC,cAAc,UAAU,CAAC,aAAa,KACpC,KAAK,MAAM,UAAU,CAAC,aAAa,MACrC,KAAK,cAAc,UAAU,CAAC,aAAa,OACzC,MAAM,UAAU,CAAC,aAAa,IAChC,WAAW,MACT,QACE,GAAG,cAAc,UAAU,CAAC,aAAa,GAAG,UAC1C,MAAM,UAAU,CAAC,aAAa,IAChC,GAAG,cAAc,UAAU,CAAC,aAAa,GAA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AAU,GAE3C,CACA,KAAK,KAAK,CAAC;;AAGV,QAAM,IAAI,MAAM,aAAa;;AAG/B,QAAO;EACL,GAAG;EACH,sBAAuB,wBACrB;EACF;EACA;EACD"}
@@ -1,4 +1,4 @@
1
1
  import * as import__powerlines_core from "@powerlines/core";
2
2
  //#endregion
3
3
  export { import__powerlines_core as t };
4
- //# sourceMappingURL=types-ro7jWCtL.d.mts.map
4
+ //# sourceMappingURL=types-9O-s0Fpu.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types-9O-s0Fpu.d.mts","names":[],"sources":["../src/types.ts"],"mappings":""}
@@ -1,8 +1,9 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
- const require_tsconfig = require('../tsconfig-BC3TZxD4.cjs');
2
+ const require_ts_morph = require('../ts-morph-Cf4wz3E0.cjs');
3
+ const require_tsconfig = require('../tsconfig-ChmbpAO7.cjs');
3
4
 
4
- exports.VirtualFileSystemHost = require_tsconfig.VirtualFileSystemHost;
5
- exports.createProgram = require_tsconfig.createProgram;
5
+ exports.VirtualFileSystemHost = require_ts_morph.VirtualFileSystemHost;
6
+ exports.createProgram = require_ts_morph.createProgram;
6
7
  exports.findIncludeMatch = require_tsconfig.findIncludeMatch;
7
8
  exports.findMatch = require_tsconfig.findMatch;
8
9
  exports.getParsedTypeScriptConfig = require_tsconfig.getParsedTypeScriptConfig;
@@ -1,3 +1,4 @@
1
- import { a as isIncludeMatchFound, c as VirtualFileSystemHost, i as getTsconfigFilePath, l as createProgram, n as findMatch, o as isMatchFound, r as getParsedTypeScriptConfig, s as tryTsconfigFilePath, t as findIncludeMatch } from "../tsconfig-CXwGIrfR.mjs";
1
+ import { n as createProgram, t as VirtualFileSystemHost } from "../ts-morph-B85ZbV1Q.mjs";
2
+ import { a as isIncludeMatchFound, i as getTsconfigFilePath, n as findMatch, o as isMatchFound, r as getParsedTypeScriptConfig, s as tryTsconfigFilePath, t as findIncludeMatch } from "../tsconfig-DoV1dUYg.mjs";
2
3
 
3
4
  export { VirtualFileSystemHost, createProgram, findIncludeMatch, findMatch, getParsedTypeScriptConfig, getTsconfigFilePath, isIncludeMatchFound, isMatchFound, tryTsconfigFilePath };
package/dist/unloader.cjs CHANGED
@@ -1,6 +1,6 @@
1
1
  Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: 'Module' } });
2
2
  const require_chunk = require('./chunk-AIJqnxB6.cjs');
3
- const require_api = require('./api-CvAosB7E.cjs');
3
+ const require_unplugin = require('./unplugin.cjs');
4
4
  let unplugin = require("unplugin");
5
5
 
6
6
  //#region src/unloader.ts
@@ -18,7 +18,7 @@ let unplugin = require("unplugin");
18
18
  *
19
19
  * ```
20
20
  */
21
- const unloader = (0, unplugin.createUnloaderPlugin)(require_api.createUnpluginFactory("unloader"));
21
+ const unloader = (0, unplugin.createUnloaderPlugin)(require_unplugin.createUnpluginFactory("unloader"));
22
22
 
23
23
  //#endregion
24
24
  exports.default = unloader;
@@ -1 +1 @@
1
- {"version":3,"file":"unloader.cjs","names":["createUnpluginFactory"],"sources":["../src/unloader.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 { createUnloaderPlugin } from \"unplugin\";\nimport { createUnpluginFactory } from \"./unplugin\";\n\n/**\n * An Unloader plugin that will invoke the Powerlines API hooks during processing.\n *\n * @example\n * ```ts\n * // unloader.config.js\n * import powerlines from \"powerlines/unloader\";\n *\n * export default defineConfig({\n * plugins: [powerlines({ name: \"example-app\", ... })],\n * });\n *\n * ```\n */\nexport const unloader = createUnloaderPlugin(createUnpluginFactory(\"unloader\"));\n\nexport default unloader;\nexport { unloader as \"module.exports\" };\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAmCA,MAAa,8CAAgCA,kCAAsB,WAAW,CAAC"}
1
+ {"version":3,"file":"unloader.cjs","names":["createUnpluginFactory"],"sources":["../src/unloader.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 { createUnloaderPlugin } from \"unplugin\";\nimport { createUnpluginFactory } from \"./unplugin\";\n\n/**\n * An Unloader plugin that will invoke the Powerlines API hooks during processing.\n *\n * @example\n * ```ts\n * // unloader.config.js\n * import powerlines from \"powerlines/unloader\";\n *\n * export default defineConfig({\n * plugins: [powerlines({ name: \"example-app\", ... })],\n * });\n *\n * ```\n */\nexport const unloader = createUnloaderPlugin(createUnpluginFactory(\"unloader\"));\n\nexport default unloader;\nexport { unloader as \"module.exports\" };\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAmCA,MAAa,8CAAgCA,uCAAsB,WAAW,CAAC"}
package/dist/unloader.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { a as createUnpluginFactory } from "./api-Dtr_u8iv.mjs";
1
+ import { createUnpluginFactory } from "./unplugin.mjs";
2
2
  import { createUnloaderPlugin } from "unplugin";
3
3
 
4
4
  //#region src/unloader.ts
package/dist/unplugin.cjs CHANGED
@@ -1,7 +1,101 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
- const require_api = require('./api-CvAosB7E.cjs');
2
+ const require_chunk = require('./chunk-AIJqnxB6.cjs');
3
+ const require_api = require('./api-LEq5A1pG.cjs');
4
+ let _stryke_fs_get_workspace_root = require("@stryke/fs/get-workspace-root");
5
+ let _powerlines_core_lib_logger = require("@powerlines/core/lib/logger");
6
+ let _storm_software_config_tools_types = require("@storm-software/config-tools/types");
7
+ let unplugin = require("unplugin");
8
+ let _powerlines_core_lib_utilities_source_file = require("@powerlines/core/lib/utilities/source-file");
3
9
 
4
- exports.createUnpluginFactory = require_api.createUnpluginFactory;
10
+ //#region src/unplugin.ts
11
+ /**
12
+ * Creates a Powerlines unplugin factory that generates a plugin instance.
13
+ *
14
+ * @param variant - The build variant for which to create the unplugin.
15
+ * @param decorate - An optional function to decorate the unplugin options.
16
+ * @returns The unplugin factory that generates a plugin instance.
17
+ */
18
+ function createUnpluginFactory(variant, decorate) {
19
+ return (config, meta) => {
20
+ const log = (0, _powerlines_core_lib_logger.createLog)("unplugin", config);
21
+ log(_storm_software_config_tools_types.LogLevelLabel.DEBUG, "Initializing Unplugin");
22
+ try {
23
+ const userConfig = {
24
+ ...config,
25
+ variant,
26
+ unplugin: meta
27
+ };
28
+ let api;
29
+ async function buildStart() {
30
+ log(_storm_software_config_tools_types.LogLevelLabel.DEBUG, "Powerlines build plugin starting...");
31
+ api = await require_api.PowerlinesAPI.from((0, _stryke_fs_get_workspace_root.getWorkspaceRoot)(process.cwd()), userConfig);
32
+ (0, unplugin.setParseImpl)(api.context.parse);
33
+ log(_storm_software_config_tools_types.LogLevelLabel.DEBUG, "Preparing build artifacts for the Powerlines project...");
34
+ await api.prepare({ command: "build" });
35
+ }
36
+ async function resolveId(id, importer, options = { isEntry: false }) {
37
+ return api.context.resolve(id, importer, options);
38
+ }
39
+ async function load(id) {
40
+ const environment = await api.context.getEnvironment();
41
+ let result = await api.callHook("load", {
42
+ environment,
43
+ order: "pre"
44
+ }, id);
45
+ if (result) return result;
46
+ result = await api.callHook("load", {
47
+ environment,
48
+ order: "normal"
49
+ }, id);
50
+ if (result) return result;
51
+ result = await environment.load(id);
52
+ if (result) return result;
53
+ return api.callHook("load", {
54
+ environment,
55
+ order: "post"
56
+ }, id);
57
+ }
58
+ async function transform(code, id) {
59
+ return api.callHook("transform", {
60
+ environment: await api.context.getEnvironment(),
61
+ result: "merge",
62
+ asNextParam: (previousResult) => (0, _powerlines_core_lib_utilities_source_file.getString)(previousResult)
63
+ }, (0, _powerlines_core_lib_utilities_source_file.getString)(code), id);
64
+ }
65
+ async function writeBundle() {
66
+ log(_storm_software_config_tools_types.LogLevelLabel.DEBUG, "Finalizing Powerlines project output...");
67
+ await api.callHook("writeBundle", { environment: await api.context.getEnvironment() });
68
+ }
69
+ const options = {
70
+ name: "powerlines",
71
+ api,
72
+ resolveId: {
73
+ filter: { id: { include: [/.*/] } },
74
+ handler: resolveId
75
+ },
76
+ load: {
77
+ filter: { id: { include: [/.*/, /^storm:/] } },
78
+ handler: load
79
+ },
80
+ transform,
81
+ buildStart,
82
+ writeBundle
83
+ };
84
+ const result = decorate ? decorate(api, options) : options;
85
+ log(_storm_software_config_tools_types.LogLevelLabel.DEBUG, "Unplugin initialized successfully.");
86
+ return {
87
+ api,
88
+ ...result
89
+ };
90
+ } catch (error) {
91
+ log(_storm_software_config_tools_types.LogLevelLabel.FATAL, error?.message);
92
+ throw error;
93
+ }
94
+ };
95
+ }
96
+
97
+ //#endregion
98
+ exports.createUnpluginFactory = createUnpluginFactory;
5
99
  var _powerlines_core_lib_unplugin = require("@powerlines/core/lib/unplugin");
6
100
  Object.keys(_powerlines_core_lib_unplugin).forEach(function (k) {
7
101
  if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
@@ -9,3 +103,5 @@ Object.keys(_powerlines_core_lib_unplugin).forEach(function (k) {
9
103
  get: function () { return _powerlines_core_lib_unplugin[k]; }
10
104
  });
11
105
  });
106
+
107
+ //# sourceMappingURL=unplugin.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"unplugin.cjs","names":["LogLevelLabel","PowerlinesAPI"],"sources":["../src/unplugin.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\n/* -------------------------------------------------------------------\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 type {\n API,\n Context,\n UnpluginBuilderVariant,\n UnpluginFactory,\n UnpluginOptions\n} from \"@powerlines/core\";\nimport { createLog } from \"@powerlines/core/lib/logger\";\nimport { getString } from \"@powerlines/core/lib/utilities/source-file\";\nimport { LogLevelLabel } from \"@storm-software/config-tools/types\";\nimport { getWorkspaceRoot } from \"@stryke/fs/get-workspace-root\";\nimport { LoadResult } from \"rolldown\";\nimport type {\n UnpluginOptions as BaseUnpluginOptions,\n TransformResult,\n UnpluginBuildContext,\n UnpluginContext\n} from \"unplugin\";\nimport { setParseImpl } from \"unplugin\";\nimport { PowerlinesAPI } from \"./api\";\n\nexport * from \"@powerlines/core/lib/unplugin\";\n\n/**\n * Creates a Powerlines unplugin factory that generates a plugin instance.\n *\n * @param variant - The build variant for which to create the unplugin.\n * @param decorate - An optional function to decorate the unplugin options.\n * @returns The unplugin factory that generates a plugin instance.\n */\nexport function createUnpluginFactory<\n TContext extends Context,\n TUnpluginBuilderVariant extends UnpluginBuilderVariant =\n UnpluginBuilderVariant\n>(\n variant: TUnpluginBuilderVariant,\n decorate?: (\n api: API<TContext[\"config\"]>,\n plugin: UnpluginOptions<TContext>\n ) => BaseUnpluginOptions\n): UnpluginFactory<TContext> {\n return (config, meta): UnpluginOptions<TContext> => {\n const log = createLog(\"unplugin\", config);\n log(LogLevelLabel.DEBUG, \"Initializing Unplugin\");\n\n try {\n const userConfig = {\n ...config,\n variant,\n unplugin: meta\n } as TContext[\"config\"][\"userConfig\"];\n\n let api!: API<TContext[\"config\"]>;\n\n async function buildStart(this: UnpluginBuildContext): Promise<void> {\n log(LogLevelLabel.DEBUG, \"Powerlines build plugin starting...\");\n\n api = await PowerlinesAPI.from(\n getWorkspaceRoot(process.cwd()),\n userConfig\n );\n setParseImpl(api.context.parse);\n\n log(\n LogLevelLabel.DEBUG,\n \"Preparing build artifacts for the Powerlines project...\"\n );\n\n await api.prepare({\n command: \"build\"\n });\n }\n\n async function resolveId(\n this: UnpluginBuildContext & UnpluginContext,\n id: string,\n importer?: string,\n options: {\n isEntry: boolean;\n } = { isEntry: false }\n ) {\n return api.context.resolve(id, importer, options);\n }\n\n async function load(\n this: UnpluginBuildContext & UnpluginContext,\n id: string\n ): Promise<LoadResult> {\n const environment = await api.context.getEnvironment();\n\n let result = await api.callHook(\n \"load\",\n { environment, order: \"pre\" },\n id\n );\n if (result) {\n return result;\n }\n\n result = await api.callHook(\n \"load\",\n { environment, order: \"normal\" },\n id\n );\n if (result) {\n return result;\n }\n\n result = await environment.load(id);\n if (result) {\n return result;\n }\n\n return api.callHook(\"load\", { environment, order: \"post\" }, id);\n }\n\n async function transform(\n code: string,\n id: string\n ): Promise<TransformResult> {\n return api.callHook(\n \"transform\",\n {\n environment: await api.context.getEnvironment(),\n result: \"merge\",\n asNextParam: previousResult => getString(previousResult)\n },\n getString(code),\n id\n );\n }\n\n async function writeBundle(): Promise<void> {\n log(LogLevelLabel.DEBUG, \"Finalizing Powerlines project output...\");\n\n await api.callHook(\"writeBundle\", {\n environment: await api.context.getEnvironment()\n });\n }\n\n const options = {\n name: \"powerlines\",\n api,\n resolveId: {\n filter: {\n id: {\n include: [/.*/]\n }\n },\n handler: resolveId\n },\n load: {\n filter: {\n id: {\n include: [/.*/, /^storm:/]\n }\n },\n handler: load\n },\n transform,\n buildStart,\n writeBundle\n } as UnpluginOptions<TContext>;\n\n const result = decorate ? decorate(api, options) : options;\n\n log(LogLevelLabel.DEBUG, \"Unplugin initialized successfully.\");\n\n return { api, ...result };\n } catch (error) {\n log(LogLevelLabel.FATAL, (error as Error)?.message);\n\n throw error;\n }\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAkEA,SAAgB,sBAKd,SACA,UAI2B;AAC3B,SAAQ,QAAQ,SAAoC;EAClD,MAAM,iDAAgB,YAAY,OAAO;AACzC,MAAIA,iDAAc,OAAO,wBAAwB;AAEjD,MAAI;GACF,MAAM,aAAa;IACjB,GAAG;IACH;IACA,UAAU;IACX;GAED,IAAI;GAEJ,eAAe,aAAsD;AACnE,QAAIA,iDAAc,OAAO,sCAAsC;AAE/D,UAAM,MAAMC,0BAAc,yDACP,QAAQ,KAAK,CAAC,EAC/B,WACD;AACD,+BAAa,IAAI,QAAQ,MAAM;AAE/B,QACED,iDAAc,OACd,0DACD;AAED,UAAM,IAAI,QAAQ,EAChB,SAAS,SACV,CAAC;;GAGJ,eAAe,UAEb,IACA,UACA,UAEI,EAAE,SAAS,OAAO,EACtB;AACA,WAAO,IAAI,QAAQ,QAAQ,IAAI,UAAU,QAAQ;;GAGnD,eAAe,KAEb,IACqB;IACrB,MAAM,cAAc,MAAM,IAAI,QAAQ,gBAAgB;IAEtD,IAAI,SAAS,MAAM,IAAI,SACrB,QACA;KAAE;KAAa,OAAO;KAAO,EAC7B,GACD;AACD,QAAI,OACF,QAAO;AAGT,aAAS,MAAM,IAAI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