@w5s/dev 3.2.3 → 3.3.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/dist/index.cjs CHANGED
@@ -1,57 +1,4 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- let node_fs = require("node:fs");
3
- let node_fs_promises = require("node:fs/promises");
4
- let node_child_process = require("node:child_process");
5
- //#region src/directory.ts
6
- async function exists$1(path) {
7
- try {
8
- await (0, node_fs_promises.access)(path, node_fs_promises.constants.F_OK);
9
- return true;
10
- } catch {
11
- return false;
12
- }
13
- }
14
- /**
15
- * Ensure directory is present/absent
16
- *
17
- * @example
18
- * ```ts
19
- * await directory({
20
- * path: 'foo/bar',
21
- * state: 'present',
22
- * })
23
- * ```
24
- *
25
- * @param options
26
- */
27
- async function directory(options) {
28
- const { path, state } = options;
29
- const isPresent = await exists$1(path);
30
- if (state === "present") {
31
- if (!isPresent) await (0, node_fs_promises.mkdir)(path, { recursive: true });
32
- } else if (isPresent) await (0, node_fs_promises.rm)(path, { recursive: true });
33
- }
34
- /**
35
- * Ensure directory is present/absent
36
- *
37
- * @example
38
- * ```ts
39
- * await directorySync({
40
- * path: 'foo/bar',
41
- * state: 'present',
42
- * })
43
- * ```
44
- *
45
- * @param options
46
- */
47
- function directorySync(options) {
48
- const { path, state } = options;
49
- const isPresent = (0, node_fs.existsSync)(path);
50
- if (state === "present") {
51
- if (!isPresent) (0, node_fs.mkdirSync)(path, { recursive: true });
52
- } else if (isPresent) (0, node_fs.rmSync)(path, { recursive: true });
53
- }
54
- //#endregion
55
2
  //#region src/ESLintConfig.ts
56
3
  function toArray(value) {
57
4
  if (value == null) return [];
@@ -116,196 +63,16 @@ let ESLintConfig;
116
63
  _ESLintConfig.renameRules = renameRules;
117
64
  })(ESLintConfig || (ESLintConfig = {}));
118
65
  //#endregion
119
- //#region src/file.ts
120
- async function exists(path) {
121
- try {
122
- await (0, node_fs_promises.access)(path, node_fs.constants.F_OK);
123
- return true;
124
- } catch {
125
- return false;
126
- }
127
- }
128
- function existsSync(path) {
129
- try {
130
- (0, node_fs.accessSync)(path, node_fs.constants.F_OK);
131
- return true;
132
- } catch {
133
- return false;
134
- }
135
- }
136
- /**
137
- * Ensure file is present/absent with content initialized or modified with `update
138
- *
139
- * @example
140
- * ```ts
141
- * await file({
142
- * path: 'foo/bar',
143
- * state: 'present',
144
- * update: (content) => content + '_test', // This will append '_test' after current content
145
- * })
146
- * ```
147
- *
148
- * @param options
149
- */
150
- async function file(options) {
151
- const { path, state, update, encoding = "utf8" } = options;
152
- if (state === "present") {
153
- const previousContent = await exists(path) ? await (0, node_fs_promises.readFile)(path, encoding) : "";
154
- const newContent = update == null ? "" : update(previousContent);
155
- if (newContent != null) await (0, node_fs_promises.writeFile)(path, newContent, encoding);
156
- } else await (0, node_fs_promises.rm)(path, { force: true });
157
- }
158
- /**
159
- * Ensure file is present/absent with content initialized or modified with `update
160
- *
161
- * @example
162
- * ```ts
163
- * fileSync({
164
- * path: 'foo/bar',
165
- * state: 'present',
166
- * update: (content) => content + '_test', // This will append '_test' after current content
167
- * })
168
- * ```
169
- *
170
- * @param options
171
- */
172
- function fileSync(options) {
173
- const { path, state, update, encoding = "utf8" } = options;
174
- if (state === "present") {
175
- const previousContent = existsSync(path) ? (0, node_fs.readFileSync)(path, encoding) : "";
176
- const newContent = update == null ? "" : update(previousContent);
177
- if (newContent != null) (0, node_fs.writeFileSync)(path, newContent, encoding);
178
- } else (0, node_fs.rmSync)(path, { force: true });
179
- }
180
- //#endregion
181
- //#region src/block.ts
182
- const EOF = "EndOfFile";
183
- const BOF = "BeginningOfFile";
184
- const insertAt = (str, index, toInsert) => str.slice(0, index) + toInsert + str.slice(index);
185
- const matchLast = (string, regexp) => {
186
- const matcher = new RegExp(regexp.source, `${regexp.flags}g`);
187
- let firstIndex = -1;
188
- let lastIndex = -1;
189
- let matches;
190
- while (true) {
191
- matches = matcher.exec(string);
192
- if (matches == null) break;
193
- firstIndex = matches.index;
194
- lastIndex = matcher.lastIndex;
195
- }
196
- return {
197
- firstIndex,
198
- lastIndex
199
- };
200
- };
201
- function toFileOptions(options) {
202
- const { marker = (mark) => `# ${mark.toUpperCase()} MANAGED BLOCK`, path, block: blockName, insertPosition = ["after", EOF], state = "present" } = options;
203
- const EOL = "\n";
204
- const beginBlock = marker("Begin");
205
- const endBlock = marker("End");
206
- /**
207
- * @param content
208
- */
209
- function findBlock(content) {
210
- const startIndex = content.indexOf(beginBlock);
211
- const endIndex = content.indexOf(endBlock) + endBlock.length;
212
- return {
213
- endIndex,
214
- exists: startIndex !== -1 && endIndex >= 0,
215
- startIndex
216
- };
217
- }
218
- function apply(fullContent, blockContent) {
219
- const found = findBlock(fullContent);
220
- const remove = state === "absent";
221
- const replaceBlock = remove ? "" : beginBlock + EOL + blockContent + EOL + endBlock;
222
- const [positionDirection, positionAnchor] = insertPosition;
223
- if (found.exists) return fullContent.slice(0, found.startIndex) + replaceBlock + fullContent.slice(found.endIndex);
224
- if (remove) return fullContent;
225
- switch (positionDirection) {
226
- case "before":
227
- if (positionAnchor !== BOF) {
228
- const { firstIndex } = matchLast(fullContent, positionAnchor);
229
- if (firstIndex >= 0) return insertAt(fullContent, firstIndex, replaceBlock + EOL);
230
- }
231
- return replaceBlock + EOL + fullContent;
232
- case "after":
233
- if (positionAnchor !== EOF) {
234
- const { lastIndex } = matchLast(fullContent, positionAnchor);
235
- if (lastIndex >= 0) return insertAt(fullContent, lastIndex, EOL + replaceBlock);
236
- }
237
- return fullContent + EOL + replaceBlock;
238
- default: throw new Error(`Unsupported position ${String(positionDirection)}`);
239
- }
240
- }
241
- return {
242
- path,
243
- state: "present",
244
- update: (sourceContent) => apply(sourceContent, blockName)
245
- };
246
- }
247
- /**
248
- * Replace asynchronously a block in file that follows pattern :
249
- *
250
- * marker(markerBegin)
251
- * ...
252
- * marker(markerEnd)
253
- *
254
- * @param options
255
- */
256
- function block(options) {
257
- return file(toFileOptions(options));
258
- }
259
- /**
260
- * Replace synchronously a block in file that follows pattern :
261
- *
262
- * marker(markerBegin)
263
- * ...
264
- * marker(markerEnd)
265
- *
266
- * @param options
267
- */
268
- function blockSync(options) {
269
- return fileSync(toFileOptions(options));
270
- }
271
- //#endregion
272
66
  //#region src/interopDefault.ts
