Skip to content

Commit c0ecffb

Browse files
committed
refactor(pipelines)!: deprecate pipelines scaffolding
closes criticalmanufacturing#268 criticalmanufacturing#288
1 parent 35f76dc commit c0ecffb

File tree

78 files changed

+382
-6643
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

78 files changed

+382
-6643
lines changed

cmf-cli/Commands/init/InitCommand.cs

+12-184
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
using Cmf.CLI.Constants;
77
using Cmf.CLI.Core.Attributes;
88
using Cmf.CLI.Core.Commands;
9+
using Cmf.CLI.Core.Constants;
910
using Cmf.CLI.Core.Enums;
1011
using Cmf.CLI.Core.Objects;
1112
using Cmf.CLI.Utilities;
@@ -27,7 +28,6 @@ internal class InitArguments
2728
public string version { get; set; }
2829
public IFileInfo config { get; set; }
2930
public IDirectoryInfo deploymentDir { get; set; }
30-
public Uri repositoryUrl { get; set; }
3131
public string BaseVersion { get; set; }
3232
public string DevTasksVersion { get; set; }
3333
public string HTMLStarterVersion { get; set; }
@@ -38,20 +38,9 @@ internal class InitArguments
3838
public IFileInfo infrastructure { get; set; }
3939
public Uri nugetRegistry { get; set; }
4040
public Uri npmRegistry { get; set; }
41-
public Uri azureDevOpsCollectionUrl { get; set; }
42-
public string agentPool { get; set; }
43-
public AgentType? agentType { get; set; }
4441
public IFileInfo ISOLocation { get; set; }
4542
public string nugetRegistryUsername { get; set; }
4643
public string nugetRegistryPassword { get; set; }
47-
public string cmfPipelineRepository { get; set; }
48-
public string cmfCliRepository { get; set; }
49-
public string pipelinesFolder { get; set; }
50-
public string releaseCustomerEnvironment { get; set; }
51-
public string releaseSite { get; set; }
52-
public string releaseDeploymentPackage { get; set; }
53-
public string releaseLicense { get; set; }
54-
public string releaseDeploymentTarget { get; set; }
5544
public RepositoryType repositoryType { get; set; }
5645
// ReSharper restore UnusedAutoPropertyAccessor.Global
5746
// ReSharper restore InconsistentNaming
@@ -117,10 +106,6 @@ public override void Configure(Command cmd)
117106
{ IsRequired = true });
118107

119108
// template-time options. These are all mandatory
120-
cmd.AddOption(new Option<Uri>(
121-
aliases: new[] { "--repositoryUrl" },
122-
description: "Git repository URL"
123-
) { IsRequired = true });
124109
cmd.AddOption(new Option<IDirectoryInfo>(
125110
aliases: new[] { "--deploymentDir" },
126111
parseArgument: argResult => Parse<IDirectoryInfo>(argResult),
@@ -171,18 +156,7 @@ public override void Configure(Command cmd)
171156
aliases: new[] { "--npmRegistry" },
172157
description: "NPM registry that contains the MES packages"
173158
));
174-
cmd.AddOption(new Option<Uri>(
175-
aliases: new[] { "--azureDevOpsCollectionUrl" },
176-
description: "The Azure DevOps collection address"
177-
));
178-
cmd.AddOption(new Option<string>(
179-
aliases: new[] { "--agentPool" },
180-
description: "Azure DevOps agent pool"
181-
));
182-
cmd.AddOption(new Option<AgentType>(
183-
aliases: new[] { "--agentType" },
184-
description: "Type of Azure DevOps agents: Cloud or Hosted"
185-
));
159+
186160
cmd.AddOption(new Option<IFileInfo>(
187161
aliases: new[] { "--ISOLocation" },
188162
parseArgument: argResult => Parse<IFileInfo>(argResult),
@@ -197,68 +171,13 @@ public override void Configure(Command cmd)
197171
aliases: new[] { "--nugetRegistryPassword" },
198172
description: "NuGet registry password"
199173
));
200-
cmd.AddOption(new Option<Uri>(
201-
aliases: new[] { "--cmfCliRepository" },
202-
description: "NPM registry that contains the CLI",
203-
getDefaultValue: () => new Uri(CliConstants.NpmJsUrl, UriKind.Absolute)
204-
));
205-
cmd.AddOption(new Option<Uri>(
206-
aliases: new[] { "--cmfPipelineRepository" },
207-
description: "NPM registry that contains the CLI Pipeline Plugin"
208-
));
209-
cmd.AddOption(new Option<string>(
210-
aliases: new[] { "--pipelinesFolder" },
211-
getDefaultValue: () => "",
212-
description: "Folder where we should put the pipelines in. Empty means the root folder"
213-
));
214-
215-
// container-specific switches
216-
cmd.AddOption(new Option<string>(
217-
aliases: new[] { "--releaseCustomerEnvironment" },
218-
description: "Customer Environment Name defined in DevOpsCenter"
219-
));
220-
cmd.AddOption(new Option<string>(
221-
aliases: new[] { "--releaseSite" },
222-
description: "Site defined in DevOpsCenter"
223-
));
224-
cmd.AddOption(new Option<string>(
225-
aliases: new[] { "--releaseDeploymentPackage" },
226-
description: "DeploymentPackage defined in DevOpsCenter"
227-
));
228-
cmd.AddOption(new Option<string>(
229-
aliases: new[] { "--releaseLicense" },
230-
description: "License defined in DevOpsCenter"
231-
));
232-
cmd.AddOption(new Option<string>(
233-
aliases: new[] { "--releaseDeploymentTarget" },
234-
description: "DeploymentTarget defined in DevOpsCenter"
235-
));
236-
174+
237175
// Add the handler
238176
cmd.Handler = CommandHandler
239177
.Create((InitArguments args) =>
240178
{
241179
this.Execute(args);
242180
});
243-
// no overload accepts these many arguments...
244-
// .Create<
245-
// IDirectoryInfo, // workingDir
246-
// string, // rootPackageName,
247-
// IFileInfo, // config
248-
// IDirectoryInfo, // deploymentDir
249-
// string, // MESVersion
250-
// string, // DevTasksVersion
251-
// string, // HTMLStarterVersion
252-
// string, // yoGeneratorVersion
253-
// string, // nugetVersion
254-
// string, // testScenariosNugetVersion
255-
// IFileInfo, // infrastructure
256-
// Uri, // nugetRegistry
257-
// Uri, // npmRegistry
258-
// Uri, // universalRegistry
259-
// string, // agentPool
260-
// AgentType? // agentType
261-
// >(this.Execute);
262181
}
263182

