@halospv3/hce.shared-config 2.6.4 → 3.0.0-develop.2
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 +356 -101
- package/README.md +100 -87
- package/dotnet/.github/workflows/_unit_test.yml +6 -3
- package/dotnet/.github/workflows/ci.yml +2 -2
- package/dotnet/.github/workflows/dotnet-release.yml +31 -28
- package/dotnet/.github/workflows/sample-dotnet-build.yml +16 -11
- package/dotnet/ExecNupkgDeterministicator.README.md +20 -0
- package/dotnet/ExecNupkgDeterministicator.targets +173 -0
- package/dotnet/GitVersion.yml +3 -1
- package/dotnet/GitVersion6.0.yml +3 -1
- package/dotnet/HCE.Shared.sln +34 -0
- package/dotnet/HCE.Shared.targets +1 -0
- package/dotnet/PublishAll.targets +2 -0
- package/dotnet/SignAfterPack.targets +104 -0
- package/dotnet/samples/HCE.Shared.DeterministicNupkg/Dummy.cs +6 -0
- package/dotnet/samples/HCE.Shared.DeterministicNupkg/HCE.Shared.DeterministicNupkg.csproj +21 -0
- package/dotnet/samples/HCE.Shared.SignAfterPack/Class1.cs +6 -0
- package/dotnet/samples/HCE.Shared.SignAfterPack/HCE.Shared.SignAfterPack.csproj +21 -0
- package/dotnet/samples/HCE.Shared.SignAfterPack/sampleCert.samplepfx +0 -0
- package/dotnet/samples/README.md +7 -0
- package/package.json +72 -73
- package/src/CaseInsensitiveMap.ts +34 -0
- package/src/commitlintConfig.ts +17 -9
- package/src/debug.ts +3 -3
- package/src/dotnet/GithubNugetRegistryInfo.ts +60 -0
- package/src/dotnet/GitlabNugetRegistryInfo.ts +112 -0
- package/src/dotnet/IsNextVersionAlreadyPublished.cli.ts +44 -0
- package/src/dotnet/MSBuildProject.ts +557 -76
- package/src/dotnet/MSBuildProjectProperties.ts +280 -15
- package/src/dotnet/NugetProjectProperties.ts +608 -0
- package/src/dotnet/NugetRegistryInfo.ts +939 -0
- package/src/dotnet/helpers.ts +448 -0
- package/src/eslintConfig.ts +174 -71
- package/src/index.ts +1 -3
- package/src/semantic-release__commit-analyzer.d.ts +44 -38
- package/src/semantic-release__exec.d.ts +15 -0
- package/src/semantic-release__git.d.ts +85 -88
- package/src/semantic-release__github.d.ts +139 -139
- package/src/semanticReleaseConfig.ts +106 -47
- package/src/semanticReleaseConfigDotnet.ts +394 -104
- package/src/setupGitPluginSpec.ts +149 -57
- package/src/tsconfig.json +8 -8
- package/src/utils/Exact.ts +49 -0
- package/src/utils/GracefulRecursion.d.ts +12 -0
- package/src/utils/env.ts +44 -0
- package/src/utils/execAsync.ts +77 -0
- package/src/utils/miscTypes.ts +17 -0
- package/src/utils/reflection/FunctionLike.d.ts +17 -0
- package/src/utils/reflection/GetterDescriptor.d.ts +8 -0
- package/src/utils/reflection/InstancePropertyDescriptorMap.d.ts +32 -0
- package/src/utils/reflection/InstanceTypeOrSelfPropertyDescriptorMap.d.ts +20 -0
- package/src/utils/reflection/OwnGetterDescriptorMap.d.ts +17 -0
- package/src/utils/reflection/OwnKeyOf.d.ts +20 -0
- package/src/utils/reflection/OwnPropertyDescriptorMap.d.ts +82 -0
- package/src/utils/reflection/PropertyDescriptorMap.d.ts +15 -0
- package/src/utils/reflection/filterForGetters.ts +59 -0
- package/src/utils/reflection/getOwnPropertyDescriptors.ts +52 -0
- package/src/utils/reflection/getOwnPropertyDescriptorsRecursively.ts +127 -0
- package/src/utils/reflection/getPrototypeChainOf.ts +85 -0
- package/src/utils/reflection/getPrototypeOf.ts +12 -0
- package/src/utils/reflection/inheritance.ts +262 -0
- package/src/utils/reflection/isConstructor.ts +74 -0
- package/src/utils/reflection/isGetterDescriptor.ts +11 -0
- package/src/utils/reflection/listOwnGetters.ts +80 -0
- package/src/utils/reflection.ts +18 -0
- package/cjs/commitlintConfig-wrapper.mjs +0 -6
- package/cjs/commitlintConfig.cjs +0 -14
- package/cjs/commitlintConfig.cjs.map +0 -1
- package/cjs/commitlintConfig.d.ts +0 -4
- package/cjs/commitlintConfig.d.ts.map +0 -1
- package/cjs/debug.cjs +0 -13
- package/cjs/debug.cjs.map +0 -1
- package/cjs/debug.d.ts +0 -4
- package/cjs/debug.d.ts.map +0 -1
- package/cjs/dotnet/MSBuildProject.cjs +0 -84
- package/cjs/dotnet/MSBuildProject.cjs.map +0 -1
- package/cjs/dotnet/MSBuildProject.d.ts +0 -42
- package/cjs/dotnet/MSBuildProject.d.ts.map +0 -1
- package/cjs/dotnet/MSBuildProjectProperties.cjs +0 -22
- package/cjs/dotnet/MSBuildProjectProperties.cjs.map +0 -1
- package/cjs/dotnet/MSBuildProjectProperties.d.ts +0 -13
- package/cjs/dotnet/MSBuildProjectProperties.d.ts.map +0 -1
- package/cjs/dotnet/createDummyNupkg.cjs +0 -26
- package/cjs/dotnet/createDummyNupkg.cjs.map +0 -1
- package/cjs/dotnet/createDummyNupkg.d.ts +0 -2
- package/cjs/dotnet/createDummyNupkg.d.ts.map +0 -1
- package/cjs/dotnet/dotnetGHPR.cjs +0 -173
- package/cjs/dotnet/dotnetGHPR.cjs.map +0 -1
- package/cjs/dotnet/dotnetGHPR.d.ts +0 -37
- package/cjs/dotnet/dotnetGHPR.d.ts.map +0 -1
- package/cjs/dotnet/dotnetGLPR.cjs +0 -41
- package/cjs/dotnet/dotnetGLPR.cjs.map +0 -1
- package/cjs/dotnet/dotnetGLPR.d.ts +0 -13
- package/cjs/dotnet/dotnetGLPR.d.ts.map +0 -1
- package/cjs/dotnet/dotnetHelpers.cjs +0 -141
- package/cjs/dotnet/dotnetHelpers.cjs.map +0 -1
- package/cjs/dotnet/dotnetHelpers.d.ts +0 -26
- package/cjs/dotnet/dotnetHelpers.d.ts.map +0 -1
- package/cjs/dotnet-wrapper.mjs +0 -6
- package/cjs/dotnet.cjs +0 -15
- package/cjs/dotnet.cjs.map +0 -1
- package/cjs/dotnet.d.ts +0 -7
- package/cjs/dotnet.d.ts.map +0 -1
- package/cjs/envUtils-wrapper.mjs +0 -6
- package/cjs/envUtils.cjs +0 -37
- package/cjs/envUtils.cjs.map +0 -1
- package/cjs/envUtils.d.ts +0 -15
- package/cjs/envUtils.d.ts.map +0 -1
- package/cjs/eslintConfig-wrapper.mjs +0 -6
- package/cjs/eslintConfig.cjs +0 -52
- package/cjs/eslintConfig.cjs.map +0 -1
- package/cjs/eslintConfig.d.ts +0 -3
- package/cjs/eslintConfig.d.ts.map +0 -1
- package/cjs/findStaticConfig-wrapper.mjs +0 -6
- package/cjs/findStaticConfig.cjs +0 -34
- package/cjs/findStaticConfig.cjs.map +0 -1
- package/cjs/findStaticConfig.d.ts +0 -2
- package/cjs/findStaticConfig.d.ts.map +0 -1
- package/cjs/index-wrapper.mjs +0 -6
- package/cjs/index.cjs +0 -10
- package/cjs/index.cjs.map +0 -1
- package/cjs/index.d.ts +0 -5
- package/cjs/index.d.ts.map +0 -1
- package/cjs/semantic-release__commit-analyzer.d.cjs +0 -2
- package/cjs/semantic-release__commit-analyzer.d.cjs.map +0 -1
- package/cjs/semantic-release__git.d.cjs +0 -2
- package/cjs/semantic-release__git.d.cjs.map +0 -1
- package/cjs/semantic-release__github.d.cjs +0 -2
- package/cjs/semantic-release__github.d.cjs.map +0 -1
- package/cjs/semanticReleaseConfig-wrapper.mjs +0 -6
- package/cjs/semanticReleaseConfig.cjs +0 -33
- package/cjs/semanticReleaseConfig.cjs.map +0 -1
- package/cjs/semanticReleaseConfig.d.ts +0 -4
- package/cjs/semanticReleaseConfig.d.ts.map +0 -1
- package/cjs/semanticReleaseConfigDotnet-wrapper.mjs +0 -7
- package/cjs/semanticReleaseConfigDotnet.cjs +0 -112
- package/cjs/semanticReleaseConfigDotnet.cjs.map +0 -1
- package/cjs/semanticReleaseConfigDotnet.d.ts +0 -51
- package/cjs/semanticReleaseConfigDotnet.d.ts.map +0 -1
- package/cjs/setupGitPluginSpec-wrapper.mjs +0 -6
- package/cjs/setupGitPluginSpec.cjs +0 -67
- package/cjs/setupGitPluginSpec.cjs.map +0 -1
- package/cjs/setupGitPluginSpec.d.ts +0 -19
- package/cjs/setupGitPluginSpec.d.ts.map +0 -1
- package/src/dotnet/createDummyNupkg.ts +0 -30
- package/src/dotnet/dotnetGHPR.ts +0 -232
- package/src/dotnet/dotnetGLPR.ts +0 -46
- package/src/dotnet/dotnetHelpers.ts +0 -184
- package/src/dotnet.ts +0 -6
- package/src/envUtils.ts +0 -36
- package/src/findStaticConfig.ts +0 -31
- package/static/.releaserc.yml +0 -35
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
/**
|
|
1
|
+
/**
|
|
2
|
+
* # Semantic-Release Config Factory (dotnet)
|
|
2
3
|
* A functional Semantic-Release configuration for dotnet projects
|
|
3
4
|
*
|
|
4
5
|
* extends {@link baseConfig }
|
|
5
6
|
*
|
|
6
7
|
* <-- TABLE OF CONTENTS -->
|
|
7
|
-
* - evaluateProperties
|
|
8
8
|
* - configureDotnetRelease
|
|
9
9
|
* - Insert-Edit Plugins
|
|
10
10
|
* - Append Plugins
|
|
@@ -12,119 +12,409 @@
|
|
|
12
12
|
*/
|
|
13
13
|
|
|
14
14
|
import { inspect } from 'node:util';
|
|
15
|
-
import type { Options
|
|
15
|
+
import type { Options } from 'semantic-release';
|
|
16
|
+
import type { Options as SRExecOptions } from '@semantic-release/exec';
|
|
16
17
|
import debug from './debug.js';
|
|
17
|
-
import { configureDotnetNugetPush, configurePrepareCmd } from './dotnet/
|
|
18
|
-
import { getEnvVarValue } from './
|
|
19
|
-
import { baseConfig
|
|
20
|
-
import {
|
|
18
|
+
import { configureDotnetNugetPush, configurePrepareCmd } from './dotnet/helpers.js';
|
|
19
|
+
import { getEnvVarValue } from './utils/env.js';
|
|
20
|
+
import { baseConfig } from './semanticReleaseConfig.js';
|
|
21
|
+
import { NugetRegistryInfo } from './dotnet/NugetRegistryInfo.js';
|
|
22
|
+
import { MSBuildProject } from './dotnet/MSBuildProject.js';
|
|
23
|
+
import { NPPGetterNames } from './dotnet/NugetProjectProperties.js';
|
|
24
|
+
|
|
25
|
+
type UnArray<T> = T extends (infer U)[] ? U : T;
|
|
26
|
+
interface SRConfigDotnetOptions extends Omit<typeof baseConfig, 'plugins'> {
|
|
27
|
+
plugins: (UnArray<typeof baseConfig.plugins> | [string, unknown])[];
|
|
28
|
+
}
|
|
21
29
|
|
|
22
30
|
/**
|
|
23
|
-
* TODO: options/params for inserts/edits. NOT ready for production. Currently, this can only add Git plugin's options if undefined or one or more is missing.
|
|
24
|
-
* Insert (`array.splice`) and/or configure plugins.\
|
|
25
|
-
* Can be used to...\
|
|
26
|
-
* ...load plugin A before plugin B\
|
|
27
|
-
* ...edit a plugin's existing configuration
|
|
28
|
-
*
|
|
29
|
-
* @param config An instance of {@link Options}
|
|
30
|
-
* @returns a modified copy of {@link config}
|
|
31
31
|
*/
|
|
32
|
-
export
|
|
33
|
-
|
|
34
|
-
|
|
32
|
+
export class SemanticReleaseConfigDotnet {
|
|
33
|
+
private readonly options: SRConfigDotnetOptions;
|
|
34
|
+
private readonly _projectsToPublish: string[] | MSBuildProject[];
|
|
35
|
+
private _projectsToPackAndPush: string[] | NugetRegistryInfo[];
|
|
36
|
+
private readonly _evaluatedProjects: MSBuildProject[];
|
|
35
37
|
|
|
36
|
-
|
|
38
|
+
/**
|
|
39
|
+
* Creates an instance of SemanticReleaseConfigDotnet.
|
|
40
|
+
* Configures {@link baseConfig} with `@semantic-release/exec` to `dotnet` publish, pack, and push.
|
|
41
|
+
*
|
|
42
|
+
* Note: To sign packages, create a Target in the corresponding project(s) e.g.
|
|
43
|
+
* ```xml
|
|
44
|
+
* <Target Name="SignNupkgs" AfterTargets="Pack">
|
|
45
|
+
* <Exec Command="dotnet nuget sign $(PackageOutputPath) [remaining args]" ConsoleToMsBuild="true" />
|
|
46
|
+
* </Target>
|
|
47
|
+
* ```
|
|
48
|
+
* Alternatively, splice your signing commands into the publishCmd string,
|
|
49
|
+
* inserting them before `dotnet nuget push`.
|
|
50
|
+
* If you sign different signatures depending on the NuGet registry,
|
|
51
|
+
* splice your signing command (with "overwrite signature" enabled, if
|
|
52
|
+
* desired) before the corresponding registry's `dotnet nuget push` command.
|
|
53
|
+
* @param projectsToPublish An array of dotnet projects' relative paths. If
|
|
54
|
+
* empty or unspecified, tries getting projects' semi-colon-separated relative
|
|
55
|
+
* paths from the `PROJECTS_TO_PUBLISH` environment variable. If configured as
|
|
56
|
+
* recommended, the projects' publish outputs will be zipped to '$PWD/publish'
|
|
57
|
+
* for use in the `publish` semantic-release step (typically, GitHub release).
|
|
58
|
+
* @param projectsToPackAndPush An array of dotnet projects' relative paths.
|
|
59
|
+
* If empty or unspecified, tries getting projects' semi-colon-separated
|
|
60
|
+
* relative paths from the `PROJECTS_TO_PACK_AND_PUSH` environment variable.
|
|
61
|
+
* Otherwise, no packages will be packed and pushed.
|
|
62
|
+
* If configured as recommended, `dotnet pack` will output the nupkg/snupkg
|
|
63
|
+
* files to `$PWD/publish` where they will be globbed by `dotnet nuget push`.
|
|
64
|
+
*/
|
|
65
|
+
constructor(
|
|
66
|
+
projectsToPublish: string[] | MSBuildProject[],
|
|
67
|
+
projectsToPackAndPush: string[] | NugetRegistryInfo[],
|
|
68
|
+
) {
|
|
69
|
+
this.options = baseConfig;
|
|
70
|
+
/* normalize PluginSpecs to tuples */
|
|
71
|
+
this.options.plugins = this.options.plugins.map(pluginSpec => typeof pluginSpec === 'string'
|
|
72
|
+
? [pluginSpec, {}]
|
|
73
|
+
: pluginSpec,
|
|
74
|
+
);
|
|
37
75
|
|
|
38
|
-
|
|
39
|
-
|
|
76
|
+
this._projectsToPublish = projectsToPublish;
|
|
77
|
+
if (this._projectsToPublish.length === 0) {
|
|
78
|
+
const p = getEnvVarValue('PROJECTS_TO_PUBLISH')?.split(';');
|
|
79
|
+
if (p && p.length > 0) {
|
|
80
|
+
this._projectsToPublish = p;
|
|
81
|
+
}
|
|
82
|
+
else if (debug.enabled) {
|
|
83
|
+
debug.log(new Error('At least one project must be published. `projectsToPackAndPush` is empty and environment variable `PROJECTS_TO_PUBLISH` is undefined or empty.'));
|
|
84
|
+
}
|
|
85
|
+
}
|
|
40
86
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
87
|
+
this._projectsToPackAndPush = projectsToPackAndPush;
|
|
88
|
+
if (this._projectsToPackAndPush.length === 0) {
|
|
89
|
+
const p = getEnvVarValue('PROJECTS_TO_PACK_AND_PUSH')?.split(';');
|
|
90
|
+
if (p && p.length > 0) {
|
|
91
|
+
this._projectsToPackAndPush = p;
|
|
92
|
+
}
|
|
93
|
+
else if (debug.enabled) {
|
|
94
|
+
debug.log(new Error('projectsToPackAndPush.length must be > 0 or PROJECTS_TO_PACK_AND_PUSH must be defined and contain at least one path.'));
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
// may be zero-length array
|
|
99
|
+
this._evaluatedProjects = [
|
|
100
|
+
...this._projectsToPublish.filter(v => v instanceof MSBuildProject),
|
|
101
|
+
...this._projectsToPackAndPush
|
|
102
|
+
.filter(v => v instanceof NugetRegistryInfo)
|
|
103
|
+
.map(v => v.project),
|
|
104
|
+
];
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
get ProjectsToPublish(): string[] | MSBuildProject[] {
|
|
108
|
+
return this._projectsToPublish;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
get ProjectsToPackAndPush(): string[] | NugetRegistryInfo[] {
|
|
112
|
+
return this._projectsToPackAndPush;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
get EvaluatedProjects(): MSBuildProject[] {
|
|
116
|
+
return this._evaluatedProjects;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
insertPlugin(
|
|
120
|
+
afterPluginsIDs: string[],
|
|
121
|
+
insertPluginIDs: string[],
|
|
122
|
+
beforePluginsIDs: string[],
|
|
123
|
+
) {
|
|
124
|
+
const pluginIDs = this.options.plugins.map(v =>
|
|
125
|
+
typeof v === 'string' ? v : v[0],
|
|
126
|
+
);
|
|
127
|
+
|
|
128
|
+
// if any beforePluginIDs are ordered before the last afterPlugin, throw. Impossible to sort.
|
|
129
|
+
|
|
130
|
+
const indexOfLastAfter = afterPluginsIDs
|
|
131
|
+
.filter(v => pluginIDs.includes(v))
|
|
132
|
+
.map(v => pluginIDs.indexOf(v))
|
|
133
|
+
.sort()
|
|
134
|
+
.find((_v, i, obj) => i === obj.length - 1);
|
|
135
|
+
if (!indexOfLastAfter)
|
|
136
|
+
throw new ReferenceError(
|
|
137
|
+
'An attempt to get the last element of an array returned undefined.',
|
|
138
|
+
);
|
|
139
|
+
|
|
140
|
+
const indicesOfBefore = beforePluginsIDs
|
|
141
|
+
.filter(v => pluginIDs.includes(v))
|
|
142
|
+
.map(v => pluginIDs.indexOf(v))
|
|
143
|
+
.sort();
|
|
144
|
+
|
|
145
|
+
// This for-of collects *all* sorting errors. The resulting AggregateError
|
|
146
|
+
// notifies the API user of *all* errors in the order rather than just the
|
|
147
|
+
// first error encountered.
|
|
148
|
+
const errors: Error[] = [];
|
|
149
|
+
for (const index of indicesOfBefore) {
|
|
150
|
+
if (index <= indexOfLastAfter) {
|
|
151
|
+
errors.push(
|
|
152
|
+
new Error(
|
|
153
|
+
`insertPlugin was instructed to insert one or more plugins after [${afterPluginsIDs.map(v => '"' + v + '"').join(', ')}] and before [${beforePluginsIDs.map(v => `"${v}"`).join(', ')}], but ${JSON.stringify(pluginIDs[indexOfLastAfter])} comes after ${JSON.stringify(pluginIDs[index])}!`,
|
|
154
|
+
),
|
|
155
|
+
);
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
if (errors.length > 0)
|
|
159
|
+
throw new AggregateError(errors, 'One or more errors occurred while inserting plugin configs into the Semantic Release config!');
|
|
160
|
+
|
|
161
|
+
// insert plugin(s)
|
|
162
|
+
this.options.plugins.splice(
|
|
163
|
+
indexOfLastAfter + 1,
|
|
164
|
+
0,
|
|
165
|
+
...insertPluginIDs.map(id =>
|
|
166
|
+
[id, {}] as [string, unknown],
|
|
167
|
+
),
|
|
168
|
+
);
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
/**
|
|
172
|
+
* generate dotnet commands for \@semantic-release/exec, appending commands with ' && ' when necessary.
|
|
173
|
+
* ?todo: change to builder method? e.g. static async SetupDotnetCommands(this: SemanticReleaseConfigDotnet): Promise<SemanticReleaseConfigDotnet>
|
|
174
|
+
* @async
|
|
175
|
+
* @see https://github.com/semantic-release/exec#usage
|
|
176
|
+
*/
|
|
177
|
+
async setupDotnetCommands(): Promise<void> {
|
|
178
|
+
const srExecIndex = this.options.plugins.findIndex(
|
|
179
|
+
v => v[0] === '@semantic-release/exec',
|
|
180
|
+
);
|
|
181
|
+
const execOptions = this.options.plugins[srExecIndex] as SRExecOptions;
|
|
182
|
+
|
|
183
|
+
// TODO: move configurePrepareCmd into SemanticReleaseConfigDotnet
|
|
184
|
+
// ensure all packable projects are evaluated
|
|
185
|
+
this._projectsToPackAndPush = await Promise.all(
|
|
186
|
+
this.ProjectsToPackAndPush.map(async (v) => {
|
|
187
|
+
if (typeof v === 'string') {
|
|
188
|
+
const msbp = await MSBuildProject.Evaluate({
|
|
189
|
+
FullName: v,
|
|
190
|
+
GetItem: [],
|
|
191
|
+
GetProperty: [
|
|
192
|
+
...MSBuildProject.MatrixProperties,
|
|
193
|
+
...NPPGetterNames.InstanceGettersRecursive,
|
|
194
|
+
],
|
|
195
|
+
GetTargetResult: [],
|
|
196
|
+
Property: {},
|
|
197
|
+
Targets: ['Restore', 'Pack'],
|
|
198
|
+
});
|
|
199
|
+
|
|
200
|
+
this._evaluatedProjects.push(msbp);
|
|
201
|
+
|
|
202
|
+
return new NugetRegistryInfo({ project: msbp });
|
|
203
|
+
}
|
|
204
|
+
else return v;
|
|
205
|
+
}),
|
|
206
|
+
);
|
|
207
|
+
// todo: double-check token-testing commands. Are they formatted prepended correctly?
|
|
208
|
+
const prepareCmdAppendix = await configurePrepareCmd(
|
|
209
|
+
this._projectsToPublish,
|
|
210
|
+
this._projectsToPackAndPush,
|
|
211
|
+
);
|
|
212
|
+
|
|
213
|
+
// 'ZipPublishDir' zips each publish folder to ./publish/*.zip
|
|
214
|
+
execOptions.prepareCmd
|
|
215
|
+
= execOptions.prepareCmd !== undefined && execOptions.prepareCmd.length > 0
|
|
216
|
+
? `${execOptions.prepareCmd} && ${prepareCmdAppendix}`
|
|
217
|
+
: prepareCmdAppendix;
|
|
218
|
+
|
|
219
|
+
// FINISHED execOptions.prepareCmd
|
|
220
|
+
// STARTING execOptions.publishCmd
|
|
221
|
+
if (this._projectsToPackAndPush.length > 0) {
|
|
222
|
+
const publishCmdAppendix: string = configureDotnetNugetPush(
|
|
223
|
+
this._projectsToPackAndPush,
|
|
224
|
+
);
|
|
225
|
+
execOptions.publishCmd
|
|
226
|
+
= execOptions.publishCmd && execOptions.publishCmd.length > 0
|
|
227
|
+
? `${execOptions.publishCmd} && ${publishCmdAppendix}`
|
|
228
|
+
: publishCmdAppendix;
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
// FINISHED execOptions.publishCmd
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
/**
|
|
235
|
+
* Insert a plugin into the plugins array.
|
|
236
|
+
* @deprecated EXPERIMENTAL: needs thorough tests implemented before use in production!
|
|
237
|
+
* @param insertAfterPluginIDs Plugins which should appear BEFORE
|
|
238
|
+
* {@link insertPluginIDs}.
|
|
239
|
+
* @param insertPluginIDs The plugin(s) to insert into the plugins array.
|
|
240
|
+
* @param insertBeforePluginsIDs plugins which should appear AFTER the
|
|
241
|
+
* inserted plugin(s).
|
|
242
|
+
*/
|
|
243
|
+
splicePlugin(
|
|
244
|
+
insertAfterPluginIDs: string[],
|
|
245
|
+
insertPluginIDs: string[],
|
|
246
|
+
insertBeforePluginsIDs: string[],
|
|
247
|
+
): void {
|
|
248
|
+
const errors: Error[] = [];
|
|
249
|
+
const pluginIDs = this.options.plugins.map(v =>
|
|
250
|
+
typeof v === 'string' ? v : v[0],
|
|
251
|
+
) as (typeof this.options.plugins[number])[][0];
|
|
252
|
+
|
|
253
|
+
// if any beforePluginIDs are ordered before the last afterPlugin, throw. Impossible to sort.
|
|
254
|
+
|
|
255
|
+
const indexOfLastPreceding: number | undefined = insertAfterPluginIDs
|
|
256
|
+
.filter(v => pluginIDs.includes(v))
|
|
257
|
+
.map(v => pluginIDs.indexOf(v))
|
|
258
|
+
.sort()
|
|
259
|
+
.find((_v, i, obj) => i === obj.length - 1);
|
|
260
|
+
if (!indexOfLastPreceding)
|
|
261
|
+
throw new ReferenceError(
|
|
262
|
+
'An attempt to get the last element of indexOfLastAfter returned undefined.',
|
|
263
|
+
);
|
|
264
|
+
|
|
265
|
+
const indicesOfBefore: number[] = insertBeforePluginsIDs
|
|
266
|
+
.filter(v => pluginIDs.includes(v))
|
|
267
|
+
.map(v => pluginIDs.indexOf(v))
|
|
268
|
+
.sort();
|
|
269
|
+
|
|
270
|
+
for (const index of indicesOfBefore) {
|
|
271
|
+
if (index <= indexOfLastPreceding) {
|
|
272
|
+
const formattedInsertIds: string
|
|
273
|
+
= '[' + insertPluginIDs.map(v => `"${v}"`).join(', ') + ']';
|
|
274
|
+
const formattedAfterIds: string
|
|
275
|
+
= '[' + insertAfterPluginIDs.map(v => `"${v}"`).join(', ') + ']';
|
|
276
|
+
const formattedBeforeIds: string
|
|
277
|
+
= '[' + insertBeforePluginsIDs.map(v => `"${v}"`).join(', ') + ']';
|
|
278
|
+
errors.push(
|
|
279
|
+
new Error(
|
|
280
|
+
`insertPlugin was instructed to insert ${formattedInsertIds} after ${formattedAfterIds} and before ${formattedBeforeIds}, `
|
|
281
|
+
+ `but ${JSON.stringify(pluginIDs[indexOfLastPreceding])} is ordered after ${JSON.stringify(pluginIDs[index])}!`,
|
|
282
|
+
),
|
|
283
|
+
);
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
if (errors.length > 0)
|
|
288
|
+
throw new AggregateError(errors, 'One or more errors occurred while splicing plugin-option tuples into the Semantic Release config!');
|
|
289
|
+
|
|
290
|
+
this.options.plugins.splice(
|
|
291
|
+
indexOfLastPreceding + 1,
|
|
292
|
+
0,
|
|
293
|
+
...insertPluginIDs.map(v => [v, {}] satisfies [string, unknown]),
|
|
294
|
+
);
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
// todo: join result with dummy pack commands
|
|
298
|
+
protected async getTokenTestingCommands(): Promise<string> {
|
|
299
|
+
const promiseProjects = this.ProjectsToPackAndPush.every(nri => nri instanceof NugetRegistryInfo)
|
|
300
|
+
? this.ProjectsToPackAndPush.map(nri => nri.project)
|
|
301
|
+
: await Promise.all(await MSBuildProject.PackableProjectsToMSBuildProjects(this.ProjectsToPackAndPush));
|
|
302
|
+
|
|
303
|
+
/** if a project is not in {@link EvaluatedProjects}, add it */
|
|
304
|
+
for (const project of promiseProjects) {
|
|
305
|
+
if (!this.EvaluatedProjects.includes(project))
|
|
306
|
+
this.EvaluatedProjects.push(project);
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
const regInfos = promiseProjects.map(
|
|
310
|
+
p => new NugetRegistryInfo({ project: p }),
|
|
311
|
+
);
|
|
312
|
+
const nupkgPaths = await Promise.all(
|
|
313
|
+
regInfos.map(async nri =>
|
|
314
|
+
nri.PackDummyPackage({}).then((nupkgs) => {
|
|
315
|
+
// this is a full file path.
|
|
316
|
+
const mainNupkg = nupkgs.find(nupkg =>
|
|
317
|
+
new RegExp(/(?<!symbols)\.nupkg$/).test(nupkg),
|
|
318
|
+
);
|
|
319
|
+
if (mainNupkg !== undefined)
|
|
320
|
+
return { nri: nri, nupkgPath: mainNupkg } as const;
|
|
321
|
+
throw new Error(
|
|
322
|
+
'None of the following dummy packages are non-symbol .nupkg files:\n'
|
|
323
|
+
+ nupkgs.map(nupkg => ` - ${nupkg}`).join('\n')
|
|
324
|
+
+ '\nIf you intended to push only symbol packages, check if a feature request already exists (https://github.com/HaloSPV3/HCE.Shared/issues?q=push+snupkg) and, if one does not exist, create one containing the keywords "push snupkg".',
|
|
325
|
+
);
|
|
326
|
+
}),
|
|
327
|
+
),
|
|
328
|
+
);
|
|
329
|
+
const pushCommands = nupkgPaths.map(pair =>
|
|
330
|
+
pair.nri.GetPushDummyCommand({}),
|
|
331
|
+
);
|
|
332
|
+
return pushCommands.join(' && ');
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
toOptions(): Options {
|
|
336
|
+
return this.options;
|
|
337
|
+
}
|
|
68
338
|
}
|
|
69
339
|
|
|
70
340
|
/**
|
|
71
341
|
* Configures {@link baseConfig} with `@semantic-release/exec` to `dotnet` publish, pack, and push.
|
|
72
|
-
* @param projectsToPublish An array of dotnet projects' relative paths.
|
|
73
|
-
* empty
|
|
74
|
-
* paths from the `PROJECTS_TO_PUBLISH` environment variable.
|
|
75
|
-
* recommended, the projects' publish outputs will be zipped to
|
|
76
|
-
* for use in the `publish` semantic-release step (typically,
|
|
77
|
-
*
|
|
78
|
-
*
|
|
79
|
-
*
|
|
80
|
-
* semi-colon-separated relative paths
|
|
81
|
-
*
|
|
82
|
-
* the
|
|
83
|
-
* nuget push`.
|
|
84
|
-
* @returns a semantic-release Options object, based on
|
|
342
|
+
* @param projectsToPublish An array of dotnet projects' relative paths.
|
|
343
|
+
* If empty, tries getting projects' semi-colon-separated relative
|
|
344
|
+
* paths from the `PROJECTS_TO_PUBLISH` environment variable.
|
|
345
|
+
* If configured as recommended, the projects' publish outputs will be zipped to
|
|
346
|
+
* '$PWD/publish' for use in the `publish` semantic-release step (typically,
|
|
347
|
+
* GitHub release).
|
|
348
|
+
* @param projectsToPackAndPush An array of dotnet projects' relative paths.
|
|
349
|
+
* If empty, `dotnet pack` and `dotnet nuget push` commands will not be configured.
|
|
350
|
+
* If undefined, tries getting projects' semi-colon-separated relative paths
|
|
351
|
+
* from the `PROJECTS_TO_PACK_AND_PUSH` environment variable.
|
|
352
|
+
* With the recommended configuration, `dotnet pack` will write the nupkg/snupkg
|
|
353
|
+
* files to `$PWD/publish` where they will be globbed by `dotnet nuget push`.
|
|
354
|
+
* @returns a semantic-release Options object, based on
|
|
355
|
+
* `@halospv3/hce.shared-config` (our base config), with the
|
|
356
|
+
* `@semantic-release/exec` plugin configured to `dotnet publish`, `pack`, and
|
|
357
|
+
* `push` the specified projects.
|
|
85
358
|
*/
|
|
86
|
-
export function getConfig(
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
359
|
+
export async function getConfig(
|
|
360
|
+
projectsToPublish: string[] | MSBuildProject[],
|
|
361
|
+
projectsToPackAndPush?: string[] | NugetRegistryInfo[],
|
|
362
|
+
): Promise<Options> {
|
|
363
|
+
if (debug.enabled) {
|
|
364
|
+
debug.log(
|
|
365
|
+
'hce.shared-config:\n' + inspect(baseConfig, false, Infinity, true),
|
|
366
|
+
);
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
const errors: Error[] = [];
|
|
370
|
+
|
|
371
|
+
if (projectsToPublish.length === 0) {
|
|
372
|
+
const _ = getEnvVarValue('PROJECTS_TO_PUBLISH');
|
|
373
|
+
if (_ === undefined)
|
|
374
|
+
errors.push(
|
|
375
|
+
new Error(
|
|
376
|
+
'projectsToPublish.length must be > 0 or PROJECTS_TO_PUBLISH must be defined and contain at least one path.',
|
|
377
|
+
),
|
|
378
|
+
);
|
|
379
|
+
else projectsToPublish = _.split(';');
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
if (!projectsToPackAndPush) {
|
|
383
|
+
const _ = getEnvVarValue('PROJECTS_TO_PACK_AND_PUSH');
|
|
384
|
+
if (_ === undefined)
|
|
385
|
+
errors.push(
|
|
386
|
+
new Error(
|
|
387
|
+
'projectsToPackAndPush.length must be > 0 or PROJECTS_TO_PACK_AND_PUSH must be defined and contain at least one path.',
|
|
388
|
+
),
|
|
389
|
+
);
|
|
390
|
+
else projectsToPackAndPush = _.split(';');
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
if (errors.length > 0) {
|
|
394
|
+
throw new Error(
|
|
395
|
+
[
|
|
396
|
+
'getConfig cannot continue. One or more errors occurred.',
|
|
397
|
+
...errors.map(v => v.stack),
|
|
398
|
+
].join('\n'),
|
|
399
|
+
);
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
const config = new SemanticReleaseConfigDotnet(
|
|
403
|
+
projectsToPublish,
|
|
404
|
+
projectsToPackAndPush ?? [],
|
|
405
|
+
);
|
|
406
|
+
await config.setupDotnetCommands();
|
|
407
|
+
|
|
408
|
+
const options: Options = config.toOptions();
|
|
409
|
+
if (debug.enabled) {
|
|
410
|
+
console.debug(
|
|
411
|
+
`modified plugins array:\n${inspect(options.plugins, false, Infinity)}`,
|
|
412
|
+
);
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
return options;
|
|
128
416
|
}
|
|
129
417
|
|
|
130
|
-
|
|
418
|
+
/**
|
|
419
|
+
* @module semanticReleaseConfigDotnet
|
|
420
|
+
*/
|