fix(core): update
This commit is contained in:
parent
4c07131e51
commit
5c5dbf303f
@ -3,6 +3,6 @@
|
|||||||
*/
|
*/
|
||||||
export const commitinfo = {
|
export const commitinfo = {
|
||||||
name: '@shipzone/npmci',
|
name: '@shipzone/npmci',
|
||||||
version: '4.1.17',
|
version: '4.1.18',
|
||||||
description: 'node and docker in gitlab ci on steroids'
|
description: 'node and docker in gitlab ci on steroids'
|
||||||
}
|
}
|
||||||
|
68
ts/manager.cloudron/index.ts
Normal file
68
ts/manager.cloudron/index.ts
Normal file
@ -0,0 +1,68 @@
|
|||||||
|
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';
|
||||||
|
|
||||||
|
export class NpmciCloudronManager {
|
||||||
|
public npmciRef: Npmci;
|
||||||
|
|
||||||
|
constructor(npmciArg: Npmci) {
|
||||||
|
this.npmciRef = npmciArg;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* handle cli input
|
||||||
|
* @param argvArg
|
||||||
|
*/
|
||||||
|
public handleCli = async (argvArg: any) => {
|
||||||
|
if (argvArg._.length >= 2) {
|
||||||
|
const action: string = argvArg._[1];
|
||||||
|
switch (action) {
|
||||||
|
case 'deploy':
|
||||||
|
await this.deploy();
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
logger.log('error', `>>npmci cloudron ...<< action >>${action}<< not supported`);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
logger.log(
|
||||||
|
'info',
|
||||||
|
`>>npmci cloudron ...<< cli arguments invalid... Please read the documentation.`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Replaces the version string in CloudronManifest file
|
||||||
|
* @param versionArg
|
||||||
|
*/
|
||||||
|
public deploy = async () => {
|
||||||
|
logger.log('info', 'now deploying to cloudron...');
|
||||||
|
logger.log('info', 'installing cloudron cli...');
|
||||||
|
await bash(`pnpm install -g cloudron`);
|
||||||
|
logger.log('ok', 'cloudron cli installed');
|
||||||
|
|
||||||
|
// lets set the version in the CloudronManifest file
|
||||||
|
await this.prepareCloudronManifest(this.npmciRef.npmciConfig.getConfig().projectInfo.npm.version);
|
||||||
|
logger.log('ok', 'CloudronManifest prepared');
|
||||||
|
|
||||||
|
// lets figure out the docker image tag
|
||||||
|
const dockerfiles = await this.npmciRef.dockerManager.getDockerfiles();
|
||||||
|
const dockerImageTag = dockerfiles[0].pushTag;
|
||||||
|
const appName = this.npmciRef.npmciConfig.getConfig().cloudronAppName;
|
||||||
|
|
||||||
|
const cloudronEnvVar = process.env.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}`);
|
||||||
|
};
|
||||||
|
|
||||||
|
private prepareCloudronManifest = async (versionArg: string) => {
|
||||||
|
const manifestPath = plugins.path.join(paths.cwd, 'CloudronManifest.json');
|
||||||
|
let manifestFile = plugins.smartfile.fs.toStringSync(manifestPath);
|
||||||
|
manifestFile = manifestFile.replace(/##version##/g, versionArg);
|
||||||
|
plugins.smartfile.memory.toFsSync(manifestFile, manifestPath);
|
||||||
|
logger.log('info', 'Version replaced in CloudronManifest file');
|
||||||
|
}
|
||||||
|
}
|
1
ts/manager.cloudron/mod.plugins.ts
Normal file
1
ts/manager.cloudron/mod.plugins.ts
Normal file
@ -0,0 +1 @@
|
|||||||
|
export * from '../npmci.plugins.js';
|
@ -179,4 +179,12 @@ export class NpmciDockerManager {
|
|||||||
await this.prepare();
|
await this.prepare();
|
||||||
return await Dockerfile.readDockerfiles(this).then(Dockerfile.testDockerfiles);
|
return await Dockerfile.readDockerfiles(this).then(Dockerfile.testDockerfiles);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* can be used to get the Dockerfiles in the directory
|
||||||
|
*/
|
||||||
|
getDockerfiles = async () => {
|
||||||
|
const dockerfiles = await Dockerfile.readDockerfiles(this);
|
||||||
|
return dockerfiles;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,17 +1,21 @@
|
|||||||
import * as plugins from './npmci.plugins.js';
|
import * as plugins from './npmci.plugins.js';
|
||||||
|
|
||||||
import { CloudlyConnector } from './connector.cloudly/cloudlyconnector.js';
|
|
||||||
|
|
||||||
|
// env
|
||||||
|
import { NpmciEnv } from './npmci.classes.npmcienv.js';
|
||||||
import { NpmciInfo } from './npmci.classes.npmciinfo.js';
|
import { NpmciInfo } from './npmci.classes.npmciinfo.js';
|
||||||
import { NpmciCli } from './npmci.classes.npmcicli.js';
|
import { NpmciCli } from './npmci.classes.npmcicli.js';
|
||||||
import { NpmciConfig } from './npmci.classes.npmciconfig.js';
|
import { NpmciConfig } from './npmci.classes.npmciconfig.js';
|
||||||
|
|
||||||
// mods
|
// connectors
|
||||||
|
import { CloudlyConnector } from './connector.cloudly/cloudlyconnector.js';
|
||||||
|
|
||||||
|
// managers
|
||||||
|
import { NpmciCloudronManager } from './manager.cloudron/index.js';
|
||||||
import { NpmciDockerManager } from './manager.docker/index.js';
|
import { NpmciDockerManager } from './manager.docker/index.js';
|
||||||
import { NpmciGitManager } from './manager.git/index.js';
|
import { NpmciGitManager } from './manager.git/index.js';
|
||||||
import { NpmciNodeJsManager } from './manager.nodejs/index.js';
|
import { NpmciNodeJsManager } from './manager.nodejs/index.js';
|
||||||
import { NpmciNpmManager } from './manager.npm/index.js';
|
import { NpmciNpmManager } from './manager.npm/index.js';
|
||||||
import { NpmciEnv } from './npmci.classes.npmcienv.js';
|
|
||||||
|
|
||||||
export class Npmci {
|
export class Npmci {
|
||||||
public analytics: plugins.smartanalytics.Analytics;
|
public analytics: plugins.smartanalytics.Analytics;
|
||||||
@ -23,6 +27,7 @@ export class Npmci {
|
|||||||
public npmciCli: NpmciCli;
|
public npmciCli: NpmciCli;
|
||||||
|
|
||||||
// managers
|
// managers
|
||||||
|
public cloudronManager: NpmciCloudronManager;
|
||||||
public dockerManager: NpmciDockerManager;
|
public dockerManager: NpmciDockerManager;
|
||||||
public gitManager: NpmciGitManager;
|
public gitManager: NpmciGitManager;
|
||||||
public nodejsManager: NpmciNodeJsManager;
|
public nodejsManager: NpmciNodeJsManager;
|
||||||
@ -41,6 +46,7 @@ export class Npmci {
|
|||||||
this.npmciConfig = new NpmciConfig(this);
|
this.npmciConfig = new NpmciConfig(this);
|
||||||
|
|
||||||
// managers
|
// managers
|
||||||
|
this.cloudronManager = new NpmciCloudronManager(this);
|
||||||
this.dockerManager = new NpmciDockerManager(this);
|
this.dockerManager = new NpmciDockerManager(this);
|
||||||
this.gitManager = new NpmciGitManager(this);
|
this.gitManager = new NpmciGitManager(this);
|
||||||
this.nodejsManager = new NpmciNodeJsManager(this);
|
this.nodejsManager = new NpmciNodeJsManager(this);
|
||||||
|
@ -24,6 +24,17 @@ export class NpmciCli {
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// cloudron
|
||||||
|
this.smartcli.addCommand('cloudron').subscribe(
|
||||||
|
async (argv) => {
|
||||||
|
await this.npmciRef.cloudronManager.handleCli(argv);
|
||||||
|
},
|
||||||
|
(err) => {
|
||||||
|
console.log(err);
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
// command
|
// command
|
||||||
this.smartcli.addCommand('command').subscribe(
|
this.smartcli.addCommand('command').subscribe(
|
||||||
async (argv) => {
|
async (argv) => {
|
||||||
@ -36,7 +47,7 @@ export class NpmciCli {
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
// command
|
// git
|
||||||
this.smartcli.addCommand('git').subscribe(
|
this.smartcli.addCommand('git').subscribe(
|
||||||
async (argvArg) => {
|
async (argvArg) => {
|
||||||
await this.npmciRef.gitManager.handleCli(argvArg);
|
await this.npmciRef.gitManager.handleCli(argvArg);
|
||||||
|
@ -25,6 +25,9 @@ export interface INpmciOptions {
|
|||||||
|
|
||||||
// urls
|
// urls
|
||||||
urlCloudly: string;
|
urlCloudly: string;
|
||||||
|
|
||||||
|
// cloudron
|
||||||
|
cloudronAppName: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user