d1-prisma 0.1.0 → 0.1.2
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.js +1 -1
- package/package.json +10 -2
package/dist/index.js
CHANGED
|
@@ -297,4 +297,4 @@ ${T}`,R);this.line=E,this.column=N,this.codeblock=T}}/*!
|
|
|
297
297
|
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
298
298
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
299
299
|
*/async function _O(){let I;try{if(await KO("wrangler.jsonc")){let R=await kI.readFile("wrangler.jsonc","utf-8");I=fO(R)}else if(await KO("wrangler.toml")){let R=await kI.readFile("wrangler.toml","utf-8");I=gI(R)}else throw Error("No wrangler.jsonc or wrangler.toml found.");return I.d1_databases?.map((R)=>({value:R.database_name,label:R.database_name}))||[]}catch(R){return[]}}async function KO(I){return kI.access(I).then(()=>!0).catch(()=>!1)}var v=VO(process.argv.slice(2)),PO=v._[0];async function E1(){BO("D1 Prisma Migrate CLI");let I=await _O();if(I.length===0)K.error("No D1 databases configured in wrangler."),process.exit(1);let R=v.d||v.database||await wO({message:"Select the D1 database:",options:I});if(a(R))process.exit(0);if(PO==="create")await N1(R);else if(PO==="apply")await T1(R);else K.info("Usage: d1-prisma [create|apply] [--remote]"),process.exit(0)}async function N1(I){let R=v.name||v.n||await CO({message:"Migration name?"});if(a(R))return;let E=v.schema||"./prisma/schema.prisma",N=`${E}.backup.${Date.now()}`,T=_I();try{await yI.copyFile(E,N),T.start("Creating migration file...");let O=(await n(`wrangler d1 migrations create ${I} ${R}`)).trim().split(`
|
|
300
|
-
`).find((L)=>L.endsWith(".sql"));if(!O)throw Error("Migration path not found");T.message("Synchronizing Prisma schema with DB..."),await n(`prisma db pull --schema ${E}`),T.message("Generating SQL diff..."),await n(`prisma migrate diff --from-schema
|
|
300
|
+
`).find((L)=>L.endsWith(".sql"));if(!O)throw Error("Migration path not found");T.message("Synchronizing Prisma schema with DB..."),await n(`prisma db pull --schema ${E}`),T.message("Generating SQL diff..."),await n(`prisma migrate diff --from-schema ${E} --to-schema ${N} --script >> ${O}`),T.stop(`Migration created: ${R1.basename(O)}`)}catch(S){K.error(`Error: ${S}`)}finally{await yI.copyFile(N,E),await yI.rm(N)}}async function T1(I){let R=_I(),E=v.remote?"--remote":"--local";try{R.start(`Applying migrations ${E}...`),await n(`wrangler d1 migrations apply ${I} ${E}`),R.message("Regenerating Prisma Client..."),await n("prisma generate"),R.stop("Database updated successfully!"),YO("Done.")}catch(N){R.stop("Failed."),K.error(`${N}`)}}E1().catch(console.error);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "d1-prisma",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Bridge CLI to manage Cloudflare D1 migrations with Prisma",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -16,6 +16,14 @@
|
|
|
16
16
|
"start": "node dist/index.js",
|
|
17
17
|
"prepublishOnly": "bun run build"
|
|
18
18
|
},
|
|
19
|
+
"repository": {
|
|
20
|
+
"type": "git",
|
|
21
|
+
"url": "git+https://github.com/Hiutaky/d1-prisma.git"
|
|
22
|
+
},
|
|
23
|
+
"bugs": {
|
|
24
|
+
"url": "https://github.com/Hiutaky/d1-prisma/issues"
|
|
25
|
+
},
|
|
26
|
+
"homepage": "https://github.com/Hiutaky/d1-prisma#readme",
|
|
19
27
|
"dependencies": {
|
|
20
28
|
"@clack/prompts": "^0.11.0",
|
|
21
29
|
"bun": "^1.3.5",
|
|
@@ -27,4 +35,4 @@
|
|
|
27
35
|
"@types/node": "^20.0.0",
|
|
28
36
|
"typescript": "^5.0.0"
|
|
29
37
|
}
|
|
30
|
-
}
|
|
38
|
+
}
|