js-dev-tool 1.0.7 → 1.0.8

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.8",
4
4
  "bin": {
5
5
  "jstool": "tools.js"
6
6
  },
@@ -1,3 +1,3 @@
1
1
  {
2
- "version": "1.0.7"
2
+ "version": "1.0.8"
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}`) {
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
  }