Skip to content

Commit 2375908

Browse files
authored
Merge pull request #130 from modern-js-dev/fix/domGetter-select
Fix/dom getter select
2 parents dd10c3a + 33e9df5 commit 2375908

Some content is hidden

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

85 files changed

+26831
-62166
lines changed

.changeset/README.md

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Changesets
2+
3+
Hello and welcome! This folder has been automatically generated by `@changesets/cli`, a build tool that works
4+
with multi-package repos, or single-package repos to help you version and publish your code. You can
5+
find the full documentation for it [in our repository](https://github.com/changesets/changesets)
6+
7+
We have a quick list of common questions to get you started engaging with this project in
8+
[our documentation](https://github.com/changesets/changesets/blob/main/docs/common-questions.md)

.changeset/config.json

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"$schema": "https://unpkg.com/@changesets/[email protected]/schema.json",
3+
"changelog": "@changesets/cli/changelog",
4+
"commit": false,
5+
"linked": [],
6+
"access": "restricted",
7+
"baseBranch": "master",
8+
"updateInternalDependencies": "patch",
9+
"ignore": []
10+
}

.eslintrc.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ module.exports = {
4747
},
4848
overrides: [
4949
{
50-
files: ['scripts/*', '*.config.js', '.eslintrc.js', '**/__tests__/**'],
50+
files: ['scripts/**', '*.config.js', '.eslintrc.js', '**/__tests__/**'],
5151
rules: {
5252
'object-curly-newline': 'off',
5353
'no-restricted-globals': 'off',

.github/workflows/ci.yml

+71
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
name: 'ci'
2+
on:
3+
push:
4+
branches:
5+
- master
6+
7+
pull_request:
8+
branches:
9+
- master
10+
11+
jobs:
12+
test:
13+
runs-on: ubuntu-20.04
14+
strategy:
15+
matrix:
16+
node-version: [14]
17+
steps:
18+
- uses: actions/checkout@v2
19+
- name: Use Node.js ${{ matrix.node-version }}
20+
uses: actions/setup-node@v2
21+
with:
22+
node-version: ${{ matrix.node-version }}
23+
- name: Cache .pnpm-store
24+
uses: actions/cache@v1
25+
with:
26+
path: ~/.pnpm-store
27+
key: ${{ runner.os }}-node${{ matrix.node-version }}-${{ hashFiles('**/pnpm-lock.yaml') }}
28+
- name: Install pnpm
29+
run: curl -f https://get.pnpm.io/v6.14.js | node - add --global pnpm@6
30+
- name: install dependency
31+
run: pnpm install --filter=\!garfish-docs
32+
- name: Run unit tests
33+
run: pnpm test
34+
35+
e2e-test:
36+
runs-on: ubuntu-20.04
37+
strategy:
38+
matrix:
39+
node-version: [14]
40+
steps:
41+
- uses: actions/checkout@v2
42+
- name: Use Node.js ${{ matrix.node-version }}
43+
uses: actions/setup-node@v2
44+
with:
45+
node-version: ${{ matrix.node-version }}
46+
- name: Cache .pnpm-store
47+
uses: actions/cache@v1
48+
with:
49+
path: ~/.pnpm-store
50+
key: ${{ runner.os }}-node${{ matrix.node-version }}-${{ hashFiles('**/pnpm-lock.yaml') }}
51+
- name: Install pnpm
52+
run: curl -f https://get.pnpm.io/v6.14.js | node - add --global pnpm@6
53+
- name: install dependency
54+
run: pnpm install --filter=\!garfish-docs
55+
- name: build
56+
run: pnpm build:all
57+
- name: Run cypress test
58+
uses: cypress-io/github-action@v2
59+
with:
60+
install: false
61+
start: npx cross-env CI_TEST_ENV=true pnpm dev
62+
wait-on: 'http://localhost:2333,http://localhost:2444,http://localhost:2555,http://localhost:2666,http://localhost:2777'
63+
wait-on-timeout: 120
64+
parallel: true
65+
record: true
66+
spec: cypress/integration/**
67+
env:
68+
CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }}
69+
# Recommended: pass the GitHub token lets this action correctly
70+
# determine the unique run id necessary to re-run the checks
71+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/documentation.yml

+27-15
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,31 @@ on:
66
- gh-pages
77
jobs:
88
build-and-deploy:
9-
runs-on: ubuntu-latest
9+
runs-on: ubuntu-20.04
10+
strategy:
11+
matrix:
12+
node-version: [14]
1013
steps:
11-
- uses: actions/checkout@v2
12-
- name: build
13-
run: |
14-
cd ./website
15-
npm install
16-
npm run build
17-
cd ../
18-
19-
- name: Deploy
20-
uses: peaceiris/actions-gh-pages@v3
21-
with:
22-
github_token: ${{ secrets.GITHUB_TOKEN }}
23-
publish_dir: ./docs
24-
cname: garfish.top
14+
- uses: actions/checkout@v2
15+
- name: Use Node.js ${{ matrix.node-version }}
16+
uses: actions/setup-node@v2
17+
with:
18+
node-version: ${{ matrix.node-version }}
19+
- name: Cache .pnpm-store
20+
uses: actions/cache@v1
21+
with:
22+
path: ~/.pnpm-store
23+
key: ${{ runner.os }}-node${{ matrix.node-version }}-${{ hashFiles('**/pnpm-lock.yaml') }}
24+
- name: Install pnpm
25+
run: curl -f https://get.pnpm.io/v6.14.js | node - add --global pnpm@6
26+
- name: build
27+
run: |
28+
pnpm install --filter garfish-docs
29+
pnpm run build --filter garfish-docs
30+
cd ./
31+
- name: Deploy
32+
uses: peaceiris/actions-gh-pages@v3
33+
with:
34+
github_token: ${{ secrets.GITHUB_TOKEN }}
35+
publish_dir: ./docs
36+
cname: garfish.top
+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*'
7+
8+
jobs:
9+
release:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v2
13+
with:
14+
fetch-depth: 0
15+
- run: npx conventional-github-releaser -p angular
16+
env:
17+
CONVENTIONAL_GITHUB_RELEASER_TOKEN: ${{secrets.GITHUB_TOKEN}}

CONTRIBUTING.md

+57-122
Original file line numberDiff line numberDiff line change
@@ -1,158 +1,93 @@
1-
# Contributing to Garfish
1+
## Contributing to Garfish
22

3-
😁 Hello, 很高兴你能有兴趣参与 Garfish 项目,下面是一些本仓库开发提示相关的介绍
3+
😁 Excited to hear that you are interested in contributing to this project! Thanks!
44

5-
- 开发设置
6-
- 项目结构
7-
- 打包介绍
8-
- 调试流程
5+
## Setup (locally)
96

10-
Garfish 仓库使用 learn 和一些额外的构建脚本共同处理,这意味着,learn 的命令也都是可以用的
7+
This project uses pnpm to manage the dependencies, install it if you haven't via
118

12-
## 开发设置
13-
14-
如果你想参与 Garfish 的开发或贡献代码,确保你安装以下依赖和插件(vscode 插件)
15-
16-
- 确保你的 node 为 **,npm 版本为 **
17-
- 安装 `Eslint` 插件
18-
- 安装 `EditorConfig for VS Code` 插件
19-
20-
克隆完本仓库后
21-
22-
```shell
23-
$ npm run setup # 安装依赖
9+
```bash
10+
npm i -g pnpm
2411
```
2512

26-
## 项目结构
27-
28-
- `dev`: 完整的 Garfish 调试模板,里面存放一个 main 模块和多个子模块
13+
Clone this repo to your local machine and install the dependencies.
2914

30-
- `packages`: 存放所有的子包(包括 runtime、tools 和 private 的包)
31-
32-
- `core`: runtime 和 plugin 相关的包
33-
34-
- `garfish`: garfish runtime 的入口包
35-
- `router`: 路由
36-
- `sandbox`: 沙箱
37-
- `statistics`: 信息收集上报的插件
38-
39-
- `tool`: garfish cli 和其他工具包
40-
- `cli`: cli 的基础包
41-
- `cli-create`: 创建微前端工程模板
42-
- `cli-dev`: 调试微前端
43-
- `proxy`: whistle 相关代理 api 的封装
44-
- `shared`: tool 公共依赖包
45-
46-
- `scripts`: 与构建调试相关的相关脚本,熟悉他们会很有帮助
47-
- `dev.js`: 调试开发的自动化脚本,启动 dev 工程并自动 watch 源码
48-
- `build.js`: 使用 rollup 打包成多种格式的包
49-
- `createPackage.js`: 生成新的子包模板工程
50-
- `utils.js`: 一些工具函数
51-
- `verifyCommit.js`: commit 信息的校验
52-
- `jestTest.js`: 启动单元测试以及测试服务器
53-
54-
## 打包介绍
15+
```bash
16+
pnpm install
17+
```
5518

56-
### Core
19+
## Development
5720

58-
Garfish runtime 相关的包使用 rollup 来构建,每个子包使用同一份脚本来构建,当然也可以做差异化的配置,在子包下的 `package.json` 下面中增加 `buildOptions`,他有以下字段,打包的文件将生成到 `dist` 下,使用 `npm run build:core` 可以打包所有 core 下面的包
21+
To build all the packages at once, run the following command on the project root
5922

60-
```json
61-
"buildOptions": {
62-
"name": "Garfish", // 当打包成 umd 或者 esm-browser,以此为例,将以 Garfish 的 namespace 注入到 window 中。没有指定时,默认用子包文件夹转为驼峰后的名字
63-
"devTemplate": "complete", // 选择需要调试的模板,complete 或 module
64-
"formats": [ // 制定需要打包的格式
65-
"umd",
66-
"cjs",
67-
"esm-browser",
68-
"esm-bundler"
69-
]
70-
}
23+
```bash
24+
pnpm build
7125
```
7226

73-
我们以 garfish 这个子包为例介绍打包的流程
27+
Build with watch mode
7428

75-
```shell
76-
$ yarn build garfish -f=umd -n -s -m
29+
```bash
30+
pnpm dev
7731
```
7832

79-
- `-f`: formats,指定打包格式
80-
- `-n`: nocheck,打包时不检查 ts 类型错误
81-
- `-s`: sourcemap,打包后生成 sourcemap
82-
- `-m`: mergetypes,打包完成后字段合并类型声明为一个文件
83-
- `-e`: noExternal,garfish 内部所用到的包都打进一个文件中
84-
85-
#### 打包后的文件介绍
86-
87-
- `dist/garfish.cjs.js`: cjs 的包,里面包含所有的警告和提示信息
88-
- `dist/garfish.cjs.prod.js`: cjs 的包,所有的警告信息都被删除掉了
89-
- `dist/garfish.esm-browser.js`: esm 的包,子包用到依赖都被打进来了
90-
- `dist/garfish.esm-bundler.js`: esm 的包,子包的依赖都没有被打进来,供使用者在类 webpack 的打包工具的帮助下的场景使用
91-
- `dist/garfish.umd.js`: umd 的包,兼容多种格式,子包的依赖都被打进来了
33+
## Run Demo
9234

93-
### Tool
35+
To run Garfish locally, you can run
9436

95-
tools 的包使用 tsc 来打包,`npm run build:tool` 打包所有 tool 下面的包。打包某一个子包可以用下面这样的例子
96-
97-
```shell
98-
# 打包 @garfish/garfish-cli 这个子包
99-
$ lerna run build --scope @garfish/garfish-cli
37+
```bash
38+
pnpm dev
10039
```
10140

102-
## 调试流程
41+
The server will restart automatically every time the builds get updated.
10342

104-
由于 Garfish 的调试需要同时调试**主工程**和多个**子工程**,靠手动去搭建项目调试是一个费时费力的流程,所以我们通过脚本来自动化构建前置的环境<br/>
105-
子包如果需要有调试模板工程的能力,需要在当前子包的 `package.json` 中的 `buildOptions` 中指定 `devTemplate` 字段
43+
## Project Structure
10644

107-
```shell
108-
# 调试 所有子包
109-
$ yarn build:watch
110-
$ yarn dev core
111-
```
45+
### Monorepo
11246

113-
然后整个 core 里面的子包,源码的改动都会实时同步打包到 `/dev/main/dist` 下。
47+
We use monorepo to manage multiple packages
11448

115-
```shell
116-
# 调试 tool 下的包
117-
$ lerna run dev --scope @garfish/garfish-cli
49+
```js
50+
website
51+
packages
52+
runtime
53+
browser-snapshot/ - snapshot sandbox
54+
browser-vm/ - vm sandbox
55+
core/ - core module with sandbox、loader、hooks、router
56+
garfish/
57+
hooks/ - hooks
58+
loader/ - loader
59+
remote-module/
60+
router/ - router
61+
utils/ - common utils
11862
```
11963

120-
## 常见的操作
64+
## The operation of the common
12165

12266
```shell
123-
# 调试 core/garfish 子包
124-
$ yarn dev garfish
125-
126-
# 调试 core/sandbox 子包,并在浏览器中打开调试页面
127-
$ yarn dev sandbox -o
128-
129-
# 单独打包 core/garfish 子包,并把相关的依赖的子包打进去,实时监听文件的变动打包
130-
$ yarn build garfish -e -w
131-
132-
# 单独打包 core/garfish 子包,并把相关的依赖的子包打进去,合并打包后的 .d.ts
133-
$ yarn build garfish -e -m
67+
# Debug core/garfish package
68+
$ pnpm dev
13469

135-
# 打包所有的 core 下面的子包
136-
$ yarn build:core
70+
# Debug core/sandbox package, and open the debug page in your browser
71+
$ pnpm dev sandbox -o
13772

138-
# 调试 tool/cli 这个子包
139-
$ lerna run dev --scope=@garfish/garfish-cli
73+
# Separate packing core/garfish son packages, and the relevant dependent child bag inside, packing real-time monitoring file changes
74+
$ pnpm build garfish -e -w
14075

141-
# 单独打包 tool/cli 这个子包
142-
$ lerna run build --scope=@garfish/garfish-cli
76+
# Separate packing core/garfish son packages, and the relevant dependent child bag in, after the merger packaging. Which s
77+
$ pnpm build garfish -e -m
14378

144-
# 打包所有 tool 下的子包
145-
$ yarn build:tool
79+
# Pack all the core below package
80+
$ pnpm build:core
14681

147-
# 打包 core tool 下面所有的子包
148-
$ yarn build:all
82+
# The core and tool below all of the packages
83+
$ pnpm build:all
14984

150-
# core 下创建一个新的子包工程
151-
$ yarn pkg <pkgName>
85+
# Under the core to create a new project
86+
$ pnpm pkg <pkgName>
15287

153-
# tool 下创建一个新的子包工程
154-
$ yarn pkg <pkgName> -t=tool
88+
# Under the tool to create a new project
89+
$ pnpm pkg <pkgName> -t=tool
15590

156-
# 发布一个 latest 的包(betaalpha 同理)
157-
$ lerna publish --dist-tag=latest
91+
# Release a latest package (beta, alpha in the same way)
92+
$ pnpm release
15893
```

0 commit comments

Comments
 (0)