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 +1 -1
- package/scripts/publish-version.json +1 -1
- package/tool-lib/cjbm.js +4 -2
- package/tools.js +18 -4
package/package.json
CHANGED
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
|
-
|
|
80
|
-
|
|
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
|
-
|
|
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
|
|
119
|
-
nextVersion = `${_major}.${_minor}.${_patch}${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(
|
|
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
|
}
|