@jsse/eslint-config 0.4.0 → 0.4.2
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/dist/chunk-CkHaCily.js +35 -0
- package/dist/cli.d.ts +1 -2
- package/dist/cli.js +598 -611
- package/dist/esm/config-fns.d.ts +5 -0
- package/dist/esm/config-fns.js +6 -0
- package/dist/esm/configs/pnpm.d.ts +2 -0
- package/dist/esm/configs/pnpm.js +34 -0
- package/dist/esm/configs/tailwind.d.ts +1 -2
- package/dist/esm/configs/tailwind.js +81 -48
- package/dist/esm/define-config.js +11 -2
- package/dist/esm/fixable.d.ts +1 -1
- package/dist/esm/generated/fixable-rules-map.js +8 -1
- package/dist/esm/generated/version.d.ts +1 -1
- package/dist/esm/generated/version.js +1 -1
- package/dist/esm/plugins-all.d.ts +1 -1
- package/dist/esm/plugins-all.js +6 -2
- package/dist/esm/plugins.d.ts +1 -6
- package/dist/esm/plugins.js +1 -18
- package/dist/esm/presets.js +0 -32
- package/dist/esm/types.d.ts +13 -0
- package/dist/index.d.ts +9052 -20639
- package/dist/index.js +17621 -13083
- package/dist/version-BnagbjMm.js +5 -0
- package/package.json +28 -29
package/dist/cli.js
CHANGED
|
@@ -1,598 +1,583 @@
|
|
|
1
|
-
|
|
2
|
-
import fs from "fs";
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
// node_modules/.pnpm/cac@6.7.14/node_modules/cac/dist/index.mjs
|
|
1
|
+
import { VERSION } from "./version-BnagbjMm.js";
|
|
2
|
+
import fs from "node:fs";
|
|
3
|
+
import process$1 from "node:process";
|
|
6
4
|
import { EventEmitter } from "events";
|
|
5
|
+
|
|
6
|
+
//#region node_modules/.pnpm/cac@6.7.14/node_modules/cac/dist/index.mjs
|
|
7
7
|
function toArr(any) {
|
|
8
|
-
|
|
8
|
+
return any == null ? [] : Array.isArray(any) ? any : [any];
|
|
9
9
|
}
|
|
10
10
|
function toVal(out, key, val, opts) {
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
var x, old = out[key], nxt = !!~opts.string.indexOf(key) ? val == null || val === true ? "" : String(val) : typeof val === "boolean" ? val : !!~opts.boolean.indexOf(key) ? val === "false" ? false : val === "true" || (out._.push((x = +val, x * 0 === 0) ? x : val), !!val) : (x = +val, x * 0 === 0) ? x : val;
|
|
12
|
+
out[key] = old == null ? nxt : Array.isArray(old) ? old.concat(nxt) : [old, nxt];
|
|
13
13
|
}
|
|
14
14
|
function mri2(args, opts) {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
15
|
+
args = args || [];
|
|
16
|
+
opts = opts || {};
|
|
17
|
+
var k, arr, arg, name, val, out = { _: [] };
|
|
18
|
+
var i = 0, j = 0, idx = 0, len = args.length;
|
|
19
|
+
const alibi = opts.alias !== void 0;
|
|
20
|
+
const strict = opts.unknown !== void 0;
|
|
21
|
+
const defaults = opts.default !== void 0;
|
|
22
|
+
opts.alias = opts.alias || {};
|
|
23
|
+
opts.string = toArr(opts.string);
|
|
24
|
+
opts.boolean = toArr(opts.boolean);
|
|
25
|
+
if (alibi) {
|
|
26
|
+
for (k in opts.alias) {
|
|
27
|
+
arr = opts.alias[k] = toArr(opts.alias[k]);
|
|
28
|
+
for (i = 0; i < arr.length; i++) {
|
|
29
|
+
(opts.alias[arr[i]] = arr.concat(k)).splice(i, 1);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
for (i = opts.boolean.length; i-- > 0;) {
|
|
34
|
+
arr = opts.alias[opts.boolean[i]] || [];
|
|
35
|
+
for (j = arr.length; j-- > 0;) opts.boolean.push(arr[j]);
|
|
36
|
+
}
|
|
37
|
+
for (i = opts.string.length; i-- > 0;) {
|
|
38
|
+
arr = opts.alias[opts.string[i]] || [];
|
|
39
|
+
for (j = arr.length; j-- > 0;) opts.string.push(arr[j]);
|
|
40
|
+
}
|
|
41
|
+
if (defaults) {
|
|
42
|
+
for (k in opts.default) {
|
|
43
|
+
name = typeof opts.default[k];
|
|
44
|
+
arr = opts.alias[k] = opts.alias[k] || [];
|
|
45
|
+
if (opts[name] !== void 0) {
|
|
46
|
+
opts[name].push(k);
|
|
47
|
+
for (i = 0; i < arr.length; i++) {
|
|
48
|
+
opts[name].push(arr[i]);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
const keys = strict ? Object.keys(opts.alias) : [];
|
|
54
|
+
for (i = 0; i < len; i++) {
|
|
55
|
+
arg = args[i];
|
|
56
|
+
if (arg === "--") {
|
|
57
|
+
out._ = out._.concat(args.slice(++i));
|
|
58
|
+
break;
|
|
59
|
+
}
|
|
60
|
+
for (j = 0; j < arg.length; j++) {
|
|
61
|
+
if (arg.charCodeAt(j) !== 45) break;
|
|
62
|
+
}
|
|
63
|
+
if (j === 0) {
|
|
64
|
+
out._.push(arg);
|
|
65
|
+
} else if (arg.substring(j, j + 3) === "no-") {
|
|
66
|
+
name = arg.substring(j + 3);
|
|
67
|
+
if (strict && !~keys.indexOf(name)) {
|
|
68
|
+
return opts.unknown(arg);
|
|
69
|
+
}
|
|
70
|
+
out[name] = false;
|
|
71
|
+
} else {
|
|
72
|
+
for (idx = j + 1; idx < arg.length; idx++) {
|
|
73
|
+
if (arg.charCodeAt(idx) === 61) break;
|
|
74
|
+
}
|
|
75
|
+
name = arg.substring(j, idx);
|
|
76
|
+
val = arg.substring(++idx) || i + 1 === len || ("" + args[i + 1]).charCodeAt(0) === 45 || args[++i];
|
|
77
|
+
arr = j === 2 ? [name] : name;
|
|
78
|
+
for (idx = 0; idx < arr.length; idx++) {
|
|
79
|
+
name = arr[idx];
|
|
80
|
+
if (strict && !~keys.indexOf(name)) return opts.unknown("-".repeat(j) + name);
|
|
81
|
+
toVal(out, name, idx + 1 < arr.length || val, opts);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
if (defaults) {
|
|
86
|
+
for (k in opts.default) {
|
|
87
|
+
if (out[k] === void 0) {
|
|
88
|
+
out[k] = opts.default[k];
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
if (alibi) {
|
|
93
|
+
for (k in out) {
|
|
94
|
+
arr = opts.alias[k] || [];
|
|
95
|
+
while (arr.length > 0) {
|
|
96
|
+
out[arr.shift()] = out[k];
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
return out;
|
|
101
101
|
}
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
102
|
+
const removeBrackets = (v) => v.replace(/[<[].+/, "").trim();
|
|
103
|
+
const findAllBrackets = (v) => {
|
|
104
|
+
const ANGLED_BRACKET_RE_GLOBAL = /<([^>]+)>/g;
|
|
105
|
+
const SQUARE_BRACKET_RE_GLOBAL = /\[([^\]]+)\]/g;
|
|
106
|
+
const res = [];
|
|
107
|
+
const parse = (match) => {
|
|
108
|
+
let variadic = false;
|
|
109
|
+
let value = match[1];
|
|
110
|
+
if (value.startsWith("...")) {
|
|
111
|
+
value = value.slice(3);
|
|
112
|
+
variadic = true;
|
|
113
|
+
}
|
|
114
|
+
return {
|
|
115
|
+
required: match[0].startsWith("<"),
|
|
116
|
+
value,
|
|
117
|
+
variadic
|
|
118
|
+
};
|
|
119
|
+
};
|
|
120
|
+
let angledMatch;
|
|
121
|
+
while (angledMatch = ANGLED_BRACKET_RE_GLOBAL.exec(v)) {
|
|
122
|
+
res.push(parse(angledMatch));
|
|
123
|
+
}
|
|
124
|
+
let squareMatch;
|
|
125
|
+
while (squareMatch = SQUARE_BRACKET_RE_GLOBAL.exec(v)) {
|
|
126
|
+
res.push(parse(squareMatch));
|
|
127
|
+
}
|
|
128
|
+
return res;
|
|
129
129
|
};
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
130
|
+
const getMriOptions = (options) => {
|
|
131
|
+
const result = {
|
|
132
|
+
alias: {},
|
|
133
|
+
boolean: []
|
|
134
|
+
};
|
|
135
|
+
for (const [index, option] of options.entries()) {
|
|
136
|
+
if (option.names.length > 1) {
|
|
137
|
+
result.alias[option.names[0]] = option.names.slice(1);
|
|
138
|
+
}
|
|
139
|
+
if (option.isBoolean) {
|
|
140
|
+
if (option.negated) {
|
|
141
|
+
const hasStringTypeOption = options.some((o, i) => {
|
|
142
|
+
return i !== index && o.names.some((name) => option.names.includes(name)) && typeof o.required === "boolean";
|
|
143
|
+
});
|
|
144
|
+
if (!hasStringTypeOption) {
|
|
145
|
+
result.boolean.push(option.names[0]);
|
|
146
|
+
}
|
|
147
|
+
} else {
|
|
148
|
+
result.boolean.push(option.names[0]);
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
return result;
|
|
150
153
|
};
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
154
|
+
const findLongest = (arr) => {
|
|
155
|
+
return arr.sort((a, b) => {
|
|
156
|
+
return a.length > b.length ? -1 : 1;
|
|
157
|
+
})[0];
|
|
155
158
|
};
|
|
156
|
-
|
|
157
|
-
|
|
159
|
+
const padRight = (str, length) => {
|
|
160
|
+
return str.length >= length ? str : `${str}${" ".repeat(length - str.length)}`;
|
|
158
161
|
};
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
162
|
+
const camelcase = (input) => {
|
|
163
|
+
return input.replace(/([a-z])-([a-z])/g, (_, p1, p2) => {
|
|
164
|
+
return p1 + p2.toUpperCase();
|
|
165
|
+
});
|
|
163
166
|
};
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
167
|
+
const setDotProp = (obj, keys, val) => {
|
|
168
|
+
let i = 0;
|
|
169
|
+
let length = keys.length;
|
|
170
|
+
let t = obj;
|
|
171
|
+
let x;
|
|
172
|
+
for (; i < length; ++i) {
|
|
173
|
+
x = t[keys[i]];
|
|
174
|
+
t = t[keys[i]] = i === length - 1 ? val : x != null ? x : !!~keys[i + 1].indexOf(".") || !(+keys[i + 1] > -1) ? {} : [];
|
|
175
|
+
}
|
|
173
176
|
};
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
177
|
+
const setByType = (obj, transforms) => {
|
|
178
|
+
for (const key of Object.keys(transforms)) {
|
|
179
|
+
const transform = transforms[key];
|
|
180
|
+
if (transform.shouldTransform) {
|
|
181
|
+
obj[key] = Array.prototype.concat.call([], obj[key]);
|
|
182
|
+
if (typeof transform.transformFunction === "function") {
|
|
183
|
+
obj[key] = obj[key].map(transform.transformFunction);
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
}
|
|
184
187
|
};
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
+
const getFileName = (input) => {
|
|
189
|
+
const m = /([^\\\/]+)$/.exec(input);
|
|
190
|
+
return m ? m[1] : "";
|
|
188
191
|
};
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
192
|
+
const camelcaseOptionName = (name) => {
|
|
193
|
+
return name.split(".").map((v, i) => {
|
|
194
|
+
return i === 0 ? camelcase(v) : v;
|
|
195
|
+
}).join(".");
|
|
193
196
|
};
|
|
194
197
|
var CACError = class extends Error {
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
198
|
+
constructor(message) {
|
|
199
|
+
super(message);
|
|
200
|
+
this.name = this.constructor.name;
|
|
201
|
+
if (typeof Error.captureStackTrace === "function") {
|
|
202
|
+
Error.captureStackTrace(this, this.constructor);
|
|
203
|
+
} else {
|
|
204
|
+
this.stack = new Error(message).stack;
|
|
205
|
+
}
|
|
206
|
+
}
|
|
204
207
|
};
|
|
205
208
|
var Option = class {
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
209
|
+
constructor(rawName, description, config) {
|
|
210
|
+
this.rawName = rawName;
|
|
211
|
+
this.description = description;
|
|
212
|
+
this.config = Object.assign({}, config);
|
|
213
|
+
rawName = rawName.replace(/\.\*/g, "");
|
|
214
|
+
this.negated = false;
|
|
215
|
+
this.names = removeBrackets(rawName).split(",").map((v) => {
|
|
216
|
+
let name = v.trim().replace(/^-{1,2}/, "");
|
|
217
|
+
if (name.startsWith("no-")) {
|
|
218
|
+
this.negated = true;
|
|
219
|
+
name = name.replace(/^no-/, "");
|
|
220
|
+
}
|
|
221
|
+
return camelcaseOptionName(name);
|
|
222
|
+
}).sort((a, b) => a.length > b.length ? 1 : -1);
|
|
223
|
+
this.name = this.names[this.names.length - 1];
|
|
224
|
+
if (this.negated && this.config.default == null) {
|
|
225
|
+
this.config.default = true;
|
|
226
|
+
}
|
|
227
|
+
if (rawName.includes("<")) {
|
|
228
|
+
this.required = true;
|
|
229
|
+
} else if (rawName.includes("[")) {
|
|
230
|
+
this.required = false;
|
|
231
|
+
} else {
|
|
232
|
+
this.isBoolean = true;
|
|
233
|
+
}
|
|
234
|
+
}
|
|
232
235
|
};
|
|
233
|
-
|
|
234
|
-
|
|
236
|
+
const processArgs = process.argv;
|
|
237
|
+
const platformInfo = `${process.platform}-${process.arch} node-${process.version}`;
|
|
235
238
|
var Command = class {
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
}).join("\n")
|
|
348
|
-
});
|
|
349
|
-
}
|
|
350
|
-
if (helpCallback) {
|
|
351
|
-
sections = helpCallback(sections) || sections;
|
|
352
|
-
}
|
|
353
|
-
console.log(sections.map((section) => {
|
|
354
|
-
return section.title ? `${section.title}:
|
|
239
|
+
constructor(rawName, description, config = {}, cli$1) {
|
|
240
|
+
this.rawName = rawName;
|
|
241
|
+
this.description = description;
|
|
242
|
+
this.config = config;
|
|
243
|
+
this.cli = cli$1;
|
|
244
|
+
this.options = [];
|
|
245
|
+
this.aliasNames = [];
|
|
246
|
+
this.name = removeBrackets(rawName);
|
|
247
|
+
this.args = findAllBrackets(rawName);
|
|
248
|
+
this.examples = [];
|
|
249
|
+
}
|
|
250
|
+
usage(text) {
|
|
251
|
+
this.usageText = text;
|
|
252
|
+
return this;
|
|
253
|
+
}
|
|
254
|
+
allowUnknownOptions() {
|
|
255
|
+
this.config.allowUnknownOptions = true;
|
|
256
|
+
return this;
|
|
257
|
+
}
|
|
258
|
+
ignoreOptionDefaultValue() {
|
|
259
|
+
this.config.ignoreOptionDefaultValue = true;
|
|
260
|
+
return this;
|
|
261
|
+
}
|
|
262
|
+
version(version, customFlags = "-v, --version") {
|
|
263
|
+
this.versionNumber = version;
|
|
264
|
+
this.option(customFlags, "Display version number");
|
|
265
|
+
return this;
|
|
266
|
+
}
|
|
267
|
+
example(example) {
|
|
268
|
+
this.examples.push(example);
|
|
269
|
+
return this;
|
|
270
|
+
}
|
|
271
|
+
option(rawName, description, config) {
|
|
272
|
+
const option = new Option(rawName, description, config);
|
|
273
|
+
this.options.push(option);
|
|
274
|
+
return this;
|
|
275
|
+
}
|
|
276
|
+
alias(name) {
|
|
277
|
+
this.aliasNames.push(name);
|
|
278
|
+
return this;
|
|
279
|
+
}
|
|
280
|
+
action(callback) {
|
|
281
|
+
this.commandAction = callback;
|
|
282
|
+
return this;
|
|
283
|
+
}
|
|
284
|
+
isMatched(name) {
|
|
285
|
+
return this.name === name || this.aliasNames.includes(name);
|
|
286
|
+
}
|
|
287
|
+
get isDefaultCommand() {
|
|
288
|
+
return this.name === "" || this.aliasNames.includes("!");
|
|
289
|
+
}
|
|
290
|
+
get isGlobalCommand() {
|
|
291
|
+
return this instanceof GlobalCommand;
|
|
292
|
+
}
|
|
293
|
+
hasOption(name) {
|
|
294
|
+
name = name.split(".")[0];
|
|
295
|
+
return this.options.find((option) => {
|
|
296
|
+
return option.names.includes(name);
|
|
297
|
+
});
|
|
298
|
+
}
|
|
299
|
+
outputHelp() {
|
|
300
|
+
const { name, commands } = this.cli;
|
|
301
|
+
const { versionNumber, options: globalOptions, helpCallback } = this.cli.globalCommand;
|
|
302
|
+
let sections = [{ body: `${name}${versionNumber ? `/${versionNumber}` : ""}` }];
|
|
303
|
+
sections.push({
|
|
304
|
+
title: "Usage",
|
|
305
|
+
body: ` $ ${name} ${this.usageText || this.rawName}`
|
|
306
|
+
});
|
|
307
|
+
const showCommands = (this.isGlobalCommand || this.isDefaultCommand) && commands.length > 0;
|
|
308
|
+
if (showCommands) {
|
|
309
|
+
const longestCommandName = findLongest(commands.map((command) => command.rawName));
|
|
310
|
+
sections.push({
|
|
311
|
+
title: "Commands",
|
|
312
|
+
body: commands.map((command) => {
|
|
313
|
+
return ` ${padRight(command.rawName, longestCommandName.length)} ${command.description}`;
|
|
314
|
+
}).join("\n")
|
|
315
|
+
});
|
|
316
|
+
sections.push({
|
|
317
|
+
title: `For more info, run any command with the \`--help\` flag`,
|
|
318
|
+
body: commands.map((command) => ` $ ${name}${command.name === "" ? "" : ` ${command.name}`} --help`).join("\n")
|
|
319
|
+
});
|
|
320
|
+
}
|
|
321
|
+
let options = this.isGlobalCommand ? globalOptions : [...this.options, ...globalOptions || []];
|
|
322
|
+
if (!this.isGlobalCommand && !this.isDefaultCommand) {
|
|
323
|
+
options = options.filter((option) => option.name !== "version");
|
|
324
|
+
}
|
|
325
|
+
if (options.length > 0) {
|
|
326
|
+
const longestOptionName = findLongest(options.map((option) => option.rawName));
|
|
327
|
+
sections.push({
|
|
328
|
+
title: "Options",
|
|
329
|
+
body: options.map((option) => {
|
|
330
|
+
return ` ${padRight(option.rawName, longestOptionName.length)} ${option.description} ${option.config.default === void 0 ? "" : `(default: ${option.config.default})`}`;
|
|
331
|
+
}).join("\n")
|
|
332
|
+
});
|
|
333
|
+
}
|
|
334
|
+
if (this.examples.length > 0) {
|
|
335
|
+
sections.push({
|
|
336
|
+
title: "Examples",
|
|
337
|
+
body: this.examples.map((example) => {
|
|
338
|
+
if (typeof example === "function") {
|
|
339
|
+
return example(name);
|
|
340
|
+
}
|
|
341
|
+
return example;
|
|
342
|
+
}).join("\n")
|
|
343
|
+
});
|
|
344
|
+
}
|
|
345
|
+
if (helpCallback) {
|
|
346
|
+
sections = helpCallback(sections) || sections;
|
|
347
|
+
}
|
|
348
|
+
console.log(sections.map((section) => {
|
|
349
|
+
return section.title ? `${section.title}:
|
|
355
350
|
${section.body}` : section.body;
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
351
|
+
}).join("\n\n"));
|
|
352
|
+
}
|
|
353
|
+
outputVersion() {
|
|
354
|
+
const { name } = this.cli;
|
|
355
|
+
const { versionNumber } = this.cli.globalCommand;
|
|
356
|
+
if (versionNumber) {
|
|
357
|
+
console.log(`${name}/${versionNumber} ${platformInfo}`);
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
checkRequiredArgs() {
|
|
361
|
+
const minimalArgsCount = this.args.filter((arg) => arg.required).length;
|
|
362
|
+
if (this.cli.args.length < minimalArgsCount) {
|
|
363
|
+
throw new CACError(`missing required args for command \`${this.rawName}\``);
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
checkUnknownOptions() {
|
|
367
|
+
const { options, globalCommand } = this.cli;
|
|
368
|
+
if (!this.config.allowUnknownOptions) {
|
|
369
|
+
for (const name of Object.keys(options)) {
|
|
370
|
+
if (name !== "--" && !this.hasOption(name) && !globalCommand.hasOption(name)) {
|
|
371
|
+
throw new CACError(`Unknown option \`${name.length > 1 ? `--${name}` : `-${name}`}\``);
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
checkOptionValue() {
|
|
377
|
+
const { options: parsedOptions, globalCommand } = this.cli;
|
|
378
|
+
const options = [...globalCommand.options, ...this.options];
|
|
379
|
+
for (const option of options) {
|
|
380
|
+
const value = parsedOptions[option.name.split(".")[0]];
|
|
381
|
+
if (option.required) {
|
|
382
|
+
const hasNegated = options.some((o) => o.negated && o.names.includes(option.name));
|
|
383
|
+
if (value === true || value === false && !hasNegated) {
|
|
384
|
+
throw new CACError(`option \`${option.rawName}\` value is missing`);
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
}
|
|
394
389
|
};
|
|
395
390
|
var GlobalCommand = class extends Command {
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
391
|
+
constructor(cli$1) {
|
|
392
|
+
super("@@global@@", "", {}, cli$1);
|
|
393
|
+
}
|
|
399
394
|
};
|
|
400
395
|
var __assign = Object.assign;
|
|
401
396
|
var CAC = class extends EventEmitter {
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
if (arg.variadic) {
|
|
579
|
-
actionArgs.push(args.slice(index));
|
|
580
|
-
} else {
|
|
581
|
-
actionArgs.push(args[index]);
|
|
582
|
-
}
|
|
583
|
-
});
|
|
584
|
-
actionArgs.push(options);
|
|
585
|
-
return command.commandAction.apply(this, actionArgs);
|
|
586
|
-
}
|
|
397
|
+
constructor(name = "") {
|
|
398
|
+
super();
|
|
399
|
+
this.name = name;
|
|
400
|
+
this.commands = [];
|
|
401
|
+
this.rawArgs = [];
|
|
402
|
+
this.args = [];
|
|
403
|
+
this.options = {};
|
|
404
|
+
this.globalCommand = new GlobalCommand(this);
|
|
405
|
+
this.globalCommand.usage("<command> [options]");
|
|
406
|
+
}
|
|
407
|
+
usage(text) {
|
|
408
|
+
this.globalCommand.usage(text);
|
|
409
|
+
return this;
|
|
410
|
+
}
|
|
411
|
+
command(rawName, description, config) {
|
|
412
|
+
const command = new Command(rawName, description || "", config, this);
|
|
413
|
+
command.globalCommand = this.globalCommand;
|
|
414
|
+
this.commands.push(command);
|
|
415
|
+
return command;
|
|
416
|
+
}
|
|
417
|
+
option(rawName, description, config) {
|
|
418
|
+
this.globalCommand.option(rawName, description, config);
|
|
419
|
+
return this;
|
|
420
|
+
}
|
|
421
|
+
help(callback) {
|
|
422
|
+
this.globalCommand.option("-h, --help", "Display this message");
|
|
423
|
+
this.globalCommand.helpCallback = callback;
|
|
424
|
+
this.showHelpOnExit = true;
|
|
425
|
+
return this;
|
|
426
|
+
}
|
|
427
|
+
version(version, customFlags = "-v, --version") {
|
|
428
|
+
this.globalCommand.version(version, customFlags);
|
|
429
|
+
this.showVersionOnExit = true;
|
|
430
|
+
return this;
|
|
431
|
+
}
|
|
432
|
+
example(example) {
|
|
433
|
+
this.globalCommand.example(example);
|
|
434
|
+
return this;
|
|
435
|
+
}
|
|
436
|
+
outputHelp() {
|
|
437
|
+
if (this.matchedCommand) {
|
|
438
|
+
this.matchedCommand.outputHelp();
|
|
439
|
+
} else {
|
|
440
|
+
this.globalCommand.outputHelp();
|
|
441
|
+
}
|
|
442
|
+
}
|
|
443
|
+
outputVersion() {
|
|
444
|
+
this.globalCommand.outputVersion();
|
|
445
|
+
}
|
|
446
|
+
setParsedInfo({ args, options }, matchedCommand, matchedCommandName) {
|
|
447
|
+
this.args = args;
|
|
448
|
+
this.options = options;
|
|
449
|
+
if (matchedCommand) {
|
|
450
|
+
this.matchedCommand = matchedCommand;
|
|
451
|
+
}
|
|
452
|
+
if (matchedCommandName) {
|
|
453
|
+
this.matchedCommandName = matchedCommandName;
|
|
454
|
+
}
|
|
455
|
+
return this;
|
|
456
|
+
}
|
|
457
|
+
unsetMatchedCommand() {
|
|
458
|
+
this.matchedCommand = void 0;
|
|
459
|
+
this.matchedCommandName = void 0;
|
|
460
|
+
}
|
|
461
|
+
parse(argv = processArgs, { run = true } = {}) {
|
|
462
|
+
this.rawArgs = argv;
|
|
463
|
+
if (!this.name) {
|
|
464
|
+
this.name = argv[1] ? getFileName(argv[1]) : "cli";
|
|
465
|
+
}
|
|
466
|
+
let shouldParse = true;
|
|
467
|
+
for (const command of this.commands) {
|
|
468
|
+
const parsed = this.mri(argv.slice(2), command);
|
|
469
|
+
const commandName = parsed.args[0];
|
|
470
|
+
if (command.isMatched(commandName)) {
|
|
471
|
+
shouldParse = false;
|
|
472
|
+
const parsedInfo = __assign(__assign({}, parsed), { args: parsed.args.slice(1) });
|
|
473
|
+
this.setParsedInfo(parsedInfo, command, commandName);
|
|
474
|
+
this.emit(`command:${commandName}`, command);
|
|
475
|
+
}
|
|
476
|
+
}
|
|
477
|
+
if (shouldParse) {
|
|
478
|
+
for (const command of this.commands) {
|
|
479
|
+
if (command.name === "") {
|
|
480
|
+
shouldParse = false;
|
|
481
|
+
const parsed = this.mri(argv.slice(2), command);
|
|
482
|
+
this.setParsedInfo(parsed, command);
|
|
483
|
+
this.emit(`command:!`, command);
|
|
484
|
+
}
|
|
485
|
+
}
|
|
486
|
+
}
|
|
487
|
+
if (shouldParse) {
|
|
488
|
+
const parsed = this.mri(argv.slice(2));
|
|
489
|
+
this.setParsedInfo(parsed);
|
|
490
|
+
}
|
|
491
|
+
if (this.options.help && this.showHelpOnExit) {
|
|
492
|
+
this.outputHelp();
|
|
493
|
+
run = false;
|
|
494
|
+
this.unsetMatchedCommand();
|
|
495
|
+
}
|
|
496
|
+
if (this.options.version && this.showVersionOnExit && this.matchedCommandName == null) {
|
|
497
|
+
this.outputVersion();
|
|
498
|
+
run = false;
|
|
499
|
+
this.unsetMatchedCommand();
|
|
500
|
+
}
|
|
501
|
+
const parsedArgv = {
|
|
502
|
+
args: this.args,
|
|
503
|
+
options: this.options
|
|
504
|
+
};
|
|
505
|
+
if (run) {
|
|
506
|
+
this.runMatchedCommand();
|
|
507
|
+
}
|
|
508
|
+
if (!this.matchedCommand && this.args[0]) {
|
|
509
|
+
this.emit("command:*");
|
|
510
|
+
}
|
|
511
|
+
return parsedArgv;
|
|
512
|
+
}
|
|
513
|
+
mri(argv, command) {
|
|
514
|
+
const cliOptions = [...this.globalCommand.options, ...command ? command.options : []];
|
|
515
|
+
const mriOptions = getMriOptions(cliOptions);
|
|
516
|
+
let argsAfterDoubleDashes = [];
|
|
517
|
+
const doubleDashesIndex = argv.indexOf("--");
|
|
518
|
+
if (doubleDashesIndex > -1) {
|
|
519
|
+
argsAfterDoubleDashes = argv.slice(doubleDashesIndex + 1);
|
|
520
|
+
argv = argv.slice(0, doubleDashesIndex);
|
|
521
|
+
}
|
|
522
|
+
let parsed = mri2(argv, mriOptions);
|
|
523
|
+
parsed = Object.keys(parsed).reduce((res, name) => {
|
|
524
|
+
return __assign(__assign({}, res), { [camelcaseOptionName(name)]: parsed[name] });
|
|
525
|
+
}, { _: [] });
|
|
526
|
+
const args = parsed._;
|
|
527
|
+
const options = { "--": argsAfterDoubleDashes };
|
|
528
|
+
const ignoreDefault = command && command.config.ignoreOptionDefaultValue ? command.config.ignoreOptionDefaultValue : this.globalCommand.config.ignoreOptionDefaultValue;
|
|
529
|
+
let transforms = Object.create(null);
|
|
530
|
+
for (const cliOption of cliOptions) {
|
|
531
|
+
if (!ignoreDefault && cliOption.config.default !== void 0) {
|
|
532
|
+
for (const name of cliOption.names) {
|
|
533
|
+
options[name] = cliOption.config.default;
|
|
534
|
+
}
|
|
535
|
+
}
|
|
536
|
+
if (Array.isArray(cliOption.config.type)) {
|
|
537
|
+
if (transforms[cliOption.name] === void 0) {
|
|
538
|
+
transforms[cliOption.name] = Object.create(null);
|
|
539
|
+
transforms[cliOption.name]["shouldTransform"] = true;
|
|
540
|
+
transforms[cliOption.name]["transformFunction"] = cliOption.config.type[0];
|
|
541
|
+
}
|
|
542
|
+
}
|
|
543
|
+
}
|
|
544
|
+
for (const key of Object.keys(parsed)) {
|
|
545
|
+
if (key !== "_") {
|
|
546
|
+
const keys = key.split(".");
|
|
547
|
+
setDotProp(options, keys, parsed[key]);
|
|
548
|
+
setByType(options, transforms);
|
|
549
|
+
}
|
|
550
|
+
}
|
|
551
|
+
return {
|
|
552
|
+
args,
|
|
553
|
+
options
|
|
554
|
+
};
|
|
555
|
+
}
|
|
556
|
+
runMatchedCommand() {
|
|
557
|
+
const { args, options, matchedCommand: command } = this;
|
|
558
|
+
if (!command || !command.commandAction) return;
|
|
559
|
+
command.checkUnknownOptions();
|
|
560
|
+
command.checkOptionValue();
|
|
561
|
+
command.checkRequiredArgs();
|
|
562
|
+
const actionArgs = [];
|
|
563
|
+
command.args.forEach((arg, index) => {
|
|
564
|
+
if (arg.variadic) {
|
|
565
|
+
actionArgs.push(args.slice(index));
|
|
566
|
+
} else {
|
|
567
|
+
actionArgs.push(args[index]);
|
|
568
|
+
}
|
|
569
|
+
});
|
|
570
|
+
actionArgs.push(options);
|
|
571
|
+
return command.commandAction.apply(this, actionArgs);
|
|
572
|
+
}
|
|
587
573
|
};
|
|
588
|
-
|
|
574
|
+
const cac = (name = "") => new CAC(name);
|
|
575
|
+
var dist_default = cac;
|
|
589
576
|
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
var cli = cac("jsselint");
|
|
595
|
-
var CONFIG_OPTIONS_STRING = `
|
|
577
|
+
//#endregion
|
|
578
|
+
//#region src/cli.ts
|
|
579
|
+
const cli = cac("jsselint");
|
|
580
|
+
const CONFIG_OPTIONS_STRING = `
|
|
596
581
|
{
|
|
597
582
|
/**
|
|
598
583
|
* ===================
|
|
@@ -629,13 +614,13 @@ var CONFIG_OPTIONS_STRING = `
|
|
|
629
614
|
// off: [],
|
|
630
615
|
}
|
|
631
616
|
`;
|
|
632
|
-
|
|
617
|
+
const CONFIG_STRING_CJS = `// @ts-check
|
|
633
618
|
|
|
634
619
|
module.exports = require("@jsse/eslint-config").jsse(
|
|
635
620
|
${CONFIG_OPTIONS_STRING}
|
|
636
621
|
)
|
|
637
622
|
`;
|
|
638
|
-
|
|
623
|
+
const CONFIG_STRING_ESM = `// @ts-check
|
|
639
624
|
import jsse from "@jsse/eslint-config";
|
|
640
625
|
|
|
641
626
|
export default jsse(
|
|
@@ -643,57 +628,59 @@ ${CONFIG_OPTIONS_STRING}
|
|
|
643
628
|
);
|
|
644
629
|
`;
|
|
645
630
|
cli.command("", "default command").action(() => {
|
|
646
|
-
|
|
647
|
-
|
|
631
|
+
cli.outputHelp();
|
|
632
|
+
process$1.exit(1);
|
|
648
633
|
});
|
|
649
634
|
cli.command("init", "create eslint config file").option("--force", "force create eslint config file").action(async (options) => {
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
635
|
+
console.log("init");
|
|
636
|
+
const configPath = "eslint.config.js";
|
|
637
|
+
if (fs.existsSync(configPath)) {
|
|
638
|
+
const msg = "eslint.config.js already exists";
|
|
639
|
+
console.warn(msg);
|
|
640
|
+
if (!options.force) {
|
|
641
|
+
throw new Error(msg);
|
|
642
|
+
}
|
|
643
|
+
}
|
|
644
|
+
if (!fs.existsSync("package.json")) {
|
|
645
|
+
const msg = "package.json not found";
|
|
646
|
+
console.warn(msg);
|
|
647
|
+
throw new Error(msg);
|
|
648
|
+
}
|
|
649
|
+
const packageJson = JSON.parse(fs.readFileSync("package.json", "utf8"));
|
|
650
|
+
const isModule = packageJson.type === "module";
|
|
651
|
+
const eslintConfigString = [
|
|
652
|
+
isModule ? CONFIG_STRING_ESM : CONFIG_STRING_CJS,
|
|
653
|
+
"/* ALT */",
|
|
654
|
+
(isModule ? CONFIG_STRING_CJS : CONFIG_STRING_ESM).split("\n").map((line) => `// ${line}`).join("\n")
|
|
655
|
+
];
|
|
656
|
+
fs.writeFileSync(configPath, eslintConfigString.join("\n"));
|
|
657
|
+
console.log(`made eslint.config.js (type: ${packageJson.type})`);
|
|
673
658
|
});
|
|
674
659
|
cli.command("version", "echo version").action(() => {
|
|
675
|
-
|
|
660
|
+
console.log(VERSION);
|
|
676
661
|
});
|
|
677
662
|
cli.version(typeof VERSION === "string" ? VERSION : "unknown");
|
|
678
663
|
cli.help();
|
|
679
664
|
async function main(args) {
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
665
|
+
const argv = args ?? process$1.argv.slice(2);
|
|
666
|
+
try {
|
|
667
|
+
const parsed = cli.parse(argv, { run: false });
|
|
668
|
+
console.log("=====");
|
|
669
|
+
console.log(parsed);
|
|
670
|
+
console.log("=====");
|
|
671
|
+
await cli.runMatchedCommand();
|
|
672
|
+
} catch (error) {
|
|
673
|
+
if (error instanceof Error) {
|
|
674
|
+
console.error("Error: %s\n\n%s", error.message, error.stack);
|
|
675
|
+
} else {
|
|
676
|
+
console.error(error);
|
|
677
|
+
}
|
|
678
|
+
process$1.exit(1);
|
|
679
|
+
}
|
|
695
680
|
}
|
|
696
681
|
main().catch((e) => {
|
|
697
|
-
|
|
698
|
-
|
|
682
|
+
console.error(e);
|
|
683
|
+
throw e;
|
|
699
684
|
});
|
|
685
|
+
|
|
686
|
+
//#endregion
|