cross-bump 0.3.0 → 0.5.0
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/dist/{index.d.ts → index.d.mts} +0 -4
- package/dist/{index.js → index.mjs} +15 -27
- package/package.json +10 -10
|
@@ -16,7 +16,6 @@ declare function getGitignores(cwd?: string, ignoreGlobs?: string[]): Set<string
|
|
|
16
16
|
* @returns An array of glob patterns.
|
|
17
17
|
*/
|
|
18
18
|
declare function parseGitingore(content: string, gitignoreFilePath: string, projectRoot: string): string[];
|
|
19
|
-
|
|
20
19
|
//#endregion
|
|
21
20
|
//#region src/project.d.ts
|
|
22
21
|
declare const supportedProjectCategory: readonly ["java", "javascript", "rust"];
|
|
@@ -43,11 +42,9 @@ type ProjectFile = {
|
|
|
43
42
|
* @return An array of file paths that match the search criteria.
|
|
44
43
|
*/
|
|
45
44
|
declare function findProjectFiles(cwd?: string, ignore?: string[], recursive?: boolean): ProjectFile[];
|
|
46
|
-
|
|
47
45
|
//#endregion
|
|
48
46
|
//#region src/util.d.ts
|
|
49
47
|
declare function isBlankPath(path?: PathLike): path is "" | undefined;
|
|
50
|
-
|
|
51
48
|
//#endregion
|
|
52
49
|
//#region src/version.d.ts
|
|
53
50
|
type VersionNumbers = {
|
|
@@ -121,6 +118,5 @@ declare function upgradeCargoVersion(filePath: PathLike, version: string, opts?:
|
|
|
121
118
|
declare function upgradeProjectVersion(nextVersion: string, projectFile?: ProjectFile, opts?: UpgradeOptions): Promise<void>;
|
|
122
119
|
declare function getProjectVersion(projectFile: ProjectFile): Promise<string | undefined>;
|
|
123
120
|
declare function isVersionValid(version?: string): boolean;
|
|
124
|
-
|
|
125
121
|
//#endregion
|
|
126
122
|
export { DEFAULT_IGNORED_GLOBS, G_GITIGNORE, ProjectCategory, ProjectFile, ProjectFileName, findProjectFiles, getGitignores, getJSProjectVersion, getJavaProjectVersion, getNextVersions, getProjectVersion, getRustProjectVersion, isBlankPath, isVersionValid, parseGitingore, parseVersion, supportedProjectCategory, supportedProjectFiles, supportedProjectGlobs, upgradeCargoVersion, upgradePackageVersion, upgradePomVersion, upgradeProjectVersion };
|
|
@@ -24,10 +24,9 @@ function getGitignores(cwd, ignoreGlobs = DEFAULT_IGNORED_GLOBS) {
|
|
|
24
24
|
ignore: ignoreGlobs,
|
|
25
25
|
onlyFiles: true
|
|
26
26
|
});
|
|
27
|
-
const set = new Set();
|
|
27
|
+
const set = /* @__PURE__ */ new Set();
|
|
28
28
|
for (const gitignoreFilePath of gitignoreFiles) {
|
|
29
|
-
const
|
|
30
|
-
const globs = parseGitingore(rules, gitignoreFilePath, cwd = process.cwd());
|
|
29
|
+
const globs = parseGitingore(readFileSync(gitignoreFilePath, { encoding: "utf8" }), gitignoreFilePath, cwd = process.cwd());
|
|
31
30
|
if (globs.length === 0) continue;
|
|
32
31
|
for (const item of globs) set.add(item);
|
|
33
32
|
}
|
|
@@ -111,8 +110,8 @@ function parseGitingore(content, gitignoreFilePath, projectRoot) {
|
|
|
111
110
|
|
|
112
111
|
//#endregion
|
|
113
112
|
//#region src/util.ts
|
|
114
|
-
function isBlankPath(path
|
|
115
|
-
return path
|
|
113
|
+
function isBlankPath(path) {
|
|
114
|
+
return path === void 0 || path.toString().trim().length === 0;
|
|
116
115
|
}
|
|
117
116
|
|
|
118
117
|
//#endregion
|
|
@@ -144,14 +143,13 @@ const projectCategoryMap = {
|
|
|
144
143
|
function findProjectFiles(cwd, ignore = [], recursive = false) {
|
|
145
144
|
const files = [];
|
|
146
145
|
if (isBlankPath(cwd)) return files;
|
|
147
|
-
|
|
146
|
+
return fg.sync(supportedProjectGlobs, {
|
|
148
147
|
absolute: true,
|
|
149
148
|
cwd,
|
|
150
149
|
deep: recursive ? Infinity : 1,
|
|
151
150
|
fs,
|
|
152
151
|
ignore
|
|
153
|
-
})
|
|
154
|
-
return projectFiles.map((f) => ({
|
|
152
|
+
}).map((f) => ({
|
|
155
153
|
category: projectCategoryMap[path.basename(f)],
|
|
156
154
|
path: f
|
|
157
155
|
}));
|
|
@@ -185,16 +183,13 @@ function getNextVersions(version, coerce = false) {
|
|
|
185
183
|
const nextMinor = semver.inc(versionNum, "minor") ?? FALLBACK_VERSION;
|
|
186
184
|
const nextPatch = semver.inc(versionNum, "patch") ?? FALLBACK_VERSION;
|
|
187
185
|
const nextRelease = (id ? semver.inc(versionNum, "prerelease", id, "1") : semver.inc(versionNum, "patch")) ?? FALLBACK_VERSION;
|
|
188
|
-
const nextPreMajor = semver.inc(versionNum, "premajor", defaultId, "1") ?? FALLBACK_VERSION;
|
|
189
|
-
const nextPreMinor = semver.inc(versionNum, "preminor", defaultId, "1") ?? FALLBACK_VERSION;
|
|
190
|
-
const nextPrePatch = semver.inc(versionNum, "prepatch", defaultId, "1") ?? FALLBACK_VERSION;
|
|
191
186
|
return {
|
|
192
187
|
nextMajor,
|
|
193
188
|
nextMinor,
|
|
194
189
|
nextPatch,
|
|
195
|
-
nextPreMajor,
|
|
196
|
-
nextPreMinor,
|
|
197
|
-
nextPrePatch,
|
|
190
|
+
nextPreMajor: semver.inc(versionNum, "premajor", defaultId, "1") ?? FALLBACK_VERSION,
|
|
191
|
+
nextPreMinor: semver.inc(versionNum, "preminor", defaultId, "1") ?? FALLBACK_VERSION,
|
|
192
|
+
nextPrePatch: semver.inc(versionNum, "prepatch", defaultId, "1") ?? FALLBACK_VERSION,
|
|
198
193
|
nextRelease
|
|
199
194
|
};
|
|
200
195
|
}
|
|
@@ -225,9 +220,7 @@ function upgradePomVersion(filePath, version, opts = {}) {
|
|
|
225
220
|
*/
|
|
226
221
|
function getJavaProjectVersion(filePath) {
|
|
227
222
|
const pom = fs$1.readFileSync(filePath, "utf8");
|
|
228
|
-
|
|
229
|
-
const currVersion = $("project>version").text();
|
|
230
|
-
return currVersion;
|
|
223
|
+
return cheerio.load(pom)("project>version").text();
|
|
231
224
|
}
|
|
232
225
|
/**
|
|
233
226
|
* Updates the version of a package in a specified file.
|
|
@@ -294,31 +287,26 @@ async function upgradeCargoVersion(filePath, version, opts = {}) {
|
|
|
294
287
|
}
|
|
295
288
|
async function upgradeProjectVersion(nextVersion, projectFile, opts = {}) {
|
|
296
289
|
switch (projectFile?.category) {
|
|
297
|
-
case "java":
|
|
290
|
+
case "java":
|
|
298
291
|
upgradePomVersion(projectFile.path, nextVersion, opts);
|
|
299
292
|
break;
|
|
300
|
-
|
|
301
|
-
case "javascript": {
|
|
293
|
+
case "javascript":
|
|
302
294
|
upgradePackageVersion(projectFile.path, nextVersion, opts);
|
|
303
295
|
break;
|
|
304
|
-
|
|
305
|
-
case "rust": {
|
|
296
|
+
case "rust":
|
|
306
297
|
await upgradeCargoVersion(projectFile.path, nextVersion, opts);
|
|
307
298
|
break;
|
|
308
|
-
}
|
|
309
299
|
}
|
|
310
300
|
}
|
|
311
301
|
async function getProjectVersion(projectFile) {
|
|
312
302
|
let projectVersion;
|
|
313
303
|
switch (projectFile?.category) {
|
|
314
|
-
case "java":
|
|
304
|
+
case "java":
|
|
315
305
|
projectVersion = getJavaProjectVersion(projectFile.path);
|
|
316
306
|
break;
|
|
317
|
-
|
|
318
|
-
case "javascript": {
|
|
307
|
+
case "javascript":
|
|
319
308
|
projectVersion = getJSProjectVersion(projectFile.path);
|
|
320
309
|
break;
|
|
321
|
-
}
|
|
322
310
|
case "rust": projectVersion = await getRustProjectVersion(projectFile.path);
|
|
323
311
|
}
|
|
324
312
|
return projectVersion;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cross-bump",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.5.0",
|
|
5
5
|
"description": "cross language bump utility",
|
|
6
6
|
"author": {
|
|
7
7
|
"name": "rainbowatcher",
|
|
@@ -23,23 +23,23 @@
|
|
|
23
23
|
],
|
|
24
24
|
"exports": {
|
|
25
25
|
".": {
|
|
26
|
-
"types": "./dist/index.d.
|
|
27
|
-
"import": "./dist/index.
|
|
26
|
+
"types": "./dist/index.d.mts",
|
|
27
|
+
"import": "./dist/index.mjs"
|
|
28
28
|
}
|
|
29
29
|
},
|
|
30
|
-
"main": "./dist/index.
|
|
31
|
-
"module": "./dist/index.
|
|
32
|
-
"types": "./dist/index.d.
|
|
30
|
+
"main": "./dist/index.mjs",
|
|
31
|
+
"module": "./dist/index.mjs",
|
|
32
|
+
"types": "./dist/index.d.mts",
|
|
33
33
|
"files": [
|
|
34
34
|
"./dist"
|
|
35
35
|
],
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@rainbowatcher/toml-edit-js": "^0.
|
|
38
|
-
"cheerio": "1.
|
|
39
|
-
"detect-indent": "^7.0.
|
|
37
|
+
"@rainbowatcher/toml-edit-js": "^0.6.4",
|
|
38
|
+
"cheerio": "^1.2.0",
|
|
39
|
+
"detect-indent": "^7.0.2",
|
|
40
40
|
"fast-glob": "^3.3.3",
|
|
41
41
|
"is-glob": "^4.0.3",
|
|
42
|
-
"semver": "^7.7.
|
|
42
|
+
"semver": "^7.7.4"
|
|
43
43
|
},
|
|
44
44
|
"scripts": {
|
|
45
45
|
"clean": "rimraf dist/*",
|