cli-argv-util 1.5.1 → 1.5.2

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/README.md CHANGED
@@ -84,17 +84,14 @@ See the **TypeScript Declarations** at the top of [cli-argv-util.ts](src/cli-arg
84
84
  <br>
85
85
 
86
86
  ---
87
- **CLI Build Tools for package.json**
88
- - 🎋 [add-dist-header](https://github.com/center-key/add-dist-header):&nbsp; _Prepend a one-line banner comment (with license notice) to distribution files_
89
- - 📄 [cli-argv-util](https://github.com/center-key/cli-argv-util):&nbsp; _Copy or rename a file with optional package version number_
90
- - 📂 [copy-folder-util](https://github.com/center-key/copy-folder-util):&nbsp; _Recursively copy files from one folder to another folder_
91
- - 🪺 [recursive-exec](https://github.com/center-key/recursive-exec):&nbsp; _Run a command on each file in a folder and its subfolders_
92
- - 🔍 [replacer-util](https://github.com/center-key/replacer-util):&nbsp; _Find and replace strings or template outputs in text files_
93
- - 🔢 [rev-web-assets](https://github.com/center-key/rev-web-assets):&nbsp; _Revision web asset filenames with cache busting content hash fingerprints_
94
- - 🚆 [run-scripts-util](https://github.com/center-key/run-scripts-util):&nbsp; _Organize npm package.json scripts into groups of easy to manage commands_
95
- - 🚦 [w3c-html-validator](https://github.com/center-key/w3c-html-validator):&nbsp; _Check the markup validity of HTML files using the W3C validator_
96
-
97
- Feel free to submit questions at:<br>
98
- [github.com/center-key/cli-argv-util/issues](https://github.com/center-key/cli-argv-util/issues)
99
-
100
87
  [MIT License](LICENSE.txt)
88
+
89
+ See the `runScriptsConfig` section of [`package.json`](package.json) for a clean way to organize build tasks:
90
+ - 🎋 [`add-dist-header`](https://github.com/center-key/add-dist-header) &mdash;&nbsp; _Prepend a one-line banner comment (with license notice) to distribution files_
91
+ - 📄 [`copy-file-util`](https://github.com/center-key/copy-file-util) &mdash;&nbsp; _Copy or rename a file with optional package version number_
92
+ - 📂 [`copy-folder-util`](https://github.com/center-key/copy-folder-util) &mdash;&nbsp; _Recursively copy files from one folder to another folder_
93
+ - 🪺 [`recursive-exec`](https://github.com/center-key/recursive-exec) &mdash;&nbsp; _Run a command on each file in a folder and its subfolders_
94
+ - 🔍 [`replacer-util`](https://github.com/center-key/replacer-util) &mdash;&nbsp; _Find and replace strings or template outputs in text files_
95
+ - 🔢 [`rev-web-assets`](https://github.com/center-key/rev-web-assets) &mdash;&nbsp; _Revision web asset filenames with cache busting content hash fingerprints_
96
+ - 🚆 [`run-scripts-util`](https://github.com/center-key/run-scripts-util) &mdash;&nbsp; _Organize npm package.json scripts into groups of easy-to-manage commands_
97
+ - 🚦 [`w3c-html-validator`](https://github.com/center-key/w3c-html-validator) &mdash;&nbsp; _Check the markup validity of HTML files using the W3C validator_
@@ -1,4 +1,4 @@
1
- //! cli-argv-util v1.5.1 ~~ https://github.com/center-key/cli-argv-util ~~ MIT License
1
+ //! cli-argv-util v1.5.2 ~~ https://github.com/center-key/cli-argv-util ~~ MIT License
2
2
 
3
3
  export type StringFlagMap = {
4
4
  [flag: string]: string | undefined;
@@ -12,7 +12,14 @@ export type Ancestor = {
12
12
  target: string;
13
13
  renamed: boolean;
14
14
  filename: string | null;
15
+ output: string;
15
16
  message: string;
17
+ color: {
18
+ common: string;
19
+ source: string;
20
+ arrow: string;
21
+ target: string;
22
+ };
16
23
  };
17
24
  export type Result = {
18
25
  flagMap: StringFlagMap;
@@ -28,7 +35,8 @@ type JsonObject = {
28
35
  [key: string]: Json;
29
36
  };
30
37
  declare const cliArgvUtil: {
31
- assert(ok: unknown, message: string | null): void;
38
+ version: string;
39
+ assertOk(ok: unknown, message: string | null): void;
32
40
  readPackageJson(): JsonObject;
33
41
  escapers: {
34
42
  regex: RegExp;
@@ -1,12 +1,13 @@
1
- //! cli-argv-util v1.5.1 ~~ https://github.com/center-key/cli-argv-util ~~ MIT License
1
+ //! cli-argv-util v1.5.2 ~~ https://github.com/center-key/cli-argv-util ~~ MIT License
2
2
 
3
3
  import { execSync } from 'node:child_process';
4
4
  import chalk from 'chalk';
5
- import fs from 'fs';
6
- import path from 'path';
5
+ import fs from 'node:fs';
6
+ import path from 'node:path';
7
7
  import slash from 'slash';
8
8
  const cliArgvUtil = {
9
- assert(ok, message) {
9
+ version: '1.5.2',
10
+ assertOk(ok, message) {
10
11
  if (!ok)
11
12
  throw new Error(`[replacer-util] ${message}`);
12
13
  },
@@ -51,7 +52,7 @@ const cliArgvUtil = {
51
52
  const macroValue = macros[macroName];
52
53
  const expandedText = macroName ? macroValue : text;
53
54
  const missing = macroName && !macroValue;
54
- cliArgvUtil.assert(!missing, `Macro "${macroName}" used but not defined in package.json`);
55
+ cliArgvUtil.assertOk(!missing, `Macro "${macroName}" used but not defined in package.json`);
55
56
  const replace = (flagValue, escaper) => flagValue.replace(escaper.regex, escaper.char);
56
57
  return cliArgvUtil.escapers.reduce(replace, expandedText);
57
58
  },
@@ -100,13 +101,19 @@ const cliArgvUtil = {
100
101
  const len = common.length ? common.length + 1 : 0;
101
102
  const source = sourceFile.substring(len);
102
103
  const target = targetFile.substring(len);
103
- const intro = common ? chalk.blue(common) + chalk.gray.bold(': ') : '';
104
104
  const renamed = path.basename(sourceFile) !== path.basename(targetFile);
105
105
  const filename = renamed ? null : path.basename(sourceFile);
106
106
  const folder = path.dirname(target);
107
107
  const dest = renamed ? target : (folder === '.' ? filename : folder + '/');
108
- const message = intro + chalk.white(source) + chalk.gray.bold(' → ') + chalk.green(dest);
109
- return { common, source, target, renamed, filename, message };
108
+ const color = {
109
+ common: common ? chalk.blue(common) + chalk.gray.bold(': ') : '',
110
+ source: chalk.white(source),
111
+ arrow: chalk.gray.bold('→'),
112
+ target: chalk.green(dest),
113
+ };
114
+ const output = `${color.source} ${color.arrow} ${color.target}`;
115
+ const message = color.common + output;
116
+ return { common, source, target, renamed, filename, output, message, color };
110
117
  },
111
118
  unquoteArgs(args) {
112
119
  const unquote = (builder, nextArg) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cli-argv-util",
3
- "version": "1.5.1",
3
+ "version": "1.5.2",
4
4
  "description": "Simple utility to parse command line parameters and flags (arguments vector)",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -64,16 +64,16 @@
64
64
  },
65
65
  "devDependencies": {
66
66
  "@eslint/js": "~10.0",
67
- "@types/node": "~25.5",
67
+ "@types/node": "~26.0",
68
68
  "add-dist-header": "~1.6",
69
69
  "assert-deep-strict-equal": "~1.2",
70
70
  "copy-file-util": "~1.3",
71
- "eslint": "~10.1",
71
+ "eslint": "~10.5",
72
72
  "jshint": "~2.13",
73
73
  "mocha": "~11.7",
74
74
  "rimraf": "~6.1",
75
75
  "run-scripts-util": "~1.3",
76
- "typescript": "~5.9",
77
- "typescript-eslint": "~8.57"
76
+ "typescript": "~6.0",
77
+ "typescript-eslint": "~8.62"
78
78
  }
79
79
  }