@halospv3/hce.shared-config 3.5.3-develop.2 → 3.6.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.
Files changed (136) hide show
  1. package/CHANGELOG.md +29 -0
  2. package/README.md +33 -10
  3. package/dotnet/.github/workflows/_unit_test.yml +1 -1
  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 +25 -24
  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
@@ -7,7 +7,7 @@ import { MSBuildProjectProperties as MSBPP } from './MSBuildProjectProperties.ts
7
7
  import { NugetRegistryInfo } from './NugetRegistryInfo.ts';
8
8
  import type { Default } from 'arktype/internal/attributes.ts';
9
9
 
10
- const ourDefaultPubDir = path.join('.', 'publish') as `.${'/' | '\\'}publish`;
10
+ const ourDefaultPubDirectory = path.join('.', 'publish') as `.${'/' | '\\'}publish`;
11
11
 
12
12
  /**
13
13
  * Build a prepareCmd string from .NET projects.\
@@ -26,31 +26,30 @@ const ourDefaultPubDir = path.join('.', 'publish') as `.${'/' | '\\'}publish`;
26
26
  * of the `--output` argument will be set to {@link ourDefaultPubDir} if `undefined`.
27
27
  * @returns A single string of CLI commands joined by ' && '
28
28
  */
29
+ // eslint-disable-next-line unicorn/name-replacements
29
30
  export async function configurePrepareCmd(
30
31
  projectsToPublish: string[] | MSBuildProject[],
31
32
  projectsToPackAndPush?: string[] | NugetRegistryInfo[],
33
+ // eslint-disable-next-line unicorn/name-replacements
32
34
  dotnetNugetSignOpts?: typeof DotnetNugetSignOptions.inferIn,
33
35
  ): Promise<string> {
34
- const evaluatedProjects: MSBuildProject[] = [];
36
+ const evaluatedProjects: MSBuildProject[] = projectsToPublish.filter(p => p instanceof MSBuildProject);
35
37
 
36
- // append evaluated projects
37
- for (const p of projectsToPublish.filter(p => p instanceof MSBuildProject)) {
38
- evaluatedProjects.push(p);
39
- }
40
38
  if (projectsToPackAndPush) {
41
- for (const p of projectsToPackAndPush.filter(p => p instanceof NugetRegistryInfo)) {
42
- evaluatedProjects.push(p.project);
39
+ for (const project of projectsToPackAndPush) {
40
+ if (project instanceof NugetRegistryInfo)
41
+ evaluatedProjects.push(project.project);
43
42
  }
44
43
  }
45
44
 
46
- const dotnetPublishCmd: string = await formatDotnetPublish(projectsToPublish);
47
- const dotnetPackCmd: string | undefined = await formatDotnetPack(projectsToPackAndPush ?? []);
48
- const dotnetNugetSignCmd: string | undefined = formatDotnetNugetSign(dotnetNugetSignOpts);
45
+ const dotnetPublishCommand: string = await formatDotnetPublish(projectsToPublish);
46
+ const dotnetPackCommand: string | undefined = await formatDotnetPack(projectsToPackAndPush ?? []);
47
+ const dotnetNugetSignCommand: string | undefined = formatDotnetNugetSign(dotnetNugetSignOpts);
49
48
 
50
49
  return [
51
- dotnetPublishCmd,
52
- dotnetPackCmd,
53
- dotnetNugetSignCmd,
50
+ dotnetPublishCommand,
51
+ dotnetPackCommand,
52
+ dotnetNugetSignCommand,
54
53
  // remove no-op commands
55
54
  ]
56
55
  .filter(v => v !== undefined)
@@ -162,7 +161,7 @@ export async function configurePrepareCmd(
162
161
  * // return array as success-chained CLI commands.
163
162
  * return publishCmdArray.join(' && ');
164
163
  */
165
- function getPublishArgsPermutations(proj: MSBuildProject):
164
+ function getPublishArgumentsPermutations(proj: MSBuildProject):
166
165
  ([`"${typeof proj.Properties.MSBuildProjectFullPath}" -t:PublishAll -p:Configuration=Release`])
167
166
  | ([`"${typeof proj.Properties.MSBuildProjectFullPath}"`])
168
167
  | (`"${typeof proj.Properties.MSBuildProjectFullPath}" --runtime ${string} --framework ${string}`)[]
@@ -212,8 +211,8 @@ export async function configurePrepareCmd(
212
211
  }
213
212
 
214
213
  /** prepend each set of args with the project's path */
215
- return tfmRidPermutations.map(permArgs =>
216
- `"${proj.Properties.MSBuildProjectFullPath}" ${permArgs}`,
214
+ return tfmRidPermutations.map(permArguments =>
215
+ `"${proj.Properties.MSBuildProjectFullPath}" ${permArguments}`,
217
216
  ) as `"${typeof proj.Properties.MSBuildProjectFullPath}" --runtime ${string} --framework ${string}`[]
218
217
  | `"${typeof proj.Properties.MSBuildProjectFullPath}" --runtime ${string}`[]
219
218
  | `"${typeof proj.Properties.MSBuildProjectFullPath}" --framework ${string}`[];
@@ -222,13 +221,13 @@ export async function configurePrepareCmd(
222
221
 
223
222
  const publishCmds: (`dotnet publish "${string}"` | `dotnet publish "${string}" ${string}` | `dotnet msbuild "${string}" -t:PublishAll -p:Configuration=Release`)[] = [];
224
223
  /** convert {@link evaluatedPublishProjects} to sets of space-separated CLI args. */
225
- const argsSets = evaluatedPublishProjects.map(
226
- proj => getPublishArgsPermutations(proj),
224
+ const argumentsSets = evaluatedPublishProjects.map(
225
+ proj => getPublishArgumentsPermutations(proj),
227
226
  );
228
- for (const args of argsSets) {
229
- if (typeof args === 'string')
227
+ for (const arguments_ of argumentsSets) {
228
+ if (typeof arguments_ === 'string')
230
229
  throw new Error(`\`args\` should not be a string!`);
231
- for (const permutation of args) {
230
+ for (const permutation of arguments_) {
232
231
  if (typeof permutation === 'string' && permutation.length === 1)
233
232
  throw new Error('Something has gone terribly wrong. A `dotnet publish` argument set was split to single characters!');
234
233
  if (/".+" -t:PublishAll -p:Configuration=Release/.test(permutation))
@@ -258,27 +257,27 @@ export async function configurePrepareCmd(
258
257
  ): Promise<string | undefined> {
259
258
  if (projectsToPackAndPush.length === 0)
260
259
  return undefined;
261
- return await Promise.all(
260
+ const nriArray = await Promise.all(
262
261
  projectsToPackAndPush.map(async (proj) => {
263
262
  if (proj instanceof NugetRegistryInfo)
264
263
  return proj;
265
264
 
266
- const msbpArr: MSBuildProject[] = await Promise.all(await MSBuildProject.PackableProjectsToMSBuildProjects([proj]));
267
- if (msbpArr.length === 0 || msbpArr[0] === undefined) {
265
+ const msbpArray: MSBuildProject[] = await Promise.all(await MSBuildProject.PackableProjectsToMSBuildProjects([proj]));
266
+ if (msbpArray.length === 0 || msbpArray[0] === undefined) {
268
267
  throw new Error('This should be impossible!');
269
268
  }
270
- const msbp: MSBuildProject = msbpArr[0];
269
+ const msbp: MSBuildProject = msbpArray[0];
271
270
 
272
271
  evaluatedProjects.push(msbp);
273
272
 
274
273
  return new NugetRegistryInfo({ project: msbp });
275
274
  }),
276
- ).then((nriArray: NugetRegistryInfo[]): string => {
277
- return nriArray
278
- .map((nri: NugetRegistryInfo): string =>
279
- nri.GetPackCommand(NugetRegistryInfo.PackPackagesOptionsType.from({})),
280
- ).join(' && ');
281
- });
275
+ );
276
+
277
+ return nriArray
278
+ .map((nri: NugetRegistryInfo): string =>
279
+ nri.GetPackCommand(NugetRegistryInfo.PackPackagesOptionsType.from({})),
280
+ ).join(' && ');
282
281
  }
283
282
  }
284
283
 
@@ -323,48 +322,49 @@ export function configureDotnetNugetPush(
323
322
  * @returns `dotnet nuget sign {...}`
324
323
  */
325
324
  function formatDotnetNugetSign(
325
+ // eslint-disable-next-line unicorn/name-replacements
326
326
  opts: typeof DotnetNugetSignOptions.inferIn | undefined,
327
327
  ): string | undefined {
328
328
  if (opts === undefined)
329
329
  return undefined;
330
330
 
331
- const validOpts = DotnetNugetSignOptions.from(opts);
332
- const args: ['--timestamper', typeof validOpts.timestamper, '-o', string, ...string[]] = [
333
- '--timestamper', validOpts.timestamper,
334
- '-o', validOpts.output ?? ourDefaultPubDir,
331
+ const validOptions = DotnetNugetSignOptions.from(opts);
332
+ const arguments_: ['--timestamper', typeof validOptions.timestamper, '-o', string, ...string[]] = [
333
+ '--timestamper', validOptions.timestamper,
334
+ '-o', validOptions.output ?? ourDefaultPubDirectory,
335
335
  ];
336
- if (validOpts.certificatePassword)
337
- args.push('---certificate-password', validOpts.certificatePassword);
338
- if (validOpts.hashAlgorithm)
339
- args.push('--hash-algorithm', validOpts.hashAlgorithm);
340
- if (validOpts.overwrite)
341
- args.push('--overwrite');
342
- if (validOpts.timestampHashAlgorithm)
343
- args.push('--timestamp-hash-algorithm', validOpts.timestampHashAlgorithm);
344
- if (validOpts.verbosity)
345
- args.push('-v', validOpts.verbosity);
346
-
347
- if ('certificatePath' in validOpts)
348
- args.push('--certificate-path', validOpts.certificatePath);
349
- else if ('certificateStoreName' in validOpts) {
336
+ if (validOptions.certificatePassword)
337
+ arguments_.push('---certificate-password', validOptions.certificatePassword);
338
+ if (validOptions.hashAlgorithm)
339
+ arguments_.push('--hash-algorithm', validOptions.hashAlgorithm);
340
+ if (validOptions.overwrite)
341
+ arguments_.push('--overwrite');
342
+ if (validOptions.timestampHashAlgorithm)
343
+ arguments_.push('--timestamp-hash-algorithm', validOptions.timestampHashAlgorithm);
344
+ if (validOptions.verbosity)
345
+ arguments_.push('-v', validOptions.verbosity);
346
+
347
+ if ('certificatePath' in validOptions)
348
+ arguments_.push('--certificate-path', validOptions.certificatePath);
349
+ else if ('certificateStoreName' in validOptions) {
350
350
  SetSubjectNameOrFingerprint();
351
- args.push('--certificate-store-name', validOpts.certificateStoreName);
351
+ arguments_.push('--certificate-store-name', validOptions.certificateStoreName);
352
352
  }
353
- else if ('certificateStoreLocation' in validOpts) {
353
+ else if ('certificateStoreLocation' in validOptions) {
354
354
  SetSubjectNameOrFingerprint();
355
- args.push('--certificate-store-location', validOpts.certificateStoreLocation);
355
+ arguments_.push('--certificate-store-location', validOptions.certificateStoreLocation);
356
356
  }
357
357
  else throw new Error('No code signing certificate was specified!');
358
358
 
359
- return `dotnet nuget sign ${args.join(' ')} `;
359
+ return `dotnet nuget sign ${arguments_.join(' ')} `;
360
360
 
361
361
  // eslint-disable-next-line jsdoc/require-jsdoc
362
362
  function SetSubjectNameOrFingerprint() {
363
- if ('certificateSubjectName' in validOpts)
364
- args.push('--certificate-subject-name', validOpts.certificateSubjectName);
363
+ if ('certificateSubjectName' in validOptions)
364
+ arguments_.push('--certificate-subject-name', validOptions.certificateSubjectName);
365
365
 
366
- else if ('certificateFingerprint' in validOpts)
367
- args.push('--certificate-fingerprint', validOpts.certificateFingerprint);
366
+ else if ('certificateFingerprint' in validOptions)
367
+ arguments_.push('--certificate-fingerprint', validOptions.certificateFingerprint);
368
368
  else throw new Error('If certificateStoreName or certificateStoreLocation is set, either certificateSubjectName or certificateFingerprint must also be set!');
369
369
  }
370
370
  }
@@ -73,8 +73,8 @@ export function insertPlugin(
73
73
  const indexOfLastAfter = afterPluginsIDs
74
74
  .filter(v => pluginIDs.includes(v))
75
75
  .map(v => pluginIDs.indexOf(v))
76
- .sort()
77
- .find((_v, i, obj) => i === obj.length - 1);
76
+ .sort((a, b) => a - b)
77
+ .find((_v, index, object) => index === object.length - 1);
78
78
  if (undefined === indexOfLastAfter)
79
79
  throw new ReferenceError(
80
80
  'An attempt to get the last element of an array returned undefined.',
@@ -83,7 +83,7 @@ export function insertPlugin(
83
83
  const indicesOfBefore = beforePluginsIDs
84
84
  .filter(v => pluginIDs.includes(v))
85
85
  .map(v => pluginIDs.indexOf(v))
86
- .sort();
86
+ .sort((a, b) => a - b);
87
87
 
88
88
  // This for-of collects *all* sorting errors. The resulting AggregateError
89
89
  // notifies the API user of *all* errors in the order rather than just the
@@ -1,3 +1,4 @@
1
+ /* eslint-disable unicorn/name-replacements */
1
2
  declare module '@semantic-release/github' {
2
3
  /**
3
4
  * @see https://github.com/semantic-release/github#configuration
@@ -22,8 +22,8 @@ import type { Options } from 'semantic-release';
22
22
  import type { Options as SRExecOptions } from '@semantic-release/exec';
23
23
  import * as console from 'node:console';
24
24
  import debug from './debug.ts';
25
- import { configureDotnetNugetPush, configurePrepareCmd } from './dotnet/helpers.ts';
26
- import { getEnvVarValue } from './utils/env.ts';
25
+ import { configureDotnetNugetPush, configurePrepareCmd as configurePrepareCommand } from './dotnet/helpers.ts';
26
+ import { getEnvVarValue as getEnvironmentVariableValue } from './utils/env.ts';
27
27
  import { baseConfig } from './semanticReleaseConfig.ts';
28
28
  import { NugetRegistryInfo } from './dotnet/NugetRegistryInfo.ts';
29
29
  import { MSBuildProject } from './dotnet/MSBuildProject.ts';
@@ -80,7 +80,7 @@ export class SemanticReleaseConfigDotnet {
80
80
 
81
81
  this._projectsToPublish = projectsToPublish;
82
82
  if (this._projectsToPublish.length === 0) {
83
- const p = getEnvVarValue('PROJECTS_TO_PUBLISH')?.split(';');
83
+ const p = getEnvironmentVariableValue('PROJECTS_TO_PUBLISH')?.split(';');
84
84
  if (p && p.length > 0) {
85
85
  this._projectsToPublish = p;
86
86
  }
@@ -91,7 +91,7 @@ export class SemanticReleaseConfigDotnet {
91
91
 
92
92
  this._projectsToPackAndPush = projectsToPackAndPush;
93
93
  if (this._projectsToPackAndPush.length === 0) {
94
- const p = getEnvVarValue('PROJECTS_TO_PACK_AND_PUSH')?.split(';');
94
+ const p = getEnvironmentVariableValue('PROJECTS_TO_PACK_AND_PUSH')?.split(';');
95
95
  if (p && p.length > 0) {
96
96
  this._projectsToPackAndPush = p;
97
97
  }
@@ -149,15 +149,15 @@ export class SemanticReleaseConfigDotnet {
149
149
  Unable to find\`['@semantic-release/exec', unknown]\` in plugins array!
150
150
  Appending it to the end of the array...This may cause an unexpected order of operations!`;
151
151
  console.warn(message);
152
- srExecIndex = this.options.plugins.push(['@semantic-release/exec', {}]) - 1;
152
+ this.options.plugins.push(['@semantic-release/exec', {}]);
153
+ srExecIndex = this.options.plugins.length - 1;
153
154
  }
154
155
 
155
156
  const plugin = this.options.plugins[srExecIndex] as ['@semantic-release/exec', SRExecOptions];
156
157
  const execOptions: SRExecOptions = plugin[1];
157
158
 
158
159
  // ensure all packable projects are evaluated
159
- // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion
160
- this._projectsToPackAndPush = await Promise.all(
160
+ const projectPromiseArrayArray = await Promise.all(
161
161
  this._projectsToPackAndPush.map(async (project) => {
162
162
  if (typeof project === 'string') {
163
163
  const packableProjects = await Promise.all(
@@ -172,28 +172,26 @@ Appending it to the end of the array...This may cause an unexpected order of ope
172
172
  // if the user doesn't want a defaulted NRI, they should pass their own NRI (or derived) instance.
173
173
  return packableProjects.map(project => new NugetRegistryInfo({ project }));
174
174
  }
175
- else return [project];
175
+ return [project];
176
176
  }),
177
- ).then(p => p.flat()) as NugetRegistryInfo[];
177
+ );
178
+ this._projectsToPackAndPush = projectPromiseArrayArray.flat();
178
179
 
179
- // todo: double-check token-testing commands. Are they formatted prepended correctly?
180
- const verifyConditionsCmdAppendix = await Promise.all(
180
+ const _pushDummyCommands = await Promise.all(
181
181
  this._projectsToPackAndPush
182
- .map(async project =>
183
- await project.PackDummyPackage({})
184
- .then(() =>
185
- project.GetPushDummyCommand({}),
186
- ),
187
- ),
188
- ).then(cmds =>
189
- cmds.join(' && '),
182
+ .map(async (project) => {
183
+ await project.PackDummyPackage({});
184
+ return project.GetPushDummyCommand({});
185
+ }),
190
186
  );
187
+ const verifyConditionsCommandAppendix = _pushDummyCommands.join(' && ');
188
+
191
189
  execOptions.verifyConditionsCmd
192
190
  = execOptions.verifyConditionsCmd && execOptions.verifyConditionsCmd.trim().length > 0
193
- ? `${execOptions.verifyConditionsCmd} && ${verifyConditionsCmdAppendix}`
194
- : verifyConditionsCmdAppendix;
191
+ ? `${execOptions.verifyConditionsCmd} && ${verifyConditionsCommandAppendix}`
192
+ : verifyConditionsCommandAppendix;
195
193
 
196
- const verifyReleaseCmdAppendix
194
+ const verifyReleaseCommandAppendix
197
195
  = this.ProjectsToPackAndPush
198
196
  .filter(project =>
199
197
  typeof project !== 'string',
@@ -202,10 +200,10 @@ Appending it to the end of the array...This may cause an unexpected order of ope
202
200
  ).join(' && ');
203
201
  execOptions.verifyReleaseCmd
204
202
  = execOptions.verifyReleaseCmd && execOptions.verifyReleaseCmd.trim().length > 0
205
- ? `${execOptions.verifyReleaseCmd} && ${verifyReleaseCmdAppendix}`
206
- : verifyConditionsCmdAppendix;
203
+ ? `${execOptions.verifyReleaseCmd} && ${verifyReleaseCommandAppendix}`
204
+ : verifyConditionsCommandAppendix;
207
205
 
208
- const prepareCmdAppendix = await configurePrepareCmd(
206
+ const prepareCommandAppendix = await configurePrepareCommand(
209
207
  this._projectsToPublish,
210
208
  this._projectsToPackAndPush,
211
209
  );
@@ -213,19 +211,19 @@ Appending it to the end of the array...This may cause an unexpected order of ope
213
211
  // 'ZipPublishDir' zips each publish folder to ./publish/*.zip
214
212
  execOptions.prepareCmd
215
213
  = execOptions.prepareCmd && execOptions.prepareCmd.trim().length > 0
216
- ? `${execOptions.prepareCmd} && ${prepareCmdAppendix}`
217
- : prepareCmdAppendix;
214
+ ? `${execOptions.prepareCmd} && ${prepareCommandAppendix}`
215
+ : prepareCommandAppendix;
218
216
 
219
217
  // FINISHED execOptions.prepareCmd
220
218
  // STARTING execOptions.publishCmd
221
219
  if (this._projectsToPackAndPush.length > 0) {
222
- const publishCmdAppendix: string = configureDotnetNugetPush(
220
+ const publishCommandAppendix: string = configureDotnetNugetPush(
223
221
  this._projectsToPackAndPush,
224
222
  );
225
223
  execOptions.publishCmd
226
224
  = execOptions.publishCmd && execOptions.publishCmd.trim().length > 0
227
- ? `${execOptions.publishCmd} && ${publishCmdAppendix}`
228
- : publishCmdAppendix;
225
+ ? `${execOptions.publishCmd} && ${publishCommandAppendix}`
226
+ : publishCommandAppendix;
229
227
  }
230
228
 
231
229
  // FINISHED execOptions.publishCmd
@@ -254,8 +252,8 @@ Appending it to the end of the array...This may cause an unexpected order of ope
254
252
  const indexOfLastPreceding: number | undefined = insertAfterPluginIDs
255
253
  .filter(v => pluginIDs.includes(v))
256
254
  .map(v => pluginIDs.indexOf(v))
257
- .sort()
258
- .find((_v, i, obj) => i === obj.length - 1);
255
+ .sort((a, b) => a - b)
256
+ .find((_v, index, object) => index === object.length - 1);
259
257
  if (!indexOfLastPreceding)
260
258
  throw new ReferenceError(
261
259
  'An attempt to get the last element of indexOfLastAfter returned undefined.',
@@ -264,23 +262,24 @@ Appending it to the end of the array...This may cause an unexpected order of ope
264
262
  const indicesOfBefore: number[] = insertBeforePluginsIDs
265
263
  .filter(v => pluginIDs.includes(v))
266
264
  .map(v => pluginIDs.indexOf(v))
267
- .sort();
265
+ .sort((a, b) => a - b);
268
266
 
269
267
  for (const index of indicesOfBefore) {
270
- if (index <= indexOfLastPreceding) {
271
- const formattedInsertIds: string
272
- = '[' + insertPluginIDs.map(v => `"${v}"`).join(', ') + ']';
273
- const formattedAfterIds: string
274
- = '[' + insertAfterPluginIDs.map(v => `"${v}"`).join(', ') + ']';
275
- const formattedBeforeIds: string
276
- = '[' + insertBeforePluginsIDs.map(v => `"${v}"`).join(', ') + ']';
277
- errors.push(
278
- new Error(
279
- `insertPlugin was instructed to insert ${formattedInsertIds} after ${formattedAfterIds} and before ${formattedBeforeIds}, `
280
- + `but ${JSON.stringify(pluginIDs[indexOfLastPreceding])} is ordered after ${JSON.stringify(pluginIDs[index])}!`,
281
- ),
282
- );
283
- }
268
+ if (index > indexOfLastPreceding)
269
+ continue;
270
+
271
+ const formattedInsertIds: string
272
+ = '[' + insertPluginIDs.map(v => `"${v}"`).join(', ') + ']';
273
+ const formattedAfterIds: string
274
+ = '[' + insertAfterPluginIDs.map(v => `"${v}"`).join(', ') + ']';
275
+ const formattedBeforeIds: string
276
+ = '[' + insertBeforePluginsIDs.map(v => `"${v}"`).join(', ') + ']';
277
+ errors.push(
278
+ new Error(
279
+ `insertPlugin was instructed to insert ${formattedInsertIds} after ${formattedAfterIds} and before ${formattedBeforeIds}, `
280
+ + `but ${JSON.stringify(pluginIDs[indexOfLastPreceding])} is ordered after ${JSON.stringify(pluginIDs[index])}!`,
281
+ ),
282
+ );
284
283
  }
285
284
 
286
285
  if (errors.length > 0)
@@ -310,6 +309,7 @@ Appending it to the end of the array...This may cause an unexpected order of ope
310
309
  );
311
310
  const nupkgPaths = await Promise.all(
312
311
  regInfos.map(nri =>
312
+ // eslint-disable-next-line unicorn/prefer-await
313
313
  nri.PackDummyPackage({}).then((nupkgs) => {
314
314
  // this is a full file path.
315
315
  const mainNupkg = nupkgs.find(nupkg =>
@@ -376,7 +376,7 @@ export async function getConfig(
376
376
  const errors: Error[] = [];
377
377
 
378
378
  if (projectsToPublish.length === 0) {
379
- const _ = getEnvVarValue('PROJECTS_TO_PUBLISH');
379
+ const _ = getEnvironmentVariableValue('PROJECTS_TO_PUBLISH');
380
380
  if (_ === undefined)
381
381
  errors.push(
382
382
  new Error(
@@ -387,7 +387,7 @@ export async function getConfig(
387
387
  }
388
388
 
389
389
  if (!projectsToPackAndPush) {
390
- const _ = getEnvVarValue('PROJECTS_TO_PACK_AND_PUSH');
390
+ const _ = getEnvironmentVariableValue('PROJECTS_TO_PACK_AND_PUSH');
391
391
  if (_ === undefined)
392
392
  errors.push(
393
393
  new Error(
@@ -398,11 +398,9 @@ export async function getConfig(
398
398
  }
399
399
 
400
400
  if (errors.length > 0) {
401
- throw new Error(
402
- [
403
- 'getConfig cannot continue. One or more errors occurred.',
404
- ...errors.map(v => v.stack),
405
- ].join('\n'),
401
+ throw new AggregateError(
402
+ errors,
403
+ 'getConfig cannot continue. One or more errors occurred.',
406
404
  );
407
405
  }
408
406
 
@@ -40,36 +40,35 @@ function gitAssetsToStringArray(
40
40
  return [assets] as string[];
41
41
  if (typeof assets.path === 'string')
42
42
  return [assets.path];
43
- else
44
- throw new TypeError('assets is not typeof GitOptions[\'assets\'!');
43
+ throw new TypeError('assets is not typeof GitOptions[\'assets\'!');
45
44
  }
46
45
 
47
46
  /**
48
47
  * Sanitize a {@link GitOptions} object so its {@link GitOptions#assets} property is either `false` or a `string[]`.
49
- * @param opts A {@link GitOptions} object.
48
+ * @param options A {@link GitOptions} object.
50
49
  * @returns A {@link GitOptions} object whose {@link GitOptions#assets} is `string[] | false`.
51
50
  */
52
- function sanitizeGitOptions(opts: GitOptions): Omit<GitOptions, 'assets'> & { assets: string[] | false } {
53
- return { ...opts, assets: opts.assets === false ? opts.assets : gitAssetsToStringArray(opts.assets) };
51
+ function sanitizeGitOptions(options: GitOptions): Omit<GitOptions, 'assets'> & { assets: string[] | false } {
52
+ return { ...options, assets: options.assets === false ? options.assets : gitAssetsToStringArray(options.assets) };
54
53
  }
55
54
 
56
55
  /**
57
- *Determine if {@link opts} is a {@link GitOptions} object.
58
- * @param opts Anything.
59
- * @returns `true` if {@link opts} is a {@link GitOptions} object. Else, `false`.
56
+ *Determine if {@link options} is a {@link GitOptions} object.
57
+ * @param options Anything.
58
+ * @returns `true` if {@link options} is a {@link GitOptions} object. Else, `false`.
60
59
  */
61
- function isGitOptions(opts: unknown): opts is GitOptions {
60
+ function isGitOptions(options: unknown): options is GitOptions {
62
61
  let isOptions = false;
63
62
 
64
- if (typeof opts !== 'object' || opts == undefined)
63
+ if (typeof options !== 'object' || options == undefined)
65
64
  return isOptions;
66
- if ('assets' in opts) {
67
- isOptions = Array.isArray(opts.assets)
68
- ? opts.assets.every(unk => isGitAsset(unk))
69
- : isGitAsset(opts.assets);
65
+ if ('assets' in options) {
66
+ isOptions = Array.isArray(options.assets)
67
+ ? options.assets.every(unk => isGitAsset(unk))
68
+ : isGitAsset(options.assets);
70
69
  }
71
- if ('message' in opts)
72
- isOptions = typeof opts.message === 'string';
70
+ if ('message' in options)
71
+ isOptions = typeof options.message === 'string';
73
72
  return isOptions;
74
73
  }
75
74
 
@@ -112,7 +111,7 @@ export function setupGitPluginSpec(plugins: PluginSpecTuple[]): PluginSpecTuple[
112
111
  */
113
112
  // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
114
113
  const firstGitPlugin = plugins[firstGitPluginIndex]!;
115
- const firstGitOpts: ReturnType<typeof sanitizeGitOptions> = isGitOptions(firstGitPlugin[1])
114
+ const firstGitOptions: ReturnType<typeof sanitizeGitOptions> = isGitOptions(firstGitPlugin[1])
116
115
  ? sanitizeGitOptions(firstGitPlugin[1])
117
116
  : DefaultOptions;
118
117
 
@@ -130,23 +129,23 @@ export function setupGitPluginSpec(plugins: PluginSpecTuple[]): PluginSpecTuple[
130
129
 
131
130
  /** if another Git PluginSpec is discovered, copy its options to the first Git PluginSpec and return undefined. */
132
131
  if (hasGitOptions(current)) {
133
- const currentGitOpts = sanitizeGitOptions(current[1]);
132
+ const currentGitOptions = sanitizeGitOptions(current[1]);
134
133
 
135
- if (currentGitOpts.assets === false) {
136
- firstGitOpts.assets = false;
134
+ if (currentGitOptions.assets === false) {
135
+ firstGitOptions.assets = false;
137
136
  }
138
137
  else {
139
- const assets: string[] = gitAssetsToStringArray(currentGitOpts.assets);
140
- if (Array.isArray(firstGitOpts.assets)) {
141
- firstGitOpts.assets.push(...assets);
138
+ const assets: string[] = gitAssetsToStringArray(currentGitOptions.assets);
139
+ if (Array.isArray(firstGitOptions.assets)) {
140
+ firstGitOptions.assets.push(...assets);
142
141
  }
143
142
  else {
144
- firstGitOpts.assets = assets;
143
+ firstGitOptions.assets = assets;
145
144
  }
146
145
  }
147
146
 
148
- if (typeof currentGitOpts.message === 'string')
149
- firstGitOpts.message = currentGitOpts.message;
147
+ if (typeof currentGitOptions.message === 'string')
148
+ firstGitOptions.message = currentGitOptions.message;
150
149
  }
151
150
  return undefined;
152
151
  }).filter(pluginSpec => pluginSpec !== undefined);
package/src/utils/env.ts CHANGED
@@ -1,3 +1,4 @@
1
+ /* eslint-disable unicorn/name-replacements */
1
2
  import dotenvx, {
2
3
  type DotenvConfigOptions,
3
4
  type GetOptions,
@@ -9,19 +9,22 @@ import { isError } from './isError.ts';
9
9
  * A `promisify(exec)` wrapper to optionally assign the child process's STDERR as the {@link Error.prototype.cause}.
10
10
  * @see {@link promisify}, {@link exec}
11
11
  * @param command The command to run, with space-separated arguments.
12
- * @param [setStderrAsCause=false] If true and the child process's stderr is available, the thrown Error's {@link Error.prototype.cause} is assigned the stderr string.
12
+ * @param [shouldSetStderrAsCause=false] If true and the child process's stderr is available, the thrown Error's {@link Error.prototype.cause} is assigned the stderr string.
13
13
  * @returns A promise of the child process's STDOUT and STDERR streams as strings
14
14
  * @throws {Error | ChildProcessSpawnException}
15
15
  */
16
- export async function execAsync(command: string, setStderrAsCause = false): Promise<{
16
+ export async function execAsync(command: string, shouldSetStderrAsCause = false): Promise<{
17
17
  stdout: string;
18
18
  stderr: string;
19
19
  }> {
20
- return await promisify(exec)(command).catch((error: unknown): never => {
20
+ try {
21
+ return await promisify(exec)(command);
22
+ }
23
+ catch (error: unknown) {
21
24
  if (!isError(error))
22
- throw new Error(JSON.stringify(error));
25
+ throw new Error(JSON.stringify(error), { cause: error });
23
26
 
24
- if (setStderrAsCause && 'stderr' in error && typeof error.stderr === 'string' && error.stderr !== '')
27
+ if (shouldSetStderrAsCause && 'stderr' in error && typeof error.stderr === 'string' && error.stderr !== '')
25
28
  error.cause ??= error.stderr;
26
29
 
27
30
  if ('stdout' in error && typeof error.stdout === 'string') {
@@ -36,7 +39,7 @@ export async function execAsync(command: string, setStderrAsCause = false): Prom
36
39
  }
37
40
 
38
41
  throw new ChildProcessSpawnException(error.message, error);
39
- });
42
+ }
40
43
  }
41
44
 
42
45
  const T_ExecException: Type<{
@@ -65,6 +68,13 @@ const T_ExecException: Type<{
65
68
  type _ExecException = typeof T_ExecException.inferOut;
66
69
 
67
70
  export class ChildProcessSpawnException extends Error implements _ExecException {
71
+ cmd: typeof T_ExecException.inferOut.cmd;
72
+ code: typeof T_ExecException.inferOut.code;
73
+ killed: typeof T_ExecException.inferOut.killed;
74
+ signal: typeof T_ExecException.inferOut.signal;
75
+ stderr: typeof T_ExecException.inferOut.stderr;
76
+ stdout: typeof T_ExecException.inferOut.stdout;
77
+
68
78
  constructor(
69
79
  message: Parameters<typeof Error>[0],
70
80
  options: typeof T_ExecException.inferIn,
@@ -78,11 +88,4 @@ export class ChildProcessSpawnException extends Error implements _ExecException
78
88
  this.stderr = options.stderr;
79
89
  this.stdout = options.stdout;
80
90
  }
81
-
82
- cmd: typeof T_ExecException.inferOut.cmd;
83
- code: typeof T_ExecException.inferOut.code;
84
- killed: typeof T_ExecException.inferOut.killed;
85
- signal: typeof T_ExecException.inferOut.signal;
86
- stderr: typeof T_ExecException.inferOut.stderr;
87
- stdout: typeof T_ExecException.inferOut.stdout;
88
91
  }
@@ -1,3 +1,4 @@
1
+ /* eslint-disable unicorn/name-replacements */
1
2
  /* eslint-disable @typescript-eslint/no-explicit-any */
2
3
  /**
3
4
  * A generic alternative to the boxing {@link Function} type. Based on the
@@ -1,10 +1,10 @@
1
1
  import type { PropertyDescriptorMap } from './PropertyDescriptorMap.d.ts';
2
2
  import type {
3
- BaseClassProto,
3
+ BaseClassProto as BaseClassPrototype,
4
4
  ConstructorConstraint,
5
5
  InstanceTypeOrSelf,
6
6
  SuperClassLike,
7
- WithProto,
7
+ WithProto as WithPrototype,
8
8
  } from './inheritance.ts';
9
9
 
10
10
  /**
@@ -26,7 +26,7 @@ import type {
26
26
  * @since 3.0.0
27
27
  */
28
28
  export type InstancePropertyDescriptorMap<
29
- Class extends ConstructorConstraint<Class> & WithProto<SuperClassLike | BaseClassProto>,
30
- > = Class['__proto__'] extends BaseClassProto
29
+ Class extends ConstructorConstraint<Class> & WithPrototype<SuperClassLike | BaseClassPrototype>,
30
+ > = Class['__proto__'] extends BaseClassPrototype
31
31
  ? PropertyDescriptorMap<InstanceType<Class>>
32
32
  : PropertyDescriptorMap<InstanceType<Class>, InstanceTypeOrSelf<Class['__proto__']>>;