@cocreate/cli 1.17.2 → 1.19.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 +19 -0
- package/package.json +1 -1
- package/src/addMeta.js +31 -29
- package/src/coc.js +0 -0
- package/src/commands/clone.js +1 -0
- package/src/commands/install.js +5 -2
- package/src/commands/link.js +7 -3
- package/src/commands/symlink.js +39 -20
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,22 @@
|
|
|
1
|
+
# [1.19.0](https://github.com/CoCreate-app/CoCreate-cli/compare/v1.18.0...v1.19.0) (2023-03-29)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Features
|
|
5
|
+
|
|
6
|
+
* link supports defining repos to excute and repolist to link ([a8c50dc](https://github.com/CoCreate-app/CoCreate-cli/commit/a8c50dcf810280b2cb61aa6b23748768ca90485d))
|
|
7
|
+
|
|
8
|
+
# [1.18.0](https://github.com/CoCreate-app/CoCreate-cli/compare/v1.17.2...v1.18.0) (2023-03-29)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Bug Fixes
|
|
12
|
+
|
|
13
|
+
* else condition if file exist ([df1eaa0](https://github.com/CoCreate-app/CoCreate-cli/commit/df1eaa0bd4de9f1d7858e0d97655df0ef9784e62))
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
### Features
|
|
17
|
+
|
|
18
|
+
* if install true symlink will install packages then will run link. fixed directory path ([97103bf](https://github.com/CoCreate-app/CoCreate-cli/commit/97103bfd1949a5db26ac836e0ba385c108f25f20))
|
|
19
|
+
|
|
1
20
|
## [1.17.2](https://github.com/CoCreate-app/CoCreate-cli/compare/v1.17.1...v1.17.2) (2023-03-16)
|
|
2
21
|
|
|
3
22
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cocreate/cli",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.19.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",
|
package/src/addMeta.js
CHANGED
|
@@ -11,7 +11,8 @@ module.exports = async function addMeta(repos, failed, directory) {
|
|
|
11
11
|
|
|
12
12
|
if (directory) {
|
|
13
13
|
repos[i].absolutePath = path.resolve(directory, repos[i].path);
|
|
14
|
-
repos[i].
|
|
14
|
+
const parsedPath = path.parse(repos[i].absolutePath);
|
|
15
|
+
repos[i].directory = parsedPath.dir
|
|
15
16
|
}
|
|
16
17
|
|
|
17
18
|
let packagejson = path.resolve(repos[i].absolutePath, 'package.json');
|
|
@@ -21,40 +22,41 @@ module.exports = async function addMeta(repos, failed, directory) {
|
|
|
21
22
|
name: repos[i].name,
|
|
22
23
|
des: 'package json not found'
|
|
23
24
|
})
|
|
24
|
-
}
|
|
25
|
+
} else {
|
|
25
26
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
27
|
+
let packageObj
|
|
28
|
+
try {
|
|
29
|
+
packageObj = require(packagejson);
|
|
30
|
+
}
|
|
31
|
+
catch (err) {
|
|
32
|
+
console.error('packageObj', err.message)
|
|
33
|
+
}
|
|
33
34
|
|
|
34
35
|
|
|
35
|
-
|
|
36
|
+
repos[i].packageName = packageObj.name;
|
|
36
37
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
repos[i].packageManager = 'yarn'
|
|
52
|
-
else {
|
|
53
|
-
const { error } = await exec('yarn --version');
|
|
54
|
-
if (!error)
|
|
38
|
+
repos[i].deps = Object.keys(packageObj['dependencies'] || {})
|
|
39
|
+
.filter(packageName => packageName.startsWith('@cocreate/'));
|
|
40
|
+
repos[i].devDeps = Object.keys(packageObj['devDependencies'] || {})
|
|
41
|
+
.filter(packageName => packageName.startsWith('@cocreate/'));
|
|
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))
|
|
55
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
|
|
56
59
|
}
|
|
57
|
-
packageManager = repos[i].packageManager
|
|
58
60
|
}
|
|
59
61
|
}
|
|
60
62
|
}
|
package/src/coc.js
CHANGED
|
File without changes
|
package/src/commands/clone.js
CHANGED
|
@@ -8,6 +8,7 @@ module.exports = async function gitClone(repos) {
|
|
|
8
8
|
const cwdPath = path.resolve(process.cwd());
|
|
9
9
|
|
|
10
10
|
for (let i = 0; i < repos.length; i++) {
|
|
11
|
+
// ToDo: Check if path exist and if git.config or package.json exist continue
|
|
11
12
|
if (cwdPath !== repos[i].absolutePath) {
|
|
12
13
|
let exitCode = await spawn('mkdir', ['-p', repos[i].directory], { stdio: 'inherit', cwd: process.cwd() })
|
|
13
14
|
if (exitCode !== 0) {
|
package/src/commands/install.js
CHANGED
|
@@ -4,11 +4,14 @@ module.exports = async function(repos) {
|
|
|
4
4
|
let failed = [];
|
|
5
5
|
try {
|
|
6
6
|
let cloneFailed = await require('./clone.js')(repos)
|
|
7
|
+
if (cloneFailed)
|
|
8
|
+
failed.push(cloneFailed)
|
|
9
|
+
|
|
7
10
|
repos = await addMeta(repos, failed)
|
|
8
11
|
|
|
9
12
|
let symlinkFailed = await require('./symlink.js')(repos)
|
|
10
|
-
|
|
11
|
-
|
|
13
|
+
if (symlinkFailed)
|
|
14
|
+
failed.push(symlinkFailed)
|
|
12
15
|
} catch (err) {
|
|
13
16
|
console.error(err);
|
|
14
17
|
failed.push({ name: 'general', des: err.message })
|
package/src/commands/link.js
CHANGED
|
@@ -1,16 +1,20 @@
|
|
|
1
1
|
const spawn = require('../spawn');
|
|
2
2
|
const colors = require('colors');
|
|
3
3
|
|
|
4
|
-
module.exports = async function linkPackages(repos) {
|
|
4
|
+
module.exports = async function linkPackages(repos, repoList) {
|
|
5
5
|
const failed = [], isLinked = {};
|
|
6
6
|
|
|
7
7
|
try {
|
|
8
8
|
for (let repo of repos) {
|
|
9
9
|
if (!repo) continue;
|
|
10
|
+
if (repo.exclude && repo.exclude.includes('link'))
|
|
11
|
+
continue
|
|
10
12
|
|
|
11
13
|
console.log(repo.packageName, 'configuring ...')
|
|
12
|
-
|
|
13
|
-
|
|
14
|
+
if (!repoList)
|
|
15
|
+
repoList = repos
|
|
16
|
+
await doLink(repo.deps, repo, repoList, failed, isLinked)
|
|
17
|
+
await doLink(repo.devDeps, repo, repoList, failed, isLinked)
|
|
14
18
|
}
|
|
15
19
|
}
|
|
16
20
|
catch (err) {
|
package/src/commands/symlink.js
CHANGED
|
@@ -2,9 +2,10 @@ const fs = require('fs')
|
|
|
2
2
|
const path = require("path")
|
|
3
3
|
const util = require('node:util');
|
|
4
4
|
const exec = util.promisify(require('node:child_process').exec);
|
|
5
|
+
const spawn = require('../spawn');
|
|
5
6
|
|
|
6
7
|
const cwdPath = path.resolve(process.cwd());
|
|
7
|
-
|
|
8
|
+
let cwdNodeModulesPath = path.resolve(cwdPath, 'node_modules')
|
|
8
9
|
|
|
9
10
|
|
|
10
11
|
// let doInstall = process.argv[2];
|
|
@@ -15,9 +16,13 @@ module.exports = async function symlink(repos) {
|
|
|
15
16
|
reposLength = repos.length
|
|
16
17
|
|
|
17
18
|
for (let i = 0; i < repos.length; i++) {
|
|
18
|
-
|
|
19
|
+
|
|
20
|
+
if (cwdPath === repos[i].absolutePath && !fs.existsSync(cwdNodeModulesPath)) {
|
|
21
|
+
await install(repos[i], repos)
|
|
19
22
|
reposLength -= 1
|
|
20
|
-
|
|
23
|
+
} else if (repos[i].install == true) {
|
|
24
|
+
reposLength -= 1
|
|
25
|
+
await install(repos[i], repos)
|
|
21
26
|
} else if (cwdPath !== repos[i].absolutePath) {
|
|
22
27
|
await createSymlink(repos[i])
|
|
23
28
|
}
|
|
@@ -76,31 +81,45 @@ function erSymlink(name, dest){
|
|
|
76
81
|
}
|
|
77
82
|
|
|
78
83
|
|
|
79
|
-
async function install(repo) {
|
|
84
|
+
async function install(repo, repos) {
|
|
80
85
|
let dpath = repo.absolutePath
|
|
81
86
|
if (!fs.existsSync(dpath)) {
|
|
82
87
|
failed.push({name: 'install', des: 'path doesn\'t exist:' + dpath})
|
|
83
88
|
return console.error(dpath, 'not exist')
|
|
84
89
|
}
|
|
85
90
|
try {
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
91
|
+
let exitCode = await spawn(repo.packageManager, ['install'], {
|
|
92
|
+
cwd: repo.absolutePath,
|
|
93
|
+
shell: true,
|
|
94
|
+
stdio: 'inherit'
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
if (exitCode !== 0) {
|
|
98
|
+
failed.push({
|
|
99
|
+
name: repo.name,
|
|
100
|
+
des: `${repo.packageManager} install failed`
|
|
101
|
+
})
|
|
102
|
+
console.error(`${repo.name}: ${repo.packageManager} install failed`.red)
|
|
103
|
+
} else {
|
|
104
|
+
// ToDo: needs to run on defined repo but stiil require all repos in order to xecute on correct path
|
|
105
|
+
let linkFailed = await require('./link.js')([repo], repos)
|
|
106
|
+
if (linkFailed)
|
|
107
|
+
failed.push(linkFailed)
|
|
108
|
+
|
|
102
109
|
}
|
|
103
110
|
|
|
111
|
+
// let {error} = await exec(`${repo.packageManager} install `, { cwd: dpath })
|
|
112
|
+
// if (!error) {
|
|
113
|
+
// console.log(repo.name, 'installed')
|
|
114
|
+
// let linkFailed = await require('./link.js')([repo])
|
|
115
|
+
// if (linkFailed)
|
|
116
|
+
// failed.push(linkFailed)
|
|
117
|
+
|
|
118
|
+
// } else {
|
|
119
|
+
// failed.push({name: 'install ', des: error})
|
|
120
|
+
// console.error(repo.name, 'failed to install', error)
|
|
121
|
+
// }
|
|
122
|
+
|
|
104
123
|
}
|
|
105
124
|
catch (err) {
|
|
106
125
|
console.error(repo.name, 'did not install', err)
|