@storm-software/eslint 0.148.20 → 0.148.21
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/README.md +1 -1
- package/dist/{chunk-DKJ6VCEL.js → chunk-2AFQKKSX.js} +91 -63
- package/dist/{chunk-G4SCUHQO.js → chunk-5ALLOW52.js} +2 -5
- package/dist/{chunk-D3EN5HD2.js → chunk-DLORY5AL.js} +4 -6
- package/dist/{chunk-SZFP4QOA.js → chunk-HO6DXXZX.js} +24 -45
- package/dist/{chunk-G7QVU75O.js → chunk-RU7GXBCG.js} +30 -42
- package/dist/{chunk-7JRBTALJ.js → chunk-WYU7W4UW.js} +21 -13
- package/dist/{chunk-FTXILLLE.js → chunk-Z2ZQTZDC.js} +2 -6
- package/dist/preset.js +603 -1147
- package/dist/utils/banner-plugin.js +2 -3
- package/dist/utils/combine.js +0 -5
- package/dist/utils/constants.js +0 -1
- package/dist/utils/correct-paths.js +1 -2
- package/dist/utils/find-workspace-root.js +2 -3
- package/dist/utils/format-config.js +1 -2
- package/dist/utils/get-file-banner.js +1 -2
- package/dist/utils/helpers.js +1 -2
- package/dist/utils/index.js +1 -2
- package/dist/utils/tsconfig-path.js +2 -3
- package/package.json +1 -1
- package/dist/chunk-SHUYVCID.js +0 -6
package/README.md
CHANGED
|
@@ -21,7 +21,7 @@ This package is part of the <b>⚡Storm-Ops</b> monorepo. The Storm-Ops packages
|
|
|
21
21
|
|
|
22
22
|
<h3 align="center">💻 Visit <a href="https://stormsoftware.com" target="_blank">stormsoftware.com</a> to stay up to date with this developer</h3><br />
|
|
23
23
|
|
|
24
|
-
[](https://prettier.io/) [](http://nx.dev/) [](https://nextjs.org/) [](http://commitizen.github.io/cz-cli/)  [](https://fumadocs.vercel.app/) 
|
|
25
25
|
|
|
26
26
|
<!-- prettier-ignore-start -->
|
|
27
27
|
<!-- markdownlint-disable -->
|
|
@@ -1,12 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
getFileBanner
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-5ALLOW52.js";
|
|
4
4
|
import {
|
|
5
5
|
GLOB_SRC
|
|
6
6
|
} from "./chunk-EJ2FSS2J.js";
|
|
7
|
-
import {
|
|
8
|
-
__name
|
|
9
|
-
} from "./chunk-SHUYVCID.js";
|
|
10
7
|
|
|
11
8
|
// src/utils/banner-plugin.ts
|
|
12
9
|
import { ESLintUtils } from "@typescript-eslint/utils";
|
|
@@ -18,19 +15,17 @@ function match(actual, expected) {
|
|
|
18
15
|
return expected === actual;
|
|
19
16
|
}
|
|
20
17
|
}
|
|
21
|
-
__name(match, "match");
|
|
22
18
|
function excludeShebangs(comments) {
|
|
23
19
|
return comments.filter((comment) => {
|
|
24
20
|
return comment.type !== "Shebang";
|
|
25
21
|
});
|
|
26
22
|
}
|
|
27
|
-
__name(excludeShebangs, "excludeShebangs");
|
|
28
23
|
function getLeadingComments(context, node) {
|
|
29
|
-
const all = excludeShebangs(
|
|
24
|
+
const all = excludeShebangs(
|
|
25
|
+
context.getSourceCode().getAllComments(node.body.length ? node.body[0] : node)
|
|
26
|
+
);
|
|
30
27
|
if (all[0].type.toLowerCase() === "block") {
|
|
31
|
-
return [
|
|
32
|
-
all[0]
|
|
33
|
-
];
|
|
28
|
+
return [all[0]];
|
|
34
29
|
}
|
|
35
30
|
let i = 1;
|
|
36
31
|
for (i = 1; i < all.length; ++i) {
|
|
@@ -41,7 +36,6 @@ function getLeadingComments(context, node) {
|
|
|
41
36
|
}
|
|
42
37
|
return all.slice(0, i);
|
|
43
38
|
}
|
|
44
|
-
__name(getLeadingComments, "getLeadingComments");
|
|
45
39
|
function genCommentBody(commentType, textArray, eol, numNewlines) {
|
|
46
40
|
const eols = eol.repeat(numNewlines);
|
|
47
41
|
if (commentType === "block") {
|
|
@@ -50,31 +44,30 @@ function genCommentBody(commentType, textArray, eol, numNewlines) {
|
|
|
50
44
|
return "//" + textArray.join(eol + "//") + eols;
|
|
51
45
|
}
|
|
52
46
|
}
|
|
53
|
-
__name(genCommentBody, "genCommentBody");
|
|
54
47
|
function genCommentsRange(context, comments, eol) {
|
|
55
48
|
const start = comments[0].range[0];
|
|
56
49
|
let end = comments.slice(-1)[0].range[1];
|
|
57
50
|
if (context.getSourceCode().text[end] === eol) {
|
|
58
51
|
end += eol.length;
|
|
59
52
|
}
|
|
60
|
-
return [
|
|
61
|
-
start,
|
|
62
|
-
end
|
|
63
|
-
];
|
|
53
|
+
return [start, end];
|
|
64
54
|
}
|
|
65
|
-
__name(genCommentsRange, "genCommentsRange");
|
|
66
55
|
function genPrependFixer(commentType, node, bannerLines, eol, numNewlines) {
|
|
67
56
|
return function(fixer) {
|
|
68
|
-
return fixer.insertTextBefore(
|
|
57
|
+
return fixer.insertTextBefore(
|
|
58
|
+
node,
|
|
59
|
+
genCommentBody(commentType, bannerLines, eol, numNewlines)
|
|
60
|
+
);
|
|
69
61
|
};
|
|
70
62
|
}
|
|
71
|
-
__name(genPrependFixer, "genPrependFixer");
|
|
72
63
|
function genReplaceFixer(commentType, context, leadingComments, bannerLines, eol, numNewlines) {
|
|
73
64
|
return function(fixer) {
|
|
74
|
-
return fixer.replaceTextRange(
|
|
65
|
+
return fixer.replaceTextRange(
|
|
66
|
+
genCommentsRange(context, leadingComments, eol),
|
|
67
|
+
genCommentBody(commentType, bannerLines, eol, numNewlines)
|
|
68
|
+
);
|
|
75
69
|
};
|
|
76
70
|
}
|
|
77
|
-
__name(genReplaceFixer, "genReplaceFixer");
|
|
78
71
|
function getEOL(options) {
|
|
79
72
|
if (options.lineEndings === "unix") {
|
|
80
73
|
return "\n";
|
|
@@ -84,7 +77,6 @@ function getEOL(options) {
|
|
|
84
77
|
}
|
|
85
78
|
return os.EOL;
|
|
86
79
|
}
|
|
87
|
-
__name(getEOL, "getEOL");
|
|
88
80
|
function hasBanner(commentType = "block", src, eol) {
|
|
89
81
|
if (src.startsWith("#!")) {
|
|
90
82
|
const bannerLines = src.split(eol);
|
|
@@ -102,7 +94,6 @@ function hasBanner(commentType = "block", src, eol) {
|
|
|
102
94
|
}
|
|
103
95
|
return commentType === "block" && src.startsWith("/*") || commentType === "line" && src.startsWith("//") || commentType !== "block" && commentType !== "line" && commentType && src.startsWith(commentType);
|
|
104
96
|
}
|
|
105
|
-
__name(hasBanner, "hasBanner");
|
|
106
97
|
function matchesLineEndings(src, num) {
|
|
107
98
|
for (let j = 0; j < num; ++j) {
|
|
108
99
|
const m = src.match(/^(\r\n|\r|\n)/);
|
|
@@ -114,8 +105,9 @@ function matchesLineEndings(src, num) {
|
|
|
114
105
|
}
|
|
115
106
|
return true;
|
|
116
107
|
}
|
|
117
|
-
|
|
118
|
-
|
|
108
|
+
var bannerRule = ESLintUtils.RuleCreator(
|
|
109
|
+
() => `https://docs.stormsoftware.com/eslint/rules/banner`
|
|
110
|
+
)({
|
|
119
111
|
name: "banner",
|
|
120
112
|
meta: {
|
|
121
113
|
docs: {
|
|
@@ -143,10 +135,7 @@ var bannerRule = ESLintUtils.RuleCreator(() => `https://docs.stormsoftware.com/e
|
|
|
143
135
|
},
|
|
144
136
|
lineEndings: {
|
|
145
137
|
type: "string",
|
|
146
|
-
enum: [
|
|
147
|
-
"unix",
|
|
148
|
-
"windows"
|
|
149
|
-
],
|
|
138
|
+
enum: ["unix", "windows"],
|
|
150
139
|
description: "The type of line endings to use. Defaults to the system default"
|
|
151
140
|
}
|
|
152
141
|
},
|
|
@@ -170,20 +159,25 @@ var bannerRule = ESLintUtils.RuleCreator(() => `https://docs.stormsoftware.com/e
|
|
|
170
159
|
lineEndings: "unix"
|
|
171
160
|
}
|
|
172
161
|
],
|
|
173
|
-
create(context, [
|
|
162
|
+
create(context, [
|
|
163
|
+
{
|
|
164
|
+
banner,
|
|
165
|
+
repositoryName = "",
|
|
166
|
+
commentType = "block",
|
|
167
|
+
numNewlines = 2,
|
|
168
|
+
lineEndings = "unix"
|
|
169
|
+
}
|
|
170
|
+
]) {
|
|
174
171
|
if (!banner) {
|
|
175
172
|
banner = getFileBanner(repositoryName);
|
|
176
173
|
}
|
|
177
174
|
const options = context.options;
|
|
178
|
-
const eol = getEOL({
|
|
179
|
-
lineEndings,
|
|
180
|
-
...options
|
|
181
|
-
});
|
|
175
|
+
const eol = getEOL({ lineEndings, ...options });
|
|
182
176
|
const canFix = true;
|
|
183
177
|
const bannerLines = banner.split(/\r?\n/);
|
|
184
178
|
let fixLines = bannerLines;
|
|
185
179
|
return {
|
|
186
|
-
Program:
|
|
180
|
+
Program: function(node) {
|
|
187
181
|
if (!hasBanner(commentType, context.sourceCode.getText(), eol)) {
|
|
188
182
|
context.report({
|
|
189
183
|
loc: node.loc,
|
|
@@ -205,7 +199,14 @@ var bannerRule = ESLintUtils.RuleCreator(() => `https://docs.stormsoftware.com/e
|
|
|
205
199
|
data: {
|
|
206
200
|
commentType
|
|
207
201
|
},
|
|
208
|
-
fix: canFix ? genReplaceFixer(
|
|
202
|
+
fix: canFix ? genReplaceFixer(
|
|
203
|
+
commentType,
|
|
204
|
+
context,
|
|
205
|
+
leadingComments,
|
|
206
|
+
fixLines,
|
|
207
|
+
eol,
|
|
208
|
+
numNewlines
|
|
209
|
+
) : null
|
|
209
210
|
});
|
|
210
211
|
} else {
|
|
211
212
|
if (commentType === "line") {
|
|
@@ -213,7 +214,14 @@ var bannerRule = ESLintUtils.RuleCreator(() => `https://docs.stormsoftware.com/e
|
|
|
213
214
|
context.report({
|
|
214
215
|
loc: node.loc,
|
|
215
216
|
messageId: "missingBanner",
|
|
216
|
-
fix: canFix ? genReplaceFixer(
|
|
217
|
+
fix: canFix ? genReplaceFixer(
|
|
218
|
+
commentType,
|
|
219
|
+
context,
|
|
220
|
+
leadingComments,
|
|
221
|
+
fixLines,
|
|
222
|
+
eol,
|
|
223
|
+
numNewlines
|
|
224
|
+
) : null
|
|
217
225
|
});
|
|
218
226
|
return;
|
|
219
227
|
}
|
|
@@ -222,23 +230,38 @@ var bannerRule = ESLintUtils.RuleCreator(() => `https://docs.stormsoftware.com/e
|
|
|
222
230
|
context.report({
|
|
223
231
|
loc: node.loc,
|
|
224
232
|
messageId: "incorrectBanner",
|
|
225
|
-
fix: canFix ? genReplaceFixer(
|
|
233
|
+
fix: canFix ? genReplaceFixer(
|
|
234
|
+
commentType,
|
|
235
|
+
context,
|
|
236
|
+
leadingComments,
|
|
237
|
+
fixLines,
|
|
238
|
+
eol,
|
|
239
|
+
numNewlines
|
|
240
|
+
) : null
|
|
226
241
|
});
|
|
227
242
|
return;
|
|
228
243
|
}
|
|
229
244
|
}
|
|
230
|
-
const postLineBanner = context.getSourceCode().text.substr(
|
|
245
|
+
const postLineBanner = context.getSourceCode().text.substr(
|
|
246
|
+
leadingComments[bannerLines.length - 1].range[1],
|
|
247
|
+
(numNewlines ?? 1) * 2
|
|
248
|
+
);
|
|
231
249
|
if (!matchesLineEndings(postLineBanner, numNewlines)) {
|
|
232
250
|
context.report({
|
|
233
251
|
loc: node.loc,
|
|
234
252
|
messageId: "noNewlineAfterBanner",
|
|
235
|
-
fix: canFix ? genReplaceFixer(
|
|
253
|
+
fix: canFix ? genReplaceFixer(
|
|
254
|
+
commentType,
|
|
255
|
+
context,
|
|
256
|
+
leadingComments,
|
|
257
|
+
fixLines,
|
|
258
|
+
eol,
|
|
259
|
+
numNewlines
|
|
260
|
+
) : null
|
|
236
261
|
});
|
|
237
262
|
}
|
|
238
263
|
} else {
|
|
239
|
-
let leadingLines = [
|
|
240
|
-
leadingComments[0].value
|
|
241
|
-
];
|
|
264
|
+
let leadingLines = [leadingComments[0].value];
|
|
242
265
|
if (bannerLines.length > 1) {
|
|
243
266
|
leadingLines = leadingComments[0].value.split(/\r?\n/);
|
|
244
267
|
}
|
|
@@ -253,29 +276,44 @@ var bannerRule = ESLintUtils.RuleCreator(() => `https://docs.stormsoftware.com/e
|
|
|
253
276
|
}
|
|
254
277
|
if (hasError) {
|
|
255
278
|
if (canFix && bannerLines.length > 1) {
|
|
256
|
-
fixLines = [
|
|
257
|
-
fixLines.join(eol)
|
|
258
|
-
];
|
|
279
|
+
fixLines = [fixLines.join(eol)];
|
|
259
280
|
}
|
|
260
281
|
context.report({
|
|
261
282
|
loc: node.loc,
|
|
262
283
|
messageId: "incorrectBanner",
|
|
263
|
-
fix: canFix ? genReplaceFixer(
|
|
284
|
+
fix: canFix ? genReplaceFixer(
|
|
285
|
+
commentType,
|
|
286
|
+
context,
|
|
287
|
+
leadingComments,
|
|
288
|
+
fixLines,
|
|
289
|
+
eol,
|
|
290
|
+
numNewlines
|
|
291
|
+
) : null
|
|
264
292
|
});
|
|
265
293
|
} else {
|
|
266
|
-
const postBlockBanner = context.getSourceCode().text.substr(
|
|
294
|
+
const postBlockBanner = context.getSourceCode().text.substr(
|
|
295
|
+
leadingComments[0].range[1],
|
|
296
|
+
(numNewlines ?? 1) * 2
|
|
297
|
+
);
|
|
267
298
|
if (!matchesLineEndings(postBlockBanner, numNewlines)) {
|
|
268
299
|
context.report({
|
|
269
300
|
loc: node.loc,
|
|
270
301
|
messageId: "noNewlineAfterBanner",
|
|
271
|
-
fix: canFix ? genReplaceFixer(
|
|
302
|
+
fix: canFix ? genReplaceFixer(
|
|
303
|
+
commentType,
|
|
304
|
+
context,
|
|
305
|
+
leadingComments,
|
|
306
|
+
fixLines,
|
|
307
|
+
eol,
|
|
308
|
+
numNewlines
|
|
309
|
+
) : null
|
|
272
310
|
});
|
|
273
311
|
}
|
|
274
312
|
}
|
|
275
313
|
}
|
|
276
314
|
}
|
|
277
315
|
}
|
|
278
|
-
}
|
|
316
|
+
}
|
|
279
317
|
};
|
|
280
318
|
}
|
|
281
319
|
});
|
|
@@ -292,12 +330,8 @@ var plugin = {
|
|
|
292
330
|
};
|
|
293
331
|
plugin.configs && (plugin.configs.recommended = {
|
|
294
332
|
name: "banner/recommended",
|
|
295
|
-
plugins: {
|
|
296
|
-
|
|
297
|
-
},
|
|
298
|
-
files: [
|
|
299
|
-
GLOB_SRC
|
|
300
|
-
],
|
|
333
|
+
plugins: { banner: plugin },
|
|
334
|
+
files: [GLOB_SRC],
|
|
301
335
|
ignores: [
|
|
302
336
|
"!**/docs/**/*",
|
|
303
337
|
"!**/crates/**/*",
|
|
@@ -310,13 +344,7 @@ plugin.configs && (plugin.configs.recommended = {
|
|
|
310
344
|
"!**/.storm/**/*"
|
|
311
345
|
],
|
|
312
346
|
rules: {
|
|
313
|
-
"banner/banner": [
|
|
314
|
-
"error",
|
|
315
|
-
{
|
|
316
|
-
commentType: "block",
|
|
317
|
-
numNewlines: 2
|
|
318
|
-
}
|
|
319
|
-
]
|
|
347
|
+
"banner/banner": ["error", { commentType: "block", numNewlines: 2 }]
|
|
320
348
|
}
|
|
321
349
|
});
|
|
322
350
|
var banner_plugin_default = plugin;
|
|
@@ -1,12 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
ACRONYMS_LIST
|
|
3
3
|
} from "./chunk-EJ2FSS2J.js";
|
|
4
|
-
import {
|
|
5
|
-
__name
|
|
6
|
-
} from "./chunk-SHUYVCID.js";
|
|
7
4
|
|
|
8
5
|
// src/utils/get-file-banner.ts
|
|
9
|
-
var getFileBanner =
|
|
6
|
+
var getFileBanner = (repositoryName = "") => {
|
|
10
7
|
if (!repositoryName) {
|
|
11
8
|
repositoryName = process.env.STORM_NAME || "";
|
|
12
9
|
}
|
|
@@ -44,7 +41,7 @@ ${padding}\u26A1 Storm Software ${titleName ? `- ${titleName}` : ""}
|
|
|
44
41
|
SPDX-License-Identifier: ${license}
|
|
45
42
|
|
|
46
43
|
------------------------------------------------------------------- `;
|
|
47
|
-
}
|
|
44
|
+
};
|
|
48
45
|
|
|
49
46
|
export {
|
|
50
47
|
getFileBanner
|
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
joinPaths
|
|
3
|
-
} from "./chunk-
|
|
4
|
-
import {
|
|
5
|
-
__name
|
|
6
|
-
} from "./chunk-SHUYVCID.js";
|
|
3
|
+
} from "./chunk-RU7GXBCG.js";
|
|
7
4
|
|
|
8
5
|
// src/utils/tsconfig-path.ts
|
|
9
6
|
import { existsSync } from "node:fs";
|
|
@@ -16,11 +13,12 @@ function getTsConfigPath(basePath = "./") {
|
|
|
16
13
|
} else if (existsSync(joinPaths(basePath, "tsconfig.lib.json"))) {
|
|
17
14
|
tsconfigPath = "tsconfig.lib.json";
|
|
18
15
|
} else {
|
|
19
|
-
console.warn(
|
|
16
|
+
console.warn(
|
|
17
|
+
"No tsconfig.json found. Consider adding a tsconfig.json file to your project's ESLint configuration."
|
|
18
|
+
);
|
|
20
19
|
}
|
|
21
20
|
return tsconfigPath;
|
|
22
21
|
}
|
|
23
|
-
__name(getTsConfigPath, "getTsConfigPath");
|
|
24
22
|
|
|
25
23
|
export {
|
|
26
24
|
getTsConfigPath
|
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
__name
|
|
3
|
-
} from "./chunk-SHUYVCID.js";
|
|
4
|
-
|
|
5
1
|
// src/utils/helpers.ts
|
|
6
2
|
import { isPackageExists } from "local-pkg";
|
|
7
3
|
import process from "node:process";
|
|
@@ -12,81 +8,64 @@ var parserPlain = {
|
|
|
12
8
|
meta: {
|
|
13
9
|
name: "parser-plain"
|
|
14
10
|
},
|
|
15
|
-
parseForESLint:
|
|
11
|
+
parseForESLint: (code) => ({
|
|
16
12
|
ast: {
|
|
17
13
|
body: [],
|
|
18
14
|
comments: [],
|
|
19
|
-
loc: {
|
|
20
|
-
|
|
21
|
-
start: 0
|
|
22
|
-
},
|
|
23
|
-
range: [
|
|
24
|
-
0,
|
|
25
|
-
code.length
|
|
26
|
-
],
|
|
15
|
+
loc: { end: code.length, start: 0 },
|
|
16
|
+
range: [0, code.length],
|
|
27
17
|
tokens: [],
|
|
28
18
|
type: "Program"
|
|
29
19
|
},
|
|
30
20
|
scopeManager: null,
|
|
31
|
-
services: {
|
|
32
|
-
isPlain: true
|
|
33
|
-
},
|
|
21
|
+
services: { isPlain: true },
|
|
34
22
|
visitorKeys: {
|
|
35
23
|
Program: []
|
|
36
24
|
}
|
|
37
|
-
})
|
|
25
|
+
})
|
|
38
26
|
};
|
|
39
27
|
function isInGitHooksOrLintStaged() {
|
|
40
28
|
return !!(process.env.GIT_PARAMS || process.env.VSCODE_GIT_COMMAND || process.env.npm_lifecycle_script?.startsWith("lint-staged") || process.env.npm_lifecycle_script?.startsWith("lefthook") || process.env.npm_lifecycle_script === "push");
|
|
41
29
|
}
|
|
42
|
-
__name(isInGitHooksOrLintStaged, "isInGitHooksOrLintStaged");
|
|
43
30
|
function isInEditorEnv() {
|
|
44
31
|
if (process.env.CI) return false;
|
|
45
32
|
if (isInGitHooksOrLintStaged()) return false;
|
|
46
33
|
return !!(process.env.VSCODE_PID || process.env.VSCODE_CWD || process.env.JETBRAINS_IDE || process.env.VIM || process.env.NVIM);
|
|
47
34
|
}
|
|
48
|
-
__name(isInEditorEnv, "isInEditorEnv");
|
|
49
35
|
async function interopDefault(m) {
|
|
50
36
|
const resolved = await m;
|
|
51
37
|
return resolved.default || resolved;
|
|
52
38
|
}
|
|
53
|
-
__name(interopDefault, "interopDefault");
|
|
54
39
|
function isPackageInScope(name) {
|
|
55
|
-
return isPackageExists(name, {
|
|
56
|
-
paths: [
|
|
57
|
-
scopeUrl
|
|
58
|
-
]
|
|
59
|
-
});
|
|
40
|
+
return isPackageExists(name, { paths: [scopeUrl] });
|
|
60
41
|
}
|
|
61
|
-
__name(isPackageInScope, "isPackageInScope");
|
|
62
42
|
async function ensurePackages(packages) {
|
|
63
|
-
if (process.env.CI || process.stdout.isTTY === false || isCwdInScope === false)
|
|
64
|
-
|
|
43
|
+
if (process.env.CI || process.stdout.isTTY === false || isCwdInScope === false)
|
|
44
|
+
return;
|
|
45
|
+
const nonExistingPackages = packages.filter(
|
|
46
|
+
(i) => i && !isPackageInScope(i)
|
|
47
|
+
);
|
|
65
48
|
if (nonExistingPackages.length === 0) return;
|
|
66
49
|
const p = await import("@clack/prompts");
|
|
67
50
|
const result = await p.confirm({
|
|
68
51
|
message: `${nonExistingPackages.length === 1 ? "Package is" : "Packages are"} required for this config: ${nonExistingPackages.join(", ")}. Do you want to install them?`
|
|
69
52
|
});
|
|
70
|
-
if (result)
|
|
71
|
-
|
|
72
|
-
|
|
53
|
+
if (result)
|
|
54
|
+
await import("@antfu/install-pkg").then(
|
|
55
|
+
(i) => i.installPackage(nonExistingPackages, { dev: true })
|
|
56
|
+
);
|
|
73
57
|
}
|
|
74
|
-
__name(ensurePackages, "ensurePackages");
|
|
75
58
|
function renameRules(rules, map) {
|
|
76
|
-
return Object.fromEntries(
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
value
|
|
86
|
-
];
|
|
87
|
-
}));
|
|
59
|
+
return Object.fromEntries(
|
|
60
|
+
Object.entries(rules).map(([key, value]) => {
|
|
61
|
+
for (const [from, to] of Object.entries(map)) {
|
|
62
|
+
if (key.startsWith(`${from}/`))
|
|
63
|
+
return [to + key.slice(from.length), value];
|
|
64
|
+
}
|
|
65
|
+
return [key, value];
|
|
66
|
+
})
|
|
67
|
+
);
|
|
88
68
|
}
|
|
89
|
-
__name(renameRules, "renameRules");
|
|
90
69
|
|
|
91
70
|
export {
|
|
92
71
|
parserPlain,
|
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
__name
|
|
3
|
-
} from "./chunk-SHUYVCID.js";
|
|
4
|
-
|
|
5
1
|
// src/utils/correct-paths.ts
|
|
6
2
|
var _DRIVE_LETTER_START_RE = /^[A-Za-z]:\//;
|
|
7
3
|
function normalizeWindowsPath(input = "") {
|
|
@@ -10,7 +6,6 @@ function normalizeWindowsPath(input = "") {
|
|
|
10
6
|
}
|
|
11
7
|
return input.replace(/\\/g, "/").replace(_DRIVE_LETTER_START_RE, (r) => r.toUpperCase());
|
|
12
8
|
}
|
|
13
|
-
__name(normalizeWindowsPath, "normalizeWindowsPath");
|
|
14
9
|
var _UNC_REGEX = /^[/\\]{2}/;
|
|
15
10
|
var _IS_ABSOLUTE_RE = /^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Za-z]:[/\\]/;
|
|
16
11
|
var _DRIVE_LETTER_RE = /^[A-Za-z]:$/;
|
|
@@ -18,7 +13,7 @@ var _ROOT_FOLDER_RE = /^\/([A-Za-z]:)?$/;
|
|
|
18
13
|
var _EXTNAME_RE = /.(\.[^./]+|\.)$/;
|
|
19
14
|
var _PATH_ROOT_RE = /^[/\\]|^[a-zA-Z]:[/\\]/;
|
|
20
15
|
var sep = "/";
|
|
21
|
-
var correctPaths =
|
|
16
|
+
var correctPaths = function(path) {
|
|
22
17
|
if (!path || path.length === 0) {
|
|
23
18
|
return ".";
|
|
24
19
|
}
|
|
@@ -46,8 +41,8 @@ var correctPaths = /* @__PURE__ */ __name(function(path) {
|
|
|
46
41
|
return `//${path}`;
|
|
47
42
|
}
|
|
48
43
|
return isPathAbsolute && !isAbsolute(path) ? `/${path}` : path;
|
|
49
|
-
}
|
|
50
|
-
var joinPaths =
|
|
44
|
+
};
|
|
45
|
+
var joinPaths = function(...segments) {
|
|
51
46
|
let path = "";
|
|
52
47
|
for (const seg of segments) {
|
|
53
48
|
if (!seg) {
|
|
@@ -67,15 +62,14 @@ var joinPaths = /* @__PURE__ */ __name(function(...segments) {
|
|
|
67
62
|
}
|
|
68
63
|
}
|
|
69
64
|
return correctPaths(path);
|
|
70
|
-
}
|
|
65
|
+
};
|
|
71
66
|
function cwd() {
|
|
72
67
|
if (typeof process !== "undefined" && typeof process.cwd === "function") {
|
|
73
68
|
return process.cwd().replace(/\\/g, "/");
|
|
74
69
|
}
|
|
75
70
|
return "/";
|
|
76
71
|
}
|
|
77
|
-
|
|
78
|
-
var resolve = /* @__PURE__ */ __name(function(...arguments_) {
|
|
72
|
+
var resolve = function(...arguments_) {
|
|
79
73
|
arguments_ = arguments_.map((argument) => normalizeWindowsPath(argument));
|
|
80
74
|
let resolvedPath = "";
|
|
81
75
|
let resolvedAbsolute = false;
|
|
@@ -92,7 +86,7 @@ var resolve = /* @__PURE__ */ __name(function(...arguments_) {
|
|
|
92
86
|
return `/${resolvedPath}`;
|
|
93
87
|
}
|
|
94
88
|
return resolvedPath.length > 0 ? resolvedPath : ".";
|
|
95
|
-
}
|
|
89
|
+
};
|
|
96
90
|
function normalizeString(path, allowAboveRoot) {
|
|
97
91
|
let res = "";
|
|
98
92
|
let lastSegmentLength = 0;
|
|
@@ -153,27 +147,24 @@ function normalizeString(path, allowAboveRoot) {
|
|
|
153
147
|
}
|
|
154
148
|
return res;
|
|
155
149
|
}
|
|
156
|
-
|
|
157
|
-
var isAbsolute = /* @__PURE__ */ __name(function(p) {
|
|
150
|
+
var isAbsolute = function(p) {
|
|
158
151
|
return _IS_ABSOLUTE_RE.test(p);
|
|
159
|
-
}
|
|
160
|
-
var toNamespacedPath =
|
|
152
|
+
};
|
|
153
|
+
var toNamespacedPath = function(p) {
|
|
161
154
|
return normalizeWindowsPath(p);
|
|
162
|
-
}
|
|
163
|
-
var extname =
|
|
155
|
+
};
|
|
156
|
+
var extname = function(p) {
|
|
164
157
|
if (p === "..") return "";
|
|
165
158
|
const match = _EXTNAME_RE.exec(normalizeWindowsPath(p));
|
|
166
159
|
return match && match[1] || "";
|
|
167
|
-
}
|
|
168
|
-
var relative =
|
|
160
|
+
};
|
|
161
|
+
var relative = function(from, to) {
|
|
169
162
|
const _from = resolve(from).replace(_ROOT_FOLDER_RE, "$1").split("/");
|
|
170
163
|
const _to = resolve(to).replace(_ROOT_FOLDER_RE, "$1").split("/");
|
|
171
164
|
if (_to[0][1] === ":" && _from[0][1] === ":" && _from[0] !== _to[0]) {
|
|
172
165
|
return _to.join("/");
|
|
173
166
|
}
|
|
174
|
-
const _fromCopy = [
|
|
175
|
-
..._from
|
|
176
|
-
];
|
|
167
|
+
const _fromCopy = [..._from];
|
|
177
168
|
for (const segment of _fromCopy) {
|
|
178
169
|
if (_to[0] !== segment) {
|
|
179
170
|
break;
|
|
@@ -181,28 +172,25 @@ var relative = /* @__PURE__ */ __name(function(from, to) {
|
|
|
181
172
|
_from.shift();
|
|
182
173
|
_to.shift();
|
|
183
174
|
}
|
|
184
|
-
return [
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
].join("/");
|
|
188
|
-
}, "relative");
|
|
189
|
-
var dirname = /* @__PURE__ */ __name(function(p) {
|
|
175
|
+
return [..._from.map(() => ".."), ..._to].join("/");
|
|
176
|
+
};
|
|
177
|
+
var dirname = function(p) {
|
|
190
178
|
const segments = normalizeWindowsPath(p).replace(/\/$/, "").split("/").slice(0, -1);
|
|
191
179
|
if (segments.length === 1 && _DRIVE_LETTER_RE.test(segments[0])) {
|
|
192
180
|
segments[0] += "/";
|
|
193
181
|
}
|
|
194
182
|
return segments.join("/") || (isAbsolute(p) ? "/" : ".");
|
|
195
|
-
}
|
|
196
|
-
var format =
|
|
183
|
+
};
|
|
184
|
+
var format = function(p) {
|
|
197
185
|
const ext = p.ext ? p.ext.startsWith(".") ? p.ext : `.${p.ext}` : "";
|
|
198
|
-
const segments = [
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
}
|
|
205
|
-
var basename =
|
|
186
|
+
const segments = [p.root, p.dir, p.base ?? (p.name ?? "") + ext].filter(
|
|
187
|
+
Boolean
|
|
188
|
+
);
|
|
189
|
+
return normalizeWindowsPath(
|
|
190
|
+
p.root ? resolve(...segments) : segments.join("/")
|
|
191
|
+
);
|
|
192
|
+
};
|
|
193
|
+
var basename = function(p, extension) {
|
|
206
194
|
const segments = normalizeWindowsPath(p).split("/");
|
|
207
195
|
let lastSegment = "";
|
|
208
196
|
for (let i = segments.length - 1; i >= 0; i--) {
|
|
@@ -213,8 +201,8 @@ var basename = /* @__PURE__ */ __name(function(p, extension) {
|
|
|
213
201
|
}
|
|
214
202
|
}
|
|
215
203
|
return extension && lastSegment.endsWith(extension) ? lastSegment.slice(0, -extension.length) : lastSegment;
|
|
216
|
-
}
|
|
217
|
-
var parse =
|
|
204
|
+
};
|
|
205
|
+
var parse = function(p) {
|
|
218
206
|
const root = _PATH_ROOT_RE.exec(p)?.[0]?.replace(/\\/g, "/") || "";
|
|
219
207
|
const base = basename(p);
|
|
220
208
|
const extension = extname(base);
|
|
@@ -225,7 +213,7 @@ var parse = /* @__PURE__ */ __name(function(p) {
|
|
|
225
213
|
ext: extension,
|
|
226
214
|
name: base.slice(0, base.length - extension.length)
|
|
227
215
|
};
|
|
228
|
-
}
|
|
216
|
+
};
|
|
229
217
|
|
|
230
218
|
export {
|
|
231
219
|
normalizeWindowsPath,
|