@halospv3/hce.shared-config 2.4.3-develop.1 → 2.5.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/CHANGELOG.md +18 -0
- package/cjs/dotnet/MSBuildProject.cjs +1 -2
- package/cjs/dotnet/MSBuildProject.cjs.map +1 -1
- package/cjs/dotnet/dotnetGHPR.cjs +84 -24
- package/cjs/dotnet/dotnetGHPR.cjs.map +1 -1
- package/cjs/dotnet/dotnetGHPR.d.ts +27 -3
- package/cjs/dotnet/dotnetGHPR.d.ts.map +1 -1
- package/cjs/dotnet/dotnetGLPR.cjs +7 -7
- package/cjs/dotnet/dotnetGLPR.cjs.map +1 -1
- package/cjs/dotnet/dotnetGLPR.d.ts.map +1 -1
- package/cjs/dotnet/dotnetHelpers.cjs +4 -3
- package/cjs/dotnet/dotnetHelpers.cjs.map +1 -1
- package/cjs/dotnet/dotnetHelpers.d.ts.map +1 -1
- package/cjs/semanticReleaseConfigDotnet.cjs +8 -6
- package/cjs/semanticReleaseConfigDotnet.cjs.map +1 -1
- package/cjs/semanticReleaseConfigDotnet.d.ts.map +1 -1
- package/package.json +6 -2
- package/src/dotnet/MSBuildProject.ts +1 -1
- package/src/dotnet/dotnetGHPR.ts +106 -32
- package/src/dotnet/dotnetGLPR.ts +5 -5
- package/src/dotnet/dotnetHelpers.ts +4 -3
- package/src/semanticReleaseConfigDotnet.ts +8 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,21 @@
|
|
|
1
|
+
## [2.5.0](https://github.com/halospv3/hce.shared/compare/v2.4.3...v2.5.0) (2024-06-04)
|
|
2
|
+
|
|
3
|
+
### Features
|
|
4
|
+
|
|
5
|
+
* overhaul dotnetGHPR; misc refactors ([8d0a1d6](https://github.com/halospv3/hce.shared/commit/8d0a1d657e7f4754881c9a130fd4aa8191fb3e81))
|
|
6
|
+
|
|
7
|
+
### Bug Fixes
|
|
8
|
+
|
|
9
|
+
* **deps:** update dependency conventional-changelog-conventionalcommits to v8 ([e1defcd](https://github.com/halospv3/hce.shared/commit/e1defcd94ba51eda7384c1ca87f33c9928610e20))
|
|
10
|
+
* **deps:** update semantic-release monorepo ([39fcf98](https://github.com/halospv3/hce.shared/commit/39fcf988fe55b894e269d64de1b48c7f8dfb950c))
|
|
11
|
+
|
|
12
|
+
## [2.4.3](https://github.com/halospv3/hce.shared/compare/v2.4.2...v2.4.3) (2024-05-31)
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
### Bug Fixes
|
|
16
|
+
|
|
17
|
+
* fix error being thrown because an 'else' is missing ([a4ed781](https://github.com/halospv3/hce.shared/commit/a4ed781dd9ebf696deae7b7914d8cf77e2beb5fb))
|
|
18
|
+
|
|
1
19
|
## [2.4.3-develop.1](https://github.com/halospv3/hce.shared/compare/v2.4.2...v2.4.3-develop.1) (2024-06-01)
|
|
2
20
|
|
|
3
21
|
### Bug Fixes
|
|
@@ -69,8 +69,7 @@ class MSBuildProject {
|
|
|
69
69
|
let props;
|
|
70
70
|
if (out.startsWith('{')) {
|
|
71
71
|
const obj = JSON.parse(out);
|
|
72
|
-
if ("Properties" in obj && typeof obj.Properties === 'object' && obj.Properties !== null) props = obj.Properties;
|
|
73
|
-
throw new Error('When evaluating properties with MSBuild, "Properties" could not be found in the deserialized JSON object.');
|
|
72
|
+
if ("Properties" in obj && typeof obj.Properties === 'object' && obj.Properties !== null) props = obj.Properties;else throw new Error('When evaluating properties with MSBuild, "Properties" could not be found in the deserialized JSON object...\n' + JSON.stringify(obj));
|
|
74
73
|
} else {
|
|
75
74
|
props = {
|
|
76
75
|
[properties[0]]: out.trim()
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MSBuildProject.cjs","sources":["../../src/dotnet/MSBuildProject.ts"],"sourcesContent":null,"names":["MSBuildProjectProperties","execFileSync"],"mappings":";;;;;AAGA;AACA;AACA;AACY,MAAC,kCAAkC,GAAG,MAAM,CAAC,IAAI,CAAC,IAAIA,iDAAwB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G,CAAC,UAAU,CAAC,iBAAiB,CAAC,EAAE,MAAM,IAAI,KAAK,CAAC,GAAG,CAAC,CAAC;AAChE,IAAI,IAAI,KAAK,CAAC;AACd,IAAI,IAAI,GAAG,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE;AAC7B,MAAM,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;AAClC,MAAM,IAAI,YAAY,IAAI,GAAG,IAAI,OAAO,GAAG,CAAC,UAAU,KAAK,QAAQ,IAAI,GAAG,CAAC,UAAU,KAAK,IAAI,EAAE,KAAK,GAAG,GAAG,CAAC,UAAU,CAAC
|
|
1
|
+
{"version":3,"file":"MSBuildProject.cjs","sources":["../../src/dotnet/MSBuildProject.ts"],"sourcesContent":null,"names":["MSBuildProjectProperties","execFileSync"],"mappings":";;;;;AAGA;AACA;AACA;AACY,MAAC,kCAAkC,GAAG,MAAM,CAAC,IAAI,CAAC,IAAIA,iDAAwB,CAAC,EAAE,EAAE,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,KAAK,UAAU,EAAE;AACrI;AACA;AACA;AACY,MAAC,wBAAwB,GAAG,GAAG;AACpC,MAAM,cAAc,CAAC;AAC5B,EAAE,UAAU,CAAC;AACb;AACA;AACA;AACA;AACA;AACA;AACA,EAAE,WAAW,CAAC,QAAQ,EAAE,gBAAgB,EAAE;AAC1C;AACA,IAAI,IAAI,CAAC,UAAU,GAAG,cAAc,CAAC,kBAAkB,CAAC,QAAQ,EAAE,gBAAgB,IAAI,EAAE,CAAC,CAAC;AAC1F,GAAG;AACH;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,EAAE,OAAO,kBAAkB,CAAC,QAAQ,EAAE,UAAU,EAAE;AAClD,IAAI,MAAM,cAAc,GAAG,IAAIA,iDAAwB,CAAC,QAAQ,CAAC,CA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R,KAAK;AACL,IAAI,OAAO;AACX,MAAM,GAAG,cAAc;AACvB,MAAM,GAAG,KAAK;AACd,KAAK,CAAC;AACN,GAAG;AACH;;;;;;"}
|
|
@@ -1,60 +1,120 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
const strict = require('node:assert/strict');
|
|
4
|
+
const node_process = require('node:process');
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* @todo support custom base URL for private GitHub instances
|
|
8
|
+
* @param tokenEnvVar The name of the environment variable containing the NUGET token
|
|
9
|
+
* @returns `true` if the token is
|
|
10
|
+
* @throws
|
|
11
|
+
* - TypeError: The environment variable ${tokenEnvVar} is undefined!
|
|
12
|
+
* - Error:
|
|
13
|
+
* - The value of the token in ${tokenEnvVar} begins with 'github_pat_' which means it's a Fine-Grained token. At the time of writing, GitHub Fine-Grained tokens cannot push packages. If you believe this is statement is outdated, report the issue at https://github.com/halospv3/hce.shared/issues/new. For more information, see https://docs.github.com/en/packages/working-with-a-github-packages-registry/working-with-the-nuget-registry.
|
|
14
|
+
* - The GitHub API response header lacked "x-oauth-scopes". This indicates the token we provided is not a workflow token nor a Personal Access Token (classic) and can never have permission to push packages.
|
|
15
|
+
*/
|
|
4
16
|
async function tokenCanWritePackages(tokenEnvVar) {
|
|
5
|
-
|
|
17
|
+
/* double-check the token exists */
|
|
18
|
+
const info = isTokenDefined(tokenEnvVar);
|
|
19
|
+
strict.ok(info.isDefined);
|
|
20
|
+
if (info.fallback) tokenEnvVar = info.fallback;
|
|
21
|
+
const tokenValue = node_process.env[tokenEnvVar];
|
|
6
22
|
if (tokenValue === undefined) throw new TypeError(`The environment variable ${tokenEnvVar} is undefined!`);
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
};
|
|
23
|
+
if (tokenValue.startsWith('github_pat_')) throw new Error(`The value of the token in ${tokenEnvVar} begins with 'github_pat_' which means it's a Fine-Grained token. At the time of writing, GitHub Fine-Grained tokens cannot push packages. If you believe this is statement is outdated, report the issue at https://github.com/halospv3/hce.shared/issues/new. For more information, see https://docs.github.com/en/packages/working-with-a-github-packages-registry/working-with-the-nuget-registry.`);
|
|
24
|
+
|
|
10
25
|
// CJS compatibility - import { request } from '@octokit/request
|
|
11
26
|
const request = (await import('@octokit/request')).request;
|
|
12
27
|
const response = await request('GET /', {
|
|
13
|
-
headers:
|
|
28
|
+
headers: {
|
|
29
|
+
authorization: `Bearer ${tokenValue}`
|
|
30
|
+
}
|
|
14
31
|
});
|
|
15
32
|
const scopes = response.headers['x-oauth-scopes'];
|
|
16
|
-
if (scopes)
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
33
|
+
if (scopes) return scopes.includes('write:packages');
|
|
34
|
+
throw new Error('GitHub API response header lacked "x-oauth-scopes". This indicates the token we provided is not a workflow token nor a Personal Access Token (classic) and can never have permission to push packages.');
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/** returns the value of {@link env.GITHUB_REPOSITORY_OWNER} */
|
|
38
|
+
function getOwner() {
|
|
39
|
+
return node_process.env.GITHUB_REPOSITORY_OWNER;
|
|
20
40
|
}
|
|
21
|
-
const GITHUB_REPOSITORY_OWNER = process.env.GITHUB_REPOSITORY_OWNER;
|
|
22
41
|
const nugetGitHubUrlBase = 'https://nuget.pkg.github.com';
|
|
23
|
-
|
|
42
|
+
|
|
43
|
+
/** @deprecated use {@link getNugetGitHubUrl()} instead. */
|
|
44
|
+
const nugetGitHubUrl = getNugetGitHubUrl();
|
|
45
|
+
function getNugetGitHubUrl() {
|
|
46
|
+
const owner = getOwner();
|
|
47
|
+
if (owner) return `${nugetGitHubUrlBase}/${owner}/index.json`;
|
|
48
|
+
return undefined;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* If tokenEnvVar is NOT 'GITHUB_TOKEN', then test if the token is defined and return the boolean.
|
|
53
|
+
* Else If tokenEnvVar is 'GITHUB_TOKEN' and defined, then return true.
|
|
54
|
+
* Else If tokenEnvVar is 'GITHUB_TOKEN' and undefined, then set tokenEnvVar to 'GH_TOKEN', test if GH_TOKEN is defined, and return the boolean.
|
|
55
|
+
* @param tokenEnvVar the name of the environment variable with the token's value. Defaults to 'GITHUB_TOKEN'. If environment variable 'GITHUB_TOKEN' is undefined, falls back to 'GH_TOKEN'.
|
|
56
|
+
* @returns `{isDefined: true}` if the token is defined. Else, if tokenEnvVar is 'GITHUB_TOKEN' (default) and token is defined, returns `true`. Else, if 'GH_TOKEN' is defined, returns `true`. Else, returns `false`
|
|
57
|
+
*/
|
|
58
|
+
function isTokenDefined(tokenEnvVar = 'GITHUB_TOKEN') {
|
|
59
|
+
if (tokenEnvVar !== 'GITHUB_TOKEN') return {
|
|
60
|
+
isDefined: node_process.env[tokenEnvVar /* custom */] !== undefined && node_process.env[tokenEnvVar /* custom */] !== 'undefined'
|
|
61
|
+
};else if (node_process.env[tokenEnvVar /* GITHUB_TOKEN */] !== undefined && node_process.env[tokenEnvVar /* GITHUB_TOKEN */] !== 'undefined') return {
|
|
62
|
+
isDefined: true
|
|
63
|
+
};else return {
|
|
64
|
+
isDefined: node_process.env[tokenEnvVar = 'GH_TOKEN'] !== undefined && node_process.env[tokenEnvVar] !== 'undefined',
|
|
65
|
+
fallback: 'GH_TOKEN'
|
|
66
|
+
};
|
|
67
|
+
}
|
|
24
68
|
|
|
25
69
|
/**
|
|
26
70
|
* Get a {@link NuGetRegistryInfo} for pushing to your GitHub Packages NuGet registry.
|
|
27
71
|
* todo: add support for private, custom GitHub instances. Token is only validated against github.com.
|
|
28
72
|
* @export
|
|
29
|
-
* @param {string} [tokenEnvVar="GITHUB_TOKEN"] The name of environment variable storing the GitHub Packages NuGet registry API key. Defaults to `"GITHUB_TOKEN"
|
|
30
|
-
* @param {string} [url=tokenEnvVar] The url of the GitHub Packages NuGet registry. Defaults to {@link
|
|
73
|
+
* @param {string | 'GITHUB_TOKEN' | 'GH_TOKEN'} [tokenEnvVar="GITHUB_TOKEN"] The name of environment variable storing the GitHub Packages NuGet registry API key. Defaults to `"GITHUB_TOKEN"`. If GITHUB_TOKEN is undefined, fallback to GH_TOKEN;
|
|
74
|
+
* @param {string} [url=tokenEnvVar] The url of the GitHub Packages NuGet registry. Defaults to return value of {@link getNugetGitHubUrl()}.
|
|
31
75
|
* @returns {(NuGetRegistryInfo | undefined)} a {@link NuGetRegistryInfo} object if {@link tokenEnvVar} and {@link url} are defined. Else, `undefined`.
|
|
32
76
|
* note: `url` defaults to job's repository owner's GitHub registry in GitHub Actions workflow. If GITHUB_REPOSITORY_OWNER is not defined, then an error will be logged and `undefined` will be returned.
|
|
33
77
|
*/
|
|
34
|
-
async function getGithubNugetRegistryPair(tokenEnvVar = 'GITHUB_TOKEN', url =
|
|
35
|
-
// yes, this is stupid. No, I won't change it.
|
|
36
|
-
const isTokenDefined = process.env[tokenEnvVar] !== undefined;
|
|
37
|
-
const isUrlDefined = url !== undefined;
|
|
38
|
-
const canTokenWritePackages = isTokenDefined ? await tokenCanWritePackages(tokenEnvVar) : false;
|
|
78
|
+
async function getGithubNugetRegistryPair(tokenEnvVar = 'GITHUB_TOKEN', url = getNugetGitHubUrl()) {
|
|
39
79
|
const errors = [];
|
|
40
|
-
|
|
41
|
-
|
|
80
|
+
const _isTokenDefinedInfo = isTokenDefined(tokenEnvVar);
|
|
81
|
+
let canTokenWritePackages = undefined;
|
|
82
|
+
if ((url ??= getNugetGitHubUrl()) === undefined) {
|
|
42
83
|
errors.push(new Error('The url for the GitHub Packages NuGet registry was undefined.\n' + 'If running in a GitHub Actions workflow, something is seriously wrong.\n' + 'If running in a different CI/CD pipeline and you wish to cross-push to GHPR, ensure GITHUB_REPOSITORY_OWNER is set correctly.\n'));
|
|
43
84
|
}
|
|
44
|
-
if (
|
|
85
|
+
if (_isTokenDefinedInfo.isDefined) {
|
|
86
|
+
if (_isTokenDefinedInfo.fallback) tokenEnvVar = _isTokenDefinedInfo.fallback;
|
|
87
|
+
try {
|
|
88
|
+
canTokenWritePackages = await tokenCanWritePackages(tokenEnvVar);
|
|
89
|
+
} catch (err) {
|
|
90
|
+
if (err instanceof Error) errors.push(err);else errors.push(new Error(String(err)));
|
|
91
|
+
}
|
|
92
|
+
} else {
|
|
93
|
+
const errMsg = `The environment variable ${tokenEnvVar} was specified as the source of the token to push a NuGet package to GitHub, but the environment variable does not exist.` + `${_isTokenDefinedInfo.fallback === undefined ? '' : ` The fallback environment variable ${_isTokenDefinedInfo.fallback} is also undefined.`}`;
|
|
94
|
+
errors.push(new Error(errMsg));
|
|
95
|
+
}
|
|
96
|
+
if (canTokenWritePackages === false) {
|
|
45
97
|
// yes, this is a critical error that should be fixed before Semantic Release can succeed.
|
|
46
98
|
// yes, this is incredibly irritating to deal with in local runs.
|
|
47
99
|
errors.push(new Error('The provided GitHub token has insufficient permissions or is a fine-grained permissions token. Only class Personal Access Tokens (classic) or workflow tokens with `repo` or `write:packages` permission can push a package.'));
|
|
48
100
|
}
|
|
49
101
|
|
|
50
102
|
// conditions checked so `url` is certainly defined
|
|
51
|
-
if (
|
|
103
|
+
if (_isTokenDefinedInfo.isDefined && url !== undefined && canTokenWritePackages) return {
|
|
52
104
|
tokenEnvVar,
|
|
53
105
|
url
|
|
54
106
|
};
|
|
55
|
-
|
|
107
|
+
const aggErr = new Error(`One more more errors occurred when getting GHPR url-token pair. Errors:\n${errors.map(v => v.stack).join('\n')}`);
|
|
108
|
+
if (node_process.env['SKIP_TOKEN'] === 'true' && aggErr.message.length > 0) {
|
|
109
|
+
console.error('WARN: errors were thrown, but SKIP_TOKEN is defined.\n' + aggErr.stack);
|
|
110
|
+
return undefined;
|
|
111
|
+
}
|
|
112
|
+
throw aggErr;
|
|
56
113
|
}
|
|
57
114
|
exports.getGithubNugetRegistryPair = getGithubNugetRegistryPair;
|
|
115
|
+
exports.getNugetGitHubUrl = getNugetGitHubUrl;
|
|
116
|
+
exports.isTokenDefined = isTokenDefined;
|
|
58
117
|
exports.nugetGitHubUrl = nugetGitHubUrl;
|
|
59
118
|
exports.nugetGitHubUrlBase = nugetGitHubUrlBase;
|
|
119
|
+
exports.tokenCanWritePackages = tokenCanWritePackages;
|
|
60
120
|
//# sourceMappingURL=dotnetGHPR.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dotnetGHPR.cjs","sources":["../../src/dotnet/dotnetGHPR.ts"],"sourcesContent":null,"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"dotnetGHPR.cjs","sources":["../../src/dotnet/dotnetGHPR.ts"],"sourcesContent":null,"names":["ok","env"],"mappings":";;;;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,eAAe,qBAAqB,CAAC,WAAW,EAAE;AACzD;AACA,EAAE,MAAM,IAAI,GAAG,cAAc,CAAC,WAAW,CAAC,CAAC;AAC3C,EAAEA,SAAE,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;AACrB,EAAE,IAAI,IAAI,CAAC,QAAQ,EAAE,WAAW,GAAG,IAAI,CAAC,QAAQ,CAAC;AACjD,EAAE,MAAM,UAAU,GAAGC,gBAAG,CAAC,WAAW,CAAC,CAAC;AACtC,EAAE,IAAI,UAAU,KAAK,SAAS,EAAE,MAAM,IAAI,SAAS,CAAC,CAAC,yBAAyB,EAAE,WAAW,CAAC,cAAc,CAAC,CAAC,CAAC;AAC7G,EAAE,IAAI,UAAU,CAAC,UAAU,CAAC,aAAa,CAAC,EAAE,MAAM,IAAI,KAAK,CAAC,CAAC,0BAA0B,EAAE,WAAW,CAAC,sYAAsY,CAAC,CAAC,CAAC;AAC9e;AACA;AACA,EAAE,MAAM,OAAO,GAAG,CAAC,MAAM,OAAO,kBAAkB,CAAC,EAAE,OAAO,CAAC;AAC7D,EAAE,MAAM,QAAQ,GAAG,MAAM,OAAO,CAAC,OAAO,EAAE;AAC1C,IAAI,OAAO,EAAE;AACb,MAAM,aAAa,EAAE,CAAC,OAAO,EAAE,UAAU,CAAC,CAAC;AAC3C,KAAK;AACL,GAAG,CAAC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C,CAAC,CAAC;AACnC,GAAG;AACH,EAAE,IAAI,qBAAqB,KAAK,KAAK,EAAE;AACvC;AACA;AACA,IAAI,MAAM,CAAC,IAAI,CAAC,IAAI,KAAK,CAAC,8NAA8N,CAAC,CAAC,CAAC;AAC3P,GAAG;AACH;AACA;AACA,EAAE,IAAI,mBAAmB,CAAC,SAAS,IAAI,GAAG,KAAK,SAAS,IAAI,qBAAqB,EAAE,OAAO;AAC1F,IAAI,WAAW;AACf,IAAI,GAAG;AACP,GAAG,CAAC;AACJ,EAAE,MAAM,MAAM,GAAG,IAAI,KAAK,CAAC,CAAC,yEAAyE,EAAE,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;AAC9I,EAAE,IAAIA,gBAAG,CAAC,YAAY,CAAC,KAAK,MAAM,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE;AACjE,IAAI,OAAO,CAAC,KAAK,CAAC,wDAAwD,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;AAC3F,IAAI,OAAO,SAAS,CAAC;AACrB,GAAG;AACH,EAAE,MAAM,MAAM,CAAC;AACf;;;;;;;;;"}
|
|
@@ -1,14 +1,38 @@
|
|
|
1
1
|
import type { NuGetRegistryInfo } from './dotnetHelpers.js';
|
|
2
|
+
/**
|
|
3
|
+
* @todo support custom base URL for private GitHub instances
|
|
4
|
+
* @param tokenEnvVar The name of the environment variable containing the NUGET token
|
|
5
|
+
* @returns `true` if the token is
|
|
6
|
+
* @throws
|
|
7
|
+
* - TypeError: The environment variable ${tokenEnvVar} is undefined!
|
|
8
|
+
* - Error:
|
|
9
|
+
* - The value of the token in ${tokenEnvVar} begins with 'github_pat_' which means it's a Fine-Grained token. At the time of writing, GitHub Fine-Grained tokens cannot push packages. If you believe this is statement is outdated, report the issue at https://github.com/halospv3/hce.shared/issues/new. For more information, see https://docs.github.com/en/packages/working-with-a-github-packages-registry/working-with-the-nuget-registry.
|
|
10
|
+
* - The GitHub API response header lacked "x-oauth-scopes". This indicates the token we provided is not a workflow token nor a Personal Access Token (classic) and can never have permission to push packages.
|
|
11
|
+
*/
|
|
12
|
+
export declare function tokenCanWritePackages(tokenEnvVar: string): Promise<boolean>;
|
|
2
13
|
export declare const nugetGitHubUrlBase = "https://nuget.pkg.github.com";
|
|
14
|
+
/** @deprecated use {@link getNugetGitHubUrl()} instead. */
|
|
3
15
|
export declare const nugetGitHubUrl: string | undefined;
|
|
16
|
+
export declare function getNugetGitHubUrl(): string | undefined;
|
|
17
|
+
/**
|
|
18
|
+
* If tokenEnvVar is NOT 'GITHUB_TOKEN', then test if the token is defined and return the boolean.
|
|
19
|
+
* Else If tokenEnvVar is 'GITHUB_TOKEN' and defined, then return true.
|
|
20
|
+
* Else If tokenEnvVar is 'GITHUB_TOKEN' and undefined, then set tokenEnvVar to 'GH_TOKEN', test if GH_TOKEN is defined, and return the boolean.
|
|
21
|
+
* @param tokenEnvVar the name of the environment variable with the token's value. Defaults to 'GITHUB_TOKEN'. If environment variable 'GITHUB_TOKEN' is undefined, falls back to 'GH_TOKEN'.
|
|
22
|
+
* @returns `{isDefined: true}` if the token is defined. Else, if tokenEnvVar is 'GITHUB_TOKEN' (default) and token is defined, returns `true`. Else, if 'GH_TOKEN' is defined, returns `true`. Else, returns `false`
|
|
23
|
+
*/
|
|
24
|
+
export declare function isTokenDefined(tokenEnvVar?: string): {
|
|
25
|
+
isDefined: boolean;
|
|
26
|
+
fallback?: string;
|
|
27
|
+
};
|
|
4
28
|
/**
|
|
5
29
|
* Get a {@link NuGetRegistryInfo} for pushing to your GitHub Packages NuGet registry.
|
|
6
30
|
* todo: add support for private, custom GitHub instances. Token is only validated against github.com.
|
|
7
31
|
* @export
|
|
8
|
-
* @param {string} [tokenEnvVar="GITHUB_TOKEN"] The name of environment variable storing the GitHub Packages NuGet registry API key. Defaults to `"GITHUB_TOKEN"
|
|
9
|
-
* @param {string} [url=tokenEnvVar] The url of the GitHub Packages NuGet registry. Defaults to {@link
|
|
32
|
+
* @param {string | 'GITHUB_TOKEN' | 'GH_TOKEN'} [tokenEnvVar="GITHUB_TOKEN"] The name of environment variable storing the GitHub Packages NuGet registry API key. Defaults to `"GITHUB_TOKEN"`. If GITHUB_TOKEN is undefined, fallback to GH_TOKEN;
|
|
33
|
+
* @param {string} [url=tokenEnvVar] The url of the GitHub Packages NuGet registry. Defaults to return value of {@link getNugetGitHubUrl()}.
|
|
10
34
|
* @returns {(NuGetRegistryInfo | undefined)} a {@link NuGetRegistryInfo} object if {@link tokenEnvVar} and {@link url} are defined. Else, `undefined`.
|
|
11
35
|
* note: `url` defaults to job's repository owner's GitHub registry in GitHub Actions workflow. If GITHUB_REPOSITORY_OWNER is not defined, then an error will be logged and `undefined` will be returned.
|
|
12
36
|
*/
|
|
13
|
-
export declare function getGithubNugetRegistryPair(tokenEnvVar?: string, url?: string | undefined): Promise<NuGetRegistryInfo | undefined>;
|
|
37
|
+
export declare function getGithubNugetRegistryPair(tokenEnvVar?: string | 'GITHUB_TOKEN' | 'GH_TOKEN', url?: string | undefined): Promise<NuGetRegistryInfo | undefined>;
|
|
14
38
|
//# sourceMappingURL=dotnetGHPR.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dotnetGHPR.d.ts","sourceRoot":"","sources":["../../src/dotnet/dotnetGHPR.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"dotnetGHPR.d.ts","sourceRoot":"","sources":["../../src/dotnet/dotnetGHPR.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAG5D;;;;;;;;;GASG;AACH,wBAAsB,qBAAqB,CAAC,WAAW,EAAE,MAAM,oBA2B9D;AAOD,eAAO,MAAM,kBAAkB,iCAAiC,CAAC;AAEjE,2DAA2D;AAC3D,eAAO,MAAM,cAAc,EAAE,MAAM,GAAG,SAA+B,CAAC;AAEtE,wBAAgB,iBAAiB,uBAKhC;AAED;;;;;;GAMG;AACH,wBAAgB,cAAc,CAAC,WAAW,SAAiB,GAAG;IAAE,SAAS,EAAE,OAAO,CAAC;IAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;CAAE,CAatG;AAED;;;;;;;;GAQG;AACH,wBAAsB,0BAA0B,CAC/C,WAAW,GAAE,MAAM,GAAG,cAAc,GAAG,UAA2B,EAClE,GAAG,GAAE,MAAM,GAAG,SAA+B,GAC3C,OAAO,CAAC,iBAAiB,GAAG,SAAS,CAAC,CAuDxC"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
const
|
|
4
|
-
const
|
|
5
|
-
CI_API_V4_URL =
|
|
6
|
-
CI_PROJECT_ID =
|
|
3
|
+
const node_process = require('node:process');
|
|
4
|
+
const _node_process$env = node_process.env,
|
|
5
|
+
CI_API_V4_URL = _node_process$env.CI_API_V4_URL,
|
|
6
|
+
CI_PROJECT_ID = _node_process$env.CI_PROJECT_ID;
|
|
7
7
|
const nameof = {
|
|
8
8
|
CI_API_V4_URL: 'CI_API_V4_URL',
|
|
9
9
|
CI_PROJECT_ID: 'CI_PROJECT_ID'
|
|
@@ -21,8 +21,8 @@ const nugetGitLabUrl = CI_API_V4_URL && CI_PROJECT_ID ? `${CI_API_V4_URL}/projec
|
|
|
21
21
|
*/
|
|
22
22
|
function getGitlabNugetRegistryPair(tokenEnvVar = GitLabTokenEnvVar, url = nugetGitLabUrl) {
|
|
23
23
|
// yes, this is stupid. No, I won't change it.
|
|
24
|
-
if (!
|
|
25
|
-
|
|
24
|
+
if (!node_process.env[tokenEnvVar]) {
|
|
25
|
+
console.error(new Error(`The environment variable ${tokenEnvVar} was specified as the source of the token to push a NuGet package to GitLab, but the environment variable does not exist.`));
|
|
26
26
|
return undefined;
|
|
27
27
|
}
|
|
28
28
|
if (url) {
|
|
@@ -31,7 +31,7 @@ function getGitlabNugetRegistryPair(tokenEnvVar = GitLabTokenEnvVar, url = nuget
|
|
|
31
31
|
url
|
|
32
32
|
};
|
|
33
33
|
}
|
|
34
|
-
|
|
34
|
+
console.error(new Error(`The environment variables ${nameof.CI_API_V4_URL} or ${nameof.CI_PROJECT_ID} do not exist and a custom GitLab Packages NuGet registry URL was not provided.`));
|
|
35
35
|
return undefined;
|
|
36
36
|
}
|
|
37
37
|
exports.GitLabTokenEnvVar = GitLabTokenEnvVar;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dotnetGLPR.cjs","sources":["../../src/dotnet/dotnetGLPR.ts"],"sourcesContent":null,"names":["
|
|
1
|
+
{"version":3,"file":"dotnetGLPR.cjs","sources":["../../src/dotnet/dotnetGLPR.ts"],"sourcesContent":null,"names":["env"],"mappings":";;;;AACA,MAAM;AACN,EAAE,aAAa;AACf,EAAE,aAAa;AACf,CAAC,GAAGA,gBAAG,CAAC;AACR,MAAM,MAAM,GAAG;AACf,EAAE,aAAa,EAAE,eAAe;AAChC,EAAE,aAAa,EAAE,eAAe;AAChC,CAAC,CAAC;AACU,MAAC,iBAAiB,GAAG,eAAe;AACpC,MAAC,kBAAkB,GAAG,cAAc;AACpC,MAAC,cAAc,GAAG,aAAa,IAAI,aAAa,GAAG,CAAC,EAAE,aAAa,CAAC,UAAU,EAAE,aAAa,CAAC,0BAA0B,CAAC,GAAG,UAAU;AAClJ;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,0BAA0B,CAAC,WAAW,GAAG,iBAAiB,EAAE,GAAG,GAAG,cAAc,EAAE;AAClG;AACA,EAAE,IAAI,CAACA,gBAAG,CAAC,WAAW,CAAC,EAAE;AACzB,IAAI,OAAO,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,CAAC,yBAAyB,EAAE,WAAW,CAAC,yHAAyH,CAAC,CAAC,CAAC,CAAC;AACjM,IAAI,OAAO,SAAS,CAAC;AACrB,GAAG;AACH,EAAE,IAAI,GAAG,EAAE;AACX,IAAI,OAAO;AACX,MAAM,WAAW;AACjB,MAAM,GAAG;AACT,KAAK,CAAC;AACN,GAAG;AACH,EAAE,OAAO,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,CAAC,0BAA0B,EAAE,MAAM,CAAC,aAAa,CAAC,IAAI,EAAE,MAAM,CAAC,aAAa,CAAC,+EAA+E,CAAC,CAAC,CAAC,CAAC;AAC1L,EAAE,OAAO,SAAS,CAAC;AACnB;;;;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dotnetGLPR.d.ts","sourceRoot":"","sources":["../../src/dotnet/dotnetGLPR.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"dotnetGLPR.d.ts","sourceRoot":"","sources":["../../src/dotnet/dotnetGLPR.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAS5D,eAAO,MAAM,iBAAiB,iBAAiB,CAAC;AAChD,eAAO,MAAM,kBAAkB,oBAAgB,CAAC;AAChD,eAAO,MAAM,cAAc,EAAE,MAAM,GAAG,SAGzB,CAAC;AAEd;;;;;;GAMG;AACH,wBAAgB,0BAA0B,CACzC,WAAW,GAAE,MAA0B,EACvC,GAAG,GAAE,MAAM,GAAG,SAA0B,GACtC,iBAAiB,GAAG,SAAS,CAmB/B"}
|
|
@@ -4,6 +4,7 @@ const strict = require('node:assert/strict');
|
|
|
4
4
|
const dotnetGHPR = require('./dotnetGHPR.cjs');
|
|
5
5
|
const dotnetGLPR = require('./dotnetGLPR.cjs');
|
|
6
6
|
const MSBuildProject = require('./MSBuildProject.cjs');
|
|
7
|
+
const node_process = require('node:process');
|
|
7
8
|
function formatDotnetPublish(projectsToPublish, publishProperties) {
|
|
8
9
|
/* Fun Fact: You can define a property and get the evaluated value in the same command!
|
|
9
10
|
```pwsh
|
|
@@ -129,9 +130,9 @@ async function configureDotnetNugetPush(nupkgDir = './publish', registries = [nu
|
|
|
129
130
|
}
|
|
130
131
|
}
|
|
131
132
|
return registries.map(registry => {
|
|
132
|
-
const tokenValue =
|
|
133
|
-
strict.ok(tokenValue, `The environment variable ${registry.tokenEnvVar} is undefined!`);
|
|
134
|
-
`dotnet nuget push ${nupkgDir} --source ${registry.url} --token ${tokenValue}`;
|
|
133
|
+
const tokenValue = node_process.env[registry.tokenEnvVar];
|
|
134
|
+
strict.ok(node_process.env['SKIP_TOKEN'] === 'true' || tokenValue, `The environment variable ${registry.tokenEnvVar} is undefined!`);
|
|
135
|
+
`dotnet nuget push ${nupkgDir} --source ${registry.url} --token ${tokenValue ?? '**placeholder**'}`;
|
|
135
136
|
}).join(' && ');
|
|
136
137
|
}
|
|
137
138
|
exports.configureDotnetNugetPush = configureDotnetNugetPush;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dotnetHelpers.cjs","sources":["../../src/dotnet/dotnetHelpers.ts"],"sourcesContent":null,"names":["MSBuildProject","MSBuildProjectPreDefinedProperties","nugetGitHubUrlBase","getGithubNugetRegistryPair","getGitlabNugetRegistryPair","ok"],"mappings":"
|
|
1
|
+
{"version":3,"file":"dotnetHelpers.cjs","sources":["../../src/dotnet/dotnetHelpers.ts"],"sourcesContent":null,"names":["MSBuildProject","MSBuildProjectPreDefinedProperties","nugetGitHubUrlBase","getGithubNugetRegistryPair","getGitlabNugetRegistryPair","env","ok"],"mappings":";;;;;;;;AAKA,SAAS,mBAAmB,CAAC,iBAAiB,EAAE,iBAAiB,EAAE;AACnE;AACA;AACA;AACA;AACA;AACA;AACA;AACA,EAAE,IAAI,EAAE,KAAK,CAAC,OAAO,CAAC,iBAAiB,CAAC,IAAI,iBAAiB,CAAC,MAAM,GAAG,CAAC,CAAC,EAAE,MAAM,IAAI,KAAK,CAAC,CAAC,2BAA2B,EAAE,OAAO,iBAAiB,CAAC,uDAAuD,CAAC,CAAC,CAAC;AAC5M;AACA;AACA,EAAE,MAAM,iBAAiB,GAAG,iBAAiB,CAAC,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sources":["../../src/dotnet/dotnetHelpers.ts"],"names":[],"mappings":"AA+GA;;;;;;;;;GASG;AACH,wBAAgB,mBAAmB,CAClC,iBAAiB,EAAE,MAAM,EAAE,EAC3B,qBAAqB,EAAE,MAAM,EAAE,GAAG,KAAK,EACvC,mBAAmB,GAAE,MAAM,EAAkB,UAU7C;AAED,MAAM,WAAW,iBAAiB;IACjC,WAAW,EAAE,MAAM,CAAC;IACpB,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CAC1B;AACD,eAAO,MAAM,YAAY,EAAE,iBAG1B,CAAC;AAEF;;;;;;GAMG;AACH,wBAAsB,wBAAwB,CAC7C,QAAQ,SAAc,EACtB,UAAU,GAAE,iBAAiB,EAAmB,EAChD,YAAY,UAAO,mBA4BnB"}
|
|
@@ -12,6 +12,8 @@ const dotnetHelpers = require('./dotnet/dotnetHelpers.cjs');
|
|
|
12
12
|
const semanticReleaseConfig = require('./semanticReleaseConfig.cjs');
|
|
13
13
|
const setupGitPluginSpec = require('./setupGitPluginSpec.cjs');
|
|
14
14
|
const debug = require('./debug.cjs');
|
|
15
|
+
const node_util = require('node:util');
|
|
16
|
+
const node_process = require('node:process');
|
|
15
17
|
|
|
16
18
|
/** Semantic-Release Config Factory (dotnet)
|
|
17
19
|
* A functional Semantic-Release configuration for dotnet projects
|
|
@@ -81,25 +83,25 @@ function appendPlugins(config, projectsToPublish, projectsToPackAndPush) {
|
|
|
81
83
|
*/
|
|
82
84
|
function getConfig(projectsToPublish = [], projectsToPackAndPush = []) {
|
|
83
85
|
if (debug.enabled) {
|
|
84
|
-
debug('hce.shared-config:\n
|
|
86
|
+
console.debug('hce.shared-config:\n' + node_util.inspect(semanticReleaseConfig.baseConfig, false, Infinity, true));
|
|
85
87
|
}
|
|
86
88
|
const errors = [];
|
|
87
89
|
if (projectsToPublish.length === 0) {
|
|
88
|
-
const _ =
|
|
90
|
+
const _ = node_process.env["PROJECTS_TO_PUBLISH"];
|
|
89
91
|
if (_ === undefined) errors.push(new Error("projectsToPublish.length must be > 0 or PROJECTS_TO_PUBLISH must be defined and contain at least one path."));else projectsToPublish = _.split(';');
|
|
90
92
|
}
|
|
91
|
-
if (projectsToPackAndPush && projectsToPackAndPush.length) {
|
|
92
|
-
const _ =
|
|
93
|
+
if (projectsToPackAndPush !== false && projectsToPackAndPush.length === 0) {
|
|
94
|
+
const _ = node_process.env["PROJECTS_TO_PACK_AND_PUSH"];
|
|
93
95
|
if (_ === undefined) errors.push(new Error("projectsToPackAndPush.length must be > 0 or PROJECTS_TO_PACK_AND_PUSH must be defined and contain at least one path."));else projectsToPackAndPush = _.split(';');
|
|
94
96
|
}
|
|
95
97
|
if (errors.length > 0) {
|
|
96
|
-
throw new Error(["getConfig cannot continue. One or more errors occurred.", ...errors.map(v => v.
|
|
98
|
+
throw new Error(["getConfig cannot continue. One or more errors occurred.", ...errors.map(v => v.stack)].join('\n'));
|
|
97
99
|
}
|
|
98
100
|
let config = _objectSpread({}, semanticReleaseConfig.baseConfig);
|
|
99
101
|
config = insertAndEditPlugins(config);
|
|
100
102
|
if (projectsToPublish) config = appendPlugins(config, projectsToPublish, projectsToPackAndPush);
|
|
101
103
|
if (debug.enabled) {
|
|
102
|
-
debug(
|
|
104
|
+
console.debug(`modified plugins array:\n${node_util.inspect(config.plugins, false, Infinity)}`);
|
|
103
105
|
}
|
|
104
106
|
return config;
|
|
105
107
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"semanticReleaseConfigDotnet.cjs","sources":["../src/semanticReleaseConfigDotnet.ts"],"sourcesContent":null,"names":["defaultPlugins","setupGitPluginSpec","configurePrepareCmd","configureDotnetNugetPush","baseConfig"],"mappings":"
|
|
1
|
+
{"version":3,"file":"semanticReleaseConfigDotnet.cjs","sources":["../src/semanticReleaseConfigDotnet.ts"],"sourcesContent":null,"names":["defaultPlugins","setupGitPluginSpec","configurePrepareCmd","configureDotnetNugetPush","inspect","baseConfig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ED,iBAAO,CAAC,MAAM,CAAC,OAAO,EAAE,KAAK,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC;AAC1F,GAAG;AACH,EAAE,OAAO,MAAM,CAAC;AAChB;;;;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"semanticReleaseConfigDotnet.d.ts","sourceRoot":"","sources":["../src/semanticReleaseConfigDotnet.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAc,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"semanticReleaseConfigDotnet.d.ts","sourceRoot":"","sources":["../src/semanticReleaseConfigDotnet.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAc,MAAM,kBAAkB,CAAC;AAQ5D;;;;;;;;;GASG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,OAAO,GAAG,OAAO,CAO7D;AAED;;;;;;GAMG;AACH,wBAAgB,aAAa,CAC5B,MAAM,EAAE,OAAO,EACf,iBAAiB,EAAE,MAAM,EAAE,EAC3B,qBAAqB,EAAE,MAAM,EAAE,GAAG,KAAK,GACrC,OAAO,CAgBT;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,SAAS,CAAC,iBAAiB,GAAE,MAAM,EAAO,EAAE,qBAAqB,GAAE,MAAM,EAAE,GAAG,KAAU,GAAG,OAAO,CA0CjH;AAED,eAAe,SAAS,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@halospv3/hce.shared-config",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.5.0",
|
|
4
4
|
"description": "Automate commit message quality, changelogs, and CI/CD releases. Exports a semantic-release shareable configuration deserialized from this package's '.releaserc.yml'. Shared resources for .NET projects are also distributed with this package.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"halo",
|
|
@@ -43,7 +43,8 @@
|
|
|
43
43
|
"prepare": "husky",
|
|
44
44
|
"presemantic-release": "npm run pack && npm run check",
|
|
45
45
|
"semantic-release": "npx semantic-release",
|
|
46
|
-
"
|
|
46
|
+
"pretest": "npm run build",
|
|
47
|
+
"test": "node --test --import tsx ./tests/**/*.test.ts",
|
|
47
48
|
"type": "tsc --build",
|
|
48
49
|
"validate": "packemon validate",
|
|
49
50
|
"watch": "packemon watch"
|
|
@@ -88,13 +89,16 @@
|
|
|
88
89
|
"@types/babel__core": "^7.20.5",
|
|
89
90
|
"@types/debug": "^4.1.12",
|
|
90
91
|
"@types/eslint__eslintrc": "^2.1.1",
|
|
92
|
+
"@types/tmp": "^0.2.6",
|
|
91
93
|
"ajv": "^8.13.0",
|
|
92
94
|
"ajv-draft-04": "^1.0.0",
|
|
95
|
+
"dotenv": "^16.4.5",
|
|
93
96
|
"eslint": "^8.57.0",
|
|
94
97
|
"node-fetch": "^3.3.2",
|
|
95
98
|
"packemon": "^4.0.1",
|
|
96
99
|
"prettier": "^3.2.5",
|
|
97
100
|
"prettier-config-moon": "^1.1.2",
|
|
101
|
+
"tmp": "^0.2.3",
|
|
98
102
|
"tslib": "^2.6.2",
|
|
99
103
|
"tsx": "^4.10.5",
|
|
100
104
|
"typescript": "^5.4.5"
|
|
@@ -69,7 +69,7 @@ export class MSBuildProject {
|
|
|
69
69
|
const obj = JSON.parse(out) as object;
|
|
70
70
|
if ("Properties" in obj && typeof obj.Properties === 'object' && obj.Properties !== null)
|
|
71
71
|
props = obj.Properties as Record<string, string>;
|
|
72
|
-
throw new Error('When evaluating properties with MSBuild, "Properties" could not be found in the deserialized JSON object.
|
|
72
|
+
else throw new Error('When evaluating properties with MSBuild, "Properties" could not be found in the deserialized JSON object...\n' + JSON.stringify(obj))
|
|
73
73
|
}
|
|
74
74
|
else {
|
|
75
75
|
props = { [properties[0]]: out.trim() }
|
package/src/dotnet/dotnetGHPR.ts
CHANGED
|
@@ -1,55 +1,103 @@
|
|
|
1
|
+
import { ok } from 'node:assert/strict';
|
|
1
2
|
import type { NuGetRegistryInfo } from './dotnetHelpers.js';
|
|
3
|
+
import { env } from 'node:process'
|
|
2
4
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
5
|
+
/**
|
|
6
|
+
* @todo support custom base URL for private GitHub instances
|
|
7
|
+
* @param tokenEnvVar The name of the environment variable containing the NUGET token
|
|
8
|
+
* @returns `true` if the token is
|
|
9
|
+
* @throws
|
|
10
|
+
* - TypeError: The environment variable ${tokenEnvVar} is undefined!
|
|
11
|
+
* - Error:
|
|
12
|
+
* - The value of the token in ${tokenEnvVar} begins with 'github_pat_' which means it's a Fine-Grained token. At the time of writing, GitHub Fine-Grained tokens cannot push packages. If you believe this is statement is outdated, report the issue at https://github.com/halospv3/hce.shared/issues/new. For more information, see https://docs.github.com/en/packages/working-with-a-github-packages-registry/working-with-the-nuget-registry.
|
|
13
|
+
* - The GitHub API response header lacked "x-oauth-scopes". This indicates the token we provided is not a workflow token nor a Personal Access Token (classic) and can never have permission to push packages.
|
|
14
|
+
*/
|
|
15
|
+
export async function tokenCanWritePackages(tokenEnvVar: string) {
|
|
16
|
+
/* double-check the token exists */
|
|
17
|
+
const info = isTokenDefined(tokenEnvVar);
|
|
18
|
+
ok(info.isDefined)
|
|
19
|
+
|
|
20
|
+
if (info.fallback)
|
|
21
|
+
tokenEnvVar = info.fallback;
|
|
22
|
+
|
|
23
|
+
const tokenValue = env[tokenEnvVar];
|
|
6
24
|
if (tokenValue === undefined)
|
|
7
25
|
throw new TypeError(`The environment variable ${tokenEnvVar} is undefined!`)
|
|
8
|
-
|
|
26
|
+
|
|
27
|
+
if (tokenValue.startsWith('github_pat_'))
|
|
28
|
+
throw new Error(`The value of the token in ${tokenEnvVar} begins with 'github_pat_' which means it's a Fine-Grained token. At the time of writing, GitHub Fine-Grained tokens cannot push packages. If you believe this is statement is outdated, report the issue at https://github.com/halospv3/hce.shared/issues/new. For more information, see https://docs.github.com/en/packages/working-with-a-github-packages-registry/working-with-the-nuget-registry.`)
|
|
29
|
+
|
|
9
30
|
// CJS compatibility - import { request } from '@octokit/request
|
|
10
31
|
const request = (await import('@octokit/request')).request;
|
|
11
|
-
const response = await request('GET /', {
|
|
32
|
+
const response = await request('GET /', {
|
|
33
|
+
headers: {
|
|
34
|
+
authorization: `Bearer ${tokenValue}`
|
|
35
|
+
}
|
|
36
|
+
});
|
|
12
37
|
const scopes = response.headers['x-oauth-scopes'];
|
|
13
|
-
if (scopes)
|
|
14
|
-
return scopes.includes('write:packages')
|
|
15
|
-
|
|
16
|
-
|
|
38
|
+
if (scopes)
|
|
39
|
+
return scopes.includes('write:packages')
|
|
40
|
+
|
|
41
|
+
throw new Error('GitHub API response header lacked "x-oauth-scopes". This indicates the token we provided is not a workflow token nor a Personal Access Token (classic) and can never have permission to push packages.')
|
|
17
42
|
}
|
|
18
43
|
|
|
19
|
-
|
|
44
|
+
/** returns the value of {@link env.GITHUB_REPOSITORY_OWNER} */
|
|
45
|
+
function getOwner(): string | undefined {
|
|
46
|
+
return env.GITHUB_REPOSITORY_OWNER;
|
|
47
|
+
}
|
|
20
48
|
|
|
21
49
|
export const nugetGitHubUrlBase = 'https://nuget.pkg.github.com';
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
50
|
+
|
|
51
|
+
/** @deprecated use {@link getNugetGitHubUrl()} instead. */
|
|
52
|
+
export const nugetGitHubUrl: string | undefined = getNugetGitHubUrl();
|
|
53
|
+
|
|
54
|
+
export function getNugetGitHubUrl() {
|
|
55
|
+
const owner = getOwner();
|
|
56
|
+
if (owner)
|
|
57
|
+
return `${nugetGitHubUrlBase}/${owner}/index.json`;
|
|
58
|
+
return undefined;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* If tokenEnvVar is NOT 'GITHUB_TOKEN', then test if the token is defined and return the boolean.
|
|
63
|
+
* Else If tokenEnvVar is 'GITHUB_TOKEN' and defined, then return true.
|
|
64
|
+
* Else If tokenEnvVar is 'GITHUB_TOKEN' and undefined, then set tokenEnvVar to 'GH_TOKEN', test if GH_TOKEN is defined, and return the boolean.
|
|
65
|
+
* @param tokenEnvVar the name of the environment variable with the token's value. Defaults to 'GITHUB_TOKEN'. If environment variable 'GITHUB_TOKEN' is undefined, falls back to 'GH_TOKEN'.
|
|
66
|
+
* @returns `{isDefined: true}` if the token is defined. Else, if tokenEnvVar is 'GITHUB_TOKEN' (default) and token is defined, returns `true`. Else, if 'GH_TOKEN' is defined, returns `true`. Else, returns `false`
|
|
67
|
+
*/
|
|
68
|
+
export function isTokenDefined(tokenEnvVar = 'GITHUB_TOKEN'): { isDefined: boolean, fallback?: string } {
|
|
69
|
+
if (tokenEnvVar !== 'GITHUB_TOKEN')
|
|
70
|
+
return {
|
|
71
|
+
isDefined: (env[tokenEnvVar /* custom */] !== undefined && env[tokenEnvVar /* custom */] !== 'undefined')
|
|
72
|
+
};
|
|
73
|
+
else if (env[tokenEnvVar /* GITHUB_TOKEN */] !== undefined && env[tokenEnvVar /* GITHUB_TOKEN */] !== 'undefined')
|
|
74
|
+
return {
|
|
75
|
+
isDefined: true
|
|
76
|
+
};
|
|
77
|
+
else return {
|
|
78
|
+
isDefined: (env[tokenEnvVar = 'GH_TOKEN'] !== undefined && env[tokenEnvVar] !== 'undefined'),
|
|
79
|
+
fallback: 'GH_TOKEN'
|
|
80
|
+
};
|
|
81
|
+
}
|
|
25
82
|
|
|
26
83
|
/**
|
|
27
84
|
* Get a {@link NuGetRegistryInfo} for pushing to your GitHub Packages NuGet registry.
|
|
28
85
|
* todo: add support for private, custom GitHub instances. Token is only validated against github.com.
|
|
29
86
|
* @export
|
|
30
|
-
* @param {string} [tokenEnvVar="GITHUB_TOKEN"] The name of environment variable storing the GitHub Packages NuGet registry API key. Defaults to `"GITHUB_TOKEN"
|
|
31
|
-
* @param {string} [url=tokenEnvVar] The url of the GitHub Packages NuGet registry. Defaults to {@link
|
|
87
|
+
* @param {string | 'GITHUB_TOKEN' | 'GH_TOKEN'} [tokenEnvVar="GITHUB_TOKEN"] The name of environment variable storing the GitHub Packages NuGet registry API key. Defaults to `"GITHUB_TOKEN"`. If GITHUB_TOKEN is undefined, fallback to GH_TOKEN;
|
|
88
|
+
* @param {string} [url=tokenEnvVar] The url of the GitHub Packages NuGet registry. Defaults to return value of {@link getNugetGitHubUrl()}.
|
|
32
89
|
* @returns {(NuGetRegistryInfo | undefined)} a {@link NuGetRegistryInfo} object if {@link tokenEnvVar} and {@link url} are defined. Else, `undefined`.
|
|
33
90
|
* note: `url` defaults to job's repository owner's GitHub registry in GitHub Actions workflow. If GITHUB_REPOSITORY_OWNER is not defined, then an error will be logged and `undefined` will be returned.
|
|
34
91
|
*/
|
|
35
92
|
export async function getGithubNugetRegistryPair(
|
|
36
|
-
tokenEnvVar = 'GITHUB_TOKEN',
|
|
37
|
-
url: string | undefined =
|
|
93
|
+
tokenEnvVar: string | 'GITHUB_TOKEN' | 'GH_TOKEN' = 'GITHUB_TOKEN',
|
|
94
|
+
url: string | undefined = getNugetGitHubUrl(),
|
|
38
95
|
): Promise<NuGetRegistryInfo | undefined> {
|
|
39
|
-
// yes, this is stupid. No, I won't change it.
|
|
40
|
-
const isTokenDefined = process.env[tokenEnvVar] !== undefined;
|
|
41
|
-
const isUrlDefined = url !== undefined;
|
|
42
|
-
const canTokenWritePackages = isTokenDefined ? await tokenCanWritePackages(tokenEnvVar) : false;
|
|
43
|
-
|
|
44
96
|
const errors: Error[] = [];
|
|
97
|
+
const _isTokenDefinedInfo = isTokenDefined(tokenEnvVar);
|
|
98
|
+
let canTokenWritePackages = undefined;
|
|
45
99
|
|
|
46
|
-
if (
|
|
47
|
-
errors.push(
|
|
48
|
-
new Error(
|
|
49
|
-
`The environment variable ${tokenEnvVar} was specified as the source of the token to push a NuGet package to GitHub, but the environment variable does not exist.`,
|
|
50
|
-
),
|
|
51
|
-
);
|
|
52
|
-
if (!isUrlDefined) {
|
|
100
|
+
if ((url ??= getNugetGitHubUrl()) === undefined) {
|
|
53
101
|
errors.push(
|
|
54
102
|
new Error(
|
|
55
103
|
'The url for the GitHub Packages NuGet registry was undefined.\n' +
|
|
@@ -58,7 +106,27 @@ export async function getGithubNugetRegistryPair(
|
|
|
58
106
|
),
|
|
59
107
|
);
|
|
60
108
|
}
|
|
61
|
-
|
|
109
|
+
|
|
110
|
+
if (_isTokenDefinedInfo.isDefined) {
|
|
111
|
+
if (_isTokenDefinedInfo.fallback)
|
|
112
|
+
tokenEnvVar = _isTokenDefinedInfo.fallback;
|
|
113
|
+
try {
|
|
114
|
+
canTokenWritePackages = await tokenCanWritePackages(tokenEnvVar);
|
|
115
|
+
}
|
|
116
|
+
catch (err) {
|
|
117
|
+
if (err instanceof Error)
|
|
118
|
+
errors.push(err);
|
|
119
|
+
else
|
|
120
|
+
errors.push(new Error(String(err)));
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
else {
|
|
124
|
+
const errMsg = `The environment variable ${tokenEnvVar} was specified as the source of the token to push a NuGet package to GitHub, but the environment variable does not exist.`
|
|
125
|
+
+ `${_isTokenDefinedInfo.fallback === undefined ? '' : ` The fallback environment variable ${_isTokenDefinedInfo.fallback} is also undefined.`}`;
|
|
126
|
+
errors.push(new Error(errMsg));
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
if (canTokenWritePackages === false) {
|
|
62
130
|
// yes, this is a critical error that should be fixed before Semantic Release can succeed.
|
|
63
131
|
// yes, this is incredibly irritating to deal with in local runs.
|
|
64
132
|
errors.push(
|
|
@@ -69,8 +137,14 @@ export async function getGithubNugetRegistryPair(
|
|
|
69
137
|
}
|
|
70
138
|
|
|
71
139
|
// conditions checked so `url` is certainly defined
|
|
72
|
-
if (
|
|
140
|
+
if (_isTokenDefinedInfo.isDefined && url !== undefined && canTokenWritePackages)
|
|
73
141
|
return { tokenEnvVar, url };
|
|
74
142
|
|
|
75
|
-
|
|
143
|
+
const aggErr = new Error(`One more more errors occurred when getting GHPR url-token pair. Errors:\n${errors.map(v => v.stack).join('\n')}`);
|
|
144
|
+
|
|
145
|
+
if (env['SKIP_TOKEN'] === 'true' && aggErr.message.length > 0) {
|
|
146
|
+
console.error('WARN: errors were thrown, but SKIP_TOKEN is defined.\n' + aggErr.stack)
|
|
147
|
+
return undefined;
|
|
148
|
+
}
|
|
149
|
+
throw aggErr;
|
|
76
150
|
}
|
package/src/dotnet/dotnetGLPR.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { error } from 'node:console';
|
|
2
1
|
import type { NuGetRegistryInfo } from './dotnetHelpers.js';
|
|
2
|
+
import { env } from "node:process"
|
|
3
3
|
|
|
4
|
-
const { CI_API_V4_URL, CI_PROJECT_ID } =
|
|
4
|
+
const { CI_API_V4_URL, CI_PROJECT_ID } = env;
|
|
5
5
|
const nameof = {
|
|
6
6
|
CI_API_V4_URL: 'CI_API_V4_URL',
|
|
7
7
|
CI_PROJECT_ID: 'CI_PROJECT_ID',
|
|
@@ -26,8 +26,8 @@ export function getGitlabNugetRegistryPair(
|
|
|
26
26
|
url: string | undefined = nugetGitLabUrl,
|
|
27
27
|
): NuGetRegistryInfo | undefined {
|
|
28
28
|
// yes, this is stupid. No, I won't change it.
|
|
29
|
-
if (!
|
|
30
|
-
error(
|
|
29
|
+
if (!env[tokenEnvVar]) {
|
|
30
|
+
console.error(
|
|
31
31
|
new Error(
|
|
32
32
|
`The environment variable ${tokenEnvVar} was specified as the source of the token to push a NuGet package to GitLab, but the environment variable does not exist.`,
|
|
33
33
|
),
|
|
@@ -37,7 +37,7 @@ export function getGitlabNugetRegistryPair(
|
|
|
37
37
|
if (url) {
|
|
38
38
|
return { tokenEnvVar, url };
|
|
39
39
|
}
|
|
40
|
-
error(
|
|
40
|
+
console.error(
|
|
41
41
|
new Error(
|
|
42
42
|
`The environment variables ${nameof.CI_API_V4_URL} or ${nameof.CI_PROJECT_ID} do not exist and a custom GitLab Packages NuGet registry URL was not provided.`,
|
|
43
43
|
),
|
|
@@ -2,6 +2,7 @@ import { ok } from 'node:assert/strict';
|
|
|
2
2
|
import { getGithubNugetRegistryPair, nugetGitHubUrlBase } from './dotnetGHPR.js';
|
|
3
3
|
import { getGitlabNugetRegistryPair } from './dotnetGLPR.js';
|
|
4
4
|
import { MSBuildProject, MSBuildProjectPreDefinedProperties } from './MSBuildProject.js';
|
|
5
|
+
import { env } from 'node:process';
|
|
5
6
|
|
|
6
7
|
|
|
7
8
|
function formatDotnetPublish(projectsToPublish: string[], publishProperties: string[]): string {
|
|
@@ -175,9 +176,9 @@ export async function configureDotnetNugetPush(
|
|
|
175
176
|
return registries
|
|
176
177
|
.map(
|
|
177
178
|
(registry) => {
|
|
178
|
-
const tokenValue =
|
|
179
|
-
ok(tokenValue, `The environment variable ${registry.tokenEnvVar} is undefined!`);
|
|
180
|
-
`dotnet nuget push ${nupkgDir} --source ${registry.url} --token ${tokenValue}`
|
|
179
|
+
const tokenValue = env[registry.tokenEnvVar];
|
|
180
|
+
ok(env['SKIP_TOKEN'] === 'true' || tokenValue, `The environment variable ${registry.tokenEnvVar} is undefined!`);
|
|
181
|
+
`dotnet nuget push ${nupkgDir} --source ${registry.url} --token ${tokenValue ?? '**placeholder**'}`
|
|
181
182
|
}
|
|
182
183
|
)
|
|
183
184
|
.join(' && ');
|
|
@@ -16,6 +16,8 @@ import { configureDotnetNugetPush, configurePrepareCmd } from './dotnet/dotnetHe
|
|
|
16
16
|
import { baseConfig, defaultPlugins } from './semanticReleaseConfig.js';
|
|
17
17
|
import { setupGitPluginSpec } from './setupGitPluginSpec.js';
|
|
18
18
|
import debug from './debug.js'
|
|
19
|
+
import { inspect } from 'node:util';
|
|
20
|
+
import { env } from "node:process"
|
|
19
21
|
|
|
20
22
|
/**
|
|
21
23
|
* TODO: options/params for inserts/edits. NOT ready for production. Currently, this can only add Git plugin's options if undefined or one or more is missing.
|
|
@@ -83,21 +85,21 @@ export function appendPlugins(
|
|
|
83
85
|
*/
|
|
84
86
|
export function getConfig(projectsToPublish: string[] = [], projectsToPackAndPush: string[] | false = []): Options {
|
|
85
87
|
if (debug.enabled) {
|
|
86
|
-
debug('hce.shared-config:\n
|
|
88
|
+
console.debug('hce.shared-config:\n' + inspect(baseConfig, false, Infinity, true));
|
|
87
89
|
}
|
|
88
90
|
|
|
89
91
|
const errors: Error[] = [];
|
|
90
92
|
|
|
91
93
|
if (projectsToPublish.length === 0) {
|
|
92
|
-
const _ =
|
|
94
|
+
const _ = env["PROJECTS_TO_PUBLISH"];
|
|
93
95
|
if (_ === undefined)
|
|
94
96
|
errors.push(new Error("projectsToPublish.length must be > 0 or PROJECTS_TO_PUBLISH must be defined and contain at least one path."));
|
|
95
97
|
else
|
|
96
98
|
projectsToPublish = _.split(';');
|
|
97
99
|
}
|
|
98
100
|
|
|
99
|
-
if (projectsToPackAndPush && projectsToPackAndPush.length) {
|
|
100
|
-
const _ =
|
|
101
|
+
if (projectsToPackAndPush !== false && projectsToPackAndPush.length === 0) {
|
|
102
|
+
const _ = env["PROJECTS_TO_PACK_AND_PUSH"]
|
|
101
103
|
if (_ === undefined)
|
|
102
104
|
errors.push(new Error("projectsToPackAndPush.length must be > 0 or PROJECTS_TO_PACK_AND_PUSH must be defined and contain at least one path."));
|
|
103
105
|
else
|
|
@@ -108,7 +110,7 @@ export function getConfig(projectsToPublish: string[] = [], projectsToPackAndPus
|
|
|
108
110
|
throw new Error(
|
|
109
111
|
[
|
|
110
112
|
"getConfig cannot continue. One or more errors occurred.",
|
|
111
|
-
...(errors.map(v => v.
|
|
113
|
+
...(errors.map(v => v.stack))
|
|
112
114
|
].join('\n')
|
|
113
115
|
)
|
|
114
116
|
}
|
|
@@ -119,7 +121,7 @@ export function getConfig(projectsToPublish: string[] = [], projectsToPackAndPus
|
|
|
119
121
|
config = appendPlugins(config, projectsToPublish, projectsToPackAndPush);
|
|
120
122
|
|
|
121
123
|
if (debug.enabled) {
|
|
122
|
-
debug(
|
|
124
|
+
console.debug(`modified plugins array:\n${inspect(config.plugins, false, Infinity)}`);
|
|
123
125
|
}
|
|
124
126
|
|
|
125
127
|
return config;
|