@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.
- package/CHANGELOG.md +29 -0
- package/README.md +33 -10
- package/dotnet/.github/workflows/_unit_test.yml +1 -1
- 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 +25 -24
- 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
package/src/dotnet/helpers.ts
CHANGED
|
@@ -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
|
|
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
|
|
42
|
-
|
|
39
|
+
for (const project of projectsToPackAndPush) {
|
|
40
|
+
if (project instanceof NugetRegistryInfo)
|
|
41
|
+
evaluatedProjects.push(project.project);
|
|
43
42
|
}
|
|
44
43
|
}
|
|
45
44
|
|
|
46
|
-
const
|
|
47
|
-
const
|
|
48
|
-
const
|
|
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
|
-
|
|
52
|
-
|
|
53
|
-
|
|
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
|
|
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(
|
|
216
|
-
`"${proj.Properties.MSBuildProjectFullPath}" ${
|
|
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
|
|
226
|
-
proj =>
|
|
224
|
+
const argumentsSets = evaluatedPublishProjects.map(
|
|
225
|
+
proj => getPublishArgumentsPermutations(proj),
|
|
227
226
|
);
|
|
228
|
-
for (const
|
|
229
|
-
if (typeof
|
|
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
|
|
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
|
-
|
|
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
|
|
267
|
-
if (
|
|
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 =
|
|
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
|
-
)
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
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
|
|
332
|
-
const
|
|
333
|
-
'--timestamper',
|
|
334
|
-
'-o',
|
|
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 (
|
|
337
|
-
|
|
338
|
-
if (
|
|
339
|
-
|
|
340
|
-
if (
|
|
341
|
-
|
|
342
|
-
if (
|
|
343
|
-
|
|
344
|
-
if (
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
if ('certificatePath' in
|
|
348
|
-
|
|
349
|
-
else if ('certificateStoreName' in
|
|
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
|
-
|
|
351
|
+
arguments_.push('--certificate-store-name', validOptions.certificateStoreName);
|
|
352
352
|
}
|
|
353
|
-
else if ('certificateStoreLocation' in
|
|
353
|
+
else if ('certificateStoreLocation' in validOptions) {
|
|
354
354
|
SetSubjectNameOrFingerprint();
|
|
355
|
-
|
|
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 ${
|
|
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
|
|
364
|
-
|
|
363
|
+
if ('certificateSubjectName' in validOptions)
|
|
364
|
+
arguments_.push('--certificate-subject-name', validOptions.certificateSubjectName);
|
|
365
365
|
|
|
366
|
-
else if ('certificateFingerprint' in
|
|
367
|
-
|
|
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
|
}
|
package/src/insertPlugins.ts
CHANGED
|
@@ -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,
|
|
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
|
|
@@ -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 =
|
|
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 =
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
175
|
+
return [project];
|
|
176
176
|
}),
|
|
177
|
-
)
|
|
177
|
+
);
|
|
178
|
+
this._projectsToPackAndPush = projectPromiseArrayArray.flat();
|
|
178
179
|
|
|
179
|
-
|
|
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
|
-
|
|
185
|
-
|
|
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} && ${
|
|
194
|
-
:
|
|
191
|
+
? `${execOptions.verifyConditionsCmd} && ${verifyConditionsCommandAppendix}`
|
|
192
|
+
: verifyConditionsCommandAppendix;
|
|
195
193
|
|
|
196
|
-
const
|
|
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} && ${
|
|
206
|
-
:
|
|
203
|
+
? `${execOptions.verifyReleaseCmd} && ${verifyReleaseCommandAppendix}`
|
|
204
|
+
: verifyConditionsCommandAppendix;
|
|
207
205
|
|
|
208
|
-
const
|
|
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} && ${
|
|
217
|
-
:
|
|
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
|
|
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} && ${
|
|
228
|
-
:
|
|
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,
|
|
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
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
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 _ =
|
|
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 _ =
|
|
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
|
|
402
|
-
|
|
403
|
-
|
|
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
|
-
|
|
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
|
|
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(
|
|
53
|
-
return { ...
|
|
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
|
|
58
|
-
* @param
|
|
59
|
-
* @returns `true` if {@link
|
|
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(
|
|
60
|
+
function isGitOptions(options: unknown): options is GitOptions {
|
|
62
61
|
let isOptions = false;
|
|
63
62
|
|
|
64
|
-
if (typeof
|
|
63
|
+
if (typeof options !== 'object' || options == undefined)
|
|
65
64
|
return isOptions;
|
|
66
|
-
if ('assets' in
|
|
67
|
-
isOptions = Array.isArray(
|
|
68
|
-
?
|
|
69
|
-
: isGitAsset(
|
|
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
|
|
72
|
-
isOptions = typeof
|
|
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
|
|
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
|
|
132
|
+
const currentGitOptions = sanitizeGitOptions(current[1]);
|
|
134
133
|
|
|
135
|
-
if (
|
|
136
|
-
|
|
134
|
+
if (currentGitOptions.assets === false) {
|
|
135
|
+
firstGitOptions.assets = false;
|
|
137
136
|
}
|
|
138
137
|
else {
|
|
139
|
-
const assets: string[] = gitAssetsToStringArray(
|
|
140
|
-
if (Array.isArray(
|
|
141
|
-
|
|
138
|
+
const assets: string[] = gitAssetsToStringArray(currentGitOptions.assets);
|
|
139
|
+
if (Array.isArray(firstGitOptions.assets)) {
|
|
140
|
+
firstGitOptions.assets.push(...assets);
|
|
142
141
|
}
|
|
143
142
|
else {
|
|
144
|
-
|
|
143
|
+
firstGitOptions.assets = assets;
|
|
145
144
|
}
|
|
146
145
|
}
|
|
147
146
|
|
|
148
|
-
if (typeof
|
|
149
|
-
|
|
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
package/src/utils/execAsync.ts
CHANGED
|
@@ -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 [
|
|
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,
|
|
16
|
+
export async function execAsync(command: string, shouldSetStderrAsCause = false): Promise<{
|
|
17
17
|
stdout: string;
|
|
18
18
|
stderr: string;
|
|
19
19
|
}> {
|
|
20
|
-
|
|
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 (
|
|
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,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> &
|
|
30
|
-
> = Class['__proto__'] extends
|
|
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__']>>;
|