update to deno

This commit is contained in:
2025-12-13 13:27:51 +00:00
parent dba2e2ae68
commit 9ad5222b95
25 changed files with 196 additions and 225 deletions

1
.serena/.gitignore vendored
View File

@@ -1 +0,0 @@
/cache

View File

@@ -1,71 +0,0 @@
# language of the project (csharp, python, rust, java, typescript, go, cpp, or ruby)
# * For C, use cpp
# * For JavaScript, use typescript
# Special requirements:
# * csharp: Requires the presence of a .sln file in the project folder.
language: typescript
# the encoding used by text files in the project
# For a list of possible encodings, see https://docs.python.org/3.11/library/codecs.html#standard-encodings
encoding: "utf-8"
# whether to use the project's gitignore file to ignore files
# Added on 2025-04-07
ignore_all_files_in_gitignore: true
# list of additional paths to ignore
# same syntax as gitignore, so you can use * and **
# Was previously called `ignored_dirs`, please update your config if you are using that.
# Added (renamed) on 2025-04-07
ignored_paths: []
# whether the project is in read-only mode
# If set to true, all editing tools will be disabled and attempts to use them will result in an error
# Added on 2025-04-18
read_only: false
# list of tool names to exclude. We recommend not excluding any tools, see the readme for more details.
# Below is the complete list of tools for convenience.
# To make sure you have the latest list of tools, and to view their descriptions,
# execute `uv run scripts/print_tool_overview.py`.
#
# * `activate_project`: Activates a project by name.
# * `check_onboarding_performed`: Checks whether project onboarding was already performed.
# * `create_text_file`: Creates/overwrites a file in the project directory.
# * `delete_lines`: Deletes a range of lines within a file.
# * `delete_memory`: Deletes a memory from Serena's project-specific memory store.
# * `execute_shell_command`: Executes a shell command.
# * `find_referencing_code_snippets`: Finds code snippets in which the symbol at the given location is referenced.
# * `find_referencing_symbols`: Finds symbols that reference the symbol at the given location (optionally filtered by type).
# * `find_symbol`: Performs a global (or local) search for symbols with/containing a given name/substring (optionally filtered by type).
# * `get_current_config`: Prints the current configuration of the agent, including the active and available projects, tools, contexts, and modes.
# * `get_symbols_overview`: Gets an overview of the top-level symbols defined in a given file.
# * `initial_instructions`: Gets the initial instructions for the current project.
# Should only be used in settings where the system prompt cannot be set,
# e.g. in clients you have no control over, like Claude Desktop.
# * `insert_after_symbol`: Inserts content after the end of the definition of a given symbol.
# * `insert_at_line`: Inserts content at a given line in a file.
# * `insert_before_symbol`: Inserts content before the beginning of the definition of a given symbol.
# * `list_dir`: Lists files and directories in the given directory (optionally with recursion).
# * `list_memories`: Lists memories in Serena's project-specific memory store.
# * `onboarding`: Performs onboarding (identifying the project structure and essential tasks, e.g. for testing or building).
# * `prepare_for_new_conversation`: Provides instructions for preparing for a new conversation (in order to continue with the necessary context).
# * `read_file`: Reads a file within the project directory.
# * `read_memory`: Reads the memory with the given name from Serena's project-specific memory store.
# * `remove_project`: Removes a project from the Serena configuration.
# * `replace_lines`: Replaces a range of lines within a file with new content.
# * `replace_symbol_body`: Replaces the full definition of a symbol.
# * `restart_language_server`: Restarts the language server, may be necessary when edits not through Serena happen.
# * `search_for_pattern`: Performs a search for a pattern in the project.
# * `summarize_changes`: Provides instructions for summarizing the changes made to the codebase.
# * `switch_modes`: Activates modes by providing a list of their names
# * `think_about_collected_information`: Thinking tool for pondering the completeness of collected information.
# * `think_about_task_adherence`: Thinking tool for determining whether the agent is still on track with the current task.
# * `think_about_whether_you_are_done`: Thinking tool for determining whether the task is truly completed.
# * `write_memory`: Writes a named memory (for future reference) to Serena's project-specific memory store.
excluded_tools: []
# initial prompt for the project. It will always be given to the LLM upon activating the project
# (contrary to the memories, which are loaded on demand).
initial_prompt: ""
project_name: "npmci"

View File

