ee-bin 4.1.10 → 4.2.0
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/config/bin_default.js +181 -181
- package/index.js +121 -120
- package/lib/extend.js +77 -77
- package/lib/pargv.js +263 -263
- package/lib/utils.js +255 -255
- package/package.json +33 -32
- package/tools/encrypt.js +178 -178
- package/tools/iconGen.js +182 -182
- package/tools/incrUpdater.js +225 -195
- package/tools/move.js +68 -68
- package/tools/serve.js +346 -346
package/tools/incrUpdater.js
CHANGED
|
@@ -1,196 +1,226 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const path = require('path');
|
|
4
|
-
const fs = require('fs');
|
|
5
|
-
const fsPro = require('fs-extra');
|
|
6
|
-
const crypto = require('crypto');
|
|
7
|
-
const chalk = require('chalk');
|
|
8
|
-
const
|
|
9
|
-
const
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
*
|
|
15
|
-
* @class
|
|
16
|
-
*/
|
|
17
|
-
|
|
18
|
-
class IncrUpdater {
|
|
19
|
-
|
|
20
|
-
constructor() {
|
|
21
|
-
this.tmpAppDirs = [
|
|
22
|
-
'mac',
|
|
23
|
-
'mac-arm64',
|
|
24
|
-
'win-unpacked',
|
|
25
|
-
'win-ia32-unpacked',
|
|
26
|
-
'linux-unpacked'
|
|
27
|
-
];
|
|
28
|
-
this.
|
|
29
|
-
this.
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
const
|
|
78
|
-
|
|
79
|
-
let
|
|
80
|
-
if (
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
const
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
const
|
|
121
|
-
//
|
|
122
|
-
//
|
|
123
|
-
zip.
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
//
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
const
|
|
185
|
-
|
|
186
|
-
const
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const path = require('path');
|
|
4
|
+
const fs = require('fs');
|
|
5
|
+
const fsPro = require('fs-extra');
|
|
6
|
+
const crypto = require('crypto');
|
|
7
|
+
const chalk = require('chalk');
|
|
8
|
+
const admZip = require('adm-zip');
|
|
9
|
+
const globby = require('globby');
|
|
10
|
+
const yaml = require('js-yaml');
|
|
11
|
+
const { loadConfig, writeJsonSync } = require('../lib/utils');
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Updater
|
|
15
|
+
* @class
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
class IncrUpdater {
|
|
19
|
+
|
|
20
|
+
constructor() {
|
|
21
|
+
this.tmpAppDirs = [
|
|
22
|
+
'mac',
|
|
23
|
+
'mac-arm64',
|
|
24
|
+
'win-unpacked',
|
|
25
|
+
'win-ia32-unpacked',
|
|
26
|
+
'linux-unpacked'
|
|
27
|
+
];
|
|
28
|
+
this.windows32Platform = 'windows_32';
|
|
29
|
+
this.windows64Platform = 'windows_64';
|
|
30
|
+
this.macosIntelPlatform = 'macos_intel';
|
|
31
|
+
this.macosApplePlatform = 'macos_apple';
|
|
32
|
+
this.linuxPlatform = 'linux';
|
|
33
|
+
this.nodeModulesString = 'node_modules';
|
|
34
|
+
this.asarUnpackedString = 'app.asar.unpacked';
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* run
|
|
39
|
+
*/
|
|
40
|
+
run(options = {}) {
|
|
41
|
+
console.log('[ee-bin] [updater] Start');
|
|
42
|
+
const { config, asarFile, platform, force } = options;
|
|
43
|
+
const binCfg = loadConfig(config);
|
|
44
|
+
const cfg = binCfg.updater;
|
|
45
|
+
const forceUpdate = force == 'true' ? true : false;
|
|
46
|
+
|
|
47
|
+
if (!cfg) {
|
|
48
|
+
console.log(chalk.blue('[ee-bin] [updater] ') + chalk.red(`Error: ${cfg} config does not exist`));
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
this.generateFile(cfg, asarFile, platform, forceUpdate);
|
|
53
|
+
|
|
54
|
+
console.log('[ee-bin] [updater] End');
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* generate json file
|
|
59
|
+
*/
|
|
60
|
+
generateFile(config, asarFile, platform, force = false) {
|
|
61
|
+
const cfg = config[platform];
|
|
62
|
+
if (!cfg) {
|
|
63
|
+
console.log(chalk.blue('[ee-bin] [updater] ') + chalk.red(`Error: ${platform} config does not exist`));
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
let latestVersionInfo = {}
|
|
69
|
+
const homeDir = process.cwd();
|
|
70
|
+
console.log(chalk.blue('[ee-bin] [updater] ') + chalk.green(`${platform} config:`), cfg);
|
|
71
|
+
|
|
72
|
+
const metadataPath = path.join(homeDir, cfg.metadata);
|
|
73
|
+
if (!fs.existsSync(metadataPath)) {
|
|
74
|
+
console.log(chalk.blue('[ee-bin] [updater] ') + chalk.red(`Error: ${metadataPath} does not exist!`));
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
const metadataObj = yaml.load(fs.readFileSync(metadataPath, 'utf8'));
|
|
78
|
+
|
|
79
|
+
let asarFilePath = "";
|
|
80
|
+
if (asarFile) {
|
|
81
|
+
asarFilePath = path.normalize(path.join(homeDir, asarFile));
|
|
82
|
+
} else {
|
|
83
|
+
asarFilePath = path.normalize(path.join(homeDir, cfg.asarFile));
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
if (!fs.existsSync(asarFilePath)) {
|
|
87
|
+
console.log(chalk.blue('[ee-bin] [updater] ') + chalk.red(`Error: ${asarFilePath} does not exist`));
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
const version = metadataObj.version;
|
|
92
|
+
let platformForFilename = platform;
|
|
93
|
+
if (platform.indexOf("_") !== -1) {
|
|
94
|
+
const platformArr = platform.split("_");
|
|
95
|
+
// windows_32 -> windows-32
|
|
96
|
+
platformForFilename = platformArr.join("-");
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
// zip
|
|
100
|
+
let zipName = "";
|
|
101
|
+
const extZip = '.zip';
|
|
102
|
+
zipName = path.basename(cfg.output.zip, extZip) + `-${platformForFilename}-${version}${extZip}`;
|
|
103
|
+
const asarZipPath = path.join(homeDir, cfg.output.directory, zipName);
|
|
104
|
+
if (fs.existsSync(asarZipPath)) {
|
|
105
|
+
fsPro.removeSync(asarZipPath);
|
|
106
|
+
}
|
|
107
|
+
const zip = new admZip();
|
|
108
|
+
// add asar
|
|
109
|
+
zip.addLocalFile(asarFilePath);
|
|
110
|
+
// add extraResources
|
|
111
|
+
if (cfg.extraResources && cfg.extraResources.length > 0) {
|
|
112
|
+
const files = globby.sync(cfg.extraResources, { cwd: homeDir });
|
|
113
|
+
for (const extraRes of files) {
|
|
114
|
+
const extraResPath = path.normalize(path.join(homeDir, extraRes));
|
|
115
|
+
if (!fs.existsSync(extraResPath)) {
|
|
116
|
+
continue;
|
|
117
|
+
}
|
|
118
|
+
const extraResDir = path.dirname(extraResPath);
|
|
119
|
+
const index = extraResDir.indexOf('extraResources');
|
|
120
|
+
const zipFileDir = extraResDir.substring(index);
|
|
121
|
+
// 资源路径 extraResPath: D:\www\gofile\src\ee\ee-demo\build\extraResources\hello\c.txt
|
|
122
|
+
// 文件在zip中的路径 zipFileDir: extraResources/hello
|
|
123
|
+
zip.addLocalFile(extraResPath, zipFileDir);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
// add asarUnpacked
|
|
127
|
+
if (cfg.asarUnpacked && cfg.asarUnpacked.length > 0) {
|
|
128
|
+
const modules = cfg.asarUnpacked;
|
|
129
|
+
for (const moduleItem of modules) {
|
|
130
|
+
const modulePath = path.normalize(path.join(homeDir, moduleItem));
|
|
131
|
+
if (!fs.existsSync(modulePath)) {
|
|
132
|
+
throw new Error(`${modulePath} is not exists!`);
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
const zipDir = path.join(this.asarUnpackedString, moduleItem);
|
|
136
|
+
// console.log('modulePath', modulePath);
|
|
137
|
+
// console.log('zipDir', zipDir);
|
|
138
|
+
zip.addLocalFolder(modulePath, zipDir);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
zip.writeZip(asarZipPath, (err) => {
|
|
143
|
+
if (err) {
|
|
144
|
+
console.log(chalk.blue('[ee-bin] [updater] create zip ') + chalk.red(`Error: ${err}`));
|
|
145
|
+
}
|
|
146
|
+
});
|
|
147
|
+
|
|
148
|
+
// generate latest.json
|
|
149
|
+
// incr file
|
|
150
|
+
const zipSha1 = this.generateHash(asarZipPath, 'sha1', 'hex');
|
|
151
|
+
const fileStat = fs.statSync(asarZipPath);
|
|
152
|
+
// full file
|
|
153
|
+
let fullFileInfo;
|
|
154
|
+
for (const item of metadataObj.files) {
|
|
155
|
+
if (item.url.indexOf('.zip') !== -1) {
|
|
156
|
+
continue;
|
|
157
|
+
}
|
|
158
|
+
fullFileInfo = item;
|
|
159
|
+
}
|
|
160
|
+
const fullFileName = fullFileInfo.url;
|
|
161
|
+
const fullFilePath = path.normalize(path.join(homeDir, cfg.output.directory, fullFileName));
|
|
162
|
+
const generateSha512 = this.generateHash(fullFilePath, 'sha512');
|
|
163
|
+
if (fullFileInfo.sha512 != generateSha512) {
|
|
164
|
+
console.log(chalk.blue('[ee-bin] [updater] ') + chalk.red(`Error: metadata sha512 is not equal to generateSha512 !
|
|
165
|
+
at metadata sha512: ${fullFileInfo.sha512}
|
|
166
|
+
at generate Sha512: ${generateSha512}`));
|
|
167
|
+
return;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
const item = {
|
|
171
|
+
version: version,
|
|
172
|
+
file: zipName,
|
|
173
|
+
size: fileStat.size,
|
|
174
|
+
sha1: zipSha1,
|
|
175
|
+
fullFile: {
|
|
176
|
+
fileName: fullFileInfo.url,
|
|
177
|
+
size: fullFileInfo.size,
|
|
178
|
+
sha512: generateSha512,
|
|
179
|
+
},
|
|
180
|
+
force,
|
|
181
|
+
releaseDate: metadataObj.releaseDate,
|
|
182
|
+
};
|
|
183
|
+
const extJson = '.json';
|
|
184
|
+
const jsonName = path.basename(cfg.output.file, extJson) + `-${platformForFilename}${extJson}`;
|
|
185
|
+
latestVersionInfo = item;
|
|
186
|
+
const updaterJsonFilePath = path.join(homeDir, cfg.output.directory, jsonName);
|
|
187
|
+
writeJsonSync(updaterJsonFilePath, latestVersionInfo);
|
|
188
|
+
|
|
189
|
+
// Delete cache files to prevent generated zip files from being outdated versions
|
|
190
|
+
if (cfg.cleanCache) {
|
|
191
|
+
this.tmpAppDirs.forEach(dir => {
|
|
192
|
+
const dirPath = path.join(homeDir, cfg.output.directory, dir);
|
|
193
|
+
fsPro.removeSync(dirPath);
|
|
194
|
+
});
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
generateHash(filepath = "", algorithm = "sha512", encoding = "base64") {
|
|
199
|
+
let data = '';
|
|
200
|
+
if (filepath.length == 0) {
|
|
201
|
+
return data;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
if (!fs.existsSync(filepath)) {
|
|
205
|
+
return data;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
console.log(chalk.blue('[ee-bin] [updater] ') + `generate ${algorithm} for filepath:${filepath}`);
|
|
209
|
+
try {
|
|
210
|
+
const buffer = fs.readFileSync(filepath);
|
|
211
|
+
const fsHash = crypto.createHash(algorithm);
|
|
212
|
+
fsHash.update(buffer);
|
|
213
|
+
data = fsHash.digest(encoding);
|
|
214
|
+
return data;
|
|
215
|
+
} catch (error) {
|
|
216
|
+
console.log(chalk.blue('[ee-bin] [updater] ') + chalk.red(`Error: generate ${algorithm} error!`));
|
|
217
|
+
console.log(chalk.blue('[ee-bin] [updater] ') + chalk.red(`Error: ${error}`));
|
|
218
|
+
}
|
|
219
|
+
return data;
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
module.exports = {
|
|
224
|
+
IncrUpdater,
|
|
225
|
+
incrUpdater: new IncrUpdater()
|
|
196
226
|
}
|
package/tools/move.js
CHANGED
|
@@ -1,69 +1,69 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const path = require('path');
|
|
4
|
-
const fs = require('fs');
|
|
5
|
-
const fsPro = require('fs-extra');
|
|
6
|
-
const chalk = require('chalk');
|
|
7
|
-
const { loadConfig, rm } = require('../lib/utils');
|
|
8
|
-
|
|
9
|
-
const homeDir = process.cwd();
|
|
10
|
-
|
|
11
|
-
// 移动资源
|
|
12
|
-
function move(options = {}) {
|
|
13
|
-
console.log('[ee-bin] [move] Start moving resources');
|
|
14
|
-
const { config, flag } = options;
|
|
15
|
-
const binCfg = loadConfig(config);
|
|
16
|
-
const moveConfig = binCfg.move;
|
|
17
|
-
|
|
18
|
-
let flags;
|
|
19
|
-
const flagString = flag.trim();
|
|
20
|
-
if (flagString.indexOf(',') !== -1) {
|
|
21
|
-
flags = flagString.split(',');
|
|
22
|
-
} else {
|
|
23
|
-
flags = [flagString];
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
for (let i = 0; i < flags.length; i++) {
|
|
27
|
-
let f = flags[i];
|
|
28
|
-
let cfg = moveConfig[f];
|
|
29
|
-
|
|
30
|
-
if (!cfg) {
|
|
31
|
-
console.log(chalk.blue('[ee-bin] [move] ') + chalk.red(`Error: ${f} config does not exist` ));
|
|
32
|
-
return;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
const { src, dest, dist, target } = cfg;
|
|
36
|
-
const source = dist ? dist : src;
|
|
37
|
-
const destination = target ? target : dest;
|
|
38
|
-
|
|
39
|
-
console.log(chalk.blue('[ee-bin] [move] ') + chalk.green(`Move flag: ${f}`));
|
|
40
|
-
console.log(chalk.blue('[ee-bin] [move] ') + chalk.green('config:'), cfg);
|
|
41
|
-
|
|
42
|
-
const srcResource = path.join(homeDir, source);
|
|
43
|
-
if (!fs.existsSync(srcResource)) {
|
|
44
|
-
const errorTips = chalk.bgRed('Error') + ` ${source} resource does not exist !`;
|
|
45
|
-
console.error(errorTips);
|
|
46
|
-
return
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
// clear the historical resource and copy it to the ee resource directory
|
|
50
|
-
const destResource = path.join(homeDir, destination);
|
|
51
|
-
if (fs.statSync(srcResource).isDirectory() && !fs.existsSync(destResource)) {
|
|
52
|
-
fs.mkdirSync(destResource, {recursive: true, mode: 0o777});
|
|
53
|
-
} else {
|
|
54
|
-
rm(destResource);
|
|
55
|
-
console.log('[ee-bin] [move] Clear history resources:', destResource);
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
fsPro.copySync(srcResource, destResource);
|
|
59
|
-
|
|
60
|
-
// [todo] go project, special treatment of package.json, reserved only necessary
|
|
61
|
-
console.log(`[ee-bin] [move] Copy ${srcResource} to ${destResource}`);
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
console.log('[ee-bin] [move] End');
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
module.exports = {
|
|
68
|
-
move
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const path = require('path');
|
|
4
|
+
const fs = require('fs');
|
|
5
|
+
const fsPro = require('fs-extra');
|
|
6
|
+
const chalk = require('chalk');
|
|
7
|
+
const { loadConfig, rm } = require('../lib/utils');
|
|
8
|
+
|
|
9
|
+
const homeDir = process.cwd();
|
|
10
|
+
|
|
11
|
+
// 移动资源
|
|
12
|
+
function move(options = {}) {
|
|
13
|
+
console.log('[ee-bin] [move] Start moving resources');
|
|
14
|
+
const { config, flag } = options;
|
|
15
|
+
const binCfg = loadConfig(config);
|
|
16
|
+
const moveConfig = binCfg.move;
|
|
17
|
+
|
|
18
|
+
let flags;
|
|
19
|
+
const flagString = flag.trim();
|
|
20
|
+
if (flagString.indexOf(',') !== -1) {
|
|
21
|
+
flags = flagString.split(',');
|
|
22
|
+
} else {
|
|
23
|
+
flags = [flagString];
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
for (let i = 0; i < flags.length; i++) {
|
|
27
|
+
let f = flags[i];
|
|
28
|
+
let cfg = moveConfig[f];
|
|
29
|
+
|
|
30
|
+
if (!cfg) {
|
|
31
|
+
console.log(chalk.blue('[ee-bin] [move] ') + chalk.red(`Error: ${f} config does not exist` ));
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const { src, dest, dist, target } = cfg;
|
|
36
|
+
const source = dist ? dist : src;
|
|
37
|
+
const destination = target ? target : dest;
|
|
38
|
+
|
|
39
|
+
console.log(chalk.blue('[ee-bin] [move] ') + chalk.green(`Move flag: ${f}`));
|
|
40
|
+
console.log(chalk.blue('[ee-bin] [move] ') + chalk.green('config:'), cfg);
|
|
41
|
+
|
|
42
|
+
const srcResource = path.join(homeDir, source);
|
|
43
|
+
if (!fs.existsSync(srcResource)) {
|
|
44
|
+
const errorTips = chalk.bgRed('Error') + ` ${source} resource does not exist !`;
|
|
45
|
+
console.error(errorTips);
|
|
46
|
+
return
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
// clear the historical resource and copy it to the ee resource directory
|
|
50
|
+
const destResource = path.join(homeDir, destination);
|
|
51
|
+
if (fs.statSync(srcResource).isDirectory() && !fs.existsSync(destResource)) {
|
|
52
|
+
fs.mkdirSync(destResource, {recursive: true, mode: 0o777});
|
|
53
|
+
} else {
|
|
54
|
+
rm(destResource);
|
|
55
|
+
console.log('[ee-bin] [move] Clear history resources:', destResource);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
fsPro.copySync(srcResource, destResource);
|
|
59
|
+
|
|
60
|
+
// [todo] go project, special treatment of package.json, reserved only necessary
|
|
61
|
+
console.log(`[ee-bin] [move] Copy ${srcResource} to ${destResource}`);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
console.log('[ee-bin] [move] End');
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
module.exports = {
|
|
68
|
+
move
|
|
69
69
|
}
|