@frsource/release-it-config 1.1.0 → 1.3.0
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 +3 -0
- package/{version-plugin.mjs → cross-deps-version-plugin.mjs} +21 -23
- package/index.cjs +3 -1
- package/index.d.cts +2 -0
- package/monorepoIndependent.cjs +19 -33
- package/monorepoIndependent.d.cts +56 -0
- package/package.json +14 -3
- package/version-file-plugin.mjs +43 -0
- package/CHANGELOG.md +0 -14
package/README.md
ADDED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { Plugin } from
|
|
2
|
-
import { existsSync, readFileSync, writeFileSync } from
|
|
3
|
-
import { join } from
|
|
4
|
-
import { tmpdir, EOL } from
|
|
1
|
+
import { Plugin } from 'release-it';
|
|
2
|
+
import { existsSync, readFileSync, writeFileSync } from 'node:fs';
|
|
3
|
+
import { join } from 'node:path';
|
|
4
|
+
import { tmpdir, EOL } from 'node:os';
|
|
5
5
|
|
|
6
|
-
const VERSION_BUMP_INFO_PATH = join(tmpdir(),
|
|
7
|
-
const docs =
|
|
6
|
+
const VERSION_BUMP_INFO_PATH = join(tmpdir(), 'FRSOURCE_VERSION_BUMP');
|
|
7
|
+
const docs = 'https://git.io/release-it-git';
|
|
8
8
|
|
|
9
9
|
const toUnique = (array) => [...new Set(array)];
|
|
10
10
|
const flattenDependencies = (infoObj, result = []) => {
|
|
@@ -18,20 +18,20 @@ const flattenDependencies = (infoObj, result = []) => {
|
|
|
18
18
|
};
|
|
19
19
|
const e = (message, docs, fail = true) => {
|
|
20
20
|
const error = new Error(
|
|
21
|
-
docs ? `${message}${EOL}Documentation: ${docs}${EOL}` : message
|
|
21
|
+
docs ? `${message}${EOL}Documentation: ${docs}${EOL}` : message,
|
|
22
22
|
);
|
|
23
23
|
error.code = fail ? 1 : 0;
|
|
24
24
|
return error;
|
|
25
25
|
};
|
|
26
26
|
|
|
27
|
-
export default class
|
|
27
|
+
export default class CrossDepsVersionPlugin extends Plugin {
|
|
28
28
|
async getLatestVersion() {
|
|
29
|
-
this.log.log(
|
|
29
|
+
this.log.log('Reading version file from:', VERSION_BUMP_INFO_PATH);
|
|
30
30
|
const gitOptions = this.config.getContext()?.git ?? {};
|
|
31
31
|
|
|
32
32
|
const shouldBeIncremented = await this.shouldBeIncremented();
|
|
33
33
|
const commitsSinceLatestTag = await this.getCommitsSinceLatestTag(
|
|
34
|
-
gitOptions.commitsPath
|
|
34
|
+
gitOptions.commitsPath,
|
|
35
35
|
);
|
|
36
36
|
|
|
37
37
|
// check commit requirement only when package doesn't need to be bumped because of workspace cross-dependencies
|
|
@@ -39,7 +39,7 @@ export default class FRSVersionPlugin extends Plugin {
|
|
|
39
39
|
throw e(
|
|
40
40
|
`There are no commits since the latest tag.`,
|
|
41
41
|
docs,
|
|
42
|
-
gitOptions.requireCommitsFail
|
|
42
|
+
gitOptions.requireCommitsFail,
|
|
43
43
|
);
|
|
44
44
|
}
|
|
45
45
|
}
|
|
@@ -47,10 +47,8 @@ export default class FRSVersionPlugin extends Plugin {
|
|
|
47
47
|
afterRelease() {
|
|
48
48
|
writeFileSync(
|
|
49
49
|
VERSION_BUMP_INFO_PATH,
|
|
50
|
-
`${this.config.getContext(
|
|
51
|
-
{
|
|
52
|
-
flag: "as",
|
|
53
|
-
}
|
|
50
|
+
`${this.config.getContext('name')}\n`,
|
|
51
|
+
{ flag: 'as' },
|
|
54
52
|
);
|
|
55
53
|
}
|
|
56
54
|
|
|
@@ -61,14 +59,14 @@ export default class FRSVersionPlugin extends Plugin {
|
|
|
61
59
|
this.debug({ recentlyBumpedPackages, workspaceDependencies });
|
|
62
60
|
|
|
63
61
|
return workspaceDependencies.some((depName) =>
|
|
64
|
-
recentlyBumpedPackages.includes(depName)
|
|
62
|
+
recentlyBumpedPackages.includes(depName),
|
|
65
63
|
);
|
|
66
64
|
}
|
|
67
65
|
|
|
68
66
|
async getWorkspaceDependencies() {
|
|
69
67
|
const packageInfoRaw = await this.exec(
|
|
70
|
-
|
|
71
|
-
{ options: { write: false } }
|
|
68
|
+
'pnpm list --only-projects --depth Infinity --json -P',
|
|
69
|
+
{ options: { write: false } },
|
|
72
70
|
);
|
|
73
71
|
const packageInfo = toUnique(JSON.parse(packageInfoRaw));
|
|
74
72
|
return flattenDependencies(packageInfo?.[0]);
|
|
@@ -77,16 +75,16 @@ export default class FRSVersionPlugin extends Plugin {
|
|
|
77
75
|
getRecentlyBumpedPackages() {
|
|
78
76
|
if (!existsSync(VERSION_BUMP_INFO_PATH)) return [];
|
|
79
77
|
return toUnique(
|
|
80
|
-
readFileSync(VERSION_BUMP_INFO_PATH,
|
|
81
|
-
.split(
|
|
78
|
+
readFileSync(VERSION_BUMP_INFO_PATH, 'utf-8')
|
|
79
|
+
.split('\n')
|
|
82
80
|
.slice(1)
|
|
83
|
-
.filter(Boolean)
|
|
81
|
+
.filter(Boolean),
|
|
84
82
|
);
|
|
85
83
|
}
|
|
86
84
|
|
|
87
|
-
async getCommitsSinceLatestTag(commitsPath =
|
|
85
|
+
async getCommitsSinceLatestTag(commitsPath = '') {
|
|
88
86
|
const { latestTag } = this.config.getContext();
|
|
89
|
-
const ref = latestTag ? `${latestTag}..HEAD` :
|
|
87
|
+
const ref = latestTag ? `${latestTag}..HEAD` : 'HEAD';
|
|
90
88
|
return this.exec(`git rev-list ${ref} --count ${commitsPath}`, {
|
|
91
89
|
options: { write: false },
|
|
92
90
|
}).then(Number);
|
package/index.cjs
CHANGED
package/index.d.cts
ADDED
package/monorepoIndependent.cjs
CHANGED
|
@@ -1,39 +1,29 @@
|
|
|
1
|
-
const path = require("path");
|
|
2
|
-
|
|
3
1
|
/**
|
|
4
2
|
* Configuration for independent package in monorepo workspace
|
|
5
3
|
* @param {Object} options
|
|
6
4
|
* @param {string} options.pkgName name of the package in the monorepo, e.g. `@frsource/my-package`
|
|
7
|
-
* @param {string} [options.path=`packages/${options.pkgName}`] path of the package relative to the monorepo root, without starting slash. Always use "/" as delimiter. Will default to `packages/${options.pkgName}` (package scope in `options.pkgName` will be omitted)
|
|
8
5
|
* @param {string} [options.buildCmd="pnpm build"] command that should be used to build the package, defaults to `pnpm build`
|
|
6
|
+
* @param {string} [options.pluginsPath=""] (for internal usage only)
|
|
9
7
|
*/
|
|
10
8
|
module.exports = ({
|
|
11
9
|
pkgName,
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* @private (for internal usage)
|
|
16
|
-
*/
|
|
17
|
-
pluginsPath = "@frsource/release-it-config",
|
|
10
|
+
buildCmd = 'pnpm build',
|
|
11
|
+
pluginsPath = '@frsource/release-it-config',
|
|
18
12
|
}) => {
|
|
19
|
-
if (pkgPath.startsWith("/")) pkgPath = pkgPath.substring(1);
|
|
20
|
-
const nestingLevel = pkgPath.split("/").length;
|
|
21
|
-
if (path.sep !== "/") pkgPath = pkgPath.replaceAll("/", path.sep);
|
|
22
|
-
|
|
23
13
|
return {
|
|
24
14
|
npm: {
|
|
25
|
-
publishPath:
|
|
15
|
+
publishPath: '*.tgz',
|
|
26
16
|
publish: true,
|
|
27
17
|
},
|
|
28
18
|
git: {
|
|
29
|
-
requireBranch:
|
|
19
|
+
requireBranch: 'main',
|
|
30
20
|
requireCommits: false,
|
|
31
21
|
requireCommitsFail: false, // if there are no new commits release-it will stop the release process, but without throwing and error
|
|
32
22
|
requireCleanWorkingDir: true,
|
|
33
|
-
commitsPath:
|
|
34
|
-
commitMessage:
|
|
35
|
-
tagName:
|
|
36
|
-
tagMatch:
|
|
23
|
+
commitsPath: '.',
|
|
24
|
+
commitMessage: 'chore(release): ${npm.name} v${version}',
|
|
25
|
+
tagName: '${npm.name}-v${version}',
|
|
26
|
+
tagMatch: '${npm.name}-v[0-9]*.[0-9]*.[0-9]*',
|
|
37
27
|
getLatestTagFromAllRefs: false, // https://github.com/release-it/release-it/blob/main/docs/git.md#use-all-refs-to-determine-latest-tag
|
|
38
28
|
},
|
|
39
29
|
github: {
|
|
@@ -43,28 +33,24 @@ module.exports = ({
|
|
|
43
33
|
submit: false, // hitting the secondary rate limit issues, see:
|
|
44
34
|
// https://github.com/FRSOURCE/toolkit/actions/runs/8730568392/job/23954615077#step:8:38
|
|
45
35
|
issue:
|
|
46
|
-
|
|
47
|
-
pr:
|
|
36
|
+
':rocket: _This issue has been resolved in [${releaseName} (click for release notes)](${releaseUrl})._',
|
|
37
|
+
pr: ':rocket: _This pull request is included in [${releaseName} (click for release notes)](${releaseUrl})._',
|
|
48
38
|
},
|
|
49
39
|
},
|
|
50
40
|
plugins: {
|
|
51
|
-
|
|
41
|
+
'@release-it/conventional-changelog': {
|
|
52
42
|
gitRawCommitsOpts: {
|
|
53
|
-
path:
|
|
43
|
+
path: '.',
|
|
54
44
|
},
|
|
55
|
-
preset:
|
|
56
|
-
infile:
|
|
45
|
+
preset: 'angular',
|
|
46
|
+
infile: 'CHANGELOG.md',
|
|
57
47
|
},
|
|
58
|
-
[`${pluginsPath}/version-plugin.mjs`]: {},
|
|
48
|
+
[`${pluginsPath}/cross-deps-version-plugin.mjs`]: {},
|
|
59
49
|
},
|
|
60
50
|
hooks: {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
`git add ${"../".repeat(nestingLevel)}pnpm-lock.yaml`,
|
|
65
|
-
],
|
|
66
|
-
"before:npm:release": "pnpm pack",
|
|
67
|
-
"after:npm:release": "rm *.tgz",
|
|
51
|
+
'before:bump': buildCmd,
|
|
52
|
+
'before:npm:release': 'pnpm pack',
|
|
53
|
+
'after:npm:release': 'rm *.tgz',
|
|
68
54
|
},
|
|
69
55
|
};
|
|
70
56
|
};
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
declare function _exports({ pkgName, buildCmd, pluginsPath, }: {
|
|
2
|
+
pkgName: string;
|
|
3
|
+
buildCmd?: string;
|
|
4
|
+
pluginsPath?: string;
|
|
5
|
+
}): {
|
|
6
|
+
npm: {
|
|
7
|
+
publishPath: string;
|
|
8
|
+
publish: boolean;
|
|
9
|
+
};
|
|
10
|
+
git: {
|
|
11
|
+
requireBranch: string;
|
|
12
|
+
requireCommits: boolean;
|
|
13
|
+
requireCommitsFail: boolean;
|
|
14
|
+
requireCleanWorkingDir: boolean;
|
|
15
|
+
commitsPath: string;
|
|
16
|
+
commitMessage: string;
|
|
17
|
+
tagName: string;
|
|
18
|
+
tagMatch: string;
|
|
19
|
+
getLatestTagFromAllRefs: boolean;
|
|
20
|
+
};
|
|
21
|
+
github: {
|
|
22
|
+
release: boolean;
|
|
23
|
+
releaseName: string;
|
|
24
|
+
comments: {
|
|
25
|
+
submit: boolean;
|
|
26
|
+
issue: string;
|
|
27
|
+
pr: string;
|
|
28
|
+
};
|
|
29
|
+
};
|
|
30
|
+
plugins: {
|
|
31
|
+
[x: string]: {
|
|
32
|
+
gitRawCommitsOpts: {
|
|
33
|
+
path: string;
|
|
34
|
+
};
|
|
35
|
+
preset: string;
|
|
36
|
+
infile: string;
|
|
37
|
+
} | {
|
|
38
|
+
gitRawCommitsOpts?: undefined;
|
|
39
|
+
preset?: undefined;
|
|
40
|
+
infile?: undefined;
|
|
41
|
+
};
|
|
42
|
+
'@release-it/conventional-changelog': {
|
|
43
|
+
gitRawCommitsOpts: {
|
|
44
|
+
path: string;
|
|
45
|
+
};
|
|
46
|
+
preset: string;
|
|
47
|
+
infile: string;
|
|
48
|
+
};
|
|
49
|
+
};
|
|
50
|
+
hooks: {
|
|
51
|
+
'before:bump': string;
|
|
52
|
+
'before:npm:release': string;
|
|
53
|
+
'after:npm:release': string;
|
|
54
|
+
};
|
|
55
|
+
};
|
|
56
|
+
export = _exports;
|
package/package.json
CHANGED
|
@@ -1,13 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@frsource/release-it-config",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.0",
|
|
4
4
|
"main": "index.cjs",
|
|
5
|
+
"types": "index.d.cts",
|
|
5
6
|
"type": "module",
|
|
6
7
|
"dependencies": {
|
|
7
8
|
"@release-it/conventional-changelog": "^8.0.1"
|
|
8
9
|
},
|
|
9
10
|
"devDependencies": {
|
|
10
|
-
"
|
|
11
|
+
"globals": "^15.0.0",
|
|
12
|
+
"release-it": "^17.2.0",
|
|
13
|
+
"typescript": "^5.4.5",
|
|
14
|
+
"@frsource/eslint-config": "1.2.0",
|
|
15
|
+
"@frsource/prettier-config": "1.2.0"
|
|
11
16
|
},
|
|
12
17
|
"peerDependencies": {
|
|
13
18
|
"release-it": ">= 17"
|
|
@@ -31,7 +36,13 @@
|
|
|
31
36
|
"release-it",
|
|
32
37
|
"release-it config"
|
|
33
38
|
],
|
|
39
|
+
"funding": "https://buymeacoffee.com/frsource",
|
|
34
40
|
"scripts": {
|
|
35
|
-
"
|
|
41
|
+
"build": "tsc index.cjs --declaration --emitDeclarationOnly --allowJs --moduleResolution bundler --target esnext",
|
|
42
|
+
"release": "release-it",
|
|
43
|
+
"eslint": "eslint .",
|
|
44
|
+
"prettier": "prettier . --check",
|
|
45
|
+
"lint": "pnpm eslint && pnpm prettier",
|
|
46
|
+
"fix": "pnpm eslint --fix && prettier . --write"
|
|
36
47
|
}
|
|
37
48
|
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { Plugin } from 'release-it';
|
|
2
|
+
import fs from 'node:fs';
|
|
3
|
+
import path from 'node:path';
|
|
4
|
+
import { EOL } from 'node:os';
|
|
5
|
+
|
|
6
|
+
// based on https://github.com/release-it/release-it/blob/679bd0e2480d2e04aea4f8d5ecc00183dbd60c05/docs/recipes/my-version.md
|
|
7
|
+
|
|
8
|
+
const e = (message, docs, fail = true) => {
|
|
9
|
+
const error = new Error(
|
|
10
|
+
docs ? `${message}${EOL}Documentation: ${docs}${EOL}` : message,
|
|
11
|
+
);
|
|
12
|
+
error.code = fail ? 1 : 0;
|
|
13
|
+
return error;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
class VersionFilePlugin extends Plugin {
|
|
17
|
+
constructor(...args) {
|
|
18
|
+
super(...args);
|
|
19
|
+
this.setContext({ versionFile: path.resolve('./VERSION') });
|
|
20
|
+
}
|
|
21
|
+
static isEnabled() {
|
|
22
|
+
try {
|
|
23
|
+
fs.accessSync(this.getContext('versionFile'));
|
|
24
|
+
return true;
|
|
25
|
+
} catch {
|
|
26
|
+
throw e('Skipping release: VERSION file not present.', false);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
init() {
|
|
30
|
+
const data = fs.readFileSync(this.getContext('versionFile'));
|
|
31
|
+
const latestVersion = data.toString().trim();
|
|
32
|
+
this.setContext({ latestVersion });
|
|
33
|
+
}
|
|
34
|
+
getLatestVersion() {
|
|
35
|
+
return this.getContext('latestVersion');
|
|
36
|
+
}
|
|
37
|
+
bump(version) {
|
|
38
|
+
this.setContext({ version });
|
|
39
|
+
fs.unlinkSync(this.getContext('versionFile'));
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export default VersionFilePlugin;
|
package/CHANGELOG.md
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
# [1.1.0](https://github.com/FRSOURCE/toolkit/compare/@frsource/release-it-config-v1.0.2...${npm.name}-v1.1.0) (2024-04-19)
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
### Features
|
|
7
|
-
|
|
8
|
-
* **release-it-config:** fix and test the feature release ([991ed9f](https://github.com/FRSOURCE/toolkit/commit/991ed9f2c8a0bbbd23057c6353b6890a0be8929b))
|
|
9
|
-
|
|
10
|
-
## [1.0.2](https://github.com/FRSOURCE/toolkit/compare/@frsource/release-it-config-v1.0.1...${npm.name}-v1.0.2) (2024-04-19)
|
|
11
|
-
|
|
12
|
-
## [1.0.1](https://github.com/FRSOURCE/toolkit/compare/@frsource/release-it-config-v1.0.0...${npm.name}-v1.0.1) (2024-04-18)
|
|
13
|
-
|
|
14
|
-
# 1.0.0 (2024-04-18)
|