@w5s/dev 2.3.0 → 2.5.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.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { ESLint, Linter } from 'eslint';
1
+ import { ESLint } from 'eslint';
2
2
 
3
3
  interface DirectoryOptions {
4
4
  /**
@@ -50,7 +50,19 @@ declare namespace ESLintConfig {
50
50
  *
51
51
  * @param _status
52
52
  */
53
- function fixme(_status: Linter.RuleLevel | [Linter.RuleLevel, ...any[]] | undefined): "off";
53
+ function fixme(_status: string | number | [string | number, ...any[]] | undefined): "off";
54
+ /**
55
+ * Renames rules in the given object according to the given map.
56
+ *
57
+ * Given a map `{ 'old-prefix': 'new-prefix' }`, and a rule object
58
+ * `{ 'old-prefix/rule-name': 'error' }`, this function will return
59
+ * `{ 'new-prefix/rule-name': 'error' }`.
60
+ *
61
+ * @param rules - The object containing the rules to rename.
62
+ * @param map - The object containing the rename map.
63
+ * @returns The object with the renamed rules.
64
+ */
65
+ function renameRules(rules: Record<string, any>, map: Record<string, string>): Record<string, any>;
54
66
  }
55
67
 
56
68
  interface BlockOptions {
@@ -149,6 +161,44 @@ declare function file(options: FileOptions): Promise<void>;
149
161
  */
150
162
  declare function fileSync(options: FileOptions): void;
151
163
 
164
+ /**
165
+ * Resolves a module or promise-like object, returning the default export if available.
166
+ *
167
+ * @example
168
+ * ```ts
169
+ * await interopDefault(import('./module'));// Can be a commonjs or esm module
170
+ * ```
171
+ *
172
+ * @template T - The type of the module or promise-like object.
173
+ * @param {T | PromiseLike<T>} m - The module or promise-like object to resolve.
174
+ * @returns {Promise<T extends { default: infer U } ? U : T>} A promise resolving to the default export if present, otherwise the module itself.
175
+ */
176
+ declare function interopDefault<T>(m: T | PromiseLike<T>): Promise<T extends {
177
+ default: infer U;
178
+ } ? U : T>;
179
+
180
+ interface LanguageIdMap {
181
+ css: true;
182
+ graphql: true;
183
+ javascript: true;
184
+ javascriptreact: true;
185
+ jpeg: true;
186
+ json: true;
187
+ jsonc: true;
188
+ less: true;
189
+ markdown: true;
190
+ sass: true;
191
+ scss: true;
192
+ typescript: true;
193
+ typescriptreact: true;
194
+ vue: true;
195
+ yaml: true;
196
+ }
197
+ /**
198
+ * A list of "vscode-like" language identifiers (i.e. "javascript", "javascriptreact")
199
+ */
200
+ type LanguageId = keyof LanguageIdMap;
201
+
152
202
  type JSONValue = null | number | string | boolean | JSONValue[] | {
153
203
  [key: string]: JSONValue;
154
204
  };
@@ -193,19 +243,9 @@ declare namespace Project {
193
243
  /**
194
244
  * Object hash of all well-known file extension category to file extensions mapping
195
245
  */
196
- interface ExtensionRegistry {
197
- graphql: readonly Extension[];
198
- jpeg: readonly Extension[];
199
- javascript: readonly Extension[];
200
- javascriptreact: readonly Extension[];
201
- typescript: readonly Extension[];
202
- typescriptreact: readonly Extension[];
203
- yaml: readonly Extension[];
204
- }
205
- /**
206
- * A list of "vscode-like" language identifiers (i.e. "javascript", "javascriptreact")
207
- */
208
- type LanguageId = keyof ExtensionRegistry;
246
+ type ExtensionRegistry = {
247
+ [K in LanguageId]: readonly Extension[];
248
+ };
209
249
  /**
210
250
  * Supported ECMA version
211
251
  *
@@ -296,4 +336,77 @@ declare const ProjectScript: {
296
336
  };
297
337
  type ProjectScript = (typeof ProjectScript)[keyof typeof ProjectScript];
298
338
 
299
- export { type BlockOptions, type DirectoryOptions, ESLintConfig, type FileOptions, type JSONOption, type JSONValue, Project, ProjectScript, block, blockSync, directory, directorySync, file, fileSync, json, jsonSync };
339
+ interface YarnConfigOptions {
340
+ /**
341
+ * Configuration key
342
+ */
343
+ readonly key: string;
344
+ /**
345
+ * Option target state
346
+ */
347
+ readonly state: 'present' | 'absent';
348
+ /**
349
+ * File content mapping function
350
+ *
351
+ * @param content
352
+ */
353
+ readonly update?: ((content: string) => string | undefined) | undefined;
354
+ }
355
+ /**
356
+ * Synchronous version of {@link yarnConfig}
357
+ *
358
+ * @example
359
+ * yarnConfigSync({
360
+ * key: 'nodeLinker',
361
+ * state: 'present',
362
+ * update: (content) => content.replace('node-modules', 'hoisted'),
363
+ * })
364
+ */
365
+ declare function yarnConfigSync(options: YarnConfigOptions): void;
366
+ /**
367
+ * Set/Unset yarn configuration value
368
+ *
369
+ * @example
370
+ * await yarnConfig({
371
+ * key: 'nodeLinker',
372
+ * state: 'present',
373
+ * update: (content) => content.replace('node-modules', 'hoisted'),
374
+ * })
375
+ */
376
+ declare function yarnConfig(options: YarnConfigOptions): Promise<void>;
377
+
378
+ type YarnVersionKind = 'berry' | 'classic';
379
+ interface YarnVersionOptions {
380
+ /**
381
+ * Option target state
382
+ */
383
+ readonly state: 'present' | 'absent';
384
+ /**
385
+ * Version mapping function
386
+ *
387
+ * @param content
388
+ */
389
+ readonly update?: (() => YarnVersionKind | undefined) | undefined;
390
+ }
391
+ /**
392
+ * Synchronous version of {@link yarnVersion}
393
+ *
394
+ * @example
395
+ * yarnVersionSync({
396
+ * state: 'present',
397
+ * update: () => 'berry', // or 'classic'
398
+ * })
399
+ */
400
+ declare function yarnVersionSync(options: YarnVersionOptions): void;
401
+ /**
402
+ * Set/Unset yarn configuration value
403
+ *
404
+ * @example
405
+ * await yarnVersion({
406
+ * state: 'present',
407
+ * update: () => 'berry', // or 'classic'
408
+ * })
409
+ */
410
+ declare function yarnVersion(options: YarnVersionOptions): Promise<void>;
411
+
412
+ export { type BlockOptions, type DirectoryOptions, ESLintConfig, type FileOptions, type JSONOption, type JSONValue, type LanguageId, type LanguageIdMap, Project, ProjectScript, type YarnConfigOptions, type YarnVersionKind, type YarnVersionOptions, block, blockSync, directory, directorySync, file, fileSync, interopDefault, json, jsonSync, yarnConfig, yarnConfigSync, yarnVersion, yarnVersionSync };
package/dist/index.js CHANGED
@@ -1,5 +1,6 @@
1
1
  import { existsSync, mkdirSync, rmSync, readFileSync, writeFileSync, constants as constants$1, accessSync } from 'node:fs';
2
2
  import { mkdir, rm, readFile, writeFile, access, constants } from 'node:fs/promises';
3
+ import { spawnSync, spawn } from 'node:child_process';
3
4
 
4
5
  // src/directory.ts
5
6
  async function exists(path) {
@@ -33,7 +34,7 @@ function directorySync(options) {
33
34
  }
34
35
  }
35
36
 
36
- // src/eslint.ts
37
+ // src/ESLintConfig.ts
37
38
  function toArray(value) {
38
39
  if (value == null) {
39
40
  return [];
@@ -79,6 +80,17 @@ var ESLintConfig;
79
80
  return "off";
80
81
  }
81
82
  ESLintConfig2.fixme = fixme;
83
+ function renameRules(rules, map) {
84
+ return Object.fromEntries(
85
+ Object.entries(rules).map(([key, value]) => {
86
+ for (const [from, to] of Object.entries(map)) {
87
+ if (key.startsWith(`${from}/`)) return [to + key.slice(from.length), value];
88
+ }
89
+ return [key, value];
90
+ })
91
+ );
92
+ }
93
+ ESLintConfig2.renameRules = renameRules;
82
94
  })(ESLintConfig || (ESLintConfig = {}));
