js-dev-tool 1.0.7 → 1.0.9

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "js-dev-tool",
3
- "version": "1.0.7",
3
+ "version": "1.0.9",
4
4
  "bin": {
5
5
  "jstool": "tools.js"
6
6
  },
@@ -35,25 +35,19 @@ const wppHandlerV4 = ((renderer, cwd) => {
35
35
  };
36
36
  })(lib.renderLine, process.cwd());
37
37
  /** @type {TWebpackProgressHandler} */
38
- const wppHandlerV5 = ((renderer, cwd) => {
39
- const cwdLen = cwd.length;
38
+ const wppHandlerV5 = ((renderer/*, cwd*/) => {
39
+ const maxLen = 70;
40
40
  return (percentage, message, ...args) => {
41
41
  if (!message) {
42
42
  message = "- done -";
43
43
  }
44
44
  let pathOrPluginName = args.shift() || "";
45
- if (pathOrPluginName) {
46
- const x = pathOrPluginName.lastIndexOf(cwd) + 1;
47
- if (x > 0) {
48
- pathOrPluginName = pathOrPluginName.slice(x + cwdLen);
49
- }
50
- }
51
45
  renderer(
52
- `pct: ${(percentage * 100).toFixed(4)}%, process: [${message}]${pathOrPluginName ? `, info: [${pathOrPluginName}]` : ""}${args.length ? " - " : ""}${args.join(", ")}`,
46
+ `pct: ${(percentage * 100).toFixed(4)}%, process: [${message}]${pathOrPluginName ? `, info: [${pathOrPluginName}]` : ""}${args.length ? " - " : ""}${args[0]?.slice(args[0].length - maxLen) || ""}`,
53
47
  );
54
48
  percentage === 1 && console.log();
55
49
  };
56
- })(lib.renderLine, process.cwd());
50
+ })(lib.renderLine/*, process.cwd()*/);
57
51
  /** @type {boolean} */
58
52
  let checkedCache;
59
53
  /**
@@ -1,3 +1,3 @@
1
1
  {
2
- "version": "1.0.7"
2
+ "version": "1.0.9"
3
3
  }
package/tool-lib/cjbm.js CHANGED
@@ -76,8 +76,10 @@ const emitProcessCallback = (ext) => {
76
76
  * @param {string[]} sourceFiles
77
77
  */
78
78
  return (sourceFiles) => {
79
- if (sourceFiles && sourceFiles.length) {
80
- for (let i = 0, sourceFilesLen = sourceFiles.length; i < sourceFilesLen;) {
79
+ /** @type {number} */
80
+ let sourceFilesLen;
81
+ if (sourceFiles && (sourceFilesLen = sourceFiles.length)) {
82
+ for (let i = 0; i < sourceFilesLen;) {
81
83
  const sourceFile = sourceFiles[i++];
82
84
  const parsed = path.parse(sourceFile);
83
85
  if (parsed.ext !== `.${ext}`) {
@@ -118,12 +120,13 @@ module.exports = () => {
118
120
  },
119
121
  get help() {
120
122
  return `${this.taskName}
121
- ex - jstool -cmd cjbm [-root ./build | -basePath "./dist/esm,extra-tests/mini-semaphore"] [-ext js] [-targets "['core.js', 'object.js']"]
123
+ ex - jstool -cmd cjbm [-root ./build | -basePath "./dist/esm,extra-tests/mini-semaphore"] [-ext js] [-test /\\.js$/] [-targets "['core.js', 'object.js']"]
122
124
  note:
123
125
  root - Recursively searches for files.
124
126
  This option is useful, but if there are directories that need to be avoided, use the 'basePath' option
125
127
  basePath - can be "<path>,<path>,..." (array type arg)
126
128
  ext - specifies the module extension for import clauses. default is "js"
129
+ test - Any file extension can be specified. (The default is /\\.js$/)
127
130
  targets - specify this if you want to apply it only to a specific file.
128
131
  the file specified here should be directly under \`basePath\`!
129
132
  value must be array type arg, "['<path>', '<path>',...]" or "<path>,<path>,..."
package/tools.js CHANGED
@@ -49,6 +49,18 @@ const terserOptions = {
49
49
  quote_style: 3,
50
50
  },
51
51
  };
52
+ function getVersionRegex() {
53
+ const RE_SOURCE = String.raw`
54
+ "?version("\s*:\s*)?
55
+ \s"?
56
+ (\d+)\.(\d+)\.(\d+) # version section
57
+ ( # tag section
58
+ (?: -[A-Za-z0-9\-]+(?:\.[A-Za-z0-9\-]+)*)?
59
+ (?:\+[A-Za-z0-9\-]+(?:\.[A-Za-z0-9\-]+)*)?
60
+ )?"?
61
+ `;
62
+ return new RegExp(RE_SOURCE.replace(/\(\?\#[\s\S]*?(?<!\\)\)|(?<![\\])(?:\#\s*$|\#[\s\S]*?$)|\s+/gm, ""), "g");
63
+ }
52
64
  /**
53
65
  * @type {Record<string, TJSToolEntry>}
54
66
  */
@@ -96,7 +108,7 @@ const ToolFunctions = {
96
108
  let nextVersion;
97
109
  !isArray(pkgJsons) && (pkgJsons = [pkgJsons]);
98
110
  utils.fireReplace(
99
- /"?version("\s*:\s*)?\s"?(\d+)\.(\d+)\.(\d+)(-\w+)?"?/,
111
+ getVersionRegex(),
100
112
  /** @type {TStringReplacer} */($0, isJson, $major, $minor, $patch, tag) => {
101
113
  /** @type {string | number} */
102
114
  let _major = $major;
@@ -115,8 +127,8 @@ const ToolFunctions = {
115
127
  } else {
116
128
  _patch = +_patch + 1;
117
129
  }
118
- currentVersion = `${$major}.${$minor}.${$patch}${tag ? tag : ""}`;
119
- nextVersion = `${_major}.${_minor}.${_patch}${tag ? tag : ""}`;
130
+ currentVersion = `${$major}.${$minor}.${$patch}${tag || ""}`;
131
+ nextVersion = `${_major}.${_minor}.${_patch}${tag || ""}`;
120
132
  return isJson ? `"version": "${nextVersion}"` : `version ${nextVersion}`;
121
133
  },
122
134
  pkgJsons,
@@ -127,7 +139,9 @@ const ToolFunctions = {
127
139
  ? [params.extras]
128
140
  : [];
129
141
  if (paths.length) {
130
- utils.fireReplace(/(v)?(\d+\.\d+\.\d+)(?:-\w+)?/g, /** @type {TStringReplacer} */($0, $prefix, $versionStr) => {
142
+ utils.fireReplace(
143
+ /(v)?(\d+\.\d+\.\d+(?:[^\s"]+)?)/g,
144
+ /** @type {TStringReplacer} */($0, $prefix, $versionStr) => {
131
145
  if ($versionStr === currentVersion && $prefix) {
132
146
  return "v" + nextVersion;
133
147
  }