jjb-cmd 2.0.6 → 2.0.8
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 +7 -0
- package/bin/command.js +47 -0
- package/package.json +1 -2
- package/src/new/cmd.init/index.js +91 -55
- package/src/new/cmd.install/config.js +16 -0
- package/src/new/cmd.init.copy/lib/jjb.config.json +0 -32
- package/src/new/cmd.init.copy/lib/jjb.script/build.js +0 -14
- package/src/new/cmd.init.copy/lib/jjb.script/config.js +0 -149
- package/src/new/cmd.init.copy/lib/jjb.script/proxy.js +0 -19
- package/src/new/cmd.init.copy/lib/jjb.script/server.js +0 -29
- package/src/new/cmd.init.copy/lib/jjb.script/utils.js +0 -13
- package/src/new/cmd.init.copy/lib/package.json +0 -62
- package/src/new/cmd.init.copy/lib/src/index.js +0 -1
- package/src/new/cmd.init.copy/lib/webstorm.config.js +0 -16
- package/src/new/cmd.init.copy/micro-app/jjb.config.json +0 -42
- package/src/new/cmd.init.copy/micro-app/jjb.script/build.js +0 -14
- package/src/new/cmd.init.copy/micro-app/jjb.script/config.js +0 -219
- package/src/new/cmd.init.copy/micro-app/jjb.script/proxy.js +0 -19
- package/src/new/cmd.init.copy/micro-app/jjb.script/server.js +0 -29
- package/src/new/cmd.init.copy/micro-app/jjb.script/utils.js +0 -13
- package/src/new/cmd.init.copy/micro-app/package.json +0 -69
- package/src/new/cmd.init.copy/micro-app/public/index.html +0 -35
- package/src/new/cmd.init.copy/micro-app/src/api/home/index.js +0 -1
- package/src/new/cmd.init.copy/micro-app/src/enumerate/namespace/index.js +0 -3
- package/src/new/cmd.init.copy/micro-app/src/index.js +0 -24
- package/src/new/cmd.init.copy/micro-app/src/pages/index.js +0 -9
- package/src/new/cmd.init.copy/micro-app/webstorm.config.js +0 -16
- package/src/new/cmd.init.copy/micro-app-ts/jjb.config.json +0 -37
- package/src/new/cmd.init.copy/micro-app-ts/jjb.script/build.js +0 -11
- package/src/new/cmd.init.copy/micro-app-ts/jjb.script/config.js +0 -273
- package/src/new/cmd.init.copy/micro-app-ts/jjb.script/proxy.js +0 -19
- package/src/new/cmd.init.copy/micro-app-ts/jjb.script/server.js +0 -29
- package/src/new/cmd.init.copy/micro-app-ts/jjb.script/utils.js +0 -13
- package/src/new/cmd.init.copy/micro-app-ts/package.json +0 -79
- package/src/new/cmd.init.copy/micro-app-ts/public/index.html +0 -35
- package/src/new/cmd.init.copy/micro-app-ts/src/api/home/index.ts +0 -1
- package/src/new/cmd.init.copy/micro-app-ts/src/enumerate/namespace/index.ts +0 -3
- package/src/new/cmd.init.copy/micro-app-ts/src/index.ts +0 -18
- package/src/new/cmd.init.copy/micro-app-ts/src/pages/index.tsx +0 -9
- package/src/new/cmd.init.copy/micro-app-ts/src/types/global.d.ts +0 -21
- package/src/new/cmd.init.copy/micro-app-ts/tsconfig.json +0 -16
- package/src/new/cmd.init.copy/micro-app-ts/webstorm.config.js +0 -16
- package/src/new/cmd.init.copy/react-component/jjb.config.json +0 -33
- package/src/new/cmd.init.copy/react-component/jjb.script/build.js +0 -14
- package/src/new/cmd.init.copy/react-component/jjb.script/config.js +0 -190
- package/src/new/cmd.init.copy/react-component/jjb.script/proxy.js +0 -22
- package/src/new/cmd.init.copy/react-component/jjb.script/server.js +0 -29
- package/src/new/cmd.init.copy/react-component/jjb.script/utils.js +0 -13
- package/src/new/cmd.init.copy/react-component/package.json +0 -60
- package/src/new/cmd.init.copy/react-component/public/index.html +0 -11
- package/src/new/cmd.init.copy/react-component/src/index.js +0 -15
- package/src/new/cmd.init.copy/react-component/webstorm.config.js +0 -16
package/README.md
CHANGED
package/bin/command.js
CHANGED
@@ -1,6 +1,10 @@
|
|
1
1
|
#! /usr/bin/env node
|
2
2
|
|
3
3
|
const commander = require('commander');
|
4
|
+
const readline = require('readline');
|
5
|
+
const path = require('path');
|
6
|
+
const fs = require('fs');
|
7
|
+
const child_process = require('child_process');
|
4
8
|
|
5
9
|
commander.command('v').description('-- 查看版本').action(() => {
|
6
10
|
console.log('当前版本 v2.0.0');
|
@@ -11,6 +15,49 @@ commander.command('view res').description('-- 预览资源').action(() => {
|
|
11
15
|
console.log('[common, react-admin-component]');
|
12
16
|
});
|
13
17
|
|
18
|
+
commander.command('link').option('-A').description('-- 创建符号链接').action(args => {
|
19
|
+
let dirList = [];
|
20
|
+
const hasFlag = args.A;
|
21
|
+
const root_path = path.resolve('./');
|
22
|
+
let r1 = readline.createInterface({
|
23
|
+
input: process.stdin,
|
24
|
+
output: process.stdout
|
25
|
+
});
|
26
|
+
r1.question('Target Path:', function (answer) {
|
27
|
+
const arr = answer.split('\\');
|
28
|
+
const name = arr.length
|
29
|
+
? arr[ arr.length - 1 ]
|
30
|
+
: '';
|
31
|
+
if (hasFlag) {
|
32
|
+
dirList = dirList.concat(fs.readdirSync(root_path).map(dir => {
|
33
|
+
return `${root_path}\\${dir}`;
|
34
|
+
}).filter(dir => fs.statSync(dir).isDirectory()).map(dir => {
|
35
|
+
return {
|
36
|
+
dir: dir + '\\' + name,
|
37
|
+
link: answer
|
38
|
+
};
|
39
|
+
}));
|
40
|
+
} else {
|
41
|
+
dirList = dirList.concat(root_path).map(dir => {
|
42
|
+
return {
|
43
|
+
dir: dir + '\\' + name,
|
44
|
+
link: answer
|
45
|
+
};
|
46
|
+
});
|
47
|
+
}
|
48
|
+
dirList.forEach(item => {
|
49
|
+
child_process.execSync(`mklink /D ${item.dir} ${item.link}`, (error, stdout) => {
|
50
|
+
if (!error) {
|
51
|
+
console.log(stdout);
|
52
|
+
}
|
53
|
+
});
|
54
|
+
});
|
55
|
+
console.log('执行完成。');
|
56
|
+
process.exit(0);
|
57
|
+
});
|
58
|
+
r1.on('close', () => process.exit(0));
|
59
|
+
});
|
60
|
+
|
14
61
|
// publish 命令
|
15
62
|
commander.command('push [args]').description('-- 发布包').action(args => {
|
16
63
|
if (args) {
|
package/package.json
CHANGED
@@ -1,66 +1,102 @@
|
|
1
1
|
const path = require('path');
|
2
2
|
const { f_file_copy } = require('../cmd.install/tools');
|
3
|
+
const { CLOUD_PROJECT, GIT_TEMP_DIR, GIT_HOST } = require('../cmd.install/config');
|
3
4
|
const fs = require('fs');
|
5
|
+
const os = require("os");
|
6
|
+
const utils = require("../../old/util");
|
7
|
+
const request = require("request");
|
8
|
+
const compressing = require("compressing");
|
4
9
|
|
5
10
|
module.exports = stdin => {
|
6
11
|
/**
|
7
12
|
* 下发数据根路径
|
8
13
|
* @type {string}
|
9
14
|
*/
|
10
|
-
const root_path = path.resolve('./');
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
console.log('初始化完成!');
|
41
|
-
process.exit(0);
|
42
|
-
} else {
|
43
|
-
console.log('初始化失败,文件已存在!');
|
44
|
-
process.exit(0);
|
45
|
-
}
|
46
|
-
} else if ([
|
47
|
-
'lib',
|
48
|
-
'react-component'
|
49
|
-
].includes(stdin)) {
|
50
|
-
if (
|
51
|
-
!fs.existsSync(`${root_path}\\jjb.script`) &&
|
52
|
-
!fs.existsSync(`${root_path}\\src`) &&
|
53
|
-
!fs.existsSync(`${root_path}\\.gitignore`) &&
|
54
|
-
!fs.existsSync(`${root_path}\\jjb.config.json`) &&
|
55
|
-
!fs.existsSync(`${root_path}\\package.json`) &&
|
56
|
-
!fs.existsSync(`${root_path}\\webstorm.config.js`)
|
57
|
-
) {
|
58
|
-
f_file_copy(`${__dirname}\\..\\cmd.init.copy\\${stdin}`, root_path);
|
59
|
-
console.log('初始化完成!');
|
60
|
-
process.exit(0);
|
61
|
-
} else {
|
62
|
-
console.log('初始化失败,文件已存在!');
|
63
|
-
process.exit(0);
|
64
|
-
}
|
15
|
+
const root_path = path.resolve('./temp');
|
16
|
+
|
17
|
+
const cloudObj = CLOUD_PROJECT[ stdin ] || undefined;
|
18
|
+
if (cloudObj) {
|
19
|
+
const tmpDir = os.tmpdir();
|
20
|
+
const zipPath = `${tmpDir}/${GIT_TEMP_DIR}/${stdin}.zip`;
|
21
|
+
const zipFolder = `${tmpDir}/${GIT_TEMP_DIR}/unzip/`;
|
22
|
+
utils.DeleteDirAllFile(`${tmpDir}/${GIT_TEMP_DIR}`, () => {
|
23
|
+
fs.mkdirSync(`${tmpDir}/${GIT_TEMP_DIR}`);
|
24
|
+
let stream = fs.createWriteStream(zipPath);
|
25
|
+
request(`${GIT_HOST}/api/v4/projects/${cloudObj.projectId}/repository/archive.zip?private_token=${cloudObj.token}&ref=master`).pipe(stream)
|
26
|
+
.on('close', () => {
|
27
|
+
fs.mkdirSync(zipFolder);
|
28
|
+
compressing.zip.uncompress(zipPath, zipFolder)
|
29
|
+
.then(() => {
|
30
|
+
setTimeout(() => {
|
31
|
+
fs.readdirSync(zipFolder).forEach(dirName => {
|
32
|
+
if (dirName.indexOf('-master-') !== -1) {
|
33
|
+
utils.CopyFolder(zipFolder + dirName, root_path, () => {
|
34
|
+
console.log('初始化完成!');
|
35
|
+
process.exit(0);
|
36
|
+
});
|
37
|
+
}
|
38
|
+
})
|
39
|
+
}, 2000);
|
40
|
+
})
|
41
|
+
});
|
42
|
+
});
|
43
|
+
} else {
|
44
|
+
console.log('【Error】:初始化失败,'+ stdin +'不存在。');
|
65
45
|
}
|
46
|
+
|
47
|
+
// if (stdin === 'micro-app') {
|
48
|
+
// if (
|
49
|
+
// !fs.existsSync(`${root_path}\\jjb.script`) &&
|
50
|
+
// !fs.existsSync(`${root_path}\\public`) &&
|
51
|
+
// !fs.existsSync(`${root_path}\\src`) &&
|
52
|
+
// !fs.existsSync(`${root_path}\\.gitignore`) &&
|
53
|
+
// !fs.existsSync(`${root_path}\\jjb.config.json`) &&
|
54
|
+
// !fs.existsSync(`${root_path}\\package.json`) &&
|
55
|
+
// !fs.existsSync(`${root_path}\\webstorm.config.js`)
|
56
|
+
// ) {
|
57
|
+
// f_file_copy(`${__dirname}\\..\\cmd.init.copy\\micro-app`, root_path);
|
58
|
+
// console.log('初始化完成!');
|
59
|
+
// process.exit(0);
|
60
|
+
// } else {
|
61
|
+
// console.log('初始化失败,文件已存在!');
|
62
|
+
// process.exit(0);
|
63
|
+
// }
|
64
|
+
// } else if(stdin === 'micro-app-ts') {
|
65
|
+
// if (
|
66
|
+
// !fs.existsSync(`${root_path}\\jjb.script`) &&
|
67
|
+
// !fs.existsSync(`${root_path}\\public`) &&
|
68
|
+
// !fs.existsSync(`${root_path}\\src`) &&
|
69
|
+
// !fs.existsSync(`${root_path}\\.gitignore`) &&
|
70
|
+
// !fs.existsSync(`${root_path}\\jjb.config.json`) &&
|
71
|
+
// !fs.existsSync(`${root_path}\\tsconfig.json`) &&
|
72
|
+
// !fs.existsSync(`${root_path}\\package.json`) &&
|
73
|
+
// !fs.existsSync(`${root_path}\\webstorm.config.js`)
|
74
|
+
// ) {
|
75
|
+
// f_file_copy(`${__dirname}\\..\\cmd.init.copy\\micro-app-ts`, root_path);
|
76
|
+
// console.log('初始化完成!');
|
77
|
+
// process.exit(0);
|
78
|
+
// } else {
|
79
|
+
// console.log('初始化失败,文件已存在!');
|
80
|
+
// process.exit(0);
|
81
|
+
// }
|
82
|
+
// } else if ([
|
83
|
+
// 'lib',
|
84
|
+
// 'react-component'
|
85
|
+
// ].includes(stdin)) {
|
86
|
+
// if (
|
87
|
+
// !fs.existsSync(`${root_path}\\jjb.script`) &&
|
88
|
+
// !fs.existsSync(`${root_path}\\src`) &&
|
89
|
+
// !fs.existsSync(`${root_path}\\.gitignore`) &&
|
90
|
+
// !fs.existsSync(`${root_path}\\jjb.config.json`) &&
|
91
|
+
// !fs.existsSync(`${root_path}\\package.json`) &&
|
92
|
+
// !fs.existsSync(`${root_path}\\webstorm.config.js`)
|
93
|
+
// ) {
|
94
|
+
// f_file_copy(`${__dirname}\\..\\cmd.init.copy\\${stdin}`, root_path);
|
95
|
+
// console.log('初始化完成!');
|
96
|
+
// process.exit(0);
|
97
|
+
// } else {
|
98
|
+
// console.log('初始化失败,文件已存在!');
|
99
|
+
// process.exit(0);
|
100
|
+
// }
|
101
|
+
// }
|
66
102
|
};
|
@@ -27,5 +27,21 @@ exports.CLOUD_PROJECT = {
|
|
27
27
|
token: 'd4wQ7dzEjYPsgVbKnYei',
|
28
28
|
projectId: 339
|
29
29
|
},
|
30
|
+
'react-component': {
|
31
|
+
token: 'snBxJ2i5kYarGGcsojhY',
|
32
|
+
projectId: 831
|
33
|
+
},
|
34
|
+
'micro-app-ts': {
|
35
|
+
token: '7V-YUxhmh51Mdhgx4rq4',
|
36
|
+
projectId: 830
|
37
|
+
},
|
38
|
+
'micro-app': {
|
39
|
+
token: 'FqNrmFAgrxasMrbbjvq9',
|
40
|
+
projectId: 829
|
41
|
+
},
|
42
|
+
'lib': {
|
43
|
+
token: 'ywPtT3xCG6b_vAxp6sTj',
|
44
|
+
projectId: 828
|
45
|
+
}
|
30
46
|
};
|
31
47
|
exports.TEMPLATE_FOLDER = `${os.tmpdir()}\\${exports.GIT_TEMP_DIR}`;
|
@@ -1,32 +0,0 @@
|
|
1
|
-
{
|
2
|
-
"projectType": "micro-spa",
|
3
|
-
"installTarget": "node_modules",
|
4
|
-
"installResources": [],
|
5
|
-
"environment": {
|
6
|
-
"development": {
|
7
|
-
"API_HOST": ""
|
8
|
-
},
|
9
|
-
"test": {
|
10
|
-
"API_HOST": ""
|
11
|
-
},
|
12
|
-
"release": {
|
13
|
-
"API_HOST": ""
|
14
|
-
},
|
15
|
-
"production": {
|
16
|
-
"API_HOST": ""
|
17
|
-
}
|
18
|
-
},
|
19
|
-
"contextInject": {},
|
20
|
-
"windowInject": {},
|
21
|
-
"server": {
|
22
|
-
"port": "8066",
|
23
|
-
"host": "127.0.0.1"
|
24
|
-
},
|
25
|
-
"framework": {
|
26
|
-
"antd": {
|
27
|
-
"link-color": "red",
|
28
|
-
"primary-color": "red",
|
29
|
-
"border-radius-base": "2px"
|
30
|
-
}
|
31
|
-
}
|
32
|
-
}
|
@@ -1,14 +0,0 @@
|
|
1
|
-
const { hasEnvironment } = require('./utils');
|
2
|
-
|
3
|
-
if ( !hasEnvironment()) {
|
4
|
-
throw Error('jjb.script[build]: 启动build需要提供NODE_ENV变量,请确认你所运行的脚本是否正确?');
|
5
|
-
}
|
6
|
-
|
7
|
-
require('webpack')(require('./config')('production').webpack).run(function (stat, compiler) {
|
8
|
-
if ( !compiler.compilation.errors.length) {
|
9
|
-
console.log('库文件Build完成!');
|
10
|
-
} else {
|
11
|
-
console.log('库文件Build失败,发现以下问题,请解决后重试!');
|
12
|
-
console.log(compiler.compilation.errors);
|
13
|
-
}
|
14
|
-
});
|
@@ -1,149 +0,0 @@
|
|
1
|
-
// noinspection JSUnresolvedVariable
|
2
|
-
|
3
|
-
const path = require('path');
|
4
|
-
const { CleanWebpackPlugin } = require('clean-webpack-plugin');
|
5
|
-
const { requireResolve } = require('./utils');
|
6
|
-
const webpack = require('webpack');
|
7
|
-
|
8
|
-
const config = require(requireResolve('jjb.config.json'));
|
9
|
-
const packageJSON = require(requireResolve('package.json'));
|
10
|
-
const server = (config.server || {});
|
11
|
-
const environment = (config.environment || {})[ process.env.NODE_ENV ];
|
12
|
-
const windowInject = (config.windowInject || {});
|
13
|
-
const contextInject = (config.contextInject || {});
|
14
|
-
const contextData = {
|
15
|
-
...environment,
|
16
|
-
...contextInject
|
17
|
-
};
|
18
|
-
|
19
|
-
module.exports = mode => {
|
20
|
-
return {
|
21
|
-
server,
|
22
|
-
webpack: {
|
23
|
-
// 模式 ‘development’ | ‘production’
|
24
|
-
mode,
|
25
|
-
// 入口
|
26
|
-
entry: './src/index.js',
|
27
|
-
// 输出
|
28
|
-
output: {
|
29
|
-
// 指定输出目录文件名
|
30
|
-
path: path.resolve(__dirname, '../dist'),
|
31
|
-
// 定义全局变量,暴露到‘window’对象中
|
32
|
-
library: 'libName',
|
33
|
-
// 指定编译的‘js’存放目录文件名称
|
34
|
-
filename: 'index.js',
|
35
|
-
// 输出公共路径
|
36
|
-
publicPath: '/',
|
37
|
-
// 默认暴露‘window’此处修改为暴露到‘exports’中 window | umd
|
38
|
-
libraryTarget: 'window'
|
39
|
-
},
|
40
|
-
// ‘node.module’
|
41
|
-
module: {
|
42
|
-
// 文件处理
|
43
|
-
rules: [
|
44
|
-
{
|
45
|
-
// 处理‘less’和‘css’文件
|
46
|
-
test: /\.(less|css)$/,
|
47
|
-
// 以此从下到上处理‘css’
|
48
|
-
use: [
|
49
|
-
{
|
50
|
-
loader: 'style-loader'
|
51
|
-
},
|
52
|
-
// 2:将被‘less-loader’处理的‘css’
|
53
|
-
// 由‘css-loader’再次处理
|
54
|
-
{
|
55
|
-
loader: 'css-loader'
|
56
|
-
},
|
57
|
-
// 1:处理‘less’文件
|
58
|
-
{
|
59
|
-
// 使用‘less-loader’
|
60
|
-
loader: 'less-loader',
|
61
|
-
// 配置‘less-loader’
|
62
|
-
options: {
|
63
|
-
// ‘less-loader’特殊配置
|
64
|
-
lessOptions: {
|
65
|
-
// 定义‘less’全局变量,从jjb.config.antd获取
|
66
|
-
modifyVars: (config.framework || {}).antd || {},
|
67
|
-
// 启用‘less-javascript’功能
|
68
|
-
javascriptEnabled: true
|
69
|
-
}
|
70
|
-
}
|
71
|
-
}
|
72
|
-
]
|
73
|
-
},
|
74
|
-
{
|
75
|
-
// 处理‘js’文件
|
76
|
-
test: /\.js$/,
|
77
|
-
// 使用‘babel-loader’
|
78
|
-
loader: 'babel-loader',
|
79
|
-
// 允许‘babel-loader’操作目录
|
80
|
-
include: [
|
81
|
-
// 整个‘src’目录
|
82
|
-
path.resolve(__dirname, '../src')
|
83
|
-
],
|
84
|
-
// 配置‘babel-loader’
|
85
|
-
options: {
|
86
|
-
// 加入一个‘babel-plugin-import’插件,特殊处理‘antd’文件过大问题
|
87
|
-
plugins: [
|
88
|
-
[
|
89
|
-
'import',
|
90
|
-
{
|
91
|
-
// ‘webpack’定义全局变量‘antd’
|
92
|
-
libraryName: 'antd',
|
93
|
-
// 按需将‘es’文件夹中组件导出,绑定到‘antd’变量
|
94
|
-
// 除了‘es’,也可以修改为‘lib’
|
95
|
-
libraryDirectory: 'es'
|
96
|
-
// 这里设为‘true’,表示自动导入‘antd/dist/less’
|
97
|
-
// 或修改为‘css’ | ‘less’
|
98
|
-
// style: true
|
99
|
-
}
|
100
|
-
],
|
101
|
-
[
|
102
|
-
'@babel/plugin-proposal-decorators',
|
103
|
-
{
|
104
|
-
'legacy': true
|
105
|
-
}
|
106
|
-
]
|
107
|
-
],
|
108
|
-
// 考虑到使用‘React JSX’语法‘babel-loader’的编译预设要改为‘preset-react’
|
109
|
-
// 可选值‘preset-env’
|
110
|
-
presets: [ '@babel/preset-react' ]
|
111
|
-
}
|
112
|
-
},
|
113
|
-
{
|
114
|
-
// 处理图片文件
|
115
|
-
test: /\.(png|jpg|jpeg|gif|ico|bmp)/,
|
116
|
-
// 使用‘url-loader’或‘raw-loader’
|
117
|
-
loader: 'url-loader',
|
118
|
-
// 配置‘url-loader’
|
119
|
-
options: {
|
120
|
-
// 当文件大小处于(?)byte,输出‘base64’,反之为‘url’.
|
121
|
-
// 这里设为‘false’,表示无论多大多小,都为‘url’.
|
122
|
-
limit: true
|
123
|
-
}
|
124
|
-
}
|
125
|
-
]
|
126
|
-
},
|
127
|
-
// 解析
|
128
|
-
resolve: {
|
129
|
-
// 为‘import’或‘require’定义别名路径
|
130
|
-
alias: {
|
131
|
-
'~': requireResolve('src')
|
132
|
-
}
|
133
|
-
},
|
134
|
-
// 插件
|
135
|
-
plugins: [
|
136
|
-
// 注入全局变量到项目中,从‘jjb.config.contextData’读取
|
137
|
-
new webpack.DefinePlugin({ 'process.env.app': JSON.stringify(contextData) }),
|
138
|
-
// 解决‘moment.js’本地化文件过多问题
|
139
|
-
// 按需加载本地化文件当前项目只需要‘zh_CN.js’
|
140
|
-
new webpack.IgnorePlugin({
|
141
|
-
contextRegExp: /moment$/,
|
142
|
-
resourceRegExp: /^\.\/locale$/
|
143
|
-
}),
|
144
|
-
// 每次打包前删除‘dist’目录
|
145
|
-
new CleanWebpackPlugin()
|
146
|
-
]
|
147
|
-
}
|
148
|
-
};
|
149
|
-
};
|
@@ -1,19 +0,0 @@
|
|
1
|
-
const express = require('express');
|
2
|
-
const history = require('connect-history-api-fallback');
|
3
|
-
const app = express();
|
4
|
-
const port = '8766';
|
5
|
-
|
6
|
-
/**
|
7
|
-
* 单页面应用需要的历史记录模块
|
8
|
-
*/
|
9
|
-
app.use(history());
|
10
|
-
|
11
|
-
/**
|
12
|
-
* 输出静态资源
|
13
|
-
*/
|
14
|
-
app.use(express.static('../dist'));
|
15
|
-
|
16
|
-
/**
|
17
|
-
* 监听端口
|
18
|
-
*/
|
19
|
-
app.listen(port, () => console.log(`Your application is running here: http://localhost:${port}`));
|
@@ -1,29 +0,0 @@
|
|
1
|
-
const Server = require('webpack-dev-server');
|
2
|
-
const webpack = require('webpack');
|
3
|
-
const { hasEnvironment } = require('./utils');
|
4
|
-
|
5
|
-
if (!hasEnvironment()) {
|
6
|
-
throw Error('jjb.script[server]: 启动server需要提供NODE_ENV变量,请确认你所运行的脚本是否正确?');
|
7
|
-
}
|
8
|
-
|
9
|
-
const config = require('./config')('development');
|
10
|
-
|
11
|
-
new Server({
|
12
|
-
host: config.server.host || '127.0.0.1',
|
13
|
-
port: config.server.port || '8080',
|
14
|
-
headers: {
|
15
|
-
'Access-Control-Allow-Origin': '*',
|
16
|
-
'Access-Control-Allow-Methods': '*',
|
17
|
-
'Access-Control-Allow-Headers': '*'
|
18
|
-
},
|
19
|
-
compress: true,
|
20
|
-
client: {
|
21
|
-
overlay: {
|
22
|
-
errors: true,
|
23
|
-
warnings: true
|
24
|
-
}
|
25
|
-
},
|
26
|
-
historyApiFallback: {
|
27
|
-
disableDotRule: true
|
28
|
-
}
|
29
|
-
}, webpack(config.webpack)).startCallback(() => console.log('jjb.server 服务已启动,正在编译。'));
|
@@ -1,13 +0,0 @@
|
|
1
|
-
const path = require('path');
|
2
|
-
/**
|
3
|
-
* @description 是否有环境变量‘NODE_ENV’
|
4
|
-
* @return {boolean}
|
5
|
-
*/
|
6
|
-
exports.hasEnvironment = () => process.env.NODE_ENV !== undefined;
|
7
|
-
|
8
|
-
/**
|
9
|
-
* @description 文件解析
|
10
|
-
* @param name {string}
|
11
|
-
* @return {`${string}\\${string}`}
|
12
|
-
*/
|
13
|
-
exports.requireResolve = name => `${path.resolve(__dirname, '..')}\\${name}`;
|
@@ -1,62 +0,0 @@
|
|
1
|
-
{
|
2
|
-
"name": "lib",
|
3
|
-
"version": "1.0.0",
|
4
|
-
"description": "工具库模板",
|
5
|
-
"main": "index.js",
|
6
|
-
"scripts": {
|
7
|
-
"serve": "node jjb.script/server.js",
|
8
|
-
"build": "node jjb.script/build.js",
|
9
|
-
"serve:development": "cross-env NODE_ENV=development npm run serve",
|
10
|
-
"serve:test": "cross-env NODE_ENV=test npm run serve",
|
11
|
-
"serve:release": "cross-env NODE_ENV=release npm run serve",
|
12
|
-
"serve:production": "cross-env NODE_ENV=production npm run serve",
|
13
|
-
"build:development": "cross-env NODE_ENV=development npm run build",
|
14
|
-
"build:test": "cross-env NODE_ENV=test npm run build",
|
15
|
-
"build:release": "cross-env NODE_ENV=release npm run build",
|
16
|
-
"build:production": "cross-env NODE_ENV=production npm run build",
|
17
|
-
"jjb-cmd:install": "jjb-cmd install"
|
18
|
-
},
|
19
|
-
"author": "JJB",
|
20
|
-
"license": "MIT",
|
21
|
-
"devDependencies": {
|
22
|
-
"@babel/core": "^7.19.3",
|
23
|
-
"@babel/plugin-proposal-decorators": "^7.19.3",
|
24
|
-
"@babel/preset-react": "^7.18.6",
|
25
|
-
"babel-loader": "^8.2.5",
|
26
|
-
"babel-plugin-import": "^1.13.5",
|
27
|
-
"clean-webpack-plugin": "^4.0.0",
|
28
|
-
"connect-history-api-fallback": "^2.0.0",
|
29
|
-
"cross-env": "^7.0.3",
|
30
|
-
"css-loader": "^6.7.1",
|
31
|
-
"css-minimizer-webpack-plugin": "^4.2.1",
|
32
|
-
"express": "^4.18.2",
|
33
|
-
"file-loader": "^6.2.0",
|
34
|
-
"html-webpack-plugin": "^5.5.0",
|
35
|
-
"less": "^4.1.3",
|
36
|
-
"less-loader": "^11.1.0",
|
37
|
-
"mini-css-extract-plugin": "^2.6.1",
|
38
|
-
"style-loader": "^3.3.1",
|
39
|
-
"terser-webpack-plugin": "^5.3.6",
|
40
|
-
"uglifyjs-webpack-plugin": "^2.2.0",
|
41
|
-
"url-loader": "^4.1.1",
|
42
|
-
"webpack": "^5.74.0",
|
43
|
-
"webpack-bundle-analyzer": "^4.6.1",
|
44
|
-
"webpack-cli": "^4.10.0",
|
45
|
-
"webpack-dev-server": "^4.11.1"
|
46
|
-
},
|
47
|
-
"dependencies": {
|
48
|
-
"@ant-design/icons": "^4.7.0",
|
49
|
-
"antd": "^4.23.5",
|
50
|
-
"axios": "^1.1.2",
|
51
|
-
"crypto-js": "^4.1.1",
|
52
|
-
"dva": "^2.6.0-beta.22",
|
53
|
-
"history": "^5.3.0",
|
54
|
-
"moment": "^2.29.4",
|
55
|
-
"prop-types": "^15.8.1",
|
56
|
-
"react": "^17.0.2",
|
57
|
-
"react-cropper": "^2.1.8",
|
58
|
-
"react-dom": "^17.0.2",
|
59
|
-
"react-router-dom": "^5.2.0",
|
60
|
-
"watch-props": "^0.0.3"
|
61
|
-
}
|
62
|
-
}
|
@@ -1 +0,0 @@
|
|
1
|
-
export {};
|
@@ -1,16 +0,0 @@
|
|
1
|
-
'use strict';
|
2
|
-
const path = require('path');
|
3
|
-
|
4
|
-
function resolve (dir) {
|
5
|
-
return path.join(__dirname, '.', dir);
|
6
|
-
}
|
7
|
-
|
8
|
-
module.exports = {
|
9
|
-
context: path.resolve(__dirname, './'),
|
10
|
-
resolve: {
|
11
|
-
extensions: [ '.js' ],
|
12
|
-
alias: {
|
13
|
-
'~': resolve('src/')
|
14
|
-
}
|
15
|
-
}
|
16
|
-
};
|
@@ -1,42 +0,0 @@
|
|
1
|
-
{
|
2
|
-
"projectType": "micro-spa",
|
3
|
-
"installTarget": "node_modules",
|
4
|
-
"installResources": [
|
5
|
-
"jjb-dva-runtime",
|
6
|
-
"jjb-common-lib",
|
7
|
-
"jjb-common-decorator",
|
8
|
-
"react-admin-component"
|
9
|
-
],
|
10
|
-
"environment": {
|
11
|
-
"development": {
|
12
|
-
"API_HOST": ""
|
13
|
-
},
|
14
|
-
"test": {
|
15
|
-
"API_HOST": ""
|
16
|
-
},
|
17
|
-
"release": {
|
18
|
-
"API_HOST": ""
|
19
|
-
},
|
20
|
-
"production": {
|
21
|
-
"API_HOST": ""
|
22
|
-
}
|
23
|
-
},
|
24
|
-
"contextInject": {
|
25
|
-
"basename": "/"
|
26
|
-
},
|
27
|
-
"windowInject": {
|
28
|
-
"title": "微应用",
|
29
|
-
"jjbCommonLibUrl": "https://cdn.cqjjb.cn/jjb-common-lib/latest/index.js"
|
30
|
-
},
|
31
|
-
"server": {
|
32
|
-
"port": "8080",
|
33
|
-
"host": "127.0.0.1"
|
34
|
-
},
|
35
|
-
"framework": {
|
36
|
-
"antd": {
|
37
|
-
"link-color": "#007AFF",
|
38
|
-
"primary-color": "#007AFF",
|
39
|
-
"border-radius-base": "2px"
|
40
|
-
}
|
41
|
-
}
|
42
|
-
}
|
@@ -1,14 +0,0 @@
|
|
1
|
-
const { hasEnvironment } = require('./utils');
|
2
|
-
|
3
|
-
if ( !hasEnvironment()) {
|
4
|
-
throw Error('jjb.script[build]: 启动build需要提供NODE_ENV变量,请确认你所运行的脚本是否正确?');
|
5
|
-
}
|
6
|
-
|
7
|
-
require('webpack')(require('./config')('production').webpack).run(function (stat, compiler) {
|
8
|
-
if ( !compiler.compilation.errors.length) {
|
9
|
-
console.log('项目Build完成!');
|
10
|
-
} else {
|
11
|
-
console.log('项目Build失败,发现以下问题,请解决后重试!');
|
12
|
-
console.log(compiler.compilation.errors);
|
13
|
-
}
|
14
|
-
});
|