@monoweave/plugin-github 2.0.6 → 2.1.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/lib/plugin.js +37 -26
- package/package.json +8 -8
package/lib/plugin.js
CHANGED
|
@@ -6,27 +6,27 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.createPluginInternals = exports.PluginName = void 0;
|
|
7
7
|
const git_1 = require("@monoweave/git");
|
|
8
8
|
const logging_1 = __importDefault(require("@monoweave/logging"));
|
|
9
|
-
const core_1 = require("@
|
|
10
|
-
const plugin_throttling_1 = require("@octokit/plugin-throttling");
|
|
9
|
+
const core_1 = require("@yarnpkg/core");
|
|
11
10
|
const request_1 = require("./request");
|
|
12
11
|
exports.PluginName = 'GitHub Plugin';
|
|
13
12
|
const createPluginInternals = (options) => async (context, config, changeset) => {
|
|
14
|
-
const
|
|
13
|
+
const { Octokit } = await import('@octokit/core');
|
|
14
|
+
const { throttling } = await import('@octokit/plugin-throttling');
|
|
15
|
+
// Try GH_TOKEN first for backwards compatibility with older versions of Monoweave
|
|
16
|
+
const personalAccessToken = process.env.GH_TOKEN || process.env.GITHUB_TOKEN;
|
|
15
17
|
if (!personalAccessToken) {
|
|
16
|
-
|
|
17
|
-
}
|
|
18
|
-
const ThrottledOctokit = core_1.Octokit.plugin(plugin_throttling_1.throttling);
|
|
19
|
-
const octokit = new ThrottledOctokit({
|
|
20
|
-
auth: personalAccessToken,
|
|
21
|
-
throttle: {
|
|
22
|
-
onRateLimit: () => true,
|
|
23
|
-
onSecondaryRateLimit: () => false,
|
|
24
|
-
},
|
|
25
|
-
});
|
|
26
|
-
const { owner, repository: repo } = await (0, git_1.parseRepositoryProperty)(context.workspace);
|
|
27
|
-
if (!owner || !repo) {
|
|
28
|
-
throw new Error('Cannot determine GitHub owner or repository');
|
|
18
|
+
context.report.reportWarning(core_1.MessageName.UNNAMED, 'Missing GitHub Personal Access Token. Unable to create GitHub release(s).');
|
|
29
19
|
}
|
|
20
|
+
const ThrottledOctokit = Octokit.plugin(throttling);
|
|
21
|
+
const octokit = personalAccessToken
|
|
22
|
+
? new ThrottledOctokit({
|
|
23
|
+
auth: personalAccessToken,
|
|
24
|
+
throttle: {
|
|
25
|
+
onRateLimit: () => true,
|
|
26
|
+
onSecondaryRateLimit: () => false,
|
|
27
|
+
},
|
|
28
|
+
})
|
|
29
|
+
: null;
|
|
30
30
|
const changesByTag = new Map();
|
|
31
31
|
for (const [pkgName, changeData] of Object.entries(changeset)) {
|
|
32
32
|
const tag = changeData.tag;
|
|
@@ -59,21 +59,32 @@ const createPluginInternals = (options) => async (context, config, changeset) =>
|
|
|
59
59
|
logging_1.default.info(`[${exports.PluginName}] Creating release for ${tag}`, {
|
|
60
60
|
report: context.report,
|
|
61
61
|
});
|
|
62
|
-
if (
|
|
62
|
+
if (!changes.length)
|
|
63
|
+
continue;
|
|
64
|
+
const pkgName = changes[0].name;
|
|
65
|
+
const workspace = context.project.getWorkspaceByIdent(core_1.structUtils.parseIdent(pkgName));
|
|
66
|
+
const { owner, repository: repo } = await (0, git_1.parseRepositoryProperty)(workspace, {
|
|
67
|
+
fallbackToTopLevel: true,
|
|
68
|
+
});
|
|
69
|
+
if (!owner || !repo) {
|
|
70
|
+
context.report.reportError(core_1.MessageName.UNNAMED, `Cannot determine GitHub owner or repository for '${pkgName}'`);
|
|
63
71
|
continue;
|
|
72
|
+
}
|
|
64
73
|
const combinedChangelog = changes
|
|
65
74
|
.sort((a, b) => a.name.localeCompare(b.name))
|
|
66
75
|
.map((change) => change.changelog)
|
|
67
76
|
.join('\n');
|
|
68
|
-
|
|
69
|
-
owner,
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
+
if (octokit && !config.dryRun) {
|
|
78
|
+
await (0, request_1.request)(octokit, 'POST /repos/{owner}/{repo}/releases', {
|
|
79
|
+
owner,
|
|
80
|
+
repo,
|
|
81
|
+
tag_name: tag,
|
|
82
|
+
name: tag,
|
|
83
|
+
body: combinedChangelog,
|
|
84
|
+
draft: false,
|
|
85
|
+
prerelease: config.prerelease,
|
|
86
|
+
});
|
|
87
|
+
}
|
|
77
88
|
}
|
|
78
89
|
};
|
|
79
90
|
exports.createPluginInternals = createPluginInternals;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@monoweave/plugin-github",
|
|
3
|
-
"version": "2.0
|
|
3
|
+
"version": "2.1.0",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/monoweave/monoweave.git",
|
|
@@ -30,17 +30,17 @@
|
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
32
|
"@monoweave/test-utils": "link:../../testUtils",
|
|
33
|
-
"@types/jest": "^29.5.
|
|
34
|
-
"@types/node": "^
|
|
33
|
+
"@types/jest": "^29.5.12",
|
|
34
|
+
"@types/node": "^20.11.24",
|
|
35
35
|
"tapable": "^2.2.1"
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@monoweave/git": "^1.
|
|
39
|
-
"@monoweave/io": "^1.
|
|
38
|
+
"@monoweave/git": "^1.1.0",
|
|
39
|
+
"@monoweave/io": "^1.1.0",
|
|
40
40
|
"@monoweave/logging": "^0.0.4",
|
|
41
|
-
"@monoweave/types": "^1.
|
|
42
|
-
"@octokit/core": "^
|
|
43
|
-
"@octokit/plugin-throttling": "^
|
|
41
|
+
"@monoweave/types": "^1.1.0",
|
|
42
|
+
"@octokit/core": "^6.0.1",
|
|
43
|
+
"@octokit/plugin-throttling": "^9.0.3",
|
|
44
44
|
"@yarnpkg/core": "^4.0.3",
|
|
45
45
|
"@yarnpkg/fslib": "^3.0.2",
|
|
46
46
|
"@yarnpkg/shell": "^4.0.0"
|