rigjs 2.1.27 → 3.0.0-alpha

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. package/README.md +146 -183
  2. package/README_CN.md +151 -137
  3. package/built/index.js +145 -175
  4. package/demo/package.json +8 -6
  5. package/demo/package.rig.json5 +64 -10
  6. package/demo/rig_dev/.gitkeep +0 -0
  7. package/demo/rig_helper.js +5 -9
  8. package/demo/vue.config.js +1 -1
  9. package/demo/yarn.lock +20 -7
  10. package/doc/cicd_cn.md +120 -0
  11. package/doc/cmd_cn.md +0 -0
  12. package/doc/dependencies.md +0 -0
  13. package/doc/dependencies_cn.md +28 -0
  14. package/doc/share_cn.md +8 -0
  15. package/jest/test.rig.json5 +14 -0
  16. package/jest.config.ts +10 -1
  17. package/lib/add/index.ts +37 -0
  18. package/lib/build/build.md +6 -0
  19. package/lib/build/index.ts +64 -58
  20. package/lib/classes/RigConfig.test.ts +14 -0
  21. package/lib/classes/RigConfig.ts +191 -0
  22. package/lib/classes/cicd/CICD.ts +6 -7
  23. package/lib/classes/cicd/CICDCmd.ts +1 -0
  24. package/lib/classes/cicd/Deploy/CDN.ts +1 -1
  25. package/lib/classes/cicd/DirLevel.ts +1 -1
  26. package/lib/classes/cicd/Endpoint.ts +7 -1
  27. package/lib/classes/dependencies/Dep.ts +56 -0
  28. package/lib/dev/index.ts +44 -0
  29. package/lib/init/index.ts +118 -0
  30. package/lib/install/{index.js → index.ts} +3 -6
  31. package/lib/postinstall/{index.js → index.ts} +12 -20
  32. package/lib/preinstall/index.ts +78 -0
  33. package/lib/print/index.ts +38 -0
  34. package/lib/publish/index.ts +187 -177
  35. package/lib/rig/index.ts +29 -13
  36. package/lib/sync/index.test.ts +4 -0
  37. package/lib/sync/index.ts +32 -0
  38. package/lib/utils/fsHelper.ts +37 -1
  39. package/lib/utils/objectHelper.ts +12 -0
  40. package/lib/utils/regexHelper.test.ts +12 -0
  41. package/lib/utils/{regex.ts → regexHelper.ts} +4 -1
  42. package/package.json +9 -8
  43. package/package.rig.json5 +8 -0
  44. package/tsconfig.json +4 -2
  45. package/demo/cicd.rig.json5 +0 -56
  46. package/lib/init/cicd.rig.json5 +0 -11
  47. package/lib/init/index.d.ts +0 -6
  48. package/lib/init/index.js +0 -189
  49. package/lib/init/rig_helper.js +0 -14
  50. package/lib/install/index.d.ts +0 -5
  51. package/lib/postinstall/index.d.ts +0 -6
  52. package/lib/preinstall/index.d.ts +0 -7
  53. package/lib/preinstall/index.js +0 -198
  54. package/lib/preinstall/index.test.js +0 -16
  55. package/lib/print/index.js +0 -33
package/README.md CHANGED
@@ -1,210 +1,173 @@
1
1
  # rig
