autorel 2.3.4 → 2.4.0-next.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/README.md +31 -30
- package/dist/autorel.js +102 -49
- package/dist/cli.d.ts +1 -9
- package/dist/cli.js +9 -14
- package/dist/config.d.ts +22 -1
- package/dist/config.js +6 -9
- package/dist/conventionalcommits.js +1 -1
- package/dist/defaults.js +1 -0
- package/dist/getPrereleaseChannel.js +1 -1
- package/dist/getTags.js +2 -1
- package/dist/index.d.ts +1 -0
- package/dist/services/github.d.ts +7 -1
- package/dist/services/github.js +21 -5
- package/dist/{lib → services}/logger.js +1 -1
- package/dist/services/npm.d.ts +7 -0
- package/dist/services/npm.js +12 -2
- package/dist/services/packageJson.d.ts +11 -0
- package/dist/{updatePackageJsonVersion.js → services/packageJson.js} +8 -7
- package/dist/services/sh.js +1 -1
- package/dist/transaction.d.ts +3 -0
- package/dist/transaction.js +29 -0
- package/package.json +3 -3
- package/dist/getNextTag.d.ts +0 -9
- package/dist/getNextTag.js +0 -40
- package/dist/runUserPrereleaseScripts.d.ts +0 -2
- package/dist/runUserPrereleaseScripts.js +0 -16
- package/dist/runUserReleaseScripts.d.ts +0 -2
- package/dist/runUserReleaseScripts.js +0 -25
- package/dist/updatePackageJsonVersion.d.ts +0 -4
- package/dist/validateUseVersion.d.ts +0 -2
- package/dist/validateUseVersion.js +0 -25
- /package/dist/{lib → services}/logger.d.ts +0 -0
- /package/dist/{lib → services}/mockLogger.d.ts +0 -0
- /package/dist/{lib → services}/mockLogger.js +0 -0
package/README.md
CHANGED
|
@@ -1,40 +1,39 @@
|
|
|
1
|
-
|
|
2
|
-
<source srcset="docs/autorel-white.svg" media="(prefers-color-scheme: dark)">
|
|
3
|
-
<source srcset="docs/autorel-black.svg" media="(prefers-color-scheme: light)">
|
|
4
|
-
<img src="docs/autorel-black.svg" alt="Autorel" size="250">
|
|
5
|
-
</picture>
|
|
6
|
-
|
|
7
|
-
---
|
|
1
|
+
# autorel
|
|
8
2
|
|
|
9
3
|
[](https://github.com/mhweiner/autorel/actions)
|
|
10
|
-
[](
|
|
4
|
+
[]()
|
|
11
5
|
[](https://conventionalcommits.org)
|
|
12
|
-
[](https://github.com/mhweiner/AutoRel)
|
|
7
|
+
|
|
8
|
+
**Autorel** is a fast, simple, and reliable tool for automating releases based on commit messages.
|
|
9
|
+
|
|
10
|
+
It follows [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/) and [Semantic Versioning](https://semver.org/) to do things like:
|
|
14
11
|
|
|
15
|
-
|
|
12
|
+
- Run pre-release tasks (tests, builds, etc.)
|
|
13
|
+
- Bump the version and tag based on commit messages
|
|
14
|
+
- Create tagged GitHub releases with notes
|
|
15
|
+
- Publish to npm
|
|
16
|
+
- Run custom scripts
|
|
16
17
|
|
|
17
|
-
|
|
18
|
+
🚀 Like `semantic-release` or `release-please`, but faster, more reliable, and easier to use.
|
|
18
19
|
|
|
19
|
-
|
|
20
|
-
- Creates a new release on GitHub with Release Notes
|
|
21
|
-
- Publishes the package to NPM
|
|
22
|
-
- Runs any arbitrary command or bash script
|
|
20
|
+
Supports GitHub Actions and npm (Node.js) natively. You can add custom scripts for other languages and systems (or contribute built-in support).
|
|
23
21
|
|
|
24
|
-
|
|
22
|
+
Use Autorel to save time, prevent broken releases, and ship with confidence.
|
|
25
23
|
|
|
26
|
-
**✅ Conventional Commit
|
|
24
|
+
**✅ Conventional Commit & SemVer Compliant**
|
|
27
25
|
- 100% compliant with Conventional Commits and SemVer out of the box, including "!" for breaking changes
|
|
28
26
|
|
|
29
|
-
|
|
27
|
+
**🔒 Safe & Reliable**
|
|
28
|
+
- Automatic rollback on failure
|
|
30
29
|
- No confusing configuration files or complex setup
|
|
31
|
-
-
|
|
32
|
-
-
|
|
33
|
-
- Built-in bash script support
|
|
30
|
+
- Configuration validation and error handling
|
|
31
|
+
- Excellent test coverage
|
|
34
32
|
|
|
35
33
|
**🚀 Fast & Lightweight**
|
|
36
|
-
- Minimal dependencies and fast execution
|
|
37
|
-
-
|
|
34
|
+
- Minimal dependencies and fast, concurrent execution
|
|
35
|
+
- Written in TypeScript with comprehensive test coverage
|
|
36
|
+
- No need to install or configure a separate CI/CD system
|
|
38
37
|
- Less broken builds and more time to focus on your code!
|
|
39
38
|
|
|
40
39
|
[Read our FAQ on why you should use `autorel` and how it compares to other tools](docs/faq.md)
|
|
@@ -60,7 +59,7 @@ _Currently only has built-in support for `GitHub` and `NPM`, but you can write y
|
|
|
60
59
|
## Example Usage (CLI)
|
|
61
60
|
|
|
62
61
|
```bash
|
|
63
|
-
npx autorel --publish --run 'echo "Next version is ${NEXT_VERSION}"'
|
|
62
|
+
npx autorel@^2 --publish --run 'echo "Next version is ${NEXT_VERSION}"'
|
|
64
63
|
```
|
|
65
64
|
|
|
66
65
|
This will:
|
|
@@ -77,11 +76,9 @@ npm i -g autorel
|
|
|
77
76
|
autorel --publish
|
|
78
77
|
```
|
|
79
78
|
|
|
80
|
-
### Avoiding Breaking Changes
|
|
79
|
+
### ⚠️ Avoiding Breaking Changes
|
|
81
80
|
|
|
82
|
-
If using the `npx` command, you may want to append the version number to prevent breaking changes in the future. You can do this by appending `@^` followed by the major version number.
|
|
83
|
-
|
|
84
|
-
Example: `npx autorel@^2`
|
|
81
|
+
If using the `npx` command, you may want to append the version number to prevent breaking changes in the future. You can do this by appending `@^` followed by the major version number, ie. `npx autorel@^2`.
|
|
85
82
|
|
|
86
83
|
## Example Usage (Library)
|
|
87
84
|
|
|
@@ -102,7 +99,7 @@ Example: `npx autorel@^2`
|
|
|
102
99
|
};
|
|
103
100
|
|
|
104
101
|
autorel(autorelConfig).then((nextVersion) => {
|
|
105
|
-
console.log(`Next version is ${nextVersion}`);
|
|
102
|
+
console.log(`Next version is ${nextVersion}`); // ie, "Next version is 1.0.1"
|
|
106
103
|
});
|
|
107
104
|
```
|
|
108
105
|
|
|
@@ -329,6 +326,10 @@ The version to use for the release INSTEAD of the version being generated. Alway
|
|
|
329
326
|
|
|
330
327
|
> ❗️ Must be a valid SemVer version, without the `v`.
|
|
331
328
|
|
|
329
|
+
### githubToken
|
|
330
|
+
|
|
331
|
+
The GitHub token to use for creating the release. If not provided, it will use the `GITHUB_TOKEN` environment variable. This is only used if `skipRelease` is `false`.
|
|
332
|
+
|
|
332
333
|
## Sample YAML Configuration
|
|
333
334
|
|
|
334
335
|
<sub>_.autorel.yaml_</sub>
|
package/dist/autorel.js
CHANGED
|
@@ -31,30 +31,39 @@ exports.autorel = void 0;
|
|
|
31
31
|
const convCom = __importStar(require("./conventionalcommits"));
|
|
32
32
|
const git = __importStar(require("./services/git"));
|
|
33
33
|
const npm = __importStar(require("./services/npm"));
|
|
34
|
-
const
|
|
34
|
+
const semver = __importStar(require("./semver"));
|
|
35
35
|
const github = __importStar(require("./services/github"));
|
|
36
|
-
const
|
|
37
|
-
const
|
|
36
|
+
const packageJson = __importStar(require("./services/packageJson"));
|
|
37
|
+
const changelog_1 = require("./changelog");
|
|
38
|
+
const logger_1 = __importDefault(require("./services/logger"));
|
|
38
39
|
const colorette_1 = require("colorette");
|
|
39
40
|
const getPrereleaseChannel_1 = require("./getPrereleaseChannel");
|
|
41
|
+
const _1 = require(".");
|
|
40
42
|
const getTags_1 = require("./getTags");
|
|
41
|
-
const
|
|
42
|
-
const
|
|
43
|
-
const
|
|
44
|
-
const
|
|
43
|
+
const transaction_1 = require("./transaction");
|
|
44
|
+
const sh_1 = require("./services/sh");
|
|
45
|
+
const node_util_1 = require("node:util");
|
|
46
|
+
const typura_1 = require("typura");
|
|
47
|
+
const onRollback = (err) => {
|
|
48
|
+
logger_1.default.error('An error occurred during release, rolling back...');
|
|
49
|
+
logger_1.default.error((0, node_util_1.inspect)(err, { depth: null, colors: false }));
|
|
50
|
+
};
|
|
51
|
+
const onRollbackError = (err) => {
|
|
52
|
+
logger_1.default.error('An error occurred during rollback:');
|
|
53
|
+
logger_1.default.error((0, node_util_1.inspect)(err, { depth: null, colors: false }));
|
|
54
|
+
};
|
|
45
55
|
async function autorel(args) {
|
|
46
|
-
const
|
|
47
|
-
if (
|
|
48
|
-
|
|
49
|
-
}
|
|
50
|
-
if (prereleaseChannel && !args.useVersion) {
|
|
51
|
-
const stmt = `Using prerelease channel: ${(0, colorette_1.bold)(prereleaseChannel)}`;
|
|
52
|
-
logger_1.default.info(!args.useVersion ? stmt : (0, colorette_1.strikethrough)(stmt));
|
|
53
|
-
}
|
|
54
|
-
else {
|
|
55
|
-
const stmt = 'This is a production release.';
|
|
56
|
-
logger_1.default.info(!args.useVersion ? stmt : (0, colorette_1.strikethrough)(stmt));
|
|
56
|
+
const [validationErr] = (0, typura_1.toResult)(() => (0, _1.validateConfig)(args));
|
|
57
|
+
if (validationErr instanceof typura_1.ValidationError) {
|
|
58
|
+
throw new Error(`Invalid configuration:\n${(0, node_util_1.inspect)(validationErr.messages, { depth: null, colors: false })}`);
|
|
57
59
|
}
|
|
60
|
+
const prereleaseChannel = (0, getPrereleaseChannel_1.getPrereleaseChannel)(args);
|
|
61
|
+
const isDryRun = !!args.dryRun;
|
|
62
|
+
const isPrerelease = !!prereleaseChannel;
|
|
63
|
+
isDryRun && logger_1.default.info('Running in dry-run mode. No changes will be made.');
|
|
64
|
+
isPrerelease && logger_1.default.info(`Using prerelease channel: ${(0, colorette_1.bold)(prereleaseChannel)}`);
|
|
65
|
+
!isPrerelease && logger_1.default.info('This is a production release.');
|
|
66
|
+
!!args.useVersion && logger_1.default.info(`Using pinned version: ${(0, colorette_1.bold)(args.useVersion)}`);
|
|
58
67
|
git.gitFetch();
|
|
59
68
|
const { highestTag, highestChannelTag, highestStableTag, tagFromWhichToFindCommits, } = (0, getTags_1.getTags)(prereleaseChannel);
|
|
60
69
|
const commits = git.getCommitsFromTag(tagFromWhichToFindCommits);
|
|
@@ -72,43 +81,87 @@ async function autorel(args) {
|
|
|
72
81
|
logger_1.default.info('No release is needed. Have a nice day (^_^)/');
|
|
73
82
|
return;
|
|
74
83
|
}
|
|
75
|
-
(
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
+
else if (releaseType === 'none' && args.useVersion) {
|
|
85
|
+
logger_1.default.info('No release is needed. But you are using --use-version, so we will do a release anyway.');
|
|
86
|
+
}
|
|
87
|
+
const nextTag = args.useVersion
|
|
88
|
+
? `v${args.useVersion}`
|
|
89
|
+
: semver.toTag(semver.incrVer({
|
|
90
|
+
latestVer: semver.fromTag(highestTag ?? 'v0.0.0'),
|
|
91
|
+
latestStableVer: semver.fromTag(highestStableTag ?? 'v0.0.0'),
|
|
92
|
+
releaseType,
|
|
93
|
+
prereleaseChannel,
|
|
94
|
+
latestChannelVer: highestChannelTag ? semver.fromTag(highestChannelTag) : undefined,
|
|
95
|
+
}));
|
|
84
96
|
const changelog = (0, changelog_1.generateChangelog)(parsedCommits, commitTypeMap, args.breakingChangeTitle);
|
|
85
97
|
logger_1.default.info(`The next version is: ${(0, colorette_1.bold)(nextTag)}`);
|
|
86
98
|
logger_1.default.debug(`The changelog is:\n${changelog}`);
|
|
87
99
|
if (args.dryRun)
|
|
88
100
|
return;
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
const { owner, repository } = git.getRepo();
|
|
94
|
-
github.createRelease({
|
|
95
|
-
token: process.env.GITHUB_TOKEN,
|
|
96
|
-
owner,
|
|
97
|
-
repository,
|
|
98
|
-
tag: nextTag,
|
|
99
|
-
name: nextTag,
|
|
100
|
-
body: changelog,
|
|
101
|
-
});
|
|
102
|
-
}
|
|
103
|
-
// publish to npm
|
|
104
|
-
if (args.publish) {
|
|
105
|
-
(0, updatePackageJsonVersion_1.updatePackageJsonVersion)(nextTag);
|
|
106
|
-
npm.publishPackage(prereleaseChannel);
|
|
101
|
+
// User-defined scripts for things like running tests, building the project, etc.
|
|
102
|
+
if (args.preRun) {
|
|
103
|
+
logger_1.default.info('Running pre-release bash script...');
|
|
104
|
+
(0, sh_1.bash)(args.preRun);
|
|
107
105
|
}
|
|
108
|
-
//
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
106
|
+
// The rest goes in a transaction so we can rollback if something goes wrong
|
|
107
|
+
await (0, transaction_1.transaction)(async (addToRollback) => {
|
|
108
|
+
git.createAndPushTag(nextTag);
|
|
109
|
+
addToRollback(async () => {
|
|
110
|
+
logger_1.default.info('Rolling back git tag...');
|
|
111
|
+
git.deleteTagFromLocalAndRemote(nextTag);
|
|
112
|
+
});
|
|
113
|
+
// create GitHub release
|
|
114
|
+
if (!args.skipRelease) {
|
|
115
|
+
if (!args.githubToken)
|
|
116
|
+
throw new Error('GitHub token is required to publish a release. Please set the GITHUB_TOKEN environment variable or pass it as an argument.');
|
|
117
|
+
const { owner, repository } = git.getRepo();
|
|
118
|
+
const releaseId = await github.createRelease({
|
|
119
|
+
token: args.githubToken,
|
|
120
|
+
owner,
|
|
121
|
+
repository,
|
|
122
|
+
tag: nextTag,
|
|
123
|
+
name: nextTag,
|
|
124
|
+
body: changelog,
|
|
125
|
+
});
|
|
126
|
+
addToRollback(async () => {
|
|
127
|
+
logger_1.default.info('Rolling back GitHub release...');
|
|
128
|
+
await github.deleteReleaseById({
|
|
129
|
+
token: process.env.GITHUB_TOKEN,
|
|
130
|
+
owner,
|
|
131
|
+
repository,
|
|
132
|
+
releaseId,
|
|
133
|
+
});
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
// update package.json and publish to npm registry
|
|
137
|
+
if (args.publish) {
|
|
138
|
+
const oldVersion = packageJson.read().version;
|
|
139
|
+
packageJson.setVersion(nextTag);
|
|
140
|
+
addToRollback(async () => {
|
|
141
|
+
logger_1.default.info('Rolling back package.json...');
|
|
142
|
+
packageJson.setVersion(oldVersion);
|
|
143
|
+
});
|
|
144
|
+
npm.publishPackage(prereleaseChannel);
|
|
145
|
+
addToRollback(async () => {
|
|
146
|
+
logger_1.default.info('Rolling back npm publish...');
|
|
147
|
+
await npm.unpublishPackage(`${packageJson.read().name}@${nextTag}`);
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
// set env variables to be available in the scripts
|
|
151
|
+
process.env.NEXT_VERSION = nextTag.replace('v', '');
|
|
152
|
+
process.env.NEXT_TAG = nextTag;
|
|
153
|
+
// run user-defined release scripts
|
|
154
|
+
if (args.run) {
|
|
155
|
+
logger_1.default.info('Running release bash script...');
|
|
156
|
+
(0, sh_1.bash)(args.run);
|
|
157
|
+
}
|
|
158
|
+
else if (args.runScript) {
|
|
159
|
+
// TODO: delete this block in the next major version
|
|
160
|
+
logger_1.default.warn('🚨 Warning: The "runScript" option is deprecated. Please use "run" instead. It will be removed in the next major version.');
|
|
161
|
+
logger_1.default.info('Running post-release bash script...');
|
|
162
|
+
(0, sh_1.bash)(args.runScript);
|
|
163
|
+
}
|
|
164
|
+
}, onRollback, onRollbackError);
|
|
112
165
|
return nextTag.replace('v', '');
|
|
113
166
|
}
|
|
114
167
|
exports.autorel = autorel;
|
package/dist/cli.d.ts
CHANGED
package/dist/cli.js
CHANGED
|
@@ -18,25 +18,20 @@ program
|
|
|
18
18
|
.option('--use-version <value>', 'Specify a version to be used instead of calculating it from commit analysis. Must be a valid SemVer version, with no \'v\'. Overrides --pre-release, commitType, and branches configuration. (arg: useVersion)')
|
|
19
19
|
.option('--run <value>', 'Command to run after the release is successful. (arg: run)')
|
|
20
20
|
.option('--pre-run <value>', 'Command to run after the release is successful. (arg: preRun)')
|
|
21
|
+
.option('--publish', 'Publish the package to npm, requires npm already set up and authenticated. (arg: publish)')
|
|
22
|
+
.option('--github-token <value>', 'GitHub token to use for creating the release. By default, we use GITHUB_TOKEN environment variable (arg: githubToken)')
|
|
21
23
|
.option('--skip-release', 'Skips creating a release on GitHub. (arg: skipRelease)')
|
|
22
|
-
.option('--publish', 'Publish the package to npm, requires passing --npm-token or NPM_TOKEN environment variable. (arg: publish)')
|
|
23
24
|
.parse(process.argv);
|
|
24
25
|
const options = program.opts();
|
|
25
|
-
const cliOptions = {
|
|
26
|
-
dryRun: options.dryRun,
|
|
27
|
-
run: options.run,
|
|
28
|
-
preRun: options.preRun,
|
|
29
|
-
prereleaseChannel: options.preRelease,
|
|
30
|
-
useVersion: options.useVersion,
|
|
31
|
-
publish: options.publish,
|
|
32
|
-
skipRelease: options.skipRelease,
|
|
33
|
-
};
|
|
34
26
|
// remove falsy values from the overrides
|
|
35
|
-
if (
|
|
36
|
-
Object.keys(
|
|
27
|
+
if (options) {
|
|
28
|
+
Object.keys(options).forEach((key) => (
|
|
37
29
|
// @ts-ignore
|
|
38
30
|
!cliOptions[key] && delete cliOptions[key]));
|
|
39
31
|
}
|
|
40
|
-
const config = (0, config_1.getConfig)(
|
|
41
|
-
(0, _1.autorel)(config)
|
|
32
|
+
const config = (0, config_1.getConfig)(options);
|
|
33
|
+
(0, _1.autorel)(config).catch((error) => {
|
|
34
|
+
console.error('[autorel] Release failed:', error);
|
|
35
|
+
process.exit(1);
|
|
36
|
+
});
|
|
42
37
|
//# sourceMappingURL=cli.js.map
|
package/dist/config.d.ts
CHANGED
|
@@ -1,2 +1,23 @@
|
|
|
1
1
|
import { Config } from '.';
|
|
2
|
-
export declare
|
|
2
|
+
export declare const validateConfig: import("typura").Pred<{
|
|
3
|
+
dryRun?: boolean | undefined;
|
|
4
|
+
run?: string | undefined;
|
|
5
|
+
preRun?: string | undefined;
|
|
6
|
+
runScript?: string | undefined;
|
|
7
|
+
prereleaseChannel?: string | undefined;
|
|
8
|
+
useVersion?: string | undefined;
|
|
9
|
+
skipRelease?: boolean | undefined;
|
|
10
|
+
publish?: boolean | undefined;
|
|
11
|
+
breakingChangeTitle?: string | undefined;
|
|
12
|
+
commitTypes?: {
|
|
13
|
+
type: string;
|
|
14
|
+
title: string;
|
|
15
|
+
release: string;
|
|
16
|
+
}[] | undefined;
|
|
17
|
+
branches?: {
|
|
18
|
+
name: string;
|
|
19
|
+
prereleaseChannel?: string | undefined;
|
|
20
|
+
}[] | undefined;
|
|
21
|
+
githubToken?: string | undefined;
|
|
22
|
+
}>;
|
|
23
|
+
export declare function getConfig(overrides?: Partial<Config>): any;
|
package/dist/config.js
CHANGED
|
@@ -26,20 +26,21 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
26
26
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
27
|
};
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.getConfig = void 0;
|
|
29
|
+
exports.getConfig = exports.validateConfig = void 0;
|
|
30
30
|
const fs = __importStar(require("node:fs"));
|
|
31
31
|
const path = __importStar(require("node:path"));
|
|
32
32
|
const yaml = __importStar(require("js-yaml"));
|
|
33
33
|
const typura_1 = require("typura");
|
|
34
|
-
const logger_1 = __importDefault(require("./
|
|
34
|
+
const logger_1 = __importDefault(require("./services/logger"));
|
|
35
35
|
const defaults_1 = require("./defaults");
|
|
36
|
-
const
|
|
36
|
+
const useVersionRegex = /^(?<major>0|[1-9]\d*)\.(?<minor>0|[1-9]\d*)\.(?<patch>0|[1-9]\d*)(?:-(?<channel>[0-9a-zA-Z-]+)(?:\.(?<build>[0-9a-zA-Z-]+))?)?(?:\+(?<buildmetadata>[0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$/;
|
|
37
|
+
exports.validateConfig = typura_1.predicates.object({
|
|
37
38
|
dryRun: typura_1.predicates.optional(typura_1.predicates.boolean()),
|
|
38
39
|
run: typura_1.predicates.optional(typura_1.predicates.string()),
|
|
39
40
|
preRun: typura_1.predicates.optional(typura_1.predicates.string()),
|
|
40
41
|
runScript: typura_1.predicates.optional(typura_1.predicates.string()),
|
|
41
42
|
prereleaseChannel: typura_1.predicates.optional(typura_1.predicates.string()),
|
|
42
|
-
useVersion: typura_1.predicates.optional(typura_1.predicates.
|
|
43
|
+
useVersion: typura_1.predicates.optional(typura_1.predicates.regex(useVersionRegex, 'Invalid version format. Should be x.y.z or x.y.z-channel.build')),
|
|
43
44
|
skipRelease: typura_1.predicates.optional(typura_1.predicates.boolean()),
|
|
44
45
|
publish: typura_1.predicates.optional(typura_1.predicates.boolean()),
|
|
45
46
|
breakingChangeTitle: typura_1.predicates.optional(typura_1.predicates.string()),
|
|
@@ -52,6 +53,7 @@ const validateConfig = typura_1.predicates.object({
|
|
|
52
53
|
name: typura_1.predicates.string(),
|
|
53
54
|
prereleaseChannel: typura_1.predicates.optional(typura_1.predicates.string()),
|
|
54
55
|
}))),
|
|
56
|
+
githubToken: typura_1.predicates.optional(typura_1.predicates.string()),
|
|
55
57
|
});
|
|
56
58
|
/**
|
|
57
59
|
* Reads and parses a local .autorel.yaml file.
|
|
@@ -92,11 +94,6 @@ function getConfig(overrides) {
|
|
|
92
94
|
logger_1.default.debug(`Yaml: ${JSON.stringify(yamlConfig, null, 2)}`);
|
|
93
95
|
logger_1.default.debug(`Overrides: ${JSON.stringify(overrides, null, 2)}`);
|
|
94
96
|
logger_1.default.debug('---');
|
|
95
|
-
const [validationErr] = (0, typura_1.toResult)(() => validateConfig(mergedConfig));
|
|
96
|
-
if (validationErr instanceof typura_1.ValidationError) {
|
|
97
|
-
logger_1.default.error('Invalid configuration:');
|
|
98
|
-
throw validationErr;
|
|
99
|
-
}
|
|
100
97
|
return mergedConfig;
|
|
101
98
|
}
|
|
102
99
|
exports.getConfig = getConfig;
|
|
@@ -5,7 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.filterBreakingCommits = exports.groupCommits = exports.determineReleaseType = exports.parseConventionalCommit = void 0;
|
|
7
7
|
const node_util_1 = require("node:util");
|
|
8
|
-
const logger_1 = __importDefault(require("./
|
|
8
|
+
const logger_1 = __importDefault(require("./services/logger"));
|
|
9
9
|
// eslint-disable-next-line max-lines-per-function
|
|
10
10
|
function parseConventionalCommit(commitMessage, hash) {
|
|
11
11
|
const lines = commitMessage.split('\n');
|
package/dist/defaults.js
CHANGED
|
@@ -52,7 +52,7 @@ function getPrereleaseChannel(config) {
|
|
|
52
52
|
const matchingBranch = config.branches.find((b) => b.name === branch);
|
|
53
53
|
if (!matchingBranch)
|
|
54
54
|
return undefined;
|
|
55
|
-
return matchingBranch.prereleaseChannel
|
|
55
|
+
return matchingBranch.prereleaseChannel ?? undefined;
|
|
56
56
|
}
|
|
57
57
|
exports.getPrereleaseChannel = getPrereleaseChannel;
|
|
58
58
|
//# sourceMappingURL=getPrereleaseChannel.js.map
|
package/dist/getTags.js
CHANGED
|
@@ -27,9 +27,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
27
27
|
};
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
29
|
exports.getTags = void 0;
|
|
30
|
+
/* eslint-disable max-lines-per-function */
|
|
30
31
|
const git = __importStar(require("./services/git"));
|
|
31
32
|
const semver = __importStar(require("./semver"));
|
|
32
|
-
const logger_1 = __importDefault(require("./
|
|
33
|
+
const logger_1 = __importDefault(require("./services/logger"));
|
|
33
34
|
const colorette_1 = require("colorette");
|
|
34
35
|
function getTags(prereleaseChannel) {
|
|
35
36
|
const recentTags = git.getRecentTags();
|
package/dist/index.d.ts
CHANGED
|
@@ -8,5 +8,11 @@ interface CreateReleaseParams {
|
|
|
8
8
|
draft?: boolean;
|
|
9
9
|
prerelease?: boolean;
|
|
10
10
|
}
|
|
11
|
-
export declare function createRelease(params: CreateReleaseParams): Promise<
|
|
11
|
+
export declare function createRelease(params: CreateReleaseParams): Promise<number>;
|
|
12
|
+
export declare function deleteReleaseById(params: {
|
|
13
|
+
token: string;
|
|
14
|
+
owner: string;
|
|
15
|
+
repository: string;
|
|
16
|
+
releaseId: number;
|
|
17
|
+
}): Promise<void>;
|
|
12
18
|
export {};
|
package/dist/services/github.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createRelease = void 0;
|
|
3
|
+
exports.deleteReleaseById = exports.createRelease = void 0;
|
|
4
4
|
const httpRequest_1 = require("../lib/httpRequest");
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
// eslint-disable-next-line max-lines-per-function
|
|
6
|
+
async function createRelease(params) {
|
|
7
|
+
const { token, owner, repository, tag, name, body, draft = false, prerelease = false, } = params;
|
|
7
8
|
const postData = JSON.stringify({
|
|
8
9
|
tag_name: tag,
|
|
9
10
|
name,
|
|
@@ -16,11 +17,26 @@ function createRelease(params) {
|
|
|
16
17
|
headers: {
|
|
17
18
|
Accept: 'application/vnd.github+json',
|
|
18
19
|
Authorization: `Bearer ${token}`,
|
|
19
|
-
'User-Agent': 'mhweiner',
|
|
20
20
|
'X-GitHub-Api-Version': '2022-11-28',
|
|
21
|
+
'User-Agent': 'autorel (https://npmjs.com/autorel)',
|
|
21
22
|
},
|
|
22
23
|
};
|
|
23
|
-
|
|
24
|
+
const responseText = await (0, httpRequest_1.httpRequest)('POST', url, postData, options);
|
|
25
|
+
const response = JSON.parse(responseText);
|
|
26
|
+
return response.id;
|
|
24
27
|
}
|
|
25
28
|
exports.createRelease = createRelease;
|
|
29
|
+
async function deleteReleaseById(params) {
|
|
30
|
+
const { token, owner, repository, releaseId } = params;
|
|
31
|
+
const url = `https://api.github.com/repos/${owner}/${repository}/releases/${releaseId}`;
|
|
32
|
+
const options = {
|
|
33
|
+
headers: {
|
|
34
|
+
Accept: 'application/vnd.github+json',
|
|
35
|
+
Authorization: `Bearer ${token}`,
|
|
36
|
+
'X-GitHub-Api-Version': '2022-11-28',
|
|
37
|
+
},
|
|
38
|
+
};
|
|
39
|
+
await (0, httpRequest_1.httpRequest)('DELETE', url, '', options);
|
|
40
|
+
}
|
|
41
|
+
exports.deleteReleaseById = deleteReleaseById;
|
|
26
42
|
//# sourceMappingURL=github.js.map
|
|
@@ -12,7 +12,7 @@ function warn(message) {
|
|
|
12
12
|
info((0, colorette_1.yellow)(`Warning: ${message}`));
|
|
13
13
|
}
|
|
14
14
|
function error(message) {
|
|
15
|
-
|
|
15
|
+
console.error((0, colorette_1.red)(`${prefix}Error: ${message}`));
|
|
16
16
|
}
|
|
17
17
|
exports.default = {
|
|
18
18
|
info,
|
package/dist/services/npm.d.ts
CHANGED
|
@@ -1 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Publishes the current package with an optional dist-tag.
|
|
3
|
+
*/
|
|
1
4
|
export declare function publishPackage(channel?: string): void;
|
|
5
|
+
/**
|
|
6
|
+
* Unpublishes a specific package version (e.g., "my-lib@1.2.3").
|
|
7
|
+
*/
|
|
8
|
+
export declare function unpublishPackage(packageAndVersion: string): Promise<void>;
|
package/dist/services/npm.js
CHANGED
|
@@ -1,9 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.publishPackage = void 0;
|
|
3
|
+
exports.unpublishPackage = exports.publishPackage = void 0;
|
|
4
4
|
const sh_1 = require("./sh");
|
|
5
|
+
/**
|
|
6
|
+
* Publishes the current package with an optional dist-tag.
|
|
7
|
+
*/
|
|
5
8
|
function publishPackage(channel) {
|
|
6
|
-
(0, sh_1.$) `npm publish --tag ${channel
|
|
9
|
+
(0, sh_1.$) `npm publish --tag ${channel ?? 'latest'}`;
|
|
7
10
|
}
|
|
8
11
|
exports.publishPackage = publishPackage;
|
|
12
|
+
/**
|
|
13
|
+
* Unpublishes a specific package version (e.g., "my-lib@1.2.3").
|
|
14
|
+
*/
|
|
15
|
+
async function unpublishPackage(packageAndVersion) {
|
|
16
|
+
(0, sh_1.$) `npm unpublish ${packageAndVersion}`;
|
|
17
|
+
}
|
|
18
|
+
exports.unpublishPackage = unpublishPackage;
|
|
9
19
|
//# sourceMappingURL=npm.js.map
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
interface PackageJson {
|
|
2
|
+
name: string;
|
|
3
|
+
version: string;
|
|
4
|
+
[key: string]: any;
|
|
5
|
+
}
|
|
6
|
+
export declare function read(): PackageJson;
|
|
7
|
+
/**
|
|
8
|
+
* Bump the version of the package.json file
|
|
9
|
+
*/
|
|
10
|
+
export declare function setVersion(newVersion: string): void;
|
|
11
|
+
export {};
|
|
@@ -26,12 +26,12 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
26
26
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
27
|
};
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.
|
|
30
|
-
const logger_1 = __importDefault(require("./
|
|
29
|
+
exports.setVersion = exports.read = void 0;
|
|
30
|
+
const logger_1 = __importDefault(require("./logger"));
|
|
31
31
|
const fs_1 = require("fs");
|
|
32
32
|
const fs = __importStar(require("fs"));
|
|
33
33
|
const path = __importStar(require("path"));
|
|
34
|
-
function
|
|
34
|
+
function read() {
|
|
35
35
|
const packageJsonPath = path.resolve(process.cwd(), 'package.json');
|
|
36
36
|
try {
|
|
37
37
|
const packageJsonData = fs.readFileSync(packageJsonPath, 'utf8');
|
|
@@ -42,16 +42,17 @@ function readPackageJson() {
|
|
|
42
42
|
throw error;
|
|
43
43
|
}
|
|
44
44
|
}
|
|
45
|
+
exports.read = read;
|
|
45
46
|
/**
|
|
46
47
|
* Bump the version of the package.json file
|
|
47
48
|
*/
|
|
48
|
-
function
|
|
49
|
-
const packageJson =
|
|
49
|
+
function setVersion(newVersion) {
|
|
50
|
+
const packageJson = read();
|
|
50
51
|
(0, fs_1.writeFileSync)('./package.json', JSON.stringify({
|
|
51
52
|
...packageJson,
|
|
52
53
|
version: newVersion.replace(/^v/, ''),
|
|
53
54
|
}, null, 2));
|
|
54
55
|
logger_1.default.info('Successfully updated package.json locally');
|
|
55
56
|
}
|
|
56
|
-
exports.
|
|
57
|
-
//# sourceMappingURL=
|
|
57
|
+
exports.setVersion = setVersion;
|
|
58
|
+
//# sourceMappingURL=packageJson.js.map
|
package/dist/services/sh.js
CHANGED
|
@@ -5,7 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.bash = exports.$ = void 0;
|
|
7
7
|
const child_process_1 = require("child_process");
|
|
8
|
-
const logger_1 = __importDefault(require("
|
|
8
|
+
const logger_1 = __importDefault(require("./logger"));
|
|
9
9
|
/**
|
|
10
10
|
* Executes a bash program/command and returns the output. This is a tagged template
|
|
11
11
|
* literal function, so you can use it like this:
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export type AddToRollback = (action: () => Promise<void>) => void;
|
|
2
|
+
export type Action = (addToRollback: AddToRollback) => Promise<void>;
|
|
3
|
+
export declare function transaction(action: Action, onRollback: (err: any) => void, onRollbackError: (err: any) => void): Promise<void>;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.transaction = void 0;
|
|
4
|
+
async function transaction(action, onRollback, onRollbackError) {
|
|
5
|
+
const rollbackActions = [];
|
|
6
|
+
const addToRollback = (action) => {
|
|
7
|
+
rollbackActions.push(action);
|
|
8
|
+
};
|
|
9
|
+
try {
|
|
10
|
+
return await action(addToRollback);
|
|
11
|
+
}
|
|
12
|
+
catch (err) {
|
|
13
|
+
onRollback(err);
|
|
14
|
+
// Rollback all actions
|
|
15
|
+
for (const rollbackAction of rollbackActions.reverse()) {
|
|
16
|
+
try {
|
|
17
|
+
await rollbackAction();
|
|
18
|
+
}
|
|
19
|
+
catch (rollbackError) {
|
|
20
|
+
// Log the error but continue with the rollback
|
|
21
|
+
onRollbackError(rollbackError);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
// Rethrow the original error after rollback
|
|
25
|
+
throw err;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
exports.transaction = transaction;
|
|
29
|
+
//# sourceMappingURL=transaction.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "autorel",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.4.0-next.1",
|
|
4
4
|
"description": "Automate semantic releases based on conventional commits. Similar to semantic-release but much simpler.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Marc H. Weiner <mhweiner234@gmail.com> (https://mhweiner.com)",
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
"@typescript-eslint/eslint-plugin": "^5.7.0",
|
|
51
51
|
"@typescript-eslint/parser": "^5.7.0",
|
|
52
52
|
"c8": "^7.10.0",
|
|
53
|
-
"cjs-mock": "
|
|
53
|
+
"cjs-mock": "1.9.0",
|
|
54
54
|
"eslint": "^8.4.1",
|
|
55
55
|
"hoare": "3.4.4",
|
|
56
56
|
"ts-node": "^10.4.0",
|
|
@@ -60,6 +60,6 @@
|
|
|
60
60
|
"colorette": "2.0.20",
|
|
61
61
|
"commander": "^12.1.0",
|
|
62
62
|
"js-yaml": "^4.1.0",
|
|
63
|
-
"typura": "
|
|
63
|
+
"typura": "1.6.4"
|
|
64
64
|
}
|
|
65
65
|
}
|
package/dist/getNextTag.d.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { ReleaseType } from './semver';
|
|
2
|
-
export declare function getNextTag({ highestTag, highestStableTag, highestChannelTag, useVersion, prereleaseChannel, releaseType, }: {
|
|
3
|
-
highestTag: string | undefined;
|
|
4
|
-
highestStableTag: string | undefined;
|
|
5
|
-
highestChannelTag: string | undefined;
|
|
6
|
-
useVersion: string | undefined;
|
|
7
|
-
prereleaseChannel: string | undefined;
|
|
8
|
-
releaseType: ReleaseType;
|
|
9
|
-
}): string;
|
package/dist/getNextTag.js
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.getNextTag = void 0;
|
|
27
|
-
const semver = __importStar(require("./semver"));
|
|
28
|
-
function getNextTag({ highestTag, highestStableTag, highestChannelTag, useVersion, prereleaseChannel, releaseType, }) {
|
|
29
|
-
return useVersion
|
|
30
|
-
? `v${useVersion}`
|
|
31
|
-
: semver.toTag(semver.incrVer({
|
|
32
|
-
latestVer: semver.fromTag(highestTag || 'v0.0.0'),
|
|
33
|
-
latestStableVer: semver.fromTag(highestStableTag || 'v0.0.0'),
|
|
34
|
-
releaseType,
|
|
35
|
-
prereleaseChannel,
|
|
36
|
-
latestChannelVer: highestChannelTag ? semver.fromTag(highestChannelTag) ?? undefined : undefined,
|
|
37
|
-
}));
|
|
38
|
-
}
|
|
39
|
-
exports.getNextTag = getNextTag;
|
|
40
|
-
//# sourceMappingURL=getNextTag.js.map
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.runUserPreleaseScripts = void 0;
|
|
7
|
-
const logger_1 = __importDefault(require("./lib/logger"));
|
|
8
|
-
const sh_1 = require("./services/sh");
|
|
9
|
-
function runUserPreleaseScripts(args) {
|
|
10
|
-
if (!args.preRun)
|
|
11
|
-
return;
|
|
12
|
-
logger_1.default.info('Running pre-release bash script...');
|
|
13
|
-
(0, sh_1.bash)(args.preRun);
|
|
14
|
-
}
|
|
15
|
-
exports.runUserPreleaseScripts = runUserPreleaseScripts;
|
|
16
|
-
//# sourceMappingURL=runUserPrereleaseScripts.js.map
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.runUserReleaseScripts = void 0;
|
|
7
|
-
const logger_1 = __importDefault(require("./lib/logger"));
|
|
8
|
-
const sh_1 = require("./services/sh");
|
|
9
|
-
function runUserReleaseScripts(args) {
|
|
10
|
-
if (args.run) {
|
|
11
|
-
logger_1.default.info('Running post-release bash script...');
|
|
12
|
-
(0, sh_1.bash)(args.run);
|
|
13
|
-
}
|
|
14
|
-
else if (args.runScript) {
|
|
15
|
-
// TODO: delete this block in the next major version
|
|
16
|
-
logger_1.default.warn('----------------------------');
|
|
17
|
-
logger_1.default.warn('🚨 The "runScript" option is deprecated. Please use "run" instead. 🚨');
|
|
18
|
-
logger_1.default.warn('🚨 The "runScript" option will be removed in the next major version. 🚨');
|
|
19
|
-
logger_1.default.warn('----------------------------');
|
|
20
|
-
logger_1.default.info('Running post-release bash script...');
|
|
21
|
-
(0, sh_1.bash)(args.runScript);
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
exports.runUserReleaseScripts = runUserReleaseScripts;
|
|
25
|
-
//# sourceMappingURL=runUserReleaseScripts.js.map
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.validateUseVersion = void 0;
|
|
7
|
-
const colorette_1 = require("colorette");
|
|
8
|
-
const logger_1 = __importDefault(require("./lib/logger"));
|
|
9
|
-
const semver_1 = require("./semver");
|
|
10
|
-
function validateUseVersion(useVersion, releaseType) {
|
|
11
|
-
if (!useVersion)
|
|
12
|
-
return;
|
|
13
|
-
if (/^v(.+)$/.test(useVersion))
|
|
14
|
-
throw new Error('useVersion should not start with a "v".');
|
|
15
|
-
if (!(0, semver_1.isValidTag)(useVersion))
|
|
16
|
-
throw new Error('useVersion must be a valid SemVer version');
|
|
17
|
-
if (releaseType === 'none') {
|
|
18
|
-
logger_1.default.warn(`We didn't find any commmits that would create a release, but you have set 'useVersion', which will force a release as: ${(0, colorette_1.bold)(useVersion)}.`);
|
|
19
|
-
}
|
|
20
|
-
else {
|
|
21
|
-
logger_1.default.warn(`The next version was explicitly set by useVersion to be: ${(0, colorette_1.bold)(useVersion)}.`);
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
exports.validateUseVersion = validateUseVersion;
|
|
25
|
-
//# sourceMappingURL=validateUseVersion.js.map
|
|
File without changes
|
|
File without changes
|
|
File without changes
|