ff-serv 0.1.7 → 0.1.8
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.js +1 -1
- package/package.json +2 -2
package/dist/cli.js
CHANGED
|
@@ -274,4 +274,4 @@ Quitting wizard mode...`));return r4(i8(F))}return s(O)}))}case"ShowVersion":{le
|
|
|
274
274
|
`);Y.push({schema:Z,tables:Q.map((G)=>G.table_name)})}return Y}),XR8=(D)=>c.gen(function*(){let X=yield*DR8(D);yield*c.log(`
|
|
275
275
|
The following will be truncated:
|
|
276
276
|
`);for(let{schema:Y,tables:Z}of X){if(Z.length===0){yield*c.log(`Schema: ${Y}`),yield*c.log(` (no tables)
|
|
277
|
-
`);continue}yield*c.log(`Schema: ${Y}`);for(let Q of Z)yield*c.log(` - ${Q}`);yield*c.log("")}let{shouldReset:J}=yield*c.tryPromise(()=>lT.prompt([{type:"confirm",name:"shouldReset",message:"Proceed with truncation?",default:!1}]));return{shouldReset:J,schemaInfo:X}}),JR8=(D,X)=>c.gen(function*(){let J=Qo(D);yield*c.addFinalizer(()=>c.ignore(c.tryPromise(()=>J.end()))),yield*c.log(`Truncating ${X.length} schema(s)...`);for(let{schema:Y,tables:Z}of X){if(Z.length===0){yield*c.log(` No tables in "${Y}"`);continue}yield*c.log(`Truncating ${Z.length} table(s) in schema "${Y}"...`);let Q=Z.map((G)=>`"${Y}"."${G}"`).join(", ");yield*c.tryPromise(()=>J.unsafe(`TRUNCATE ${Q} RESTART IDENTITY CASCADE`))}yield*c.log("Database reset complete")}),YR8=(D,X)=>c.gen(function*(){yield*c.log("Restoring from file"),yield*d9.make("psql",D,"-f",X).pipe(d9.stdout("inherit"),d9.exitCode)}),ZR8=c.gen(function*(){let D=yield*H5.FileSystem,X=yield*pq.Path,J=yield*D.makeTempDirectory(),Y=X.join(J,"dump.sql");return yield*c.log(`Prepared dump file: ${Y}`),Y}),QR8=(D,X)=>c.gen(function*(){yield*(yield*H5.FileSystem).copy(D,X),yield*c.log(`Dump saved to: ${X}`)}),Go=(D,X)=>c.catchAll(D,(J)=>c.gen(function*(){if(yield*c.logError(`Operation failed: ${J}`),X.downloaded)yield*c.log(`Dump file preserved at: ${X.filePath}`),yield*c.log("You can retry using --fromDump flag");if(yield*aI0)return yield*c.log("Retrying..."),yield*Go(D,X);return yield*c.fail(J)})),w_0=S7.make("pull",{fromDump:m9.file("fromDump").pipe(m9.optional),targetDatabaseUrl:XT.text({name:"targetDatabaseUrl"}).pipe(XT.optional),saveDump:m9.file("saveDump").pipe(m9.optional),config:m9.file("config").pipe(m9.optional)},({fromDump:D,targetDatabaseUrl:X,saveDump:J,config:Y})=>c.gen(function*(){let Z=yield*SE(F0.isSome(Y)?Y.value:void 0),Q=F0.getOrUndefined(X)||F0.flatMap(Z,(H)=>F0.fromNullable(H.pullDatabase?.targetDatabaseUrl)).pipe(F0.getOrUndefined)||(yield*rI0(eM8)),G;if(F0.isSome(D)){if(G={filePath:D.value,downloaded:!0},yield*c.log(`Using dump file: ${G.filePath}`),!(yield*A_0(null,Q))){yield*c.log("Operation cancelled");return}}else{G={filePath:yield*ZR8,downloaded:!1};let K=yield*Mj(F0.flatMap(Z,($)=>F0.fromNullable($.pullDatabase?.source)).pipe(F0.getOrUndefined)),B=yield*Aj(K);if(!(yield*A_0(B,Q))){yield*c.log("Operation cancelled");return}if(yield*Go(wj(B,G.filePath).pipe(c.tap(()=>c.sync(()=>{G.downloaded=!0}))),G),F0.isSome(J))yield*QR8(G.filePath,J.value)}if(yield*Go(c.gen(function*(){let{shouldReset:H,schemaInfo:K}=yield*XR8(Q);if(H)yield*JR8(Q,K);yield*YR8(Q,G.filePath)}),G),!F0.isSome(D))if(yield*sI0(G.filePath))yield*(yield*H5.FileSystem).remove(G.filePath,{recursive:!0}),yield*c.log("Dump file cleaned up");else yield*c.log(`Dump file kept at: ${G.filePath}`);yield*c.log("Database pull complete!")}).pipe(c.scoped));var M_0=S7.make("db",{},()=>c.log("Database commands - UsepullCommandle subcommands")).pipe(S7.withSubcommands([w_0,eI0]));var R_0={name:"ff-serv",version:"0.1.
|
|
277
|
+
`);continue}yield*c.log(`Schema: ${Y}`);for(let Q of Z)yield*c.log(` - ${Q}`);yield*c.log("")}let{shouldReset:J}=yield*c.tryPromise(()=>lT.prompt([{type:"confirm",name:"shouldReset",message:"Proceed with truncation?",default:!1}]));return{shouldReset:J,schemaInfo:X}}),JR8=(D,X)=>c.gen(function*(){let J=Qo(D);yield*c.addFinalizer(()=>c.ignore(c.tryPromise(()=>J.end()))),yield*c.log(`Truncating ${X.length} schema(s)...`);for(let{schema:Y,tables:Z}of X){if(Z.length===0){yield*c.log(` No tables in "${Y}"`);continue}yield*c.log(`Truncating ${Z.length} table(s) in schema "${Y}"...`);let Q=Z.map((G)=>`"${Y}"."${G}"`).join(", ");yield*c.tryPromise(()=>J.unsafe(`TRUNCATE ${Q} RESTART IDENTITY CASCADE`))}yield*c.log("Database reset complete")}),YR8=(D,X)=>c.gen(function*(){yield*c.log("Restoring from file"),yield*d9.make("psql",D,"-f",X).pipe(d9.stdout("inherit"),d9.exitCode)}),ZR8=c.gen(function*(){let D=yield*H5.FileSystem,X=yield*pq.Path,J=yield*D.makeTempDirectory(),Y=X.join(J,"dump.sql");return yield*c.log(`Prepared dump file: ${Y}`),Y}),QR8=(D,X)=>c.gen(function*(){yield*(yield*H5.FileSystem).copy(D,X),yield*c.log(`Dump saved to: ${X}`)}),Go=(D,X)=>c.catchAll(D,(J)=>c.gen(function*(){if(yield*c.logError(`Operation failed: ${J}`),X.downloaded)yield*c.log(`Dump file preserved at: ${X.filePath}`),yield*c.log("You can retry using --fromDump flag");if(yield*aI0)return yield*c.log("Retrying..."),yield*Go(D,X);return yield*c.fail(J)})),w_0=S7.make("pull",{fromDump:m9.file("fromDump").pipe(m9.optional),targetDatabaseUrl:XT.text({name:"targetDatabaseUrl"}).pipe(XT.optional),saveDump:m9.file("saveDump").pipe(m9.optional),config:m9.file("config").pipe(m9.optional)},({fromDump:D,targetDatabaseUrl:X,saveDump:J,config:Y})=>c.gen(function*(){let Z=yield*SE(F0.isSome(Y)?Y.value:void 0),Q=F0.getOrUndefined(X)||F0.flatMap(Z,(H)=>F0.fromNullable(H.pullDatabase?.targetDatabaseUrl)).pipe(F0.getOrUndefined)||(yield*rI0(eM8)),G;if(F0.isSome(D)){if(G={filePath:D.value,downloaded:!0},yield*c.log(`Using dump file: ${G.filePath}`),!(yield*A_0(null,Q))){yield*c.log("Operation cancelled");return}}else{G={filePath:yield*ZR8,downloaded:!1};let K=yield*Mj(F0.flatMap(Z,($)=>F0.fromNullable($.pullDatabase?.source)).pipe(F0.getOrUndefined)),B=yield*Aj(K);if(!(yield*A_0(B,Q))){yield*c.log("Operation cancelled");return}if(yield*Go(wj(B,G.filePath).pipe(c.tap(()=>c.sync(()=>{G.downloaded=!0}))),G),F0.isSome(J))yield*QR8(G.filePath,J.value)}if(yield*Go(c.gen(function*(){let{shouldReset:H,schemaInfo:K}=yield*XR8(Q);if(H)yield*JR8(Q,K);yield*YR8(Q,G.filePath)}),G),!F0.isSome(D))if(yield*sI0(G.filePath))yield*(yield*H5.FileSystem).remove(G.filePath,{recursive:!0}),yield*c.log("Dump file cleaned up");else yield*c.log(`Dump file kept at: ${G.filePath}`);yield*c.log("Database pull complete!")}).pipe(c.scoped));var M_0=S7.make("db",{},()=>c.log("Database commands - UsepullCommandle subcommands")).pipe(S7.withSubcommands([w_0,eI0]));var R_0={name:"ff-serv",version:"0.1.8",type:"module",bin:{"ff-serv":"./dist/cli.js"},exports:{".":{types:"./dist/index.d.ts",import:"./dist/index.js",require:"./dist/index.cjs"},"./orpc":{types:"./dist/exports/orpc.d.ts",import:"./dist/exports/orpc.js",require:"./dist/exports/orpc.cjs"}},files:["dist","src"],scripts:{build:"tsup && bun run build:cli","build:cli":"bun build src/cli/index.ts --production --target=bun --outfile dist/cli.js",test:"bun -b vitest run",dev:"tsup --watch"},devDependencies:{"@effect/cli":"^0.71.0","@effect/platform-bun":"^0.87.0","@effect/vitest":"^0.27.0","@orpc/client":"^1.13.2","@types/bun":"^1.3.2","@types/cli-progress":"^3.11.6","cli-progress":"^3.12.0","ff-effect":"^0.0.7",inquirer:"^12.10.0",postgres:"^3.4.7",tsup:"^8.5.0",typescript:"^5.9.3",vitest:"^4.0.16"},peerDependencies:{effect:"^3",pino:"^9","@effect/opentelemetry":"^0.60.0","get-port":"^7","@orpc/server":"^1"},publishConfig:{access:"public"},homepage:"https://github.com/fdarian/ff.git",repository:{type:"git",url:"git+https://github.com/fdarian/ff.git"},bugs:{url:"https://github.com/fdarian/ff/issues"},keywords:["effect","server","service"],dependencies:{"@effect/platform":"^0.94.1",nanoid:"^5.1.6"}};var HR8=S7.make("ff-serv",{},()=>c.log("ff-serv CLI - Use --help for available commands")).pipe(S7.withSubcommands([M_0])),KR8=S7.run(HR8,{name:"ff-serv",version:R_0.version});KR8(process.argv).pipe(c.provide(ON0),LN0);
|