@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.js CHANGED
@@ -1,56 +1,3 @@
1
- import { accessSync, constants, existsSync, mkdirSync, readFileSync, rmSync, writeFileSync } from "node:fs";
2
- import { access, constants as constants$1, mkdir, readFile, rm, writeFile } from "node:fs/promises";
3
- import { spawn, spawnSync } from "node:child_process";
4
- //#region src/directory.ts
5
- async function exists$1(path) {
6
- try {
7
- await access(path, constants$1.F_OK);
8
- return true;
9
- } catch {
10
- return false;
11
- }
12
- }
13
- /**
14
- * Ensure directory is present/absent
15
- *
16
- * @example
17
- * ```ts
18
- * await directory({
19
- * path: 'foo/bar',
20
- * state: 'present',
21
- * })
22
- * ```
23
- *
24
- * @param options
25
- */
26
- async function directory(options) {
27
- const { path, state } = options;
28
- const isPresent = await exists$1(path);
29
- if (state === "present") {
30
- if (!isPresent) await mkdir(path, { recursive: true });
31
- } else if (isPresent) await rm(path, { recursive: true });
32
- }
33
- /**
34
- * Ensure directory is present/absent
35
- *
36
- * @example
37
- * ```ts
38
- * await directorySync({
39
- * path: 'foo/bar',
40
- * state: 'present',
41
- * })
42
- * ```
43
- *
44
- * @param options
45
- */
46
- function directorySync(options) {
47
- const { path, state } = options;
48
- const isPresent = existsSync(path);
49
- if (state === "present") {
50
- if (!isPresent) mkdirSync(path, { recursive: true });
51
- } else if (isPresent) rmSync(path, { recursive: true });
52
- }
53
- //#endregion
54
1
  //#region src/ESLintConfig.ts
55
2
  function toArray(value) {
56
3
  if (value == null) return [];
@@ -115,196 +62,16 @@ let ESLintConfig;
115
62
  _ESLintConfig.renameRules = renameRules;
116
63
  })(ESLintConfig || (ESLintConfig = {}));
117
64
  //#endregion