264183
/// <summary>
@@ -287,29 +206,9 @@ internal void Execute(InitArguments x)
287206
if (x.deploymentDir != null)
288207
{
289208
args.AddRange(new [] {"--deploymentDir", x.deploymentDir.FullName});
290-
// repositories are sub-folders of deploymentDir
291-
args.AddRange(new [] {"--CIRepo", $"{x.deploymentDir.FullName}\\CIPackages"});
292-
args.AddRange(new [] {"--ADArtifactsRepo", $"{x.deploymentDir.FullName}\\ADArtifacts"});
293-
args.AddRange(new [] {"--RCRepo", $"{x.deploymentDir.FullName}\\ReleaseCandidates"});
294209
args.AddRange(new [] {"--DeliveredRepo", $"{x.deploymentDir.FullName}\\Delivered"});
210+
args.AddRange(new[] { "--CIRepo", $"{x.deploymentDir.FullName}\\CIPackages" });
295211
}
296-
297-
var repoName = x.projectName;
298-
if (x.repositoryUrl != null)
299-
{
300-
args.AddRange(new [] {"--repositoryUrl", x.repositoryUrl.AbsoluteUri});
301-
var match = CliConstants.RepoRegex.Match(x.repositoryUrl.AbsoluteUri);
302-
if ((match?.Success ?? false) && match.Groups.ContainsKey("repo"))
303-
{
304-
repoName = match.Groups["repo"].Value;
305-
}
306-
}
307-
308-
if (repoName != null)
309-
{
310-
args.AddRange(new [] {"--repositoryName", repoName});
311-
}
312-
313212
if (x.BaseVersion != null)
314213
{
315214
args.AddRange(new [] {"--MESVersion", x.BaseVersion});
@@ -329,16 +228,6 @@ internal void Execute(InitArguments x)
329228
args.AddRange(new [] {"--testScenariosNugetVersion", x.testScenariosNugetVersion});
330229
}
331230

332-
if (!string.IsNullOrWhiteSpace(x.pipelinesFolder))
333-
{
334-
var folder = x.pipelinesFolder.Replace("/", "\\");
335-
if (!folder.StartsWith("\\"))
336-
{
337-
folder = "\\" + folder;
338-
}
339-
args.AddRange(new []{"--pipelinesFolder", folder});
340-
}
341-
342231
#region infrastructure
343232

