@pagopa/dx-cli 0.11.1 → 0.13.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/bin/index.js +83 -26
- package/package.json +5 -3
package/bin/index.js
CHANGED
|
@@ -740,11 +740,26 @@ var makeInfoCommand = (dependencies) => new Command3().name("info").description(
|
|
|
740
740
|
});
|
|
741
741
|
|
|
742
742
|
// src/adapters/commander/commands/init.ts
|
|
743
|
-
import
|
|
743
|
+
import loadMonorepoScaffolder, {
|
|
744
|
+
answersSchema,
|
|
745
|
+
PLOP_MONOREPO_GENERATOR_NAME
|
|
746
|
+
} from "@pagopa/monorepo-generator";
|
|
747
|
+
import chalk from "chalk";
|
|
744
748
|
import { Command as Command4 } from "commander";
|
|
745
|
-
import {
|
|
749
|
+
import { $ as $2 } from "execa";
|
|
750
|
+
import { okAsync as okAsync2, Result, ResultAsync as ResultAsync5 } from "neverthrow";
|
|
746
751
|
import nodePlop from "node-plop";
|
|
747
|
-
|
|
752
|
+
import { oraPromise } from "ora";
|
|
753
|
+
|
|
754
|
+
// src/adapters/zod/index.ts
|
|
755
|
+
import { ResultAsync as ResultAsync4 } from "neverthrow";
|
|
756
|
+
var decode = (schema) => (data) => ResultAsync4.fromPromise(
|
|
757
|
+
schema.parseAsync(data),
|
|
758
|
+
(cause) => new Error("Input is not valid for the given schema", { cause })
|
|
759
|
+
);
|
|
760
|
+
|
|
761
|
+
// src/adapters/commander/commands/init.ts
|
|
762
|
+
var initPlop = () => ResultAsync5.fromPromise(
|
|
748
763
|
nodePlop(),
|
|
749
764
|
() => new Error("Failed to initialize plop")
|
|
750
765
|
);
|
|
@@ -752,24 +767,70 @@ var getGenerator = (plopAPI) => Result.fromThrowable(
|
|
|
752
767
|
plopAPI.getGenerator,
|
|
753
768
|
() => new Error("Generator not found")
|
|
754
769
|
);
|
|
755
|
-
var
|
|
770
|
+
var getPrompts = (generator) => ResultAsync5.fromPromise(
|
|
756
771
|
generator.runPrompts(),
|
|
757
|
-
() => new Error("Failed to run the generator prompts")
|
|
772
|
+
(cause) => new Error("Failed to run the generator prompts", { cause })
|
|
773
|
+
);
|
|
774
|
+
var withSpinner = (text, successText, failText, promise) => ResultAsync5.fromPromise(
|
|
775
|
+
oraPromise(promise, {
|
|
776
|
+
failText,
|
|
777
|
+
successText,
|
|
778
|
+
text
|
|
779
|
+
}),
|
|
780
|
+
(cause) => new Error(failText, { cause })
|
|
781
|
+
);
|
|
782
|
+
var validateAnswers = (answers) => okAsync2(answers);
|
|
783
|
+
var runGeneratorActions = (generator) => (answers) => withSpinner(
|
|
784
|
+
"Creating workspace files...",
|
|
785
|
+
"Workspace files created successfully!",
|
|
786
|
+
"Failed to create workspace files.",
|
|
787
|
+
generator.runActions(answers)
|
|
788
|
+
).map(() => answers);
|
|
789
|
+
var displaySummary = (answers) => {
|
|
790
|
+
const { csp, repoName, repoOwner } = answers;
|
|
791
|
+
console.log(chalk.green.bold("\nWorkspace created successfully!"));
|
|
792
|
+
console.log(`- Name: ${chalk.cyan(repoName)}`);
|
|
793
|
+
console.log(`- Cloud Service Provider: ${chalk.cyan(csp)}`);
|
|
794
|
+
const cspLocation = csp === "azure" ? answers.azureLocation : answers.awsRegion;
|
|
795
|
+
console.log(`- CSP location: ${chalk.cyan(cspLocation)}`);
|
|
796
|
+
console.log(
|
|
797
|
+
`- GitHub Repository: ${chalk.cyan(`https://github.com/${repoOwner}/${repoName}`)}
|
|
798
|
+
`
|
|
799
|
+
);
|
|
800
|
+
console.log(chalk.green.bold("\nNext Steps:"));
|
|
801
|
+
console.log(`1. Review the Pull Request in the GitHub repository.`);
|
|
802
|
+
console.log(
|
|
803
|
+
`2. Wait for the approval on eng-azure-authorization and then merge both PRs.`
|
|
804
|
+
);
|
|
805
|
+
console.log(
|
|
806
|
+
`3. Visit ${chalk.underline("https://dx.pagopa.it/getting-started")} to deploy your first project
|
|
807
|
+
`
|
|
808
|
+
);
|
|
809
|
+
};
|
|
810
|
+
var checkGhCliIsInstalled = (text, successText, failText) => withSpinner(text, successText, failText, $2`gh --version`);
|
|
811
|
+
var checkGhCliIsLoggedIn = (text, successText, failText) => withSpinner(text, successText, failText, $2`gh auth status`);
|
|
812
|
+
var checkPreconditions = () => checkGhCliIsInstalled(
|
|
813
|
+
"Checking GitHub CLI is installed...",
|
|
814
|
+
"GitHub CLI is installed!",
|
|
815
|
+
"GitHub CLI is not installed."
|
|
758
816
|
).andThen(
|
|
759
|
-
(
|
|
760
|
-
|
|
761
|
-
|
|
817
|
+
() => checkGhCliIsLoggedIn(
|
|
818
|
+
"Checking GitHub CLI login...",
|
|
819
|
+
"GitHub CLI is logged in!",
|
|
820
|
+
"GitHub CLI is not logged in."
|
|
762
821
|
)
|
|
763
|
-
);
|
|
822
|
+
).map(() => void 0);
|
|
823
|
+
var handleNewGitHubRepository = (answers) => okAsync2(answers);
|
|
764
824
|
var makeInitCommand = () => new Command4().name("init").description(
|
|
765
825
|
"Command to initialize resources (like projects, subscriptions, ...)"
|
|
766
826
|
).addCommand(
|
|
767
827
|
new Command4("project").description("Initialize a new monorepo project").action(async function() {
|
|
768
|
-
await
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
828
|
+
await checkPreconditions().andThen(initPlop).andTee(loadMonorepoScaffolder).andThen((plop) => getGenerator(plop)(PLOP_MONOREPO_GENERATOR_NAME)).andThen(
|
|
829
|
+
(generator) => (
|
|
830
|
+
// Ask the user the questions defined in the plop generator
|
|
831
|
+
getPrompts(generator).andThen(decode(answersSchema)).andThen(validateAnswers).andThen(runGeneratorActions(generator))
|
|
832
|
+
)
|
|
833
|
+
).andThen(handleNewGitHubRepository).match(displaySummary, exitWithError(this));
|
|
773
834
|
})
|
|
774
835
|
);
|
|
775
836
|
|
|
@@ -806,7 +867,7 @@ var makeSavemoneyCommand = () => new Command5("savemoney").description(
|
|
|
806
867
|
// src/adapters/commander/index.ts
|
|
807
868
|
var makeCli = (deps2, config2, cliDeps) => {
|
|
808
869
|
const program2 = new Command6();
|
|
809
|
-
program2.name("dx").description("The CLI for DX-Platform").version("0.
|
|
870
|
+
program2.name("dx").description("The CLI for DX-Platform").version("0.13.0");
|
|
810
871
|
program2.addCommand(makeDoctorCommand(deps2, config2));
|
|
811
872
|
program2.addCommand(makeCodemodCommand(cliDeps));
|
|
812
873
|
program2.addCommand(makeInitCommand());
|
|
@@ -814,6 +875,9 @@ var makeCli = (deps2, config2, cliDeps) => {
|
|
|
814
875
|
program2.addCommand(makeInfoCommand(deps2));
|
|
815
876
|
return program2;
|
|
816
877
|
};
|
|
878
|
+
var exitWithError = (command) => (error) => {
|
|
879
|
+
command.error(error.message);
|
|
880
|
+
};
|
|
817
881
|
|
|
818
882
|
// src/adapters/logtape/validation-reporter.ts
|
|
819
883
|
import { getLogger as getLogger7 } from "@logtape/logtape";
|
|
@@ -838,13 +902,6 @@ import * as process3 from "process";
|
|
|
838
902
|
import { ResultAsync as ResultAsync6 } from "neverthrow";
|
|
839
903
|
import fs3 from "fs/promises";
|
|
840
904
|
|
|
841
|
-
// src/adapters/zod/index.ts
|
|
842
|
-
import { ResultAsync as ResultAsync5 } from "neverthrow";
|
|
843
|
-
var decode = (schema) => ResultAsync5.fromThrowable(
|
|
844
|
-
schema.parseAsync,
|
|
845
|
-
(cause) => new Error("File content is not valid for the given schema", { cause })
|
|
846
|
-
);
|
|
847
|
-
|
|
848
905
|
// src/adapters/node/json/index.ts
|
|
849
906
|
import { Result as Result2 } from "neverthrow";
|
|
850
907
|
var parseJson = Result2.fromThrowable(
|
|
@@ -889,7 +946,7 @@ var makePackageJsonReader = () => ({
|
|
|
889
946
|
|
|
890
947
|
// src/adapters/node/repository.ts
|
|
891
948
|
import * as glob from "glob";
|
|
892
|
-
import { okAsync as
|
|
949
|
+
import { okAsync as okAsync3, ResultAsync as ResultAsync7 } from "neverthrow";
|
|
893
950
|
import * as path from "path";
|
|
894
951
|
import { z as z3 } from "zod/v4";
|
|
895
952
|
|
|
@@ -927,7 +984,7 @@ var getWorkspaces = (repoRoot) => readFile2(path.join(repoRoot, "pnpm-workspace.
|
|
|
927
984
|
(obj) => (
|
|
928
985
|
// If no packages are defined, go on with an empty array
|
|
929
986
|
decode(z3.object({ packages: z3.array(z3.string()) }))(obj).orElse(
|
|
930
|
-
() =>
|
|
987
|
+
() => okAsync3({ packages: [] })
|
|
931
988
|
)
|
|
932
989
|
)
|
|
933
990
|
).andThen(
|
|
@@ -966,9 +1023,9 @@ var getConfig = () => ({
|
|
|
966
1023
|
});
|
|
967
1024
|
|
|
968
1025
|
// src/use-cases/apply-codemod.ts
|
|
969
|
-
import { errAsync, okAsync as
|
|
1026
|
+
import { errAsync, okAsync as okAsync4, ResultAsync as ResultAsync8 } from "neverthrow";
|
|
970
1027
|
var getCodemodById = (registry2, id) => registry2.getById(id).andThen(
|
|
971
|
-
(codemod) => codemod ?
|
|
1028
|
+
(codemod) => codemod ? okAsync4(codemod) : errAsync(new Error(`Codemod with id ${id} not found`))
|
|
972
1029
|
);
|
|
973
1030
|
var safeGetInfo = (getInfo2) => ResultAsync8.fromPromise(
|
|
974
1031
|
getInfo2(),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pagopa/dx-cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.13.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "A CLI useful to manage DX tools.",
|
|
6
6
|
"repository": {
|
|
@@ -20,6 +20,7 @@
|
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
22
|
"@logtape/logtape": "^1.2.2",
|
|
23
|
+
"chalk": "^5.6.2",
|
|
23
24
|
"commander": "^14.0.2",
|
|
24
25
|
"core-js": "^3.47.0",
|
|
25
26
|
"execa": "^9.6.1",
|
|
@@ -27,12 +28,13 @@
|
|
|
27
28
|
"neverthrow": "^8.2.0",
|
|
28
29
|
"node-plop": "^0.32.3",
|
|
29
30
|
"octokit": "^5.0.5",
|
|
31
|
+
"ora": "^9.0.0",
|
|
30
32
|
"replace-in-file": "^8.3.0",
|
|
31
33
|
"semver": "^7.7.2",
|
|
32
34
|
"yaml": "^2.8.2",
|
|
33
|
-
"zod": "^
|
|
35
|
+
"zod": "^4.1.13",
|
|
34
36
|
"@pagopa/dx-savemoney": "^0.1.4",
|
|
35
|
-
"@pagopa/monorepo-generator": "^0.
|
|
37
|
+
"@pagopa/monorepo-generator": "^0.13.0"
|
|
36
38
|
},
|
|
37
39
|
"devDependencies": {
|
|
38
40
|
"@tsconfig/node22": "22.0.2",
|