@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
|
@@ -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
|
-
}
|
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
const fs = require('fs')
|
|
2
|
-
const path = require("path")
|
|
3
|
-
const {
|
|
4
|
-
promisify
|
|
5
|
-
} = require('util');
|
|
6
|
-
const spawn = require('../../spawn');
|
|
7
|
-
const colors = require('colors');
|
|
8
|
-
const addMeta = require('../../addMeta');
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
module.exports = async function updateYarnInstall(repos, allrepo) {
|
|
15
|
-
|
|
16
|
-
const failed = [],
|
|
17
|
-
isLinked = {};
|
|
18
|
-
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
|
-
for (let repo of repos) {
|
|
35
|
-
|
|
36
|
-
if (!repo)
|
|
37
|
-
continue;
|
|
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)
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
catch (err) {
|
|
54
|
-
failed.push({ name: 'GENERAL', des: err.message })
|
|
55
|
-
console.error(err.red)
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
return failed;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
async function doLink(deps, repo, allrepo, failed, isLinked) {
|
|
63
|
-
for (let dep of deps) {
|
|
64
|
-
let depMeta = allrepo.find(meta => meta.packageName === dep);
|
|
65
|
-
// console.log(depMeta)
|
|
66
|
-
// return failed;
|
|
67
|
-
try {
|
|
68
|
-
if (!depMeta) {
|
|
69
|
-
failed.push({
|
|
70
|
-
name: repo.name,
|
|
71
|
-
des: `"${dep}" component can not be found in repositories.js`
|
|
72
|
-
})
|
|
73
|
-
console.error(`${repo.name}: "${dep}" component can not be found in repositories.js`.red)
|
|
74
|
-
continue;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
let exitCode;
|
|
79
|
-
if (depMeta.packageName === '@cocreate/crdt') {
|
|
80
|
-
|
|
81
|
-
console.log('creating symbolic link')
|
|
82
|
-
let linkPath = path.resolve(repo.ppath, 'node_modules/@cocreate', depMeta.plainName)
|
|
83
|
-
if (fs.existsSync(linkPath))
|
|
84
|
-
fs.unlinkSync(linkPath)
|
|
85
|
-
exitCode = await spawn('ln', ['-s', '-f', depMeta.ppath, linkPath], {
|
|
86
|
-
cwd: repo.ppath,
|
|
87
|
-
stdio: 'inherit',
|
|
88
|
-
})
|
|
89
|
-
if (exitCode !== 0) {
|
|
90
|
-
failed.push({
|
|
91
|
-
name: repo.name,
|
|
92
|
-
des: `ln failed`
|
|
93
|
-
});
|
|
94
|
-
console.error(`${repo.name}:ln failed`.red)
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
}
|
|
101
|
-
catch (err) {
|
|
102
|
-
failed.push({ name: repo.packageName, des: err.message })
|
|
103
|
-
console.error(err)
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
}
|
|
107
|
-
}
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
const fs = require('fs');
|
|
2
|
-
const path = require("path");
|
|
3
|
-
const spawn = require('../../spawn');
|
|
4
|
-
const colors = require('colors');
|
|
5
|
-
const addMeta = require('../../addMeta');
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
module.exports = async function updateYarnLink(repos) {
|
|
9
|
-
let failed = [];
|
|
10
|
-
|
|
11
|
-
try {
|
|
12
|
-
repos = addMeta(repos, failed);
|
|
13
|
-
|
|
14
|
-
}
|
|
15
|
-
catch (err) {
|
|
16
|
-
failed.push({
|
|
17
|
-
name: 'GENERAL',
|
|
18
|
-
des: err.message
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
for (let repo of repos) {
|
|
24
|
-
await yarnInstall(repo, failed, '');
|
|
25
|
-
}
|
|
26
|
-
return failed;
|
|
27
|
-
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
async function yarnInstall(repo, failed, param = '') {
|
|
32
|
-
try {
|
|
33
|
-
console.log(`${repo.name}: `.green, `yarn install`);
|
|
34
|
-
let exitCode = await spawn( 'yarn', ['install'], {
|
|
35
|
-
cwd: repo.ppath, stdio: 'inherit',
|
|
36
|
-
});
|
|
37
|
-
if (exitCode !== 0) {
|
|
38
|
-
failed.push({
|
|
39
|
-
name: repo.name,
|
|
40
|
-
des: `yarn ${param}`
|
|
41
|
-
})
|
|
42
|
-
console.error(`${repo.name}: yarn ${param}`.red)
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
catch (err) {
|
|
46
|
-
failed.push({
|
|
47
|
-
name: repo.name,
|
|
48
|
-
des: err.message
|
|
49
|
-
})
|
|
50
|
-
console.error(`${repo.name}: ${err.message}`.red)
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
|
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
|
-
}
|