autorel 0.0.14 → 0.0.16

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.
Files changed (42) hide show
  1. package/README.md +177 -70
  2. package/bin/cli.js +3 -0
  3. package/dist/changelog.d.ts +1 -1
  4. package/dist/cli.js +10 -6
  5. package/dist/config.d.ts +2 -16
  6. package/dist/config.js +10 -20
  7. package/dist/conventionalcommits.d.ts +1 -1
  8. package/dist/defaults.d.ts +2 -0
  9. package/dist/defaults.js +22 -0
  10. package/dist/index.d.ts +14 -1
  11. package/dist/index.js +25 -4
  12. package/dist/lib/bash.d.ts +2 -0
  13. package/dist/lib/bash.js +10 -1
  14. package/package.json +7 -1
  15. package/dist/changelog.js.map +0 -1
  16. package/dist/changelog.spec.d.ts +0 -1
  17. package/dist/changelog.spec.js +0 -95
  18. package/dist/changelog.spec.js.map +0 -1
  19. package/dist/cli.js.map +0 -1
  20. package/dist/config.js.map +0 -1
  21. package/dist/config.spec.d.ts +0 -1
  22. package/dist/config.spec.js +0 -126
  23. package/dist/config.spec.js.map +0 -1
  24. package/dist/conventionalcommits.js.map +0 -1
  25. package/dist/conventionalcommits.spec.d.ts +0 -1
  26. package/dist/conventionalcommits.spec.js +0 -136
  27. package/dist/conventionalcommits.spec.js.map +0 -1
  28. package/dist/index.js.map +0 -1
  29. package/dist/lib/bash.js.map +0 -1
  30. package/dist/lib/colors.js.map +0 -1
  31. package/dist/lib/git.js.map +0 -1
  32. package/dist/lib/httpRequest.js.map +0 -1
  33. package/dist/lib/npm.js.map +0 -1
  34. package/dist/lib/output.js.map +0 -1
  35. package/dist/lib/toResult.js.map +0 -1
  36. package/dist/semver.js.map +0 -1
  37. package/dist/semver.spec.d.ts +0 -1
  38. package/dist/semver.spec.js +0 -77
  39. package/dist/semver.spec.js.map +0 -1
  40. package/dist/services/github.js.map +0 -1
  41. package/dist/test_fixtures/fakeLog.js.map +0 -1
  42. package/dist/versionBump.js.map +0 -1
