2022-10-09 16:15:37 +00:00
|
|
|
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';
|
2019-08-29 18:26:23 +00:00
|
|
|
|
|
|
|
export class NpmciCli {
|
|
|
|
public npmciRef: Npmci;
|
|
|
|
public smartcli: plugins.smartcli.Smartcli;
|
|
|
|
|
|
|
|
constructor(npmciArg: Npmci) {
|
|
|
|
this.npmciRef = npmciArg;
|
|
|
|
this.smartcli = new plugins.smartcli.Smartcli();
|
|
|
|
this.smartcli.addVersion(this.npmciRef.npmciInfo.projectInfo.version);
|
|
|
|
|
|
|
|
// clean
|
|
|
|
this.smartcli.addCommand('clean').subscribe(
|
2021-05-14 18:11:12 +00:00
|
|
|
async (argv) => {
|
2022-10-09 16:15:37 +00:00
|
|
|
const modClean = await import('./mod_clean/index.js');
|
2019-08-29 18:26:23 +00:00
|
|
|
await modClean.clean();
|
|
|
|
},
|
2021-05-14 18:11:12 +00:00
|
|
|
(err) => {
|
2019-08-29 18:26:23 +00:00
|
|
|
console.log(err);
|
|
|
|
process.exit(1);
|
|
|
|
}
|
|
|
|
);
|
|
|
|
|
2023-07-01 20:05:43 +00:00
|
|
|
// cloudron
|
|
|
|
this.smartcli.addCommand('cloudron').subscribe(
|
|
|
|
async (argv) => {
|
|
|
|
await this.npmciRef.cloudronManager.handleCli(argv);
|
|
|
|
},
|
|
|
|
(err) => {
|
|
|
|
console.log(err);
|
|
|
|
process.exit(1);
|
|
|
|
}
|
|
|
|
);
|
|
|
|
|
2019-08-29 18:26:23 +00:00
|
|
|
// command
|
|
|
|
this.smartcli.addCommand('command').subscribe(
|
2021-05-14 18:11:12 +00:00
|
|
|
async (argv) => {
|
2022-10-09 16:15:37 +00:00
|
|
|
const modCommand = await import('./mod_command/index.js');
|
2019-08-29 18:26:23 +00:00
|
|
|
await modCommand.command();
|
|
|
|
},
|
2021-05-14 18:11:12 +00:00
|
|
|
(err) => {
|
2019-08-29 18:26:23 +00:00
|
|
|
console.log(err);
|
|
|
|
process.exit(1);
|
|
|
|
}
|
|
|
|
);
|
|
|
|
|
2023-07-01 20:05:43 +00:00
|
|
|
// git
|
2019-08-29 18:26:23 +00:00
|
|
|
this.smartcli.addCommand('git').subscribe(
|
2021-05-14 18:11:12 +00:00
|
|
|
async (argvArg) => {
|
2019-08-29 18:26:23 +00:00
|
|
|
await this.npmciRef.gitManager.handleCli(argvArg);
|
|
|
|
},
|
2021-05-14 18:11:12 +00:00
|
|
|
(err) => {
|
2019-08-29 18:26:23 +00:00
|
|
|
console.log(err);
|
|
|
|
process.exit(1);
|
|
|
|
}
|
|
|
|
);
|
|
|
|
|
|
|
|
// build
|
|
|
|
this.smartcli.addCommand('docker').subscribe(
|
2021-05-14 18:11:12 +00:00
|
|
|
async (argvArg) => {
|
2019-08-29 18:26:23 +00:00
|
|
|
await this.npmciRef.dockerManager.handleCli(argvArg);
|
|
|
|
},
|
2021-05-14 18:11:12 +00:00
|
|
|
(err) => {
|
2019-08-29 18:26:23 +00:00
|
|
|
console.log(err);
|
|
|
|
process.exit(1);
|
|
|
|
}
|
|
|
|
);
|
|
|
|
|
|
|
|
// node
|
|
|
|
this.smartcli.addCommand('node').subscribe(
|
2021-05-14 18:11:12 +00:00
|
|
|
async (argvArg) => {
|
2019-08-29 18:26:23 +00:00
|
|
|
await this.npmciRef.nodejsManager.handleCli(argvArg);
|
|
|
|
},
|
2021-05-14 18:11:12 +00:00
|
|
|
(err) => {
|
2019-08-29 18:26:23 +00:00
|
|
|
console.log(err);
|
|
|
|
process.exit(1);
|
|
|
|
}
|
|
|
|
);
|
|
|
|
|
|
|
|
// npm
|
|
|
|
this.smartcli.addCommand('npm').subscribe(
|
2021-05-14 18:11:12 +00:00
|
|
|
async (argvArg) => {
|
2019-08-29 18:26:23 +00:00
|
|
|
await this.npmciRef.npmManager.handleCli(argvArg);
|
|
|
|
},
|
2021-05-14 18:11:12 +00:00
|
|
|
(err) => {
|
2019-08-29 18:26:23 +00:00
|
|
|
console.log(err);
|
|
|
|
}
|
|
|
|
);
|
|
|
|
|
2022-10-24 19:23:14 +00:00
|
|
|
this.smartcli.addCommand('precheck').subscribe(async (argvArg) => {
|
|
|
|
const modPrecheck = await import('./mod_precheck/index.js');
|
|
|
|
await modPrecheck.handleCli(this.npmciRef, argvArg);
|
2023-05-07 19:30:58 +00:00
|
|
|
});
|
2022-10-24 19:23:14 +00:00
|
|
|
|
2019-08-29 18:26:23 +00:00
|
|
|
// trigger
|
2023-05-07 19:30:58 +00:00
|
|
|
this.smartcli.addCommand('ssh').subscribe(async (argvArg) => {
|
|
|
|
const modSsh = await import('./mod_ssh/index.js');
|
|
|
|
await modSsh.handleCli(argvArg);
|
|
|
|
});
|
2019-08-29 18:26:23 +00:00
|
|
|
|
|
|
|
// trigger
|
|
|
|
this.smartcli.addCommand('trigger').subscribe(
|
2021-05-14 18:11:12 +00:00
|
|
|
async (argv) => {
|
2022-10-09 16:15:37 +00:00
|
|
|
const modTrigger = await import('./mod_trigger/index.js');
|
2019-08-29 18:26:23 +00:00
|
|
|
await modTrigger.trigger();
|
|
|
|
},
|
2021-05-14 18:11:12 +00:00
|
|
|
(err) => {
|
2019-08-29 18:26:23 +00:00
|
|
|
console.log(err);
|
|
|
|
process.exit(1);
|
|
|
|
}
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
public startParse = () => {
|
|
|
|
this.smartcli.startParse();
|
2019-08-29 18:38:44 +00:00
|
|
|
};
|
2019-08-29 18:26:23 +00:00
|
|
|
}
|