@coreframe/scripts 0.1.8 → 0.1.10
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/coreframe.d.ts +2 -0
- package/dist/coreframe.js +1 -1
- package/dist/db/drizzle-kit.d.ts +1 -11
- package/dist/db/drizzle-kit.js +1 -1
- package/dist/db/ensure.d.ts +1 -19
- package/dist/db/ensure.js +1 -1
- package/dist/db/local-postgres.d.ts +6 -24
- package/dist/db/local-postgres.js +2 -2
- package/dist/db/migrate-held.d.ts +1 -3
- package/dist/db/migrate-held.js +1 -1
- package/dist/db/migrate.d.ts +1 -5
- package/dist/db/migrate.js +1 -1
- package/dist/db/project.d.ts +2 -10
- package/dist/db/project.js +1 -1
- package/dist/db/reset.d.ts +1 -5
- package/dist/db/reset.js +1 -1
- package/dist/db/schema-check.d.ts +1 -16
- package/dist/db/schema-check.js +1 -1
- package/dist/db/seed.d.ts +1 -14
- package/dist/db/seed.js +1 -1
- package/dist/db/setup.d.ts +1 -4
- package/dist/db/setup.js +1 -1
- package/dist/dev-https.d.ts +17 -0
- package/dist/dev-https.js +1 -0
- package/dist/dev.d.ts +3 -9
- package/dist/dev.js +1 -1
- package/dist/environment.d.ts +24 -0
- package/dist/environment.js +1 -0
- package/dist/project.d.ts +2 -1
- package/dist/project.js +1 -1
- package/dist/upgrade/check-skill-current.js +1 -1
- package/package.json +7 -7
package/dist/coreframe.d.ts
CHANGED
|
@@ -53,6 +53,7 @@ declare const coreframeCli: Partial<import("cmd-ts/dist/cjs/argparser").Register
|
|
|
53
53
|
} | {
|
|
54
54
|
command: "dev";
|
|
55
55
|
args: {
|
|
56
|
+
https: boolean;
|
|
56
57
|
platform: "ios" | "android" | "web" | "desktop" | undefined;
|
|
57
58
|
};
|
|
58
59
|
} | {
|
|
@@ -177,6 +178,7 @@ declare const coreframeCli: Partial<import("cmd-ts/dist/cjs/argparser").Register
|
|
|
177
178
|
} | {
|
|
178
179
|
command: "dev";
|
|
179
180
|
args: {
|
|
181
|
+
https: boolean;
|
|
180
182
|
platform: "ios" | "android" | "web" | "desktop" | undefined;
|
|
181
183
|
};
|
|
182
184
|
} | {
|
package/dist/coreframe.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{addAsset as e,buildAssets as t,checkAssets as n,printAssetResult as r,publishAssets as i}from"./assets.js";import{runDrizzleKitCommand as a}from"./db/drizzle-kit.js";import{seedLocalDb as o}from"./db/seed.js";import{migrateLocalDb as s}from"./db/migrate.js";import{resetLocalDb as c}from"./db/reset.js";import{setupLocalDb as l}from"./db/setup.js";import{ensureLocalDb as u}from"./db/ensure.js";import{migrateHeldMigrations as d}from"./db/migrate-held.js";import{checkSchemaPush as f}from"./db/schema-check.js";import{tauriReleasePlatforms as p}from"./deploy/config.js";import{deployProject as m}from"./deploy.js";import{checkDeployMigrations as h}from"./deploy/check-migrations.js";import{devPlatforms as g,runDevServer as _}from"./dev.js";import{typecheckProject as v}from"./typecheck.js";import{checkUpgradeSkillCurrent as y}from"./upgrade/check-skill-current.js";import{ensureTemplateRemote as b}from"./upgrade/ensure-template-remote.js";import{fastForwardTemplateFiles as x}from"./upgrade/fast-forward-template-files.js";import{array as S,binary as C,command as w,flag as T,multioption as E,oneOf as D,option as O,optional as k,positional as A,rest as j,run as M,string as N,subcommands as P}from"cmd-ts";const F=P({name:`coreframe`,cmds:{assets:P({name:`assets`,cmds:{add:w({name:`add`,args:{file:A({type:N,displayName:`file`,description:`Source image to add to the asset library.`}),id:O({long:`id`,type:N,description:`Logical asset ID, such as blog/my-post/hero.`}),alt:O({long:`alt`,type:N,description:`Required alt text for the asset.`}),json:T({long:`json`,description:`Print machine-readable JSON.`,defaultValue:()=>!1})},handler:async({alt:t,file:n,id:i,json:a})=>r(await e({alt:t,file:n,id:i,json:a}),a)}),build:w({name:`build`,args:{id:O({long:`id`,type:k(N),description:`Build only one logical asset ID.`}),noPull:T({long:`no-pull`,description:`Do not perform targeted Git LFS pulls for missing source objects.`,defaultValue:()=>!1}),json:T({long:`json`,description:`Print machine-readable JSON.`,defaultValue:()=>!1})},handler:async({id:e,json:n,noPull:i})=>r(await t({id:e,json:n,pull:!i}),n)}),check:w({name:`check`,args:{fix:T({long:`fix`,description:`Build missing generated variants when possible.`,defaultValue:()=>!1}),json:T({long:`json`,description:`Print machine-readable JSON.`,defaultValue:()=>!1})},handler:async({fix:e,json:t})=>{let i=await n({fix:e,json:t});r(i,t),i.ok||(process.exitCode=1)}}),publish:w({name:`publish`,args:{outputDir:O({long:`output-dir`,type:k(N),description:`Directory for additive local publish output. Defaults to COREFRAME_ASSETS_PUBLISH_DIR or release-upload/assets.`}),json:T({long:`json`,description:`Print machine-readable JSON.`,defaultValue:()=>!1})},handler:async({json:e,outputDir:t})=>{let n=await i({json:e,outputDir:t});r(n,e),n.ok||(process.exitCode=1)}}),status:w({name:`status`,args:{json:T({long:`json`,description:`Print machine-readable JSON.`,defaultValue:()=>!1})},handler:async({json:e})=>{let t=await n({json:e});r(t,e),t.ok||(process.exitCode=1)}})}}),deploy:w({name:`deploy`,args:{runMigrations:T({long:`run-migrations`,description:`Run pending deploy-safe database migrations before deploying.`,defaultValue:()=>!1}),skipMigrations:T({long:`skip-migrations`,description:`Deploy without running pending deploy-safe database migrations.`,defaultValue:()=>!1}),skipPostDeployChecks:T({long:`skip-post-deploy-checks`,description:`Skip post-deploy checks after Cloudflare deployment.`,defaultValue:()=>!1}),tauriLocalPlatforms:E({long:`tauri-local-platform`,type:S(D(p)),description:`Build one Tauri release platform locally. Repeat for multiple platforms.`,defaultValue:()=>[]}),tauriWorkflowName:O({long:`tauri-workflow-name`,type:k(N),description:`GitHub Actions workflow file or name for remote Tauri release builds.`}),tauriWorkflowPlatforms:E({long:`tauri-workflow-platform`,type:S(D(p)),description:`Build one Tauri release platform with GitHub Actions. Repeat for multiple platforms.`,defaultValue:()=>[]}),tauriWorkflowRef:O({long:`tauri-workflow-ref`,type:k(N),description:`Git ref used when dispatching remote Tauri release builds.`}),yes:T({long:`yes`,short:`y`,description:`Approve noninteractive deploy prompts.`,defaultValue:()=>!1})},handler:({runMigrations:e,skipMigrations:t,skipPostDeployChecks:n,tauriLocalPlatforms:r,tauriWorkflowName:i,tauriWorkflowPlatforms:a,tauriWorkflowRef:o,yes:s})=>m([...e?[`--run-migrations`]:[],...t?[`--skip-migrations`]:[],...n?[`--skip-post-deploy-checks`]:[],...r.flatMap(e=>[`--tauri-local-platform`,e]),...i?[`--tauri-workflow-name`,i]:[],...a.flatMap(e=>[`--tauri-workflow-platform`,e]),...o?[`--tauri-workflow-ref`,o]:[],...s?[`--yes`]:[]])}),typecheck:w({name:`typecheck`,args:{},handler:v}),dev:w({name:`dev`,args:{platform:A({type:k(D(g)),displayName:`platform`,description:`Development target platform. Defaults to web.`})},handler:({platform:
|
|
2
|
+
import{addAsset as e,buildAssets as t,checkAssets as n,printAssetResult as r,publishAssets as i}from"./assets.js";import{runDrizzleKitCommand as a}from"./db/drizzle-kit.js";import{seedLocalDb as o}from"./db/seed.js";import{migrateLocalDb as s}from"./db/migrate.js";import{resetLocalDb as c}from"./db/reset.js";import{setupLocalDb as l}from"./db/setup.js";import{ensureLocalDb as u}from"./db/ensure.js";import{migrateHeldMigrations as d}from"./db/migrate-held.js";import{checkSchemaPush as f}from"./db/schema-check.js";import{tauriReleasePlatforms as p}from"./deploy/config.js";import{deployProject as m}from"./deploy.js";import{checkDeployMigrations as h}from"./deploy/check-migrations.js";import{devPlatforms as g,runDevServer as _}from"./dev.js";import{typecheckProject as v}from"./typecheck.js";import{checkUpgradeSkillCurrent as y}from"./upgrade/check-skill-current.js";import{ensureTemplateRemote as b}from"./upgrade/ensure-template-remote.js";import{fastForwardTemplateFiles as x}from"./upgrade/fast-forward-template-files.js";import{array as S,binary as C,command as w,flag as T,multioption as E,oneOf as D,option as O,optional as k,positional as A,rest as j,run as M,string as N,subcommands as P}from"cmd-ts";const F=P({name:`coreframe`,cmds:{assets:P({name:`assets`,cmds:{add:w({name:`add`,args:{file:A({type:N,displayName:`file`,description:`Source image to add to the asset library.`}),id:O({long:`id`,type:N,description:`Logical asset ID, such as blog/my-post/hero.`}),alt:O({long:`alt`,type:N,description:`Required alt text for the asset.`}),json:T({long:`json`,description:`Print machine-readable JSON.`,defaultValue:()=>!1})},handler:async({alt:t,file:n,id:i,json:a})=>r(await e({alt:t,file:n,id:i,json:a}),a)}),build:w({name:`build`,args:{id:O({long:`id`,type:k(N),description:`Build only one logical asset ID.`}),noPull:T({long:`no-pull`,description:`Do not perform targeted Git LFS pulls for missing source objects.`,defaultValue:()=>!1}),json:T({long:`json`,description:`Print machine-readable JSON.`,defaultValue:()=>!1})},handler:async({id:e,json:n,noPull:i})=>r(await t({id:e,json:n,pull:!i}),n)}),check:w({name:`check`,args:{fix:T({long:`fix`,description:`Build missing generated variants when possible.`,defaultValue:()=>!1}),json:T({long:`json`,description:`Print machine-readable JSON.`,defaultValue:()=>!1})},handler:async({fix:e,json:t})=>{let i=await n({fix:e,json:t});r(i,t),i.ok||(process.exitCode=1)}}),publish:w({name:`publish`,args:{outputDir:O({long:`output-dir`,type:k(N),description:`Directory for additive local publish output. Defaults to COREFRAME_ASSETS_PUBLISH_DIR or release-upload/assets.`}),json:T({long:`json`,description:`Print machine-readable JSON.`,defaultValue:()=>!1})},handler:async({json:e,outputDir:t})=>{let n=await i({json:e,outputDir:t});r(n,e),n.ok||(process.exitCode=1)}}),status:w({name:`status`,args:{json:T({long:`json`,description:`Print machine-readable JSON.`,defaultValue:()=>!1})},handler:async({json:e})=>{let t=await n({json:e});r(t,e),t.ok||(process.exitCode=1)}})}}),deploy:w({name:`deploy`,args:{runMigrations:T({long:`run-migrations`,description:`Run pending deploy-safe database migrations before deploying.`,defaultValue:()=>!1}),skipMigrations:T({long:`skip-migrations`,description:`Deploy without running pending deploy-safe database migrations.`,defaultValue:()=>!1}),skipPostDeployChecks:T({long:`skip-post-deploy-checks`,description:`Skip post-deploy checks after Cloudflare deployment.`,defaultValue:()=>!1}),tauriLocalPlatforms:E({long:`tauri-local-platform`,type:S(D(p)),description:`Build one Tauri release platform locally. Repeat for multiple platforms.`,defaultValue:()=>[]}),tauriWorkflowName:O({long:`tauri-workflow-name`,type:k(N),description:`GitHub Actions workflow file or name for remote Tauri release builds.`}),tauriWorkflowPlatforms:E({long:`tauri-workflow-platform`,type:S(D(p)),description:`Build one Tauri release platform with GitHub Actions. Repeat for multiple platforms.`,defaultValue:()=>[]}),tauriWorkflowRef:O({long:`tauri-workflow-ref`,type:k(N),description:`Git ref used when dispatching remote Tauri release builds.`}),yes:T({long:`yes`,short:`y`,description:`Approve noninteractive deploy prompts.`,defaultValue:()=>!1})},handler:({runMigrations:e,skipMigrations:t,skipPostDeployChecks:n,tauriLocalPlatforms:r,tauriWorkflowName:i,tauriWorkflowPlatforms:a,tauriWorkflowRef:o,yes:s})=>m([...e?[`--run-migrations`]:[],...t?[`--skip-migrations`]:[],...n?[`--skip-post-deploy-checks`]:[],...r.flatMap(e=>[`--tauri-local-platform`,e]),...i?[`--tauri-workflow-name`,i]:[],...a.flatMap(e=>[`--tauri-workflow-platform`,e]),...o?[`--tauri-workflow-ref`,o]:[],...s?[`--yes`]:[]])}),typecheck:w({name:`typecheck`,args:{},handler:v}),dev:w({name:`dev`,args:{https:T({long:`https`,description:`Serve the web app over locally trusted HTTPS.`,defaultValue:()=>!1}),platform:A({type:k(D(g)),displayName:`platform`,description:`Development target platform. Defaults to web.`})},handler:({https:e,platform:t})=>_({https:e,platform:t??`web`})}),upgrade:P({name:`upgrade`,cmds:{"ensure-template-remote":w({name:`ensure-template-remote`,args:{remote:O({long:`remote`,type:N,defaultValue:()=>`template`,description:`Remote name to ensure.`}),noFetch:T({long:`no-fetch`,description:`Do not fetch the remote after ensuring it exists.`,defaultValue:()=>!1})},handler:({noFetch:e,remote:t})=>b({fetch:!e,remote:t})}),"check-skill-current":w({name:`check-skill-current`,args:{target:O({long:`target`,type:N,description:`Target Coreframe template git ref.`}),apply:T({long:`apply`,description:`Replace the local upgrade skill with the target version when it differs.`,defaultValue:()=>!1})},handler:({apply:e,target:t})=>{process.exitCode=y({apply:e,target:t})}}),"fast-forward-template-files":w({name:`fast-forward-template-files`,args:{target:O({long:`target`,type:N,description:`Target Coreframe template git ref.`}),base:O({long:`base`,type:k(N),description:`Previous Coreframe template git ref. Defaults to package.json engines.coreframe.`}),apply:T({long:`apply`,description:`Write clean fast-forwards to the worktree.`,defaultValue:()=>!1})},handler:({apply:e,base:t,target:n})=>x({apply:e,base:t,target:n})})}}),db:P({name:`db`,cmds:{ensure:w({name:`ensure`,args:{},handler:u}),generate:w({name:`generate`,args:{args:j({displayName:`drizzle-kit args`,description:`Additional arguments passed to drizzle-kit generate.`})},handler:({args:e})=>a(`generate`,e)}),migrate:w({name:`migrate`,args:{args:j({displayName:`drizzle-kit args`,description:`Additional arguments passed to drizzle-kit migrate.`})},handler:({args:e})=>a(`migrate`,e)}),"migrate-held":w({name:`migrate-held`,args:{confirm:O({long:`confirm`,type:k(D([`run-held-migrations`])),description:`Required confirmation value for held migrations.`})},handler:({confirm:e})=>d({argv:e?[`--confirm=${e}`]:[]})}),"migrate-local":w({name:`migrate-local`,args:{},handler:s}),"migrations-check":w({name:`migrations-check`,args:{},handler:h}),reset:w({name:`reset`,args:{},handler:c}),seed:w({name:`seed`,args:{},handler:()=>o()}),"schema-check":w({name:`schema-check`,args:{seed:T({long:`seed`,description:`Run the configured project seed against the throwaway database.`,defaultValue:()=>!1})},handler:({seed:e})=>f({seed:e})}),setup:w({name:`setup`,args:{},handler:()=>l()}),studio:w({name:`studio`,args:{args:j({displayName:`drizzle-kit args`,description:`Additional arguments passed to drizzle-kit studio.`})},handler:({args:e})=>a(`studio`,e)})}})}});import.meta.main&&M(C(F),process.argv);export{F as coreframeCli};
|
package/dist/db/drizzle-kit.d.ts
CHANGED
|
@@ -1,20 +1,10 @@
|
|
|
1
|
-
import { startProjectPostgres } from "./local-postgres.js";
|
|
2
|
-
|
|
3
1
|
//#region db/drizzle-kit.d.ts
|
|
4
|
-
type Spawn = (file: string, args: readonly string[], options: {
|
|
5
|
-
env: NodeJS.ProcessEnv;
|
|
6
|
-
stdio: "inherit";
|
|
7
|
-
}) => PromiseLike<unknown>;
|
|
8
2
|
type DrizzleKitCommand = "generate" | "migrate" | "studio";
|
|
9
3
|
type RunDrizzleKitCommandOptions = {
|
|
10
4
|
env?: NodeJS.ProcessEnv;
|
|
11
|
-
spawn?: Spawn;
|
|
12
|
-
startProjectPostgres?: typeof startProjectPostgres;
|
|
13
5
|
};
|
|
14
6
|
declare function runDrizzleKitCommand(command: DrizzleKitCommand, args?: string[], {
|
|
15
|
-
env
|
|
16
|
-
spawn,
|
|
17
|
-
startProjectPostgres
|
|
7
|
+
env
|
|
18
8
|
}?: RunDrizzleKitCommandOptions): Promise<void>;
|
|
19
9
|
//#endregion
|
|
20
10
|
export { runDrizzleKitCommand };
|
package/dist/db/drizzle-kit.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{startProjectPostgres as e}from"./local-postgres.js";import t from"../_virtual/_@oxc-project_runtime@0.138.0/helpers/esm/usingCtx.js";import n from"node:path";import r from"nano-spawn";import i from"node:process";const a=n.resolve(`node_modules`,`.bin`),o=i.platform===`win32`?`drizzle-kit.cmd`:`drizzle-kit
|
|
2
|
+
import{startProjectPostgres as e}from"./local-postgres.js";import t from"../_virtual/_@oxc-project_runtime@0.138.0/helpers/esm/usingCtx.js";import n from"node:path";import r from"nano-spawn";import i from"node:process";const a=n.resolve(`node_modules`,`.bin`),o=i.platform===`win32`?`drizzle-kit.cmd`:`drizzle-kit`;async function s(s,c=[],{env:l=i.env}={}){try{var u=t();let i=u.a(await e({env:l})),d=l.PATH??l.Path??``;await r(o,[s,...c],{env:{...i.env,PATH:a+n.delimiter+d},stdio:`inherit`})}catch(e){u.e=e}finally{await u.d()}}import.meta.main&&s(i.argv[2],i.argv.slice(3)).catch(e=>{console.error(e),i.exit(1)});export{s as runDrizzleKitCommand};
|
package/dist/db/ensure.d.ts
CHANGED
|
@@ -1,27 +1,9 @@
|
|
|
1
|
-
import { importProjectModule } from "../project.js";
|
|
2
|
-
import { createLocalPostgresDb, startProjectPostgres } from "./local-postgres.js";
|
|
3
|
-
import { planLocalSchemaPush } from "./schema-push.js";
|
|
4
|
-
import { seedLocalDb } from "./seed.js";
|
|
5
|
-
import { setupLocalDb } from "./setup.js";
|
|
6
|
-
|
|
7
1
|
//#region db/ensure.d.ts
|
|
8
2
|
type EnsureLocalDbOptions = {
|
|
9
|
-
createLocalPostgresDb?: typeof createLocalPostgresDb;
|
|
10
3
|
env?: NodeJS.ProcessEnv;
|
|
11
|
-
importProjectModule?: typeof importProjectModule;
|
|
12
|
-
planLocalSchemaPush?: typeof planLocalSchemaPush;
|
|
13
|
-
seedLocalDb?: typeof seedLocalDb;
|
|
14
|
-
startProjectPostgres?: typeof startProjectPostgres;
|
|
15
|
-
setupLocalDb?: typeof setupLocalDb;
|
|
16
4
|
};
|
|
17
5
|
declare function ensureLocalDb({
|
|
18
|
-
|
|
19
|
-
env,
|
|
20
|
-
importProjectModule,
|
|
21
|
-
planLocalSchemaPush,
|
|
22
|
-
seedLocalDb,
|
|
23
|
-
startProjectPostgres,
|
|
24
|
-
setupLocalDb
|
|
6
|
+
env
|
|
25
7
|
}?: EnsureLocalDbOptions): Promise<void>;
|
|
26
8
|
//#endregion
|
|
27
9
|
export { ensureLocalDb };
|
package/dist/db/ensure.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{importProjectModule as e}from"../project.js";import{createLocalPostgresDb as t,startProjectPostgres as n}from"./local-postgres.js";import r from"../_virtual/_@oxc-project_runtime@0.138.0/helpers/esm/usingCtx.js";import{SEED_EMAILS as i,SEED_IDS as a}from"./config.js";import{inferSchemaDialect as o,planLocalSchemaPush as s}from"./schema-push.js";import{seedLocalDb as c}from"./seed.js";import{setupLocalDb as l}from"./setup.js";import{eq as u}from"drizzle-orm";
|
|
2
|
+
import{importProjectModule as e}from"../project.js";import{createLocalPostgresDb as t,startProjectPostgres as n}from"./local-postgres.js";import r from"../_virtual/_@oxc-project_runtime@0.138.0/helpers/esm/usingCtx.js";import{SEED_EMAILS as i,SEED_IDS as a}from"./config.js";import{inferSchemaDialect as o,planLocalSchemaPush as s}from"./schema-push.js";import{seedLocalDb as c}from"./seed.js";import{setupLocalDb as l}from"./setup.js";import{eq as u}from"drizzle-orm";async function d(){return{schema:await e(`src/db/schema.ts`)}}async function f(e,{users:t}){let[n]=await e.select({id:t.id}).from(t).where(u(t.email,i.adminUser)).limit(1);return n?.id===a.adminUser}async function p(e,{schema:t}){let n=await s(o(t),t,e);return n.sqlStatements.length===0?(console.log(`Local database schema already in sync`),{appliedStatements:0,plan:n}):(console.log(`Local database schema drift detected; applying ${n.sqlStatements.length} statement(s)`),await n.apply(),console.log(`Local database schema synced`),{appliedStatements:n.sqlStatements.length,plan:n})}async function m({env:e=process.env}={}){try{var i=r();let a=i.a(await n({env:e})).env,o=await d(),s=await t({env:a});try{if(await h(s,o.schema))console.log(`Local database already set up`);else{console.log(`Local database is missing or unseeded; running setup`),await l(`default`,{env:a});return}(await p(s,o)).appliedStatements>0&&!await h(s,o.schema)&&(console.log(`Local database seed data missing after schema sync; running seed`),await c(void 0,{env:a}))}finally{await s.$client.end()}}catch(e){i.e=e}finally{await i.d()}}async function h(e,t){try{return await f(e,t)}catch{return!1}}import.meta.main&&m().catch(e=>{console.error(e),process.exit(1)});export{m as ensureLocalDb};
|
|
@@ -1,8 +1,6 @@
|
|
|
1
|
+
import { CoreframeConfig } from "../config.js";
|
|
1
2
|
import { createProjectPostgresDrizzleDatabase } from "./project.js";
|
|
2
|
-
import {
|
|
3
|
-
import { readFile, rm } from "node:fs/promises";
|
|
4
|
-
import { tmpdir } from "node:os";
|
|
5
|
-
import { LocalPostgresEnv, startPostgres } from "local-postgres";
|
|
3
|
+
import { LocalPostgresEnv, PostgresOutputTarget } from "local-postgres";
|
|
6
4
|
|
|
7
5
|
//#region db/local-postgres.d.ts
|
|
8
6
|
declare const LOCAL_POSTGRES_ENV_FLAG = "COREFRAME_LOCAL_POSTGRES";
|
|
@@ -31,35 +29,19 @@ type StartProjectPostgresOptions = {
|
|
|
31
29
|
config?: CoreframeConfig;
|
|
32
30
|
cwd?: string;
|
|
33
31
|
env?: NodeJS.ProcessEnv;
|
|
34
|
-
|
|
35
|
-
readProjectConfig?: typeof readProjectConfig;
|
|
36
|
-
readFile?: typeof readFile;
|
|
37
|
-
rm?: typeof rm;
|
|
38
|
-
startPostgres?: typeof startPostgres;
|
|
39
|
-
};
|
|
40
|
-
type StartTemporaryProjectPostgresOptions = StartProjectPostgresOptions & {
|
|
41
|
-
mkdtemp?: (prefix: string) => Promise<string>;
|
|
42
|
-
tmpdir?: typeof tmpdir;
|
|
32
|
+
postgresOutput?: PostgresOutputTarget;
|
|
43
33
|
};
|
|
34
|
+
type StartTemporaryProjectPostgresOptions = StartProjectPostgresOptions;
|
|
44
35
|
declare function startProjectPostgres({
|
|
45
36
|
config,
|
|
46
37
|
cwd,
|
|
47
38
|
env,
|
|
48
|
-
|
|
49
|
-
readProjectConfig,
|
|
50
|
-
readFile,
|
|
51
|
-
rm,
|
|
52
|
-
startPostgres
|
|
39
|
+
postgresOutput
|
|
53
40
|
}?: StartProjectPostgresOptions): Promise<ProjectPostgresSidecar>;
|
|
54
41
|
declare function startTemporaryProjectPostgres({
|
|
55
42
|
config,
|
|
56
43
|
cwd,
|
|
57
|
-
env
|
|
58
|
-
mkdtemp,
|
|
59
|
-
readProjectConfig,
|
|
60
|
-
rm,
|
|
61
|
-
startPostgres,
|
|
62
|
-
tmpdir
|
|
44
|
+
env
|
|
63
45
|
}?: StartTemporaryProjectPostgresOptions): Promise<ProjectPostgresSidecar>;
|
|
64
46
|
declare function createLocalPostgresEnv(env: NodeJS.ProcessEnv, postgresEnv: LocalPostgresEnv): NodeJS.ProcessEnv;
|
|
65
47
|
declare function createLocalPostgresDb({
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{readProjectConfig as e}from"../config.js";import{
|
|
2
|
-
`,1)[0]);if(!(!Number.isSafeInteger(
|
|
1
|
+
import{readProjectConfig as e}from"../config.js";import{fs as t,os as n}from"../environment.js";import{createProjectPostgresDrizzleDatabase as r}from"./project.js";import i from"node:path";import{startPostgres as a}from"local-postgres";const o=`COREFRAME_LOCAL_POSTGRES`,s=`coreframe`,c={name:`coreframe`,password:`coreframe`};async function l({config:n,cwd:r=process.cwd(),env:o=process.env,postgresOutput:l}={}){if(o.COREFRAME_LOCAL_POSTGRES===`1`||((n??await e({cwd:r})).database?.dialect??`postgres`)!==`postgres`)return m(o);let u=i.resolve(r,`.coreframe/postgres`),d=await h(u);if(d!==void 0)throw Error(`PostgreSQL is already running for this project (PID ${d}). Stop the other top-level \`coreframe dev\` process before starting another.`);let f=i.join(u,`postgres.log`);await t.rm(f,{force:!0});let _;try{_=await a({dataDir:u,database:s,postgresOutput:l??{filePath:f},postgres:{strategy:`prefer-local`},superuser:c})}catch(e){throw await g(e,l?void 0:f)}return p(o,_)}async function u({config:r,cwd:o=process.cwd(),env:l=process.env}={}){let u=(r??await e({cwd:o})).database?.dialect??`postgres`;if(u!==`postgres`)throw Error(`Temporary schema push checks require PostgreSQL, but this project uses ${u}.`);let d=await t.mkdtemp(i.join(n.tmpdir(),`coreframe-schema-check-`));try{let e=p(l,await a({dataDir:d,database:s,postgresOutput:`ignore`,postgres:{strategy:`prefer-local`},superuser:c}));return{env:e.env,async[Symbol.asyncDispose](){try{await e[Symbol.asyncDispose]()}finally{await t.rm(d,{force:!0,recursive:!0})}}}}catch(e){throw await t.rm(d,{force:!0,recursive:!0}),e}}function d(e,t){return{...e,...t,[o]:`1`}}async function f({env:e=process.env}={}){let t=v(e);return r({env:{...e,DATABASE_URL:t}})}function p(e,t){return{env:d(e,t.env),async[Symbol.asyncDispose](){await t[Symbol.asyncDispose]()}}}function m(e){return{env:e,async[Symbol.asyncDispose](){}}}async function h(e){let r;try{r=await t.readFile(i.join(e,`postmaster.pid`),`utf8`)}catch{return}let a=Number(r.split(`
|
|
2
|
+
`,1)[0]);if(!(!Number.isSafeInteger(a)||a<=0))try{return n.kill(a,0),a}catch(e){return _(e)&&e.code===`EPERM`?a:void 0}}async function g(e,n){let r=e instanceof Error?e.message:String(e),i;if(n)try{i=(await t.readFile(n,`utf8`)).trim()||void 0}catch{}let a=i?`\n\nPostgreSQL output:\n${i}`:``,o=n?`\n\nPostgreSQL log: ${n}`:``;return Error(`Local PostgreSQL failed to start: ${r}${a}${o}`,{cause:e})}function _(e){return e instanceof Error}function v(e=process.env){let t=e.DATABASE_URL||y(e);if(!t)throw Error(`DATABASE_URL or PGDATABASE, PGHOST, PGPORT, and PGUSER are required.`);return t}function y(e){let{PGDATABASE:t,PGHOST:n,PGPASSWORD:r,PGPORT:i,PGUSER:a}=e;if(!t||!n||!i||!a)return;let o=new URL(`postgresql://${n}:${i}/${t}`);return o.username=a,r&&(o.password=r),o.href}export{o as LOCAL_POSTGRES_ENV_FLAG,f as createLocalPostgresDb,d as createLocalPostgresEnv,v as getLocalPostgresConnectionString,l as startProjectPostgres,u as startTemporaryProjectPostgres};
|
|
@@ -1,14 +1,12 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { DatabaseDialect } from "./client.js";
|
|
2
2
|
|
|
3
3
|
//#region db/migrate-held.d.ts
|
|
4
4
|
type MigrateHeldOptions = {
|
|
5
5
|
argv?: string[];
|
|
6
|
-
database?: DatabaseClient;
|
|
7
6
|
env?: NodeJS.ProcessEnv;
|
|
8
7
|
};
|
|
9
8
|
declare function migrateHeldMigrations({
|
|
10
9
|
argv,
|
|
11
|
-
database,
|
|
12
10
|
env
|
|
13
11
|
}?: MigrateHeldOptions): Promise<void>;
|
|
14
12
|
declare function validateHeldMigrationHeader(sql: string, relativePath: string): void;
|
package/dist/db/migrate-held.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{createProjectDeployDatabase as e}from"./project.js";import{collectHeldMigrationFiles as t,formatMigrationList as n}from"../deploy/migrations.js";import{createHash as r}from"node:crypto";import{readFile as i}from"node:fs/promises";const a=`--confirm=run-held-migrations`,o=[`-- Held migration:`,`-- Safe after:`,`-- Verification:`];async function s({argv:r=process.argv.slice(2),
|
|
2
|
+
import{createProjectDeployDatabase as e}from"./project.js";import{collectHeldMigrationFiles as t,formatMigrationList as n}from"../deploy/migrations.js";import{createHash as r}from"node:crypto";import{readFile as i}from"node:fs/promises";const a=`--confirm=run-held-migrations`,o=[`-- Held migration:`,`-- Safe after:`,`-- Verification:`];async function s({argv:r=process.argv.slice(2),env:o=process.env}={}){let s=await t();if(console.log(`Held migration files:`),console.log(n(s)),!r.includes(a))throw Error(`Held migrations require explicit confirmation. Re-run with ${a}.`);if(s.length===0){console.log(`No held migrations to run.`);return}let d=await e({env:o});try{await u(d);for(let e of s){let t=await i(e.path,`utf8`);c(t,e.relativePath);let n=l(t),r=await d.execute(f(d.dialect,e.id));if(r.rows.length===1){if(r.rows[0]?.sha256!==n)throw Error(`Held migration ${e.relativePath} changed after it was applied.`);console.log(`Skipping already-applied held migration ${e.relativePath}`);continue}console.log(`Applying held migration ${e.relativePath}`),await h(d,async r=>{await r.execute(t),await r.execute(p(d.dialect,e.id,n))})}}finally{await d.close?.()}}function c(e,t){let n=o.filter(t=>!e.includes(t));if(n.length>0)throw Error(`${t} is missing held migration header fields: ${n.join(`, `)}`)}function l(e){return r(`sha256`).update(e).digest(`hex`)}async function u(e){for(let t of d(e.dialect))await e.execute(t)}function d(e){switch(e){case`postgres`:return[`create schema if not exists drizzle`,`create table if not exists drizzle.__held_migrations (
|
|
3
3
|
id text primary key,
|
|
4
4
|
sha256 text not null,
|
|
5
5
|
applied_at timestamptz not null default now()
|
package/dist/db/migrate.d.ts
CHANGED
|
@@ -1,13 +1,9 @@
|
|
|
1
|
-
import { startProjectPostgres } from "./local-postgres.js";
|
|
2
|
-
|
|
3
1
|
//#region db/migrate.d.ts
|
|
4
2
|
type MigrateLocalDbOptions = {
|
|
5
3
|
env?: NodeJS.ProcessEnv;
|
|
6
|
-
startProjectPostgres?: typeof startProjectPostgres;
|
|
7
4
|
};
|
|
8
5
|
declare function migrateLocalDb({
|
|
9
|
-
env
|
|
10
|
-
startProjectPostgres
|
|
6
|
+
env
|
|
11
7
|
}?: MigrateLocalDbOptions): Promise<void>;
|
|
12
8
|
//#endregion
|
|
13
9
|
export { migrateLocalDb };
|
package/dist/db/migrate.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{createLocalPostgresDb as e,startProjectPostgres as t}from"./local-postgres.js";import n from"../_virtual/_@oxc-project_runtime@0.138.0/helpers/esm/usingCtx.js";import{MIGRATIONS_FOLDER as r}from"./config.js";import{access as i}from"node:fs/promises";import{resolve as a}from"node:path";import{migrate as o}from"drizzle-orm/node-postgres/migrator";const s=a(r)
|
|
2
|
+
import{createLocalPostgresDb as e,startProjectPostgres as t}from"./local-postgres.js";import n from"../_virtual/_@oxc-project_runtime@0.138.0/helpers/esm/usingCtx.js";import{MIGRATIONS_FOLDER as r}from"./config.js";import{access as i}from"node:fs/promises";import{resolve as a}from"node:path";import{migrate as o}from"drizzle-orm/node-postgres/migrator";const s=a(r);async function c({env:r=process.env}={}){try{var a=n();await i(s);let c=await e({env:a.a(await t({env:r})).env});try{await o(c,{migrationsFolder:s}),console.log(`Applied local migrations from ${s}`)}finally{await c.$client.end()}}catch(e){a.e=e}finally{await a.d()}}import.meta.main&&c().catch(e=>{console.error(e),process.exit(1)});export{c as migrateLocalDb};
|
package/dist/db/project.d.ts
CHANGED
|
@@ -1,13 +1,10 @@
|
|
|
1
1
|
import { DatabaseClient, DrizzleExecutor } from "./client.js";
|
|
2
|
-
import { importProjectModule } from "../project.js";
|
|
3
2
|
import { DatabaseConfig } from "../config.js";
|
|
4
3
|
|
|
5
4
|
//#region db/project.d.ts
|
|
6
5
|
type CreateProjectDatabaseOptions = {
|
|
7
6
|
config?: DatabaseConfig;
|
|
8
7
|
env?: NodeJS.ProcessEnv;
|
|
9
|
-
importProjectDependency?: ImportProjectDependency;
|
|
10
|
-
importProjectModule?: typeof importProjectModule;
|
|
11
8
|
};
|
|
12
9
|
type DrizzleDatabase = DrizzleExecutor & {
|
|
13
10
|
$client?: {
|
|
@@ -15,17 +12,12 @@ type DrizzleDatabase = DrizzleExecutor & {
|
|
|
15
12
|
end?(): Promise<void>;
|
|
16
13
|
};
|
|
17
14
|
};
|
|
18
|
-
type ImportProjectDependency = <T>(specifier: string) => Promise<T>;
|
|
19
15
|
declare function createProjectDeployDatabase({
|
|
20
16
|
config,
|
|
21
|
-
env
|
|
22
|
-
importProjectDependency,
|
|
23
|
-
importProjectModule
|
|
17
|
+
env
|
|
24
18
|
}?: CreateProjectDatabaseOptions): Promise<DatabaseClient>;
|
|
25
19
|
declare function createProjectPostgresDrizzleDatabase({
|
|
26
|
-
env
|
|
27
|
-
importProjectDependency,
|
|
28
|
-
importProjectModule
|
|
20
|
+
env
|
|
29
21
|
}?: CreateProjectDatabaseOptions): Promise<DrizzleDatabase>;
|
|
30
22
|
//#endregion
|
|
31
23
|
export { CreateProjectDatabaseOptions, createProjectDeployDatabase, createProjectPostgresDrizzleDatabase };
|
package/dist/db/project.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{readProjectConfig as e}from"../config.js";import{importProjectModule as
|
|
1
|
+
import{readProjectConfig as e}from"../config.js";import{importProjectDependency as t,importProjectModule as n}from"../project.js";import{createDatabaseAdapter as r}from"./client.js";const i=`src/db/relations.ts`;async function a({config:t,env:n=process.env}={}){let r=(t??(await e()).database)?.dialect??`postgres`;if(r===`postgres`)return s({env:n});if(r===`sqlite`)return c({env:n});throw Error(`Unsupported database dialect "${r}".`)}async function o({env:e=process.env}={}){let r=e.DATABASE_URL;if(!r)throw Error(`DATABASE_URL is required to create the PostgreSQL database.`);let[{drizzle:a},{relations:o}]=await Promise.all([t(`drizzle-orm/node-postgres`),n(i)]);return a({connection:{connectionString:r,max:1},relations:o})}async function s({env:e}){let t=await o({env:e});return r({database:t,dialect:`postgres`,close:()=>t.$client?.end?.()??Promise.resolve()})}async function c({env:e}){let a=e.TURSO_DATABASE_URL??e.DATABASE_URL;if(!a)throw Error(`TURSO_DATABASE_URL or DATABASE_URL is required to create the deploy database.`);let[{createClient:o},{drizzle:s},{relations:c}]=await Promise.all([t(`@libsql/client`),t(`drizzle-orm/libsql`),n(i)]),l=o({url:a,authToken:e.TURSO_AUTH_TOKEN});return r({database:s({client:l,relations:c}),dialect:`sqlite`,close:async()=>{await l.close?.()}})}export{a as createProjectDeployDatabase,o as createProjectPostgresDrizzleDatabase};
|
package/dist/db/reset.d.ts
CHANGED
|
@@ -1,13 +1,9 @@
|
|
|
1
|
-
import { startProjectPostgres } from "./local-postgres.js";
|
|
2
|
-
|
|
3
1
|
//#region db/reset.d.ts
|
|
4
2
|
type ResetLocalDbOptions = {
|
|
5
3
|
env?: NodeJS.ProcessEnv;
|
|
6
|
-
startProjectPostgres?: typeof startProjectPostgres;
|
|
7
4
|
};
|
|
8
5
|
declare function resetLocalDb({
|
|
9
|
-
env
|
|
10
|
-
startProjectPostgres
|
|
6
|
+
env
|
|
11
7
|
}?: ResetLocalDbOptions): Promise<void>;
|
|
12
8
|
//#endregion
|
|
13
9
|
export { resetLocalDb };
|
package/dist/db/reset.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{createLocalPostgresDb as e,startProjectPostgres as t}from"./local-postgres.js";import n from"../_virtual/_@oxc-project_runtime@0.138.0/helpers/esm/usingCtx.js";import{sql as r}from"drizzle-orm";
|
|
2
|
+
import{createLocalPostgresDb as e,startProjectPostgres as t}from"./local-postgres.js";import n from"../_virtual/_@oxc-project_runtime@0.138.0/helpers/esm/usingCtx.js";import{sql as r}from"drizzle-orm";async function i({env:i=process.env}={}){try{var a=n();let o=await e({env:a.a(await t({env:i})).env});try{await o.execute(r`drop schema if exists public cascade`),await o.execute(r`create schema public`),console.log(`Reset local PostgreSQL schema`)}finally{await o.$client.end()}}catch(e){a.e=e}finally{await a.d()}}import.meta.main&&i().catch(e=>{console.error(e),process.exit(1)});export{i as resetLocalDb};
|
|
@@ -1,26 +1,11 @@
|
|
|
1
|
-
import { importProjectModule } from "../project.js";
|
|
2
|
-
import { createLocalPostgresDb, startTemporaryProjectPostgres } from "./local-postgres.js";
|
|
3
|
-
import { planLocalSchemaPush } from "./schema-push.js";
|
|
4
|
-
import { runProjectSeed } from "./seed.js";
|
|
5
|
-
|
|
6
1
|
//#region db/schema-check.d.ts
|
|
7
2
|
type CheckSchemaPushOptions = {
|
|
8
|
-
createLocalPostgresDb?: typeof createLocalPostgresDb;
|
|
9
3
|
env?: NodeJS.ProcessEnv;
|
|
10
|
-
importProjectModule?: typeof importProjectModule;
|
|
11
|
-
planLocalSchemaPush?: typeof planLocalSchemaPush;
|
|
12
4
|
seed?: boolean;
|
|
13
|
-
runProjectSeed?: typeof runProjectSeed;
|
|
14
|
-
startTemporaryProjectPostgres?: typeof startTemporaryProjectPostgres;
|
|
15
5
|
};
|
|
16
6
|
declare function checkSchemaPush({
|
|
17
|
-
createLocalPostgresDb,
|
|
18
7
|
env,
|
|
19
|
-
|
|
20
|
-
planLocalSchemaPush,
|
|
21
|
-
seed,
|
|
22
|
-
runProjectSeed,
|
|
23
|
-
startTemporaryProjectPostgres
|
|
8
|
+
seed
|
|
24
9
|
}?: CheckSchemaPushOptions): Promise<void>;
|
|
25
10
|
//#endregion
|
|
26
11
|
export { checkSchemaPush };
|
package/dist/db/schema-check.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{importProjectModule as e}from"../project.js";import{createLocalPostgresDb as t,startTemporaryProjectPostgres as n}from"./local-postgres.js";import r from"../_virtual/_@oxc-project_runtime@0.138.0/helpers/esm/usingCtx.js";import{inferSchemaDialect as i,planLocalSchemaPush as a}from"./schema-push.js";import{runProjectSeed as o}from"./seed.js";
|
|
2
|
+
import{importProjectModule as e}from"../project.js";import{createLocalPostgresDb as t,startTemporaryProjectPostgres as n}from"./local-postgres.js";import r from"../_virtual/_@oxc-project_runtime@0.138.0/helpers/esm/usingCtx.js";import{inferSchemaDialect as i,planLocalSchemaPush as a}from"./schema-push.js";import{runProjectSeed as o}from"./seed.js";async function s({env:s=process.env,seed:l=!1}={}){try{var u=r();console.log(`Checking Drizzle schema against a throwaway PostgreSQL database`);let d=u.a(await n({env:s})),f=await e(`src/db/schema.ts`),p=await t({env:d.env});try{let e=i(f);if(e!==`postgres`)throw Error(`Temporary schema push checks require PostgreSQL schema, but found ${e}.`);let t=await a(e,f,p);t.sqlStatements.length===0?console.log(`Drizzle schema check passed with no changes`):(console.log(`Applying ${t.sqlStatements.length} statement(s) to throwaway database`),await t.apply(),console.log(`Drizzle schema check passed`)),l&&(console.log(`Seeding throwaway database`),await o(`default`,{env:d.env}),console.log(`Throwaway database seed check passed`))}finally{await c(p)}}catch(e){u.e=e}finally{await u.d()}}function c(e){return e.$client.end()}import.meta.main&&s().catch(e=>{console.error(e),process.exit(1)});export{s as checkSchemaPush};
|
package/dist/db/seed.d.ts
CHANGED
|
@@ -1,31 +1,18 @@
|
|
|
1
|
-
import { importProjectModule } from "../project.js";
|
|
2
|
-
import { startProjectPostgres } from "./local-postgres.js";
|
|
3
|
-
import { readProjectConfig } from "../config.js";
|
|
4
1
|
import { SeedProfile } from "./config.js";
|
|
5
2
|
|
|
6
3
|
//#region db/seed.d.ts
|
|
7
4
|
type SeedLocalDbOptions = {
|
|
8
5
|
env?: NodeJS.ProcessEnv;
|
|
9
|
-
importProjectModule?: typeof importProjectModule;
|
|
10
|
-
readProjectConfig?: typeof readProjectConfig;
|
|
11
|
-
startProjectPostgres?: typeof startProjectPostgres;
|
|
12
6
|
};
|
|
13
7
|
type RunProjectSeedOptions = {
|
|
14
8
|
env: NodeJS.ProcessEnv;
|
|
15
|
-
importProjectModule?: typeof importProjectModule;
|
|
16
|
-
readProjectConfig?: typeof readProjectConfig;
|
|
17
9
|
seedEntryPoint?: string;
|
|
18
10
|
};
|
|
19
11
|
declare function seedLocalDb(profile?: SeedProfile, {
|
|
20
|
-
env
|
|
21
|
-
importProjectModule,
|
|
22
|
-
readProjectConfig,
|
|
23
|
-
startProjectPostgres
|
|
12
|
+
env
|
|
24
13
|
}?: SeedLocalDbOptions): Promise<void>;
|
|
25
14
|
declare function runProjectSeed(profile: SeedProfile | undefined, {
|
|
26
15
|
env,
|
|
27
|
-
importProjectModule,
|
|
28
|
-
readProjectConfig,
|
|
29
16
|
seedEntryPoint
|
|
30
17
|
}: RunProjectSeedOptions): Promise<void>;
|
|
31
18
|
//#endregion
|
package/dist/db/seed.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{readProjectConfig as e}from"../config.js";import{importProjectModule as t}from"../project.js";import{startProjectPostgres as n}from"./local-postgres.js";import r from"../_virtual/_@oxc-project_runtime@0.138.0/helpers/esm/usingCtx.js";import{getSeedProfile as i}from"./config.js";
|
|
2
|
+
import{readProjectConfig as e}from"../config.js";import{importProjectModule as t}from"../project.js";import{startProjectPostgres as n}from"./local-postgres.js";import r from"../_virtual/_@oxc-project_runtime@0.138.0/helpers/esm/usingCtx.js";import{getSeedProfile as i}from"./config.js";async function a(t=i(),{env:a=process.env}={}){try{var c=r();let i=await e(),l=s(i);await o(t,{env:c.a(await n({config:i,env:a})).env,seedEntryPoint:l}),console.log(`Seeded local database with "${t}" profile`)}catch(e){c.e=e}finally{await c.d()}}async function o(n=i(),{env:r,seedEntryPoint:a}){a??=s(await e()),await l(r,async()=>{await c(await t(a),a)({env:r,profile:n})})}function s(e){let t=e.database?.seed;if(!t)throw Error(`coreframe.config.ts must configure database.seed before running db seed.`);return t}function c(e,t){let n=e.default??e.seed??e.seedLocalDb;if(!n)throw Error(`${t} must export a default seed function, seed function, or seedLocalDb function.`);return n}async function l(e,t){let n=new Map;for(let[t,r]of Object.entries(e))n.set(t,process.env[t]),r===void 0?delete process.env[t]:process.env[t]=r;try{await t()}finally{for(let[e,t]of n)t===void 0?delete process.env[e]:process.env[e]=t}}import.meta.main&&a().catch(e=>{console.error(e),process.exit(1)});export{o as runProjectSeed,a as seedLocalDb};
|
package/dist/db/setup.d.ts
CHANGED
|
@@ -1,14 +1,11 @@
|
|
|
1
|
-
import { startProjectPostgres } from "./local-postgres.js";
|
|
2
1
|
import { SeedProfile } from "./config.js";
|
|
3
2
|
|
|
4
3
|
//#region db/setup.d.ts
|
|
5
4
|
type SetupLocalDbOptions = {
|
|
6
5
|
env?: NodeJS.ProcessEnv;
|
|
7
|
-
startProjectPostgres?: typeof startProjectPostgres;
|
|
8
6
|
};
|
|
9
7
|
declare function setupLocalDb(profile?: SeedProfile, {
|
|
10
|
-
env
|
|
11
|
-
startProjectPostgres
|
|
8
|
+
env
|
|
12
9
|
}?: SetupLocalDbOptions): Promise<void>;
|
|
13
10
|
//#endregion
|
|
14
11
|
export { setupLocalDb };
|
package/dist/db/setup.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{startProjectPostgres as e}from"./local-postgres.js";import t from"../_virtual/_@oxc-project_runtime@0.138.0/helpers/esm/usingCtx.js";import{seedLocalDb as n}from"./seed.js";import{migrateLocalDb as r}from"./migrate.js";import{resetLocalDb as i}from"./reset.js";
|
|
2
|
+
import{startProjectPostgres as e}from"./local-postgres.js";import t from"../_virtual/_@oxc-project_runtime@0.138.0/helpers/esm/usingCtx.js";import{seedLocalDb as n}from"./seed.js";import{migrateLocalDb as r}from"./migrate.js";import{resetLocalDb as i}from"./reset.js";async function a(a=`default`,{env:o=process.env}={}){try{var s=t();let c=s.a(await e({env:o})).env;await i({env:c}),await r({env:c}),await n(a,{env:c})}catch(e){s.e=e}finally{await s.d()}}import.meta.main&&a().catch(e=>{console.error(e),process.exit(1)});export{a as setupLocalDb};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { UserConfig } from "vite";
|
|
2
|
+
|
|
3
|
+
//#region dev-https.d.ts
|
|
4
|
+
declare const devHttpsCertEnv = "COREFRAME_HTTPS_CERT";
|
|
5
|
+
declare const devHttpsKeyEnv = "COREFRAME_HTTPS_KEY";
|
|
6
|
+
type PrepareDevHttpsOptions = {
|
|
7
|
+
cwd?: string;
|
|
8
|
+
};
|
|
9
|
+
declare function prepareDevHttps({
|
|
10
|
+
cwd
|
|
11
|
+
}?: PrepareDevHttpsOptions): Promise<{
|
|
12
|
+
cert: string;
|
|
13
|
+
key: string;
|
|
14
|
+
}>;
|
|
15
|
+
declare function coreframeDevHttpsConfig(env?: NodeJS.ProcessEnv): UserConfig;
|
|
16
|
+
//#endregion
|
|
17
|
+
export { coreframeDevHttpsConfig, devHttpsCertEnv, devHttpsKeyEnv, prepareDevHttps };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{fs as e}from"./environment.js";import t from"node:path";import n from"nano-spawn";const r=`COREFRAME_HTTPS_CERT`,i=`COREFRAME_HTTPS_KEY`;async function a({cwd:r=process.cwd()}={}){let i=t.resolve(r,`.coreframe`,`https`),a=t.join(i,`localhost.pem`),o=t.join(i,`localhost-key.pem`);if(!await s(a,o)){let r;try{r=(await n(`mkcert`,[`-CAROOT`],{stdin:`ignore`})).stdout.trim()}catch{throw Error("Local HTTPS requires mkcert. Install it, run `mkcert -install`, then retry `coreframe dev --https`.")}try{await e.access(t.join(r,`rootCA.pem`))}catch{throw Error("The mkcert local CA is not initialized. Run `mkcert -install`, then retry `coreframe dev --https`.")}await e.mkdir(i,{recursive:!0}),await n(`mkcert`,[`-cert-file`,a,`-key-file`,o,`localhost`,`127.0.0.1`,`::1`],{stdin:`ignore`}),process.platform!==`win32`&&await e.chmod(o,384)}return{cert:a,key:o}}function o(t=process.env){let n=t[r],a=t[i];if(!n&&!a)return{};if(!n||!a)throw Error(`${r} and ${i} must be set together.`);return{server:{https:{cert:e.readFileSync(n),key:e.readFileSync(a)}}}}async function s(...t){try{return await Promise.all(t.map(t=>e.access(t))),!0}catch{return!1}}export{o as coreframeDevHttpsConfig,r as devHttpsCertEnv,i as devHttpsKeyEnv,a as prepareDevHttps};
|
package/dist/dev.d.ts
CHANGED
|
@@ -1,14 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { CoreframeConfig, readProjectConfig } from "./config.js";
|
|
1
|
+
import { CoreframeConfig } from "./config.js";
|
|
3
2
|
|
|
4
3
|
//#region dev.d.ts
|
|
5
4
|
type DevServerOptions = {
|
|
6
5
|
cwd?: string;
|
|
7
6
|
env?: NodeJS.ProcessEnv;
|
|
8
|
-
|
|
7
|
+
https?: boolean;
|
|
9
8
|
platform?: DevPlatform;
|
|
10
|
-
readProjectConfig?: typeof readProjectConfig;
|
|
11
|
-
startProjectPostgres?: typeof startProjectPostgres;
|
|
12
9
|
webPort?: number;
|
|
13
10
|
};
|
|
14
11
|
declare const devPlatforms: readonly ["web", "desktop", "ios", "android"];
|
|
@@ -17,12 +14,9 @@ declare function resolveDevPlatforms(config: CoreframeConfig): DevPlatform[];
|
|
|
17
14
|
declare function runDevServer({
|
|
18
15
|
cwd,
|
|
19
16
|
env,
|
|
20
|
-
|
|
17
|
+
https,
|
|
21
18
|
platform,
|
|
22
|
-
readProjectConfig,
|
|
23
|
-
startProjectPostgres,
|
|
24
19
|
webPort
|
|
25
20
|
}?: DevServerOptions): Promise<void>;
|
|
26
|
-
declare function getAvailablePort(): Promise<number>;
|
|
27
21
|
//#endregion
|
|
28
22
|
export { DevPlatform, DevServerOptions, devPlatforms, resolveDevPlatforms, runDevServer };
|
package/dist/dev.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{readProjectConfig as e}from"./config.js";import{
|
|
2
|
+
import{readProjectConfig as e}from"./config.js";import{fs as t,net as n}from"./environment.js";import{startProjectPostgres as r}from"./db/local-postgres.js";import i from"./_virtual/_@oxc-project_runtime@0.138.0/helpers/esm/usingCtx.js";import{devHttpsCertEnv as a,devHttpsKeyEnv as o,prepareDevHttps as s}from"./dev-https.js";import c from"node:path";import l from"node:process";import{PassThrough as u}from"node:stream";import{supervise as d}from"procband";const f=[`web`,`desktop`,`ios`,`android`];function p(e){let t=e.dev?.platforms??[`web`];for(let e of t)if(!f.includes(e))throw Error(`Invalid development platform "${String(e)}". Expected one of: ${f.join(`, `)}.`);return[...new Set(t)]}const m=c.resolve(`node_modules`,`.bin`),h=l.platform===`win32`?`pnpm.cmd`:`pnpm`,g=l.platform===`win32`?`react-router.cmd`:`react-router`,_=l.platform===`win32`?`turso.cmd`:`turso`;async function v({cwd:f=l.cwd(),env:p=l.env,https:v=!1,platform:C=`web`,webPort:w}={}){let T=p.PATH??p.Path??``,E=C===`web`?w??S(p.COREFRAME_WEB_PORT):void 0,D,O=p;if(v&&C!==`web`)throw Error(`Local HTTPS is only supported for the web development platform.`);try{if(C===`web`){let b=await e({cwd:f}),S=v?await s({cwd:f}):void 0;if(O=S?{...p,[a]:S.cert,[o]:S.key}:p,b.database?.dialect===`sqlite`){let e=await n.getAvailablePort(),r=c.resolve(f,`.coreframe`),i=c.join(r,`turso.db`);await t.mkdir(r,{recursive:!0}),O={...O,TURSO_DATABASE_URL:`http://127.0.0.1:${e}`},D=d({name:`turso`,command:_,args:[`dev`,`--port`,String(e),`--db-file`,i],cwd:f,env:p}),await D.waitFor(`listening`),await d({name:`db`,command:h,args:[`db`,`ensure`],cwd:f,env:O,prefix:!1}).expectSuccess()}if(y(b)){let e=new u,t=d({name:`postgres`,command:l.execPath,args:[`-e`,`process.stdin.pipe(process.stdout)`],cwd:f,stdin:e});try{try{var k=i();let t=k.a(await r({config:b,cwd:f,env:O,postgresOutput:e})).env;await d({name:`db`,command:h,args:[`db`,`ensure`],cwd:f,env:t,prefix:!1}).expectSuccess(),await d({name:`web`,command:g,args:x(E),cwd:f,env:{...t,CLOUDFLARE_ENV:`development`,PATH:m+c.delimiter+T}}).expectSuccess()}catch(e){k.e=e}finally{await k.d()}}finally{e.end(),await t.expectSuccess()}return}await d({name:`web`,command:g,args:x(E),cwd:f,env:{...O,CLOUDFLARE_ENV:`development`,PATH:m+c.delimiter+T}}).expectSuccess();return}let S=b(C);await d({name:C,command:h,args:S,cwd:f,env:p}).expectSuccess()}finally{D&&D.kill(`SIGTERM`)}}function y(e){return(e.database?.dialect??`postgres`)===`postgres`}function b(e){return[`--dir=tauri`,`tauri`,...e===`desktop`?[]:[e],`dev`]}function x(e){return e===void 0?[`dev`]:[`dev`,`--port`,String(e)]}function S(e){if(e===void 0)return;let t=Number(e);if(!Number.isInteger(t)||t<=0||t>65535)throw Error(`COREFRAME_WEB_PORT must be a valid TCP port.`);return t}import.meta.main&&v({env:{...l.env,FORCE_COLOR:`1`}}).catch(e=>{console.error(e),l.exit(1)});export{f as devPlatforms,p as resolveDevPlatforms,v as runDevServer};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { access, chmod, mkdir, mkdtemp, readFile, rm } from "node:fs/promises";
|
|
2
|
+
import { readFileSync } from "node:fs";
|
|
3
|
+
import { tmpdir } from "node:os";
|
|
4
|
+
|
|
5
|
+
//#region environment.d.ts
|
|
6
|
+
declare const fs: {
|
|
7
|
+
access: typeof access;
|
|
8
|
+
chmod: typeof chmod;
|
|
9
|
+
mkdir: typeof mkdir;
|
|
10
|
+
mkdtemp: typeof mkdtemp;
|
|
11
|
+
readFile: typeof readFile;
|
|
12
|
+
readFileSync: typeof readFileSync;
|
|
13
|
+
rm: typeof rm;
|
|
14
|
+
};
|
|
15
|
+
declare const net: {
|
|
16
|
+
getAvailablePort: typeof getAvailablePort;
|
|
17
|
+
};
|
|
18
|
+
declare const os: {
|
|
19
|
+
kill: (pid: number, signal?: string | number) => true;
|
|
20
|
+
tmpdir: typeof tmpdir;
|
|
21
|
+
};
|
|
22
|
+
declare function getAvailablePort(): Promise<number>;
|
|
23
|
+
//#endregion
|
|
24
|
+
export { fs, net, os };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{access as e,chmod as t,mkdir as n,mkdtemp as r,readFile as i,rm as a}from"node:fs/promises";import o from"node:process";import{readFileSync as s}from"node:fs";import{createServer as c}from"node:net";import{tmpdir as l}from"node:os";const u={access:e,chmod:t,mkdir:n,mkdtemp:r,readFile:i,readFileSync:s,rm:a},d={getAvailablePort:p},f={kill:o.kill,tmpdir:l};async function p(){let e=c();try{await new Promise((t,n)=>{e.once(`error`,n),e.listen(0,`127.0.0.1`,t)});let t=e.address();if(!t||typeof t==`string`)throw Error(`Could not allocate an available TCP port.`);return t.port}finally{e.listening&&await new Promise((t,n)=>{e.close(e=>e?n(e):t())})}}export{u as fs,d as net,f as os};
|
package/dist/project.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
//#region project.d.ts
|
|
2
2
|
declare function importProjectModule<T>(path: string): Promise<T>;
|
|
3
|
+
declare function importProjectDependency<T>(specifier: string): Promise<T>;
|
|
3
4
|
//#endregion
|
|
4
|
-
export { importProjectModule };
|
|
5
|
+
export { importProjectDependency, importProjectModule };
|
package/dist/project.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{createRequire as e}from"node:module";import{resolve as t}from"node:path";import{pathToFileURL as n}from"node:url";async function r(e){return await import(n(t(process.cwd(),e)).href)}async function i(r){return await import(n(e(t(`package.json`)).resolve(r)).href)}export{i as importProjectDependency,r as importProjectModule};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{coreframeGitRef as e,coreframeTemplateFile as t}from"./template-ref.js";import{join as n}from"node:path";import{
|
|
2
|
+
import{coreframeGitRef as e,coreframeTemplateFile as t}from"./template-ref.js";import{join as n}from"node:path";import{existsSync as r,mkdtempSync as i,readFileSync as a,rmSync as o,writeFileSync as s}from"node:fs";import{tmpdir as c}from"node:os";import{spawnSync as l}from"node:child_process";const u=`.agents/skills/coreframe-upgrade/SKILL.md`;function d(e,t={}){return l(`git`,e,t)}function f(e){return e.stderr.toString(`utf8`).trim()||e.stdout.toString(`utf8`).trim()}function p(e,n){let r=t(e,n),i=d([`show`,r],{encoding:`utf8`});if(i.status!==0){let e=f(i);throw Error(`Could not read ${r}.${e?` ${e}`:``}`)}return i.stdout.toString()}function m(){let e=d([`rev-parse`,`--show-toplevel`],{encoding:`utf8`});if(e.status!==0){let t=f(e);throw Error(`Could not find git repository root.${t?` ${t}`:``}`)}return e.stdout.toString().trim()}function h(e,t){let r=i(n(c(),`coreframe-upgrade-skill-`)),a=n(r,`SKILL.md`);try{s(a,t);let n=f(d([`--no-pager`,`diff`,`--no-index`,`--color=never`,`--`,e,a]));n&&console.log(n)}finally{o(r,{force:!0,recursive:!0})}}function g({apply:t,target:i}){let o=n(m(),u),c=e(i);if(!r(o))throw Error(`Local ${u} does not exist.`);let l=a(o,`utf8`),d=p(i,u);return l===d?(console.log(`Coreframe upgrade skill matches ${c}:template/${u}.`),0):t?(s(o,d),console.error(`Updated ${u} from ${c}:template. Reread it before continuing the upgrade.`),20):(console.error(`Coreframe upgrade skill differs from ${c}:template/${u}.`),console.error(`Run again with --apply to update it, then reread ${u} before continuing.`),h(o,d),20)}if(import.meta.main){let e=process.argv.indexOf(`--target`),t=e===-1?null:process.argv[e+1];t||(console.error(`Usage: coreframe upgrade check-skill-current --target <git-ref> [--apply]`),process.exit(64));try{process.exit(g({apply:process.argv.includes(`--apply`),target:t}))}catch(e){console.error(e instanceof Error?e.message:String(e)),process.exit(65)}}export{g as checkUpgradeSkillCurrent};
|
package/package.json
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@coreframe/scripts",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.10",
|
|
4
|
+
"repository": {
|
|
5
|
+
"type": "git",
|
|
6
|
+
"url": "git+https://github.com/airlock-labs/coreframe.git",
|
|
7
|
+
"directory": "scripts"
|
|
8
|
+
},
|
|
4
9
|
"bin": {
|
|
5
10
|
"coreframe": "./bin/coreframe.js"
|
|
6
11
|
},
|
|
@@ -9,11 +14,6 @@
|
|
|
9
14
|
"dist/"
|
|
10
15
|
],
|
|
11
16
|
"type": "module",
|
|
12
|
-
"repository": {
|
|
13
|
-
"type": "git",
|
|
14
|
-
"url": "git+https://github.com/airlock-labs/coreframe.git",
|
|
15
|
-
"directory": "scripts"
|
|
16
|
-
},
|
|
17
17
|
"exports": {
|
|
18
18
|
"./*": {
|
|
19
19
|
"types": "./dist/*.d.ts",
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"@clack/prompts": "^1.6.0",
|
|
32
32
|
"cmd-ts": "0.15.0",
|
|
33
33
|
"drizzle-orm": "1.0.0-rc.4",
|
|
34
|
-
"local-postgres": "0.
|
|
34
|
+
"local-postgres": "0.3.0",
|
|
35
35
|
"nano-spawn": "^2.1.0",
|
|
36
36
|
"procband": "^0.3.6",
|
|
37
37
|
"tinyglobby": "^0.2.17"
|