344233
if (x.infrastructure != null)
@@ -349,12 +238,6 @@ internal void Execute(InitArguments x)
349238
{
350239
x.nugetRegistry ??= GenericUtilities.JsonObjectToUri(infraJson["NuGetRegistry"]);
351240
x.npmRegistry ??= GenericUtilities.JsonObjectToUri(infraJson["NPMRegistry"]);
352-
x.azureDevOpsCollectionUrl ??= GenericUtilities.JsonObjectToUri(infraJson["AzureDevopsCollectionURL"]);
353-
x.agentPool ??= infraJson["AgentPool"]?.Value;
354-
if (Enum.TryParse<AgentType>(infraJson["AgentType"]?.Value, out AgentType agentTypeParsed))
355-
{
356-
x.agentType ??= agentTypeParsed;
357-
}
358241
if (!string.IsNullOrEmpty(infraJson["NuGetRegistryUsername"]?.Value))
359242
{
360243
x.nugetRegistryUsername ??= infraJson["NuGetRegistryUsername"]?.Value;
@@ -363,22 +246,16 @@ internal void Execute(InitArguments x)
363246
{
364247
x.nugetRegistryPassword ??= infraJson["NuGetRegistryPassword"]?.Value;
365248
}
366-
if(!string.IsNullOrEmpty(infraJson["CmfCliRepository"]?.Value))
367-
{
368-
x.cmfCliRepository ??= infraJson["CmfCliRepository"]?.Value;
369-
}
370-
if (!string.IsNullOrEmpty(infraJson["CmfPipelineRepository"]?.Value))
371-
{
372-
x.cmfPipelineRepository ??= infraJson["CmfPipelineRepository"]?.Value;
373-
}
374-
}
375249
}
250+
}
376251

377252
if (x.nugetRegistry == null ||
378253
x.npmRegistry == null ||
379-
x.azureDevOpsCollectionUrl == null ||
380-
x.ISOLocation == null ||
381-
x.agentPool == null)
254+
//x.azureDevOpsCollectionUrl == null ||
255+
x.ISOLocation == null
256+
//||
257+
//x.agentPool == null
258+
)
382259
{
383260
throw new CliException("Missing infrastructure options. Either specify an infrastructure file with [--infrastructure] or specify each infrastructure option separately.");
384261
}
@@ -391,10 +268,6 @@ internal void Execute(InitArguments x)
391268
{
392269
args.AddRange(new [] {"--npmRegistry", x.npmRegistry.AbsoluteUri});
393270
}
394-
if (x.azureDevOpsCollectionUrl != null)
395-
{
396-
args.AddRange(new [] {"--azureDevOpsCollectionUrl", x.azureDevOpsCollectionUrl.AbsoluteUri});
397-
}
398271
if (x.ISOLocation != null)
399272
{
400273
args.AddRange(new [] {"--ISOLocation", x.ISOLocation.FullName});
@@ -406,56 +279,11 @@ internal void Execute(InitArguments x)
406279
if (x.nugetRegistryPassword != null)
407280
{
408281
args.AddRange(new[] { "--nugetRegistryPassword", x.nugetRegistryPassword });
409-
}
282+
}
410283

411-
args.AddRange(x.cmfCliRepository != null
412-
? new[] { "--cmfCliRepository", x.cmfCliRepository }
413-
: new[] { "--cmfCliRepository", CliConstants.NpmJsUrl });
414-
args.AddRange(x.cmfPipelineRepository != null
415-
? new[] { "--cmfPipelineRepository", x.cmfPipelineRepository }
416-
: new[] { "--cmfPipelineRepository", CliConstants.NpmJsUrl });
417-
418-
if (!string.IsNullOrEmpty(x.agentPool))
419-
{
420-
args.AddRange(new [] {"--agentPool", x.agentPool});
421-
}
422-
args.AddRange(new [] {"--agentType", (x.agentType ??= AgentType.Hosted).ToString()});
423284

424285

