@unreal-orm/cli 1.0.0-alpha.4 → 1.0.0-alpha.5
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 +1 -1
package/dist/index.js
CHANGED
|
@@ -7,7 +7,7 @@ Operation cancelled.`),process.exit(0)}})).value}async function j0($,X,Q){let Z=
|
|
|
7
7
|
|
|
8
8
|
${H}
|
|
9
9
|
`),B.success("Appended SurrealDB config to .env")}else if((await g({type:"confirm",name:"createEnv",message:"Create .env file with SurrealDB config?",initial:!0},{onCancel:h})).createEnv)await T.writeFile(q,`${H}
|
|
10
|
-
`),B.success("Created .env file"),B.info(" Remember to add .env to your .gitignore!");let K=_2(),A=["unreal-orm@
|
|
10
|
+
`),B.success("Created .env file"),B.info(" Remember to add .env to your .gitignore!");let K=_2(),A=["unreal-orm@latest","surrealdb@alpha"],D=["@unreal-orm/cli"];if(Q==="memory"||Q==="file")A.push("@surrealdb/node@alpha");let O=$.install;if(O===void 0){let I=[...A,...D.map((w)=>`${w} (dev)`)],{install:E}=await g({type:"confirm",name:"install",message:`Install dependencies? (${I.join(", ")})`,initial:!0},{onCancel:h});O=E}if(O){let I=$.pm??"";if(!I){let P=[{title:"npm",value:"npm"},{title:"yarn",value:"yarn"},{title:"pnpm",value:"pnpm"},{title:"bun",value:"bun"}],F=P.findIndex((N)=>N.value===K),{pm:L}=await g({type:"select",name:"pm",message:"Package manager:",choices:P,initial:F>=0?F:0},{onCancel:h});I=L??K}let E=X1(I,A,!1);B.newline(),B.info(`Running: ${E}...`);try{J1(E,{stdio:"inherit"})}catch(P){B.error("Failed to install dependencies")}let w=X1(I,D,!0);B.info(`Running: ${w}...`);try{J1(w,{stdio:"inherit"}),B.success("Dependencies installed")}catch(P){B.error("Failed to install dev dependencies")}}let V="none";if($.sample)V="sample";else if($.fromDb)V="from-db";else if($.fromSurql)V="from-surql";else V=(await g({type:"select",name:"action",message:"What would you like to do next?",choices:[{title:"Generate sample tables",value:"sample",description:"User, Post, Follow tables with indexes & relations"},{title:"Import from Database",value:"from-db",description:"Introspect existing DB"},{title:"Import from .surql file",value:"from-surql",description:"Parse SurrealQL file"},{title:"Nothing for now",value:"none"}]},{onCancel:h})).action;if(V==="sample"){let I=f.resolve(__dirname,"../../examples/simple"),E=["User.ts","Post.ts","Follow.ts"];for(let w of E){let P=await T.readFile(f.join(I,w),"utf-8");await T.writeFile(f.join(j,w),P)}B.success("Generated sample tables:"),console.log(B.dim(" • User.ts - Basic user table with indexes")),console.log(B.dim(" • Post.ts - Posts with record links, arrays, and methods")),console.log(B.dim(" • Follow.ts - Relation table (graph edge) example"))}else if(V==="from-db")B.info("Run 'unreal pull' to import schema from database");else if(V==="from-surql")B.info("Run 'unreal pull --file <path>' to import schema");if(B.newline(),(await g({type:"confirm",name:"addImport",message:"Add import to your entry point? (e.g., index.ts, main.ts)",initial:!0},{onCancel:h})).addImport){let I=["src/index.ts","src/main.ts","src/app.ts","index.ts","main.ts","app.ts"],E=null;for(let F of I){let L=f.join(process.cwd(),F);if(await T.access(L).then(()=>!0).catch(()=>!1)){E=F;break}}let P=(await g({type:"text",name:"entryPoint",message:"Entry point file:",initial:E||"src/index.ts"},{onCancel:h})).entryPoint;if(P){let F=f.join(process.cwd(),P),L=await T.access(F).then(()=>!0).catch(()=>!1),N=f.dirname(F),v=f.relative(N,G);if(!v.startsWith("."))v=`./${v}`;v=v.replace(/\\/g,"/");let C=`// Initialize database connection and configure ORM (must be first import)
|
|
11
11
|
import "${v}/surreal";`;if(L){let S=await T.readFile(F,"utf-8");if(S.includes("/surreal"))B.warn("Entry point already imports surreal.ts, skipping");else{let b=`${C}
|
|
12
12
|
${S}`;await T.writeFile(F,b),B.success(`Added import to ${P}`)}}else{let S=`${C}
|
|
13
13
|
|
package/package.json
CHANGED