Skip to content

Commit

Permalink
release @arco-design/arco-cli@1.21.2
Browse files Browse the repository at this point in the history
fix: allow user to init project without login
  • Loading branch information
Helium-Z committed Oct 29, 2021
1 parent 37da8ab commit 918f393
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 19 deletions.
2 changes: 1 addition & 1 deletion packages/arco-cli/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@arco-design/arco-cli",
"version": "1.21.1",
"version": "1.21.2",
"description": "Init an Arco material project quickly",
"keywords": [
"arco",
Expand Down
19 changes: 13 additions & 6 deletions packages/arco-cli/src/bin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,8 @@ function registerCommand() {
program
.command('sync')
.description(locale.CMD_DES_SYNC)
.option('-s, --screenshot [screenshotPath]', locale.TIP_SYNC_SCREENSHOT)
// TODO rewrite this command
// .option('-s, --screenshot [screenshotPath]', locale.TIP_SYNC_SCREENSHOT)
.option('--from-current-package', locale.TIP_SYNC_FROM_CURRENT_PACKAGE)
.option('--fetch', locale.TIP_SYNC_FETCH)
.action(async ({ screenshot, fromCurrentPackage, fetch }) => {
Expand Down Expand Up @@ -176,11 +177,17 @@ function registerCommand() {
}

printLogo();
registerCommand();

if (process.argv[2] !== 'env' && checkEnv() === false) {
print.warn(locale.TIP_SET_ENV_FIRST);
process.exit(0);
switchEnv()
.then(() => {
program.parse(process.argv);
})
.catch((err) => {
print.error(err);
process.exit(0);
});
} else {
program.parse(process.argv);
}

registerCommand();
program.parse(process.argv);
8 changes: 1 addition & 7 deletions packages/arco-cli/src/env.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import axios from 'axios';
import { getGlobalInfo, print, writeGlobalInfo } from '@arco-design/arco-dev-utils';
import inquirer from 'inquirer';
import { login } from '@arco-design/arco-cli-auth';
import locale from './locale';

export function checkEnv() {
Expand All @@ -25,10 +24,7 @@ export function printEnv() {
export async function switchEnv() {
const {
data: { result: hostInfo },
} = await axios.get('https://arco.design/material/api/getHostInfo', {
// TODO remove it
headers: { 'x-arco-dev': '1' },
});
} = await axios.get('https://arco.design/material/api/getHostInfo');
const { env } = await inquirer.prompt({
type: 'list',
name: 'env',
Expand All @@ -45,8 +41,6 @@ export async function switchEnv() {
print.success(
env === 'private' ? locale.TIP_SWITCH_SUCCESS_TO_PRIVATE : locale.TIP_SWITCH_SUCCESS_TO_PUBLIC
);
print.info(locale.TIP_NEED_LOGIN_AGAIN);
login();
} else {
print.error('[arco env]', 'failed to get host info.');
}
Expand Down
8 changes: 3 additions & 5 deletions packages/arco-cli/src/locale/zh-CN.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,9 @@ export default {
TIP_TEMPLATE_CREATE: '基于已有项目创建物料模板',
TIP_SHOW_HELP: '如需查看某个子命令,可以使用子命令帮助,如:arco sync -h',

TIP_SET_ENV_FIRST: '请先运行 arco env --switch 设置环境',
TIP_SELECT_ENV: '请选择使用的 Arco 物料平台版本',
TIP_ENV_PUBLIC: '公共版本',
TIP_ENV_PRIVATE: '内网版本(仅限内部员工使用,需使用 SSO 登录)',
TIP_ENV_PUBLIC: '公共版本(使用 GitHub 账户授权登录)',
TIP_ENV_PRIVATE: '内网版本(使用 ByteDance SSO 验证登录,仅限内部员工使用)',
TIP_SWITCH_SUCCESS_TO_PUBLIC: '已成功切换至公共环境',
TIP_SWITCH_SUCCESS_TO_PRIVATE: '已成功切换至内网环境',
TIP_ADD_GROUP_MEMBER: '输入需要添加的用户的用户名',
Expand All @@ -44,8 +43,7 @@ export default {
TIP_ADD_GROUP_MEMBER_FAIL: '添加成员失败:',
TIP_REMOVE_GROUP_MEMBER_SUCCESS: '移除成员成功:',
TIP_REMOVE_GROUP_MEMBER_FAIL: '移除成员失败:',
TIP_NEED_LOGIN_AGAIN: '切换环境需要重新登录...',
TIP_NO_ENV_SET: '当前环境未选择,请运行 arco env --switch 设置环境',
TIP_NO_ENV_SET: '当前环境未选择,请运行 arco env -s 设置环境',

LABEL_GROUP_OWNER: '管理员',
LABEL_GROUP_MASTER: '协作者',
Expand Down

0 comments on commit 918f393

Please sign in to comment.