create-prisma 0.4.2-pr.34.112.1 → 0.4.2-pr.34.114.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.
package/dist/cli.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import "./create-D7XYRH3T.mjs";
2
+ import "./create-CzguBCmV.mjs";
3
3
  import { createCreatePrismaCli } from "./index.mjs";
4
4
 
5
5
  //#region src/cli.ts
@@ -1707,8 +1707,6 @@ async function executeCreateAddonSetupContext(params) {
1707
1707
  //#endregion
1708
1708
  //#region src/tasks/deploy-to-compute.ts
1709
1709
  const PRISMA_CLI_PACKAGE = "@prisma/cli@latest";
1710
- const COMPUTE_DEPLOY_BRANCH = "main";
1711
- const COMPUTE_ENV_ROLE = "production";
1712
1710
  const DEPLOY_OPTIONS_BY_TEMPLATE = {
1713
1711
  hono: {
1714
1712
  framework: "hono",
@@ -1724,6 +1722,26 @@ const DEPLOY_OPTIONS_BY_TEMPLATE = {
1724
1722
  function getPrismaCliCommand(packageManager) {
1725
1723
  return getPackageExecutionCommand(getPrismaCliExecutionPackageManager(packageManager), [PRISMA_CLI_PACKAGE]);
1726
1724
  }
1725
+ function getPrismaCliAppDeployCommand(packageManager) {
1726
+ return getPackageExecutionCommand(getPrismaCliExecutionPackageManager(packageManager), [
1727
+ PRISMA_CLI_PACKAGE,
1728
+ "app",
1729
+ "deploy"
1730
+ ]);
1731
+ }
1732
+ function getComputeDeployScriptMap(context) {
1733
+ const deployArgs = [
1734
+ "--prod",
1735
+ "--framework",
1736
+ context.framework,
1737
+ ...context.httpPort ? ["--http-port", String(context.httpPort)] : []
1738
+ ];
1739
+ const deployCommand = [getPrismaCliAppDeployCommand(context.packageManager), ...deployArgs].join(" ");
1740
+ return {
1741
+ "compute:deploy": deployCommand,
1742
+ "compute:deploy:ci": `${deployCommand} --yes`
1743
+ };
1744
+ }
1727
1745
  function runPrismaCli(packageManager, args, options = {}) {
1728
1746
  const execution = getPackageExecutionArgs(getPrismaCliExecutionPackageManager(packageManager), [PRISMA_CLI_PACKAGE, ...args]);
1729
1747
  return execa(execution.command, execution.args, options);
@@ -1806,15 +1824,6 @@ function redactSecrets(message) {
1806
1824
  return message.replace(/(['"])([A-Z0-9_]*(?:DATABASE_URL|DIRECT_URL|TOKEN|SECRET|PASSWORD|API_KEY|PRIVATE_KEY|ACCESS_KEY)[A-Z0-9_]*=)(.*?)\1/g, "$1$2<redacted>$1").replace(/\b([A-Z0-9_]*(?:DATABASE_URL|DIRECT_URL|TOKEN|SECRET|PASSWORD|API_KEY|PRIVATE_KEY|ACCESS_KEY)[A-Z0-9_]*=)[^\s]+/g, "$1<redacted>");
1807
1825
  }
1808
1826
  function parseDeployJson(stdout) {
1809
- return parsePrismaCliJson(stdout);
1810
- }
1811
- function parseProjectCreateJson(stdout) {
1812
- return parsePrismaCliJson(stdout);
1813
- }
1814
- function parseProjectEnvJson(stdout) {
1815
- return parsePrismaCliJson(stdout);
1816
- }
1817
- function parsePrismaCliJson(stdout) {
1818
1827
  if (typeof stdout !== "string" || stdout.trim().length === 0) return null;
1819
1828
  try {
1820
1829
  return JSON.parse(stdout);
@@ -1846,70 +1855,9 @@ function toComputeDeployResult(data) {
1846
1855
  branchName: data.result.branch.name
1847
1856
  };
1848
1857
  }
1849
- async function createComputeProjectForDeploy(params) {
1850
- const { stdout, exitCode } = await runPrismaCli(params.context.packageManager, [
1851
- "project",
1852
- "create",
1853
- params.context.createProjectName,
1854
- "--json",
1855
- "--yes"
1856
- ], {
1857
- cwd: params.projectDir,
1858
- reject: false,
1859
- stdio: [
1860
- "ignore",
1861
- "pipe",
1862
- "pipe"
1863
- ]
1864
- });
1865
- const parsed = parseProjectCreateJson(stdout);
1866
- if (!parsed) throw new Error("Could not parse prisma project create output.");
1867
- if (exitCode !== 0 || !parsed.ok) throw createDeployError(parsed.ok ? "Prisma project create failed." : getJsonErrorMessage(parsed.error, "Prisma project create failed."));
1868
- return parsed.result.project.id;
1869
- }
1870
- async function writeComputeEnvironmentVariables(params) {
1871
- for (const [key, value] of Object.entries(params.envVars ?? {})) {
1872
- const commonArgs = [
1873
- `${key}=${value}`,
1874
- "--project",
1875
- params.projectRef,
1876
- "--role",
1877
- COMPUTE_ENV_ROLE,
1878
- "--json",
1879
- "--yes"
1880
- ];
1881
- if ((await runProjectEnvCommand(params.context, params.projectDir, ["add", ...commonArgs])).ok) continue;
1882
- const updateResult = await runProjectEnvCommand(params.context, params.projectDir, ["update", ...commonArgs]);
1883
- if (!updateResult.ok) throw createDeployError(getJsonErrorMessage(updateResult.error, `Failed to configure ${key} for Prisma Compute.`));
1884
- }
1885
- }
1886
- async function runProjectEnvCommand(context, projectDir, args) {
1887
- const { stdout, exitCode } = await runPrismaCli(context.packageManager, [
1888
- "project",
1889
- "env",
1890
- ...args
1891
- ], {
1892
- cwd: projectDir,
1893
- reject: false,
1894
- stdio: [
1895
- "ignore",
1896
- "pipe",
1897
- "pipe"
1898
- ]
1899
- });
1900
- const parsed = parseProjectEnvJson(stdout);
1901
- if (!parsed) throw new Error("Could not parse prisma project env output.");
1902
- if (exitCode !== 0 && parsed.ok) return {
1903
- ok: false,
1904
- error: { message: "Prisma project env command failed." }
1905
- };
1906
- return parsed;
1907
- }
1908
1858
  async function executeComputeDeployContext(params) {
1909
1859
  const deploySpinner = spinner();
1910
1860
  deploySpinner.start("Deploying to Prisma Compute...");
1911
- const envVars = params.envVars ?? {};
1912
- const shouldPreconfigureEnvVars = Object.keys(envVars).length > 0;
1913
1861
  const args = [
1914
1862
  "app",
1915
1863
  "deploy",
@@ -1917,23 +1865,11 @@ async function executeComputeDeployContext(params) {
1917
1865
  "--yes",
1918
1866
  "--framework",
1919
1867
  params.context.framework,
1920
- "--branch",
1921
- COMPUTE_DEPLOY_BRANCH
1868
+ "--create-project",
1869
+ params.context.createProjectName
1922
1870
  ];
1923
1871
  try {
1924
- if (shouldPreconfigureEnvVars) {
1925
- const projectRef = await createComputeProjectForDeploy({
1926
- context: params.context,
1927
- projectDir: params.projectDir
1928
- });
1929
- await writeComputeEnvironmentVariables({
1930
- context: params.context,
1931
- projectDir: params.projectDir,
1932
- projectRef,
1933
- envVars
1934
- });
1935
- args.push("--project", projectRef);
1936
- } else args.push("--create-project", params.context.createProjectName);
1872
+ for (const [key, value] of Object.entries(params.envVars ?? {})) args.push("--env", `${key}=${value}`);
1937
1873
  if (params.context.httpPort) args.push("--http-port", String(params.context.httpPort));
1938
1874
  const { stdout, exitCode } = await runPrismaCli(params.context.packageManager, args, {
1939
1875
  cwd: params.projectDir,
@@ -2024,7 +1960,7 @@ async function getAnonymousId() {
2024
1960
  }
2025
1961
  function getCommonProperties() {
2026
1962
  return {
2027
- "cli-version": "0.4.2-pr.34.112.1",
1963
+ "cli-version": "0.4.2-pr.34.114.1",
2028
1964
  "node-version": process.version,
2029
1965
  platform: process.platform,
2030
1966
  arch: process.arch
@@ -2358,6 +2294,11 @@ async function executeCreateContext(context) {
2358
2294
  packageManager: context.prismaSetupContext.packageManager,
2359
2295
  projectDir: context.targetDirectory
2360
2296
  });
2297
+ if (context.computeDeployContext) await addPackageDependency({
2298
+ scripts: getComputeDeployScriptMap(context.computeDeployContext),
2299
+ scriptMode: "if-missing",
2300
+ projectDir: context.targetDirectory
2301
+ });
2361
2302
  } catch (error) {
2362
2303
  return {
2363
2304
  ok: false,
@@ -2411,7 +2352,10 @@ async function executeCreateContext(context) {
2411
2352
  stage: "compute_deploy",
2412
2353
  error: result.error
2413
2354
  };
2414
- if (result.ok) deployResult = result.result;
2355
+ if (result.ok) {
2356
+ deployResult = result.result;
2357
+ prismaResult.nextSteps.push(`- ${getRunScriptCommand(context.prismaSetupContext.packageManager, "compute:deploy")}`);
2358
+ }
2415
2359
  } catch (error) {
2416
2360
  return {
2417
2361
  ok: false,
package/dist/index.mjs CHANGED
@@ -1,10 +1,10 @@
1
1
  #!/usr/bin/env node
2
- import { a as DatabaseUrlSchema, i as DatabaseProviderSchema, n as CreateCommandInputSchema, o as PackageManagerSchema, r as CreateTemplateSchema, s as SchemaPresetSchema, t as runCreateCommand } from "./create-D7XYRH3T.mjs";
2
+ import { a as DatabaseUrlSchema, i as DatabaseProviderSchema, n as CreateCommandInputSchema, o as PackageManagerSchema, r as CreateTemplateSchema, s as SchemaPresetSchema, t as runCreateCommand } from "./create-CzguBCmV.mjs";
3
3
  import { os } from "@orpc/server";
4
4
  import { createCli } from "trpc-cli";
5
5
 
6
6
  //#region src/index.ts
7
- const CLI_VERSION = "0.4.2-pr.34.112.1";
7
+ const CLI_VERSION = "0.4.2-pr.34.114.1";
8
8
  const router = os.router({ create: os.meta({
9
9
  description: "Create a new project with Prisma setup",
10
10
  default: true,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-prisma",
3
- "version": "0.4.2-pr.34.112.1",
3
+ "version": "0.4.2-pr.34.114.1",
4
4
  "private": false,
5
5
  "description": "Create Prisma 7 projects with first-party templates and great DX.",
6
6
  "homepage": "https://github.com/prisma/create-prisma",