jjb-cmd 1.0.15 → 1.0.17

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jjb-cmd",
3
- "version": "1.0.15",
3
+ "version": "1.0.17",
4
4
  "description": "jjb脚手架工具",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -14,6 +14,7 @@
14
14
  "dependencies": {
15
15
  "commander": "1.3.2",
16
16
  "compressing": "^1.5.1",
17
- "request": "2.88.2"
17
+ "request": "2.88.2",
18
+ "single-line-log": "1.1.2"
18
19
  }
19
20
  }
@@ -26,15 +26,11 @@ export const registerApplication = (selector = '#root') => {
26
26
  return {
27
27
  mount: () => render(),
28
28
  unmount: props => {
29
- if (window.__POWERED_BY_QIANKUN__) {
30
- const { container } = props;
31
- const element = container
32
- ? container.querySelector(selector)
33
- : document.querySelector(selector);
34
- unmountComponentAtNode(element);
35
- } else {
36
- console.error('卸载APP失败,原因:', '当前环境非QianKun');
37
- }
29
+ const { container } = props;
30
+ const element = container
31
+ ? container.querySelector(selector)
32
+ : document.querySelector(selector);
33
+ unmountComponentAtNode(element);
38
34
  },
39
35
  bootstrap: props => props
40
36
  };
@@ -6,7 +6,7 @@
6
6
 
7
7
  import React from 'react';
8
8
  import { ConfigProvider } from 'antd';
9
- import { Route, Router, Switch } from 'dva/router';
9
+ import { BrowserRouter, Route, Switch } from 'dva/router';
10
10
 
11
11
  /**
12
12
  * @description 是否匹配页面
@@ -153,27 +153,26 @@ function treeRoutes (routes = []) {
153
153
  return optimizationTree(result);
154
154
  }
155
155
 
156
- function RenderRouter (routes = [], inProps = {}) {
156
+ function RenderRoute (routes = [], inProps = {}) {
157
157
  return (
158
- <Router history={inProps.history}>
159
- <Switch>
160
- {routes.map(({
161
- path,
162
- children,
163
- Component
164
- }, index) => (
165
- <Route
166
- key={index}
167
- path={`${(process.env.app || {}).basename || ''}${path}`}
168
- render={props => (
169
- <Component {...props}>
170
- {RenderRouter(children, inProps)}
171
- </Component>
172
- )}
173
- />
174
- ))}
175
- </Switch>
176
- </Router>
158
+ <Switch>
159
+ {routes.map(({
160
+ path,
161
+ children,
162
+ Component
163
+ }, index) => (
164
+ <Route
165
+ exact={path === '/'}
166
+ key={index}
167
+ path={path}
168
+ render={props => (
169
+ <Component {...props}>
170
+ {RenderRoute(children, inProps)}
171
+ </Component>
172
+ )}
173
+ />
174
+ ))}
175
+ </Switch>
177
176
  );
178
177
  }
179
178
 
@@ -189,10 +188,23 @@ export const AutomaticRouter = ({
189
188
  }) => {
190
189
  return (
191
190
  <ConfigProvider locale={require('antd/lib/locale/zh_CN').default}>
192
- {RenderRouter(treeRoutes(getRoutes()), {
193
- app,
194
- history
195
- })}
191
+ <BrowserRouter basename={(process.env.app || {}).basename || ''}>
192
+ <Switch>
193
+ {(process.env.app || {}).notRouter
194
+ ? (
195
+ <Route
196
+ path="*"
197
+ component={require('~/pages').default}
198
+ />
199
+ )
200
+ : (
201
+ RenderRoute(treeRoutes(getRoutes()), {
202
+ app,
203
+ history
204
+ })
205
+ )}
206
+ </Switch>
207
+ </BrowserRouter>
196
208
  </ConfigProvider>
197
209
  );
198
210
  };
@@ -38,7 +38,9 @@ module.exports = mode => {
38
38
  // 指定编译的‘js’存放目录文件名称
39
39
  filename: 'static/js/[id].js',
40
40
  // 输出公共路径
41
- publicPath: '/'
41
+ publicPath: '/',
42
+ // 默认暴露‘window’此处修改为暴露到‘exports’中
43
+ libraryTarget: 'umd'
42
44
  },
43
45
  // ‘node.module’
44
46
  module: {
package/src/cli.pull2.js CHANGED
@@ -16,12 +16,14 @@ const CLOUD_PROJECT = {
16
16
  'common': {
17
17
  token: 'G4HJRsHr9D7Ssmixegw2',
18
18
  projectId: 279,
19
- localName: 'common'
19
+ localName: 'common',
20
+ sha: '20e00c48'
20
21
  },
21
22
  'react-admin-component': {
22
23
  token: 'FT3pKzxpRynFkmddJ9Bs',
23
24
  projectId: 340,
24
- localName: 'components'
25
+ localName: 'components',
26
+ sha: 'a79d730b'
25
27
  }
26
28
  };
27
29
  // common 需要替换的文本(常规应用)
@@ -217,7 +219,7 @@ module.exports = input => {
217
219
  utils.DeleteDirAllFile(`${tmpDir}/${GIT_TEMP_DIR}`, () => {
218
220
  fs.mkdirSync(`${tmpDir}/${GIT_TEMP_DIR}`);
219
221
  const stream = fs.createWriteStream(zipPath);
220
- request(`${GIT_HOST}/api/v4/projects/${cloudObj.projectId}/repository/archive.zip?private_token=${cloudObj.token}&ref=master`)
222
+ request(`${GIT_HOST}/api/v4/projects/${cloudObj.projectId}/repository/archive.zip?private_token=${cloudObj.token}&sha=${cloudObj.sha}`)
221
223
  .pipe(stream)
222
224
  .on('close', () => {
223
225
  fs.mkdirSync(zipFolder);
@@ -225,7 +227,7 @@ module.exports = input => {
225
227
  .then(() => {
226
228
  setTimeout(() => {
227
229
  fs.readdirSync(zipFolder).forEach(dirName => {
228
- if (dirName.indexOf('-master-') !== -1) {
230
+ if (dirName.indexOf(`-${cloudObj.sha}`) !== -1) {
229
231
  /* 删除下载的文件 */
230
232
  utils.DeleteDirAllFile(`${srcFolderPath}\\${cloudObj.localName}`, () => {
231
233
  /* 创建临时文件夹 */