118
- //#region src/file.ts
119
- async function exists(path) {
120
- try {
121
- await access(path, constants.F_OK);
122
- return true;
123
- } catch {
124
- return false;
125
- }
126
- }
127
- function existsSync$1(path) {
128
- try {
129
- accessSync(path, constants.F_OK);
130
- return true;
131
- } catch {
132
- return false;
133
- }
134
- }
135
- /**
136
- * Ensure file is present/absent with content initialized or modified with `update
137
- *
138
- * @example
139
- * ```ts
140
- * await file({
141
- * path: 'foo/bar',
142
- * state: 'present',
143
- * update: (content) => content + '_test', // This will append '_test' after current content
144
- * })
145
- * ```
146
- *
147
- * @param options
148
- */
149
- async function file(options) {
150
- const { path, state, update, encoding = "utf8" } = options;
151
- if (state === "present") {
152
- const previousContent = await exists(path) ? await readFile(path, encoding) : "";
153
- const newContent = update == null ? "" : update(previousContent);
154
- if (newContent != null) await writeFile(path, newContent, encoding);
155
- } else await rm(path, { force: true });
156
- }
157
- /**
158
- * Ensure file is present/absent with content initialized or modified with `update
159
- *
160
- * @example
161
- * ```ts
162
- * fileSync({
163
- * path: 'foo/bar',
164
- * state: 'present',
165
- * update: (content) => content + '_test', // This will append '_test' after current content
166
- * })
167
- * ```
168
- *
169
- * @param options
170
- */
171
- function fileSync(options) {
172
- const { path, state, update, encoding = "utf8" } = options;
173
- if (state === "present") {
174
- const previousContent = existsSync$1(path) ? readFileSync(path, encoding) : "";
175
- const newContent = update == null ? "" : update(previousContent);
176
- if (newContent != null) writeFileSync(path, newContent, encoding);
177
- } else rmSync(path, { force: true });
178
- }
179
- //#endregion
180
- //#region src/block.ts
181
- const EOF = "EndOfFile";
182
- const BOF = "BeginningOfFile";
183
- const insertAt = (str, index, toInsert) => str.slice(0, index) + toInsert + str.slice(index);
184
- const matchLast = (string, regexp) => {
185
- const matcher = new RegExp(regexp.source, `${regexp.flags}g`);
186
- let firstIndex = -1;
187
- let lastIndex = -1;
188
- let matches;
189
- while (true) {
190
- matches = matcher.exec(string);
191
- if (matches == null) break;
192
- firstIndex = matches.index;
193
- lastIndex = matcher.lastIndex;
194
- }
195
- return {
196
- firstIndex,
197
- lastIndex
198
- };
199
- };
200
- function toFileOptions(options) {
201
- const { marker = (mark) => `# ${mark.toUpperCase()} MANAGED BLOCK`, path, block: blockName, insertPosition = ["after", EOF], state = "present" } = options;
202
- const EOL = "\n";
203
- const beginBlock = marker("Begin");
204
- const endBlock = marker("End");
205
- /**
206
- * @param content
207
- */
208
- function findBlock(content) {
209
- const startIndex = content.indexOf(beginBlock);
210
- const endIndex = content.indexOf(endBlock) + endBlock.length;
211
- return {
212
- endIndex,
213
- exists: startIndex !== -1 && endIndex >= 0,
214
- startIndex
215
- };
216
- }
217
- function apply(fullContent, blockContent) {
218
- const found = findBlock(fullContent);
219
- const remove = state === "absent";
220
- const replaceBlock = remove ? "" : beginBlock + EOL + blockContent + EOL + endBlock;
221
- const [positionDirection, positionAnchor] = insertPosition;
222
- if (found.exists) return fullContent.slice(0, found.startIndex) + replaceBlock + fullContent.slice(found.endIndex);
223
- if (remove) return fullContent;
224
- switch (positionDirection) {
225
- case "before":
226
- if (positionAnchor !== BOF) {
227
- const { firstIndex } = matchLast(fullContent, positionAnchor);
228
- if (firstIndex >= 0) return insertAt(fullContent, firstIndex, replaceBlock + EOL);
229
- }
230
- return replaceBlock + EOL + fullContent;
231
- case "after":
232
- if (positionAnchor !== EOF) {
233
- const { lastIndex } = matchLast(fullContent, positionAnchor);
234
- if (lastIndex >= 0) return insertAt(fullContent, lastIndex, EOL + replaceBlock);
235
- }
236
- return fullContent + EOL + replaceBlock;
237
- default: throw new Error(`Unsupported position ${String(positionDirection)}`);
238
- }
239
- }
240
- return {
241
- path,
242
- state: "present",
243
- update: (sourceContent) => apply(sourceContent, blockName)
244
- };
245
- }
246
- /**
247
- * Replace asynchronously a block in file that follows pattern :
248
- *
249
- * marker(markerBegin)
250
- * ...
251
- * marker(markerEnd)
252
- *
253
- * @param options
254
- */
255
- function block(options) {
256
- return file(toFileOptions(options));
257
- }
258
- /**
259
- * Replace synchronously a block in file that follows pattern :
260
- *
261
- * marker(markerBegin)
262
- * ...
263
- * marker(markerEnd)
264
- *
265
- * @param options
266
- */
267
- function blockSync(options) {
268
- return fileSync(toFileOptions(options));
269
- }
270
- //#endregion
271
65
  //#region src/interopDefault.ts
272
66
  const getDefaultOrElse = (_) => _?.default ?? _;
273
67
  function interopDefault(m) {
274
68
  return m != null && typeof m.then === "function" ? Promise.resolve(m).then(getDefaultOrElse) : getDefaultOrElse(m);
275
69
  }
276
70
  //#endregion
277
- //#region src/json.ts
278
- function toFileOption({ update, ...otherOptions }) {
279
- return {
280
- ...otherOptions,
281
- update: update == null ? update : (content) => {
282
- const jsonValue = content === "" ? void 0 : JSON.parse(content);
283
- return JSON.stringify(update(jsonValue));
284
- }
285
- };
286
- }
287
- /**
288
- * Ensure file is present/absent asynchronously with content value initialized or modified with `update`
289
- *
290
- * @param options
291
- */
292
- async function json(options) {
293
- return file(toFileOption(options));
294
- }
295
- /**
296
- * Ensure file is present/absent synchronously with content value initialized or modified with `update`
297
- *
298
- * @param options
299
- */
300
- function jsonSync(options) {
301
- return fileSync(toFileOption(options));
302
- }
303
- //#endregion
304
71
  //#region src/meta.ts
