@mnci/cli 4.28.0 → 4.29.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/dist/cli.js +45 -1
- package/dist/cli.js.map +1 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -2539,6 +2539,31 @@ function assertValidProjectName(name, label) {
|
|
|
2539
2539
|
var import_node_fs6 = require("fs");
|
|
2540
2540
|
var import_node_path6 = require("path");
|
|
2541
2541
|
|
|
2542
|
+
// src/project-scaffolding/csharp-example.algorithm.ts
|
|
2543
|
+
function csharpExampleFiles(identity) {
|
|
2544
|
+
return {
|
|
2545
|
+
"Greeting.cs": `namespace ${identity};
|
|
2546
|
+
|
|
2547
|
+
/// <summary>What greeting someone returns.</summary>
|
|
2548
|
+
public sealed record Greeting(string Message);
|
|
2549
|
+
`,
|
|
2550
|
+
"GreetUseCase.cs": `namespace ${identity};
|
|
2551
|
+
|
|
2552
|
+
/// <summary>Greets someone by name: a worked example of a use case. Replace it with your own.</summary>
|
|
2553
|
+
public static class GreetUseCase
|
|
2554
|
+
{
|
|
2555
|
+
public static Greeting Greet(string name) => new("Hello, " + name + "!");
|
|
2556
|
+
}
|
|
2557
|
+
`
|
|
2558
|
+
};
|
|
2559
|
+
}
|
|
2560
|
+
function csharpConsoleProgram(identity) {
|
|
2561
|
+
return `using ${identity};
|
|
2562
|
+
|
|
2563
|
+
Console.WriteLine(GreetUseCase.Greet("world").Message);
|
|
2564
|
+
`;
|
|
2565
|
+
}
|
|
2566
|
+
|
|
2542
2567
|
// src/project-scaffolding/post-generation.use-case.ts
|
|
2543
2568
|
var import_node_fs5 = require("fs");
|
|
2544
2569
|
var import_node_path5 = require("path");
|
|
@@ -2933,6 +2958,18 @@ function scaffoldDotnetProject(workspaceRoot, projectRoot, identity, template) {
|
|
|
2933
2958
|
throw new Error(`dotnet new ${template} failed for ${projectRoot}`);
|
|
2934
2959
|
}
|
|
2935
2960
|
}
|
|
2961
|
+
function writeCsharpExample(absoluteRoot, identity, kind) {
|
|
2962
|
+
if (kind === "classlib") {
|
|
2963
|
+
(0, import_node_fs6.rmSync)((0, import_node_path6.join)(absoluteRoot, "Class1.cs"), { force: true });
|
|
2964
|
+
}
|
|
2965
|
+
const files = csharpExampleFiles(identity);
|
|
2966
|
+
for (const [file, contents] of Object.entries(files)) {
|
|
2967
|
+
writeFileEnsured((0, import_node_path6.join)(absoluteRoot, file), contents);
|
|
2968
|
+
}
|
|
2969
|
+
if (kind === "console") {
|
|
2970
|
+
writeFileEnsured((0, import_node_path6.join)(absoluteRoot, "Program.cs"), csharpConsoleProgram(identity));
|
|
2971
|
+
}
|
|
2972
|
+
}
|
|
2936
2973
|
function csharpAppPackageTarget(tag, projectRoot, name) {
|
|
2937
2974
|
const outDir = `dist/apps/${name}`;
|
|
2938
2975
|
const zip = `dist/drop/${tag}-${name}.zip`;
|
|
@@ -2956,6 +2993,7 @@ function addCsharpApp(workspaceRoot, name, template = "console") {
|
|
|
2956
2993
|
ensureAdmZip(workspaceRoot);
|
|
2957
2994
|
const projectRoot = `apps/${name}`;
|
|
2958
2995
|
scaffoldDotnetProject(workspaceRoot, projectRoot, pascalCase(name), template);
|
|
2996
|
+
writeCsharpExample((0, import_node_path6.join)(workspaceRoot, projectRoot), pascalCase(name), template);
|
|
2959
2997
|
addProjectJsonTargets((0, import_node_path6.join)(workspaceRoot, projectRoot, "project.json"), {
|
|
2960
2998
|
package: csharpAppPackageTarget("csharp-app", projectRoot, name),
|
|
2961
2999
|
start: csharpAppStartTarget(projectRoot)
|
|
@@ -3079,6 +3117,7 @@ async function addCsharpLib(workspaceRoot, name, options, kindProvided) {
|
|
|
3079
3117
|
const projectRoot = `packages/${name}`;
|
|
3080
3118
|
const identity = `${pascalScope(scope)}.${pascalCase(name)}`;
|
|
3081
3119
|
scaffoldDotnetProject(workspaceRoot, projectRoot, identity, "classlib");
|
|
3120
|
+
writeCsharpExample((0, import_node_path6.join)(workspaceRoot, projectRoot), identity, "classlib");
|
|
3082
3121
|
addInitialVersion((0, import_node_path6.join)(workspaceRoot, projectRoot, `${identity}.csproj`));
|
|
3083
3122
|
writeCsharpVersionActions(workspaceRoot);
|
|
3084
3123
|
addProjectJsonReleaseVersionActions((0, import_node_path6.join)(workspaceRoot, projectRoot, "project.json"));
|
|
@@ -3095,6 +3134,7 @@ function addCsharpInternalLib(workspaceRoot, name) {
|
|
|
3095
3134
|
const projectRoot = `libs/${name}`;
|
|
3096
3135
|
const identity = pascalCase(name);
|
|
3097
3136
|
scaffoldDotnetProject(workspaceRoot, projectRoot, identity, "classlib");
|
|
3137
|
+
writeCsharpExample((0, import_node_path6.join)(workspaceRoot, projectRoot), identity, "classlib");
|
|
3098
3138
|
registerProjectCommands(workspaceRoot, name, { build: false });
|
|
3099
3139
|
logger.step(
|
|
3100
3140
|
`Reference it from a consumer with: dotnet add <consumer>.csproj reference ${projectRoot}/${identity}.csproj`
|
|
@@ -3143,7 +3183,7 @@ public class Hello
|
|
|
3143
3183
|
[Function("Hello")]
|
|
3144
3184
|
public IActionResult Run([HttpTrigger(AuthorizationLevel.Anonymous, "get")] HttpRequest req)
|
|
3145
3185
|
{
|
|
3146
|
-
return new OkObjectResult("
|
|
3186
|
+
return new OkObjectResult(GreetUseCase.Greet("mnci").Message);
|
|
3147
3187
|
}
|
|
3148
3188
|
}
|
|
3149
3189
|
`;
|
|
@@ -3166,6 +3206,10 @@ function addCsharpFunctionApp(workspaceRoot, name) {
|
|
|
3166
3206
|
writeFileEnsured((0, import_node_path6.join)(absoluteRoot, `${identity}.csproj`), csharpFunctionAppCsproj());
|
|
3167
3207
|
writeFileEnsured((0, import_node_path6.join)(absoluteRoot, "Program.cs"), CSHARP_FUNCTION_APP_PROGRAM);
|
|
3168
3208
|
writeFileEnsured((0, import_node_path6.join)(absoluteRoot, "Hello.cs"), csharpFunctionAppHello(identity));
|
|
3209
|
+
const example = csharpExampleFiles(identity);
|
|
3210
|
+
for (const [file, contents] of Object.entries(example)) {
|
|
3211
|
+
writeFileEnsured((0, import_node_path6.join)(absoluteRoot, file), contents);
|
|
3212
|
+
}
|
|
3169
3213
|
writeFileEnsured((0, import_node_path6.join)(absoluteRoot, "host.json"), CSHARP_FUNCTION_APP_HOST_JSON);
|
|
3170
3214
|
if (runShell("dotnet", ["restore", projectRoot], workspaceRoot) !== 0) {
|
|
3171
3215
|
throw new Error(`dotnet restore failed for ${projectRoot}`);
|