diff --git a/src/handlers/extension.js b/src/handlers/extension.js index d7b5fd9..b73b409 100644 --- a/src/handlers/extension.js +++ b/src/handlers/extension.js @@ -1,7 +1,18 @@ import IO from '../base/io.js'; import { resolve } from 'path'; +import Others from './others.js'; import NpmHandler from './npm.js'; +import LogoHandler from './logo.js'; +import GulpHandler from './gulp.js'; +import DelayHanlder from './delay.js'; +import ConfigRender from './config.js'; +import MirrorHandler from './mirror.js'; +import NetWork from '../base/network.js'; +import ModuleResolver from './module.js'; import InfoHandler from './information.js'; +import VerionsHandler from './versions.js'; +import ManifestHandler from './manifest.js'; +import DelayHanlderWithInfo from './delayInfo.js'; import { done, error, start } from '../base/console.js'; class ExtensionClass { @@ -43,6 +54,7 @@ class ExtensionClass { async load(program) { if (this.extList.length) { start('Load extensions...'); + try { for (const packageName of this.extList) { ( @@ -54,11 +66,26 @@ class ExtensionClass { 'index.js' ) ) - ).cli(program, InfoHandler, IO); + )(program, { + Others, + NpmHandler, + LogoHandler, + GulpHandler, + DelayHanlder, + ConfigRender, + MirrorHandler, + NetWork, + ModuleResolver, + InfoHandler, + VerionsHandler, + ManifestHandler, + DelayHanlderWithInfo + }); } } catch (e) { console.log(error('Failed to load extension!'), e); } + done('Load extensions.'); } } diff --git a/src/handlers/npm.js b/src/handlers/npm.js index ee55365..345bba2 100644 --- a/src/handlers/npm.js +++ b/src/handlers/npm.js @@ -27,6 +27,8 @@ class NpmClass extends DelayHanlderWithInfo { async update() { this.pnpm = checkPnpm(); this.platform = process.platform; + this.android_suffix = + this.platform === 'android' ? '--no-bin-links' : ''; this.mirror = await MirrorHandler.getFastestMirror(); if (existsSync('package.json')) { this.package = IO.readJSON('package.json'); @@ -126,8 +128,6 @@ class NpmClass extends DelayHanlderWithInfo { async install() { await this.check(); - const android_suffix = - this.platform === 'android' ? '--no-bin-links' : ''; if (this.pnpm) { if (this.platform === 'android') IO.writeText('.npmrc', 'node-linker=hoisted'); @@ -138,14 +138,15 @@ class NpmClass extends DelayHanlderWithInfo { ); IO.exec(`pnpm install --registry=${this.mirror}`); } else - IO.exec(`npm install --registry=${this.mirror} ${android_suffix}`); + IO.exec( + `npm install --registry=${this.mirror} ${this.android_suffix}` + ); } async add(packageName) { await this.check(); - const android_suffix = - this.platform === 'android' ? '--no-bin-links' : ''; start(`Install extension "${packageName}"...`); + if (this.pnpm) { if (this.platform === 'android') IO.writeText('.npmrc', 'node-linker=hoisted'); @@ -154,11 +155,12 @@ class NpmClass extends DelayHanlderWithInfo { 'Detects that you have pnpm and will automatically enable the pnpm installation dependency.' ) ); - IO.exec(`pnpm install ${packageName} --registry=${this.mirror}`); + IO.exec(`pnpm install ${packageName} --registry=${this.mirror} --save-dev`); } else IO.exec( - `npm install ${packageName} --registry=${this.mirror} ${android_suffix}` + `npm install ${packageName} --registry=${this.mirror} ${this.android_suffix} --save-dev` ); + done(`Install extension "${packageName}".`); }