@mnci/cli 4.30.0 → 4.31.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 +32 -0
- package/dist/cli.js.map +1 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -2563,6 +2563,19 @@ function csharpConsoleProgram(identity) {
|
|
|
2563
2563
|
Console.WriteLine(GreetUseCase.Greet("world").Message);
|
|
2564
2564
|
`;
|
|
2565
2565
|
}
|
|
2566
|
+
function csharpExampleTest(identity) {
|
|
2567
|
+
return `using ${identity};
|
|
2568
|
+
|
|
2569
|
+
public class GreetUseCaseTests
|
|
2570
|
+
{
|
|
2571
|
+
[Fact]
|
|
2572
|
+
public void GreetsAName()
|
|
2573
|
+
{
|
|
2574
|
+
Assert.Equal("Hello, world!", GreetUseCase.Greet("world").Message);
|
|
2575
|
+
}
|
|
2576
|
+
}
|
|
2577
|
+
`;
|
|
2578
|
+
}
|
|
2566
2579
|
|
|
2567
2580
|
// src/project-scaffolding/post-generation.use-case.ts
|
|
2568
2581
|
var import_node_fs5 = require("fs");
|
|
@@ -2970,6 +2983,21 @@ function writeCsharpExample(absoluteRoot, identity, kind) {
|
|
|
2970
2983
|
writeFileEnsured((0, import_node_path6.join)(absoluteRoot, "Program.cs"), csharpConsoleProgram(identity));
|
|
2971
2984
|
}
|
|
2972
2985
|
}
|
|
2986
|
+
function addCsharpTestProject(workspaceRoot, projectRoot, identity) {
|
|
2987
|
+
const name = (0, import_node_path6.basename)(projectRoot);
|
|
2988
|
+
const testRoot = `tests/${name}`;
|
|
2989
|
+
scaffoldDotnetProject(workspaceRoot, testRoot, `${identity}.Tests`, "xunit");
|
|
2990
|
+
(0, import_node_fs6.rmSync)((0, import_node_path6.join)(workspaceRoot, testRoot, "UnitTest1.cs"), { force: true });
|
|
2991
|
+
writeFileEnsured((0, import_node_path6.join)(workspaceRoot, testRoot, "GreetUseCaseTests.cs"), csharpExampleTest(identity));
|
|
2992
|
+
writeFileEnsured(
|
|
2993
|
+
(0, import_node_path6.join)(workspaceRoot, testRoot, "project.json"),
|
|
2994
|
+
toJson({ name: `${name}-tests`, tags: ["type:csharp-test"] })
|
|
2995
|
+
);
|
|
2996
|
+
const reference = (0, import_node_path6.join)(workspaceRoot, projectRoot, `${identity}.csproj`);
|
|
2997
|
+
if (runShell("dotnet", ["add", (0, import_node_path6.join)(workspaceRoot, testRoot), "reference", reference], workspaceRoot) !== 0) {
|
|
2998
|
+
throw new Error(`dotnet add reference failed for ${testRoot}`);
|
|
2999
|
+
}
|
|
3000
|
+
}
|
|
2973
3001
|
function csharpAppPackageTarget(tag, projectRoot, name) {
|
|
2974
3002
|
const outDir = `dist/apps/${name}`;
|
|
2975
3003
|
const zip = `dist/drop/${tag}-${name}.zip`;
|
|
@@ -2994,6 +3022,7 @@ function addCsharpApp(workspaceRoot, name, template = "console") {
|
|
|
2994
3022
|
const projectRoot = `apps/${name}`;
|
|
2995
3023
|
scaffoldDotnetProject(workspaceRoot, projectRoot, pascalCase(name), template);
|
|
2996
3024
|
writeCsharpExample((0, import_node_path6.join)(workspaceRoot, projectRoot), pascalCase(name), template);
|
|
3025
|
+
addCsharpTestProject(workspaceRoot, projectRoot, pascalCase(name));
|
|
2997
3026
|
addProjectJsonTargets((0, import_node_path6.join)(workspaceRoot, projectRoot, "project.json"), {
|
|
2998
3027
|
package: csharpAppPackageTarget("csharp-app", projectRoot, name),
|
|
2999
3028
|
start: csharpAppStartTarget(projectRoot)
|
|
@@ -3118,6 +3147,7 @@ async function addCsharpLib(workspaceRoot, name, options, kindProvided) {
|
|
|
3118
3147
|
const identity = `${pascalScope(scope)}.${pascalCase(name)}`;
|
|
3119
3148
|
scaffoldDotnetProject(workspaceRoot, projectRoot, identity, "classlib");
|
|
3120
3149
|
writeCsharpExample((0, import_node_path6.join)(workspaceRoot, projectRoot), identity, "classlib");
|
|
3150
|
+
addCsharpTestProject(workspaceRoot, projectRoot, identity);
|
|
3121
3151
|
addInitialVersion((0, import_node_path6.join)(workspaceRoot, projectRoot, `${identity}.csproj`));
|
|
3122
3152
|
writeCsharpVersionActions(workspaceRoot);
|
|
3123
3153
|
addProjectJsonReleaseVersionActions((0, import_node_path6.join)(workspaceRoot, projectRoot, "project.json"));
|
|
@@ -3135,6 +3165,7 @@ function addCsharpInternalLib(workspaceRoot, name) {
|
|
|
3135
3165
|
const identity = pascalCase(name);
|
|
3136
3166
|
scaffoldDotnetProject(workspaceRoot, projectRoot, identity, "classlib");
|
|
3137
3167
|
writeCsharpExample((0, import_node_path6.join)(workspaceRoot, projectRoot), identity, "classlib");
|
|
3168
|
+
addCsharpTestProject(workspaceRoot, projectRoot, identity);
|
|
3138
3169
|
registerProjectCommands(workspaceRoot, name, { build: false });
|
|
3139
3170
|
logger.step(
|
|
3140
3171
|
`Reference it from a consumer with: dotnet add <consumer>.csproj reference ${projectRoot}/${identity}.csproj`
|
|
@@ -3214,6 +3245,7 @@ function addCsharpFunctionApp(workspaceRoot, name) {
|
|
|
3214
3245
|
if (runShell("dotnet", ["restore", projectRoot], workspaceRoot) !== 0) {
|
|
3215
3246
|
throw new Error(`dotnet restore failed for ${projectRoot}`);
|
|
3216
3247
|
}
|
|
3248
|
+
addCsharpTestProject(workspaceRoot, projectRoot, identity);
|
|
3217
3249
|
addProjectJsonTargets((0, import_node_path6.join)(absoluteRoot, "project.json"), {
|
|
3218
3250
|
package: csharpAppPackageTarget("csharp-function-app", projectRoot, name),
|
|
3219
3251
|
start: csharpFunctionAppStartTarget(projectRoot)
|