@w5s/dev 3.1.4 → 3.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -1,411 +1,589 @@
1
- 'use strict';
2
-
3
- var fs = require('fs');
4
- var promises = require('fs/promises');
5
- var child_process = require('child_process');
6
-
7
- // src/directory.ts
8
- async function exists(path) {
9
- try {
10
- await promises.access(path, promises.constants.F_OK);
11
- return true;
12
- } catch {
13
- return false;
14
- }
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ let node_fs = require("node:fs");
3
+ let node_fs_promises = require("node:fs/promises");
4
+ let node_child_process = require("node:child_process");
5
+ //#region src/directory.ts
6
+ async function exists$1(path) {
7
+ try {
8
+ await (0, node_fs_promises.access)(path, node_fs_promises.constants.F_OK);
9
+ return true;
10
+ } catch {
11
+ return false;
12
+ }
15
13
  }
14
+ /**
15
+ * Ensure directory is present/absent
16
+ *
17
+ * @example
18
+ * ```ts
19
+ * await directory({
20
+ * path: 'foo/bar',
21
+ * state: 'present',
22
+ * })
23
+ * ```
24
+ *
25
+ * @param options
26
+ */
16
27
  async function directory(options) {
17
- const { path, state } = options;
18
- const isPresent = await exists(path);
19
- if (state === "present") {
20
- if (!isPresent) {
21
- await promises.mkdir(path, { recursive: true });
22
- }
23
- } else if (isPresent) {
24
- await promises.rm(path, { recursive: true });
25
- }
28
+ const { path, state } = options;
29
+ const isPresent = await exists$1(path);
30
+ if (state === "present") {
31
+ if (!isPresent) await (0, node_fs_promises.mkdir)(path, { recursive: true });
32
+ } else if (isPresent) await (0, node_fs_promises.rm)(path, { recursive: true });
26
33
  }
34
+ /**
35
+ * Ensure directory is present/absent
36
+ *
37
+ * @example
38
+ * ```ts
39
+ * await directorySync({
40
+ * path: 'foo/bar',
41
+ * state: 'present',
42
+ * })
43
+ * ```
44
+ *
45
+ * @param options
46
+ */
27
47
  function directorySync(options) {
28
- const { path, state } = options;
29
- const isPresent = fs.existsSync(path);
30
- if (state === "present") {
31
- if (!isPresent) {
32
- fs.mkdirSync(path, { recursive: true });
33
- }
34
- } else if (isPresent) {
35
- fs.rmSync(path, { recursive: true });
36
- }
48
+ const { path, state } = options;
49
+ const isPresent = (0, node_fs.existsSync)(path);
50
+ if (state === "present") {
51
+ if (!isPresent) (0, node_fs.mkdirSync)(path, { recursive: true });
52
+ } else if (isPresent) (0, node_fs.rmSync)(path, { recursive: true });
37
53
  }
38
-
39
- // src/ESLintConfig.ts
54
+ //#endregion
55
+ //#region src/ESLintConfig.ts
40
56
  function toArray(value) {
41
- if (value == null) {
42
- return [];
43
- }
44
- if (Array.isArray(value)) {
45
- return value;
46
- }
47
- return [value];
57
+ if (value == null) return [];
58
+ if (Array.isArray(value)) return value;
59
+ return [value];
48
60
  }
49
61
  function concatArray(left, right) {
50
- return [...toArray(left), ...toArray(right)];
62
+ return [...toArray(left), ...toArray(right)];
51
63
  }
52
- exports.ESLintConfig = void 0;
53
- ((ESLintConfig2) => {
54
- function concat(...configs) {
55
- return configs.reduce(
56
- (returnValue, config) => ({
57
- ...returnValue,
58
- ...config,
59
- env: { ...returnValue.env, ...config.env },
60
- extends: concatArray(returnValue.extends, config.extends),
61
- globals: { ...returnValue.globals, ...config.globals },
62
- overrides: concatArray(returnValue.overrides, config.overrides),
63
- parserOptions: { ...returnValue.parserOptions, ...config.parserOptions },
64
- plugins: concatArray(returnValue.plugins, config.plugins),
65
- rules: { ...returnValue.rules, ...config.rules },
66
- settings: { ...returnValue.settings, ...config.settings }
67
- }),
68
- {
69
- env: {},
70
- extends: [],
71
- globals: {},
72
- overrides: [],
73
- parserOptions: {},
74
- plugins: [],
75
- rules: {},
76
- settings: {}
77
- }
78
- );
79
- }
80
- ESLintConfig2.concat = concat;
81
- function fixme(_status) {
82
- return "off";
83
- }
84
- ESLintConfig2.fixme = fixme;
85
- function renameRules(rules, map) {
86
- return Object.fromEntries(
87
- Object.entries(rules).map(([key, value]) => {
88
- for (const [from, to] of Object.entries(map)) {
89
- if (key.startsWith(`${from}/`)) return [to + key.slice(from.length), value];
90
- else if (from === "" && !key.includes("/") && to !== "") return [to + key, value];
91
- }
92
- return [key, value];
93
- })
94
- );
95
- }
96
- ESLintConfig2.renameRules = renameRules;
97
- })(exports.ESLintConfig || (exports.ESLintConfig = {}));
98
- async function exists2(path) {
99
- try {
100
- await promises.access(path, fs.constants.F_OK);
101
- return true;
102
- } catch {
103
- return false;
104
- }
64
+ let ESLintConfig;
65
+ (function(_ESLintConfig) {
66
+ function concat(...configs) {
67
+ return configs.reduce((returnValue, config) => ({
68
+ ...returnValue,
69
+ ...config,
70
+ env: {
71
+ ...returnValue.env,
72
+ ...config.env
73
+ },
74
+ extends: concatArray(returnValue.extends, config.extends),
75
+ globals: {
76
+ ...returnValue.globals,
77
+ ...config.globals
78
+ },
79
+ overrides: concatArray(returnValue.overrides, config.overrides),
80
+ parserOptions: {
81
+ ...returnValue.parserOptions,
82
+ ...config.parserOptions
83
+ },
84
+ plugins: concatArray(returnValue.plugins, config.plugins),
85
+ rules: {
86
+ ...returnValue.rules,
87
+ ...config.rules
88
+ },
89
+ settings: {
90
+ ...returnValue.settings,
91
+ ...config.settings
92
+ }
93
+ }), {
94
+ env: {},
95
+ extends: [],
96
+ globals: {},
97
+ overrides: [],
98
+ parserOptions: {},
99
+ plugins: [],
100
+ rules: {},
101
+ settings: {}
102
+ });
103
+ }
104
+ _ESLintConfig.concat = concat;
105
+ function fixme(_status) {
106
+ return "off";
107
+ }
108
+ _ESLintConfig.fixme = fixme;
109
+ function renameRules(rules, map) {
110
+ return Object.fromEntries(Object.entries(rules).map(([key, value]) => {
111
+ for (const [from, to] of Object.entries(map)) if (key.startsWith(`${from}/`)) return [to + key.slice(from.length), value];
112
+ else if (from === "" && !key.includes("/") && to !== "") return [to + key, value];
113
+ return [key, value];
114
+ }));
115
+ }
116
+ _ESLintConfig.renameRules = renameRules;
117
+ })(ESLintConfig || (ESLintConfig = {}));
118
+ //#endregion
119
+ //#region src/file.ts
120
+ async function exists(path) {
121
+ try {
122
+ await (0, node_fs_promises.access)(path, node_fs.constants.F_OK);
123
+ return true;
124
+ } catch {
125
+ return false;
126
+ }
105
127
  }
106
- function existsSync2(path) {
107
- try {
108
- fs.accessSync(path, fs.constants.F_OK);
109
- return true;
110
- } catch {
111
- return false;
112
- }
128
+ function existsSync(path) {
129
+ try {
130
+ (0, node_fs.accessSync)(path, node_fs.constants.F_OK);
131
+ return true;
132
+ } catch {
133
+ return false;
134
+ }
113
135
  }
136
+ /**
137
+ * Ensure file is present/absent with content initialized or modified with `update
138
+ *
139
+ * @example
140
+ * ```ts
141
+ * await file({
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
+ */
114
150
  async function file(options) {
115
- const { path, state, update, encoding = "utf8" } = options;
116
- if (state === "present") {
117
- const isPresent = await exists2(path);
118
- const previousContent = isPresent ? await promises.readFile(path, encoding) : "";
119
- const newContent = update == null ? "" : update(previousContent);
120
- if (newContent != null) {
121
- await promises.writeFile(path, newContent, encoding);
122
- }
123
- } else {
124
- await promises.rm(path, { force: true });
125
- }
151
+ const { path, state, update, encoding = "utf8" } = options;
152
+ if (state === "present") {
153
+ const previousContent = await exists(path) ? await (0, node_fs_promises.readFile)(path, encoding) : "";
154
+ const newContent = update == null ? "" : update(previousContent);
155
+ if (newContent != null) await (0, node_fs_promises.writeFile)(path, newContent, encoding);
156
+ } else await (0, node_fs_promises.rm)(path, { force: true });
126
157
  }
158
+ /**
159
+ * Ensure file is present/absent with content initialized or modified with `update
160
+ *
161
+ * @example
162
+ * ```ts
163
+ * fileSync({
164
+ * path: 'foo/bar',
165
+ * state: 'present',
166
+ * update: (content) => content + '_test', // This will append '_test' after current content
167
+ * })
168
+ * ```
169
+ *
170
+ * @param options
171
+ */
127
172
  function fileSync(options) {
128
- const { path, state, update, encoding = "utf8" } = options;
129
- if (state === "present") {
130
- const isPresent = existsSync2(path);
131
- const previousContent = isPresent ? fs.readFileSync(path, encoding) : "";
132
- const newContent = update == null ? "" : update(previousContent);
133
- if (newContent != null) {
134
- fs.writeFileSync(path, newContent, encoding);
135
- }
136
- } else {
137
- fs.rmSync(path, { force: true });
138
- }
173
+ const { path, state, update, encoding = "utf8" } = options;
174
+ if (state === "present") {
175
+ const previousContent = existsSync(path) ? (0, node_fs.readFileSync)(path, encoding) : "";
176
+ const newContent = update == null ? "" : update(previousContent);
177
+ if (newContent != null) (0, node_fs.writeFileSync)(path, newContent, encoding);
178
+ } else (0, node_fs.rmSync)(path, { force: true });
139
179
  }
140
-
141
- // src/block.ts
142
- var EOF = "EndOfFile";
143
- var BOF = "BeginningOfFile";
144
- var insertAt = (str, index, toInsert) => str.slice(0, index) + toInsert + str.slice(index);
145
- var matchLast = (string, regexp) => {
146
- const matcher = new RegExp(regexp.source, `${regexp.flags}g`);
147
- let firstIndex = -1;
148
- let lastIndex = -1;
149
- let matches;
150
- while (true) {
151
- matches = matcher.exec(string);
152
- if (matches == null) {
153
- break;
154
- }
155
- firstIndex = matches.index;
156
- lastIndex = matcher.lastIndex;
157
- }
158
- return { firstIndex, lastIndex };
180
+ //#endregion
181
+ //#region src/block.ts
182
+ const EOF = "EndOfFile";
183
+ const BOF = "BeginningOfFile";
184
+ const insertAt = (str, index, toInsert) => str.slice(0, index) + toInsert + str.slice(index);
185
+ const matchLast = (string, regexp) => {
186
+ const matcher = new RegExp(regexp.source, `${regexp.flags}g`);
187
+ let firstIndex = -1;
188
+ let lastIndex = -1;
189
+ let matches;
190
+ while (true) {
191
+ matches = matcher.exec(string);
192
+ if (matches == null) break;
193
+ firstIndex = matches.index;
194
+ lastIndex = matcher.lastIndex;
195
+ }
196
+ return {
197
+ firstIndex,
198
+ lastIndex
199
+ };
159
200
  };
160
201
  function toFileOptions(options) {
161
- const {
162
- marker = (mark) => `# ${mark.toUpperCase()} MANAGED BLOCK`,
163
- path,
164
- block: blockName,
165
- insertPosition = ["after", EOF],
166
- state = "present"
167
- } = options;
168
- const EOL = "\n";
169
- const beginBlock = marker("Begin");
170
- const endBlock = marker("End");
171
- function findBlock(content) {
172
- const startIndex = content.indexOf(beginBlock);
173
- const endIndex = content.indexOf(endBlock) + endBlock.length;
174
- return {
175
- endIndex,
176
- exists: startIndex !== -1 && endIndex >= 0,
177
- startIndex
178
- };
179
- }
180
- function apply(fullContent, blockContent) {
181
- const found = findBlock(fullContent);
182
- const remove = state === "absent";
183
- const replaceBlock = remove ? "" : beginBlock + EOL + blockContent + EOL + endBlock;
184
- const [positionDirection, positionAnchor] = insertPosition;
185
- if (found.exists) {
186
- return fullContent.slice(0, found.startIndex) + replaceBlock + fullContent.slice(found.endIndex);
187
- }
188
- if (remove) {
189
- return fullContent;
190
- }
191
- switch (positionDirection) {
192
- case "before": {
193
- if (positionAnchor !== BOF) {
194
- const { firstIndex } = matchLast(fullContent, positionAnchor);
195
- if (firstIndex >= 0) {
196
- return insertAt(fullContent, firstIndex, replaceBlock + EOL);
197
- }
198
- }
199
- return replaceBlock + EOL + fullContent;
200
- }
201
- case "after": {
202
- if (positionAnchor !== EOF) {
203
- const { lastIndex } = matchLast(fullContent, positionAnchor);
204
- if (lastIndex >= 0) {
205
- return insertAt(fullContent, lastIndex, EOL + replaceBlock);
206
- }
207
- }
208
- return fullContent + EOL + replaceBlock;
209
- }
210
- default: {
211
- throw new Error(`Unsupported position ${String(positionDirection)}`);
212
- }
213
- }
214
- }
215
- return {
216
- path,
217
- state: "present",
218
- update: (sourceContent) => apply(sourceContent, blockName)
219
- };
202
+ const { marker = (mark) => `# ${mark.toUpperCase()} MANAGED BLOCK`, path, block: blockName, insertPosition = ["after", EOF], state = "present" } = options;
203
+ const EOL = "\n";
204
+ const beginBlock = marker("Begin");
205
+ const endBlock = marker("End");
206
+ /**
207
+ * @param content
208
+ */
209
+ function findBlock(content) {
210
+ const startIndex = content.indexOf(beginBlock);
211
+ const endIndex = content.indexOf(endBlock) + endBlock.length;
212
+ return {
213
+ endIndex,
214
+ exists: startIndex !== -1 && endIndex >= 0,
215
+ startIndex
216
+ };
217
+ }
218
+ function apply(fullContent, blockContent) {
219
+ const found = findBlock(fullContent);
220
+ const remove = state === "absent";
221
+ const replaceBlock = remove ? "" : beginBlock + EOL + blockContent + EOL + endBlock;
222
+ const [positionDirection, positionAnchor] = insertPosition;
223
+ if (found.exists) return fullContent.slice(0, found.startIndex) + replaceBlock + fullContent.slice(found.endIndex);
224
+ if (remove) return fullContent;
225
+ switch (positionDirection) {
226
+ case "before":
227
+ if (positionAnchor !== BOF) {
228
+ const { firstIndex } = matchLast(fullContent, positionAnchor);
229
+ if (firstIndex >= 0) return insertAt(fullContent, firstIndex, replaceBlock + EOL);
230
+ }
231
+ return replaceBlock + EOL + fullContent;
232
+ case "after":
233
+ if (positionAnchor !== EOF) {
234
+ const { lastIndex } = matchLast(fullContent, positionAnchor);
235
+ if (lastIndex >= 0) return insertAt(fullContent, lastIndex, EOL + replaceBlock);
236
+ }
237
+ return fullContent + EOL + replaceBlock;
238
+ default: throw new Error(`Unsupported position ${String(positionDirection)}`);
239
+ }
240
+ }
241
+ return {
242
+ path,
243
+ state: "present",
244
+ update: (sourceContent) => apply(sourceContent, blockName)
245
+ };
220
246
  }
247
+ /**
248
+ * Replace asynchronously a block in file that follows pattern :
249
+ *
250
+ * marker(markerBegin)
251
+ * ...
252
+ * marker(markerEnd)
253
+ *
254
+ * @param options
255
+ */
221
256
  function block(options) {
222
- return file(toFileOptions(options));
257
+ return file(toFileOptions(options));
223
258
  }
259
+ /**
260
+ * Replace synchronously a block in file that follows pattern :
261
+ *
262
+ * marker(markerBegin)
263
+ * ...
264
+ * marker(markerEnd)
265
+ *
266
+ * @param options
267
+ */
224
268
  function blockSync(options) {
225
- return fileSync(toFileOptions(options));
269
+ return fileSync(toFileOptions(options));
226
270
  }
227
-
228
- // src/interopDefault.ts
229
- var getDefaultOrElse = (_) => _?.default ?? _;
271
+ //#endregion
272
+ //#region src/interopDefault.ts
273
+ const getDefaultOrElse = (_) => _?.default ?? _;
230
274
  function interopDefault(m) {
231
- return m != null && typeof m.then === "function" ? Promise.resolve(m).then(getDefaultOrElse) : getDefaultOrElse(m);
275
+ return m != null && typeof m.then === "function" ? Promise.resolve(m).then(getDefaultOrElse) : getDefaultOrElse(m);
232
276
  }
233
-
234
- // src/json.ts
277
+ //#endregion
278
+ //#region src/json.ts
235
279
  function toFileOption({ update, ...otherOptions }) {
236
- return {
237
- ...otherOptions,
238
- update: update == null ? update : (content) => {
239
- const jsonValue = content === "" ? void 0 : JSON.parse(content);
240
- return JSON.stringify(update(jsonValue));
241
- }
242
- };
280
+ return {
281
+ ...otherOptions,
282
+ update: update == null ? update : (content) => {
283
+ const jsonValue = content === "" ? void 0 : JSON.parse(content);
284
+ return JSON.stringify(update(jsonValue));
285
+ }
286
+ };
243
287
  }
288
+ /**
289
+ * Ensure file is present/absent asynchronously with content value initialized or modified with `update`
290
+ *
291
+ * @param options
292
+ */
244
293
  async function json(options) {
245
- return file(toFileOption(options));
294
+ return file(toFileOption(options));
246
295
  }
296
+ /**
297
+ * Ensure file is present/absent synchronously with content value initialized or modified with `update`
298
+ *
299
+ * @param options
300
+ */
247
301
  function jsonSync(options) {
248
- return fileSync(toFileOption(options));
302
+ return fileSync(toFileOption(options));
249
303
  }
250
-
251
- // src/Project.ts
304
+ //#endregion
305
+ //#region src/meta.ts
306
+ const meta = Object.freeze({
307
+ name: "@w5s/dev",
308
+ version: "3.2.1",
309
+ buildNumber: 1
310
+ });
311
+ //#endregion
312
+ //#region src/Project.ts
252
313
  function escapeRegExp(value) {
253
- return value.replaceAll(/[$()*+.?[\\\]^{|}]/g, "\\$&");
314
+ return value.replaceAll(/[$()*+.?[\\\]^{|}]/g, "\\$&");
254
315
  }
255
- exports.Project = void 0;
256
- ((Project2) => {
257
- function ecmaVersion() {
258
- return 2022;
259
- }
260
- Project2.ecmaVersion = ecmaVersion;
261
- const registry = {
262
- css: [".css"],
263
- graphql: [".gql", ".graphql"],
264
- javascript: [".js", ".cjs", ".mjs"],
265
- javascriptreact: [".jsx"],
266
- jpeg: [".jpg", ".jpeg"],
267
- json: [".json"],
268
- jsonc: [".jsonc"],
269
- less: [".less"],
270
- markdown: [".markdown", ".mdown", ".mkd", ".md"],
271
- sass: [".sass"],
272
- scss: [".scss"],
273
- typescript: [".ts", ".cts", ".mts"],
274
- typescriptreact: [".tsx"],
275
- vue: [".vue"],
276
- yaml: [".yaml", ".yml"]
277
- };
278
- function queryExtensions(languages) {
279
- return languages.reduce((previousValue, currentValue) => (
280
- // eslint-disable-next-line unicorn/prefer-spread
281
- previousValue.concat(registry[currentValue] ?? [])
282
- ), []).sort();
283
- }
284
- Project2.queryExtensions = queryExtensions;
285
- function sourceExtensions() {
286
- return queryExtensions(["javascript", "javascriptreact", "typescript", "typescriptreact"]);
287
- }
288
- Project2.sourceExtensions = sourceExtensions;
289
- const RESOURCE_EXTENSIONS = Object.freeze([
290
- ".gif",
291
- ".png",
292
- ".svg",
293
- ...queryExtensions(["css", "graphql", "jpeg", "less", "sass", "sass", "yaml"])
294
- ]);
295
- function resourceExtensions() {
296
- return RESOURCE_EXTENSIONS;
297
- }
298
- Project2.resourceExtensions = resourceExtensions;
299
- const IGNORED = Object.freeze([
300
- "node_modules/",
301
- "build/",
302
- "cjs/",
303
- "coverage/",
304
- "dist/",
305
- "dts/",
306
- "esm/",
307
- "lib/",
308
- "mjs/",
309
- "umd/"
310
- ]);
311
- function ignored() {
312
- return IGNORED;
313
- }
314
- Project2.ignored = ignored;
315
- function extensionsToMatcher(extensions) {
316
- return new RegExp(`(${extensions.map(escapeRegExp).join("|")})$`);
317
- }
318
- Project2.extensionsToMatcher = extensionsToMatcher;
319
- function extensionsToGlob(extensions) {
320
- return `*.+(${extensions.map((_) => _.replace(/^\./, "")).join("|")})`;
321
- }
322
- Project2.extensionsToGlob = extensionsToGlob;
323
- })(exports.Project || (exports.Project = {}));
324
-
325
- // src/ProjectScript.ts
326
- var ProjectScript = {
327
- Build: "build",
328
- Clean: "clean",
329
- CodeAnalysis: "code-analysis",
330
- Coverage: "coverage",
331
- Develop: "develop",
332
- Docs: "docs",
333
- Format: "format",
334
- Install: "install",
335
- Lint: "lint",
336
- Prepare: "prepare",
337
- Release: "release",
338
- Rescue: "rescue",
339
- Spellcheck: "spellcheck",
340
- Test: "test",
341
- Validate: "validate"
316
+ let Project;
317
+ (function(_Project) {
318
+ function ecmaVersion() {
319
+ return 2022;
320
+ }
321
+ _Project.ecmaVersion = ecmaVersion;
322
+ const registry = {
323
+ css: [".css"],
324
+ graphql: [".gql", ".graphql"],
325
+ javascript: [
326
+ ".js",
327
+ ".cjs",
328
+ ".mjs"
329
+ ],
330
+ javascriptreact: [".jsx"],
331
+ jpeg: [".jpg", ".jpeg"],
332
+ json: [".json"],
333
+ jsonc: [".jsonc"],
334
+ less: [".less"],
335
+ markdown: [
336
+ ".markdown",
337
+ ".mdown",
338
+ ".mkd",
339
+ ".md"
340
+ ],
341
+ sass: [".sass"],
342
+ scss: [".scss"],
343
+ typescript: [
344
+ ".ts",
345
+ ".cts",
346
+ ".mts"
347
+ ],
348
+ typescriptreact: [".tsx"],
349
+ vue: [".vue"],
350
+ yaml: [".yaml", ".yml"]
351
+ };
352
+ function queryExtensions(languages) {
353
+ return languages.reduce((previousValue, currentValue) => previousValue.concat(registry[currentValue] ?? []), []).sort();
354
+ }
355
+ _Project.queryExtensions = queryExtensions;
356
+ function sourceExtensions() {
357
+ return queryExtensions([
358
+ "javascript",
359
+ "javascriptreact",
360
+ "typescript",
361
+ "typescriptreact"
362
+ ]);
363
+ }
364
+ _Project.sourceExtensions = sourceExtensions;
365
+ const RESOURCE_EXTENSIONS = Object.freeze([
366
+ ".gif",
367
+ ".png",
368
+ ".svg",
369
+ ...queryExtensions([
370
+ "css",
371
+ "graphql",
372
+ "jpeg",
373
+ "less",
374
+ "sass",
375
+ "sass",
376
+ "yaml"
377
+ ])
378
+ ]);
379
+ function resourceExtensions() {
380
+ return RESOURCE_EXTENSIONS;
381
+ }
382
+ _Project.resourceExtensions = resourceExtensions;
383
+ const IGNORED = Object.freeze([
384
+ "node_modules/",
385
+ "build/",
386
+ "cjs/",
387
+ "coverage/",
388
+ "dist/",
389
+ "dts/",
390
+ "esm/",
391
+ "lib/",
392
+ "mjs/",
393
+ "umd/"
394
+ ]);
395
+ function ignored() {
396
+ return IGNORED;
397
+ }
398
+ _Project.ignored = ignored;
399
+ function extensionsToMatcher(extensions) {
400
+ return new RegExp(`(${extensions.map(escapeRegExp).join("|")})$`);
401
+ }
402
+ _Project.extensionsToMatcher = extensionsToMatcher;
403
+ function extensionsToGlob(extensions) {
404
+ return `*.+(${extensions.map((_) => _.replace(/^\./, "")).join("|")})`;
405
+ }
406
+ _Project.extensionsToGlob = extensionsToGlob;
407
+ })(Project || (Project = {}));
408
+ //#endregion
409
+ //#region src/ProjectScript.ts
410
+ /**
411
+ * Project common scripts
412
+ */
413
+ const ProjectScript = {
414
+ Build: "build",
415
+ Clean: "clean",
416
+ CodeAnalysis: "code-analysis",
417
+ Coverage: "coverage",
418
+ Develop: "develop",
419
+ Docs: "docs",
420
+ Format: "format",
421
+ Install: "install",
422
+ Lint: "lint",
423
+ Prepare: "prepare",
424
+ Release: "release",
425
+ Rescue: "rescue",
426
+ Spellcheck: "spellcheck",
427
+ Test: "test",
428
+ Validate: "validate"
342
429
  };
430
+ //#endregion
431
+ //#region src/exec.ts
432
+ /**
433
+ * Runs a command in a shell and returns a promise that resolves with an object
434
+ * containing the stdout and stderr strings.
435
+ *
436
+ * @param command The command to run
437
+ * @param args The arguments to pass to the command
438
+ * @param options
439
+ * @returns A promise that resolves with an object like `{ stdout: string, stderr: string }`
440
+ */
343
441
  function execSync(command, args, options) {
344
- const result = child_process.spawnSync(command, args, { ...options });
345
- const encoding = "utf8";
346
- return { stdout: result.stdout.toString(encoding), stderr: result.stderr.toString(encoding) };
442
+ const result = (0, node_child_process.spawnSync)(command, args, { ...options });
443
+ const encoding = "utf8";
444
+ return {
445
+ stdout: result.stdout.toString(encoding),
446
+ stderr: result.stderr.toString(encoding)
447
+ };
347
448
  }
449
+ /**
450
+ * Runs a command in a shell and returns a promise that resolves with an object
451
+ * containing the stdout and stderr strings.
452
+ *
453
+ * @param command The command to run
454
+ * @param args The arguments to pass to the command
455
+ * @param options
456
+ */
348
457
  async function exec(command, args, options) {
349
- return new Promise((resolve, reject) => {
350
- const encoding = "utf8";
351
- const child = child_process.spawn(command, args, { ...options });
352
- let stdout = "";
353
- let stderr = "";
354
- if (child.stdout != null) {
355
- child.stdout.on("data", (data) => {
356
- stdout += data.toString(encoding);
357
- });
358
- }
359
- if (child.stderr != null) {
360
- child.stderr.on("data", (data) => {
361
- stderr += data.toString(encoding);
362
- });
363
- }
364
- child.on("close", (_code) => {
365
- resolve({ stdout, stderr });
366
- });
367
- child.on("error", reject);
368
- });
458
+ return new Promise((resolve, reject) => {
459
+ const encoding = "utf8";
460
+ const child = (0, node_child_process.spawn)(command, args, { ...options });
461
+ let stdout = "";
462
+ let stderr = "";
463
+ if (child.stdout != null) child.stdout.on("data", (data) => {
464
+ stdout += data.toString(encoding);
465
+ });
466
+ if (child.stderr != null) child.stderr.on("data", (data) => {
467
+ stderr += data.toString(encoding);
468
+ });
469
+ child.on("close", (_code) => {
470
+ resolve({
471
+ stdout,
472
+ stderr
473
+ });
474
+ });
475
+ child.on("error", reject);
476
+ });
369
477
  }
370
-
371
- // src/yarnConfig.ts
478
+ //#endregion
479
+ //#region src/yarnConfig.ts
480
+ /**
481
+ * Synchronous version of {@link yarnConfig}
482
+ *
483
+ * @param options
484
+ * @example
485
+ * yarnConfigSync({
486
+ * key: 'nodeLinker',
487
+ * state: 'present',
488
+ * update: (content) => content.replace('node-modules', 'hoisted'),
489
+ * })
490
+ */
372
491
  function yarnConfigSync(options) {
373
- const { key, state, update } = options;
374
- if (state === "present") {
375
- const { stdout } = execSync("yarn", ["config", "get", String(key)]);
376
- execSync("yarn", ["config", "set", String(key), `${update == null ? "" : update(stdout)}`]);
377
- } else {
378
- execSync("yarn", ["config", "unset"]);
379
- }
492
+ const { key, state, update } = options;
493
+ if (state === "present") {
494
+ const { stdout } = execSync("yarn", [
495
+ "config",
496
+ "get",
497
+ String(key)
498
+ ]);
499
+ execSync("yarn", [
500
+ "config",
501
+ "set",
502
+ String(key),
503
+ `${update == null ? "" : update(stdout)}`
504
+ ]);
505
+ } else execSync("yarn", ["config", "unset"]);
380
506
  }
507
+ /**
508
+ * Set/Unset yarn configuration value
509
+ *
510
+ * @param options
511
+ * @example
512
+ * await yarnConfig({
513
+ * key: 'nodeLinker',
514
+ * state: 'present',
515
+ * update: (content) => content.replace('node-modules', 'hoisted'),
516
+ * })
517
+ */
381
518
  async function yarnConfig(options) {
382
- const { key, state, update } = options;
383
- if (state === "present") {
384
- const { stdout } = await exec("yarn", ["config", "get", String(key)]);
385
- await exec("yarn", ["config", "set", String(key), `${update == null ? "" : update(stdout)}`]);
386
- } else {
387
- await exec("yarn", ["config", "unset"]);
388
- }
519
+ const { key, state, update } = options;
520
+ if (state === "present") {
521
+ const { stdout } = await exec("yarn", [
522
+ "config",
523
+ "get",
524
+ String(key)
525
+ ]);
526
+ await exec("yarn", [
527
+ "config",
528
+ "set",
529
+ String(key),
530
+ `${update == null ? "" : update(stdout)}`
531
+ ]);
532
+ } else await exec("yarn", ["config", "unset"]);
389
533
  }
390
-
391
- // src/yarnVersion.ts
534
+ //#endregion
535
+ //#region src/yarnVersion.ts
536
+ /**
537
+ * Synchronous version of {@link yarnVersion}
538
+ *
539
+ * @param options
540
+ * @example
541
+ * yarnVersionSync({
542
+ * state: 'present',
543
+ * update: () => 'berry', // or 'classic'
544
+ * })
545
+ */
392
546
  function yarnVersionSync(options) {
393
- const { state, update } = options;
394
- if (state === "present") {
395
- execSync("yarn", ["set", "version", `${update == null ? "berry" : update()}`]);
396
- } else {
397
- throw new Error("Not implemented");
398
- }
547
+ const { state, update } = options;
548
+ if (state === "present") execSync("yarn", [
549
+ "set",
550
+ "version",
551
+ `${update == null ? "berry" : update()}`
552
+ ]);
553
+ else throw new Error("Not implemented");
399
554
  }
555
+ /**
556
+ * Set/Unset yarn configuration value
557
+ *
558
+ * @param options
559
+ * @example
560
+ * await yarnVersion({
561
+ * state: 'present',
562
+ * update: () => 'berry', // or 'classic'
563
+ * })
564
+ */
400
565
  async function yarnVersion(options) {
401
- const { state, update } = options;
402
- if (state === "present") {
403
- await exec("yarn", ["set", "version", `${update == null ? "berry" : update()}`]);
404
- } else {
405
- throw new Error("Not implemented");
406
- }
566
+ const { state, update } = options;
567
+ if (state === "present") await exec("yarn", [
568
+ "set",
569
+ "version",
570
+ `${update == null ? "berry" : update()}`
571
+ ]);
572
+ else throw new Error("Not implemented");
407
573
  }
408
-
574
+ //#endregion
575
+ Object.defineProperty(exports, "ESLintConfig", {
576
+ enumerable: true,
577
+ get: function() {
578
+ return ESLintConfig;
579
+ }
580
+ });
581
+ Object.defineProperty(exports, "Project", {
582
+ enumerable: true,
583
+ get: function() {
584
+ return Project;
585
+ }
586
+ });
409
587
  exports.ProjectScript = ProjectScript;
410
588
  exports.block = block;
411
589
  exports.blockSync = blockSync;
@@ -416,9 +594,10 @@ exports.fileSync = fileSync;
416
594
  exports.interopDefault = interopDefault;
417
595
  exports.json = json;
418
596
  exports.jsonSync = jsonSync;
597
+ exports.meta = meta;
419
598
  exports.yarnConfig = yarnConfig;
420
599
  exports.yarnConfigSync = yarnConfigSync;
421
600
  exports.yarnVersion = yarnVersion;
422
601
  exports.yarnVersionSync = yarnVersionSync;
423
- //# sourceMappingURL=index.cjs.map
602
+
424
603
  //# sourceMappingURL=index.cjs.map