Skip to content

Commit dcf9c21

Browse files
authored
升级项目基础依赖,优化构建流程、开发体验 (#590)
* merge qiniu/master * 细节调整 * 将大量私有的方法标记为 deprecated & 更新文档 * 调试 workflow actions * 为 upload 的上传结果添加泛型 * 基本完成 * 移除一些非必要的文件及改动 * build 不应该使用 parallel * 添加 vscode workspace 配置文件 * update dev-test package.json * 针对 iife 输出 umd 格式 * update
1 parent 5c7686f commit dcf9c21

File tree

122 files changed

+34034
-62196
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

122 files changed

+34034
-62196
lines changed

.eslintignore

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
/src/__mock__
22
/src/__tests__
3-
/test/*
3+
/test/
4+
node_modules
45
dist
5-
site
6+
esm
7+
umd
68
*.js
9+
*.d.ts
10+
*.test.ts

.eslintrc.js

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,8 @@
11
module.exports = {
2-
extends: [
3-
'@qiniu'
4-
],
5-
settings: {
6-
"import/resolver": {
7-
node: {
8-
extensions: ['.js', '.ts'],
9-
moduleDirectory: ['node_modules', 'src/']
10-
}
11-
}
2+
root: true,
3+
extends: ['@qiniu'],
4+
parserOptions: {
5+
tsconfigRootDir: __dirname,
6+
project: ['./packages/*/tsconfig.json'],
127
}
138
}

.github/workflows/dev-check.yml

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,26 +10,32 @@ jobs:
1010
- uses: actions/setup-node@v3
1111
with:
1212
cache: 'npm'
13-
node-version: 12
14-
- run: npm install
15-
- run: npm run lint
13+
node-version: 16
14+
- run: |
15+
npm install
16+
npm run boot
17+
npm run lint
1618
test:
1719
runs-on: ubuntu-latest
1820
steps:
1921
- uses: actions/checkout@v3
2022
- uses: actions/setup-node@v3
2123
with:
2224
cache: 'npm'
23-
node-version: 12
24-
- run: npm install
25-
- run: npm run test
25+
node-version: 16
26+
- run: |
27+
npm install
28+
npm run boot
29+
npm run test
2630
build:
2731
runs-on: ubuntu-latest
2832
steps:
2933
- uses: actions/checkout@v3
3034
- uses: actions/setup-node@v3
3135
with:
3236
cache: 'npm'
33-
node-version: 12
34-
- run: npm install
35-
- run: npm run build
37+
node-version: 16
38+
- run: |
39+
npm install
40+
npm run boot
41+
npm run build

.github/workflows/npm-publish.yml

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,13 @@ jobs:
1111
- uses: actions/checkout@v3
1212
- uses: actions/setup-node@v3
1313
with:
14-
node-version: 12
14+
node-version: 16
1515
registry-url: https://registry.npmjs.org/
16-
- run: npm install
17-
- run: npm run build
18-
- run: npm publish
16+
- run: |
17+
npm install
18+
npm run boot
19+
npm run build
20+
cd packages/qiniu-js/
21+
npm publish --dry-run
1922
env:
2023
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}

.gitignore

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,4 @@
11
.DS_Store
22
.vscode
33
node_modules
4-
bower_components
5-
demo/config.js
6-
deploy.sh
7-
npm-debug.log
8-
dist
9-
test/config.json
104
coverage
11-
lib
12-
esm

.npmignore

Lines changed: 0 additions & 9 deletions
This file was deleted.

README.md

