@powerlines/nx 0.9.4 → 0.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +14 -0
- package/README.md +34 -32
- package/dist/{chunk-RLV2BDHW.mjs → chunk-3E654WM2.mjs} +1 -1
- package/dist/{chunk-JMPM6JPD.js → chunk-5BPEG52U.js} +2 -2
- package/dist/chunk-67ALH5AX.js +327 -0
- package/dist/{chunk-Y2I6ZDWH.js → chunk-DODH7R3U.js} +2 -2
- package/dist/{chunk-SV7QXBCB.mjs → chunk-DVGRVHRD.mjs} +51 -52
- package/dist/{chunk-EVC3CWDX.mjs → chunk-H4ROBXJM.mjs} +1 -1
- package/dist/{chunk-P5UNWOB6.js → chunk-IS2MEDGI.js} +2 -2
- package/dist/chunk-KBRKYARM.mjs +320 -0
- package/dist/{chunk-IXFAMU7J.js → chunk-MI5C7LYS.js} +2 -2
- package/dist/{chunk-TEBG7V3S.mjs → chunk-MSR5HSGP.mjs} +513 -481
- package/dist/{chunk-GW5UQFFS.js → chunk-NFAKPYKX.js} +2 -2
- package/dist/{chunk-HTYRXIRM.mjs → chunk-QEHHWZYD.mjs} +1 -1
- package/dist/{chunk-F3XVH3HG.mjs → chunk-QY2HEZSZ.mjs} +1 -1
- package/dist/{chunk-OVUCSGTD.mjs → chunk-RPI3PNLJ.mjs} +1 -1
- package/dist/{chunk-JTW7QFIT.js → chunk-SXA7B3TE.js} +533 -502
- package/dist/{chunk-4UWZOCEA.js → chunk-UOTRU26N.js} +51 -52
- package/dist/executors.js +12 -12
- package/dist/executors.mjs +7 -7
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +15 -15
- package/dist/index.mjs +8 -8
- package/dist/src/base/base-executor.js +3 -3
- package/dist/src/base/base-executor.mjs +2 -2
- package/dist/src/executors/build/executor.js +5 -5
- package/dist/src/executors/build/executor.mjs +3 -3
- package/dist/src/executors/build/schema.d.ts +85 -0
- package/dist/src/executors/build/schema.json +96 -0
- package/dist/src/executors/clean/executor.js +5 -5
- package/dist/src/executors/clean/executor.mjs +3 -3
- package/dist/src/executors/clean/schema.d.ts +75 -0
- package/dist/src/executors/clean/schema.json +77 -0
- package/dist/src/executors/docs/executor.js +5 -5
- package/dist/src/executors/docs/executor.mjs +3 -3
- package/dist/src/executors/docs/schema.d.ts +75 -0
- package/dist/src/executors/docs/schema.json +77 -0
- package/dist/src/executors/lint/executor.js +5 -5
- package/dist/src/executors/lint/executor.mjs +3 -3
- package/dist/src/executors/lint/schema.d.ts +75 -0
- package/dist/src/executors/lint/schema.json +77 -0
- package/dist/src/executors/prepare/executor.js +5 -5
- package/dist/src/executors/prepare/executor.mjs +3 -3
- package/dist/src/executors/prepare/schema.d.ts +75 -0
- package/dist/src/executors/prepare/schema.json +77 -0
- package/dist/src/generators/sync/schema.d.ts +15 -0
- package/dist/src/generators/sync/schema.json +19 -0
- package/dist/src/plugin/index.d.mts +173 -11
- package/dist/src/plugin/index.d.ts +173 -11
- package/dist/src/plugin/index.js +4 -4
- package/dist/src/plugin/index.mjs +2 -2
- package/package.json +18 -18
- package/dist/chunk-FFBOHADM.mjs +0 -286
- package/dist/chunk-IFMXBBI7.js +0 -293
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkUOTRU26N_js = require('./chunk-UOTRU26N.js');
|
|
4
4
|
var chunkSHUYVCID_js = require('./chunk-SHUYVCID.js');
|
|
5
5
|
var logger = require('@storm-software/config-tools/logger');
|
|
6
6
|
var baseExecutor = require('@storm-software/workspace-tools/base/base-executor');
|
|
7
7
|
var isError = require('@stryke/type-checks/is-error');
|
|
8
|
-
var
|
|
8
|
+
var defu3 = require('defu');
|
|
9
|
+
var core = require('@babel/core');
|
|
9
10
|
var console = require('@storm-software/config-tools/logger/console');
|
|
10
11
|
var types = require('@storm-software/config-tools/types');
|
|
11
12
|
var toArray = require('@stryke/convert/to-array');
|
|
@@ -15,6 +16,7 @@ var helpers = require('@stryke/fs/helpers');
|
|
|
15
16
|
var install = require('@stryke/fs/install');
|
|
16
17
|
var listFiles = require('@stryke/fs/list-files');
|
|
17
18
|
var packageFns = require('@stryke/fs/package-fns');
|
|
19
|
+
var resolve = require('@stryke/fs/resolve');
|
|
18
20
|
var joinPaths = require('@stryke/path/join-paths');
|
|
19
21
|
var replace = require('@stryke/path/replace');
|
|
20
22
|
var isFunction = require('@stryke/type-checks/is-function');
|
|
@@ -25,19 +27,16 @@ var isSetObject = require('@stryke/type-checks/is-set-object');
|
|
|
25
27
|
var isSetString = require('@stryke/type-checks/is-set-string');
|
|
26
28
|
var chalk5 = require('chalk');
|
|
27
29
|
var Handlebars = require('handlebars');
|
|
28
|
-
var
|
|
29
|
-
var
|
|
30
|
-
var ts2 = require('typescript');
|
|
31
|
-
var isUndefined = require('@stryke/type-checks/is-undefined');
|
|
32
|
-
var writeFile$1 = require('@stryke/fs/write-file');
|
|
33
|
-
var prettier = require('prettier');
|
|
34
|
-
var resolve = require('@stryke/fs/resolve');
|
|
30
|
+
var helperPluginUtils = require('@babel/helper-plugin-utils');
|
|
31
|
+
var t = require('@babel/types');
|
|
35
32
|
var titleCase = require('@stryke/string-format/title-case');
|
|
36
33
|
var getEnvPaths = require('@stryke/env/get-env-paths');
|
|
37
34
|
var getWorkspaceRoot = require('@stryke/fs/get-workspace-root');
|
|
35
|
+
var json = require('@stryke/fs/json');
|
|
38
36
|
var murmurhash = require('@stryke/hash/murmurhash');
|
|
39
37
|
var getUnique = require('@stryke/helpers/get-unique');
|
|
40
38
|
var omit = require('@stryke/helpers/omit');
|
|
39
|
+
var append = require('@stryke/path/append');
|
|
41
40
|
var filePathFns = require('@stryke/path/file-path-fns');
|
|
42
41
|
var isType = require('@stryke/path/is-type');
|
|
43
42
|
var join = require('@stryke/path/join');
|
|
@@ -46,8 +45,10 @@ var isString = require('@stryke/type-checks/is-string');
|
|
|
46
45
|
var uuid = require('@stryke/unique-id/uuid');
|
|
47
46
|
var oxcParser = require('oxc-parser');
|
|
48
47
|
var parseTypeDefinition = require('@stryke/convert/parse-type-definition');
|
|
48
|
+
var isFile = require('@stryke/fs/is-file');
|
|
49
49
|
var colors = require('@storm-software/config-tools/utilities/colors');
|
|
50
50
|
var noop = require('@stryke/helpers/noop');
|
|
51
|
+
var isUndefined = require('@stryke/type-checks/is-undefined');
|
|
51
52
|
var jiti = require('jiti');
|
|
52
53
|
var bufferToString = require('@stryke/convert/buffer-to-string');
|
|
53
54
|
var isParentPath = require('@stryke/path/is-parent-path');
|
|
@@ -56,20 +57,20 @@ var isBuffer = require('@stryke/type-checks/is-buffer');
|
|
|
56
57
|
var memfs = require('memfs');
|
|
57
58
|
var buffer = require('buffer');
|
|
58
59
|
var fs = require('fs');
|
|
60
|
+
var prettier = require('prettier');
|
|
59
61
|
var unionfs = require('unionfs');
|
|
60
62
|
var isObject = require('@stryke/type-checks/is-object');
|
|
61
|
-
var
|
|
62
|
-
var readFile = require('@stryke/fs/read-file');
|
|
63
|
-
var MagicString = require('magic-string');
|
|
64
|
-
var helperPluginUtils = require('@babel/helper-plugin-utils');
|
|
65
|
-
var t = require('@babel/types');
|
|
63
|
+
var ts2 = require('typescript');
|
|
66
64
|
var _package = require('@stryke/string-format/package');
|
|
67
65
|
var superdiff = require('@donedeal0/superdiff');
|
|
68
66
|
var tsconfig = require('@stryke/fs/tsconfig');
|
|
69
67
|
var stormJson = require('@stryke/json/storm-json');
|
|
68
|
+
var writeFile$1 = require('@stryke/fs/write-file');
|
|
70
69
|
var environmentChecks = require('@stryke/env/environment-checks');
|
|
71
70
|
var unplugin = require('unplugin');
|
|
72
71
|
var bundleRequire = require('bundle-require');
|
|
72
|
+
require('@stryke/fs/read-file');
|
|
73
|
+
require('magic-string');
|
|
73
74
|
var kit = require('@nuxt/kit');
|
|
74
75
|
require('@nuxt/schema');
|
|
75
76
|
|
|
@@ -93,185 +94,117 @@ function _interopNamespace(e) {
|
|
|
93
94
|
return Object.freeze(n);
|
|
94
95
|
}
|
|
95
96
|
|
|
96
|
-
var
|
|
97
|
+
var defu3__default = /*#__PURE__*/_interopDefault(defu3);
|
|
97
98
|
var chalk5__default = /*#__PURE__*/_interopDefault(chalk5);
|
|
98
99
|
var Handlebars__default = /*#__PURE__*/_interopDefault(Handlebars);
|
|
99
|
-
var ts2__default = /*#__PURE__*/_interopDefault(ts2);
|
|
100
|
-
var fs__default = /*#__PURE__*/_interopDefault(fs);
|
|
101
|
-
var MagicString__default = /*#__PURE__*/_interopDefault(MagicString);
|
|
102
100
|
var t__namespace = /*#__PURE__*/_interopNamespace(t);
|
|
101
|
+
var fs__default = /*#__PURE__*/_interopDefault(fs);
|
|
102
|
+
var ts2__default = /*#__PURE__*/_interopDefault(ts2);
|
|
103
103
|
|
|
104
|
-
function
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
tsconfigFilePath = append.appendPath(tsconfig, projectRoot);
|
|
108
|
-
if (!exists.existsSync(tsconfigFilePath)) {
|
|
109
|
-
tsconfigFilePath = append.appendPath(tsconfig, workspaceRoot);
|
|
110
|
-
if (!exists.existsSync(tsconfigFilePath)) {
|
|
111
|
-
tsconfigFilePath = append.appendPath(tsconfig, joinPaths.joinPaths(workspaceRoot, projectRoot));
|
|
112
|
-
if (!exists.existsSync(tsconfigFilePath)) {
|
|
113
|
-
throw new Error(`Cannot find the \`tsconfig.json\` configuration file at ${tsconfig}, ${append.appendPath(tsconfig, projectRoot)}, ${append.appendPath(tsconfig, workspaceRoot)}, or ${tsconfigFilePath}`);
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
return tsconfigFilePath;
|
|
119
|
-
}
|
|
120
|
-
chunkSHUYVCID_js.__name(getTsconfigFilePath, "getTsconfigFilePath");
|
|
121
|
-
function findMatch(tsconfigType, types, extensions = [
|
|
122
|
-
".ts",
|
|
123
|
-
".tsx",
|
|
124
|
-
".d.ts"
|
|
125
|
-
]) {
|
|
126
|
-
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}`));
|
|
127
|
-
}
|
|
128
|
-
chunkSHUYVCID_js.__name(findMatch, "findMatch");
|
|
129
|
-
function findIncludeMatch(tsconfigType, types) {
|
|
130
|
-
return findMatch(tsconfigType, types, [
|
|
131
|
-
".ts",
|
|
132
|
-
".tsx",
|
|
133
|
-
".d.ts",
|
|
134
|
-
".js",
|
|
135
|
-
".jsx",
|
|
136
|
-
".mjs",
|
|
137
|
-
".cjs",
|
|
138
|
-
".mts",
|
|
139
|
-
".cts",
|
|
140
|
-
"/*.ts",
|
|
141
|
-
"/*.tsx",
|
|
142
|
-
"/*.d.ts",
|
|
143
|
-
"/*.js",
|
|
144
|
-
"/*.jsx",
|
|
145
|
-
"/*.mjs",
|
|
146
|
-
"/*.cjs",
|
|
147
|
-
"/*.mts",
|
|
148
|
-
"/*.cts",
|
|
149
|
-
"/**/*.ts",
|
|
150
|
-
"/**/*.tsx",
|
|
151
|
-
"/**/*.d.ts",
|
|
152
|
-
"/**/*.js",
|
|
153
|
-
"/**/*.jsx",
|
|
154
|
-
"/**/*.mjs",
|
|
155
|
-
"/**/*.cjs",
|
|
156
|
-
"/**/*.mts",
|
|
157
|
-
"/**/*.cts"
|
|
158
|
-
]);
|
|
159
|
-
}
|
|
160
|
-
chunkSHUYVCID_js.__name(findIncludeMatch, "findIncludeMatch");
|
|
161
|
-
function isIncludeMatchFound(tsconfigType, types) {
|
|
162
|
-
return findIncludeMatch(tsconfigType, types) !== void 0;
|
|
163
|
-
}
|
|
164
|
-
chunkSHUYVCID_js.__name(isIncludeMatchFound, "isIncludeMatchFound");
|
|
165
|
-
function getParsedTypeScriptConfig(workspaceRoot, projectRoot, tsconfig, tsconfigRaw = {}, originalTsconfigJson, host = ts2__default.default.sys) {
|
|
166
|
-
const tsconfigFilePath = getTsconfigFilePath(workspaceRoot, projectRoot, tsconfig);
|
|
167
|
-
const tsconfigJson = json.readJsonFileSync(tsconfigFilePath);
|
|
168
|
-
if (!tsconfigJson) {
|
|
169
|
-
throw new Error(`Cannot find the \`tsconfig.json\` configuration file at ${joinPaths.joinPaths(projectRoot, tsconfig ?? "tsconfig.json")}`);
|
|
104
|
+
function resolveModulePath(nodePath, state) {
|
|
105
|
+
if (!t__namespace.isStringLiteral(nodePath.node)) {
|
|
106
|
+
return;
|
|
170
107
|
}
|
|
171
|
-
const
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
108
|
+
const sourcePath = nodePath.node.value;
|
|
109
|
+
const resolvedPath = state.context?.fs.resolve(sourcePath);
|
|
110
|
+
if (resolvedPath) {
|
|
111
|
+
nodePath.replaceWith(t__namespace.stringLiteral(
|
|
112
|
+
// Remove the file extension if it exists
|
|
113
|
+
resolvedPath.replace(/\.(?:ts|mts|cts)x?$/, "")
|
|
114
|
+
));
|
|
177
115
|
}
|
|
178
|
-
return {
|
|
179
|
-
...parsedCommandLine,
|
|
180
|
-
originalTsconfigJson: originalTsconfigJson ?? tsconfigJson,
|
|
181
|
-
tsconfigJson,
|
|
182
|
-
tsconfigFilePath
|
|
183
|
-
};
|
|
184
116
|
}
|
|
185
|
-
chunkSHUYVCID_js.__name(
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
"
|
|
190
|
-
|
|
191
|
-
"
|
|
192
|
-
"
|
|
193
|
-
"
|
|
194
|
-
"
|
|
195
|
-
|
|
196
|
-
"
|
|
197
|
-
"
|
|
117
|
+
chunkSHUYVCID_js.__name(resolveModulePath, "resolveModulePath");
|
|
118
|
+
var TRANSFORM_FUNCTIONS = [
|
|
119
|
+
"require",
|
|
120
|
+
"require.resolve",
|
|
121
|
+
"System.import",
|
|
122
|
+
// Jest methods
|
|
123
|
+
"jest.genMockFromModule",
|
|
124
|
+
"jest.mock",
|
|
125
|
+
"jest.unmock",
|
|
126
|
+
"jest.doMock",
|
|
127
|
+
// eslint-disable-next-line @cspell/spellchecker
|
|
128
|
+
"jest.dontMock",
|
|
129
|
+
"jest.setMock",
|
|
130
|
+
"jest.requireActual",
|
|
131
|
+
"jest.requireMock",
|
|
132
|
+
// Older Jest methods
|
|
133
|
+
"require.requireActual",
|
|
134
|
+
"require.requireMock"
|
|
198
135
|
];
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
}
|
|
204
|
-
chunkSHUYVCID_js.__name(isPlugin, "isPlugin");
|
|
205
|
-
function isPluginConfigObject(value) {
|
|
206
|
-
return isSetObject.isSetObject(value) && "plugin" in value && ((isSetString.isSetString(value.plugin) || isFunction.isFunction(value.plugin)) && "options" in value && isSetObject.isSetObject(value.options) || isPlugin(value.plugin));
|
|
207
|
-
}
|
|
208
|
-
chunkSHUYVCID_js.__name(isPluginConfigObject, "isPluginConfigObject");
|
|
209
|
-
function isPluginConfigTuple(value) {
|
|
210
|
-
return Array.isArray(value) && (value.length === 1 || value.length === 2) && ((isSetString.isSetString(value[0]) || isFunction.isFunction(value[0])) && value.length > 1 && isSetObject.isSetObject(value[1]) || isPlugin(value[0]));
|
|
211
|
-
}
|
|
212
|
-
chunkSHUYVCID_js.__name(isPluginConfigTuple, "isPluginConfigTuple");
|
|
213
|
-
function isPluginConfig(value) {
|
|
214
|
-
return isSetString.isSetString(value) || isFunction.isFunction(value) || isPlugin(value) || isPluginConfigObject(value) || isPluginConfigTuple(value);
|
|
215
|
-
}
|
|
216
|
-
chunkSHUYVCID_js.__name(isPluginConfig, "isPluginConfig");
|
|
217
|
-
function isPluginHookFunction(value) {
|
|
218
|
-
return isFunction.isFunction(value) || isSetObject.isSetObject(value) && "handler" in value && isFunction.isFunction(value.handler);
|
|
219
|
-
}
|
|
220
|
-
chunkSHUYVCID_js.__name(isPluginHookFunction, "isPluginHookFunction");
|
|
221
|
-
function isPluginHookObject(value) {
|
|
222
|
-
return isSetObject.isSetObject(value) && "handler" in value && isFunction.isFunction(value.handler);
|
|
223
|
-
}
|
|
224
|
-
chunkSHUYVCID_js.__name(isPluginHookObject, "isPluginHookObject");
|
|
225
|
-
function isPluginHook(value) {
|
|
226
|
-
return isPluginHookFunction(value) || isPluginHookObject(value);
|
|
227
|
-
}
|
|
228
|
-
chunkSHUYVCID_js.__name(isPluginHook, "isPluginHook");
|
|
229
|
-
function getHookHandler(pluginHook) {
|
|
230
|
-
return isFunction.isFunction(pluginHook) ? pluginHook : pluginHook.handler;
|
|
231
|
-
}
|
|
232
|
-
chunkSHUYVCID_js.__name(getHookHandler, "getHookHandler");
|
|
233
|
-
function isHookExternal(hook) {
|
|
234
|
-
return hook.startsWith("vite:") || hook.startsWith("esbuild:") || hook.startsWith("rolldown:") || hook.startsWith("rollup:") || hook.startsWith("webpack:") || hook.startsWith("rspack:") || hook.startsWith("farm:");
|
|
235
|
-
}
|
|
236
|
-
chunkSHUYVCID_js.__name(isHookExternal, "isHookExternal");
|
|
237
|
-
function checkDedupe(plugin, plugins2) {
|
|
238
|
-
return plugin.dedupe === false || plugins2.some((p) => p.dedupe !== false && (isFunction.isFunction(p.dedupe) && p.dedupe(plugin) || p.name === plugin.name));
|
|
239
|
-
}
|
|
240
|
-
chunkSHUYVCID_js.__name(checkDedupe, "checkDedupe");
|
|
241
|
-
function addPluginHook(context, plugin, pluginHook, hooksList) {
|
|
242
|
-
if (!checkDedupe(plugin, hooksList.map((hook) => hook.plugin))) {
|
|
243
|
-
hooksList.push(isFunction.isFunction(pluginHook) ? {
|
|
244
|
-
plugin,
|
|
245
|
-
handler: getHookHandler(pluginHook).bind(context)
|
|
246
|
-
} : {
|
|
247
|
-
plugin,
|
|
248
|
-
...pluginHook,
|
|
249
|
-
handler: getHookHandler(pluginHook).bind(context)
|
|
250
|
-
});
|
|
136
|
+
function matchesPattern(state, calleePath, pattern) {
|
|
137
|
+
const { node } = calleePath;
|
|
138
|
+
if (t__namespace.isMemberExpression(node)) {
|
|
139
|
+
return calleePath.matchesPattern(pattern);
|
|
251
140
|
}
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
async function writeFile(log, filepath, content, skipFormat = false) {
|
|
255
|
-
try {
|
|
256
|
-
if (skipFormat) {
|
|
257
|
-
await writeFile$1.writeFile(filepath, content);
|
|
258
|
-
} else {
|
|
259
|
-
const config = await prettier.resolveConfig(filepath);
|
|
260
|
-
const formatted = await prettier.format(content, {
|
|
261
|
-
...config ?? {},
|
|
262
|
-
filepath
|
|
263
|
-
});
|
|
264
|
-
await writeFile$1.writeFile(filepath, formatted || "");
|
|
265
|
-
}
|
|
266
|
-
} catch (error) {
|
|
267
|
-
log(types.LogLevelLabel.ERROR, `Failed to write file ${filepath} to disk
|
|
268
|
-
${error?.message ? error.message : ""}`);
|
|
141
|
+
if (!t__namespace.isIdentifier(node) || pattern.includes(".")) {
|
|
142
|
+
return false;
|
|
269
143
|
}
|
|
144
|
+
const name = pattern.split(".")[0];
|
|
145
|
+
return node.name === name;
|
|
270
146
|
}
|
|
271
|
-
chunkSHUYVCID_js.__name(
|
|
147
|
+
chunkSHUYVCID_js.__name(matchesPattern, "matchesPattern");
|
|
148
|
+
var importVisitors = {
|
|
149
|
+
CallExpression: /* @__PURE__ */ chunkSHUYVCID_js.__name((nodePath, state) => {
|
|
150
|
+
if (state.moduleResolverVisited.has(nodePath)) {
|
|
151
|
+
return;
|
|
152
|
+
}
|
|
153
|
+
const calleePath = nodePath.get("callee");
|
|
154
|
+
if (calleePath && TRANSFORM_FUNCTIONS.some((pattern) => matchesPattern(state, calleePath, pattern)) || t__namespace.isImport(nodePath.node.callee)) {
|
|
155
|
+
state.moduleResolverVisited.add(nodePath);
|
|
156
|
+
resolveModulePath(nodePath.get("arguments.0"), state);
|
|
157
|
+
}
|
|
158
|
+
}, "CallExpression"),
|
|
159
|
+
// eslint-disable-next-line ts/naming-convention
|
|
160
|
+
"ImportDeclaration|ExportDeclaration|ExportAllDeclaration": /* @__PURE__ */ chunkSHUYVCID_js.__name((nodePath, state) => {
|
|
161
|
+
if (!nodePath || !nodePath.get("source") || state.moduleResolverVisited.has(nodePath)) {
|
|
162
|
+
return;
|
|
163
|
+
}
|
|
164
|
+
state.moduleResolverVisited.add(nodePath);
|
|
165
|
+
resolveModulePath(nodePath.get("source"), state);
|
|
166
|
+
}, "ImportDeclaration|ExportDeclaration|ExportAllDeclaration")
|
|
167
|
+
};
|
|
168
|
+
var moduleResolverBabelPlugin = /* @__PURE__ */ chunkSHUYVCID_js.__name((context) => {
|
|
169
|
+
return helperPluginUtils.declare(/* @__PURE__ */ chunkSHUYVCID_js.__name(function builder(api) {
|
|
170
|
+
let moduleResolverVisited = /* @__PURE__ */ new Set();
|
|
171
|
+
return {
|
|
172
|
+
name: "powerlines:module-resolver",
|
|
173
|
+
manipulateOptions(opts) {
|
|
174
|
+
opts.filename ??= "unknown";
|
|
175
|
+
},
|
|
176
|
+
pre() {
|
|
177
|
+
moduleResolverVisited = /* @__PURE__ */ new Set();
|
|
178
|
+
},
|
|
179
|
+
visitor: {
|
|
180
|
+
Program: {
|
|
181
|
+
enter(programPath, state) {
|
|
182
|
+
programPath.traverse(importVisitors, {
|
|
183
|
+
...state,
|
|
184
|
+
context,
|
|
185
|
+
moduleResolverVisited,
|
|
186
|
+
api
|
|
187
|
+
});
|
|
188
|
+
},
|
|
189
|
+
exit(programPath, state) {
|
|
190
|
+
programPath.traverse(importVisitors, {
|
|
191
|
+
...state,
|
|
192
|
+
context,
|
|
193
|
+
moduleResolverVisited,
|
|
194
|
+
api
|
|
195
|
+
});
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
},
|
|
199
|
+
post() {
|
|
200
|
+
moduleResolverVisited.clear();
|
|
201
|
+
}
|
|
202
|
+
};
|
|
203
|
+
}, "builder"));
|
|
204
|
+
}, "moduleResolverBabelPlugin");
|
|
272
205
|
var DEFAULT_ENVIRONMENT = "default";
|
|
273
206
|
function createEnvironment(name, userConfig) {
|
|
274
|
-
return
|
|
207
|
+
return defu3__default.default(userConfig.environments?.[name] ?? {}, {
|
|
275
208
|
name,
|
|
276
209
|
title: userConfig.title || titleCase.titleCase(userConfig.name),
|
|
277
210
|
ssr: false,
|
|
@@ -326,7 +259,7 @@ function resolveEntryInput(context, typeDefinition) {
|
|
|
326
259
|
}
|
|
327
260
|
chunkSHUYVCID_js.__name(resolveEntryInput, "resolveEntryInput");
|
|
328
261
|
function resolveEntryOutput(context, typeDefinition) {
|
|
329
|
-
return joinPaths.joinPaths(replace.replacePath(replace.replacePath(replace.replacePath(replace.replacePath(typeDefinition.file, joinPaths.joinPaths(context.workspaceConfig.workspaceRoot, context.config.sourceRoot)), joinPaths.joinPaths(context.workspaceConfig.workspaceRoot, context.config.projectRoot)), context.config.sourceRoot), context.config.projectRoot))
|
|
262
|
+
return replace.replaceExtension(joinPaths.joinPaths(replace.replacePath(replace.replacePath(replace.replacePath(replace.replacePath(typeDefinition.file, joinPaths.joinPaths(context.workspaceConfig.workspaceRoot, context.config.sourceRoot)), joinPaths.joinPaths(context.workspaceConfig.workspaceRoot, context.config.projectRoot)), context.config.sourceRoot), context.config.projectRoot)));
|
|
330
263
|
}
|
|
331
264
|
chunkSHUYVCID_js.__name(resolveEntryOutput, "resolveEntryOutput");
|
|
332
265
|
function resolveEntry(context, typeDefinition) {
|
|
@@ -341,7 +274,14 @@ chunkSHUYVCID_js.__name(resolveEntry, "resolveEntry");
|
|
|
341
274
|
function resolveEntriesSync(context, typeDefinitions) {
|
|
342
275
|
return typeDefinitions.map((typeDefinition) => {
|
|
343
276
|
const parsed = parseTypeDefinition.parseTypeDefinition(typeDefinition);
|
|
344
|
-
|
|
277
|
+
const filePath = append.appendPath(parsed.file, context.config.projectRoot);
|
|
278
|
+
if (isFile.isFile(filePath)) {
|
|
279
|
+
return resolveEntry(context, {
|
|
280
|
+
file: replace.replacePath(filePath, context.config.projectRoot),
|
|
281
|
+
name: parsed.name
|
|
282
|
+
});
|
|
283
|
+
}
|
|
284
|
+
return listFiles.listFilesSync(filePath).map((file) => resolveEntry(context, {
|
|
345
285
|
file,
|
|
346
286
|
name: parsed.name
|
|
347
287
|
}));
|
|
@@ -392,8 +332,76 @@ var BADGE_COLORS = [
|
|
|
392
332
|
var extendLog = /* @__PURE__ */ chunkSHUYVCID_js.__name((logFn, name) => {
|
|
393
333
|
return (type, ...args) => logFn(type, ` ${chalk5__default.default.inverse.hex(BADGE_COLORS[name.split("").map((char) => char.charCodeAt(0)).reduce((ret, charCode) => ret + charCode, 0) % BADGE_COLORS.length] || BADGE_COLORS[0])(` ${titleCase.titleCase(name)} `)} ${args.join(" ")} `);
|
|
394
334
|
}, "extendLog");
|
|
335
|
+
|
|
336
|
+
// ../powerlines/src/types/commands.ts
|
|
337
|
+
var SUPPORTED_COMMANDS = [
|
|
338
|
+
"new",
|
|
339
|
+
"clean",
|
|
340
|
+
"prepare",
|
|
341
|
+
"lint",
|
|
342
|
+
"test",
|
|
343
|
+
"build",
|
|
344
|
+
"docs",
|
|
345
|
+
"release",
|
|
346
|
+
"finalize"
|
|
347
|
+
];
|
|
348
|
+
|
|
349
|
+
// ../powerlines/src/plugin-utils/helpers.ts
|
|
350
|
+
function isPlugin(value) {
|
|
351
|
+
return isSetObject.isSetObject(value) && "name" in value && isSetString.isSetString(value.name) && (isUndefined.isUndefined(value.applyToEnvironment) || "applyToEnvironment" in value && isFunction.isFunction(value.applyToEnvironment)) && (isUndefined.isUndefined(value.dedupe) || "dedupe" in value && isFunction.isFunction(value.dedupe)) && (isUndefined.isUndefined(value.dependsOn) || "dependsOn" in value && Array.isArray(value.dependsOn) && value.dependsOn.every(isPluginConfig)) && SUPPORTED_COMMANDS.every((command) => isUndefined.isUndefined(value[command]) || command in value && (isFunction.isFunction(value[command]) || isSetObject.isSetObject(value[command]) && "handler" in value[command] && isFunction.isFunction(value[command].handler)));
|
|
352
|
+
}
|
|
353
|
+
chunkSHUYVCID_js.__name(isPlugin, "isPlugin");
|
|
354
|
+
function isPluginConfigObject(value) {
|
|
355
|
+
return isSetObject.isSetObject(value) && "plugin" in value && ((isSetString.isSetString(value.plugin) || isFunction.isFunction(value.plugin)) && "options" in value && isSetObject.isSetObject(value.options) || isPlugin(value.plugin));
|
|
356
|
+
}
|
|
357
|
+
chunkSHUYVCID_js.__name(isPluginConfigObject, "isPluginConfigObject");
|
|
358
|
+
function isPluginConfigTuple(value) {
|
|
359
|
+
return Array.isArray(value) && (value.length === 1 || value.length === 2) && ((isSetString.isSetString(value[0]) || isFunction.isFunction(value[0])) && value.length > 1 && isSetObject.isSetObject(value[1]) || isPlugin(value[0]));
|
|
360
|
+
}
|
|
361
|
+
chunkSHUYVCID_js.__name(isPluginConfigTuple, "isPluginConfigTuple");
|
|
362
|
+
function isPluginConfig(value) {
|
|
363
|
+
return isSetString.isSetString(value) || isFunction.isFunction(value) || isPlugin(value) || isPluginConfigObject(value) || isPluginConfigTuple(value);
|
|
364
|
+
}
|
|
365
|
+
chunkSHUYVCID_js.__name(isPluginConfig, "isPluginConfig");
|
|
366
|
+
function isPluginHookFunction(value) {
|
|
367
|
+
return isFunction.isFunction(value) || isSetObject.isSetObject(value) && "handler" in value && isFunction.isFunction(value.handler);
|
|
368
|
+
}
|
|
369
|
+
chunkSHUYVCID_js.__name(isPluginHookFunction, "isPluginHookFunction");
|
|
370
|
+
function isPluginHookObject(value) {
|
|
371
|
+
return isSetObject.isSetObject(value) && "handler" in value && isFunction.isFunction(value.handler);
|
|
372
|
+
}
|
|
373
|
+
chunkSHUYVCID_js.__name(isPluginHookObject, "isPluginHookObject");
|
|
374
|
+
function isPluginHook(value) {
|
|
375
|
+
return isPluginHookFunction(value) || isPluginHookObject(value);
|
|
376
|
+
}
|
|
377
|
+
chunkSHUYVCID_js.__name(isPluginHook, "isPluginHook");
|
|
378
|
+
function getHookHandler(pluginHook) {
|
|
379
|
+
return isFunction.isFunction(pluginHook) ? pluginHook : pluginHook.handler;
|
|
380
|
+
}
|
|
381
|
+
chunkSHUYVCID_js.__name(getHookHandler, "getHookHandler");
|
|
382
|
+
function isHookExternal(hook) {
|
|
383
|
+
return hook.startsWith("vite:") || hook.startsWith("esbuild:") || hook.startsWith("rolldown:") || hook.startsWith("rollup:") || hook.startsWith("webpack:") || hook.startsWith("rspack:") || hook.startsWith("farm:");
|
|
384
|
+
}
|
|
385
|
+
chunkSHUYVCID_js.__name(isHookExternal, "isHookExternal");
|
|
386
|
+
function checkDedupe(plugin, plugins2) {
|
|
387
|
+
return plugin.dedupe === false || plugins2.some((p) => p.dedupe !== false && (isFunction.isFunction(p.dedupe) && p.dedupe(plugin) || p.name === plugin.name));
|
|
388
|
+
}
|
|
389
|
+
chunkSHUYVCID_js.__name(checkDedupe, "checkDedupe");
|
|
390
|
+
function addPluginHook(context, plugin, pluginHook, hooksList) {
|
|
391
|
+
if (!checkDedupe(plugin, hooksList.map((hook) => hook.plugin))) {
|
|
392
|
+
hooksList.push(isFunction.isFunction(pluginHook) ? {
|
|
393
|
+
plugin,
|
|
394
|
+
handler: getHookHandler(pluginHook).bind(context)
|
|
395
|
+
} : {
|
|
396
|
+
plugin,
|
|
397
|
+
...pluginHook,
|
|
398
|
+
handler: getHookHandler(pluginHook).bind(context)
|
|
399
|
+
});
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
chunkSHUYVCID_js.__name(addPluginHook, "addPluginHook");
|
|
395
403
|
function resolveOptions(options) {
|
|
396
|
-
return
|
|
404
|
+
return defu3__default.default(options, {
|
|
397
405
|
interopDefault: true,
|
|
398
406
|
fsCache: options.mode !== "development" ? joinPaths.joinPaths(options.cacheDir, "jiti") : false,
|
|
399
407
|
moduleCache: options.mode !== "development"
|
|
@@ -624,25 +632,25 @@ var VirtualFileSystem = class {
|
|
|
624
632
|
/**
|
|
625
633
|
* Exposes the internal VFS map for advanced usage.
|
|
626
634
|
*/
|
|
627
|
-
get [
|
|
635
|
+
get [chunkUOTRU26N_js.__VFS_CACHE__]() {
|
|
628
636
|
return this.#cachedFS;
|
|
629
637
|
}
|
|
630
638
|
/**
|
|
631
639
|
* Exposes the internal VFS resolver cache for advanced usage.
|
|
632
640
|
*/
|
|
633
|
-
get [
|
|
641
|
+
get [chunkUOTRU26N_js.__VFS_RESOLVER__]() {
|
|
634
642
|
return this.#cachedResolver;
|
|
635
643
|
}
|
|
636
644
|
/**
|
|
637
645
|
* Exposes the internal VFS map for advanced usage.
|
|
638
646
|
*/
|
|
639
|
-
get [
|
|
647
|
+
get [chunkUOTRU26N_js.__VFS_VIRTUAL__]() {
|
|
640
648
|
return this.#virtualFS;
|
|
641
649
|
}
|
|
642
650
|
/**
|
|
643
651
|
* Exposes the internal UFS map for advanced usage.
|
|
644
652
|
*/
|
|
645
|
-
get [
|
|
653
|
+
get [chunkUOTRU26N_js.__VFS_UNIFIED__]() {
|
|
646
654
|
return this.#unifiedFS;
|
|
647
655
|
}
|
|
648
656
|
/**
|
|
@@ -759,13 +767,13 @@ var VirtualFileSystem = class {
|
|
|
759
767
|
}
|
|
760
768
|
this.#log = extendLog(this.#context.log, "virtual-file-system");
|
|
761
769
|
}
|
|
762
|
-
[
|
|
770
|
+
[chunkUOTRU26N_js.__VFS_INIT__]() {
|
|
763
771
|
if (!this.#isPatched && this.#context.config.output.mode !== "fs") {
|
|
764
772
|
this.#revert = patchFS(fs__default.default, this);
|
|
765
773
|
this.#isPatched = true;
|
|
766
774
|
}
|
|
767
775
|
}
|
|
768
|
-
[
|
|
776
|
+
[chunkUOTRU26N_js.__VFS_REVERT__]() {
|
|
769
777
|
if (this.#isPatched && this.#context.config.output.mode !== "fs") {
|
|
770
778
|
if (!this.#revert) {
|
|
771
779
|
throw new Error("Attempting to revert File System patch prior to calling `__init__` function");
|
|
@@ -881,7 +889,7 @@ var VirtualFileSystem = class {
|
|
|
881
889
|
return;
|
|
882
890
|
}
|
|
883
891
|
this.#log(types.LogLevelLabel.TRACE, `Synchronously removing directory: ${formattedPath}`);
|
|
884
|
-
this.resolveFS(path, options).rmdirSync(formattedPath,
|
|
892
|
+
this.resolveFS(path, options).rmdirSync(formattedPath, defu3__default.default(options, {
|
|
885
893
|
recursive: true
|
|
886
894
|
}));
|
|
887
895
|
this.#cachedFS.delete(formattedPath);
|
|
@@ -901,14 +909,14 @@ var VirtualFileSystem = class {
|
|
|
901
909
|
}
|
|
902
910
|
this.#log(types.LogLevelLabel.TRACE, `Removing directory: ${formattedPath}`);
|
|
903
911
|
if (isFunction.isFunction(this.resolveFS(path, options).promises.rm)) {
|
|
904
|
-
await this.resolveFS(path, options).promises.rm(formattedPath,
|
|
912
|
+
await this.resolveFS(path, options).promises.rm(formattedPath, defu3__default.default(options, {
|
|
905
913
|
force: true,
|
|
906
914
|
recursive: true
|
|
907
915
|
}));
|
|
908
916
|
this.#cachedFS.delete(formattedPath);
|
|
909
917
|
this.clearResolverCache(formattedPath);
|
|
910
918
|
} else {
|
|
911
|
-
this.rmdirSync(formattedPath,
|
|
919
|
+
this.rmdirSync(formattedPath, defu3__default.default(options ?? {}, {
|
|
912
920
|
force: true,
|
|
913
921
|
recursive: true
|
|
914
922
|
}));
|
|
@@ -951,7 +959,7 @@ var VirtualFileSystem = class {
|
|
|
951
959
|
mkdirSync(path, options = {}) {
|
|
952
960
|
const filePath = toFilePath(path);
|
|
953
961
|
this.clearResolverCache(filePath);
|
|
954
|
-
return this.resolveFS(filePath, options).mkdirSync(filePath,
|
|
962
|
+
return this.resolveFS(filePath, options).mkdirSync(filePath, defu3__default.default(options ?? {}, {
|
|
955
963
|
recursive: true
|
|
956
964
|
}));
|
|
957
965
|
}
|
|
@@ -966,11 +974,11 @@ var VirtualFileSystem = class {
|
|
|
966
974
|
let result;
|
|
967
975
|
const filePath = toFilePath(path);
|
|
968
976
|
if (isFunction.isFunction(this.resolveFS(filePath, options).promises.mkdir)) {
|
|
969
|
-
result = await this.resolveFS(filePath, options).promises.mkdir(filePath,
|
|
977
|
+
result = await this.resolveFS(filePath, options).promises.mkdir(filePath, defu3__default.default(options ?? {}, {
|
|
970
978
|
recursive: true
|
|
971
979
|
}));
|
|
972
980
|
} else {
|
|
973
|
-
result = this.resolveFS(filePath, options).mkdirSync(filePath,
|
|
981
|
+
result = this.resolveFS(filePath, options).mkdirSync(filePath, defu3__default.default(options ?? {}, {
|
|
974
982
|
recursive: true
|
|
975
983
|
}));
|
|
976
984
|
}
|
|
@@ -1705,7 +1713,7 @@ var PowerlinesContext = class _PowerlinesContext {
|
|
|
1705
1713
|
* @returns A promise that resolves to the new context.
|
|
1706
1714
|
*/
|
|
1707
1715
|
static async from(workspaceRoot, config) {
|
|
1708
|
-
const context = new _PowerlinesContext(await
|
|
1716
|
+
const context = new _PowerlinesContext(await chunkUOTRU26N_js.loadWorkspaceConfig(workspaceRoot, config.root));
|
|
1709
1717
|
await context.withUserConfig(config);
|
|
1710
1718
|
context.powerlinesPath = await resolve.resolvePackage("powerlines");
|
|
1711
1719
|
if (!context.powerlinesPath) {
|
|
@@ -1792,10 +1800,10 @@ var PowerlinesContext = class _PowerlinesContext {
|
|
|
1792
1800
|
workspaceRoot: this.workspaceConfig?.workspaceRoot,
|
|
1793
1801
|
projectRoot: this.config?.projectRoot
|
|
1794
1802
|
}, {
|
|
1795
|
-
maxLength:
|
|
1803
|
+
maxLength: chunkUOTRU26N_js.PROJECT_ROOT_HASH_LENGTH
|
|
1796
1804
|
}),
|
|
1797
1805
|
configHash: murmurhash.murmurhash(this.config, {
|
|
1798
|
-
maxLength:
|
|
1806
|
+
maxLength: chunkUOTRU26N_js.CACHE_HASH_LENGTH
|
|
1799
1807
|
}),
|
|
1800
1808
|
builtinIdMap: {},
|
|
1801
1809
|
virtualFiles: {}
|
|
@@ -1857,7 +1865,7 @@ var PowerlinesContext = class _PowerlinesContext {
|
|
|
1857
1865
|
* Get the path to the data directory for the project
|
|
1858
1866
|
*/
|
|
1859
1867
|
get dataPath() {
|
|
1860
|
-
return join.joinPaths(this.envPaths.data, "projects",
|
|
1868
|
+
return join.joinPaths(this.envPaths.data, "projects", chunkUOTRU26N_js.getPrefixedProjectRootHash(this.config.name, this.meta.projectRootHash));
|
|
1861
1869
|
}
|
|
1862
1870
|
/**
|
|
1863
1871
|
* Get the path to the cache directory for the project
|
|
@@ -1867,7 +1875,7 @@ var PowerlinesContext = class _PowerlinesContext {
|
|
|
1867
1875
|
checksum: this.#checksum,
|
|
1868
1876
|
config: this.meta.configHash
|
|
1869
1877
|
}, {
|
|
1870
|
-
maxLength:
|
|
1878
|
+
maxLength: chunkUOTRU26N_js.CACHE_HASH_LENGTH
|
|
1871
1879
|
}));
|
|
1872
1880
|
}
|
|
1873
1881
|
/**
|
|
@@ -1912,7 +1920,7 @@ var PowerlinesContext = class _PowerlinesContext {
|
|
|
1912
1920
|
return this.fs.writeFile(isType.isAbsolute(path) ? path : append.appendPath(path, this.entryPath), {
|
|
1913
1921
|
code,
|
|
1914
1922
|
variant: "entry"
|
|
1915
|
-
},
|
|
1923
|
+
}, defu3__default.default(options, {
|
|
1916
1924
|
mode: this.config.output.mode
|
|
1917
1925
|
}));
|
|
1918
1926
|
}
|
|
@@ -1929,7 +1937,7 @@ var PowerlinesContext = class _PowerlinesContext {
|
|
|
1929
1937
|
id,
|
|
1930
1938
|
code,
|
|
1931
1939
|
variant: "builtin"
|
|
1932
|
-
},
|
|
1940
|
+
}, defu3__default.default(options, {
|
|
1933
1941
|
mode: this.config.output.mode
|
|
1934
1942
|
}));
|
|
1935
1943
|
}
|
|
@@ -1951,7 +1959,7 @@ var PowerlinesContext = class _PowerlinesContext {
|
|
|
1951
1959
|
options
|
|
1952
1960
|
});
|
|
1953
1961
|
}
|
|
1954
|
-
const result = await oxcParser.parseAsync(id, code,
|
|
1962
|
+
const result = await oxcParser.parseAsync(id, code, defu3__default.default(options ?? {}, {
|
|
1955
1963
|
lang: filePathFns.hasFileExtension(id) ? void 0 : "ts",
|
|
1956
1964
|
astType: filePathFns.hasFileExtension(id) ? void 0 : "ts",
|
|
1957
1965
|
sourceType: "module",
|
|
@@ -2053,6 +2061,7 @@ ${result.errors.map((error) => ` [${error.severity}] ${error.message}${error.co
|
|
|
2053
2061
|
mode: (config.mode ?? this.config.mode) || this.workspaceConfig.mode,
|
|
2054
2062
|
skipCache: config.skipCache ?? this.config.skipCache ?? false,
|
|
2055
2063
|
configFile: config.configFile ?? this.config.configFile,
|
|
2064
|
+
framework: config.framework ?? this.config.framework ?? "powerlines",
|
|
2056
2065
|
command: this.config.inlineConfig?.command
|
|
2057
2066
|
};
|
|
2058
2067
|
if (configCache.has(cacheKey)) {
|
|
@@ -2071,7 +2080,7 @@ ${result.errors.map((error) => ` [${error.severity}] ${error.message}${error.co
|
|
|
2071
2080
|
if (exists.existsSync(packageJsonPath)) {
|
|
2072
2081
|
this.packageJson = await json.readJsonFile(packageJsonPath);
|
|
2073
2082
|
}
|
|
2074
|
-
this.#checksum = await
|
|
2083
|
+
this.#checksum = await chunkUOTRU26N_js.getChecksum(cacheKey.projectRoot);
|
|
2075
2084
|
this.resolver = createResolver({
|
|
2076
2085
|
workspaceRoot: this.workspaceConfig.workspaceRoot,
|
|
2077
2086
|
projectRoot: cacheKey.projectRoot,
|
|
@@ -2079,7 +2088,7 @@ ${result.errors.map((error) => ` [${error.severity}] ${error.message}${error.co
|
|
|
2079
2088
|
mode: cacheKey.mode,
|
|
2080
2089
|
skipCache: cacheKey.skipCache
|
|
2081
2090
|
});
|
|
2082
|
-
const userConfig = await
|
|
2091
|
+
const userConfig = await chunkUOTRU26N_js.loadUserConfigFile(cacheKey.projectRoot, this.resolver, cacheKey.command, cacheKey.mode, cacheKey.configFile, cacheKey.framework);
|
|
2083
2092
|
this.mergeUserConfig(userConfig.config);
|
|
2084
2093
|
configCache.set(cacheKey, {
|
|
2085
2094
|
projectJson: this.projectJson,
|
|
@@ -2090,7 +2099,7 @@ ${result.errors.map((error) => ` [${error.severity}] ${error.message}${error.co
|
|
|
2090
2099
|
});
|
|
2091
2100
|
}
|
|
2092
2101
|
if (isSetObject.isSetObject(config)) {
|
|
2093
|
-
this.resolvedConfig =
|
|
2102
|
+
this.resolvedConfig = defu3__default.default({
|
|
2094
2103
|
inlineConfig: this.config.inlineConfig,
|
|
2095
2104
|
userConfig: this.config.userConfig
|
|
2096
2105
|
}, options.isHighPriority ? this.#getConfigProps(config) : {}, {
|
|
@@ -2186,7 +2195,7 @@ ${result.errors.map((error) => ` [${error.severity}] ${error.message}${error.co
|
|
|
2186
2195
|
}, []);
|
|
2187
2196
|
}
|
|
2188
2197
|
mergeUserConfig(from = {}, into = this.config.userConfig ?? {}) {
|
|
2189
|
-
this.config.userConfig =
|
|
2198
|
+
this.config.userConfig = defu3__default.default({
|
|
2190
2199
|
entry: Array.isArray(from.entry) && from.entry.length > 0 ? from.entry : Array.isArray(into?.entry) && into.entry.length > 0 ? into.entry : []
|
|
2191
2200
|
}, omit.omit(from ?? {}, [
|
|
2192
2201
|
"entry"
|
|
@@ -2241,7 +2250,7 @@ async function callHook(context, hook, options, ...args) {
|
|
|
2241
2250
|
if (definedResults.length > 0) {
|
|
2242
2251
|
let mergedResult = void 0;
|
|
2243
2252
|
for (const result of definedResults) {
|
|
2244
|
-
mergedResult =
|
|
2253
|
+
mergedResult = defu3.defu(result, mergedResult ?? {});
|
|
2245
2254
|
}
|
|
2246
2255
|
return mergedResult;
|
|
2247
2256
|
}
|
|
@@ -2443,7 +2452,7 @@ var PowerlinesAPIContext = class _PowerlinesAPIContext extends PowerlinesContext
|
|
|
2443
2452
|
* @returns A promise that resolves to the new context.
|
|
2444
2453
|
*/
|
|
2445
2454
|
static async from(workspaceRoot, config) {
|
|
2446
|
-
const context = new _PowerlinesAPIContext(await
|
|
2455
|
+
const context = new _PowerlinesAPIContext(await chunkUOTRU26N_js.loadWorkspaceConfig(workspaceRoot, config.root));
|
|
2447
2456
|
await context.withUserConfig(config);
|
|
2448
2457
|
context.powerlinesPath = await resolve.resolvePackage("powerlines");
|
|
2449
2458
|
if (!context.powerlinesPath) {
|
|
@@ -2499,272 +2508,61 @@ var PowerlinesAPIContext = class _PowerlinesAPIContext extends PowerlinesContext
|
|
|
2499
2508
|
context.environment = environment;
|
|
2500
2509
|
context.plugins = [];
|
|
2501
2510
|
for (const plugin of this.plugins) {
|
|
2502
|
-
await context.addPlugin(plugin);
|
|
2503
|
-
}
|
|
2504
|
-
return context;
|
|
2505
|
-
}
|
|
2506
|
-
async addPlugin(plugin) {
|
|
2507
|
-
this.plugins.push(plugin);
|
|
2508
|
-
await Promise.all(Object.keys(this.environments).map(async (name) => {
|
|
2509
|
-
await this.environments[name].addPlugin(plugin);
|
|
2510
|
-
}));
|
|
2511
|
-
}
|
|
2512
|
-
async getEnvironment(name) {
|
|
2513
|
-
let environment;
|
|
2514
|
-
if (name) {
|
|
2515
|
-
environment = this.environments[name];
|
|
2516
|
-
}
|
|
2517
|
-
if (Object.keys(this.environments).length === 1) {
|
|
2518
|
-
environment = this.environments[Object.keys(this.environments)[0]];
|
|
2519
|
-
this.log(types.LogLevelLabel.DEBUG, `Applying the only configured environment: ${chalk5__default.default.bold.cyanBright(environment?.environment.name)}`);
|
|
2520
|
-
}
|
|
2521
|
-
if (!environment) {
|
|
2522
|
-
if (name) {
|
|
2523
|
-
throw new Error(`Environment "${name}" not found.`);
|
|
2524
|
-
}
|
|
2525
|
-
environment = await this.in(createDefaultEnvironment(this.config.userConfig));
|
|
2526
|
-
this.log(types.LogLevelLabel.WARN, `No environment specified, and no default environment found. Using a temporary default environment: ${chalk5__default.default.bold.cyanBright(environment?.environment.name)}`);
|
|
2527
|
-
}
|
|
2528
|
-
return environment;
|
|
2529
|
-
}
|
|
2530
|
-
async getEnvironmentSafe(name) {
|
|
2531
|
-
try {
|
|
2532
|
-
return await this.getEnvironment(name);
|
|
2533
|
-
} catch {
|
|
2534
|
-
return void 0;
|
|
2535
|
-
}
|
|
2536
|
-
}
|
|
2537
|
-
};
|
|
2538
|
-
function getBaseFileHeader(context) {
|
|
2539
|
-
return `
|
|
2540
|
-
// Generated with ${titleCase.titleCase(context.config.framework)}
|
|
2541
|
-
// Note: Do not edit this file manually - it will be overwritten automatically
|
|
2542
|
-
`;
|
|
2543
|
-
}
|
|
2544
|
-
chunkSHUYVCID_js.__name(getBaseFileHeader, "getBaseFileHeader");
|
|
2545
|
-
function getFileHeader(context, options = {}) {
|
|
2546
|
-
const { directive = null, prettierIgnore = false } = options;
|
|
2547
|
-
return `/* eslint-disable */
|
|
2548
|
-
// biome-ignore lint: disable
|
|
2549
|
-
${prettierIgnore ? `// prettier-ignore` : ""}${directive ? `
|
|
2550
|
-
|
|
2551
|
-
${directive}
|
|
2552
|
-
` : "\n"}
|
|
2553
|
-
${getBaseFileHeader(context)}
|
|
2554
|
-
|
|
2555
|
-
`;
|
|
2556
|
-
}
|
|
2557
|
-
chunkSHUYVCID_js.__name(getFileHeader, "getFileHeader");
|
|
2558
|
-
function getString(code) {
|
|
2559
|
-
if (!code) {
|
|
2560
|
-
return "";
|
|
2561
|
-
}
|
|
2562
|
-
if (isString.isString(code)) {
|
|
2563
|
-
return code;
|
|
2564
|
-
}
|
|
2565
|
-
if (isSetObject.isSetObject(code) && "code" in code) {
|
|
2566
|
-
return code.code;
|
|
2567
|
-
}
|
|
2568
|
-
return code.toString();
|
|
2569
|
-
}
|
|
2570
|
-
chunkSHUYVCID_js.__name(getString, "getString");
|
|
2571
|
-
function getMagicString(code) {
|
|
2572
|
-
if (isString.isString(code)) {
|
|
2573
|
-
return new MagicString__default.default(code);
|
|
2574
|
-
}
|
|
2575
|
-
return code;
|
|
2576
|
-
}
|
|
2577
|
-
chunkSHUYVCID_js.__name(getMagicString, "getMagicString");
|
|
2578
|
-
function getSourceFile(code, id) {
|
|
2579
|
-
const content = code ?? readFile.readFileIfExistingSync(id);
|
|
2580
|
-
return {
|
|
2581
|
-
id,
|
|
2582
|
-
code: getMagicString(content),
|
|
2583
|
-
env: []
|
|
2584
|
-
};
|
|
2585
|
-
}
|
|
2586
|
-
chunkSHUYVCID_js.__name(getSourceFile, "getSourceFile");
|
|
2587
|
-
function resolveModulePath(nodePath, state) {
|
|
2588
|
-
if (!t__namespace.isStringLiteral(nodePath.node)) {
|
|
2589
|
-
return;
|
|
2590
|
-
}
|
|
2591
|
-
const sourcePath = nodePath.node.value;
|
|
2592
|
-
const resolvedPath = state.context?.fs.resolve(sourcePath);
|
|
2593
|
-
if (resolvedPath) {
|
|
2594
|
-
nodePath.replaceWith(t__namespace.stringLiteral(
|
|
2595
|
-
// Remove the file extension if it exists
|
|
2596
|
-
resolvedPath.replace(/\.(?:ts|mts|cts)x?$/, "")
|
|
2597
|
-
));
|
|
2598
|
-
}
|
|
2599
|
-
}
|
|
2600
|
-
chunkSHUYVCID_js.__name(resolveModulePath, "resolveModulePath");
|
|
2601
|
-
var TRANSFORM_FUNCTIONS = [
|
|
2602
|
-
"require",
|
|
2603
|
-
"require.resolve",
|
|
2604
|
-
"System.import",
|
|
2605
|
-
// Jest methods
|
|
2606
|
-
"jest.genMockFromModule",
|
|
2607
|
-
"jest.mock",
|
|
2608
|
-
"jest.unmock",
|
|
2609
|
-
"jest.doMock",
|
|
2610
|
-
// eslint-disable-next-line @cspell/spellchecker
|
|
2611
|
-
"jest.dontMock",
|
|
2612
|
-
"jest.setMock",
|
|
2613
|
-
"jest.requireActual",
|
|
2614
|
-
"jest.requireMock",
|
|
2615
|
-
// Older Jest methods
|
|
2616
|
-
"require.requireActual",
|
|
2617
|
-
"require.requireMock"
|
|
2618
|
-
];
|
|
2619
|
-
function matchesPattern(state, calleePath, pattern) {
|
|
2620
|
-
const { node } = calleePath;
|
|
2621
|
-
if (t__namespace.isMemberExpression(node)) {
|
|
2622
|
-
return calleePath.matchesPattern(pattern);
|
|
2623
|
-
}
|
|
2624
|
-
if (!t__namespace.isIdentifier(node) || pattern.includes(".")) {
|
|
2625
|
-
return false;
|
|
2626
|
-
}
|
|
2627
|
-
const name = pattern.split(".")[0];
|
|
2628
|
-
return node.name === name;
|
|
2629
|
-
}
|
|
2630
|
-
chunkSHUYVCID_js.__name(matchesPattern, "matchesPattern");
|
|
2631
|
-
var importVisitors = {
|
|
2632
|
-
CallExpression: /* @__PURE__ */ chunkSHUYVCID_js.__name((nodePath, state) => {
|
|
2633
|
-
if (state.moduleResolverVisited.has(nodePath)) {
|
|
2634
|
-
return;
|
|
2635
|
-
}
|
|
2636
|
-
const calleePath = nodePath.get("callee");
|
|
2637
|
-
if (calleePath && TRANSFORM_FUNCTIONS.some((pattern) => matchesPattern(state, calleePath, pattern)) || t__namespace.isImport(nodePath.node.callee)) {
|
|
2638
|
-
state.moduleResolverVisited.add(nodePath);
|
|
2639
|
-
resolveModulePath(nodePath.get("arguments.0"), state);
|
|
2511
|
+
await context.addPlugin(plugin);
|
|
2640
2512
|
}
|
|
2641
|
-
|
|
2642
|
-
|
|
2643
|
-
|
|
2644
|
-
|
|
2645
|
-
|
|
2513
|
+
return context;
|
|
2514
|
+
}
|
|
2515
|
+
async addPlugin(plugin) {
|
|
2516
|
+
this.plugins.push(plugin);
|
|
2517
|
+
await Promise.all(Object.keys(this.environments).map(async (name) => {
|
|
2518
|
+
await this.environments[name].addPlugin(plugin);
|
|
2519
|
+
}));
|
|
2520
|
+
}
|
|
2521
|
+
async getEnvironment(name) {
|
|
2522
|
+
let environment;
|
|
2523
|
+
if (name) {
|
|
2524
|
+
environment = this.environments[name];
|
|
2646
2525
|
}
|
|
2647
|
-
|
|
2648
|
-
|
|
2649
|
-
|
|
2650
|
-
}
|
|
2651
|
-
|
|
2652
|
-
|
|
2653
|
-
|
|
2654
|
-
return {
|
|
2655
|
-
name: "powerlines:module-resolver",
|
|
2656
|
-
manipulateOptions(opts) {
|
|
2657
|
-
opts.filename ??= "unknown";
|
|
2658
|
-
},
|
|
2659
|
-
pre() {
|
|
2660
|
-
moduleResolverVisited = /* @__PURE__ */ new Set();
|
|
2661
|
-
},
|
|
2662
|
-
visitor: {
|
|
2663
|
-
Program: {
|
|
2664
|
-
enter(programPath, state) {
|
|
2665
|
-
programPath.traverse(importVisitors, {
|
|
2666
|
-
...state,
|
|
2667
|
-
context,
|
|
2668
|
-
moduleResolverVisited,
|
|
2669
|
-
api
|
|
2670
|
-
});
|
|
2671
|
-
},
|
|
2672
|
-
exit(programPath, state) {
|
|
2673
|
-
programPath.traverse(importVisitors, {
|
|
2674
|
-
...state,
|
|
2675
|
-
context,
|
|
2676
|
-
moduleResolverVisited,
|
|
2677
|
-
api
|
|
2678
|
-
});
|
|
2679
|
-
}
|
|
2680
|
-
}
|
|
2681
|
-
},
|
|
2682
|
-
post() {
|
|
2683
|
-
moduleResolverVisited.clear();
|
|
2526
|
+
if (Object.keys(this.environments).length === 1) {
|
|
2527
|
+
environment = this.environments[Object.keys(this.environments)[0]];
|
|
2528
|
+
this.log(types.LogLevelLabel.DEBUG, `Applying the only configured environment: ${chalk5__default.default.bold.cyanBright(environment?.environment.name)}`);
|
|
2529
|
+
}
|
|
2530
|
+
if (!environment) {
|
|
2531
|
+
if (name) {
|
|
2532
|
+
throw new Error(`Environment "${name}" not found.`);
|
|
2684
2533
|
}
|
|
2685
|
-
|
|
2686
|
-
|
|
2687
|
-
}, "moduleResolverBabelPlugin");
|
|
2688
|
-
|
|
2689
|
-
// ../powerlines/src/internal/helpers/generate-types.ts
|
|
2690
|
-
async function generateTypes(context) {
|
|
2691
|
-
context.log(types.LogLevelLabel.TRACE, `Preparing the TypeScript definitions for the Powerlines project.`);
|
|
2692
|
-
context.log(types.LogLevelLabel.TRACE, "Transforming built-ins runtime modules files.");
|
|
2693
|
-
const builtinFiles = await context.getBuiltins();
|
|
2694
|
-
const builtinFilePaths = await Promise.all(builtinFiles.map(async (file) => {
|
|
2695
|
-
const result = await core.transformAsync(file.code.toString(), {
|
|
2696
|
-
highlightCode: true,
|
|
2697
|
-
code: true,
|
|
2698
|
-
ast: false,
|
|
2699
|
-
cloneInputAst: false,
|
|
2700
|
-
comments: true,
|
|
2701
|
-
sourceType: "module",
|
|
2702
|
-
configFile: false,
|
|
2703
|
-
babelrc: false,
|
|
2704
|
-
envName: context.config.mode,
|
|
2705
|
-
caller: {
|
|
2706
|
-
name: "powerlines"
|
|
2707
|
-
},
|
|
2708
|
-
...context.config.transform.babel,
|
|
2709
|
-
filename: file.path,
|
|
2710
|
-
plugins: [
|
|
2711
|
-
[
|
|
2712
|
-
"@babel/plugin-syntax-typescript"
|
|
2713
|
-
],
|
|
2714
|
-
[
|
|
2715
|
-
moduleResolverBabelPlugin(context)
|
|
2716
|
-
]
|
|
2717
|
-
]
|
|
2718
|
-
});
|
|
2719
|
-
if (!result?.code) {
|
|
2720
|
-
throw new Error(`Powerlines - Generate Types failed to compile ${file.id}`);
|
|
2534
|
+
environment = await this.in(createDefaultEnvironment(this.config.userConfig));
|
|
2535
|
+
this.log(types.LogLevelLabel.WARN, `No environment specified, and no default environment found. Using a temporary default environment: ${chalk5__default.default.bold.cyanBright(environment?.environment.name)}`);
|
|
2721
2536
|
}
|
|
2722
|
-
|
|
2723
|
-
|
|
2724
|
-
|
|
2725
|
-
|
|
2726
|
-
|
|
2727
|
-
|
|
2728
|
-
|
|
2729
|
-
|
|
2730
|
-
|
|
2731
|
-
|
|
2732
|
-
|
|
2733
|
-
|
|
2734
|
-
|
|
2735
|
-
|
|
2736
|
-
|
|
2737
|
-
|
|
2738
|
-
|
|
2739
|
-
|
|
2740
|
-
|
|
2741
|
-
compilerOptions: {
|
|
2742
|
-
strict: false,
|
|
2743
|
-
noEmit: false,
|
|
2744
|
-
declaration: true,
|
|
2745
|
-
declarationMap: false,
|
|
2746
|
-
emitDeclarationOnly: true,
|
|
2747
|
-
skipLibCheck: true
|
|
2748
|
-
},
|
|
2749
|
-
exclude: [
|
|
2750
|
-
"node_modules",
|
|
2751
|
-
"dist"
|
|
2752
|
-
],
|
|
2753
|
-
include: files
|
|
2754
|
-
}, context.config.tsconfigRaw ?? {}));
|
|
2755
|
-
resolvedTsconfig.options.configFilePath = joinPaths.joinPaths(context.workspaceConfig.workspaceRoot, context.tsconfig.tsconfigFilePath);
|
|
2756
|
-
resolvedTsconfig.options.pathsBasePath = context.workspaceConfig.workspaceRoot;
|
|
2757
|
-
resolvedTsconfig.options.suppressOutputPathCheck = true;
|
|
2537
|
+
return environment;
|
|
2538
|
+
}
|
|
2539
|
+
async getEnvironmentSafe(name) {
|
|
2540
|
+
try {
|
|
2541
|
+
return await this.getEnvironment(name);
|
|
2542
|
+
} catch {
|
|
2543
|
+
return void 0;
|
|
2544
|
+
}
|
|
2545
|
+
}
|
|
2546
|
+
};
|
|
2547
|
+
function formatTypes(code) {
|
|
2548
|
+
return code.replace(
|
|
2549
|
+
// eslint-disable-next-line regexp/no-super-linear-backtracking
|
|
2550
|
+
/import\s*(?:type\s*)?\{?[\w,\s]*(?:\}\s*)?from\s*(?:'|")@?[a-zA-Z0-9-\\/.]*(?:'|");?/g,
|
|
2551
|
+
""
|
|
2552
|
+
).replaceAll("#private;", "").replace(/__Ω/g, "");
|
|
2553
|
+
}
|
|
2554
|
+
chunkSHUYVCID_js.__name(formatTypes, "formatTypes");
|
|
2555
|
+
async function emitTypes(context, tsconfig, files) {
|
|
2758
2556
|
context.log(types.LogLevelLabel.TRACE, "Creating the TypeScript compiler host");
|
|
2759
|
-
const program = ts2.createProgram(files,
|
|
2760
|
-
context.log(types.LogLevelLabel.TRACE, `Running TypeScript compiler
|
|
2557
|
+
const program = ts2.createProgram(files, tsconfig.options, ts2.createCompilerHost(tsconfig.options));
|
|
2558
|
+
context.log(types.LogLevelLabel.TRACE, `Running the TypeScript compiler for ${context.builtins.length} built-in runtime files.`);
|
|
2761
2559
|
let builtinModules = "";
|
|
2762
2560
|
const emitResult = program.emit(void 0, (fileName, text, _, __, sourceFiles, _data) => {
|
|
2763
|
-
const
|
|
2764
|
-
if (
|
|
2765
|
-
if (
|
|
2561
|
+
const sourceFile = sourceFiles?.[0];
|
|
2562
|
+
if (sourceFile?.fileName && !fileName.endsWith(".map")) {
|
|
2563
|
+
if (context.builtins.some((file) => file === sourceFile.fileName || context.fs.meta[file]?.id && context.fs.meta[file]?.id === sourceFile.fileName)) {
|
|
2766
2564
|
builtinModules += `
|
|
2767
|
-
declare module "${context.fs.resolve(
|
|
2565
|
+
declare module "${context.fs.resolve(sourceFile.fileName)}" {
|
|
2768
2566
|
${text.trim().replace(/^\s*export\s*declare\s*/gm, "export ").replace(/^\s*declare\s*/gm, "")}
|
|
2769
2567
|
}
|
|
2770
2568
|
`;
|
|
@@ -2789,25 +2587,9 @@ declare module "${context.fs.resolve(sourceFile2.fileName)}" {
|
|
|
2789
2587
|
|
|
2790
2588
|
${diagnosticMessage.length > 5e3 ? `${diagnosticMessage.slice(0, 5e3)}...` : diagnosticMessage}`);
|
|
2791
2589
|
}
|
|
2792
|
-
|
|
2793
|
-
const sourceFile = getSourceFile(String(context.config.output.dts), `/// <reference types="powerlines/shared" />${context.config.build.platform !== "neutral" ? `
|
|
2794
|
-
/// <reference types="powerlines/${context.config.build.platform}" />` : ""}
|
|
2795
|
-
|
|
2796
|
-
${getFileHeader(context, {
|
|
2797
|
-
directive: null,
|
|
2798
|
-
prettierIgnore: false
|
|
2799
|
-
})}
|
|
2800
|
-
|
|
2801
|
-
${builtinModules}`.replace(
|
|
2802
|
-
// eslint-disable-next-line regexp/no-super-linear-backtracking
|
|
2803
|
-
/import\s*(?:type\s*)?\{?[\w,\s]*(?:\}\s*)?from\s*(?:'|")@?[a-zA-Z0-9-\\/.]*(?:'|");?/g,
|
|
2804
|
-
""
|
|
2805
|
-
).replaceAll("#private;", "").replace(/__Ω/g, ""));
|
|
2806
|
-
await context.fs.writeFile(sourceFile.id, getString(sourceFile.code), {
|
|
2807
|
-
mode: "fs"
|
|
2808
|
-
});
|
|
2590
|
+
return formatTypes(builtinModules);
|
|
2809
2591
|
}
|
|
2810
|
-
chunkSHUYVCID_js.__name(
|
|
2592
|
+
chunkSHUYVCID_js.__name(emitTypes, "emitTypes");
|
|
2811
2593
|
async function installPackage(context, packageName, dev = false) {
|
|
2812
2594
|
if (!await packageFns.isPackageListed(_package.getPackageName(packageName), {
|
|
2813
2595
|
cwd: context.config.projectRoot
|
|
@@ -2843,7 +2625,12 @@ chunkSHUYVCID_js.__name(installPackage, "installPackage");
|
|
|
2843
2625
|
async function installDependencies(context) {
|
|
2844
2626
|
context.log(types.LogLevelLabel.TRACE, `Checking and installing missing project dependencies.`);
|
|
2845
2627
|
context.dependencies ??= {};
|
|
2846
|
-
context.
|
|
2628
|
+
context.devDependencies ??= {};
|
|
2629
|
+
if (Object.keys(context.dependencies).length === 0 && Object.keys(context.devDependencies).length === 0) {
|
|
2630
|
+
context.log(types.LogLevelLabel.TRACE, `No dependencies or devDependencies to install. Skipping installation step.`);
|
|
2631
|
+
return;
|
|
2632
|
+
}
|
|
2633
|
+
context.log(types.LogLevelLabel.DEBUG, `The following packages are required:
|
|
2847
2634
|
Dependencies:
|
|
2848
2635
|
${Object.entries(context.dependencies).map(([name, version]) => `- ${name}@${String(version)}`).join(" \n")}
|
|
2849
2636
|
|
|
@@ -2855,6 +2642,108 @@ ${Object.entries(context.devDependencies).map(([name, version]) => `- ${name}@${
|
|
|
2855
2642
|
]);
|
|
2856
2643
|
}
|
|
2857
2644
|
chunkSHUYVCID_js.__name(installDependencies, "installDependencies");
|
|
2645
|
+
function getTsconfigFilePath(workspaceRoot, projectRoot, tsconfig = "tsconfig.json") {
|
|
2646
|
+
let tsconfigFilePath = tsconfig;
|
|
2647
|
+
if (!exists.existsSync(tsconfigFilePath)) {
|
|
2648
|
+
tsconfigFilePath = append.appendPath(tsconfig, projectRoot);
|
|
2649
|
+
if (!exists.existsSync(tsconfigFilePath)) {
|
|
2650
|
+
tsconfigFilePath = append.appendPath(tsconfig, workspaceRoot);
|
|
2651
|
+
if (!exists.existsSync(tsconfigFilePath)) {
|
|
2652
|
+
tsconfigFilePath = append.appendPath(tsconfig, joinPaths.joinPaths(workspaceRoot, projectRoot));
|
|
2653
|
+
if (!exists.existsSync(tsconfigFilePath)) {
|
|
2654
|
+
throw new Error(`Cannot find the \`tsconfig.json\` configuration file at ${tsconfig}, ${append.appendPath(tsconfig, projectRoot)}, ${append.appendPath(tsconfig, workspaceRoot)}, or ${tsconfigFilePath}`);
|
|
2655
|
+
}
|
|
2656
|
+
}
|
|
2657
|
+
}
|
|
2658
|
+
}
|
|
2659
|
+
return tsconfigFilePath;
|
|
2660
|
+
}
|
|
2661
|
+
chunkSHUYVCID_js.__name(getTsconfigFilePath, "getTsconfigFilePath");
|
|
2662
|
+
function findMatch(tsconfigType, types, extensions = [
|
|
2663
|
+
".ts",
|
|
2664
|
+
".tsx",
|
|
2665
|
+
".d.ts"
|
|
2666
|
+
]) {
|
|
2667
|
+
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}`));
|
|
2668
|
+
}
|
|
2669
|
+
chunkSHUYVCID_js.__name(findMatch, "findMatch");
|
|
2670
|
+
function findIncludeMatch(tsconfigType, types) {
|
|
2671
|
+
return findMatch(tsconfigType, types, [
|
|
2672
|
+
".ts",
|
|
2673
|
+
".tsx",
|
|
2674
|
+
".d.ts",
|
|
2675
|
+
".js",
|
|
2676
|
+
".jsx",
|
|
2677
|
+
".mjs",
|
|
2678
|
+
".cjs",
|
|
2679
|
+
".mts",
|
|
2680
|
+
".cts",
|
|
2681
|
+
"/*.ts",
|
|
2682
|
+
"/*.tsx",
|
|
2683
|
+
"/*.d.ts",
|
|
2684
|
+
"/*.js",
|
|
2685
|
+
"/*.jsx",
|
|
2686
|
+
"/*.mjs",
|
|
2687
|
+
"/*.cjs",
|
|
2688
|
+
"/*.mts",
|
|
2689
|
+
"/*.cts",
|
|
2690
|
+
"/**/*.ts",
|
|
2691
|
+
"/**/*.tsx",
|
|
2692
|
+
"/**/*.d.ts",
|
|
2693
|
+
"/**/*.js",
|
|
2694
|
+
"/**/*.jsx",
|
|
2695
|
+
"/**/*.mjs",
|
|
2696
|
+
"/**/*.cjs",
|
|
2697
|
+
"/**/*.mts",
|
|
2698
|
+
"/**/*.cts"
|
|
2699
|
+
]);
|
|
2700
|
+
}
|
|
2701
|
+
chunkSHUYVCID_js.__name(findIncludeMatch, "findIncludeMatch");
|
|
2702
|
+
function isIncludeMatchFound(tsconfigType, types) {
|
|
2703
|
+
return findIncludeMatch(tsconfigType, types) !== void 0;
|
|
2704
|
+
}
|
|
2705
|
+
chunkSHUYVCID_js.__name(isIncludeMatchFound, "isIncludeMatchFound");
|
|
2706
|
+
function getParsedTypeScriptConfig(workspaceRoot, projectRoot, tsconfig, tsconfigRaw = {}, originalTsconfigJson, host = ts2__default.default.sys) {
|
|
2707
|
+
const tsconfigFilePath = getTsconfigFilePath(workspaceRoot, projectRoot, tsconfig);
|
|
2708
|
+
const tsconfigJson = json.readJsonFileSync(tsconfigFilePath);
|
|
2709
|
+
if (!tsconfigJson) {
|
|
2710
|
+
throw new Error(`Cannot find the \`tsconfig.json\` configuration file at ${joinPaths.joinPaths(projectRoot, tsconfig ?? "tsconfig.json")}`);
|
|
2711
|
+
}
|
|
2712
|
+
const parsedCommandLine = ts2__default.default.parseJsonConfigFileContent(defu3__default.default(tsconfigRaw ?? {}, tsconfigJson), host, append.appendPath(projectRoot, workspaceRoot));
|
|
2713
|
+
if (parsedCommandLine.errors.length > 0) {
|
|
2714
|
+
const errorMessage = `Cannot parse the TypeScript compiler options. Please investigate the following issues:
|
|
2715
|
+
${parsedCommandLine.errors.map((error) => `- ${(error.category !== void 0 && error.code ? `[${error.category}-${error.code}]: ` : "") + error.messageText.toString()}`).join("\n")}
|
|
2716
|
+
`;
|
|
2717
|
+
throw new Error(errorMessage);
|
|
2718
|
+
}
|
|
2719
|
+
return {
|
|
2720
|
+
...parsedCommandLine,
|
|
2721
|
+
originalTsconfigJson: originalTsconfigJson ?? tsconfigJson,
|
|
2722
|
+
tsconfigJson,
|
|
2723
|
+
tsconfigFilePath
|
|
2724
|
+
};
|
|
2725
|
+
}
|
|
2726
|
+
chunkSHUYVCID_js.__name(getParsedTypeScriptConfig, "getParsedTypeScriptConfig");
|
|
2727
|
+
async function writeFile(log, filepath, content, skipFormat = false) {
|
|
2728
|
+
try {
|
|
2729
|
+
if (skipFormat) {
|
|
2730
|
+
await writeFile$1.writeFile(filepath, content);
|
|
2731
|
+
} else {
|
|
2732
|
+
const config = await prettier.resolveConfig(filepath);
|
|
2733
|
+
const formatted = await prettier.format(content, {
|
|
2734
|
+
...config ?? {},
|
|
2735
|
+
filepath
|
|
2736
|
+
});
|
|
2737
|
+
await writeFile$1.writeFile(filepath, formatted || "");
|
|
2738
|
+
}
|
|
2739
|
+
} catch (error) {
|
|
2740
|
+
log(types.LogLevelLabel.ERROR, `Failed to write file ${filepath} to disk
|
|
2741
|
+
${error?.message ? error.message : ""}`);
|
|
2742
|
+
}
|
|
2743
|
+
}
|
|
2744
|
+
chunkSHUYVCID_js.__name(writeFile, "writeFile");
|
|
2745
|
+
|
|
2746
|
+
// ../powerlines/src/internal/helpers/resolve-tsconfig.ts
|
|
2858
2747
|
async function resolveTsconfigChanges(context) {
|
|
2859
2748
|
const tsconfig$1 = getParsedTypeScriptConfig(context.workspaceConfig.workspaceRoot, context.config.projectRoot, context.config.tsconfig, context.config.tsconfigRaw);
|
|
2860
2749
|
const tsconfigFilePath = getTsconfigFilePath(context.workspaceConfig.workspaceRoot, context.config.projectRoot, context.config.tsconfig);
|
|
@@ -3029,8 +2918,28 @@ async function resolveTsconfig(context) {
|
|
|
3029
2918
|
context.tsconfig.tsconfigJson.compilerOptions.strict = false;
|
|
3030
2919
|
}
|
|
3031
2920
|
chunkSHUYVCID_js.__name(resolveTsconfig, "resolveTsconfig");
|
|
2921
|
+
function getBaseFileHeader(context) {
|
|
2922
|
+
return `
|
|
2923
|
+
// Generated with ${titleCase.titleCase(context.config.framework)}
|
|
2924
|
+
// Note: Do not edit this file manually - it will be overwritten automatically
|
|
2925
|
+
`;
|
|
2926
|
+
}
|
|
2927
|
+
chunkSHUYVCID_js.__name(getBaseFileHeader, "getBaseFileHeader");
|
|
2928
|
+
function getFileHeader(context, options = {}) {
|
|
2929
|
+
const { directive = null, prettierIgnore = false } = options;
|
|
2930
|
+
return `/* eslint-disable */
|
|
2931
|
+
// biome-ignore lint: disable
|
|
2932
|
+
${prettierIgnore ? `// prettier-ignore` : ""}${directive ? `
|
|
2933
|
+
|
|
2934
|
+
${directive}
|
|
2935
|
+
` : "\n"}
|
|
2936
|
+
${getBaseFileHeader(context)}
|
|
3032
2937
|
|
|
3033
|
-
|
|
2938
|
+
`;
|
|
2939
|
+
}
|
|
2940
|
+
chunkSHUYVCID_js.__name(getFileHeader, "getFileHeader");
|
|
2941
|
+
|
|
2942
|
+
// ../powerlines/src/api.ts
|
|
3034
2943
|
var PowerlinesAPI = class _PowerlinesAPI {
|
|
3035
2944
|
static {
|
|
3036
2945
|
chunkSHUYVCID_js.__name(this, "PowerlinesAPI");
|
|
@@ -3095,8 +3004,8 @@ ${context.entry.map((entry) => `- ${entry.input.file || entry.file}${entry.outpu
|
|
|
3095
3004
|
context.log(types.LogLevelLabel.TRACE, `Powerlines configuration has been resolved:
|
|
3096
3005
|
|
|
3097
3006
|
${console.formatLogMessage(context.config)}`);
|
|
3098
|
-
context.fs[
|
|
3099
|
-
await
|
|
3007
|
+
context.fs[chunkUOTRU26N_js.__VFS_INIT__]();
|
|
3008
|
+
await chunkUOTRU26N_js.writeMetaFile(context);
|
|
3100
3009
|
context.persistedMeta = context.meta;
|
|
3101
3010
|
if (!exists.existsSync(context.cachePath)) {
|
|
3102
3011
|
await helpers.createDirectory(context.cachePath);
|
|
@@ -3105,20 +3014,129 @@ ${console.formatLogMessage(context.config)}`);
|
|
|
3105
3014
|
await helpers.createDirectory(context.dataPath);
|
|
3106
3015
|
}
|
|
3107
3016
|
await this.callPreHook(context, "prepare");
|
|
3108
|
-
|
|
3109
|
-
context.log(types.LogLevelLabel.TRACE, "Generating built-in barrel file");
|
|
3110
|
-
}
|
|
3017
|
+
await this.callNormalHook(context, "prepare");
|
|
3111
3018
|
if (context.config.output.dts !== false) {
|
|
3112
|
-
|
|
3019
|
+
context.log(types.LogLevelLabel.TRACE, `Preparing the TypeScript definitions for the Powerlines project.`);
|
|
3020
|
+
context.log(types.LogLevelLabel.TRACE, "Transforming built-ins runtime modules files.");
|
|
3021
|
+
const builtinFilePaths = await Promise.all((await context.getBuiltins()).map(async (file) => {
|
|
3022
|
+
const result2 = await core.transformAsync(file.code.toString(), {
|
|
3023
|
+
highlightCode: true,
|
|
3024
|
+
code: true,
|
|
3025
|
+
ast: false,
|
|
3026
|
+
cloneInputAst: false,
|
|
3027
|
+
comments: true,
|
|
3028
|
+
sourceType: "module",
|
|
3029
|
+
configFile: false,
|
|
3030
|
+
babelrc: false,
|
|
3031
|
+
envName: context.config.mode,
|
|
3032
|
+
caller: {
|
|
3033
|
+
name: "powerlines"
|
|
3034
|
+
},
|
|
3035
|
+
...context.config.transform.babel,
|
|
3036
|
+
filename: file.path,
|
|
3037
|
+
plugins: [
|
|
3038
|
+
[
|
|
3039
|
+
"@babel/plugin-syntax-typescript"
|
|
3040
|
+
],
|
|
3041
|
+
[
|
|
3042
|
+
moduleResolverBabelPlugin(context)
|
|
3043
|
+
]
|
|
3044
|
+
]
|
|
3045
|
+
});
|
|
3046
|
+
if (!result2?.code) {
|
|
3047
|
+
throw new Error(`Powerlines - Generate Types failed to compile ${file.id}`);
|
|
3048
|
+
}
|
|
3049
|
+
context.log(types.LogLevelLabel.TRACE, `Writing transformed built-in runtime file ${file.id}.`);
|
|
3050
|
+
await context.writeBuiltin(result2.code, file.id, file.path);
|
|
3051
|
+
return file.path;
|
|
3052
|
+
}));
|
|
3053
|
+
const typescriptPath = await resolve.resolvePackage("typescript");
|
|
3054
|
+
if (!typescriptPath) {
|
|
3055
|
+
throw new Error("Could not resolve TypeScript package location. Please ensure TypeScript is installed.");
|
|
3056
|
+
}
|
|
3057
|
+
const files = builtinFilePaths.reduce((ret, fileName) => {
|
|
3058
|
+
const formatted = replace.replacePath(fileName, context.workspaceConfig.workspaceRoot);
|
|
3059
|
+
if (!ret.includes(formatted)) {
|
|
3060
|
+
ret.push(formatted);
|
|
3061
|
+
}
|
|
3062
|
+
return ret;
|
|
3063
|
+
}, [
|
|
3064
|
+
joinPaths.joinPaths(typescriptPath, "lib", "lib.esnext.full.d.ts")
|
|
3065
|
+
]);
|
|
3066
|
+
context.log(types.LogLevelLabel.TRACE, "Parsing TypeScript configuration for the Powerlines project.");
|
|
3067
|
+
const resolvedTsconfig = getParsedTypeScriptConfig(context.workspaceConfig.workspaceRoot, context.config.projectRoot, context.tsconfig.tsconfigFilePath, defu3__default.default({
|
|
3068
|
+
compilerOptions: {
|
|
3069
|
+
strict: false,
|
|
3070
|
+
noEmit: false,
|
|
3071
|
+
declaration: true,
|
|
3072
|
+
declarationMap: false,
|
|
3073
|
+
emitDeclarationOnly: true,
|
|
3074
|
+
skipLibCheck: true
|
|
3075
|
+
},
|
|
3076
|
+
exclude: [
|
|
3077
|
+
"node_modules",
|
|
3078
|
+
"dist"
|
|
3079
|
+
],
|
|
3080
|
+
include: files
|
|
3081
|
+
}, context.config.tsconfigRaw ?? {}));
|
|
3082
|
+
resolvedTsconfig.options.configFilePath = joinPaths.joinPaths(context.workspaceConfig.workspaceRoot, context.tsconfig.tsconfigFilePath);
|
|
3083
|
+
resolvedTsconfig.options.pathsBasePath = context.workspaceConfig.workspaceRoot;
|
|
3084
|
+
resolvedTsconfig.options.suppressOutputPathCheck = true;
|
|
3085
|
+
let generatedTypes = await emitTypes(context, resolvedTsconfig, files);
|
|
3086
|
+
context.log(types.LogLevelLabel.TRACE, `Generating TypeScript declaration file in ${context.config.output.dts}.`);
|
|
3087
|
+
const directives = [];
|
|
3088
|
+
let result = await this.callPreHook(context, "generateTypes", generatedTypes);
|
|
3089
|
+
if (result) {
|
|
3090
|
+
if (isSetObject.isSetObject(result)) {
|
|
3091
|
+
generatedTypes = result.code;
|
|
3092
|
+
if (Array.isArray(result.directives) && result.directives.length > 0) {
|
|
3093
|
+
directives.push(...result.directives);
|
|
3094
|
+
}
|
|
3095
|
+
} else if (isSetString.isSetString(result)) {
|
|
3096
|
+
generatedTypes = result;
|
|
3097
|
+
}
|
|
3098
|
+
}
|
|
3099
|
+
result = await this.callNormalHook(context, "generateTypes", generatedTypes);
|
|
3100
|
+
if (result) {
|
|
3101
|
+
if (isSetObject.isSetObject(result)) {
|
|
3102
|
+
generatedTypes = result.code;
|
|
3103
|
+
if (Array.isArray(result.directives) && result.directives.length > 0) {
|
|
3104
|
+
directives.push(...result.directives);
|
|
3105
|
+
}
|
|
3106
|
+
} else if (isSetString.isSetString(result)) {
|
|
3107
|
+
generatedTypes = result;
|
|
3108
|
+
}
|
|
3109
|
+
}
|
|
3110
|
+
result = await this.callPostHook(context, "generateTypes", generatedTypes);
|
|
3111
|
+
if (result) {
|
|
3112
|
+
if (isSetObject.isSetObject(result)) {
|
|
3113
|
+
generatedTypes = result.code;
|
|
3114
|
+
if (Array.isArray(result.directives) && result.directives.length > 0) {
|
|
3115
|
+
directives.push(...result.directives);
|
|
3116
|
+
}
|
|
3117
|
+
} else if (isSetString.isSetString(result)) {
|
|
3118
|
+
generatedTypes = result;
|
|
3119
|
+
}
|
|
3120
|
+
}
|
|
3121
|
+
await context.fs.writeFile(context.config.output.dts, `${directives ? `${directives.map((directive) => `/// <reference types="${directive}" />`).join("\n")}
|
|
3122
|
+
|
|
3123
|
+
` : ""}${getFileHeader(context, {
|
|
3124
|
+
directive: null,
|
|
3125
|
+
prettierIgnore: false
|
|
3126
|
+
})}
|
|
3127
|
+
|
|
3128
|
+
${formatTypes(generatedTypes)}
|
|
3129
|
+
`, {
|
|
3130
|
+
mode: "fs"
|
|
3131
|
+
});
|
|
3113
3132
|
}
|
|
3114
|
-
await this.callNormalHook(context, "prepare");
|
|
3115
3133
|
context.tsconfig = getParsedTypeScriptConfig(context.workspaceConfig.workspaceRoot, context.config.projectRoot, context.config.tsconfig);
|
|
3116
3134
|
if (!context.tsconfig) {
|
|
3117
3135
|
throw new Error("Failed to parse the TypeScript configuration file.");
|
|
3118
3136
|
}
|
|
3119
3137
|
await this.callPostHook(context, "prepare");
|
|
3120
|
-
await
|
|
3121
|
-
context.fs[
|
|
3138
|
+
await chunkUOTRU26N_js.writeMetaFile(context);
|
|
3139
|
+
context.fs[chunkUOTRU26N_js.__VFS_REVERT__]();
|
|
3122
3140
|
});
|
|
3123
3141
|
this.context.log(types.LogLevelLabel.INFO, "Powerlines API has been prepared successfully");
|
|
3124
3142
|
}
|
|
@@ -3277,7 +3295,7 @@ ${console.formatLogMessage(context.config)}`);
|
|
|
3277
3295
|
this.context.log(types.LogLevelLabel.TRACE, "Powerlines finalize execution started");
|
|
3278
3296
|
await this.#executeEnvironments(async (context) => {
|
|
3279
3297
|
await this.callHook(context, "finalize");
|
|
3280
|
-
context.fs[
|
|
3298
|
+
context.fs[chunkUOTRU26N_js.__VFS_REVERT__]();
|
|
3281
3299
|
});
|
|
3282
3300
|
this.context.log(types.LogLevelLabel.TRACE, "Powerlines finalize execution completed");
|
|
3283
3301
|
}
|
|
@@ -3549,7 +3567,7 @@ var DEFAULT_ESBUILD_CONFIG = {
|
|
|
3549
3567
|
logLevel: "silent"
|
|
3550
3568
|
};
|
|
3551
3569
|
function extractESBuildConfig(context) {
|
|
3552
|
-
return
|
|
3570
|
+
return defu3__default.default({
|
|
3553
3571
|
alias: context.builtins.reduce((ret, id) => {
|
|
3554
3572
|
const path = context.fs.ids[id];
|
|
3555
3573
|
if (path) {
|
|
@@ -3592,7 +3610,7 @@ var DEFAULT_VITE_CONFIG = {
|
|
|
3592
3610
|
clearScreen: true
|
|
3593
3611
|
};
|
|
3594
3612
|
function extractViteConfig(context) {
|
|
3595
|
-
return
|
|
3613
|
+
return defu3__default.default({
|
|
3596
3614
|
resolve: {
|
|
3597
3615
|
alias: context.builtins.reduce((ret, id) => {
|
|
3598
3616
|
const path = context.fs.ids[id];
|
|
@@ -3629,6 +3647,19 @@ function extractViteConfig(context) {
|
|
|
3629
3647
|
}, DEFAULT_VITE_CONFIG);
|
|
3630
3648
|
}
|
|
3631
3649
|
chunkSHUYVCID_js.__name(extractViteConfig, "extractViteConfig");
|
|
3650
|
+
function getString(code) {
|
|
3651
|
+
if (!code) {
|
|
3652
|
+
return "";
|
|
3653
|
+
}
|
|
3654
|
+
if (isString.isString(code)) {
|
|
3655
|
+
return code;
|
|
3656
|
+
}
|
|
3657
|
+
if (isSetObject.isSetObject(code) && "code" in code) {
|
|
3658
|
+
return code.code;
|
|
3659
|
+
}
|
|
3660
|
+
return code.toString();
|
|
3661
|
+
}
|
|
3662
|
+
chunkSHUYVCID_js.__name(getString, "getString");
|
|
3632
3663
|
var NON_NODE_MODULE_REGEX = /^[A-Z]:[/\\]|^\.{0,2}\/|^\.{1,2}$/;
|
|
3633
3664
|
async function handleResolveId(context, args, options = {}) {
|
|
3634
3665
|
if (args.id) {
|
|
@@ -3833,7 +3864,7 @@ var vite = unplugin.createVitePlugin(createUnpluginFactory("vite", (api, plugin)
|
|
|
3833
3864
|
api.context.config.mode = environmentChecks.isDevelopmentMode(env.mode) ? "development" : environmentChecks.isTestMode(env.mode) ? "test" : "production";
|
|
3834
3865
|
const environment = await api.context.getEnvironment();
|
|
3835
3866
|
const result = await api.callHook(environment, "config");
|
|
3836
|
-
return
|
|
3867
|
+
return defu3__default.default(extractViteConfig(api.context), result?.build ?? {}, config);
|
|
3837
3868
|
},
|
|
3838
3869
|
async configResolved(_config) {
|
|
3839
3870
|
const environment = await api.context.getEnvironment();
|
|
@@ -3910,7 +3941,7 @@ function withExecutor(command, executorFn) {
|
|
|
3910
3941
|
throw new Error("The executor requires `projectsConfigurations` on the context object.");
|
|
3911
3942
|
}
|
|
3912
3943
|
const projectConfig = context.projectsConfigurations.projects[context.projectName];
|
|
3913
|
-
const api = await src_default.from(workspaceConfig.workspaceRoot,
|
|
3944
|
+
const api = await src_default.from(workspaceConfig.workspaceRoot, defu3__default.default({
|
|
3914
3945
|
root: projectConfig.root,
|
|
3915
3946
|
type: projectConfig.projectType,
|
|
3916
3947
|
sourceRoot: projectConfig.sourceRoot,
|
|
@@ -3923,7 +3954,7 @@ function withExecutor(command, executorFn) {
|
|
|
3923
3954
|
}
|
|
3924
3955
|
}, options));
|
|
3925
3956
|
try {
|
|
3926
|
-
return await Promise.resolve(executorFn(
|
|
3957
|
+
return await Promise.resolve(executorFn(defu3__default.default({
|
|
3927
3958
|
projectName: context.projectName,
|
|
3928
3959
|
options,
|
|
3929
3960
|
workspaceConfig,
|