@halospv3/hce.shared-config 2.2.3 → 2.3.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 +2 -0
- package/LICENSE +1 -1
- package/README.md +116 -88
- package/cjs/commitlintConfig-wrapper.mjs +6 -0
- package/cjs/commitlintConfig.cjs +14 -0
- package/cjs/commitlintConfig.cjs.map +1 -0
- package/cjs/commitlintConfig.d.ts +4 -0
- package/cjs/commitlintConfig.d.ts.map +1 -0
- package/cjs/dotnet/MSBuildProject.cjs +85 -0
- package/cjs/dotnet/MSBuildProject.cjs.map +1 -0
- package/cjs/dotnet/MSBuildProject.d.ts +42 -0
- package/cjs/dotnet/MSBuildProject.d.ts.map +1 -0
- package/cjs/dotnet/MSBuildProjectProperties.cjs +22 -0
- package/cjs/dotnet/MSBuildProjectProperties.cjs.map +1 -0
- package/cjs/dotnet/MSBuildProjectProperties.d.ts +13 -0
- package/cjs/dotnet/MSBuildProjectProperties.d.ts.map +1 -0
- package/cjs/dotnet/dotnetGHPR.cjs +60 -0
- package/cjs/dotnet/dotnetGHPR.cjs.map +1 -0
- package/cjs/dotnet/dotnetGHPR.d.ts +14 -0
- package/cjs/dotnet/dotnetGHPR.d.ts.map +1 -0
- package/cjs/dotnet/dotnetGLPR.cjs +41 -0
- package/cjs/dotnet/dotnetGLPR.cjs.map +1 -0
- package/cjs/dotnet/dotnetGLPR.d.ts +13 -0
- package/cjs/dotnet/dotnetGLPR.d.ts.map +1 -0
- package/cjs/dotnet/dotnetHelpers.cjs +144 -0
- package/cjs/dotnet/dotnetHelpers.cjs.map +1 -0
- package/cjs/dotnet/dotnetHelpers.d.ts +26 -0
- package/cjs/dotnet/dotnetHelpers.d.ts.map +1 -0
- package/cjs/dotnet-wrapper.mjs +6 -0
- package/cjs/dotnet.cjs +13 -0
- package/cjs/dotnet.cjs.map +1 -0
- package/cjs/dotnet.d.ts +6 -0
- package/cjs/dotnet.d.ts.map +1 -0
- package/cjs/eslintConfig-wrapper.mjs +6 -0
- package/cjs/eslintConfig.cjs +55 -0
- package/cjs/eslintConfig.cjs.map +1 -0
- package/cjs/eslintConfig.d.ts +4 -0
- package/cjs/eslintConfig.d.ts.map +1 -0
- package/cjs/findStaticConfig-wrapper.mjs +6 -0
- package/cjs/findStaticConfig.cjs +34 -0
- package/cjs/findStaticConfig.cjs.map +1 -0
- package/cjs/findStaticConfig.d.ts +2 -0
- package/cjs/findStaticConfig.d.ts.map +1 -0
- package/cjs/index.cjs +5 -35
- package/cjs/index.cjs.map +1 -1
- package/cjs/index.d.ts +2 -5
- package/cjs/index.d.ts.map +1 -1
- package/cjs/semantic-release__git.d.cjs +2 -0
- package/cjs/semantic-release__git.d.cjs.map +1 -0
- package/cjs/semanticReleaseConfig-wrapper.mjs +6 -0
- package/cjs/semanticReleaseConfig.cjs +16 -0
- package/cjs/semanticReleaseConfig.cjs.map +1 -0
- package/cjs/semanticReleaseConfig.d.ts +4 -0
- package/cjs/semanticReleaseConfig.d.ts.map +1 -0
- package/cjs/semanticReleaseConfigDotnet-wrapper.mjs +6 -0
- package/cjs/semanticReleaseConfigDotnet.cjs +74 -0
- package/cjs/semanticReleaseConfigDotnet.cjs.map +1 -0
- package/cjs/semanticReleaseConfigDotnet.d.ts +30 -0
- package/cjs/semanticReleaseConfigDotnet.d.ts.map +1 -0
- package/cjs/setupGitPluginSpec-wrapper.mjs +6 -0
- package/cjs/setupGitPluginSpec.cjs +67 -0
- package/cjs/setupGitPluginSpec.cjs.map +1 -0
- package/cjs/setupGitPluginSpec.d.ts +18 -0
- package/cjs/setupGitPluginSpec.d.ts.map +1 -0
- package/dotnet/HCE.Shared.CI.props +8 -0
- package/dotnet/HCE.Shared.props +6 -0
- package/dotnet/HCE.Shared.targets +9 -0
- package/dotnet/PublishAll.targets +43 -0
- package/dotnet/ZipPublishDir.targets +20 -9
- package/dotnet/dotnet-build.ps1 +67 -0
- package/package.json +72 -41
- package/src/commitlintConfig.ts +15 -0
- package/src/dotnet/MSBuildProject.ts +83 -0
- package/src/dotnet/MSBuildProjectProperties.ts +28 -0
- package/src/dotnet/dotnetGHPR.ts +76 -0
- package/src/dotnet/dotnetGLPR.ts +46 -0
- package/src/dotnet/dotnetHelpers.ts +182 -0
- package/src/dotnet.ts +5 -0
- package/src/eslintConfig.ts +86 -0
- package/src/findStaticConfig.ts +31 -0
- package/src/index.ts +2 -40
- package/src/semantic-release__git.d.ts +67 -0
- package/src/semanticReleaseConfig.ts +15 -0
- package/src/semanticReleaseConfigDotnet.ts +78 -0
- package/src/setupGitPluginSpec.ts +75 -0
- package/src/tsconfig.json +10 -0
- package/static/.releaserc.yml +2 -3
- package/commitlint.config.ts +0 -10
- package/dotnet/.releaserc.cjs +0 -77
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"semanticReleaseConfigDotnet.cjs","sources":["../src/semanticReleaseConfigDotnet.ts"],"sourcesContent":null,"names":["defaultPlugins","setupGitPluginSpec","configurePrepareCmd","configureDotnetNugetPush","log","baseConfig"],"mappings":";;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAKA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,oBAAoB,CAAC,MAAM,EAAE;AAC7C,EAAE,MAAM,SAAS,GAAG,MAAM,CAAC;AAC3B;AACA,EAAE,SAAS,CAAC,OAAO,GAAG,CAAC,IAAI,MAAM,CAAC,OAAO,IAAIA,oCAAc,EAAE,CAAC;AAC9D,EAAE,SAAS,CAAC,OAAO,GAAGC,qCAAkB,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;AAC5D,EAAE,OAAO,SAAS,CAAC;AACnB,CAAC;AACM,SAAS,aAAa,CAAC,MAAM,EAAE,iBAAiB,EAAE,qBAAqB,EAAE;AAChF,EAAE,MAAM,SAAS,GAAG,MAAM,CAAC;AAC3B,EAAE,IAAI,SAAS,CAAC,OAAO,KAA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antic-Release Config Factory (dotnet)
|
|
2
|
+
* A functional Semantic-Release configuration for dotnet projects
|
|
3
|
+
*
|
|
4
|
+
* extends {@link baseConfig }
|
|
5
|
+
*
|
|
6
|
+
* <-- TABLE OF CONTENTS -->
|
|
7
|
+
* - evaluateProperties
|
|
8
|
+
* - configureDotnetRelease
|
|
9
|
+
* - Insert-Edit Plugins
|
|
10
|
+
* - Append Plugins
|
|
11
|
+
*
|
|
12
|
+
*/
|
|
13
|
+
import type { Options } from 'semantic-release';
|
|
14
|
+
/**
|
|
15
|
+
* 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.
|
|
16
|
+
* Insert (`array.splice`) and/or configure plugins.\
|
|
17
|
+
* Can be used to...\
|
|
18
|
+
* ...load plugin A before plugin B\
|
|
19
|
+
* ...edit a plugin's existing configuration
|
|
20
|
+
*
|
|
21
|
+
* @param config An instance of {@link Options}
|
|
22
|
+
* @returns a modified copy of {@link config}
|
|
23
|
+
*/
|
|
24
|
+
export declare function insertAndEditPlugins(config: Options): Options;
|
|
25
|
+
export declare function appendPlugins(config: Options, projectsToPublish: string[], projectsToPackAndPush: string[]): Options;
|
|
26
|
+
/**
|
|
27
|
+
* @type {import("semantic-release").Options}
|
|
28
|
+
*/
|
|
29
|
+
export declare function getConfig(projectsToPublish: string[], projectsToPackAndPush: string[]): void;
|
|
30
|
+
//# sourceMappingURL=semanticReleaseConfigDotnet.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"semanticReleaseConfigDotnet.d.ts","sourceRoot":"","sources":["../src/semanticReleaseConfigDotnet.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAGH,OAAO,KAAK,EAAE,OAAO,EAAc,MAAM,kBAAkB,CAAC;AAK5D;;;;;;;;;GASG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,OAAO,GAAG,OAAO,CAQ7D;AAED,wBAAgB,aAAa,CAC5B,MAAM,EAAE,OAAO,EACf,iBAAiB,EAAE,MAAM,EAAE,EAC3B,qBAAqB,EAAE,MAAM,EAAE,WAkB/B;AAED;;GAEG;AACH,wBAAgB,SAAS,CAAC,iBAAiB,EAAE,MAAM,EAAE,EAAE,qBAAqB,EAAE,MAAM,EAAE,QAYrF"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const GitPluginId = '@semantic-release/git';
|
|
4
|
+
const DefaultOptions = {
|
|
5
|
+
assets: ['CHANGELOG.md', 'package.json', 'package-lock.json', 'npm-shrinkwrap.json'],
|
|
6
|
+
// eslint-disable-next-line no-template-curly-in-string
|
|
7
|
+
message: 'chore(release): ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}'
|
|
8
|
+
};
|
|
9
|
+
function gitAssetsToArray(assets) {
|
|
10
|
+
if (assets === undefined || assets === false) return [];
|
|
11
|
+
if (Array.isArray(assets)) return assets;
|
|
12
|
+
if (typeof assets === 'string') return [assets];
|
|
13
|
+
return assets.path === 'string' ? [assets.path] : [];
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* https://github.com/semantic-release/git#options
|
|
18
|
+
*
|
|
19
|
+
* This plugin may be deprecated at a later date.
|
|
20
|
+
* Why do you need to commit during release?
|
|
21
|
+
* If you don't need to update a changelog or version in a file, then you don't need this.
|
|
22
|
+
*
|
|
23
|
+
* @returns A {@link PluginSpec} array with {@link PluginSpec<GitOptions>}. If Git plugin not in original array, returns the original array.
|
|
24
|
+
* todo: deprecate for generic or parameterized function
|
|
25
|
+
*/
|
|
26
|
+
function setupGitPluginSpec(plugins) {
|
|
27
|
+
let newPlugins = plugins;
|
|
28
|
+
let gitPluginIndex = -1;
|
|
29
|
+
function pluginSpecIsGit(pluginSpec, pluginSpecIndex) {
|
|
30
|
+
if (pluginSpec === GitPluginId || pluginSpec[0] === GitPluginId) {
|
|
31
|
+
gitPluginIndex = pluginSpecIndex;
|
|
32
|
+
return true;
|
|
33
|
+
}
|
|
34
|
+
return false;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
// if Git plugin not in load order, return as-is.
|
|
38
|
+
if (!newPlugins.some(pluginSpecIsGit)) return plugins;
|
|
39
|
+
|
|
40
|
+
// if string, replace with tuple with default options.
|
|
41
|
+
newPlugins = newPlugins.map(plugin => plugin === GitPluginId ? [GitPluginId, DefaultOptions] : plugin);
|
|
42
|
+
|
|
43
|
+
// ensure assets is an array
|
|
44
|
+
newPlugins[gitPluginIndex][1].assets = gitAssetsToArray(newPlugins[gitPluginIndex][1].assets);
|
|
45
|
+
const discardPile = [];
|
|
46
|
+
|
|
47
|
+
// de-duplicate Git plugin entries; assign single entry to newPlugins[gitPluginIndex]
|
|
48
|
+
newPlugins.forEach((current, i) => {
|
|
49
|
+
if (i > gitPluginIndex && pluginSpecIsGit(current, gitPluginIndex)) {
|
|
50
|
+
// convert its assets to an array
|
|
51
|
+
const assets = newPlugins[i][1].assets;
|
|
52
|
+
const message = newPlugins[i][1].message;
|
|
53
|
+
// push unique assets to first entry's assets array
|
|
54
|
+
if (assets !== undefined) newPlugins[gitPluginIndex][1].assets.push(...gitAssetsToArray(assets));
|
|
55
|
+
if (message !== undefined) newPlugins[gitPluginIndex][1].message = message;
|
|
56
|
+
discardPile.push(i);
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
for (const i of discardPile.sort().reverse()) {
|
|
60
|
+
newPlugins.splice(i, 1);
|
|
61
|
+
}
|
|
62
|
+
return newPlugins;
|
|
63
|
+
}
|
|
64
|
+
exports.DefaultOptions = DefaultOptions;
|
|
65
|
+
exports.GitPluginId = GitPluginId;
|
|
66
|
+
exports.setupGitPluginSpec = setupGitPluginSpec;
|
|
67
|
+
//# sourceMappingURL=setupGitPluginSpec.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"setupGitPluginSpec.cjs","sources":["../src/setupGitPluginSpec.ts"],"sourcesContent":null,"names":[],"mappings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type { PluginSpec } from 'semantic-release';
|
|
2
|
+
export declare const GitPluginId = "@semantic-release/git";
|
|
3
|
+
export declare const DefaultOptions: {
|
|
4
|
+
assets: string[];
|
|
5
|
+
message: string;
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* https://github.com/semantic-release/git#options
|
|
9
|
+
*
|
|
10
|
+
* This plugin may be deprecated at a later date.
|
|
11
|
+
* Why do you need to commit during release?
|
|
12
|
+
* If you don't need to update a changelog or version in a file, then you don't need this.
|
|
13
|
+
*
|
|
14
|
+
* @returns A {@link PluginSpec} array with {@link PluginSpec<GitOptions>}. If Git plugin not in original array, returns the original array.
|
|
15
|
+
* todo: deprecate for generic or parameterized function
|
|
16
|
+
*/
|
|
17
|
+
export declare function setupGitPluginSpec(plugins: PluginSpec[]): PluginSpec[];
|
|
18
|
+
//# sourceMappingURL=setupGitPluginSpec.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"setupGitPluginSpec.d.ts","sourceRoot":"","sources":["../src/setupGitPluginSpec.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAGnD,eAAO,MAAM,WAAW,0BAA0B,CAAC;AACnD,eAAO,MAAM,cAAc;;;CAIL,CAAC;AASvB;;;;;;;;;GASG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,UAAU,EAAE,GAAG,UAAU,EAAE,CA+CtE"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
<!-- Provides sane defaults for CI builds -->
|
|
2
|
+
<Project>
|
|
3
|
+
<PropertyGroup Condition="'$(CI)' != '' AND '$(CI)' != 'Debug'">
|
|
4
|
+
<Configuration>Release</Configuration>
|
|
5
|
+
<ContinuousIntegrationBuild>true</ContinuousIntegrationBuild>
|
|
6
|
+
<Deterministic>true</Deterministic>
|
|
7
|
+
</PropertyGroup>
|
|
8
|
+
</Project>
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
<Project>
|
|
2
|
+
<PropertyGroup>
|
|
3
|
+
<HCESharedDir>$([System.IO.Path]::GetDirectoryName($(MSBuildThisFileDirectory)))</HCESharedDir>
|
|
4
|
+
<GitVersion_Path Condition="'$(GitVersion_Path)' == ''">$(MSBuildThisFileDirectory)GitVersion.yml</GitVersion_Path>
|
|
5
|
+
</PropertyGroup>
|
|
6
|
+
</Project>
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
Import all other .props and .targets in this directory
|
|
3
|
+
If you import this, you don't need to import anything else. -->
|
|
4
|
+
<Project Label="All HCE.Shared Properties and Targets">
|
|
5
|
+
<Import Project="./HCE.Shared.CI.props" />
|
|
6
|
+
<Import Project="./ZipPublishDir.targets" />
|
|
7
|
+
<!-- Must be explicitly targeted via 'dotnet project.csproj -t:PublishAll'. May lead to incompatibility errors -->
|
|
8
|
+
<Import Project="./PublishAll.targets" />
|
|
9
|
+
</Project>
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
<!-- `dotnet -t:PublishAll` will publish all permutations derived from TargetFrameworks and RuntimeIdentifiers
|
|
2
|
+
!Beware: No compatibility checks are performed!
|
|
3
|
+
netstandard2.0 + PublishSingleFile may cause errors! Weirdly, net480 + linux-x64 builds AND runs on both WSL and Windows...
|
|
4
|
+
|
|
5
|
+
Based on https://stackoverflow.com/a/43951971/14894786
|
|
6
|
+
Licensed under CC BY-SA 3.0
|
|
7
|
+
|
|
8
|
+
?Ask yourself "Do I *really* need multi-targeting?"
|
|
9
|
+
If you want to target netstandard2.0, then just do that. It's forward-compatible.
|
|
10
|
+
If you want that AND you want conditional access to .NET 5+ stuff, then multi-target.
|
|
11
|
+
If you want to target net462 and net6.0, then multi-target. But also ask yourself why you need to target net462.
|
|
12
|
+
|
|
13
|
+
Multi-runtimes?
|
|
14
|
+
Only useful if you need Self-Contained i.e. include the runtime with your project.
|
|
15
|
+
If you want to publish Single-File, you don't *need* Self-Contained. Just inform users they must install a particular runtime/framework beforehand.
|
|
16
|
+
-->
|
|
17
|
+
<Project>
|
|
18
|
+
|
|
19
|
+
<Target Name="_PublishProjectIfFrameworkSetAndNotMultiRuntime"
|
|
20
|
+
DependsOnTargets="Publish"
|
|
21
|
+
Condition="'$(RuntimeIdentifiers)' == '' And '$(TargetFramework)' != '' " />
|
|
22
|
+
|
|
23
|
+
<Target Name="_PublishProjectForAllFrameworksAndRuntimes"
|
|
24
|
+
Condition=" '$(TargetFramework)' == '' And '$(RuntimeIdentifiers)' != '' ">
|
|
25
|
+
<ItemGroup>
|
|
26
|
+
<_PublishFramework Include="$(TargetFrameworks)" />
|
|
27
|
+
<_PublishRuntime Include="$(RuntimeIdentifiers)" />
|
|
28
|
+
</ItemGroup>
|
|
29
|
+
|
|
30
|
+
<MSBuild Projects="$(MSBuildProjectFile)" Targets="Publish" Properties="TargetFramework=%(_PublishFramework.Identity);RuntimeIdentifier=%(_PublishRuntime.Identity)" />
|
|
31
|
+
</Target>
|
|
32
|
+
|
|
33
|
+
<Target Name="_PublishProjectForAllFrameworksIfFrameworkUnset"
|
|
34
|
+
Condition=" '$(TargetFramework)' == '' And '$(RuntimeIdentifiers)' == '' ">
|
|
35
|
+
<ItemGroup>
|
|
36
|
+
<_PublishFramework Include="$(TargetFrameworks)" />
|
|
37
|
+
</ItemGroup>
|
|
38
|
+
<MSBuild Projects="$(MSBuildProjectFile)" Targets="Publish" Properties="TargetFramework=%(_PublishFramework.Identity)" />
|
|
39
|
+
</Target>
|
|
40
|
+
|
|
41
|
+
<Target Name="PublishAll"
|
|
42
|
+
DependsOnTargets="_PublishProjectIfFrameworkSetAndNotMultiRuntime;_PublishProjectIfFrameworkSetAndNotMultiRuntime;_PublishProjectForAllFrameworksIfFrameworkUnset" />
|
|
43
|
+
</Project>
|
|
@@ -1,12 +1,23 @@
|
|
|
1
1
|
<Project>
|
|
2
|
+
<PropertyGroup>
|
|
3
|
+
<RepoRoot Condition="'$(RepoRoot)' == '' And '$(ProjectRootDir)' != ''">$(ProjectRootDir)</RepoRoot>
|
|
4
|
+
<RepoRoot Condition="'$(RepoRoot)' == ''">$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), '.git/index'))</RepoRoot>
|
|
5
|
+
<RepoRootPublishDir>$(RepoRoot)/publish</RepoRootPublishDir>
|
|
6
|
+
<PackageOutputPath Condition="'$(PackageOutputPath)' == ''">$(RepoRootPublishDir)</PackageOutputPath>
|
|
7
|
+
</PropertyGroup>
|
|
8
|
+
|
|
9
|
+
<PropertyGroup Condition="'$(CI)' != ''">
|
|
10
|
+
<Deterministic>true</Deterministic>
|
|
11
|
+
<ContinuousIntegrationBuild>true</ContinuousIntegrationBuild>
|
|
12
|
+
<Configuration>Release</Configuration>
|
|
13
|
+
</PropertyGroup>
|
|
14
|
+
|
|
2
15
|
<Target Name="ZipPublishDir" AfterTargets="Publish"
|
|
3
16
|
Outputs="$(DestinationFile)">
|
|
4
17
|
<PropertyGroup>
|
|
5
|
-
<!--
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
<!-- Optional Parameters
|
|
18
|
+
<!-- inputs
|
|
19
|
+
- RepoRoot
|
|
20
|
+
- RepoRootPublishDir
|
|
10
21
|
- AssemblyName
|
|
11
22
|
- Version
|
|
12
23
|
- VariantArgs (default: Configuration;TargetFramework;RuntimeIdentifier)
|
|
@@ -17,8 +28,8 @@
|
|
|
17
28
|
<AppendVariantArgs Condition="'$(AppendVariantArgs)' == ''">true</AppendVariantArgs>
|
|
18
29
|
|
|
19
30
|
<appendVarArgs>$(AppendVariantArgs)</appendVarArgs>
|
|
20
|
-
<
|
|
21
|
-
|
|
31
|
+
<RepoRootPublishDir>$(RepoRoot)/publish</RepoRootPublishDir>
|
|
32
|
+
|
|
22
33
|
<!-- Only add Configuration when Debug -->
|
|
23
34
|
<dbgCfg Condition="'$(Configuration)' == 'Debug'">$(Configuration)</dbgCfg>
|
|
24
35
|
<!-- "net6.0 win7-x86"
|
|
@@ -33,11 +44,11 @@
|
|
|
33
44
|
"" -->
|
|
34
45
|
<version Condition="'$(Version)' != ''"> $(Version)</version>
|
|
35
46
|
<!-- "C:\Repos\HaloSPV3\HXE\publish\HXE 1.2.3-preview.4 (net6.0 win7-x86).zip" -->
|
|
36
|
-
<DestinationFile>$(
|
|
47
|
+
<DestinationFile>$(RepoRootPublishDir)/$(AssemblyName)$(version)$(enclosedVArgs).zip</DestinationFile>
|
|
37
48
|
<!-- todo: look into .NET 8 SDK's Artifacts feature -->
|
|
38
49
|
</PropertyGroup>
|
|
39
50
|
|
|
40
|
-
<MakeDir Condition="!Exists('$(
|
|
51
|
+
<MakeDir Condition="!Exists('$(RepoRootPublishDir)')" Directories="$(RepoRootPublishDir)"/>
|
|
41
52
|
<ZipDirectory
|
|
42
53
|
SourceDirectory="$(PublishDir)"
|
|
43
54
|
DestinationFile="$(DestinationFile)"
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
# input: SLN_OR_PROJ_FILES
|
|
2
|
+
# Comma-separated. May be relative or absolute.
|
|
3
|
+
|
|
4
|
+
[System.IO.FileInfo[]]$solutions += ($env:SLN_OR_PROJ_FILES -split ';' | ForEach-Object { if ($_.Length -gt 0) { Get-Item $_ } });
|
|
5
|
+
if ($args.Count -gt 0) {
|
|
6
|
+
$args | ForEach-Object {
|
|
7
|
+
$solutions += ($_ -split ';' | ForEach-Object { Get-Item $_ })
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
$excludedDirs = '.git', 'bin', 'node_modules', 'obj', 'publish';
|
|
12
|
+
$slnExts = '.sln', '.slnf', '.slnx';
|
|
13
|
+
|
|
14
|
+
function RecursivelySearchForSolutions {
|
|
15
|
+
$result;
|
|
16
|
+
|
|
17
|
+
# get solutions (*.sln, *.slnf, *.slnx, etc) -in $rootItems
|
|
18
|
+
$solutions += (Get-ChildItem -File |
|
|
19
|
+
Where-Object { $_.Extension.ToLowerInvariant() -in $slnExts } |
|
|
20
|
+
Sort-Object |
|
|
21
|
+
Get-Unique
|
|
22
|
+
);
|
|
23
|
+
|
|
24
|
+
# also check in sub-directories
|
|
25
|
+
$subdirs = Get-ChildItem -Path $rootDir -Directory;
|
|
26
|
+
for ($i = 0; $i -lt $subdirs.Count; $i++) {
|
|
27
|
+
if (-not ($subdirs[$i].Name -in $excludedDirs)) {
|
|
28
|
+
$subdirs += (
|
|
29
|
+
Get-ChildItem -Path $curDir -Directory |
|
|
30
|
+
Where-Object { -not ($_.Name -in $excludedDirs) }
|
|
31
|
+
);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
$solutions += (
|
|
35
|
+
$subdirs |
|
|
36
|
+
ForEach-Object {
|
|
37
|
+
Get-ChildItem -Path $_ -File |
|
|
38
|
+
Where-Object {
|
|
39
|
+
$_.Extension.ToLowerInvariant() -in $slnExts
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
# search for solutions files
|
|
46
|
+
if ($solutions.Count -eq 0) {
|
|
47
|
+
RecursivelySearchForSolutions
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
# search for project files
|
|
51
|
+
if ($solutions.Count -eq 0 ) {
|
|
52
|
+
$slnExts += ('.csproj', '.fsproj', '.proj');
|
|
53
|
+
RecursivelySearchForSolutions
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
if ($solutions.Count -eq 0) {
|
|
57
|
+
throw [System.IO.FileNotFoundException]::new('No Solution files (.sln, .slnf, .slnx) or Project files (.csproj, .fsproj, .proj) could be found!')
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
# solutions/projects are build sequentially. Debug is built, then Release is build.
|
|
61
|
+
$solutions | ForEach-Object {
|
|
62
|
+
($_, 'Debug'), ($_, 'Release') |
|
|
63
|
+
ForEach-Object {
|
|
64
|
+
Set-Location $_[0].Directory
|
|
65
|
+
dotnet build ($_[0].FullName) --configuration $_[1]
|
|
66
|
+
}
|
|
67
|
+
}
|
package/package.json
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@halospv3/hce.shared-config",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.3.0",
|
|
4
4
|
"description": "Automate commit message quality, changelogs, and CI/CD releases. Exports a semantic-release shareable configuration deserialized from this package's '.releaserc.yml'. Shared resources for .NET projects are also distributed with this package.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"halo",
|
|
7
7
|
"halo-ce",
|
|
8
8
|
"semantic-release",
|
|
9
|
-
"semantic-release-config"
|
|
9
|
+
"semantic-release-config",
|
|
10
|
+
"commitlint",
|
|
11
|
+
"commitlint-config"
|
|
10
12
|
],
|
|
11
13
|
"type": "module",
|
|
12
14
|
"homepage": "https://github.com/halospv3/hce.shared#readme",
|
|
@@ -14,12 +16,15 @@
|
|
|
14
16
|
"license": "MIT",
|
|
15
17
|
"author": "Noah Sherwin",
|
|
16
18
|
"files": [
|
|
19
|
+
"!.github/",
|
|
20
|
+
"!.husky/",
|
|
21
|
+
"!.vscode/",
|
|
22
|
+
"!_tsout/",
|
|
17
23
|
"!tests/",
|
|
18
24
|
"CHANGELOG.md",
|
|
19
25
|
"cjs/**/*",
|
|
20
|
-
"
|
|
21
|
-
"
|
|
22
|
-
"dotnet/",
|
|
26
|
+
"dotnet/**/*",
|
|
27
|
+
"mjs/**/*",
|
|
23
28
|
"src/**/*",
|
|
24
29
|
"static/**/*"
|
|
25
30
|
],
|
|
@@ -27,66 +32,75 @@
|
|
|
27
32
|
"infra": "polyrepo",
|
|
28
33
|
"repository": "github:halospv3/hce.shared",
|
|
29
34
|
"scripts": {
|
|
30
|
-
"build": "packemon build",
|
|
35
|
+
"build": "packemon build --addExports --addFiles --declaration --loadConfigs",
|
|
31
36
|
"check": "npm run type && npm run test && npm run lint",
|
|
32
37
|
"clean": "packemon clean",
|
|
33
38
|
"coverage": "npm run test --coverage",
|
|
34
|
-
"format": "prettier --write
|
|
35
|
-
"lint": "eslint --cache --fix
|
|
36
|
-
"
|
|
39
|
+
"format": "prettier --write",
|
|
40
|
+
"lint": "eslint --cache --fix .",
|
|
41
|
+
"eslint-inspector": "eslint --inspect-config",
|
|
42
|
+
"pack": "packemon pack --addExports --addFiles --declaration --loadConfigs && npm run validate",
|
|
37
43
|
"prepare": "husky",
|
|
38
44
|
"presemantic-release": "npm run pack && npm run check",
|
|
39
45
|
"semantic-release": "npx semantic-release",
|
|
40
|
-
"test": "
|
|
41
|
-
"type": "tsc",
|
|
46
|
+
"test": "node --test --import tsx ./tests/**/*.test.ts",
|
|
47
|
+
"type": "tsc --build",
|
|
42
48
|
"validate": "packemon validate",
|
|
43
49
|
"watch": "packemon watch"
|
|
44
50
|
},
|
|
45
51
|
"dependencies": {
|
|
46
|
-
"@commitlint/cli": "^19.
|
|
47
|
-
"@commitlint/config-conventional": "^19.
|
|
52
|
+
"@commitlint/cli": "^19.3.0",
|
|
53
|
+
"@commitlint/config-conventional": "^19.2.2",
|
|
48
54
|
"@commitlint/types": "^19.0.3",
|
|
55
|
+
"@eslint/js": "^9.3.0",
|
|
56
|
+
"@octokit/request": "^9.1.0",
|
|
49
57
|
"@semantic-release/changelog": "^6.0.3",
|
|
50
58
|
"@semantic-release/commit-analyzer": "^12.0.0",
|
|
51
59
|
"@semantic-release/exec": "^6.0.3",
|
|
52
60
|
"@semantic-release/git": "^10.0.1",
|
|
53
|
-
"@semantic-release/github": "^10.0.
|
|
61
|
+
"@semantic-release/github": "^10.0.4",
|
|
54
62
|
"@semantic-release/npm": "^12.0.0",
|
|
55
63
|
"@semantic-release/release-notes-generator": "^13.0.0",
|
|
56
|
-
"
|
|
64
|
+
"@stylistic/eslint-plugin": "^2.1.0",
|
|
65
|
+
"@types/eslint__js": "^8.42.3",
|
|
66
|
+
"@types/js-yaml": "^4.0.9",
|
|
67
|
+
"@types/node": "^20.12.12",
|
|
68
|
+
"@types/semantic-release": "^20.0.6",
|
|
69
|
+
"@typescript-eslint/eslint-plugin": "^7.10.0",
|
|
70
|
+
"@typescript-eslint/parser": "^7.10.0",
|
|
71
|
+
"conventional-changelog-conventionalcommits": "^8.0.0",
|
|
72
|
+
"eslint-plugin-jsonc": "^2.15.1",
|
|
73
|
+
"globals": "^15.3.0",
|
|
57
74
|
"husky": "^9.0.11",
|
|
58
75
|
"js-yaml": "^4.1.0",
|
|
59
76
|
"node-fetch": "^3.3.2",
|
|
60
|
-
"semantic-release": "^23.
|
|
61
|
-
"semantic-release-export-data": "^1.0.1"
|
|
77
|
+
"semantic-release": "^23.1.1",
|
|
78
|
+
"semantic-release-export-data": "^1.0.1",
|
|
79
|
+
"typescript-eslint": "^7.10.0"
|
|
62
80
|
},
|
|
63
81
|
"devDependencies": {
|
|
64
|
-
"@babel/cli": "^7.
|
|
65
|
-
"@
|
|
82
|
+
"@babel/cli": "^7.24.5",
|
|
83
|
+
"@babel/core": "^7.24.5",
|
|
84
|
+
"@babel/eslint-parser": "^7.24.5",
|
|
85
|
+
"@eslint/eslintrc": "^3.1.0",
|
|
66
86
|
"@tsconfig/node-lts": "^20.1.2",
|
|
87
|
+
"@types/babel__core": "^7.20.5",
|
|
67
88
|
"@types/debug": "^4.1.12",
|
|
68
|
-
"@types/
|
|
69
|
-
"
|
|
70
|
-
"@types/semantic-release": "^20.0.6",
|
|
71
|
-
"@typescript-eslint/eslint-plugin": "^7.2.0",
|
|
72
|
-
"@typescript-eslint/parser": "^7.2.0",
|
|
73
|
-
"ajv": "^8.12.0",
|
|
89
|
+
"@types/eslint__eslintrc": "^2.1.1",
|
|
90
|
+
"ajv": "^8.13.0",
|
|
74
91
|
"ajv-draft-04": "^1.0.0",
|
|
75
92
|
"babel-plugin-cjs-esm-interop": "^4.0.0",
|
|
76
93
|
"eslint": "^8.57.0",
|
|
77
|
-
"eslint-config-moon": "^3.0.0",
|
|
78
|
-
"eslint-plugin-disable": "^2.0.3",
|
|
79
94
|
"node-fetch": "^3.3.2",
|
|
80
95
|
"packemon": "^4.0.1",
|
|
81
96
|
"prettier": "^3.2.5",
|
|
82
97
|
"prettier-config-moon": "^1.1.2",
|
|
83
|
-
"tsconfig-moon": "^1.3.0",
|
|
84
98
|
"tslib": "^2.6.2",
|
|
85
|
-
"tsx": "^4.
|
|
86
|
-
"typescript": "^5.4.
|
|
99
|
+
"tsx": "^4.10.5",
|
|
100
|
+
"typescript": "^5.4.5"
|
|
87
101
|
},
|
|
88
102
|
"engines": {
|
|
89
|
-
"node": ">=
|
|
103
|
+
"node": ">=20.8.1",
|
|
90
104
|
"npm": ">=10.5.0"
|
|
91
105
|
},
|
|
92
106
|
"engineStrict": true,
|
|
@@ -94,19 +108,36 @@
|
|
|
94
108
|
"tag": "latest"
|
|
95
109
|
},
|
|
96
110
|
"exports": {
|
|
97
|
-
".":
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
111
|
+
"./package.json": "./package.json",
|
|
112
|
+
"./*": {
|
|
113
|
+
"types": "./cjs/*.d.ts",
|
|
114
|
+
"default": "./cjs/*.cjs"
|
|
115
|
+
},
|
|
116
|
+
"./dotnet/*": {
|
|
117
|
+
"types": "./cjs/dotnet/*.d.ts",
|
|
118
|
+
"default": "./cjs/dotnet/*.cjs"
|
|
103
119
|
},
|
|
104
|
-
"
|
|
105
|
-
|
|
120
|
+
".": {
|
|
121
|
+
"types": "./cjs/index.d.ts",
|
|
122
|
+
"import": "./cjs/index-wrapper.mjs",
|
|
123
|
+
"default": "./cjs/index.cjs"
|
|
124
|
+
}
|
|
106
125
|
},
|
|
107
126
|
"types": "./cjs/index.d.ts",
|
|
108
127
|
"packemon": {
|
|
109
|
-
"format":
|
|
110
|
-
|
|
128
|
+
"format": [
|
|
129
|
+
"cjs"
|
|
130
|
+
],
|
|
131
|
+
"platform": "node",
|
|
132
|
+
"inputs": {
|
|
133
|
+
"commitlintConfig": "src/commitlintConfig.ts",
|
|
134
|
+
"dotnet": "src/dotnet.ts",
|
|
135
|
+
"eslintConfig": "src/eslintConfig.ts",
|
|
136
|
+
"findStaticConfig": "src/findStaticConfig.ts",
|
|
137
|
+
"index": "src/index.ts",
|
|
138
|
+
"semanticReleaseConfig": "src/semanticReleaseConfig.ts",
|
|
139
|
+
"semanticReleaseConfigDotnet": "src/semanticReleaseConfigDotnet.ts",
|
|
140
|
+
"setupGitPluginSpec": "src/setupGitPluginSpec.ts"
|
|
141
|
+
}
|
|
111
142
|
}
|
|
112
143
|
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { type RuleConfigSeverity, type UserConfig } from '@commitlint/types';
|
|
2
|
+
|
|
3
|
+
// CJS compatibility; This enum cannot be required.
|
|
4
|
+
const disabled = 0 as RuleConfigSeverity.Disabled;
|
|
5
|
+
const commitlintConfig: UserConfig = {
|
|
6
|
+
extends: ['@commitlint/config-conventional'],
|
|
7
|
+
rules: {
|
|
8
|
+
'body-max-line-length': [disabled],
|
|
9
|
+
'footer-max-line-length': [disabled],
|
|
10
|
+
'header-max-length': [disabled],
|
|
11
|
+
},
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
// only `default` export is loaded via `extends` config key!
|
|
15
|
+
export default commitlintConfig;
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { execFileSync } from 'node:child_process';
|
|
2
|
+
import { MSBuildProjectProperties } from './MSBuildProjectProperties.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* All pre-defined properties of {@link MSBuildProjectProperties} except FullPath
|
|
6
|
+
*/
|
|
7
|
+
export const MSBuildProjectPreDefinedProperties = Object.keys(
|
|
8
|
+
new MSBuildProjectProperties('', false),
|
|
9
|
+
).filter((p) => p !== 'FullPath');
|
|
10
|
+
/** @todo Experimental and may be removed in a later release.
|
|
11
|
+
* A cache for your evaluated MSBuild Projects.
|
|
12
|
+
*/
|
|
13
|
+
export const MSBuildEvaluatedProjects: MSBuildProject[] = [];
|
|
14
|
+
|
|
15
|
+
export class MSBuildProject {
|
|
16
|
+
Properties: MSBuildProjectProperties;
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
*
|
|
20
|
+
* @param fullPath The full path of the .NET MSBuild project file.
|
|
21
|
+
* @param customProperties MSBuild properties to evaluate in addition to those pre-defined in {@link MSBuildProjectProperties}
|
|
22
|
+
*/
|
|
23
|
+
constructor(fullPath: string, customProperties?: string[]) {
|
|
24
|
+
// super();
|
|
25
|
+
this.Properties = MSBuildProject.evaluateProperties(fullPath, customProperties ?? []);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
*
|
|
30
|
+
* `dotnet msbuild src -getProperty:TargetFramework -getProperty:TargetFrameworks -getProperty:RuntimeIdentifiers -getProperty:IsTrimmable`
|
|
31
|
+
*
|
|
32
|
+
* ...produces...
|
|
33
|
+
*
|
|
34
|
+
* ```json
|
|
35
|
+
* {
|
|
36
|
+
* "Properties": {
|
|
37
|
+
* "TargetFramework": "net6.0",
|
|
38
|
+
* "TargetFrameworks": "",
|
|
39
|
+
* "RuntimeIdentifiers": "win7-x64;win7-x86;win-arm64;linux-x64;linux-arm64",
|
|
40
|
+
* "IsTrimmable": "true",
|
|
41
|
+
* }
|
|
42
|
+
* }
|
|
43
|
+
* ```
|
|
44
|
+
*
|
|
45
|
+
* ...which can can be parsed like...
|
|
46
|
+
* ```js
|
|
47
|
+
* var ridArray = JSON.parse(out).Properties.RuntimeIdentifiers.split(';');
|
|
48
|
+
* ```
|
|
49
|
+
*/
|
|
50
|
+
static evaluateProperties(fullPath: string, properties: string[]): MSBuildProjectProperties {
|
|
51
|
+
const evaluatedProps: MSBuildProjectProperties = new MSBuildProjectProperties(fullPath);
|
|
52
|
+
|
|
53
|
+
// if a default prop isn't in properties, add it
|
|
54
|
+
const defaultProps = MSBuildProjectPreDefinedProperties;
|
|
55
|
+
for (const defaultProp of defaultProps) {
|
|
56
|
+
if (!properties.includes(defaultProp)) properties.push(defaultProp);
|
|
57
|
+
}
|
|
58
|
+
const getPropArgs: string[] = properties.map((propName) => `-getProperty:${propName}`);
|
|
59
|
+
// should return a single value OR string-encoded JSON object with 'Properties' object-type property.
|
|
60
|
+
const out = execFileSync('dotnet', ['msbuild', evaluatedProps.FullPath, ...getPropArgs], {
|
|
61
|
+
encoding: 'utf8',
|
|
62
|
+
stdio: 'pipe',
|
|
63
|
+
}).trim();
|
|
64
|
+
if (out.startsWith('MSBUILD : error'))
|
|
65
|
+
throw new Error(out);
|
|
66
|
+
|
|
67
|
+
let props: Record<string, string>;
|
|
68
|
+
if (out.startsWith('{')) {
|
|
69
|
+
const obj = JSON.parse(out) as object;
|
|
70
|
+
if ("Properties" in obj && typeof obj.Properties === 'object' && obj.Properties !== null)
|
|
71
|
+
props = obj.Properties as Record<string, string>;
|
|
72
|
+
throw new Error('When evaluating properties with MSBuild, "Properties" could not be found in the deserialized JSON object.')
|
|
73
|
+
}
|
|
74
|
+
else {
|
|
75
|
+
props = { [properties[0]]: out.trim() }
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
return {
|
|
79
|
+
...evaluatedProps,
|
|
80
|
+
...props,
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { existsSync } from 'node:fs';
|
|
2
|
+
import { basename, isAbsolute, resolve } from 'node:path';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Known properties. Additional properties may be added upon request.
|
|
6
|
+
*/
|
|
7
|
+
export class MSBuildProjectProperties {
|
|
8
|
+
[Property: string]: string;
|
|
9
|
+
|
|
10
|
+
FullPath = '';
|
|
11
|
+
|
|
12
|
+
TargetFramework = '';
|
|
13
|
+
|
|
14
|
+
TargetFrameworks = '';
|
|
15
|
+
|
|
16
|
+
RuntimeIdentifier = '';
|
|
17
|
+
|
|
18
|
+
RuntimeIdentifiers = '';
|
|
19
|
+
|
|
20
|
+
constructor(fullPath: string, exists = true) {
|
|
21
|
+
this.FullPath = fullPath;
|
|
22
|
+
if (!isAbsolute(this.FullPath)) this.FullPath = resolve(this.FullPath);
|
|
23
|
+
if (!existsSync(this.FullPath) && exists)
|
|
24
|
+
throw new Error(
|
|
25
|
+
`Project ${basename(this.FullPath)} could not be found at "${this.FullPath}"`,
|
|
26
|
+
);
|
|
27
|
+
}
|
|
28
|
+
}
|