cli-argv-util 1.5.1 → 1.5.3

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.3 ~~ 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;
@@ -41,6 +49,7 @@ declare const cliArgvUtil: {
41
49
  }, posix: string): NonSharedBuffer;
42
50
  readFolder(folder: string): string[];
43
51
  cleanPath(name: string): string;
52
+ colorizePath(pathname: string): string;
44
53
  calcAncestor(sourceFile: string, targetFile: string): Ancestor;
45
54
  unquoteArgs(args: string[]): string[];
46
55
  };
@@ -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.3 ~~ 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.3',
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
  },
@@ -93,6 +94,9 @@ const cliArgvUtil = {
93
94
  cleanPath(name) {
94
95
  return slash(path.normalize(name)).trim().replace(/\/$/, '');
95
96
  },
97
+ colorizePath(pathname) {
98
+ return chalk.green(path.dirname(pathname) + '/') + chalk.white(path.basename(pathname));
99
+ },
96
100
  calcAncestor(sourceFile, targetFile) {
97
101
  const index = Array.from(sourceFile).findIndex((char, i) => targetFile[i] !== char);
98
102
  const substr = index === -1 ? sourceFile : sourceFile.substring(0, index);
@@ -100,13 +104,19 @@ const cliArgvUtil = {
100
104
  const len = common.length ? common.length + 1 : 0;
101
105
  const source = sourceFile.substring(len);
102
106
  const target = targetFile.substring(len);
103
- const intro = common ? chalk.blue(common) + chalk.gray.bold(': ') : '';
104
107
  const renamed = path.basename(sourceFile) !== path.basename(targetFile);
105
108
  const filename = renamed ? null : path.basename(sourceFile);
106
109
  const folder = path.dirname(target);
107
110
  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 };
111
+ const color = {
112
+ common: common ? chalk.blue(common) + chalk.gray.bold(': ') : '',
113
+ source: chalk.white(source),
114
+ arrow: chalk.gray.bold('→'),
115
+ target: chalk.green(dest),
116
+ };
117
+ const output = `${color.source} ${color.arrow} ${color.target}`;
118
+ const message = color.common + output;
119
+ return { common, source, target, renamed, filename, output, message, color };
110
120
  },
111
121
  unquoteArgs(args) {
112
122
  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.3",
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.6",
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
  }