create-prisma 0.11.2 → 0.11.3

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/index.mjs CHANGED
@@ -1,38 +1,74 @@
1
1
  #!/usr/bin/env node
2
- import { a as DatabaseProviderSchema, i as CreateTemplateSchema, n as AuthoringStyleSchema, o as PackageManagerSchema, r as CreateCommandInputSchema, s as CREATE_PRISMA_RESULT_SCHEMA_VERSION, t as runCreateCommand } from "./create-TR_gtjND.mjs";
3
- import { os } from "@orpc/server";
4
- import { createCli } from "trpc-cli";
5
- import { z } from "zod";
2
+ import { _ as databaseProviderInputs, c as CreateCommandResultSchema, d as CreateCommandInputSchema, f as CreateTemplateSchema, g as createTemplates, h as authoringStyles, i as getErrorMessage, l as createCommandFailureResult, m as PackageManagerSchema, n as writeJsonResult, o as applicationRuntime, p as DatabaseProviderSchema, r as runCreateCommandEffect, s as CREATE_PRISMA_RESULT_SCHEMA_VERSION, t as isJsonOutputRequested, u as AuthoringStyleSchema, v as normalizeDatabaseProvider, y as packageManagers } from "./json-output-DzDD1nb9.mjs";
3
+ import { Console, Effect, Option } from "effect";
4
+ import { Argument, CliError, Command, Flag } from "effect/unstable/cli";
6
5
 
7
6
  //#region src/index.ts
