@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.
Files changed (136) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/README.md +33 -10
  3. package/dotnet/.github/workflows/_unit_test.yml +2 -2
  4. package/dotnet/.github/workflows/dotnet-release.yml +1 -1
  5. package/dotnet/.github/workflows/sample-dotnet-build.yml +1 -1
  6. package/dotnet/CleanupWpfTmp.targets +15 -0
  7. package/dotnet/HCE.Shared.targets +3 -0
  8. package/mjs/CaseInsensitiveMap.mjs.map +1 -1
  9. package/mjs/commitlintConfig.mjs.map +1 -1
  10. package/mjs/debug.mjs.map +1 -1
  11. package/mjs/dotnet/GithubNugetRegistryInfo.d.mts +5 -5
  12. package/mjs/dotnet/GithubNugetRegistryInfo.d.mts.map +1 -1
  13. package/mjs/dotnet/GithubNugetRegistryInfo.mjs +7 -7
  14. package/mjs/dotnet/GithubNugetRegistryInfo.mjs.map +1 -1
  15. package/mjs/dotnet/GitlabNugetRegistryInfo.d.mts +6 -6
  16. package/mjs/dotnet/GitlabNugetRegistryInfo.d.mts.map +1 -1
  17. package/mjs/dotnet/GitlabNugetRegistryInfo.mjs +14 -14
  18. package/mjs/dotnet/GitlabNugetRegistryInfo.mjs.map +1 -1
  19. package/mjs/dotnet/IsNextVersionAlreadyPublished.cli.mjs +5 -5
  20. package/mjs/dotnet/IsNextVersionAlreadyPublished.cli.mjs.map +1 -1
  21. package/mjs/dotnet/MSBuildProject.d.mts +28 -28
  22. package/mjs/dotnet/MSBuildProject.d.mts.map +1 -1
  23. package/mjs/dotnet/MSBuildProject.mjs +88 -66
  24. package/mjs/dotnet/MSBuildProject.mjs.map +1 -1
  25. package/mjs/dotnet/MSBuildProjectProperties.d.mts.map +1 -1
  26. package/mjs/dotnet/MSBuildProjectProperties.mjs +1 -1
  27. package/mjs/dotnet/MSBuildProjectProperties.mjs.map +1 -1
  28. package/mjs/dotnet/NugetProjectProperties.d.mts +3 -3
  29. package/mjs/dotnet/NugetProjectProperties.d.mts.map +1 -1
  30. package/mjs/dotnet/NugetProjectProperties.mjs +7 -9
  31. package/mjs/dotnet/NugetProjectProperties.mjs.map +1 -1
  32. package/mjs/dotnet/NugetRegistryInfo.d.mts +40 -40
  33. package/mjs/dotnet/NugetRegistryInfo.d.mts.map +1 -1
  34. package/mjs/dotnet/NugetRegistryInfo.mjs +170 -148
  35. package/mjs/dotnet/NugetRegistryInfo.mjs.map +1 -1
  36. package/mjs/dotnet/helpers.d.mts.map +1 -1
  37. package/mjs/dotnet/helpers.mjs +33 -34
  38. package/mjs/dotnet/helpers.mjs.map +1 -1
  39. package/mjs/eslintConfig.mjs.map +1 -1
  40. package/mjs/insertPlugins.mjs +2 -2
  41. package/mjs/insertPlugins.mjs.map +1 -1
  42. package/mjs/semantic-release__commit-analyzer.d.mts.map +1 -1
  43. package/mjs/semantic-release__exec.d.mts.map +1 -1
  44. package/mjs/semantic-release__git.d.mts.map +1 -1
  45. package/mjs/semantic-release__github.d.mts +1 -0
  46. package/mjs/semantic-release__github.d.mts.map +1 -1
  47. package/mjs/semanticReleaseConfig.d.mts.map +1 -1
  48. package/mjs/semanticReleaseConfig.mjs.map +1 -1
  49. package/mjs/semanticReleaseConfigDotnet.d.mts.map +1 -1
  50. package/mjs/semanticReleaseConfigDotnet.mjs +23 -16
  51. package/mjs/semanticReleaseConfigDotnet.mjs.map +1 -1
  52. package/mjs/setupGitPluginSpec.d.mts.map +1 -1
  53. package/mjs/setupGitPluginSpec.default.mjs.map +1 -1
  54. package/mjs/setupGitPluginSpec.mjs +19 -19
  55. package/mjs/setupGitPluginSpec.mjs.map +1 -1
  56. package/mjs/utils/Exact.d.mts.map +1 -1
  57. package/mjs/utils/GracefulRecursion.d.mts.map +1 -1
  58. package/mjs/utils/env.d.mts.map +1 -1
  59. package/mjs/utils/env.mjs.map +1 -1
  60. package/mjs/utils/execAsync.d.mts +3 -3
  61. package/mjs/utils/execAsync.d.mts.map +1 -1
  62. package/mjs/utils/execAsync.mjs +14 -12
  63. package/mjs/utils/execAsync.mjs.map +1 -1
  64. package/mjs/utils/isError.mjs.map +1 -1
  65. package/mjs/utils/miscTypes.d.mts.map +1 -1
  66. package/mjs/utils/miscTypes.mjs.map +1 -1
  67. package/mjs/utils/reflection/FunctionLike.d.mts +1 -0
  68. package/mjs/utils/reflection/FunctionLike.d.mts.map +1 -1
  69. package/mjs/utils/reflection/GetterDescriptor.d.mts.map +1 -1
  70. package/mjs/utils/reflection/InstancePropertyDescriptorMap.d.mts.map +1 -1
  71. package/mjs/utils/reflection/InstanceTypeOrSelfPropertyDescriptorMap.d.mts +1 -1
  72. package/mjs/utils/reflection/InstanceTypeOrSelfPropertyDescriptorMap.d.mts.map +1 -1
  73. package/mjs/utils/reflection/OwnGetterDescriptorMap.d.mts +1 -1
  74. package/mjs/utils/reflection/OwnGetterDescriptorMap.d.mts.map +1 -1
  75. package/mjs/utils/reflection/OwnKeyOf.d.mts +1 -1
  76. package/mjs/utils/reflection/OwnKeyOf.d.mts.map +1 -1
  77. package/mjs/utils/reflection/OwnPropertyDescriptorMap.d.mts.map +1 -1
  78. package/mjs/utils/reflection/PropertyDescriptorMap.d.mts +1 -1
  79. package/mjs/utils/reflection/PropertyDescriptorMap.d.mts.map +1 -1
  80. package/mjs/utils/reflection/filterForGetters.d.mts.map +1 -1
  81. package/mjs/utils/reflection/filterForGetters.mjs.map +1 -1
  82. package/mjs/utils/reflection/getOwnPropertyDescriptors.d.mts.map +1 -1
  83. package/mjs/utils/reflection/getOwnPropertyDescriptors.mjs.map +1 -1
  84. package/mjs/utils/reflection/getOwnPropertyDescriptorsRecursively.d.mts.map +1 -1
  85. package/mjs/utils/reflection/getOwnPropertyDescriptorsRecursively.mjs +3 -3
  86. package/mjs/utils/reflection/getOwnPropertyDescriptorsRecursively.mjs.map +1 -1
  87. package/mjs/utils/reflection/getPrototypeChainOf.d.mts +2 -2
  88. package/mjs/utils/reflection/getPrototypeChainOf.d.mts.map +1 -1
  89. package/mjs/utils/reflection/getPrototypeChainOf.mjs +1 -2
  90. package/mjs/utils/reflection/getPrototypeChainOf.mjs.map +1 -1
  91. package/mjs/utils/reflection/getPrototypeOf.d.mts.map +1 -1
  92. package/mjs/utils/reflection/getPrototypeOf.mjs.map +1 -1
  93. package/mjs/utils/reflection/inheritance.d.mts +4 -4
  94. package/mjs/utils/reflection/inheritance.d.mts.map +1 -1
  95. package/mjs/utils/reflection/inheritance.mjs.map +1 -1
  96. package/mjs/utils/reflection/isConstructor.d.mts +3 -3
  97. package/mjs/utils/reflection/isConstructor.d.mts.map +1 -1
  98. package/mjs/utils/reflection/isConstructor.mjs +7 -7
  99. package/mjs/utils/reflection/isConstructor.mjs.map +1 -1
  100. package/mjs/utils/reflection/isGetterDescriptor.d.mts.map +1 -1
  101. package/mjs/utils/reflection/isGetterDescriptor.mjs.map +1 -1
  102. package/mjs/utils/reflection/listOwnGetters.d.mts.map +1 -1
  103. package/mjs/utils/reflection/listOwnGetters.mjs +4 -2
  104. package/mjs/utils/reflection/listOwnGetters.mjs.map +1 -1
  105. package/mjs/utils/reflection.d.mts +1 -1
  106. package/package.json +26 -25
  107. package/src/dotnet/GithubNugetRegistryInfo.ts +18 -15
  108. package/src/dotnet/GitlabNugetRegistryInfo.ts +28 -26
  109. package/src/dotnet/IsNextVersionAlreadyPublished.cli.ts +6 -6
  110. package/src/dotnet/MSBuildProject.ts +103 -106
  111. package/src/dotnet/MSBuildProjectProperties.ts +1 -1
  112. package/src/dotnet/NugetProjectProperties.ts +13 -18
  113. package/src/dotnet/NugetRegistryInfo.ts +287 -243
  114. package/src/dotnet/helpers.ts +58 -58
  115. package/src/insertPlugins.ts +3 -3
  116. package/src/semantic-release__github.d.ts +1 -0
  117. package/src/semanticReleaseConfigDotnet.ts +52 -54
  118. package/src/setupGitPluginSpec.ts +25 -26
  119. package/src/utils/env.ts +1 -0
  120. package/src/utils/execAsync.ts +16 -13
  121. package/src/utils/reflection/FunctionLike.d.ts +1 -0
  122. package/src/utils/reflection/InstancePropertyDescriptorMap.d.ts +4 -4
  123. package/src/utils/reflection/InstanceTypeOrSelfPropertyDescriptorMap.d.ts +6 -6
  124. package/src/utils/reflection/OwnGetterDescriptorMap.d.ts +2 -2
  125. package/src/utils/reflection/OwnKeyOf.d.ts +3 -3
  126. package/src/utils/reflection/OwnPropertyDescriptorMap.d.ts +3 -3
  127. package/src/utils/reflection/PropertyDescriptorMap.d.ts +3 -3
  128. package/src/utils/reflection/filterForGetters.ts +10 -10
  129. package/src/utils/reflection/getOwnPropertyDescriptors.ts +2 -2
  130. package/src/utils/reflection/getOwnPropertyDescriptorsRecursively.ts +13 -13
  131. package/src/utils/reflection/getPrototypeChainOf.ts +17 -17
  132. package/src/utils/reflection/getPrototypeOf.ts +2 -2
  133. package/src/utils/reflection/inheritance.ts +5 -4
  134. package/src/utils/reflection/isConstructor.ts +7 -7
  135. package/src/utils/reflection/listOwnGetters.ts +8 -8
  136. 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 tmpDirNamespace = node_path.join(tmpdir(), "HCE.Shared", ".NET", "Dummies");
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 envOutput = config({
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(envOutput.error)) throw envOutput.error;
39
- return envOutput.parsed;
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 envOutput = config({
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 envOutput) throw envOutput.error;
60
- return envOutput.parsed;
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 getDummiesDir(project) {
70
+ function getDummiesDirectory(project) {
71
71
  switch (true) {
72
- case project === void 0: return node_path.join(tmpDirNamespace, node_path.sep);
73
- case project instanceof MSBuildProject: return node_path.join(tmpDirNamespace, project.Properties.PackageId, node_path.sep);
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 tokenEnvVars The name of the environment variables whose values are
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 _GetTokenEnvVariables(tokenEnvVars) {
86
- const definedTokens = Object.freeze(tokenEnvVars.map((key) => [key, getEnvVarValue(key)]).filter((envVarTuple) => envVarTuple[1] !== void 0));
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 opts The input type of {@link NRIOpts.from}
129
- * @param opts.project The project whose package(s) will be
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 [opts.tokenEnvVars] The environment variables
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 [opts.source] A NuGet package registry's API endpoint URL or name. Default: 'https://api.nuget.org/v3/index.json'
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(opts) {
142
- const validOpts = NRIOpts.from(opts);
143
- this._project = validOpts.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 tokenVars = _GetTokenEnvVariables(validOpts.tokenEnvVars);
149
- if (tokenVars) this._resolvedEnvVariable = tokenVars[0][0];
150
- this._source = validOpts.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 errMsg = `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.`;
174
- const err = new Error(errMsg);
175
- return this._canPushPackagesToSource = Promise.reject(err);
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 opts Options passed to
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 usePerSourceSubfolder} and {@link usePerPackageIdSubfolder}
254
+ * {@link shouldUsePerSourceSubfolder} and {@link shouldUsePerPackageIdSubfolder}
255
255
  * arguments.
256
- * @param usePerSourceSubfolder If true, the path of the package output will
256
+ * @param shouldUsePerSourceSubfolder If true, the path of the package output will
257
257
  * include a subfolder named after the NuGet Source.
258
- * @param usePerPackageIdSubfolder If true, the path of the package output
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(opts, usePerSourceSubfolder = false, usePerPackageIdSubfolder = false) {
264
- const validOpts = NRI.PackPackagesOptionsType.from(opts);
265
- type.boolean.assert(usePerSourceSubfolder);
266
- type.boolean.assert(usePerPackageIdSubfolder);
267
- validOpts.output ??= node_path.join(cwd(), "publish");
268
- if (usePerSourceSubfolder) validOpts.output = node_path.join(validOpts.output, NugetRegistryInfo.GetDirNameForSource(this.source), node_path.sep);
269
- if (usePerPackageIdSubfolder) validOpts.output = node_path.join(validOpts.output, this._project.Properties.PackageId, node_path.sep);
270
- const packCmdArr = [
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 (validOpts.artifactsPath !== void 0) packCmdArr.push("--artifactsPath", `"${validOpts.artifactsPath}"`);
276
- if (validOpts.configuration !== void 0) packCmdArr.push("--configuration", validOpts.configuration);
277
- if (validOpts.disableBuildServers === true) packCmdArr.push("--disable-build-servers");
278
- if (validOpts.force === true) packCmdArr.push("--force");
279
- if (validOpts.includeSource === true) packCmdArr.push("--include-source");
280
- if (validOpts.includeSymbols === true) packCmdArr.push("--include-symbols");
281
- if (validOpts.interactive === true) packCmdArr.push("--interactive");
282
- if (validOpts.noBuild === true) packCmdArr.push("--no-build");
283
- if (validOpts.noLogo === true) packCmdArr.push("--nologo");
284
- if (validOpts.noRestore === true) packCmdArr.push("--no-restore");
285
- if (validOpts.runtime !== void 0) packCmdArr.push("--runtime", validOpts.runtime);
286
- if (validOpts.serviceable === true) packCmdArr.push("--serviceable");
287
- if (validOpts.terminalLogger !== void 0) packCmdArr.push("--tl", validOpts.terminalLogger);
288
- if (validOpts.useCurrentRuntime === true) packCmdArr.push("--use-current-runtime");
289
- if (validOpts.verbosity !== void 0) packCmdArr.push("--verbosity", validOpts.verbosity);
290
- if (validOpts.versionSuffix !== void 0) packCmdArr.push("--version-suffix", validOpts.versionSuffix);
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 (validOpts.propertyOverrides) {
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(validOpts.propertyOverrides).map((v) => `${v[0]}=${v[1]}`).join(";");
298
- packCmdArr.push(`"${assignments}"`);
297
+ const assignments = "-p:" + Object.entries(validOptions.propertyOverrides).map((v) => `${v[0]}=${v[1]}`).join(";");
298
+ packCommandArray.push(`"${assignments}"`);
299
299
  }
300
- if (validOpts["-GetItem"] && validOpts["-GetItem"].length > 0) packCmdArr.push(`-GetItem:${validOpts["-GetItem"].join(",")}`);
301
- packCmdArr.push("-o", `"${validOpts.output}"`);
302
- return packCmdArr.join(" ");
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 opts `dotnet pack` options. See `dotnet pack -h`,
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 opts['-GetItem']} will _always_ have '_OutputPackItems'.
318
- * @param [usePerSourceSubfolder] If `true`, modify the output path to
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 [usePerPackageIdSubfolder] If `true`, modify the output path
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(opts, usePerSourceSubfolder = false, usePerPackageIdSubfolder = false) {
327
- opts["-GetItem"] = [...opts["-GetItem"] ?? [], key_OutputPackItems];
328
- const packCmd = this.GetPackCommand(opts, usePerSourceSubfolder, usePerPackageIdSubfolder);
329
- let packOutput = void 0;
330
- while (packOutput === void 0) packOutput = await setTimeout(1e3, execAsync(packCmd, true)).then(async (p) => await p).catch(catchEBUSY);
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 opts Options passed to
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(opts) {
348
- const packCmd = this.GetPackCommand({
349
- ...opts,
350
- output: getDummiesDir(this._project),
351
+ async PackDummyPackage(options) {
352
+ const packCommand = this.GetPackCommand({
353
+ ...options,
354
+ output: getDummiesDirectory(this._project),
351
355
  propertyOverrides: {
352
- ...opts.propertyOverrides,
356
+ ...options.propertyOverrides,
353
357
  Version: "0.0.1-DUMMY",
354
358
  UpdateVersionProperties: "false"
355
359
  },
356
- "-GetItem": [...opts["-GetItem"] ?? [], key_OutputPackItems]
360
+ "-GetItem": [...options["-GetItem"] ?? [], key_OutputPackItems]
357
361
  }, true);
358
- let packOutput = void 0;
359
- while (packOutput === void 0) packOutput = await setTimeout(1e3, execAsync(packCmd, true)).then(async (p) => await p).catch(catchEBUSY);
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 opts See {@link PushPackagesOptionsType}
412
- * @param usePerSourceSubfolder If `true`, the NuGet Source name or URL is formatted
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 usePerPackageIdSubfolder If `true`, the
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(opts, usePerSourceSubfolder = false, usePerPackageIdSubfolder = false) {
423
- const validOpts = NRI.PushPackagesOptionsType.from(opts);
424
- type.boolean.assert(usePerSourceSubfolder);
425
- type.boolean.assert(usePerPackageIdSubfolder);
426
- validOpts.root = validOpts.root === "" ? `${cwd()}/publish` : validOpts.root;
427
- if (usePerSourceSubfolder) validOpts.root = node_path.join(validOpts.root, NugetRegistryInfo.GetDirNameForSource(this.source), node_path.sep);
428
- if (usePerPackageIdSubfolder) validOpts.root = node_path.join(validOpts.root, this._project.Properties.PackageId, node_path.sep);
429
- const packCmdArr = [
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(validOpts.root, "*.nupkg")}"`
446
+ `"${node_path.join(validOptions.root, "*.nupkg")}"`
434
447
  ];
435
- if (this.resolvedEnvVariable) validOpts.apiKey ??= NRI._GetTokenValue(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 (validOpts.apiKey && validOpts.apiKey !== "") packCmdArr.push("--api-key", validOpts.apiKey);
442
- if (validOpts.configFile) packCmdArr.push("--configfile", validOpts.configFile);
443
- if (validOpts.disableBuffering === true) packCmdArr.push("--disable-buffering");
444
- if (validOpts.forceEnglishOutput === true) packCmdArr.push("--force-english-output");
445
- if (validOpts.interactive === true) packCmdArr.push("--interactive");
446
- if (validOpts.noServiceEndpoint === true) packCmdArr.push("--no-service-endpoint");
447
- if (validOpts.noSymbols === true) packCmdArr.push("--no-symbols");
448
- if (validOpts.skipDuplicate === true) packCmdArr.push("--skip-duplicate");
449
- validOpts.source ??= this.source;
450
- packCmdArr.push("--source", validOpts.source);
451
- if (validOpts.symbolApiKey !== void 0) packCmdArr.push("--symbol-api-key", validOpts.symbolApiKey);
452
- if (validOpts.symbolSource !== void 0) packCmdArr.push("--symbol-source", validOpts.symbolSource);
453
- if (validOpts.timeout !== void 0) packCmdArr.push("--timeout", validOpts.timeout.toString());
454
- return packCmdArr.join(" ");
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 usePerSourceSubfolder} and {@link usePerPackageIdSubfolder}
471
+ * {@link shouldUsePerSourceSubfolder} and {@link shouldUsePerPackageIdSubfolder}
459
472
  * arguments.
460
- * @param opts The `dotnet nuget push` command line options, including the
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 usePerSourceSubfolder If `true`, the NuGet Source name or URL is formatted
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 usePerPackageIdSubfolder If `true`, the current {@link project}'s
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(opts, usePerSourceSubfolder = false, usePerPackageIdSubfolder = false) {
471
- await execAsync(this.GetPushCommand(opts, usePerSourceSubfolder, usePerPackageIdSubfolder), true).catch((error) => {
472
- const _error = isError(error) ? error : new Error(JSON.stringify(error));
473
- throw opts.apiKey ? _censorTokenInError(_error, opts.apiKey) : _error;
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 opts options for `dotnet nuget push`. The following
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(opts) {
518
+ GetPushDummyCommand(options) {
503
519
  return this.GetPushCommand({
504
- ...NRI.PushDummyPackagesOptionsType.from(opts),
505
- root: getDummiesDir(this._project)
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 opts the ROOT arg and options for `dotnet nuget push`. The following
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(opts) {
520
- return await execAsync(this.GetPushDummyCommand(opts), true).catch((error) => {
521
- const _error = isError(error) ? error : new Error(String(error));
522
- throw opts.apiKey ? _censorTokenInError(_error, opts.apiKey) : _error;
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
- return await execAsync(`dotnet package search --format JSON --exact-match --source ${source} --prerelease ${packageId}`, true).then((stdPair) => stdPair.stdout).then((json) => this._ParseNugetSearchReturn(json)).then((errsOrObj) => errsOrObj instanceof type.errors ? errsOrObj.throw() : errsOrObj).then((obj) => obj.searchResult).then((results) => results[0].packages).then((pkgs) => pkgs.find((p) => p.version === type("string.semver").from(nextVersion))).then((pkg) => pkg !== void 0);
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
- return Object.assign(error, JSON.parse(_censorToken(JSON.stringify({
681
+ const text = JSON.stringify({
661
682
  ...error,
662
683
  message: error.message,
663
684
  stack: error.stack
664
- }), token)));
685
+ });
686
+ return Object.assign(error, JSON.parse(_censorToken(text, token)));
665
687
  }
666
688
  //#endregion
667
689
  export { NRIOpts, NRIOptsBase, NugetRegistryInfo, getGithubOutput, getGithubOutputSync };