@cocreate/cli 1.14.30 → 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 +14 -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 +7 -14
- package/src/commands/link.js +27 -59
- package/src/commands/{add.js → other/add.js} +2 -2
- package/src/commands/{symbolic.js → other/symbolic.js} +2 -2
- package/src/commands/{yarnInstall.js → other/yarnInstall.js} +2 -2
- package/src/commands/symlink.js +109 -0
- package/src/execute.js +22 -44
- package/src/commands/other/symbolic-link.js +0 -116
- package/src/repoList.js +0 -44
|
@@ -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,24 +1,17 @@
|
|
|
1
|
-
const
|
|
2
|
-
|
|
3
|
-
module.exports = async function(
|
|
1
|
+
const addMeta = require('../addMeta');
|
|
2
|
+
|
|
3
|
+
module.exports = async function(repos) {
|
|
4
4
|
let failed = [];
|
|
5
5
|
try {
|
|
6
|
-
|
|
7
6
|
let cloneFailed = await require('./clone.js')(repos)
|
|
7
|
+
repos = await addMeta(repos, failed)
|
|
8
8
|
|
|
9
|
-
let
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
failed = [...cloneFailed, ...installFailed, ...linkFailed];
|
|
13
|
-
|
|
14
|
-
let exitCode = spawn('yarn', ['start', '-w'], { cwd: '../CoCreateJS' })
|
|
15
|
-
if (exitCode !== 0) {
|
|
16
|
-
failed.push({ name: 'cocreatejs', des: `yarn start failed` })
|
|
17
|
-
}
|
|
9
|
+
let symlinkFailed = await require('./symlink.js')(repos)
|
|
10
|
+
let linkFailed = await require('./link.js')(repos)
|
|
11
|
+
failed = [...cloneFailed, ...symlinkFailed, ...linkFailed];
|
|
18
12
|
} catch (err) {
|
|
19
13
|
console.error(err);
|
|
20
14
|
failed.push({ name: 'general', des: err.message })
|
|
21
|
-
|
|
22
15
|
}
|
|
23
16
|
return failed;
|
|
24
17
|
}
|
package/src/commands/link.js
CHANGED
|
@@ -1,113 +1,81 @@
|
|
|
1
|
-
const fs = require('fs')
|
|
2
|
-
const path = require("path")
|
|
3
|
-
const {
|
|
4
|
-
promisify
|
|
5
|
-
} = require('util');
|
|
6
1
|
const spawn = require('../spawn');
|
|
7
2
|
const colors = require('colors');
|
|
8
|
-
const addMeta = require('../addMeta');
|
|
9
3
|
|
|
4
|
+
module.exports = async function linkPackages(repos) {
|
|
5
|
+
const failed = [], isLinked = {};
|
|
10
6
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
module.exports = async function updateYarnInstall(repos, allrepo) {
|
|
15
|
-
|
|
16
|
-
const failed = [],
|
|
17
|
-
isLinked = {};
|
|
18
7
|
try {
|
|
19
|
-
repos = addMeta(repos, failed)
|
|
20
|
-
allrepo = addMeta(allrepo, failed)
|
|
21
|
-
|
|
22
|
-
}
|
|
23
|
-
catch (err) {
|
|
24
|
-
failed.push({
|
|
25
|
-
name: 'GENERAL',
|
|
26
|
-
des: err.message
|
|
27
|
-
})
|
|
28
|
-
console.log(err)
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
try {
|
|
32
|
-
// console.log(repos)
|
|
33
|
-
|
|
34
8
|
for (let repo of repos) {
|
|
9
|
+
if (!repo) continue;
|
|
35
10
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
let {
|
|
41
|
-
ppath,
|
|
42
|
-
packageName,
|
|
43
|
-
deps,
|
|
44
|
-
devDeps,
|
|
45
|
-
name
|
|
46
|
-
} = repo;
|
|
47
|
-
|
|
48
|
-
console.log(packageName, 'configuring ...')
|
|
49
|
-
await doLink(deps, repo, allrepo, failed, isLinked)
|
|
50
|
-
await doLink(devDeps, repo, allrepo, failed, isLinked)
|
|
11
|
+
console.log(repo.packageName, 'configuring ...')
|
|
12
|
+
await doLink(repo.deps, repo, repos, failed, isLinked)
|
|
13
|
+
await doLink(repo.devDeps, repo, repos, failed, isLinked)
|
|
51
14
|
}
|
|
52
15
|
}
|
|
53
16
|
catch (err) {
|
|
54
17
|
failed.push({ name: 'GENERAL', des: err.message })
|
|
55
|
-
console.error(err
|
|
18
|
+
console.error(`${err}`.red)
|
|
56
19
|
}
|
|
57
20
|
|
|
58
21
|
return failed;
|
|
59
22
|
}
|
|
60
23
|
|
|
61
24
|
|
|
62
|
-
async function doLink(deps, repo,
|
|
25
|
+
async function doLink(deps, repo, repos, failed, isLinked) {
|
|
26
|
+
let { packageManager } = repo;
|
|
27
|
+
|
|
63
28
|
for (let dep of deps) {
|
|
64
|
-
let depMeta =
|
|
65
|
-
// console.log(depMeta)
|
|
66
|
-
// return failed;
|
|
29
|
+
let depMeta = repos.find(meta => meta.packageName === dep);
|
|
67
30
|
try {
|
|
68
31
|
if (!depMeta) {
|
|
32
|
+
// ToDo: search file system for a package.json containing the package.name
|
|
69
33
|
failed.push({
|
|
70
34
|
name: repo.name,
|
|
71
|
-
des: `"${
|
|
35
|
+
des: `"${dep}" component can not be found in repositories.js`
|
|
72
36
|
})
|
|
73
|
-
console.error(`${repo.name}: "${
|
|
37
|
+
console.error(`${repo.name}: "${dep}" component can not be found in repositories.js`.red)
|
|
74
38
|
continue;
|
|
75
39
|
}
|
|
76
40
|
|
|
77
41
|
|
|
78
42
|
|
|
79
43
|
if (!isLinked[depMeta.packageName]) {
|
|
44
|
+
|
|
80
45
|
isLinked[depMeta.packageName] = true;
|
|
81
|
-
let exitCode = await spawn(
|
|
46
|
+
let exitCode = await spawn(packageManager, ['link'], {
|
|
82
47
|
cwd: depMeta.ppath,
|
|
83
|
-
|
|
48
|
+
shell: true,
|
|
49
|
+
stdio: 'inherit'
|
|
84
50
|
});
|
|
51
|
+
|
|
85
52
|
if (exitCode !== 0) {
|
|
86
53
|
failed.push({
|
|
87
54
|
name: depMeta.name,
|
|
88
|
-
des:
|
|
55
|
+
des: `${packageManager} link failed`
|
|
89
56
|
})
|
|
90
|
-
console.error(`${depMeta.name}:
|
|
57
|
+
console.error(`${depMeta.name}: ${packageManager} link failed`.red)
|
|
91
58
|
}
|
|
92
59
|
}
|
|
93
60
|
console.log(repo.packageName, 'linking', depMeta.packageName, '...')
|
|
94
61
|
|
|
95
|
-
let exitCode = await spawn(
|
|
62
|
+
let exitCode = await spawn(packageManager, ['link', depMeta.packageName], {
|
|
96
63
|
cwd: repo.ppath,
|
|
97
|
-
|
|
64
|
+
shell: true,
|
|
65
|
+
stdio: 'inherit'
|
|
98
66
|
})
|
|
99
67
|
if (exitCode !== 0) {
|
|
100
68
|
failed.push({
|
|
101
69
|
name: repo.name,
|
|
102
|
-
des:
|
|
70
|
+
des: `${packageManager} link ${depMeta.packageName} failed`
|
|
103
71
|
});
|
|
104
|
-
console.error(`${repo.name}:
|
|
72
|
+
console.error(`${repo.name}: ${packageManager} link ${depMeta.packageName} failed`.red)
|
|
105
73
|
}
|
|
106
74
|
|
|
107
75
|
}
|
|
108
76
|
catch (err) {
|
|
109
77
|
failed.push({ name: repo.packageName, des: err.message })
|
|
110
|
-
console.error(err
|
|
78
|
+
console.error(`${err}`.red)
|
|
111
79
|
}
|
|
112
80
|
|
|
113
81
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
const fs = require('fs')
|
|
2
2
|
const path = require("path")
|
|
3
|
-
const spawn = require('
|
|
3
|
+
const spawn = require('../../spawn');
|
|
4
4
|
const colors = require('colors');
|
|
5
|
-
const addMeta = require('
|
|
5
|
+
const addMeta = require('../../addMeta');
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
module.exports = async function updateYarnLink(repos) {
|
|
@@ -3,9 +3,9 @@ const path = require("path")
|
|
|
3
3
|
const {
|
|
4
4
|
promisify
|
|
5
5
|
} = require('util');
|
|
6
|
-
const spawn = require('
|
|
6
|
+
const spawn = require('../../spawn');
|
|
7
7
|
const colors = require('colors');
|
|
8
|
-
const addMeta = require('
|
|
8
|
+
const addMeta = require('../../addMeta');
|
|
9
9
|
|
|
10
10
|
|
|
11
11
|
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
const fs = require('fs');
|
|
2
2
|
const path = require("path");
|
|
3
|
-
const spawn = require('
|
|
3
|
+
const spawn = require('../../spawn');
|
|
4
4
|
const colors = require('colors');
|
|
5
|
-
const addMeta = require('
|
|
5
|
+
const addMeta = require('../../addMeta');
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
module.exports = async function updateYarnLink(repos) {
|
|
@@ -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
|
@@ -1,54 +1,41 @@
|
|
|
1
1
|
const colors = require('colors');
|
|
2
2
|
const path = require("path");
|
|
3
3
|
const fs = require("fs");
|
|
4
|
-
const {
|
|
5
|
-
promisify
|
|
6
|
-
} = require('util');
|
|
7
4
|
const spawn = require('./spawn');
|
|
8
|
-
const
|
|
5
|
+
const util = require('node:util');
|
|
6
|
+
const exec = util.promisify(require('node:child_process').exec);
|
|
9
7
|
|
|
10
|
-
module.exports = async function execute(command, repos, config) {
|
|
11
8
|
|
|
9
|
+
module.exports = async function execute(command, repos, config) {
|
|
12
10
|
let failed = [];
|
|
13
11
|
let predefined = path.resolve(__dirname, 'commands', command + '.js');
|
|
12
|
+
|
|
14
13
|
if (fs.existsSync(predefined)) {
|
|
15
14
|
console.warn(`executing a predefined command in ${predefined}`.blue);
|
|
16
|
-
|
|
17
|
-
if (
|
|
15
|
+
|
|
16
|
+
if (repos.length == 1)
|
|
17
|
+
console.log(`running on ${repos[0].name} repo`.blue)
|
|
18
|
+
else
|
|
18
19
|
console.log('running on all repos'.blue)
|
|
19
|
-
failed = require(predefined)(repos, repos )
|
|
20
|
-
}
|
|
21
|
-
else {
|
|
22
|
-
let currentRepoConfig = repos.find(m => m.name === path.basename(process.cwd()).toLowerCase());
|
|
23
|
-
if (currentRepoConfig && currentRepoConfig.ppath == path.resolve(process.cwd())) {
|
|
24
|
-
console.log(`running on ${currentRepoConfig.name} repo`.blue)
|
|
25
|
-
failed = require(predefined)([currentRepoConfig], repos )
|
|
26
|
-
}
|
|
27
|
-
else {
|
|
28
|
-
console.error(`${currentRepoConfig.name} can not be found or have diferent path`.red)
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
}
|
|
34
|
-
else {
|
|
35
20
|
|
|
21
|
+
failed = require(predefined)(repos)
|
|
36
22
|
|
|
23
|
+
} else {
|
|
24
|
+
let type = command.split(' ')[0]
|
|
37
25
|
for (let repo of repos) {
|
|
38
|
-
if (!repo)
|
|
39
|
-
console.log(repo, repos)
|
|
40
|
-
// let repo = {name: 'aa', ppath: '/home/ubuntu/environment/CoCreate-plugins/CoCreate-sendgrid'}
|
|
41
26
|
try {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
}
|
|
45
|
-
console.log(`${name}: `.green, command)
|
|
27
|
+
if (repo.exclude && repo.exclude.includes(type))
|
|
28
|
+
continue
|
|
29
|
+
console.log(`${repo.name}: `.green, command)
|
|
46
30
|
let exitCode;
|
|
47
|
-
if (config.hideMessage)
|
|
48
|
-
|
|
31
|
+
if (config.hideMessage) {
|
|
32
|
+
const { error } = await exec(command, {
|
|
49
33
|
cwd: repo.ppath,
|
|
50
|
-
})
|
|
51
|
-
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
if (error)
|
|
37
|
+
exitCode = 1
|
|
38
|
+
} else
|
|
52
39
|
exitCode = await spawn(command, null, {
|
|
53
40
|
cwd: repo.ppath,
|
|
54
41
|
shell: true,
|
|
@@ -57,27 +44,18 @@ module.exports = async function execute(command, repos, config) {
|
|
|
57
44
|
|
|
58
45
|
if (exitCode !== 0)
|
|
59
46
|
failed.push({
|
|
60
|
-
name,
|
|
47
|
+
name: repo.name,
|
|
61
48
|
des: 'command failed: ' + command
|
|
62
49
|
})
|
|
63
50
|
|
|
64
51
|
|
|
65
52
|
}
|
|
66
53
|
catch (err) {
|
|
67
|
-
|
|
68
54
|
console.error(`an error occured executing command in ${repo.name} repository`.red, err.message);;
|
|
69
|
-
|
|
70
55
|
}
|
|
71
56
|
}
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
57
|
}
|
|
76
58
|
|
|
77
|
-
|
|
78
|
-
|
|
79
59
|
return failed;
|
|
80
60
|
|
|
81
|
-
|
|
82
|
-
|
|
83
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
|
-
}
|