425-
#endregion
426-
427-
#region container-specific switches
428-
if (!string.IsNullOrEmpty(x.releaseCustomerEnvironment))
429-
{
430-
args.AddRange(new[] { "--releaseCustomerEnvironment", x.releaseCustomerEnvironment });
431-
}
432-
433-
if (!string.IsNullOrEmpty(x.releaseSite))
434-
{
435-
args.AddRange(new[] { "--releaseSite", x.releaseSite });
436-
}
437-
438-
if (!string.IsNullOrEmpty(x.releaseDeploymentPackage))
439-
{
440-
// we need to escape the @ symbol to avoid that commandline lib parses it as a file
441-
// https://github.com/dotnet/command-line-api/issues/816
442-
x.releaseDeploymentPackage = x.releaseDeploymentPackage.Length > 1 && x.releaseDeploymentPackage[0] == '\\'
443-
? x.releaseDeploymentPackage[1..]
444-
: x.releaseDeploymentPackage;
445-
446-
args.AddRange(new[] { "--releaseDeploymentPackage", $"{x.releaseDeploymentPackage}" });
447-
}
448-
449-
if (!string.IsNullOrEmpty(x.releaseLicense))
450-
{
451-
args.AddRange(new[] { "--releaseLicense", x.releaseLicense });
452-
}
453-
454-
if (!string.IsNullOrEmpty(x.releaseDeploymentTarget))
455-
{
456-
args.AddRange(new[] { "--releaseDeploymentTarget", x.releaseDeploymentTarget });
457-
}
458-
#endregion
286+
#endregion
459287

460288
#region version-specific bits
461289

cmf-cli/Constants/CliConstants.cs

-5
Original file line numberDiff line numberDiff line change
@@ -84,11 +84,6 @@ public static class CliConstants
8484
/// </summary>
8585
public const string DefaultStrategyPath = "$.tenants.config.$(tenant).strategies";
8686

87-
/// <summary>
88-
/// regex to determine repository name from the url
89-
/// </summary>
90-
public static readonly Regex RepoRegex = new Regex(@"^(?<proto>\w+):\/\/(?<host>[^\/]+)\/(?<collection>[^/]+)\/(?<project>[^\/]+\/)?_git\/(?<repo>.+)\/?$", RegexOptions.ExplicitCapture | RegexOptions.IgnoreCase);
91-
9287
/// <summary>
9388
/// Default repository type
9489
/// </summary>

cmf-cli/cmf.csproj

+1-22
Original file line numberDiff line numberDiff line change
@@ -59,28 +59,7 @@
5959
<ItemGroup>
6060
<EmbeddedResource Remove="resources\template_feed\**" />
6161
<Compile Remove="resources\template_feed\**" />
62-
<None Include="resources\template_feed\**\.template.config\template.json">
63-
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
64-
</None>
65-
<None Update="resources\template_feed\**">
66-
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
67-
</None>
68-
<None Include="resources\template_feed\**\*.cs">
69-
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
70-
</None>
71-
<None Include="resources\template_feed\**\*.csproj">
72-
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
73-
</None>
74-
<None Include="resources\template_feed\**\*.sln">
75-
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
76-
</None>
77-
<None Include="resources\template_feed\database\**\*.sqlproj">
78-
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
79-
</None>
80-
<None Include="resources\template_feed\**\.tasks\**">
81-
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
82-
</None>
83-
<None Include="resources\template_feed\**\.vars\**">
62+
<None Include="resources\template_feed\**">
8463
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
8564
</None>
8665
</ItemGroup>

cmf-cli/resources/template_feed/init/.project-config.json

+3-5
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,6 @@
44
"BaseLayer": "<%= $CLI_PARAM_BaseLayer %>",
55
"NPMRegistry": "<%= $CLI_PARAM_NPMRegistry %>",
66
"NuGetRegistry": "<%= $CLI_PARAM_NuGetRegistry %>",
7-
"AzureDevopsCollectionURL": "<%= $CLI_PARAM_AzureDevopsCollectionURL %>",
8-
"AgentPool": "<%= $CLI_PARAM_AgentPool %>",
9-
"AgentType": "<%= $CLI_PARAM_AgentType %>",
10-
"RepositoryURL": "<%= $CLI_PARAM_RepositoryURL %>",
117
"EnvironmentName": "<%= $CLI_PARAM_EnvironmentName %>",
128
"DefaultDomain": "<%= $CLI_PARAM_DefaultDomain %>",
139
"RESTPort": "<%= $CLI_PARAM_RESTPort %>",
@@ -34,5 +30,7 @@
3430
"HTMLPort": "<%= $CLI_PARAM_HTMLPort %>",
3531
"GatewayPort": "<%= $CLI_PARAM_GatewayPort %>",
3632
"ReleaseEnvironmentConfig": "<%= $CLI_PARAM_ReleaseEnvironmentConfig %>",
37-
"ISOLocation": "<%= $CLI_PARAM_ISOLocation_JSON %>"
33+
"ISOLocation": "<%= $CLI_PARAM_ISOLocation_JSON %>",
34+
"DeploymentDir": "<%= $CLI_PARAM_DeploymentDir %>",
35+
"DeliveredRepo": "<%= $CLI_PARAM_DeliveredRepo %>"
3836
}

0 commit comments

Comments
 (0)