@cocreate/cli 1.15.0 → 1.16.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/CHANGELOG.md +7 -0
- package/package.json +1 -2
- package/repositories.js +9 -33
- package/src/addMeta.js +43 -38
- package/src/coc.js +26 -69
- package/src/commands/bump.js +62 -103
- package/src/commands/clone.js +15 -16
- package/src/commands/git/gitConfig.js +59 -67
- package/src/commands/gitConfig.js +3 -1
- package/src/commands/install.js +6 -22
- package/src/commands/link.js +12 -38
- package/src/commands/symlink.js +109 -0
- package/src/execute.js +13 -38
- package/src/commands/other/symbolic-link.js +0 -116
- package/src/repoList.js +0 -44
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
# [1.16.0](https://github.com/CoCreate-app/CoCreate-cli/compare/v1.15.0...v1.16.0) (2023-02-21)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Features
|
|
5
|
+
|
|
6
|
+
* run symlink on coc install ([c4bdf15](https://github.com/CoCreate-app/CoCreate-cli/commit/c4bdf15d7b7f6c6cbe90a68904ca6042f2d6db38))
|
|
7
|
+
|
|
1
8
|
# [1.15.0](https://github.com/CoCreate-app/CoCreate-cli/compare/v1.14.30...v1.15.0) (2023-02-18)
|
|
2
9
|
|
|
3
10
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cocreate/cli",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.16.0",
|
|
4
4
|
"description": "Polyrepo management bash CLI tool. Run all git commands and yarn commands on multiple repositories. Also includes a few custom macros for cloning, installing, etc.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cli",
|
|
@@ -77,7 +77,6 @@
|
|
|
77
77
|
"colors": "latest",
|
|
78
78
|
"glob": "^7.1.7",
|
|
79
79
|
"got": "latest",
|
|
80
|
-
"minimist": "latest",
|
|
81
80
|
"prettier": "^2.3.2",
|
|
82
81
|
"prompt": "^1.2.0"
|
|
83
82
|
}
|
package/repositories.js
CHANGED
|
@@ -87,7 +87,7 @@ module.exports = [
|
|
|
87
87
|
'repo': 'github.com/CoCreate-app/CoCreate-elements.git'
|
|
88
88
|
},
|
|
89
89
|
{
|
|
90
|
-
'path': '
|
|
90
|
+
'path': '/home/ubuntu/CoCreateServer/CoCreate-components/CoCreate-events',
|
|
91
91
|
'repo': 'github.com/CoCreate-app/CoCreate-events.git'
|
|
92
92
|
},
|
|
93
93
|
{
|
|
@@ -214,10 +214,6 @@ module.exports = [
|
|
|
214
214
|
'path': '/home/ubuntu/CoCreateServer/CoCreate-components/CoCreate-select',
|
|
215
215
|
'repo': 'github.com/CoCreate-app/CoCreate-select.git'
|
|
216
216
|
},
|
|
217
|
-
{
|
|
218
|
-
'path': '/home/ubuntu/CoCreateServer/CoCreate-components/CoCreate-selected',
|
|
219
|
-
'repo': 'github.com/CoCreate-app/CoCreate-selected.git'
|
|
220
|
-
},
|
|
221
217
|
{
|
|
222
218
|
'path': '/home/ubuntu/CoCreateServer/CoCreate-components/CoCreate-selection',
|
|
223
219
|
'repo': 'github.com/CoCreate-app/CoCreate-selection.git'
|
|
@@ -238,10 +234,6 @@ module.exports = [
|
|
|
238
234
|
'path': '/home/ubuntu/CoCreateServer/CoCreate-components/CoCreate-text',
|
|
239
235
|
'repo': 'github.com/CoCreate-app/CoCreate-text.git'
|
|
240
236
|
},
|
|
241
|
-
// {
|
|
242
|
-
// 'path': '/home/ubuntu/CoCreateServer/CoCreate-components/CoCreate-toggle',
|
|
243
|
-
// 'repo': 'github.com/CoCreate-app/CoCreate-toggle.git'
|
|
244
|
-
// },
|
|
245
237
|
{
|
|
246
238
|
'path': '/home/ubuntu/CoCreateServer/CoCreate-components/CoCreate-toolbar',
|
|
247
239
|
'repo': 'github.com/CoCreate-app/CoCreate-toolbar.git'
|
|
@@ -350,10 +342,6 @@ module.exports = [
|
|
|
350
342
|
'path': '/home/ubuntu/CoCreateServer/CoCreate-plugins/CoCreate-linkedin',
|
|
351
343
|
'repo': 'github.com/CoCreate-app/CoCreate-linkedin.git'
|
|
352
344
|
},
|
|
353
|
-
// {
|
|
354
|
-
// 'path': '/home/ubuntu/CoCreateServer/CoCreate-plugins/CoCreate-monaco',
|
|
355
|
-
// 'repo': 'github.com/CoCreate-app/CoCreate-monaco.git'
|
|
356
|
-
// },
|
|
357
345
|
{
|
|
358
346
|
'path': '/home/ubuntu/CoCreateServer/CoCreate-plugins/CoCreate-pickr',
|
|
359
347
|
'repo': 'github.com/CoCreate-app/CoCreate-pickr.git'
|
|
@@ -370,10 +358,6 @@ module.exports = [
|
|
|
370
358
|
'path': '/home/ubuntu/CoCreateServer/CoCreate-plugins/CoCreate-prism',
|
|
371
359
|
'repo': 'github.com/CoCreate-app/CoCreate-prism.git'
|
|
372
360
|
},
|
|
373
|
-
// {
|
|
374
|
-
// 'path': '/home/ubuntu/CoCreateServer/CoCreate-plugins/CoCreate-quill',
|
|
375
|
-
// 'repo': 'github.com/CoCreate-app/CoCreate-quill.git'
|
|
376
|
-
// },
|
|
377
361
|
{
|
|
378
362
|
'path': '/home/ubuntu/CoCreateServer/CoCreate-plugins/CoCreate-s3',
|
|
379
363
|
'repo': 'github.com/CoCreate-app/CoCreate-s3.git'
|
|
@@ -409,14 +393,14 @@ module.exports = [
|
|
|
409
393
|
|
|
410
394
|
|
|
411
395
|
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
396
|
+
{
|
|
397
|
+
'path': '/home/ubuntu/CoCreateServer/CoCreateWS',
|
|
398
|
+
'repo': 'github.com/CoCreate-app/CoCreateWS.git'
|
|
399
|
+
},
|
|
400
|
+
{
|
|
401
|
+
'path': '/home/ubuntu/CoCreateServer/CoCreateApi',
|
|
402
|
+
'repo': 'github.com/CoCreate-app/CoCreateApi.git'
|
|
403
|
+
},
|
|
420
404
|
|
|
421
405
|
{
|
|
422
406
|
'path': '/home/ubuntu/CoCreateServer/CoCreateLB',
|
|
@@ -479,14 +463,6 @@ module.exports = [
|
|
|
479
463
|
'path': '/home/ubuntu/CoCreateServer/CoCreate-components/CoCreate-keepalived',
|
|
480
464
|
'repo': 'github.com/CoCreate-app/CoCreate-keepalived.git'
|
|
481
465
|
},
|
|
482
|
-
// {
|
|
483
|
-
// 'path': '/home/ubuntu/CoCreateServer/CoCreate-components/CoCreate-mongodb',
|
|
484
|
-
// 'repo': 'github.com/CoCreate-app/CoCreate-mongodb.git'
|
|
485
|
-
// },
|
|
486
|
-
// {
|
|
487
|
-
// 'path': '/home/ubuntu/CoCreateServer/CoCreate-components/CoCreate-openebs',
|
|
488
|
-
// 'repo': 'github.com/CoCreate-app/CoCreate-openebs.git'
|
|
489
|
-
// },
|
|
490
466
|
{
|
|
491
467
|
'path': '/home/ubuntu/CoCreateServer/CoCreate-components/CoCreate-ide',
|
|
492
468
|
'repo': 'github.com/CoCreate-app/CoCreate-ide.git'
|
package/src/addMeta.js
CHANGED
|
@@ -1,60 +1,65 @@
|
|
|
1
1
|
const fs = require('fs')
|
|
2
2
|
const path = require("path")
|
|
3
|
+
const util = require('node:util');
|
|
4
|
+
const exec = util.promisify(require('node:child_process').exec);
|
|
5
|
+
|
|
6
|
+
module.exports = async function addMeta(repos, failed, directory) {
|
|
7
|
+
let packageManager;
|
|
8
|
+
for (let i = 0; i < repos.length; i++) {
|
|
9
|
+
repos[i].name = path.basename(repos[i].path);
|
|
10
|
+
repos[i].plainName = repos[i].name.substr(9);
|
|
11
|
+
|
|
12
|
+
if (directory) {
|
|
13
|
+
repos[i].ppath = path.resolve(directory, repos[i].path);
|
|
14
|
+
repos[i].absolutePath = path.resolve(directory, repos[i].path);
|
|
15
|
+
repos[i].directory = directory;
|
|
16
|
+
}
|
|
3
17
|
|
|
4
|
-
|
|
5
|
-
return repos.map(repo => {
|
|
6
|
-
let {
|
|
7
|
-
name,
|
|
8
|
-
ppath
|
|
9
|
-
} = repo;
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
let packagejson = path.resolve(ppath, 'package.json');
|
|
18
|
+
let packagejson = path.resolve(repos[i].absolutePath, 'package.json');
|
|
14
19
|
if (!fs.existsSync(packagejson)) {
|
|
15
|
-
console.error('package json not found for', name);
|
|
20
|
+
console.error('package json not found for', repos[i].name);
|
|
16
21
|
failed.push({
|
|
17
|
-
name,
|
|
22
|
+
name: repos[i].name,
|
|
18
23
|
des: 'package json not found'
|
|
19
24
|
})
|
|
20
|
-
return false;
|
|
21
25
|
}
|
|
26
|
+
|
|
22
27
|
let packageObj
|
|
23
28
|
try {
|
|
24
29
|
packageObj = require(packagejson);
|
|
25
|
-
|
|
26
30
|
}
|
|
27
31
|
catch (err) {
|
|
28
|
-
console.error(err.message)
|
|
29
|
-
return false;
|
|
32
|
+
console.error('packageObj', err.message)
|
|
30
33
|
}
|
|
31
34
|
|
|
32
35
|
|
|
33
|
-
|
|
34
|
-
'@cocreate/' + name.substr(9) : packageObj.name;
|
|
36
|
+
repos[i].packageName = packageObj.name;
|
|
35
37
|
|
|
36
|
-
|
|
38
|
+
repos[i].deps = Object.keys(packageObj['dependencies'] || {})
|
|
37
39
|
.filter(packageName => packageName.startsWith('@cocreate/'));
|
|
38
|
-
|
|
40
|
+
repos[i].devDeps = Object.keys(packageObj['devDependencies'] || {})
|
|
39
41
|
.filter(packageName => packageName.startsWith('@cocreate/'));
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
42
|
+
|
|
43
|
+
if (!repos[i].packageManager) {
|
|
44
|
+
if (packageManager)
|
|
45
|
+
repos[i].packageManager = packageManager
|
|
46
|
+
else {
|
|
47
|
+
repos[i].packageManager = 'npm'
|
|
48
|
+
let lockFile = path.resolve(repos[i].absolutePath, 'package-lock.json');
|
|
49
|
+
if (!fs.existsSync(lockFile)) {
|
|
50
|
+
lockFile = path.resolve(repos[i].absolutePath, 'yarn.lock');
|
|
51
|
+
if (fs.existsSync(lockFile))
|
|
52
|
+
repos[i].packageManager = 'yarn'
|
|
53
|
+
else {
|
|
54
|
+
const { error } = await exec('yarn --version');
|
|
55
|
+
if (!error)
|
|
56
|
+
repos[i].packageManager = 'yarn'
|
|
57
|
+
}
|
|
58
|
+
packageManager = repos[i].packageManager
|
|
59
|
+
}
|
|
60
|
+
}
|
|
54
61
|
}
|
|
62
|
+
}
|
|
55
63
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
})
|
|
59
|
-
|
|
64
|
+
return repos
|
|
60
65
|
}
|
package/src/coc.js
CHANGED
|
@@ -1,32 +1,30 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
const minimist = require('minimist');
|
|
4
|
-
|
|
5
2
|
const path = require("path");
|
|
6
3
|
const fs = require("fs");
|
|
7
4
|
const execute = require('./execute');
|
|
8
5
|
const argv = process.argv.slice(2);
|
|
9
|
-
|
|
6
|
+
const addMeta = require('./addMeta');
|
|
7
|
+
|
|
10
8
|
|
|
11
9
|
if (argv.length < 1) {
|
|
12
10
|
console.error("enter some command to do something");
|
|
13
11
|
process.exit(1);
|
|
14
12
|
}
|
|
13
|
+
let repos, command, config = {};
|
|
14
|
+
|
|
15
|
+
const options = ['-self']
|
|
16
|
+
for (let option of options) {
|
|
17
|
+
if (argv.includes(option)) {
|
|
18
|
+
config.self = true
|
|
19
|
+
const index = argv.indexOf(option);
|
|
20
|
+
delete argv[index];
|
|
21
|
+
}
|
|
22
|
+
}
|
|
15
23
|
|
|
16
|
-
|
|
17
|
-
let config = minimist(argv, {
|
|
18
|
-
alias: { config: 'c', absolutePath: 'cf', hideMessage: 'h' },
|
|
19
|
-
stopEarly: true
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
let repos, command;
|
|
24
|
-
|
|
25
|
-
command = config['_']
|
|
24
|
+
command = argv
|
|
26
25
|
.map((part) => part.match(/ |'|"/) ? `'${part.replace(/'/,'\\\'')}'` : part)
|
|
27
26
|
.join(" ");
|
|
28
27
|
|
|
29
|
-
|
|
30
28
|
function getRepositories(path) {
|
|
31
29
|
try {
|
|
32
30
|
return require(path);
|
|
@@ -38,23 +36,18 @@ function getRepositories(path) {
|
|
|
38
36
|
}
|
|
39
37
|
|
|
40
38
|
const currentRepoPath = path.resolve(process.cwd(), "./repositories.js");
|
|
41
|
-
// let cliRepoPath = path.resolve(__dirname, '..', 'repositories.js');
|
|
42
39
|
let packageJsonPath = path.resolve(process.cwd(), './package.json');
|
|
43
|
-
let
|
|
40
|
+
let directory
|
|
44
41
|
|
|
45
|
-
if (fs.existsSync(config['c'])) {
|
|
42
|
+
if (config['c'] && fs.existsSync(config['c'])) {
|
|
46
43
|
repos = getRepositories(config['c']);
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
}
|
|
51
|
-
else if (fs.existsSync(currentRepoPath)) {
|
|
44
|
+
directory = path.dirname(config['c']);
|
|
45
|
+
console.warn(`using ${config['c']} configuration`.yellow);
|
|
46
|
+
} else if (!config['self'] && fs.existsSync(currentRepoPath)) {
|
|
52
47
|
repos = getRepositories(currentRepoPath);
|
|
53
|
-
|
|
54
|
-
doAllRepo = true;
|
|
48
|
+
directory = path.dirname(currentRepoPath);
|
|
55
49
|
console.warn(`using ${currentRepoPath} configuration`.yellow);
|
|
56
|
-
}
|
|
57
|
-
else if (fs.existsSync(packageJsonPath)) {
|
|
50
|
+
} else if (fs.existsSync(packageJsonPath)) {
|
|
58
51
|
let repoPath = path.resolve(process.cwd());
|
|
59
52
|
let packageObj = require(packageJsonPath);
|
|
60
53
|
let repoUrl = packageObj.repository.url.substr(12);
|
|
@@ -62,53 +55,18 @@ else if (fs.existsSync(packageJsonPath)) {
|
|
|
62
55
|
path: `${repoPath}`,
|
|
63
56
|
repo: `${repoUrl}`
|
|
64
57
|
}];
|
|
65
|
-
|
|
66
|
-
doAllRepo = false;
|
|
58
|
+
directory = path.dirname(packageJsonPath);
|
|
67
59
|
console.warn(`using ${packageJsonPath} configuration`.yellow);
|
|
68
|
-
}
|
|
69
|
-
// else if (fs.existsSync(cliRepoPath)) {
|
|
70
|
-
|
|
71
|
-
// repos = getRepositories(cliRepoPath)
|
|
72
|
-
// repoDir = path.dirname(cliRepoPath);
|
|
73
|
-
// doAllRepo = false;
|
|
74
|
-
// console.warn(`using ${cliRepoPath} configuration`.yellow)
|
|
75
|
-
|
|
76
|
-
// }
|
|
77
|
-
else {
|
|
60
|
+
} else {
|
|
78
61
|
console.error(`a configuration file can not be found`.red);
|
|
79
62
|
process.exit(1);
|
|
80
63
|
}
|
|
81
|
-
config = {hideMessage: false, ...config
|
|
82
|
-
|
|
83
|
-
let repoFullMeta = repos.map(meta => {
|
|
84
|
-
let name = path.basename(meta.path).toLowerCase();
|
|
85
|
-
let plainName = name.substr(9);
|
|
86
|
-
let ppath = path.resolve(repoDir, meta.path);
|
|
87
|
-
try {
|
|
88
|
-
if (!fs.existsSync(ppath))
|
|
89
|
-
console.error(`${ppath} not found`.red);
|
|
90
|
-
|
|
91
|
-
return { ...meta, name, ppath, plainName };
|
|
92
|
-
}
|
|
93
|
-
catch (err) {
|
|
94
|
-
console.error(name.red, err.message.red, ppath);
|
|
95
|
-
// process.exit(1)
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
});
|
|
64
|
+
config = {hideMessage: false, ...config };
|
|
99
65
|
|
|
100
66
|
(async() => {
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
require(predefined)(repos, repos )
|
|
105
|
-
}
|
|
106
|
-
if (command == 'gitConfig'){
|
|
107
|
-
let predefined = path.resolve(__dirname, 'commands', command + '.js');
|
|
108
|
-
require(predefined)(repos, repos )
|
|
109
|
-
}
|
|
110
|
-
else {
|
|
111
|
-
let failed = await execute(command, repoFullMeta, config);
|
|
67
|
+
repos = await addMeta(repos, [], directory)
|
|
68
|
+
let failed = await execute(command, repos, config);
|
|
69
|
+
if (failed) {
|
|
112
70
|
if (failed.length === 0)
|
|
113
71
|
process.exit(0);
|
|
114
72
|
else {
|
|
@@ -118,5 +76,4 @@ let repoFullMeta = repos.map(meta => {
|
|
|
118
76
|
|
|
119
77
|
}
|
|
120
78
|
}
|
|
121
|
-
// console.log(`success: ${report.success}`.green, `failed: ${report.fail}`.red);
|
|
122
79
|
})();
|
package/src/commands/bump.js
CHANGED
|
@@ -1,126 +1,85 @@
|
|
|
1
|
-
|
|
2
1
|
let fs = require('fs');
|
|
3
|
-
const prettier = require("prettier");
|
|
4
|
-
let list = require('../../../repositories.js');
|
|
5
2
|
const path = require("path")
|
|
6
|
-
|
|
7
|
-
const spawn = require('../spawn');
|
|
8
3
|
const colors = require('colors');
|
|
9
|
-
const
|
|
10
|
-
|
|
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
|
-
// console.log('bump versions', item)
|
|
37
|
-
|
|
38
|
-
// for (let [index, name] of nameList.entries()) {
|
|
39
|
-
// await bumpVersion(pathList[index] + '/package.json', name)
|
|
40
|
-
// }
|
|
41
|
-
// } catch (err) {
|
|
42
|
-
// failed.push({ name: 'GENERAL', des: err.message })
|
|
43
|
-
// }
|
|
44
|
-
|
|
45
|
-
// console.log('completed')
|
|
46
|
-
// return failed
|
|
47
|
-
// // process.exit()
|
|
48
|
-
// }
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
async function run() {
|
|
52
|
-
// let failed = [];
|
|
53
|
-
|
|
54
|
-
// try {
|
|
55
|
-
// repos = addMeta(repos, failed)
|
|
56
|
-
|
|
57
|
-
// }
|
|
58
|
-
// catch (err) {
|
|
59
|
-
// failed.push({
|
|
60
|
-
// name: 'GENERAL',
|
|
61
|
-
// des: err.message
|
|
62
|
-
// })
|
|
4
|
+
const util = require('node:util');
|
|
5
|
+
const exec = util.promisify(require('node:child_process').exec);
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
let pathList, nameList, item = {}, failed = [];
|
|
9
|
+
|
|
10
|
+
module.exports = async function bump(repos) {
|
|
11
|
+
pathList = repos.map(o => o.path)
|
|
12
|
+
if (repos.length === 1) {
|
|
13
|
+
let packageJsonPath = path.resolve(process.cwd(), './package.json');
|
|
14
|
+
|
|
15
|
+
if (fs.existsSync(packageJsonPath)) {
|
|
16
|
+
let object = require(packageJsonPath)
|
|
17
|
+
if (object.dependencies) {
|
|
18
|
+
for (let key of Object.keys(object.dependencies)) {
|
|
19
|
+
if (key.startsWith("@cocreate/")) {
|
|
20
|
+
const version = await exec(`npm view ${key} version`);
|
|
21
|
+
item[key] = `^${version.stdout}`.trim()
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
console.log('bump versions', item)
|
|
25
|
+
|
|
26
|
+
for (let name of Object.keys(item)) {
|
|
27
|
+
bumpVersion(packageJsonPath, name)
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
63
31
|
|
|
64
|
-
|
|
32
|
+
} else {
|
|
33
|
+
nameList = pathList.map(fn => path.basename(fn).toLowerCase());
|
|
65
34
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
// await reAdd(repo.deps, repo, failed, '')
|
|
70
|
-
// await reAdd(repo.devDeps, repo, failed, '-D ')
|
|
71
|
-
// }
|
|
72
|
-
// return failed;
|
|
35
|
+
for (let [index, name] of nameList.entries()) {
|
|
36
|
+
getVersions(pathList[index] + '/package.json', `@${name}`)
|
|
37
|
+
}
|
|
73
38
|
|
|
74
|
-
|
|
39
|
+
console.log('bump versions', item)
|
|
75
40
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
console.log('bump versions', item)
|
|
41
|
+
for (let [index, name] of nameList.entries()) {
|
|
42
|
+
bumpVersion(pathList[index] + '/package.json', name)
|
|
43
|
+
}
|
|
80
44
|
|
|
81
|
-
for (let [index, name] of nameList.entries()) {
|
|
82
|
-
await bumpVersion(pathList[index] + '/package.json', name)
|
|
83
45
|
}
|
|
84
46
|
|
|
85
47
|
console.log('completed')
|
|
86
|
-
|
|
48
|
+
return failed;
|
|
87
49
|
}
|
|
88
50
|
|
|
89
|
-
function getVersions(
|
|
90
|
-
if (
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
51
|
+
function getVersions(filePath) {
|
|
52
|
+
if (fs.existsSync(filePath)) {
|
|
53
|
+
let object = require(filePath)
|
|
54
|
+
if (object.name && object.version) {
|
|
55
|
+
item[object.name] = `^${object.version}`
|
|
56
|
+
}
|
|
57
|
+
} else {
|
|
58
|
+
failed.push({name: 'get version', des: 'path doesn\'t exist:' + filePath})
|
|
95
59
|
}
|
|
96
60
|
}
|
|
97
61
|
|
|
98
62
|
function bumpVersion(filePath, name) {
|
|
99
|
-
if (!fs.existsSync(filePath))
|
|
100
|
-
return console.error('path doesn\'t exist:', path)
|
|
101
63
|
let object = require(filePath)
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
64
|
+
if (object) {
|
|
65
|
+
let newObject = {...object}
|
|
66
|
+
|
|
67
|
+
if (!object.dependencies)
|
|
68
|
+
return console.log(name, 'not updated')
|
|
69
|
+
else {
|
|
70
|
+
for (const name of Object.keys(object.dependencies)) {
|
|
71
|
+
if (item[name]) {
|
|
72
|
+
newObject.dependencies[name] = item[name]
|
|
73
|
+
}
|
|
110
74
|
}
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
// let str = JSON.stringify(object, null, 2)
|
|
114
|
-
// let formated = prettier.format(str, { semi: false, parser: "json" });
|
|
115
75
|
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
76
|
+
if (fs.existsSync(filePath)){
|
|
77
|
+
fs.unlinkSync(filePath)
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
fs.writeFileSync(filePath, JSON.stringify(object, null, 2))
|
|
120
81
|
}
|
|
121
|
-
|
|
122
|
-
|
|
82
|
+
} else {
|
|
83
|
+
failed.push({name: 'bump version', des: 'path doesn\'t exist:' + filePath})
|
|
123
84
|
}
|
|
124
85
|
}
|
|
125
|
-
|
|
126
|
-
// run()
|
package/src/commands/clone.js
CHANGED
|
@@ -5,22 +5,21 @@ const path = require('path');
|
|
|
5
5
|
|
|
6
6
|
module.exports = async function gitClone(repos) {
|
|
7
7
|
const failed = [];
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
8
|
+
const cwdPath = path.resolve(process.cwd());
|
|
9
|
+
|
|
10
|
+
for (let i = 0; i < repos.length; i++) {
|
|
11
|
+
if (cwdPath !== repos[i].absolutePath) {
|
|
12
|
+
let exitCode = await spawn('mkdir', ['-p', repos[i].directory], { stdio: 'inherit', cwd: process.cwd() })
|
|
13
|
+
if (exitCode !== 0) {
|
|
14
|
+
failed.push({ name: repos[i].name, des: `creating directory failed` })
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
exitCode = await spawn('git', ['clone', `https://${repos[i].repo}`], { stdio: 'inherit', cwd: repos[i].directory })
|
|
18
|
+
if (exitCode !== 0) {
|
|
19
|
+
failed.push({ name: repos[i].name, des: `cloning failed` })
|
|
20
|
+
|
|
21
|
+
}
|
|
22
|
+
|
|
24
23
|
}
|
|
25
24
|
}
|
|
26
25
|
|
|
@@ -1,79 +1,71 @@
|
|
|
1
|
-
const getRepoList = require('../repoList');
|
|
2
1
|
let fs = require('fs');
|
|
3
2
|
const path = require("path");
|
|
4
|
-
let list = getRepoList()
|
|
5
|
-
console.log(list)
|
|
6
3
|
|
|
7
|
-
|
|
4
|
+
module.exports = async function linkPackages(repos) {
|
|
5
|
+
const failed = []
|
|
6
|
+
const prompt = require('prompt');
|
|
8
7
|
|
|
9
|
-
prompt.start();
|
|
8
|
+
prompt.start();
|
|
10
9
|
|
|
11
|
-
const properties = [
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
];
|
|
10
|
+
const properties = [
|
|
11
|
+
{
|
|
12
|
+
name: 'email',
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
name: 'name',
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
name: 'username',
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
name: 'password',
|
|
22
|
+
hidden: true
|
|
23
|
+
}
|
|
24
|
+
];
|
|
26
25
|
|
|
27
|
-
prompt.get(properties, async function (err, result) {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
26
|
+
prompt.get(properties, async function (err, result) {
|
|
27
|
+
if (err)
|
|
28
|
+
return [{
|
|
29
|
+
name: 'gitConfig',
|
|
30
|
+
des: err
|
|
31
|
+
}]
|
|
31
32
|
|
|
33
|
+
await updateConfig(result);
|
|
34
|
+
});
|
|
32
35
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
return meta;
|
|
36
|
+
async function updateConfig(result){
|
|
37
|
+
(async() => {
|
|
38
|
+
for (let repo of repos) {
|
|
39
|
+
await update(repo, result);
|
|
40
|
+
}
|
|
41
|
+
console.log('finished');
|
|
42
|
+
return failed
|
|
43
|
+
})();
|
|
42
44
|
}
|
|
43
45
|
|
|
44
|
-
|
|
46
|
+
function update(param, result) {
|
|
47
|
+
if (!param) return;
|
|
48
|
+
let { absoutePath, name } = param;
|
|
49
|
+
let fileContent = `[core]
|
|
50
|
+
repositoryformatversion = 0
|
|
51
|
+
filemode = true
|
|
52
|
+
bare = false
|
|
53
|
+
logallrefupdates = true
|
|
54
|
+
[user]
|
|
55
|
+
name = ${result.name}
|
|
56
|
+
email = ${result.email}
|
|
57
|
+
[remote "origin"]
|
|
58
|
+
url = https://${result.username}:${result.password}@github.com/CoCreate-app/${name}.git
|
|
59
|
+
fetch = +refs/heads/*:refs/remotes/origin/*
|
|
60
|
+
[branch "master"]
|
|
61
|
+
remote = origin
|
|
62
|
+
merge = refs/heads/master
|
|
45
63
|
|
|
46
|
-
|
|
47
|
-
(async() => {
|
|
48
|
-
for (let meta of metaYarnLink) {
|
|
49
|
-
await update(meta, result);
|
|
50
|
-
}
|
|
51
|
-
console.log('finished');
|
|
52
|
-
})();
|
|
53
|
-
}
|
|
64
|
+
`;
|
|
54
65
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
bare = false
|
|
62
|
-
logallrefupdates = true
|
|
63
|
-
[user]
|
|
64
|
-
name = ${result.name}
|
|
65
|
-
email = ${result.email}
|
|
66
|
-
[remote "origin"]
|
|
67
|
-
url = https://${result.username}:${result.password}@github.com/CoCreate-app/${repoName}.git
|
|
68
|
-
fetch = +refs/heads/*:refs/remotes/origin/*
|
|
69
|
-
[branch "master"]
|
|
70
|
-
remote = origin
|
|
71
|
-
merge = refs/heads/master
|
|
72
|
-
|
|
73
|
-
`;
|
|
74
|
-
|
|
75
|
-
let MdPath = path.resolve(ppath, '.git/config');
|
|
76
|
-
if (fs.existsSync(MdPath))
|
|
77
|
-
fs.unlinkSync(MdPath);
|
|
78
|
-
fs.writeFileSync(MdPath, fileContent);
|
|
79
|
-
}
|
|
66
|
+
let MdPath = path.resolve(absoutePath, '.git/config');
|
|
67
|
+
if (fs.existsSync(MdPath))
|
|
68
|
+
fs.unlinkSync(MdPath);
|
|
69
|
+
fs.writeFileSync(MdPath, fileContent);
|
|
70
|
+
}
|
|
71
|
+
}
|
package/src/commands/install.js
CHANGED
|
@@ -1,30 +1,14 @@
|
|
|
1
|
-
const
|
|
2
|
-
const exec = util.promisify(require('node:child_process').exec);
|
|
3
|
-
const spawn = require('../spawn');
|
|
1
|
+
const addMeta = require('../addMeta');
|
|
4
2
|
|
|
5
|
-
module.exports = async function(
|
|
3
|
+
module.exports = async function(repos) {
|
|
6
4
|
let failed = [];
|
|
7
5
|
try {
|
|
8
|
-
|
|
9
6
|
let cloneFailed = await require('./clone.js')(repos)
|
|
7
|
+
repos = await addMeta(repos, failed)
|
|
10
8
|
|
|
11
|
-
let
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
let packageManager = 'npm'
|
|
15
|
-
const { error } = await exec('yarn --version');
|
|
16
|
-
if (!error)
|
|
17
|
-
packageManager = 'yarn';
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
let exitCode = spawn(packageManager, ['start'], {
|
|
21
|
-
cwd: '../CoCreateJS',
|
|
22
|
-
shell: true,
|
|
23
|
-
stdio: 'inherit'
|
|
24
|
-
})
|
|
25
|
-
if (exitCode !== 0) {
|
|
26
|
-
failed.push({ name: 'cocreatejs', des: `${packageManager} start failed` })
|
|
27
|
-
}
|
|
9
|
+
let symlinkFailed = await require('./symlink.js')(repos)
|
|
10
|
+
let linkFailed = await require('./link.js')(repos)
|
|
11
|
+
failed = [...cloneFailed, ...symlinkFailed, ...linkFailed];
|
|
28
12
|
} catch (err) {
|
|
29
13
|
console.error(err);
|
|
30
14
|
failed.push({ name: 'general', des: err.message })
|
package/src/commands/link.js
CHANGED
|
@@ -1,45 +1,16 @@
|
|
|
1
1
|
const spawn = require('../spawn');
|
|
2
2
|
const colors = require('colors');
|
|
3
|
-
const addMeta = require('../addMeta');
|
|
4
|
-
|
|
5
|
-
const util = require('node:util');
|
|
6
|
-
const exec = util.promisify(require('node:child_process').exec);
|
|
7
|
-
|
|
8
|
-
module.exports = async function linkPackages(repos, allrepo) {
|
|
9
|
-
let packageManager = 'npm'
|
|
10
|
-
const { error } = await exec('yarn --version');
|
|
11
|
-
if (!error)
|
|
12
|
-
packageManager = 'yarn';
|
|
13
3
|
|
|
4
|
+
module.exports = async function linkPackages(repos) {
|
|
14
5
|
const failed = [], isLinked = {};
|
|
15
|
-
try {
|
|
16
|
-
repos = addMeta(repos, failed)
|
|
17
|
-
allrepo = addMeta(allrepo, failed)
|
|
18
|
-
|
|
19
|
-
}
|
|
20
|
-
catch (err) {
|
|
21
|
-
failed.push({
|
|
22
|
-
name: 'GENERAL',
|
|
23
|
-
des: err.message
|
|
24
|
-
})
|
|
25
|
-
console.log(err)
|
|
26
|
-
}
|
|
27
6
|
|
|
28
7
|
try {
|
|
29
8
|
for (let repo of repos) {
|
|
9
|
+
if (!repo) continue;
|
|
30
10
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
let {
|
|
35
|
-
packageName,
|
|
36
|
-
deps,
|
|
37
|
-
devDeps,
|
|
38
|
-
} = repo;
|
|
39
|
-
|
|
40
|
-
console.log(packageName, 'configuring ...')
|
|
41
|
-
await doLink(deps, repo, allrepo, failed, isLinked, packageManager)
|
|
42
|
-
await doLink(devDeps, repo, allrepo, failed, isLinked, packageManager)
|
|
11
|
+
console.log(repo.packageName, 'configuring ...')
|
|
12
|
+
await doLink(repo.deps, repo, repos, failed, isLinked)
|
|
13
|
+
await doLink(repo.devDeps, repo, repos, failed, isLinked)
|
|
43
14
|
}
|
|
44
15
|
}
|
|
45
16
|
catch (err) {
|
|
@@ -51,16 +22,19 @@ module.exports = async function linkPackages(repos, allrepo) {
|
|
|
51
22
|
}
|
|
52
23
|
|
|
53
24
|
|
|
54
|
-
async function doLink(deps, repo,
|
|
25
|
+
async function doLink(deps, repo, repos, failed, isLinked) {
|
|
26
|
+
let { packageManager } = repo;
|
|
27
|
+
|
|
55
28
|
for (let dep of deps) {
|
|
56
|
-
let depMeta =
|
|
29
|
+
let depMeta = repos.find(meta => meta.packageName === dep);
|
|
57
30
|
try {
|
|
58
31
|
if (!depMeta) {
|
|
32
|
+
// ToDo: search file system for a package.json containing the package.name
|
|
59
33
|
failed.push({
|
|
60
34
|
name: repo.name,
|
|
61
|
-
des: `"${
|
|
35
|
+
des: `"${dep}" component can not be found in repositories.js`
|
|
62
36
|
})
|
|
63
|
-
console.error(`${repo.name}: "${
|
|
37
|
+
console.error(`${repo.name}: "${dep}" component can not be found in repositories.js`.red)
|
|
64
38
|
continue;
|
|
65
39
|
}
|
|
66
40
|
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
const fs = require('fs')
|
|
2
|
+
const path = require("path")
|
|
3
|
+
const util = require('node:util');
|
|
4
|
+
const exec = util.promisify(require('node:child_process').exec);
|
|
5
|
+
|
|
6
|
+
const cwdPath = path.resolve(process.cwd());
|
|
7
|
+
const cwdNodeModulesPath = path.resolve(cwdPath, 'node_modules')
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
// let doInstall = process.argv[2];
|
|
11
|
+
// console.log('doInstall', doInstall)
|
|
12
|
+
let reposLength, failed = [];
|
|
13
|
+
|
|
14
|
+
module.exports = async function symlink(repos) {
|
|
15
|
+
reposLength = repos.length
|
|
16
|
+
|
|
17
|
+
for (let i = 0; i < repos.length; i++) {
|
|
18
|
+
if (repos[i].install == true) {
|
|
19
|
+
reposLength -= 1
|
|
20
|
+
await install(repos[i])
|
|
21
|
+
} else if (cwdPath !== repos[i].absolutePath) {
|
|
22
|
+
await createSymlink(repos[i])
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
async function createSymlink(repo) {
|
|
30
|
+
let dpath = path.resolve(repo.absolutePath);
|
|
31
|
+
if (!fs.existsSync(dpath)) {
|
|
32
|
+
failed.push({name: 'createSymlink', des: 'path doesn\'t exist:' + dpath})
|
|
33
|
+
return console.error(dpath, 'not exist')
|
|
34
|
+
}
|
|
35
|
+
let response = ''
|
|
36
|
+
|
|
37
|
+
try {
|
|
38
|
+
let dest = path.resolve(dpath, 'node_modules');
|
|
39
|
+
if (dest) {
|
|
40
|
+
if (fs.existsSync(dest)) {
|
|
41
|
+
fs.rm(dest, { recursive: true, force: true }, function (err) {
|
|
42
|
+
if (err) {
|
|
43
|
+
console.log('failed');
|
|
44
|
+
}
|
|
45
|
+
erSymlink(repo.name, dest)
|
|
46
|
+
});
|
|
47
|
+
} else {
|
|
48
|
+
erSymlink(repo.name, dest)
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
catch (err) {
|
|
53
|
+
failed.push({name: 'symlink', des: 'with response:' + response + err})
|
|
54
|
+
console.error(repo.name, 'failed to aquire symlink', 'with response:', response, err)
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
function erSymlink(name, dest){
|
|
60
|
+
fs.symlink( cwdNodeModulesPath, dest, 'dir', (err) => {
|
|
61
|
+
reposLength -= 1
|
|
62
|
+
|
|
63
|
+
if (err)
|
|
64
|
+
console.log(err);
|
|
65
|
+
else {
|
|
66
|
+
console.log(name, "node_modules symlink added");
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
if (!reposLength) {
|
|
70
|
+
console.log('symlink complete')
|
|
71
|
+
return failed
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
})
|
|
75
|
+
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
async function install(repo) {
|
|
80
|
+
let dpath = repo.absolutePath
|
|
81
|
+
if (!fs.existsSync(dpath)) {
|
|
82
|
+
failed.push({name: 'install', des: 'path doesn\'t exist:' + dpath})
|
|
83
|
+
return console.error(dpath, 'not exist')
|
|
84
|
+
}
|
|
85
|
+
try {
|
|
86
|
+
// let node_modules = path.resolve(dpath, 'node_modules');
|
|
87
|
+
// if (fs.existsSync(node_modules)) {
|
|
88
|
+
// fs.rm(node_modules, { recursive: true, force: true }, function (err) {
|
|
89
|
+
// if (err) {
|
|
90
|
+
// console.log('failed');
|
|
91
|
+
// } else {
|
|
92
|
+
// erSymlink(repo.name, dest)
|
|
93
|
+
// }
|
|
94
|
+
// });
|
|
95
|
+
// }
|
|
96
|
+
let {error} = await exec(`${repo.packageManager} install `, { cwd: dpath })
|
|
97
|
+
if (!error)
|
|
98
|
+
console.log(repo.name, 'installed')
|
|
99
|
+
else {
|
|
100
|
+
failed.push({name: 'install ', des: error})
|
|
101
|
+
console.error(repo.name, 'failed to install', error)
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
}
|
|
105
|
+
catch (err) {
|
|
106
|
+
console.error(repo.name, 'did not install', err)
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
}
|
package/src/execute.js
CHANGED
|
@@ -7,45 +7,29 @@ const exec = util.promisify(require('node:child_process').exec);
|
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
module.exports = async function execute(command, repos, config) {
|
|
10
|
-
|
|
11
10
|
let failed = [];
|
|
12
11
|
let predefined = path.resolve(__dirname, 'commands', command + '.js');
|
|
12
|
+
|
|
13
13
|
if (fs.existsSync(predefined)) {
|
|
14
14
|
console.warn(`executing a predefined command in ${predefined}`.blue);
|
|
15
|
-
|
|
16
|
-
if (
|
|
15
|
+
|
|
16
|
+
if (repos.length == 1)
|
|
17
|
+
console.log(`running on ${repos[0].name} repo`.blue)
|
|
18
|
+
else
|
|
17
19
|
console.log('running on all repos'.blue)
|
|
18
|
-
failed = require(predefined)(repos, repos )
|
|
19
|
-
}
|
|
20
|
-
else {
|
|
21
|
-
let currentRepoConfig = repos.find(m => m.name === path.basename(process.cwd()).toLowerCase());
|
|
22
|
-
if (currentRepoConfig && currentRepoConfig.ppath == path.resolve(process.cwd())) {
|
|
23
|
-
console.log(`running on ${currentRepoConfig.name} repo`.blue)
|
|
24
|
-
failed = require(predefined)([currentRepoConfig], repos )
|
|
25
|
-
}
|
|
26
|
-
else {
|
|
27
|
-
console.error(`${currentRepoConfig.name} can not be found or have diferent path`.red)
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
}
|
|
33
|
-
else {
|
|
34
20
|
|
|
21
|
+
failed = require(predefined)(repos)
|
|
35
22
|
|
|
23
|
+
} else {
|
|
24
|
+
let type = command.split(' ')[0]
|
|
36
25
|
for (let repo of repos) {
|
|
37
|
-
if (!repo)
|
|
38
|
-
console.log(repo, repos)
|
|
39
|
-
// let repo = {name: 'aa', ppath: '/home/ubuntu/environment/CoCreate-plugins/CoCreate-sendgrid'}
|
|
40
26
|
try {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
}
|
|
44
|
-
console.log(`${name}: `.green, command)
|
|
27
|
+
if (repo.exclude && repo.exclude.includes(type))
|
|
28
|
+
continue
|
|
29
|
+
console.log(`${repo.name}: `.green, command)
|
|
45
30
|
let exitCode;
|
|
46
31
|
if (config.hideMessage) {
|
|
47
|
-
const
|
|
48
|
-
const { error } = await exec(strCommand, {
|
|
32
|
+
const { error } = await exec(command, {
|
|
49
33
|
cwd: repo.ppath,
|
|
50
34
|
});
|
|
51
35
|
|
|
@@ -60,27 +44,18 @@ module.exports = async function execute(command, repos, config) {
|
|
|
60
44
|
|
|
61
45
|
if (exitCode !== 0)
|
|
62
46
|
failed.push({
|
|
63
|
-
name,
|
|
47
|
+
name: repo.name,
|
|
64
48
|
des: 'command failed: ' + command
|
|
65
49
|
})
|
|
66
50
|
|
|
67
51
|
|
|
68
52
|
}
|
|
69
53
|
catch (err) {
|
|
70
|
-
|
|
71
54
|
console.error(`an error occured executing command in ${repo.name} repository`.red, err.message);;
|
|
72
|
-
|
|
73
55
|
}
|
|
74
56
|
}
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
57
|
}
|
|
79
58
|
|
|
80
|
-
|
|
81
|
-
|
|
82
59
|
return failed;
|
|
83
60
|
|
|
84
|
-
|
|
85
|
-
|
|
86
61
|
}
|
|
@@ -1,116 +0,0 @@
|
|
|
1
|
-
// install nodejs 14 from: https://github.com/nodesource/distributions/blob/master/README.md#installation-instructions
|
|
2
|
-
// install yarn from https://classic.yarnpkg.com/en/docs/install/#debian-stable
|
|
3
|
-
// -> alternatives -> debian/ununtu -> run the 3 commands there consecutively
|
|
4
|
-
|
|
5
|
-
// both node and nodejs --version should be the same and > then v12
|
|
6
|
-
const fs = require('fs')
|
|
7
|
-
const path = require("path")
|
|
8
|
-
const { promisify } = require('util');
|
|
9
|
-
const exec = promisify(require('child_process').exec)
|
|
10
|
-
let list = require('../repositories.js');
|
|
11
|
-
|
|
12
|
-
let pathList = list.map(o => o.path);
|
|
13
|
-
let nameList = pathList.map(fn => path.basename(fn).toLowerCase());
|
|
14
|
-
|
|
15
|
-
let CoCreateJsPath = path.resolve('../CoCreateJS');
|
|
16
|
-
// console.log(syarnInstall);
|
|
17
|
-
// process.exit()
|
|
18
|
-
|
|
19
|
-
const ignore = [
|
|
20
|
-
'CoCreateJS',
|
|
21
|
-
'CoCreate-repositories',
|
|
22
|
-
'CoCreate-charts',
|
|
23
|
-
'CoCreate-codemirror',
|
|
24
|
-
'CoCreate-crdt',
|
|
25
|
-
'CoCreate-croppie',
|
|
26
|
-
'CoCreate-docs',
|
|
27
|
-
'CoCreate-domain',
|
|
28
|
-
'CoCreate-facebook',
|
|
29
|
-
'CoCreate-fullcalendar',
|
|
30
|
-
'CoCreate-google-auth',
|
|
31
|
-
'CoCreate-instagram',
|
|
32
|
-
'CoCreate-lighthouse',
|
|
33
|
-
'CoCreate-linkedin',
|
|
34
|
-
'CoCreate-monaco',
|
|
35
|
-
'CoCreate-pinterest',
|
|
36
|
-
'CoCreate-pickr',
|
|
37
|
-
'CoCreate-progress-bar',
|
|
38
|
-
'CoCreate-quill',
|
|
39
|
-
'CoCreate-s3',
|
|
40
|
-
'CoCreate-sengrid',
|
|
41
|
-
'CoCreate-shipengine',
|
|
42
|
-
'CoCreate-stripe',
|
|
43
|
-
'CoCreate-twilio',
|
|
44
|
-
'CoCreate-twitter',
|
|
45
|
-
'CoCreate-uppy',
|
|
46
|
-
];
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
let doInstall = process.argv[2];
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
(async() => {
|
|
55
|
-
for (let i = 0; i < ignore.length; i++) {
|
|
56
|
-
ignore[i] = ignore[i].toLowerCase();
|
|
57
|
-
}
|
|
58
|
-
for (let [index, name] of nameList.entries()) {
|
|
59
|
-
if (ignore.includes(name.toLowerCase()))
|
|
60
|
-
{
|
|
61
|
-
if (doInstall == "true")
|
|
62
|
-
await updateYarnInstall(pathList[index], name)
|
|
63
|
-
}
|
|
64
|
-
else
|
|
65
|
-
await updateSymbolic(pathList[index], name)
|
|
66
|
-
|
|
67
|
-
}
|
|
68
|
-
})()
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
async function updateSymbolic(dpath, name) {
|
|
73
|
-
// let packageName = path.basename(dpath);
|
|
74
|
-
let res1, res2;
|
|
75
|
-
dpath = path.resolve(dpath);
|
|
76
|
-
if (!fs.existsSync(dpath))
|
|
77
|
-
return console.error(dpath, 'not exist')
|
|
78
|
-
|
|
79
|
-
try {
|
|
80
|
-
let dest = path.resolve(dpath, 'node_modules');
|
|
81
|
-
if (fs.existsSync(dest))
|
|
82
|
-
fs.rmdirSync(dest, { recursive: true })
|
|
83
|
-
console.log('copying node_modules to', name);
|
|
84
|
-
res2 = await exec(`ln -sf ${CoCreateJsPath}/node_modules ${dest} `, { cwd: CoCreateJsPath })
|
|
85
|
-
|
|
86
|
-
console.log(name, 'is finished')
|
|
87
|
-
}
|
|
88
|
-
catch (err) {
|
|
89
|
-
console.error(name, 'had error for command', err.cmd, 'with response:', res1, res2, err)
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
async function updateYarnInstall(dpath, name) {
|
|
97
|
-
// let packageName = path.basename(dpath);
|
|
98
|
-
let res1, res2;
|
|
99
|
-
dpath = path.resolve(dpath);
|
|
100
|
-
if (!fs.existsSync(dpath))
|
|
101
|
-
return console.error(dpath, 'not exist')
|
|
102
|
-
|
|
103
|
-
try {
|
|
104
|
-
let node_modules = path.resolve(dpath, 'node_modules');
|
|
105
|
-
if (fs.existsSync(node_modules))
|
|
106
|
-
fs.rmdirSync(node_modules,{ recursive: true })
|
|
107
|
-
console.log('yarn install inside', name);
|
|
108
|
-
res2 = await exec(`yarn install `, { cwd: dpath })
|
|
109
|
-
|
|
110
|
-
console.log(name, 'is finished', '\n')
|
|
111
|
-
}
|
|
112
|
-
catch (err) {
|
|
113
|
-
console.error(name, 'had error for command', err.cmd, 'with response:', res1, res2, err)
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
}
|
package/src/repoList.js
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
const path = require("path");
|
|
2
|
-
const fs = require("fs");
|
|
3
|
-
|
|
4
|
-
module.exports = async function getRepoList(){
|
|
5
|
-
const currentRepoPath = path.resolve(process.cwd(), "./repositories.js");
|
|
6
|
-
const packageJsonPath = path.resolve(process.cwd(), './package.json');
|
|
7
|
-
|
|
8
|
-
let repos, repoDir, doAllRepo;
|
|
9
|
-
|
|
10
|
-
if (fs.existsSync(currentRepoPath)) {
|
|
11
|
-
repos = getRepositories(currentRepoPath);
|
|
12
|
-
repoDir = path.dirname(currentRepoPath);
|
|
13
|
-
doAllRepo = true;
|
|
14
|
-
console.warn(`using ${currentRepoPath} configuration`.yellow);
|
|
15
|
-
}
|
|
16
|
-
else if (fs.existsSync(packageJsonPath)) {
|
|
17
|
-
let repoPath = path.resolve(process.cwd());
|
|
18
|
-
let packageObj = require(packageJsonPath);
|
|
19
|
-
let repoUrl = packageObj.repository.url.substr(12);
|
|
20
|
-
repos = [{
|
|
21
|
-
path: `${repoPath}`,
|
|
22
|
-
repo: `${repoUrl}`
|
|
23
|
-
}];
|
|
24
|
-
repoDir = path.dirname(packageJsonPath);
|
|
25
|
-
doAllRepo = false;
|
|
26
|
-
console.warn(`using ${packageJsonPath} configuration`.yellow);
|
|
27
|
-
}
|
|
28
|
-
else {
|
|
29
|
-
console.error(`a configuration file can not be found`.red);
|
|
30
|
-
process.exit(1);
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
return repos;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
function getRepositories(path) {
|
|
37
|
-
try {
|
|
38
|
-
return require(path);
|
|
39
|
-
}
|
|
40
|
-
catch (err) {
|
|
41
|
-
console.error('can not read repository file in'.red, path, 'error:'.red, err.message.red);
|
|
42
|
-
process.exit(1);
|
|
43
|
-
}
|
|
44
|
-
}
|