diff --git a/app/service/cnpm.ts b/app/service/cnpm.ts index 1cef34d..206bad6 100644 --- a/app/service/cnpm.ts +++ b/app/service/cnpm.ts @@ -15,13 +15,12 @@ import { Service } from 'egg'; export default class CnpmService extends Service { authToken = this.config.authToken; registry = this.config.registry; - async loginInNpm(packagePath) { const commands = [ 'npm config set strict-ssl false', - `npm config set registry https://${this.registry}`, - `npm config set //${this.registry}:_authToken=${this.authToken}`, - `npm whoami --registry https://${this.registry}` + `npm config set registry ${this.registry}`, + `npm config set //${this.registry.split("//")?.[1]}:_authToken=${this.authToken}`, + `npm whoami --registry ${this.registry}` ]; return this.ctx.helper.execCommandWithCatch(commands, { cwd: packagePath }, 'login npm'); } @@ -30,5 +29,5 @@ export default class CnpmService extends Service { const commands = ['npm publish --access=public']; return this.ctx.helper.execCommandWithCatch(commands, { cwd: packagePath }, 'publish cnpm'); } - + } diff --git a/app/service/material-center/vueBlockBuilder.ts b/app/service/material-center/vueBlockBuilder.ts index fbcf535..90e1d4c 100644 --- a/app/service/material-center/vueBlockBuilder.ts +++ b/app/service/material-center/vueBlockBuilder.ts @@ -13,7 +13,7 @@ import spawn from 'cross-spawn'; import { Service } from 'egg'; import * as fs from 'fs-extra'; import * as path from 'path'; -export default class VueBlockBuilder extends Service{ +export default class VueBlockBuilder extends Service { base = this.config.buildground baseNpm = this.config.baseNpm framework = 'Vue' @@ -45,7 +45,7 @@ export default class VueBlockBuilder extends Service{ cwd: buildGround }) await this.spawnCommand(['npm', 'init', '-y'], { cwd: buildGround }) - const registries = this.config.npmRegistryOptions + const registries = this.config.cnpmRegistryOptions await this.spawnCommand(['npm', 'pack', baseNpm, ...registries, '--strict-ssl=false'], { cwd: buildGround }) @@ -54,7 +54,7 @@ export default class VueBlockBuilder extends Service{ await this.spawnCommand(['tar', '-xzvf', tgz], { cwd: buildGround }) await fs.copy(path.join(buildGround, 'package'), buildGround) await this.spawnCommand( - ['npm', 'install', ...registries, '--no-audit', '--no-fund', '--production=false', '--strict-ssl=false'], + ['pnpm', 'install', ...registries, '--production=false'], { cwd: buildGround } diff --git a/config/config.default.ts b/config/config.default.ts index ac0d902..5f5e836 100644 --- a/config/config.default.ts +++ b/config/config.default.ts @@ -11,8 +11,8 @@ */ import * as path from 'path'; import { EggAppConfig, PowerPartial } from 'egg'; +import { E_FOUNDATION_MODEL, E_SchemaFormatFunc } from '../app/lib/enum'; import { I_SchemaConvert } from '../app/lib/interface'; -import { E_SchemaFormatFunc, E_FOUNDATION_MODEL } from '../app/lib/enum'; export default (appInfo) => { @@ -308,11 +308,14 @@ export default (appInfo) => { config.npmRegistryOptions = [ '--registry=https://registry.npmjs.org/' ]; - + // 国内镜像 + config.cnpmRegistryOptions = [ + '--registry=http://registry.npmmirror.com/' + ]; config.buildground = '/tmp/buildground'; config.baseNpm = '@opentiny/tiny-engine-block-build'; config.authToken = process.env.NPM_AUTH_TOKEN; // 替换为自己的npm token - config.registry = 'registry.npmjs.org/'; + config.registry = 'https://registry.npmjs.org/'; // 如果部署了私仓可替换为自己私仓地址 config.projectName = process.env.GIT_REPO; // 应用发布git仓库地址 config.gitBranch = process.env.GIT_BRANCH; // 应用发布git代码默认提交分支 config.userName = process.env.GIT_USERNAME;