305
72
  const meta = Object.freeze({
306
73
  name: "@w5s/dev",
307
- version: "3.2.3",
74
+ version: "3.3.0",
308
75
  buildNumber: 1
309
76
  });
310
77
  //#endregion
@@ -427,150 +194,6 @@ const ProjectScript = {
427
194
  Validate: "validate"
428
195
  };
429
196
  //#endregion
430
- //#region src/exec.ts
431
- /**
432
- * Runs a command in a shell and returns a promise that resolves with an object
433
- * containing the stdout and stderr strings.
434
- *
435
- * @param command The command to run
436
- * @param args The arguments to pass to the command
437
- * @param options
438
- * @returns A promise that resolves with an object like `{ stdout: string, stderr: string }`
439
- */
440
- function execSync(command, args, options) {
441
- const result = spawnSync(command, args, { ...options });
442
- const encoding = "utf8";
443
- return {
444
- stdout: result.stdout.toString(encoding),
445
- stderr: result.stderr.toString(encoding)
446
- };
447
- }
448
- /**
449
- * Runs a command in a shell and returns a promise that resolves with an object
450
- * containing the stdout and stderr strings.
451
- *
452
- * @param command The command to run
453
- * @param args The arguments to pass to the command
454
- * @param options
455
- */
456
- async function exec(command, args, options) {
457
- return new Promise((resolve, reject) => {
458
- const encoding = "utf8";
459
- const child = spawn(command, args, { ...options });
460
- let stdout = "";
461
- let stderr = "";
462
- if (child.stdout != null) child.stdout.on("data", (data) => {
463
- stdout += data.toString(encoding);
464
- });
465
- if (child.stderr != null) child.stderr.on("data", (data) => {
466
- stderr += data.toString(encoding);
467
- });
468
- child.on("close", (_code) => {
469
- resolve({
470
- stdout,
471
- stderr
472
- });
473
- });
474
- child.on("error", reject);
475
- });
476
- }
477
- //#endregion
478
- //#region src/yarnConfig.ts
479
- /**
480
- * Synchronous version of {@link yarnConfig}
481
- *
482
- * @param options
483
- * @example
484
- * yarnConfigSync({
485
- * key: 'nodeLinker',
486
- * state: 'present',
487
- * update: (content) => content.replace('node-modules', 'hoisted'),
488
- * })
489
- */
490
- function yarnConfigSync(options) {
491
- const { key, state, update } = options;
492
- if (state === "present") {
493
- const { stdout } = execSync("yarn", [
494
- "config",
495
- "get",
496
- String(key)
497
- ]);
498
- execSync("yarn", [
499
- "config",
500
- "set",
501
- String(key),
502
- `${update == null ? "" : update(stdout)}`
503
- ]);
504
- } else execSync("yarn", ["config", "unset"]);
505
- }
506
- /**
507
- * Set/Unset yarn configuration value
508
- *
509
- * @param options
510
- * @example
511
- * await yarnConfig({
512
- * key: 'nodeLinker',
513
- * state: 'present',
514
- * update: (content) => content.replace('node-modules', 'hoisted'),
515
- * })
516
- */
517
- async function yarnConfig(options) {
518
- const { key, state, update } = options;
519
- if (state === "present") {
520
- const { stdout } = await exec("yarn", [
521
- "config",
522
- "get",
523
- String(key)
524
- ]);
525
- await exec("yarn", [
526
- "config",
527
- "set",
528
- String(key),
529
- `${update == null ? "" : update(stdout)}`
530
- ]);
531
- } else await exec("yarn", ["config", "unset"]);
532
- }
533
- //#endregion
534
- //#region src/yarnVersion.ts
535
- /**
536
- * Synchronous version of {@link yarnVersion}
537
- *
538
- * @param options
539
- * @example
540
- * yarnVersionSync({
541
- * state: 'present',
542
- * update: () => 'berry', // or 'classic'
543
- * })
544
- */
545
- function yarnVersionSync(options) {
546
- const { state, update } = options;
547
- if (state === "present") execSync("yarn", [
548
- "set",
549
- "version",
550
- `${update == null ? "berry" : update()}`
551
- ]);
552
- else throw new Error("Not implemented");
553
- }
554
- /**
555
- * Set/Unset yarn configuration value
556
- *
557
- * @param options
558
- * @example
559
- * await yarnVersion({
560
- * state: 'present',
561
- * update: () => 'berry', // or 'classic'
562
- * })
563
- */
564
- async function yarnVersion(options) {
565
- const { state, update } = options;
566
- if (state === "present") await exec("yarn", [
567
- "set",
568
- "version",
569
- `${update == null ? "berry" : update()}`
570
- ]);
571
- else throw new Error("Not implemented");
572
- }
573
- //#endregion
574
- export { ESLintConfig, Project, ProjectScript, block, blockSync, directory, directorySync, file, fileSync, interopDefault, json, jsonSync, meta, yarnConfig, yarnConfigSync, yarnVersion, yarnVersionSync };
197
+ export { ESLintConfig, Project, ProjectScript, interopDefault, meta };
575
198
 