@@ -5,9 +5,9 @@
"schema": {
"type": "object",
"properties": {
"npmci": {
"szci": {
"type": "object",
"description": "settings for npmci"
"description": "settings for szci"
},
"gitzone": {
"type": "object",

View File

@@ -1,21 +1,21 @@
{
"npmci": {
"@ship.zone/szci": {
"npmGlobalTools": [],
"npmAccessLevel": "public",
"npmRegistryUrl": "registry.npmjs.org"
},
"npmdocker": {
"@git.zone/tsdocker": {
"baseImage": "hosttoday/ht-docker-node:npmci",
"command": "npmci test stable"
"command": "szci test stable"
},
"gitzone": {
"@git.zone/cli": {
"projectType": "npm",
"module": {
"githost": "gitlab.com",
"gitscope": "ship.zone",
"gitrepo": "npmci",
"gitrepo": "szci",
"description": "A tool to streamline Node.js and Docker workflows within CI environments, particularly GitLab CI, providing various CI/CD utilities.",
"npmPackagename": "@ship.zone/npmci",
"npmPackagename": "@ship.zone/szci",
"license": "MIT",
"keywords": [
"Node.js",

View File

@@ -1,2 +1,31 @@
- focus on cli usage in CI environments.
- show Gitlab CI, GitHub CI and Gitea CI examples.
## Deno Migration Status
The project has been fully migrated from Node.js to Deno runtime.
### Environment Variables
All environment variables have been rebranded from NPMCI_* to SZCI_*:
| Old Name | New Name |
|----------|----------|
| `NPMCI_COMPUTED_REPOURL` | `SZCI_COMPUTED_REPOURL` |
| `NPMCI_URL_CLOUDLY` | `SZCI_URL_CLOUDLY` |
| `NPMCI_GIT_GITHUBTOKEN` | `SZCI_GIT_GITHUBTOKEN` |
| `NPMCI_GIT_GITHUBGROUP` | `SZCI_GIT_GITHUBGROUP` |
| `NPMCI_GIT_GITHUB` | `SZCI_GIT_GITHUB` |
| `NPMCI_TRIGGER_*` | `SZCI_TRIGGER_*` |
| `NPMCI_LOGIN_CLOUDRON` | `SZCI_LOGIN_CLOUDRON` |
| `NPMCI_SSHKEY_*` | `SZCI_SSHKEY_*` |
| `NPMCI_LOGIN_DOCKER*` | `SZCI_LOGIN_DOCKER*` |
| `NPMCI_TOKEN_NPM*` | `SZCI_TOKEN_NPM*` |
| `NPMTS_TEST` | `SZCI_TEST` |
| `DEBUG_NPMCI` | `DEBUG_SZCI` |
### Runtime
- Uses Deno APIs (`Deno.env`, `Deno.cwd`, `Deno.exit`)
- Logger runtime set to 'deno'
- Dynamic imports use `.ts` extensions

View File

@@ -17,7 +17,7 @@ export class CloudlyConnector {
optionsArg: plugins.tsclass.container.IContainer,
testCloudlyUrlArg?: string
) {
const cloudlyUrl = testCloudlyUrlArg || this.szciRef.npmciConfig.getConfig().urlCloudly;
const cloudlyUrl = testCloudlyUrlArg || this.szciRef.szciConfig.getConfig().urlCloudly;
if (!cloudlyUrl) {
logger.log(
'warn',

View File

@@ -1,9 +1,9 @@
import { Szci } from './szci.classes.szci.ts';
import { Dockerfile } from './manager.docker/mod.classes.dockerfile.ts';
export const szciInstance = new Npmci();
export const szciInstance = new Szci();
export { Dockerfile, Npmci };
export { Dockerfile, Szci };
export const runCli = async () => {
await szciInstance.start();

View File

@@ -23,12 +23,12 @@ export class SzciCloudronManager {
await this.deploy();
break;
default:
logger.log('error', `>>npmci cloudron ...<< action >>${action}<< not supported`);
logger.log('error', `>>szci cloudron ...<< action >>${action}<< not supported`);
}
} else {
logger.log(
'info',
`>>npmci cloudron ...<< cli arguments invalid... Please read the documentation.`
`>>szci cloudron ...<< cli arguments invalid... Please read the documentation.`
);
}
};
@@ -44,14 +44,18 @@ export class SzciCloudronManager {
logger.log('ok', 'cloudron cli installed');
// lets set the version in the CloudronManifest file
await this.prepareCloudronManifest(this.szciRef.npmciConfig.getConfig().projectInfo.npm.version);
await this.prepareCloudronManifest(this.szciRef.szciConfig.getConfig().projectInfo.npm.version);
logger.log('ok', 'CloudronManifest prepared');
// lets figure out the docker image tag
const dockerImageTag = await this.szciRef.npmciConfig.kvStorage.readKey('latestPushedDockerTag');
const appName = this.szciRef.npmciConfig.getConfig().cloudronAppName;
const dockerImageTag = await this.szciRef.szciConfig.kvStorage.readKey('latestPushedDockerTag');
const appName = this.szciRef.szciConfig.getConfig().cloudronAppName;
const cloudronEnvVar = Deno.env.get("NPMCI_LOGIN_CLOUDRON");
const cloudronEnvVar = Deno.env.get("SZCI_LOGIN_CLOUDRON");
if (!cloudronEnvVar) {
logger.log('error', 'SZCI_LOGIN_CLOUDRON environment variable is not set');
Deno.exit(1);
}
const cloudronServer = cloudronEnvVar.split('|')[0];
const cloudronToken = cloudronEnvVar.split('|')[1];
await bash(`cloudron update --server ${cloudronServer} --token ${cloudronToken} --image ${dockerImageTag} --app ${appName}`);

View File

@@ -11,7 +11,7 @@ import { RegistryStorage } from './mod.classes.registrystorage.ts';
export class SzciDockerManager {
public szciRef: Szci;
public npmciRegistryStorage = new RegistryStorage();
public szciRegistryStorage = new RegistryStorage();
constructor(szciArg: Szci) {
this.szciRef = szciArg;
@@ -42,12 +42,12 @@ export class SzciDockerManager {
await this.pull(argvArg);
break;
default:
logger.log('error', `>>npmci docker ...<< action >>${action}<< not supported`);
logger.log('error', `>>szci docker ...<< action >>${action}<< not supported`);
}
} else {
logger.log(
'info',
`>>npmci docker ...<< cli arguments invalid... Please read the documentation.`
`>>szci docker ...<< cli arguments invalid... Please read the documentation.`
);
}
};
@@ -69,7 +69,7 @@ export class SzciDockerManager {
*/
public login = async () => {
await this.prepare();
await this.npmciRegistryStorage.loginAll();
await this.szciRegistryStorage.loginAll();
};
/**
@@ -83,11 +83,11 @@ export class SzciDockerManager {
logger.log('error', 'Running in Gitlab CI, but no registry token specified by gitlab!');
Deno.exit(1);
}
this.npmciRegistryStorage.addRegistry(
this.szciRegistryStorage.addRegistry(
new DockerRegistry({
registryUrl: 'registry.gitlab.com',
username: 'gitlab-ci-token',
password: Deno.env.get("CI_JOB_TOKEN"),
password: Deno.env.get("CI_JOB_TOKEN")!,
})
);
}
@@ -95,9 +95,9 @@ export class SzciDockerManager {
// handle registries
await plugins.smartobject.forEachMinimatch(
Deno.env.toObject(),
'NPMCI_LOGIN_DOCKER*',
'SZCI_LOGIN_DOCKER*',
async (envString: string) => {
this.npmciRegistryStorage.addRegistry(DockerRegistry.fromEnvString(envString));
this.szciRegistryStorage.addRegistry(DockerRegistry.fromEnvString(envString));
}
);
return;
@@ -115,14 +115,14 @@ export class SzciDockerManager {
if (argvArg._.length >= 3 && argvArg._[2] !== 'npmextra') {
dockerRegistryUrls.push(argvArg._[2]);
} else {
if (this.szciRef.npmciConfig.getConfig().dockerRegistries.length === 0) {
if (this.szciRef.szciConfig.getConfig().dockerRegistries.length === 0) {
logger.log(
'warn',
`There are no docker registries listed in npmextra.json! This is strange!`
);
}
dockerRegistryUrls = dockerRegistryUrls.concat(
this.szciRef.npmciConfig.getConfig().dockerRegistries
this.szciRef.szciConfig.getConfig().dockerRegistries
);
}
@@ -137,7 +137,7 @@ export class SzciDockerManager {
const dockerfileArray = await Dockerfile.readDockerfiles(this)
.then(Dockerfile.sortDockerfiles)
.then(Dockerfile.mapDockerfiles);
const dockerRegistryToPushTo = await this.npmciRegistryStorage.getRegistryByUrl(
const dockerRegistryToPushTo = await this.szciRegistryStorage.getRegistryByUrl(
dockerRegistryUrl
);
if (!dockerRegistryToPushTo) {
@@ -163,7 +163,7 @@ export class SzciDockerManager {
if (argvArg._.length >= 4) {
suffix = argvArg._[3];
}
const localDockerRegistry = await this.npmciRegistryStorage.getRegistryByUrl(registryUrlArg);
const localDockerRegistry = await this.szciRegistryStorage.getRegistryByUrl(registryUrlArg);
const dockerfileArray = await Dockerfile.readDockerfiles(this)
.then(Dockerfile.sortDockerfiles)
.then(Dockerfile.mapDockerfiles);

View File

@@ -10,7 +10,7 @@ import { SzciDockerManager } from './index.ts';
import { Szci } from '../szci.classes.szci.ts';
/**
* class Dockerfile represents a Dockerfile on disk in npmci
* class Dockerfile represents a Dockerfile on disk in szci
*/
export class Dockerfile {
// STATIC
@@ -20,7 +20,7 @@ export class Dockerfile {
* @returns Promise<Dockerfile[]>
*/
public static async readDockerfiles(
npmciDockerManagerRefArg: SzciDockerManager
szciDockerManagerRefArg: SzciDockerManager
): Promise<Dockerfile[]> {
const fileTree = await plugins.smartfile.fs.listFileTree(paths.cwd, 'Dockerfile*');
@@ -29,7 +29,7 @@ export class Dockerfile {
logger.log('info', `found ${fileTree.length} Dockerfiles:`);
console.log(fileTree);
for (const dockerfilePath of fileTree) {
const myDockerfile = new Dockerfile(npmciDockerManagerRefArg, {
const myDockerfile = new Dockerfile(szciDockerManagerRefArg, {
filePath: dockerfilePath,
read: true,
});
@@ -61,7 +61,7 @@ export class Dockerfile {
// Check if the baseImage is among the local Dockerfiles
if (tagToDockerfile.has(baseImage)) {
const baseDockerfile = tagToDockerfile.get(baseImage);
const baseDockerfile = tagToDockerfile.get(baseImage)!;
dependencies.push(baseDockerfile);
dockerfile.localBaseImageDependent = true;
dockerfile.localBaseDockerfile = baseDockerfile;
@@ -96,7 +96,7 @@ export class Dockerfile {
}
});
} catch (error) {
logger.log('error', error.message);
logger.log('error', (error as Error).message);
throw error;
}
@@ -167,7 +167,7 @@ export class Dockerfile {
}
versionString = versionString.replace(
'##version##',
dockerfileInstanceArg.npmciDockerManagerRef.szciRef.npmciConfig.getConfig().projectInfo.npm
dockerfileInstanceArg.szciDockerManagerRef.szciRef.szciConfig.getConfig().projectInfo.npm
.version
);
return versionString;
@@ -236,7 +236,7 @@ export class Dockerfile {
* returns the docker tag
*/
public static getDockerTagString(
npmciDockerManagerRef: SzciDockerManager,
szciDockerManagerRef: 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.szciRef.npmciConfig.getConfig().dockerRegistryRepoMap[registryArg];
szciDockerManagerRef.szciRef.szciConfig.getConfig().dockerRegistryRepoMap[registryArg];
const repo = (() => {
if (mappedRepo) {
return mappedRepo;
@@ -264,15 +264,15 @@ export class Dockerfile {
}
public static async getDockerBuildArgs(
npmciDockerManagerRef: SzciDockerManager
szciDockerManagerRef: 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.szciRef.npmciConfig.getConfig().dockerBuildargEnvMap
szciDockerManagerRef.szciRef.szciConfig.getConfig().dockerBuildargEnvMap
)) {
const dockerArgOuterEnvVar =
npmciDockerManagerRef.szciRef.npmciConfig.getConfig().dockerBuildargEnvMap[dockerArgKey];
szciDockerManagerRef.szciRef.szciConfig.getConfig().dockerBuildargEnvMap[dockerArgKey];
logger.log(
'note',
`docker ARG "${dockerArgKey}" maps to outer env var "${dockerArgOuterEnvVar}"`
@@ -284,31 +284,31 @@ export class Dockerfile {
}
// INSTANCE
public npmciDockerManagerRef: SzciDockerManager;
public szciDockerManagerRef: SzciDockerManager;
public filePath: string;
public filePath!: string;
public repo: string;
public version: string;
public cleanTag: string;
public buildTag: string;
public pushTag: string;
public pushTag!: string;
public containerName: string;
public content: string;
public content!: string;
public baseImage: string;
public localBaseImageDependent: boolean;
public localBaseDockerfile: Dockerfile;
public localBaseDockerfile!: Dockerfile;
constructor(
dockerManagerRefArg: SzciDockerManager,
options: { filePath?: string; fileContents?: string | Buffer; read?: boolean }
options: { filePath?: string; fileContents?: string | Uint8Array; read?: boolean }
) {
this.npmciDockerManagerRef = dockerManagerRefArg;
this.filePath = options.filePath;
this.szciDockerManagerRef = dockerManagerRefArg;
this.filePath = options.filePath!;
this.repo =
this.npmciDockerManagerRef.szciRef.npmciEnv.repo.user +
this.szciDockerManagerRef.szciRef.szciEnv.repo.user +
'/' +
this.npmciDockerManagerRef.szciRef.npmciEnv.repo.repo;
this.version = Dockerfile.dockerFileVersion(this, plugins.path.parse(options.filePath).base);
this.szciDockerManagerRef.szciRef.szciEnv.repo.repo;
this.version = Dockerfile.dockerFileVersion(this, plugins.path.parse(this.filePath).base);
this.cleanTag = this.repo + ':' + this.version;
this.buildTag = this.cleanTag;
@@ -325,9 +325,9 @@ export class Dockerfile {
*/
public async build() {
logger.log('info', 'now building Dockerfile for ' + this.cleanTag);
const buildArgsString = await Dockerfile.getDockerBuildArgs(this.npmciDockerManagerRef);
const buildArgsString = await Dockerfile.getDockerBuildArgs(this.szciDockerManagerRef);
const buildCommand = `docker build --label="version=${
this.npmciDockerManagerRef.szciRef.npmciConfig.getConfig().projectInfo.npm.version
this.szciDockerManagerRef.szciRef.szciConfig.getConfig().projectInfo.npm.version
}" -t ${this.buildTag} -f ${this.filePath} ${buildArgsString} .`;
await bash(buildCommand);
return;
@@ -336,9 +336,9 @@ export class Dockerfile {
/**
* pushes the Dockerfile to a registry
*/
public async push(dockerRegistryArg: DockerRegistry, versionSuffix: string = null) {
public async push(dockerRegistryArg: DockerRegistry, versionSuffix?: string) {
this.pushTag = Dockerfile.getDockerTagString(
this.npmciDockerManagerRef,
this.szciDockerManagerRef,
dockerRegistryArg.registryUrl,
this.repo,
this.version,
@@ -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.szciRef.cloudlyConnector.announceDockerContainer({
await this.szciDockerManagerRef.szciRef.cloudlyConnector.announceDockerContainer({
registryUrl: this.pushTag,
tag: this.buildTag,
labels: [],
version: this.npmciDockerManagerRef.szciRef.npmciConfig.getConfig().projectInfo.npm.version,
version: this.szciDockerManagerRef.szciRef.szciConfig.getConfig().projectInfo.npm.version,
});
await this.npmciDockerManagerRef.szciRef.npmciConfig.kvStorage.writeKey(
await this.szciDockerManagerRef.szciRef.szciConfig.kvStorage.writeKey(
'latestPushedDockerTag',
this.pushTag
);
@@ -365,9 +365,9 @@ export class Dockerfile {
/**
* pulls the Dockerfile from a registry
*/
public async pull(registryArg: DockerRegistry, versionSuffixArg: string = null) {
public async pull(registryArg: DockerRegistry, versionSuffixArg?: string) {
const pullTag = Dockerfile.getDockerTagString(
this.npmciDockerManagerRef,
this.szciDockerManagerRef,
registryArg.registryUrl,
this.repo,
this.version,
@@ -386,13 +386,13 @@ export class Dockerfile {
if (testFileExists) {
// run tests
await bash(
`docker run --name npmci_test_container --entrypoint="bash" ${this.buildTag} -c "mkdir /npmci_test"`
`docker run --name szci_test_container --entrypoint="bash" ${this.buildTag} -c "mkdir /szci_test"`
);
await bash(`docker cp ${testFile} npmci_test_container:/npmci_test/test.sh`);
await bash(`docker commit npmci_test_container npmci_test_image`);
await bash(`docker run --entrypoint="bash" npmci_test_image -x /npmci_test/test.sh`);
await bash(`docker rm npmci_test_container`);
await bash(`docker rmi --force npmci_test_image`);
await bash(`docker cp ${testFile} szci_test_container:/szci_test/test.sh`);
await bash(`docker commit szci_test_container szci_test_image`);
await bash(`docker run --entrypoint="bash" szci_test_image -x /szci_test/test.sh`);
await bash(`docker rm szci_test_container`);
await bash(`docker rmi --force szci_test_image`);
} else {
logger.log('warn', 'skipping tests for ' + this.cleanTag + ' because no testfile was found!');
}

View File

@@ -24,7 +24,6 @@ export class DockerRegistry {
if (dockerRegexResultArray.length !== 3) {
logger.log('error', 'malformed docker env var...');
Deno.exit(1);
return;
}
const registryUrl = dockerRegexResultArray[0].replace('https://', '').replace('http://', '');
const username = dockerRegexResultArray[1];

View File

@@ -22,20 +22,20 @@ export class SzciGitManager {
await this.mirror();
break;
default:
logger.log('error', `npmci git -> action >>${action}<< not supported!`);
logger.log('error', `szci git -> action >>${action}<< not supported!`);
}
} else {
logger.log('info', `npmci git -> cli arguments invalid! Please read the documentation.`);
logger.log('info', `szci git -> cli arguments invalid! Please read the documentation.`);
}
};
public mirror = async () => {
const githubToken = Deno.env.get("NPMCI_GIT_GITHUBTOKEN");
const githubUser = Deno.env.get("NPMCI_GIT_GITHUBGROUP") || this.szciRef.npmciEnv.repo.user;
const githubRepo = Deno.env.get("NPMCI_GIT_GITHUB") || this.szciRef.npmciEnv.repo.repo;
const githubToken = Deno.env.get("SZCI_GIT_GITHUBTOKEN");
const githubUser = Deno.env.get("SZCI_GIT_GITHUBGROUP") || this.szciRef.szciEnv.repo.user;
const githubRepo = Deno.env.get("SZCI_GIT_GITHUB") || this.szciRef.szciEnv.repo.repo;
if (
this.szciRef.npmciConfig.getConfig().projectInfo.npm.packageJson.private === true ||
this.szciRef.npmciConfig.getConfig().npmAccessLevel === 'private'
this.szciRef.szciConfig.getConfig().projectInfo.npm.packageJson.private === true ||
this.szciRef.szciConfig.getConfig().npmAccessLevel === 'private'
) {
logger.log(
'warn',
@@ -64,7 +64,7 @@ export class SzciGitManager {
// remove old mirrors
await bashNoError('git remote rm mirror');
} else {
logger.log('error', `cannot find NPMCI_GIT_GITHUBTOKEN env var!`);
logger.log('error', `cannot find SZCI_GIT_GITHUBTOKEN env var!`);
Deno.exit(1);
}
};

View File

@@ -24,13 +24,13 @@ export class SzciNodeJsManager {
await this.install(argvArg._[2]);
break;
default:
logger.log('error', `>>npmci node ...<< action >>${action}<< not supported`);
logger.log('error', `>>szci node ...<< action >>${action}<< not supported`);
Deno.exit(1);
}
} else {
logger.log(
'error',
`>>npmci node ...<< cli arguments invalid... Please read the documentation.`
`>>szci node ...<< cli arguments invalid... Please read the documentation.`
);
Deno.exit(1);
}
@@ -64,7 +64,7 @@ export class SzciNodeJsManager {
await bash('npm -v');
// lets look for further config
const config = await this.szciRef.npmciConfig.getConfig();
const config = await this.szciRef.szciConfig.getConfig();
logger.log('info', 'Now checking for needed global npm tools...');
for (const npmTool of config.npmGlobalTools) {
logger.log('info', `Checking for global "${npmTool}"`);

View File

@@ -36,13 +36,13 @@ export class SzciNpmManager {
await this.publish();
break;
default:
logger.log('error', `>>npmci npm ...<< action >>${action}<< not supported`);
logger.log('error', `>>szci npm ...<< action >>${action}<< not supported`);
Deno.exit(1);
}
} else {
logger.log(
'info',
`>>npmci npm ...<< cli arguments invalid... Please read the documentation.`
`>>szci npm ...<< cli arguments invalid... Please read the documentation.`
);
Deno.exit(1);
}
@@ -53,11 +53,11 @@ export class SzciNpmManager {
*/
public async prepare() {
logger.log('info', 'running >>npm prepare<<');
const config = this.szciRef.npmciConfig.getConfig();
const config = this.szciRef.szciConfig.getConfig();
let npmrcFileString: string = '';
await plugins.smartobject.forEachMinimatch(
Deno.env.toObject(),
'NPMCI_TOKEN_NPM*',
'SZCI_TOKEN_NPM*',
(npmEnvArg: string) => {
if (!npmEnvArg) {
logger.log('note','found empty token...');
@@ -103,11 +103,11 @@ export class SzciNpmManager {
let npmAccessCliString = ``;
let npmRegistryCliString = ``;
let publishVerdaccioAsWell = false;
const config = this.szciRef.npmciConfig.getConfig();
const config = this.szciRef.szciConfig.getConfig();
const availableRegistries: string[] = [];
await plugins.smartobject.forEachMinimatch(
Deno.env.toObject(),
'NPMCI_TOKEN_NPM*',
'SZCI_TOKEN_NPM*',
(npmEnvArg: string) => {
availableRegistries.push(npmEnvArg.split('|')[0]);
}
@@ -166,7 +166,7 @@ export class SzciNpmManager {
logger.log('success', `Nice!!! The build for the publication was successfull!`);
logger.log('info', `Lets clean up so we don't publish any packages that don't belong to us:`);
// -> clean up before we publish stuff
await bashNoError(`rm -r ./.npmci_cache`);
await bashNoError(`rm -r ./.szci_cache`);
await bash(`rm -r ./node_modules`);
logger.log('success', `Cleaned up!:`);

View File

@@ -2,7 +2,7 @@ import * as plugins from './mod.plugins.ts';
import * as paths from '../szci.paths.ts';
/**
* cleans npmci config files
* cleans szci config files
*/
export let clean = async (): Promise<void> => {
plugins.smartfile.fs.removeSync(paths.SzciPackageConfig);

View File

@@ -5,11 +5,16 @@ import { Szci } from '../szci.classes.szci.ts';
export const handleCli = async (szciRefArg: Szci, argvArg: any) => {
logger.log('info', 'checking execution context');
const presentRunnerTags = Deno.env.get("CI_RUNNER_TAGS").split(',').map((stringArg) =>
const ciRunnerTags = Deno.env.get("CI_RUNNER_TAGS");
if (!ciRunnerTags) {
logger.log('error', 'CI_RUNNER_TAGS environment variable is not set');
Deno.exit(1);
}
const presentRunnerTags = ciRunnerTags.split(',').map((stringArg) =>
stringArg.trim()
);
let allDesiredGitlabRunnerTagsPresent = true;
for (const desiredRunnerTag of szciRefArg.npmciConfig.getConfig().gitlabRunnerTags) {
for (const desiredRunnerTag of szciRefArg.szciConfig.getConfig().gitlabRunnerTags) {
if (!presentRunnerTags.includes(desiredRunnerTag)) {
allDesiredGitlabRunnerTagsPresent = false;
logger.log(

View File

@@ -14,7 +14,7 @@ export let handleCli = async (argvArg: any) => {
Deno.exit(1);
}
} else {
logger.log('error', `>>npmci ssh ...<< please specify an action!`);
logger.log('error', `>>szci ssh ...<< please specify an action!`);
Deno.exit(1);
}
};
@@ -27,12 +27,12 @@ const notUndefined = (stringArg: string) => {
};
/**
* checks for ENV vars in form of NPMCI_SSHKEY_* and deploys any found ones
* checks for ENV vars in form of SZCI_SSHKEY_* and deploys any found ones
*/
export let prepare = async () => {
sshInstance = new plugins.smartssh.SshInstance(); // init ssh instance
plugins.smartobject.forEachMinimatch(Deno.env.toObject(), 'NPMCI_SSHKEY_*', evaluateSshEnv);
if (!Deno.env.get("NPMTS_TEST")) {
plugins.smartobject.forEachMinimatch(Deno.env.toObject(), 'SZCI_SSHKEY_*', evaluateSshEnv);
if (!Deno.env.get("SZCI_TEST")) {
sshInstance.writeToDisk();
} else {
logger.log('info', 'In test mode, so not storing SSH keys to disk!');

View File

@@ -7,16 +7,20 @@ const triggerValueRegex =
export let trigger = async () => {
logger.log('info', 'now running triggers');
await plugins.smartobject.forEachMinimatch(Deno.env.toObject(), 'NPMCI_TRIGGER_*', evaluateTrigger);
await plugins.smartobject.forEachMinimatch(Deno.env.toObject(), 'SZCI_TRIGGER_*', evaluateTrigger);
};
const evaluateTrigger = async (triggerEnvVarArg) => {
const evaluateTrigger = async (triggerEnvVarArg: string) => {
const triggerRegexResultArray = triggerValueRegex.exec(triggerEnvVarArg);
if (!triggerRegexResultArray) {
logger.log('error', 'malformed trigger env var...');
return;
}
const regexDomain = triggerRegexResultArray[1];
const regexProjectId = triggerRegexResultArray[2];
const regexProjectTriggerToken = triggerRegexResultArray[3];
const regexRefName = triggerRegexResultArray[4];
let regexTriggerName;
let regexTriggerName: string;
if (triggerRegexResultArray.length === 6) {
regexTriggerName = triggerRegexResultArray[5];
} else {

View File

@@ -7,9 +7,9 @@ import * as paths from './szci.paths.ts';
*/
export let nvmAvailable = plugins.smartpromise.defer<boolean>();
/**
* the smartshell instance for npmci
* the smartshell instance for szci
*/
const npmciSmartshell = new plugins.smartshell.Smartshell({
const szciSmartshell = new plugins.smartshell.Smartshell({
executor: 'bash',
sourceFilePaths: [],
});
@@ -19,16 +19,16 @@ const npmciSmartshell = new plugins.smartshell.Smartshell({
*/
const checkToolsAvailable = async () => {
// check for nvm
if (!Deno.env.get('NPMTS_TEST')) {
if (!Deno.env.get('SZCI_TEST')) {
if (
(await npmciSmartshell.execSilent(`bash -c "source /usr/local/nvm/nvm.sh"`)).exitCode === 0
(await szciSmartshell.execSilent(`bash -c "source /usr/local/nvm/nvm.sh"`)).exitCode === 0
) {
npmciSmartshell.shellEnv.addSourceFiles([`/usr/local/nvm/nvm.sh`]);
szciSmartshell.shellEnv.addSourceFiles([`/usr/local/nvm/nvm.sh`]);
nvmAvailable.resolve(true);
} else if (
(await npmciSmartshell.execSilent(`bash -c "source ~/.nvm/nvm.sh"`)).exitCode === 0
(await szciSmartshell.execSilent(`bash -c "source ~/.nvm/nvm.sh"`)).exitCode === 0
) {
npmciSmartshell.shellEnv.addSourceFiles([`~/.nvm/nvm.sh`]);
szciSmartshell.shellEnv.addSourceFiles([`~/.nvm/nvm.sh`]);
nvmAvailable.resolve(true);
} else {
nvmAvailable.resolve(false);
@@ -46,7 +46,7 @@ checkToolsAvailable();
*/
export let bash = async (commandArg: string, retryArg: number = 2): Promise<string> => {
await nvmAvailable.promise; // make sure nvm check has run
let execResult: plugins.smartshell.IExecResult;
let execResult!: plugins.smartshell.IExecResult;
// determine if we fail
let failOnError: boolean = true;
@@ -55,13 +55,13 @@ export let bash = async (commandArg: string, retryArg: number = 2): Promise<stri
retryArg = 0;
}
if (!Deno.env.get('NPMTS_TEST')) {
// NPMTS_TEST is used during testing
if (!Deno.env.get('SZCI_TEST')) {
// SZCI_TEST is used during testing
for (let i = 0; i <= retryArg; i++) {
if (Deno.env.get('DEBUG_NPMCI') === 'true') {
if (Deno.env.get('DEBUG_SZCI') === 'true') {
console.log(commandArg);
}
execResult = await npmciSmartshell.exec(commandArg);
execResult = await szciSmartshell.exec(commandArg);
// determine how bash reacts to error and success
if (execResult.exitCode !== 0 && i === retryArg) {

View File

@@ -19,19 +19,19 @@ import { SzciNpmManager } from './manager.npm/index.ts';
export class Szci {
public analytics: plugins.smartanalytics.Analytics;
public cloudlyConnector: CloudlyConnector;
public cloudlyConnector!: CloudlyConnector;
public npmciEnv: SzciEnv;
public npmciInfo: SzciInfo;
public npmciConfig: SzciConfig;
public npmciCli: SzciCli;
public szciEnv!: SzciEnv;
public szciInfo!: SzciInfo;
public szciConfig!: SzciConfig;
public szciCli!: SzciCli;
// managers
public cloudronManager: SzciCloudronManager;
public dockerManager: SzciDockerManager;
public gitManager: SzciGitManager;
public nodejsManager: SzciNodeJsManager;
public npmManager: SzciNpmManager;
public cloudronManager!: SzciCloudronManager;
public dockerManager!: SzciDockerManager;
public gitManager!: SzciGitManager;
public nodejsManager!: SzciNodeJsManager;
public npmManager!: SzciNpmManager;
constructor() {
this.analytics = new plugins.smartanalytics.Analytics({
@@ -43,12 +43,12 @@ export class Szci {
public async start() {
this.cloudlyConnector = new CloudlyConnector(this);
this.npmciEnv = new SzciEnv(this);
this.npmciInfo = new SzciInfo(this);
await this.npmciInfo.printToConsole();
this.npmciCli = new SzciCli(this);
this.npmciConfig = new SzciConfig(this);
await this.npmciConfig.init();
this.szciEnv = new SzciEnv(this);
this.szciInfo = new SzciInfo(this);
await this.szciInfo.printToConsole();
this.szciCli = new SzciCli(this);
this.szciConfig = new SzciConfig(this);
await this.szciConfig.init();
// managers
this.cloudronManager = new SzciCloudronManager(this);
@@ -56,6 +56,6 @@ export class Szci {
this.gitManager = new SzciGitManager(this);
this.nodejsManager = new SzciNodeJsManager(this);
this.npmManager = new SzciNpmManager(this);
this.npmciCli.startParse();
this.szciCli.startParse();
}
}

View File

@@ -10,12 +10,12 @@ export class SzciCli {
constructor(szciArg: Szci) {
this.szciRef = szciArg;
this.smartcli = new plugins.smartcli.Smartcli();
this.smartcli.addVersion(this.szciRef.npmciInfo.version);
this.smartcli.addVersion(this.szciRef.szciInfo.version);
// clean
this.smartcli.addCommand('clean').subscribe(
async (argv) => {
const modClean = await import('./mod_clean/index.js');
const modClean = await import('./mod_clean/index.ts');
await modClean.clean();
},
(err) => {
@@ -38,7 +38,7 @@ export class SzciCli {
// command
this.smartcli.addCommand('command').subscribe(
async (argv) => {
const modCommand = await import('./mod_command/index.js');
const modCommand = await import('./mod_command/index.ts');
await modCommand.command();
},
(err) => {
@@ -91,20 +91,20 @@ export class SzciCli {
);
this.smartcli.addCommand('precheck').subscribe(async (argvArg) => {
const modPrecheck = await import('./mod_precheck/index.js');
const modPrecheck = await import('./mod_precheck/index.ts');
await modPrecheck.handleCli(this.szciRef, argvArg);
});
// trigger
this.smartcli.addCommand('ssh').subscribe(async (argvArg) => {
const modSsh = await import('./mod_ssh/index.js');
const modSsh = await import('./mod_ssh/index.ts');
await modSsh.handleCli(argvArg);
});
// trigger
this.smartcli.addCommand('trigger').subscribe(
async (argv) => {
const modTrigger = await import('./mod_trigger/index.js');
const modTrigger = await import('./mod_trigger/index.ts');
await modTrigger.trigger();
},
(err) => {

View File

@@ -5,7 +5,7 @@ import { logger } from './szci.logging.ts';
import { Szci } from './szci.classes.szci.ts';
/**
* the main config interface for npmci
* the main config interface for szci
*/
export interface ISzciOptions {
projectInfo: plugins.projectinfo.ProjectInfo;
@@ -24,35 +24,35 @@ export interface ISzciOptions {
gitlabRunnerTags: string[];
// urls
urlCloudly: string;
urlCloudly?: string;
// cloudron
cloudronAppName?: string;
}
/**
* a config class for Npmci
* a config class for Szci
*/
export class SzciConfig {
public szciRef: Szci;
public npmciNpmextra: plugins.npmextra.Npmextra;
public kvStorage: plugins.npmextra.KeyValueStore;
public npmciQenv: plugins.qenv.Qenv;
public szciNpmextra!: plugins.npmextra.Npmextra;
public kvStorage!: plugins.npmextra.KeyValueStore;
public szciQenv!: plugins.qenv.Qenv;
private configObject: ISzciOptions;
private configObject!: ISzciOptions;
constructor(szciRefArg: Szci) {
this.szciRef = szciRefArg;
}
public async init() {
this.npmciNpmextra = new plugins.npmextra.Npmextra(paths.cwd);
this.szciNpmextra = new plugins.npmextra.Npmextra(paths.cwd);
this.kvStorage = new plugins.npmextra.KeyValueStore({
typeArg: 'userHomeDir',
identityArg: `.npmci_${this.szciRef.npmciEnv.repo.user}_${this.szciRef.npmciEnv.repo.repo}`,
identityArg: `.szci_${this.szciRef.szciEnv.repo.user}_${this.szciRef.szciEnv.repo.repo}`,
});
this.npmciQenv = new plugins.qenv.Qenv(
this.szciQenv = new plugins.qenv.Qenv(
paths.SzciProjectDir,
paths.SzciProjectNogitDir,
false
@@ -67,9 +67,9 @@ export class SzciConfig {
npmRegistryUrl: 'registry.npmjs.org',
gitlabRunnerTags: [],
dockerBuildargEnvMap: {},
urlCloudly: await this.npmciQenv.getEnvVarOnDemand('NPMCI_URL_CLOUDLY'),
urlCloudly: await this.szciQenv.getEnvVarOnDemand('SZCI_URL_CLOUDLY'),
};
this.configObject = this.npmciNpmextra.dataFor<ISzciOptions>('szci', this.configObject);
this.configObject = this.szciNpmextra.dataFor<ISzciOptions>('@ship.zone/szci', this.configObject);
}
public getConfig(): ISzciOptions {

View File

@@ -9,15 +9,17 @@ export class SzciEnv {
constructor(szciRefArg: Szci) {
this.szciRef = szciRefArg;
if (!this.repoString && Deno.env.get("GITLAB_CI")) {
this.repoString = Deno.env.get("CI_REPOSITORY_URL");
// Determine repo string from environment
let repoUrl: string | undefined;
if (Deno.env.get("GITLAB_CI")) {
repoUrl = Deno.env.get("CI_REPOSITORY_URL");
}
if (!this.repoString && Deno.env.get("NPMCI_COMPUTED_REPOURL")) {
this.repoString = Deno.env.get("NPMCI_COMPUTED_REPOURL");
}
if (!this.repoString) {
this.repoString = 'https://undefined:undefined@github.com/undefined/undefined.git';
if (!repoUrl && Deno.env.get("SZCI_COMPUTED_REPOURL")) {
repoUrl = Deno.env.get("SZCI_COMPUTED_REPOURL");
}
this.repoString = repoUrl || 'https://undefined:undefined@github.com/undefined/undefined.git';
this.repo = new plugins.smartstring.GitRepo(this.repoString);
}
}

View File

@@ -6,7 +6,7 @@ export const logger = new plugins.smartlog.Smartlog({
companyunit: 'Some Unit',
containerName: 'Some ContainerName',
environment: 'test',
runtime: 'node',
runtime: 'deno',
zone: 'Some Zone',
},
});

View File

@@ -13,4 +13,4 @@ export const SzciPackageConfig = plugins.path.join(SzciPackageRoot, './config.js
export const SzciProjectDir = cwd;
export const SzciProjectNogitDir = plugins.path.join(SzciProjectDir, './.nogit');
export const SzciTestDir = plugins.path.join(cwd, './test');
export const SzciCacheDir = plugins.path.join(cwd, './.npmci_cache');
export const SzciCacheDir = plugins.path.join(cwd, './.szci_cache');