Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modify the block template download method to pnpm, modify the block release environment variables #14

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions app/service/cnpm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ import { Service } from 'egg';
export default class CnpmService extends Service {
authToken = this.config.authToken;
registry = this.config.registry;

tokenRegistry = this.config.tokenRegistry
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.tokenRegistry}:_authToken=${this.authToken}`,
`npm whoami --registry ${this.registry}`
];
return this.ctx.helper.execCommandWithCatch(commands, { cwd: packagePath }, 'login npm');
}
Expand All @@ -30,5 +30,5 @@ export default class CnpmService extends Service {
const commands = ['npm publish --access=public'];
return this.ctx.helper.execCommandWithCatch(commands, { cwd: packagePath }, 'publish cnpm');
}

}
6 changes: 3 additions & 3 deletions app/service/material-center/vueBlockBuilder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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
})
Expand All @@ -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
}
Expand Down
10 changes: 7 additions & 3 deletions config/config.default.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
* A PARTICULAR PURPOSE. SEE THE APPLICABLE LICENSES FOR MORE DETAILS.
*
*/
import * as path from 'path';
import { EggAppConfig, PowerPartial } from 'egg';
import * as path from 'path';
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) => {
Expand Down Expand Up @@ -296,10 +296,14 @@ export default (appInfo) => {
'--registry=https://registry.npmjs.org/',
];

config.cnpmRegistryOptions = [
'--registry=http://registry.npmmirror.com/'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里加了一个新配置参数,在这里注释一下这个新配置参数的用途吧,还要检查一下是否需要调整我们原来的文档

];
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/';
wenmine marked this conversation as resolved.
Show resolved Hide resolved
config.tokenRegistry = 'registry.npmjs.org/';
wenmine marked this conversation as resolved.
Show resolved Hide resolved
config.projectName = process.env.GIT_REPO; // 应用发布git仓库地址
config.gitBranch = process.env.GIT_BRANCH; // 应用发布git代码默认提交分支
config.userName = process.env.GIT_USERNAME;
Expand Down
Loading