package/README.md CHANGED
@@ -10,123 +10,230 @@
10
10
  [![Conventional Commits](https://img.shields.io/badge/Conventional%20Commits-1.0.0-yellow.svg)](https://conventionalcommits.org)
11
11
  [![SemVer](https://img.shields.io/badge/SemVer-2.0.0-blue)]()
12
12
 
13
- A DevOps friendly, small, and simple logger for Typescript/Javascript projects. Sponsored by [Aeroview](https://aeroview.io).
13
+ Automate releases based on [SemVer](https://semver.org/) and [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/). Like `semantic-release` and `release-please` but much simpler and more flexible.
14
14
 
15
- **Structured Logs 🔒**
16
- - Supports both human-readable CLI output and JSON output for log aggregation into services like sumologic, New Relic, DataDog, etc.
15
+ Autorel automatically does the following, if appropriate:
17
16
 
18
- **Defensive & Devops Friendly 🛡**
19
- - Logs are enabled in production mode by default
20
- - Transport should be handled outside of the process via `STDOUT` and `STDERR`
21
- - Configuration should also be handled outside of the code
22
- - Simple configurations make it hard to mess up
23
- - Minimal dependencies
17
+ - Bumps the version based on the commit messages
18
+ - Creates a new release on GitHub with Release Notes
19
+ - Publishes the release to NPM
20
+ - Any other custom release steps you want to add
24
21
 
25
- **Simple & Easy to Use 😃**
26
- - Automatic Error serialization
27
- - Out-of-the-box Typescript support
28
- - Nice human readable output
22
+ **✅ Conventional Commit and SemVer Compliant**
23
+ - Unlike some other tools, `autorel` is 100% compliant with Conventional Commits and SemVer out of the box, including "!" for breaking changes
29
24
 
30
- **Flexible & Powerful 💪**
31
- - Easily set configuration using simple CLI overrides
32
- - Simple and well-defined enough to build custom tooling around, such as custom error handling and logging pipelines.
25
+ **😃 Simple & Easy to Use**
26
+ - No confusing configuration files
27
+ - Works with any CI/CD system, including GitHub Actions
28
+ - Out of the box TypeScript support
33
29
 
34
- ## Installation
30
+ **💪 Flexible & Powerful**
31
+ - Use via `npx`, or import as a library
32
+ - If using CLI, supports both `yaml` configuration and arguments
33
+
34
+ # Example Usage (CLI)
35
35
 
36
36
  ```bash
37
- npm i jsout
37
+ npx autorel --publish --run "echo 'Hello, World!'"
38
38
  ```
39
-
40
- ## Example Usage
41
39
 
42
- ```typescript
43
- import {logger} from 'jsout';
40
+ This will:
41
+
42
+ 1. Bump the version based on the commit messages, push the new tag, and change the package.json version
43
+ 2. Create a new release on GitHub with Release Notes
44
+ 3. Publish the release to NPM
45
+ 4. Run the command `echo 'Hello, World!'` via `bash` and `child_process`
44
46
 
45
- logger.info('test message');
46
- logger.fatal('oops!', new Error(), {foo: 'bar'})
47
- logger.error('', new Error('test')); //infers "test" as message
47
+ > If you don't want to use npx, you can also install `autorel` globally and run it that way:
48
+
49
+ ```bash
50
+ npm i -g autorel
51
+ autorel --publish --run "echo 'Hello, World!'"
48
52
  ```
49
53
 
50
- ## Express.js HTTP Request Logger
54
+ # Example Usage (Library)
51
55
 
52
- See [jsout-express](https://github.com/mhweiner/jsout-express)
56
+ 1. Install `autorel` as a dependency
53
57
 
54
- ## Configuration
58
+ ```bash
59
+ npm i autorel
60
+ ```
55
61
 
56
- Configuration is set through the CLI environment variables. By default, the logger is set to `info` level, `json` format, and `verbose` verbosity, which is recommended for production.
62
+ 2. Import and use in your project
57
63
 
58
- You can override these settings by setting the following environment variables before running your application.
64
+ ```typescript
65
+ import {autorel} from 'autorel';
59
66
 
60
- For example, here is the recommended way to run your application locally:
67
+ autorel({
68
+ publish: true
69
+ run: 'echo "Hello, World!"'
70
+ });
71
+ ```
72
+ This will do the same as the CLI example above.
61
73
 
62
- ```bash
63
- LOG=debug LOG_FORMAT=human LOG_VERBOSITY=terse node /path/to/yourApp.js
64
- ```
74
+ # Configuration
75
+
76
+ Unless otherwise noted, configuration can be done via `yaml`, file, CLI arguments, or any combination of the two. CLI arguments take precedence and will override the `yaml` file.
77
+
78
+ You can also use the library in your project, in which case you can pass the options directly to the `autorel` function.
79
+
80
+ All arguments are optional, but setting `branches` is recommended.
81
+
82
+ > If using yaml, the file must be named `autorel.yml` and be in the root of your project.
83
+
84
+ ## help (CLI only)
85
+
86
+ Man page for the CLI
87
+
88
+ - CLI: `--help`
89
+
90
+ ## publish
91
+
92
+ Whether to publish the release to NPM. If `true`, you must be authenticated with NPM. To do so via GitHub Actions, see [this](https://docs.github.com/en/actions/guides/publishing-nodejs-packages#publishing-packages-to-the-npm-registry).
93
+
94
+ - CLI: `--publish`
95
+ - Argument: `publish: boolean`
96
+ - Default: `false`
97
+
98
+ ## dryRun
99
+
100
+ Whether to run in dry-run mode. This will not push the tag, create the release, publish to NPM, or run the command.
101
+
102
+ - CLI: `--dry`
103
+ - Argument: `dryRun: boolean`
104
+ - Default: `false`
105
+
106
+ ## noRelease
65
107
 
66
- ### `process.env.LOG`
108
+ Whether to skip creating a release on GitHub. If `true`, the release will not be created, but the tag will still be pushed and the package on npm will still be updated, if applicable.
67
109
 
68
- Sets the log level. Any logs lower than this log level are ignored.
110
+ - CLI: `--no-release`
111
+ - Argument: `noRelease: boolean`
112
+ - Default: `false`
69
113
 
70
- **Possible values**: `"trace"`, `"debug"`, `"info"`, `"warn"`, `"error"`, `"fatal"`
114
+ ## run
71
115
 
72
- **Default**: `"info"` (recommended for production)
116
+ A command to run after the release is complete. This will be run via `child_process`.
73
117
 
74
- ### `process.env.LOG_FORMAT`
118
+ - CLI: `--run`
119
+ - Argument: `run: string`
120
+ - Default: `undefined`
75
121
 
76
- Set the format for the output to either be human-readable (great for local development in the console), or JSON formatted (great for data aggregation on a server).
122
+ ## runScript (YAML only)
77
123
 
78
- **Possible values**: `"human"`, `"json"`
124
+ A bash script to run after the release is complete. This will be run via `bash` and `child_process`.
79
125
 
80
- **Default**: `"json"` (recommended for production)
126
+ - Argument: `runScript: string`
127
+ - Default: `undefined`
81
128
 
82
- ### `process.env.LOG_VERBOSITY`
129
+ > This requires `bash` to be installed on the system.
83
130
 
84
- If verbose, extra metadata is appended to `log.context`. Example:
131
+ You can use the multi-line string syntax in YAML to write a script:
85
132
 
86
- ```json
87
- {
88
- "date": "2021-12-19T06:17:38.147Z",
89
- "pid": 71971,
90
- "ppid": 71970,
91
- "nodeVersion": "v16.13.0"
92
- }
133
+ ```yaml
134
+ runScript: |
135
+ echo 'Hello, World!' > hello.txt
136
+ echo 'Goodbye, World!' > goodbye.txt
93
137
  ```
94
138
 
95
- **Possible values**: `"terse"`, `"verbose"`
139
+ ## tag
96
140
 
97
- **Default**: `"verbose"` (recommended for production)
141
+ The tag to use for the release. Note that this will skip the commit message analysis and use the tag verbatim. Always results in a release being created unless `noRelease` is `true`. Advanced usage only.
98
142
 
99
- ## API
143
+ - CLI: `--tag`
144
+ - Argument: `tag: string`
145
+ - Default: `undefined`
100
146
 
101
- For all of the following, please note:
147
+ ## pre-release
102
148
 
103
- - `error` should be an actual `Error` object with stack traces. This is not enforced.
104
- - `context` should by any information not necessarily directly related to the error, ie. server request information, app component, configurations, etc. This is where the [verbose metadata](#processenvlog_verbosity) is appended (this will override anything in the context object).
105
- - `data` any object that might be useful to debug the error, or any pertinant information relating to the log message
149
+ The pre-release channel to use. This will be appended to the version number. For example, if the version is `1.0.0` and the pre-release is `alpha`, the version will be `1.0.0-alpha.1`. For "production" releases, leave this blank. In this case, "latest" will be used for the NPM tag/channel.
106
150
 
107
- ### `logger.trace(message?: string, data?: any, context?: any)`
151
+ - CLI: `--pre`
152
+ - Argument: `pre: string`
153
+ - Default: `undefined`
108
154
 
109
- Emits a log to `stdout` with a level of `TRACE (10)`
155
+ ## breakingChangeTitle (YAML only)
110
156
 
111
- ### `logger.debug(message?: string, data?: any, context?: any)`
157
+ The title to use for the breaking changes section in the release notes.
112
158
 
113
- Emits a log to `stdout` with a level of `DEBUG (20)`
159
+ - Argument: `breakingChangeTitle: string`
160
+ - Default: `"🚨 Breaking Changes 🚨"`
114
161
 
115
- ### `logger.info(message?: string, data?: any, context?: any)`
162
+ ## commitTypes (YAML only)
116
163
 
117
- Emits a log to `stdout` with a level of `INFO (30)`
164
+ The commit types to use for both the release notes and version bumping. If not provided, the default commit types can be found in [src/defaults.ts](src/defaults.ts).
118
165
 
119
- ### `logger.warn(message?: string, error?: any, data?: any, context?: any)`
166
+ - Argument: `commitTypes: CommitType[]`
120
167
 
121
- Emits a log to `stderr` with a level of `WARN (40)`
168
+ ## branches (YAML only)
122
169
 
123
- ### `logger.error(message?: string, error?: any, data?: any, context?: any)`
170
+ The branches to use for the release along with their channel. If not provided, the default is:
124
171
 
125
- Emits a log to `stderr` with a level of `ERROR (50)`
172
+ ```yaml
173
+ - {name: 'main'}
174
+ ```
175
+
176
+ The above will release to the `latest` channel on NPM. If you want to release to a different channel, you can specify it like so:
177
+
178
+ ```yaml
179
+ branches:
180
+ - {name: 'main'}
181
+ - {name: 'develop', channel: 'alpha'}
182
+ - {name: 'staging', channel: 'beta'}
183
+ ```
184
+
185
+ The above will release to the `latest` channel (production) on NPM for the `main` branch, the `alpha` pre-release channel for the `develop` branch, and the `beta` pre-release channel for the `staging` branch.
186
+
187
+ - Argument: `branches: ReleaseBranch[]`
188
+
189
+ # Sample YAML Configuration
190
+
191
+ <sub>_.autorel.yaml_</sub>
192
+ ```yaml
193
+ branches:
194
+ - {name: main}
195
+ - {name: next, channel: next}
196
+ - {name: beta, channel: beta}
197
+ publish: true
198
+ run: echo 'Hello, World!'
199
+ ```
200
+
201
+ # Types
126
202
 
127
- ### `logger.fatal(message?: string, error?: any, data?: any, context?: any)`
203
+ ## CommitType
128
204
 
129
- Emits a log to `stderr` with a level of `FATAL (60)`
205
+ ```typescript
206
+ type CommitType = {
207
+ type: string;
208
+ title: string;
209
+ release: 'major' | 'minor' | 'patch' | 'none';
210
+ };
211
+ ```
212
+
213
+ ## ReleaseBranch
214
+
215
+ ```typescript
216
+ type ReleaseBranch = {
217
+ name: string;
218
+ channel?: string;
219
+ };
220
+ ```
221
+
222
+ ## Config
223
+
224
+ ```typescript
225
+ type Config = {
226
+ run?: string;
227
+ publish?: boolean;
228
+ dryRun?: boolean;
229
+ noRelease?: boolean;
230
+ tag?: string;
231
+ pre?: string;
232
+ breakingChangeTitle?: string;
233
+ commitTypes?: CommitType[];
234
+ branches?: ReleaseBranch[];
235
+ };
236
+ ```
130
237
 
131
238
  ## Contribution
132
239
 
package/bin/cli.js ADDED
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+
3
+ require('../dist/cli');
@@ -1,3 +1,3 @@
1
- import { CommitType } from './config';
1
+ import { CommitType } from '.';
2
2
  import { ConventionalCommit } from './conventionalcommits';
3
3
  export declare function generateChangelog(commits: ConventionalCommit[], commitTypeMap: Map<string, CommitType>, breakingTitle?: string): string;
package/dist/cli.js CHANGED
@@ -7,6 +7,7 @@ const commander_1 = require("commander");
7
7
  const colors_1 = require("./lib/colors");
8
8
  const _1 = require(".");
9
9
  const output_1 = __importDefault(require("./lib/output"));
10
+ const config_1 = require("./config");
10
11
  // eslint-disable-next-line @typescript-eslint/no-require-imports, @typescript-eslint/no-var-requires
11
12
  const packageJson = require('../package.json');
12
13
  const program = new commander_1.Command();
@@ -16,19 +17,22 @@ console.log('----------------------------');
16
17
  program
17
18
  .version(packageJson.version, '-v, --version')
18
19
  .description('An example CLI for managing a directory')
19
- .option('-d, --dry', 'Do a dry run')
20
- .option('-p, --pre <value>', 'Pre-release channel. If specified, the release will be marked as a pre-release. Overrides any other configuration.')
21
- .option('-t, --tag <value>', 'Specify a tag to be used instead of calculating it from commit analysis. Overrides --pre.')
22
- .option('-r, --run <value>', 'Bash script to run after the release is successful')
20
+ .option('--dry', 'Do a dry run')
21
+ .option('--pre-release <value>', 'Pre-release channel. If specified, the release will be marked as a pre-release. Overrides any other configuration.')
22
+ .option('--tag <value>', 'Specify a tag to be used instead of calculating it from commit analysis. Overrides --pre.')
23
+ .option('--run <value>', 'Command to run after the release is successful')
23
24
  .option('--no-release', 'Does not create a release on GitHub (advanced use only)')
24
25
  .option('--publish', 'Publish the package to npm, requires passing --npm-token or NPM_TOKEN environment variable')
25
26
  .parse(process.argv);
26
27
  const options = program.opts();
28
+ const config = (0, config_1.getConfig)();
27
29
  output_1.default.debug(`Options: ${JSON.stringify(options, null, 2)}`);
30
+ output_1.default.debug(`Config: ${JSON.stringify(config, null, 2)}`);
28
31
  (0, _1.autorel)({
32
+ ...config,
29
33
  dryRun: options.dry,
30
- postReleaseBashScript: options.run,
31
- prereleaseChannel: options.pre,
34
+ run: options.run,
35
+ prereleaseChannel: options.preRelease,
32
36
  tag: options.tag,
33
37
  publish: options.publish,
34
38
  noRelease: options.noRelease,
package/dist/config.d.ts CHANGED
@@ -1,16 +1,2 @@
1
- export type CommitType = {
2
- type: string;
3
- title: string;
4
- release: 'minor' | 'patch' | 'none';
5
- };
6
- export type ReleaseBranch = {
7
- name: string;
8
- prereleaseChannel?: string;
9
- };
10
- export type Config = {
11
- breakingChangeTitle: string;
12
- commitTypes: CommitType[];
13
- branches: ReleaseBranch[];
14
- };
15
- export declare const defaultConfig: Config;
16
- export declare function getConfig(): Config;
1
+ import { Args } from '.';
2
+ export declare function getConfig(): Args;
package/dist/config.js CHANGED
@@ -26,31 +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 = exports.defaultConfig = void 0;
29
+ exports.getConfig = 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 rtype_1 = require("@aeroview-io/rtype");
34
34
  const output_1 = __importDefault(require("./lib/output"));
35
- exports.defaultConfig = {
36
- breakingChangeTitle: '🚨 Breaking Changes 🚨',
37
- commitTypes: [
38
- { type: 'feat', title: '✨ Features', release: 'minor' },
39
- { type: 'fix', title: '🐛 Bug Fixes', release: 'patch' },
40
- { type: 'perf', title: '⚡ Performance Improvements', release: 'patch' },
41
- { type: 'revert', title: '⏪ Reverts', release: 'patch' },
42
- { type: 'docs', title: '📚 Documentation', release: 'none' },
43
- { type: 'style', title: '💅 Styles', release: 'none' },
44
- { type: 'refactor', title: '🛠 Code Refactoring', release: 'none' },
45
- { type: 'test', title: '🧪 Tests', release: 'none' },
46
- { type: 'build', title: '🏗 Build System', release: 'none' },
47
- { type: 'ci', title: '🔧 Continuous Integration', release: 'none' },
48
- ],
49
- branches: [
50
- { name: 'main' },
51
- ],
52
- };
35
+ const defaults_1 = require("./defaults");
53
36
  const validateConfig = rtype_1.predicates.object({
37
+ dryRun: rtype_1.predicates.optional(rtype_1.predicates.boolean()),
38
+ run: rtype_1.predicates.optional(rtype_1.predicates.string()),
39
+ runScript: rtype_1.predicates.optional(rtype_1.predicates.string()),
40
+ prereleaseChannel: rtype_1.predicates.optional(rtype_1.predicates.string()),
41
+ tag: rtype_1.predicates.optional(rtype_1.predicates.string()),
42
+ noRelease: rtype_1.predicates.optional(rtype_1.predicates.boolean()),
43
+ publish: rtype_1.predicates.optional(rtype_1.predicates.boolean()),
54
44
  breakingChangeTitle: rtype_1.predicates.optional(rtype_1.predicates.string()),
55
45
  commitTypes: rtype_1.predicates.optional(rtype_1.predicates.array(rtype_1.predicates.object({
56
46
  type: rtype_1.predicates.string(),
@@ -94,7 +84,7 @@ function readAutorelYaml(filePath = '.autorel.yaml') {
94
84
  function getConfig() {
95
85
  const localConfig = readAutorelYaml();
96
86
  return {
97
- ...exports.defaultConfig,
87
+ ...defaults_1.defaultConfig,
98
88
  ...localConfig,
99
89
  };
100
90
  }
@@ -1,4 +1,4 @@
1
- import { CommitType } from './config';
1
+ import { CommitType } from '.';
2
2
  type ReleaseType = 'major' | 'minor' | 'patch' | 'none';
3
3
  export type ConventionalCommit = {
4
4
  hash: string;
@@ -0,0 +1,2 @@
1
+ import { Args } from '.';
2
+ export declare const defaultConfig: Args;
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.defaultConfig = void 0;
4
+ exports.defaultConfig = {
5
+ breakingChangeTitle: '🚨 Breaking Changes 🚨',
6
+ commitTypes: [
7
+ { type: 'feat', title: '✨ Features', release: 'minor' },
8
+ { type: 'fix', title: '🐛 Bug Fixes', release: 'patch' },
9
+ { type: 'perf', title: '🚀 Performance Improvements', release: 'patch' },
10
+ { type: 'revert', title: '⏪ Reverts', release: 'patch' },
11
+ { type: 'docs', title: '📚 Documentation', release: 'none' },
12
+ { type: 'style', title: '💅 Styles', release: 'none' },
13
+ { type: 'refactor', title: '🛠 Code Refactoring', release: 'none' },
14
+ { type: 'test', title: '🧪 Tests', release: 'none' },
15
+ { type: 'build', title: '🏗 Build System', release: 'none' },
16
+ { type: 'ci', title: '🔧 Continuous Integration', release: 'none' },
17
+ ],
18
+ branches: [
19
+ { name: 'main' },
20
+ ],
21
+ };
22
+ //# sourceMappingURL=defaults.js.map
package/dist/index.d.ts CHANGED
@@ -1,10 +1,23 @@
1
+ export type CommitType = {
2
+ type: string;
3
+ title: string;
4
+ release: 'minor' | 'patch' | 'none';
5
+ };
6
+ export type ReleaseBranch = {
7
+ name: string;
8
+ prereleaseChannel?: string;
9
+ };
1
10
  export type Args = {
2
11
  dryRun?: boolean;
3
- postReleaseBashScript?: string;
12
+ run?: string;
13
+ runScript?: string;
4
14
  prereleaseChannel?: string;
5
15
  tag?: string;
6
16
  noRelease?: boolean;
7
17
  publish?: boolean;
18
+ breakingChangeTitle: string;
19
+ commitTypes: CommitType[];
20
+ branches: ReleaseBranch[];
8
21
  };
9
22
  export declare function getPrereleaseChannel(args: Args): string | undefined;
10
23
  export declare function autorel(args: Args): Promise<void>;
package/dist/index.js CHANGED
@@ -38,6 +38,7 @@ const github = __importStar(require("./services/github"));
38
38
  const output_1 = __importDefault(require("./lib/output"));
39
39
  const config_1 = require("./config");
40
40
  const versionBump_1 = require("./versionBump");
41
+ const bash_1 = require("./lib/bash");
41
42
  function getPrereleaseChannel(args) {
42
43
  if (args.prereleaseChannel)
43
44
  return args.prereleaseChannel;
@@ -49,7 +50,7 @@ function getPrereleaseChannel(args) {
49
50
  throw new Error('Branches are not defined in the configuration.');
50
51
  const matchingBranch = config.branches.find((b) => b.name === branch);
51
52
  if (!matchingBranch)
52
- throw new Error(`Branch ${branch} is not defined in the configuration.`);
53
+ return undefined;
53
54
  return matchingBranch.prereleaseChannel || undefined;
54
55
  }
55
56
  exports.getPrereleaseChannel = getPrereleaseChannel;
@@ -61,8 +62,7 @@ async function autorel(args) {
61
62
  if (prereleaseChannel && !args.tag) {
62
63
  output_1.default.log(`Using prerelease channel: ${color.bold(prereleaseChannel)}`);
63
64
  }
64
- const config = (0, config_1.getConfig)();
65
- const commitTypeMap = new Map(config.commitTypes.map((type) => [type.type, type]));
65
+ const commitTypeMap = new Map(args.commitTypes.map((type) => [type.type, type]));
66
66
  const lastTag = git.getLastTag();
67
67
  const lastProdTag = git.getLastProdTag();
68
68
  output_1.default.log(`The last tag is: ${lastTag ? lastTag : color.grey('none')}`);
@@ -89,7 +89,7 @@ async function autorel(args) {
89
89
  else {
90
90
  output_1.default.log(`The next version is: ${color.bold(nextTag)}`);
91
91
  }
92
- const changelog = (0, changelog_1.generateChangelog)(parsedCommits, commitTypeMap, config.breakingChangeTitle);
92
+ const changelog = (0, changelog_1.generateChangelog)(parsedCommits, commitTypeMap, args.breakingChangeTitle);
93
93
  output_1.default.debug(`The changelog is:\n${changelog}`);
94
94
  if (args.dryRun)
95
95
  return;
@@ -107,6 +107,27 @@ async function autorel(args) {
107
107
  (0, versionBump_1.versionBump)(nextTag);
108
108
  // publish package
109
109
  args.publish && npm.publishPackage(prereleaseChannel);
110
+ process.env.NEXT_VERSION = nextTag.replace('v', '');
111
+ process.env.NEXT_TAG = nextTag;
112
+ // run post-release script
113
+ if (args.run) {
114
+ output_1.default.log('Running post-release command:');
115
+ output_1.default.log('');
116
+ output_1.default.log('----------------------------');
117
+ output_1.default.log(args.run);
118
+ output_1.default.log('----------------------------');
119
+ output_1.default.log('');
120
+ (0, bash_1.cmd)(args.run);
121
+ }
122
+ else if (args.runScript) {
123
+ output_1.default.log('Running post-release bash script:');
124
+ output_1.default.log('');
125
+ output_1.default.log('----------------------------');
126
+ output_1.default.log(args.runScript);
127
+ output_1.default.log('----------------------------');
128
+ output_1.default.log('');
129
+ (0, bash_1.bash)(args.runScript);
130
+ }
110
131
  }
111
132
  exports.autorel = autorel;
112
133
  //# sourceMappingURL=index.js.map
@@ -1 +1,3 @@
1
1
  export declare function $(strings: TemplateStringsArray, ...values: any[]): string;
2
+ export declare function bash(cmd: string): void;
3
+ export declare function cmd(cmd: string): void;
package/dist/lib/bash.js CHANGED
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.$ = void 0;
6
+ exports.cmd = exports.bash = exports.$ = void 0;
7
7
  const child_process_1 = require("child_process");
8
8
  const output_1 = __importDefault(require("./output"));
9
9
  function $(strings, ...values) {
@@ -14,4 +14,13 @@ function $(strings, ...values) {
14
14
  return output.trim();
15
15
  }
16
16
  exports.$ = $;
17
+ function bash(cmd) {
18
+ const escapedCommand = cmd.replace(/(["$`\\])/g, '\\$1').replace(/\n/g, '\\n');
19
+ (0, child_process_1.execSync)(`bash -c "${escapedCommand}"`, { encoding: 'utf8', stdio: 'inherit' });
20
+ }
21
+ exports.bash = bash;
22
+ function cmd(cmd) {
23
+ (0, child_process_1.execSync)(cmd, { encoding: 'utf8', stdio: 'inherit' });
24
+ }
25
+ exports.cmd = cmd;
17
26
  //# sourceMappingURL=bash.js.map
package/package.json CHANGED
@@ -1,13 +1,19 @@
1
1
  {
2
2
  "name": "autorel",
3
- "version": "0.0.14",
3
+ "version": "0.0.16",
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)",
7
7
  "main": "dist/index.js",
8
8
  "types": "dist/index.d.ts",
9
+ "bin": {
10
+ "autorel": "bin/cli.js"
11
+ },
9
12
  "files": [
13
+ "bin",
10
14
  "dist",
15
+ "!dist/**/*.map",
16
+ "!dist/**/*.spec.*",
11
17
  "package.json",
12
18
  "package-lock.json"
13
19
  ],
@@ -1 +0,0 @@
1
- {"version":3,"file":"changelog.js","sourceRoot":"","sources":["../src/changelog.ts"],"names":[],"mappings":";;;AACA,+DAA8F;AAE9F,SAAgB,iBAAiB,CAC7B,OAA6B,EAC7B,aAAsC,EACtC,aAAa,GAAG,kBAAkB;IAGlC,MAAM,cAAc,GAAG,IAAA,kCAAY,EAAC,OAAO,CAAC,CAAC;IAC7C,MAAM,eAAe,GAAG,IAAA,2CAAqB,EAAC,OAAO,CAAC,CAAC;IACvD,MAAM,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC,cAAc,CAAC;SACzC,GAAG,CAAC,CAAC,CAAC,IAAI,EAAE,OAAO,CAAC,EAAE,EAAE;QAErB,MAAM,KAAK,GAAG,aAAa,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,KAAK,IAAI,IAAI,CAAC;QAErD,OAAO,MAAM,KAAK,OAAO,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,KAAK,MAAM,CAAC,WAAW,KAAK,MAAM,CAAC,IAAI,GAAG,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;IAE9G,CAAC,CAAC;SACD,IAAI,CAAC,MAAM,CAAC,CAAC;IAClB,MAAM,QAAQ,GAAG,eAAe,CAAC,MAAM;QACnC,CAAC,CAAC,MAAM,aAAa,OAAO,eAAe,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,KAAK,MAAM,CAAC,WAAW,KAAK,MAAM,CAAC,IAAI,GAAG,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM;QACxH,CAAC,CAAC,EAAE,CAAC;IAET,OAAO,GAAG,QAAQ,GAAG,OAAO,EAAE,CAAC;AAEnC,CAAC;AAvBD,8CAuBC"}
@@ -1 +0,0 @@
1
- export {};