273
67
  const getDefaultOrElse = (_) => _?.default ?? _;
274
68
  function interopDefault(m) {
275
69
  return m != null && typeof m.then === "function" ? Promise.resolve(m).then(getDefaultOrElse) : getDefaultOrElse(m);
276
70
  }
277
71
  //#endregion
278
- //#region src/json.ts
279
- function toFileOption({ update, ...otherOptions }) {
280
- return {
281
- ...otherOptions,
282
- update: update == null ? update : (content) => {
283
- const jsonValue = content === "" ? void 0 : JSON.parse(content);
284
- return JSON.stringify(update(jsonValue));
285
- }
286
- };
287
- }
288
- /**
289
- * Ensure file is present/absent asynchronously with content value initialized or modified with `update`
290
- *
291
- * @param options
292
- */
293
- async function json(options) {
294
- return file(toFileOption(options));
295
- }
296
- /**
297
- * Ensure file is present/absent synchronously with content value initialized or modified with `update`
298
- *
299
- * @param options
300
- */
301
- function jsonSync(options) {
302
- return fileSync(toFileOption(options));
303
- }
304
- //#endregion
305
72
  //#region src/meta.ts
306
73
  const meta = Object.freeze({
307
74
  name: "@w5s/dev",
308
- version: "3.2.3",
75
+ version: "3.3.0",
309
76
  buildNumber: 1
310
77
  });
311
78
  //#endregion
@@ -428,150 +195,6 @@ const ProjectScript = {
428
195
  Validate: "validate"
429
196
  };
430
197
  //#endregion
