@pagopa/dx-cli 0.5.0 → 0.6.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 +56 -19
- package/package.json +6 -4
package/bin/index.js
CHANGED
|
@@ -40,7 +40,7 @@ registry.add(example_default);
|
|
|
40
40
|
var codemods_default = registry;
|
|
41
41
|
|
|
42
42
|
// src/adapters/commander/index.ts
|
|
43
|
-
import { Command as
|
|
43
|
+
import { Command as Command6 } from "commander";
|
|
44
44
|
|
|
45
45
|
// src/adapters/commander/commands/codemod.ts
|
|
46
46
|
import { Command } from "commander";
|
|
@@ -364,27 +364,64 @@ var makeInfoCommand = (dependencies, config2) => new Command3().name("info").des
|
|
|
364
364
|
printInfo(result);
|
|
365
365
|
});
|
|
366
366
|
|
|
367
|
-
// src/adapters/commander/commands/
|
|
367
|
+
// src/adapters/commander/commands/init.ts
|
|
368
|
+
import scaffoldMonorepo from "@pagopa/monorepo-generator";
|
|
368
369
|
import { Command as Command4 } from "commander";
|
|
370
|
+
import { Result, ResultAsync as ResultAsync4 } from "neverthrow";
|
|
371
|
+
import nodePlop from "node-plop";
|
|
372
|
+
var initPlop = () => ResultAsync4.fromPromise(
|
|
373
|
+
nodePlop(),
|
|
374
|
+
() => new Error("Failed to initialize plop")
|
|
375
|
+
);
|
|
376
|
+
var getGenerator = (plopAPI) => Result.fromThrowable(
|
|
377
|
+
plopAPI.getGenerator,
|
|
378
|
+
() => new Error("Generator not found")
|
|
379
|
+
);
|
|
380
|
+
var runGenerator = (generator) => ResultAsync4.fromPromise(
|
|
381
|
+
generator.runPrompts(),
|
|
382
|
+
() => new Error("Failed to run the generator prompts")
|
|
383
|
+
).andThen(
|
|
384
|
+
(answers) => ResultAsync4.fromPromise(
|
|
385
|
+
generator.runActions(answers),
|
|
386
|
+
() => new Error("Failed to run the generator actions")
|
|
387
|
+
)
|
|
388
|
+
);
|
|
389
|
+
var makeInitCommand = () => new Command4().name("init").description(
|
|
390
|
+
"Command to initialize resources (like projects, subscriptions, ...)"
|
|
391
|
+
).addCommand(
|
|
392
|
+
new Command4("project").description("Initialize a new monorepo project").action(async function() {
|
|
393
|
+
await initPlop().andTee(scaffoldMonorepo).andThen((plop) => getGenerator(plop)("monorepo")).andThen(runGenerator).andTee(() => {
|
|
394
|
+
console.log("Monorepo initialized successfully \u2705");
|
|
395
|
+
}).orTee((err2) => {
|
|
396
|
+
this.error(err2.message);
|
|
397
|
+
});
|
|
398
|
+
})
|
|
399
|
+
);
|
|
400
|
+
|
|
401
|
+
// src/adapters/commander/commands/version.ts
|
|
402
|
+
import { Command as Command5 } from "commander";
|
|
369
403
|
|
|
370
404
|
// src/domain/version.ts
|
|
371
405
|
import { getLogger as getLogger2 } from "@logtape/logtape";
|
|
372
406
|
function printVersion() {
|
|
373
407
|
const logger2 = getLogger2(["dx-cli", "version"]);
|
|
374
|
-
logger2.info(`dx CLI version: ${"0.
|
|
408
|
+
logger2.info(`dx CLI version: ${"0.6.0"}`);
|
|
375
409
|
}
|
|
376
410
|
|
|
377
411
|
// src/adapters/commander/commands/version.ts
|
|
378
|
-
var makeVersionCommand = () => new
|
|
412
|
+
var makeVersionCommand = () => new Command5().name("version").alias("v").action(() => printVersion());
|
|
379
413
|
|
|
380
414
|
// src/adapters/commander/index.ts
|
|
381
415
|
var makeCli = (deps2, config2) => {
|
|
382
|
-
const program2 = new
|
|
383
|
-
program2.name("dx").description("The CLI for DX-Platform").version("0.
|
|
416
|
+
const program2 = new Command6();
|
|
417
|
+
program2.name("dx").description("The CLI for DX-Platform").version("0.6.0");
|
|
384
418
|
program2.addCommand(makeDoctorCommand(deps2, config2));
|
|
385
419
|
if (process.env.ENABLE_CODEMODS) {
|
|
386
420
|
program2.addCommand(makeCodemodCommand(deps2));
|
|
387
421
|
}
|
|
422
|
+
if (process.env.ENABLE_INIT_COMMAND) {
|
|
423
|
+
program2.addCommand(makeInitCommand());
|
|
424
|
+
}
|
|
388
425
|
program2.addCommand(makeVersionCommand());
|
|
389
426
|
program2.addCommand(makeInfoCommand(deps2, config2));
|
|
390
427
|
return program2;
|
|
@@ -410,30 +447,30 @@ import { join as join2 } from "path";
|
|
|
410
447
|
import * as process3 from "process";
|
|
411
448
|
|
|
412
449
|
// src/adapters/node/fs/file-reader.ts
|
|
413
|
-
import { ResultAsync as
|
|
450
|
+
import { ResultAsync as ResultAsync6 } from "neverthrow";
|
|
414
451
|
import fs2 from "fs/promises";
|
|
415
452
|
|
|
416
453
|
// src/adapters/zod/index.ts
|
|
417
|
-
import { ResultAsync as
|
|
418
|
-
var decode = (schema) =>
|
|
454
|
+
import { ResultAsync as ResultAsync5 } from "neverthrow";
|
|
455
|
+
var decode = (schema) => ResultAsync5.fromThrowable(
|
|
419
456
|
schema.parseAsync,
|
|
420
457
|
(cause) => new Error("File content is not valid for the given schema", { cause })
|
|
421
458
|
);
|
|
422
459
|
|
|
423
460
|
// src/adapters/node/json/index.ts
|
|
424
|
-
import { Result } from "neverthrow";
|
|
425
|
-
var parseJson =
|
|
461
|
+
import { Result as Result2 } from "neverthrow";
|
|
462
|
+
var parseJson = Result2.fromThrowable(
|
|
426
463
|
JSON.parse,
|
|
427
464
|
(cause) => new Error("Failed to parse JSON", { cause })
|
|
428
465
|
);
|
|
429
466
|
|
|
430
467
|
// src/adapters/node/fs/file-reader.ts
|
|
431
|
-
var readFile = (filePath) =>
|
|
468
|
+
var readFile = (filePath) => ResultAsync6.fromPromise(
|
|
432
469
|
fs2.readFile(filePath, "utf-8"),
|
|
433
470
|
(cause) => new Error(`Failed to read file: ${filePath}`, { cause })
|
|
434
471
|
);
|
|
435
472
|
var readFileAndDecode = (filePath, schema) => readFile(filePath).andThen(parseJson).andThen(decode(schema));
|
|
436
|
-
var fileExists = (path2) =>
|
|
473
|
+
var fileExists = (path2) => ResultAsync6.fromPromise(
|
|
437
474
|
fs2.stat(path2),
|
|
438
475
|
() => new Error(`${path2} not found.`)
|
|
439
476
|
).map(() => true);
|
|
@@ -464,14 +501,14 @@ var makePackageJsonReader = () => ({
|
|
|
464
501
|
|
|
465
502
|
// src/adapters/node/repository.ts
|
|
466
503
|
import * as glob from "glob";
|
|
467
|
-
import { okAsync as okAsync3, ResultAsync as
|
|
504
|
+
import { okAsync as okAsync3, ResultAsync as ResultAsync7 } from "neverthrow";
|
|
468
505
|
import * as path from "path";
|
|
469
506
|
import { z as z3 } from "zod/v4";
|
|
470
507
|
|
|
471
508
|
// src/adapters/yaml/index.ts
|
|
472
|
-
import { Result as
|
|
509
|
+
import { Result as Result3 } from "neverthrow";
|
|
473
510
|
import yaml from "yaml";
|
|
474
|
-
var parseYaml =
|
|
511
|
+
var parseYaml = Result3.fromThrowable(
|
|
475
512
|
(content) => yaml.parse(content),
|
|
476
513
|
() => new Error("Failed to parse YAML")
|
|
477
514
|
);
|
|
@@ -485,7 +522,7 @@ var findRepositoryRoot = (dir = process.cwd()) => {
|
|
|
485
522
|
)
|
|
486
523
|
).map(() => dir);
|
|
487
524
|
};
|
|
488
|
-
var resolveWorkspacePattern = (repoRoot2, pattern) =>
|
|
525
|
+
var resolveWorkspacePattern = (repoRoot2, pattern) => ResultAsync7.fromPromise(
|
|
489
526
|
// For now it is not possible to use the fs.glob function (from node:fs/promises)
|
|
490
527
|
// because it is not possible to run it on Node 20.x
|
|
491
528
|
glob.glob(pattern, { cwd: repoRoot2 }),
|
|
@@ -508,7 +545,7 @@ var getWorkspaces = (repoRoot2) => readFile(path.join(repoRoot2, "pnpm-workspace
|
|
|
508
545
|
).andThen(
|
|
509
546
|
({ packages }) => (
|
|
510
547
|
// For every package pattern in the pnpm-workspace.yaml file, get the list of subdirectories
|
|
511
|
-
|
|
548
|
+
ResultAsync7.combine(
|
|
512
549
|
packages.map((pattern) => resolveWorkspacePattern(repoRoot2, pattern))
|
|
513
550
|
).map((workspacesList) => workspacesList.flat()).andThen((workspaceFolders) => {
|
|
514
551
|
const workspaceResults = workspaceFolders.map(
|
|
@@ -522,7 +559,7 @@ var getWorkspaces = (repoRoot2) => readFile(path.join(repoRoot2, "pnpm-workspace
|
|
|
522
559
|
)
|
|
523
560
|
)
|
|
524
561
|
);
|
|
525
|
-
return
|
|
562
|
+
return ResultAsync7.combine(workspaceResults);
|
|
526
563
|
})
|
|
527
564
|
)
|
|
528
565
|
);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pagopa/dx-cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "A CLI useful to manage DX tools.",
|
|
6
6
|
"repository": {
|
|
@@ -24,14 +24,16 @@
|
|
|
24
24
|
"core-js": "^3.44.0",
|
|
25
25
|
"glob": "^11.0.3",
|
|
26
26
|
"neverthrow": "^8.2.0",
|
|
27
|
+
"node-plop": "^0.32.1",
|
|
27
28
|
"semver": "^7.7.2",
|
|
28
29
|
"yaml": "^2.8.0",
|
|
29
|
-
"zod": "^3.25.28"
|
|
30
|
+
"zod": "^3.25.28",
|
|
31
|
+
"@pagopa/monorepo-generator": "^0.6.0"
|
|
30
32
|
},
|
|
31
33
|
"devDependencies": {
|
|
32
34
|
"@tsconfig/node22": "22.0.2",
|
|
33
35
|
"@types/node": "^22.16.2",
|
|
34
|
-
"@types/semver": "^7.7.
|
|
36
|
+
"@types/semver": "^7.7.1",
|
|
35
37
|
"@vitest/coverage-v8": "^3.2.4",
|
|
36
38
|
"eslint": "^9.30.0",
|
|
37
39
|
"memfs": "^4.23.0",
|
|
@@ -40,7 +42,7 @@
|
|
|
40
42
|
"typescript": "~5.8.3",
|
|
41
43
|
"vitest": "^3.2.4",
|
|
42
44
|
"vitest-mock-extended": "^3.1.0",
|
|
43
|
-
"@pagopa/eslint-config": "^5.
|
|
45
|
+
"@pagopa/eslint-config": "^5.1.0"
|
|
44
46
|
},
|
|
45
47
|
"engines": {
|
|
46
48
|
"node": ">=22.0.0"
|