feat(core): new tools scope

This commit is contained in:
2018-06-07 22:41:25 +02:00
parent 82b6654b94
commit f01e275044
29 changed files with 1841 additions and 1406 deletions

View File

@ -1,3 +1,2 @@
import plugins = require("./npmg.plugins");
import * as cli from './npmg.cli'
cli.run()
import plugins = require('./tools.plugins');
import * as cli from './tools.cli';

View File

@ -1,11 +0,0 @@
import * as plugins from './npmg.plugins'
import * as npmgInstall from './npmg.install'
let npmgSmartcli = new plugins.smartcli.Smartcli()
export let run = async () => {
npmgSmartcli.addCommand('install').then(async (argvArg) => {
npmgInstall.install('default')
})
npmgSmartcli.startParse()
}

View File

@ -1,30 +0,0 @@
import plugins = require('./npmg.plugins');
import paths = require('./npmg.paths');
let installExec = async (packageNames: string[]) => {
let installString = ''
for (let packageName of packageNames) {
installString = installString + `${packageName} `
}
await plugins.smartshell.exec(`yarn global remove ${installString}`)
for (let packageName of packageNames) {
plugins.beautylog.info(`now preparing ${packageName}`)
await plugins.smartshell.exec(`yarn global remove ${packageName}`)
}
await plugins.smartshell.exec(`yarn global add ${installString}`)
}
let packageLibrary = plugins.smartfile.fs.toObjectSync(
plugins.path.join(paths.packageBase, 'package_library.json')
);
export let install = async (packageSetArg: String) => {
switch (packageSetArg) {
case 'default':
await installExec(packageLibrary.default)
break
default:
plugins.beautylog.warn('no set has been specified');
break
}
}

View File

@ -1,3 +0,0 @@
import plugins = require('./npmg.plugins');
export let packageBase = plugins.path.join('__dirname', '../')

View File

@ -1,14 +0,0 @@
import 'typings-global'
import * as beautylog from 'beautylog'
import * as path from 'path'
import * as smartcli from 'smartcli'
import * as smartfile from 'smartfile'
import * as smartshell from 'smartshell'
export {
beautylog,
path,
smartcli,
smartfile,
smartshell
}

11
ts/tools.cli.ts Normal file
View File

@ -0,0 +1,11 @@
import * as plugins from './tools.plugins';
import * as toolsInstall from './tools.install';
let npmgSmartcli = new plugins.smartcli.Smartcli();
npmgSmartcli.addCommand('install').subscribe(async argvArg => {
toolsInstall.install('default');
});
npmgSmartcli.addVersion('no version set');
npmgSmartcli.startParse();

30
ts/tools.install.ts Normal file
View File

@ -0,0 +1,30 @@
import plugins = require('./tools.plugins');
import paths = require('./tools.paths');
const installExec = async (packageNames: string[]) => {
let installString = '';
for (let packageName of packageNames) {
installString = installString + `${packageName} `;
}
await plugins.smartshell.exec(`yarn global remove ${installString}`);
for (let packageName of packageNames) {
plugins.beautylog.info(`now preparing ${packageName}`);
plugins.beautylog.log(`Installing ${packageName}`);
}
await plugins.smartshell.exec(`npm install -g ${installString}`);
};
let packageLibrary = plugins.smartfile.fs.toObjectSync(
plugins.path.join(paths.packageBase, 'package_library.json')
);
export const install = async (packageSetArg: String) => {
switch (packageSetArg) {
case 'default':
await installExec(packageLibrary.default);
break;
default:
plugins.beautylog.warn('no set has been specified');
break;
}
};

3
ts/tools.paths.ts Normal file
View File

@ -0,0 +1,3 @@
import plugins = require('./tools.plugins');
export let packageBase = plugins.path.join('__dirname', '../');

8
ts/tools.plugins.ts Normal file
View File

@ -0,0 +1,8 @@
import 'typings-global';
import * as beautylog from 'beautylog';
import * as path from 'path';
import * as smartcli from '@pushrocks/smartcli';
import * as smartfile from 'smartfile';
import * as smartshell from 'smartshell';
export { beautylog, path, smartcli, smartfile, smartshell };