@stacksjs/buddy 0.75.242 → 0.75.243
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/commands/features.js +1 -1
- package/package.json +55 -55
|
@@ -127,4 +127,4 @@ export default {
|
|
|
127
127
|
},
|
|
128
128
|
} satisfies QueueConfig
|
|
129
129
|
`};function withoutComments(src){return src.replace(/\/\*[\s\S]*?\*\//g,(m)=>" ".repeat(m.length)).replace(/\/\/[^\n]*/g,(m)=>" ".repeat(m.length))}function findTopLevelEnabled(src){const scan=withoutComments(src),start=scan.search(/export default\s*\{/);if(start===-1)return null;const open=scan.indexOf("{",start);let depth=0;for(let i=open;i<scan.length;i++){const char=scan[i];if(char==="{"){depth++;continue}if(char==="}"){depth--;if(depth===0)return null;continue}if(depth!==1||char!=="e")continue;const match=/^enabled\s*:\s*(true|false)/.exec(scan.slice(i));if(!match)continue;if(i>0&&/[\w$]/.test(scan[i-1]))continue;return{index:i,length:match[0].length,value:match[1]==="true"}}return null}export function readFeatureFlag(feature,root=projectPath()){const path=join(root,`config/${feature}.ts`);if(!existsSync(path))return"absent";const found=findTopLevelEnabled(readFileSync(path,"utf8"));if(!found)return"unset";return found.value}export function featureMigrationCounts(feature,root=projectPath()){const counts={active:0,hidden:0},base=join(root,"database/migrations");if(!existsSync(base))return counts;const dirs=[base];for(const entry of readdirSync(base,{withFileTypes:!0}))if(entry.isDirectory())dirs.push(join(base,entry.name));for(const dir of dirs)for(const file of readdirSync(dir)){const hidden=file.endsWith(".sql.disabled");if(!hidden&&!file.endsWith(".sql"))continue;const sqlName=hidden?file.slice(0,-9):file;if(migrationFeature(sqlName)!==feature)continue;if(hidden)counts.hidden++;else counts.active++}return counts}export async function setFeatureEnabled(feature,enabled,options){const write=async(target,contents)=>{if(options.dryRun!==!0)await Bun.write(target,contents)},path=options.root?join(options.root,`config/${feature}.ts`):projectPath(`config/${feature}.ts`),file=Bun.file(path);if(!await file.exists()){if(!options.createIfMissing)return"missing";await write(path,STARTER_TEMPLATES[feature]);return"created"}const src=await file.text(),found=findTopLevelEnabled(src);if(found){if(found.value===enabled)return"unchanged";const replaced=src.slice(0,found.index)+`enabled: ${enabled}`+src.slice(found.index+found.length);await write(path,replaced);return"flipped"}const insertRegex=/(export default\s*\{)/;if(!insertRegex.test(src))throw Error(`Could not locate \`export default {\` in ${path} - please add \`enabled: ${enabled}\` manually.`);const next=src.replace(insertRegex,`$1
|
|
130
|
-
enabled: ${enabled},`);await write(path,next);return"flipped"}export async function uninstallAllFeatures(options={}){const root=options.root??projectPath(),results=[];for(const feature of FEATURE_NAMES){const configOutcome=await setFeatureEnabled(feature,!1,{createIfMissing:!1,root}),{removed:filesRemoved}=await deleteFeatureFiles(feature,root,{force:!0});results.push({feature,configOutcome,filesRemoved})}return results}function isDryRun(options){return options.dryRun===!0||process.argv.includes("--dry-run")}async function offerMigrate(feature){const{active,hidden}=featureMigrationCounts(feature),total=active+hidden;if(total===0)return;console.log(` \u2192 ${feature} owns ${total} ${total===1?"migration":"migrations"}; its tables do not exist until they run.`);const answer=await confirmOrNull({message:"Run ./buddy migrate now?",initial:!1});if(answer!==!0){console.log(answer===null?" \u2192 Not asking (non-interactive). Run ./buddy migrate when ready.":" \u2192 Skipped. Run ./buddy migrate when ready.");return}const result=await runCommand("./buddy migrate",{cwd:projectPath()});if(resultFailed(result)){console.error(`\u2717 ./buddy migrate failed: ${resultError(result)}`);console.error(` \u2192 ${feature} is installed; re-run ./buddy migrate once that is resolved.`);return}console.log("\u2713 Migrated.")}function registerInstallPair(buddy,feature){const desc=FEATURE_DESCRIPTIONS[feature],configRel=`config/${feature}.ts`;buddy.command(`${feature}:install`,`Activate the ${feature} feature bundle. ${desc}`).option("--
|
|
130
|
+
enabled: ${enabled},`);await write(path,next);return"flipped"}export async function uninstallAllFeatures(options={}){const root=options.root??projectPath(),results=[];for(const feature of FEATURE_NAMES){const configOutcome=await setFeatureEnabled(feature,!1,{createIfMissing:!1,root}),{removed:filesRemoved}=await deleteFeatureFiles(feature,root,{force:!0});results.push({feature,configOutcome,filesRemoved})}return results}function isDryRun(options){return options.dryRun===!0||process.argv.includes("--dry-run")}async function offerMigrate(feature){const{active,hidden}=featureMigrationCounts(feature),total=active+hidden;if(total===0)return;console.log(` \u2192 ${feature} owns ${total} ${total===1?"migration":"migrations"}; its tables do not exist until they run.`);const answer=await confirmOrNull({message:"Run ./buddy migrate now?",initial:!1});if(answer!==!0){console.log(answer===null?" \u2192 Not asking (non-interactive). Run ./buddy migrate when ready.":" \u2192 Skipped. Run ./buddy migrate when ready.");return}const result=await runCommand("./buddy migrate",{cwd:projectPath()});if(resultFailed(result)){console.error(`\u2717 ./buddy migrate failed: ${resultError(result)}`);console.error(` \u2192 ${feature} is installed; re-run ./buddy migrate once that is resolved.`);return}console.log("\u2713 Migrated.")}function registerInstallPair(buddy,feature){const desc=FEATURE_DESCRIPTIONS[feature],configRel=`config/${feature}.ts`;buddy.command(`${feature}:install`,`Activate the ${feature} feature bundle. ${desc}`).option("--publish-all",`Also copy every ${feature} file into the project so you can edit it in place. Not needed to run the feature - see \`publish:action\`/\`publish:model\` to take ownership of one file at a time.`).option("--force",`With --publish-all, overwrite existing ${feature} files (default skips existing paths so the copy is idempotent).`).option("--dry-run",`Say what ${feature}:install would change, and change nothing.`,{default:!1}).action(async(options)=>{try{const dryRun=isDryRun(options),mark=dryRun?"\xB7":"\u2713";switch(await setFeatureEnabled(feature,!0,{createIfMissing:!0,dryRun})){case"created":console.log(dryRun?`${mark} Would create ${configRel} with '${feature}' enabled.`:`${mark} Created ${configRel} with '${feature}' enabled.`);break;case"flipped":console.log(dryRun?`${mark} Would enable '${feature}' in ${configRel}.`:`${mark} Enabled '${feature}' in ${configRel}.`);break;case"unchanged":console.log(`${mark} '${feature}' is already enabled in ${configRel}.`);break}if(options.publishAll===!0){const{copied}=await copyFeatureFiles(feature,{force:options.force===!0,dryRun});if(copied.length>0){console.log(dryRun?`${mark} Would copy ${copied.length} stamped path(s) from framework defaults:`:`${mark} Copied ${copied.length} stamped path(s) from framework defaults:`);for(const path of copied)console.log(` - ${path}`);console.log(" \u2192 These now shadow storage/framework/defaults/; `buddy upgrade` will not update them.")}else if(featurePathsPresent(feature).length>0)console.log(` \u2192 ${feature} files already in the project - use --force to overwrite.`)}else{const present=featurePathsPresent(feature).length;if(present>0)console.log(` \u2192 ${present} ${feature} path(s) already in the project; those shadow the framework defaults.`);else console.log(" \u2192 Runs from the framework defaults. `publish:action`/`publish:model` copies one file into app/ when you want to change it.")}if(dryRun){console.log(` \u2192 Dry run: nothing was written. Run it without --dry-run to install ${feature}.`);process.exit(ExitCode.Success)}await offerMigrate(feature);console.log(` \u2192 next ./buddy dev will boot with ${feature} loaded.`);process.exit(ExitCode.Success)}catch(err){console.error(`\u2717 Failed to install ${feature}:`,err);process.exit(ExitCode.FatalError)}});buddy.command(`${feature}:uninstall`,`Deactivate the ${feature} feature bundle.`).option("--keep-files",`Don't delete the ${feature} scaffolding (action/model/view files). Flip the flag only.`).option("--force",`Delete the ${feature} scaffolding even where you have edited it. Without this, changed files are kept.`).option("--dry-run",`Say what ${feature}:uninstall would change, and change nothing.`,{default:!1}).action(async(options)=>{try{const dryRun=isDryRun(options),mark=dryRun?"\xB7":"\u2713";switch(await setFeatureEnabled(feature,!1,{createIfMissing:!1,dryRun})){case"missing":console.log(`${mark} '${feature}' is already disabled (${configRel} is absent).`);break;case"flipped":console.log(dryRun?`${mark} Would disable '${feature}' in ${configRel}.`:`${mark} Disabled '${feature}' in ${configRel}. Custom config preserved.`);break;case"unchanged":console.log(`${mark} '${feature}' is already disabled in ${configRel}.`);break;case"created":console.log(`\u2717 Unexpected create on uninstall for ${feature}; please re-run with --force or report this bug.`);break}if(options.keepFiles){const stillPresent=featurePathsPresent(feature);if(stillPresent.length>0)console.log(` \u2192 ${stillPresent.length} stamped path(s) preserved (--keep-files).`)}else{const{removed,preserved}=await deleteFeatureFiles(feature,projectPath(),{force:options.force,dryRun});if(removed.length>0){console.log(dryRun?`${mark} Would remove ${removed.length} stamped path(s):`:`${mark} Removed ${removed.length} stamped path(s):`);for(const path of removed)console.log(` - ${path}`)}if(preserved.length>0){console.log(dryRun?` \u2192 Would keep ${preserved.length} path(s) you have edited (--force would remove them):`:` \u2192 Kept ${preserved.length} path(s) you have edited (re-run with --force to remove):`);for(const path of preserved)console.log(` - ${path}`)}}console.log(dryRun?` \u2192 Dry run: nothing was written or removed. Run it without --dry-run to uninstall ${feature}.`:` \u2192 next ./buddy dev will boot without ${feature}.`);process.exit(ExitCode.Success)}catch(err){console.error(`\u2717 Failed to uninstall ${feature}:`,err);process.exit(ExitCode.FatalError)}})}function registerStatus(buddy){buddy.command("features","Show which framework feature bundles are active.").action(async()=>{try{const{feature,overridesReady}=await import("@stacksjs/config");await overridesReady;const rows=FEATURE_NAMES.map((name)=>{const declared=readFeatureFlag(name),active=feature(name),migrations=featureMigrationCounts(name);return{name,declared,active,migrations,scaffolded:featurePathsPresent(name).length}}),enabled=rows.filter((r)=>r.active).length;console.log("");console.log(`Feature bundles (${enabled} of ${rows.length} active)`);console.log("");for(const row of rows){const mark=row.active?"\u2713":"\xB7",declared=row.declared==="absent"?"no config":row.declared==="unset"?"flag unset":`enabled: ${row.declared}`,parts=[`${mark} ${row.name.padEnd(11)}`,declared.padEnd(14)],total=row.migrations.active+row.migrations.hidden,plural=total===1?"migration":"migrations";if(total>0)parts.push(row.migrations.hidden>0?`${total} ${plural} (${row.migrations.hidden} hidden)`:`${total} ${plural}`);else parts.push("");console.log(` ${parts.join(" ")}`);if(row.declared===!0&&!row.active)console.log(` declared on but reading off - check \`env\` in config/${row.name}.ts against config.app.env`);if(row.declared===!1&&row.active)console.log(" declared off but reading on - a runtime override is in play");if(!row.active&&row.scaffolded>0)console.log(` ${row.scaffolded} scaffolded path(s) still present - \`./buddy ${row.name}:uninstall\` removes them`);if(row.active&&row.migrations.hidden>0)console.log(` ${row.migrations.hidden} migration(s) still hidden from a previous run - \`./buddy migrate\` restores them`)}console.log("");console.log(" ./buddy <feature>:install activates one, <feature>:uninstall turns it off.");console.log("");console.log("Config gates (switched by `enabled` in their config file)");console.log("");for(const[name,description]of Object.entries(CONFIG_GATES)){const declared=readFeatureFlag(name),label=declared==="absent"?"no config":declared==="unset"?"flag unset":`enabled: ${declared}`;console.log(` ${feature(name)?"\u2713":"\xB7"} ${name.padEnd(11)} ${label.padEnd(14)} ${description}`)}console.log("");process.exit(ExitCode.Success)}catch(err){console.error("\u2717 Failed to read feature status:",err);process.exit(ExitCode.FatalError)}})}export function features(buddy){registerStatus(buddy);for(const feature of FEATURE_NAMES)registerInstallPair(buddy,feature)}
|
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.243",
|
|
6
6
|
"description": "Meet Buddy. The Stacks runtime.",
|
|
7
7
|
"author": "Chris Breuer",
|
|
8
8
|
"contributors": [
|
|
@@ -96,68 +96,68 @@
|
|
|
96
96
|
},
|
|
97
97
|
"dependencies": {
|
|
98
98
|
"@stacksjs/bumpx": "^0.2.25",
|
|
99
|
-
"@stacksjs/actions": "0.75.
|
|
100
|
-
"@stacksjs/ai": "0.75.
|
|
101
|
-
"@stacksjs/alias": "0.75.
|
|
102
|
-
"@stacksjs/analytics": "0.75.
|
|
103
|
-
"@stacksjs/api": "0.75.
|
|
104
|
-
"@stacksjs/arrays": "0.75.
|
|
105
|
-
"@stacksjs/auth": "0.75.
|
|
106
|
-
"@stacksjs/browser-extension": "0.75.
|
|
107
|
-
"@stacksjs/build": "0.75.
|
|
108
|
-
"@stacksjs/cache": "0.75.
|
|
109
|
-
"@stacksjs/chat": "0.75.
|
|
99
|
+
"@stacksjs/actions": "0.75.243",
|
|
100
|
+
"@stacksjs/ai": "0.75.243",
|
|
101
|
+
"@stacksjs/alias": "0.75.243",
|
|
102
|
+
"@stacksjs/analytics": "0.75.243",
|
|
103
|
+
"@stacksjs/api": "0.75.243",
|
|
104
|
+
"@stacksjs/arrays": "0.75.243",
|
|
105
|
+
"@stacksjs/auth": "0.75.243",
|
|
106
|
+
"@stacksjs/browser-extension": "0.75.243",
|
|
107
|
+
"@stacksjs/build": "0.75.243",
|
|
108
|
+
"@stacksjs/cache": "0.75.243",
|
|
109
|
+
"@stacksjs/chat": "0.75.243",
|
|
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.243",
|
|
112
|
+
"@stacksjs/cloud": "0.75.243",
|
|
113
|
+
"@stacksjs/cms": "0.75.243",
|
|
114
|
+
"@stacksjs/collections": "0.75.243",
|
|
115
|
+
"@stacksjs/commerce": "0.75.243",
|
|
116
|
+
"@stacksjs/config": "0.75.243",
|
|
117
|
+
"@stacksjs/database": "0.75.243",
|
|
118
|
+
"@stacksjs/desktop-build": "0.75.243",
|
|
119
|
+
"@stacksjs/dns": "0.75.243",
|
|
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.243",
|
|
122
|
+
"@stacksjs/enums": "0.75.243",
|
|
123
|
+
"@stacksjs/env": "0.75.243",
|
|
124
|
+
"@stacksjs/error-handling": "0.75.243",
|
|
125
|
+
"@stacksjs/events": "0.75.243",
|
|
126
|
+
"@stacksjs/features": "0.75.243",
|
|
127
|
+
"@stacksjs/git": "0.75.243",
|
|
128
128
|
"@stacksjs/gitit": "^0.2.5",
|
|
129
|
-
"@stacksjs/health": "0.75.
|
|
129
|
+
"@stacksjs/health": "0.75.243",
|
|
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.243",
|
|
132
|
+
"@stacksjs/lint": "0.75.243",
|
|
133
|
+
"@stacksjs/logging": "0.75.243",
|
|
134
|
+
"@stacksjs/notifications": "0.75.243",
|
|
135
|
+
"@stacksjs/objects": "0.75.243",
|
|
136
|
+
"@stacksjs/orm": "0.75.243",
|
|
137
|
+
"@stacksjs/path": "0.75.243",
|
|
138
|
+
"@stacksjs/payments": "0.75.243",
|
|
139
|
+
"@stacksjs/realtime": "0.75.243",
|
|
140
|
+
"@stacksjs/router": "0.75.243",
|
|
141
141
|
"@stacksjs/rpx": "^0.11.54",
|
|
142
|
-
"@stacksjs/scheduler": "0.75.
|
|
143
|
-
"@stacksjs/search-engine": "0.75.
|
|
144
|
-
"@stacksjs/security": "0.75.
|
|
145
|
-
"@stacksjs/server": "0.75.
|
|
146
|
-
"@stacksjs/sites": "0.75.
|
|
147
|
-
"@stacksjs/skills": "0.75.
|
|
148
|
-
"@stacksjs/socials": "0.75.
|
|
149
|
-
"@stacksjs/storage": "0.75.
|
|
150
|
-
"@stacksjs/strings": "0.75.
|
|
142
|
+
"@stacksjs/scheduler": "0.75.243",
|
|
143
|
+
"@stacksjs/search-engine": "0.75.243",
|
|
144
|
+
"@stacksjs/security": "0.75.243",
|
|
145
|
+
"@stacksjs/server": "0.75.243",
|
|
146
|
+
"@stacksjs/sites": "0.75.243",
|
|
147
|
+
"@stacksjs/skills": "0.75.243",
|
|
148
|
+
"@stacksjs/socials": "0.75.243",
|
|
149
|
+
"@stacksjs/storage": "0.75.243",
|
|
150
|
+
"@stacksjs/strings": "0.75.243",
|
|
151
151
|
"@stacksjs/stx": "^0.2.604",
|
|
152
|
-
"@stacksjs/testing": "0.75.
|
|
153
|
-
"@stacksjs/tinker": "0.75.
|
|
152
|
+
"@stacksjs/testing": "0.75.243",
|
|
153
|
+
"@stacksjs/tinker": "0.75.243",
|
|
154
154
|
"@stacksjs/tlsx": "^0.13.19",
|
|
155
155
|
"@stacksjs/ts-cloud": "^0.16.58",
|
|
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.243",
|
|
157
|
+
"@stacksjs/types": "0.75.243",
|
|
158
|
+
"@stacksjs/ui": "0.75.243",
|
|
159
|
+
"@stacksjs/utils": "0.75.243",
|
|
160
|
+
"@stacksjs/validation": "0.75.243",
|
|
161
161
|
"ajv": "^8.20.0",
|
|
162
162
|
"ajv-formats": "^3.0.1",
|
|
163
163
|
"bun-plugin-stx": "^0.2.604",
|