@w5s/dev 2.4.0 → 2.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +95 -14
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +113 -16
- package/dist/index.d.ts +113 -16
- package/dist/index.js +92 -15
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/src/{eslint.ts → ESLintConfig.ts} +24 -2
- package/src/LanguageId.ts +22 -0
- package/src/{project.ts → Project.ts} +16 -24
- package/src/exec.ts +73 -0
- package/src/index.ts +6 -3
- package/src/yarnConfig.ts +60 -0
- package/src/yarnVersion.ts +55 -0
- /package/src/{projectScript.ts → ProjectScript.ts} +0 -0
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/
|
|
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 {
|
|
@@ -233,7 +245,7 @@ function jsonSync(options) {
|
|
|
233
245
|
return fileSync(toFileOption(options));
|
|
234
246
|
}
|
|
235
247
|
|
|
236
|
-
// src/
|
|
248
|
+
// src/Project.ts
|
|
237
249
|
function escapeRegExp(value) {
|
|
238
250
|
return value.replaceAll(/[$()*+.?[\\\]^{|}]/g, "\\$&");
|
|
239
251
|
}
|
|
@@ -244,20 +256,24 @@ var Project;
|
|
|
244
256
|
}
|
|
245
257
|
Project2.ecmaVersion = ecmaVersion;
|
|
246
258
|
const registry = {
|
|
259
|
+
css: [".css"],
|
|
247
260
|
graphql: [".gql", ".graphql"],
|
|
248
|
-
jpeg: [".jpg", ".jpeg"],
|
|
249
261
|
javascript: [".js", ".cjs", ".mjs"],
|
|
250
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"],
|
|
251
270
|
typescript: [".ts", ".cts", ".mts"],
|
|
252
271
|
typescriptreact: [".tsx"],
|
|
272
|
+
vue: [".vue"],
|
|
253
273
|
yaml: [".yaml", ".yml"]
|
|
254
274
|
};
|
|
255
275
|
function queryExtensions(languages) {
|
|
256
|
-
return languages.reduce(
|
|
257
|
-
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
258
|
-
(previousValue, currentValue) => previousValue.concat(registry[currentValue] ?? []),
|
|
259
|
-
[]
|
|
260
|
-
).sort();
|
|
276
|
+
return languages.reduce((previousValue, currentValue) => previousValue.concat(registry[currentValue] ?? []), []).sort();
|
|
261
277
|
}
|
|
262
278
|
Project2.queryExtensions = queryExtensions;
|
|
263
279
|
function sourceExtensions() {
|
|
@@ -265,14 +281,10 @@ var Project;
|
|
|
265
281
|
}
|
|
266
282
|
Project2.sourceExtensions = sourceExtensions;
|
|
267
283
|
const RESOURCE_EXTENSIONS = Object.freeze([
|
|
268
|
-
".css",
|
|
269
|
-
".sass",
|
|
270
|
-
".scss",
|
|
271
|
-
".less",
|
|
272
284
|
".gif",
|
|
273
285
|
".png",
|
|
274
286
|
".svg",
|
|
275
|
-
...queryExtensions(["graphql", "jpeg", "yaml"])
|
|
287
|
+
...queryExtensions(["css", "graphql", "jpeg", "less", "sass", "sass", "yaml"])
|
|
276
288
|
]);
|
|
277
289
|
function resourceExtensions() {
|
|
278
290
|
return RESOURCE_EXTENSIONS;
|
|
@@ -304,7 +316,7 @@ var Project;
|
|
|
304
316
|
Project2.extensionsToGlob = extensionsToGlob;
|
|
305
317
|
})(Project || (Project = {}));
|
|
306
318
|
|
|
307
|
-
// src/
|
|
319
|
+
// src/ProjectScript.ts
|
|
308
320
|
var ProjectScript = {
|
|
309
321
|
Build: "build",
|
|
310
322
|
Clean: "clean",
|
|
@@ -322,7 +334,72 @@ var ProjectScript = {
|
|
|
322
334
|
Test: "test",
|
|
323
335
|
Validate: "validate"
|
|
324
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
|
+
}
|
|
325
402
|
|
|
326
|
-
export { ESLintConfig, Project, ProjectScript, block, blockSync, directory, directorySync, file, fileSync, interopDefault, json, jsonSync };
|
|
403
|
+
export { ESLintConfig, Project, ProjectScript, block, blockSync, directory, directorySync, file, fileSync, interopDefault, json, jsonSync, yarnConfig, yarnConfigSync, yarnVersion, yarnVersionSync };
|
|
327
404
|
//# sourceMappingURL=index.js.map
|
|
328
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/interopDefault.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,KAA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OAAA,GAAA,EAAA,CAAA,CAAA;;;ACFV,IAAM,aAAgB,GAAA;AAAA,EAC3B,KAAO,EAAA,OAAA;AAAA,EACP,KAAO,EAAA,OAAA;AAAA,EACP,YAAc,EAAA,eAAA;AAAA,EACd,QAAU,EAAA,UAAA;AAAA,EACV,OAAS,EAAA,SAAA;AAAA,EACT,IAAM,EAAA,MAAA;AAAA,EACN,MAAQ,EAAA,QAAA;AAAA,EACR,OAAS,EAAA,SAAA;AAAA,EACT,IAAM,EAAA,MAAA;AAAA,EACN,OAAS,EAAA,SAAA;AAAA,EACT,OAAS,EAAA,SAAA;AAAA,EACT,MAAQ,EAAA,QAAA;AAAA,EACR,UAAY,EAAA,YAAA;AAAA,EACZ,IAAM,EAAA,MAAA;AAAA,EACN,QAAU,EAAA;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","/**\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","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,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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AAA,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
|
+
"version": "2.5.1",
|
|
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": "
|
|
57
|
+
"gitHead": "4617d8f7fa8546c928dcb225e5a2735302ce1c85"
|
|
58
58
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { 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:
|
|
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
|
|
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<
|
|
62
|
+
.reduce<
|
|
63
|
+
Extension[]
|
|
66
64
|
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
67
|
-
|
|
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
|
/**
|
package/src/exec.ts
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { spawn, spawnSync } from 'node:child_process';
|
|
2
|
+
|
|
3
|
+
export interface ExecOptions {
|
|
4
|
+
/**
|
|
5
|
+
* Current working directory
|
|
6
|
+
*/
|
|
7
|
+
cwd?: string;
|
|
8
|
+
/**
|
|
9
|
+
* Stdio options
|
|
10
|
+
*/
|
|
11
|
+
stdio?: 'inherit' | 'pipe' | 'ignore';
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Runs a command in a shell and returns a promise that resolves with an object
|
|
16
|
+
* containing the stdout and stderr strings.
|
|
17
|
+
*
|
|
18
|
+
* @param command - The command to run
|
|
19
|
+
* @param args - The arguments to pass to the command
|
|
20
|
+
* @returns A promise that resolves with an object like `{ stdout: string, stderr: string }`
|
|
21
|
+
*/
|
|
22
|
+
export function execSync(
|
|
23
|
+
command: string,
|
|
24
|
+
args: ReadonlyArray<string>,
|
|
25
|
+
options?: ExecOptions,
|
|
26
|
+
): { stdout: string; stderr: string } {
|
|
27
|
+
const result = spawnSync(command, args, { ...options });
|
|
28
|
+
const encoding = 'utf8';
|
|
29
|
+
|
|
30
|
+
return { stdout: result.stdout.toString(encoding), stderr: result.stderr.toString(encoding) };
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Runs a command in a shell and returns a promise that resolves with an object
|
|
35
|
+
* containing the stdout and stderr strings.
|
|
36
|
+
*
|
|
37
|
+
* @param command - The command to run
|
|
38
|
+
* @param args - The arguments to pass to the command
|
|
39
|
+
* @returns A promise that resolves with an object containing the stdout and stderr strings
|
|
40
|
+
*/
|
|
41
|
+
export async function exec(
|
|
42
|
+
command: string,
|
|
43
|
+
args: ReadonlyArray<string>,
|
|
44
|
+
options?: ExecOptions,
|
|
45
|
+
): Promise<{ stdout: string; stderr: string }> {
|
|
46
|
+
return new Promise((resolve, reject) => {
|
|
47
|
+
const encoding = 'utf8';
|
|
48
|
+
const child = spawn(command, args, { ...options });
|
|
49
|
+
let stdout = '';
|
|
50
|
+
let stderr = '';
|
|
51
|
+
|
|
52
|
+
// Capture the stdout and stderr streams
|
|
53
|
+
if (child.stdout != null) {
|
|
54
|
+
child.stdout.on('data', (data) => {
|
|
55
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access
|
|
56
|
+
stdout += data.toString(encoding);
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
if (child.stderr != null) {
|
|
60
|
+
child.stderr.on('data', (data) => {
|
|
61
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access
|
|
62
|
+
stderr += data.toString(encoding);
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
// Handle process exit
|
|
66
|
+
child.on('close', (_code) => {
|
|
67
|
+
resolve({ stdout, stderr });
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
// Handle errors
|
|
71
|
+
child.on('error', reject);
|
|
72
|
+
});
|
|
73
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
export * from './directory.js';
|
|
2
|
-
export * from './
|
|
2
|
+
export * from './ESLintConfig.js';
|
|
3
3
|
export * from './block.js';
|
|
4
4
|
export * from './file.js';
|
|
5
5
|
export * from './interopDefault.js';
|
|
6
|
+
export * from './LanguageId.js';
|
|
6
7
|
export * from './json.js';
|
|
7
|
-
export * from './
|
|
8
|
-
export * from './
|
|
8
|
+
export * from './Project.js';
|
|
9
|
+
export * from './ProjectScript.js';
|
|
10
|
+
export * from './yarnConfig.js';
|
|
11
|
+
export * from './yarnVersion.js';
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { exec, execSync } from './exec.js';
|
|
2
|
+
|
|
3
|
+
export interface YarnConfigOptions {
|
|
4
|
+
/**
|
|
5
|
+
* Configuration key
|
|
6
|
+
*/
|
|
7
|
+
readonly key: string;
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Option target state
|
|
11
|
+
*/
|
|
12
|
+
readonly state: 'present' | 'absent';
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* File content mapping function
|
|
16
|
+
*
|
|
17
|
+
* @param content
|
|
18
|
+
*/
|
|
19
|
+
readonly update?: ((content: string) => string | undefined) | undefined;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Synchronous version of {@link yarnConfig}
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* yarnConfigSync({
|
|
27
|
+
* key: 'nodeLinker',
|
|
28
|
+
* state: 'present',
|
|
29
|
+
* update: (content) => content.replace('node-modules', 'hoisted'),
|
|
30
|
+
* })
|
|
31
|
+
*/
|
|
32
|
+
export function yarnConfigSync(options: YarnConfigOptions) {
|
|
33
|
+
const { key, state, update } = options;
|
|
34
|
+
if (state === 'present') {
|
|
35
|
+
const { stdout } = execSync('yarn', ['config', 'get', String(key)]);
|
|
36
|
+
execSync('yarn', ['config', 'set', String(key), `${update == null ? '' : update(stdout)}`]);
|
|
37
|
+
} else {
|
|
38
|
+
execSync('yarn', ['config', 'unset']);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Set/Unset yarn configuration value
|
|
44
|
+
*
|
|
45
|
+
* @example
|
|
46
|
+
* await yarnConfig({
|
|
47
|
+
* key: 'nodeLinker',
|
|
48
|
+
* state: 'present',
|
|
49
|
+
* update: (content) => content.replace('node-modules', 'hoisted'),
|
|
50
|
+
* })
|
|
51
|
+
*/
|
|
52
|
+
export async function yarnConfig(options: YarnConfigOptions): Promise<void> {
|
|
53
|
+
const { key, state, update } = options;
|
|
54
|
+
if (state === 'present') {
|
|
55
|
+
const { stdout } = await exec('yarn', ['config', 'get', String(key)]);
|
|
56
|
+
await exec('yarn', ['config', 'set', String(key), `${update == null ? '' : update(stdout)}`]);
|
|
57
|
+
} else {
|
|
58
|
+
await exec('yarn', ['config', 'unset']);
|
|
59
|
+
}
|
|
60
|
+
}
|