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

Modifying a Block Release #23

Merged
merged 8 commits into from
Oct 12, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
9 changes: 4 additions & 5 deletions app/service/cnpm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}
Expand All @@ -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');
}

}
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
9 changes: 6 additions & 3 deletions config/config.default.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down Expand Up @@ -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;
Expand Down
Loading