Skip to content

Commit 93ee227

Browse files
author
winjo
committed
chore: config upload by env
1 parent cbd90b1 commit 93ee227

2 files changed

Lines changed: 20 additions & 8 deletions

File tree

README.md

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
# SpaceX
2-
> Ant Codespaces 纯前端版本临时代号
1+
# ALEX (ali light editor extension)
2+
> Ant Codespaces 极速版,无容器环境
33
44

55
## 项目启动
@@ -8,14 +8,15 @@
88

99
### 配置 antcode 私有令牌
1010
https://code.alipay.com/profile/private_tokens 找到私有临牌,在根目录新建文件 .env
11-
输入 `PRIVATE_TOKEN=<令牌>`,.env 已自动被 git 忽略,也可直接通过环境变量配置 PRIVATE_TOKEN
11+
输入 `PRIVATE_TOKEN=<令牌>`,.env 已被 git 忽略,也可直接通过环境变量配置 PRIVATE_TOKEN
1212

1313
### 启动项目
1414
```bash
1515
1. yarn
1616
2. npm run init
1717
3. npm start
1818
```
19+
终端打开输出的地址,默认端口 9009,如被占用,会从 9009 查找可用端口
1920

2021
## 项目研发
2122
### 安装依赖
@@ -27,17 +28,20 @@
2728
2. 通过命令 npm run create <package> 新建项目
2829

2930
### 构建打包
30-
```sh
31+
```bash
3132
# 构建所有 packages
3233
npm run build
3334
# 单独构建 package
3435
npm run build -- --scope <package>
3536
# 单独构建并监听
3637
npm run build -- --scope <package> --watch
3738
# 构建 worker 和 webview 资源并发布 cdn
39+
# 需要在 .env 配置 ak,从 https://yuyan.antfin-inc.com/cloud-ide/services/accesskey 获取 alex-app 的 ak
3840
node scripts/build-assets
3941
# bundle 成 umd 文件
4042
node scripts/bundle
4143
# 发布,此步骤会自动构建打包,运行测试等,可通过 --no 跳过一些步骤
44+
# --no-test 跳过测试
45+
# --no-assets 跳过 worker 和 webview 资源构建,在 kaitian 未升级的情况下跳过
4246
node scripts/release
4347
```

scripts/utils/upload.js

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,25 @@
11
const Basement = require('@alipay/basement');
22
const urllib = require('urllib');
33
const path = require('path');
4+
const chalk = require('chalk');
45

5-
const basement = new Basement({
6+
require('dotenv').config({ path: path.join(__dirname, '../../.env') });
7+
8+
const options = {
69
// 从 cloud-ide 获取 appId 和 masterKey:
710
// https://basement.alipay.com/doc/detail/ziarab#da1386cd
8-
appId: '6039249f8ee5e40583902ff7',
9-
masterKey: 'aaItsFwEiBDX_WgXM5DDmcA4',
11+
appId: process.env.APP_ID,
12+
masterKey: process.env.MASTER_KEY,
1013
urllib,
1114
endpoint: 'https://basement-gzone.alipay.com',
12-
});
15+
};
1316

1417
exports.uploadFile = async (filepath, filename) => {
18+
if (!options.appId || !options.masterKey) {
19+
throw new Error(chalk.red('请配置文件服务 Access Key'));
20+
}
21+
22+
const basement = new Basement(options);
1523
if (!filename) {
1624
filename = path.basename(filepath);
1725
}

0 commit comments

Comments
 (0)