fix: persist spark bootstrap settings

This commit is contained in:
2026-05-08 16:24:45 +00:00
parent 82dd073e50
commit 24fc803b09
8 changed files with 974 additions and 1390 deletions
+22 -22
View File
@@ -34,30 +34,30 @@
"strict": true
},
"imports": {
"@std/path": "jsr:@std/path@^1.0.0",
"@std/fmt": "jsr:@std/fmt@^1.0.0",
"@std/assert": "jsr:@std/assert@^1.0.0",
"@serve.zone/interfaces": "npm:@serve.zone/interfaces@^5.4.3",
"@serve.zone/api": "npm:@serve.zone/api@^5.3.1",
"@apiclient.xyz/docker": "npm:@apiclient.xyz/docker@^5.1.0",
"@std/path": "jsr:@std/path@^1.1.4",
"@std/fmt": "jsr:@std/fmt@^1.0.10",
"@std/assert": "jsr:@std/assert@^1.0.19",
"@serve.zone/interfaces": "npm:@serve.zone/interfaces@^5.5.0",
"@serve.zone/api": "npm:@serve.zone/api@^5.3.4",
"@apiclient.xyz/docker": "npm:@apiclient.xyz/docker@^5.1.4",
"@push.rocks/npmextra": "npm:@push.rocks/npmextra@^5.3.3",
"@push.rocks/projectinfo": "npm:@push.rocks/projectinfo@^5.0.2",
"@push.rocks/qenv": "npm:@push.rocks/qenv@^6.1.3",
"@push.rocks/smartcli": "npm:@push.rocks/smartcli@^4.0.20",
"@push.rocks/smartdaemon": "npm:@push.rocks/smartdaemon@^2.1.0",
"@push.rocks/smartdelay": "npm:@push.rocks/smartdelay@^3.0.5",
"@push.rocks/smartfile": "npm:@push.rocks/smartfile@^11.0.23",
"@push.rocks/smartjson": "npm:@push.rocks/smartjson@^5.0.20",
"@push.rocks/smartlog": "npm:@push.rocks/smartlog@^3.1.10",
"@push.rocks/projectinfo": "npm:@push.rocks/projectinfo@^5.1.0",
"@push.rocks/qenv": "npm:@push.rocks/qenv@^6.1.4",
"@push.rocks/smartcli": "npm:@push.rocks/smartcli@^4.0.21",
"@push.rocks/smartdaemon": "npm:@push.rocks/smartdaemon@^2.1.1",
"@push.rocks/smartdelay": "npm:@push.rocks/smartdelay@^3.1.0",
"@push.rocks/smartfile": "npm:@push.rocks/smartfile@^13.1.3",
"@push.rocks/smartjson": "npm:@push.rocks/smartjson@^6.0.1",
"@push.rocks/smartlog": "npm:@push.rocks/smartlog@^3.2.2",
"@push.rocks/smartlog-destination-local": "npm:@push.rocks/smartlog-destination-local@^9.0.2",
"@push.rocks/smartpath": "npm:@push.rocks/smartpath@^5.0.5",
"@push.rocks/smartshell": "npm:@push.rocks/smartshell@^3.3.0",
"@push.rocks/smartupdate": "npm:@push.rocks/smartupdate@^2.0.6",
"@push.rocks/taskbuffer": "npm:@push.rocks/taskbuffer@^3.0.10",
"@push.rocks/smartexpect": "npm:@push.rocks/smartexpect@^1.0.15",
"@push.rocks/smartpath": "npm:@push.rocks/smartpath@^6.0.0",
"@push.rocks/smartshell": "npm:@push.rocks/smartshell@^3.3.8",
"@push.rocks/smartupdate": "npm:@push.rocks/smartupdate@^2.0.7",
"@push.rocks/taskbuffer": "npm:@push.rocks/taskbuffer@^8.0.2",
"@push.rocks/smartexpect": "npm:@push.rocks/smartexpect@^2.5.0",
"@push.rocks/smartrx": "npm:@push.rocks/smartrx@^3.0.10",
"@push.rocks/smartpromise": "npm:@push.rocks/smartpromise@^4.2.3",
"@push.rocks/smartstring": "npm:@push.rocks/smartstring@^4.1.0",
"@push.rocks/smarttime": "npm:@push.rocks/smarttime@^4.1.1"
"@push.rocks/smartpromise": "npm:@push.rocks/smartpromise@^4.2.4",
"@push.rocks/smartstring": "npm:@push.rocks/smartstring@^4.1.1",
"@push.rocks/smarttime": "npm:@push.rocks/smarttime@^4.2.3"
}
}
Generated
+889 -1362
View File
File diff suppressed because it is too large Load Diff
+9
View File
@@ -0,0 +1,9 @@
lockfileVersion: '9.0'
settings:
autoInstallPeers: true
excludeLinksFromLockfile: false
importers:
.: {}
+5 -1
View File
@@ -40,6 +40,10 @@ function getBinaryInfo() {
const mappedPlatform = platformMap[plat];
const mappedArch = archMap[architecture];
if (plat === 'win32' && architecture === 'arm64') {
return { supported: false, platform: plat, arch: architecture };
}
if (!mappedPlatform || !mappedArch) {
return { supported: false, platform: plat, arch: architecture };
}
@@ -228,4 +232,4 @@ async function main() {
main().catch(err => {
console.error(`❌ Installation failed: ${err.message}`);
process.exit(1);
});
});
+3 -1
View File
@@ -2,9 +2,11 @@ import * as plugins from './spark.plugins.ts';
import * as paths from './spark.paths.ts';
import { Spark } from './spark.classes.spark.ts';
const projectInfo = await plugins.projectinfo.ProjectinfoNpm.create(paths.packageDir);
export class SparkInfo {
public sparkRef: Spark;
public projectInfo = new plugins.projectinfo.ProjectinfoNpm(paths.packageDir);
public projectInfo = projectInfo;
constructor(sparkRefArg: Spark) {
this.sparkRef = sparkRefArg;
+3 -1
View File
@@ -21,7 +21,9 @@ export class SparkTaskManager {
name: 'updateSpark',
taskFunction: async () => {
const smartupdateInstance = new plugins.smartupdate.SmartUpdate({
npmRegistryUrl: 'https://registry.npmjs.org',
npmRegistryOptions: {
npmRegistryUrl: 'https://registry.npmjs.org',
},
});
const shouldUpdate = await smartupdateInstance.check(
this.sparkRef.sparkInfo.projectInfo.name,
+43
View File
@@ -17,6 +17,7 @@ export const runCli = async () => {
smartcliInstance.addCommand('installdaemon').subscribe(async (argvArg) => {
logger.log('ok', 'we are apparently not running as daemon yet');
logger.log('info', 'trying to set this up now');
await persistDaemonOptions(sparkInstance, argvArg);
const sparkService = await sparkInstance.smartdaemon.addService({
name: 'spark',
version: sparkInstance.sparkInfo.projectInfo.version,
@@ -32,6 +33,7 @@ export const runCli = async () => {
smartcliInstance.addCommand('updatedaemon').subscribe(async (argvArg) => {
logger.log('ok', 'we are apparently trying to update the daemon for spark');
logger.log('info', 'trying to set this up now');
await persistDaemonOptions(sparkInstance, argvArg);
const sparkService = await sparkInstance.smartdaemon.addService({
name: 'spark',
version: sparkInstance.sparkInfo.projectInfo.version,
@@ -46,6 +48,8 @@ export const runCli = async () => {
logger.log('success', 'looks like we are running as daemon now');
logger.log('info', 'starting spark in daemon mode');
await persistDaemonOptions(sparkInstance, argvArg);
// lets determine the mode if specified
let mode = argvArg.mode;
if (mode === 'cloudly') {
@@ -76,6 +80,12 @@ export const runCli = async () => {
},
});
} else if (mode === 'coreflow-node') {
const cloudlyUrl = await readOption(sparkInstance, argvArg, 'cloudlyUrl', 'cloudly-url', 'CLOUDLY_URL');
const jumpcode = await readOption(sparkInstance, argvArg, 'jumpcode', 'jumpCode', 'JUMPCODE');
if (!cloudlyUrl || !jumpcode) {
logger.log('error', 'coreflow-node mode requires CLOUDLY_URL/cloudlyUrl and JUMPCODE/jumpcode');
Deno.exit(1);
}
sparkInstance.sparkUpdateManager.services.push({
name: `coreflow`,
image: `code.foss.global/serve.zone/coreflow`,
@@ -85,6 +95,8 @@ export const runCli = async () => {
secretJson: {
SERVEZONE_PORT: `3000`,
SERVEZONE_ENVIRONMENT: `production`,
CLOUDLY_URL: cloudlyUrl,
JUMPCODE: jumpcode,
},
});
}
@@ -137,3 +149,34 @@ export const runCli = async () => {
});
smartcliInstance.startParse();
};
const persistDaemonOptions = async (sparkInstance: Spark, argvArg: any) => {
const mode = argvArg.mode;
if (mode) {
await sparkInstance.sparkConfig.kvStore.writeKey('mode', mode);
}
const cloudlyUrl = argvArg.cloudlyUrl || argvArg['cloudly-url'] || Deno.env.get('CLOUDLY_URL');
if (cloudlyUrl) {
await sparkInstance.sparkConfig.kvStore.writeKey('cloudlyUrl', cloudlyUrl);
}
const jumpcode = argvArg.jumpcode || argvArg.jumpCode || Deno.env.get('JUMPCODE');
if (jumpcode) {
await sparkInstance.sparkConfig.kvStore.writeKey('jumpcode', jumpcode);
}
};
const readOption = async (
sparkInstance: Spark,
argvArg: any,
primaryKey: string,
secondaryKey: string,
envKey: string,
) => {
return argvArg[primaryKey]
|| argvArg[secondaryKey]
|| Deno.env.get(envKey)
|| await sparkInstance.sparkConfig.kvStore.readKey(primaryKey)
|| await sparkInstance.sparkConfig.kvStore.readKey(secondaryKey);
};
-3
View File
@@ -1,7 +1,4 @@
import * as plugins from './spark.plugins.ts';
import * as paths from './spark.paths.ts';
import { commitinfo } from './00_commitinfo_data.ts';
const projectInfoNpm = new plugins.projectinfo.ProjectinfoNpm(paths.packageDir);
export const logger = plugins.smartlog.Smartlog.createForCommitinfo(commitinfo);