8
- const CLI_VERSION = "0.11.2";
9
- const CreateCliInputSchema = z.tuple([z.string().trim().min(1, "Please enter a valid project name").optional().describe("Project name / directory"), CreateCommandInputSchema]);
10
- function normalizeCreateCliInput(input) {
11
- const [projectName, options] = input;
12
- return {
13
- ...options,
14
- name: options.name ?? projectName
7
+ const CLI_VERSION = "0.11.3";
8
+ const optionalArgument = (name, description) => Argument.string(name).pipe(Argument.withDescription(description), Argument.optional, Argument.map(Option.getOrUndefined));
9
+ const optionalBoolean = (name, description) => Flag.boolean(name).pipe(Flag.withDescription(description), Flag.optional, Flag.map(Option.getOrUndefined));
10
+ const optionalString = (name, description) => Flag.string(name).pipe(Flag.withDescription(description), Flag.optional, Flag.map(Option.getOrUndefined));
11
+ const createPrismaCommand = Command.make("create-prisma", {
12
+ projectName: optionalArgument("project-name", "Project name / directory"),
13
+ name: optionalString("name", "Project name / directory"),
14
+ template: Flag.choice("template", createTemplates).pipe(Flag.withDescription("Project template"), Flag.optional, Flag.map(Option.getOrUndefined)),
15
+ provider: Flag.choice("provider", databaseProviderInputs).pipe(Flag.withDescription("Database provider"), Flag.optional, Flag.map(Option.map(normalizeDatabaseProvider)), Flag.map(Option.getOrUndefined)),
16
+ authoring: Flag.choice("authoring", authoringStyles).pipe(Flag.withDescription("Contract authoring style"), Flag.optional, Flag.map(Option.getOrUndefined)),
17
+ packageManager: Flag.choice("package-manager", packageManagers).pipe(Flag.withDescription("Package manager used for dependency installation"), Flag.optional, Flag.map(Option.getOrUndefined)),
18
+ deploy: optionalBoolean("deploy", "Deploy the generated app to Prisma immediately"),
19
+ workspace: optionalString("workspace", "Prisma workspace id or name to deploy into"),
20
+ force: optionalBoolean("force", "Allow scaffolding into a non-empty target directory"),
21
+ yes: optionalBoolean("yes", "Skip prompts and accept default choices"),
22
+ verbose: optionalBoolean("verbose", "Show verbose command output during setup"),
23
+ json: optionalBoolean("json", "Emit one quiet JSON result for agents and automation (non-interactive; deploys unless --no-deploy)")
24
+ }, Effect.fn("Cli.create")(function* (options) {
25
+ const input = {
26
+ ...options.name ?? options.projectName ? { name: options.name ?? options.projectName } : {},
27
+ ...options.template ? { template: options.template } : {},
28
+ ...options.provider ? { provider: options.provider } : {},
29
+ ...options.authoring ? { authoring: options.authoring } : {},
30
+ ...options.packageManager ? { packageManager: options.packageManager } : {},
31
+ ...options.deploy !== void 0 ? { deploy: options.deploy } : {},
32
+ ...options.workspace ? { workspace: options.workspace } : {},
33
+ ...options.force !== void 0 ? { force: options.force } : {},
34
+ ...options.yes !== void 0 ? { yes: options.yes } : {},
35
+ ...options.verbose !== void 0 ? { verbose: options.verbose } : {},
36
+ ...options.json !== void 0 ? { json: options.json } : {}
15
37
  };
16
- }
17
- const router = os.router({ create: os.meta({
18
- description: "Create a new project with Prisma setup",
19
- default: true,
20
- negateBooleans: true
21
- }).input(CreateCliInputSchema).handler(async ({ input }) => {
22
- const createInput = normalizeCreateCliInput(input);
23
- const result = await runCreateCommand(createInput);
24
- return createInput.json ? result : void 0;
25
- }) });
38
+ const result = yield* runCreateCommandEffect(input);
39
+ if (input.json) yield* writeJsonResult(result);
40
+ if (!result.ok) yield* Effect.sync(() => void (process.exitCode = 1));
41
+ })).pipe(Command.withDescription("Create a new project with Prisma setup"), Command.withExamples([{
42
+ command: "create-prisma my-app",
43
+ description: "Create a project interactively"
44
+ }, {
45
+ command: "create-prisma my-app --yes --json",
46
+ description: "Create and deploy with machine-readable output"
47
+ }]));
48
+ const silentConsole = Object.assign(Object.create(console), {
49
+ log() {},
50
+ error() {}
51
+ });
26
52
  function createCreatePrismaCli() {
27
- return createCli({
28
- router,
29
- name: "create-prisma",
30
- version: CLI_VERSION
31
- });
53
+ return createPrismaCommand;
54
+ }
55
+ function runCreatePrismaCli(argv = process.argv.slice(2)) {
56
+ const json = isJsonOutputRequested(argv);
57
+ const args = argv[0] === "create" ? argv.slice(1) : argv;
58
+ let program = Command.runWith(createPrismaCommand, {
59
+ version: CLI_VERSION,
60
+ renderErrors: !json
61
+ })(args).pipe(Effect.catch((error) => Effect.gen(function* () {
62
+ if (error instanceof CliError.ShowHelp && error.errors.length === 0) return;
63
+ process.exitCode = 1;
64
+ if (json) yield* writeJsonResult(createCommandFailureResult("parse_arguments", error instanceof CliError.ShowHelp ? error.errors.map((item) => item.message).join("; ") : getErrorMessage(error)));
65
+ })));
66
+ if (json) program = Effect.provideService(program, Console.Console, silentConsole);
67
+ return program;
32
68
  }
33
- async function create(input = {}) {
34
- await runCreateCommand(input);
69
+ function create(input = {}) {
70
+ return applicationRuntime.runPromise(runCreateCommandEffect(input).pipe(Effect.asVoid));
35
71
  }
36
72
 
37
73
  //#endregion
38
- export { AuthoringStyleSchema, CREATE_PRISMA_RESULT_SCHEMA_VERSION, CreateCommandInputSchema, CreateTemplateSchema, DatabaseProviderSchema, PackageManagerSchema, create, createCreatePrismaCli, router };
74
+ export { AuthoringStyleSchema, CREATE_PRISMA_RESULT_SCHEMA_VERSION, CreateCommandInputSchema, CreateCommandResultSchema, CreateTemplateSchema, DatabaseProviderSchema, PackageManagerSchema, create, createCreatePrismaCli, createPrismaCommand, runCreatePrismaCli };