rigjs 2.1.1 → 2.1.2
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.
- package/README.md +117 -75
- package/built/index.js +145 -142
- package/built/index.js.map +7 -0
- package/demo/package.rig.json5 +1 -1
- package/jest.config.ts +7 -0
- package/lib/preinstall/index.d.ts +1 -0
- package/lib/preinstall/index.js +34 -21
- package/lib/preinstall/index.test.js +16 -0
- package/lib/tag/index.js +1 -1
- package/package.json +10 -3
package/README.md
CHANGED
|
@@ -1,83 +1,127 @@
|
|
|
1
1
|
# rig
|
|
2
|
+
|
|
2
3
|
## [中文文档](./README_CN.md)
|
|
4
|
+
|
|
3
5
|
- [Getting Started](#getting-started)
|
|
4
6
|
- [How It Works](#how-it-works)
|
|
5
7
|
- Commands
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
- [`rig init`](#rig-init)
|
|
9
|
+
- [`rig install`](#rig-install)
|
|
10
|
+
- [`rig check`](#rig-check)
|
|
11
|
+
- [`rig tag`](#rig-tag)
|
|
12
|
+
|
|
12
13
|
## Getting started
|
|
13
|
-
|
|
14
|
+
###Prerequisites
|
|
15
|
+
- Should install yarn first.Rig is using yarn workspace to do module-hoisting.
|
|
16
|
+
```shell
|
|
17
|
+
npm i -g yarn
|
|
18
|
+
```
|
|
14
19
|
|
|
15
|
-
|
|
20
|
+
###Installation
|
|
16
21
|
|
|
17
22
|
```shell script
|
|
18
|
-
npm i -g yarn
|
|
19
23
|
yarn global add rigjs
|
|
24
|
+
```
|
|
25
|
+
|
|
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.
|
|
31
|
+
|
|
32
|
+
```shell script
|
|
20
33
|
rig init
|
|
21
34
|
```
|
|
35
|
+
|
|
22
36
|
package.rig.json5 will be added to your project's root.
|
|
23
37
|
|
|
24
|
-
|
|
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
|
|
50
|
+
|
|
51
|
+
***copy this and try***
|
|
25
52
|
```json5
|
|
26
53
|
//dev is false by default
|
|
27
54
|
[
|
|
28
|
-
// {
|
|
29
|
-
// name: '
|
|
30
|
-
// source: 'git@git.domain.com:
|
|
31
|
-
// version: '1.0.0',//Notice:this used as tag.module's version ,
|
|
32
|
-
// },
|
|
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
|
+
// },
|
|
33
60
|
{
|
|
34
|
-
name: '
|
|
35
|
-
source: 'git@
|
|
61
|
+
name: 'rig-test-1',
|
|
62
|
+
source: 'git@github.com:FlashHand/rig-test-1.git',
|
|
36
63
|
version: '1.0.0',
|
|
37
64
|
},
|
|
38
65
|
{
|
|
39
|
-
name: '
|
|
40
|
-
source: 'git@
|
|
41
|
-
version: '1.0.
|
|
66
|
+
name: 'rig-test-2',
|
|
67
|
+
source: 'git@github.com:FlashHand/rig-test-2.git',
|
|
68
|
+
version: '1.0.1',
|
|
42
69
|
dev: true
|
|
43
70
|
}
|
|
44
71
|
]
|
|
45
72
|
```
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
rig install
|
|
49
|
-
```
|
|
50
|
-
OR
|
|
73
|
+
|
|
74
|
+
####4.run install:
|
|
51
75
|
```shell script
|
|
52
|
-
yarn
|
|
76
|
+
yarn
|
|
53
77
|
```
|
|
78
|
+
|
|
54
79
|
**Result:**
|
|
55
80
|
|
|
56
|
-
|
|
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.
|
|
57
95
|
|
|
58
|
-
r-c will be cloned to rigs/
|
|
59
96
|
|
|
60
|
-
|
|
61
|
-
|
|
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.
|
|
62
107
|
|
|
63
108
|
|
|
64
109
|
## How it works
|
|
65
110
|
|
|
66
111
|
#### package.rig.json5
|
|
67
112
|
|
|
68
|
-
Rig is inspired by cocoapods.
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
Data in "package.rig.json5" can look like this:
|
|
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:
|
|
115
|
+
|
|
72
116
|
```json5
|
|
73
117
|
//dev is false by default
|
|
74
118
|
//dev 默认为false
|
|
75
119
|
[
|
|
76
|
-
// {
|
|
77
|
-
// name: 'r-a',//module's name
|
|
78
|
-
// source: 'git@git.domain.com:common/r-a.git',//module's source
|
|
79
|
-
// version: '1.0.0',//Notice:this used as tag.module's version ,
|
|
80
|
-
// },
|
|
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
|
+
// },
|
|
81
125
|
{
|
|
82
126
|
name: 'r-b',
|
|
83
127
|
source: 'git@git.domain.com:common/r-b.git',
|
|
@@ -91,6 +135,7 @@ Data in "package.rig.json5" can look like this:
|
|
|
91
135
|
}
|
|
92
136
|
]
|
|
93
137
|
```
|
|
138
|
+
|
|
94
139
|
package.rig.json5 has an array of modules.
|
|
95
140
|
|
|
96
141
|
So rig create a folder named "rigs".
|
|
@@ -105,64 +150,61 @@ And it gets automatically linked in node_modules.
|
|
|
105
150
|
//Rig will insert these to package.json
|
|
106
151
|
//Rig won't cover your preinstall or postinstall's settings.Scripts and workspaces will be appended.
|
|
107
152
|
let inserted = {
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
153
|
+
private: true,
|
|
154
|
+
workspaces: [
|
|
155
|
+
"rigs/*",
|
|
156
|
+
"rigs_dev/*"
|
|
157
|
+
],
|
|
158
|
+
scripts: {
|
|
159
|
+
preinstall: "rig preinstall",
|
|
160
|
+
postinstall: "rig postinstall",
|
|
161
|
+
}
|
|
162
|
+
}
|
|
118
163
|
```
|
|
119
164
|
|
|
120
|
-
#### Main Features
|
|
121
|
-
|
|
122
|
-
1. Created for modular architecture.
|
|
123
|
-
2. An organizer for multi repos.
|
|
124
|
-
3. You can develop and test your module within your project.Just set **dev** to true.
|
|
125
|
-
4. Using yarn workspace.
|
|
126
|
-
5. Automatically link your developing modules in rigs/.
|
|
127
|
-
|
|
128
165
|
**How to remove your modules**
|
|
129
166
|
|
|
130
167
|
Remove your modules from both package.json and package.rig.json5 then run **rig install** or **yarn install**.
|
|
131
168
|
|
|
132
169
|
//TODO:
|
|
133
|
-
rig check //if has dev:true then end shell
|
|
134
|
-
rig tag //using package.json version
|
|
170
|
+
rig check //if has dev:true then end shell rig tag //using package.json version
|
|
135
171
|
|
|
136
172
|
## Command
|
|
137
173
|
|
|
138
174
|
### rig init
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
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
|
+
|
|
144
181
|
### rig install
|
|
182
|
+
|
|
145
183
|
equals to "yarn install"
|
|
146
184
|
|
|
147
185
|
### rig check
|
|
186
|
+
|
|
148
187
|
If a module's dev status is true in "package.rig.json5",the config will not be passed!
|
|
149
188
|
|
|
150
189
|
Make sure you are not using developing modules for production.
|
|
151
190
|
|
|
152
191
|
### rig tag
|
|
153
|
-
Using version in package.json to tag.
|
|
154
|
-
|
|
155
|
-
### rig --env fp_test
|
|
156
|
-
This command automatically reads the file named "env.rig.json5" in the root directory,
|
|
157
|
-
and looks for the environment variable configuration in mode "fp_test",
|
|
158
|
-
and eventually generates a file for you with a fixed name of ".env.rig".
|
|
159
|
-
Warning: Like "fp_test" is a mandatory variable.
|
|
160
192
|
|
|
161
|
-
|
|
162
|
-
rig install不覆盖rigs下的文件
|
|
163
|
-
es5兼容文档
|
|
164
|
-
不能删除rigs下的文件
|
|
193
|
+
Using version in package.json to tag.
|
|
165
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.
|
|
202
|
+
```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
|
|
207
|
+
```
|
|
166
208
|
|
|
167
209
|
|
|
168
210
|
|