@w5s/configurator-core 1.21.0 → 1.23.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,10 +1,10 @@
1
1
  import { accessSync, chmodSync, constants, mkdirSync, readFileSync, rmSync, writeFileSync } from "node:fs";
2
2
  import { access, chmod, mkdir, readFile, rm, writeFile } from "node:fs/promises";
3
- import path from "node:path";
3
+ import nodePath from "node:path";
4
4
  import YAML from "yaml";
5
5
  import { spawn, spawnSync } from "node:child_process";
6
- //#region src/__exists.ts
7
- async function __exists(path) {
6
+ // src/internal/fileExists.ts
7
+ async function fileExists(path) {
8
8
  try {
9
9
  await access(path, constants.F_OK);
10
10
  return true;
@@ -12,9 +12,8 @@ async function __exists(path) {
12
12
  return false;
13
13
  }
14
14
  }
15
- //#endregion
16
- //#region src/__existsSync.ts
17
- function __existsSync(path) {
15
+ // src/internal/fileExistsSync.ts
16
+ function fileExistsSync(path) {
18
17
  try {
19
18
  accessSync(path, constants.F_OK);
20
19
  return true;
@@ -22,16 +21,14 @@ function __existsSync(path) {
22
21
  return false;
23
22
  }
24
23
  }
25
- //#endregion
26
- //#region src/__toMode.ts
27
- function __toMode(mode) {
24
+ // src/internal/toMode.ts
25
+ function toMode(mode) {
28
26
  return mode == null ? mode : toModeFlag(mode.owner, 256, 128, 64) | toModeFlag(mode.group, 32, 16, 8) | toModeFlag(mode.other, 4, 2, 1);
29
27
  }
30
28
  function toModeFlag(permissionSet, read, write, execute) {
31
29
  return (permissionSet?.read === true ? read : 0) | (permissionSet?.write === true ? write : 0) | (permissionSet?.execute === true ? execute : 0);
32
30
  }
33
- //#endregion
34
- //#region src/file.ts
31
+ // src/file.ts
35
32
  /**
36
33
  * Ensure file is present/absent with content initialized or modified with `update
37
34
  *
@@ -54,10 +51,10 @@ function toModeFlag(permissionSet, read, write, execute) {
54
51
  async function file(options) {
55
52
  const { encoding = "utf8", mode, path, state, update } = options;
56
53
  if (state === "present") {
57
- const isPresent = await __exists(path);
54
+ const isPresent = await fileExists(path);
58
55
  const previousContent = isPresent ? await readFile(path, encoding) : "";
59
56
  const newContent = update == null ? isPresent ? void 0 : "" : update(previousContent);
60
- const newMode = __toMode(mode);
57
+ const newMode = toMode(mode);
61
58
  if (newContent != null) await writeFile(path, newContent, {
62
59
  encoding,
63
60
  mode: newMode
@@ -87,10 +84,10 @@ async function file(options) {
87
84
  function fileSync(options) {
88
85
  const { encoding = "utf8", mode, path, state, update } = options;
89
86
  if (state === "present") {
90
- const isPresent = __existsSync(path);
87
+ const isPresent = fileExistsSync(path);
91
88
  const previousContent = isPresent ? readFileSync(path, encoding) : "";
92
89
  const newContent = update == null ? isPresent ? void 0 : "" : update(previousContent);
93
- const newMode = __toMode(mode);
90
+ const newMode = toMode(mode);
94
91
  if (newContent != null) writeFileSync(path, newContent, {
95
92
  encoding,
96
93
  mode: newMode
@@ -98,10 +95,65 @@ function fileSync(options) {
98
95
  if (newMode != null && (isPresent || newContent != null)) chmodSync(path, newMode);
99
96
  } else rmSync(path, { force: true });
100
97
  }
101
- //#endregion
102
- //#region src/block.ts
98
+ // src/internal/resolveCommentStyle.ts
99
+ const HASH_BASENAMES = /* @__PURE__ */ new Set([
100
+ "containerfile",
101
+ "dockerfile",
102
+ "gemfile",
103
+ "makefile"
104
+ ]);
105
+ const HTML_EXTENSIONS = /* @__PURE__ */ new Set([
106
+ "htm",
107
+ "html",
108
+ "md",
109
+ "mdx",
110
+ "svg",
111
+ "xml"
112
+ ]);
113
+ const LINE_EXTENSIONS = /* @__PURE__ */ new Set([
114
+ "c",
115
+ "cjs",
116
+ "cpp",
117
+ "cs",
118
+ "cts",
119
+ "go",
120
+ "h",
121
+ "java",
122
+ "js",
123
+ "jsx",
124
+ "kt",
125
+ "mjs",
126
+ "mts",
127
+ "rs",
128
+ "swift",
129
+ "ts",
130
+ "tsx"
131
+ ]);
132
+ const BLOCK_EXTENSIONS = /* @__PURE__ */ new Set([
133
+ "css",
134
+ "less",
135
+ "sass",
136
+ "scss"
137
+ ]);
138
+ /**
139
+ * Resolve comment style from the file path when `commentStyle` is `'auto'`.
140
+ *
141
+ * @param path File path used to infer the comment style.
142
+ */
143
+ function resolveCommentStyle(path) {
144
+ const basename = nodePath.basename(path);
145
+ const basenameLower = basename.toLowerCase();
146
+ if (basename.startsWith(".") || HASH_BASENAMES.has(basenameLower)) return "#";
147
+ const extension = nodePath.extname(basename).slice(1).toLowerCase();
148
+ if (HTML_EXTENSIONS.has(extension)) return "<!--";
149
+ if (LINE_EXTENSIONS.has(extension)) return "//";
150
+ if (BLOCK_EXTENSIONS.has(extension)) return "/*";
151
+ return "#";
152
+ }
153
+ // src/block.ts
103
154
  const EOF = "EndOfFile";
104
155
  const BOF = "BeginningOfFile";
156
+ const DEFAULT_TOPIC = "managed-block";
105
157
  const insertAt = (str, index, toInsert) => str.slice(0, index) + toInsert + str.slice(index);
106
158
  const matchLast = (string, regexp) => {
107
159
  const matcher = new RegExp(regexp.source, `${regexp.flags}g`);
@@ -143,11 +195,22 @@ function block(options) {
143
195
  function blockSync(options) {
144
196
  return fileSync(toFileOptions(options));
145
197
  }
198
+ function formatMarker(style, mark, topic) {
199
+ const inner = `${mark.toUpperCase()}:${topic}`;
200
+ switch (style) {
201
+ case "#": return `# ${inner}`;
202
+ case "/*": return `/* ${inner} */`;
203
+ case "//": return `// ${inner}`;
204
+ case "<!--": return `<!-- ${inner} -->`;
205
+ default: throw new Error(`Unsupported comment style ${String(style)}`);
206
+ }
207
+ }
146
208
  function toFileOptions(options) {
147
- const { block: blockName, insertPosition = ["after", EOF], marker = (mark) => `# ${mark.toUpperCase()} MANAGED BLOCK`, path, state = "present" } = options;
209
+ const { block: blockName, insertPosition = ["after", EOF], marker, path, state = "present" } = options;
148
210
  const EOL = "\n";
149
- const beginBlock = marker("Begin");
150
- const endBlock = marker("End");
211
+ const markerFn = toMarkerFn(marker, path);
212
+ const beginBlock = markerFn("Begin");
213
+ const endBlock = markerFn("End");
151
214
  /**
152
215
  * @param content
153
216
  */
@@ -189,8 +252,14 @@ function toFileOptions(options) {
189
252
  update: (sourceContent) => apply(sourceContent, blockName)
190
253
  };
191
254
  }
192
- //#endregion
193
- //#region src/directory.ts
255
+ function toMarkerFn(marker, path) {
256
+ if (typeof marker === "function") return marker;
257
+ const commentStyle = marker?.commentStyle ?? "auto";
258
+ const topic = marker?.topic ?? DEFAULT_TOPIC;
259
+ const resolvedStyle = commentStyle === "auto" ? resolveCommentStyle(path) : commentStyle;
260
+ return (mark) => formatMarker(resolvedStyle, mark, topic);
261
+ }
262
+ // src/directory.ts
194
263
  /**
195
264
  * Ensure directory is present/absent
196
265
  *
@@ -211,9 +280,9 @@ function toFileOptions(options) {
211
280
  */
212
281
  async function directory(options) {
213
282
  const { mode, path, state } = options;
214
- const isPresent = await __exists(path);
283
+ const isPresent = await fileExists(path);
215
284
  if (state === "present") {
216
- const newMode = __toMode(mode);
285
+ const newMode = toMode(mode);
217
286
  if (!isPresent) await mkdir(path, {
218
287
  mode: newMode,
219
288
  recursive: true
@@ -241,9 +310,9 @@ async function directory(options) {
241
310
  */
242
311
  function directorySync(options) {
243
312
  const { mode, path, state } = options;
244
- const isPresent = __existsSync(path);
313
+ const isPresent = fileExistsSync(path);
245
314
  if (state === "present") {
246
- const newMode = __toMode(mode);
315
+ const newMode = toMode(mode);
247
316
  if (!isPresent) mkdirSync(path, {
248
317
  mode: newMode,
249
318
  recursive: true
@@ -251,8 +320,7 @@ function directorySync(options) {
251
320
  if (newMode != null && isPresent) chmodSync(path, newMode);
252
321
  } else if (isPresent) rmSync(path, { recursive: true });
253
322
  }
254
- //#endregion
255
- //#region src/ignoreFile.ts
323
+ // src/ignoreFile.ts
256
324
  /**
257
325
  * Ensure file is present/absent asynchronously with content initialized or modified by line.
258
326
  *
@@ -266,7 +334,7 @@ function directorySync(options) {
266
334
  * @param options File target options.
267
335
  */
268
336
  async function ignoreFile(options) {
269
- return file(toFileOption$2(options));
337
+ return file(toFileOption$3(options));
270
338
  }
271
339
  /**
272
340
  * Ensure file is present/absent synchronously with content initialized or modified by line.
@@ -281,9 +349,9 @@ async function ignoreFile(options) {
281
349
  * @param options File target options.
282
350
  */
283
351
  function ignoreFileSync(options) {
284
- return fileSync(toFileOption$2(options));
352
+ return fileSync(toFileOption$3(options));
285
353
  }
286
- function toFileOption$2({ update, ...otherOptions }) {
354
+ function toFileOption$3({ update, ...otherOptions }) {
287
355
  return {
288
356
  ...otherOptions,
289
357
  update: update == null ? update : (content) => {
@@ -293,8 +361,7 @@ function toFileOption$2({ update, ...otherOptions }) {
293
361
  }
294
362
  };
295
363
  }
296
- //#endregion
297
- //#region src/isConfigPresent.ts
364
+ // src/isConfigPresent.ts
298
365
  const defaultExtensions = [
299
366
  ".json",
300
367
  ".yaml",
@@ -321,8 +388,8 @@ async function isConfigPresent(options) {
321
388
  }
322
389
  function isConfigPresentSync(options) {
323
390
  const { candidatePaths, packageConfig, packageJsonPath } = toCandidates(options);
324
- for (const candidatePath of candidatePaths) if (__existsSync(candidatePath)) return true;
325
- if (__existsSync(packageJsonPath)) try {
391
+ for (const candidatePath of candidatePaths) if (fileExistsSync(candidatePath)) return true;
392
+ if (fileExistsSync(packageJsonPath)) try {
326
393
  return hasPackageConfigKey(readFileSync(packageJsonPath, "utf8"), packageConfig);
327
394
  } catch {
328
395
  return false;
@@ -330,10 +397,10 @@ function isConfigPresentSync(options) {
330
397
  return false;
331
398
  }
332
399
  async function hasAnyFile(paths) {
333
- return (await Promise.all(paths.map((candidatePath) => __exists(candidatePath)))).some(Boolean);
400
+ return (await Promise.all(paths.map((candidatePath) => fileExists(candidatePath)))).some(Boolean);
334
401
  }
335
402
  async function hasPackageConfigFile(packageJsonPath, packageConfig) {
336
- if (!await __exists(packageJsonPath)) return false;
403
+ if (!await fileExists(packageJsonPath)) return false;
337
404
  try {
338
405
  return hasPackageConfigKey(await readFile(packageJsonPath, "utf8"), packageConfig);
339
406
  } catch {
@@ -345,23 +412,22 @@ function hasPackageConfigKey(packageJsonContent, packageConfig) {
345
412
  return value !== void 0 && value !== null && value !== false;
346
413
  }
347
414
  function toCandidates({ app, cwd = process.cwd(), extensions = defaultExtensions, packageConfig = app }) {
348
- const candidatePaths = [path.join(cwd, `.${app}rc`)];
349
- for (const extension of extensions) candidatePaths.push(path.join(cwd, `.${app}rc${extension}`), path.join(cwd, `${app}.config${extension}`));
415
+ const candidatePaths = [nodePath.join(cwd, `.${app}rc`)];
416
+ for (const extension of extensions) candidatePaths.push(nodePath.join(cwd, `.${app}rc${extension}`), nodePath.join(cwd, `${app}.config${extension}`));
350
417
  return {
351
418
  candidatePaths,
352
419
  packageConfig,
353
- packageJsonPath: path.join(cwd, "package.json")
420
+ packageJsonPath: nodePath.join(cwd, "package.json")
354
421
  };
355
422
  }
356
- //#endregion
357
- //#region src/json.ts
423
+ // src/json.ts
358
424
  /**
359
425
  * Ensure file is present/absent asynchronously with content value initialized or modified with `update`
360
426
  *
361
427
  * @param options
362
428
  */
363
429
  async function json(options) {
364
- return file(toFileOption$1(options));
430
+ return file(toFileOption$2(options));
365
431
  }
366
432
  /**
367
433
  * Ensure file is present/absent synchronously with content value initialized or modified with `update`
@@ -369,9 +435,9 @@ async function json(options) {
369
435
  * @param options
370
436
  */
371
437
  function jsonSync(options) {
372
- return fileSync(toFileOption$1(options));
438
+ return fileSync(toFileOption$2(options));
373
439
  }
374
- function toFileOption$1({ update, ...otherOptions }) {
440
+ function toFileOption$2({ update, ...otherOptions }) {
375
441
  return {
376
442
  ...otherOptions,
377
443
  update: update == null ? update : (content) => {
@@ -380,15 +446,40 @@ function toFileOption$1({ update, ...otherOptions }) {
380
446
  }
381
447
  };
382
448
  }
383
- //#endregion
384
- //#region src/meta.ts
449
+ // src/meta.ts
385
450
  const meta = Object.freeze({
386
- buildNumber: 1790932147,
451
+ buildNumber: 0x6b04cca5,
387
452
  name: "@w5s/configurator-core",
388
- version: "1.21.0"
453
+ version: "1.23.0"
389
454
  });
390
- //#endregion
391
- //#region src/yaml.ts
455
+ // src/toolVersions.ts
456
+ const reToolVersion = /\s+/;
457
+ function toolVersions(options) {
458
+ return file(toFileOption$1(options));
459
+ }
460
+ function toolVersionsSync(options) {
461
+ return fileSync(toFileOption$1(options));
462
+ }
463
+ function toFileOption$1({ update, ...otherOptions }) {
464
+ return {
465
+ ...otherOptions,
466
+ path: otherOptions.path ?? ".tool-versions",
467
+ update: update == null ? update : (content) => {
468
+ const eol = "\n";
469
+ const lines = content.split(eol);
470
+ const parsed = Object.fromEntries(function* () {
471
+ for (const line of lines) {
472
+ const [tool, value] = line.split(reToolVersion, 2);
473
+ if (tool) yield [tool, value ?? ""];
474
+ }
475
+ }());
476
+ const updated = update ? update(parsed) : parsed;
477
+ if (updated === void 0) return updated;
478
+ return Object.entries(updated).map(([tool, value]) => `${tool} ${value}`).join(eol);
479
+ }
480
+ };
481
+ }
482
+ // src/yaml.ts
392
483
  /**
393
484
  * Ensure file is present/absent asynchronously with content value initialized or modified with `update`
394
485
  *
@@ -414,8 +505,7 @@ function toFileOption({ update, ...otherOptions }) {
414
505
  }
415
506
  };
416
507
  }
417
- //#endregion
418
- //#region src/exec.ts
508
+ // src/exec.ts
419
509
  /**
420
510
  * Runs a command in a shell and returns a promise that resolves with an object
421
511
  * containing the stdout and stderr strings.
@@ -462,8 +552,7 @@ function execSync(command, args, options) {
462
552
  stdout: result.stdout.toString(encoding)
463
553
  };
464
554
  }
465
- //#endregion
466
- //#region src/yarnConfig.ts
555
+ // src/yarnConfig.ts
467
556
  /**
468
557
  * Set/Unset yarn configuration value
469
558
  *
@@ -526,8 +615,7 @@ function yarnConfigSync(options) {
526
615
  key
527
616
  ]);
528
617
  }
529
- //#endregion
530
- //#region src/yarnVersion.ts
618
+ // src/yarnVersion.ts
531
619
  /**
532
620
  * Set/Unset yarn configuration value
533
621
  *
@@ -566,7 +654,6 @@ function yarnVersionSync(options) {
566
654
  ]);
567
655
  else throw new Error("Not implemented");
568
656
  }
569
- //#endregion
570
- export { block, blockSync, directory, directorySync, file, fileSync, ignoreFile, ignoreFileSync, isConfigPresent, isConfigPresentSync, json, jsonSync, meta, yaml, yamlSync, yarnConfig, yarnConfigSync, yarnVersion, yarnVersionSync };
657
+ export { block, blockSync, directory, directorySync, file, fileSync, ignoreFile, ignoreFileSync, isConfigPresent, isConfigPresentSync, json, jsonSync, meta, toolVersions, toolVersionsSync, yaml, yamlSync, yarnConfig, yarnConfigSync, yarnVersion, yarnVersionSync };
571
658
 
572
659
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["toFileOption","toFileOption"],"sources":["../src/__exists.ts","../src/__existsSync.ts","../src/__toMode.ts","../src/file.ts","../src/block.ts","../src/directory.ts","../src/ignoreFile.ts","../src/isConfigPresent.ts","../src/json.ts","../src/meta.ts","../src/yaml.ts","../src/exec.ts","../src/yarnConfig.ts","../src/yarnVersion.ts"],"sourcesContent":["import { constants } from 'node:fs';\nimport { access } from 'node:fs/promises';\n\nexport async function __exists(path: string) {\n try {\n await access(path, constants.F_OK);\n return true;\n } catch {\n return false;\n }\n}\n","import { accessSync, constants } from 'node:fs';\n\nexport function __existsSync(path: string) {\n try {\n accessSync(path, constants.F_OK);\n return true;\n } catch {\n return false;\n }\n}\n","import type { FileMode, FilePermissionSet } from './FileMode.js';\n\nexport function __toMode(mode: FileMode | undefined): number | undefined {\n return mode == null\n ? mode\n : (\n toModeFlag(mode.owner, 0o400, 0o200, 0o100)\n | toModeFlag(mode.group, 0o040, 0o020, 0o010)\n | toModeFlag(mode.other, 0o004, 0o002, 0o001)\n );\n}\n\nfunction toModeFlag(permissionSet: FilePermissionSet | undefined, read: number, write: number, execute: number): number {\n return (\n (permissionSet?.read === true ? read : 0)\n | (permissionSet?.write === true ? write : 0)\n | (permissionSet?.execute === true ? execute : 0)\n );\n}\n","import { chmodSync, readFileSync, rmSync, writeFileSync } from 'node:fs';\nimport { chmod, readFile, rm, writeFile } from 'node:fs/promises';\n\nimport type { FileMode } from './FileMode.js';\n\nimport { __exists } from './__exists.js';\nimport { __existsSync } from './__existsSync.js';\nimport { __toMode } from './__toMode.js';\n\nexport interface FileOptions {\n /**\n * File encoding\n */\n readonly encoding?: BufferEncoding;\n\n /**\n * File permissions\n */\n readonly mode?: FileMode;\n\n /**\n * File path\n */\n readonly path: string;\n\n /**\n * File target state\n */\n readonly state: 'absent' | 'present';\n\n /**\n * File content mapping function\n *\n */\n readonly update?: ((content: string) => string | undefined) | undefined;\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 * mode: {\n * owner: { read: true, write: true, execute: true },\n * group: { read: true, write: true, execute: true },\n * other: { read: true, write: true, execute: true },\n * },\n * })\n * ```\n *\n * @param options\n */\nexport async function file(options: FileOptions): Promise<void> {\n const { encoding = 'utf8', mode, path, state, update } = options;\n if (state === 'present') {\n const isPresent = await __exists(path);\n const previousContent = isPresent ? await readFile(path, encoding) : '';\n const newContent = update == null ? (isPresent ? undefined : '') : update(previousContent);\n const newMode = __toMode(mode);\n if (newContent != null) {\n await writeFile(path, newContent, { encoding, mode: newMode });\n }\n if (newMode != null && (isPresent || newContent != null)) {\n await chmod(path, newMode);\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 * mode: {\n * owner: { read: true, write: true, execute: true },\n * group: { read: true, write: true, execute: true },\n * other: { read: true, write: true, execute: true },\n * },\n * })\n * ```\n *\n * @param options\n */\nexport function fileSync(options: FileOptions): void {\n const { encoding = 'utf8', mode, path, state, update } = options;\n if (state === 'present') {\n const isPresent = __existsSync(path);\n const previousContent = isPresent ? readFileSync(path, encoding) : '';\n const newContent = update == null ? (isPresent ? undefined : '') : update(previousContent);\n const newMode = __toMode(mode);\n if (newContent != null) {\n writeFileSync(path, newContent, { encoding, mode: newMode });\n }\n if (newMode != null && (isPresent || newContent != null)) {\n chmodSync(path, newMode);\n }\n } else {\n rmSync(path, { force: true });\n }\n}\n","import { file, type FileOptions, fileSync } from './file.js';\n\nexport interface BlockOptions {\n /**\n * Block content to insert\n */\n block: string;\n\n /**\n * Insert position\n */\n insertPosition?: ['after', 'EndOfFile' | RegExp] | ['before', 'BeginningOfFile' | RegExp];\n\n /**\n * The marker builder function that will take either `markerBegin` or `markerEnd`\n *\n * @default '# ${mark} MANAGED BLOCK'\n */\n marker?: (mark: 'Begin' | 'End') => string;\n\n /**\n * File path\n */\n path: string;\n\n /**\n * Block target state\n */\n state?: 'absent' | 'present';\n}\n\nconst EOF = 'EndOfFile';\nconst BOF = 'BeginningOfFile';\nconst insertAt = (str: string, index: number, toInsert: string) => str.slice(0, index) + toInsert + str.slice(index);\nconst matchLast = (string: string, regexp: RegExp) => {\n const matcher = new RegExp(regexp.source, `${regexp.flags}g`);\n let firstIndex = -1;\n let lastIndex = -1;\n let matches;\n\n while (true) {\n matches = matcher.exec(string);\n if (matches == null) {\n break;\n }\n firstIndex = matches.index;\n lastIndex = matcher.lastIndex;\n }\n return { firstIndex, lastIndex };\n};\n\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\nfunction toFileOptions(options: BlockOptions): FileOptions {\n const {\n block: blockName,\n insertPosition = ['after', EOF],\n marker = (mark) => `# ${mark.toUpperCase()} MANAGED BLOCK`,\n path,\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 '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 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\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","import { chmodSync, mkdirSync, rmSync } from 'node:fs';\nimport { chmod, mkdir, rm } from 'node:fs/promises';\n\nimport type { FileMode } from './FileMode.js';\n\nimport { __exists } from './__exists.js';\nimport { __existsSync } from './__existsSync.js';\nimport { __toMode } from './__toMode.js';\n\nexport interface DirectoryOptions {\n /**\n * File permissions\n */\n readonly mode?: FileMode;\n\n /**\n * Directory path\n */\n readonly path: string;\n\n /**\n * Directory target state\n */\n readonly state: 'absent' | 'present';\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 * mode: {\n * owner: { read: true, write: true, execute: true },\n * group: { read: true, write: true, execute: true },\n * other: { read: true, write: true, execute: true },\n * },\n * })\n * ```\n *\n * @param options\n */\nexport async function directory(options: DirectoryOptions): Promise<void> {\n const { mode, path, state } = options;\n const isPresent = await __exists(path);\n if (state === 'present') {\n const newMode = __toMode(mode);\n if (!isPresent) {\n await mkdir(path, { mode: newMode, recursive: true });\n }\n if (newMode != null && isPresent) {\n await chmod(path, newMode);\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 * directorySync({\n * path: 'foo/bar',\n * state: 'present',\n * mode: {\n * owner: { read: true, write: true, execute: true },\n * group: { read: true, write: true, execute: true },\n * other: { read: true, write: true, execute: true },\n * },\n * })\n * ```\n *\n * @param options\n */\nexport function directorySync(options: DirectoryOptions): void {\n const { mode, path, state } = options;\n const isPresent = __existsSync(path);\n if (state === 'present') {\n const newMode = __toMode(mode);\n if (!isPresent) {\n mkdirSync(path, { mode: newMode, recursive: true });\n }\n if (newMode != null && isPresent) {\n chmodSync(path, newMode);\n }\n } else if (isPresent) {\n rmSync(path, { recursive: true });\n }\n}\n","import { file, type FileOptions, fileSync } from './file.js';\n\nexport interface IgnoreFileOptions extends Omit<FileOptions, 'update'> {\n /**\n * File content mapping function where content is represented as lines.\n * When the file does not yet exist, the callback receives `undefined`.\n */\n readonly update?: ((content: Array<string> | undefined) => Array<string> | undefined) | undefined;\n}\n\n/**\n * Ensure file is present/absent asynchronously with content initialized or modified by line.\n *\n * @example\n * ```ts\n * await ignoreFile({\n * path: '.gitignore',\n * update: (lines) => [...(lines ?? []), 'dist'],\n * });\n * ```\n * @param options File target options.\n */\nexport async function ignoreFile(options: IgnoreFileOptions): Promise<void> {\n return file(toFileOption(options));\n}\n\n/**\n * Ensure file is present/absent synchronously with content initialized or modified by line.\n *\n * @example\n * ```ts\n * ignoreFileSync({\n * path: '.gitignore',\n * update: (lines) => [...(lines ?? []), 'dist'],\n * });\n * ```\n * @param options File target options.\n */\nexport function ignoreFileSync(options: IgnoreFileOptions): void {\n return fileSync(toFileOption(options));\n}\n\nfunction toFileOption({ update, ...otherOptions }: IgnoreFileOptions): FileOptions {\n return {\n ...otherOptions,\n\n update:\n update == null\n ? update\n : (content) => {\n const eol = content.includes('\\r\\n') ? '\\r\\n' : '\\n';\n const lines = content === '' ? undefined : content.split(eol);\n const updatedLines = update(lines);\n\n return updatedLines == null ? undefined : updatedLines.join(eol);\n },\n };\n}\n","import { readFileSync } from 'node:fs';\nimport { readFile } from 'node:fs/promises';\nimport path from 'node:path';\n\nimport { __exists } from './__exists.js';\nimport { __existsSync } from './__existsSync.js';\n\nconst defaultExtensions: Array<string> = ['.json', '.yaml', '.yml', '.js', '.cjs', '.mjs', '.ts', '.cts', '.mts'];\n\nexport interface IsConfigPresentOptions {\n /**\n * The name of the application.\n */\n app: string;\n\n /**\n * The directory to look into. Defaults to `process.cwd()`.\n */\n cwd?: string | undefined;\n\n /**\n * The list of extensions to check for.\n */\n extensions?: Array<string> | undefined;\n\n /**\n * The name of the package configuration. Defaults to `app`.\n */\n packageConfig?: string | undefined;\n}\n\n/**\n * Return whether tool configuration exists at `cwd` (cosmiconfig-style).\n *\n * Looks for `.{app}rc`, `.{app}rc.{ext}`, `{app}.config.{ext}` and a matching\n * `package.json` key.\n *\n * @param options\n */\nexport async function isConfigPresent(options: IsConfigPresentOptions): Promise<boolean> {\n const { candidatePaths, packageConfig, packageJsonPath } = toCandidates(options);\n\n const [hasConfigFile, hasPackageConfig] = await Promise.all([\n hasAnyFile(candidatePaths),\n hasPackageConfigFile(packageJsonPath, packageConfig),\n ]);\n\n return hasConfigFile || hasPackageConfig;\n}\n\nexport function isConfigPresentSync(options: IsConfigPresentOptions): boolean {\n const { candidatePaths, packageConfig, packageJsonPath } = toCandidates(options);\n\n for (const candidatePath of candidatePaths) {\n if (__existsSync(candidatePath)) {\n return true;\n }\n }\n\n if (__existsSync(packageJsonPath)) {\n try {\n return hasPackageConfigKey(readFileSync(packageJsonPath, 'utf8'), packageConfig);\n } catch {\n return false;\n }\n }\n\n return false;\n}\n\nasync function hasAnyFile(paths: Array<string>): Promise<boolean> {\n const results = await Promise.all(paths.map((candidatePath) => __exists(candidatePath)));\n\n return results.some(Boolean);\n}\n\nasync function hasPackageConfigFile(packageJsonPath: string, packageConfig: string): Promise<boolean> {\n if (!(await __exists(packageJsonPath))) {\n return false;\n }\n\n try {\n return hasPackageConfigKey(await readFile(packageJsonPath, 'utf8'), packageConfig);\n } catch {\n return false;\n }\n}\n\nfunction hasPackageConfigKey(packageJsonContent: string, packageConfig: string): boolean {\n const packageJson = JSON.parse(packageJsonContent) as Record<string, unknown>;\n const value = packageJson[packageConfig];\n\n return value !== undefined && value !== null && value !== false;\n}\n\nfunction toCandidates({ app, cwd = process.cwd(), extensions = defaultExtensions, packageConfig = app }: IsConfigPresentOptions) {\n const candidatePaths = [path.join(cwd, `.${app}rc`)];\n for (const extension of extensions) {\n candidatePaths.push(path.join(cwd, `.${app}rc${extension}`), path.join(cwd, `${app}.config${extension}`));\n }\n\n return {\n candidatePaths,\n packageConfig,\n packageJsonPath: path.join(cwd, 'package.json'),\n };\n}\n","import { file, type FileOptions, fileSync } from './file.js';\n\nexport interface JSONOption<V = JSONValue> extends Omit<FileOptions, 'update'> {\n /**\n * File content mapping function\n */\n readonly update?: ((content: undefined | V) => undefined | V) | undefined;\n}\n\nexport type JSONValue = Array<JSONValue> | boolean | null | number | string | { [key: string]: JSONValue };\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\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","export const meta = Object.freeze({\n // @ts-ignore - these variables are injected at build time\n buildNumber: (typeof __PACKAGE_BUILD_NUMBER__ === 'undefined' ? 0 : __PACKAGE_BUILD_NUMBER__) as number,\n // @ts-ignore - these variables are injected at build time\n name: (typeof __PACKAGE_NAME__ === 'undefined' ? '' : __PACKAGE_NAME__) as string,\n // @ts-ignore - these variables are injected at build time\n version: (typeof __PACKAGE_VERSION__ === 'undefined' ? '' : __PACKAGE_VERSION__) as string,\n});\n","import YAML from 'yaml';\n\nimport { file, type FileOptions, fileSync } from './file.js';\n\nexport interface YAMLOption<V = YAMLValue> extends Omit<FileOptions, 'update'> {\n /**\n * File content mapping function\n */\n readonly update?: ((content: undefined | V) => undefined | V) | undefined;\n}\n\nexport type YAMLValue = Array<YAMLValue> | boolean | null | number | string | { [key: string]: YAMLValue };\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 yaml<Value>(options: YAMLOption<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 yamlSync<Value>(options: YAMLOption<Value>): void {\n return fileSync(toFileOption(options));\n}\n\nfunction toFileOption<Value>({ update, ...otherOptions }: YAMLOption<Value>): FileOptions {\n return {\n ...otherOptions,\n\n update:\n update == null\n ? update\n : (content) => {\n const yamlValue = content === '' ? undefined : (YAML.parse(content) as Value);\n\n return YAML.stringify(update(yamlValue));\n },\n };\n}\n","import { spawn, spawnSync } from 'node:child_process';\n\nexport interface ExecOptions {\n /**\n * Current working directory\n */\n cwd?: string;\n\n /**\n * Stdio options\n */\n stdio?: 'ignore' | 'inherit' | 'pipe';\n}\n\n/**\n * Runs a command in a shell and returns a promise that resolves with an object\n * containing the stdout and stderr strings.\n *\n * @param command The command to run\n * @param args The arguments to pass to the command\n * @param options\n */\nexport async function exec(\n command: string,\n args: ReadonlyArray<string>,\n options?: ExecOptions,\n): Promise<{ stderr: string; stdout: 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 ts/no-unsafe-call, ts/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 ts/no-unsafe-call, ts/no-unsafe-member-access\n stderr += data.toString(encoding);\n });\n }\n // Handle process exit\n child.on('close', (_code) => {\n resolve({ stderr, stdout });\n });\n\n // Handle errors\n child.on('error', reject);\n });\n}\n\n/**\n * Runs a command in a shell and returns a promise that resolves with an object\n * containing the stdout and stderr strings.\n *\n * @param command The command to run\n * @param args The arguments to pass to the command\n * @param options\n * @returns A promise that resolves with an object like `{ stdout: string, stderr: string }`\n */\nexport function execSync(\n command: string,\n args: ReadonlyArray<string>,\n options?: ExecOptions,\n): { stderr: string; stdout: string } {\n const result = spawnSync(command, args, { ...options });\n const encoding = 'utf8';\n\n return { stderr: result.stderr.toString(encoding), stdout: result.stdout.toString(encoding) };\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: 'absent' | 'present';\n\n /**\n * File content mapping function\n *\n */\n readonly update?: ((content: string) => string | undefined) | undefined;\n}\n\n/**\n * Set/Unset yarn configuration value\n *\n * @param options\n * @example\n * await yarnConfig({\n * key: 'nodeLinker',\n * state: 'present',\n * update: (content) => content.replace('node-modules', 'hoisted'),\n * })\n */\nexport async function yarnConfig(options: YarnConfigOptions): Promise<void> {\n const { key, state, update } = options;\n if (state === 'present') {\n const { stdout } = await exec('yarn', ['config', 'get', key]);\n await exec('yarn', ['config', 'set', key, String(update == null ? '' : update(stdout))]);\n } else {\n await exec('yarn', ['config', 'unset', key]);\n }\n}\n\n/**\n * Synchronous version of {@link yarnConfig}\n *\n * @param options\n * @example\n * yarnConfigSync({\n * key: 'nodeLinker',\n * state: 'present',\n * update: (content) => content.replace('node-modules', 'hoisted'),\n * })\n */\nexport function yarnConfigSync(options: YarnConfigOptions) {\n const { key, state, update } = options;\n if (state === 'present') {\n const { stdout } = execSync('yarn', ['config', 'get', key]);\n execSync('yarn', ['config', 'set', key, String(update == null ? '' : update(stdout))]);\n } else {\n execSync('yarn', ['config', 'unset', key]);\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: 'absent' | 'present';\n\n /**\n * Version mapping function\n *\n */\n readonly update?: (() => undefined | YarnVersionKind) | undefined;\n}\n\n/**\n * Set/Unset yarn configuration value\n *\n * @param options\n * @example\n * await yarnVersion({\n * state: 'present',\n * update: () => 'berry', // or 'classic'\n * })\n */\nexport async function yarnVersion(options: YarnVersionOptions): Promise<void> {\n const { state, update } = options;\n if (state === 'present') {\n await exec('yarn', ['set', 'version', String(update == null ? 'berry' : update())]);\n } else {\n // TODO: remove yarn.lock\n throw new Error('Not implemented');\n }\n}\n\n/**\n * Synchronous version of {@link yarnVersion}\n *\n * @param options\n * @example\n * yarnVersionSync({\n * state: 'present',\n * update: () => 'berry', // or 'classic'\n * })\n */\nexport function yarnVersionSync(options: YarnVersionOptions) {\n const { state, update } = options;\n if (state === 'present') {\n execSync('yarn', ['set', 'version', String(update == null ? 'berry' : update())]);\n } else {\n // TODO: remove yarn.lock\n throw new Error('Not implemented');\n }\n}\n"],"mappings":";;;;;;AAGA,eAAsB,SAAS,MAAc;CAC3C,IAAI;EACF,MAAM,OAAO,MAAM,UAAU,IAAI;EACjC,OAAO;CACT,QAAQ;EACN,OAAO;CACT;AACF;;;ACRA,SAAgB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MAGhF,MAAM,IAAI,MAAM,iBAAiB;AAErC"}
1
+ {"version":3,"file":"index.js","names":["toFileOption","path","toFileOption","toFileOption"],"sources":["../src/internal/fileExists.ts","../src/internal/fileExistsSync.ts","../src/internal/toMode.ts","../src/file.ts","../src/internal/resolveCommentStyle.ts","../src/block.ts","../src/directory.ts","../src/ignoreFile.ts","../src/isConfigPresent.ts","../src/json.ts","../src/meta.ts","../src/toolVersions.ts","../src/yaml.ts","../src/exec.ts","../src/yarnConfig.ts","../src/yarnVersion.ts"],"sourcesContent":["import { constants } from 'node:fs';\nimport { access } from 'node:fs/promises';\n\nexport async function fileExists(path: string) {\n try {\n await access(path, constants.F_OK);\n return true;\n } catch {\n return false;\n }\n}\n","import { accessSync, constants } from 'node:fs';\n\nexport function fileExistsSync(path: string) {\n try {\n accessSync(path, constants.F_OK);\n return true;\n } catch {\n return false;\n }\n}\n","import type { FileMode, FilePermissionSet } from '../FileMode.js';\n\nexport function toMode(mode: FileMode | undefined): number | undefined {\n return mode == null\n ? mode\n : (\n toModeFlag(mode.owner, 0o400, 0o200, 0o100)\n | toModeFlag(mode.group, 0o040, 0o020, 0o010)\n | toModeFlag(mode.other, 0o004, 0o002, 0o001)\n );\n}\n\nfunction toModeFlag(permissionSet: FilePermissionSet | undefined, read: number, write: number, execute: number): number {\n return (\n (permissionSet?.read === true ? read : 0)\n | (permissionSet?.write === true ? write : 0)\n | (permissionSet?.execute === true ? execute : 0)\n );\n}\n","import { chmodSync, readFileSync, rmSync, writeFileSync } from 'node:fs';\nimport { chmod, readFile, rm, writeFile } from 'node:fs/promises';\n\nimport type { FileMode } from './FileMode.js';\n\nimport { fileExists } from './internal/fileExists.js';\nimport { fileExistsSync } from './internal/fileExistsSync.js';\nimport { toMode } from './internal/toMode.js';\n\nexport interface FileOptions {\n /**\n * File encoding\n */\n readonly encoding?: BufferEncoding;\n\n /**\n * File permissions\n */\n readonly mode?: FileMode;\n\n /**\n * File path\n */\n readonly path: string;\n\n /**\n * File target state\n */\n readonly state: 'absent' | 'present';\n\n /**\n * File content mapping function\n *\n */\n readonly update?: ((content: string) => string | undefined) | undefined;\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 * mode: {\n * owner: { read: true, write: true, execute: true },\n * group: { read: true, write: true, execute: true },\n * other: { read: true, write: true, execute: true },\n * },\n * })\n * ```\n *\n * @param options\n */\nexport async function file(options: FileOptions): Promise<void> {\n const { encoding = 'utf8', mode, path, state, update } = options;\n if (state === 'present') {\n const isPresent = await fileExists(path);\n const previousContent = isPresent ? await readFile(path, encoding) : '';\n const newContent = update == null ? (isPresent ? undefined : '') : update(previousContent);\n const newMode = toMode(mode);\n if (newContent != null) {\n await writeFile(path, newContent, { encoding, mode: newMode });\n }\n if (newMode != null && (isPresent || newContent != null)) {\n await chmod(path, newMode);\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 * mode: {\n * owner: { read: true, write: true, execute: true },\n * group: { read: true, write: true, execute: true },\n * other: { read: true, write: true, execute: true },\n * },\n * })\n * ```\n *\n * @param options\n */\nexport function fileSync(options: FileOptions): void {\n const { encoding = 'utf8', mode, path, state, update } = options;\n if (state === 'present') {\n const isPresent = fileExistsSync(path);\n const previousContent = isPresent ? readFileSync(path, encoding) : '';\n const newContent = update == null ? (isPresent ? undefined : '') : update(previousContent);\n const newMode = toMode(mode);\n if (newContent != null) {\n writeFileSync(path, newContent, { encoding, mode: newMode });\n }\n if (newMode != null && (isPresent || newContent != null)) {\n chmodSync(path, newMode);\n }\n } else {\n rmSync(path, { force: true });\n }\n}\n","import nodePath from 'node:path';\n\nexport type ResolvedCommentStyle = '#' | '/*' | '//' | '<!--';\n\n/* cspell:ignore containerfile */\nconst HASH_BASENAMES = new Set(['containerfile', 'dockerfile', 'gemfile', 'makefile']);\n\nconst HTML_EXTENSIONS = new Set(['htm', 'html', 'md', 'mdx', 'svg', 'xml']);\nconst LINE_EXTENSIONS = new Set([\n 'c',\n 'cjs',\n 'cpp',\n 'cs',\n 'cts',\n 'go',\n 'h',\n 'java',\n 'js',\n 'jsx',\n 'kt',\n 'mjs',\n 'mts',\n 'rs',\n 'swift',\n 'ts',\n 'tsx',\n]);\nconst BLOCK_EXTENSIONS = new Set(['css', 'less', 'sass', 'scss']);\n\n/**\n * Resolve comment style from the file path when `commentStyle` is `'auto'`.\n *\n * @param path File path used to infer the comment style.\n */\nexport function resolveCommentStyle(path: string): ResolvedCommentStyle {\n const basename = nodePath.basename(path);\n const basenameLower = basename.toLowerCase();\n\n if (basename.startsWith('.') || HASH_BASENAMES.has(basenameLower)) {\n return '#';\n }\n\n const extension = nodePath.extname(basename).slice(1).toLowerCase();\n if (HTML_EXTENSIONS.has(extension)) {\n return '<!--';\n }\n if (LINE_EXTENSIONS.has(extension)) {\n return '//';\n }\n\n if (BLOCK_EXTENSIONS.has(extension)) {\n return '/*';\n }\n\n // py, rb, sh, toml, yaml, yml, json, no extension, and unknown → #\n return '#';\n}\n","import { file, type FileOptions, fileSync } from './file.js';\nimport { resolveCommentStyle, type ResolvedCommentStyle } from './internal/resolveCommentStyle.js';\n\nexport type BlockCommentStyle = '#' | '/*' | '//' | '<!--' | 'auto';\n\nexport interface BlockMarkerOptions {\n /**\n * Comment opener used for the marker lines: `'auto'` (from file name),\n * `'#'`, `'//'`, slash-star, or `'<!--'`.\n *\n * @default 'auto'\n */\n commentStyle?: BlockCommentStyle;\n\n /**\n * Identity after `BEGIN:` / `END:`, so multiple blocks in one file do not collide.\n *\n * @default 'managed-block'\n */\n topic?: string;\n}\n\nexport interface BlockOptions {\n /**\n * Block content to insert\n */\n block: string;\n\n /**\n * Insert position\n */\n insertPosition?: ['after', 'EndOfFile' | RegExp] | ['before', 'BeginningOfFile' | RegExp];\n\n /**\n * Marker configuration, or a function that returns the full marker line.\n *\n * @default `{ commentStyle: 'auto', topic: 'managed-block' }`\n */\n marker?: ((mark: 'Begin' | 'End') => string) | BlockMarkerOptions;\n\n /**\n * File path\n */\n path: string;\n\n /**\n * Block target state\n */\n state?: 'absent' | 'present';\n}\n\nconst EOF = 'EndOfFile';\nconst BOF = 'BeginningOfFile';\nconst DEFAULT_TOPIC = 'managed-block';\n\nconst insertAt = (str: string, index: number, toInsert: string) => str.slice(0, index) + toInsert + str.slice(index);\nconst matchLast = (string: string, regexp: RegExp) => {\n const matcher = new RegExp(regexp.source, `${regexp.flags}g`);\n let firstIndex = -1;\n let lastIndex = -1;\n let matches;\n\n while (true) {\n matches = matcher.exec(string);\n if (matches == null) {\n break;\n }\n firstIndex = matches.index;\n lastIndex = matcher.lastIndex;\n }\n return { firstIndex, lastIndex };\n};\n\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\nfunction formatMarker(style: ResolvedCommentStyle, mark: 'Begin' | 'End', topic: string): string {\n const inner = `${mark.toUpperCase()}:${topic}`;\n switch (style) {\n case '#': {\n return `# ${inner}`;\n }\n case '/*': {\n return `/* ${inner} */`;\n }\n case '//': {\n return `// ${inner}`;\n }\n case '<!--': {\n return `<!-- ${inner} -->`;\n }\n default: {\n throw new Error(`Unsupported comment style ${String(style)}`);\n }\n }\n}\n\nfunction toFileOptions(options: BlockOptions): FileOptions {\n const { block: blockName, insertPosition = ['after', EOF], marker, path, state = 'present' } = options;\n\n const EOL = '\\n';\n const markerFn = toMarkerFn(marker, path);\n const beginBlock = markerFn('Begin');\n const endBlock = markerFn('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 '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 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\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\nfunction toMarkerFn(marker: BlockOptions['marker'], path: string): (mark: 'Begin' | 'End') => string {\n if (typeof marker === 'function') {\n return marker;\n }\n\n const commentStyle = marker?.commentStyle ?? 'auto';\n const topic = marker?.topic ?? DEFAULT_TOPIC;\n const resolvedStyle = commentStyle === 'auto' ? resolveCommentStyle(path) : commentStyle;\n\n return (mark) => formatMarker(resolvedStyle, mark, topic);\n}\n","import { chmodSync, mkdirSync, rmSync } from 'node:fs';\nimport { chmod, mkdir, rm } from 'node:fs/promises';\n\nimport type { FileMode } from './FileMode.js';\n\nimport { fileExists } from './internal/fileExists.js';\nimport { fileExistsSync } from './internal/fileExistsSync.js';\nimport { toMode } from './internal/toMode.js';\n\nexport interface DirectoryOptions {\n /**\n * File permissions\n */\n readonly mode?: FileMode;\n\n /**\n * Directory path\n */\n readonly path: string;\n\n /**\n * Directory target state\n */\n readonly state: 'absent' | 'present';\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 * mode: {\n * owner: { read: true, write: true, execute: true },\n * group: { read: true, write: true, execute: true },\n * other: { read: true, write: true, execute: true },\n * },\n * })\n * ```\n *\n * @param options\n */\nexport async function directory(options: DirectoryOptions): Promise<void> {\n const { mode, path, state } = options;\n const isPresent = await fileExists(path);\n if (state === 'present') {\n const newMode = toMode(mode);\n if (!isPresent) {\n await mkdir(path, { mode: newMode, recursive: true });\n }\n if (newMode != null && isPresent) {\n await chmod(path, newMode);\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 * directorySync({\n * path: 'foo/bar',\n * state: 'present',\n * mode: {\n * owner: { read: true, write: true, execute: true },\n * group: { read: true, write: true, execute: true },\n * other: { read: true, write: true, execute: true },\n * },\n * })\n * ```\n *\n * @param options\n */\nexport function directorySync(options: DirectoryOptions): void {\n const { mode, path, state } = options;\n const isPresent = fileExistsSync(path);\n if (state === 'present') {\n const newMode = toMode(mode);\n if (!isPresent) {\n mkdirSync(path, { mode: newMode, recursive: true });\n }\n if (newMode != null && isPresent) {\n chmodSync(path, newMode);\n }\n } else if (isPresent) {\n rmSync(path, { recursive: true });\n }\n}\n","import { file, type FileOptions, fileSync } from './file.js';\n\nexport interface IgnoreFileOptions extends Omit<FileOptions, 'update'> {\n /**\n * File content mapping function where content is represented as lines.\n * When the file does not yet exist, the callback receives `undefined`.\n */\n readonly update?: ((content: Array<string> | undefined) => Array<string> | undefined) | undefined;\n}\n\n/**\n * Ensure file is present/absent asynchronously with content initialized or modified by line.\n *\n * @example\n * ```ts\n * await ignoreFile({\n * path: '.gitignore',\n * update: (lines) => [...(lines ?? []), 'dist'],\n * });\n * ```\n * @param options File target options.\n */\nexport async function ignoreFile(options: IgnoreFileOptions): Promise<void> {\n return file(toFileOption(options));\n}\n\n/**\n * Ensure file is present/absent synchronously with content initialized or modified by line.\n *\n * @example\n * ```ts\n * ignoreFileSync({\n * path: '.gitignore',\n * update: (lines) => [...(lines ?? []), 'dist'],\n * });\n * ```\n * @param options File target options.\n */\nexport function ignoreFileSync(options: IgnoreFileOptions): void {\n return fileSync(toFileOption(options));\n}\n\nfunction toFileOption({ update, ...otherOptions }: IgnoreFileOptions): FileOptions {\n return {\n ...otherOptions,\n\n update:\n update == null\n ? update\n : (content) => {\n const eol = content.includes('\\r\\n') ? '\\r\\n' : '\\n';\n const lines = content === '' ? undefined : content.split(eol);\n const updatedLines = update(lines);\n\n return updatedLines == null ? undefined : updatedLines.join(eol);\n },\n };\n}\n","import { readFileSync } from 'node:fs';\nimport { readFile } from 'node:fs/promises';\nimport path from 'node:path';\n\nimport { fileExists } from './internal/fileExists.js';\nimport { fileExistsSync } from './internal/fileExistsSync.js';\n\nconst defaultExtensions: Array<string> = ['.json', '.yaml', '.yml', '.js', '.cjs', '.mjs', '.ts', '.cts', '.mts'];\n\nexport interface IsConfigPresentOptions {\n /**\n * The name of the application.\n */\n app: string;\n\n /**\n * The directory to look into. Defaults to `process.cwd()`.\n */\n cwd?: string | undefined;\n\n /**\n * The list of extensions to check for.\n */\n extensions?: Array<string> | undefined;\n\n /**\n * The name of the package configuration. Defaults to `app`.\n */\n packageConfig?: string | undefined;\n}\n\n/**\n * Return whether tool configuration exists at `cwd` (cosmiconfig-style).\n *\n * Looks for `.{app}rc`, `.{app}rc.{ext}`, `{app}.config.{ext}` and a matching\n * `package.json` key.\n *\n * @param options\n */\nexport async function isConfigPresent(options: IsConfigPresentOptions): Promise<boolean> {\n const { candidatePaths, packageConfig, packageJsonPath } = toCandidates(options);\n\n const [hasConfigFile, hasPackageConfig] = await Promise.all([\n hasAnyFile(candidatePaths),\n hasPackageConfigFile(packageJsonPath, packageConfig),\n ]);\n\n return hasConfigFile || hasPackageConfig;\n}\n\nexport function isConfigPresentSync(options: IsConfigPresentOptions): boolean {\n const { candidatePaths, packageConfig, packageJsonPath } = toCandidates(options);\n\n for (const candidatePath of candidatePaths) {\n if (fileExistsSync(candidatePath)) {\n return true;\n }\n }\n\n if (fileExistsSync(packageJsonPath)) {\n try {\n return hasPackageConfigKey(readFileSync(packageJsonPath, 'utf8'), packageConfig);\n } catch {\n return false;\n }\n }\n\n return false;\n}\n\nasync function hasAnyFile(paths: Array<string>): Promise<boolean> {\n const results = await Promise.all(paths.map((candidatePath) => fileExists(candidatePath)));\n\n return results.some(Boolean);\n}\n\nasync function hasPackageConfigFile(packageJsonPath: string, packageConfig: string): Promise<boolean> {\n if (!(await fileExists(packageJsonPath))) {\n return false;\n }\n\n try {\n return hasPackageConfigKey(await readFile(packageJsonPath, 'utf8'), packageConfig);\n } catch {\n return false;\n }\n}\n\nfunction hasPackageConfigKey(packageJsonContent: string, packageConfig: string): boolean {\n const packageJson = JSON.parse(packageJsonContent) as Record<string, unknown>;\n const value = packageJson[packageConfig];\n\n return value !== undefined && value !== null && value !== false;\n}\n\nfunction toCandidates({ app, cwd = process.cwd(), extensions = defaultExtensions, packageConfig = app }: IsConfigPresentOptions) {\n const candidatePaths = [path.join(cwd, `.${app}rc`)];\n for (const extension of extensions) {\n candidatePaths.push(path.join(cwd, `.${app}rc${extension}`), path.join(cwd, `${app}.config${extension}`));\n }\n\n return {\n candidatePaths,\n packageConfig,\n packageJsonPath: path.join(cwd, 'package.json'),\n };\n}\n","import { file, type FileOptions, fileSync } from './file.js';\n\nexport interface JSONOption<V = JSONValue> extends Omit<FileOptions, 'update'> {\n /**\n * File content mapping function\n */\n readonly update?: ((content: undefined | V) => undefined | V) | undefined;\n}\n\nexport type JSONValue = Array<JSONValue> | boolean | null | number | string | { [key: string]: JSONValue };\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\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","export const meta = Object.freeze({\n // @ts-ignore - these variables are injected at build time\n buildNumber: (typeof __PACKAGE_BUILD_NUMBER__ === 'undefined' ? 0 : __PACKAGE_BUILD_NUMBER__) as number,\n // @ts-ignore - these variables are injected at build time\n name: (typeof __PACKAGE_NAME__ === 'undefined' ? '' : __PACKAGE_NAME__) as string,\n // @ts-ignore - these variables are injected at build time\n version: (typeof __PACKAGE_VERSION__ === 'undefined' ? '' : __PACKAGE_VERSION__) as string,\n});\n","import { file, type FileOptions, fileSync } from './file.js';\n\nconst reToolVersion = /\\s+/;\n\n/**\n * Regular expression to split tool and version\n */\nexport type ToolVersions = Record<string, string>;\n\nexport interface ToolVersionsOption extends Omit<FileOptions, 'path' | 'update'>, Partial<Pick<FileOptions, 'path'>> {\n /**\n * File content mapping function\n */\n readonly update?: ((content: ToolVersions | undefined) => ToolVersions | undefined) | undefined;\n}\n\nexport function toolVersions(options: ToolVersionsOption) {\n return file(toFileOption(options));\n}\n\nexport function toolVersionsSync(options: ToolVersionsOption) {\n return fileSync(toFileOption(options));\n}\n\nfunction toFileOption({ update, ...otherOptions }: ToolVersionsOption): FileOptions {\n return {\n ...otherOptions,\n path: otherOptions.path ?? '.tool-versions',\n update:\n update == null\n ? update\n : (content) => {\n const eol = '\\n';\n const lines = content.split(eol);\n const parsed = Object.fromEntries(\n (function* () {\n for (const line of lines) {\n const [tool, value] = line.split(reToolVersion, 2);\n if (tool) {\n yield [tool, value ?? ''];\n }\n }\n }()),\n );\n const updated = update ? update(parsed) : parsed;\n if (updated === undefined) return updated;\n\n const formatted = Object.entries(updated)\n .map(([tool, value]) => `${tool} ${value}`)\n .join(eol);\n return formatted;\n },\n };\n}\n","import YAML from 'yaml';\n\nimport { file, type FileOptions, fileSync } from './file.js';\n\nexport interface YAMLOption<V = YAMLValue> extends Omit<FileOptions, 'update'> {\n /**\n * File content mapping function\n */\n readonly update?: ((content: undefined | V) => undefined | V) | undefined;\n}\n\nexport type YAMLValue = Array<YAMLValue> | boolean | null | number | string | { [key: string]: YAMLValue };\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 yaml<Value>(options: YAMLOption<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 yamlSync<Value>(options: YAMLOption<Value>): void {\n return fileSync(toFileOption(options));\n}\n\nfunction toFileOption<Value>({ update, ...otherOptions }: YAMLOption<Value>): FileOptions {\n return {\n ...otherOptions,\n\n update:\n update == null\n ? update\n : (content) => {\n const yamlValue = content === '' ? undefined : (YAML.parse(content) as Value);\n\n return YAML.stringify(update(yamlValue));\n },\n };\n}\n","import { spawn, spawnSync } from 'node:child_process';\n\nexport interface ExecOptions {\n /**\n * Current working directory\n */\n cwd?: string;\n\n /**\n * Stdio options\n */\n stdio?: 'ignore' | 'inherit' | 'pipe';\n}\n\n/**\n * Runs a command in a shell and returns a promise that resolves with an object\n * containing the stdout and stderr strings.\n *\n * @param command The command to run\n * @param args The arguments to pass to the command\n * @param options\n */\nexport async function exec(\n command: string,\n args: ReadonlyArray<string>,\n options?: ExecOptions,\n): Promise<{ stderr: string; stdout: 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 ts/no-unsafe-call, ts/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 ts/no-unsafe-call, ts/no-unsafe-member-access\n stderr += data.toString(encoding);\n });\n }\n // Handle process exit\n child.on('close', (_code) => {\n resolve({ stderr, stdout });\n });\n\n // Handle errors\n child.on('error', reject);\n });\n}\n\n/**\n * Runs a command in a shell and returns a promise that resolves with an object\n * containing the stdout and stderr strings.\n *\n * @param command The command to run\n * @param args The arguments to pass to the command\n * @param options\n * @returns A promise that resolves with an object like `{ stdout: string, stderr: string }`\n */\nexport function execSync(\n command: string,\n args: ReadonlyArray<string>,\n options?: ExecOptions,\n): { stderr: string; stdout: string } {\n const result = spawnSync(command, args, { ...options });\n const encoding = 'utf8';\n\n return { stderr: result.stderr.toString(encoding), stdout: result.stdout.toString(encoding) };\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: 'absent' | 'present';\n\n /**\n * File content mapping function\n *\n */\n readonly update?: ((content: string) => string | undefined) | undefined;\n}\n\n/**\n * Set/Unset yarn configuration value\n *\n * @param options\n * @example\n * await yarnConfig({\n * key: 'nodeLinker',\n * state: 'present',\n * update: (content) => content.replace('node-modules', 'hoisted'),\n * })\n */\nexport async function yarnConfig(options: YarnConfigOptions): Promise<void> {\n const { key, state, update } = options;\n if (state === 'present') {\n const { stdout } = await exec('yarn', ['config', 'get', key]);\n await exec('yarn', ['config', 'set', key, String(update == null ? '' : update(stdout))]);\n } else {\n await exec('yarn', ['config', 'unset', key]);\n }\n}\n\n/**\n * Synchronous version of {@link yarnConfig}\n *\n * @param options\n * @example\n * yarnConfigSync({\n * key: 'nodeLinker',\n * state: 'present',\n * update: (content) => content.replace('node-modules', 'hoisted'),\n * })\n */\nexport function yarnConfigSync(options: YarnConfigOptions) {\n const { key, state, update } = options;\n if (state === 'present') {\n const { stdout } = execSync('yarn', ['config', 'get', key]);\n execSync('yarn', ['config', 'set', key, String(update == null ? '' : update(stdout))]);\n } else {\n execSync('yarn', ['config', 'unset', key]);\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: 'absent' | 'present';\n\n /**\n * Version mapping function\n *\n */\n readonly update?: (() => undefined | YarnVersionKind) | undefined;\n}\n\n/**\n * Set/Unset yarn configuration value\n *\n * @param options\n * @example\n * await yarnVersion({\n * state: 'present',\n * update: () => 'berry', // or 'classic'\n * })\n */\nexport async function yarnVersion(options: YarnVersionOptions): Promise<void> {\n const { state, update } = options;\n if (state === 'present') {\n await exec('yarn', ['set', 'version', String(update == null ? 'berry' : update())]);\n } else {\n // TODO: remove yarn.lock\n throw new Error('Not implemented');\n }\n}\n\n/**\n * Synchronous version of {@link yarnVersion}\n *\n * @param options\n * @example\n * yarnVersionSync({\n * state: 'present',\n * update: () => 'berry', // or 'classic'\n * })\n */\nexport function yarnVersionSync(options: YarnVersionOptions) {\n const { state, update } = options;\n if (state === 'present') {\n execSync('yarn', ['set', 'version', String(update == null ? 'berry' : update())]);\n } else {\n // TODO: remove yarn.lock\n throw new Error('Not implemented');\n }\n}\n"],"mappings":";;;;;;AAGA,eAAsB,WAAW,MAAc;CAC7C,IAAI;EACF,MAAM,OAAO,MAAM,UAAU,IAAI;EACjC,OAAO;CACT,QAAQ;EACN,OAAO;CACT;AACF;;ACRA,SAAgB,eAAe,MAAc;CAC3C,IAAI;EACF,WAAW,MAAM,UAAU,IAAI;EAC/B,OAAO;CACT,QAAQ;EACN,OAAO;CACT;AACF;;ACPA,SAAgB,OAAO,MAAgD;CACrE,OAAO,QAAQ,OACX,OAEE,WAAW,KAAK,OAAO,KAAO,KAAO,EAAK,IAC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AI,UAAU,WAAW;EACvB,MAAM,EAAE,WAAW,SAAS,QAAQ;GAAC;GAAU;GAAO;EAAG,CAAC;EAC1D,SAAS,QAAQ;GAAC;GAAU;GAAO;GAAK,OAAO,UAAU,OAAO,KAAK,OAAO,MAAM,CAAC;EAAC,CAAC;CACvF,OACE,SAAS,QAAQ;EAAC;EAAU;EAAS;CAAG,CAAC;AAE7C;;;;;;;;;;;;ACjCA,eAAsB,YAAY,SAA4C;CAC5E,MAAM,EAAE,OAAO,WAAW;CAC1B,IAAI,UAAU,WACZ,MAAM,KAAK,QAAQ;EAAC;EAAO;EAAW,OAAO,UAAU,OAAO,UAAU,OAAO,CAAC;CAAC,CAAC;MAGlF,MAAM,IAAI,MAAM,iBAAiB;AAErC;;;;;;;;;;;AAYA,SAAgB,gBAAgB,SAA6B;CAC3D,MAAM,EAAE,OAAO,WAAW;CAC1B,IAAI,UAAU,WACZ,SAAS,QAAQ;EAAC;EAAO;EAAW,OAAO,UAAU,OAAO,UAAU,OAAO,CAAC;CAAC,CAAC;MAGhF,MAAM,IAAI,MAAM,iBAAiB;AAErC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@w5s/configurator-core",
3
- "version": "1.21.0",
3
+ "version": "1.23.0",
4
4
  "description": "Core library for @w5s/configurator-core",
5
5
  "keywords": [
6
6
  "config",
@@ -46,5 +46,5 @@
46
46
  "publishConfig": {
47
47
  "access": "public"
48
48
  },
49
- "gitHead": "7ea7f0176cdd3156d9b24af722a38b280aa99427"
49
+ "gitHead": "8c839f967fbc4477af3e767c4ecfa2d8a693eda0"
50
50
  }