BREAKING CHANGE(szci): Rename project from npmci to szci and migrate runtime to Deno; add compiled binaries, installer and wrapper; update imports, env handling and package metadata
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
* autocreated commitinfo by @push.rocks/commitinfo
|
||||
*/
|
||||
export const commitinfo = {
|
||||
name: '@ship.zone/npmci',
|
||||
version: '4.1.37',
|
||||
description: 'A tool to streamline Node.js and Docker workflows within CI environments, particularly GitLab CI, providing various CI/CD utilities.'
|
||||
name: '@ship.zone/szci',
|
||||
version: '6.0.0',
|
||||
description: 'Serve Zone CI - A tool to streamline Node.js and Docker workflows within CI environments, particularly GitLab CI, providing various CI/CD utilities. Powered by Deno with standalone executables.'
|
||||
}
|
||||
|
||||
@@ -1,23 +1,23 @@
|
||||
import * as plugins from '../npmci.plugins.js';
|
||||
import * as plugins from '../szci.plugins.ts';
|
||||
|
||||
import { Npmci } from '../npmci.classes.npmci.js';
|
||||
import { logger } from '../npmci.logging.js';
|
||||
import { Szci } from '../szci.classes.szci.ts';
|
||||
import { logger } from '../szci.logging.ts';
|
||||
|
||||
/**
|
||||
* connects to cloudly
|
||||
*/
|
||||
export class CloudlyConnector {
|
||||
public npmciRef: Npmci;
|
||||
public szciRef: Szci;
|
||||
|
||||
constructor(npmciRefArg: Npmci) {
|
||||
this.npmciRef = npmciRefArg;
|
||||
constructor(szciRefArg: Szci) {
|
||||
this.szciRef = szciRefArg;
|
||||
}
|
||||
|
||||
public async announceDockerContainer(
|
||||
optionsArg: plugins.tsclass.container.IContainer,
|
||||
testCloudlyUrlArg?: string
|
||||
) {
|
||||
const cloudlyUrl = testCloudlyUrlArg || this.npmciRef.npmciConfig.getConfig().urlCloudly;
|
||||
const cloudlyUrl = testCloudlyUrlArg || this.szciRef.npmciConfig.getConfig().urlCloudly;
|
||||
if (!cloudlyUrl) {
|
||||
logger.log(
|
||||
'warn',
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import { Npmci } from './npmci.classes.npmci.js';
|
||||
import { Dockerfile } from './manager.docker/mod.classes.dockerfile.js';
|
||||
import { Szci } from './szci.classes.szci.ts';
|
||||
import { Dockerfile } from './manager.docker/mod.classes.dockerfile.ts';
|
||||
|
||||
export const npmciInstance = new Npmci();
|
||||
export const szciInstance = new Npmci();
|
||||
|
||||
export { Dockerfile, Npmci };
|
||||
|
||||
export const runCli = async () => {
|
||||
await npmciInstance.start();
|
||||
await szciInstance.start();
|
||||
};
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
import { logger } from '../npmci.logging.js';
|
||||
import * as plugins from './mod.plugins.js';
|
||||
import * as paths from '../npmci.paths.js';
|
||||
import { bash } from '../npmci.bash.js';
|
||||
import { Npmci } from '../npmci.classes.npmci.js';
|
||||
import { logger } from '../szci.logging.ts';
|
||||
import * as plugins from './mod.plugins.ts';
|
||||
import * as paths from '../szci.paths.ts';
|
||||
import { bash } from '../szci.bash.ts';
|
||||
import { Szci } from '../szci.classes.szci.ts';
|
||||
|
||||
export class NpmciCloudronManager {
|
||||
public npmciRef: Npmci;
|
||||
export class SzciCloudronManager {
|
||||
public szciRef: Szci;
|
||||
|
||||
constructor(npmciArg: Npmci) {
|
||||
this.npmciRef = npmciArg;
|
||||
constructor(szciArg: Szci) {
|
||||
this.szciRef = szciArg;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -44,14 +44,14 @@ export class NpmciCloudronManager {
|
||||
logger.log('ok', 'cloudron cli installed');
|
||||
|
||||
// lets set the version in the CloudronManifest file
|
||||
await this.prepareCloudronManifest(this.npmciRef.npmciConfig.getConfig().projectInfo.npm.version);
|
||||
await this.prepareCloudronManifest(this.szciRef.npmciConfig.getConfig().projectInfo.npm.version);
|
||||
logger.log('ok', 'CloudronManifest prepared');
|
||||
|
||||
// lets figure out the docker image tag
|
||||
const dockerImageTag = await this.npmciRef.npmciConfig.kvStorage.readKey('latestPushedDockerTag');
|
||||
const appName = this.npmciRef.npmciConfig.getConfig().cloudronAppName;
|
||||
const dockerImageTag = await this.szciRef.npmciConfig.kvStorage.readKey('latestPushedDockerTag');
|
||||
const appName = this.szciRef.npmciConfig.getConfig().cloudronAppName;
|
||||
|
||||
const cloudronEnvVar = process.env.NPMCI_LOGIN_CLOUDRON;
|
||||
const cloudronEnvVar = Deno.env.get("NPMCI_LOGIN_CLOUDRON");
|
||||
const cloudronServer = cloudronEnvVar.split('|')[0];
|
||||
const cloudronToken = cloudronEnvVar.split('|')[1];
|
||||
await bash(`cloudron update --server ${cloudronServer} --token ${cloudronToken} --image ${dockerImageTag} --app ${appName}`);
|
||||
|
||||
@@ -1 +1 @@
|
||||
export * from '../npmci.plugins.js';
|
||||
export * from '../szci.plugins.ts';
|
||||
@@ -1,20 +1,20 @@
|
||||
import { logger } from '../npmci.logging.js';
|
||||
import * as plugins from './mod.plugins.js';
|
||||
import * as paths from '../npmci.paths.js';
|
||||
import { bash } from '../npmci.bash.js';
|
||||
import { logger } from '../szci.logging.ts';
|
||||
import * as plugins from './mod.plugins.ts';
|
||||
import * as paths from '../szci.paths.ts';
|
||||
import { bash } from '../szci.bash.ts';
|
||||
|
||||
// classes
|
||||
import { Npmci } from '../npmci.classes.npmci.js';
|
||||
import { Dockerfile } from './mod.classes.dockerfile.js';
|
||||
import { DockerRegistry } from './mod.classes.dockerregistry.js';
|
||||
import { RegistryStorage } from './mod.classes.registrystorage.js';
|
||||
import { Szci } from '../szci.classes.szci.ts';
|
||||
import { Dockerfile } from './mod.classes.dockerfile.ts';
|
||||
import { DockerRegistry } from './mod.classes.dockerregistry.ts';
|
||||
import { RegistryStorage } from './mod.classes.registrystorage.ts';
|
||||
|
||||
export class NpmciDockerManager {
|
||||
public npmciRef: Npmci;
|
||||
export class SzciDockerManager {
|
||||
public szciRef: Szci;
|
||||
public npmciRegistryStorage = new RegistryStorage();
|
||||
|
||||
constructor(npmciArg: Npmci) {
|
||||
this.npmciRef = npmciArg;
|
||||
constructor(szciArg: Szci) {
|
||||
this.szciRef = szciArg;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -77,24 +77,24 @@ export class NpmciDockerManager {
|
||||
*/
|
||||
public prepare = async () => {
|
||||
// Always login to GitLab Registry
|
||||
if (process.env.GITLAB_CI) {
|
||||
if (Deno.env.get("GITLAB_CI")) {
|
||||
console.log('gitlab ci detected');
|
||||
if (!process.env.CI_JOB_TOKEN || process.env.CI_JOB_TOKEN === '') {
|
||||
if (!Deno.env.get("CI_JOB_TOKEN") || Deno.env.get("CI_JOB_TOKEN") === '') {
|
||||
logger.log('error', 'Running in Gitlab CI, but no registry token specified by gitlab!');
|
||||
process.exit(1);
|
||||
Deno.exit(1);
|
||||
}
|
||||
this.npmciRegistryStorage.addRegistry(
|
||||
new DockerRegistry({
|
||||
registryUrl: 'registry.gitlab.com',
|
||||
username: 'gitlab-ci-token',
|
||||
password: process.env.CI_JOB_TOKEN,
|
||||
password: Deno.env.get("CI_JOB_TOKEN"),
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
// handle registries
|
||||
await plugins.smartobject.forEachMinimatch(
|
||||
process.env,
|
||||
Deno.env.toObject(),
|
||||
'NPMCI_LOGIN_DOCKER*',
|
||||
async (envString: string) => {
|
||||
this.npmciRegistryStorage.addRegistry(DockerRegistry.fromEnvString(envString));
|
||||
@@ -115,14 +115,14 @@ export class NpmciDockerManager {
|
||||
if (argvArg._.length >= 3 && argvArg._[2] !== 'npmextra') {
|
||||
dockerRegistryUrls.push(argvArg._[2]);
|
||||
} else {
|
||||
if (this.npmciRef.npmciConfig.getConfig().dockerRegistries.length === 0) {
|
||||
if (this.szciRef.npmciConfig.getConfig().dockerRegistries.length === 0) {
|
||||
logger.log(
|
||||
'warn',
|
||||
`There are no docker registries listed in npmextra.json! This is strange!`
|
||||
);
|
||||
}
|
||||
dockerRegistryUrls = dockerRegistryUrls.concat(
|
||||
this.npmciRef.npmciConfig.getConfig().dockerRegistries
|
||||
this.szciRef.npmciConfig.getConfig().dockerRegistries
|
||||
);
|
||||
}
|
||||
|
||||
@@ -145,7 +145,7 @@ export class NpmciDockerManager {
|
||||
'error',
|
||||
`Cannot push to registry ${dockerRegistryUrl}, because it was not found in the authenticated registry list.`
|
||||
);
|
||||
process.exit(1);
|
||||
Deno.exit(1);
|
||||
}
|
||||
for (const dockerfile of dockerfileArray) {
|
||||
await dockerfile.push(dockerRegistryToPushTo, suffix);
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
import * as plugins from './mod.plugins.js';
|
||||
import * as paths from '../npmci.paths.js';
|
||||
import * as plugins from './mod.plugins.ts';
|
||||
import * as paths from '../szci.paths.ts';
|
||||
|
||||
import { logger } from '../npmci.logging.js';
|
||||
import { bash } from '../npmci.bash.js';
|
||||
import { logger } from '../szci.logging.ts';
|
||||
import { bash } from '../szci.bash.ts';
|
||||
|
||||
import { DockerRegistry } from './mod.classes.dockerregistry.js';
|
||||
import * as helpers from './mod.helpers.js';
|
||||
import { NpmciDockerManager } from './index.js';
|
||||
import { Npmci } from '../npmci.classes.npmci.js';
|
||||
import { DockerRegistry } from './mod.classes.dockerregistry.ts';
|
||||
import * as helpers from './mod.helpers.ts';
|
||||
import { SzciDockerManager } from './index.ts';
|
||||
import { Szci } from '../szci.classes.szci.ts';
|
||||
|
||||
/**
|
||||
* class Dockerfile represents a Dockerfile on disk in npmci
|
||||
@@ -20,7 +20,7 @@ export class Dockerfile {
|
||||
* @returns Promise<Dockerfile[]>
|
||||
*/
|
||||
public static async readDockerfiles(
|
||||
npmciDockerManagerRefArg: NpmciDockerManager
|
||||
npmciDockerManagerRefArg: SzciDockerManager
|
||||
): Promise<Dockerfile[]> {
|
||||
const fileTree = await plugins.smartfile.fs.listFileTree(paths.cwd, 'Dockerfile*');
|
||||
|
||||
@@ -167,7 +167,7 @@ export class Dockerfile {
|
||||
}
|
||||
versionString = versionString.replace(
|
||||
'##version##',
|
||||
dockerfileInstanceArg.npmciDockerManagerRef.npmciRef.npmciConfig.getConfig().projectInfo.npm
|
||||
dockerfileInstanceArg.npmciDockerManagerRef.szciRef.npmciConfig.getConfig().projectInfo.npm
|
||||
.version
|
||||
);
|
||||
return versionString;
|
||||
@@ -194,7 +194,7 @@ export class Dockerfile {
|
||||
const argMatch = trimmedLine.match(/^ARG\s+([^\s=]+)(?:=(.*))?$/i);
|
||||
if (argMatch) {
|
||||
const argName = argMatch[1];
|
||||
const argValue = argMatch[2] !== undefined ? argMatch[2] : process.env[argName] || '';
|
||||
const argValue = argMatch[2] !== undefined ? argMatch[2] : Deno.env.get(argName) || '';
|
||||
args[argName] = argValue;
|
||||
continue;
|
||||
}
|
||||
@@ -236,7 +236,7 @@ export class Dockerfile {
|
||||
* returns the docker tag
|
||||
*/
|
||||
public static getDockerTagString(
|
||||
npmciDockerManagerRef: NpmciDockerManager,
|
||||
npmciDockerManagerRef: SzciDockerManager,
|
||||
registryArg: string,
|
||||
repoArg: string,
|
||||
versionArg: string,
|
||||
@@ -244,7 +244,7 @@ export class Dockerfile {
|
||||
): string {
|
||||
// determine wether the repo should be mapped accordingly to the registry
|
||||
const mappedRepo =
|
||||
npmciDockerManagerRef.npmciRef.npmciConfig.getConfig().dockerRegistryRepoMap[registryArg];
|
||||
npmciDockerManagerRef.szciRef.npmciConfig.getConfig().dockerRegistryRepoMap[registryArg];
|
||||
const repo = (() => {
|
||||
if (mappedRepo) {
|
||||
return mappedRepo;
|
||||
@@ -264,27 +264,27 @@ export class Dockerfile {
|
||||
}
|
||||
|
||||
public static async getDockerBuildArgs(
|
||||
npmciDockerManagerRef: NpmciDockerManager
|
||||
npmciDockerManagerRef: SzciDockerManager
|
||||
): Promise<string> {
|
||||
logger.log('info', 'checking for env vars to be supplied to the docker build');
|
||||
let buildArgsString: string = '';
|
||||
for (const dockerArgKey of Object.keys(
|
||||
npmciDockerManagerRef.npmciRef.npmciConfig.getConfig().dockerBuildargEnvMap
|
||||
npmciDockerManagerRef.szciRef.npmciConfig.getConfig().dockerBuildargEnvMap
|
||||
)) {
|
||||
const dockerArgOuterEnvVar =
|
||||
npmciDockerManagerRef.npmciRef.npmciConfig.getConfig().dockerBuildargEnvMap[dockerArgKey];
|
||||
npmciDockerManagerRef.szciRef.npmciConfig.getConfig().dockerBuildargEnvMap[dockerArgKey];
|
||||
logger.log(
|
||||
'note',
|
||||
`docker ARG "${dockerArgKey}" maps to outer env var "${dockerArgOuterEnvVar}"`
|
||||
);
|
||||
const targetValue = process.env[dockerArgOuterEnvVar];
|
||||
const targetValue = Deno.env.get(dockerArgOuterEnvVar);
|
||||
buildArgsString = `${buildArgsString} --build-arg ${dockerArgKey}="${targetValue}"`;
|
||||
}
|
||||
return buildArgsString;
|
||||
}
|
||||
|
||||
// INSTANCE
|
||||
public npmciDockerManagerRef: NpmciDockerManager;
|
||||
public npmciDockerManagerRef: SzciDockerManager;
|
||||
|
||||
public filePath: string;
|
||||
public repo: string;
|
||||
@@ -299,15 +299,15 @@ export class Dockerfile {
|
||||
public localBaseDockerfile: Dockerfile;
|
||||
|
||||
constructor(
|
||||
dockerManagerRefArg: NpmciDockerManager,
|
||||
dockerManagerRefArg: SzciDockerManager,
|
||||
options: { filePath?: string; fileContents?: string | Buffer; read?: boolean }
|
||||
) {
|
||||
this.npmciDockerManagerRef = dockerManagerRefArg;
|
||||
this.filePath = options.filePath;
|
||||
this.repo =
|
||||
this.npmciDockerManagerRef.npmciRef.npmciEnv.repo.user +
|
||||
this.npmciDockerManagerRef.szciRef.npmciEnv.repo.user +
|
||||
'/' +
|
||||
this.npmciDockerManagerRef.npmciRef.npmciEnv.repo.repo;
|
||||
this.npmciDockerManagerRef.szciRef.npmciEnv.repo.repo;
|
||||
this.version = Dockerfile.dockerFileVersion(this, plugins.path.parse(options.filePath).base);
|
||||
this.cleanTag = this.repo + ':' + this.version;
|
||||
this.buildTag = this.cleanTag;
|
||||
@@ -327,7 +327,7 @@ export class Dockerfile {
|
||||
logger.log('info', 'now building Dockerfile for ' + this.cleanTag);
|
||||
const buildArgsString = await Dockerfile.getDockerBuildArgs(this.npmciDockerManagerRef);
|
||||
const buildCommand = `docker build --label="version=${
|
||||
this.npmciDockerManagerRef.npmciRef.npmciConfig.getConfig().projectInfo.npm.version
|
||||
this.npmciDockerManagerRef.szciRef.npmciConfig.getConfig().projectInfo.npm.version
|
||||
}" -t ${this.buildTag} -f ${this.filePath} ${buildArgsString} .`;
|
||||
await bash(buildCommand);
|
||||
return;
|
||||
@@ -350,13 +350,13 @@ export class Dockerfile {
|
||||
await bash(`docker inspect --format="{{index .RepoDigests 0}}" ${this.pushTag}`)
|
||||
).split('@')[1];
|
||||
console.log(`The image ${this.pushTag} has digest ${imageDigest}`);
|
||||
await this.npmciDockerManagerRef.npmciRef.cloudlyConnector.announceDockerContainer({
|
||||
await this.npmciDockerManagerRef.szciRef.cloudlyConnector.announceDockerContainer({
|
||||
registryUrl: this.pushTag,
|
||||
tag: this.buildTag,
|
||||
labels: [],
|
||||
version: this.npmciDockerManagerRef.npmciRef.npmciConfig.getConfig().projectInfo.npm.version,
|
||||
version: this.npmciDockerManagerRef.szciRef.npmciConfig.getConfig().projectInfo.npm.version,
|
||||
});
|
||||
await this.npmciDockerManagerRef.npmciRef.npmciConfig.kvStorage.writeKey(
|
||||
await this.npmciDockerManagerRef.szciRef.npmciConfig.kvStorage.writeKey(
|
||||
'latestPushedDockerTag',
|
||||
this.pushTag
|
||||
);
|
||||
@@ -381,7 +381,7 @@ export class Dockerfile {
|
||||
* tests the Dockerfile;
|
||||
*/
|
||||
public async test() {
|
||||
const testFile: string = plugins.path.join(paths.NpmciTestDir, 'test_' + this.version + '.sh');
|
||||
const testFile: string = plugins.path.join(paths.SzciTestDir, 'test_' + this.version + '.sh');
|
||||
const testFileExists: boolean = plugins.smartfile.fs.fileExistsSync(testFile);
|
||||
if (testFileExists) {
|
||||
// run tests
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { logger } from '../npmci.logging.js';
|
||||
import * as plugins from './mod.plugins.js';
|
||||
import { bash } from '../npmci.bash.js';
|
||||
import { logger } from '../szci.logging.ts';
|
||||
import * as plugins from './mod.plugins.ts';
|
||||
import { bash } from '../szci.bash.ts';
|
||||
|
||||
export interface IDockerRegistryConstructorOptions {
|
||||
registryUrl: string;
|
||||
@@ -23,7 +23,7 @@ export class DockerRegistry {
|
||||
const dockerRegexResultArray = envString.split('|');
|
||||
if (dockerRegexResultArray.length !== 3) {
|
||||
logger.log('error', 'malformed docker env var...');
|
||||
process.exit(1);
|
||||
Deno.exit(1);
|
||||
return;
|
||||
}
|
||||
const registryUrl = dockerRegexResultArray[0].replace('https://', '').replace('http://', '');
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { logger } from '../npmci.logging.js';
|
||||
import * as plugins from './mod.plugins.js';
|
||||
import { logger } from '../szci.logging.ts';
|
||||
import * as plugins from './mod.plugins.ts';
|
||||
|
||||
import { DockerRegistry } from './mod.classes.dockerregistry.js';
|
||||
import { DockerRegistry } from './mod.classes.dockerregistry.ts';
|
||||
|
||||
export class RegistryStorage {
|
||||
objectMap = new plugins.lik.ObjectMap<DockerRegistry>();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { logger } from '../npmci.logging.js';
|
||||
import * as plugins from './mod.plugins.js';
|
||||
import * as paths from '../npmci.paths.js';
|
||||
import { logger } from '../szci.logging.ts';
|
||||
import * as plugins from './mod.plugins.ts';
|
||||
import * as paths from '../szci.paths.ts';
|
||||
|
||||
import { Dockerfile } from './mod.classes.dockerfile.js';
|
||||
import { Dockerfile } from './mod.classes.dockerfile.ts';
|
||||
|
||||
@@ -1 +1 @@
|
||||
export * from '../npmci.plugins.js';
|
||||
export * from '../szci.plugins.ts';
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
import { logger } from '../npmci.logging.js';
|
||||
import * as plugins from './mod.plugins.js';
|
||||
import { bash, bashNoError } from '../npmci.bash.js';
|
||||
import { Npmci } from '../npmci.classes.npmci.js';
|
||||
import { logger } from '../szci.logging.ts';
|
||||
import * as plugins from './mod.plugins.ts';
|
||||
import { bash, bashNoError } from '../szci.bash.ts';
|
||||
import { Szci } from '../szci.classes.szci.ts';
|
||||
|
||||
export class NpmciGitManager {
|
||||
public npmciRef: Npmci;
|
||||
export class SzciGitManager {
|
||||
public szciRef: Szci;
|
||||
|
||||
constructor(npmciRefArg: Npmci) {
|
||||
this.npmciRef = npmciRefArg;
|
||||
constructor(szciRefArg: Szci) {
|
||||
this.szciRef = szciRefArg;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -30,12 +30,12 @@ export class NpmciGitManager {
|
||||
};
|
||||
|
||||
public mirror = async () => {
|
||||
const githubToken = process.env.NPMCI_GIT_GITHUBTOKEN;
|
||||
const githubUser = process.env.NPMCI_GIT_GITHUBGROUP || this.npmciRef.npmciEnv.repo.user;
|
||||
const githubRepo = process.env.NPMCI_GIT_GITHUB || this.npmciRef.npmciEnv.repo.repo;
|
||||
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;
|
||||
if (
|
||||
this.npmciRef.npmciConfig.getConfig().projectInfo.npm.packageJson.private === true ||
|
||||
this.npmciRef.npmciConfig.getConfig().npmAccessLevel === 'private'
|
||||
this.szciRef.npmciConfig.getConfig().projectInfo.npm.packageJson.private === true ||
|
||||
this.szciRef.npmciConfig.getConfig().npmAccessLevel === 'private'
|
||||
) {
|
||||
logger.log(
|
||||
'warn',
|
||||
@@ -65,7 +65,7 @@ export class NpmciGitManager {
|
||||
await bashNoError('git remote rm mirror');
|
||||
} else {
|
||||
logger.log('error', `cannot find NPMCI_GIT_GITHUBTOKEN env var!`);
|
||||
process.exit(1);
|
||||
Deno.exit(1);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1 +1 @@
|
||||
export * from '../npmci.plugins.js';
|
||||
export * from '../szci.plugins.ts';
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
import * as plugins from '../npmci.plugins.js';
|
||||
import * as paths from '../npmci.paths.js';
|
||||
import * as plugins from '../szci.plugins.ts';
|
||||
import * as paths from '../szci.paths.ts';
|
||||
|
||||
import { logger } from '../npmci.logging.js';
|
||||
import { bash, bashNoError, nvmAvailable } from '../npmci.bash.js';
|
||||
import { Npmci } from '../npmci.classes.npmci.js';
|
||||
import { logger } from '../szci.logging.ts';
|
||||
import { bash, bashNoError, nvmAvailable } from '../szci.bash.ts';
|
||||
import { Szci } from '../szci.classes.szci.ts';
|
||||
|
||||
export class NpmciNodeJsManager {
|
||||
public npmciRef: Npmci;
|
||||
export class SzciNodeJsManager {
|
||||
public szciRef: Szci;
|
||||
|
||||
constructor(npmciRefArg: Npmci) {
|
||||
this.npmciRef = npmciRefArg;
|
||||
constructor(szciRefArg: Szci) {
|
||||
this.szciRef = szciRefArg;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -25,14 +25,14 @@ export class NpmciNodeJsManager {
|
||||
break;
|
||||
default:
|
||||
logger.log('error', `>>npmci node ...<< action >>${action}<< not supported`);
|
||||
process.exit(1);
|
||||
Deno.exit(1);
|
||||
}
|
||||
} else {
|
||||
logger.log(
|
||||
'error',
|
||||
`>>npmci node ...<< cli arguments invalid... Please read the documentation.`
|
||||
);
|
||||
process.exit(1);
|
||||
Deno.exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -64,7 +64,7 @@ export class NpmciNodeJsManager {
|
||||
await bash('npm -v');
|
||||
|
||||
// lets look for further config
|
||||
const config = await this.npmciRef.npmciConfig.getConfig();
|
||||
const config = await this.szciRef.npmciConfig.getConfig();
|
||||
logger.log('info', 'Now checking for needed global npm tools...');
|
||||
for (const npmTool of config.npmGlobalTools) {
|
||||
logger.log('info', `Checking for global "${npmTool}"`);
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
import * as plugins from './mod.plugins.js';
|
||||
import * as paths from '../npmci.paths.js';
|
||||
import * as plugins from './mod.plugins.ts';
|
||||
import * as paths from '../szci.paths.ts';
|
||||
|
||||
import { logger } from '../npmci.logging.js';
|
||||
import { bash, bashNoError, nvmAvailable } from '../npmci.bash.js';
|
||||
import { Npmci } from '../npmci.classes.npmci.js';
|
||||
import { logger } from '../szci.logging.ts';
|
||||
import { bash, bashNoError, nvmAvailable } from '../szci.bash.ts';
|
||||
import { Szci } from '../szci.classes.szci.ts';
|
||||
|
||||
export class NpmciNpmManager {
|
||||
public npmciRef: Npmci;
|
||||
export class SzciNpmManager {
|
||||
public szciRef: Szci;
|
||||
|
||||
constructor(npmciRefArg: Npmci) {
|
||||
this.npmciRef = npmciRefArg;
|
||||
constructor(szciRefArg: Szci) {
|
||||
this.szciRef = szciRefArg;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -37,14 +37,14 @@ export class NpmciNpmManager {
|
||||
break;
|
||||
default:
|
||||
logger.log('error', `>>npmci npm ...<< action >>${action}<< not supported`);
|
||||
process.exit(1);
|
||||
Deno.exit(1);
|
||||
}
|
||||
} else {
|
||||
logger.log(
|
||||
'info',
|
||||
`>>npmci npm ...<< cli arguments invalid... Please read the documentation.`
|
||||
);
|
||||
process.exit(1);
|
||||
Deno.exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -53,10 +53,10 @@ export class NpmciNpmManager {
|
||||
*/
|
||||
public async prepare() {
|
||||
logger.log('info', 'running >>npm prepare<<');
|
||||
const config = this.npmciRef.npmciConfig.getConfig();
|
||||
const config = this.szciRef.npmciConfig.getConfig();
|
||||
let npmrcFileString: string = '';
|
||||
await plugins.smartobject.forEachMinimatch(
|
||||
process.env,
|
||||
Deno.env.toObject(),
|
||||
'NPMCI_TOKEN_NPM*',
|
||||
(npmEnvArg: string) => {
|
||||
if (!npmEnvArg) {
|
||||
@@ -83,14 +83,14 @@ export class NpmciNpmManager {
|
||||
logger.log('info', 'found one or more access tokens');
|
||||
} else {
|
||||
logger.log('error', 'no access token found! Exiting!');
|
||||
process.exit(1);
|
||||
Deno.exit(1);
|
||||
}
|
||||
|
||||
// lets save it to disk
|
||||
plugins.smartfile.memory.toFsSync(npmrcFileString, '/root/.npmrc');
|
||||
|
||||
// lets set the cache directory
|
||||
await bash(`npm config set cache ${paths.NpmciCacheDir} --global `);
|
||||
await bash(`npm config set cache ${paths.SzciCacheDir} --global `);
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -103,10 +103,10 @@ export class NpmciNpmManager {
|
||||
let npmAccessCliString = ``;
|
||||
let npmRegistryCliString = ``;
|
||||
let publishVerdaccioAsWell = false;
|
||||
const config = this.npmciRef.npmciConfig.getConfig();
|
||||
const config = this.szciRef.npmciConfig.getConfig();
|
||||
const availableRegistries: string[] = [];
|
||||
await plugins.smartobject.forEachMinimatch(
|
||||
process.env,
|
||||
Deno.env.toObject(),
|
||||
'NPMCI_TOKEN_NPM*',
|
||||
(npmEnvArg: string) => {
|
||||
availableRegistries.push(npmEnvArg.split('|')[0]);
|
||||
@@ -127,7 +127,7 @@ export class NpmciNpmManager {
|
||||
npmRegistryCliString = `--registry=https://${config.npmRegistryUrl}`;
|
||||
} else {
|
||||
logger.log('error', `no registry url specified. Can't publish!`);
|
||||
process.exit(1);
|
||||
Deno.exit(1);
|
||||
}
|
||||
|
||||
let publishCommand = `npm publish ${npmAccessCliString} ${npmRegistryCliString} `;
|
||||
|
||||
@@ -1 +1 @@
|
||||
export * from '../npmci.plugins.js';
|
||||
export * from '../szci.plugins.ts';
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import * as plugins from './mod.plugins.js';
|
||||
import * as paths from '../npmci.paths.js';
|
||||
import * as plugins from './mod.plugins.ts';
|
||||
import * as paths from '../szci.paths.ts';
|
||||
|
||||
/**
|
||||
* cleans npmci config files
|
||||
*/
|
||||
export let clean = async (): Promise<void> => {
|
||||
plugins.smartfile.fs.removeSync(paths.NpmciPackageConfig);
|
||||
plugins.smartfile.fs.removeSync(paths.SzciPackageConfig);
|
||||
return;
|
||||
};
|
||||
|
||||
@@ -1 +1 @@
|
||||
export * from '../npmci.plugins.js';
|
||||
export * from '../szci.plugins.ts';
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import * as plugins from './mod.plugins.js';
|
||||
import { bash } from '../npmci.bash.js';
|
||||
import * as plugins from './mod.plugins.ts';
|
||||
import { bash } from '../szci.bash.ts';
|
||||
|
||||
export let command = async () => {
|
||||
let wrappedCommand: string = '';
|
||||
let argvArray = process.argv;
|
||||
let argvArray = ['deno', 'mod.ts', ...Deno.args];
|
||||
for (let i = 3; i < argvArray.length; i++) {
|
||||
wrappedCommand = wrappedCommand + argvArray[i];
|
||||
if (i + 1 !== argvArray.length) {
|
||||
|
||||
@@ -1 +1 @@
|
||||
export * from '../npmci.plugins.js';
|
||||
export * from '../szci.plugins.ts';
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
import * as plugins from './plugins.js';
|
||||
import * as paths from '../npmci.paths.js';
|
||||
import { logger } from '../npmci.logging.js';
|
||||
import { Npmci } from '../npmci.classes.npmci.js';
|
||||
import * as plugins from './plugins.ts';
|
||||
import * as paths from '../szci.paths.ts';
|
||||
import { logger } from '../szci.logging.ts';
|
||||
import { Szci } from '../szci.classes.szci.ts';
|
||||
|
||||
export const handleCli = async (npmciRefArg: Npmci, argvArg: any) => {
|
||||
export const handleCli = async (szciRefArg: Szci, argvArg: any) => {
|
||||
logger.log('info', 'checking execution context');
|
||||
const presentRunnerTags = process.env.CI_RUNNER_TAGS.split(',').map((stringArg) =>
|
||||
const presentRunnerTags = Deno.env.get("CI_RUNNER_TAGS").split(',').map((stringArg) =>
|
||||
stringArg.trim()
|
||||
);
|
||||
let allDesiredGitlabRunnerTagsPresent = true;
|
||||
for (const desiredRunnerTag of npmciRefArg.npmciConfig.getConfig().gitlabRunnerTags) {
|
||||
for (const desiredRunnerTag of szciRefArg.npmciConfig.getConfig().gitlabRunnerTags) {
|
||||
if (!presentRunnerTags.includes(desiredRunnerTag)) {
|
||||
allDesiredGitlabRunnerTagsPresent = false;
|
||||
logger.log(
|
||||
@@ -19,6 +19,6 @@ export const handleCli = async (npmciRefArg: Npmci, argvArg: any) => {
|
||||
}
|
||||
}
|
||||
if (!allDesiredGitlabRunnerTagsPresent) {
|
||||
process.exit(1);
|
||||
Deno.exit(1);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1 +1 @@
|
||||
export * from '../npmci.plugins.js';
|
||||
export * from '../szci.plugins.ts';
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { logger } from '../npmci.logging.js';
|
||||
import * as plugins from './mod.plugins.js';
|
||||
import { logger } from '../szci.logging.ts';
|
||||
import * as plugins from './mod.plugins.ts';
|
||||
let sshInstance: plugins.smartssh.SshInstance;
|
||||
|
||||
export let handleCli = async (argvArg: any) => {
|
||||
@@ -11,11 +11,11 @@ export let handleCli = async (argvArg: any) => {
|
||||
break;
|
||||
default:
|
||||
logger.log('error', `action >>${action}<< not supported`);
|
||||
process.exit(1);
|
||||
Deno.exit(1);
|
||||
}
|
||||
} else {
|
||||
logger.log('error', `>>npmci ssh ...<< please specify an action!`);
|
||||
process.exit(1);
|
||||
Deno.exit(1);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -31,8 +31,8 @@ const notUndefined = (stringArg: string) => {
|
||||
*/
|
||||
export let prepare = async () => {
|
||||
sshInstance = new plugins.smartssh.SshInstance(); // init ssh instance
|
||||
plugins.smartobject.forEachMinimatch(process.env, 'NPMCI_SSHKEY_*', evaluateSshEnv);
|
||||
if (!process.env.NPMTS_TEST) {
|
||||
plugins.smartobject.forEachMinimatch(Deno.env.toObject(), 'NPMCI_SSHKEY_*', evaluateSshEnv);
|
||||
if (!Deno.env.get("NPMTS_TEST")) {
|
||||
sshInstance.writeToDisk();
|
||||
} else {
|
||||
logger.log('info', 'In test mode, so not storing SSH keys to disk!');
|
||||
|
||||
@@ -1 +1 @@
|
||||
export * from '../npmci.plugins.js';
|
||||
export * from '../szci.plugins.ts';
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
import * as plugins from './mod.plugins.js';
|
||||
import { bash } from '../npmci.bash.js';
|
||||
import { logger } from '../npmci.logging.js';
|
||||
import * as plugins from './mod.plugins.ts';
|
||||
import { bash } from '../szci.bash.ts';
|
||||
import { logger } from '../szci.logging.ts';
|
||||
|
||||
const triggerValueRegex =
|
||||
/^([a-zA-Z0-9\.]*)\|([a-zA-Z0-9\.]*)\|([a-zA-Z0-9\.]*)\|([a-zA-Z0-9\.]*)\|?([a-zA-Z0-9\.\-\/]*)/;
|
||||
|
||||
export let trigger = async () => {
|
||||
logger.log('info', 'now running triggers');
|
||||
await plugins.smartobject.forEachMinimatch(process.env, 'NPMCI_TRIGGER_*', evaluateTrigger);
|
||||
await plugins.smartobject.forEachMinimatch(Deno.env.toObject(), 'NPMCI_TRIGGER_*', evaluateTrigger);
|
||||
};
|
||||
|
||||
const evaluateTrigger = async (triggerEnvVarArg) => {
|
||||
|
||||
@@ -1 +1 @@
|
||||
export * from '../npmci.plugins.js';
|
||||
export * from '../szci.plugins.ts';
|
||||
|
||||
@@ -1,61 +0,0 @@
|
||||
import * as plugins from './npmci.plugins.js';
|
||||
|
||||
|
||||
// env
|
||||
import { NpmciEnv } from './npmci.classes.npmcienv.js';
|
||||
import { NpmciInfo } from './npmci.classes.npmciinfo.js';
|
||||
import { NpmciCli } from './npmci.classes.npmcicli.js';
|
||||
import { NpmciConfig } from './npmci.classes.npmciconfig.js';
|
||||
|
||||
// connectors
|
||||
import { CloudlyConnector } from './connector.cloudly/cloudlyconnector.js';
|
||||
|
||||
// managers
|
||||
import { NpmciCloudronManager } from './manager.cloudron/index.js';
|
||||
import { NpmciDockerManager } from './manager.docker/index.js';
|
||||
import { NpmciGitManager } from './manager.git/index.js';
|
||||
import { NpmciNodeJsManager } from './manager.nodejs/index.js';
|
||||
import { NpmciNpmManager } from './manager.npm/index.js';
|
||||
|
||||
export class Npmci {
|
||||
public analytics: plugins.smartanalytics.Analytics;
|
||||
public cloudlyConnector: CloudlyConnector;
|
||||
|
||||
public npmciEnv: NpmciEnv;
|
||||
public npmciInfo: NpmciInfo;
|
||||
public npmciConfig: NpmciConfig;
|
||||
public npmciCli: NpmciCli;
|
||||
|
||||
// managers
|
||||
public cloudronManager: NpmciCloudronManager;
|
||||
public dockerManager: NpmciDockerManager;
|
||||
public gitManager: NpmciGitManager;
|
||||
public nodejsManager: NpmciNodeJsManager;
|
||||
public npmManager: NpmciNpmManager;
|
||||
|
||||
constructor() {
|
||||
this.analytics = new plugins.smartanalytics.Analytics({
|
||||
apiEndPoint: 'https://pubapi.lossless.one/analytics',
|
||||
projectId: 'gitzone',
|
||||
appName: 'npmci',
|
||||
});
|
||||
}
|
||||
|
||||
public async start() {
|
||||
this.cloudlyConnector = new CloudlyConnector(this);
|
||||
this.npmciEnv = new NpmciEnv(this);
|
||||
this.npmciInfo = new NpmciInfo(this);
|
||||
await this.npmciInfo.printToConsole();
|
||||
this.npmciCli = new NpmciCli(this);
|
||||
this.npmciConfig = new NpmciConfig(this);
|
||||
await this.npmciConfig.init();
|
||||
|
||||
// managers
|
||||
this.cloudronManager = new NpmciCloudronManager(this);
|
||||
this.dockerManager = new NpmciDockerManager(this);
|
||||
this.gitManager = new NpmciGitManager(this);
|
||||
this.nodejsManager = new NpmciNodeJsManager(this);
|
||||
this.npmManager = new NpmciNpmManager(this);
|
||||
this.npmciCli.startParse();
|
||||
}
|
||||
}
|
||||
@@ -1,23 +0,0 @@
|
||||
import * as plugins from './npmci.plugins.js';
|
||||
import { Npmci } from './npmci.classes.npmci.js';
|
||||
|
||||
export class NpmciEnv {
|
||||
public npmciRef: Npmci;
|
||||
|
||||
public repoString: string;
|
||||
public repo: plugins.smartstring.GitRepo;
|
||||
|
||||
constructor(npmciRefArg: Npmci) {
|
||||
this.npmciRef = npmciRefArg;
|
||||
if (!this.repoString && process.env.GITLAB_CI) {
|
||||
this.repoString = process.env.CI_REPOSITORY_URL;
|
||||
}
|
||||
if (!this.repoString && process.env.NPMCI_COMPUTED_REPOURL) {
|
||||
this.repoString = process.env.NPMCI_COMPUTED_REPOURL;
|
||||
}
|
||||
if (!this.repoString) {
|
||||
this.repoString = 'https://undefined:undefined@github.com/undefined/undefined.git';
|
||||
}
|
||||
this.repo = new plugins.smartstring.GitRepo(this.repoString);
|
||||
}
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
import * as plugins from './npmci.plugins.js';
|
||||
import * as paths from './npmci.paths.js';
|
||||
import { logger } from './npmci.logging.js';
|
||||
import { Npmci } from './npmci.classes.npmci.js';
|
||||
|
||||
export class NpmciInfo {
|
||||
public npmciRef: Npmci;
|
||||
public projectInfo = new plugins.projectinfo.ProjectinfoNpm(paths.NpmciPackageRoot);
|
||||
|
||||
constructor(npmciArg: Npmci) {
|
||||
this.npmciRef = npmciArg;
|
||||
}
|
||||
|
||||
public async printToConsole() {
|
||||
await logger.log('info', `npmci version: ${this.projectInfo.version}`);
|
||||
}
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
import * as plugins from './npmci.plugins.js';
|
||||
|
||||
export const cwd = process.cwd();
|
||||
|
||||
// package paths
|
||||
export const NpmciPackageRoot = plugins.path.join(
|
||||
plugins.smartpath.get.dirnameFromImportMetaUrl(import.meta.url),
|
||||
'../'
|
||||
);
|
||||
export const NpmciPackageConfig = plugins.path.join(NpmciPackageRoot, './config.json');
|
||||
|
||||
// project paths
|
||||
export const NpmciProjectDir = cwd;
|
||||
export const NpmciProjectNogitDir = plugins.path.join(NpmciProjectDir, './.nogit');
|
||||
export const NpmciTestDir = plugins.path.join(cwd, './test');
|
||||
export const NpmciCacheDir = plugins.path.join(cwd, './.npmci_cache');
|
||||
@@ -1,6 +1,6 @@
|
||||
import { logger } from './npmci.logging.js';
|
||||
import * as plugins from './npmci.plugins.js';
|
||||
import * as paths from './npmci.paths.js';
|
||||
import { logger } from './szci.logging.ts';
|
||||
import * as plugins from './szci.plugins.ts';
|
||||
import * as paths from './szci.paths.ts';
|
||||
|
||||
/**
|
||||
* wether nvm is available or not
|
||||
@@ -19,7 +19,7 @@ const npmciSmartshell = new plugins.smartshell.Smartshell({
|
||||
*/
|
||||
const checkToolsAvailable = async () => {
|
||||
// check for nvm
|
||||
if (!process.env.NPMTS_TEST) {
|
||||
if (!Deno.env.get('NPMTS_TEST')) {
|
||||
if (
|
||||
(await npmciSmartshell.execSilent(`bash -c "source /usr/local/nvm/nvm.sh"`)).exitCode === 0
|
||||
) {
|
||||
@@ -55,10 +55,10 @@ export let bash = async (commandArg: string, retryArg: number = 2): Promise<stri
|
||||
retryArg = 0;
|
||||
}
|
||||
|
||||
if (!process.env.NPMTS_TEST) {
|
||||
if (!Deno.env.get('NPMTS_TEST')) {
|
||||
// NPMTS_TEST is used during testing
|
||||
for (let i = 0; i <= retryArg; i++) {
|
||||
if (process.env.DEBUG_NPMCI === 'true') {
|
||||
if (Deno.env.get('DEBUG_NPMCI') === 'true') {
|
||||
console.log(commandArg);
|
||||
}
|
||||
execResult = await npmciSmartshell.exec(commandArg);
|
||||
@@ -68,7 +68,7 @@ export let bash = async (commandArg: string, retryArg: number = 2): Promise<stri
|
||||
// something went wrong and retries are exhausted
|
||||
if (failOnError) {
|
||||
logger.log('error', 'something went wrong and retries are exhausted');
|
||||
process.exit(1);
|
||||
Deno.exit(1);
|
||||
}
|
||||
} else if (execResult.exitCode === 0) {
|
||||
// everything went fine, or no error wanted
|
||||
61
ts/szci.classes.szci.ts
Normal file
61
ts/szci.classes.szci.ts
Normal file
@@ -0,0 +1,61 @@
|
||||
import * as plugins from './szci.plugins.ts';
|
||||
|
||||
|
||||
// env
|
||||
import { SzciEnv } from './szci.classes.szcienv.ts';
|
||||
import { SzciInfo } from './szci.classes.szciinfo.ts';
|
||||
import { SzciCli } from './szci.classes.szcicli.ts';
|
||||
import { SzciConfig } from './szci.classes.szciconfig.ts';
|
||||
|
||||
// connectors
|
||||
import { CloudlyConnector } from './connector.cloudly/cloudlyconnector.ts';
|
||||
|
||||
// managers
|
||||
import { SzciCloudronManager } from './manager.cloudron/index.ts';
|
||||
import { SzciDockerManager } from './manager.docker/index.ts';
|
||||
import { SzciGitManager } from './manager.git/index.ts';
|
||||
import { SzciNodeJsManager } from './manager.nodejs/index.ts';
|
||||
import { SzciNpmManager } from './manager.npm/index.ts';
|
||||
|
||||
export class Szci {
|
||||
public analytics: plugins.smartanalytics.Analytics;
|
||||
public cloudlyConnector: CloudlyConnector;
|
||||
|
||||
public npmciEnv: SzciEnv;
|
||||
public npmciInfo: SzciInfo;
|
||||
public npmciConfig: SzciConfig;
|
||||
public npmciCli: SzciCli;
|
||||
|
||||
// managers
|
||||
public cloudronManager: SzciCloudronManager;
|
||||
public dockerManager: SzciDockerManager;
|
||||
public gitManager: SzciGitManager;
|
||||
public nodejsManager: SzciNodeJsManager;
|
||||
public npmManager: SzciNpmManager;
|
||||
|
||||
constructor() {
|
||||
this.analytics = new plugins.smartanalytics.Analytics({
|
||||
apiEndPoint: 'https://pubapi.lossless.one/analytics',
|
||||
projectId: 'gitzone',
|
||||
appName: '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();
|
||||
|
||||
// managers
|
||||
this.cloudronManager = new SzciCloudronManager(this);
|
||||
this.dockerManager = new SzciDockerManager(this);
|
||||
this.gitManager = new SzciGitManager(this);
|
||||
this.nodejsManager = new SzciNodeJsManager(this);
|
||||
this.npmManager = new SzciNpmManager(this);
|
||||
this.npmciCli.startParse();
|
||||
}
|
||||
}
|
||||
@@ -1,16 +1,16 @@
|
||||
import { logger } from './npmci.logging.js';
|
||||
import * as plugins from './npmci.plugins.js';
|
||||
import * as paths from './npmci.paths.js';
|
||||
import { Npmci } from './npmci.classes.npmci.js';
|
||||
import { logger } from './szci.logging.ts';
|
||||
import * as plugins from './szci.plugins.ts';
|
||||
import * as paths from './szci.paths.ts';
|
||||
import { Szci } from './szci.classes.szci.ts';
|
||||
|
||||
export class NpmciCli {
|
||||
public npmciRef: Npmci;
|
||||
export class SzciCli {
|
||||
public szciRef: Szci;
|
||||
public smartcli: plugins.smartcli.Smartcli;
|
||||
|
||||
constructor(npmciArg: Npmci) {
|
||||
this.npmciRef = npmciArg;
|
||||
constructor(szciArg: Szci) {
|
||||
this.szciRef = szciArg;
|
||||
this.smartcli = new plugins.smartcli.Smartcli();
|
||||
this.smartcli.addVersion(this.npmciRef.npmciInfo.projectInfo.version);
|
||||
this.smartcli.addVersion(this.szciRef.npmciInfo.version);
|
||||
|
||||
// clean
|
||||
this.smartcli.addCommand('clean').subscribe(
|
||||
@@ -20,18 +20,18 @@ export class NpmciCli {
|
||||
},
|
||||
(err) => {
|
||||
console.log(err);
|
||||
process.exit(1);
|
||||
Deno.exit(1);
|
||||
}
|
||||
);
|
||||
|
||||
// cloudron
|
||||
this.smartcli.addCommand('cloudron').subscribe(
|
||||
async (argv) => {
|
||||
await this.npmciRef.cloudronManager.handleCli(argv);
|
||||
await this.szciRef.cloudronManager.handleCli(argv);
|
||||
},
|
||||
(err) => {
|
||||
console.log(err);
|
||||
process.exit(1);
|
||||
Deno.exit(1);
|
||||
}
|
||||
);
|
||||
|
||||
@@ -43,47 +43,47 @@ export class NpmciCli {
|
||||
},
|
||||
(err) => {
|
||||
console.log(err);
|
||||
process.exit(1);
|
||||
Deno.exit(1);
|
||||
}
|
||||
);
|
||||
|
||||
// git
|
||||
this.smartcli.addCommand('git').subscribe(
|
||||
async (argvArg) => {
|
||||
await this.npmciRef.gitManager.handleCli(argvArg);
|
||||
await this.szciRef.gitManager.handleCli(argvArg);
|
||||
},
|
||||
(err) => {
|
||||
console.log(err);
|
||||
process.exit(1);
|
||||
Deno.exit(1);
|
||||
}
|
||||
);
|
||||
|
||||
// build
|
||||
this.smartcli.addCommand('docker').subscribe(
|
||||
async (argvArg) => {
|
||||
await this.npmciRef.dockerManager.handleCli(argvArg);
|
||||
await this.szciRef.dockerManager.handleCli(argvArg);
|
||||
},
|
||||
(err) => {
|
||||
console.log(err);
|
||||
process.exit(1);
|
||||
Deno.exit(1);
|
||||
}
|
||||
);
|
||||
|
||||
// node
|
||||
this.smartcli.addCommand('node').subscribe(
|
||||
async (argvArg) => {
|
||||
await this.npmciRef.nodejsManager.handleCli(argvArg);
|
||||
await this.szciRef.nodejsManager.handleCli(argvArg);
|
||||
},
|
||||
(err) => {
|
||||
console.log(err);
|
||||
process.exit(1);
|
||||
Deno.exit(1);
|
||||
}
|
||||
);
|
||||
|
||||
// npm
|
||||
this.smartcli.addCommand('npm').subscribe(
|
||||
async (argvArg) => {
|
||||
await this.npmciRef.npmManager.handleCli(argvArg);
|
||||
await this.szciRef.npmManager.handleCli(argvArg);
|
||||
},
|
||||
(err) => {
|
||||
console.log(err);
|
||||
@@ -92,7 +92,7 @@ export class NpmciCli {
|
||||
|
||||
this.smartcli.addCommand('precheck').subscribe(async (argvArg) => {
|
||||
const modPrecheck = await import('./mod_precheck/index.js');
|
||||
await modPrecheck.handleCli(this.npmciRef, argvArg);
|
||||
await modPrecheck.handleCli(this.szciRef, argvArg);
|
||||
});
|
||||
|
||||
// trigger
|
||||
@@ -109,7 +109,7 @@ export class NpmciCli {
|
||||
},
|
||||
(err) => {
|
||||
console.log(err);
|
||||
process.exit(1);
|
||||
Deno.exit(1);
|
||||
}
|
||||
);
|
||||
}
|
||||
@@ -1,13 +1,13 @@
|
||||
import * as plugins from './npmci.plugins.js';
|
||||
import * as paths from './npmci.paths.js';
|
||||
import * as plugins from './szci.plugins.ts';
|
||||
import * as paths from './szci.paths.ts';
|
||||
|
||||
import { logger } from './npmci.logging.js';
|
||||
import { Npmci } from './npmci.classes.npmci.js';
|
||||
import { logger } from './szci.logging.ts';
|
||||
import { Szci } from './szci.classes.szci.ts';
|
||||
|
||||
/**
|
||||
* the main config interface for npmci
|
||||
*/
|
||||
export interface INpmciOptions {
|
||||
export interface ISzciOptions {
|
||||
projectInfo: plugins.projectinfo.ProjectInfo;
|
||||
|
||||
// npm
|
||||
@@ -33,28 +33,28 @@ export interface INpmciOptions {
|
||||
/**
|
||||
* a config class for Npmci
|
||||
*/
|
||||
export class NpmciConfig {
|
||||
public npmciRef: Npmci;
|
||||
export class SzciConfig {
|
||||
public szciRef: Szci;
|
||||
|
||||
public npmciNpmextra: plugins.npmextra.Npmextra;
|
||||
public kvStorage: plugins.npmextra.KeyValueStore;
|
||||
public npmciQenv: plugins.qenv.Qenv;
|
||||
|
||||
private configObject: INpmciOptions;
|
||||
private configObject: ISzciOptions;
|
||||
|
||||
constructor(npmciRefArg: Npmci) {
|
||||
this.npmciRef = npmciRefArg;
|
||||
constructor(szciRefArg: Szci) {
|
||||
this.szciRef = szciRefArg;
|
||||
}
|
||||
|
||||
public async init() {
|
||||
this.npmciNpmextra = new plugins.npmextra.Npmextra(paths.cwd);
|
||||
this.kvStorage = new plugins.npmextra.KeyValueStore({
|
||||
typeArg: 'userHomeDir',
|
||||
identityArg: `.npmci_${this.npmciRef.npmciEnv.repo.user}_${this.npmciRef.npmciEnv.repo.repo}`,
|
||||
identityArg: `.npmci_${this.szciRef.npmciEnv.repo.user}_${this.szciRef.npmciEnv.repo.repo}`,
|
||||
});
|
||||
this.npmciQenv = new plugins.qenv.Qenv(
|
||||
paths.NpmciProjectDir,
|
||||
paths.NpmciProjectNogitDir,
|
||||
paths.SzciProjectDir,
|
||||
paths.SzciProjectNogitDir,
|
||||
false
|
||||
);
|
||||
|
||||
@@ -69,10 +69,10 @@ export class NpmciConfig {
|
||||
dockerBuildargEnvMap: {},
|
||||
urlCloudly: await this.npmciQenv.getEnvVarOnDemand('NPMCI_URL_CLOUDLY'),
|
||||
};
|
||||
this.configObject = this.npmciNpmextra.dataFor<INpmciOptions>('npmci', this.configObject);
|
||||
this.configObject = this.npmciNpmextra.dataFor<ISzciOptions>('szci', this.configObject);
|
||||
}
|
||||
|
||||
public getConfig(): INpmciOptions {
|
||||
public getConfig(): ISzciOptions {
|
||||
return this.configObject;
|
||||
}
|
||||
}
|
||||
23
ts/szci.classes.szcienv.ts
Normal file
23
ts/szci.classes.szcienv.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
import * as plugins from './szci.plugins.ts';
|
||||
import { Szci } from './szci.classes.szci.ts';
|
||||
|
||||
export class SzciEnv {
|
||||
public szciRef: Szci;
|
||||
|
||||
public repoString: string;
|
||||
public repo: plugins.smartstring.GitRepo;
|
||||
|
||||
constructor(szciRefArg: Szci) {
|
||||
this.szciRef = szciRefArg;
|
||||
if (!this.repoString && Deno.env.get("GITLAB_CI")) {
|
||||
this.repoString = 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';
|
||||
}
|
||||
this.repo = new plugins.smartstring.GitRepo(this.repoString);
|
||||
}
|
||||
}
|
||||
18
ts/szci.classes.szciinfo.ts
Normal file
18
ts/szci.classes.szciinfo.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
import * as plugins from './szci.plugins.ts';
|
||||
import * as paths from './szci.paths.ts';
|
||||
import { logger } from './szci.logging.ts';
|
||||
import { Szci } from './szci.classes.szci.ts';
|
||||
import denoConfig from '../deno.json' with { type: 'json' };
|
||||
|
||||
export class SzciInfo {
|
||||
public szciRef: Szci;
|
||||
public version = denoConfig.version;
|
||||
|
||||
constructor(szciArg: Szci) {
|
||||
this.szciRef = szciArg;
|
||||
}
|
||||
|
||||
public async printToConsole() {
|
||||
await logger.log('info', `szci version: ${this.version}`);
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
import * as plugins from './npmci.plugins.js';
|
||||
import * as plugins from './szci.plugins.ts';
|
||||
|
||||
export const logger = new plugins.smartlog.Smartlog({
|
||||
logContext: {
|
||||
16
ts/szci.paths.ts
Normal file
16
ts/szci.paths.ts
Normal file
@@ -0,0 +1,16 @@
|
||||
import * as plugins from './szci.plugins.ts';
|
||||
|
||||
export const cwd = Deno.cwd();
|
||||
|
||||
// package paths
|
||||
export const SzciPackageRoot = plugins.path.join(
|
||||
plugins.smartpath.get.dirnameFromImportMetaUrl(import.meta.url),
|
||||
'../'
|
||||
);
|
||||
export const SzciPackageConfig = plugins.path.join(SzciPackageRoot, './config.json');
|
||||
|
||||
// project paths
|
||||
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');
|
||||
@@ -1,5 +1,5 @@
|
||||
// node native
|
||||
import * as path from 'path';
|
||||
// Deno std libraries
|
||||
import * as path from '@std/path';
|
||||
|
||||
export { path };
|
||||
|
||||
Reference in New Issue
Block a user