@cocreate/cli 1.31.2 → 1.32.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/.github/workflows/automated.yml +38 -15
- package/CHANGELOG.md +8 -0
- package/CoCreate.config.js +472 -0
- package/package.json +1 -4
- package/src/coc.js +12 -11
- package/src/commands/bump.js +7 -8
- package/src/commands/link.js +12 -12
- package/src/commands/other/add.js +21 -22
- package/src/execute.js +10 -11
- package/src/fonts.js +42 -0
- package/repositories.js +0 -471
package/src/commands/bump.js
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
let fs = require('fs');
|
|
2
2
|
const path = require("path")
|
|
3
|
-
const colors = require('colors');
|
|
4
3
|
const util = require('node:util');
|
|
5
4
|
const exec = util.promisify(require('node:child_process').exec);
|
|
6
|
-
|
|
5
|
+
const { color } = require('./fonts');
|
|
7
6
|
|
|
8
7
|
let pathList, nameList, item = {}, failed = [];
|
|
9
8
|
|
|
@@ -55,15 +54,15 @@ function getVersions(filePath) {
|
|
|
55
54
|
item[object.name] = `^${object.version}`
|
|
56
55
|
}
|
|
57
56
|
} else {
|
|
58
|
-
failed.push({name: 'get version', des: 'path doesn\'t exist:' + filePath})
|
|
57
|
+
failed.push({ name: 'get version', des: 'path doesn\'t exist:' + filePath })
|
|
59
58
|
}
|
|
60
59
|
}
|
|
61
60
|
|
|
62
61
|
function bumpVersion(filePath, name) {
|
|
63
62
|
let object = require(filePath)
|
|
64
63
|
if (object) {
|
|
65
|
-
let newObject = {...object}
|
|
66
|
-
|
|
64
|
+
let newObject = { ...object }
|
|
65
|
+
|
|
67
66
|
if (!object.dependencies)
|
|
68
67
|
return console.log(name, 'not updated')
|
|
69
68
|
else {
|
|
@@ -73,13 +72,13 @@ function bumpVersion(filePath, name) {
|
|
|
73
72
|
}
|
|
74
73
|
}
|
|
75
74
|
|
|
76
|
-
if (fs.existsSync(filePath)){
|
|
75
|
+
if (fs.existsSync(filePath)) {
|
|
77
76
|
fs.unlinkSync(filePath)
|
|
78
77
|
}
|
|
79
|
-
|
|
78
|
+
|
|
80
79
|
fs.writeFileSync(filePath, JSON.stringify(object, null, 2))
|
|
81
80
|
}
|
|
82
81
|
} else {
|
|
83
|
-
failed.push({name: 'bump version', des: 'path doesn\'t exist:' + filePath})
|
|
82
|
+
failed.push({ name: 'bump version', des: 'path doesn\'t exist:' + filePath })
|
|
84
83
|
}
|
|
85
84
|
}
|
package/src/commands/link.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const spawn = require('../spawn');
|
|
2
|
-
const
|
|
2
|
+
const { color } = require('./fonts');
|
|
3
3
|
|
|
4
4
|
module.exports = async function linkPackages(repos, args) {
|
|
5
5
|
const failed = [], isLinked = {};
|
|
@@ -7,12 +7,12 @@ module.exports = async function linkPackages(repos, args) {
|
|
|
7
7
|
try {
|
|
8
8
|
for (let repo of repos) {
|
|
9
9
|
if (!repo) continue;
|
|
10
|
-
if (repo.exclude && repo.exclude.includes('link'))
|
|
10
|
+
if (repo.exclude && repo.exclude.includes('link'))
|
|
11
11
|
continue
|
|
12
12
|
|
|
13
13
|
if (process.cwd() === repo.absolutePath)
|
|
14
14
|
continue
|
|
15
|
-
|
|
15
|
+
|
|
16
16
|
let exitCode = await spawn(repo.packageManager, ['link'], {
|
|
17
17
|
cwd: repo.absolutePath,
|
|
18
18
|
shell: true,
|
|
@@ -24,7 +24,7 @@ module.exports = async function linkPackages(repos, args) {
|
|
|
24
24
|
name: repo.name,
|
|
25
25
|
des: `${repo.packageManager} link failed`
|
|
26
26
|
})
|
|
27
|
-
console.error(`${repo.name}: ${repo.packageManager} link failed
|
|
27
|
+
console.error(color.red + `${repo.name}: ${repo.packageManager} link failed` + color.reset)
|
|
28
28
|
} else {
|
|
29
29
|
console.log(repo.packageManager, 'link', repo.packageName)
|
|
30
30
|
|
|
@@ -36,9 +36,9 @@ module.exports = async function linkPackages(repos, args) {
|
|
|
36
36
|
if (exitCode !== 0) {
|
|
37
37
|
failed.push({
|
|
38
38
|
name: repo.name,
|
|
39
|
-
des: `${
|
|
39
|
+
des: `${repo.packageManager} link ${repo.packageName} failed`
|
|
40
40
|
});
|
|
41
|
-
console.error(`${repo.name}: ${
|
|
41
|
+
console.error(color.red + `${repo.name}: ${repo.packageManager} link ${repo.packageName} failed` + color.reset)
|
|
42
42
|
}
|
|
43
43
|
}
|
|
44
44
|
|
|
@@ -48,7 +48,7 @@ module.exports = async function linkPackages(repos, args) {
|
|
|
48
48
|
}
|
|
49
49
|
catch (err) {
|
|
50
50
|
failed.push({ name: 'GENERAL', des: err.message })
|
|
51
|
-
console.error(`${err}
|
|
51
|
+
console.error(color.red + `${err}` + color.reset)
|
|
52
52
|
}
|
|
53
53
|
|
|
54
54
|
return failed;
|
|
@@ -70,18 +70,18 @@ async function doLink(deps, repo, repos, failed, isLinked) {
|
|
|
70
70
|
shell: true,
|
|
71
71
|
stdio: 'inherit'
|
|
72
72
|
});
|
|
73
|
-
|
|
73
|
+
|
|
74
74
|
if (exitCode !== 0) {
|
|
75
75
|
failed.push({
|
|
76
76
|
name: depMeta.name,
|
|
77
77
|
des: `${packageManager} link failed`
|
|
78
78
|
})
|
|
79
|
-
console.error(`${depMeta.name}: ${packageManager} link failed
|
|
79
|
+
console.error(color.red + `${depMeta.name}: ${packageManager} link failed` + color.reset)
|
|
80
80
|
}
|
|
81
81
|
}
|
|
82
82
|
|
|
83
83
|
if (!depMeta)
|
|
84
|
-
depMeta = {packageName: dep}
|
|
84
|
+
depMeta = { packageName: dep }
|
|
85
85
|
console.log(repo.packageName, 'linking', depMeta.packageName, '...')
|
|
86
86
|
|
|
87
87
|
let exitCode = await spawn(packageManager, ['link', depMeta.packageName], {
|
|
@@ -94,13 +94,13 @@ async function doLink(deps, repo, repos, failed, isLinked) {
|
|
|
94
94
|
name: repo.name,
|
|
95
95
|
des: `${packageManager} link ${depMeta.packageName} failed`
|
|
96
96
|
});
|
|
97
|
-
console.error(`${repo.name}: ${packageManager} link ${depMeta.packageName} failed
|
|
97
|
+
console.error(color.red + `${repo.name}: ${packageManager} link ${depMeta.packageName} failed` + color.reset)
|
|
98
98
|
}
|
|
99
99
|
|
|
100
100
|
}
|
|
101
101
|
catch (err) {
|
|
102
102
|
failed.push({ name: repo.packageName, des: err.message })
|
|
103
|
-
console.error(`${err}
|
|
103
|
+
console.error(color.red + `${err}` + color.reset)
|
|
104
104
|
}
|
|
105
105
|
|
|
106
106
|
}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
const fs = require('fs')
|
|
2
2
|
const path = require("path")
|
|
3
3
|
const spawn = require('../../spawn');
|
|
4
|
-
const colors = require('colors');
|
|
5
4
|
const addMeta = require('../../addMeta');
|
|
6
5
|
|
|
7
6
|
|
|
@@ -32,32 +31,32 @@ module.exports = async function updateYarnLink(repos, args) {
|
|
|
32
31
|
|
|
33
32
|
|
|
34
33
|
async function reAdd(deps, repo, failed, param = '') {
|
|
35
|
-
|
|
36
|
-
|
|
34
|
+
try {
|
|
35
|
+
if (!deps.length)
|
|
37
36
|
return;
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
failed.push({
|
|
48
|
-
name: repo.name,
|
|
49
|
-
des: `yarn ${param} ${packageListLog}`
|
|
50
|
-
})
|
|
51
|
-
console.error(`${repo.name}: yarn ${param} ${packageListLog}`.red)
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
catch (err) {
|
|
37
|
+
deps.unshift("add")
|
|
38
|
+
let packageList = deps;
|
|
39
|
+
let packageListLog = deps.join(' ');
|
|
40
|
+
console.log(color.green + `${repo.name}: ` + color.reset, `yarn ${packageListLog}`);
|
|
41
|
+
// let exitCode = await spawn(`yarn`, ['add', ...param && [param], packageList], {
|
|
42
|
+
let exitCode = await spawn('yarn', packageList, {
|
|
43
|
+
cwd: repo.absolutePath, stdio: 'inherit',
|
|
44
|
+
});
|
|
45
|
+
if (exitCode !== 0) {
|
|
55
46
|
failed.push({
|
|
56
47
|
name: repo.name,
|
|
57
|
-
des:
|
|
48
|
+
des: `yarn ${param} ${packageListLog}`
|
|
58
49
|
})
|
|
59
|
-
console.error(`${repo.name}: ${
|
|
50
|
+
console.error(color.red + `${repo.name}: yarn ${param} ${packageListLog}` + color.reset)
|
|
60
51
|
}
|
|
61
52
|
}
|
|
53
|
+
catch (err) {
|
|
54
|
+
failed.push({
|
|
55
|
+
name: repo.name,
|
|
56
|
+
des: err.message
|
|
57
|
+
})
|
|
58
|
+
console.error(color.red + `${repo.name}: ${err.message}` + color.reset)
|
|
59
|
+
}
|
|
60
|
+
}
|
|
62
61
|
|
|
63
62
|
|
package/src/execute.js
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
const colors = require('colors');
|
|
2
1
|
const path = require("path");
|
|
3
2
|
const fs = require("fs");
|
|
4
3
|
const spawn = require('./spawn');
|
|
5
4
|
const util = require('node:util');
|
|
6
5
|
const exec = util.promisify(require('node:child_process').exec);
|
|
7
|
-
|
|
6
|
+
const { color } = require('./fonts');
|
|
8
7
|
|
|
9
8
|
module.exports = async function execute(command, repos = [], config) {
|
|
10
9
|
let failed = [];
|
|
@@ -15,28 +14,28 @@ module.exports = async function execute(command, repos = [], config) {
|
|
|
15
14
|
let predefined = path.resolve(__dirname, 'commands', type + '.js');
|
|
16
15
|
|
|
17
16
|
if (fs.existsSync(predefined)) {
|
|
18
|
-
console.warn(`executing a predefined command in ${predefined}
|
|
19
|
-
|
|
17
|
+
console.warn(color.blue + `executing a predefined command in ${predefined}` + color.reset);
|
|
18
|
+
|
|
20
19
|
if (repos.length == 1)
|
|
21
|
-
console.log(`running on ${repos[0].name} repo
|
|
20
|
+
console.log(color.blue + `running on ${repos[0].name} repo` + color.reset)
|
|
22
21
|
else if (repos.length)
|
|
23
|
-
console.log('running on all repos'.
|
|
22
|
+
console.log(color.blue + 'running on all repos' + color.reset)
|
|
24
23
|
|
|
25
24
|
failed = require(predefined)(repos, args)
|
|
26
25
|
|
|
27
26
|
} else {
|
|
28
|
-
|
|
27
|
+
|
|
29
28
|
for (let repo of repos) {
|
|
30
29
|
try {
|
|
31
|
-
if (repo.exclude && repo.exclude.includes(type))
|
|
30
|
+
if (repo.exclude && repo.exclude.includes(type))
|
|
32
31
|
continue
|
|
33
|
-
console.log(`${repo.name}:
|
|
32
|
+
console.log(color.green + `${repo.name}: ` + color.reset, command)
|
|
34
33
|
let exitCode;
|
|
35
34
|
if (config.hideMessage) {
|
|
36
35
|
const { error } = await exec(command, {
|
|
37
36
|
cwd: repo.absolutePath,
|
|
38
37
|
});
|
|
39
|
-
|
|
38
|
+
|
|
40
39
|
if (error)
|
|
41
40
|
exitCode = 1
|
|
42
41
|
} else {
|
|
@@ -56,7 +55,7 @@ module.exports = async function execute(command, repos = [], config) {
|
|
|
56
55
|
|
|
57
56
|
}
|
|
58
57
|
catch (err) {
|
|
59
|
-
console.error(`an error occured executing command in ${repo.name} repository
|
|
58
|
+
console.error(color.red + `an error occured executing command in ${repo.name} repository` + color.reset, err.message);;
|
|
60
59
|
}
|
|
61
60
|
}
|
|
62
61
|
}
|
package/src/fonts.js
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
const color = {
|
|
2
|
+
black: '\x1b[30m',
|
|
3
|
+
red: '\x1b[31m',
|
|
4
|
+
green: '\x1b[32m',
|
|
5
|
+
yellow: '\x1b[33m',
|
|
6
|
+
blue: '\x1b[34m',
|
|
7
|
+
magenta: '\x1b[35m',
|
|
8
|
+
cyan: '\x1b[36m',
|
|
9
|
+
white: '\x1b[37m',
|
|
10
|
+
reset: '\x1b[39m',
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
const background = {
|
|
14
|
+
black: '\x1b[40m',
|
|
15
|
+
red: '\x1b[41m',
|
|
16
|
+
green: '\x1b[42m',
|
|
17
|
+
yellow: '\x1b[43m',
|
|
18
|
+
blue: '\x1b[44m',
|
|
19
|
+
magenta: '\x1b[45m',
|
|
20
|
+
cyan: '\x1b[46m',
|
|
21
|
+
white: '\x1b[47m',
|
|
22
|
+
reset: '\x1b[49m',
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
const font = {
|
|
26
|
+
underline: '\x1b[4m',
|
|
27
|
+
strikethrough: '\x1b[9m',
|
|
28
|
+
bold: '\x1b[1m',
|
|
29
|
+
italic: '\x1b[3m',
|
|
30
|
+
inverse: '\x1b[7m',
|
|
31
|
+
reset: '\x1b[0m',
|
|
32
|
+
link: '\x1b]8;;',
|
|
33
|
+
linkClose: '\x1b]8;;\x1b\\',
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
// console.log(color.blue + 'This text will be displayed in blue.' + font.reset);
|
|
37
|
+
// console.log(color.red + font.bold + 'This text will be displayed in bold red.' + font.reset);
|
|
38
|
+
// console.log(background.yellow + color.black + 'This text will have a yellow background and black text color.' + font.reset);
|
|
39
|
+
// console.log(font.link + 'https://example.com' + font.linkClose + 'Click here to visit the website');
|
|
40
|
+
// console.log(font.underline + color.green + 'Underlined green text.' + font.reset);
|
|
41
|
+
|
|
42
|
+
module.exports = { color, background, font }
|