rigjs 2.1.18 → 2.1.21

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.
@@ -71,7 +71,7 @@ export interface CICDConfig {
71
71
  * fafafafa
72
72
  */
73
73
  tree_schema: string;
74
- web_type: 'spa'|'mpa';
74
+ web_type: 'hash'|'history'|'mpa';
75
75
  source: DeploySource;
76
76
  target: DeployTarget | DeployTarget[];
77
77
  endpoints: EndpointDict;
@@ -85,7 +85,7 @@ class CICD {
85
85
  * @type {string}
86
86
  */
87
87
  treeSchema: string;
88
- web_type: 'spa' | 'mpa' = 'spa';
88
+ web_type: 'hash' | 'history'|'mpa' = 'hash';
89
89
  /**
90
90
  * DirLevel shows every level of the directory structure
91
91
  * @type {DirLevel[]}
@@ -102,7 +102,7 @@ class CICD {
102
102
 
103
103
  constructor(config: CICDConfig) {
104
104
  this.treeSchema = config.tree_schema;
105
- this.web_type = config.web_type || 'spa';
105
+ this.web_type = config.web_type || 'hash';
106
106
  this.schema = DirLevel.createSchema(this.treeSchema);
107
107
  this.endpoints = Endpoint.createEndpointArr(config, this.schema);
108
108
  this.source = config.source;
@@ -62,7 +62,7 @@ class Endpoint {
62
62
  this.domains = info.domains
63
63
  this.defines = info.defines;
64
64
  this.uri_rewrite = info.uri_rewrite;
65
- this.web_entry_path = info.web_entry_path || '/';
65
+ this.web_entry_path = info.web_entry_path;
66
66
  this.vue_env = info.vue_env;
67
67
  this.extra_env = info.extra_env;
68
68
 
@@ -85,6 +85,8 @@ export default async (cmd: any) => {
85
85
  let webEntryPath: string;
86
86
  if (cicd.web_type === 'mpa') {
87
87
  webEntryPath = '/';
88
+ } else if (cicd.web_type === 'history'){
89
+ webEntryPath = '/';
88
90
  } else {
89
91
  webEntryPath = endpoint.web_entry_path
90
92
  ? endpoint.web_entry_path
@@ -92,7 +94,7 @@ export default async (cmd: any) => {
92
94
  }
93
95
  for (const domain of endpoint.domains) {
94
96
  if (cicd.web_type === 'mpa') {
95
- //文件
97
+ //mpa匹配文件
96
98
  setRewriteUriPromises.push(
97
99
  setRewriteUri(
98
100
  domain,
@@ -101,7 +103,7 @@ export default async (cmd: any) => {
101
103
  cdn
102
104
  )
103
105
  );
104
- //非首页
106
+ //mpa匹配非首页
105
107
  setRewriteUriPromises.push(
106
108
  setRewriteUri(
107
109
  domain,
@@ -110,8 +112,27 @@ export default async (cmd: any) => {
110
112
  cdn
111
113
  )
112
114
  );
113
- } else {
114
- //文件
115
+ } else if (cicd.web_type === 'history'){
116
+ //spa/history匹配非首页
117
+ setRewriteUriPromises.push(
118
+ setRewriteUri(
119
+ domain,
120
+ '^\\/([\\w-/]*\\w+)(?![^?]*\\.\\w+)',
121
+ `/${endpoint.deployDir.replace(/\\/g, '/')}/index.html`,
122
+ cdn
123
+ )
124
+ );
125
+ //spa/history匹配文件
126
+ setRewriteUriPromises.push(
127
+ setRewriteUri(
128
+ domain,
129
+ '^\\/([^?]*\\.[a-zA-Z0-9]+)($|\\?)',
130
+ `/${endpoint.deployDir.replace(/\\/g, '/')}/$1`,
131
+ cdn
132
+ )
133
+ );
134
+ }else if (cicd.web_type === 'hash') {
135
+ //hash模式匹配文件
115
136
  setRewriteUriPromises.push(
116
137
  setRewriteUri(
117
138
  domain,
@@ -121,6 +142,7 @@ export default async (cmd: any) => {
121
142
  )
122
143
  );
123
144
  }
145
+ //首页匹配正则,hash,history,mpa三个模式通用
124
146
  setRewriteUriPromises.push(
125
147
  setRewriteUri(
126
148
  domain,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rigjs",
3
- "version": "2.1.18",
3
+ "version": "2.1.21",
4
4
  "description": "A multi-repos dev tool based on yarn and git.Rig is inspired by cocoapods. Not like those monorepo solutions,rig is a tool for organizing multi-repos.",
5
5
  "keywords": [
6
6
  "modular",