@stacksjs/actions 0.70.70 → 0.70.71
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/upgrade/framework.js +4 -4
- package/dist/upgrade/packages.d.ts +14 -0
- package/dist/upgrade/packages.js +11 -0
- package/package.json +16 -16
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{c as
|
|
2
|
+
import{c as R,d as x,e as w,f as S,g as u,h as y,i as h,j as p,k as g,l as d,m as D,n as l,o as H,p as m}from"../chunk-n24m8prb.js";import{pb as j}from"../chunk-4qzb8g3z.js";import{copyFileSync as i,cpSync as a,existsSync as B,mkdirSync as f,readFileSync as e,rmSync as qq}from"fs";import{dirname as zq,join as U}from"path";import I from"process";import{parseOptions as Kq}from"@stacksjs/cli";import{downloadTemplate as n}from"@stacksjs/gitit";import{path as N}from"@stacksjs/path";import{ExitCode as C}from"@stacksjs/types";var Y=Kq(),O=N.projectPath();if(!B(N.projectPath("storage/framework/core"))){let{upgradeStacksPackages:q}=await import("./packages.js");await q(O,{version:Y.version,canary:Y.canary,stable:Y.stable,force:Y.force,dryRun:Y.dryRun,noPostinstall:Y.noPostinstall??Y.postinstall===!1})}var c=U(O,".stacks-channel"),s=U(O,".stacks-version"),A=S(c),$=R(Y,A),r=N.projectPath("storage/framework/core/buddy/package.json"),Qq=w(r),Wq=Y.from?N.projectPath(Y.from):null,_=Wq??l(O),E=!!_;console.log(g($,A,!!Y.stable));console.log(E?` source: local checkout at ${_}`:` source: github:stacksjs/stacks#${$.ref}`);if(!Y.force){let q=await Jq(O);if(q.length>0){console.warn(`
|
|
3
3
|
\u26A0 The following framework-managed paths have uncommitted changes:`);for(let z of q)console.warn(` - ${z}`);console.warn(`
|
|
4
4
|
Aborting to avoid clobbering your edits.`),console.warn(` Re-run with --force to overwrite, or commit / stash the changes first.
|
|
5
|
-
`),I.exit(C.FatalError)}}var
|
|
6
|
-
`);let q=I.argv.slice(2).filter((Q)=>Q!=="--__restarted"),K=await Bun.spawn({cmd:[I.argv[0]||"bun",b,...q,"--__restarted"],cwd:
|
|
7
|
-
`).filter((W)=>W.length>0).map((W)=>W.slice(3))}catch{return[]}}async function
|
|
5
|
+
`),I.exit(C.FatalError)}}var G=null;if(!Y.force&&!$.targetVersion){G=await t($,E,_);let q=y(s);if(p({force:!!Y.force,targetVersion:$.targetVersion,remoteSha:G,synced:q,channel:$.channel}))console.log(`\u2714 Already on the latest ${$.channel} (${G.slice(0,7)}).`),I.exit(C.Success)}var b=N.frameworkPath("core/actions/src/upgrade/framework.ts"),k=await o(b),V={added:0,changed:0,removed:0,unchanged:0},v=[];try{for(let q of D){let z=U(O,q.localPath),K=q.isFile?await T(z):await H(z,q.skip);if(E&&_)await Bq(_,q,z);else{if(q.isFile)continue;await Iq($.ref,q,z,!!Y.force)}let Q=q.isFile?await T(z):await H(z,q.skip),W=m(K,Q);V.added+=W.added,V.changed+=W.changed,V.removed+=W.removed,V.unchanged+=W.unchanged,v.push({managed:q,summary:W})}if(!E)await Uq($.ref)}catch(q){console.error("\u2718 Failed to upgrade Stacks framework:",q?.message||q),I.exit(C.FatalError)}var Xq=w(r),P=await o(b),Yq=I.argv.includes("--__restarted");if(k!==0n&&P!==0n&&k!==P&&!Yq){console.log(`Upgrade pulled a newer version of the upgrade action \u2014 re-running once to pick up new sync paths and hooks.
|
|
6
|
+
`);let q=I.argv.slice(2).filter((Q)=>Q!=="--__restarted"),K=await Bun.spawn({cmd:[I.argv[0]||"bun",b,...q,"--__restarted"],cwd:O,stdout:"inherit",stderr:"inherit"}).exited;I.exit(K??0)}if(!$.targetVersion){if(u(c,$.channel),!G)G=await t($,E,_);if(G)h(s,$.channel,G)}console.log(`\u2714 ${d($,Qq,Xq,A,!!Y.force)}`);console.log("Sync summary:");for(let{managed:q,summary:z}of v)if(q.isFile){let K=z.added+z.changed>0;console.log(` ${q.label.padEnd(10)} ${K?"updated":"unchanged"}`)}else if(z.added+z.changed+z.removed===0)console.log(` ${q.label.padEnd(10)} unchanged (${z.unchanged} files)`);else console.log(` ${q.label.padEnd(10)} +${z.added} ~${z.changed} -${z.removed} (${z.unchanged} unchanged)`);var $q=!Y.noPostinstall&&Y.postinstall!==!1;if($q)await Zq({aggregate:V,perPath:v,projectRoot:O});if($.channel==="canary"&&!$.targetVersion)console.warn("\u26A0 Canary builds may contain bugs or breaking changes. Not recommended for production.");I.exit(C.Success);async function Jq(q){let z=U(q,".git");if(!B(z))return[];try{let K=Bun.spawn({cmd:["git","-C",q,"status","--porcelain","--",...D.map((W)=>W.localPath)],stdout:"pipe",stderr:"pipe"}),Q=await new Response(K.stdout).text();return await K.exited,Q.split(`
|
|
7
|
+
`).filter((W)=>W.length>0).map((W)=>W.slice(3))}catch{return[]}}async function t(q,z,K){let Q=/^[0-9a-f]{40}$/i;try{if(z&&K){let J=Bun.spawn({cmd:["git","-C",K,"rev-parse",q.ref],stdout:"pipe",stderr:"pipe"}),Z=(await new Response(J.stdout).text()).trim();if(await J.exited===0&&Q.test(Z))return Z.toLowerCase();let F=Bun.spawn({cmd:["git","-C",K,"rev-parse","HEAD"],stdout:"pipe",stderr:"pipe"}),L=(await new Response(F.stdout).text()).trim();return await F.exited===0&&Q.test(L)?L.toLowerCase():null}let W=Bun.spawn({cmd:["git","ls-remote","https://github.com/stacksjs/stacks.git",`refs/heads/${q.ref}`],stdout:"pipe",stderr:"pipe"}),M=await new Response(W.stdout).text();if(await W.exited!==0)return null;let X=M.match(/^([0-9a-f]{40})\s/i);return X?.[1]?X[1].toLowerCase():null}catch{return null}}async function o(q){try{if(!B(q))return 0n;let z=await Bun.file(q).arrayBuffer();return Bun.hash(z)}catch{return 0n}}async function T(q){let z=new Map;if(!B(q))return z;try{let K=Bun.file(q);if(K.size>0){let Q=await K.arrayBuffer();z.set("self",{size:K.size,hash:Bun.hash(Q)})}}catch{}return z}async function Bq(q,z,K){let Q=U(q,z.subPath);if(!B(Q)){console.warn(` skip ${z.label}: source missing at ${Q}`);return}if(z.isFile){f(zq(K),{recursive:!0}),i(Q,K);return}f(K,{recursive:!0}),a(Q,K,{recursive:!0,force:!0,filter:(W)=>{if(!z.skip)return!0;let M=W.split("/").pop()||"";return!z.skip.includes(M)}})}async function Iq(q,z,K,Q){let W=x(q,z.subPath);await n(W,{dir:K,force:!0,forceClean:!1,preferOffline:!Q})}async function Uq(q){let z=N.projectPath(".tmp-upgrade");try{await n(`github:stacksjs/stacks#${q}`,{dir:z,force:!0,forceClean:!0,preferOffline:!0,silent:!0});for(let K of D){if(!K.isFile)continue;let Q=U(z,K.subPath),W=N.projectPath(K.localPath);try{if(B(Q)&&B(W))i(Q,W)}catch{}}}catch{}finally{if(B(z))qq(z,{recursive:!0,force:!0})}}async function Zq(q){let{aggregate:z,perPath:K,projectRoot:Q}=q;if(z.added+z.changed+z.removed===0){console.log("Nothing changed \u2014 skipping post-sync hooks.");return}console.log("Regenerating auto-import manifest...");try{let{generateAutoImportFiles:X}=await import("@stacksjs/server");await X()}catch(X){console.warn(` auto-imports failed (non-fatal): ${X?.message||X}`)}if(K.some((X)=>{let{managed:J,summary:Z}=X;if(J.isFile)return!1;if(J.label!=="core"&&J.label!=="defaults")return!1;if(Z.added+Z.changed===0)return!1;return Nq(U(Q,J.localPath))})){console.log("Running `bun install` to refresh dependencies...");try{let J=await Bun.spawn({cmd:[I.argv[0]||"bun","install"],cwd:Q,stdout:"inherit",stderr:"inherit"}).exited;if(J!==0)console.warn(` bun install exited with code ${J} (non-fatal)`)}catch(X){console.warn(` bun install failed (non-fatal): ${X?.message||X}`)}}let M=U(Q,"database","migrations");if(B(M)){console.log("Running pending migrations...");try{let X=N.frameworkPath("core/buddy/src/cli.ts"),Z=await Bun.spawn({cmd:[I.argv[0]||"bun",X,"migrate"],cwd:Q,stdout:"inherit",stderr:"inherit"}).exited;if(Z!==0)console.warn(` migrate exited with code ${Z} (non-fatal \u2014 DB may not be set up yet)`)}catch(X){console.warn(` migrate failed (non-fatal): ${X?.message||X}`)}}}function Nq(q){try{if(!B(q))return!1;return e(U(q,"package.json"),"utf-8").length>0}catch{return B(q)}}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Upgrade a node_modules app to a published framework version. Called by the
|
|
3
|
+
* framework upgrade script when no vendored `storage/framework/core` exists.
|
|
4
|
+
* Handles resolution, package.json rewrite, and reinstall; then `process.exit`s.
|
|
5
|
+
*/
|
|
6
|
+
export declare function upgradeStacksPackages(projectRoot: string, options: PackageUpgradeOptions): Promise<never>;
|
|
7
|
+
export declare interface PackageUpgradeOptions {
|
|
8
|
+
version?: string
|
|
9
|
+
canary?: boolean
|
|
10
|
+
stable?: boolean
|
|
11
|
+
force?: boolean
|
|
12
|
+
dryRun?: boolean
|
|
13
|
+
noPostinstall?: boolean
|
|
14
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import"../chunk-4qzb8g3z.js";import{existsSync as U,readFileSync as V,writeFileSync as W}from"fs";import{join as X}from"path";import M from"process";import{runCommand as Y}from"@stacksjs/cli";async function Z(A){let z=await fetch("https://registry.npmjs.org/stacks").catch(()=>null);if(!z||!z.ok)throw Error("Could not reach the npm registry to resolve the target `stacks` version.");let H=await z.json(),J=H["dist-tags"]??{},G=H.versions??{},q;if(A.version){if(!G[A.version])throw Error(`stacks@${A.version} was not found on the npm registry.`);q=A.version}else{let I=A.canary?"canary":"latest",b=J[I];if(!b)throw Error(`The \`${I}\` dist-tag is not published for \`stacks\`.`);q=b}let E=new Set(Object.keys(G[q]?.dependencies??{}));return{version:q,coreDeps:E}}function _(A,z,H){let J=[],G=(q)=>q==="stacks"||q.startsWith("@stacksjs/")&&H.has(q);for(let q of["dependencies","devDependencies"]){let E=A[q];if(!E)continue;for(let[I,b]of Object.entries(E)){if(!G(I))continue;let Q=`${/^[\^~]/.test(b)?b[0]:/^\d/.test(b)?"":"^"}${z}`;if(b!==Q)J.push({name:I,from:b,to:Q}),E[I]=Q}}return J}async function F(A,z){let H=X(A,"package.json");if(!U(H))console.error("No package.json found \u2014 nothing to upgrade."),M.exit(1);let J=V(H,"utf-8"),G=JSON.parse(J),q=G.dependencies?.stacks??G.devDependencies?.stacks,{version:E,coreDeps:I}=await Z(z).catch((N)=>{console.error(`\u2717 ${N.message}`),M.exit(1)});if(console.log(`
|
|
3
|
+
Upgrading the Stacks framework${z.canary?" (canary)":""} \u2192 ${E}`),q)console.log(` current \`stacks\` constraint: ${q}
|
|
4
|
+
`);let b=_(G,E,I);if(b.length===0&&!z.force)console.log(`\u2714 Already up to date \u2014 every framework dependency matches the target.
|
|
5
|
+
`),M.exit(0);if(b.length>0){console.log(" The following dependencies will be updated:");let N=Math.max(...b.map((O)=>O.name.length));for(let O of b)console.log(` ${O.name.padEnd(N)} ${O.from} \u2192 ${O.to}`);console.log("")}if(z.dryRun)console.log(` --dry-run: no files were written and nothing was installed.
|
|
6
|
+
`),M.exit(0);if(b.length>0){let N=J.endsWith(`
|
|
7
|
+
`)?`
|
|
8
|
+
`:"";W(H,`${JSON.stringify(G,null,2)}${N}`),console.log("\u2714 Updated package.json")}if(z.noPostinstall)console.log(" --no-postinstall: skipping `bun install`. Run it yourself to pull the new versions.\n"),M.exit(0);console.log(` Installing\u2026
|
|
9
|
+
`);let K=await Y("bun install",{cwd:A});if(K&&typeof K==="object"&&"isErr"in K?typeof K.isErr==="function"?K.isErr():K.isErr===!0:!1)console.error("\n\u2717 `bun install` failed. Your package.json was updated \u2014 resolve the install error and re-run `bun install`.\n"),M.exit(1);console.log(`
|
|
10
|
+
\u2714 Upgraded to stacks@${E}. Review the changelog: https://github.com/stacksjs/stacks/releases/tag/v${E}
|
|
11
|
+
`),M.exit(0)}export{F as upgradeStacksPackages};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stacksjs/actions",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.70.
|
|
4
|
+
"version": "0.70.71",
|
|
5
5
|
"description": "The Stacks actions.",
|
|
6
6
|
"author": "Chris Breuer",
|
|
7
7
|
"contributors": [
|
|
@@ -65,22 +65,22 @@
|
|
|
65
65
|
"@stacksjs/ts-md": "^0.1.1"
|
|
66
66
|
},
|
|
67
67
|
"devDependencies": {
|
|
68
|
-
"@stacksjs/api": "0.70.
|
|
69
|
-
"@stacksjs/cli": "0.70.
|
|
70
|
-
"@stacksjs/config": "0.70.
|
|
71
|
-
"@stacksjs/database": "0.70.
|
|
68
|
+
"@stacksjs/api": "0.70.71",
|
|
69
|
+
"@stacksjs/cli": "0.70.71",
|
|
70
|
+
"@stacksjs/config": "0.70.71",
|
|
71
|
+
"@stacksjs/database": "0.70.71",
|
|
72
72
|
"@stacksjs/tlsx": "^0.13.2",
|
|
73
73
|
"better-dx": "^0.2.12",
|
|
74
|
-
"@stacksjs/dns": "0.70.
|
|
75
|
-
"@stacksjs/enums": "0.70.
|
|
76
|
-
"@stacksjs/env": "0.70.
|
|
77
|
-
"@stacksjs/error-handling": "0.70.
|
|
78
|
-
"@stacksjs/logging": "0.70.
|
|
79
|
-
"@stacksjs/path": "0.70.
|
|
80
|
-
"@stacksjs/security": "0.70.
|
|
81
|
-
"@stacksjs/storage": "0.70.
|
|
82
|
-
"@stacksjs/strings": "0.70.
|
|
83
|
-
"@stacksjs/utils": "0.70.
|
|
84
|
-
"@stacksjs/validation": "0.70.
|
|
74
|
+
"@stacksjs/dns": "0.70.71",
|
|
75
|
+
"@stacksjs/enums": "0.70.71",
|
|
76
|
+
"@stacksjs/env": "0.70.71",
|
|
77
|
+
"@stacksjs/error-handling": "0.70.71",
|
|
78
|
+
"@stacksjs/logging": "0.70.71",
|
|
79
|
+
"@stacksjs/path": "0.70.71",
|
|
80
|
+
"@stacksjs/security": "0.70.71",
|
|
81
|
+
"@stacksjs/storage": "0.70.71",
|
|
82
|
+
"@stacksjs/strings": "0.70.71",
|
|
83
|
+
"@stacksjs/utils": "0.70.71",
|
|
84
|
+
"@stacksjs/validation": "0.70.71"
|
|
85
85
|
}
|
|
86
86
|
}
|