@mnci/cli 4.10.8 → 4.11.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/README.md CHANGED
@@ -1360,7 +1360,7 @@ pipeline installs `golangci-lint` itself (see below).
1360
1360
 
1361
1361
  | Kind | Location | Build / deploy |
1362
1362
  | ----------------- | ----------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
1363
- | `go-app` | `apps/<name>` | `go build` binary into `dist/apps/<name>/`, zipped by mnci into `dist/drop/go-app-<name>.zip` |
1363
+ | `go-app` | `apps/<name>` | `go build` binary into `dist/apps/<name>/`, zipped by mnci into `dist/drop/go-app-<name>.zip`; `build-all` / `package-all` cross-compile six platforms into `dist/platforms/<name>/<goos>-<goarch>/` and zip each (`VERSION` env stamps `main.version`) |
1364
1364
  | `go-function-app` | `apps/<name>` | same build; zipped into `dist/drop/go-function-app-<name>.zip`. The handler body is yours to write — AWS Lambda, Google Cloud Functions and Azure each want a different signature, and mnci does not pick one |
1365
1365
  | `go-lib` | `packages/<name>` | publishable **by git tag** — see below; lint + test targets only |
1366
1366
  | `go-internal-lib` | `libs/<name>` | private shared code, lint + test only — a non-`main` package produces no binary |
package/dist/cli.js CHANGED
@@ -2636,6 +2636,63 @@ function goPackageTarget(tag, name) {
2636
2636
  options: { command }
2637
2637
  };
2638
2638
  }
