@cocreate/cli 1.15.0 → 1.16.1
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 +15 -0
- package/package.json +1 -2
- package/repositories.js +9 -33
- package/src/addMeta.js +42 -38
- package/src/coc.js +26 -69
- package/src/commands/bump.js +62 -103
- package/src/commands/clone.js +15 -16
- package/src/commands/fs/contribution.js +5 -5
- package/src/commands/fs/readme.js +5 -6
- 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 +25 -47
- package/src/commands/other/add.js +1 -1
- package/src/commands/symlink.js +109 -0
- package/src/execute.js +15 -40
- package/src/commands/other/symbolic-crdt.js +0 -116
- package/src/commands/other/symbolic-link.js +0 -116
- package/src/commands/other/symbolic.js +0 -107
- package/src/commands/other/yarnInstall.js +0 -54
- package/src/repoList.js +0 -44
|
@@ -10,10 +10,10 @@ let list = require('../repositories.js');
|
|
|
10
10
|
let metaYarnLink = list.map(meta => {
|
|
11
11
|
let name = path.basename(meta.path).toLowerCase();
|
|
12
12
|
try {
|
|
13
|
-
let
|
|
13
|
+
let absolutePath = path.resolve(meta.path);
|
|
14
14
|
|
|
15
15
|
|
|
16
|
-
let packagejson = path.resolve(
|
|
16
|
+
let packagejson = path.resolve(absolutePath, 'package.json');
|
|
17
17
|
if (!fs.existsSync(packagejson)) {
|
|
18
18
|
console.error('package json not found for', name);
|
|
19
19
|
return false;
|
|
@@ -23,7 +23,7 @@ let metaYarnLink = list.map(meta => {
|
|
|
23
23
|
let packageName = name.startsWith('cocreate-') ?
|
|
24
24
|
'@cocreate/' + name.substr(9) : packageObj.name;
|
|
25
25
|
|
|
26
|
-
return { ...meta, name, packageName,
|
|
26
|
+
return { ...meta, name, packageName, absolutePath, packageObj }
|
|
27
27
|
}
|
|
28
28
|
catch (err) {
|
|
29
29
|
console.error('error: ', name, err.message);
|
|
@@ -35,7 +35,6 @@ let metaYarnLink = list.map(meta => {
|
|
|
35
35
|
(async() => {
|
|
36
36
|
for (let meta of metaYarnLink) {
|
|
37
37
|
await update(meta)
|
|
38
|
-
// await updateYarnLink(metaYarnLink[0])
|
|
39
38
|
}
|
|
40
39
|
})();
|
|
41
40
|
|
|
@@ -43,7 +42,7 @@ let metaYarnLink = list.map(meta => {
|
|
|
43
42
|
function update(param) {
|
|
44
43
|
// component name
|
|
45
44
|
if (!param) return;
|
|
46
|
-
let { packageObj,
|
|
45
|
+
let { packageObj, absolutePath } = param;
|
|
47
46
|
let { name, description } = packageObj;
|
|
48
47
|
let shortName = name.substr(10);
|
|
49
48
|
let fileContent = `# CoCreate-${shortName}
|
|
@@ -127,7 +126,7 @@ We appreciate your continued support, thank you!
|
|
|
127
126
|
|
|
128
127
|
`;
|
|
129
128
|
|
|
130
|
-
let MdPath = path.resolve(
|
|
129
|
+
let MdPath = path.resolve(absolutePath, 'README.md')
|
|
131
130
|
let formated = prettier.format(fileContent, { semi: false, parser: "markdown" });
|
|
132
131
|
if (fs.existsSync(MdPath))
|
|
133
132
|
fs.unlinkSync(MdPath)
|
|
@@ -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,26 +22,30 @@ 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
|
-
if (!depMeta) {
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
}
|
|
31
|
+
// if (!depMeta) {
|
|
32
|
+
// // ToDo: search file system for a package.json containing the package.name
|
|
33
|
+
|
|
34
|
+
// failed.push({
|
|
35
|
+
// name: repo.name,
|
|
36
|
+
// des: `"${dep}" component can not be found in repositories.js`
|
|
37
|
+
// })
|
|
38
|
+
// console.error(`${repo.name}: "${dep}" component can not be found in repositories.js`.red)
|
|
39
|
+
// continue;
|
|
40
|
+
// }
|
|
66
41
|
|
|
67
42
|
|
|
68
43
|
|
|
69
|
-
if (!isLinked[depMeta.packageName]) {
|
|
44
|
+
if (depMeta && !isLinked[depMeta.packageName]) {
|
|
70
45
|
|
|
71
46
|
isLinked[depMeta.packageName] = true;
|
|
72
47
|
let exitCode = await spawn(packageManager, ['link'], {
|
|
73
|
-
cwd: depMeta.
|
|
48
|
+
cwd: depMeta.absolutePath,
|
|
74
49
|
shell: true,
|
|
75
50
|
stdio: 'inherit'
|
|
76
51
|
});
|
|
@@ -83,10 +58,13 @@ async function doLink(deps, repo, allrepo, failed, isLinked, packageManager) {
|
|
|
83
58
|
console.error(`${depMeta.name}: ${packageManager} link failed`.red)
|
|
84
59
|
}
|
|
85
60
|
}
|
|
61
|
+
|
|
62
|
+
if (!depMeta)
|
|
63
|
+
depMeta = {packageName: dep}
|
|
86
64
|
console.log(repo.packageName, 'linking', depMeta.packageName, '...')
|
|
87
65
|
|
|
88
66
|
let exitCode = await spawn(packageManager, ['link', depMeta.packageName], {
|
|
89
|
-
cwd: repo.
|
|
67
|
+
cwd: repo.absolutePath,
|
|
90
68
|
shell: true,
|
|
91
69
|
stdio: 'inherit'
|
|
92
70
|
})
|
|
@@ -41,7 +41,7 @@ async function reAdd(deps, repo, failed, param = '') {
|
|
|
41
41
|
console.log(`${repo.name}: `.green, `yarn ${packageListLog}`);
|
|
42
42
|
// let exitCode = await spawn(`yarn`, ['add', ...param && [param], packageList], {
|
|
43
43
|
let exitCode = await spawn( 'yarn', packageList, {
|
|
44
|
-
cwd: repo.
|
|
44
|
+
cwd: repo.absolutePath, stdio: 'inherit',
|
|
45
45
|
});
|
|
46
46
|
if (exitCode !== 0) {
|
|
47
47
|
failed.push({
|
|
@@ -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,80 +7,55 @@ 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
|
-
|
|
49
|
-
cwd: repo.ppath,
|
|
32
|
+
const { error } = await exec(command, {
|
|
33
|
+
cwd: repo.absolutePath,
|
|
50
34
|
});
|
|
51
35
|
|
|
52
36
|
if (error)
|
|
53
37
|
exitCode = 1
|
|
54
38
|
} else
|
|
55
39
|
exitCode = await spawn(command, null, {
|
|
56
|
-
cwd: repo.
|
|
40
|
+
cwd: repo.absolutePath,
|
|
57
41
|
shell: true,
|
|
58
42
|
stdio: 'inherit'
|
|
59
43
|
})
|
|
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('../CoCreate-components/CoCreate-crdt');
|
|
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
|
-
}
|