@pagopa/dx-cli 0.16.0 → 0.16.1

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.
@@ -5,6 +5,7 @@ import { $, ExecaError } from "execa";
5
5
  import { okAsync, ResultAsync } from "neverthrow";
6
6
  import * as path from "node:path";
7
7
  import { oraPromise } from "ora";
8
+ import { z } from "zod";
8
9
  import { Repository, } from "../../../domain/github.js";
9
10
  import { tf$ } from "../../execa/terraform.js";
10
11
  import { getPlopInstance, runDeploymentEnvironmentGenerator, runMonorepoGenerator, } from "../../plop/index.js";
@@ -34,8 +35,20 @@ const displaySummary = (initResult) => {
34
35
  console.log(`Please, manually create a Pull Request in the GitHub repository to review the scaffolded code.\n`);
35
36
  }
36
37
  };
37
- const checkTerraformCliIsInstalled = () => withSpinner("Checking Terraform installation...", "Terraform is installed!", "Please install terraform CLI before running this command.", tf$ `terraform -version`);
38
- const checkAzLogin = () => withSpinner("Check Azure login status...", "You are logged in to Azure", "Please log in to Azure CLI using `az login` before running this command.", tf$ `az account show`);
38
+ const checkTerraformCliIsInstalled = () => withSpinner("Checking Terraform installation...", "Terraform is installed!", "Please install terraform CLI before running this command. If you use tfenv, run: tfenv install latest && tfenv use latest", tf$ `terraform -version`);
39
+ const azureAccountSchema = z.object({
40
+ user: z.object({
41
+ name: z.string().min(1),
42
+ }),
43
+ });
44
+ const ensureAzLogin = async () => {
45
+ const { stdout } = await tf$ `az account show`;
46
+ await tf$ `az group list`;
47
+ const parsed = JSON.parse(stdout);
48
+ const { user } = azureAccountSchema.parse(parsed);
49
+ return user.name;
50
+ };
51
+ const checkAzLogin = () => withSpinner("Check Azure login status...", (userName) => `You are logged in to Azure (${userName})`, "Please log in to Azure CLI using `az login` before running this command.", ensureAzLogin());
39
52
  const checkPreconditions = () => checkTerraformCliIsInstalled().andThen(() => checkAzLogin());
40
53
  const createRemoteRepository = ({ repoName, repoOwner, }) => {
41
54
  const logger = getLogger(["dx-cli", "init"]);
@@ -9,7 +9,7 @@ export declare const makeMockPackageJson: (overrides?: Partial<PackageJson>) =>
9
9
  typescript: string;
10
10
  };
11
11
  name: string;
12
- scripts: Map<string & import("zod/v4").$brand<"ScriptName">, string> | {
12
+ scripts: Map<string & import("zod").$brand<"ScriptName">, string> | {
13
13
  build: string;
14
14
  "code-review": string;
15
15
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pagopa/dx-cli",
3
- "version": "0.16.0",
3
+ "version": "0.16.1",
4
4
  "type": "module",
5
5
  "description": "A CLI useful to manage DX tools.",
6
6
  "repository": {