@stacksjs/buddy 0.75.310 → 0.75.315
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/native-project.js +12 -3
- package/package.json +56 -56
package/dist/native-project.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{chmodSync,existsSync,mkdirSync,readFileSync,
|
|
1
|
+
import{chmodSync,existsSync,mkdirSync,readdirSync,readFileSync,writeFileSync}from"node:fs";import{basename,join,resolve}from"node:path";import{pathToFileURL}from"node:url";import{setEnv}from"@stacksjs/env/cli";import{generateAppKey}from"@stacksjs/security/key";import{auditNativeEnvironment,defaultCraftRuntime,prepareNativeAppBuild,readNativeAppConfig,recordNativeArtifact}from"ts-pantry/native";export function isNativeProject(root){try{return JSON.parse(readFileSync(join(root,"package.json"),"utf8")).stacks?.type==="native"}catch{return!1}}export function scaffoldNativeProject(root,options){const manifest=join(root,"package.json");if(existsSync(root)&&readdirSync(root).some((name)=>name!==".git")&&!options.adopt)throw Error(`Path ${root} already exists. Use --adopt to integrate an existing native app.`);if(options.adopt&&(!existsSync(manifest)||!existsSync(join(root,"craft.config.ts"))))throw Error("--adopt requires package.json and craft.config.ts; no files were changed.");const pkg=existsSync(manifest)?JSON.parse(readFileSync(manifest,"utf8")):{name:basename(root),version:"0.1.0",description:"A Stacks native app"};if(pkg.stacks?.type&&pkg.stacks.type!=="native")throw Error("This project already declares a different Stacks application type.");const name=basename(root).replace(/(^|[-_ ])\w/g,(word)=>word.replace(/[-_ ]/g," ").toUpperCase());pkg.stacks={...pkg.stacks,type:"native"};pkg.devDependencies={"@stacksjs/buddy":`^${options.buddyVersion}`,...pkg.devDependencies};pkg.dependencies={"@stacksjs/stx":`^${options.stxVersion}`,"@stacksjs/desktop":`^${options.stxVersion}`,...pkg.dependencies};pkg.scripts={dev:"./buddy dev",build:"./buddy build",package:"./buddy package","release:patch":"./buddy release --bump patch","release:minor":"./buddy release --bump minor","release:major":"./buddy release --bump major",...pkg.scripts};mkdirSync(root,{recursive:!0});const writeMissing=(name,content)=>{const file=join(root,name);if(existsSync(file))return;mkdirSync(resolve(file,".."),{recursive:!0});writeFileSync(file,content)};writeMissing("buddy",`#!/bin/sh
|
|
2
2
|
set -eu
|
|
3
3
|
cd -- "$(dirname -- "$0")"
|
|
4
4
|
BUDDY_NATIVE_ENTRY=$(bun --print 'Bun.resolveSync("@stacksjs/buddy/cli", process.cwd())')
|
|
@@ -10,6 +10,7 @@ exec bun "$BUDDY_NATIVE_ENTRY" "$@"
|
|
|
10
10
|
bundleId: ${JSON.stringify(`com.example.${basename(root).toLowerCase().replace(/[^a-z0-9-]/g,"-")}`)},
|
|
11
11
|
window: { title: ${JSON.stringify(name)}, width: 640, height: 480 },
|
|
12
12
|
}
|
|
13
|
+
`);const pantryFile=join(root,"pantry.json"),pantry=existsSync(pantryFile)?JSON.parse(readFileSync(pantryFile,"utf8")):{};pantry.native={environment:"production",runtime:defaultCraftRuntime,...pantry.native,macos:{notarize:!0,...pantry.native?.macos}};writeFileSync(pantryFile,`${JSON.stringify(pantry,null,2)}
|
|
13
14
|
`);if(!options.adopt)writeMissing("src/app.stx",`<!doctype html>
|
|
14
15
|
<html lang="en">
|
|
15
16
|
<head><meta charset="utf-8"><title>${name.replace(/&/g,"&").replace(/</g,"<")}</title></head>
|
|
@@ -18,10 +19,18 @@ exec bun "$BUDDY_NATIVE_ENTRY" "$@"
|
|
|
18
19
|
`);writeMissing(".gitignore",`node_modules/
|
|
19
20
|
dist/
|
|
20
21
|
.stx/
|
|
22
|
+
.pantry/
|
|
23
|
+
`);const ignoreFile=join(root,".gitignore");let ignore=readFileSync(ignoreFile,"utf8");for(const pattern of[".env.keys",".env.local",".env.*.local"])if(!ignore.split(`
|
|
24
|
+
`).includes(pattern))ignore=`${ignore.trimEnd()}
|
|
25
|
+
${pattern}
|
|
26
|
+
`;writeFileSync(ignoreFile,ignore);if(!existsSync(join(root,".env.production")))for(const[key,value]of Object.entries({APP_ENV:"production",APP_KEY:generateAppKey()})){const result=setEnv(key,value,{cwd:root,file:".env.production"});if(!result.success)throw Error(result.error||"Could not create the native production environment")}auditNativeEnvironment(root,"production");if(!ignore.split(`
|
|
27
|
+
`).includes("!.env.production"))writeFileSync(ignoreFile,`${ignore.trimEnd()}
|
|
28
|
+
!.env.production
|
|
21
29
|
`);writeFileSync(manifest,`${JSON.stringify(pkg,null,2)}
|
|
22
|
-
`)}export async function buildNativeProject(root,args=[]){const pkg=await Bun.file(join(root,"package.json")).json(),loaded=await import(pathToFileURL(join(root,"craft.config.ts")).href),config=loaded.default??loaded.config;if(!config||typeof config!=="object")throw Error("craft.config.ts must export a native build configuration.");const{buildNative}=await import(pathToFileURL(Bun.resolveSync("@stacksjs/stx/craft",root)).href),output=resolve(root,config.output??"dist");if(output===root||!output.startsWith(`${root}/`))throw Error("Native output must be a directory inside the app.");const result=await buildNative({...config,input:resolve(root,config.input??"src/app.stx"),output,version:pkg.version,description:pkg.description,author:pkg.author,...config.icon?{icon:resolve(root,config.icon)}:{},...config.backend?{backend:{...config.backend,entry:resolve(root,config.backend.entry)}}:{},...args.includes("--dmg")?{format:"dmg"}:{},verbose:args.includes("--verbose")});if(!result.success||!result.outputPath)throw Error(result.error??"Native build produced no artifact.");return result.outputPath}export async function runNativeProjectCommand(root,args){const[command="help",...flags]=args;if(!["build","build:desktop","build:native","package","dev","dev:desktop","dev:native","upgrade","update"].includes(command))return!1;if(flags.includes("--help")||flags.includes("-h")){console.log(`buddy ${command} (native app)
|
|
30
|
+
`)}export async function buildNativeProject(root,args=[]){const pkg=await Bun.file(join(root,"package.json")).json(),loaded=await import(pathToFileURL(join(root,"craft.config.ts")).href),config=loaded.default??loaded.config;if(!config||typeof config!=="object")throw Error("craft.config.ts must export a native build configuration.");const{buildNative}=await import(pathToFileURL(Bun.resolveSync("@stacksjs/stx/craft",root)).href),prepared=await prepareNativeAppBuild(root,config);try{const output=resolve(root,prepared.overrides.output??config.output??"dist");if(output===root||!output.startsWith(`${root}/`))throw Error("Native output must be a directory inside the app.");const buildNumber=process.env.PANTRY_BUILD_NUMBER||config.infoPlist?.CFBundleVersion||pkg.version,result=await buildNative({...config,...prepared.overrides,input:resolve(root,config.input??"src/app.stx"),output,version:pkg.version,description:pkg.description,author:pkg.author,infoPlist:{...config.infoPlist,CFBundleVersion:buildNumber},...config.icon?{icon:resolve(root,config.icon)}:{},...config.backend?{backend:{...config.backend,entry:resolve(root,config.backend.entry)}}:{},...args.includes("--dmg")?{format:"dmg"}:{},verbose:args.includes("--verbose")});if(!result.success||!result.outputPath)throw Error(result.error??"Native build produced no artifact.");if(readNativeAppConfig(root))recordNativeArtifact(root,{path:result.outputPath,...result.target==="macos"?{appPath:join(output,`${config.name}.app`)}:{},name:config.name,bundleId:config.bundleId,version:pkg.version,buildNumber:String(buildNumber),target:result.target,minimumSystemVersion:config.minimumSystemVersion});return result.outputPath}finally{prepared.cleanup()}}export async function runNativeProjectCommand(root,args){const[command="help",...flags]=args;if(!["build","build:desktop","build:native","package","dev","dev:desktop","dev:native","upgrade","update","release"].includes(command))return!1;if(flags.includes("--help")||flags.includes("-h")){console.log(`buddy ${command} (native app)
|
|
23
31
|
|
|
24
32
|
Build: --dmg --verbose
|
|
25
33
|
Upgrade: --dry-run
|
|
34
|
+
Release: --bump patch|minor|major --dry-run
|
|
26
35
|
|
|
27
|
-
|
|
36
|
+
Application: craft.config.ts. Runtime and publishing: pantry.json. Development runtime override: CRAFT_BIN.`);return!0}if(command==="release"){const index=flags.indexOf("--bump"),bump=index>=0?flags[index+1]:"patch";if(!bump||!["patch","minor","major"].includes(bump)||flags.some((flag,position)=>flag!=="--dry-run"&&flag!=="--bump"&&!(index>=0&&position===index+1)))throw Error("Native releases support --bump patch|minor|major and --dry-run");const{releaseNativeApp}=await import("ts-pantry/native/release");await releaseNativeApp(root,{bump,dryRun:flags.includes("--dry-run")});return!0}if(command==="upgrade"||command==="update"){if(flags.some((flag)=>flag!=="--dry-run"&&flag!=="--verbose"))throw Error("Native upgrades support --dry-run and --verbose. Use bun add to select a specific package version.");if(flags.includes("--dry-run"))console.log("Would run bun update for the native app; no files changed.");else if(await Bun.spawn(["bun","update"],{cwd:root,stdin:"inherit",stdout:"inherit",stderr:"inherit"}).exited!==0)throw Error("Native dependency upgrade failed.");return!0}const artifact=await buildNativeProject(root,command==="package"?[...flags,"--dmg"]:flags);console.log(`Built ${artifact}`);if(command.startsWith("dev")){const config=(await import(pathToFileURL(join(root,"craft.config.ts")).href)).default;if(process.platform!=="darwin")throw Error("Native development launch currently requires macOS.");const executable=join(artifact,"Contents","MacOS",config.name),child=Bun.spawn([executable],{cwd:root,stdin:"inherit",stdout:"inherit",stderr:"inherit"});let interrupted=!1;const stop=()=>{interrupted=!0;child.kill("SIGTERM")};process.once("SIGINT",stop);process.once("SIGTERM",stop);try{const code=await child.exited;if(code!==0&&!interrupted)throw Error(`Native app exited with ${child.signalCode??`code ${code}`}.`)}finally{process.removeListener("SIGINT",stop);process.removeListener("SIGTERM",stop)}}return!0}
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@stacksjs/buddy",
|
|
3
3
|
"type": "module",
|
|
4
4
|
"sideEffects": false,
|
|
5
|
-
"version": "0.75.
|
|
5
|
+
"version": "0.75.315",
|
|
6
6
|
"description": "Meet Buddy. The Stacks runtime.",
|
|
7
7
|
"author": "Chris Breuer",
|
|
8
8
|
"contributors": [
|
|
@@ -95,73 +95,73 @@
|
|
|
95
95
|
"prepublishOnly": "bun run build"
|
|
96
96
|
},
|
|
97
97
|
"dependencies": {
|
|
98
|
-
"@stacksjs/actions": "0.75.
|
|
99
|
-
"@stacksjs/ai": "0.75.
|
|
100
|
-
"@stacksjs/alias": "0.75.
|
|
101
|
-
"@stacksjs/analytics": "0.75.
|
|
102
|
-
"@stacksjs/api": "0.75.
|
|
103
|
-
"@stacksjs/arrays": "0.75.
|
|
104
|
-
"@stacksjs/auth": "0.75.
|
|
105
|
-
"@stacksjs/browser-extension": "0.75.
|
|
106
|
-
"@stacksjs/build": "0.75.
|
|
98
|
+
"@stacksjs/actions": "0.75.315",
|
|
99
|
+
"@stacksjs/ai": "0.75.315",
|
|
100
|
+
"@stacksjs/alias": "0.75.315",
|
|
101
|
+
"@stacksjs/analytics": "0.75.315",
|
|
102
|
+
"@stacksjs/api": "0.75.315",
|
|
103
|
+
"@stacksjs/arrays": "0.75.315",
|
|
104
|
+
"@stacksjs/auth": "0.75.315",
|
|
105
|
+
"@stacksjs/browser-extension": "0.75.315",
|
|
106
|
+
"@stacksjs/build": "0.75.315",
|
|
107
107
|
"@stacksjs/bumpx": "^0.2.26",
|
|
108
|
-
"@stacksjs/cache": "0.75.
|
|
109
|
-
"@stacksjs/chat": "0.75.
|
|
108
|
+
"@stacksjs/cache": "0.75.315",
|
|
109
|
+
"@stacksjs/chat": "0.75.315",
|
|
110
110
|
"@stacksjs/clapp": "^0.2.16",
|
|
111
|
-
"@stacksjs/cli": "0.75.
|
|
112
|
-
"@stacksjs/cloud": "0.75.
|
|
113
|
-
"@stacksjs/cms": "0.75.
|
|
114
|
-
"@stacksjs/collections": "0.75.
|
|
115
|
-
"@stacksjs/commerce": "0.75.
|
|
116
|
-
"@stacksjs/config": "0.75.
|
|
117
|
-
"@stacksjs/database": "0.75.
|
|
118
|
-
"@stacksjs/desktop-build": "0.75.
|
|
119
|
-
"@stacksjs/dns": "0.75.
|
|
111
|
+
"@stacksjs/cli": "0.75.315",
|
|
112
|
+
"@stacksjs/cloud": "0.75.315",
|
|
113
|
+
"@stacksjs/cms": "0.75.315",
|
|
114
|
+
"@stacksjs/collections": "0.75.315",
|
|
115
|
+
"@stacksjs/commerce": "0.75.315",
|
|
116
|
+
"@stacksjs/config": "0.75.315",
|
|
117
|
+
"@stacksjs/database": "0.75.315",
|
|
118
|
+
"@stacksjs/desktop-build": "0.75.315",
|
|
119
|
+
"@stacksjs/dns": "0.75.315",
|
|
120
120
|
"@stacksjs/dnsx": "^0.2.3",
|
|
121
|
-
"@stacksjs/email": "0.75.
|
|
122
|
-
"@stacksjs/enums": "0.75.
|
|
123
|
-
"@stacksjs/env": "0.75.
|
|
124
|
-
"@stacksjs/error-handling": "0.75.
|
|
125
|
-
"@stacksjs/events": "0.75.
|
|
126
|
-
"@stacksjs/features": "0.75.
|
|
127
|
-
"@stacksjs/git": "0.75.
|
|
121
|
+
"@stacksjs/email": "0.75.315",
|
|
122
|
+
"@stacksjs/enums": "0.75.315",
|
|
123
|
+
"@stacksjs/env": "0.75.315",
|
|
124
|
+
"@stacksjs/error-handling": "0.75.315",
|
|
125
|
+
"@stacksjs/events": "0.75.315",
|
|
126
|
+
"@stacksjs/features": "0.75.315",
|
|
127
|
+
"@stacksjs/git": "0.75.315",
|
|
128
128
|
"@stacksjs/gitit": "^0.2.5",
|
|
129
|
-
"@stacksjs/health": "0.75.
|
|
129
|
+
"@stacksjs/health": "0.75.315",
|
|
130
130
|
"@stacksjs/httx": "^0.1.10",
|
|
131
|
-
"@stacksjs/image": "0.75.
|
|
132
|
-
"@stacksjs/lint": "0.75.
|
|
133
|
-
"@stacksjs/logging": "0.75.
|
|
134
|
-
"@stacksjs/notifications": "0.75.
|
|
135
|
-
"@stacksjs/objects": "0.75.
|
|
136
|
-
"@stacksjs/orm": "0.75.
|
|
137
|
-
"@stacksjs/path": "0.75.
|
|
138
|
-
"@stacksjs/payments": "0.75.
|
|
139
|
-
"@stacksjs/realtime": "0.75.
|
|
140
|
-
"@stacksjs/router": "0.75.
|
|
131
|
+
"@stacksjs/image": "0.75.315",
|
|
132
|
+
"@stacksjs/lint": "0.75.315",
|
|
133
|
+
"@stacksjs/logging": "0.75.315",
|
|
134
|
+
"@stacksjs/notifications": "0.75.315",
|
|
135
|
+
"@stacksjs/objects": "0.75.315",
|
|
136
|
+
"@stacksjs/orm": "0.75.315",
|
|
137
|
+
"@stacksjs/path": "0.75.315",
|
|
138
|
+
"@stacksjs/payments": "0.75.315",
|
|
139
|
+
"@stacksjs/realtime": "0.75.315",
|
|
140
|
+
"@stacksjs/router": "0.75.315",
|
|
141
|
+
"@stacksjs/security": "0.75.315",
|
|
141
142
|
"@stacksjs/rpx": "^0.11.54",
|
|
142
|
-
"@stacksjs/scheduler": "0.75.
|
|
143
|
-
"@stacksjs/search-engine": "0.75.
|
|
144
|
-
"@stacksjs/
|
|
145
|
-
"@stacksjs/
|
|
146
|
-
"@stacksjs/
|
|
147
|
-
"@stacksjs/
|
|
148
|
-
"@stacksjs/
|
|
149
|
-
"@stacksjs/
|
|
150
|
-
"@stacksjs/strings": "0.75.310",
|
|
143
|
+
"@stacksjs/scheduler": "0.75.315",
|
|
144
|
+
"@stacksjs/search-engine": "0.75.315",
|
|
145
|
+
"@stacksjs/server": "0.75.315",
|
|
146
|
+
"@stacksjs/sites": "0.75.315",
|
|
147
|
+
"@stacksjs/skills": "0.75.315",
|
|
148
|
+
"@stacksjs/socials": "0.75.315",
|
|
149
|
+
"@stacksjs/storage": "0.75.315",
|
|
150
|
+
"@stacksjs/strings": "0.75.315",
|
|
151
151
|
"@stacksjs/stx": "0.2.691",
|
|
152
|
-
"@stacksjs/testing": "0.75.
|
|
153
|
-
"@stacksjs/tinker": "0.75.
|
|
152
|
+
"@stacksjs/testing": "0.75.315",
|
|
153
|
+
"@stacksjs/tinker": "0.75.315",
|
|
154
154
|
"@stacksjs/tlsx": "^0.13.19",
|
|
155
155
|
"@stacksjs/ts-cloud": "^0.16.69",
|
|
156
|
-
"@stacksjs/tunnel": "0.75.
|
|
157
|
-
"@stacksjs/types": "0.75.
|
|
158
|
-
"@stacksjs/ui": "0.75.
|
|
159
|
-
"@stacksjs/utils": "0.75.
|
|
160
|
-
"@stacksjs/validation": "0.75.
|
|
156
|
+
"@stacksjs/tunnel": "0.75.315",
|
|
157
|
+
"@stacksjs/types": "0.75.315",
|
|
158
|
+
"@stacksjs/ui": "0.75.315",
|
|
159
|
+
"@stacksjs/utils": "0.75.315",
|
|
160
|
+
"@stacksjs/validation": "0.75.315",
|
|
161
161
|
"ajv": "^8.20.0",
|
|
162
162
|
"ajv-formats": "^3.0.1",
|
|
163
163
|
"bun-plugin-stx": "0.2.691",
|
|
164
|
-
"ts-pantry": "^0.11.
|
|
164
|
+
"ts-pantry": "^0.11.130"
|
|
165
165
|
},
|
|
166
166
|
"devDependencies": {
|
|
167
167
|
"better-dx": "^0.2.24"
|