2
+ *[中文文档](./README_CN.md)*
3
+ - [Goals](#Goals)
4
+ - [Get started:Modular developing by rigjs](#Get started:Modular developing by rigjs.)
5
+ - [dependencies config](./doc/dependencies_cn.md)
6
+ - [CICD config](./doc/cicd_cn.md)
7
+ - [share config](./doc/share_cn.md)
2
8
 
3
- ## [中文文档](./README_CN.md)
4
-
5
- - [Getting Started](#getting-started)
6
- - [How It Works](#how-it-works)
7
- - Commands
8
- - [`rig init`](#rig-init)
9
- - [`rig install`](#rig-install)
10
- - [`rig check`](#rig-check)
11
- - [`rig tag`](#rig-tag)
12
-
13
- ## Getting started
14
- ###Prerequisites
15
- - Should install yarn first.Rig is using yarn workspace to do module-hoisting.
16
- ```shell
17
- npm i -g yarn
18
- ```
19
-
20
- ###Installation
21
9
 
22
- ```shell script
10
+ ## Get started:Modular developing by rigjs.
11
+ ### 0.Prerequisites
12
+ #### Install yarn
13
+ ```shell
23
14
  yarn global add rigjs
24
15
  ```
16
+ Rigjs use yarn workspaces to achieve module-hoisting. [About yarn workspaces](https://classic.yarnpkg.com/en/docs/workspaces).
17
+ #### NodeJS version >= 14
18
+ Use [n](https://github.com/tj/n) to update NodeJS.
19
+ ```shell
20
+ yarn global add n
21
+ #upgrade to lts
22
+ sudo n lts
23
+ #specify the version.
24
+ sudo n 14.19.1
25
+ ```
25
26
 
26
- ###Configuration
27
- You could try the demo for quick practice.
28
-
29
- ####1.init rig in your project
30
- In your project's root path.
27
+ ### 1.Initialize rigjs configuration。
31
28
 
32
29
  ```shell script
30
+ #in your project's root path(same level with package.json):
33
31
  rig init
34
32
  ```
33
+ package.rig.json5 will be added in root path.
35
34
 
36
- package.rig.json5 will be added to your project's root.
37
-
38
- ####2.Put the modules you want in git repos
39
- - Create semver style tag for your modules
40
-
41
- - Tags like 1,1.0,1.0.0,v1.0.0-alpha.110 are supported.
42
-
43
- Or you can just use following repos for testing:
44
-
45
- rig-test-1:git@github.com:FlashHand/rig-test-1.git
46
-
47
- rig-test-2:git@github.com:FlashHand/rig-test-2.git
48
-
49
- ####3.configuring package.rig.json5
35
+ ### 2.Use rigjs to install existing repos.
36
+ #### 2.1 Method-one:rig add
37
+ rig add [your git ssh url] [tag]
38
+ e.g.
39
+ ```shell
40
+ rig add git@github.com:FlashHand/rig-demo-1.git 0.0.1
41
+ ```
42
+ import or require the module.
43
+ ```ecmascript 6
44
+ const {hello} = require('rig-demo-1');
45
+ hello();
46
+ ```
50
47
 
51
- ***copy this and try***
48
+ #### 2.2 Method-two:change package.rig.json5
52
49
  ```json5
53
- //dev is false by default
54
- [
55
- // {
56
- // name: 'module',//module's name
57
- // source: 'git@git.domain.com:path/module.git',//module's source,not supporting http for now.
58
- // version: '1.0.0',//Notice:this used as tag.module's version ,
59
- // },
60
- {
61
- name: 'rig-test-1',
62
- source: 'git@github.com:FlashHand/rig-test-1.git',
63
- version: '1.0.0',
64
- },
65
- {
66
- name: 'rig-test-2',
67
- source: 'git@github.com:FlashHand/rig-test-2.git',
68
- version: '1.0.1',
69
- dev: true
50
+ {
51
+ dependencies: {
52
+ 'rig-demo-1': {
53
+ source: 'git@github.com:FlashHand/rig-demo-1.git',
54
+ version: '0.0.1',
55
+ }
70
56
  }
71
- ]
57
+ }
72
58
  ```
73
-
74
- ####4.run install:
75
- ```shell script
76
- yarn
59
+ then
60
+ ```shell
61
+ yarn install
77
62
  ```
63
+ ### 3.Use rigjs to develop an existing repo.
64
+ #### 3.1 Method-one:rig dev
65
+ rig dev [package's name|git-ssh-url]
78
66
 
79
- **Result:**
80
-
81
- rig-test-1 will be installed in node_modules.
82
-
83
- rig-test-2 will be cloned to rigs/.A shortcut of rig-test-2 will be created in node_modules.
84
-
85
- ## Main Features
86
- ###Intergrating and reusing codes really fast.
87
- 1. Git is enough.No need to publish to npm or private registry.Much simpler than git submodule.
88
- 2. Easily configurable.After configuration in simply use 'yarn install' and import/require your modules just like npm modules.
89
- 3. Support modules in any scale: from a simple js file to many web page files.
90
- 4.
91
-
92
- ###Easily develop and debug modules inside your project.
93
-
94
- ###All modules managed by rigjs are flatten.
95
-
96
-
97
-
98
- 1. Put the modules you wanna intergrating in git repos.
99
- 2. Configure those modules in
100
-
101
-
102
- 1. Integrating other git reposCreated for modular architecture.
103
- 2. An organizer for multi repos.
104
- 3. You can develop and test your module within your project just by setting **dev** to true,then rigjs automatically create shortcuts in node_modules folder for your developing modules in rigs folder.
105
- 4. Modules are hoisted,because rigjs uses yarn's workspace.
106
- 5. Automatically create shortcuts in node_modules folder for your developing modules in rigs folder.
107
-
108
-
109
- ## How it works
110
-
111
- #### package.rig.json5
112
-
113
- Rig is inspired by cocoapods. Not like those popular monorepo solutions,rig is a tool for organizing multi repos. So rig
114
- create a file named "package.rig.json5". Data in "package.rig.json5" can look like this:
67
+ When package is already in package.rig.json5:
68
+ ```shell
69
+ rig dev rig-demo-1
70
+ ```
71
+ When package is not in package.rig.json5:
72
+ ```shell
73
+ rig dev git@github.com:FlashHand/rig-demo-1.git
74
+ ```
115
75
 
76
+ **rig-demo-1** will be installed in rig_dev directory.And a symlink of the module will be created in node_modules.
77
+ #### 3.1 Method-two:change package.rig.json5
116
78
  ```json5
117
- //dev is false by default
118
- //dev 默认为false
119
- [
120
- // {
121
- // name: 'r-a',//module's name
122
- // source: 'git@git.domain.com:common/r-a.git',//module's source
123
- // version: '1.0.0',//Notice:this used as tag.module's version ,
124
- // },
125
- {
126
- name: 'r-b',
127
- source: 'git@git.domain.com:common/r-b.git',
128
- version: '1.0.0',
129
- },
130
- {
131
- name: 'r-c',
132
- source: 'git@git.domain.com:common/r-c.git',
133
- version: '1.0.0',
134
- dev: true
79
+ {
80
+ dependencies: {
81
+ 'rig-demo-1': {
82
+ source: 'git@github.com:FlashHand/rig-demo-1.git',
83
+ version: '0.0.1',
84
+ dev: true //false by default
85
+ }
135
86
  }
136
- ]
137
- ```
138
-
139
- package.rig.json5 has an array of modules.
140
-
141
- So rig create a folder named "rigs".
142
-
143
- When dev is true,the module will be cloned in rigs/**(using master branch)**.
144
-
145
- And it gets automatically linked in node_modules.
146
-
147
- #### How rig modifies package.json
148
-
149
- ```javascript
150
- //Rig will insert these to package.json
151
- //Rig won't cover your preinstall or postinstall's settings.Scripts and workspaces will be appended.
152
- let inserted = {
153
- private: true,
154
- workspaces: [
155
- "rigs/*",
156
- "rigs_dev/*"
157
- ],
158
- scripts: {
159
- preinstall: "rig preinstall",
160
- postinstall: "rig postinstall",
161
- }
162
87
  }
163
88
  ```
164
-
165
- **How to remove your modules**
166
-
167
- Remove your modules from both package.json and package.rig.json5 then run **rig install** or **yarn install**.
168
-
169
- //TODO:
170
- rig check //if has dev:true then end shell rig tag //using package.json version
171
-
172
- ## Command
173
-
174
- ### rig init
175
-
176
- 1. create a "package.rig.json5" file
177
- 2. insert config to package.json
178
- 3. create "rigs" folder
179
- 4. modify .gitignore
180
-
181
- ### rig install
182
-
183
- equals to "yarn install"
184
-
185
- ### rig check
186
-
187
- If a module's dev status is true in "package.rig.json5",the config will not be passed!
188
-
189
- Make sure you are not using developing modules for production.
190
-
191
- ### rig tag
192
-
193
- Using version in package.json to tag.
194
-
195
- ### rig --vueenv <env>
196
-
197
- This command is specially for vue.This command reads the file named "env.rig.json5" in the root directory, and looks for
198
- the environment configuration in mode <env>.Then it will create a file named ".env.rig" or overwrite the file if ".env.rig" is not
199
- existed.
200
- After "rig --vueenv" you must use "--mode rig" to make it effective.
201
- e.g.
89
+ then
202
90
  ```shell
203
- #serving a local site in dev enviroment
204
- rig --env dev && vue-cli-service serve --mode rig
205
- #building a site in prod enviroment
206
- rig --env prod && vue-cli-service build --mode rig
91
+ yarn install
207
92
  ```
208
93
 
94
+ ### 4.Create and develop a new rigjs module。
95
+ #### 4.1 Create a git repo。
96
+ get git-ssh url: git@github.com:FlashHand/rig-demo-1.git
97
+ #### 4.2 Start developing your modules in rigjs dependencies
98
+ rig dev git@github.com:FlashHand/rig-demo-1.git
99
+ #### 4.3 Initialize your module
100
+ ```shell
101
+ cd your_project_path
102
+ cd rig_dev/rig-demo-1
103
+ yarn init
104
+ echo "module.export={hello:()=>{console.log('hello')}}" > index.js
105
+ ```
106
+ #### 4.4 Use rigjs modules in your main project。
107
+ ```ecmascript 6
108
+ const {hello} = require('rig-demo-1');
109
+ hello();
110
+ ```
111
+ #### 4.5 Use rigjs module in production。
112
+ publish tag
113
+ ```shell
114
+ cd rig_dev/rig-demo-1
115
+ git add .
116
+ git commit -m 'demo for rig'
117
+ git tag 0.0.1
118
+ git push origin your_branch --tag
119
+ ```
120
+ Modify package.rig.json5
121
+ - Change the module's version
122
+ - Set dev to false.Don't use dev mode in production and should specify the version you need.
123
+ ```json5
124
+ {
125
+ dependencies: {
126
+ 'rig-demo-1': {
127
+ source: 'git@github.com:FlashHand/rig-demo-1.git',
128
+ version: '0.0.1',
129
+ // dev:true//Don't use dev mode in production and should specify the version you need.
130
+ }
131
+ }
132
+ }
133
+ ```
209
134
 
135
+ ## Advantages
136
+ - 💡Rigjs only needs git.No need to publish packages to private registry.
137
+ - ⚡️Instant code sharing between multiple projects and multiple developers.Packages can be easily installed by git-ssh-url and tag.
138
+ - ⚙️Auto npm link in dev mode.Import or require packages just like normal node_modules with friendly code suggestion.
139
+ - 🔍Easily develop packages within your projects.Packages in *dev* mode are all in *rig_dev* folder.
140
+ - 💨Easily transform existing code into a sharable package for multiple projects.
141
+ - 📏Large content scale.You can share from a simple js file to multiple files that contains many pages.
142
+ - 🧹Flat dependencies.No need to worry complex packages' relationship.
143
+
144
+ ## Goals
145
+ ### Sharing codes or files.
146
+ 1. Reuse codes between different developers or different projects in most flexible and unobtrusive way.
147
+ 2. Easily turn modules into developing mode,no need to use npm link or change package.json.
148
+ 3. Also support sharing files between projects like '.eslintrc.js' or 'tsconfig.json'...
149
+ 4. Developing one website in multiple modules.
150
+
151
+ ### Serverless CI/CD
152
+ 1. Build multiple versions for different environments at same time.
153
+ 2. Support deploying and publishing(Only support ali-cloud's oss and cdn by now).
154
+
155
+ ### Remote modules' helper(in development)
156
+ - Working with webpack5's module federation.
157
+ - Easily active modules' developing mode.
158
+ - Friendly Code suggestion.
159
+ - Simple router that can brings you everywhere.
160
+ - Sandbox,state sharing....
161
+
162
+ ### Current Limits
163
+ - Rigjs packages can share source code directly in node_modules.So transpiling or compiling might be needed.
164
+ - Rigjs can not remove redundant codes for remote modules.
165
+ - Although rigjs supports developing one website in multiple repos,
166
+ But they all need to be built together into one application package.
167
+ So it wastes time to build those unchanged modules ,which seems wrong when your website has hundreds or thousands of pages.
168
+ - CI/CD only supports ali-cloud's oss and cdn.I don't have plans to make it better for now.
169
+
170
+ I'm still developing new features in most flexible and unobtrusive way.So my team won't cost extra time to upgrade their applications' architecture.
171
+
172
+ Rigjs works great for my team in development of vue-apps,uni-apps,electron apps and nodejs apps.If you don't need many remote modules,it will work fine for you too.
210
173
 
package/README_CN.md CHANGED
@@ -1,157 +1,171 @@
1
1
  # rig
2
- - [快速开始](#快速开始)
3
- - [工作机制](#工作机制)
4
- - 命令
5
- - [`rig init`](#rig-init)
6
- - [`rig install`](#rig-install)
7
- - [`rig check`](#rig-check)
8
- - [`rig tag`](#rig-tag)
9
-
10
-
11
- ## 快速开始
12
- **0.必要前提**
13
- 必须安装yarn,rig采用yarn workspaces实现依赖晋升。
2
+ - [目标](#目标)
3
+ - [快速开始](#快速开始:基于rig的模块化开发)
4
+ - [dependencies配置](./doc/dependencies_cn.md)
5
+ - [CICD配置](./doc/cicd_cn.md)
6
+ - [share 文件共享](./doc/share_cn.md)
7
+
8
+ ## 快速开始:基于rig的模块化开发
9
+ ### 0.前提准备
10
+ #### 安装yarn,
11
+ ```shell
12
+ yarn global add rigjs
13
+ ```
14
+ rig采用yarn workspaces实现依赖晋升。[关于yarn workspaces](https://classic.yarnpkg.com/en/docs/workspaces)
15
+ #### NodeJS版本不低于14
16
+ 使用 [n](https://github.com/tj/n) 更新NodeJS
17
+ ```shell
18
+ yarn global add n
19
+ #更新到lts
20
+ sudo n lts
21
+ #或指定版本
22
+ sudo n 14.19.1
23
+ ```
14
24
 
15
- **1.init rig**
25
+ ### 1.在项目中初始化rig配置。
16
26
 
17
27
  ```shell script
18
- npm i -g yarn
19
- yarn global add rigjs
28
+ #在你的项目根目录中(和package.json同级)执行:
20
29
  rig init
21
30
  ```
22
- package.rig.json5 会被添加到工程根目录
31
+ package.rig.json5 会被添加到工程根目录。
32
+
33
+ ### 2.使用rig安装现有的代码库
34
+ #### 2.1 方法一:rig add
35
+ rig add [your git ssh url] [tag]
36
+ e.g.
37
+ ```shell
38
+ rig add git@github.com:FlashHand/rig-demo-1.git 0.0.1
39
+ ```
40
+ 引用该仓库
41
+ ```ecmascript 6
42
+ const {hello} = require('rig-demo-1');
43
+ hello();
44
+ ```
23
45
 
24
- **2.配置 package.rig.json5**
46
+ #### 2.2 方法二:在package.rig.json5中修改配置
25
47
  ```json5
26
- //dev 默认为false
27
- [
28
- // {
29
- // name: 'r-a',//module's name
30
- // source: 'git@git.domain.com:common/r-a.git',//module's source
31
- // version: '1.0.0',//Notice:this used as tag.module's version ,
32
- // },
33
- {
34
- name: 'r-b',
35
- source: 'git@git.domain.com:common/r-b.git',
36
- version: '1.0.0',
37
- },
38
- {
39
- name: 'r-c',
40
- source: 'git@git.domain.com:common/r-c.git',
41
- version: '1.0.0',
42
- dev: true
48
+ {
49
+ dependencies: {
50
+ 'rig-demo-1': {
51
+ source: 'git@github.com:FlashHand/rig-demo-1.git',
52
+ version: '0.0.1',
53
+ }
43
54
  }
44
- ]
45
- ```
46
- version等于tag
47
-
48
- **3.run install:**
49
- ```shell script
50
- rig install
55
+ }
51
56
  ```
52
- OR
53
- ```shell script
57
+ 然后执行
58
+ ```shell
54
59
  yarn install
55
60
  ```
56
- **Results:**
57
-
58
- r-b 会被安装到node_modules中
59
-
60
- r-c 会被安装到rigs/下,同时在node_modules中创建一个对它的软链接。
61
-
62
- "rig install" 等价于 "yarn install".
63
- 因为所有的功能都是在preinstall和postinstall中实现。
64
-
65
- ## 工作机制
66
-
67
- #### package.rig.json5
68
-
69
- ig由cocoaprods启发。
70
- 不像那些流行的monorepo的解决方案。Rig是一个多库开发的集成工具。
61
+ ### 3.在rig管理下,开发一个现有的代码库
62
+ #### 3.1 方法一:rig dev
63
+ rig dev [包名称|git-ssh-url]
64
+ 当package已经存在于package.rig.json5
65
+ ```shell
66
+ rig dev rig-demo-1
67
+ ```
68
+ 当package还不存在于package.rig.json5.
69
+ ```shell
70
+ #安装代码包并设为开发模式
71
+ rig dev rig-demo-1 git@github.com:FlashHand/rig-demo-1.git
72
+ ```
71
73
 
72
- 所以rig会创建一个package.rig.json5文件。
73
- package.rig.json5里的数据看起来如下:
74
+ rig-demo-1会被安装到rig_dev目录下。node_modules会存在rig-demo-1的symlink.
75
+ #### 3.1 方法二:在package.rig.json5中修改配置
74
76
  ```json5
75
- //dev 默认为false
76
- [
77
- // {
78
- // name: 'r-a',//module's name
79
- // source: 'git@git.domain.com:common/r-a.git',//module's source
80
- // version: '1.0.0',//Notice:this used as tag.module's version ,
81
- // },
82
- {
83
- name: 'r-b',
84
- source: 'git@git.domain.com:common/r-b.git',
85
- version: '1.0.0',
86
- },
87
- {
88
- name: 'r-c',
89
- source: 'git@git.domain.com:common/r-c.git',
90
- version: '1.0.0',
91
- dev: true
77
+ {
78
+ dependencies: {
79
+ 'rig-demo-1': {
80
+ source: 'git@github.com:FlashHand/rig-demo-1.git',
81
+ version: '0.0.1',
82
+ dev: true //默认是false,
83
+ }
92
84
  }
93
- ]
85
+ }
86
+ ```
87
+ 然后执行
88
+ ```shell
89
+ yarn install
94
90
  ```
95
- package.rig.json5拥有一组模块,每个模块都可以给自己定义单独的源。
96
-
97
- rig 会创建一个叫rigs的文件夹
98
-
99
- 当dev为true时文件的主干会被clone到rigs下
100
-
101
- 而且代码库会被自动链接到node_modules中。
102
-
103
- #### rig如何修改package.rig.json5
104
91
 
105
- ```javascript
106
- //rig会向package.json中注入这些内容
107
- //rig 不会覆盖你的preinstall和postinstall的脚本。workspaces的配置也是补充进去的,不回去覆盖。
108
- let inserted = {
109
- private: true,
110
- workspaces: [
111
- "rigs/*",
112
- "rigs_dev/*"
113
- ],
114
- scripts:{
115
- preinstall:"rig preinstall",
116
- postinstall:"rig postinstall",
117
- }
92
+ ### 4.制作和开发新的rig代码库。
93
+ #### 4.1 创建一个git仓库。
94
+ 获取git ssh url例如: git@github.com:FlashHand/rig-demo-1.git
95
+ #### 4.2 在rig依赖中添加你的仓库
96
+ rig dev git@github.com:FlashHand/rig-demo-1.git
97
+ #### 4.3 开发你的rig库
98
+ ```shell
99
+ cd your_project_path
100
+ cd rigs_dev/rig-demo-1
101
+ #如果项目没有初始化,执行初始化,并创建index
102
+ yarn init
103
+ echo "module.export={hello:()=>{console.log('hello')}}" > index.js
104
+ ```
105
+ #### 4.4 在项目中使用rig仓库。
106
+ ```ecmascript 6
107
+ const {hello} = require('rig-demo-1');
108
+ hello();
109
+ ```
110
+ #### 4.5 在生产环境中使用rig仓库。
111
+ 发布rig仓库的tag
112
+ ```shell
113
+ cd rigs_dev/rig-demo-1
114
+ git add .
115
+ git commit -m 'demo for rig'
116
+ git tag 0.0.1
117
+ git push origin your_branch --tag
118
+ ```
119
+ 在package.rig.json5中修改配置
120
+ - 修改version
121
+ - 设dev为false,生产环境中不要使用dev模式,应该指定安装确定的version.
122
+ ```json5
123
+ {
124
+ dependencies: {
125
+ 'rig-demo-1': {
126
+ source: 'git@github.com:FlashHand/rig-demo-1.git',
127
+ version: '0.0.1',
128
+ // dev:true//生产环境中不要使用dev模式,应该指定安装确定的version.
118
129
  }
130
+ }
131
+ }
119
132
  ```
120
- rig机制概括起来就是分库开发,整体构建。
121
- ![develop](https://github.com/FlashHand/rig/raw/main/develop.png)
122
- ![production](https://github.com/FlashHand/rig/raw/main/production.png)
123
- #### 主要功能
124
-
125
- 1. 更方便的进行模块化开发,
126
- 2. 自动集成多个开发库
127
- 3. 只要将dev设为true,就可以在项目中开发调试任何模块。
128
- 4. 采用yarn的workspaces,避免依赖冗余.
129
- 5. 自动对rigs中的模块做软链接。
130
- 6. 生产环境检查,运行rig check可以防止开发中的库被部署(dev:true),一般用于部署脚本。
131
- 7. 无侵入,与一般微前端方案无冲突。
132
-
133
- ## Command
134
-
135
- ### rig init
136
- 1. 创建"package.rig.json5"
137
- 2. 将配置注入到package.json中
138
- 3. 创建rigs文件夹
139
- 4. 修改.gitignore文件
140
-
141
- ### rig install
142
- 等价于 "yarn install"
143
-
144
- ### rig check
145
- 如果有模块处于开发模式(dev:true)检查不会通过,构建脚本抛出异常。
146
- 该命令用于部署,以确保开发模式的代码不会被发到线上。
147
-
148
- ### rig tag
149
- 使用package.json中的version打tag
150
- //TODO:自动检查是否存在未提交代码。
151
-
152
- ### rig --env fp_test
153
- 该指令首先会在根目录下寻找名为'env.rig.json5'的文件,然后根据所传变量fp_test去该文件读取相应配置,
154
- 最后自动将该配置写入固定名称为".env.rig"的文件。注意:类似"fp_test"的变量为必传项。
155
133
 
156
- ###rig info
157
- 查看模块配置信息
134
+ ## Advantages
135
+ - 💡Rigjs only needs git.No need to publish packages to private registry.
136
+ - ⚡️Instant code sharing between multiple projects and multiple developers.Packages can be easily installed by git-ssh-url and tag.
137
+ - ⚙️Auto npm link in dev mode.Import or require packages just like normal node_modules with friendly code suggestion.
138
+ - 🔍Easily develop packages within your projects.Packages in *dev* mode are all in *rig_dev* folder.
139
+ - 💨Easily transform existing code into a sharable package for multiple projects.
140
+ - 📏Large content scale.You can share from a simple js file to multiple files that contains many pages.
141
+ - 🧹Flat dependencies.No need to worry complex packages' relationship.
142
+
143
+ ## Goals
144
+ ### Sharing codes or files.
145
+ 1. Reuse codes between different developers or different projects in most flexible and unobtrusive way.
146
+ 2. Easily turn modules into developing mode,no need to use npm link or change package.json.
147
+ 3. Also support sharing files between projects like '.eslintrc.js' or 'tsconfig.json'...
148
+ 4. Developing one website in multiple modules.
149
+
150
+ ### Serverless CI/CD
151
+ 1. Build multiple versions for different environments at same time.
152
+ 2. Support deploying and publishing(Only support ali-cloud's oss and cdn by now).
153
+
154
+ ### Remote modules' helper(in development)
155
+ - Working with webpack5's module federation.
156
+ - Easily active modules' developing mode.
157
+ - Friendly Code suggestion.
158
+ - Simple router that can brings you everywhere.
159
+ - Sandbox,state sharing....
160
+
161
+ ### Current Limits
162
+ - Rigjs packages can share source code directly in node_modules.So transpiling or compiling might be needed.
163
+ - Rigjs can not remove redundant codes for remote modules.
164
+ - Although rigjs supports developing one website in multiple repos,
165
+ But they all need to be built together into one application package.
166
+ So it wastes time to build those unchanged modules ,which seems wrong when your website has hundreds or thousands of pages.
167
+ - CI/CD only supports ali-cloud's oss and cdn.I don't have plans to make it better for now.
168
+
169
+ I'm still developing new features in most flexible and unobtrusive way.So my team won't cost extra time to upgrade their applications' architecture.
170
+
171
+ Rigjs works great for my team in development of vue-apps,uni-apps,electron apps and nodejs apps.If you don't need many remote modules,it will work fine for you too.