@cocreate/cli 1.18.0 → 1.19.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 +14 -0
- package/package.json +1 -1
- package/src/commands/link.js +5 -15
- package/src/commands/symlink.js +25 -26
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
## [1.19.1](https://github.com/CoCreate-app/CoCreate-cli/compare/v1.19.0...v1.19.1) (2023-03-29)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* execute replace with spawn ([1e8e538](https://github.com/CoCreate-app/CoCreate-cli/commit/1e8e538309ff7725d8423e7b734f87d6b9bfe926))
|
|
7
|
+
|
|
8
|
+
# [1.19.0](https://github.com/CoCreate-app/CoCreate-cli/compare/v1.18.0...v1.19.0) (2023-03-29)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Features
|
|
12
|
+
|
|
13
|
+
* link supports defining repos to excute and repolist to link ([a8c50dc](https://github.com/CoCreate-app/CoCreate-cli/commit/a8c50dcf810280b2cb61aa6b23748768ca90485d))
|
|
14
|
+
|
|
1
15
|
# [1.18.0](https://github.com/CoCreate-app/CoCreate-cli/compare/v1.17.2...v1.18.0) (2023-03-29)
|
|
2
16
|
|
|
3
17
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cocreate/cli",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.19.1",
|
|
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/commands/link.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
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 {
|
|
@@ -11,8 +11,10 @@ module.exports = async function linkPackages(repos) {
|
|
|
11
11
|
continue
|
|
12
12
|
|
|
13
13
|
console.log(repo.packageName, 'configuring ...')
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
if (!repoList)
|
|
15
|
+
repoList = repos
|
|
16
|
+
await doLink(repo.deps, repo, repoList, failed, isLinked)
|
|
17
|
+
await doLink(repo.devDeps, repo, repoList, failed, isLinked)
|
|
16
18
|
}
|
|
17
19
|
}
|
|
18
20
|
catch (err) {
|
|
@@ -30,18 +32,6 @@ async function doLink(deps, repo, repos, failed, isLinked) {
|
|
|
30
32
|
for (let dep of deps) {
|
|
31
33
|
let depMeta = repos.find(meta => meta.packageName === dep);
|
|
32
34
|
try {
|
|
33
|
-
// if (!depMeta) {
|
|
34
|
-
// // ToDo: search file system for a package.json containing the package.name
|
|
35
|
-
|
|
36
|
-
// failed.push({
|
|
37
|
-
// name: repo.name,
|
|
38
|
-
// des: `"${dep}" component can not be found in repositories.js`
|
|
39
|
-
// })
|
|
40
|
-
// console.error(`${repo.name}: "${dep}" component can not be found in repositories.js`.red)
|
|
41
|
-
// continue;
|
|
42
|
-
// }
|
|
43
|
-
|
|
44
|
-
|
|
45
35
|
|
|
46
36
|
if (depMeta && !isLinked[depMeta.packageName]) {
|
|
47
37
|
|
package/src/commands/symlink.js
CHANGED
|
@@ -1,24 +1,25 @@
|
|
|
1
1
|
const fs = require('fs')
|
|
2
2
|
const path = require("path")
|
|
3
3
|
const util = require('node:util');
|
|
4
|
-
const
|
|
4
|
+
const spawn = require('../spawn');
|
|
5
5
|
|
|
6
6
|
const cwdPath = path.resolve(process.cwd());
|
|
7
|
-
|
|
7
|
+
let cwdNodeModulesPath = path.resolve(cwdPath, 'node_modules')
|
|
8
8
|
|
|
9
9
|
|
|
10
|
-
// let doInstall = process.argv[2];
|
|
11
|
-
// console.log('doInstall', doInstall)
|
|
12
10
|
let reposLength, failed = [];
|
|
13
11
|
|
|
14
12
|
module.exports = async function symlink(repos) {
|
|
15
13
|
reposLength = repos.length
|
|
16
14
|
|
|
17
15
|
for (let i = 0; i < repos.length; i++) {
|
|
18
|
-
|
|
16
|
+
|
|
17
|
+
if (cwdPath === repos[i].absolutePath && !fs.existsSync(cwdNodeModulesPath)) {
|
|
18
|
+
await install(repos[i], repos)
|
|
19
19
|
reposLength -= 1
|
|
20
|
-
|
|
21
|
-
|
|
20
|
+
} else if (repos[i].install == true) {
|
|
21
|
+
reposLength -= 1
|
|
22
|
+
await install(repos[i], repos)
|
|
22
23
|
} else if (cwdPath !== repos[i].absolutePath) {
|
|
23
24
|
await createSymlink(repos[i])
|
|
24
25
|
}
|
|
@@ -77,33 +78,31 @@ function erSymlink(name, dest){
|
|
|
77
78
|
}
|
|
78
79
|
|
|
79
80
|
|
|
80
|
-
async function install(repo) {
|
|
81
|
+
async function install(repo, repos) {
|
|
81
82
|
let dpath = repo.absolutePath
|
|
82
83
|
if (!fs.existsSync(dpath)) {
|
|
83
84
|
failed.push({name: 'install', des: 'path doesn\'t exist:' + dpath})
|
|
84
85
|
return console.error(dpath, 'not exist')
|
|
85
86
|
}
|
|
86
87
|
try {
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
console.
|
|
100
|
-
|
|
88
|
+
console.log('installing', repo.name)
|
|
89
|
+
let exitCode = await spawn(repo.packageManager, ['install'], {
|
|
90
|
+
cwd: repo.absolutePath,
|
|
91
|
+
shell: true,
|
|
92
|
+
stdio: 'inherit'
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
if (exitCode !== 0) {
|
|
96
|
+
failed.push({
|
|
97
|
+
name: repo.name,
|
|
98
|
+
des: `${repo.packageManager} install failed`
|
|
99
|
+
})
|
|
100
|
+
console.error(`${repo.name}: ${repo.packageManager} install failed`.red)
|
|
101
|
+
} else {
|
|
102
|
+
let linkFailed = await require('./link.js')([repo], repos)
|
|
101
103
|
if (linkFailed)
|
|
102
104
|
failed.push(linkFailed)
|
|
103
|
-
|
|
104
|
-
} else {
|
|
105
|
-
failed.push({name: 'install ', des: error})
|
|
106
|
-
console.error(repo.name, 'failed to install', error)
|
|
105
|
+
|
|
107
106
|
}
|
|
108
107
|
|
|
109
108
|
}
|