BREAKING CHANGE(szci): Rename project from npmci to szci and migrate runtime to Deno; add compiled binaries, installer and wrapper; update imports, env handling and package metadata

This commit is contained in:
2025-10-26 15:23:56 +00:00
parent 4854d27a19
commit 88f64536c2
58 changed files with 1550 additions and 867 deletions

View File

@@ -1,13 +1,13 @@
import * as plugins from './mod.plugins.js';
import * as paths from '../npmci.paths.js';
import * as plugins from './mod.plugins.ts';
import * as paths from '../szci.paths.ts';
import { logger } from '../npmci.logging.js';
import { bash } from '../npmci.bash.js';
import { logger } from '../szci.logging.ts';
import { bash } from '../szci.bash.ts';
import { DockerRegistry } from './mod.classes.dockerregistry.js';
import * as helpers from './mod.helpers.js';
import { NpmciDockerManager } from './index.js';
import { Npmci } from '../npmci.classes.npmci.js';
import { DockerRegistry } from './mod.classes.dockerregistry.ts';
import * as helpers from './mod.helpers.ts';
import { SzciDockerManager } from './index.ts';
import { Szci } from '../szci.classes.szci.ts';
/**
* class Dockerfile represents a Dockerfile on disk in npmci
@@ -20,7 +20,7 @@ export class Dockerfile {
* @returns Promise<Dockerfile[]>
*/
public static async readDockerfiles(
npmciDockerManagerRefArg: NpmciDockerManager
npmciDockerManagerRefArg: SzciDockerManager
): Promise<Dockerfile[]> {
const fileTree = await plugins.smartfile.fs.listFileTree(paths.cwd, 'Dockerfile*');
@@ -167,7 +167,7 @@ export class Dockerfile {
}
versionString = versionString.replace(
'##version##',
dockerfileInstanceArg.npmciDockerManagerRef.npmciRef.npmciConfig.getConfig().projectInfo.npm
dockerfileInstanceArg.npmciDockerManagerRef.szciRef.npmciConfig.getConfig().projectInfo.npm
.version
);
return versionString;
@@ -194,7 +194,7 @@ export class Dockerfile {
const argMatch = trimmedLine.match(/^ARG\s+([^\s=]+)(?:=(.*))?$/i);
if (argMatch) {
const argName = argMatch[1];
const argValue = argMatch[2] !== undefined ? argMatch[2] : process.env[argName] || '';
const argValue = argMatch[2] !== undefined ? argMatch[2] : Deno.env.get(argName) || '';
args[argName] = argValue;
continue;
}
@@ -236,7 +236,7 @@ export class Dockerfile {
* returns the docker tag
*/
public static getDockerTagString(
npmciDockerManagerRef: NpmciDockerManager,
npmciDockerManagerRef: SzciDockerManager,
registryArg: string,
repoArg: string,
versionArg: string,
@@ -244,7 +244,7 @@ export class Dockerfile {
): string {
// determine wether the repo should be mapped accordingly to the registry
const mappedRepo =
npmciDockerManagerRef.npmciRef.npmciConfig.getConfig().dockerRegistryRepoMap[registryArg];
npmciDockerManagerRef.szciRef.npmciConfig.getConfig().dockerRegistryRepoMap[registryArg];
const repo = (() => {
if (mappedRepo) {
return mappedRepo;
@@ -264,27 +264,27 @@ export class Dockerfile {
}
public static async getDockerBuildArgs(
npmciDockerManagerRef: NpmciDockerManager
npmciDockerManagerRef: SzciDockerManager
): Promise<string> {
logger.log('info', 'checking for env vars to be supplied to the docker build');
let buildArgsString: string = '';
for (const dockerArgKey of Object.keys(
npmciDockerManagerRef.npmciRef.npmciConfig.getConfig().dockerBuildargEnvMap
npmciDockerManagerRef.szciRef.npmciConfig.getConfig().dockerBuildargEnvMap
)) {
const dockerArgOuterEnvVar =
npmciDockerManagerRef.npmciRef.npmciConfig.getConfig().dockerBuildargEnvMap[dockerArgKey];
npmciDockerManagerRef.szciRef.npmciConfig.getConfig().dockerBuildargEnvMap[dockerArgKey];
logger.log(
'note',
`docker ARG "${dockerArgKey}" maps to outer env var "${dockerArgOuterEnvVar}"`
);
const targetValue = process.env[dockerArgOuterEnvVar];
const targetValue = Deno.env.get(dockerArgOuterEnvVar);
buildArgsString = `${buildArgsString} --build-arg ${dockerArgKey}="${targetValue}"`;
}
return buildArgsString;
}
// INSTANCE
public npmciDockerManagerRef: NpmciDockerManager;
public npmciDockerManagerRef: SzciDockerManager;
public filePath: string;
public repo: string;
@@ -299,15 +299,15 @@ export class Dockerfile {
public localBaseDockerfile: Dockerfile;
constructor(
dockerManagerRefArg: NpmciDockerManager,
dockerManagerRefArg: SzciDockerManager,
options: { filePath?: string; fileContents?: string | Buffer; read?: boolean }
) {
this.npmciDockerManagerRef = dockerManagerRefArg;
this.filePath = options.filePath;
this.repo =
this.npmciDockerManagerRef.npmciRef.npmciEnv.repo.user +
this.npmciDockerManagerRef.szciRef.npmciEnv.repo.user +
'/' +
this.npmciDockerManagerRef.npmciRef.npmciEnv.repo.repo;
this.npmciDockerManagerRef.szciRef.npmciEnv.repo.repo;
this.version = Dockerfile.dockerFileVersion(this, plugins.path.parse(options.filePath).base);
this.cleanTag = this.repo + ':' + this.version;
this.buildTag = this.cleanTag;
@@ -327,7 +327,7 @@ export class Dockerfile {
logger.log('info', 'now building Dockerfile for ' + this.cleanTag);
const buildArgsString = await Dockerfile.getDockerBuildArgs(this.npmciDockerManagerRef);
const buildCommand = `docker build --label="version=${
this.npmciDockerManagerRef.npmciRef.npmciConfig.getConfig().projectInfo.npm.version
this.npmciDockerManagerRef.szciRef.npmciConfig.getConfig().projectInfo.npm.version
}" -t ${this.buildTag} -f ${this.filePath} ${buildArgsString} .`;
await bash(buildCommand);
return;
@@ -350,13 +350,13 @@ export class Dockerfile {
await bash(`docker inspect --format="{{index .RepoDigests 0}}" ${this.pushTag}`)
).split('@')[1];
console.log(`The image ${this.pushTag} has digest ${imageDigest}`);
await this.npmciDockerManagerRef.npmciRef.cloudlyConnector.announceDockerContainer({
await this.npmciDockerManagerRef.szciRef.cloudlyConnector.announceDockerContainer({
registryUrl: this.pushTag,
tag: this.buildTag,
labels: [],
version: this.npmciDockerManagerRef.npmciRef.npmciConfig.getConfig().projectInfo.npm.version,
version: this.npmciDockerManagerRef.szciRef.npmciConfig.getConfig().projectInfo.npm.version,
});
await this.npmciDockerManagerRef.npmciRef.npmciConfig.kvStorage.writeKey(
await this.npmciDockerManagerRef.szciRef.npmciConfig.kvStorage.writeKey(
'latestPushedDockerTag',
this.pushTag
);
@@ -381,7 +381,7 @@ export class Dockerfile {
* tests the Dockerfile;
*/
public async test() {
const testFile: string = plugins.path.join(paths.NpmciTestDir, 'test_' + this.version + '.sh');
const testFile: string = plugins.path.join(paths.SzciTestDir, 'test_' + this.version + '.sh');
const testFileExists: boolean = plugins.smartfile.fs.fileExistsSync(testFile);
if (testFileExists) {
// run tests