2639
+ var GO_PLATFORMS = [
2640
+ "windows/amd64",
2641
+ "windows/arm64",
2642
+ "linux/amd64",
2643
+ "linux/arm64",
2644
+ "darwin/amd64",
2645
+ "darwin/arm64"
2646
+ ];
2647
+ function goBuildAllTarget(name) {
2648
+ const platforms = JSON.stringify(GO_PLATFORMS).replaceAll('"', "'");
2649
+ const command = `node -e "const{spawnSync}=require('node:child_process');const v=process.env.VERSION||'dev';for(const p of ${platforms}){const[os,arch]=p.split('/');const out='../../dist/platforms/${name}/'+os+'-'+arch+'/${name}'+(os==='windows'?'.exe':'');const r=spawnSync('go',['build','-trimpath','-ldflags','-s -w -X main.version='+v,'-o',out,'.'],{cwd:'apps/${name}',stdio:'inherit',env:{...process.env,CGO_ENABLED:'0',GOOS:os,GOARCH:arch}});if(r.status!==0)process.exit(r.status??1)}"`;
2650
+ return {
2651
+ executor: "nx:run-commands",
2652
+ inputs: ["default", "^default", "{workspaceRoot}/go.mod", "{workspaceRoot}/go.sum", { env: "VERSION" }],
2653
+ outputs: [`{workspaceRoot}/dist/platforms/${name}`],
2654
+ options: { command }
2655
+ };
2656
+ }
2657
+ function goPackageAllTarget(tag, name) {
2658
+ const command = `node -e "const fs=require('node:fs');const A=require('adm-zip');fs.mkdirSync('dist/drop',{recursive:true});for(const d of fs.readdirSync('dist/platforms/${name}')){const z=new A();z.addLocalFolder('dist/platforms/${name}/'+d);z.writeZip('dist/drop/${tag}-${name}-'+d+'.zip')}"`;
2659
+ return {
2660
+ executor: "nx:run-commands",
2661
+ dependsOn: ["build-all"],
2662
+ outputs: [`{workspaceRoot}/dist/drop/${tag}-${name}-*.zip`],
2663
+ options: { command }
2664
+ };
2665
+ }
2666
+ function addGoPlatformTargets(workspaceRoot) {
2667
+ const changed = [];
2668
+ const apps = (0, import_node_path6.join)(workspaceRoot, "apps");
2669
+ if (!fileExists(apps)) {
2670
+ return changed;
2671
+ }
2672
+ for (const name of (0, import_node_fs5.readdirSync)(apps)) {
2673
+ const projectJsonPath = (0, import_node_path6.join)(apps, name, "project.json");
2674
+ if (!fileExists(projectJsonPath)) {
2675
+ continue;
2676
+ }
2677
+ const project = JSON.parse((0, import_node_fs5.readFileSync)(projectJsonPath, "utf8"));
2678
+ const tag = (project.tags ?? []).find((each) => each === "type:go-app" || each === "type:go-function-app")?.slice("type:".length);
2679
+ if (tag === void 0) {
2680
+ continue;
2681
+ }
2682
+ const missing = {};
2683
+ if (project.targets?.["build-all"] === void 0) {
2684
+ missing["build-all"] = goBuildAllTarget(name);
2685
+ }
2686
+ if (project.targets?.["package-all"] === void 0) {
2687
+ missing["package-all"] = goPackageAllTarget(tag, name);
2688
+ }
2689
+ if (Object.keys(missing).length > 0) {
2690
+ addProjectJsonTargets(projectJsonPath, missing);
2691
+ changed.push(`apps/${name}/project.json`);
2692
+ }
2693
+ }
2694
+ return changed;
2695
+ }
2639
2696
  function goStartTarget(name) {
2640
2697
  return {
2641
2698
  executor: "nx:run-commands",
@@ -2723,11 +2780,13 @@ function addGoApp(workspaceRoot, name) {
2723
2780
  workspaceRoot
2724
2781
  );
2725
2782
  addProjectJsonTargets((0, import_node_path6.join)(workspaceRoot, "apps", name, "project.json"), {
2726
- build: goBuildTarget(name),
2727
- test: goTestTarget(),
2728
- lint: goLintTarget(),
2729
- package: goPackageTarget("go-app", name),
2730
- start: goStartTarget(name)
2783
+ "build": goBuildTarget(name),
2784
+ "test": goTestTarget(),
2785
+ "lint": goLintTarget(),
2786
+ "package": goPackageTarget("go-app", name),
2787
+ "build-all": goBuildAllTarget(name),
2788
+ "package-all": goPackageAllTarget("go-app", name),
2789
+ "start": goStartTarget(name)
2731
2790
  });
2732
2791
  registerProjectCommands(workspaceRoot, name, { build: true, start: `nx run ${name}:start` });
2733
2792
  }
@@ -2746,10 +2805,12 @@ function addGoFunctionApp(workspaceRoot, name) {
2746
2805
  workspaceRoot
2747
2806
  );
2748
2807
  addProjectJsonTargets((0, import_node_path6.join)(workspaceRoot, "apps", name, "project.json"), {
2749
- build: goBuildTarget(name),
2750
- test: goTestTarget(),
2751
- lint: goLintTarget(),
2752
- package: goPackageTarget("go-function-app", name)
2808
+ "build": goBuildTarget(name),
2809
+ "test": goTestTarget(),
2810
+ "lint": goLintTarget(),
2811
+ "package": goPackageTarget("go-function-app", name),
2812
+ "build-all": goBuildAllTarget(name),
2813
+ "package-all": goPackageAllTarget("go-function-app", name)
2753
2814
  });
2754
2815
  registerProjectCommands(workspaceRoot, name, { build: true });
2755
2816
  }
@@ -5662,6 +5723,13 @@ function runUpgrade(workspaceRoot, options) {
5662
5723
  logger.detail(`updated ${path}`);
5663
5724
  }
5664
5725
  }
5726
+ const goApps = addGoPlatformTargets(workspaceRoot);
5727
+ if (goApps.length > 0) {
5728
+ logger.step("Adding the six-platform build to Go apps (build-all, package-all)");
5729
+ for (const path of goApps) {
5730
+ logger.detail(`updated ${path}`);
5731
+ }
5732
+ }
5665
5733
  const upgradedDtsPlugins = upgradeDeclarationSpecifierPlugins(workspaceRoot);
5666
5734
  if (upgradedDtsPlugins.length > 0) {
5667
5735
  logger.step("Upgrading declaration specifiers to resolve under nodenext");