diff --git a/packages/cli/package.json b/packages/cli/package.json index fe55d498dd65..3d5ea9c4659c 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -42,11 +42,11 @@ "change-case": "^5.4.4", "deepmerge": "^4.3.1", "env-paths": "^3.0.0", - "execa": "^7.2.0", "p-limit": "^4.0.0", "parse5": "7.1.2", "picocolors": "^1.1.0", "strip-indent": "^4.0.0", + "tinyexec": "^0.3.1", "yargs": "^17.7.2", "zod": "^3.22.4" }, diff --git a/packages/cli/src/commands/init-flow.ts b/packages/cli/src/commands/init-flow.ts index 22d8ac22da4c..4e49634067d2 100644 --- a/packages/cli/src/commands/init-flow.ts +++ b/packages/cli/src/commands/init-flow.ts @@ -1,6 +1,7 @@ import { chdir, cwd } from "node:process"; import { join } from "node:path"; import pc from "picocolors"; +import { x } from "tinyexec"; import { cancel, confirm, @@ -10,7 +11,6 @@ import { spinner, text, } from "@clack/prompts"; -import { $ } from "execa"; import { createFolderIfNotExists, isFileExists } from "../fs-utils"; import { PROJECT_TEMPLATES } from "../config"; import { link, validateShareLink } from "./link"; @@ -112,7 +112,7 @@ export const initFlow = async ( if (shouldInstallDeps === true) { const install = spinner(); install.start("Installing dependencies"); - await $`npm install`; + await x("npm", ["install"]); install.stop("Installed dependencies"); } diff --git a/packages/prisma-client/migrations-cli/cli.ts b/packages/prisma-client/migrations-cli/cli.ts index a9644bfe532c..46f44a4dc569 100755 --- a/packages/prisma-client/migrations-cli/cli.ts +++ b/packages/prisma-client/migrations-cli/cli.ts @@ -14,7 +14,6 @@ Commands: create-schema — Create a migration based on the changes in schema.prisma create-data — Create a migration that will change data rather than schema migrate — Apply all pending migrations - reset — Clear the database and apply all migrations status — Information about the state of the migrations pending-count — Get the number of pending migrations resolve — Mark a failed migration as applied or rolled-back @@ -102,11 +101,6 @@ const main = async () => { return; } - if (command === "reset") { - await commands.reset(); - return; - } - throw new UserError(`Unknown command: ${command}`); }; diff --git a/packages/prisma-client/migrations-cli/commands.ts b/packages/prisma-client/migrations-cli/commands.ts index 8a0ee574e5b6..1bb6681de86a 100644 --- a/packages/prisma-client/migrations-cli/commands.ts +++ b/packages/prisma-client/migrations-cli/commands.ts @@ -346,16 +346,3 @@ export const resolve = async ({ logger.info(`Resolved ${migrationName} as rolled back`); logger.info(""); }; - -export const reset = async () => { - // Just to make it read the migrations folder - // and fail early if something is wrong with it. - await getStatus(); - - logger.info("You're about to DELETE ALL INFORMATION from the database,"); - logger.info("and run all migrations from scratch!"); - logger.info(""); - - await prismaMigrations.resetDatabase(); - await up(); -}; diff --git a/packages/prisma-client/migrations-cli/prisma-migrations.ts b/packages/prisma-client/migrations-cli/prisma-migrations.ts index 8f68c0d7c5a7..22c8f048fa5a 100644 --- a/packages/prisma-client/migrations-cli/prisma-migrations.ts +++ b/packages/prisma-client/migrations-cli/prisma-migrations.ts @@ -2,11 +2,11 @@ // We want to preserve semantics of the migrations folder and the _prisma_migrations table. // https://github.com/prisma/prisma-engines/blob/4.3.0/migration-engine/ARCHITECTURE.md -import { $ } from "execa"; import path from "node:path"; import fs from "node:fs"; import { fileURLToPath } from "node:url"; import { createHash } from "node:crypto"; +import { x } from "tinyexec"; import { createPrisma } from "../src/prisma"; import { UserError } from "./errors"; import { PrismaClient } from "../src/__generated__"; @@ -248,32 +248,33 @@ export const generateMigrationName = (baseName: string) => { return `${prefix}_${baseName}`.slice(0, 254); }; -export const resetDatabase = async () => { - const { stdout: sqlToDeleteEverything } = await $({ - cwd: prismaDir, - })`"prisma migrate diff --from-schema-datasource ${schemaFilePath} --to-empty --script`; - - await $({ - input: sqlToDeleteEverything, - cwd: prismaDir, - })`prisma db execute --stdin --schema ${schemaFilePath}`; - - await context.prisma.$executeRaw`DROP TABLE IF EXISTS _prisma_migrations`; -}; - // https://www.prisma.io/docs/reference/api-reference/command-reference#migrate-diff export const cliDiff = async () => { - const { stdout } = await $({ - cwd: prismaDir, - })`prisma migrate diff --from-schema-datasource ${schemaFilePath} --to-schema-datamodel ${schemaFilePath} --script`; + const { stdout } = await x( + "prisma", + [ + "migrate", + "diff", + `--from-schema-datasource=${schemaFilePath}`, + `--to-schema-datamodel=${schemaFilePath}`, + "--script", + ], + { + nodeOptions: { cwd: prismaDir }, + } + ); return stdout; }; // https://www.prisma.io/docs/reference/api-reference/command-reference#db-execute export const cliExecute = async (filePath: string) => { - await $({ - cwd: prismaDir, - })`prisma db execute --file ${filePath} --schema ${schemaFilePath}`; + await x( + "prisma", + ["db", "execute", `--file=${filePath}`, `--schema=${schemaFilePath}`], + { + nodeOptions: { cwd: prismaDir }, + } + ); }; export const generateMigrationClient = async (migrationName: string) => { @@ -297,7 +298,7 @@ export const generateMigrationClient = async (migrationName: string) => { } // https://www.prisma.io/docs/reference/api-reference/command-reference#generate - await $({ - cwd: prismaDir, - })`prisma generate --schema ${schemaPath}`; + await x("prisma", ["generate", `--schema=${schemaPath}`], { + nodeOptions: { cwd: prismaDir }, + }); }; diff --git a/packages/prisma-client/package.json b/packages/prisma-client/package.json index 46c33a578c2a..beebfca5543b 100644 --- a/packages/prisma-client/package.json +++ b/packages/prisma-client/package.json @@ -25,8 +25,7 @@ "license": "AGPL-3.0-or-later", "private": true, "dependencies": { - "execa": "^7.2.0", - "nanoid": "^5.0.1", + "tinyexec": "^0.3.1", "umzug": "^3.2.1" }, "peerDependencies": { diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index b9d3c893d84a..b8b6dd9dc533 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -1065,9 +1065,6 @@ importers: env-paths: specifier: ^3.0.0 version: 3.0.0 - execa: - specifier: ^7.2.0 - version: 7.2.0 p-limit: specifier: ^4.0.0 version: 4.0.0 @@ -1080,6 +1077,9 @@ importers: strip-indent: specifier: ^4.0.0 version: 4.0.0 + tinyexec: + specifier: ^0.3.1 + version: 0.3.1 yargs: specifier: ^17.7.2 version: 17.7.2 @@ -1697,12 +1697,9 @@ importers: packages/prisma-client: dependencies: - execa: - specifier: ^7.2.0 - version: 7.2.0 - nanoid: - specifier: ^5.0.1 - version: 5.0.1 + tinyexec: + specifier: ^0.3.1 + version: 0.3.1 umzug: specifier: ^3.2.1 version: 3.2.1 @@ -6349,10 +6346,6 @@ packages: resolution: {integrity: sha512-8uSpZZocAZRBAPIEINJj3Lo9HyGitllczc27Eh5YYojjMFMn8yHMDMaUHE2Jqfq05D/wucwI4JGURyXt1vchyg==} engines: {node: '>=10'} - execa@7.2.0: - resolution: {integrity: sha512-UduyVP7TLB5IcAQl+OzLyLcS/l32W/GLg+AhHJ+ow40FOk2U3SAllPwR44v4vmdFwIWqpdwxxpQbF1n5ta9seA==} - engines: {node: ^14.18.0 || ^16.14.0 || >=18.0.0} - exit-hook@2.2.1: resolution: {integrity: sha512-eNTPlAD67BmP31LDINZ3U7HSF8l57TxOY2PmBJ1shpCvpnxBF93mWCE8YHBnXs8qiUZJc9WDcWIeC3a2HIAMfw==} engines: {node: '>=6'} @@ -6692,10 +6685,6 @@ packages: resolution: {integrity: sha512-B4FFZ6q/T2jhhksgkbEW3HBvWIfDW85snkQgawt07S7J5QXTk6BkNV+0yAeZrM5QpMAdYlocGoljn0sJ/WQkFw==} engines: {node: '>=10.17.0'} - human-signals@4.3.1: - resolution: {integrity: sha512-nZXjEF2nbo7lIw3mgYjItAfgQXog3OjJogSbKa2CQIIvSGWcKgeJnQlNXip6NglNzYH45nSRiEVimMvYL8DDqQ==} - engines: {node: '>=14.18.0'} - humanize-ms@1.2.1: resolution: {integrity: sha512-Fl70vYtsAFb/C06PTS9dZBo7ihau+Tu/DNCk/OyHhea07S+aeMWpFFkUaXRa8fI+ScZbEI8dfSxwY7gxZ9SAVQ==} @@ -6906,10 +6895,6 @@ packages: resolution: {integrity: sha512-hFoiJiTl63nn+kstHGBtewWSKnQLpyb155KHheA1l39uvtO9nWIop1p3udqPcUd/xbF1VLMO4n7OI6p7RbngDg==} engines: {node: '>=8'} - is-stream@3.0.0: - resolution: {integrity: sha512-LnQR4bZ9IADDRSkvpqMGvt/tEJWclzklNgSw48V5EAaAeDd6qGvN8ei6k5p0tvxSR171VmGyHuTiAOfxAbr8kA==} - engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0} - is-string@1.0.7: resolution: {integrity: sha512-tE2UXzivje6ofPW7l23cjDOMa09gb7xlAqG6jG5ej6uPV32TlWP3NKPigtaGeHNu9fohccRYvIiZMfOOnOYUtg==} engines: {node: '>= 0.4'} @@ -7637,10 +7622,6 @@ packages: resolution: {integrity: sha512-OqbOk5oEQeAZ8WXWydlu9HJjz9WVdEIvamMCcXmuqUYjTknH/sqsWvhQ3vgwKFRR1HpjvNBKQ37nbJgYzGqGcg==} engines: {node: '>=6'} - mimic-fn@4.0.0: - resolution: {integrity: sha512-vqiC06CuhBTUdZH+RYl8sFrL096vA45Ok5ISO6sE/Mr1jRbGH4Csnhi8f3wKVl7x8mO4Au7Ir9D3Oyv1VYMFJw==} - engines: {node: '>=12'} - mimic-function@5.0.1: resolution: {integrity: sha512-VP79XUPxV2CigYP3jWwAUFSku2aKqBH7uTAapFWCBqutsbmDo96KY5o8uh6U+/YSIn5OxJnXp73beVkpqMIGhA==} engines: {node: '>=18'} @@ -7837,10 +7818,6 @@ packages: resolution: {integrity: sha512-S48WzZW777zhNIrn7gxOlISNAqi9ZC/uQFnRdbeIHhZhCA6UqpkOT8T1G7BvfdgP4Er8gF4sUbaS0i7QvIfCWw==} engines: {node: '>=8'} - npm-run-path@5.1.0: - resolution: {integrity: sha512-sJOdmRGrY2sjNTRMbSvluQqg+8X7ZK61yvzBEIDhz4f8z1TZFYABsqjjCBd/0PUNE9M6QDgHJXQkGUEm7Q+l9Q==} - engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0} - nth-check@2.1.1: resolution: {integrity: sha512-lqjrjmaOoAnWfMmBPL+XNnynZh2+swxiX3WUE0s4yEHI6m+AwrK2UZOimIRl3X/4QctVqS8AiZjFqyOGrMXb/w==} @@ -7889,10 +7866,6 @@ packages: resolution: {integrity: sha512-kbpaSSGJTWdAY5KPVeMOKXSrPtr8C8C7wodJbcsd51jRnmD+GZu8Y0VoU6Dm5Z4vWr0Ig/1NKuWRKf7j5aaYSg==} engines: {node: '>=6'} - onetime@6.0.0: - resolution: {integrity: sha512-1FlR+gjXK7X+AsAHso35MnyN5KqGwJRi/31ft6x0M194ht7S+rWAvd7PHss9xSKMzE0asv1pyIHaJYq+BbacAQ==} - engines: {node: '>=12'} - open@8.4.2: resolution: {integrity: sha512-7x81NCL719oNbsq/3mh+hVrAWmFuEYUqrq/Iw3kUzH8ReypT9QQ0BLoJS7/G9k6N81XjW4qHWtjWwe/9eLy1EQ==} engines: {node: '>=12'} @@ -7991,10 +7964,6 @@ packages: resolution: {integrity: sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==} engines: {node: '>=8'} - path-key@4.0.0: - resolution: {integrity: sha512-haREypq7xkM7ErfgIyA0z+Bj4AGKlMSdlQE2jvJo6huWD1EdkKYV+G/T4nq0YEF2vgTT8kqMFKo1uHn950r4SQ==} - engines: {node: '>=12'} - path-parse@1.0.7: resolution: {integrity: sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw==} @@ -8850,10 +8819,6 @@ packages: resolution: {integrity: sha512-BrpvfNAE3dcvq7ll3xVumzjKjZQ5tI1sEUIKr3Uoks0XUl45St3FlatVqef9prk4jRDzhW6WZg+3bk93y6pLjA==} engines: {node: '>=6'} - strip-final-newline@3.0.0: - resolution: {integrity: sha512-dOESqjYr96iWYylGObzd39EuNTa5VJxyvVAEm5Jnh7KGo75V43Hk1odPQkNDyXNmUR6k+gEiDVXnjB8HJ3crXw==} - engines: {node: '>=12'} - strip-indent@3.0.0: resolution: {integrity: sha512-laJTa3Jb+VQpaC6DseHhF7dXVqHTfJPCRDaEbid/drOhgitgYku/letMUqOXFoWV0zIIUbjpdH2t+tYj4bQMRQ==} engines: {node: '>=8'} @@ -8961,6 +8926,9 @@ packages: tiny-invariant@1.3.3: resolution: {integrity: sha512-+FbBPE1o9QAYvviau/qC5SE3caw21q3xkvWKBtja5vgqOWIHHJ3ioaq1VPfn/Szqctz2bU/oYeKd9/z5BL+PVg==} + tinyexec@0.3.1: + resolution: {integrity: sha512-WiCJLEECkO18gwqIp6+hJg0//p23HXp4S+gGtAKu3mI2F2/sXC4FvHvXvB0zJVVaTPhx1/tOwdbRsa1sOBIKqQ==} + title-case@4.3.2: resolution: {integrity: sha512-I/nkcBo73mO42Idfv08jhInV61IMb61OdIFxk+B4Gu1oBjWBPOLmhZdsli+oJCVaD+86pYQA93cJfFt224ZFAA==} @@ -14177,18 +14145,6 @@ snapshots: signal-exit: 3.0.7 strip-final-newline: 2.0.0 - execa@7.2.0: - dependencies: - cross-spawn: 7.0.3 - get-stream: 6.0.1 - human-signals: 4.3.1 - is-stream: 3.0.0 - merge-stream: 2.0.0 - npm-run-path: 5.1.0 - onetime: 6.0.0 - signal-exit: 3.0.7 - strip-final-newline: 3.0.0 - exit-hook@2.2.1: {} exit@0.1.2: {} @@ -14601,8 +14557,6 @@ snapshots: human-signals@2.1.0: {} - human-signals@4.3.1: {} - humanize-ms@1.2.1: dependencies: ms: 2.1.3 @@ -14781,8 +14735,6 @@ snapshots: is-stream@2.0.1: {} - is-stream@3.0.0: {} - is-string@1.0.7: dependencies: has-tostringtag: 1.0.0 @@ -16051,8 +16003,6 @@ snapshots: mimic-fn@2.1.0: {} - mimic-fn@4.0.0: {} - mimic-function@5.0.1: {} min-indent@1.0.1: {} @@ -16232,10 +16182,6 @@ snapshots: dependencies: path-key: 3.1.1 - npm-run-path@5.1.0: - dependencies: - path-key: 4.0.0 - nth-check@2.1.1: dependencies: boolbase: 1.0.0 @@ -16280,10 +16226,6 @@ snapshots: dependencies: mimic-fn: 2.1.0 - onetime@6.0.0: - dependencies: - mimic-fn: 4.0.0 - open@8.4.2: dependencies: define-lazy-prop: 2.0.0 @@ -16418,8 +16360,6 @@ snapshots: path-key@3.1.1: {} - path-key@4.0.0: {} - path-parse@1.0.7: {} path-scurry@1.10.1: @@ -17297,8 +17237,6 @@ snapshots: strip-final-newline@2.0.0: {} - strip-final-newline@3.0.0: {} - strip-indent@3.0.0: dependencies: min-indent: 1.0.1 @@ -17457,6 +17395,8 @@ snapshots: tiny-invariant@1.3.3: {} + tinyexec@0.3.1: {} + title-case@4.3.2: {} tmpl@1.0.5: {}