@w5s/dev 2.2.6 → 2.2.10

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 ADDED
@@ -0,0 +1,332 @@
1
+ 'use strict';
2
+
3
+ var fs = require('fs');
4
+ var promises = require('fs/promises');
5
+
6
+ // src/directory.ts
7
+ async function exists(path) {
8
+ try {
9
+ await promises.access(path, promises.constants.F_OK);
10
+ return true;
11
+ } catch {
12
+ return false;
13
+ }
14
+ }
15
+ async function directory(options) {
16
+ const { path, state } = options;
17
+ const isPresent = await exists(path);
18
+ if (state === "present") {
19
+ if (!isPresent) {
20
+ await promises.mkdir(path, { recursive: true });
21
+ }
22
+ } else if (isPresent) {
23
+ await promises.rm(path, { recursive: true });
24
+ }
25
+ }
26
+ function directorySync(options) {
27
+ const { path, state } = options;
28
+ const isPresent = fs.existsSync(path);
29
+ if (state === "present") {
30
+ if (!isPresent) {
31
+ fs.mkdirSync(path, { recursive: true });
32
+ }
33
+ } else if (isPresent) {
34
+ fs.rmSync(path, { recursive: true });
35
+ }
36
+ }
37
+
38
+ // src/eslint.ts
39
+ function toArray(value) {
40
+ if (value == null) {
41
+ return [];
42
+ }
43
+ if (Array.isArray(value)) {
44
+ return value;
45
+ }
46
+ return [value];
47
+ }
48
+ function concatArray(left, right) {
49
+ return toArray(left).concat(toArray(right));
50
+ }
51
+ exports.ESLintConfig = void 0;
52
+ ((ESLintConfig2) => {
53
+ function concat(...configs) {
54
+ return configs.reduce(
55
+ (returnValue, config) => ({
56
+ ...returnValue,
57
+ ...config,
58
+ env: { ...returnValue.env, ...config.env },
59
+ extends: concatArray(returnValue.extends, config.extends),
60
+ globals: { ...returnValue.globals, ...config.globals },
61
+ overrides: concatArray(returnValue.overrides, config.overrides),
62
+ parserOptions: { ...returnValue.parserOptions, ...config.parserOptions },
63
+ plugins: concatArray(returnValue.plugins, config.plugins),
64
+ rules: { ...returnValue.rules, ...config.rules },
65
+ settings: { ...returnValue.settings, ...config.settings }
66
+ }),
67
+ {
68
+ env: {},
69
+ extends: [],
70
+ globals: {},
71
+ overrides: [],
72
+ parserOptions: {},
73
+ plugins: [],
74
+ rules: {},
75
+ settings: {}
76
+ }
77
+ );
78
+ }
79
+ ESLintConfig2.concat = concat;
80
+ function fixme(_status) {
81
+ return "off";
82
+ }
83
+ ESLintConfig2.fixme = fixme;
84
+ })(exports.ESLintConfig || (exports.ESLintConfig = {}));
85
+ async function exists2(path) {
86
+ try {
87
+ await promises.access(path, fs.constants.F_OK);
88
+ return true;
89
+ } catch {
90
+ return false;
91
+ }
92
+ }
93
+ function existsSync2(path) {
94
+ try {
95
+ fs.accessSync(path, fs.constants.F_OK);
96
+ return true;
97
+ } catch {
98
+ return false;
99
+ }
100
+ }
101
+ async function file(options) {
102
+ const { path, state, update, encoding = "utf8" } = options;
103
+ if (state === "present") {
104
+ const isPresent = await exists2(path);
105
+ const previousContent = isPresent ? await promises.readFile(path, encoding) : "";
106
+ const newContent = update == null ? "" : update(previousContent);
107
+ if (newContent != null) {
108
+ await promises.writeFile(path, newContent, encoding);
109
+ }
110
+ } else {
111
+ await promises.rm(path, { force: true });
112
+ }
113
+ }
114
+ function fileSync(options) {
115
+ const { path, state, update, encoding = "utf8" } = options;
116
+ if (state === "present") {
117
+ const isPresent = existsSync2(path);
118
+ const previousContent = isPresent ? fs.readFileSync(path, encoding) : "";
119
+ const newContent = update == null ? "" : update(previousContent);
120
+ if (newContent != null) {
121
+ fs.writeFileSync(path, newContent, encoding);
122
+ }
123
+ } else {
124
+ fs.rmSync(path, { force: true });
125
+ }
126
+ }
127
+
128
+ // src/block.ts
129
+ var EOF = "EndOfFile";
130
+ var BOF = "BeginningOfFile";
131
+ var insertAt = (str, index, toInsert) => str.slice(0, index) + toInsert + str.slice(index);
132
+ var matchLast = (string, regexp) => {
133
+ const matcher = new RegExp(regexp.source, `${regexp.flags}g`);
134
+ let firstIndex = -1;
135
+ let lastIndex = -1;
136
+ let matches;
137
+ while (true) {
138
+ matches = matcher.exec(string);
139
+ if (matches == null) {
140
+ break;
141
+ }
142
+ firstIndex = matches.index;
143
+ lastIndex = matcher.lastIndex;
144
+ }
145
+ return { firstIndex, lastIndex };
146
+ };
147
+ function toFileOptions(options) {
148
+ const {
149
+ marker = (mark) => `# ${mark.toUpperCase()} MANAGED BLOCK`,
150
+ path,
151
+ block: blockName,
152
+ insertPosition = ["after", EOF],
153
+ state = "present"
154
+ } = options;
155
+ const EOL = "\n";
156
+ const beginBlock = marker("Begin");
157
+ const endBlock = marker("End");
158
+ function findBlock(content) {
159
+ const startIndex = content.indexOf(beginBlock);
160
+ const endIndex = content.indexOf(endBlock) + endBlock.length;
161
+ return {
162
+ endIndex,
163
+ exists: startIndex >= 0 && endIndex >= 0,
164
+ startIndex
165
+ };
166
+ }
167
+ function apply(fullContent, blockContent) {
168
+ const found = findBlock(fullContent);
169
+ const remove = state === "absent";
170
+ const replaceBlock = remove ? "" : beginBlock + EOL + blockContent + EOL + endBlock;
171
+ const [positionDirection, positionAnchor] = insertPosition;
172
+ if (found.exists) {
173
+ return fullContent.slice(0, found.startIndex) + replaceBlock + fullContent.slice(found.endIndex);
174
+ }
175
+ if (remove) {
176
+ return fullContent;
177
+ }
178
+ switch (positionDirection) {
179
+ case "before": {
180
+ if (positionAnchor !== BOF) {
181
+ const { firstIndex } = matchLast(fullContent, positionAnchor);
182
+ if (firstIndex >= 0) {
183
+ return insertAt(fullContent, firstIndex, replaceBlock + EOL);
184
+ }
185
+ }
186
+ return replaceBlock + EOL + fullContent;
187
+ }
188
+ case "after": {
189
+ if (positionAnchor !== EOF) {
190
+ const { lastIndex } = matchLast(fullContent, positionAnchor);
191
+ if (lastIndex >= 0) {
192
+ return insertAt(fullContent, lastIndex, EOL + replaceBlock);
193
+ }
194
+ }
195
+ return fullContent + EOL + replaceBlock;
196
+ }
197
+ default: {
198
+ throw new Error(`Unsupported position ${String(positionDirection)}`);
199
+ }
200
+ }
201
+ }
202
+ return {
203
+ path,
204
+ state: "present",
205
+ update: (sourceContent) => apply(sourceContent, blockName)
206
+ };
207
+ }
208
+ function block(options) {
209
+ return file(toFileOptions(options));
210
+ }
211
+ function blockSync(options) {
212
+ return fileSync(toFileOptions(options));
213
+ }
214
+
215
+ // src/json.ts
216
+ function toFileOption({ update, ...otherOptions }) {
217
+ return {
218
+ ...otherOptions,
219
+ update: update == null ? update : (content) => {
220
+ const jsonValue = content === "" ? void 0 : JSON.parse(content);
221
+ return JSON.stringify(update(jsonValue));
222
+ }
223
+ };
224
+ }
225
+ async function json(options) {
226
+ return file(toFileOption(options));
227
+ }
228
+ function jsonSync(options) {
229
+ return fileSync(toFileOption(options));
230
+ }
231
+
232
+ // src/project.ts
233
+ function escapeRegExp(value) {
234
+ return value.replaceAll(/[$()*+.?[\\\]^{|}]/g, "\\$&");
235
+ }
236
+ exports.Project = void 0;
237
+ ((Project2) => {
238
+ function ecmaVersion() {
239
+ return 2022;
240
+ }
241
+ Project2.ecmaVersion = ecmaVersion;
242
+ const registry = {
243
+ graphql: [".gql", ".graphql"],
244
+ jpeg: [".jpg", ".jpeg"],
245
+ javascript: [".js", ".cjs", ".mjs"],
246
+ javascriptreact: [".jsx"],
247
+ typescript: [".ts", ".cts", ".mts"],
248
+ typescriptreact: [".tsx"],
249
+ yaml: [".yaml", ".yml"]
250
+ };
251
+ function queryExtensions(languages) {
252
+ return languages.reduce(
253
+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
254
+ (previousValue, currentValue) => previousValue.concat(registry[currentValue] ?? []),
255
+ []
256
+ ).sort();
257
+ }
258
+ Project2.queryExtensions = queryExtensions;
259
+ function sourceExtensions() {
260
+ return queryExtensions(["javascript", "javascriptreact", "typescript", "typescriptreact"]);
261
+ }
262
+ Project2.sourceExtensions = sourceExtensions;
263
+ const RESOURCE_EXTENSIONS = Object.freeze([
264
+ ".css",
265
+ ".sass",
266
+ ".scss",
267
+ ".less",
268
+ ".gif",
269
+ ".png",
270
+ ".svg",
271
+ ...queryExtensions(["graphql", "jpeg", "yaml"])
272
+ ]);
273
+ function resourceExtensions() {
274
+ return RESOURCE_EXTENSIONS;
275
+ }
276
+ Project2.resourceExtensions = resourceExtensions;
277
+ const IGNORED = Object.freeze([
278
+ "node_modules/",
279
+ "build/",
280
+ "cjs/",
281
+ "coverage/",
282
+ "dist/",
283
+ "dts/",
284
+ "esm/",
285
+ "lib/",
286
+ "mjs/",
287
+ "umd/"
288
+ ]);
289
+ function ignored() {
290
+ return IGNORED;
291
+ }
292
+ Project2.ignored = ignored;
293
+ function extensionsToMatcher(extensions) {
294
+ return new RegExp(`(${extensions.map(escapeRegExp).join("|")})$`);
295
+ }
296
+ Project2.extensionsToMatcher = extensionsToMatcher;
297
+ function extensionsToGlob(extensions) {
298
+ return `*.+(${extensions.map((_) => _.replace(/^\./, "")).join("|")})`;
299
+ }
300
+ Project2.extensionsToGlob = extensionsToGlob;
301
+ })(exports.Project || (exports.Project = {}));
302
+
303
+ // src/projectScript.ts
304
+ var ProjectScript = {
305
+ Build: "build",
306
+ Clean: "clean",
307
+ CodeAnalysis: "code-analysis",
308
+ Coverage: "coverage",
309
+ Develop: "develop",
310
+ Docs: "docs",
311
+ Format: "format",
312
+ Install: "install",
313
+ Lint: "lint",
314
+ Prepare: "prepare",
315
+ Release: "release",
316
+ Rescue: "rescue",
317
+ Spellcheck: "spellcheck",
318
+ Test: "test",
319
+ Validate: "validate"
320
+ };
321
+
322
+ exports.ProjectScript = ProjectScript;
323
+ exports.block = block;
324
+ exports.blockSync = blockSync;
325
+ exports.directory = directory;
326
+ exports.directorySync = directorySync;
327
+ exports.file = file;
328
+ exports.fileSync = fileSync;
329
+ exports.json = json;
330
+ exports.jsonSync = jsonSync;
331
+ //# sourceMappingURL=index.cjs.map
332
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/directory.ts","../src/eslint.ts","../src/file.ts","../src/block.ts","../src/json.ts","../src/project.ts","../src/projectScript.ts"],"names":["access","constants","mkdir","rm","existsSync","mkdirSync","rmSync","ESLintConfig","exists","accessSync","readFile","writeFile","readFileSync","writeFileSync","Project"],"mappings":";;;;;;AAGA,eAAe,OAAO,IAAc,EAAA;AAClC,EAAI,IAAA;AACF,IAAM,MAAAA,eAAA,CAAO,IAAM,EAAAC,kBAAA,CAAU,IAAI,CAAA,CAAA;AACjC,IAAO,OAAA,IAAA,CAAA;AAAA,GACD,CAAA,MAAA;AACN,IAAO,OAAA,KAAA,CAAA;AAAA,GACT;AACF,CAAA;AA0BA,eAAsB,UAAU,OAA0C,EAAA;AACxE,EAAM,MAAA,EAAE,IAAM,EAAA,KAAA,EAAU,GAAA,OAAA,CAAA;AACxB,EAAM,MAAA,SAAA,GAAY,MAAM,MAAA,CAAO,IAAI,CAAA,CAAA;AACnC,EAAA,IAAI,UAAU,SAAW,EAAA;AACvB,IAAA,IAAI,CAAC,SAAW,EAAA;AACd,MAAA,MAAMC,cAAM,CAAA,IAAA,EAAM,EAAE,SAAA,EAAW,MAAM,CAAA,CAAA;AAAA,KACvC;AAAA,aACS,SAAW,EAAA;AACpB,IAAA,MAAMC,WAAG,CAAA,IAAA,EAAM,EAAE,SAAA,EAAW,MAAM,CAAA,CAAA;AAAA,GACpC;AACF,CAAA;AAeO,SAAS,cAAc,OAAiC,EAAA;AAC7D,EAAM,MAAA,EAAE,IAAM,EAAA,KAAA,EAAU,GAAA,OAAA,CAAA;AACxB,EAAM,MAAA,SAAA,GAAYC,cAAW,IAAI,CAAA,CAAA;AACjC,EAAA,IAAI,UAAU,SAAW,EAAA;AACvB,IAAA,IAAI,CAAC,SAAW,EAAA;AACd,MAAAC,YAAA,CAAU,IAAM,EAAA,EAAE,SAAW,EAAA,IAAA,EAAM,CAAA,CAAA;AAAA,KACrC;AAAA,aACS,SAAW,EAAA;AACpB,IAAAC,SAAA,CAAO,IAAM,EAAA,EAAE,SAAW,EAAA,IAAA,EAAM,CAAA,CAAA;AAAA,GAClC;AACF,CAAA;;;ACrEA,SA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,EAAAA,QAAS,CAAA,mBAAA,GAAA,mBAAA,CAAA;AAYT,EAAA,SAAS,iBAAiB,UAA0C,EAAA;AACzE,IAAA,OAAO,CAAO,IAAA,EAAA,UAAA,CAAW,GAAI,CAAA,CAAC,CAAM,KAAA,CAAA,CAAE,OAAQ,CAAA,KAAA,EAAO,EAAE,CAAC,CAAE,CAAA,IAAA,CAAK,GAAG,CAAC,CAAA,CAAA,CAAA,CAAA;AAAA,GACrE;AAFO,EAAAA,QAAS,CAAA,gBAAA,GAAA,gBAAA,CAAA;AAAA,CAnJD,EAAAA,eAAA,KAAAA,eAAA,GAAA,EAAA,CAAA,CAAA,CAAA;;;ACDV,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,UAAA;AACZ","file":"index.cjs","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;\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 >= 0 && endIndex >= 0,\n startIndex,\n };\n }\n\n function apply(fullContent: string, blockContent: string) {\n const found = findBlock(fullContent);\n const remove = state === 'absent';\n const replaceBlock = remove ? '' : beginBlock + EOL + blockContent + EOL + endBlock;\n const [positionDirection, positionAnchor] = insertPosition;\n\n if (found.exists) {\n return fullContent.slice(0, found.startIndex) + replaceBlock + fullContent.slice(found.endIndex);\n }\n if (remove) {\n return fullContent;\n }\n switch (positionDirection) {\n case 'before': {\n if (positionAnchor !== BOF) {\n const { firstIndex } = matchLast(fullContent, positionAnchor);\n if (firstIndex >= 0) {\n return insertAt(fullContent, firstIndex, replaceBlock + EOL);\n }\n }\n\n // Beginning of file\n return replaceBlock + EOL + fullContent;\n }\n case 'after': {\n // insert\n if (positionAnchor !== EOF) {\n const { lastIndex } = matchLast(fullContent, positionAnchor);\n if (lastIndex >= 0) {\n return insertAt(fullContent, lastIndex, EOL + replaceBlock);\n }\n }\n\n // end of file\n return fullContent + EOL + replaceBlock;\n }\n\n default: {\n throw new Error(`Unsupported position ${String(positionDirection)}`);\n }\n }\n }\n\n return {\n path,\n state: 'present',\n update: (sourceContent) => apply(sourceContent, blockName),\n };\n}\n\n/**\n * Replace asynchronously a block in file that follows pattern :\n *\n * marker(markerBegin)\n * ...\n * marker(markerEnd)\n *\n * @param options\n */\nexport function block(options: BlockOptions) {\n return file(toFileOptions(options));\n}\n\n/**\n * Replace synchronously a block in file that follows pattern :\n *\n * marker(markerBegin)\n * ...\n * marker(markerEnd)\n *\n * @param options\n */\nexport function blockSync(options: BlockOptions) {\n return fileSync(toFileOptions(options));\n}\n","import { type FileOptions, file, fileSync } from './file.js';\n\nexport type JSONValue = null | number | string | boolean | JSONValue[] | { [key: string]: JSONValue };\n\nexport interface JSONOption<V = JSONValue> {\n /**\n * File path\n */\n readonly path: string;\n /**\n * File target state\n */\n readonly state: 'present' | 'absent';\n /**\n * File content mapping function\n *\n * @param content\n */\n readonly update?: (content: V | undefined) => V | undefined;\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 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"]}
@@ -0,0 +1,299 @@
1
+ import { ESLint, Linter } from 'eslint';
2
+
3
+ interface DirectoryOptions {
4
+ /**
5
+ * Directory path
6
+ */
7
+ readonly path: string;
8
+ /**
9
+ * Directory target state
10
+ */
11
+ readonly state: 'present' | 'absent';
12
+ }
13
+ /**
14
+ * Ensure directory is present/absent
15
+ *
16
+ * @example
17
+ * ```ts
18
+ * await directory({
19
+ * path: 'foo/bar',
20
+ * state: 'present',
21
+ * })
22
+ * ```
23
+ *
24
+ * @param options
25
+ */
26
+ declare function directory(options: DirectoryOptions): Promise<void>;
27
+ /**
28
+ * Ensure directory is present/absent
29
+ *
30
+ * @example
31
+ * ```ts
32
+ * await directorySync({
33
+ * path: 'foo/bar',
34
+ * state: 'present',
35
+ * })
36
+ * ```
37
+ *
38
+ * @param options
39
+ */
40
+ declare function directorySync(options: DirectoryOptions): void;
41
+
42
+ declare namespace ESLintConfig {
43
+ /**
44
+ *
45
+ * @param configs
46
+ */
47
+ function concat(...configs: ESLint.ConfigData[]): ESLint.ConfigData;
48
+ /**
49
+ * Always return 'off'. `_status` is the previous rule value.
50
+ *
51
+ * @param _status
52
+ */
53
+ function fixme(_status: Linter.RuleLevel | [Linter.RuleLevel, ...any[]] | undefined): "off";
54
+ }
55
+
56
+ interface BlockOptions {
57
+ /**
58
+ * The marker builder function that will take either `markerBegin` or `markerEnd`
59
+ *
60
+ * @default '# ${mark} MANAGED BLOCK'
61
+ */
62
+ marker?: (mark: 'Begin' | 'End') => string;
63
+ /**
64
+ * File path
65
+ */
66
+ path: string;
67
+ /**
68
+ * Block content to insert
69
+ */
70
+ block: string;
71
+ /**
72
+ * Insert position
73
+ */
74
+ insertPosition?: ['before', 'BeginningOfFile' | RegExp] | ['after', 'EndOfFile' | RegExp];
75
+ /**
76
+ * Block target state
77
+ */
78
+ state?: 'present' | 'absent';
79
+ }
80
+ /**
81
+ * Replace asynchronously a block in file that follows pattern :
82
+ *
83
+ * marker(markerBegin)
84
+ * ...
85
+ * marker(markerEnd)
86
+ *
87
+ * @param options
88
+ */
89
+ declare function block(options: BlockOptions): Promise<void>;
90
+ /**
91
+ * Replace synchronously a block in file that follows pattern :
92
+ *
93
+ * marker(markerBegin)
94
+ * ...
95
+ * marker(markerEnd)
96
+ *
97
+ * @param options
98
+ */
99
+ declare function blockSync(options: BlockOptions): void;
100
+
101
+ interface FileOptions {
102
+ /**
103
+ * File path
104
+ */
105
+ readonly path: string;
106
+ /**
107
+ * File target state
108
+ */
109
+ readonly state: 'present' | 'absent';
110
+ /**
111
+ * File content mapping function
112
+ *
113
+ * @param content
114
+ */
115
+ readonly update?: (content: string) => string | undefined;
116
+ /**
117
+ * File encoding
118
+ */
119
+ readonly encoding?: BufferEncoding;
120
+ }
121
+ /**
122
+ * Ensure file is present/absent with content initialized or modified with `update
123
+ *
124
+ * @example
125
+ * ```ts
126
+ * await file({
127
+ * path: 'foo/bar',
128
+ * state: 'present',
129
+ * update: (content) => content + '_test', // This will append '_test' after current content
130
+ * })
131
+ * ```
132
+ *
133
+ * @param options
134
+ */
135
+ declare function file(options: FileOptions): Promise<void>;
136
+ /**
137
+ * Ensure file is present/absent with content initialized or modified with `update
138
+ *
139
+ * @example
140
+ * ```ts
141
+ * fileSync({
142
+ * path: 'foo/bar',
143
+ * state: 'present',
144
+ * update: (content) => content + '_test', // This will append '_test' after current content
145
+ * })
146
+ * ```
147
+ *
148
+ * @param options
149
+ */
150
+ declare function fileSync(options: FileOptions): void;
151
+
152
+ type JSONValue = null | number | string | boolean | JSONValue[] | {
153
+ [key: string]: JSONValue;
154
+ };
155
+ interface JSONOption<V = JSONValue> {
156
+ /**
157
+ * File path
158
+ */
159
+ readonly path: string;
160
+ /**
161
+ * File target state
162
+ */
163
+ readonly state: 'present' | 'absent';
164
+ /**
165
+ * File content mapping function
166
+ *
167
+ * @param content
168
+ */
169
+ readonly update?: (content: V | undefined) => V | undefined;
170
+ /**
171
+ * File encoding
172
+ */
173
+ readonly encoding?: BufferEncoding;
174
+ }
175
+ /**
176
+ * Ensure file is present/absent asynchronously with content value initialized or modified with `update`
177
+ *
178
+ * @param options
179
+ */
180
+ declare function json<Value>(options: JSONOption<Value>): Promise<void>;
181
+ /**
182
+ * Ensure file is present/absent synchronously with content value initialized or modified with `update`
183
+ *
184
+ * @param options
185
+ */
186
+ declare function jsonSync<Value>(options: JSONOption<Value>): void;
187
+
188
+ declare namespace Project {
189
+ /**
190
+ * A type of a file extension
191
+ */
192
+ type Extension = `.${string}`;
193
+ /**
194
+ * Object hash of all well-known file extension category to file extensions mapping
195
+ */
196
+ interface ExtensionRegistry {
197
+ graphql: readonly Extension[];
198
+ jpeg: readonly Extension[];
199
+ javascript: readonly Extension[];
200
+ javascriptreact: readonly Extension[];
201
+ typescript: readonly Extension[];
202
+ typescriptreact: readonly Extension[];
203
+ yaml: readonly Extension[];
204
+ }
205
+ /**
206
+ * A list of "vscode-like" language identifiers (i.e. "javascript", "javascriptreact")
207
+ */
208
+ type LanguageId = keyof ExtensionRegistry;
209
+ /**
210
+ * Supported ECMA version
211
+ *
212
+ * @example
213
+ * ```ts
214
+ * Project.ecmaVersion() // 2022
215
+ * ```
216
+ */
217
+ function ecmaVersion(): 2022;
218
+ /**
219
+ * Return a list of extensions
220
+ *
221
+ * @example
222
+ * ```ts
223
+ * Project.queryExtensions(['javascript']); // ['.js', '.cjs', ...]
224
+ * Project.queryExtensions(['typescript', 'typescriptreact']); // ['.ts', '.mts', ..., '.tsx']
225
+ * ```
226
+ *
227
+ * @param languages
228
+ */
229
+ function queryExtensions(languages: LanguageId[]): readonly Extension[];
230
+ /**
231
+ * Supported file extensions
232
+ *
233
+ * @example
234
+ * ```ts
235
+ * Project.sourceExtensions() // ['.ts', '.js', ...]
236
+ * ```
237
+ */
238
+ function sourceExtensions(): readonly `.${string}`[];
239
+ /**
240
+ * Resource file extensions
241
+ *
242
+ * @example
243
+ * ```ts
244
+ * Project.resourceExtensions() // ['.css', '.sass', ...]
245
+ * ```
246
+ */
247
+ function resourceExtensions(): readonly `.${string}`[];
248
+ /**
249
+ * Files and folders to always ignore
250
+ *
251
+ * @example
252
+ * ```ts
253
+ * IGNORED // ['node_modules/', 'build/', ...]
254
+ * ```
255
+ */
256
+ function ignored(): readonly string[];
257
+ /**
258
+ * Return a RegExp that will match any list of extensions
259
+ *
260
+ * @example
261
+ * ```ts
262
+ * Project.extensionsToMatcher(['.js', '.ts']) // RegExp = /(\.js|\.ts)$/
263
+ * ```
264
+ */
265
+ function extensionsToMatcher(extensions: readonly Extension[]): RegExp;
266
+ /**
267
+ * Return a glob matcher that will match any list of extensions
268
+ *
269
+ * @example
270
+ * ```ts
271
+ * Project.extensionsToGlob(['.js', '.ts']) // '*.+(js|ts)'
272
+ * ```
273
+ */
274
+ function extensionsToGlob(extensions: readonly Extension[]): string;
275
+ }
276
+
277
+ /**
278
+ * Project common scripts
279
+ */
280
+ declare const ProjectScript: {
281
+ readonly Build: "build";
282
+ readonly Clean: "clean";
283
+ readonly CodeAnalysis: "code-analysis";
284
+ readonly Coverage: "coverage";
285
+ readonly Develop: "develop";
286
+ readonly Docs: "docs";
287
+ readonly Format: "format";
288
+ readonly Install: "install";
289
+ readonly Lint: "lint";
290
+ readonly Prepare: "prepare";
291
+ readonly Release: "release";
292
+ readonly Rescue: "rescue";
293
+ readonly Spellcheck: "spellcheck";
294
+ readonly Test: "test";
295
+ readonly Validate: "validate";
296
+ };
297
+ type ProjectScript = (typeof ProjectScript)[keyof typeof ProjectScript];
298
+
299
+ export { type BlockOptions, type DirectoryOptions, ESLintConfig, type FileOptions, type JSONOption, type JSONValue, Project, ProjectScript, block, blockSync, directory, directorySync, file, fileSync, json, jsonSync };