Skip to content

Commit 1a8373f

Browse files
committed
Started to build out version bump tool.
1 parent ecf4094 commit 1a8373f

File tree

3 files changed

+53
-0
lines changed

3 files changed

+53
-0
lines changed

bin/.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
declare module 'parse-cmd-args';

bin/version.js

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
#!/usr/bin/env node
2+
3+
import { join } from 'path';
4+
5+
import { readFile, writeFile } from 'fs/promises';
6+
7+
import { inc, parse } from 'semver';
8+
9+
import parseCmdArgs from 'parse-cmd-args';
10+
11+
const { input } = parseCmdArgs(null, {
12+
requireUserInput: true
13+
});
14+
15+
const loadAndParsePackageFile = async path => {
16+
return JSON.parse(await readFile(path, 'utf8'));
17+
};
18+
19+
(async () => {
20+
const { workspaces } = await loadAndParsePackageFile('./package.json');
21+
22+
const versions = (
23+
await Promise.all(
24+
workspaces.map(async workspace => {
25+
const pkg = await loadAndParsePackageFile(
26+
join(workspace, './package.json')
27+
);
28+
29+
const { prerelease } = parse(pkg.version);
30+
31+
const nextVersion = inc(pkg.version, input, prerelease[0]);
32+
33+
await writeFile(
34+
join(workspace, './package.json'),
35+
`${JSON.stringify(
36+
{ ...pkg, version: nextVersion },
37+
null,
38+
2
39+
)}\n`
40+
);
41+
42+
return {
43+
name: pkg.name,
44+
version: nextVersion
45+
};
46+
})
47+
)
48+
).reduce((all, workspace) => ({ ...all, [workspace.name]: workspace }), {});
49+
50+
console.log(versions);
51+
})();

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
"name": "doxdox-workspace",
33
"version": "4.0.0-preview.1",
4+
"type": "module",
45
"workspaces": [
56
"./packages/doxdox-core",
67
"./packages/doxdox-parser-jsdoc",

0 commit comments

Comments
 (0)