feat(migration): Migrate from Node.js to Deno runtime
Major migration to Deno runtime following the nupst project pattern:
Core Changes:
- Created deno.json configuration with tasks, imports, and settings
- Created mod.ts as main entry point with Deno permissions
- Updated all TypeScript imports from .js to .ts extensions
- Replaced Node.js APIs (process.exit) with Deno equivalents (Deno.exit)
- Updated path imports to use @std/path from JSR
Dependencies:
- Migrated all npm dependencies to use npm: prefix in import map
- Added Deno standard library imports (@std/path, @std/assert)
- Configured import aliases for all @push.rocks and @serve.zone packages
Build & Distribution:
- Created install.sh for downloading pre-compiled binaries
- Created uninstall.sh for clean system removal
- Created scripts/compile-all.sh for multi-platform compilation
- Supports Linux (x64, ARM64), macOS (x64, ARM64), Windows (x64)
Testing:
- Migrated tests to Deno test framework using @std/assert
- Created test.simple.ts for basic verification
- Updated test structure to use Deno.test instead of tap
CI/CD:
- Created .gitea/workflows/ci.yml for type checking, linting, and builds
- Created .gitea/workflows/release.yml for automated releases
- Created .gitea/release-template.md for release documentation
Cleanup:
- Removed package.json, pnpm-lock.yaml, tsconfig.json
- Removed Node.js CLI files (cli.js, cli.child.ts, cli.ts.js)
- Removed dist_ts/ compiled output directory
- Removed npmextra.json configuration
This migration enables standalone binary distribution without Node.js
runtime dependency while maintaining all existing functionality.
2025-10-23 23:22:16 +00:00
|
|
|
import * as plugins from './spark.plugins.ts';
|
|
|
|
|
import * as paths from './spark.paths.ts';
|
|
|
|
|
import { Spark } from './spark.classes.spark.ts';
|
|
|
|
|
import { logger } from './spark.logging.ts';
|
2024-05-08 20:49:10 +02:00
|
|
|
|
2024-12-20 01:29:21 +01:00
|
|
|
/**
|
|
|
|
|
* this class takes care of updating the services that are managed by spark
|
|
|
|
|
*/
|
|
|
|
|
export class SparkServicesManager {
|
2024-05-08 20:49:10 +02:00
|
|
|
public sparkRef: Spark;
|
|
|
|
|
public dockerHost: plugins.docker.DockerHost;
|
|
|
|
|
public smartupdate: plugins.smartupdate.SmartUpdate;
|
2024-12-20 01:29:21 +01:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* the services that are managed by spark
|
|
|
|
|
*/
|
|
|
|
|
services: Array<{
|
|
|
|
|
name: string;
|
|
|
|
|
image: string;
|
|
|
|
|
url: string;
|
|
|
|
|
port: string;
|
|
|
|
|
environment: string;
|
|
|
|
|
secretJson: any;
|
|
|
|
|
}> = [];
|
|
|
|
|
|
2024-05-08 20:49:10 +02:00
|
|
|
constructor(sparkrefArg: Spark) {
|
|
|
|
|
this.sparkRef = sparkrefArg;
|
2024-06-13 15:12:07 +02:00
|
|
|
this.dockerHost = new plugins.docker.DockerHost({});
|
2024-05-08 20:49:10 +02:00
|
|
|
this.smartupdate = new plugins.smartupdate.SmartUpdate();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* start the instance
|
|
|
|
|
*/
|
|
|
|
|
public async start() {
|
|
|
|
|
await this.dockerHost.activateSwarm();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public async updateServices() {
|
2024-12-20 01:29:21 +01:00
|
|
|
for (const service of this.services) {
|
|
|
|
|
const existingService = await plugins.docker.DockerService.getServiceByName(
|
|
|
|
|
this.dockerHost,
|
|
|
|
|
service.name
|
|
|
|
|
);
|
|
|
|
|
const existingServiceSecret = await plugins.docker.DockerSecret.getSecretByName(
|
|
|
|
|
this.dockerHost,
|
|
|
|
|
`${service.name}Secret`
|
|
|
|
|
);
|
|
|
|
|
if (existingService) {
|
|
|
|
|
const needsUpdate: boolean = await existingService.needsUpdate();
|
|
|
|
|
if (!needsUpdate) {
|
|
|
|
|
logger.log('info', `service >>${service.name}<< not needing update.`);
|
|
|
|
|
// we simply return here to end the functions
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
// continuing here means we need to update the service
|
|
|
|
|
logger.log('ok', `${service.name} needs to be updated!`);
|
|
|
|
|
await existingService.remove();
|
|
|
|
|
await existingServiceSecret.remove();
|
|
|
|
|
}
|
|
|
|
|
if (!existingService && existingServiceSecret) {
|
|
|
|
|
await existingServiceSecret.remove();
|
|
|
|
|
}
|
2024-06-13 15:12:07 +02:00
|
|
|
|
2024-12-20 01:29:21 +01:00
|
|
|
const newServiceImage = await plugins.docker.DockerImage.createFromRegistry(
|
|
|
|
|
this.dockerHost,
|
|
|
|
|
{
|
|
|
|
|
creationObject: {
|
|
|
|
|
imageUrl: service.image,
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
const newServiceSecret = await plugins.docker.DockerSecret.createSecret(this.dockerHost, {
|
|
|
|
|
name: `${service.name}Secret`,
|
|
|
|
|
contentArg: plugins.smartjson.stringify(service.secretJson),
|
|
|
|
|
version: await newServiceImage.getVersion(),
|
|
|
|
|
labels: {},
|
2024-06-13 15:12:07 +02:00
|
|
|
});
|
|
|
|
|
|
2024-12-20 01:29:21 +01:00
|
|
|
const newService = await plugins.docker.DockerService.createService(this.dockerHost, {
|
|
|
|
|
image: newServiceImage,
|
|
|
|
|
labels: {},
|
|
|
|
|
name: service.name,
|
|
|
|
|
networkAlias: service.name,
|
|
|
|
|
networks: [],
|
|
|
|
|
secrets: [newServiceSecret],
|
|
|
|
|
ports: [`${service.port}:${service.secretJson.SERVEZONE_PORT}`],
|
2024-06-13 15:12:07 +02:00
|
|
|
});
|
2024-12-20 01:29:21 +01:00
|
|
|
logger.log('ok', `updated service >>${newService.Spec.Name}<<!`);
|
2024-05-08 20:49:10 +02:00
|
|
|
}
|
2024-12-20 01:29:21 +01:00
|
|
|
|
|
|
|
|
logger.log('success', `updated ${this.services.length} services!`);
|
2024-05-08 20:49:10 +02:00
|
|
|
}
|
|
|
|
|
}
|