update to deno
This commit is contained in:
1
.serena/.gitignore
vendored
1
.serena/.gitignore
vendored
@@ -1 +0,0 @@
|
|||||||
/cache
|
|
||||||
@@ -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"
|
|
||||||
4
.vscode/settings.json
vendored
4
.vscode/settings.json
vendored
@@ -5,9 +5,9 @@
|
|||||||
"schema": {
|
"schema": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
"npmci": {
|
"szci": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"description": "settings for npmci"
|
"description": "settings for szci"
|
||||||
},
|
},
|
||||||
"gitzone": {
|
"gitzone": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
|
|||||||
@@ -1,21 +1,21 @@
|
|||||||
{
|
{
|
||||||
"npmci": {
|
"@ship.zone/szci": {
|
||||||
"npmGlobalTools": [],
|
"npmGlobalTools": [],
|
||||||
"npmAccessLevel": "public",
|
"npmAccessLevel": "public",
|
||||||
"npmRegistryUrl": "registry.npmjs.org"
|
"npmRegistryUrl": "registry.npmjs.org"
|
||||||
},
|
},
|
||||||
"npmdocker": {
|
"@git.zone/tsdocker": {
|
||||||
"baseImage": "hosttoday/ht-docker-node:npmci",
|
"baseImage": "hosttoday/ht-docker-node:npmci",
|
||||||
"command": "npmci test stable"
|
"command": "szci test stable"
|
||||||
},
|
},
|
||||||
"gitzone": {
|
"@git.zone/cli": {
|
||||||
"projectType": "npm",
|
"projectType": "npm",
|
||||||
"module": {
|
"module": {
|
||||||
"githost": "gitlab.com",
|
"githost": "gitlab.com",
|
||||||
"gitscope": "ship.zone",
|
"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.",
|
"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",
|
"license": "MIT",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"Node.js",
|
"Node.js",
|
||||||
@@ -36,4 +36,4 @@
|
|||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,2 +1,31 @@
|
|||||||
- focus on cli usage in CI environments.
|
- focus on cli usage in CI environments.
|
||||||
- show Gitlab CI, GitHub CI and Gitea CI examples.
|
- 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
|
||||||
@@ -17,7 +17,7 @@ export class CloudlyConnector {
|
|||||||
optionsArg: plugins.tsclass.container.IContainer,
|
optionsArg: plugins.tsclass.container.IContainer,
|
||||||
testCloudlyUrlArg?: string
|
testCloudlyUrlArg?: string
|
||||||
) {
|
) {
|
||||||
const cloudlyUrl = testCloudlyUrlArg || this.szciRef.npmciConfig.getConfig().urlCloudly;
|
const cloudlyUrl = testCloudlyUrlArg || this.szciRef.szciConfig.getConfig().urlCloudly;
|
||||||
if (!cloudlyUrl) {
|
if (!cloudlyUrl) {
|
||||||
logger.log(
|
logger.log(
|
||||||
'warn',
|
'warn',
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
import { Szci } from './szci.classes.szci.ts';
|
import { Szci } from './szci.classes.szci.ts';
|
||||||
import { Dockerfile } from './manager.docker/mod.classes.dockerfile.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 () => {
|
export const runCli = async () => {
|
||||||
await szciInstance.start();
|
await szciInstance.start();
|
||||||
|
|||||||
@@ -23,12 +23,12 @@ export class SzciCloudronManager {
|
|||||||
await this.deploy();
|
await this.deploy();
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
logger.log('error', `>>npmci cloudron ...<< action >>${action}<< not supported`);
|
logger.log('error', `>>szci cloudron ...<< action >>${action}<< not supported`);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
logger.log(
|
logger.log(
|
||||||
'info',
|
'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');
|
logger.log('ok', 'cloudron cli installed');
|
||||||
|
|
||||||
// lets set the version in the CloudronManifest file
|
// 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');
|
logger.log('ok', 'CloudronManifest prepared');
|
||||||
|
|
||||||
// lets figure out the docker image tag
|
// lets figure out the docker image tag
|
||||||
const dockerImageTag = await this.szciRef.npmciConfig.kvStorage.readKey('latestPushedDockerTag');
|
const dockerImageTag = await this.szciRef.szciConfig.kvStorage.readKey('latestPushedDockerTag');
|
||||||
const appName = this.szciRef.npmciConfig.getConfig().cloudronAppName;
|
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 cloudronServer = cloudronEnvVar.split('|')[0];
|
||||||
const cloudronToken = cloudronEnvVar.split('|')[1];
|
const cloudronToken = cloudronEnvVar.split('|')[1];
|
||||||
await bash(`cloudron update --server ${cloudronServer} --token ${cloudronToken} --image ${dockerImageTag} --app ${appName}`);
|
await bash(`cloudron update --server ${cloudronServer} --token ${cloudronToken} --image ${dockerImageTag} --app ${appName}`);
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ import { RegistryStorage } from './mod.classes.registrystorage.ts';
|
|||||||
|
|
||||||
export class SzciDockerManager {
|
export class SzciDockerManager {
|
||||||
public szciRef: Szci;
|
public szciRef: Szci;
|
||||||
public npmciRegistryStorage = new RegistryStorage();
|
public szciRegistryStorage = new RegistryStorage();
|
||||||
|
|
||||||
constructor(szciArg: Szci) {
|
constructor(szciArg: Szci) {
|
||||||
this.szciRef = szciArg;
|
this.szciRef = szciArg;
|
||||||
@@ -42,12 +42,12 @@ export class SzciDockerManager {
|
|||||||
await this.pull(argvArg);
|
await this.pull(argvArg);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
logger.log('error', `>>npmci docker ...<< action >>${action}<< not supported`);
|
logger.log('error', `>>szci docker ...<< action >>${action}<< not supported`);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
logger.log(
|
logger.log(
|
||||||
'info',
|
'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 () => {
|
public login = async () => {
|
||||||
await this.prepare();
|
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!');
|
logger.log('error', 'Running in Gitlab CI, but no registry token specified by gitlab!');
|
||||||
Deno.exit(1);
|
Deno.exit(1);
|
||||||
}
|
}
|
||||||
this.npmciRegistryStorage.addRegistry(
|
this.szciRegistryStorage.addRegistry(
|
||||||
new DockerRegistry({
|
new DockerRegistry({
|
||||||
registryUrl: 'registry.gitlab.com',
|
registryUrl: 'registry.gitlab.com',
|
||||||
username: 'gitlab-ci-token',
|
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
|
// handle registries
|
||||||
await plugins.smartobject.forEachMinimatch(
|
await plugins.smartobject.forEachMinimatch(
|
||||||
Deno.env.toObject(),
|
Deno.env.toObject(),
|
||||||
'NPMCI_LOGIN_DOCKER*',
|
'SZCI_LOGIN_DOCKER*',
|
||||||
async (envString: string) => {
|
async (envString: string) => {
|
||||||
this.npmciRegistryStorage.addRegistry(DockerRegistry.fromEnvString(envString));
|
this.szciRegistryStorage.addRegistry(DockerRegistry.fromEnvString(envString));
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
return;
|
return;
|
||||||
@@ -115,14 +115,14 @@ export class SzciDockerManager {
|
|||||||
if (argvArg._.length >= 3 && argvArg._[2] !== 'npmextra') {
|
if (argvArg._.length >= 3 && argvArg._[2] !== 'npmextra') {
|
||||||
dockerRegistryUrls.push(argvArg._[2]);
|
dockerRegistryUrls.push(argvArg._[2]);
|
||||||
} else {
|
} else {
|
||||||
if (this.szciRef.npmciConfig.getConfig().dockerRegistries.length === 0) {
|
if (this.szciRef.szciConfig.getConfig().dockerRegistries.length === 0) {
|
||||||
logger.log(
|
logger.log(
|
||||||
'warn',
|
'warn',
|
||||||
`There are no docker registries listed in npmextra.json! This is strange!`
|
`There are no docker registries listed in npmextra.json! This is strange!`
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
dockerRegistryUrls = dockerRegistryUrls.concat(
|
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)
|
const dockerfileArray = await Dockerfile.readDockerfiles(this)
|
||||||
.then(Dockerfile.sortDockerfiles)
|
.then(Dockerfile.sortDockerfiles)
|
||||||
.then(Dockerfile.mapDockerfiles);
|
.then(Dockerfile.mapDockerfiles);
|
||||||
const dockerRegistryToPushTo = await this.npmciRegistryStorage.getRegistryByUrl(
|
const dockerRegistryToPushTo = await this.szciRegistryStorage.getRegistryByUrl(
|
||||||
dockerRegistryUrl
|
dockerRegistryUrl
|
||||||
);
|
);
|
||||||
if (!dockerRegistryToPushTo) {
|
if (!dockerRegistryToPushTo) {
|
||||||
@@ -163,7 +163,7 @@ export class SzciDockerManager {
|
|||||||
if (argvArg._.length >= 4) {
|
if (argvArg._.length >= 4) {
|
||||||
suffix = argvArg._[3];
|
suffix = argvArg._[3];
|
||||||
}
|
}
|
||||||
const localDockerRegistry = await this.npmciRegistryStorage.getRegistryByUrl(registryUrlArg);
|
const localDockerRegistry = await this.szciRegistryStorage.getRegistryByUrl(registryUrlArg);
|
||||||
const dockerfileArray = await Dockerfile.readDockerfiles(this)
|
const dockerfileArray = await Dockerfile.readDockerfiles(this)
|
||||||
.then(Dockerfile.sortDockerfiles)
|
.then(Dockerfile.sortDockerfiles)
|
||||||
.then(Dockerfile.mapDockerfiles);
|
.then(Dockerfile.mapDockerfiles);
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ import { SzciDockerManager } from './index.ts';
|
|||||||
import { Szci } from '../szci.classes.szci.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 {
|
export class Dockerfile {
|
||||||
// STATIC
|
// STATIC
|
||||||
@@ -20,7 +20,7 @@ export class Dockerfile {
|
|||||||
* @returns Promise<Dockerfile[]>
|
* @returns Promise<Dockerfile[]>
|
||||||
*/
|
*/
|
||||||
public static async readDockerfiles(
|
public static async readDockerfiles(
|
||||||
npmciDockerManagerRefArg: SzciDockerManager
|
szciDockerManagerRefArg: SzciDockerManager
|
||||||
): Promise<Dockerfile[]> {
|
): Promise<Dockerfile[]> {
|
||||||
const fileTree = await plugins.smartfile.fs.listFileTree(paths.cwd, '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:`);
|
logger.log('info', `found ${fileTree.length} Dockerfiles:`);
|
||||||
console.log(fileTree);
|
console.log(fileTree);
|
||||||
for (const dockerfilePath of fileTree) {
|
for (const dockerfilePath of fileTree) {
|
||||||
const myDockerfile = new Dockerfile(npmciDockerManagerRefArg, {
|
const myDockerfile = new Dockerfile(szciDockerManagerRefArg, {
|
||||||
filePath: dockerfilePath,
|
filePath: dockerfilePath,
|
||||||
read: true,
|
read: true,
|
||||||
});
|
});
|
||||||
@@ -61,7 +61,7 @@ export class Dockerfile {
|
|||||||
|
|
||||||
// Check if the baseImage is among the local Dockerfiles
|
// Check if the baseImage is among the local Dockerfiles
|
||||||
if (tagToDockerfile.has(baseImage)) {
|
if (tagToDockerfile.has(baseImage)) {
|
||||||
const baseDockerfile = tagToDockerfile.get(baseImage);
|
const baseDockerfile = tagToDockerfile.get(baseImage)!;
|
||||||
dependencies.push(baseDockerfile);
|
dependencies.push(baseDockerfile);
|
||||||
dockerfile.localBaseImageDependent = true;
|
dockerfile.localBaseImageDependent = true;
|
||||||
dockerfile.localBaseDockerfile = baseDockerfile;
|
dockerfile.localBaseDockerfile = baseDockerfile;
|
||||||
@@ -96,7 +96,7 @@ export class Dockerfile {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
logger.log('error', error.message);
|
logger.log('error', (error as Error).message);
|
||||||
throw error;
|
throw error;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -167,7 +167,7 @@ export class Dockerfile {
|
|||||||
}
|
}
|
||||||
versionString = versionString.replace(
|
versionString = versionString.replace(
|
||||||
'##version##',
|
'##version##',
|
||||||
dockerfileInstanceArg.npmciDockerManagerRef.szciRef.npmciConfig.getConfig().projectInfo.npm
|
dockerfileInstanceArg.szciDockerManagerRef.szciRef.szciConfig.getConfig().projectInfo.npm
|
||||||
.version
|
.version
|
||||||
);
|
);
|
||||||
return versionString;
|
return versionString;
|
||||||
@@ -236,7 +236,7 @@ export class Dockerfile {
|
|||||||
* returns the docker tag
|
* returns the docker tag
|
||||||
*/
|
*/
|
||||||
public static getDockerTagString(
|
public static getDockerTagString(
|
||||||
npmciDockerManagerRef: SzciDockerManager,
|
szciDockerManagerRef: SzciDockerManager,
|
||||||
registryArg: string,
|
registryArg: string,
|
||||||
repoArg: string,
|
repoArg: string,
|
||||||
versionArg: string,
|
versionArg: string,
|
||||||
@@ -244,7 +244,7 @@ export class Dockerfile {
|
|||||||
): string {
|
): string {
|
||||||
// determine wether the repo should be mapped accordingly to the registry
|
// determine wether the repo should be mapped accordingly to the registry
|
||||||
const mappedRepo =
|
const mappedRepo =
|
||||||
npmciDockerManagerRef.szciRef.npmciConfig.getConfig().dockerRegistryRepoMap[registryArg];
|
szciDockerManagerRef.szciRef.szciConfig.getConfig().dockerRegistryRepoMap[registryArg];
|
||||||
const repo = (() => {
|
const repo = (() => {
|
||||||
if (mappedRepo) {
|
if (mappedRepo) {
|
||||||
return mappedRepo;
|
return mappedRepo;
|
||||||
@@ -264,15 +264,15 @@ export class Dockerfile {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static async getDockerBuildArgs(
|
public static async getDockerBuildArgs(
|
||||||
npmciDockerManagerRef: SzciDockerManager
|
szciDockerManagerRef: SzciDockerManager
|
||||||
): Promise<string> {
|
): Promise<string> {
|
||||||
logger.log('info', 'checking for env vars to be supplied to the docker build');
|
logger.log('info', 'checking for env vars to be supplied to the docker build');
|
||||||
let buildArgsString: string = '';
|
let buildArgsString: string = '';
|
||||||
for (const dockerArgKey of Object.keys(
|
for (const dockerArgKey of Object.keys(
|
||||||
npmciDockerManagerRef.szciRef.npmciConfig.getConfig().dockerBuildargEnvMap
|
szciDockerManagerRef.szciRef.szciConfig.getConfig().dockerBuildargEnvMap
|
||||||
)) {
|
)) {
|
||||||
const dockerArgOuterEnvVar =
|
const dockerArgOuterEnvVar =
|
||||||
npmciDockerManagerRef.szciRef.npmciConfig.getConfig().dockerBuildargEnvMap[dockerArgKey];
|
szciDockerManagerRef.szciRef.szciConfig.getConfig().dockerBuildargEnvMap[dockerArgKey];
|
||||||
logger.log(
|
logger.log(
|
||||||
'note',
|
'note',
|
||||||
`docker ARG "${dockerArgKey}" maps to outer env var "${dockerArgOuterEnvVar}"`
|
`docker ARG "${dockerArgKey}" maps to outer env var "${dockerArgOuterEnvVar}"`
|
||||||
@@ -284,31 +284,31 @@ export class Dockerfile {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// INSTANCE
|
// INSTANCE
|
||||||
public npmciDockerManagerRef: SzciDockerManager;
|
public szciDockerManagerRef: SzciDockerManager;
|
||||||
|
|
||||||
public filePath: string;
|
public filePath!: string;
|
||||||
public repo: string;
|
public repo: string;
|
||||||
public version: string;
|
public version: string;
|
||||||
public cleanTag: string;
|
public cleanTag: string;
|
||||||
public buildTag: string;
|
public buildTag: string;
|
||||||
public pushTag: string;
|
public pushTag!: string;
|
||||||
public containerName: string;
|
public containerName: string;
|
||||||
public content: string;
|
public content!: string;
|
||||||
public baseImage: string;
|
public baseImage: string;
|
||||||
public localBaseImageDependent: boolean;
|
public localBaseImageDependent: boolean;
|
||||||
public localBaseDockerfile: Dockerfile;
|
public localBaseDockerfile!: Dockerfile;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
dockerManagerRefArg: SzciDockerManager,
|
dockerManagerRefArg: SzciDockerManager,
|
||||||
options: { filePath?: string; fileContents?: string | Buffer; read?: boolean }
|
options: { filePath?: string; fileContents?: string | Uint8Array; read?: boolean }
|
||||||
) {
|
) {
|
||||||
this.npmciDockerManagerRef = dockerManagerRefArg;
|
this.szciDockerManagerRef = dockerManagerRefArg;
|
||||||
this.filePath = options.filePath;
|
this.filePath = options.filePath!;
|
||||||
this.repo =
|
this.repo =
|
||||||
this.npmciDockerManagerRef.szciRef.npmciEnv.repo.user +
|
this.szciDockerManagerRef.szciRef.szciEnv.repo.user +
|
||||||
'/' +
|
'/' +
|
||||||
this.npmciDockerManagerRef.szciRef.npmciEnv.repo.repo;
|
this.szciDockerManagerRef.szciRef.szciEnv.repo.repo;
|
||||||
this.version = Dockerfile.dockerFileVersion(this, plugins.path.parse(options.filePath).base);
|
this.version = Dockerfile.dockerFileVersion(this, plugins.path.parse(this.filePath).base);
|
||||||
this.cleanTag = this.repo + ':' + this.version;
|
this.cleanTag = this.repo + ':' + this.version;
|
||||||
this.buildTag = this.cleanTag;
|
this.buildTag = this.cleanTag;
|
||||||
|
|
||||||
@@ -325,9 +325,9 @@ export class Dockerfile {
|
|||||||
*/
|
*/
|
||||||
public async build() {
|
public async build() {
|
||||||
logger.log('info', 'now building Dockerfile for ' + this.cleanTag);
|
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=${
|
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} .`;
|
}" -t ${this.buildTag} -f ${this.filePath} ${buildArgsString} .`;
|
||||||
await bash(buildCommand);
|
await bash(buildCommand);
|
||||||
return;
|
return;
|
||||||
@@ -336,9 +336,9 @@ export class Dockerfile {
|
|||||||
/**
|
/**
|
||||||
* pushes the Dockerfile to a registry
|
* 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.pushTag = Dockerfile.getDockerTagString(
|
||||||
this.npmciDockerManagerRef,
|
this.szciDockerManagerRef,
|
||||||
dockerRegistryArg.registryUrl,
|
dockerRegistryArg.registryUrl,
|
||||||
this.repo,
|
this.repo,
|
||||||
this.version,
|
this.version,
|
||||||
@@ -350,13 +350,13 @@ export class Dockerfile {
|
|||||||
await bash(`docker inspect --format="{{index .RepoDigests 0}}" ${this.pushTag}`)
|
await bash(`docker inspect --format="{{index .RepoDigests 0}}" ${this.pushTag}`)
|
||||||
).split('@')[1];
|
).split('@')[1];
|
||||||
console.log(`The image ${this.pushTag} has digest ${imageDigest}`);
|
console.log(`The image ${this.pushTag} has digest ${imageDigest}`);
|
||||||
await this.npmciDockerManagerRef.szciRef.cloudlyConnector.announceDockerContainer({
|
await this.szciDockerManagerRef.szciRef.cloudlyConnector.announceDockerContainer({
|
||||||
registryUrl: this.pushTag,
|
registryUrl: this.pushTag,
|
||||||
tag: this.buildTag,
|
tag: this.buildTag,
|
||||||
labels: [],
|
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',
|
'latestPushedDockerTag',
|
||||||
this.pushTag
|
this.pushTag
|
||||||
);
|
);
|
||||||
@@ -365,9 +365,9 @@ export class Dockerfile {
|
|||||||
/**
|
/**
|
||||||
* pulls the Dockerfile from a registry
|
* 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(
|
const pullTag = Dockerfile.getDockerTagString(
|
||||||
this.npmciDockerManagerRef,
|
this.szciDockerManagerRef,
|
||||||
registryArg.registryUrl,
|
registryArg.registryUrl,
|
||||||
this.repo,
|
this.repo,
|
||||||
this.version,
|
this.version,
|
||||||
@@ -386,13 +386,13 @@ export class Dockerfile {
|
|||||||
if (testFileExists) {
|
if (testFileExists) {
|
||||||
// run tests
|
// run tests
|
||||||
await bash(
|
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 cp ${testFile} szci_test_container:/szci_test/test.sh`);
|
||||||
await bash(`docker commit npmci_test_container npmci_test_image`);
|
await bash(`docker commit szci_test_container szci_test_image`);
|
||||||
await bash(`docker run --entrypoint="bash" npmci_test_image -x /npmci_test/test.sh`);
|
await bash(`docker run --entrypoint="bash" szci_test_image -x /szci_test/test.sh`);
|
||||||
await bash(`docker rm npmci_test_container`);
|
await bash(`docker rm szci_test_container`);
|
||||||
await bash(`docker rmi --force npmci_test_image`);
|
await bash(`docker rmi --force szci_test_image`);
|
||||||
} else {
|
} else {
|
||||||
logger.log('warn', 'skipping tests for ' + this.cleanTag + ' because no testfile was found!');
|
logger.log('warn', 'skipping tests for ' + this.cleanTag + ' because no testfile was found!');
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,7 +24,6 @@ export class DockerRegistry {
|
|||||||
if (dockerRegexResultArray.length !== 3) {
|
if (dockerRegexResultArray.length !== 3) {
|
||||||
logger.log('error', 'malformed docker env var...');
|
logger.log('error', 'malformed docker env var...');
|
||||||
Deno.exit(1);
|
Deno.exit(1);
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
const registryUrl = dockerRegexResultArray[0].replace('https://', '').replace('http://', '');
|
const registryUrl = dockerRegexResultArray[0].replace('https://', '').replace('http://', '');
|
||||||
const username = dockerRegexResultArray[1];
|
const username = dockerRegexResultArray[1];
|
||||||
|
|||||||
@@ -22,20 +22,20 @@ export class SzciGitManager {
|
|||||||
await this.mirror();
|
await this.mirror();
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
logger.log('error', `npmci git -> action >>${action}<< not supported!`);
|
logger.log('error', `szci git -> action >>${action}<< not supported!`);
|
||||||
}
|
}
|
||||||
} else {
|
} 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 () => {
|
public mirror = async () => {
|
||||||
const githubToken = Deno.env.get("NPMCI_GIT_GITHUBTOKEN");
|
const githubToken = Deno.env.get("SZCI_GIT_GITHUBTOKEN");
|
||||||
const githubUser = Deno.env.get("NPMCI_GIT_GITHUBGROUP") || this.szciRef.npmciEnv.repo.user;
|
const githubUser = Deno.env.get("SZCI_GIT_GITHUBGROUP") || this.szciRef.szciEnv.repo.user;
|
||||||
const githubRepo = Deno.env.get("NPMCI_GIT_GITHUB") || this.szciRef.npmciEnv.repo.repo;
|
const githubRepo = Deno.env.get("SZCI_GIT_GITHUB") || this.szciRef.szciEnv.repo.repo;
|
||||||
if (
|
if (
|
||||||
this.szciRef.npmciConfig.getConfig().projectInfo.npm.packageJson.private === true ||
|
this.szciRef.szciConfig.getConfig().projectInfo.npm.packageJson.private === true ||
|
||||||
this.szciRef.npmciConfig.getConfig().npmAccessLevel === 'private'
|
this.szciRef.szciConfig.getConfig().npmAccessLevel === 'private'
|
||||||
) {
|
) {
|
||||||
logger.log(
|
logger.log(
|
||||||
'warn',
|
'warn',
|
||||||
@@ -64,7 +64,7 @@ export class SzciGitManager {
|
|||||||
// remove old mirrors
|
// remove old mirrors
|
||||||
await bashNoError('git remote rm mirror');
|
await bashNoError('git remote rm mirror');
|
||||||
} else {
|
} else {
|
||||||
logger.log('error', `cannot find NPMCI_GIT_GITHUBTOKEN env var!`);
|
logger.log('error', `cannot find SZCI_GIT_GITHUBTOKEN env var!`);
|
||||||
Deno.exit(1);
|
Deno.exit(1);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -24,13 +24,13 @@ export class SzciNodeJsManager {
|
|||||||
await this.install(argvArg._[2]);
|
await this.install(argvArg._[2]);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
logger.log('error', `>>npmci node ...<< action >>${action}<< not supported`);
|
logger.log('error', `>>szci node ...<< action >>${action}<< not supported`);
|
||||||
Deno.exit(1);
|
Deno.exit(1);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
logger.log(
|
logger.log(
|
||||||
'error',
|
'error',
|
||||||
`>>npmci node ...<< cli arguments invalid... Please read the documentation.`
|
`>>szci node ...<< cli arguments invalid... Please read the documentation.`
|
||||||
);
|
);
|
||||||
Deno.exit(1);
|
Deno.exit(1);
|
||||||
}
|
}
|
||||||
@@ -64,7 +64,7 @@ export class SzciNodeJsManager {
|
|||||||
await bash('npm -v');
|
await bash('npm -v');
|
||||||
|
|
||||||
// lets look for further config
|
// 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...');
|
logger.log('info', 'Now checking for needed global npm tools...');
|
||||||
for (const npmTool of config.npmGlobalTools) {
|
for (const npmTool of config.npmGlobalTools) {
|
||||||
logger.log('info', `Checking for global "${npmTool}"`);
|
logger.log('info', `Checking for global "${npmTool}"`);
|
||||||
|
|||||||
@@ -36,13 +36,13 @@ export class SzciNpmManager {
|
|||||||
await this.publish();
|
await this.publish();
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
logger.log('error', `>>npmci npm ...<< action >>${action}<< not supported`);
|
logger.log('error', `>>szci npm ...<< action >>${action}<< not supported`);
|
||||||
Deno.exit(1);
|
Deno.exit(1);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
logger.log(
|
logger.log(
|
||||||
'info',
|
'info',
|
||||||
`>>npmci npm ...<< cli arguments invalid... Please read the documentation.`
|
`>>szci npm ...<< cli arguments invalid... Please read the documentation.`
|
||||||
);
|
);
|
||||||
Deno.exit(1);
|
Deno.exit(1);
|
||||||
}
|
}
|
||||||
@@ -53,11 +53,11 @@ export class SzciNpmManager {
|
|||||||
*/
|
*/
|
||||||
public async prepare() {
|
public async prepare() {
|
||||||
logger.log('info', 'running >>npm prepare<<');
|
logger.log('info', 'running >>npm prepare<<');
|
||||||
const config = this.szciRef.npmciConfig.getConfig();
|
const config = this.szciRef.szciConfig.getConfig();
|
||||||
let npmrcFileString: string = '';
|
let npmrcFileString: string = '';
|
||||||
await plugins.smartobject.forEachMinimatch(
|
await plugins.smartobject.forEachMinimatch(
|
||||||
Deno.env.toObject(),
|
Deno.env.toObject(),
|
||||||
'NPMCI_TOKEN_NPM*',
|
'SZCI_TOKEN_NPM*',
|
||||||
(npmEnvArg: string) => {
|
(npmEnvArg: string) => {
|
||||||
if (!npmEnvArg) {
|
if (!npmEnvArg) {
|
||||||
logger.log('note','found empty token...');
|
logger.log('note','found empty token...');
|
||||||
@@ -103,11 +103,11 @@ export class SzciNpmManager {
|
|||||||
let npmAccessCliString = ``;
|
let npmAccessCliString = ``;
|
||||||
let npmRegistryCliString = ``;
|
let npmRegistryCliString = ``;
|
||||||
let publishVerdaccioAsWell = false;
|
let publishVerdaccioAsWell = false;
|
||||||
const config = this.szciRef.npmciConfig.getConfig();
|
const config = this.szciRef.szciConfig.getConfig();
|
||||||
const availableRegistries: string[] = [];
|
const availableRegistries: string[] = [];
|
||||||
await plugins.smartobject.forEachMinimatch(
|
await plugins.smartobject.forEachMinimatch(
|
||||||
Deno.env.toObject(),
|
Deno.env.toObject(),
|
||||||
'NPMCI_TOKEN_NPM*',
|
'SZCI_TOKEN_NPM*',
|
||||||
(npmEnvArg: string) => {
|
(npmEnvArg: string) => {
|
||||||
availableRegistries.push(npmEnvArg.split('|')[0]);
|
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('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:`);
|
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
|
// -> clean up before we publish stuff
|
||||||
await bashNoError(`rm -r ./.npmci_cache`);
|
await bashNoError(`rm -r ./.szci_cache`);
|
||||||
await bash(`rm -r ./node_modules`);
|
await bash(`rm -r ./node_modules`);
|
||||||
|
|
||||||
logger.log('success', `Cleaned up!:`);
|
logger.log('success', `Cleaned up!:`);
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import * as plugins from './mod.plugins.ts';
|
|||||||
import * as paths from '../szci.paths.ts';
|
import * as paths from '../szci.paths.ts';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* cleans npmci config files
|
* cleans szci config files
|
||||||
*/
|
*/
|
||||||
export let clean = async (): Promise<void> => {
|
export let clean = async (): Promise<void> => {
|
||||||
plugins.smartfile.fs.removeSync(paths.SzciPackageConfig);
|
plugins.smartfile.fs.removeSync(paths.SzciPackageConfig);
|
||||||
|
|||||||
@@ -5,11 +5,16 @@ import { Szci } from '../szci.classes.szci.ts';
|
|||||||
|
|
||||||
export const handleCli = async (szciRefArg: Szci, argvArg: any) => {
|
export const handleCli = async (szciRefArg: Szci, argvArg: any) => {
|
||||||
logger.log('info', 'checking execution context');
|
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()
|
stringArg.trim()
|
||||||
);
|
);
|
||||||
let allDesiredGitlabRunnerTagsPresent = true;
|
let allDesiredGitlabRunnerTagsPresent = true;
|
||||||
for (const desiredRunnerTag of szciRefArg.npmciConfig.getConfig().gitlabRunnerTags) {
|
for (const desiredRunnerTag of szciRefArg.szciConfig.getConfig().gitlabRunnerTags) {
|
||||||
if (!presentRunnerTags.includes(desiredRunnerTag)) {
|
if (!presentRunnerTags.includes(desiredRunnerTag)) {
|
||||||
allDesiredGitlabRunnerTagsPresent = false;
|
allDesiredGitlabRunnerTagsPresent = false;
|
||||||
logger.log(
|
logger.log(
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ export let handleCli = async (argvArg: any) => {
|
|||||||
Deno.exit(1);
|
Deno.exit(1);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
logger.log('error', `>>npmci ssh ...<< please specify an action!`);
|
logger.log('error', `>>szci ssh ...<< please specify an action!`);
|
||||||
Deno.exit(1);
|
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 () => {
|
export let prepare = async () => {
|
||||||
sshInstance = new plugins.smartssh.SshInstance(); // init ssh instance
|
sshInstance = new plugins.smartssh.SshInstance(); // init ssh instance
|
||||||
plugins.smartobject.forEachMinimatch(Deno.env.toObject(), 'NPMCI_SSHKEY_*', evaluateSshEnv);
|
plugins.smartobject.forEachMinimatch(Deno.env.toObject(), 'SZCI_SSHKEY_*', evaluateSshEnv);
|
||||||
if (!Deno.env.get("NPMTS_TEST")) {
|
if (!Deno.env.get("SZCI_TEST")) {
|
||||||
sshInstance.writeToDisk();
|
sshInstance.writeToDisk();
|
||||||
} else {
|
} else {
|
||||||
logger.log('info', 'In test mode, so not storing SSH keys to disk!');
|
logger.log('info', 'In test mode, so not storing SSH keys to disk!');
|
||||||
|
|||||||
@@ -7,16 +7,20 @@ const triggerValueRegex =
|
|||||||
|
|
||||||
export let trigger = async () => {
|
export let trigger = async () => {
|
||||||
logger.log('info', 'now running triggers');
|
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);
|
const triggerRegexResultArray = triggerValueRegex.exec(triggerEnvVarArg);
|
||||||
|
if (!triggerRegexResultArray) {
|
||||||
|
logger.log('error', 'malformed trigger env var...');
|
||||||
|
return;
|
||||||
|
}
|
||||||
const regexDomain = triggerRegexResultArray[1];
|
const regexDomain = triggerRegexResultArray[1];
|
||||||
const regexProjectId = triggerRegexResultArray[2];
|
const regexProjectId = triggerRegexResultArray[2];
|
||||||
const regexProjectTriggerToken = triggerRegexResultArray[3];
|
const regexProjectTriggerToken = triggerRegexResultArray[3];
|
||||||
const regexRefName = triggerRegexResultArray[4];
|
const regexRefName = triggerRegexResultArray[4];
|
||||||
let regexTriggerName;
|
let regexTriggerName: string;
|
||||||
if (triggerRegexResultArray.length === 6) {
|
if (triggerRegexResultArray.length === 6) {
|
||||||
regexTriggerName = triggerRegexResultArray[5];
|
regexTriggerName = triggerRegexResultArray[5];
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -7,9 +7,9 @@ import * as paths from './szci.paths.ts';
|
|||||||
*/
|
*/
|
||||||
export let nvmAvailable = plugins.smartpromise.defer<boolean>();
|
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',
|
executor: 'bash',
|
||||||
sourceFilePaths: [],
|
sourceFilePaths: [],
|
||||||
});
|
});
|
||||||
@@ -19,16 +19,16 @@ const npmciSmartshell = new plugins.smartshell.Smartshell({
|
|||||||
*/
|
*/
|
||||||
const checkToolsAvailable = async () => {
|
const checkToolsAvailable = async () => {
|
||||||
// check for nvm
|
// check for nvm
|
||||||
if (!Deno.env.get('NPMTS_TEST')) {
|
if (!Deno.env.get('SZCI_TEST')) {
|
||||||
if (
|
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);
|
nvmAvailable.resolve(true);
|
||||||
} else if (
|
} 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);
|
nvmAvailable.resolve(true);
|
||||||
} else {
|
} else {
|
||||||
nvmAvailable.resolve(false);
|
nvmAvailable.resolve(false);
|
||||||
@@ -46,7 +46,7 @@ checkToolsAvailable();
|
|||||||
*/
|
*/
|
||||||
export let bash = async (commandArg: string, retryArg: number = 2): Promise<string> => {
|
export let bash = async (commandArg: string, retryArg: number = 2): Promise<string> => {
|
||||||
await nvmAvailable.promise; // make sure nvm check has run
|
await nvmAvailable.promise; // make sure nvm check has run
|
||||||
let execResult: plugins.smartshell.IExecResult;
|
let execResult!: plugins.smartshell.IExecResult;
|
||||||
|
|
||||||
// determine if we fail
|
// determine if we fail
|
||||||
let failOnError: boolean = true;
|
let failOnError: boolean = true;
|
||||||
@@ -55,13 +55,13 @@ export let bash = async (commandArg: string, retryArg: number = 2): Promise<stri
|
|||||||
retryArg = 0;
|
retryArg = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!Deno.env.get('NPMTS_TEST')) {
|
if (!Deno.env.get('SZCI_TEST')) {
|
||||||
// NPMTS_TEST is used during testing
|
// SZCI_TEST is used during testing
|
||||||
for (let i = 0; i <= retryArg; i++) {
|
for (let i = 0; i <= retryArg; i++) {
|
||||||
if (Deno.env.get('DEBUG_NPMCI') === 'true') {
|
if (Deno.env.get('DEBUG_SZCI') === 'true') {
|
||||||
console.log(commandArg);
|
console.log(commandArg);
|
||||||
}
|
}
|
||||||
execResult = await npmciSmartshell.exec(commandArg);
|
execResult = await szciSmartshell.exec(commandArg);
|
||||||
|
|
||||||
// determine how bash reacts to error and success
|
// determine how bash reacts to error and success
|
||||||
if (execResult.exitCode !== 0 && i === retryArg) {
|
if (execResult.exitCode !== 0 && i === retryArg) {
|
||||||
|
|||||||
@@ -19,19 +19,19 @@ import { SzciNpmManager } from './manager.npm/index.ts';
|
|||||||
|
|
||||||
export class Szci {
|
export class Szci {
|
||||||
public analytics: plugins.smartanalytics.Analytics;
|
public analytics: plugins.smartanalytics.Analytics;
|
||||||
public cloudlyConnector: CloudlyConnector;
|
public cloudlyConnector!: CloudlyConnector;
|
||||||
|
|
||||||
public npmciEnv: SzciEnv;
|
public szciEnv!: SzciEnv;
|
||||||
public npmciInfo: SzciInfo;
|
public szciInfo!: SzciInfo;
|
||||||
public npmciConfig: SzciConfig;
|
public szciConfig!: SzciConfig;
|
||||||
public npmciCli: SzciCli;
|
public szciCli!: SzciCli;
|
||||||
|
|
||||||
// managers
|
// managers
|
||||||
public cloudronManager: SzciCloudronManager;
|
public cloudronManager!: SzciCloudronManager;
|
||||||
public dockerManager: SzciDockerManager;
|
public dockerManager!: SzciDockerManager;
|
||||||
public gitManager: SzciGitManager;
|
public gitManager!: SzciGitManager;
|
||||||
public nodejsManager: SzciNodeJsManager;
|
public nodejsManager!: SzciNodeJsManager;
|
||||||
public npmManager: SzciNpmManager;
|
public npmManager!: SzciNpmManager;
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
this.analytics = new plugins.smartanalytics.Analytics({
|
this.analytics = new plugins.smartanalytics.Analytics({
|
||||||
@@ -43,12 +43,12 @@ export class Szci {
|
|||||||
|
|
||||||
public async start() {
|
public async start() {
|
||||||
this.cloudlyConnector = new CloudlyConnector(this);
|
this.cloudlyConnector = new CloudlyConnector(this);
|
||||||
this.npmciEnv = new SzciEnv(this);
|
this.szciEnv = new SzciEnv(this);
|
||||||
this.npmciInfo = new SzciInfo(this);
|
this.szciInfo = new SzciInfo(this);
|
||||||
await this.npmciInfo.printToConsole();
|
await this.szciInfo.printToConsole();
|
||||||
this.npmciCli = new SzciCli(this);
|
this.szciCli = new SzciCli(this);
|
||||||
this.npmciConfig = new SzciConfig(this);
|
this.szciConfig = new SzciConfig(this);
|
||||||
await this.npmciConfig.init();
|
await this.szciConfig.init();
|
||||||
|
|
||||||
// managers
|
// managers
|
||||||
this.cloudronManager = new SzciCloudronManager(this);
|
this.cloudronManager = new SzciCloudronManager(this);
|
||||||
@@ -56,6 +56,6 @@ export class Szci {
|
|||||||
this.gitManager = new SzciGitManager(this);
|
this.gitManager = new SzciGitManager(this);
|
||||||
this.nodejsManager = new SzciNodeJsManager(this);
|
this.nodejsManager = new SzciNodeJsManager(this);
|
||||||
this.npmManager = new SzciNpmManager(this);
|
this.npmManager = new SzciNpmManager(this);
|
||||||
this.npmciCli.startParse();
|
this.szciCli.startParse();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,12 +10,12 @@ export class SzciCli {
|
|||||||
constructor(szciArg: Szci) {
|
constructor(szciArg: Szci) {
|
||||||
this.szciRef = szciArg;
|
this.szciRef = szciArg;
|
||||||
this.smartcli = new plugins.smartcli.Smartcli();
|
this.smartcli = new plugins.smartcli.Smartcli();
|
||||||
this.smartcli.addVersion(this.szciRef.npmciInfo.version);
|
this.smartcli.addVersion(this.szciRef.szciInfo.version);
|
||||||
|
|
||||||
// clean
|
// clean
|
||||||
this.smartcli.addCommand('clean').subscribe(
|
this.smartcli.addCommand('clean').subscribe(
|
||||||
async (argv) => {
|
async (argv) => {
|
||||||
const modClean = await import('./mod_clean/index.js');
|
const modClean = await import('./mod_clean/index.ts');
|
||||||
await modClean.clean();
|
await modClean.clean();
|
||||||
},
|
},
|
||||||
(err) => {
|
(err) => {
|
||||||
@@ -38,7 +38,7 @@ export class SzciCli {
|
|||||||
// command
|
// command
|
||||||
this.smartcli.addCommand('command').subscribe(
|
this.smartcli.addCommand('command').subscribe(
|
||||||
async (argv) => {
|
async (argv) => {
|
||||||
const modCommand = await import('./mod_command/index.js');
|
const modCommand = await import('./mod_command/index.ts');
|
||||||
await modCommand.command();
|
await modCommand.command();
|
||||||
},
|
},
|
||||||
(err) => {
|
(err) => {
|
||||||
@@ -91,20 +91,20 @@ export class SzciCli {
|
|||||||
);
|
);
|
||||||
|
|
||||||
this.smartcli.addCommand('precheck').subscribe(async (argvArg) => {
|
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);
|
await modPrecheck.handleCli(this.szciRef, argvArg);
|
||||||
});
|
});
|
||||||
|
|
||||||
// trigger
|
// trigger
|
||||||
this.smartcli.addCommand('ssh').subscribe(async (argvArg) => {
|
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);
|
await modSsh.handleCli(argvArg);
|
||||||
});
|
});
|
||||||
|
|
||||||
// trigger
|
// trigger
|
||||||
this.smartcli.addCommand('trigger').subscribe(
|
this.smartcli.addCommand('trigger').subscribe(
|
||||||
async (argv) => {
|
async (argv) => {
|
||||||
const modTrigger = await import('./mod_trigger/index.js');
|
const modTrigger = await import('./mod_trigger/index.ts');
|
||||||
await modTrigger.trigger();
|
await modTrigger.trigger();
|
||||||
},
|
},
|
||||||
(err) => {
|
(err) => {
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import { logger } from './szci.logging.ts';
|
|||||||
import { Szci } from './szci.classes.szci.ts';
|
import { Szci } from './szci.classes.szci.ts';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* the main config interface for npmci
|
* the main config interface for szci
|
||||||
*/
|
*/
|
||||||
export interface ISzciOptions {
|
export interface ISzciOptions {
|
||||||
projectInfo: plugins.projectinfo.ProjectInfo;
|
projectInfo: plugins.projectinfo.ProjectInfo;
|
||||||
@@ -24,35 +24,35 @@ export interface ISzciOptions {
|
|||||||
gitlabRunnerTags: string[];
|
gitlabRunnerTags: string[];
|
||||||
|
|
||||||
// urls
|
// urls
|
||||||
urlCloudly: string;
|
urlCloudly?: string;
|
||||||
|
|
||||||
// cloudron
|
// cloudron
|
||||||
cloudronAppName?: string;
|
cloudronAppName?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* a config class for Npmci
|
* a config class for Szci
|
||||||
*/
|
*/
|
||||||
export class SzciConfig {
|
export class SzciConfig {
|
||||||
public szciRef: Szci;
|
public szciRef: Szci;
|
||||||
|
|
||||||
public npmciNpmextra: plugins.npmextra.Npmextra;
|
public szciNpmextra!: plugins.npmextra.Npmextra;
|
||||||
public kvStorage: plugins.npmextra.KeyValueStore;
|
public kvStorage!: plugins.npmextra.KeyValueStore;
|
||||||
public npmciQenv: plugins.qenv.Qenv;
|
public szciQenv!: plugins.qenv.Qenv;
|
||||||
|
|
||||||
private configObject: ISzciOptions;
|
private configObject!: ISzciOptions;
|
||||||
|
|
||||||
constructor(szciRefArg: Szci) {
|
constructor(szciRefArg: Szci) {
|
||||||
this.szciRef = szciRefArg;
|
this.szciRef = szciRefArg;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async init() {
|
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({
|
this.kvStorage = new plugins.npmextra.KeyValueStore({
|
||||||
typeArg: 'userHomeDir',
|
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.SzciProjectDir,
|
||||||
paths.SzciProjectNogitDir,
|
paths.SzciProjectNogitDir,
|
||||||
false
|
false
|
||||||
@@ -67,9 +67,9 @@ export class SzciConfig {
|
|||||||
npmRegistryUrl: 'registry.npmjs.org',
|
npmRegistryUrl: 'registry.npmjs.org',
|
||||||
gitlabRunnerTags: [],
|
gitlabRunnerTags: [],
|
||||||
dockerBuildargEnvMap: {},
|
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 {
|
public getConfig(): ISzciOptions {
|
||||||
|
|||||||
@@ -9,15 +9,17 @@ export class SzciEnv {
|
|||||||
|
|
||||||
constructor(szciRefArg: Szci) {
|
constructor(szciRefArg: Szci) {
|
||||||
this.szciRef = szciRefArg;
|
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")) {
|
if (!repoUrl && Deno.env.get("SZCI_COMPUTED_REPOURL")) {
|
||||||
this.repoString = Deno.env.get("NPMCI_COMPUTED_REPOURL");
|
repoUrl = Deno.env.get("SZCI_COMPUTED_REPOURL");
|
||||||
}
|
|
||||||
if (!this.repoString) {
|
|
||||||
this.repoString = 'https://undefined:undefined@github.com/undefined/undefined.git';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.repoString = repoUrl || 'https://undefined:undefined@github.com/undefined/undefined.git';
|
||||||
this.repo = new plugins.smartstring.GitRepo(this.repoString);
|
this.repo = new plugins.smartstring.GitRepo(this.repoString);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ export const logger = new plugins.smartlog.Smartlog({
|
|||||||
companyunit: 'Some Unit',
|
companyunit: 'Some Unit',
|
||||||
containerName: 'Some ContainerName',
|
containerName: 'Some ContainerName',
|
||||||
environment: 'test',
|
environment: 'test',
|
||||||
runtime: 'node',
|
runtime: 'deno',
|
||||||
zone: 'Some Zone',
|
zone: 'Some Zone',
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -13,4 +13,4 @@ export const SzciPackageConfig = plugins.path.join(SzciPackageRoot, './config.js
|
|||||||
export const SzciProjectDir = cwd;
|
export const SzciProjectDir = cwd;
|
||||||
export const SzciProjectNogitDir = plugins.path.join(SzciProjectDir, './.nogit');
|
export const SzciProjectNogitDir = plugins.path.join(SzciProjectDir, './.nogit');
|
||||||
export const SzciTestDir = plugins.path.join(cwd, './test');
|
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');
|
||||||
|
|||||||
Reference in New Issue
Block a user