@coreframe/scripts 0.1.19 → 0.1.20
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
CHANGED
|
@@ -117,6 +117,12 @@ declare const coreframeCli: Partial<import("cmd-ts/dist/cjs/argparser").Register
|
|
|
117
117
|
base: string | undefined;
|
|
118
118
|
apply: boolean;
|
|
119
119
|
};
|
|
120
|
+
} | {
|
|
121
|
+
command: "sync-coreframe-packages";
|
|
122
|
+
args: {
|
|
123
|
+
target: string;
|
|
124
|
+
apply: boolean;
|
|
125
|
+
};
|
|
120
126
|
};
|
|
121
127
|
} | {
|
|
122
128
|
command: "db";
|
|
@@ -282,6 +288,12 @@ declare const coreframeCli: Partial<import("cmd-ts/dist/cjs/argparser").Register
|
|
|
282
288
|
base: string | undefined;
|
|
283
289
|
apply: boolean;
|
|
284
290
|
};
|
|
291
|
+
} | {
|
|
292
|
+
command: "sync-coreframe-packages";
|
|
293
|
+
args: {
|
|
294
|
+
target: string;
|
|
295
|
+
apply: boolean;
|
|
296
|
+
};
|
|
285
297
|
};
|
|
286
298
|
} | {
|
|
287
299
|
command: "db";
|
|
@@ -388,6 +400,9 @@ declare const coreframeCli: Partial<import("cmd-ts/dist/cjs/argparser").Register
|
|
|
388
400
|
} | {
|
|
389
401
|
command: "fast-forward-template-files";
|
|
390
402
|
value: void;
|
|
403
|
+
} | {
|
|
404
|
+
command: "sync-coreframe-packages";
|
|
405
|
+
value: void;
|
|
391
406
|
};
|
|
392
407
|
} | {
|
|
393
408
|
command: "db";
|
|
@@ -485,6 +500,9 @@ declare const coreframeCli: Partial<import("cmd-ts/dist/cjs/argparser").Register
|
|
|
485
500
|
} | {
|
|
486
501
|
command: "fast-forward-template-files";
|
|
487
502
|
value: void;
|
|
503
|
+
} | {
|
|
504
|
+
command: "sync-coreframe-packages";
|
|
505
|
+
value: void;
|
|
488
506
|
};
|
|
489
507
|
} | {
|
|
490
508
|
command: "db";
|
package/dist/coreframe.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
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{deployEnvironments as p,tauriReleasePlatforms as m}from"./deploy/config.js";import{discoverStagingUrl as h,reassignStagingHostname as g}from"./staging.js";import{discardPendingWorkerSecret as _,inspectWorkerEnvironment as v,queueWorkerSecret as y}from"./worker-environment.js";import{deployProject as b}from"./deploy.js";import{checkDeployMigrations as x}from"./deploy/check-migrations.js";import{devPlatforms as S,runDevServer as C}from"./dev.js";import{run as w}from"./runner.js";import{typecheckProject as T}from"./typecheck.js";import{checkUpgradeSkillCurrent as E}from"./upgrade/check-skill-current.js";import{ensureTemplateRemote as D}from"./upgrade/ensure-template-remote.js";import{fastForwardTemplateFiles as O}from"./upgrade/fast-forward-template-files.js";import*as k from"@clack/prompts";import{array as A,command as j,extendType as M,flag as N,multioption as P,number as F,oneOf as I,option as L,optional as R,positional as z,rest as B,string as V,subcommands as H}from"cmd-ts";const U=[`Cookies and sessions are origin-scoped.`,`Exact-host passkeys may require re-registration unless a stable eligible parent RP ID was configured in advance.`,`External OAuth callbacks such as Google may need updating.`,`Database data and private backend resources are unchanged.`],W=M(V,{displayName:`widths`,description:`Comma-separated responsive variant widths.`,async from(e){let t=e.split(`,`).map(e=>Number(e));if(t.length===0||t.some(e=>!Number.isInteger(e)||e<=0)||t.some((e,n)=>n>0&&e<=t[n-1]))throw Error(`Widths must be positive, unique, strictly ascending integers.`);return t}}),G=H({name:`coreframe`,cmds:{assets:H({name:`assets`,cmds:{add:j({name:`add`,args:{file:z({type:V,displayName:`file`,description:`Source image to add to the asset library.`}),id:L({long:`id`,type:V,description:`Logical asset ID, such as blog/my-post/hero.`}),alt:L({long:`alt`,type:V,description:`Required alt text for the asset.`}),variantWidths:L({long:`widths`,type:R(W),description:`Generate exactly these comma-separated widths instead of the default ladder.`}),json:N({long:`json`,description:`Print machine-readable JSON.`,defaultValue:()=>!1})},handler:async({alt:t,file:n,id:i,json:a,variantWidths:o})=>r(await e({alt:t,file:n,id:i,json:a,variantWidths:o}),a)}),build:j({name:`build`,args:{id:L({long:`id`,type:R(V),description:`Build only one logical asset ID.`}),noPull:N({long:`no-pull`,description:`Do not perform targeted Git LFS pulls for missing source objects.`,defaultValue:()=>!1}),json:N({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:j({name:`check`,args:{fix:N({long:`fix`,description:`Build missing generated variants when possible.`,defaultValue:()=>!1}),json:N({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:j({name:`publish`,args:{outputDir:L({long:`output-dir`,type:R(V),description:`Root directory for additive local publish output. Defaults to COREFRAME_ASSETS_PUBLISH_DIR or release-upload.`}),json:N({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:j({name:`status`,args:{json:N({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:j({name:`deploy`,args:{environment:z({type:I(p),displayName:`environment`,description:`Deploy to the staging or production environment.`}),runMigrations:N({long:`run-migrations`,description:`Run pending deploy-safe database migrations before deploying.`,defaultValue:()=>!1}),skipMigrations:N({long:`skip-migrations`,description:`Deploy without running pending deploy-safe database migrations.`,defaultValue:()=>!1}),skipPostDeployChecks:N({long:`skip-post-deploy-checks`,description:`Skip post-deploy checks after Cloudflare deployment.`,defaultValue:()=>!1}),tauriLocalPlatforms:P({long:`tauri-local-platform`,type:A(I(m)),description:`Build one Tauri release platform locally. Repeat for multiple platforms.`,defaultValue:()=>[]}),tauriWorkflowName:L({long:`tauri-workflow-name`,type:R(V),description:`GitHub Actions workflow file or name for remote Tauri release builds.`}),tauriWorkflowPlatforms:P({long:`tauri-workflow-platform`,type:A(I(m)),description:`Build one Tauri release platform with GitHub Actions. Repeat for multiple platforms.`,defaultValue:()=>[]}),tauriWorkflowRef:L({long:`tauri-workflow-ref`,type:R(V),description:`Git ref used when dispatching remote Tauri release builds.`}),yes:N({long:`yes`,short:`y`,description:`Approve the production deployment confirmation.`,defaultValue:()=>!1})},handler:({environment:e,runMigrations:t,skipMigrations:n,skipPostDeployChecks:r,tauriLocalPlatforms:i,tauriWorkflowName:a,tauriWorkflowPlatforms:o,tauriWorkflowRef:s,yes:c})=>b([e,...t?[`--run-migrations`]:[],...n?[`--skip-migrations`]:[],...r?[`--skip-post-deploy-checks`]:[],...i.flatMap(e=>[`--tauri-local-platform`,e]),...a?[`--tauri-workflow-name`,a]:[],...o.flatMap(e=>[`--tauri-workflow-platform`,e]),...s?[`--tauri-workflow-ref`,s]:[],...c?[`--yes`]:[]])}),staging:H({name:`staging`,cmds:{reassign:j({name:`reassign`,args:{json:N({long:`json`,description:`Print machine-readable JSON.`,defaultValue:()=>!1})},handler:async({json:e})=>{let t=await g();if(e){console.log(JSON.stringify({...t,notices:U}));return}console.log(t.url),console.error(`Staging hostname reassigned. ${U.join(` `)}`)}}),url:j({name:`url`,args:{json:N({long:`json`,description:`Print machine-readable JSON.`,defaultValue:()=>!1})},handler:async({json:e})=>{let t=await h();console.log(e?JSON.stringify({url:t}):t)}})}}),secrets:H({name:`secrets`,cmds:{status:j({name:`status`,args:{environment:z({type:R(I(p)),displayName:`environment`,description:`Inspect staging, production, or both when omitted.`}),json:N({long:`json`,description:`Print machine-readable JSON.`,defaultValue:()=>!1})},handler:async({environment:e,json:t})=>{let n=await v({environment:e});console.log(t?JSON.stringify(n):K(n))}}),set:j({name:`set`,args:{environment:z({type:I(p),displayName:`environment`,description:`Worker environment to update on its next deploy.`}),name:z({type:V,displayName:`name`,description:`Declared Worker secret name.`})},handler:async({environment:e,name:t})=>{await y({environment:e,name:t,value:await q(t)}),console.log(`Queued ${t} for ${e}. Run coreframe deploy ${e} to apply.`)}}),discard:j({name:`discard`,args:{environment:z({type:I(p),displayName:`environment`,description:`Worker environment with a queued secret update.`}),name:z({type:V,displayName:`name`,description:`Declared Worker secret name.`})},handler:async({environment:e,name:t})=>{let n=await _({environment:e,name:t});console.log(n?`Discarded the queued ${t} update for ${e}.`:`No ${t} update is queued for ${e}.`)}})}}),typecheck:j({name:`typecheck`,args:{},handler:T}),dev:j({name:`dev`,args:{https:N({long:`https`,description:`Serve the web app over locally trusted HTTPS.`,defaultValue:()=>!1}),host:L({long:`host`,type:R(V),description:`Host address for the web development server.`}),managed:N({long:`managed`,description:`Run managed checkout synchronization even without an interactive terminal.`,defaultValue:()=>!1}),noManaged:N({long:`no-managed`,description:`Run without managed checkout synchronization for this invocation.`,defaultValue:()=>!1}),platform:z({type:R(I(S)),displayName:`platform`,description:`Development target platform. Defaults to web.`}),port:L({long:`port`,type:R(F),description:`Port for the web development server.`})},handler:({host:e,https:t,managed:n,noManaged:r,platform:i,port:a})=>C({host:e,https:t,managed:n,noManaged:r,platform:i??`web`,webPort:a})}),upgrade:H({name:`upgrade`,cmds:{"ensure-template-remote":j({name:`ensure-template-remote`,args:{remote:L({long:`remote`,type:V,defaultValue:()=>`template`,description:`Remote name to ensure.`}),noFetch:N({long:`no-fetch`,description:`Do not fetch the remote after ensuring it exists.`,defaultValue:()=>!1})},handler:({noFetch:e,remote:t})=>D({fetch:!e,remote:t})}),"check-skill-current":j({name:`check-skill-current`,args:{target:L({long:`target`,type:V,description:`Target Coreframe template git ref.`}),apply:N({long:`apply`,description:`Replace the local upgrade skill with the target version when it differs.`,defaultValue:()=>!1})},handler:({apply:e,target:t})=>{process.exitCode=E({apply:e,target:t})}}),"fast-forward-template-files":j({name:`fast-forward-template-files`,args:{target:L({long:`target`,type:V,description:`Target Coreframe template git ref.`}),base:L({long:`base`,type:R(V),description:`Previous Coreframe template git ref. Defaults to package.json engines.coreframe.`}),apply:N({long:`apply`,description:`Write clean fast-forwards to the worktree.`,defaultValue:()=>!1})},handler:({apply:e,base:t,target:n})=>O({apply:e,base:t,target:n})})}}),db:H({name:`db`,cmds:{ensure:j({name:`ensure`,args:{},handler:u}),generate:j({name:`generate`,args:{args:B({displayName:`drizzle-kit args`,description:`Additional arguments passed to drizzle-kit generate.`})},handler:({args:e})=>a(`generate`,e)}),migrate:j({name:`migrate`,args:{args:B({displayName:`drizzle-kit args`,description:`Additional arguments passed to drizzle-kit migrate.`})},handler:({args:e})=>a(`migrate`,e)}),"migrate-held":j({name:`migrate-held`,args:{confirm:L({long:`confirm`,type:R(I([`run-held-migrations`])),description:`Required confirmation value for held migrations.`})},handler:({confirm:e})=>d({argv:e?[`--confirm=${e}`]:[]})}),"migrate-local":j({name:`migrate-local`,args:{},handler:s}),"migrations-check":j({name:`migrations-check`,args:{},handler:x}),reset:j({name:`reset`,args:{},handler:c}),seed:j({name:`seed`,args:{},handler:()=>o()}),"schema-check":j({name:`schema-check`,args:{seed:N({long:`seed`,description:`Run the configured project seed against the throwaway database.`,defaultValue:()=>!1})},handler:({seed:e})=>f({seed:e})}),setup:j({name:`setup`,args:{},handler:()=>l()}),studio:j({name:`studio`,args:{args:B({displayName:`drizzle-kit args`,description:`Additional arguments passed to drizzle-kit studio.`})},handler:({args:e})=>a(`studio`,e)})}})}});import.meta.main&&w(G);function K(e){if(e.entries.length===0)return`No Worker environment values are declared in coreframe.config.ts.`;let t=e.entries.map(e=>[e.name,e.kind,e.local===`override`?`override`:`built-in default`,e.deployed.staging.replaceAll(`_`,` `),e.deployed.production.replaceAll(`_`,` `)]),n=[`Name`,`Kind`,`Local`,`Staging`,`Production`],r=n.map((e,n)=>Math.max(e.length,...t.map(e=>e[n].length))),i=e=>e.map((e,t)=>e.padEnd(r[t])).join(` `).trimEnd();return[i(n),i(r.map(e=>`-`.repeat(e))),...t].join(`
|
|
3
|
-
`)}async function
|
|
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{deployEnvironments as p,tauriReleasePlatforms as m}from"./deploy/config.js";import{discoverStagingUrl as h,reassignStagingHostname as g}from"./staging.js";import{discardPendingWorkerSecret as _,inspectWorkerEnvironment as v,queueWorkerSecret as y}from"./worker-environment.js";import{deployProject as b}from"./deploy.js";import{checkDeployMigrations as x}from"./deploy/check-migrations.js";import{devPlatforms as S,runDevServer as C}from"./dev.js";import{run as w}from"./runner.js";import{typecheckProject as T}from"./typecheck.js";import{checkUpgradeSkillCurrent as E}from"./upgrade/check-skill-current.js";import{ensureTemplateRemote as D}from"./upgrade/ensure-template-remote.js";import{fastForwardTemplateFiles as O}from"./upgrade/fast-forward-template-files.js";import{syncCoreframePackages as k}from"./upgrade/sync-coreframe-packages.js";import*as A from"@clack/prompts";import{array as j,command as M,extendType as N,flag as P,multioption as F,number as I,oneOf as L,option as R,optional as z,positional as B,rest as V,string as H,subcommands as U}from"cmd-ts";const W=[`Cookies and sessions are origin-scoped.`,`Exact-host passkeys may require re-registration unless a stable eligible parent RP ID was configured in advance.`,`External OAuth callbacks such as Google may need updating.`,`Database data and private backend resources are unchanged.`],G=N(H,{displayName:`widths`,description:`Comma-separated responsive variant widths.`,async from(e){let t=e.split(`,`).map(e=>Number(e));if(t.length===0||t.some(e=>!Number.isInteger(e)||e<=0)||t.some((e,n)=>n>0&&e<=t[n-1]))throw Error(`Widths must be positive, unique, strictly ascending integers.`);return t}}),K=U({name:`coreframe`,cmds:{assets:U({name:`assets`,cmds:{add:M({name:`add`,args:{file:B({type:H,displayName:`file`,description:`Source image to add to the asset library.`}),id:R({long:`id`,type:H,description:`Logical asset ID, such as blog/my-post/hero.`}),alt:R({long:`alt`,type:H,description:`Required alt text for the asset.`}),variantWidths:R({long:`widths`,type:z(G),description:`Generate exactly these comma-separated widths instead of the default ladder.`}),json:P({long:`json`,description:`Print machine-readable JSON.`,defaultValue:()=>!1})},handler:async({alt:t,file:n,id:i,json:a,variantWidths:o})=>r(await e({alt:t,file:n,id:i,json:a,variantWidths:o}),a)}),build:M({name:`build`,args:{id:R({long:`id`,type:z(H),description:`Build only one logical asset ID.`}),noPull:P({long:`no-pull`,description:`Do not perform targeted Git LFS pulls for missing source objects.`,defaultValue:()=>!1}),json:P({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:M({name:`check`,args:{fix:P({long:`fix`,description:`Build missing generated variants when possible.`,defaultValue:()=>!1}),json:P({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:M({name:`publish`,args:{outputDir:R({long:`output-dir`,type:z(H),description:`Root directory for additive local publish output. Defaults to COREFRAME_ASSETS_PUBLISH_DIR or release-upload.`}),json:P({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:M({name:`status`,args:{json:P({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:M({name:`deploy`,args:{environment:B({type:L(p),displayName:`environment`,description:`Deploy to the staging or production environment.`}),runMigrations:P({long:`run-migrations`,description:`Run pending deploy-safe database migrations before deploying.`,defaultValue:()=>!1}),skipMigrations:P({long:`skip-migrations`,description:`Deploy without running pending deploy-safe database migrations.`,defaultValue:()=>!1}),skipPostDeployChecks:P({long:`skip-post-deploy-checks`,description:`Skip post-deploy checks after Cloudflare deployment.`,defaultValue:()=>!1}),tauriLocalPlatforms:F({long:`tauri-local-platform`,type:j(L(m)),description:`Build one Tauri release platform locally. Repeat for multiple platforms.`,defaultValue:()=>[]}),tauriWorkflowName:R({long:`tauri-workflow-name`,type:z(H),description:`GitHub Actions workflow file or name for remote Tauri release builds.`}),tauriWorkflowPlatforms:F({long:`tauri-workflow-platform`,type:j(L(m)),description:`Build one Tauri release platform with GitHub Actions. Repeat for multiple platforms.`,defaultValue:()=>[]}),tauriWorkflowRef:R({long:`tauri-workflow-ref`,type:z(H),description:`Git ref used when dispatching remote Tauri release builds.`}),yes:P({long:`yes`,short:`y`,description:`Approve the production deployment confirmation.`,defaultValue:()=>!1})},handler:({environment:e,runMigrations:t,skipMigrations:n,skipPostDeployChecks:r,tauriLocalPlatforms:i,tauriWorkflowName:a,tauriWorkflowPlatforms:o,tauriWorkflowRef:s,yes:c})=>b([e,...t?[`--run-migrations`]:[],...n?[`--skip-migrations`]:[],...r?[`--skip-post-deploy-checks`]:[],...i.flatMap(e=>[`--tauri-local-platform`,e]),...a?[`--tauri-workflow-name`,a]:[],...o.flatMap(e=>[`--tauri-workflow-platform`,e]),...s?[`--tauri-workflow-ref`,s]:[],...c?[`--yes`]:[]])}),staging:U({name:`staging`,cmds:{reassign:M({name:`reassign`,args:{json:P({long:`json`,description:`Print machine-readable JSON.`,defaultValue:()=>!1})},handler:async({json:e})=>{let t=await g();if(e){console.log(JSON.stringify({...t,notices:W}));return}console.log(t.url),console.error(`Staging hostname reassigned. ${W.join(` `)}`)}}),url:M({name:`url`,args:{json:P({long:`json`,description:`Print machine-readable JSON.`,defaultValue:()=>!1})},handler:async({json:e})=>{let t=await h();console.log(e?JSON.stringify({url:t}):t)}})}}),secrets:U({name:`secrets`,cmds:{status:M({name:`status`,args:{environment:B({type:z(L(p)),displayName:`environment`,description:`Inspect staging, production, or both when omitted.`}),json:P({long:`json`,description:`Print machine-readable JSON.`,defaultValue:()=>!1})},handler:async({environment:e,json:t})=>{let n=await v({environment:e});console.log(t?JSON.stringify(n):q(n))}}),set:M({name:`set`,args:{environment:B({type:L(p),displayName:`environment`,description:`Worker environment to update on its next deploy.`}),name:B({type:H,displayName:`name`,description:`Declared Worker secret name.`})},handler:async({environment:e,name:t})=>{await y({environment:e,name:t,value:await J(t)}),console.log(`Queued ${t} for ${e}. Run coreframe deploy ${e} to apply.`)}}),discard:M({name:`discard`,args:{environment:B({type:L(p),displayName:`environment`,description:`Worker environment with a queued secret update.`}),name:B({type:H,displayName:`name`,description:`Declared Worker secret name.`})},handler:async({environment:e,name:t})=>{let n=await _({environment:e,name:t});console.log(n?`Discarded the queued ${t} update for ${e}.`:`No ${t} update is queued for ${e}.`)}})}}),typecheck:M({name:`typecheck`,args:{},handler:T}),dev:M({name:`dev`,args:{https:P({long:`https`,description:`Serve the web app over locally trusted HTTPS.`,defaultValue:()=>!1}),host:R({long:`host`,type:z(H),description:`Host address for the web development server.`}),managed:P({long:`managed`,description:`Run managed checkout synchronization even without an interactive terminal.`,defaultValue:()=>!1}),noManaged:P({long:`no-managed`,description:`Run without managed checkout synchronization for this invocation.`,defaultValue:()=>!1}),platform:B({type:z(L(S)),displayName:`platform`,description:`Development target platform. Defaults to web.`}),port:R({long:`port`,type:z(I),description:`Port for the web development server.`})},handler:({host:e,https:t,managed:n,noManaged:r,platform:i,port:a})=>C({host:e,https:t,managed:n,noManaged:r,platform:i??`web`,webPort:a})}),upgrade:U({name:`upgrade`,cmds:{"ensure-template-remote":M({name:`ensure-template-remote`,args:{remote:R({long:`remote`,type:H,defaultValue:()=>`template`,description:`Remote name to ensure.`}),noFetch:P({long:`no-fetch`,description:`Do not fetch the remote after ensuring it exists.`,defaultValue:()=>!1})},handler:({noFetch:e,remote:t})=>D({fetch:!e,remote:t})}),"check-skill-current":M({name:`check-skill-current`,args:{target:R({long:`target`,type:H,description:`Target Coreframe template git ref.`}),apply:P({long:`apply`,description:`Replace the local upgrade skill with the target version when it differs.`,defaultValue:()=>!1})},handler:({apply:e,target:t})=>{process.exitCode=E({apply:e,target:t})}}),"fast-forward-template-files":M({name:`fast-forward-template-files`,args:{target:R({long:`target`,type:H,description:`Target Coreframe template git ref.`}),base:R({long:`base`,type:z(H),description:`Previous Coreframe template git ref. Defaults to package.json engines.coreframe.`}),apply:P({long:`apply`,description:`Write clean fast-forwards to the worktree.`,defaultValue:()=>!1})},handler:({apply:e,base:t,target:n})=>O({apply:e,base:t,target:n})}),"sync-coreframe-packages":M({name:`sync-coreframe-packages`,args:{target:R({long:`target`,type:H,description:`Target Coreframe template git ref.`}),apply:P({long:`apply`,description:`Update existing published Coreframe dependency specifications.`,defaultValue:()=>!1})},handler:({apply:e,target:t})=>k({apply:e,target:t})})}}),db:U({name:`db`,cmds:{ensure:M({name:`ensure`,args:{},handler:u}),generate:M({name:`generate`,args:{args:V({displayName:`drizzle-kit args`,description:`Additional arguments passed to drizzle-kit generate.`})},handler:({args:e})=>a(`generate`,e)}),migrate:M({name:`migrate`,args:{args:V({displayName:`drizzle-kit args`,description:`Additional arguments passed to drizzle-kit migrate.`})},handler:({args:e})=>a(`migrate`,e)}),"migrate-held":M({name:`migrate-held`,args:{confirm:R({long:`confirm`,type:z(L([`run-held-migrations`])),description:`Required confirmation value for held migrations.`})},handler:({confirm:e})=>d({argv:e?[`--confirm=${e}`]:[]})}),"migrate-local":M({name:`migrate-local`,args:{},handler:s}),"migrations-check":M({name:`migrations-check`,args:{},handler:x}),reset:M({name:`reset`,args:{},handler:c}),seed:M({name:`seed`,args:{},handler:()=>o()}),"schema-check":M({name:`schema-check`,args:{seed:P({long:`seed`,description:`Run the configured project seed against the throwaway database.`,defaultValue:()=>!1})},handler:({seed:e})=>f({seed:e})}),setup:M({name:`setup`,args:{},handler:()=>l()}),studio:M({name:`studio`,args:{args:V({displayName:`drizzle-kit args`,description:`Additional arguments passed to drizzle-kit studio.`})},handler:({args:e})=>a(`studio`,e)})}})}});import.meta.main&&w(K);function q(e){if(e.entries.length===0)return`No Worker environment values are declared in coreframe.config.ts.`;let t=e.entries.map(e=>[e.name,e.kind,e.local===`override`?`override`:`built-in default`,e.deployed.staging.replaceAll(`_`,` `),e.deployed.production.replaceAll(`_`,` `)]),n=[`Name`,`Kind`,`Local`,`Staging`,`Production`],r=n.map((e,n)=>Math.max(e.length,...t.map(e=>e[n].length))),i=e=>e.map((e,t)=>e.padEnd(r[t])).join(` `).trimEnd();return[i(n),i(r.map(e=>`-`.repeat(e))),...t].join(`
|
|
3
|
+
`)}async function J(e){if(!process.stdin.isTTY){let e=``;for await(let t of process.stdin)e+=t.toString();return e.replace(/\r?\n$/,``)}let t=await A.password({message:`Enter the new value for ${e}`});if(A.isCancel(t))throw A.cancel(`Secret update cancelled.`),Error(`Secret update cancelled.`);return t}export{K as coreframeCli};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
//#region upgrade/sync-coreframe-packages.d.ts
|
|
2
|
+
type SyncCoreframePackagesOptions = {
|
|
3
|
+
apply: boolean;
|
|
4
|
+
target: string;
|
|
5
|
+
};
|
|
6
|
+
declare function syncCoreframePackages(args: SyncCoreframePackagesOptions): void;
|
|
7
|
+
//#endregion
|
|
8
|
+
export { SyncCoreframePackagesOptions, syncCoreframePackages };
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import{coreframeGitRef as e}from"./template-ref.js";import{posix as t,resolve as n}from"node:path";import{readFileSync as r,writeFileSync as i}from"node:fs";import{spawnSync as a}from"node:child_process";const o=[`dependencies`,`devDependencies`];function s(e){let t=a(`git`,e,{encoding:`utf8`});if(t.status!==0){let n=t.stderr.trim()||t.stdout.trim();throw Error(`Git command failed: git ${e.join(` `)}${n?`\n${n}`:``}`)}return t.stdout}function c(e,t){try{return JSON.parse(e)}catch(e){throw Error(`Could not parse ${t}: ${e instanceof Error?e.message:e}`)}}function l(t,n){let r=`${e(t)}:${n}`;return c(s([`show`,r]),r)}function u(e){return e.startsWith(`@coreframe/`)}function d(e){return e.startsWith(`file:`)||e.startsWith(`link:`)||e.startsWith(`workspace:`)}function f(e){return e.startsWith(`file:`)||e.startsWith(`link:`)}function p(e,n){let r=e.indexOf(`:`),i=e.slice(r+1),a=t.normalize(t.join(`template`,i,`package.json`));if(i.length===0||t.isAbsolute(i)||a===`..`||a.startsWith(`../`))throw Error(`Invalid local template dependency for ${n}: ${e}`);return a}function m(t){let n=l(t,`template/package.json`),r=[],i=new Set;for(let a of o)for(let[o,s]of Object.entries(n[a]??{})){if(!u(o)||!f(s))continue;if(i.has(o))throw Error(`Target template declares ${o} more than once.`);let n=p(s,o),c=l(t,n);if(c.name!==o||typeof c.version!=`string`)throw Error(`${e(t)}:${n} must declare ${o} with a version.`);r.push({group:a,name:o,spec:`^${c.version}`}),i.add(o)}return r}function h(e,t){for(let n of o){let r=e[n]?.[t];if(r)return{group:n,spec:r}}}function g(e,t,n){let r=t.match(/\n([\t ]+)"/u)?.[1]??` `,a=t.endsWith(`
|
|
3
|
+
`)?`
|
|
4
|
+
`:``;i(e,`${JSON.stringify(n,null,r)}${a}`)}function _(e,t){if(t.length!==0){console.log(`${e}:`);for(let e of t)console.log(` ${e}`);console.log(``)}}function v(t){let i=n(s([`rev-parse`,`--show-toplevel`]).trim(),`package.json`),a=r(i,`utf8`),l=c(a,i),f=e(t.target),p=m(f),v=new Set(p.map(({name:e})=>e)),y=[],b=[],x=[],S=0;for(let e of p){let t=h(l,e.name);if(!t){b.push(`missing: ${e.name} ${e.spec} (${e.group})`);continue}if(d(t.spec)){x.push(`linked: ${e.name} ${t.spec}`);continue}if(t.spec===e.spec){S+=1;continue}y.push({...e,currentGroup:t.group,currentSpec:t.spec})}let C=o.flatMap(e=>Object.entries(l[e]??{}).filter(([e])=>u(e)&&!v.has(e)).map(([t,n])=>`review: ${t} ${n} (${e})`));if(t.apply&&y.length>0){for(let e of y)l[e.currentGroup][e.name]=e.spec;g(i,a,l)}console.log(`Coreframe package sync: ${f}`),console.log(``),_(t.apply?`Updated Coreframe packages`:`Would update Coreframe packages`,y.map(({currentSpec:e,name:t,spec:n})=>`update: ${t} ${e} -> ${n}`)),_(`Missing target Coreframe packages`,b),_(`Locally linked Coreframe packages`,x),_(`Downstream-only Coreframe packages`,C),S>0&&console.log(`${S} Coreframe package(s) already match the target versions.`),y.length===0?console.log(`No Coreframe package version updates found.`):t.apply||(console.log(``),console.log(`Run with --apply to write the ${y.length} package update(s).`))}export{v as syncCoreframePackages};
|