@mnci/cli 4.40.6 → 4.40.7
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 +26 -0
- package/dist/cli.js.map +1 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -4464,6 +4464,28 @@ function setGoModulePath(workspaceRoot, projectDir) {
|
|
|
4464
4464
|
const rewritten = (0, import_node_fs18.readFileSync)(goModPath, "utf8").replace(/^module\s+\S+/m, () => `module ${prefix}/${projectDir}`);
|
|
4465
4465
|
writeFileEnsured(goModPath, rewritten);
|
|
4466
4466
|
}
|
|
4467
|
+
var GO_DIRECTIVE_CEILING = "1.24";
|
|
4468
|
+
function exceedsGoCeiling(version) {
|
|
4469
|
+
const [major, minor] = version.split(".").map(Number);
|
|
4470
|
+
const [ceilingMajor, ceilingMinor] = GO_DIRECTIVE_CEILING.split(".").map(Number);
|
|
4471
|
+
return major > ceilingMajor || major === ceilingMajor && minor > ceilingMinor;
|
|
4472
|
+
}
|
|
4473
|
+
function clampGoDirective(filePath) {
|
|
4474
|
+
if (!fileExists(filePath)) {
|
|
4475
|
+
return;
|
|
4476
|
+
}
|
|
4477
|
+
const before = (0, import_node_fs18.readFileSync)(filePath, "utf8");
|
|
4478
|
+
const directive = /^go\s+(\d+\.\d+(?:\.\d+)?)/m.exec(before);
|
|
4479
|
+
if (directive === null || !exceedsGoCeiling(directive[1])) {
|
|
4480
|
+
return;
|
|
4481
|
+
}
|
|
4482
|
+
const after = before.replace(/^go\s+\d+\.\d+(?:\.\d+)?/m, () => `go ${GO_DIRECTIVE_CEILING}`).replace(/^toolchain\s+\S+(?:\r?\n){1,2}/m, "");
|
|
4483
|
+
writeFileEnsured(filePath, after);
|
|
4484
|
+
}
|
|
4485
|
+
function pinGoDirective(workspaceRoot, projectDir) {
|
|
4486
|
+
clampGoDirective((0, import_node_path17.join)(workspaceRoot, projectDir, "go.mod"));
|
|
4487
|
+
clampGoDirective((0, import_node_path17.join)(workspaceRoot, "go.work"));
|
|
4488
|
+
}
|
|
4467
4489
|
function writeGoAppExample(workspaceRoot, projectDir) {
|
|
4468
4490
|
const goModPath = (0, import_node_path17.join)(workspaceRoot, projectDir, "go.mod");
|
|
4469
4491
|
const modulePath = fileExists(goModPath) ? /^module\s+(\S+)/m.exec((0, import_node_fs18.readFileSync)(goModPath, "utf8"))?.[1] : void 0;
|
|
@@ -4654,6 +4676,7 @@ function addGoApp(workspaceRoot, name, options = {}) {
|
|
|
4654
4676
|
workspaceRoot
|
|
4655
4677
|
);
|
|
4656
4678
|
setGoModulePath(workspaceRoot, `apps/${name}`);
|
|
4679
|
+
pinGoDirective(workspaceRoot, `apps/${name}`);
|
|
4657
4680
|
if (options.web === void 0) {
|
|
4658
4681
|
writeGoAppExample(workspaceRoot, `apps/${name}`);
|
|
4659
4682
|
}
|
|
@@ -4696,6 +4719,7 @@ function addGoFunctionApp(workspaceRoot, name) {
|
|
|
4696
4719
|
workspaceRoot
|
|
4697
4720
|
);
|
|
4698
4721
|
setGoModulePath(workspaceRoot, `apps/${name}`);
|
|
4722
|
+
pinGoDirective(workspaceRoot, `apps/${name}`);
|
|
4699
4723
|
writeGoAppExample(workspaceRoot, `apps/${name}`);
|
|
4700
4724
|
addProjectJsonTargets((0, import_node_path17.join)(workspaceRoot, "apps", name, "project.json"), {
|
|
4701
4725
|
"build": goBuildTarget(name),
|
|
@@ -4721,6 +4745,7 @@ function addGoLib(workspaceRoot, name) {
|
|
|
4721
4745
|
workspaceRoot
|
|
4722
4746
|
);
|
|
4723
4747
|
setGoModulePath(workspaceRoot, `packages/${name}`);
|
|
4748
|
+
pinGoDirective(workspaceRoot, `packages/${name}`);
|
|
4724
4749
|
addProjectJsonTargets((0, import_node_path17.join)(workspaceRoot, "packages", name, "project.json"), {
|
|
4725
4750
|
test: goTestTarget(),
|
|
4726
4751
|
lint: goLintTarget()
|
|
@@ -4746,6 +4771,7 @@ function addGoInternalLib(workspaceRoot, name) {
|
|
|
4746
4771
|
workspaceRoot
|
|
4747
4772
|
);
|
|
4748
4773
|
setGoModulePath(workspaceRoot, `libs/${name}`);
|
|
4774
|
+
pinGoDirective(workspaceRoot, `libs/${name}`);
|
|
4749
4775
|
addProjectJsonTargets((0, import_node_path17.join)(workspaceRoot, "libs", name, "project.json"), {
|
|
4750
4776
|
test: goTestTarget(),
|
|
4751
4777
|
lint: goLintTarget()
|