83
95
  async function exists2(path) {
84
96
  try {
@@ -210,6 +222,12 @@ function blockSync(options) {
210
222
  return fileSync(toFileOptions(options));
211
223
  }
212
224
 
225
+ // src/interopDefault.ts
226
+ async function interopDefault(m) {
227
+ const resolved = await m;
228
+ return resolved.default ?? resolved;
229
+ }
230
+
213
231
  // src/json.ts
214
232
  function toFileOption({ update, ...otherOptions }) {
215
233
  return {
@@ -227,7 +245,7 @@ function jsonSync(options) {
227
245
  return fileSync(toFileOption(options));
228
246
  }
229
247
 
230
- // src/project.ts
248
+ // src/Project.ts
231
249
  function escapeRegExp(value) {
232
250
  return value.replaceAll(/[$()*+.?[\\\]^{|}]/g, "\\$&");
233
251
  }
@@ -238,20 +256,24 @@ var Project;
238
256
  }
239
257
  Project2.ecmaVersion = ecmaVersion;
240
258
  const registry = {
259
+ css: [".css"],
241
260
  graphql: [".gql", ".graphql"],
242
- jpeg: [".jpg", ".jpeg"],
243
261
  javascript: [".js", ".cjs", ".mjs"],
244
262
  javascriptreact: [".jsx"],
263
+ jpeg: [".jpg", ".jpeg"],
264
+ json: [".json"],
265
+ jsonc: [".jsonc"],
266
+ less: [".less"],
267
+ markdown: [".markdown", ".mdown", ".mkd", ".md"],
268
+ sass: [".sass"],
269
+ scss: [".scss"],
245
270
  typescript: [".ts", ".cts", ".mts"],
246
271
  typescriptreact: [".tsx"],
272
+ vue: [".vue"],
247
273
  yaml: [".yaml", ".yml"]
248
274
  };
249
275
  function queryExtensions(languages) {
250
- return languages.reduce(
251
- // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
252
- (previousValue, currentValue) => previousValue.concat(registry[currentValue] ?? []),
253
- []
254
- ).sort();
276
+ return languages.reduce((previousValue, currentValue) => previousValue.concat(registry[currentValue] ?? []), []).sort();
255
277
  }
256
278
  Project2.queryExtensions = queryExtensions;
257
279
  function sourceExtensions() {
@@ -259,14 +281,10 @@ var Project;
259
281
  }
260
282
  Project2.sourceExtensions = sourceExtensions;
261
283
  const RESOURCE_EXTENSIONS = Object.freeze([
262
- ".css",
263
- ".sass",
264
- ".scss",
265
- ".less",
266
284
  ".gif",
267
285
  ".png",
268
286
  ".svg",
269
- ...queryExtensions(["graphql", "jpeg", "yaml"])
287
+ ...queryExtensions(["css", "graphql", "jpeg", "less", "sass", "sass", "yaml"])
270
288
  ]);
271
289
  function resourceExtensions() {
272
290
  return RESOURCE_EXTENSIONS;
@@ -298,7 +316,7 @@ var Project;
298
316
  Project2.extensionsToGlob = extensionsToGlob;
299
317
  })(Project || (Project = {}));
300
318
 
301
- // src/projectScript.ts
319
+ // src/ProjectScript.ts
302
320
  var ProjectScript = {
303
321
  Build: "build",
304
322
  Clean: "clean",
@@ -316,7 +334,72 @@ var ProjectScript = {
316
334
  Test: "test",
317
335
  Validate: "validate"
318
336
  };
337
+ function execSync(command, args, options) {
338
+ const result = spawnSync(command, args, { ...options });
339
+ const encoding = "utf8";
340
+ return { stdout: result.stdout.toString(encoding), stderr: result.stderr.toString(encoding) };
341
+ }
342
+ async function exec(command, args, options) {
343
+ return new Promise((resolve, reject) => {
344
+ const encoding = "utf8";
345
+ const child = spawn(command, args, { ...options });
346
+ let stdout = "";
347
+ let stderr = "";
348
+ if (child.stdout != null) {
349
+ child.stdout.on("data", (data) => {
350
+ stdout += data.toString(encoding);
351
+ });
352
+ }
353
+ if (child.stderr != null) {
354
+ child.stderr.on("data", (data) => {
355
+ stderr += data.toString(encoding);
356
+ });
357
+ }
358
+ child.on("close", (_code) => {
359
+ resolve({ stdout, stderr });
360
+ });
361
+ child.on("error", reject);
362
+ });
363
+ }
364
+
365
+ // src/yarnConfig.ts
366
+ function yarnConfigSync(options) {
367
+ const { key, state, update } = options;
368
+ if (state === "present") {
369
+ const { stdout } = execSync("yarn", ["config", "get", String(key)]);
370
+ execSync("yarn", ["config", "set", String(key), `${update == null ? "" : update(stdout)}`]);
371
+ } else {
372
+ execSync("yarn", ["config", "unset"]);
373
+ }
374
+ }
375
+ async function yarnConfig(options) {
376
+ const { key, state, update } = options;
377
+ if (state === "present") {
378
+ const { stdout } = await exec("yarn", ["config", "get", String(key)]);
379
+ await exec("yarn", ["config", "set", String(key), `${update == null ? "" : update(stdout)}`]);
380
+ } else {
381
+ await exec("yarn", ["config", "unset"]);
382
+ }
383
+ }
384
+
385
+ // src/yarnVersion.ts
386
+ function yarnVersionSync(options) {
387
+ const { state, update } = options;
388
+ if (state === "present") {
389
+ execSync("yarn", ["set", "version", `${update == null ? "berry" : update()}`]);
390
+ } else {
391
+ throw new Error("Not implemented");
392
+ }
393
+ }
394
+ async function yarnVersion(options) {
395
+ const { state, update } = options;
396
+ if (state === "present") {
397
+ await exec("yarn", ["set", "version", `${update == null ? "berry" : update()}`]);
398
+ } else {
399
+ throw new Error("Not implemented");
400
+ }
401
+ }
319
402
 
320
- export { ESLintConfig, Project, ProjectScript, block, blockSync, directory, directorySync, file, fileSync, json, jsonSync };
403
+ export { ESLintConfig, Project, ProjectScript, block, blockSync, directory, directorySync, file, fileSync, interopDefault, json, jsonSync, yarnConfig, yarnConfigSync, yarnVersion, yarnVersionSync };
321
404
  //# sourceMappingURL=index.js.map
322
405
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/directory.ts","../src/eslint.ts","../src/file.ts","../src/block.ts","../src/json.ts","../src/project.ts","../src/projectScript.ts"],"names":["ESLintConfig","exists","access","constants","existsSync","rm","rmSync","Project"],"mappings":";;;;AAGA,eAAe,OAAO,IAAc,EAAA;AAClC,EAAI,IAAA;AACF,IAAM,MAAA,MAAA,CAAO,IAAM,EAAA,SAAA,CAAU,IAAI,CAAA;AACjC,IAAO,OAAA,IAAA;AAAA,GACD,CAAA,MAAA;AACN,IAAO,OAAA,KAAA;AAAA;AAEX;AA0BA,eAAsB,UAAU,OAA0C,EAAA;AACxE,EAAM,MAAA,EAAE,IAAM,EAAA,KAAA,EAAU,GAAA,OAAA;AACxB,EAAM,MAAA,SAAA,GAAY,MAAM,MAAA,CAAO,IAAI,CAAA;AACnC,EAAA,IAAI,UAAU,SAAW,EAAA;AACvB,IAAA,IAAI,CAAC,SAAW,EAAA;AACd,MAAA,MAAM,KAAM,CAAA,IAAA,EAAM,EAAE,SAAA,EAAW,MAAM,CAAA;AAAA;AACvC,aACS,SAAW,EAAA;AACpB,IAAA,MAAM,EAAG,CAAA,IAAA,EAAM,EAAE,SAAA,EAAW,MAAM,CAAA;AAAA;AAEtC;AAeO,SAAS,cAAc,OAAiC,EAAA;AAC7D,EAAM,MAAA,EAAE,IAAM,EAAA,KAAA,EAAU,GAAA,OAAA;AACxB,EAAM,MAAA,SAAA,GAAY,WAAW,IAAI,CAAA;AACjC,EAAA,IAAI,UAAU,SAAW,EAAA;AACvB,IAAA,IAAI,CAAC,SAAW,EAAA;AACd,MAAA,SAAA,CAAU,IAAM,EAAA,EAAE,SAAW,EAAA,IAAA,EAAM,CAAA;AAAA;AACrC,aACS,SAAW,EAAA;AACpB,IAAA,MAAA,CAAO,IAAM,EAAA,EAAE,SAAW,EAAA,IAAA,EAAM,CAAA;AAAA;AAEpC;;;ACrEA,SAAS,QAAW,KAAiC,EAAA;A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AA;AACZ","file":"index.js","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 * 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, Linter } 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).concat(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: Linter.RuleLevel | [Linter.RuleLevel, ...any[]] | undefined) {\n return 'off' as const;\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 * File target state\n */\n readonly state: 'present' | 'absent';\n /**\n * File content mapping function\n *\n * @param content\n */\n readonly update?: ((content: string) => string | undefined) | undefined;\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 * File path\n */\n path: string;\n /**\n * Block content to insert\n */\n block: string;\n /**\n * Insert position\n */\n insertPosition?: ['before', 'BeginningOfFile' | RegExp] | ['after', 'EndOfFile' | RegExp];\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 // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition, no-constant-condition\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","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 * File target state\n */\n readonly state: 'present' | 'absent';\n /**\n * File content mapping function\n *\n * @param content\n */\n readonly update?: ((content: V | undefined) => V | undefined) | undefined;\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","function 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 interface ExtensionRegistry {\n graphql: readonly Extension[];\n jpeg: readonly Extension[];\n javascript: readonly Extension[];\n javascriptreact: readonly Extension[];\n typescript: readonly Extension[];\n typescriptreact: readonly Extension[];\n yaml: readonly Extension[];\n }\n\n /**\n * A list of \"vscode-like\" language identifiers (i.e. \"javascript\", \"javascriptreact\")\n */\n export type LanguageId = keyof ExtensionRegistry;\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 graphql: ['.gql', '.graphql'],\n jpeg: ['.jpg', '.jpeg'],\n javascript: ['.js', '.cjs', '.mjs'],\n javascriptreact: ['.jsx'],\n typescript: ['.ts', '.cts', '.mts'],\n typescriptreact: ['.tsx'],\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[]>(\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition\n (previousValue, currentValue) => previousValue.concat(registry[currentValue] ?? ([] as Extension[])),\n [],\n )\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 '.css',\n '.sass',\n '.scss',\n '.less',\n '.gif',\n '.png',\n '.svg',\n ...queryExtensions(['graphql', 'jpeg', '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 * @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 * @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"]}
1
+ {"version":3,"sources":["../src/directory.ts","../src/ESLintConfig.ts","../src/file.ts","../src/block.ts","../src/interopDefault.ts","../src/json.ts","../src/Project.ts","../src/ProjectScript.ts","../src/exec.ts","../src/yarnConfig.ts","../src/yarnVersion.ts"],"names":["ESLintConfig","exists","access","constants","existsSync","rm","rmSync","Project"],"mappings":";;;;;AAGA,eAAe,OAAO,IAAc,EAAA;AAClC,EAAI,IAAA;AACF,IAAM,MAAA,MAAA,CAAO,IAAM,EAAA,SAAA,CAAU,IAAI,CAAA;AACjC,IAAO,OAAA,IAAA;AAAA,GACD,CAAA,MAAA;AACN,IAAO,OAAA,KAAA;AAAA;AAEX;AA0BA,eAAsB,UAAU,OAA0C,EAAA;AACxE,EAAM,MAAA,EAAE,IAAM,EAAA,KAAA,EAAU,GAAA,OAAA;AACxB,EAAM,MAAA,SAAA,GAAY,MAAM,MAAA,CAAO,IAAI,CAAA;AACnC,EAAA,IAAI,UAAU,SAAW,EAAA;AACvB,IAAA,IAAI,CAAC,SAAW,EAAA;AACd,MAAA,MAAM,KAAM,CAAA,IAAA,EAAM,EAAE,SAAA,EAAW,MAAM,CAAA;AAAA;AACvC,aACS,SAAW,EAAA;AACpB,IAAA,MAAM,EAAG,CAAA,IAAA,EAAM,EAAE,SAAA,EAAW,MAAM,CAAA;AAAA;AAEtC;AAeO,SAAS,cAAc,OAAiC,EAAA;AAC7D,EAAM,MAAA,EAAE,IA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ACvF,MAAA;AACL,IAAA,MAAM,IAAK,CAAA,MAAA,EAAQ,CAAC,QAAA,EAAU,OAAO,CAAC,CAAA;AAAA;AAE1C;;;AChCO,SAAS,gBAAgB,OAA6B,EAAA;AAC3D,EAAM,MAAA,EAAE,KAAO,EAAA,MAAA,EAAW,GAAA,OAAA;AAC1B,EAAA,IAAI,UAAU,SAAW,EAAA;AACvB,IAAS,QAAA,CAAA,MAAA,EAAQ,CAAC,KAAA,EAAO,SAAW,EAAA,CAAA,EAAG,MAAU,IAAA,IAAA,GAAO,OAAU,GAAA,MAAA,EAAQ,CAAA,CAAE,CAAC,CAAA;AAAA,GACxE,MAAA;AAEL,IAAM,MAAA,IAAI,MAAM,iBAAiB,CAAA;AAAA;AAErC;AAWA,eAAsB,YAAY,OAA4C,EAAA;AAC5E,EAAM,MAAA,EAAE,KAAO,EAAA,MAAA,EAAW,GAAA,OAAA;AAC1B,EAAA,IAAI,UAAU,SAAW,EAAA;AACvB,IAAA,MAAM,IAAK,CAAA,MAAA,EAAQ,CAAC,KAAA,EAAO,SAAW,EAAA,CAAA,EAAG,MAAU,IAAA,IAAA,GAAO,OAAU,GAAA,MAAA,EAAQ,CAAA,CAAE,CAAC,CAAA;AAAA,GAC1E,MAAA;AAEL,IAAM,MAAA,IAAI,MAAM,iBAAiB,CAAA;AAAA;AAErC","file":"index.js","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 * 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).concat(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 * @returns The object with the renamed rules.\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 }\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 * File target state\n */\n readonly state: 'present' | 'absent';\n /**\n * File content mapping function\n *\n * @param content\n */\n readonly update?: ((content: string) => string | undefined) | undefined;\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 * File path\n */\n path: string;\n /**\n * Block content to insert\n */\n block: string;\n /**\n * Insert position\n */\n insertPosition?: ['before', 'BeginningOfFile' | RegExp] | ['after', 'EndOfFile' | RegExp];\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 // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition, no-constant-condition\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","/**\n * Resolves a module or promise-like object, returning the default export if available.\n *\n * @example\n * ```ts\n * await interopDefault(import('./module'));// Can be a commonjs or esm module\n * ```\n *\n * @template T - The type of the module or promise-like object.\n * @param {T | PromiseLike<T>} m - The module or promise-like object to resolve.\n * @returns {Promise<T extends { default: infer U } ? U : T>} A promise resolving to the default export if present, otherwise the module itself.\n */\n\nexport async function interopDefault<T>(m: T | PromiseLike<T>): Promise<T extends { default: infer U } ? U : T> {\n const resolved = await m;\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return, @typescript-eslint/no-unsafe-member-access\n return (resolved as any).default ?? resolved;\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 * File target state\n */\n readonly state: 'present' | 'absent';\n /**\n * File content mapping function\n *\n * @param content\n */\n readonly update?: ((content: V | undefined) => V | undefined) | undefined;\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","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<\n Extension[]\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition\n >((previousValue, currentValue) => previousValue.concat(registry[currentValue] ?? ([] as Extension[])), [])\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 * @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 * @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 * 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 * @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 * @returns A promise that resolves with an object containing the stdout and stderr strings\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 // eslint-disable-next-line @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access\n stdout += data.toString(encoding);\n });\n }\n if (child.stderr != null) {\n child.stderr.on('data', (data) => {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access\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 * @param content\n */\n readonly update?: ((content: string) => string | undefined) | undefined;\n}\n\n/**\n * Synchronous version of {@link yarnConfig}\n *\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 * @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 * @param content\n */\n readonly update?: (() => YarnVersionKind | undefined) | undefined;\n}\n\n/**\n * Synchronous version of {@link yarnVersion}\n *\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 * @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"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@w5s/dev",
3
- "version": "2.3.0",
3
+ "version": "2.5.0",
4
4
  "description": "Shared development constants and functions",
5
5
  "keywords": [
6
6
  "config",
@@ -54,5 +54,5 @@
54
54
  "access": "public"
55
55
  },
56
56
  "sideEffect": false,
57
- "gitHead": "2e302c874daea8739aee214365edff536ae5c263"
57
+ "gitHead": "dec47d615efa7aadd8cd30f68e9911033ac365e2"
58
58
  }
@@ -1,4 +1,4 @@
1
- import type { ESLint, Linter } from 'eslint';
1
+ import type { ESLint } from 'eslint';
2
2
 
3
3
  function toArray<T>(value: T[] | T | undefined): T[] {
4
4
  if (value == null) {
@@ -51,7 +51,29 @@ export namespace ESLintConfig {
51
51
  *
52
52
  * @param _status
53
53
  */
54
- export function fixme(_status: Linter.RuleLevel | [Linter.RuleLevel, ...any[]] | undefined) {
54
+ export function fixme(_status: string | number | [string | number, ...any[]] | undefined) {
55
55
  return 'off' as const;
56
56
  }
57
+
58
+ /**
59
+ * Renames rules in the given object according to the given map.
60
+ *
61
+ * Given a map `{ 'old-prefix': 'new-prefix' }`, and a rule object
62
+ * `{ 'old-prefix/rule-name': 'error' }`, this function will return
63
+ * `{ 'new-prefix/rule-name': 'error' }`.
64
+ *
65
+ * @param rules - The object containing the rules to rename.
66
+ * @param map - The object containing the rename map.
67
+ * @returns The object with the renamed rules.
68
+ */
69
+ export function renameRules(rules: Record<string, any>, map: Record<string, string>): Record<string, any> {
70
+ return Object.fromEntries(
71
+ Object.entries(rules).map(([key, value]) => {
72
+ for (const [from, to] of Object.entries(map)) {
73
+ if (key.startsWith(`${from}/`)) return [to + key.slice(from.length), value];
74
+ }
75
+ return [key, value];
76
+ }),
77
+ );
78
+ }
57
79
  }
@@ -0,0 +1,22 @@
1
+ export interface LanguageIdMap {
2
+ css: true;
3
+ graphql: true;
4
+ javascript: true;
5
+ javascriptreact: true;
6
+ jpeg: true;
7
+ json: true;
8
+ jsonc: true;
9
+ less: true;
10
+ markdown: true;
11
+ sass: true;
12
+ scss: true;
13
+ typescript: true;
14
+ typescriptreact: true;
15
+ vue: true;
16
+ yaml: true;
17
+ }
18
+
19
+ /**
20
+ * A list of "vscode-like" language identifiers (i.e. "javascript", "javascriptreact")
21
+ */
22
+ export type LanguageId = keyof LanguageIdMap;
@@ -1,3 +1,5 @@
1
+ import type { LanguageId } from './LanguageId.js';
2
+
1
3
  function escapeRegExp(value: string) {
2
4
  // eslint-disable-next-line unicorn/prefer-string-raw
3
5
  return value.replaceAll(/[$()*+.?[\\\]^{|}]/g, '\\$&'); // $& means the whole matched string
@@ -12,20 +14,7 @@ export namespace Project {
12
14
  /**
13
15
  * Object hash of all well-known file extension category to file extensions mapping
14
16
  */
15
- export interface ExtensionRegistry {
16
- graphql: readonly Extension[];
17
- jpeg: readonly Extension[];
18
- javascript: readonly Extension[];
19
- javascriptreact: readonly Extension[];
20
- typescript: readonly Extension[];
21
- typescriptreact: readonly Extension[];
22
- yaml: readonly Extension[];
23
- }
24
-
25
- /**
26
- * A list of "vscode-like" language identifiers (i.e. "javascript", "javascriptreact")
27
- */
28
- export type LanguageId = keyof ExtensionRegistry;
17
+ export type ExtensionRegistry = { [K in LanguageId]: readonly Extension[] };
29
18
 
30
19
  /**
31
20
  * Supported ECMA version
@@ -40,12 +29,20 @@ export namespace Project {
40
29
  }
41
30
 
42
31
  const registry: ExtensionRegistry = {
32
+ css: ['.css'],
43
33
  graphql: ['.gql', '.graphql'],
44
- jpeg: ['.jpg', '.jpeg'],
45
34
  javascript: ['.js', '.cjs', '.mjs'],
46
35
  javascriptreact: ['.jsx'],
36
+ jpeg: ['.jpg', '.jpeg'],
37
+ json: ['.json'],
38
+ jsonc: ['.jsonc'],
39
+ less: ['.less'],
40
+ markdown: ['.markdown', '.mdown', '.mkd', '.md'],
41
+ sass: ['.sass'],
42
+ scss: ['.scss'],
47
43
  typescript: ['.ts', '.cts', '.mts'],
48
44
  typescriptreact: ['.tsx'],
45
+ vue: ['.vue'],
49
46
  yaml: ['.yaml', '.yml'],
50
47
  };
51
48
 
@@ -62,11 +59,10 @@ export namespace Project {
62
59
  */
63
60
  export function queryExtensions(languages: LanguageId[]): readonly Extension[] {
64
61
  return languages
65
- .reduce<Extension[]>(
62
+ .reduce<
63
+ Extension[]
66
64
  // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
67
- (previousValue, currentValue) => previousValue.concat(registry[currentValue] ?? ([] as Extension[])),
68
- [],
69
- )
65
+ >((previousValue, currentValue) => previousValue.concat(registry[currentValue] ?? ([] as Extension[])), [])
70
66
  .sort();
71
67
  }
72
68
 
@@ -83,14 +79,10 @@ export namespace Project {
83
79
  }
84
80
 
85
81
  const RESOURCE_EXTENSIONS: readonly Extension[] = Object.freeze([
86
- '.css',
87
- '.sass',
88
- '.scss',
89
- '.less',
90
82
  '.gif',
91
83
  '.png',
92
84
  '.svg',
93
- ...queryExtensions(['graphql', 'jpeg', 'yaml']),
85
+ ...queryExtensions(['css', 'graphql', 'jpeg', 'less', 'sass', 'sass', 'yaml']),
94
86
  ]);
95
87
 
96
88
  /**