Lines changed: 28 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
* [准备](#ready)
1717
* [引入](#install)
1818
* [使用](#usage)
19-
* [运行示例](#demo)
19+
* [本地开发](#develop)
2020
* [说明](#note)
2121
* [常见问题](#faq)
2222

@@ -80,24 +80,12 @@ Qiniu-JavaScript-SDK 的示例 [Demo](http://jssdk-v2.demo.qiniu.io) 中的服
8080

8181
支持以下几种安装方式
8282

83-
* 直接使用静态文件地址:
84-
85-
```
86-
https://cdnjs.cloudflare.com/ajax/libs/qiniu-js/<version>/qiniu.min.js
87-
88-
// 当上方资源链接访问不稳定时,可选使用下方资源链接
89-
https://cdn.staticfile.org/qiniu-js/<version>/qiniu.min.js
90-
```
91-
92-
通过 script 标签引入该文件,会在全局生成名为 `qiniu` 的对象
93-
94-
9583
* 使用 NPM 安装
9684

9785
NPM 的全称是 Node Package Manager,是一个 [NodeJS](https://nodejs.org) 包管理和分发工具,已经成为了非官方的发布 Node 模块(包)的标准。如果需要更详细的关于 NPM 的使用说明,您可以访问 [NPM 官方网站](https://www.npmjs.com),或对应的 [中文网站](http://www.npmjs.com.cn/)
9886

9987
```shell
100-
npm install qiniu-js
88+
$ npm install qiniu-js
10189
```
10290

10391
```Javascript
@@ -106,9 +94,22 @@ Qiniu-JavaScript-SDK 的示例 [Demo](http://jssdk-v2.demo.qiniu.io) 中的服
10694
import * as qiniu from 'qiniu-js'
10795
```
10896

109-
* 通过源码编译
97+
* 直接通过 `script` 标签引入,通过这种方式将会在全局生成名为 `qiniu` 的对象
11098

111-
`git clone [email protected]:qiniu/js-sdk.git`,进入项目根目录执行 `npm install` ,执行 `npm run build`,即可在dist 目录生成 `qiniu.min.js`
99+
```html
100+
<script src="https://cdnjs.cloudflare.com/ajax/libs/qiniu-js/<version>/qiniu.min.js"></script>
101+
// 当上方资源链接访问不稳定时,可选用下方资源链接
102+
<script src="https://cdn.staticfile.org/qiniu-js/<version>/qiniu.min.js"></script>
103+
```
104+
105+
* 通过源码编译,依次执行以下命令即可在本地构建
106+
107+
``` bash
108+
$ git clone [email protected]:qiniu/js-sdk.git
109+
$ cd js-sdk
110+
$ npm install
111+
$ npm run build
112+
```
112113

113114
<a id="usage"></a>
114115

@@ -461,27 +462,20 @@ qiniu.compressImage(file, options).then(data => {
461462

462463
fopArr包含的具体管道操作解释见 [管道操作](https://developer.qiniu.com/dora/manual/processing-mechanism)
463464

464-
<a id="demo"></a>
465+
<a id="develop"></a>
465466

466-
### 运行示例
467+
### 本地开发
467468

468-
1. 进入 test 目录,按照目录下的 `config.json.example` 示例,创建 `config.json` 文件,其中,`Access Key``Secret Key` 按如下方式获取
469-
470-
* [开通七牛开发者帐号](https://portal.qiniu.com/signup)
471-
* [登录七牛开发者自助平台,查看 AccessKey 和 SecretKey](https://portal.qiniu.com/user/key) 。
472-
473-
```javascript
474-
{
475-
"AccessKey": "<Your Access Key>",
476-
"SecretKey": "<Your Secret Key>",
477-
"Bucket": "<Your Bucket Name>",
478-
"Port": 9000,
479-
"UptokenUrl": "<Your Uptoken_Url>", // demo 启动后会在本地 /uptoken 上提供获取 uptoken 的接口,所以这里可以填 'token'
480-
"Domain": "<Your Bucket Domain>" // Bucket 的外链默认域名,在 Bucket 的内容管理里查看,如:'http://xxx.bkt.clouddn.com/'
481-
}
482-
```
469+
```bash
470+
$ git clone [email protected]:qiniu/js-sdk.git
471+
$ cd js-sdk/
472+
$ npm install
473+
$ npm run boot
474+
$ npm run dev
475+
```
483476

484-
2. 进入项目根目录,执行 `npm install` 安装依赖库,然后打开两个终端,一个执行 `npm run serve` 跑 server, 一个执行 `npm run dev` 运行服务;demo1:`http://0.0.0.0:8080/test/demo1`;demo3:`http://0.0.0.0:8080/test/demo3`;demo1为测试上传功能的示例,demo3为测试图片压缩功能的示例;demo2 为测试 es6 语法的示例,进入 demo2 目录,执行 `npm install`,然后 `npm start` 运行 demo2;demo1、demo2 和 demo3 都共用一个 server,请注意 server 文件里的 `region` 设置跟 `config` 里的`region` 设置要保持一致。
477+
打开您的浏览器并访问终端中提示的地址即可访问开发调试页面。
478+
如果你在使用 `vscode`,推荐通过根目录下的 `js-sdk.code-workspace` 文件打开工作空间快速进行开发和调试。
485479

486480
<a id="note"></a>
487481

jest.config.js

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,17 @@
1+
function getProjectConfig(name) {
2+
return {
3+
displayName: name,
4+
testEnvironment: 'jsdom',
5+
transform: {
6+
".ts": 'ts-jest'
7+
},
8+
testMatch: [`<rootDir>/packages/${name}/src/**/*.test.ts`],
9+
}
10+
}
11+
112
module.exports = {
2-
transform: {
3-
".ts": 'ts-jest'
4-
},
5-
testRegex: '.+\\.test\\.ts$',
6-
testPathIgnorePatterns: [
7-
"esm",
8-
"lib",
9-
"examples",
10-
"node_modules"
13+
projects: [
14+
getProjectConfig('qiniu-js'),
15+
getProjectConfig('doc-site')
1116
]
12-
};
17+
}

js-sdk.code-workspace

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"folders": [
3+
{
4+
"name": "✨ root",
5+
"path": "."
6+
},
7+
{
8+
"name": "📦 dev-test",
9+
"path": "packages/dev-test"
10+
},
11+
{
12+
"name": "📦 qiniu-js",
13+
"path": "packages/qiniu-js"
14+
}
15+
]
16+
}

lerna.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"packages": [
3+
"packages/*"
4+
],
5+
"useNx": false,
6+
"npmClient": "npm",
7+
"version": "independent"
8+
}

0 commit comments

Comments
 (0)