@halospv3/hce.shared-config 3.5.3-develop.1 → 3.6.0-develop.1
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 +20 -0
- package/README.md +33 -10
- package/dotnet/.github/workflows/_unit_test.yml +2 -2
- package/dotnet/.github/workflows/dotnet-release.yml +1 -1
- package/dotnet/.github/workflows/sample-dotnet-build.yml +1 -1
- package/dotnet/CleanupWpfTmp.targets +15 -0
- package/dotnet/HCE.Shared.targets +3 -0
- package/mjs/CaseInsensitiveMap.mjs.map +1 -1
- package/mjs/commitlintConfig.mjs.map +1 -1
- package/mjs/debug.mjs.map +1 -1
- package/mjs/dotnet/GithubNugetRegistryInfo.d.mts +5 -5
- package/mjs/dotnet/GithubNugetRegistryInfo.d.mts.map +1 -1
- package/mjs/dotnet/GithubNugetRegistryInfo.mjs +7 -7
- package/mjs/dotnet/GithubNugetRegistryInfo.mjs.map +1 -1
- package/mjs/dotnet/GitlabNugetRegistryInfo.d.mts +6 -6
- package/mjs/dotnet/GitlabNugetRegistryInfo.d.mts.map +1 -1
- package/mjs/dotnet/GitlabNugetRegistryInfo.mjs +14 -14
- package/mjs/dotnet/GitlabNugetRegistryInfo.mjs.map +1 -1
- package/mjs/dotnet/IsNextVersionAlreadyPublished.cli.mjs +5 -5
- package/mjs/dotnet/IsNextVersionAlreadyPublished.cli.mjs.map +1 -1
- package/mjs/dotnet/MSBuildProject.d.mts +28 -28
- package/mjs/dotnet/MSBuildProject.d.mts.map +1 -1
- package/mjs/dotnet/MSBuildProject.mjs +88 -66
- package/mjs/dotnet/MSBuildProject.mjs.map +1 -1
- package/mjs/dotnet/MSBuildProjectProperties.d.mts.map +1 -1
- package/mjs/dotnet/MSBuildProjectProperties.mjs +1 -1
- package/mjs/dotnet/MSBuildProjectProperties.mjs.map +1 -1
- package/mjs/dotnet/NugetProjectProperties.d.mts +3 -3
- package/mjs/dotnet/NugetProjectProperties.d.mts.map +1 -1
- package/mjs/dotnet/NugetProjectProperties.mjs +7 -9
- package/mjs/dotnet/NugetProjectProperties.mjs.map +1 -1
- package/mjs/dotnet/NugetRegistryInfo.d.mts +40 -40
- package/mjs/dotnet/NugetRegistryInfo.d.mts.map +1 -1
- package/mjs/dotnet/NugetRegistryInfo.mjs +170 -148
- package/mjs/dotnet/NugetRegistryInfo.mjs.map +1 -1
- package/mjs/dotnet/helpers.d.mts.map +1 -1
- package/mjs/dotnet/helpers.mjs +33 -34
- package/mjs/dotnet/helpers.mjs.map +1 -1
- package/mjs/eslintConfig.mjs.map +1 -1
- package/mjs/insertPlugins.mjs +2 -2
- package/mjs/insertPlugins.mjs.map +1 -1
- package/mjs/semantic-release__commit-analyzer.d.mts.map +1 -1
- package/mjs/semantic-release__exec.d.mts.map +1 -1
- package/mjs/semantic-release__git.d.mts.map +1 -1
- package/mjs/semantic-release__github.d.mts +1 -0
- package/mjs/semantic-release__github.d.mts.map +1 -1
- package/mjs/semanticReleaseConfig.d.mts.map +1 -1
- package/mjs/semanticReleaseConfig.mjs.map +1 -1
- package/mjs/semanticReleaseConfigDotnet.d.mts.map +1 -1
- package/mjs/semanticReleaseConfigDotnet.mjs +23 -16
- package/mjs/semanticReleaseConfigDotnet.mjs.map +1 -1
- package/mjs/setupGitPluginSpec.d.mts.map +1 -1
- package/mjs/setupGitPluginSpec.default.mjs.map +1 -1
- package/mjs/setupGitPluginSpec.mjs +19 -19
- package/mjs/setupGitPluginSpec.mjs.map +1 -1
- package/mjs/utils/Exact.d.mts.map +1 -1
- package/mjs/utils/GracefulRecursion.d.mts.map +1 -1
- package/mjs/utils/env.d.mts.map +1 -1
- package/mjs/utils/env.mjs.map +1 -1
- package/mjs/utils/execAsync.d.mts +3 -3
- package/mjs/utils/execAsync.d.mts.map +1 -1
- package/mjs/utils/execAsync.mjs +14 -12
- package/mjs/utils/execAsync.mjs.map +1 -1
- package/mjs/utils/isError.mjs.map +1 -1
- package/mjs/utils/miscTypes.d.mts.map +1 -1
- package/mjs/utils/miscTypes.mjs.map +1 -1
- package/mjs/utils/reflection/FunctionLike.d.mts +1 -0
- package/mjs/utils/reflection/FunctionLike.d.mts.map +1 -1
- package/mjs/utils/reflection/GetterDescriptor.d.mts.map +1 -1
- package/mjs/utils/reflection/InstancePropertyDescriptorMap.d.mts.map +1 -1
- package/mjs/utils/reflection/InstanceTypeOrSelfPropertyDescriptorMap.d.mts +1 -1
- package/mjs/utils/reflection/InstanceTypeOrSelfPropertyDescriptorMap.d.mts.map +1 -1
- package/mjs/utils/reflection/OwnGetterDescriptorMap.d.mts +1 -1
- package/mjs/utils/reflection/OwnGetterDescriptorMap.d.mts.map +1 -1
- package/mjs/utils/reflection/OwnKeyOf.d.mts +1 -1
- package/mjs/utils/reflection/OwnKeyOf.d.mts.map +1 -1
- package/mjs/utils/reflection/OwnPropertyDescriptorMap.d.mts.map +1 -1
- package/mjs/utils/reflection/PropertyDescriptorMap.d.mts +1 -1
- package/mjs/utils/reflection/PropertyDescriptorMap.d.mts.map +1 -1
- package/mjs/utils/reflection/filterForGetters.d.mts.map +1 -1
- package/mjs/utils/reflection/filterForGetters.mjs.map +1 -1
- package/mjs/utils/reflection/getOwnPropertyDescriptors.d.mts.map +1 -1
- package/mjs/utils/reflection/getOwnPropertyDescriptors.mjs.map +1 -1
- package/mjs/utils/reflection/getOwnPropertyDescriptorsRecursively.d.mts.map +1 -1
- package/mjs/utils/reflection/getOwnPropertyDescriptorsRecursively.mjs +3 -3
- package/mjs/utils/reflection/getOwnPropertyDescriptorsRecursively.mjs.map +1 -1
- package/mjs/utils/reflection/getPrototypeChainOf.d.mts +2 -2
- package/mjs/utils/reflection/getPrototypeChainOf.d.mts.map +1 -1
- package/mjs/utils/reflection/getPrototypeChainOf.mjs +1 -2
- package/mjs/utils/reflection/getPrototypeChainOf.mjs.map +1 -1
- package/mjs/utils/reflection/getPrototypeOf.d.mts.map +1 -1
- package/mjs/utils/reflection/getPrototypeOf.mjs.map +1 -1
- package/mjs/utils/reflection/inheritance.d.mts +4 -4
- package/mjs/utils/reflection/inheritance.d.mts.map +1 -1
- package/mjs/utils/reflection/inheritance.mjs.map +1 -1
- package/mjs/utils/reflection/isConstructor.d.mts +3 -3
- package/mjs/utils/reflection/isConstructor.d.mts.map +1 -1
- package/mjs/utils/reflection/isConstructor.mjs +7 -7
- package/mjs/utils/reflection/isConstructor.mjs.map +1 -1
- package/mjs/utils/reflection/isGetterDescriptor.d.mts.map +1 -1
- package/mjs/utils/reflection/isGetterDescriptor.mjs.map +1 -1
- package/mjs/utils/reflection/listOwnGetters.d.mts.map +1 -1
- package/mjs/utils/reflection/listOwnGetters.mjs +4 -2
- package/mjs/utils/reflection/listOwnGetters.mjs.map +1 -1
- package/mjs/utils/reflection.d.mts +1 -1
- package/package.json +26 -25
- package/src/dotnet/GithubNugetRegistryInfo.ts +18 -15
- package/src/dotnet/GitlabNugetRegistryInfo.ts +28 -26
- package/src/dotnet/IsNextVersionAlreadyPublished.cli.ts +6 -6
- package/src/dotnet/MSBuildProject.ts +103 -106
- package/src/dotnet/MSBuildProjectProperties.ts +1 -1
- package/src/dotnet/NugetProjectProperties.ts +13 -18
- package/src/dotnet/NugetRegistryInfo.ts +287 -243
- package/src/dotnet/helpers.ts +58 -58
- package/src/insertPlugins.ts +3 -3
- package/src/semantic-release__github.d.ts +1 -0
- package/src/semanticReleaseConfigDotnet.ts +52 -54
- package/src/setupGitPluginSpec.ts +25 -26
- package/src/utils/env.ts +1 -0
- package/src/utils/execAsync.ts +16 -13
- package/src/utils/reflection/FunctionLike.d.ts +1 -0
- package/src/utils/reflection/InstancePropertyDescriptorMap.d.ts +4 -4
- package/src/utils/reflection/InstanceTypeOrSelfPropertyDescriptorMap.d.ts +6 -6
- package/src/utils/reflection/OwnGetterDescriptorMap.d.ts +2 -2
- package/src/utils/reflection/OwnKeyOf.d.ts +3 -3
- package/src/utils/reflection/OwnPropertyDescriptorMap.d.ts +3 -3
- package/src/utils/reflection/PropertyDescriptorMap.d.ts +3 -3
- package/src/utils/reflection/filterForGetters.ts +10 -10
- package/src/utils/reflection/getOwnPropertyDescriptors.ts +2 -2
- package/src/utils/reflection/getOwnPropertyDescriptorsRecursively.ts +13 -13
- package/src/utils/reflection/getPrototypeChainOf.ts +17 -17
- package/src/utils/reflection/getPrototypeOf.ts +2 -2
- package/src/utils/reflection/inheritance.ts +5 -4
- package/src/utils/reflection/isConstructor.ts +7 -7
- package/src/utils/reflection/listOwnGetters.ts +8 -8
- package/tsconfig.base.json +2 -0
|
@@ -14,7 +14,7 @@ import { config } from "@dotenvx/dotenvx";
|
|
|
14
14
|
import { detectFile, detectFileSync } from "chardet";
|
|
15
15
|
import sanitizeFileName from "sanitize-filename";
|
|
16
16
|
//#region src/dotnet/NugetRegistryInfo.ts
|
|
17
|
-
const
|
|
17
|
+
const temporaryDirectoryNamespace = node_path.join(tmpdir(), "HCE.Shared", ".NET", "Dummies");
|
|
18
18
|
const defaultNugetSource = "https://api.nuget.org/v3/index.json";
|
|
19
19
|
const key_OutputPackItems = "_OutputPackItems";
|
|
20
20
|
/**
|
|
@@ -29,14 +29,14 @@ async function getGithubOutput() {
|
|
|
29
29
|
env["GITHUB_OUTPUT"] = githubOutputPath;
|
|
30
30
|
}
|
|
31
31
|
const encoding = await detectFile(env["GITHUB_OUTPUT"]);
|
|
32
|
-
const
|
|
32
|
+
const environmentOutput = config({
|
|
33
33
|
path: env["GITHUB_OUTPUT"],
|
|
34
34
|
override: true,
|
|
35
35
|
encoding: encoding ?? void 0,
|
|
36
36
|
processEnv: {}
|
|
37
37
|
});
|
|
38
|
-
if (isError(
|
|
39
|
-
return
|
|
38
|
+
if (isError(environmentOutput.error)) throw environmentOutput.error;
|
|
39
|
+
return environmentOutput.parsed;
|
|
40
40
|
}
|
|
41
41
|
/**
|
|
42
42
|
* Read the contents of $GITHUB_OUTPUT (if its value is a file path) or $TEMP/GITHUB_OUTPUT.
|
|
@@ -50,14 +50,14 @@ function getGithubOutputSync() {
|
|
|
50
50
|
env["GITHUB_OUTPUT"] = githubOutputPath;
|
|
51
51
|
}
|
|
52
52
|
const encoding = detectFileSync(env["GITHUB_OUTPUT"]);
|
|
53
|
-
const
|
|
53
|
+
const environmentOutput = config({
|
|
54
54
|
path: env["GITHUB_OUTPUT"],
|
|
55
55
|
override: true,
|
|
56
56
|
encoding: encoding ?? void 0,
|
|
57
57
|
processEnv: {}
|
|
58
58
|
});
|
|
59
|
-
if ("error" in
|
|
60
|
-
return
|
|
59
|
+
if ("error" in environmentOutput) throw environmentOutput.error;
|
|
60
|
+
return environmentOutput.parsed;
|
|
61
61
|
}
|
|
62
62
|
/**
|
|
63
63
|
* Get HCE.Shared's temporary directory for .NET projects' dummy packages.
|
|
@@ -67,32 +67,45 @@ function getGithubOutputSync() {
|
|
|
67
67
|
* `${tmpdir()}/HCE.Shared/.NET/Dummies/${project.Properties.PackageId}` if
|
|
68
68
|
* {@link project} is defined. Else `${tmpdir()}/HCE.Shared/.NET/Dummies`
|
|
69
69
|
*/
|
|
70
|
-
function
|
|
70
|
+
function getDummiesDirectory(project) {
|
|
71
71
|
switch (true) {
|
|
72
|
-
case project === void 0: return node_path.join(
|
|
73
|
-
case project instanceof MSBuildProject: return node_path.join(
|
|
72
|
+
case project === void 0: return node_path.join(temporaryDirectoryNamespace, node_path.sep);
|
|
73
|
+
case project instanceof MSBuildProject: return node_path.join(temporaryDirectoryNamespace, project.Properties.PackageId, node_path.sep);
|
|
74
74
|
default: throw new Error("The type of argument `project` must be `undefined` or `MSBuildProject`.");
|
|
75
75
|
}
|
|
76
76
|
}
|
|
77
77
|
/**
|
|
78
78
|
* Get the environment variables as key-value pairs.
|
|
79
|
-
* @param
|
|
79
|
+
* @param tokenEnvironmentVariables The name of the environment variables whose values are
|
|
80
80
|
* NuGet API keys.
|
|
81
81
|
* @returns an array of key-value pairs of the given environment variables and
|
|
82
82
|
* their values, filtered to only those whose values are not undefined.
|
|
83
83
|
* @throws {Error} when none of the provided environment variables are defined.
|
|
84
84
|
*/
|
|
85
|
-
function
|
|
86
|
-
const definedTokens = Object.freeze(
|
|
85
|
+
function _GetTokenEnvironmentVariables(tokenEnvironmentVariables) {
|
|
86
|
+
const definedTokens = Object.freeze(tokenEnvironmentVariables.map((key) => [key, getEnvVarValue(key)]).filter((environmentVariableTuple) => environmentVariableTuple[1] !== void 0));
|
|
87
87
|
if (definedTokens.length > 0) return definedTokens;
|
|
88
88
|
}
|
|
89
89
|
var NugetRegistryInfo = class NugetRegistryInfo {
|
|
90
|
-
_canPushPackagesToSource = void 0;
|
|
91
|
-
_project;
|
|
92
|
-
_resolvedEnvVariable;
|
|
93
|
-
_source;
|
|
94
90
|
static DefaultTokenEnvVars = Object.freeze(["NUGET_TOKEN"]);
|
|
95
91
|
/**
|
|
92
|
+
* Get the API token from {@link NugetRegistryInfo#resolvedEnvVariable}
|
|
93
|
+
* @param resolvedEnvironmentVariable The name of the environment variable(s) whose
|
|
94
|
+
* value is a NuGet API key. Typically, the value of
|
|
95
|
+
* {@link NugetRegistryInfo#resolvedEnvVariable}.
|
|
96
|
+
* @returns The value of the first defined environment variable.
|
|
97
|
+
* @throws {Error} when none of the provided environment variables are defined.
|
|
98
|
+
*/
|
|
99
|
+
static _GetTokenValue(resolvedEnvironmentVariable) {
|
|
100
|
+
type.string.assert(resolvedEnvironmentVariable);
|
|
101
|
+
const tokenValue = getEnvVarValue(resolvedEnvironmentVariable);
|
|
102
|
+
if (tokenValue === void 0) throw new Error(`\
|
|
103
|
+
The environment variable ${resolvedEnvironmentVariable} was specified \
|
|
104
|
+
as the source of the token to push a NuGet package, \
|
|
105
|
+
but the environment variable is empty or undefined.`);
|
|
106
|
+
return tokenValue;
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
96
109
|
* Convert a URL string to a filesystem folder name.
|
|
97
110
|
*
|
|
98
111
|
* Intended usage: modify the output path of `dotnet pack` based on the NuGet
|
|
@@ -109,6 +122,10 @@ var NugetRegistryInfo = class NugetRegistryInfo {
|
|
|
109
122
|
static GetDirNameForSource(source) {
|
|
110
123
|
return sanitizeFileName(source.replaceAll(/\/index.json$/g, ""), { replacement: "_" });
|
|
111
124
|
}
|
|
125
|
+
_canPushPackagesToSource = void 0;
|
|
126
|
+
_project;
|
|
127
|
+
_resolvedEnvVariable;
|
|
128
|
+
_source;
|
|
112
129
|
/**
|
|
113
130
|
* Creates an instance of NugetRegistryInfo.\
|
|
114
131
|
* This class enables the ability to push a given {@link project}'s
|
|
@@ -125,29 +142,29 @@ var NugetRegistryInfo = class NugetRegistryInfo {
|
|
|
125
142
|
* Release's config object for later use by `@semantic-release/exec`.
|
|
126
143
|
* - Other EcmaScript modules can access the environment variable(s) and steal
|
|
127
144
|
* your key. Be aware of malicious dependencies!
|
|
128
|
-
* @param
|
|
129
|
-
* @param
|
|
145
|
+
* @param options The input type of {@link NRIOpts.from}
|
|
146
|
+
* @param options.project The project whose package(s) will be
|
|
130
147
|
* pushed.\
|
|
131
148
|
* - Its {@link NugetProjectProperties#PackageId} will be read.\
|
|
132
149
|
* - Its {@link NugetProjectProperties#PackageVersion} will be overridden via CLI args when creating a dummy package. The real package's
|
|
133
150
|
* `PackageVersion` will *not* be overridden.
|
|
134
|
-
* @param [
|
|
151
|
+
* @param [options.tokenEnvVars] The environment variables
|
|
135
152
|
* whose values are tokens with permission to push a package to the NuGet
|
|
136
153
|
* package registry. The array is iterated through until one token is found.
|
|
137
154
|
* If none of the environment variables are defined, this constructor will
|
|
138
155
|
* throw an {@link Error}.
|
|
139
|
-
* @param [
|
|
156
|
+
* @param [options.source] A NuGet package registry's API endpoint URL or name. Default: 'https://api.nuget.org/v3/index.json'
|
|
140
157
|
*/
|
|
141
|
-
constructor(
|
|
142
|
-
const
|
|
143
|
-
this._project =
|
|
158
|
+
constructor(options) {
|
|
159
|
+
const validOptions = NRIOpts.from(options);
|
|
160
|
+
this._project = validOptions.project;
|
|
144
161
|
/**
|
|
145
162
|
* May throw! Assign key of the first key-value pair to
|
|
146
163
|
* {@link resolvedEnvVariable}
|
|
147
164
|
*/
|
|
148
|
-
const
|
|
149
|
-
if (
|
|
150
|
-
this._source =
|
|
165
|
+
const tokenVariables = _GetTokenEnvironmentVariables(validOptions.tokenEnvVars);
|
|
166
|
+
if (tokenVariables) this._resolvedEnvVariable = tokenVariables[0][0];
|
|
167
|
+
this._source = validOptions.source;
|
|
151
168
|
}
|
|
152
169
|
get project() {
|
|
153
170
|
return this._project;
|
|
@@ -170,9 +187,9 @@ var NugetRegistryInfo = class NugetRegistryInfo {
|
|
|
170
187
|
let tokenValue;
|
|
171
188
|
if (this.resolvedEnvVariable !== void 0) tokenValue = NRI._GetTokenValue(this.resolvedEnvVariable);
|
|
172
189
|
if (tokenValue?.startsWith("github_pat_")) {
|
|
173
|
-
const
|
|
174
|
-
const
|
|
175
|
-
return this._canPushPackagesToSource = Promise.reject(
|
|
190
|
+
const errorMessage = `The value of the token in 'resolvedEnvVariable' ${String(this.resolvedEnvVariable)} begins with 'github_pat_', indicating 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.`;
|
|
191
|
+
const error = new Error(errorMessage);
|
|
192
|
+
return this._canPushPackagesToSource = Promise.reject(error);
|
|
176
193
|
}
|
|
177
194
|
return this._canPushPackagesToSource = this.PackDummyPackage({}).then(async () => await this._PushDummyPackages({ apiKey: tokenValue })).then((execAsyncReturn) => {
|
|
178
195
|
ok(execAsyncReturn);
|
|
@@ -191,23 +208,6 @@ var NugetRegistryInfo = class NugetRegistryInfo {
|
|
|
191
208
|
return this._source;
|
|
192
209
|
}
|
|
193
210
|
/**
|
|
194
|
-
* Get the API token from {@link NugetRegistryInfo#resolvedEnvVariable}
|
|
195
|
-
* @param resolvedEnvVariable The name of the environment variable(s) whose
|
|
196
|
-
* value is a NuGet API key. Typically, the value of
|
|
197
|
-
* {@link NugetRegistryInfo#resolvedEnvVariable}.
|
|
198
|
-
* @returns The value of the first defined environment variable.
|
|
199
|
-
* @throws {Error} when none of the provided environment variables are defined.
|
|
200
|
-
*/
|
|
201
|
-
static _GetTokenValue(resolvedEnvVariable) {
|
|
202
|
-
type.string.assert(resolvedEnvVariable);
|
|
203
|
-
const tokenValue = getEnvVarValue(resolvedEnvVariable);
|
|
204
|
-
if (tokenValue === void 0) throw new Error(`\
|
|
205
|
-
The environment variable ${resolvedEnvVariable} was specified \
|
|
206
|
-
as the source of the token to push a NuGet package, \
|
|
207
|
-
but the environment variable is empty or undefined.`);
|
|
208
|
-
return tokenValue;
|
|
209
|
-
}
|
|
210
|
-
/**
|
|
211
211
|
* The type for options and arguments of `dotnet pack`. See https://learn.microsoft.com/en-us/dotnet/core/tools/dotnet-pack.
|
|
212
212
|
*
|
|
213
213
|
* {@link NRI.PackPackagesOptionsType.t.propertyOverrides `propertyOverrides`}
|
|
@@ -248,58 +248,58 @@ but the environment variable is empty or undefined.`);
|
|
|
248
248
|
* When pushing the package(s), you only need to supply the main .nupkg's path
|
|
249
249
|
* or its directory to the dotnet CLI—by default, it will also push the
|
|
250
250
|
* symbols package, if present.
|
|
251
|
-
* @param
|
|
251
|
+
* @param options Options passed to
|
|
252
252
|
* `dotnet pack`, excluding the required `<PROJECT | SOLUTION>` argument. The
|
|
253
253
|
* {@link PackPackagesOptionsType.t.output} path is modified according to the
|
|
254
|
-
* {@link
|
|
254
|
+
* {@link shouldUsePerSourceSubfolder} and {@link shouldUsePerPackageIdSubfolder}
|
|
255
255
|
* arguments.
|
|
256
|
-
* @param
|
|
256
|
+
* @param shouldUsePerSourceSubfolder If true, the path of the package output will
|
|
257
257
|
* include a subfolder named after the NuGet Source.
|
|
258
|
-
* @param
|
|
258
|
+
* @param shouldUsePerPackageIdSubfolder If true, the path of the package output
|
|
259
259
|
* will include a subfolder named after the NuGet package's ID.
|
|
260
260
|
* @returns `dotnet pack "${this.project.Properties.MSBuildProjectFullPath}"
|
|
261
261
|
* -o "${outDir}"` where outDir may be `${cwd()}/publish/${NugetRegistryInfo.GetNameForURL(this.source)}/${this._project.Properties.PackageId}`
|
|
262
262
|
*/
|
|
263
|
-
GetPackCommand(
|
|
264
|
-
const
|
|
265
|
-
type.boolean.assert(
|
|
266
|
-
type.boolean.assert(
|
|
267
|
-
|
|
268
|
-
if (
|
|
269
|
-
if (
|
|
270
|
-
const
|
|
263
|
+
GetPackCommand(options, shouldUsePerSourceSubfolder = false, shouldUsePerPackageIdSubfolder = false) {
|
|
264
|
+
const validOptions = NRI.PackPackagesOptionsType.from(options);
|
|
265
|
+
type.boolean.assert(shouldUsePerSourceSubfolder);
|
|
266
|
+
type.boolean.assert(shouldUsePerPackageIdSubfolder);
|
|
267
|
+
validOptions.output ??= node_path.join(cwd(), "publish");
|
|
268
|
+
if (shouldUsePerSourceSubfolder) validOptions.output = node_path.join(validOptions.output, NugetRegistryInfo.GetDirNameForSource(this.source), node_path.sep);
|
|
269
|
+
if (shouldUsePerPackageIdSubfolder) validOptions.output = node_path.join(validOptions.output, this._project.Properties.PackageId, node_path.sep);
|
|
270
|
+
const packCommandArray = [
|
|
271
271
|
"dotnet",
|
|
272
272
|
"pack",
|
|
273
273
|
`"${this._project.Properties.MSBuildProjectFullPath}"`
|
|
274
274
|
];
|
|
275
|
-
if (
|
|
276
|
-
if (
|
|
277
|
-
if (
|
|
278
|
-
if (
|
|
279
|
-
if (
|
|
280
|
-
if (
|
|
281
|
-
if (
|
|
282
|
-
if (
|
|
283
|
-
if (
|
|
284
|
-
if (
|
|
285
|
-
if (
|
|
286
|
-
if (
|
|
287
|
-
if (
|
|
288
|
-
if (
|
|
289
|
-
if (
|
|
290
|
-
if (
|
|
275
|
+
if (validOptions.artifactsPath !== void 0) packCommandArray.push("--artifactsPath", `"${validOptions.artifactsPath}"`);
|
|
276
|
+
if (validOptions.configuration !== void 0) packCommandArray.push("--configuration", validOptions.configuration);
|
|
277
|
+
if (validOptions.disableBuildServers === true) packCommandArray.push("--disable-build-servers");
|
|
278
|
+
if (validOptions.force === true) packCommandArray.push("--force");
|
|
279
|
+
if (validOptions.includeSource === true) packCommandArray.push("--include-source");
|
|
280
|
+
if (validOptions.includeSymbols === true) packCommandArray.push("--include-symbols");
|
|
281
|
+
if (validOptions.interactive === true) packCommandArray.push("--interactive");
|
|
282
|
+
if (validOptions.noBuild === true) packCommandArray.push("--no-build");
|
|
283
|
+
if (validOptions.noLogo === true) packCommandArray.push("--nologo");
|
|
284
|
+
if (validOptions.noRestore === true) packCommandArray.push("--no-restore");
|
|
285
|
+
if (validOptions.runtime !== void 0) packCommandArray.push("--runtime", validOptions.runtime);
|
|
286
|
+
if (validOptions.serviceable === true) packCommandArray.push("--serviceable");
|
|
287
|
+
if (validOptions.terminalLogger !== void 0) packCommandArray.push("--tl", validOptions.terminalLogger);
|
|
288
|
+
if (validOptions.useCurrentRuntime === true) packCommandArray.push("--use-current-runtime");
|
|
289
|
+
if (validOptions.verbosity !== void 0) packCommandArray.push("--verbosity", validOptions.verbosity);
|
|
290
|
+
if (validOptions.versionSuffix !== void 0) packCommandArray.push("--version-suffix", validOptions.versionSuffix);
|
|
291
291
|
/**
|
|
292
292
|
* Haphazard. I need to override the Version and I'm not considering side
|
|
293
293
|
* effects of arbitrary overrides.
|
|
294
294
|
*/
|
|
295
|
-
if (
|
|
295
|
+
if (validOptions.propertyOverrides) {
|
|
296
296
|
/** convert propertyOverrides record to "-p:n0=v0;n1=v1;n2=v2" et cetera */
|
|
297
|
-
const assignments = "-p:" + Object.entries(
|
|
298
|
-
|
|
297
|
+
const assignments = "-p:" + Object.entries(validOptions.propertyOverrides).map((v) => `${v[0]}=${v[1]}`).join(";");
|
|
298
|
+
packCommandArray.push(`"${assignments}"`);
|
|
299
299
|
}
|
|
300
|
-
if (
|
|
301
|
-
|
|
302
|
-
return
|
|
300
|
+
if (validOptions["-GetItem"] && validOptions["-GetItem"].length > 0) packCommandArray.push(`-GetItem:${validOptions["-GetItem"].join(",")}`);
|
|
301
|
+
packCommandArray.push("-o", `"${validOptions.output}"`);
|
|
302
|
+
return packCommandArray.join(" ");
|
|
303
303
|
}
|
|
304
304
|
/**
|
|
305
305
|
* !Not ready for use! Remove private modifier and commit as `feat(dotnet)` when ready for release!
|
|
@@ -311,29 +311,33 @@ but the environment variable is empty or undefined.`);
|
|
|
311
311
|
* NuGet packages should be created during the `prepare` step, but complex
|
|
312
312
|
* configuration of `dotnet pack` via command lines intended to be invoked by
|
|
313
313
|
* `@semantic-release/exec` is impractical.
|
|
314
|
-
* @param
|
|
314
|
+
* @param options `dotnet pack` options. See `dotnet pack -h`,
|
|
315
315
|
* https://learn.microsoft.com/en-us/dotnet/core/tools/dotnet-pack, and
|
|
316
316
|
* {@link PackPackagesOptionsType}.
|
|
317
|
-
* {@link
|
|
318
|
-
* @param [
|
|
317
|
+
* {@link options['-GetItem']} will _always_ have '_OutputPackItems'.
|
|
318
|
+
* @param [shouldUsePerSourceSubfolder] If `true`, modify the output path to
|
|
319
319
|
* include a subfolder bearing a path-safe encoding of the NuGet Source that
|
|
320
320
|
* will receive the nupkg.
|
|
321
|
-
* @param [
|
|
321
|
+
* @param [shouldUsePerPackageIdSubfolder] If `true`, modify the output path
|
|
322
322
|
* to include a subfolder named after the the PackageId.
|
|
323
323
|
* @returns a string[] containing the full file paths of all new packages i.e.
|
|
324
324
|
* .nupkg, .symbols.nupkg, .snupkg
|
|
325
325
|
*/
|
|
326
|
-
async _PackPackages(
|
|
327
|
-
|
|
328
|
-
const
|
|
329
|
-
let packOutput
|
|
330
|
-
while (packOutput === void 0)
|
|
326
|
+
async _PackPackages(options, shouldUsePerSourceSubfolder = false, shouldUsePerPackageIdSubfolder = false) {
|
|
327
|
+
options["-GetItem"] = [...options["-GetItem"] ?? [], key_OutputPackItems];
|
|
328
|
+
const packCommand = this.GetPackCommand(options, shouldUsePerSourceSubfolder, shouldUsePerPackageIdSubfolder);
|
|
329
|
+
let packOutput;
|
|
330
|
+
while (packOutput === void 0) try {
|
|
331
|
+
packOutput = await setTimeout(1e3, execAsync(packCommand, true));
|
|
332
|
+
} catch (error) {
|
|
333
|
+
catchEBUSY(error);
|
|
334
|
+
}
|
|
331
335
|
return new MSBuildEvaluationOutput(packOutput.stdout).Items?.[key_OutputPackItems]?.filter((item) => item.Extension !== ".nuspec").map((item) => item.FullPath) ?? [];
|
|
332
336
|
}
|
|
333
337
|
/**
|
|
334
338
|
* Create a dummy package for the current {@link project} by executing a
|
|
335
339
|
* command line like \``dotnet pack ${this.project.Properties.MSBuildProjectFullPath} -p:Version=0.0.1-DUMMY -output ${getDummiesDir(this._project)}/${GetNameForURL(this.source)}`\`
|
|
336
|
-
* @param
|
|
340
|
+
* @param options Options passed to
|
|
337
341
|
* `dotnet pack`, excluding the required `<PROJECT | SOLUTION>` argument.
|
|
338
342
|
* - The `output` field is ignored and overwritten. It is replaced with
|
|
339
343
|
* ${{@link getDummiesDir}({@link project})}/${{@link GetDirNameForSource}({@link source})}
|
|
@@ -344,19 +348,28 @@ but the environment variable is empty or undefined.`);
|
|
|
344
348
|
* created by the Pack target, as extracted from the dotnet process's STDOUT.
|
|
345
349
|
* If mixed with other nupkgs, filter for the {@link NugetProjectProperties#PackageId}
|
|
346
350
|
*/
|
|
347
|
-
async PackDummyPackage(
|
|
348
|
-
const
|
|
349
|
-
...
|
|
350
|
-
output:
|
|
351
|
+
async PackDummyPackage(options) {
|
|
352
|
+
const packCommand = this.GetPackCommand({
|
|
353
|
+
...options,
|
|
354
|
+
output: getDummiesDirectory(this._project),
|
|
351
355
|
propertyOverrides: {
|
|
352
|
-
...
|
|
356
|
+
...options.propertyOverrides,
|
|
353
357
|
Version: "0.0.1-DUMMY",
|
|
354
358
|
UpdateVersionProperties: "false"
|
|
355
359
|
},
|
|
356
|
-
"-GetItem": [...
|
|
360
|
+
"-GetItem": [...options["-GetItem"] ?? [], key_OutputPackItems]
|
|
357
361
|
}, true);
|
|
358
|
-
let packOutput
|
|
359
|
-
|
|
362
|
+
let packOutput;
|
|
363
|
+
let delay = 0;
|
|
364
|
+
while (packOutput === void 0) {
|
|
365
|
+
try {
|
|
366
|
+
packOutput = await setTimeout(delay, execAsync(packCommand, true));
|
|
367
|
+
} catch (error) {
|
|
368
|
+
if (delay <= 1e4) catchEBUSY(error);
|
|
369
|
+
else throw new Error("Unable to pack dummy package; (10/10) Maximum retries reached.", { cause: error });
|
|
370
|
+
}
|
|
371
|
+
delay += 1e3;
|
|
372
|
+
}
|
|
360
373
|
return new MSBuildEvaluationOutput(packOutput.stdout).Items?.[key_OutputPackItems]?.filter((item) => item.Extension !== ".nuspec").map((item) => item.FullPath) ?? [];
|
|
361
374
|
}
|
|
362
375
|
/**
|
|
@@ -408,70 +421,73 @@ but the environment variable is empty or undefined.`);
|
|
|
408
421
|
/**
|
|
409
422
|
* Create a `dotnet nuget push` command line from the given options and
|
|
410
423
|
* optional boolean parameters.
|
|
411
|
-
* @param
|
|
412
|
-
* @param
|
|
424
|
+
* @param options See {@link PushPackagesOptionsType}
|
|
425
|
+
* @param shouldUsePerSourceSubfolder If `true`, the NuGet Source name or URL is formatted
|
|
413
426
|
* to a folder name and appended to the ROOT as a subfolder. Do not use
|
|
414
427
|
* wildcards in ROOT with this set to `true`!
|
|
415
|
-
* @param
|
|
428
|
+
* @param shouldUsePerPackageIdSubfolder If `true`, the
|
|
416
429
|
* {@link project}'s {@link NugetProjectProperties#PackageId}
|
|
417
430
|
* is appended to the ROOT as a subfolder. Do not use wildcards in
|
|
418
431
|
* ROOT with this set to `true`!
|
|
419
432
|
* @returns A `dotnet nuget push` command line formatted with the
|
|
420
433
|
* appropriate arguments.
|
|
421
434
|
*/
|
|
422
|
-
GetPushCommand(
|
|
423
|
-
const
|
|
424
|
-
type.boolean.assert(
|
|
425
|
-
type.boolean.assert(
|
|
426
|
-
|
|
427
|
-
if (
|
|
428
|
-
if (
|
|
429
|
-
const
|
|
435
|
+
GetPushCommand(options, shouldUsePerSourceSubfolder = false, shouldUsePerPackageIdSubfolder = false) {
|
|
436
|
+
const validOptions = NRI.PushPackagesOptionsType.from(options);
|
|
437
|
+
type.boolean.assert(shouldUsePerSourceSubfolder);
|
|
438
|
+
type.boolean.assert(shouldUsePerPackageIdSubfolder);
|
|
439
|
+
validOptions.root = validOptions.root === "" ? `${cwd()}/publish` : validOptions.root;
|
|
440
|
+
if (shouldUsePerSourceSubfolder) validOptions.root = node_path.join(validOptions.root, NugetRegistryInfo.GetDirNameForSource(this.source), node_path.sep);
|
|
441
|
+
if (shouldUsePerPackageIdSubfolder) validOptions.root = node_path.join(validOptions.root, this._project.Properties.PackageId, node_path.sep);
|
|
442
|
+
const packCommandArray = [
|
|
430
443
|
"dotnet",
|
|
431
444
|
"nuget",
|
|
432
445
|
"push",
|
|
433
|
-
`"${node_path.join(
|
|
446
|
+
`"${node_path.join(validOptions.root, "*.nupkg")}"`
|
|
434
447
|
];
|
|
435
|
-
if (this.resolvedEnvVariable)
|
|
448
|
+
if (this.resolvedEnvVariable) validOptions.apiKey ??= NRI._GetTokenValue(this.resolvedEnvVariable);
|
|
436
449
|
/**
|
|
437
450
|
* If apiKey is an empty string, defer to the dotnet CLI's NuGet client
|
|
438
451
|
* ability to lookup API keys saved via `dotnet nuget add source` or NuGet config
|
|
439
452
|
* files.
|
|
440
453
|
*/
|
|
441
|
-
if (
|
|
442
|
-
if (
|
|
443
|
-
if (
|
|
444
|
-
if (
|
|
445
|
-
if (
|
|
446
|
-
if (
|
|
447
|
-
if (
|
|
448
|
-
if (
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
if (
|
|
452
|
-
if (
|
|
453
|
-
if (
|
|
454
|
-
return
|
|
454
|
+
if (validOptions.apiKey && validOptions.apiKey !== "") packCommandArray.push("--api-key", validOptions.apiKey);
|
|
455
|
+
if (validOptions.configFile) packCommandArray.push("--configfile", validOptions.configFile);
|
|
456
|
+
if (validOptions.disableBuffering === true) packCommandArray.push("--disable-buffering");
|
|
457
|
+
if (validOptions.forceEnglishOutput === true) packCommandArray.push("--force-english-output");
|
|
458
|
+
if (validOptions.interactive === true) packCommandArray.push("--interactive");
|
|
459
|
+
if (validOptions.noServiceEndpoint === true) packCommandArray.push("--no-service-endpoint");
|
|
460
|
+
if (validOptions.noSymbols === true) packCommandArray.push("--no-symbols");
|
|
461
|
+
if (validOptions.skipDuplicate === true) packCommandArray.push("--skip-duplicate");
|
|
462
|
+
validOptions.source ??= this.source;
|
|
463
|
+
packCommandArray.push("--source", validOptions.source);
|
|
464
|
+
if (validOptions.symbolApiKey !== void 0) packCommandArray.push("--symbol-api-key", validOptions.symbolApiKey);
|
|
465
|
+
if (validOptions.symbolSource !== void 0) packCommandArray.push("--symbol-source", validOptions.symbolSource);
|
|
466
|
+
if (validOptions.timeout !== void 0) packCommandArray.push("--timeout", validOptions.timeout.toString());
|
|
467
|
+
return packCommandArray.join(" ");
|
|
455
468
|
}
|
|
456
469
|
/**
|
|
457
470
|
* Immediately push packages. The input path may be modified according to the
|
|
458
|
-
* {@link
|
|
471
|
+
* {@link shouldUsePerSourceSubfolder} and {@link shouldUsePerPackageIdSubfolder}
|
|
459
472
|
* arguments.
|
|
460
|
-
* @param
|
|
473
|
+
* @param options The `dotnet nuget push` command line options, including the
|
|
461
474
|
* ROOT argument, the directory containing local nuget packages ready to be
|
|
462
475
|
* pushed.
|
|
463
|
-
* @param
|
|
476
|
+
* @param shouldUsePerSourceSubfolder If `true`, the NuGet Source name or URL is formatted
|
|
464
477
|
* to a folder name and appended to the ROOT as a subfolder. Do not use
|
|
465
478
|
* wildcards in ROOT with this set to `true`!
|
|
466
|
-
* @param
|
|
479
|
+
* @param shouldUsePerPackageIdSubfolder If `true`, the current {@link project}'s
|
|
467
480
|
* PackageId is appended to the ROOT as a subfolder. Do not use wildcards in
|
|
468
481
|
* ROOT with this set to `true`!
|
|
469
482
|
*/
|
|
470
|
-
async _PushPackages(
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
})
|
|
483
|
+
async _PushPackages(options, shouldUsePerSourceSubfolder = false, shouldUsePerPackageIdSubfolder = false) {
|
|
484
|
+
let command = "";
|
|
485
|
+
try {
|
|
486
|
+
await execAsync(command = this.GetPushCommand(options, shouldUsePerSourceSubfolder, shouldUsePerPackageIdSubfolder), true);
|
|
487
|
+
} catch (error) {
|
|
488
|
+
const _error = Object.assign(isError(error) ? error : new Error(JSON.stringify(error)), { cmd: command });
|
|
489
|
+
throw options.apiKey ? _censorTokenInError(_error, options.apiKey) : _error;
|
|
490
|
+
}
|
|
475
491
|
}
|
|
476
492
|
/**
|
|
477
493
|
*
|
|
@@ -492,17 +508,17 @@ but the environment variable is empty or undefined.`);
|
|
|
492
508
|
* nri.GetPushDummyPackageCommand(pushOpts, false, false),
|
|
493
509
|
* ].join(' && ')
|
|
494
510
|
* ```
|
|
495
|
-
* @param
|
|
511
|
+
* @param options options for `dotnet nuget push`. The following
|
|
496
512
|
* fields are overwritten:
|
|
497
513
|
* - root: getDummiesDir(this.project)
|
|
498
514
|
* - skipDuplicates: true
|
|
499
515
|
* @returns a `dotnet nuget push` command to push a dummy package
|
|
500
516
|
* (created by executing {@link PackDummyPackage}) to {@link source}
|
|
501
517
|
*/
|
|
502
|
-
GetPushDummyCommand(
|
|
518
|
+
GetPushDummyCommand(options) {
|
|
503
519
|
return this.GetPushCommand({
|
|
504
|
-
...NRI.PushDummyPackagesOptionsType.from(
|
|
505
|
-
root:
|
|
520
|
+
...NRI.PushDummyPackagesOptionsType.from(options),
|
|
521
|
+
root: getDummiesDirectory(this._project)
|
|
506
522
|
}, true);
|
|
507
523
|
}
|
|
508
524
|
/**
|
|
@@ -510,17 +526,20 @@ but the environment variable is empty or undefined.`);
|
|
|
510
526
|
* @throws {Error} when the process exits with an error code indicating
|
|
511
527
|
* failure i.e. the command line is invalid, the process fails to start,
|
|
512
528
|
* the push fails, et cetera.
|
|
513
|
-
* @param
|
|
529
|
+
* @param options the ROOT arg and options for `dotnet nuget push`. The following
|
|
514
530
|
* fields are overwritten:
|
|
515
531
|
* - root: getDummiesDir(this.project)
|
|
516
532
|
* - skipDuplicates: true
|
|
517
533
|
* @returns The return type of {@link execAsync} i.e. a {@link Promise} resolving to `{ stdout: string; stderr: string }`.
|
|
518
534
|
*/
|
|
519
|
-
async _PushDummyPackages(
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
})
|
|
535
|
+
async _PushDummyPackages(options) {
|
|
536
|
+
const pushCommand = this.GetPushDummyCommand(options);
|
|
537
|
+
try {
|
|
538
|
+
return await execAsync(pushCommand, true);
|
|
539
|
+
} catch (error) {
|
|
540
|
+
const _error = Object.assign(isError(error) ? error : new Error(JSON.stringify(error)), { cmd: pushCommand });
|
|
541
|
+
throw options.apiKey ? _censorTokenInError(_error, options.apiKey) : _error;
|
|
542
|
+
}
|
|
524
543
|
}
|
|
525
544
|
static _NugetSearchReturnTypes = { ExactMatch: { v2: type({
|
|
526
545
|
version: "2",
|
|
@@ -554,7 +573,9 @@ but the environment variable is empty or undefined.`);
|
|
|
554
573
|
*/
|
|
555
574
|
static async IsNextVersionAlreadyPublished(source, packageId, nextVersion) {
|
|
556
575
|
if (nextVersion === "") throw new Error("The value of nextVersion is empty");
|
|
557
|
-
|
|
576
|
+
const json = (await execAsync(`dotnet package search --format JSON --exact-match --source ${source} --prerelease ${packageId}`, true)).stdout;
|
|
577
|
+
const errsOrObject = this._ParseNugetSearchReturn(json);
|
|
578
|
+
return (errsOrObject instanceof type.errors ? errsOrObject.throw() : errsOrObject).searchResult[0].packages.find((p) => p.version === type("string.semver").from(nextVersion)) !== void 0;
|
|
558
579
|
}
|
|
559
580
|
/**
|
|
560
581
|
* !WARNING: GITHUB_OUTPUT must be the full path to an environment file.
|
|
@@ -657,11 +678,12 @@ function _censorToken(string, token) {
|
|
|
657
678
|
* NuGet API token.
|
|
658
679
|
*/
|
|
659
680
|
function _censorTokenInError(error, token) {
|
|
660
|
-
|
|
681
|
+
const text = JSON.stringify({
|
|
661
682
|
...error,
|
|
662
683
|
message: error.message,
|
|
663
684
|
stack: error.stack
|
|
664
|
-
})
|
|
685
|
+
});
|
|
686
|
+
return Object.assign(error, JSON.parse(_censorToken(text, token)));
|
|
665
687
|
}
|
|
666
688
|
//#endregion
|
|
667
689
|
export { NRIOpts, NRIOptsBase, NugetRegistryInfo, getGithubOutput, getGithubOutputSync };
|