@cocreate/cli 1.34.4 → 1.35.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 +3 -3
- package/src/commands/link.js +35 -74
- package/src/commands/symlink.js +18 -29
- package/check-coc.js +0 -16
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
## [1.35.1](https://github.com/CoCreate-app/CoCreate-cli/compare/v1.35.0...v1.35.1) (2023-06-16)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* removed coc-check ([2dd089b](https://github.com/CoCreate-app/CoCreate-cli/commit/2dd089b1d105840c305177027b23e4573fc26239))
|
|
7
|
+
|
|
8
|
+
# [1.35.0](https://github.com/CoCreate-app/CoCreate-cli/compare/v1.34.4...v1.35.0) (2023-06-16)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Features
|
|
12
|
+
|
|
13
|
+
* Add symlink and linkPackages functionality ([a1a8e90](https://github.com/CoCreate-app/CoCreate-cli/commit/a1a8e9067e8232ebe127f0114fc547aeca869bf2))
|
|
14
|
+
|
|
1
15
|
## [1.34.4](https://github.com/CoCreate-app/CoCreate-cli/compare/v1.34.3...v1.34.4) (2023-06-15)
|
|
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.35.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",
|
|
@@ -57,8 +57,8 @@
|
|
|
57
57
|
"coc": "src/coc.js"
|
|
58
58
|
},
|
|
59
59
|
"dependencies": {
|
|
60
|
-
"@cocreate/config": "^1.0.
|
|
61
|
-
"@cocreate/file": "^1.3.
|
|
60
|
+
"@cocreate/config": "^1.0.9",
|
|
61
|
+
"@cocreate/file": "^1.3.9",
|
|
62
62
|
"glob": "^7.1.7",
|
|
63
63
|
"prettier": "^2.3.2"
|
|
64
64
|
}
|
package/src/commands/link.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
const spawn = require('../spawn');
|
|
2
|
+
const path = require("path")
|
|
2
3
|
const { color } = require('../fonts');
|
|
3
4
|
|
|
4
|
-
module.exports = async
|
|
5
|
+
module.exports = async (repos, args) => {
|
|
5
6
|
const failed = [], isLinked = {};
|
|
6
7
|
|
|
7
8
|
try {
|
|
@@ -13,38 +14,50 @@ module.exports = async function linkPackages(repos, args) {
|
|
|
13
14
|
if (process.cwd() === repo.absolutePath)
|
|
14
15
|
continue
|
|
15
16
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
17
|
+
if (repo.packageManager === 'npm') {
|
|
18
|
+
let dir = path.resolve(process.cwd(), 'node_modules');
|
|
19
|
+
let dest = path.resolve(path.resolve(repo.absolutePath), 'node_modules');
|
|
20
|
+
if (dir && dest) {
|
|
21
|
+
if (fs.existsSync(dest))
|
|
22
|
+
await fs.promises.rm(dest, { recursive: true, force: true });
|
|
21
23
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
des: `${repo.packageManager} link failed`
|
|
26
|
-
})
|
|
27
|
-
console.error(color.red + `${repo.name}: ${repo.packageManager} link failed` + color.reset)
|
|
24
|
+
await fs.promises.symlink(dir, dest, 'dir');
|
|
25
|
+
console.log(repo.packageManager, 'link', repo.packageName)
|
|
26
|
+
}
|
|
28
27
|
} else {
|
|
29
|
-
console.log(repo.packageManager, 'link', repo.packageName)
|
|
30
28
|
|
|
31
|
-
let exitCode = await spawn(repo.packageManager, ['link'
|
|
32
|
-
cwd:
|
|
29
|
+
let exitCode = await spawn(repo.packageManager, ['link'], {
|
|
30
|
+
cwd: repo.absolutePath,
|
|
33
31
|
shell: true,
|
|
34
32
|
stdio: 'inherit'
|
|
35
|
-
})
|
|
33
|
+
});
|
|
34
|
+
|
|
36
35
|
if (exitCode !== 0) {
|
|
37
36
|
failed.push({
|
|
38
37
|
name: repo.name,
|
|
39
|
-
des: `${repo.packageManager} link
|
|
40
|
-
})
|
|
41
|
-
console.error(color.red + `${repo.name}: ${repo.packageManager} link
|
|
38
|
+
des: `${repo.packageManager} link failed`
|
|
39
|
+
})
|
|
40
|
+
console.error(color.red + `${repo.name}: ${repo.packageManager} link failed` + color.reset)
|
|
41
|
+
} else {
|
|
42
|
+
console.log(repo.packageManager, 'link', repo.packageName)
|
|
43
|
+
|
|
44
|
+
let exitCode = await spawn(repo.packageManager, ['link', repo.packageName], {
|
|
45
|
+
cwd: process.cwd(),
|
|
46
|
+
shell: true,
|
|
47
|
+
stdio: 'inherit'
|
|
48
|
+
})
|
|
49
|
+
if (exitCode !== 0) {
|
|
50
|
+
failed.push({
|
|
51
|
+
name: repo.name,
|
|
52
|
+
des: `${repo.packageManager} link ${repo.packageName} failed`
|
|
53
|
+
});
|
|
54
|
+
console.error(color.red + `${repo.name}: ${repo.packageManager} link ${repo.packageName} failed` + color.reset)
|
|
55
|
+
}
|
|
42
56
|
}
|
|
43
|
-
}
|
|
44
57
|
|
|
45
|
-
|
|
46
|
-
// await doLink(repo.devDeps, repo, repos, failed, isLinked)
|
|
58
|
+
}
|
|
47
59
|
}
|
|
60
|
+
|
|
48
61
|
}
|
|
49
62
|
catch (err) {
|
|
50
63
|
failed.push({ name: 'GENERAL', des: err.message })
|
|
@@ -53,55 +66,3 @@ module.exports = async function linkPackages(repos, args) {
|
|
|
53
66
|
|
|
54
67
|
return failed;
|
|
55
68
|
}
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
async function doLink(deps, repo, repos, failed, isLinked) {
|
|
59
|
-
let { packageManager } = repo;
|
|
60
|
-
|
|
61
|
-
for (let dep of deps) {
|
|
62
|
-
let depMeta = repos.find(meta => meta.packageName === dep);
|
|
63
|
-
try {
|
|
64
|
-
|
|
65
|
-
if (depMeta && !isLinked[depMeta.packageName]) {
|
|
66
|
-
|
|
67
|
-
isLinked[depMeta.packageName] = true;
|
|
68
|
-
let exitCode = await spawn(packageManager, ['link'], {
|
|
69
|
-
cwd: depMeta.absolutePath,
|
|
70
|
-
shell: true,
|
|
71
|
-
stdio: 'inherit'
|
|
72
|
-
});
|
|
73
|
-
|
|
74
|
-
if (exitCode !== 0) {
|
|
75
|
-
failed.push({
|
|
76
|
-
name: depMeta.name,
|
|
77
|
-
des: `${packageManager} link failed`
|
|
78
|
-
})
|
|
79
|
-
console.error(color.red + `${depMeta.name}: ${packageManager} link failed` + color.reset)
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
if (!depMeta)
|
|
84
|
-
depMeta = { packageName: dep }
|
|
85
|
-
console.log(repo.packageName, 'linking', depMeta.packageName, '...')
|
|
86
|
-
|
|
87
|
-
let exitCode = await spawn(packageManager, ['link', depMeta.packageName], {
|
|
88
|
-
cwd: repo.absolutePath,
|
|
89
|
-
shell: true,
|
|
90
|
-
stdio: 'inherit'
|
|
91
|
-
})
|
|
92
|
-
if (exitCode !== 0) {
|
|
93
|
-
failed.push({
|
|
94
|
-
name: repo.name,
|
|
95
|
-
des: `${packageManager} link ${depMeta.packageName} failed`
|
|
96
|
-
});
|
|
97
|
-
console.error(color.red + `${repo.name}: ${packageManager} link ${depMeta.packageName} failed` + color.reset)
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
}
|
|
101
|
-
catch (err) {
|
|
102
|
-
failed.push({ name: repo.packageName, des: err.message })
|
|
103
|
-
console.error(color.red + `${err}` + color.reset)
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
}
|
|
107
|
-
}
|
package/src/commands/symlink.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
const fs = require('fs')
|
|
2
2
|
const path = require("path")
|
|
3
|
-
const util = require('node:util');
|
|
4
3
|
const spawn = require('../spawn');
|
|
5
4
|
|
|
6
5
|
const cwdPath = path.resolve(process.cwd());
|
|
@@ -9,7 +8,7 @@ let cwdNodeModulesPath = path.resolve(cwdPath, 'node_modules')
|
|
|
9
8
|
|
|
10
9
|
let reposLength, failed = [];
|
|
11
10
|
|
|
12
|
-
module.exports = async function
|
|
11
|
+
module.exports = async function (repos, args) {
|
|
13
12
|
reposLength = repos.length
|
|
14
13
|
|
|
15
14
|
for (let i = 0; i < repos.length; i++) {
|
|
@@ -25,6 +24,10 @@ module.exports = async function symlink(repos, args) {
|
|
|
25
24
|
}
|
|
26
25
|
|
|
27
26
|
}
|
|
27
|
+
|
|
28
|
+
console.log('symlink complete');
|
|
29
|
+
return failed;
|
|
30
|
+
|
|
28
31
|
}
|
|
29
32
|
|
|
30
33
|
|
|
@@ -39,8 +42,6 @@ async function createSymlink(repo) {
|
|
|
39
42
|
try {
|
|
40
43
|
let dest = path.resolve(dpath, 'node_modules');
|
|
41
44
|
if (dest) {
|
|
42
|
-
// let exists = await fs.promises.access(filePath, fs.constants.F_OK);
|
|
43
|
-
|
|
44
45
|
if (fs.existsSync(dest)) {
|
|
45
46
|
|
|
46
47
|
if (!cwdNodeModulesPath.includes('/CoCreateJS')) {
|
|
@@ -53,18 +54,10 @@ async function createSymlink(repo) {
|
|
|
53
54
|
}
|
|
54
55
|
}
|
|
55
56
|
}
|
|
57
|
+
}
|
|
56
58
|
|
|
57
|
-
|
|
58
|
-
if (err) {
|
|
59
|
-
failed.push({ name: 'symlink', des: 'with response:' + response, err })
|
|
60
|
-
console.error(repo.name, 'failed to aquire symlink', 'with response:', response, err)
|
|
59
|
+
await symlink(repo.name, dest)
|
|
61
60
|
|
|
62
|
-
} else
|
|
63
|
-
runSymlink(repo.name, dest)
|
|
64
|
-
});
|
|
65
|
-
} else {
|
|
66
|
-
runSymlink(repo.name, dest)
|
|
67
|
-
}
|
|
68
61
|
}
|
|
69
62
|
}
|
|
70
63
|
catch (err) {
|
|
@@ -74,23 +67,18 @@ async function createSymlink(repo) {
|
|
|
74
67
|
|
|
75
68
|
}
|
|
76
69
|
|
|
77
|
-
function
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
if (err)
|
|
82
|
-
console.log(err);
|
|
83
|
-
else {
|
|
84
|
-
console.log(name, "node_modules symlink added");
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
if (!reposLength) {
|
|
88
|
-
console.log('symlink complete')
|
|
89
|
-
return failed
|
|
90
|
-
}
|
|
70
|
+
async function symlink(name, dest) {
|
|
71
|
+
try {
|
|
72
|
+
if (fs.existsSync(dest))
|
|
73
|
+
await fs.promises.rm(dest, { recursive: true, force: true });
|
|
91
74
|
|
|
92
|
-
|
|
75
|
+
await fs.promises.symlink(cwdNodeModulesPath, dest, 'dir');
|
|
76
|
+
console.log(name, 'node_modules symlink added');
|
|
93
77
|
|
|
78
|
+
} catch (err) {
|
|
79
|
+
failed.push({ name: 'symlink', des: 'with response: ' + response, err });
|
|
80
|
+
console.error(repo.name, 'failed to acquire symlink', 'with response:', response, err);
|
|
81
|
+
}
|
|
94
82
|
}
|
|
95
83
|
|
|
96
84
|
|
|
@@ -145,3 +133,4 @@ async function getSymlinkTargetPath(symlinkPath) {
|
|
|
145
133
|
}
|
|
146
134
|
}
|
|
147
135
|
|
|
136
|
+
// module.exports = { symlink }
|
package/check-coc.js
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
const { execSync } = require('child_process');
|
|
2
|
-
|
|
3
|
-
try {
|
|
4
|
-
// Try to run "coc" command
|
|
5
|
-
execSync('coc --version', { stdio: 'ignore' });
|
|
6
|
-
console.log('"coc" is already installed globally.');
|
|
7
|
-
} catch (error) {
|
|
8
|
-
// If "coc" command does not exist, install it globally
|
|
9
|
-
console.log('"coc" command not found. Installing globally...');
|
|
10
|
-
try {
|
|
11
|
-
execSync('npm install -g @cocreate/cli', { stdio: 'inherit' });
|
|
12
|
-
console.log('"coc" has been installed globally.');
|
|
13
|
-
} catch (error) {
|
|
14
|
-
console.error('Failed to install "coc" globally:', error);
|
|
15
|
-
}
|
|
16
|
-
}
|