431
- //#region src/exec.ts
432
- /**
433
- * Runs a command in a shell and returns a promise that resolves with an object
434
- * containing the stdout and stderr strings.
435
- *
436
- * @param command The command to run
437
- * @param args The arguments to pass to the command
438
- * @param options
439
- * @returns A promise that resolves with an object like `{ stdout: string, stderr: string }`
440
- */
441
- function execSync(command, args, options) {
442
- const result = (0, node_child_process.spawnSync)(command, args, { ...options });
443
- const encoding = "utf8";
444
- return {
445
- stdout: result.stdout.toString(encoding),
446
- stderr: result.stderr.toString(encoding)
447
- };
448
- }
449
- /**
450
- * Runs a command in a shell and returns a promise that resolves with an object
451
- * containing the stdout and stderr strings.
452
- *
453
- * @param command The command to run
454
- * @param args The arguments to pass to the command
455
- * @param options
456
- */
457
- async function exec(command, args, options) {
458
- return new Promise((resolve, reject) => {
459
- const encoding = "utf8";
460
- const child = (0, node_child_process.spawn)(command, args, { ...options });
461
- let stdout = "";
462
- let stderr = "";
463
- if (child.stdout != null) child.stdout.on("data", (data) => {
464
- stdout += data.toString(encoding);
465
- });
466
- if (child.stderr != null) child.stderr.on("data", (data) => {
467
- stderr += data.toString(encoding);
468
- });
469
- child.on("close", (_code) => {
470
- resolve({
471
- stdout,
472
- stderr
473
- });
474
- });
475
- child.on("error", reject);
476
- });
477
- }
478
- //#endregion
479
- //#region src/yarnConfig.ts
480
- /**
481
- * Synchronous version of {@link yarnConfig}
482
- *
483
- * @param options
484
- * @example
485
- * yarnConfigSync({
486
- * key: 'nodeLinker',
487
- * state: 'present',
488
- * update: (content) => content.replace('node-modules', 'hoisted'),
489
- * })
490
- */
491
- function yarnConfigSync(options) {
492
- const { key, state, update } = options;
493
- if (state === "present") {
494
- const { stdout } = execSync("yarn", [
495
- "config",
496
- "get",
497
- String(key)
498
- ]);
499
- execSync("yarn", [
500
- "config",
501
- "set",
502
- String(key),
503
- `${update == null ? "" : update(stdout)}`
504
- ]);
505
- } else execSync("yarn", ["config", "unset"]);
506
- }
507
- /**
508
- * Set/Unset yarn configuration value
509
- *
510
- * @param options
511
- * @example
512
- * await yarnConfig({
513
- * key: 'nodeLinker',
514
- * state: 'present',
515
- * update: (content) => content.replace('node-modules', 'hoisted'),
516
- * })
517
- */
518
- async function yarnConfig(options) {
519
- const { key, state, update } = options;
520
- if (state === "present") {
521
- const { stdout } = await exec("yarn", [
522
- "config",
523
- "get",
524
- String(key)
525
- ]);
526
- await exec("yarn", [
527
- "config",
528
- "set",
529
- String(key),
530
- `${update == null ? "" : update(stdout)}`
531
- ]);
532
- } else await exec("yarn", ["config", "unset"]);
533
- }
534
- //#endregion
535
- //#region src/yarnVersion.ts
536
- /**
537
- * Synchronous version of {@link yarnVersion}
538
- *
539
- * @param options
540
- * @example
541
- * yarnVersionSync({
542
- * state: 'present',
543
- * update: () => 'berry', // or 'classic'
544
- * })
545
- */
546
- function yarnVersionSync(options) {
547
- const { state, update } = options;
548
- if (state === "present") execSync("yarn", [
549
- "set",
550
- "version",
551
- `${update == null ? "berry" : update()}`
552
- ]);
553
- else throw new Error("Not implemented");
554
- }
555
- /**
556
- * Set/Unset yarn configuration value
557
- *
558
- * @param options
559
- * @example
560
- * await yarnVersion({
561
- * state: 'present',
562
- * update: () => 'berry', // or 'classic'
563
- * })
564
- */
565
- async function yarnVersion(options) {
566
- const { state, update } = options;
567
- if (state === "present") await exec("yarn", [
568
- "set",
569
- "version",
570
- `${update == null ? "berry" : update()}`
571
- ]);
572
- else throw new Error("Not implemented");
573
- }
574
- //#endregion
575
198
  Object.defineProperty(exports, "ESLintConfig", {
576
199
  enumerable: true,
577
200
  get: function() {
@@ -585,19 +208,7 @@ Object.defineProperty(exports, "Project", {
585
208
  }
586
209
  });
587
210
  exports.ProjectScript = ProjectScript;
588
- exports.block = block;
589
- exports.blockSync = blockSync;
590
- exports.directory = directory;
591
- exports.directorySync = directorySync;
592
- exports.file = file;
593
- exports.fileSync = fileSync;
594
211
  exports.interopDefault = interopDefault;
595
- exports.json = json;
596
- exports.jsonSync = jsonSync;
597
212
  exports.meta = meta;
598
- exports.yarnConfig = yarnConfig;
599
- exports.yarnConfigSync = yarnConfigSync;
600
- exports.yarnVersion = yarnVersion;
601
- exports.yarnVersionSync = yarnVersionSync;
602
213
 
603
214
  //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","names":["exists","constants","constants"],"sources":["../src/directory.ts","../src/ESLintConfig.ts","../src/file.ts","../src/block.ts","../src/interopDefault.ts","../src/json.ts","../src/meta.ts","../src/Project.ts","../src/ProjectScript.ts","../src/exec.ts","../src/yarnConfig.ts","../src/yarnVersion.ts"],"sourcesContent":["import { existsSync, mkdirSync, rmSync } from 'node:fs';\nimport { access, constants, mkdir, rm } from 'node:fs/promises';\n\nasync function exists(path: string) {\n try {\n await access(path, constants.F_OK);\n return true;\n } catch {\n return false;\n }\n}\n\nexport interface DirectoryOptions {\n /**\n * Directory path\n */\n readonly path: string;\n\n /**\n * Directory target state\n */\n readonly state: 'present' | 'absent';\n}\n\n/**\n * Ensure directory is present/absent\n *\n * @example\n * ```ts\n * await directory({\n * path: 'foo/bar',\n * state: 'present',\n * })\n * ```\n *\n * @param options\n */\nexport async function directory(options: DirectoryOptions): Promise<void> {\n const { path, state } = options;\n const isPresent = await exists(path);\n if (state === 'present') {\n if (!isPresent) {\n await mkdir(path, { recursive: true });\n }\n } else if (isPresent) {\n await rm(path, { recursive: true });\n }\n}\n\n/**\n * Ensure directory is present/absent\n *\n * @example\n * ```ts\n * await directorySync({\n * path: 'foo/bar',\n * state: 'present',\n * })\n * ```\n *\n * @param options\n */\nexport function directorySync(options: DirectoryOptions): void {\n const { path, state } = options;\n const isPresent = existsSync(path);\n if (state === 'present') {\n if (!isPresent) {\n mkdirSync(path, { recursive: true });\n }\n } else if (isPresent) {\n rmSync(path, { recursive: true });\n }\n}\n","import type { ESLint } from 'eslint';\n\nfunction toArray<T>(value: T[] | T | undefined): T[] {\n if (value == null) {\n return [];\n }\n if (Array.isArray(value)) {\n return value;\n }\n return [value];\n}\n\nfunction concatArray<T>(left: T[] | T | undefined, right: T[] | T | undefined): T[] {\n return [...toArray(left), ...toArray(right)];\n}\n\nexport namespace ESLintConfig {\n /**\n *\n * @param configs\n */\n export function concat(...configs: ESLint.ConfigData[]): ESLint.ConfigData {\n return configs.reduce(\n (returnValue, config) => ({\n ...returnValue,\n ...config,\n env: { ...returnValue.env, ...config.env },\n extends: concatArray(returnValue.extends, config.extends),\n globals: { ...returnValue.globals, ...config.globals },\n overrides: concatArray(returnValue.overrides, config.overrides),\n parserOptions: { ...returnValue.parserOptions, ...config.parserOptions },\n plugins: concatArray(returnValue.plugins, config.plugins),\n rules: { ...returnValue.rules, ...config.rules },\n settings: { ...returnValue.settings, ...config.settings },\n }),\n {\n env: {},\n extends: [],\n globals: {},\n overrides: [],\n parserOptions: {},\n plugins: [],\n rules: {},\n settings: {},\n },\n );\n }\n\n /**\n * Always return 'off'. `_status` is the previous rule value.\n *\n * @param _status\n */\n export function fixme(_status: string | number | [string | number, ...any[]] | undefined) {\n return 'off' as const;\n }\n\n /**\n * Renames rules in the given object according to the given map.\n *\n * Given a map `{ 'old-prefix': 'new-prefix' }`, and a rule object\n * `{ 'old-prefix/rule-name': 'error' }`, this function will return\n * `{ 'new-prefix/rule-name': 'error' }`.\n *\n * @param rules The object containing the rules to rename.\n * @param map The object containing the rename map.\n */\n export function renameRules(rules: Record<string, any>, map: Record<string, string>): Record<string, any> {\n return Object.fromEntries(\n Object.entries(rules).map(([key, value]) => {\n for (const [from, to] of Object.entries(map)) {\n if (key.startsWith(`${from}/`)) return [to + key.slice(from.length), value];\n else if (from === '' && !key.includes('/') && to !== '') return [to + key, value];\n }\n return [key, value];\n }),\n );\n }\n}\n","import { readFile, rm, writeFile, access } from 'node:fs/promises';\nimport { accessSync, constants, readFileSync, rmSync, writeFileSync } from 'node:fs';\n\nasync function exists(path: string) {\n try {\n await access(path, constants.F_OK);\n return true;\n } catch {\n return false;\n }\n}\n\nfunction existsSync(path: string) {\n try {\n accessSync(path, constants.F_OK);\n return true;\n } catch {\n return false;\n }\n}\n\nexport interface FileOptions {\n /**\n * File path\n */\n readonly path: string;\n\n /**\n * File target state\n */\n readonly state: 'present' | 'absent';\n\n /**\n * File content mapping function\n *\n */\n readonly update?: ((content: string) => string | undefined) | undefined;\n\n /**\n * File encoding\n */\n readonly encoding?: BufferEncoding;\n}\n\n/**\n * Ensure file is present/absent with content initialized or modified with `update\n *\n * @example\n * ```ts\n * await file({\n * path: 'foo/bar',\n * state: 'present',\n * update: (content) => content + '_test', // This will append '_test' after current content\n * })\n * ```\n *\n * @param options\n */\nexport async function file(options: FileOptions): Promise<void> {\n const { path, state, update, encoding = 'utf8' } = options;\n if (state === 'present') {\n const isPresent = await exists(path);\n const previousContent = isPresent ? await readFile(path, encoding) : '';\n const newContent = update == null ? '' : update(previousContent);\n if (newContent != null) {\n await writeFile(path, newContent, encoding);\n }\n } else {\n await rm(path, { force: true });\n }\n}\n\n/**\n * Ensure file is present/absent with content initialized or modified with `update\n *\n * @example\n * ```ts\n * fileSync({\n * path: 'foo/bar',\n * state: 'present',\n * update: (content) => content + '_test', // This will append '_test' after current content\n * })\n * ```\n *\n * @param options\n */\nexport function fileSync(options: FileOptions): void {\n const { path, state, update, encoding = 'utf8' } = options;\n if (state === 'present') {\n const isPresent = existsSync(path);\n const previousContent = isPresent ? readFileSync(path, encoding) : '';\n const newContent = update == null ? '' : update(previousContent);\n if (newContent != null) {\n writeFileSync(path, newContent, encoding);\n }\n } else {\n rmSync(path, { force: true });\n }\n}\n","import { type FileOptions, file, fileSync } from './file.js';\n\nexport interface BlockOptions {\n /**\n * The marker builder function that will take either `markerBegin` or `markerEnd`\n *\n * @default '# ${mark} MANAGED BLOCK'\n */\n marker?: (mark: 'Begin' | 'End') => string;\n\n /**\n * File path\n */\n path: string;\n\n /**\n * Block content to insert\n */\n block: string;\n\n /**\n * Insert position\n */\n insertPosition?: ['before', 'BeginningOfFile' | RegExp] | ['after', 'EndOfFile' | RegExp];\n\n /**\n * Block target state\n */\n state?: 'present' | 'absent';\n}\n\nconst EOF = 'EndOfFile';\nconst BOF = 'BeginningOfFile';\nconst insertAt = (str: string, index: number, toInsert: string) => str.slice(0, index) + toInsert + str.slice(index);\nconst matchLast = (string: string, regexp: RegExp) => {\n const matcher = new RegExp(regexp.source, `${regexp.flags}g`);\n let firstIndex = -1;\n let lastIndex = -1;\n let matches;\n\n while (true) {\n matches = matcher.exec(string);\n if (matches == null) {\n break;\n }\n firstIndex = matches.index;\n lastIndex = matcher.lastIndex;\n }\n return { firstIndex, lastIndex };\n};\n\nfunction toFileOptions(options: BlockOptions): FileOptions {\n const {\n marker = (mark) => `# ${mark.toUpperCase()} MANAGED BLOCK`,\n path,\n block: blockName,\n insertPosition = ['after', EOF],\n state = 'present',\n } = options;\n\n const EOL = '\\n';\n const beginBlock = marker('Begin');\n const endBlock = marker('End');\n\n /**\n * @param content\n */\n function findBlock(content: string) {\n const startIndex = content.indexOf(beginBlock);\n const endIndex = content.indexOf(endBlock) + endBlock.length;\n\n return {\n endIndex,\n exists: startIndex !== -1 && endIndex >= 0,\n startIndex,\n };\n }\n\n function apply(fullContent: string, blockContent: string) {\n const found = findBlock(fullContent);\n const remove = state === 'absent';\n const replaceBlock = remove ? '' : beginBlock + EOL + blockContent + EOL + endBlock;\n const [positionDirection, positionAnchor] = insertPosition;\n\n if (found.exists) {\n return fullContent.slice(0, found.startIndex) + replaceBlock + fullContent.slice(found.endIndex);\n }\n if (remove) {\n return fullContent;\n }\n switch (positionDirection) {\n case 'before': {\n if (positionAnchor !== BOF) {\n const { firstIndex } = matchLast(fullContent, positionAnchor);\n if (firstIndex >= 0) {\n return insertAt(fullContent, firstIndex, replaceBlock + EOL);\n }\n }\n\n // Beginning of file\n return replaceBlock + EOL + fullContent;\n }\n case 'after': {\n // insert\n if (positionAnchor !== EOF) {\n const { lastIndex } = matchLast(fullContent, positionAnchor);\n if (lastIndex >= 0) {\n return insertAt(fullContent, lastIndex, EOL + replaceBlock);\n }\n }\n\n // end of file\n return fullContent + EOL + replaceBlock;\n }\n\n default: {\n throw new Error(`Unsupported position ${String(positionDirection)}`);\n }\n }\n }\n\n return {\n path,\n state: 'present',\n update: (sourceContent) => apply(sourceContent, blockName),\n };\n}\n\n/**\n * Replace asynchronously a block in file that follows pattern :\n *\n * marker(markerBegin)\n * ...\n * marker(markerEnd)\n *\n * @param options\n */\nexport function block(options: BlockOptions) {\n return file(toFileOptions(options));\n}\n\n/**\n * Replace synchronously a block in file that follows pattern :\n *\n * marker(markerBegin)\n * ...\n * marker(markerEnd)\n *\n * @param options\n */\nexport function blockSync(options: BlockOptions) {\n return fileSync(toFileOptions(options));\n}\n","const getDefaultOrElse = (_: any) => _?.default ?? _;\n\n/**\n * Resolves a module or promise-like object, returning the default export if available.\n *\n * @example\n * ```ts\n * // modules.ts\n * export default {\n * foo: true\n * };\n * // Async API\n * const modPromise = import('./module');\n * interopDefault(modPromise); // == Promise.resolve({ foo: true })\n * // Sync API\n * const mod = await import('./module');\n * interopDefault(mod); // == { foo: true }\n * ```\n *\n * @template T - The type of the module or promise-like object.\n * @param m The module or promise-like object to resolve.\n */\nexport function interopDefault<T>(m: PromiseLike<T>): Promise<T extends { default: infer U } ? U : T>;\nexport function interopDefault<T>(m: T): T extends { default: infer U } ? U : T;\nexport function interopDefault<T>(m: T | PromiseLike<T>): Promise<T extends { default: infer U } ? U : T> {\n // @ts-ignore We know what we are doing\n return m != null && typeof m.then === 'function' ? Promise.resolve(m).then(getDefaultOrElse) : getDefaultOrElse(m);\n}\n","import { type FileOptions, file, fileSync } from './file.js';\n\nexport type JSONValue = null | number | string | boolean | JSONValue[] | { [key: string]: JSONValue };\n\nexport interface JSONOption<V = JSONValue> {\n /**\n * File path\n */\n readonly path: string;\n\n /**\n * File target state\n */\n readonly state: 'present' | 'absent';\n\n /**\n * File content mapping function\n */\n readonly update?: ((content: V | undefined) => V | undefined) | undefined;\n\n /**\n * File encoding\n */\n readonly encoding?: BufferEncoding;\n}\n\nfunction toFileOption<Value>({ update, ...otherOptions }: JSONOption<Value>): FileOptions {\n return {\n ...otherOptions,\n\n update:\n update == null\n ? update\n : (content) => {\n const jsonValue = content === '' ? undefined : (JSON.parse(content) as Value);\n\n return JSON.stringify(update(jsonValue));\n },\n };\n}\n\n/**\n * Ensure file is present/absent asynchronously with content value initialized or modified with `update`\n *\n * @param options\n */\nexport async function json<Value>(options: JSONOption<Value>): Promise<void> {\n return file(toFileOption(options));\n}\n\n/**\n * Ensure file is present/absent synchronously with content value initialized or modified with `update`\n *\n * @param options\n */\nexport function jsonSync<Value>(options: JSONOption<Value>): void {\n return fileSync(toFileOption(options));\n}\n","export const meta = Object.freeze({\n // @ts-ignore - these variables are injected at build time\n name: (typeof __PACKAGE_NAME__ === 'undefined' ? '' : __PACKAGE_NAME__) as string,\n // @ts-ignore - these variables are injected at build time\n version: (typeof __PACKAGE_VERSION__ === 'undefined' ? '' : __PACKAGE_VERSION__) as string,\n // @ts-ignore - these variables are injected at build time\n buildNumber: 1 as number, // (typeof __PACKAGE_BUILD_NUMBER__ === 'undefined' ? 0 : __PACKAGE_BUILD_NUMBER__) as number,\n});\n","import type { LanguageId } from './LanguageId.js';\n\nfunction escapeRegExp(value: string) {\n // eslint-disable-next-line unicorn/prefer-string-raw\n return value.replaceAll(/[$()*+.?[\\\\\\]^{|}]/g, '\\\\$&'); // $& means the whole matched string\n}\n\nexport namespace Project {\n /**\n * A type of a file extension\n */\n export type Extension = `.${string}`;\n\n /**\n * Object hash of all well-known file extension category to file extensions mapping\n */\n export type ExtensionRegistry = { [K in LanguageId]: readonly Extension[] };\n\n /**\n * Supported ECMA version\n *\n * @example\n * ```ts\n * Project.ecmaVersion() // 2022\n * ```\n */\n export function ecmaVersion() {\n return 2022 as const;\n }\n\n const registry: ExtensionRegistry = {\n css: ['.css'],\n graphql: ['.gql', '.graphql'],\n javascript: ['.js', '.cjs', '.mjs'],\n javascriptreact: ['.jsx'],\n jpeg: ['.jpg', '.jpeg'],\n json: ['.json'],\n jsonc: ['.jsonc'],\n less: ['.less'],\n markdown: ['.markdown', '.mdown', '.mkd', '.md'],\n sass: ['.sass'],\n scss: ['.scss'],\n typescript: ['.ts', '.cts', '.mts'],\n typescriptreact: ['.tsx'],\n vue: ['.vue'],\n yaml: ['.yaml', '.yml'],\n };\n\n /**\n * Return a list of extensions\n *\n * @example\n * ```ts\n * Project.queryExtensions(['javascript']); // ['.js', '.cjs', ...]\n * Project.queryExtensions(['typescript', 'typescriptreact']); // ['.ts', '.mts', ..., '.tsx']\n * ```\n *\n * @param languages\n */\n export function queryExtensions(languages: LanguageId[]): readonly Extension[] {\n return languages\n .reduce<Extension[]>((previousValue, currentValue) =>\n // eslint-disable-next-line unicorn/prefer-spread\n previousValue.concat(registry[currentValue] ?? ([] as Extension[])), [])\n // eslint-disable-next-line unicorn/no-array-sort\n .sort();\n }\n\n /**\n * Supported file extensions\n *\n * @example\n * ```ts\n * Project.sourceExtensions() // ['.ts', '.js', ...]\n * ```\n */\n export function sourceExtensions() {\n return queryExtensions(['javascript', 'javascriptreact', 'typescript', 'typescriptreact']);\n }\n\n const RESOURCE_EXTENSIONS: readonly Extension[] = Object.freeze([\n '.gif',\n '.png',\n '.svg',\n ...queryExtensions(['css', 'graphql', 'jpeg', 'less', 'sass', 'sass', 'yaml']),\n ]);\n\n /**\n * Resource file extensions\n *\n * @example\n * ```ts\n * Project.resourceExtensions() // ['.css', '.sass', ...]\n * ```\n */\n export function resourceExtensions() {\n return RESOURCE_EXTENSIONS;\n }\n\n const IGNORED = Object.freeze([\n 'node_modules/',\n 'build/',\n 'cjs/',\n 'coverage/',\n 'dist/',\n 'dts/',\n 'esm/',\n 'lib/',\n 'mjs/',\n 'umd/',\n ]);\n\n /**\n * Files and folders to always ignore\n *\n * @example\n * ```ts\n * IGNORED // ['node_modules/', 'build/', ...]\n * ```\n */\n export function ignored() {\n return IGNORED;\n }\n\n /**\n * Return a RegExp that will match any list of extensions\n *\n * @param extensions\n * @example\n * ```ts\n * Project.extensionsToMatcher(['.js', '.ts']) // RegExp = /(\\.js|\\.ts)$/\n * ```\n */\n export function extensionsToMatcher(extensions: readonly Extension[]): RegExp {\n return new RegExp(`(${extensions.map(escapeRegExp).join('|')})$`);\n }\n\n /**\n * Return a glob matcher that will match any list of extensions\n *\n * @param extensions\n * @example\n * ```ts\n * Project.extensionsToGlob(['.js', '.ts']) // '*.+(js|ts)'\n * ```\n */\n export function extensionsToGlob(extensions: readonly Extension[]): string {\n return `*.+(${extensions.map((_) => _.replace(/^\\./, '')).join('|')})`;\n }\n}\n","/**\n * Project common scripts\n */\nexport const ProjectScript = {\n Build: 'build',\n Clean: 'clean',\n CodeAnalysis: 'code-analysis',\n Coverage: 'coverage',\n Develop: 'develop',\n Docs: 'docs',\n Format: 'format',\n Install: 'install',\n Lint: 'lint',\n Prepare: 'prepare',\n Release: 'release',\n Rescue: 'rescue',\n Spellcheck: 'spellcheck',\n Test: 'test',\n Validate: 'validate',\n} as const;\nexport type ProjectScript = (typeof ProjectScript)[keyof typeof ProjectScript];\n","import { spawn, spawnSync } from 'node:child_process';\n\nexport interface ExecOptions {\n /**\n * Current working directory\n */\n cwd?: string;\n\n /**\n * Stdio options\n */\n stdio?: 'inherit' | 'pipe' | 'ignore';\n}\n\n/**\n * Runs a command in a shell and returns a promise that resolves with an object\n * containing the stdout and stderr strings.\n *\n * @param command The command to run\n * @param args The arguments to pass to the command\n * @param options\n * @returns A promise that resolves with an object like `{ stdout: string, stderr: string }`\n */\nexport function execSync(\n command: string,\n args: ReadonlyArray<string>,\n options?: ExecOptions,\n): { stdout: string; stderr: string } {\n const result = spawnSync(command, args, { ...options });\n const encoding = 'utf8';\n\n return { stdout: result.stdout.toString(encoding), stderr: result.stderr.toString(encoding) };\n}\n\n/**\n * Runs a command in a shell and returns a promise that resolves with an object\n * containing the stdout and stderr strings.\n *\n * @param command The command to run\n * @param args The arguments to pass to the command\n * @param options\n */\nexport async function exec(\n command: string,\n args: ReadonlyArray<string>,\n options?: ExecOptions,\n): Promise<{ stdout: string; stderr: string }> {\n return new Promise((resolve, reject) => {\n const encoding = 'utf8';\n const child = spawn(command, args, { ...options });\n let stdout = '';\n let stderr = '';\n\n // Capture the stdout and stderr streams\n if (child.stdout != null) {\n child.stdout.on('data', (data) => {\n stdout += data.toString(encoding);\n });\n }\n if (child.stderr != null) {\n child.stderr.on('data', (data) => {\n stderr += data.toString(encoding);\n });\n }\n // Handle process exit\n child.on('close', (_code) => {\n resolve({ stdout, stderr });\n });\n\n // Handle errors\n child.on('error', reject);\n });\n}\n","import { exec, execSync } from './exec.js';\n\nexport interface YarnConfigOptions {\n /**\n * Configuration key\n */\n readonly key: string;\n\n /**\n * Option target state\n */\n readonly state: 'present' | 'absent';\n\n /**\n * File content mapping function\n *\n */\n readonly update?: ((content: string) => string | undefined) | undefined;\n}\n\n/**\n * Synchronous version of {@link yarnConfig}\n *\n * @param options\n * @example\n * yarnConfigSync({\n * key: 'nodeLinker',\n * state: 'present',\n * update: (content) => content.replace('node-modules', 'hoisted'),\n * })\n */\nexport function yarnConfigSync(options: YarnConfigOptions) {\n const { key, state, update } = options;\n if (state === 'present') {\n const { stdout } = execSync('yarn', ['config', 'get', String(key)]);\n execSync('yarn', ['config', 'set', String(key), `${update == null ? '' : update(stdout)}`]);\n } else {\n execSync('yarn', ['config', 'unset']);\n }\n}\n\n/**\n * Set/Unset yarn configuration value\n *\n * @param options\n * @example\n * await yarnConfig({\n * key: 'nodeLinker',\n * state: 'present',\n * update: (content) => content.replace('node-modules', 'hoisted'),\n * })\n */\nexport async function yarnConfig(options: YarnConfigOptions): Promise<void> {\n const { key, state, update } = options;\n if (state === 'present') {\n const { stdout } = await exec('yarn', ['config', 'get', String(key)]);\n await exec('yarn', ['config', 'set', String(key), `${update == null ? '' : update(stdout)}`]);\n } else {\n await exec('yarn', ['config', 'unset']);\n }\n}\n","import { exec, execSync } from './exec.js';\n\nexport type YarnVersionKind = 'berry' | 'classic';\n\nexport interface YarnVersionOptions {\n /**\n * Option target state\n */\n readonly state: 'present' | 'absent';\n\n /**\n * Version mapping function\n *\n */\n readonly update?: (() => YarnVersionKind | undefined) | undefined;\n}\n\n/**\n * Synchronous version of {@link yarnVersion}\n *\n * @param options\n * @example\n * yarnVersionSync({\n * state: 'present',\n * update: () => 'berry', // or 'classic'\n * })\n */\nexport function yarnVersionSync(options: YarnVersionOptions) {\n const { state, update } = options;\n if (state === 'present') {\n execSync('yarn', ['set', 'version', `${update == null ? 'berry' : update()}`]);\n } else {\n // TODO: remove yarn.lock\n throw new Error('Not implemented');\n }\n}\n\n/**\n * Set/Unset yarn configuration value\n *\n * @param options\n * @example\n * await yarnVersion({\n * state: 'present',\n * update: () => 'berry', // or 'classic'\n * })\n */\nexport async function yarnVersion(options: YarnVersionOptions): Promise<void> {\n const { state, update } = options;\n if (state === 'present') {\n await exec('yarn', ['set', 'version', `${update == null ? 'berry' : update()}`]);\n } else {\n // TODO: remove yarn.lock\n throw new Error('Not implemented');\n }\n}\n"],"mappings":";;;;;AAGA,eAAeA,SAAO,MAAc;AAClC,KAAI;AACF,SAAA,GAAA,iBAAA,QAAa,MAAMC,iBAAAA,UAAU,KAAK;AAClC,SAAO;SACD;AACN,SAAO;;;;;;;;;;;;;;;;AA6BX,eAAsB,UAAU,SAA0C;CACxE,MAAM,EAAE,MAAM,UAAU;CACxB,MAAM,YAAY,MAAMD,SAAO,KAAK;AACpC,KAAI,UAAU;MACR,CAAC,UACH,QAAA,GAAA,iBAAA,OAAY,MAAM,EAAE,WAAW,MAAM,CAAC;YAE/B,UACT,QAAA,GAAA,iBAAA,IAAS,MAAM,EAAE,WAAW,MAAM,CAAC;;;;;;;;;;;;;;;AAiBvC,SAAgB,cAAc,SAAiC;CAC7D,MAAM,EAAE,MAAM,UAAU;CACxB,MAAM,aAAA,GAAA,QAAA,YAAuB,KAAK;AAClC,KAAI,UAAU;MACR,CAAC,UACH,EAAA,GAAA,QAAA,WAAU,MAAM,EAAE,WAAW,MAAM,CAAC;YAE7B,UACT,EAAA,GAAA,QAAA,QAAO,MAAM,EAAE,WAAW,MAAM,CAAC;;;;ACpErC,SAAS,QAAW,OAAiC;AACnD,KAAI,SAAS,KACX,QAAO,EAAE;AAEX,KAAI,MAAM,QAAQ,MAAM,CACtB,QAAO;AAET,QAAO,CAAC,MAAM;;AAGhB,SAAS,YAAe,MAA2B,OAAiC;AAClF,QAAO,CAAC,GAAG,QAAQ,KAAK,EAAE,GAAG,QAAQ,MAAM,CAAC;;AAGvC,IAAA;;CAKE,SAAS,OAAO,GAAG,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,KAAK,OAAO,OAAO;GAAG,CAAC;OAE7F,OAAM,KAAK,QAAQ,CAAC,UAAU,QAAQ,CAAC;;;;;;;;;;;;;;AC/B3C,SAAgB,gBAAgB,SAA6B;CAC3D,MAAM,EAAE,OAAO,WAAW;AAC1B,KAAI,UAAU,UACZ,UAAS,QAAQ;EAAC;EAAO;EAAW,GAAG,UAAU,OAAO,UAAU,QAAQ;EAAG,CAAC;KAG9E,OAAM,IAAI,MAAM,kBAAkB;;;;;;;;;;;;AActC,eAAsB,YAAY,SAA4C;CAC5E,MAAM,EAAE,OAAO,WAAW;AAC1B,KAAI,UAAU,UACZ,OAAM,KAAK,QAAQ;EAAC;EAAO;EAAW,GAAG,UAAU,OAAO,UAAU,QAAQ;EAAG,CAAC;KAGhF,OAAM,IAAI,MAAM,kBAAkB"}
1
+ {"version":3,"file":"index.cjs","names":[],"sources":["../src/ESLintConfig.ts","../src/interopDefault.ts","../src/meta.ts","../src/Project.ts","../src/ProjectScript.ts"],"sourcesContent":["import type { ESLint } from 'eslint';\n\nfunction toArray<T>(value: T[] | T | undefined): T[] {\n if (value == null) {\n return [];\n }\n if (Array.isArray(value)) {\n return value;\n }\n return [value];\n}\n\nfunction concatArray<T>(left: T[] | T | undefined, right: T[] | T | undefined): T[] {\n return [...toArray(left), ...toArray(right)];\n}\n\nexport namespace ESLintConfig {\n /**\n *\n * @param configs\n */\n export function concat(...configs: ESLint.ConfigData[]): ESLint.ConfigData {\n return configs.reduce(\n (returnValue, config) => ({\n ...returnValue,\n ...config,\n env: { ...returnValue.env, ...config.env },\n extends: concatArray(returnValue.extends, config.extends),\n globals: { ...returnValue.globals, ...config.globals },\n overrides: concatArray(returnValue.overrides, config.overrides),\n parserOptions: { ...returnValue.parserOptions, ...config.parserOptions },\n plugins: concatArray(returnValue.plugins, config.plugins),\n rules: { ...returnValue.rules, ...config.rules },\n settings: { ...returnValue.settings, ...config.settings },\n }),\n {\n env: {},\n extends: [],\n globals: {},\n overrides: [],\n parserOptions: {},\n plugins: [],\n rules: {},\n settings: {},\n },\n );\n }\n\n /**\n * Always return 'off'. `_status` is the previous rule value.\n *\n * @param _status\n */\n export function fixme(_status: string | number | [string | number, ...any[]] | undefined) {\n return 'off' as const;\n }\n\n /**\n * Renames rules in the given object according to the given map.\n *\n * Given a map `{ 'old-prefix': 'new-prefix' }`, and a rule object\n * `{ 'old-prefix/rule-name': 'error' }`, this function will return\n * `{ 'new-prefix/rule-name': 'error' }`.\n *\n * @param rules The object containing the rules to rename.\n * @param map The object containing the rename map.\n */\n export function renameRules(rules: Record<string, any>, map: Record<string, string>): Record<string, any> {\n return Object.fromEntries(\n Object.entries(rules).map(([key, value]) => {\n for (const [from, to] of Object.entries(map)) {\n if (key.startsWith(`${from}/`)) return [to + key.slice(from.length), value];\n else if (from === '' && !key.includes('/') && to !== '') return [to + key, value];\n }\n return [key, value];\n }),\n );\n }\n}\n","const getDefaultOrElse = (_: any) => _?.default ?? _;\n\n/**\n * Resolves a module or promise-like object, returning the default export if available.\n *\n * @example\n * ```ts\n * // modules.ts\n * export default {\n * foo: true\n * };\n * // Async API\n * const modPromise = import('./module');\n * interopDefault(modPromise); // == Promise.resolve({ foo: true })\n * // Sync API\n * const mod = await import('./module');\n * interopDefault(mod); // == { foo: true }\n * ```\n *\n * @template T - The type of the module or promise-like object.\n * @param m The module or promise-like object to resolve.\n */\nexport function interopDefault<T>(m: PromiseLike<T>): Promise<T extends { default: infer U } ? U : T>;\nexport function interopDefault<T>(m: T): T extends { default: infer U } ? U : T;\nexport function interopDefault<T>(m: T | PromiseLike<T>): Promise<T extends { default: infer U } ? U : T> {\n // @ts-ignore We know what we are doing\n return m != null && typeof m.then === 'function' ? Promise.resolve(m).then(getDefaultOrElse) : getDefaultOrElse(m);\n}\n","export const meta = Object.freeze({\n // @ts-ignore - these variables are injected at build time\n name: (typeof __PACKAGE_NAME__ === 'undefined' ? '' : __PACKAGE_NAME__) as string,\n // @ts-ignore - these variables are injected at build time\n version: (typeof __PACKAGE_VERSION__ === 'undefined' ? '' : __PACKAGE_VERSION__) as string,\n // @ts-ignore - these variables are injected at build time\n buildNumber: 1 as number, // (typeof __PACKAGE_BUILD_NUMBER__ === 'undefined' ? 0 : __PACKAGE_BUILD_NUMBER__) as number,\n});\n","import type { LanguageId } from './LanguageId.js';\n\nfunction escapeRegExp(value: string) {\n // eslint-disable-next-line unicorn/prefer-string-raw\n return value.replaceAll(/[$()*+.?[\\\\\\]^{|}]/g, '\\\\$&'); // $& means the whole matched string\n}\n\nexport namespace Project {\n /**\n * A type of a file extension\n */\n export type Extension = `.${string}`;\n\n /**\n * Object hash of all well-known file extension category to file extensions mapping\n */\n export type ExtensionRegistry = { [K in LanguageId]: readonly Extension[] };\n\n /**\n * Supported ECMA version\n *\n * @example\n * ```ts\n * Project.ecmaVersion() // 2022\n * ```\n */\n export function ecmaVersion() {\n return 2022 as const;\n }\n\n const registry: ExtensionRegistry = {\n css: ['.css'],\n graphql: ['.gql', '.graphql'],\n javascript: ['.js', '.cjs', '.mjs'],\n javascriptreact: ['.jsx'],\n jpeg: ['.jpg', '.jpeg'],\n json: ['.json'],\n jsonc: ['.jsonc'],\n less: ['.less'],\n markdown: ['.markdown', '.mdown', '.mkd', '.md'],\n sass: ['.sass'],\n scss: ['.scss'],\n typescript: ['.ts', '.cts', '.mts'],\n typescriptreact: ['.tsx'],\n vue: ['.vue'],\n yaml: ['.yaml', '.yml'],\n };\n\n /**\n * Return a list of extensions\n *\n * @example\n * ```ts\n * Project.queryExtensions(['javascript']); // ['.js', '.cjs', ...]\n * Project.queryExtensions(['typescript', 'typescriptreact']); // ['.ts', '.mts', ..., '.tsx']\n * ```\n *\n * @param languages\n */\n export function queryExtensions(languages: LanguageId[]): readonly Extension[] {\n return languages\n .reduce<Extension[]>((previousValue, currentValue) =>\n // eslint-disable-next-line unicorn/prefer-spread\n previousValue.concat(registry[currentValue] ?? ([] as Extension[])), [])\n // eslint-disable-next-line unicorn/no-array-sort\n .sort();\n }\n\n /**\n * Supported file extensions\n *\n * @example\n * ```ts\n * Project.sourceExtensions() // ['.ts', '.js', ...]\n * ```\n */\n export function sourceExtensions() {\n return queryExtensions(['javascript', 'javascriptreact', 'typescript', 'typescriptreact']);\n }\n\n const RESOURCE_EXTENSIONS: readonly Extension[] = Object.freeze([\n '.gif',\n '.png',\n '.svg',\n ...queryExtensions(['css', 'graphql', 'jpeg', 'less', 'sass', 'sass', 'yaml']),\n ]);\n\n /**\n * Resource file extensions\n *\n * @example\n * ```ts\n * Project.resourceExtensions() // ['.css', '.sass', ...]\n * ```\n */\n export function resourceExtensions() {\n return RESOURCE_EXTENSIONS;\n }\n\n const IGNORED = Object.freeze([\n 'node_modules/',\n 'build/',\n 'cjs/',\n 'coverage/',\n 'dist/',\n 'dts/',\n 'esm/',\n 'lib/',\n 'mjs/',\n 'umd/',\n ]);\n\n /**\n * Files and folders to always ignore\n *\n * @example\n * ```ts\n * IGNORED // ['node_modules/', 'build/', ...]\n * ```\n */\n export function ignored() {\n return IGNORED;\n }\n\n /**\n * Return a RegExp that will match any list of extensions\n *\n * @param extensions\n * @example\n * ```ts\n * Project.extensionsToMatcher(['.js', '.ts']) // RegExp = /(\\.js|\\.ts)$/\n * ```\n */\n export function extensionsToMatcher(extensions: readonly Extension[]): RegExp {\n return new RegExp(`(${extensions.map(escapeRegExp).join('|')})$`);\n }\n\n /**\n * Return a glob matcher that will match any list of extensions\n *\n * @param extensions\n * @example\n * ```ts\n * Project.extensionsToGlob(['.js', '.ts']) // '*.+(js|ts)'\n * ```\n */\n export function extensionsToGlob(extensions: readonly Extension[]): string {\n return `*.+(${extensions.map((_) => _.replace(/^\\./, '')).join('|')})`;\n }\n}\n","/**\n * Project common scripts\n */\nexport const ProjectScript = {\n Build: 'build',\n Clean: 'clean',\n CodeAnalysis: 'code-analysis',\n Coverage: 'coverage',\n Develop: 'develop',\n Docs: 'docs',\n Format: 'format',\n Install: 'install',\n Lint: 'lint',\n Prepare: 'prepare',\n Release: 'release',\n Rescue: 'rescue',\n Spellcheck: 'spellcheck',\n Test: 'test',\n Validate: 'validate',\n} as const;\nexport type ProjectScript = (typeof ProjectScript)[keyof typeof ProjectScript];\n"],"mappings":";;AAEA,SAAS,QAAW,OAAiC;CACnD,IAAI,SAAS,MACX,OAAO,EAAE;CAEX,IAAI,MAAM,QAAQ,MAAM,EACtB,OAAO;CAET,OAAO,CAAC,MAAM;;AAGhB,SAAS,YAAe,MAA2B,OAAiC;CAClF,OAAO,CAAC,GAAG,QAAQ,KAAK,EAAE,GAAG,QAAQ,MAAM,CAAC;;AAGvC,IAAA;;CAKE,SAAS,OAAO,GAAG,SAAiD;EACzE,OAAO,QAAQ,QACZ,aAAa,YAAY;GACxB,GAAG;GACH,GAAG;GACH,KAAK;IAAE,GAAG,YAAY;IAAK,GAAG,OAAO;IAAK;GAC1C,SAAS,YAAY,YAAY,SAAS,OAAO,QAAQ;GACzD,SAAS;IAAE,GAAG,YAAY;IAAS,GAAG,OAAO;IAAS;GACtD,WAAW,YAAY,YAAY,WAAW,OAAO,UAAU;GAC/D,eAAe;IAAE,GAAG,YAAY;IAAe,GAAG,OAAO;IAAe;GACxE,SAAS,YAAY,YAAY,SAAS,OAAO,QAAQ;GACzD,OAAO;IAAE,GAAG,YAAY;IAAO,GAAG,OAAO;IAAO;GAChD,UAAU;IAAE,GAAG,YAAY;IAAU,GAAG,OAAO;IAAU;GAC1D,GACD;GACE,KAAK,EAAE;GACP,SAAS,EAAE;GACX,SAAS,EAAE;GACX,WAAW,EAAE;GACb,eAAe,EAAE;GACjB,SAAS,EAAE;GACX,OAAO,EAAE;GACT,UAAU,EAAE;GACb,CACF;;;CAQI,SAAS,MAAM,SAAoE;EACxF,OAAO;;;CAaF,SAAS,YAAY,OAA4B,KAAkD;EACxG,OAAO,OAAO,YACZ,OAAO,QAAQ,MAAM,CAAC,KAAK,CAAC,KAAK,WAAW;GAC1C,KAAK,MAAM,CAAC,MAAM,OAAO,OAAO,QAAQ,IAAI,EAC1C,IAAI,IAAI,WA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