autorel 0.0.12
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 +158 -0
- package/dist/changelog.d.ts +3 -0
- package/dist/changelog.js +20 -0
- package/dist/changelog.js.map +1 -0
- package/dist/changelog.spec.d.ts +1 -0
- package/dist/changelog.spec.js +95 -0
- package/dist/changelog.spec.js.map +1 -0
- package/dist/cli.d.ts +1 -0
- package/dist/cli.js +40 -0
- package/dist/cli.js.map +1 -0
- package/dist/config.d.ts +16 -0
- package/dist/config.js +102 -0
- package/dist/config.js.map +1 -0
- package/dist/config.spec.d.ts +1 -0
- package/dist/config.spec.js +126 -0
- package/dist/config.spec.js.map +1 -0
- package/dist/conventionalcommits.d.ts +16 -0
- package/dist/conventionalcommits.js +122 -0
- package/dist/conventionalcommits.js.map +1 -0
- package/dist/conventionalcommits.spec.d.ts +1 -0
- package/dist/conventionalcommits.spec.js +136 -0
- package/dist/conventionalcommits.spec.js.map +1 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.js +122 -0
- package/dist/index.js.map +1 -0
- package/dist/lib/bash.d.ts +1 -0
- package/dist/lib/bash.js +17 -0
- package/dist/lib/bash.js.map +1 -0
- package/dist/lib/colors.d.ts +5 -0
- package/dist/lib/colors.js +24 -0
- package/dist/lib/colors.js.map +1 -0
- package/dist/lib/git.d.ts +13 -0
- package/dist/lib/git.js +52 -0
- package/dist/lib/git.js.map +1 -0
- package/dist/lib/httpRequest.d.ts +10 -0
- package/dist/lib/httpRequest.js +58 -0
- package/dist/lib/httpRequest.js.map +1 -0
- package/dist/lib/npm.d.ts +1 -0
- package/dist/lib/npm.js +12 -0
- package/dist/lib/npm.js.map +1 -0
- package/dist/lib/output.d.ts +11 -0
- package/dist/lib/output.js +23 -0
- package/dist/lib/output.js.map +1 -0
- package/dist/lib/toResult.d.ts +4 -0
- package/dist/lib/toResult.js +24 -0
- package/dist/lib/toResult.js.map +1 -0
- package/dist/semver.d.ts +16 -0
- package/dist/semver.js +229 -0
- package/dist/semver.js.map +1 -0
- package/dist/semver.spec.d.ts +1 -0
- package/dist/semver.spec.js +77 -0
- package/dist/semver.spec.js.map +1 -0
- package/dist/services/github.d.ts +12 -0
- package/dist/services/github.js +26 -0
- package/dist/services/github.js.map +1 -0
- package/dist/test_fixtures/fakeLog.d.ts +6 -0
- package/dist/test_fixtures/fakeLog.js +10 -0
- package/dist/test_fixtures/fakeLog.js.map +1 -0
- package/dist/versionBump.d.ts +4 -0
- package/dist/versionBump.js +57 -0
- package/dist/versionBump.js.map +1 -0
- package/package.json +43 -0
package/README.md
ADDED
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
<picture>
|
|
2
|
+
<source srcset="docs/autorel.svg" media="(prefers-color-scheme: dark)">
|
|
3
|
+
<source srcset="docs/autorel-dark.svg" media="(prefers-color-scheme: light)">
|
|
4
|
+
<img src="docs/autorel-dark.svg" alt="Logo" style="margin: 0 0 10px" size="250">
|
|
5
|
+
</picture>
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
[](https://github.com/mhweiner/autorel/actions)
|
|
10
|
+
[](https://conventionalcommits.org)
|
|
11
|
+
[]()
|
|
12
|
+
|
|
13
|
+
A DevOps friendly, small, and simple logger for Typescript/Javascript projects. Sponsored by [Aeroview](https://aeroview.io).
|
|
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.
|
|
17
|
+
|
|
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
|
|
24
|
+
|
|
25
|
+
**Simple & Easy to Use ๐**
|
|
26
|
+
- Automatic Error serialization
|
|
27
|
+
- Out-of-the-box Typescript support
|
|
28
|
+
- Nice human readable output
|
|
29
|
+
|
|
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.
|
|
33
|
+
|
|
34
|
+
## Installation
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
npm i jsout
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## Example Usage
|
|
41
|
+
|
|
42
|
+
```typescript
|
|
43
|
+
import {logger} from 'jsout';
|
|
44
|
+
|
|
45
|
+
logger.info('test message');
|
|
46
|
+
logger.fatal('oops!', new Error(), {foo: 'bar'})
|
|
47
|
+
logger.error('', new Error('test')); //infers "test" as message
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
## Express.js HTTP Request Logger
|
|
51
|
+
|
|
52
|
+
See [jsout-express](https://github.com/mhweiner/jsout-express)
|
|
53
|
+
|
|
54
|
+
## Configuration
|
|
55
|
+
|
|
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.
|
|
57
|
+
|
|
58
|
+
You can override these settings by setting the following environment variables before running your application.
|
|
59
|
+
|
|
60
|
+
For example, here is the recommended way to run your application locally:
|
|
61
|
+
|
|
62
|
+
```bash
|
|
63
|
+
LOG=debug LOG_FORMAT=human LOG_VERBOSITY=terse node /path/to/yourApp.js
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
### `process.env.LOG`
|
|
67
|
+
|
|
68
|
+
Sets the log level. Any logs lower than this log level are ignored.
|
|
69
|
+
|
|
70
|
+
**Possible values**: `"trace"`, `"debug"`, `"info"`, `"warn"`, `"error"`, `"fatal"`
|
|
71
|
+
|
|
72
|
+
**Default**: `"info"` (recommended for production)
|
|
73
|
+
|
|
74
|
+
### `process.env.LOG_FORMAT`
|
|
75
|
+
|
|
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).
|
|
77
|
+
|
|
78
|
+
**Possible values**: `"human"`, `"json"`
|
|
79
|
+
|
|
80
|
+
**Default**: `"json"` (recommended for production)
|
|
81
|
+
|
|
82
|
+
### `process.env.LOG_VERBOSITY`
|
|
83
|
+
|
|
84
|
+
If verbose, extra metadata is appended to `log.context`. Example:
|
|
85
|
+
|
|
86
|
+
```json
|
|
87
|
+
{
|
|
88
|
+
"date": "2021-12-19T06:17:38.147Z",
|
|
89
|
+
"pid": 71971,
|
|
90
|
+
"ppid": 71970,
|
|
91
|
+
"nodeVersion": "v16.13.0"
|
|
92
|
+
}
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
**Possible values**: `"terse"`, `"verbose"`
|
|
96
|
+
|
|
97
|
+
**Default**: `"verbose"` (recommended for production)
|
|
98
|
+
|
|
99
|
+
## API
|
|
100
|
+
|
|
101
|
+
For all of the following, please note:
|
|
102
|
+
|
|
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
|
|
106
|
+
|
|
107
|
+
### `logger.trace(message?: string, data?: any, context?: any)`
|
|
108
|
+
|
|
109
|
+
Emits a log to `stdout` with a level of `TRACE (10)`
|
|
110
|
+
|
|
111
|
+
### `logger.debug(message?: string, data?: any, context?: any)`
|
|
112
|
+
|
|
113
|
+
Emits a log to `stdout` with a level of `DEBUG (20)`
|
|
114
|
+
|
|
115
|
+
### `logger.info(message?: string, data?: any, context?: any)`
|
|
116
|
+
|
|
117
|
+
Emits a log to `stdout` with a level of `INFO (30)`
|
|
118
|
+
|
|
119
|
+
### `logger.warn(message?: string, error?: any, data?: any, context?: any)`
|
|
120
|
+
|
|
121
|
+
Emits a log to `stderr` with a level of `WARN (40)`
|
|
122
|
+
|
|
123
|
+
### `logger.error(message?: string, error?: any, data?: any, context?: any)`
|
|
124
|
+
|
|
125
|
+
Emits a log to `stderr` with a level of `ERROR (50)`
|
|
126
|
+
|
|
127
|
+
### `logger.fatal(message?: string, error?: any, data?: any, context?: any)`
|
|
128
|
+
|
|
129
|
+
Emits a log to `stderr` with a level of `FATAL (60)`
|
|
130
|
+
|
|
131
|
+
## Contribution
|
|
132
|
+
|
|
133
|
+
Please contribute to this project! Issue a PR against `main` and request review.
|
|
134
|
+
|
|
135
|
+
- Please test your work thoroughly.
|
|
136
|
+
- Make sure all tests pass with appropriate coverage.
|
|
137
|
+
|
|
138
|
+
### How to build locally
|
|
139
|
+
|
|
140
|
+
```bash
|
|
141
|
+
npm i
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
### Running tests
|
|
145
|
+
|
|
146
|
+
```shell script
|
|
147
|
+
npm test
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
## Sponors
|
|
151
|
+
|
|
152
|
+
<picture>
|
|
153
|
+
<source srcset="docs/aeroview-logo-lockup.svg" media="(prefers-color-scheme: dark)">
|
|
154
|
+
<source srcset="docs/aeroview-logo-lockup-dark.svg" media="(prefers-color-scheme: light)">
|
|
155
|
+
<img src="docs/aeroview-logo-lockup-dark.svg" alt="Logo" style="max-width: 150px;margin: 0 0 10px">
|
|
156
|
+
</picture>
|
|
157
|
+
|
|
158
|
+
Aeroview is a developer-friendly, AI-powered observability platform that helps you monitor, troubleshoot, and optimize your applications. Get started for free at [https://aeroview.io](https://aeroview.io).
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.generateChangelog = void 0;
|
|
4
|
+
const conventionalcommits_1 = require("./conventionalcommits");
|
|
5
|
+
function generateChangelog(commits, commitTypeMap, breakingTitle = 'Breaking Changes') {
|
|
6
|
+
const groupedCommits = (0, conventionalcommits_1.groupCommits)(commits);
|
|
7
|
+
const breakingCommits = (0, conventionalcommits_1.filterBreakingCommits)(commits);
|
|
8
|
+
const entries = Object.entries(groupedCommits)
|
|
9
|
+
.map(([type, commits]) => {
|
|
10
|
+
const title = commitTypeMap.get(type)?.title || type;
|
|
11
|
+
return `## ${title}\n\n${commits.map((commit) => `- ${commit.description} (${commit.hash})`).join('\n')}`;
|
|
12
|
+
})
|
|
13
|
+
.join('\n\n');
|
|
14
|
+
const breaking = breakingCommits.length
|
|
15
|
+
? `## ${breakingTitle}\n\n${breakingCommits.map((commit) => `- ${commit.description} (${commit.hash})`).join('\n')}\n\n`
|
|
16
|
+
: '';
|
|
17
|
+
return `${breaking}${entries}`;
|
|
18
|
+
}
|
|
19
|
+
exports.generateChangelog = generateChangelog;
|
|
20
|
+
//# sourceMappingURL=changelog.js.map
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const hoare_1 = require("hoare");
|
|
4
|
+
const changelog_1 = require("./changelog");
|
|
5
|
+
const commitTypes = [
|
|
6
|
+
{ type: 'feat', title: 'Features', release: 'minor' },
|
|
7
|
+
{ type: 'fix', title: 'Bug Fixes', release: 'patch' },
|
|
8
|
+
{ type: 'docs', title: 'Documentation', release: 'none' },
|
|
9
|
+
];
|
|
10
|
+
const commitTypeMap = new Map(commitTypes.map((type) => [type.type, type]));
|
|
11
|
+
(0, hoare_1.test)('generateChangelog with no commits', (assert) => {
|
|
12
|
+
const commits = [];
|
|
13
|
+
const expected = '';
|
|
14
|
+
const actual = (0, changelog_1.generateChangelog)(commits, commitTypeMap);
|
|
15
|
+
assert.equal(actual, expected);
|
|
16
|
+
});
|
|
17
|
+
(0, hoare_1.test)('generateChangelog with mapped titles and no breaking changes', (assert) => {
|
|
18
|
+
const commits = [
|
|
19
|
+
{ type: 'feat', description: 'Add new feature', hash: 'abc123', breaking: false, footers: [] },
|
|
20
|
+
{ type: 'fix', description: 'Fix a bug', hash: 'def456', breaking: false, footers: [] },
|
|
21
|
+
{ type: 'docs', description: 'Update documentation', hash: 'ghi789', breaking: false, footers: [] },
|
|
22
|
+
];
|
|
23
|
+
const expected = `## Features
|
|
24
|
+
|
|
25
|
+
- Add new feature (abc123)
|
|
26
|
+
|
|
27
|
+
## Bug Fixes
|
|
28
|
+
|
|
29
|
+
- Fix a bug (def456)
|
|
30
|
+
|
|
31
|
+
## Documentation
|
|
32
|
+
|
|
33
|
+
- Update documentation (ghi789)`;
|
|
34
|
+
const actual = (0, changelog_1.generateChangelog)(commits, commitTypeMap);
|
|
35
|
+
assert.equal(actual, expected);
|
|
36
|
+
});
|
|
37
|
+
(0, hoare_1.test)('generateChangelog with mapped titles with breaking changes', (assert) => {
|
|
38
|
+
const commits = [
|
|
39
|
+
{ type: 'feat', description: 'Add new feature', hash: 'abc123', breaking: true, footers: [] },
|
|
40
|
+
{ type: 'fix', description: 'Fix a bug', hash: 'def456', breaking: false, footers: [] },
|
|
41
|
+
{ type: 'docs', description: 'Update documentation', hash: 'ghi789', breaking: false, footers: [] },
|
|
42
|
+
];
|
|
43
|
+
const expected = `## Breaking Changes
|
|
44
|
+
|
|
45
|
+
- Add new feature (abc123)
|
|
46
|
+
|
|
47
|
+
## Features
|
|
48
|
+
|
|
49
|
+
- Add new feature (abc123)
|
|
50
|
+
|
|
51
|
+
## Bug Fixes
|
|
52
|
+
|
|
53
|
+
- Fix a bug (def456)
|
|
54
|
+
|
|
55
|
+
## Documentation
|
|
56
|
+
|
|
57
|
+
- Update documentation (ghi789)`;
|
|
58
|
+
const actual = (0, changelog_1.generateChangelog)(commits, commitTypeMap);
|
|
59
|
+
assert.equal(actual, expected);
|
|
60
|
+
});
|
|
61
|
+
(0, hoare_1.test)('generateChangelog with unmapped titles', (assert) => {
|
|
62
|
+
const commits = [
|
|
63
|
+
{ type: 'feat', description: 'Add new feature', hash: 'abc123', breaking: false, footers: [] },
|
|
64
|
+
{ type: 'fix', description: 'Fix a bug', hash: 'def456', breaking: false, footers: [] },
|
|
65
|
+
{ type: 'docs', description: 'Update documentation', hash: 'ghi789', breaking: false, footers: [] },
|
|
66
|
+
];
|
|
67
|
+
const expected = `## feat
|
|
68
|
+
|
|
69
|
+
- Add new feature (abc123)
|
|
70
|
+
|
|
71
|
+
## fix
|
|
72
|
+
|
|
73
|
+
- Fix a bug (def456)
|
|
74
|
+
|
|
75
|
+
## docs
|
|
76
|
+
|
|
77
|
+
- Update documentation (ghi789)`;
|
|
78
|
+
const actual = (0, changelog_1.generateChangelog)(commits, new Map());
|
|
79
|
+
assert.equal(actual, expected);
|
|
80
|
+
});
|
|
81
|
+
(0, hoare_1.test)('generateChangelog with breaking changes and no other commits', (assert) => {
|
|
82
|
+
const commits = [
|
|
83
|
+
{ type: 'feat', description: 'Add new feature', hash: 'abc123', breaking: true, footers: [] },
|
|
84
|
+
];
|
|
85
|
+
const expected = `## Breaking Changes
|
|
86
|
+
|
|
87
|
+
- Add new feature (abc123)
|
|
88
|
+
|
|
89
|
+
## Features
|
|
90
|
+
|
|
91
|
+
- Add new feature (abc123)`;
|
|
92
|
+
const actual = (0, changelog_1.generateChangelog)(commits, commitTypeMap);
|
|
93
|
+
assert.equal(actual, expected);
|
|
94
|
+
});
|
|
95
|
+
//# sourceMappingURL=changelog.spec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"changelog.spec.js","sourceRoot":"","sources":["../src/changelog.spec.ts"],"names":[],"mappings":";;AAAA,iCAA2B;AAC3B,2CAA8C;AAI9C,MAAM,WAAW,GAAiB;IAC9B,EAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,UAAU,EAAE,OAAO,EAAE,OAAO,EAAC;IACnD,EAAC,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,WAAW,EAAE,OAAO,EAAE,OAAO,EAAC;IACnD,EAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,eAAe,EAAE,OAAO,EAAE,MAAM,EAAC;CAC1D,CAAC;AACF,MAAM,aAAa,GAAG,IAAI,GAAG,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,C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AErD,MAAM,CAAC,KAAK,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;AAEnC,CAAC,CAAC,CAAC;AAEH,IAAA,YAAI,EAAC,8DAA8D,EAAE,CAAC,MAAM,EAAE,EAAE;IAE5E,MAAM,OAAO,GAAyB;QAClC,EAAC,IAAI,EAAE,MAAM,EAAE,WAAW,EAAE,iBAAiB,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE,OAAO,EAAE,EAAE,EAAC;KAC9F,CAAC;IACF,MAAM,QAAQ,GAClB;;;;;;2BAM2B,CAAC;IACxB,MAAM,MAAM,GAAG,IAAA,6BAAiB,EAAC,OAAO,EAAE,aAAa,CAAC,CAAC;IAEzD,MAAM,CAAC,KAAK,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;AAEnC,CAAC,CAAC,CAAC"}
|
package/dist/cli.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/cli.js
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
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
|
+
const commander_1 = require("commander");
|
|
7
|
+
const colors_1 = require("./lib/colors");
|
|
8
|
+
const _1 = require(".");
|
|
9
|
+
const output_1 = __importDefault(require("./lib/output"));
|
|
10
|
+
// eslint-disable-next-line @typescript-eslint/no-require-imports, @typescript-eslint/no-var-requires
|
|
11
|
+
const packageJson = require('../package.json');
|
|
12
|
+
const program = new commander_1.Command();
|
|
13
|
+
console.log('----------------------------');
|
|
14
|
+
console.log(`${(0, colors_1.bold)('โ๏ธ autorel ')}v${packageJson.version}`);
|
|
15
|
+
console.log('----------------------------');
|
|
16
|
+
program
|
|
17
|
+
.version(packageJson.version, '-v, --version')
|
|
18
|
+
.description('An example CLI for managing a directory')
|
|
19
|
+
.option('--github-token [value]', 'Provide GitHub Token')
|
|
20
|
+
.option('--npm-token [value]', 'Provide NPM Token')
|
|
21
|
+
.option('-d, --dry', 'Do a dry run')
|
|
22
|
+
.option('-p, --pre <value>', 'Pre-release channel. If specified, the release will be marked as a pre-release. Overrides any other configuration.')
|
|
23
|
+
.option('-t, --tag <value>', 'Specify a tag to be used instead of calculating it from commit analysis. Overrides --pre.')
|
|
24
|
+
.option('-r, --run <value>', 'Bash script to run after the release is successful')
|
|
25
|
+
.option('--no-release', 'Does not create a release on GitHub (advanced use only)')
|
|
26
|
+
.option('--publish', 'Publish the package to npm, requires passing --npm-token or NPM_TOKEN environment variable')
|
|
27
|
+
.parse(process.argv);
|
|
28
|
+
const options = program.opts();
|
|
29
|
+
output_1.default.debug(`Options: ${JSON.stringify(options, null, 2)}`);
|
|
30
|
+
(0, _1.autorel)({
|
|
31
|
+
githubToken: options.githubToken,
|
|
32
|
+
npmToken: options.npmToken,
|
|
33
|
+
dryRun: options.dry,
|
|
34
|
+
postReleaseBashScript: options.run,
|
|
35
|
+
prereleaseChannel: options.pre,
|
|
36
|
+
tag: options.tag,
|
|
37
|
+
publish: options.publish,
|
|
38
|
+
noRelease: options.noRelease,
|
|
39
|
+
});
|
|
40
|
+
//# sourceMappingURL=cli.js.map
|
package/dist/cli.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";;;;;AAAA,yCAAkC;AAClC,yCAAkC;AAClC,wBAA0B;AAC1B,0DAAkC;AAElC,qGAAqG;AACrG,MAAM,WAAW,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAAC;AAC/C,MAAM,OAAO,GAAG,IAAI,mBAAO,EAAE,CAAC;AAE9B,OAAO,CAAC,GAAG,CAAC,8BAA8B,CAAC,CAAC;AAC5C,OAAO,CAAC,GAAG,CAAC,GAAG,IAAA,aAAI,EAAC,aAAa,CA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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;
|
package/dist/config.js
ADDED
|
@@ -0,0 +1,102 @@
|
|
|
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
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
+
};
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
exports.getConfig = exports.defaultConfig = void 0;
|
|
30
|
+
const fs = __importStar(require("node:fs"));
|
|
31
|
+
const path = __importStar(require("node:path"));
|
|
32
|
+
const yaml = __importStar(require("js-yaml"));
|
|
33
|
+
const rtype_1 = require("@aeroview-io/rtype");
|
|
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
|
+
};
|
|
53
|
+
const validateConfig = rtype_1.predicates.object({
|
|
54
|
+
breakingChangeTitle: rtype_1.predicates.optional(rtype_1.predicates.string()),
|
|
55
|
+
commitTypes: rtype_1.predicates.optional(rtype_1.predicates.array(rtype_1.predicates.object({
|
|
56
|
+
type: rtype_1.predicates.string(),
|
|
57
|
+
title: rtype_1.predicates.string(),
|
|
58
|
+
release: rtype_1.predicates.string(),
|
|
59
|
+
}))),
|
|
60
|
+
branches: rtype_1.predicates.optional(rtype_1.predicates.array(rtype_1.predicates.object({
|
|
61
|
+
name: rtype_1.predicates.string(),
|
|
62
|
+
prereleaseChannel: rtype_1.predicates.optional(rtype_1.predicates.string()),
|
|
63
|
+
}))),
|
|
64
|
+
});
|
|
65
|
+
/**
|
|
66
|
+
* Reads and parses a local .autorel.yaml file.
|
|
67
|
+
* @param filePath The path to the .autorel.yaml file.
|
|
68
|
+
* @returns The parsed JSON object from the YAML file.
|
|
69
|
+
*/
|
|
70
|
+
function readAutorelYaml(filePath = '.autorel.yaml') {
|
|
71
|
+
const absolutePath = path.resolve(filePath);
|
|
72
|
+
// Check if the file exists
|
|
73
|
+
if (!fs.existsSync(absolutePath)) {
|
|
74
|
+
output_1.default.log('.autorel.yaml not found, using default configuration');
|
|
75
|
+
return {};
|
|
76
|
+
}
|
|
77
|
+
const [readErr, fileContents] = (0, rtype_1.toResult)(() => fs.readFileSync(absolutePath, 'utf8'));
|
|
78
|
+
if (readErr) {
|
|
79
|
+
output_1.default.error('Error reading .autorel.yaml file:');
|
|
80
|
+
throw readErr;
|
|
81
|
+
}
|
|
82
|
+
const [parseErr, parsedData] = (0, rtype_1.toResult)(() => yaml.load(fileContents));
|
|
83
|
+
if (parseErr) {
|
|
84
|
+
output_1.default.error('Error parsing .autorel.yaml file:');
|
|
85
|
+
throw parseErr;
|
|
86
|
+
}
|
|
87
|
+
const [validationErr] = (0, rtype_1.toResult)(() => validateConfig(parsedData));
|
|
88
|
+
if (validationErr instanceof rtype_1.ValidationError) {
|
|
89
|
+
output_1.default.error('Invalid configuration:');
|
|
90
|
+
throw validationErr;
|
|
91
|
+
}
|
|
92
|
+
return parsedData;
|
|
93
|
+
}
|
|
94
|
+
function getConfig() {
|
|
95
|
+
const localConfig = readAutorelYaml();
|
|
96
|
+
return {
|
|
97
|
+
...exports.defaultConfig,
|
|
98
|
+
...localConfig,
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
exports.getConfig = get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AC,GAAG,IAAA,gBAAQ,EAAC,GAAG,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC;IAEvE,IAAI,QAAQ,EAAE;QAEV,gBAAM,CAAC,KAAK,CAAC,mCAAmC,CAAC,CAAC;QAClD,MAAM,QAAQ,CAAC;KAElB;IAED,MAAM,CAAC,aAAa,CAAC,GAAG,IAAA,gBAAQ,EAAC,GAAG,EAAE,CAAC,cAAc,CAAC,UAAU,CAAC,CAAC,CAAC;IAEnE,IAAI,aAAa,YAAY,uBAAe,EAAE;QAE1C,gBAAM,CAAC,KAAK,CAAC,wBAAwB,CAAC,CAAC;QACvC,MAAM,aAAa,CAAC;KAEvB;IAED,OAAO,UAAoB,CAAC;AAEhC,CAAC;AAED,SAAgB,SAAS;IAErB,MAAM,WAAW,GAAG,eAAe,EAAE,CAAC;IAEtC,OAAO;QACH,GAAG,qBAAa;QAChB,GAAG,WAAW;KACjB,CAAC;AAEN,CAAC;AATD,8BASC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,126 @@
|
|
|
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
|
+
/* eslint-disable max-lines-per-function */
|
|
27
|
+
const hoare_1 = require("hoare");
|
|
28
|
+
const cjs_mock_1 = require("cjs-mock");
|
|
29
|
+
const mod = __importStar(require("./config"));
|
|
30
|
+
const fakeLog_1 = require("./test_fixtures/fakeLog");
|
|
31
|
+
const rtype_1 = require("@aeroview-io/rtype");
|
|
32
|
+
(0, hoare_1.test)('readAutorelYaml: happy path, with no .autorel.yaml', async (assert) => {
|
|
33
|
+
const mockFs = {
|
|
34
|
+
existsSync: () => false,
|
|
35
|
+
readFileSync: () => {
|
|
36
|
+
throw new Error('File not found'); // This should not be called
|
|
37
|
+
},
|
|
38
|
+
};
|
|
39
|
+
const configMod = (0, cjs_mock_1.mock)('./config', {
|
|
40
|
+
'node:fs': mockFs,
|
|
41
|
+
'node:path': { resolve: (p) => p },
|
|
42
|
+
'./lib/output': fakeLog_1.fakeLogger,
|
|
43
|
+
});
|
|
44
|
+
assert.equal(configMod.getConfig(), mod.defaultConfig, 'should return the default configuration');
|
|
45
|
+
});
|
|
46
|
+
(0, hoare_1.test)('readAutorelYaml: happy path, with .autorel.yaml', async (assert) => {
|
|
47
|
+
const mockFs = {
|
|
48
|
+
existsSync: () => true,
|
|
49
|
+
readFileSync: () => `
|
|
50
|
+
breakingChangeTitle: 'BREAKING CHANGES'
|
|
51
|
+
commitTypes:
|
|
52
|
+
- type: 'test'
|
|
53
|
+
title: '๐งช Tests'
|
|
54
|
+
release: 'none'
|
|
55
|
+
- type: 'build'
|
|
56
|
+
title: '๐ Build System'
|
|
57
|
+
release: 'none'
|
|
58
|
+
`,
|
|
59
|
+
};
|
|
60
|
+
const configMod = (0, cjs_mock_1.mock)('./config', {
|
|
61
|
+
'node:fs': mockFs,
|
|
62
|
+
'node:path': { resolve: (p) => p },
|
|
63
|
+
'./lib/output': fakeLog_1.fakeLogger,
|
|
64
|
+
});
|
|
65
|
+
assert.equal(configMod.getConfig(), {
|
|
66
|
+
breakingChangeTitle: 'BREAKING CHANGES',
|
|
67
|
+
commitTypes: [
|
|
68
|
+
{ type: 'test', title: '๐งช Tests', release: 'none' },
|
|
69
|
+
{ type: 'build', title: '๐ Build System', release: 'none' },
|
|
70
|
+
],
|
|
71
|
+
branches: mod.defaultConfig.branches,
|
|
72
|
+
}, 'should return the parsed configuration');
|
|
73
|
+
});
|
|
74
|
+
(0, hoare_1.test)('readAutorelYaml: invalid configuration', async (assert) => {
|
|
75
|
+
const mockFs = {
|
|
76
|
+
existsSync: () => true,
|
|
77
|
+
readFileSync: () => `
|
|
78
|
+
breakingChange: 'BREAKING CHANGES'
|
|
79
|
+
commitTypes:
|
|
80
|
+
- test
|
|
81
|
+
- build
|
|
82
|
+
`,
|
|
83
|
+
};
|
|
84
|
+
const configMod = (0, cjs_mock_1.mock)('./config', {
|
|
85
|
+
'node:fs': mockFs,
|
|
86
|
+
'node:path': { resolve: (p) => p },
|
|
87
|
+
'./lib/output': fakeLog_1.fakeLogger,
|
|
88
|
+
});
|
|
89
|
+
assert.throws(() => configMod.getConfig(), new rtype_1.ValidationError({
|
|
90
|
+
'commitTypes.[0]': 'must be an object with keys type, title, release',
|
|
91
|
+
'commitTypes.[1]': 'must be an object with keys type, title, release',
|
|
92
|
+
}), 'should throw ValidationError');
|
|
93
|
+
});
|
|
94
|
+
(0, hoare_1.test)('readAutorelYaml: readFile error', async (assert) => {
|
|
95
|
+
const mockFs = {
|
|
96
|
+
existsSync: () => true,
|
|
97
|
+
readFileSync: () => {
|
|
98
|
+
throw new Error('something happened');
|
|
99
|
+
},
|
|
100
|
+
};
|
|
101
|
+
const configMod = (0, cjs_mock_1.mock)('./config', {
|
|
102
|
+
'node:fs': mockFs,
|
|
103
|
+
'node:path': { resolve: (p) => p },
|
|
104
|
+
'./lib/output': fakeLog_1.fakeLogger,
|
|
105
|
+
});
|
|
106
|
+
assert.throws(() => configMod.getConfig(), new Error('something happened'), 'should re-throw error');
|
|
107
|
+
});
|
|
108
|
+
(0, hoare_1.test)('readAutorelYaml: yaml error', async (assert) => {
|
|
109
|
+
const invalidYaml = `
|
|
110
|
+
a:
|
|
111
|
+
b: "This is valid
|
|
112
|
+
c: "This is invalid because the string isn't closed
|
|
113
|
+
`;
|
|
114
|
+
const mockFs = {
|
|
115
|
+
existsSync: () => true,
|
|
116
|
+
readFileSync: () => invalidYaml,
|
|
117
|
+
};
|
|
118
|
+
const configMod = (0, cjs_mock_1.mock)('./config', {
|
|
119
|
+
'node:fs': mockFs,
|
|
120
|
+
'node:path': { resolve: (p) => p },
|
|
121
|
+
'./lib/output': fakeLog_1.fakeLogger,
|
|
122
|
+
});
|
|
123
|
+
const [err] = (0, rtype_1.toResult)(() => configMod.getConfig());
|
|
124
|
+
assert.equal(err?.name, 'YAMLException', 'should re-throw error');
|
|
125
|
+
});
|
|
126
|
+
//# sourceMappingURL=config.spec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.spec.js","sourceRoot":"","sources":["../src/config.spec.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,2CAA2C;AAC3C,iCAA2B;AAC3B,uCAA8B;AAC9B,8CAAgC;AAChC,qDAAmD;AACnD,8CAA6D;AAE7D,IAAA,YAAI,EAAC,oDAAoD,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE;IAExE,MAAM,MAAM,GAAG;QACX,UAAU,EAAE,GAAG,EAAE,CAAC,KAAK;QACvB,YAAY,EAAE,GAAG,EAAE;YAEf,MAAM,IAA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AAM,EAAE,EAAE;IAEjD,MAAM,WAAW,GAAG;;;;CAIvB,CAAC;IACE,MAAM,MAAM,GAAG;QACX,UAAU,EAAE,GAAG,EAAE,CAAC,IAAI;QACtB,YAAY,EAAE,GAAG,EAAE,CAAC,WAAW;KAClC,CAAC;IACF,MAAM,SAAS,GAAe,IAAA,eAAI,EAAC,UAAU,EAAE;QAC3C,SAAS,EAAE,MAAM;QACjB,WAAW,EAAE,EAAC,OAAO,EAAE,CAAC,CAAS,EAAE,EAAE,CAAC,CAAC,EAAC;QACxC,cAAc,EAAE,oBAAU;KAC7B,CAAC,CAAC;IAEH,MAAM,CAAC,GAAG,CAAC,GAAG,IAAA,gBAAQ,EAAC,GAAG,EAAE,CAAC,SAAS,CAAC,SAAS,EAAE,CAAC,CAAC;IAEpD,MAAM,CAAC,KAAK,CAAC,GAAG,EAAE,IAAI,EAAE,eAAe,EAAE,uBAAuB,CAAC,CAAC;AAEtE,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { CommitType } from './config';
|
|
2
|
+
type ReleaseType = 'major' | 'minor' | 'patch' | 'none';
|
|
3
|
+
export type ConventionalCommit = {
|
|
4
|
+
hash: string;
|
|
5
|
+
type: string;
|
|
6
|
+
scope?: string;
|
|
7
|
+
description: string;
|
|
8
|
+
body?: string;
|
|
9
|
+
footers: string[];
|
|
10
|
+
breaking: boolean;
|
|
11
|
+
};
|
|
12
|
+
export declare function parseConventionalCommit(commitMessage: string, hash: string): ConventionalCommit | undefined;
|
|
13
|
+
export declare function determineReleaseType(commits: ConventionalCommit[], commitTypeMap: Map<string, CommitType>): ReleaseType;
|
|
14
|
+
export declare function groupCommits(commits: ConventionalCommit[]): Record<string, ConventionalCommit[]>;
|
|
15
|
+
export declare function filterBreakingCommits(commits: ConventionalCommit[]): ConventionalCommit[];
|
|
16
|
+
export {};
|