576
199
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["exists","constants","existsSync"],"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,QAAM,OAAO,MAAMC,YAAU,KAAK;AAClC,SAAO;SACD;AACN,SAAO;;;;;;;;;;;;;;;;AA6BX,eAAsB,UAAU,SAA0C;CACxE,MAAM,EAAE,MAAM,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AI,UAAU,WAAW;EACvB,MAAM,EAAE,WAAW,SAAS,QAAQ;GAAC;GAAU;GAAO,OAAO,IAAI;GAAC,CAAC;AACnE,WAAS,QAAQ;GAAC;GAAU;GAAO,OAAO,IAAI;GAAE,GAAG,UAAU,OAAO,KAAK,OAAO,OAAO;GAAG,CAAC;OAE3F,UAAS,QAAQ,CAAC,UAAU,QAAQ,CAAC;;;;;;;;;;;;;AAezC,eAAsB,WAAW,SAA2C;CAC1E,MAAM,EAAE,KAAK,OAAO,WAAW;AAC/B,KAAI,UAAU,WAAW;EACvB,MAAM,EAAE,WAAW,MAAM,KAAK,QAAQ;GAAC;GAAU;GAAO,OAAO,IAAI;GAAC,CAAC;AACrE,QAAM,KAAK,QAAQ;GAAC;GAAU;GAAO,OAAO,IAAI;GAAE,GAAG,UAAU,OAAO,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.js","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,SAA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ACT,MAAM;CACN,SAAS;CACT,SAAS;CACT,QAAQ;CACR,YAAY;CACZ,MAAM;CACN,UAAU;CACX"}
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@w5s/dev",
3
- "version": "3.2.3",
3
+ "version": "3.3.0",
4
4
  "description": "Shared development constants and functions",
5
5
  "keywords": [
6
6
  "config",
7
7
  "dev"
8
8
  ],
9
- "homepage": "https://github.com/w5s/project-config/blob/main/packagesdev#readme",
9
+ "homepage": "https://github.com/w5s/project-config/blob/main/packages/dev#readme",
10
10
  "bugs": {
11
11
  "url": "https://github.com/w5s/project-config/issues"
12
12
  },
@@ -48,11 +48,11 @@
48
48
  "@types/eslint": "^9.0.0"
49
49
  },
50
50
  "engines": {
51
- "node": ">=20.0.0"
51
+ "node": ">=22.0.0"
52
52
  },
53
53
  "publishConfig": {
54
54
  "access": "public"
55
55
  },
56
56
  "sideEffect": false,
57
- "gitHead": "4e72e6d3c7b204e0f08c3f44817d48ad0d44ea33"
57
+ "gitHead": "38cf5f5877af4c8a1c292b9b7039c5a11863fc00"
58
58
  }
package/src/index.ts CHANGED
@@ -1,12 +1,6 @@
1
- export * from './directory.js';
2
1
  export * from './ESLintConfig.js';
3
- export * from './block.js';
4
- export * from './file.js';
5
2
  export * from './interopDefault.js';
6
3
  export * from './LanguageId.js';
7
- export * from './json.js';
8
4
  export * from './meta.js';
9
5
  export * from './Project.js';
10
6
  export * from './ProjectScript.js';
11
- export * from './yarnConfig.js';
12
- export * from './yarnVersion.js';