@oneblink/release-cli 1.2.0 → 2.0.0-beta.1
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/bin.js
CHANGED
|
@@ -1,22 +1,23 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const
|
|
8
|
-
|
|
9
|
-
const meow_1 = __importDefault(require("meow"));
|
|
10
|
-
const enquirer_1 = __importDefault(require("enquirer"));
|
|
11
|
-
const startReleaseProcess_1 = __importDefault(require("./startReleaseProcess"));
|
|
12
|
-
const cli = meow_1.default(`
|
|
13
|
-
oneblink-release [next-version] [--no-git] [--cwd path]
|
|
2
|
+
import path from 'path';
|
|
3
|
+
import updateNotifier from 'update-notifier';
|
|
4
|
+
import meow from 'meow';
|
|
5
|
+
import enquirer from 'enquirer';
|
|
6
|
+
import startReleaseProcess from './startReleaseProcess.js';
|
|
7
|
+
const cli = meow(`
|
|
8
|
+
oneblink-release [next-version] [--no-git] [--name] [--no-name] [--cwd path]
|
|
14
9
|
|
|
15
10
|
next-version ..... The next version, will prompt for this if not supplied,
|
|
16
11
|
must be a valid semver number.
|
|
17
12
|
|
|
18
13
|
--no-git ....... Skip committing changes and creating an annotated git tag.
|
|
19
14
|
|
|
15
|
+
--name ......... Skip the question to enter a name for the release by passing
|
|
16
|
+
a release name as a flag.
|
|
17
|
+
|
|
18
|
+
--no-name ...... Skip the question to enter a name for the release. Use
|
|
19
|
+
option when running a release for an open source repository.
|
|
20
|
+
|
|
20
21
|
--cwd .......... Directory of the code base to release relative to the
|
|
21
22
|
current working directory, defaults to the current
|
|
22
23
|
working directory.
|
|
@@ -24,10 +25,13 @@ oneblink-release [next-version] [--no-git] [--cwd path]
|
|
|
24
25
|
Examples
|
|
25
26
|
|
|
26
27
|
oneblink-release
|
|
28
|
+
oneblink-release --no-name
|
|
29
|
+
oneblink-release --name="Inappropriate Release Name"
|
|
27
30
|
oneblink-release 1.1.1
|
|
28
31
|
oneblink-release 1.1.1 --cwd ../path/to/code
|
|
29
32
|
oneblink-release 1.1.1-uat.1 --no-git
|
|
30
33
|
`, {
|
|
34
|
+
importMeta: import.meta,
|
|
31
35
|
flags: {
|
|
32
36
|
help: {
|
|
33
37
|
type: 'boolean',
|
|
@@ -43,13 +47,32 @@ Examples
|
|
|
43
47
|
type: 'boolean',
|
|
44
48
|
default: true,
|
|
45
49
|
},
|
|
50
|
+
name: {
|
|
51
|
+
type: 'string',
|
|
52
|
+
},
|
|
46
53
|
cwd: {
|
|
47
54
|
type: 'string',
|
|
48
55
|
default: process.cwd(),
|
|
49
56
|
},
|
|
50
57
|
},
|
|
51
58
|
});
|
|
52
|
-
|
|
59
|
+
async function getReleaseName(name) {
|
|
60
|
+
if (typeof name === 'string' && name) {
|
|
61
|
+
return name;
|
|
62
|
+
}
|
|
63
|
+
if (typeof name === 'boolean' && !name) {
|
|
64
|
+
return undefined;
|
|
65
|
+
}
|
|
66
|
+
const { releaseName } = await enquirer.prompt([
|
|
67
|
+
{
|
|
68
|
+
type: 'input',
|
|
69
|
+
message: 'Release name? i.e. JIRA release',
|
|
70
|
+
name: 'releaseName',
|
|
71
|
+
},
|
|
72
|
+
]);
|
|
73
|
+
return releaseName;
|
|
74
|
+
}
|
|
75
|
+
updateNotifier({
|
|
53
76
|
// @ts-expect-error difference in types between packages
|
|
54
77
|
pkg: cli.pkg,
|
|
55
78
|
}).notify();
|
|
@@ -60,7 +83,7 @@ run().catch((error) => {
|
|
|
60
83
|
async function run() {
|
|
61
84
|
let input = cli.input[0];
|
|
62
85
|
if (!input) {
|
|
63
|
-
const { nextVersion } = await
|
|
86
|
+
const { nextVersion } = await enquirer.prompt([
|
|
64
87
|
{
|
|
65
88
|
type: 'input',
|
|
66
89
|
message: 'Next version? e.g. "1.2.3" or "1.2.3-beta.1"',
|
|
@@ -69,9 +92,11 @@ async function run() {
|
|
|
69
92
|
]);
|
|
70
93
|
input = nextVersion;
|
|
71
94
|
}
|
|
72
|
-
await
|
|
95
|
+
const releaseName = await getReleaseName(cli.flags.name);
|
|
96
|
+
await startReleaseProcess({
|
|
73
97
|
nextVersion: input,
|
|
74
98
|
git: cli.flags.git,
|
|
75
|
-
|
|
99
|
+
releaseName,
|
|
100
|
+
cwd: path.resolve(process.cwd(), cli.flags.cwd),
|
|
76
101
|
});
|
|
77
102
|
}
|
|
@@ -1,24 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
};
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
const
|
|
12
|
-
const
|
|
13
|
-
const semver_1 = __importDefault(require("semver"));
|
|
14
|
-
const ora_1 = __importDefault(require("ora"));
|
|
15
|
-
const read_pkg_up_1 = __importDefault(require("read-pkg-up"));
|
|
16
|
-
const readFileAsync = util_1.default.promisify(fs_1.default.readFile);
|
|
17
|
-
const writeFileAsync = util_1.default.promisify(fs_1.default.writeFile);
|
|
1
|
+
import fs from 'fs';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
import util from 'util';
|
|
4
|
+
import { execa } from 'execa';
|
|
5
|
+
import prettier from 'prettier';
|
|
6
|
+
import parseChangelog from 'changelog-parser';
|
|
7
|
+
import { main as packageDiffSummary } from 'package-diff-summary';
|
|
8
|
+
import semver from 'semver';
|
|
9
|
+
import ora from 'ora';
|
|
10
|
+
import { readPackageUp } from 'read-pkg-up';
|
|
11
|
+
const readFileAsync = util.promisify(fs.readFile);
|
|
12
|
+
const writeFileAsync = util.promisify(fs.writeFile);
|
|
18
13
|
const UNRELEASED_VERSION_INDEX = 0;
|
|
19
14
|
const GIT_TAG_PREFIX = 'v';
|
|
20
15
|
async function wrapWithLoading({ startText, failText }, fn) {
|
|
21
|
-
const spinner =
|
|
16
|
+
const spinner = ora(startText).start();
|
|
22
17
|
try {
|
|
23
18
|
const t = await fn(spinner);
|
|
24
19
|
if (spinner.isSpinning) {
|
|
@@ -31,13 +26,13 @@ async function wrapWithLoading({ startText, failText }, fn) {
|
|
|
31
26
|
throw error;
|
|
32
27
|
}
|
|
33
28
|
}
|
|
34
|
-
async function updateChangelog({ nextSemverVersion, cwd, }) {
|
|
35
|
-
const changelogPath =
|
|
29
|
+
async function updateChangelog({ nextSemverVersion, cwd, releaseName, }) {
|
|
30
|
+
const changelogPath = path.join(cwd, 'CHANGELOG.md');
|
|
36
31
|
const parsedChangelog = await wrapWithLoading({
|
|
37
32
|
startText: `Parsing ${changelogPath}`,
|
|
38
33
|
failText: `Failed to parsed ${changelogPath}`,
|
|
39
34
|
}, async (spinner) => {
|
|
40
|
-
const parsedChangelog = (await
|
|
35
|
+
const parsedChangelog = (await parseChangelog(changelogPath));
|
|
41
36
|
spinner.succeed(`Parsed ${changelogPath}`);
|
|
42
37
|
return parsedChangelog;
|
|
43
38
|
});
|
|
@@ -63,7 +58,7 @@ async function updateChangelog({ nextSemverVersion, cwd, }) {
|
|
|
63
58
|
let dependenciesChangelogEntries = '';
|
|
64
59
|
const lastGitTag = `${GIT_TAG_PREFIX}${lastVersion.version}`;
|
|
65
60
|
try {
|
|
66
|
-
const result = await
|
|
61
|
+
const result = await packageDiffSummary({
|
|
67
62
|
cwd,
|
|
68
63
|
previousVersion: lastGitTag,
|
|
69
64
|
});
|
|
@@ -87,22 +82,22 @@ ${dependenciesChangelogHeading}
|
|
|
87
82
|
${dependenciesChangelogEntries}
|
|
88
83
|
`;
|
|
89
84
|
});
|
|
90
|
-
const nextReleaseTitle = `[${nextSemverVersion}]
|
|
85
|
+
const nextReleaseTitle = `[${nextSemverVersion}] (${new Date()
|
|
91
86
|
.toISOString()
|
|
92
|
-
.substring(0, 10)}`;
|
|
87
|
+
.substring(0, 10)})${releaseName ? ` ${releaseName}` : ''}`;
|
|
93
88
|
await wrapWithLoading({
|
|
94
89
|
startText: `Updating CHANGELOG.md with next release (${nextReleaseTitle})`,
|
|
95
90
|
failText: `Failed to update CHANGELOG.md with next release (${nextReleaseTitle})`,
|
|
96
91
|
}, async (spinner) => {
|
|
97
92
|
let prettierOptions = {};
|
|
98
93
|
try {
|
|
99
|
-
const s = await readFileAsync(
|
|
94
|
+
const s = await readFileAsync(path.join(cwd, '.prettierrc'), 'utf-8');
|
|
100
95
|
prettierOptions = JSON.parse(s);
|
|
101
96
|
}
|
|
102
97
|
catch (error) {
|
|
103
98
|
// ignore errors attempting to find prettier configuration
|
|
104
99
|
}
|
|
105
|
-
const changelog =
|
|
100
|
+
const changelog = prettier.format(`
|
|
106
101
|
# ${parsedChangelog.title}
|
|
107
102
|
|
|
108
103
|
${parsedChangelog.description || ''}
|
|
@@ -130,12 +125,12 @@ ${body}
|
|
|
130
125
|
...prettierOptions,
|
|
131
126
|
parser: 'markdown',
|
|
132
127
|
});
|
|
133
|
-
await writeFileAsync(changelogPath, changelog, '
|
|
128
|
+
await writeFileAsync(changelogPath, changelog, 'utf-8');
|
|
134
129
|
spinner.succeed(`Updated CHANGELOG.md with next release (${nextReleaseTitle})`);
|
|
135
130
|
});
|
|
136
131
|
}
|
|
137
132
|
async function checkIfNPMPackageVersionShouldBeUpdated(cwd) {
|
|
138
|
-
const result = await
|
|
133
|
+
const result = await readPackageUp({
|
|
139
134
|
cwd,
|
|
140
135
|
});
|
|
141
136
|
return !!result?.packageJson;
|
|
@@ -145,27 +140,28 @@ async function executeCommand(command, args, cwd) {
|
|
|
145
140
|
startText: `Running "${command} ${args.join(' ')}"`,
|
|
146
141
|
failText: `Failed to run "${command} ${args.join(' ')}"`,
|
|
147
142
|
}, async (spinner) => {
|
|
148
|
-
await
|
|
143
|
+
await execa(command, args, {
|
|
149
144
|
cwd,
|
|
150
145
|
});
|
|
151
146
|
spinner.succeed(`Ran "${command} ${args.join(' ')}"`);
|
|
152
147
|
});
|
|
153
148
|
}
|
|
154
|
-
async function startReleaseProcess({ nextVersion, cwd, git, }) {
|
|
155
|
-
const nextSemverVersion =
|
|
149
|
+
export default async function startReleaseProcess({ nextVersion, cwd, git, releaseName, }) {
|
|
150
|
+
const nextSemverVersion = semver.valid(nextVersion);
|
|
156
151
|
if (!nextSemverVersion) {
|
|
157
152
|
throw new Error('Next version is not valid semver');
|
|
158
153
|
}
|
|
159
154
|
const npm = await checkIfNPMPackageVersionShouldBeUpdated(cwd);
|
|
160
|
-
const preReleaseComponents =
|
|
155
|
+
const preReleaseComponents = semver.prerelease(nextSemverVersion);
|
|
161
156
|
if (preReleaseComponents && preReleaseComponents[0]) {
|
|
162
157
|
const text = `Skipping changelog updates for "${preReleaseComponents[0]}" release`;
|
|
163
|
-
|
|
158
|
+
ora(text).start().info(text);
|
|
164
159
|
}
|
|
165
160
|
else {
|
|
166
161
|
await updateChangelog({
|
|
167
162
|
nextSemverVersion,
|
|
168
163
|
cwd,
|
|
164
|
+
releaseName,
|
|
169
165
|
});
|
|
170
166
|
}
|
|
171
167
|
if (npm) {
|
|
@@ -173,7 +169,7 @@ async function startReleaseProcess({ nextVersion, cwd, git, }) {
|
|
|
173
169
|
}
|
|
174
170
|
if (!git) {
|
|
175
171
|
const text = `Skipping committing release changes using git`;
|
|
176
|
-
|
|
172
|
+
ora(text).start().info(text);
|
|
177
173
|
return;
|
|
178
174
|
}
|
|
179
175
|
await executeCommand('git', ['add', '-A'], cwd);
|
|
@@ -188,4 +184,3 @@ async function startReleaseProcess({ nextVersion, cwd, git, }) {
|
|
|
188
184
|
], cwd);
|
|
189
185
|
await executeCommand('git', ['push', '--tags'], cwd);
|
|
190
186
|
}
|
|
191
|
-
exports.default = startReleaseProcess;
|
|
@@ -47,8 +47,4 @@
|
|
|
47
47
|
"release": "gh-release && npm publish",
|
|
48
48
|
"test": "standard && node test | tap-spec"
|
|
49
49
|
}
|
|
50
|
-
|
|
51
|
-
,"_resolved": "https://registry.npmjs.org/changelog-parser/-/changelog-parser-2.8.0.tgz"
|
|
52
|
-
,"_integrity": "sha512-ZtSwN0hY7t+WpvaXqqXz98RHCNhWX9HsvCRAv1aBLlqJ7BpKtqdM6Nu6JOiUhRAWR7Gov0aN0fUnmflTz0WgZg=="
|
|
53
|
-
,"_from": "changelog-parser@2.8.0"
|
|
54
|
-
}
|
|
50
|
+
}
|
|
@@ -11,8 +11,4 @@
|
|
|
11
11
|
"type": "git",
|
|
12
12
|
"url": "https://nickewing@github.com/nickewing/line-reader.git"
|
|
13
13
|
}
|
|
14
|
-
|
|
15
|
-
,"_resolved": "https://registry.npmjs.org/line-reader/-/line-reader-0.2.4.tgz"
|
|
16
|
-
,"_integrity": "sha1-xDkrWH3qOFgMlnhXDm6OSfzlJiI="
|
|
17
|
-
,"_from": "line-reader@0.2.4"
|
|
18
|
-
}
|
|
14
|
+
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@oneblink/release-cli",
|
|
3
3
|
"description": "Used internally by OneBlink to release code bases quickly and consistently",
|
|
4
|
-
"version": "
|
|
4
|
+
"version": "2.0.0-beta.1",
|
|
5
5
|
"author": "OneBlink <developers@oneblink> (https://github.com/oneblink)",
|
|
6
6
|
"bin": {
|
|
7
7
|
"oneblink-release": "dist/bin.js"
|
|
@@ -12,40 +12,41 @@
|
|
|
12
12
|
"dependencies": {
|
|
13
13
|
"changelog-parser": "^2.8.0",
|
|
14
14
|
"enquirer": "^2.3.6",
|
|
15
|
-
"execa": "^
|
|
16
|
-
"meow": "^
|
|
17
|
-
"ora": "^
|
|
15
|
+
"execa": "^7.1.1",
|
|
16
|
+
"meow": "^11.0.0",
|
|
17
|
+
"ora": "^6.3.0",
|
|
18
18
|
"package-diff-summary": "^3.0.1",
|
|
19
|
-
"patch-package": "^6.
|
|
20
|
-
"prettier": "^2.
|
|
21
|
-
"read-pkg-up": "^
|
|
22
|
-
"semver": "^7.3.
|
|
23
|
-
"update-notifier": "^
|
|
19
|
+
"patch-package": "^6.5.1",
|
|
20
|
+
"prettier": "^2.8.7",
|
|
21
|
+
"read-pkg-up": "^9.1.0",
|
|
22
|
+
"semver": "^7.3.8",
|
|
23
|
+
"update-notifier": "^6.0.2"
|
|
24
24
|
},
|
|
25
25
|
"bundleDependencies": [
|
|
26
26
|
"changelog-parser"
|
|
27
27
|
],
|
|
28
28
|
"devDependencies": {
|
|
29
|
-
"@types/changelog-parser": "^2.
|
|
30
|
-
"@types/jest": "^
|
|
31
|
-
"@types/node": "^
|
|
32
|
-
"@types/semver": "^7.3.
|
|
33
|
-
"@types/update-notifier": "^
|
|
34
|
-
"@typescript-eslint/eslint-plugin": "^
|
|
35
|
-
"@typescript-eslint/parser": "^
|
|
36
|
-
"
|
|
37
|
-
"eslint
|
|
38
|
-
"eslint-
|
|
39
|
-
"
|
|
40
|
-
"
|
|
41
|
-
"
|
|
29
|
+
"@types/changelog-parser": "^2.8.1",
|
|
30
|
+
"@types/jest": "^29.5.0",
|
|
31
|
+
"@types/node": "^18.15.11",
|
|
32
|
+
"@types/semver": "^7.3.13",
|
|
33
|
+
"@types/update-notifier": "^6.0.2",
|
|
34
|
+
"@typescript-eslint/eslint-plugin": "^5.57.0",
|
|
35
|
+
"@typescript-eslint/parser": "^5.57.0",
|
|
36
|
+
"cross-env": "^7.0.3",
|
|
37
|
+
"eslint": "^8.37.0",
|
|
38
|
+
"eslint-config-prettier": "^8.8.0",
|
|
39
|
+
"eslint-plugin-prettier": "^4.2.1",
|
|
40
|
+
"jest": "^29.5.0",
|
|
41
|
+
"ts-jest": "^29.1.0",
|
|
42
|
+
"typescript": "^5.0.3"
|
|
42
43
|
},
|
|
43
44
|
"directories": {
|
|
44
45
|
"test": "test"
|
|
45
46
|
},
|
|
46
47
|
"engines": {
|
|
47
|
-
"node": ">=
|
|
48
|
-
"npm": ">=
|
|
48
|
+
"node": ">=18",
|
|
49
|
+
"npm": ">=8"
|
|
49
50
|
},
|
|
50
51
|
"files": [
|
|
51
52
|
"dist",
|
|
@@ -67,10 +68,11 @@
|
|
|
67
68
|
"scripts": {
|
|
68
69
|
"build": "tsc --build",
|
|
69
70
|
"eslint": "eslint --fix --cache --quiet ./src",
|
|
70
|
-
"jest": "jest --silent",
|
|
71
|
+
"jest": "cross-env NODE_OPTIONS=--experimental-vm-modules jest --silent",
|
|
71
72
|
"prepare": "npm run build",
|
|
72
73
|
"pretest": "npm run eslint",
|
|
73
74
|
"test": "npm run jest",
|
|
74
75
|
"postinstall": "patch-package"
|
|
75
|
-
}
|
|
76
|
+
},
|
|
77
|
+
"type": "module"
|
|
76
78
|
}
|
package/CHANGELOG.md
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
# Changelog
|
|
2
|
-
|
|
3
|
-
All notable changes to this project will be documented in this file.
|
|
4
|
-
|
|
5
|
-
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
|
-
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
|
-
|
|
8
|
-
## [Unreleased]
|
|
9
|
-
|
|
10
|
-
### Moved
|
|
11
|
-
|
|
12
|
-
`patch-package` to deps
|
|
13
|
-
|
|
14
|
-
### Added
|
|
15
|
-
|
|
16
|
-
`patches` dir to `files` in `package.json` file
|
|
17
|
-
|
|
18
|
-
## [1.1.0] - 2022-08-26
|
|
19
|
-
|
|
20
|
-
### Patched
|
|
21
|
-
|
|
22
|
-
- `changelog-parser` to use `\n` as line endings instead of detecting based on platform
|
|
23
|
-
|
|
24
|
-
## [1.0.0] - 2021-04-21
|
|
25
|
-
|
|
26
|
-
### Added
|
|
27
|
-
|
|
28
|
-
- Initial Release
|