@cocreate/cli 1.28.4 → 1.29.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/.github/FUNDING.yml +3 -3
- package/.github/workflows/automated.yml +55 -55
- package/CHANGELOG.md +20 -0
- package/CONTRIBUTING.md +96 -96
- package/CoCreate.config.js +26 -26
- package/LICENSE +21 -21
- package/README.md +76 -76
- package/docs/index.html +242 -67
- package/package.json +1 -1
- package/release.config.js +21 -21
- package/repositories.js +475 -475
- package/src/addMeta.js +74 -74
- package/src/coc.js +80 -80
- package/src/commands/bump.js +85 -85
- package/src/commands/clone.js +2 -2
- package/src/commands/fs/automated.js +141 -141
- package/src/commands/fs/bump.js +74 -74
- package/src/commands/fs/config.js +78 -78
- package/src/commands/fs/contribution.js +136 -136
- package/src/commands/fs/gitignore.js +40 -40
- package/src/commands/fs/icon-extract.js +31 -31
- package/src/commands/fs/manual.js +91 -91
- package/src/commands/fs/package.js +39 -39
- package/src/commands/fs/readme.js +138 -138
- package/src/commands/fs/remove.js +28 -28
- package/src/commands/fs/replace.js +42 -42
- package/src/commands/fs/webpack.js +191 -191
- package/src/commands/git/gitConfig.js +70 -70
- package/src/commands/gitConfig.js +72 -72
- package/src/commands/install.js +24 -24
- package/src/commands/link.js +107 -107
- package/src/commands/nginx.js +25 -25
- package/src/commands/other/add.js +63 -63
- package/src/commands/other/config.sh +4 -4
- package/src/commands/other/nginxConfigManager.js +137 -137
- package/src/commands/other/nodeCertManager.js +147 -147
- package/src/commands/other/symlinkPwa.js +38 -38
- package/src/commands/other/test.js +43 -43
- package/src/commands/other/updateModules.js +50 -50
- package/src/commands/symlink.js +113 -111
- package/src/execute.js +66 -66
- package/src/spawn.js +9 -9
- package/webpack.config.js +84 -84
|
@@ -1,43 +1,43 @@
|
|
|
1
|
-
const { spawn, exec } = require('child_process');
|
|
2
|
-
var child = spawn('npm', ['login'], {stdio: [ 'pipe', 'pipe', 'pipe' ], shell: true });
|
|
3
|
-
// var child = exec('npm login');
|
|
4
|
-
|
|
5
|
-
process.stdout.pipe(child.stdout);
|
|
6
|
-
process.stderr.pipe(child.stderr);
|
|
7
|
-
process.stdin.pipe(child.stdin);
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
child.stdout.on('data', function (data) {
|
|
11
|
-
// exec('\n')
|
|
12
|
-
// console.log('stdout: ' + data, '\n\n\n\n\n\n\n');
|
|
13
|
-
child.stdin.write('newwrite\n'); //my command takes a markdown string...
|
|
14
|
-
child.stdin.end('newend\n');
|
|
15
|
-
// process.stdout.pipe(child.stdout);
|
|
16
|
-
// process.stderr.pipe(child.stderr);
|
|
17
|
-
// process.stdin.pipe(child.stdin);
|
|
18
|
-
process.stdin.write('test\n');
|
|
19
|
-
process.stdin.end('test\n');
|
|
20
|
-
|
|
21
|
-
});
|
|
22
|
-
// console.log(child)
|
|
23
|
-
// child.stdout.pipe(process.stdout);
|
|
24
|
-
// child.stderr.pipe(process.stderr);
|
|
25
|
-
// process.stdin.pipe(child.stdin);
|
|
26
|
-
|
|
27
|
-
child.on('exit', () => {
|
|
28
|
-
console.log('exiting')
|
|
29
|
-
process.exit()
|
|
30
|
-
})
|
|
31
|
-
|
|
32
|
-
child.on('close', (code) => {
|
|
33
|
-
console.log(`Child process exited with code ${code}.`);
|
|
34
|
-
});
|
|
35
|
-
child.on('spawn', (code) => {
|
|
36
|
-
console.log(`Child process spawn with code ${code}.`);
|
|
37
|
-
});
|
|
38
|
-
child.on('message', (code) => {
|
|
39
|
-
console.log(`Child process message with code ${code}.`);
|
|
40
|
-
});
|
|
41
|
-
child.on('disconnect', (code) => {
|
|
42
|
-
console.log(`Child process disconnect with code ${code}.`);
|
|
43
|
-
});
|
|
1
|
+
const { spawn, exec } = require('child_process');
|
|
2
|
+
var child = spawn('npm', ['login'], {stdio: [ 'pipe', 'pipe', 'pipe' ], shell: true });
|
|
3
|
+
// var child = exec('npm login');
|
|
4
|
+
|
|
5
|
+
process.stdout.pipe(child.stdout);
|
|
6
|
+
process.stderr.pipe(child.stderr);
|
|
7
|
+
process.stdin.pipe(child.stdin);
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
child.stdout.on('data', function (data) {
|
|
11
|
+
// exec('\n')
|
|
12
|
+
// console.log('stdout: ' + data, '\n\n\n\n\n\n\n');
|
|
13
|
+
child.stdin.write('newwrite\n'); //my command takes a markdown string...
|
|
14
|
+
child.stdin.end('newend\n');
|
|
15
|
+
// process.stdout.pipe(child.stdout);
|
|
16
|
+
// process.stderr.pipe(child.stderr);
|
|
17
|
+
// process.stdin.pipe(child.stdin);
|
|
18
|
+
process.stdin.write('test\n');
|
|
19
|
+
process.stdin.end('test\n');
|
|
20
|
+
|
|
21
|
+
});
|
|
22
|
+
// console.log(child)
|
|
23
|
+
// child.stdout.pipe(process.stdout);
|
|
24
|
+
// child.stderr.pipe(process.stderr);
|
|
25
|
+
// process.stdin.pipe(child.stdin);
|
|
26
|
+
|
|
27
|
+
child.on('exit', () => {
|
|
28
|
+
console.log('exiting')
|
|
29
|
+
process.exit()
|
|
30
|
+
})
|
|
31
|
+
|
|
32
|
+
child.on('close', (code) => {
|
|
33
|
+
console.log(`Child process exited with code ${code}.`);
|
|
34
|
+
});
|
|
35
|
+
child.on('spawn', (code) => {
|
|
36
|
+
console.log(`Child process spawn with code ${code}.`);
|
|
37
|
+
});
|
|
38
|
+
child.on('message', (code) => {
|
|
39
|
+
console.log(`Child process message with code ${code}.`);
|
|
40
|
+
});
|
|
41
|
+
child.on('disconnect', (code) => {
|
|
42
|
+
console.log(`Child process disconnect with code ${code}.`);
|
|
43
|
+
});
|
|
@@ -1,51 +1,51 @@
|
|
|
1
|
-
async function updateModules() {
|
|
2
|
-
|
|
3
|
-
let data = await CoCreate.crud.readDocument({
|
|
4
|
-
collection: ['modules'],
|
|
5
|
-
})
|
|
6
|
-
|
|
7
|
-
if (data && data.document && data.document.length) {
|
|
8
|
-
for (let document of data.document) {
|
|
9
|
-
let isUpdateable = false
|
|
10
|
-
if (document.icon) {
|
|
11
|
-
console.log(document.icon)
|
|
12
|
-
let name = document.icon
|
|
13
|
-
if (name.includes('fa fa-'))
|
|
14
|
-
name = name.substring(16).replace('"></i>', "")
|
|
15
|
-
else
|
|
16
|
-
name = name.substring(17).replace('"></i>', "")
|
|
17
|
-
console.log(name)
|
|
18
|
-
if (name) {
|
|
19
|
-
document.icon = name
|
|
20
|
-
let updateDocument = await CoCreate.crud.updateDocument({
|
|
21
|
-
collection: ['modules'],
|
|
22
|
-
document
|
|
23
|
-
})
|
|
24
|
-
console.log(updateDocument)
|
|
25
|
-
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
// let keys = ['navbar-menu-primary', 'navbar-menu-secondary', 'main-menu-primary', 'main-menu-secondary', 'settings-menu-primary', 'settings-menu-secondary']
|
|
29
|
-
// for (let key of keys) {
|
|
30
|
-
// if (document[key] && document[key].path) {
|
|
31
|
-
// let parts = document[key].path.split('/')
|
|
32
|
-
// let name = parts.pop()
|
|
33
|
-
// let parentDirectory = parts.pop()
|
|
34
|
-
// if (!name)
|
|
35
|
-
// continue
|
|
36
|
-
// console.log(name, parentDirectory)
|
|
37
|
-
// document[key].name = name
|
|
38
|
-
// document[key].parentDirectory = parentDirectory || ''
|
|
39
|
-
// isUpdateable = true
|
|
40
|
-
// }
|
|
41
|
-
// }
|
|
42
|
-
// if (isUpdateable) {
|
|
43
|
-
// let updateDocument = await CoCreate.crud.updateDocument({
|
|
44
|
-
// collection: ['modules'],
|
|
45
|
-
// document
|
|
46
|
-
// })
|
|
47
|
-
// console.log(updateDocument)
|
|
48
|
-
// }
|
|
49
|
-
}
|
|
50
|
-
}
|
|
1
|
+
async function updateModules() {
|
|
2
|
+
|
|
3
|
+
let data = await CoCreate.crud.readDocument({
|
|
4
|
+
collection: ['modules'],
|
|
5
|
+
})
|
|
6
|
+
|
|
7
|
+
if (data && data.document && data.document.length) {
|
|
8
|
+
for (let document of data.document) {
|
|
9
|
+
let isUpdateable = false
|
|
10
|
+
if (document.icon) {
|
|
11
|
+
console.log(document.icon)
|
|
12
|
+
let name = document.icon
|
|
13
|
+
if (name.includes('fa fa-'))
|
|
14
|
+
name = name.substring(16).replace('"></i>', "")
|
|
15
|
+
else
|
|
16
|
+
name = name.substring(17).replace('"></i>', "")
|
|
17
|
+
console.log(name)
|
|
18
|
+
if (name) {
|
|
19
|
+
document.icon = name
|
|
20
|
+
let updateDocument = await CoCreate.crud.updateDocument({
|
|
21
|
+
collection: ['modules'],
|
|
22
|
+
document
|
|
23
|
+
})
|
|
24
|
+
console.log(updateDocument)
|
|
25
|
+
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
// let keys = ['navbar-menu-primary', 'navbar-menu-secondary', 'main-menu-primary', 'main-menu-secondary', 'settings-menu-primary', 'settings-menu-secondary']
|
|
29
|
+
// for (let key of keys) {
|
|
30
|
+
// if (document[key] && document[key].path) {
|
|
31
|
+
// let parts = document[key].path.split('/')
|
|
32
|
+
// let name = parts.pop()
|
|
33
|
+
// let parentDirectory = parts.pop()
|
|
34
|
+
// if (!name)
|
|
35
|
+
// continue
|
|
36
|
+
// console.log(name, parentDirectory)
|
|
37
|
+
// document[key].name = name
|
|
38
|
+
// document[key].parentDirectory = parentDirectory || ''
|
|
39
|
+
// isUpdateable = true
|
|
40
|
+
// }
|
|
41
|
+
// }
|
|
42
|
+
// if (isUpdateable) {
|
|
43
|
+
// let updateDocument = await CoCreate.crud.updateDocument({
|
|
44
|
+
// collection: ['modules'],
|
|
45
|
+
// document
|
|
46
|
+
// })
|
|
47
|
+
// console.log(updateDocument)
|
|
48
|
+
// }
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
51
|
}
|
package/src/commands/symlink.js
CHANGED
|
@@ -1,111 +1,113 @@
|
|
|
1
|
-
const fs = require('fs')
|
|
2
|
-
const path = require("path")
|
|
3
|
-
const util = require('node:util');
|
|
4
|
-
const spawn = require('../spawn');
|
|
5
|
-
|
|
6
|
-
const cwdPath = path.resolve(process.cwd());
|
|
7
|
-
let cwdNodeModulesPath = path.resolve(cwdPath, 'node_modules')
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
let reposLength, failed = [];
|
|
11
|
-
|
|
12
|
-
module.exports = async function symlink(repos, args) {
|
|
13
|
-
reposLength = repos.length
|
|
14
|
-
|
|
15
|
-
for (let i = 0; i < repos.length; i++) {
|
|
16
|
-
|
|
17
|
-
if (cwdPath === repos[i].absolutePath && !fs.existsSync(cwdNodeModulesPath)) {
|
|
18
|
-
await install(repos[i], repos)
|
|
19
|
-
reposLength -= 1
|
|
20
|
-
} else if (repos[i].install == true) {
|
|
21
|
-
reposLength -= 1
|
|
22
|
-
await install(repos[i], repos)
|
|
23
|
-
} else if (cwdPath !== repos[i].absolutePath) {
|
|
24
|
-
await createSymlink(repos[i])
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
async function createSymlink(repo) {
|
|
32
|
-
let dpath = path.resolve(repo.absolutePath);
|
|
33
|
-
if (!fs.existsSync(dpath)) {
|
|
34
|
-
failed.push({name: 'createSymlink', des: 'path doesn\'t exist:' + dpath})
|
|
35
|
-
return console.error(dpath, 'not exist')
|
|
36
|
-
}
|
|
37
|
-
let response = ''
|
|
38
|
-
|
|
39
|
-
try {
|
|
40
|
-
let dest = path.resolve(dpath, 'node_modules');
|
|
41
|
-
if (dest) {
|
|
42
|
-
if (fs.existsSync(dest)) {
|
|
43
|
-
fs.rm(dest, { recursive: true, force: true }, function (err) {
|
|
44
|
-
if (err) {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
console.
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
}
|
|
1
|
+
const fs = require('fs')
|
|
2
|
+
const path = require("path")
|
|
3
|
+
const util = require('node:util');
|
|
4
|
+
const spawn = require('../spawn');
|
|
5
|
+
|
|
6
|
+
const cwdPath = path.resolve(process.cwd());
|
|
7
|
+
let cwdNodeModulesPath = path.resolve(cwdPath, 'node_modules')
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
let reposLength, failed = [];
|
|
11
|
+
|
|
12
|
+
module.exports = async function symlink(repos, args) {
|
|
13
|
+
reposLength = repos.length
|
|
14
|
+
|
|
15
|
+
for (let i = 0; i < repos.length; i++) {
|
|
16
|
+
|
|
17
|
+
if (cwdPath === repos[i].absolutePath && !fs.existsSync(cwdNodeModulesPath)) {
|
|
18
|
+
await install(repos[i], repos)
|
|
19
|
+
reposLength -= 1
|
|
20
|
+
} else if (repos[i].install == true) {
|
|
21
|
+
reposLength -= 1
|
|
22
|
+
await install(repos[i], repos)
|
|
23
|
+
} else if (cwdPath !== repos[i].absolutePath) {
|
|
24
|
+
await createSymlink(repos[i])
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
async function createSymlink(repo) {
|
|
32
|
+
let dpath = path.resolve(repo.absolutePath);
|
|
33
|
+
if (!fs.existsSync(dpath)) {
|
|
34
|
+
failed.push({ name: 'createSymlink', des: 'path doesn\'t exist:' + dpath })
|
|
35
|
+
return console.error(dpath, 'not exist')
|
|
36
|
+
}
|
|
37
|
+
let response = ''
|
|
38
|
+
|
|
39
|
+
try {
|
|
40
|
+
let dest = path.resolve(dpath, 'node_modules');
|
|
41
|
+
if (dest) {
|
|
42
|
+
if (fs.existsSync(dest)) {
|
|
43
|
+
fs.rm(dest, { recursive: true, force: true }, function (err) {
|
|
44
|
+
if (err) {
|
|
45
|
+
failed.push({ name: 'symlink', des: 'with response:' + response, err })
|
|
46
|
+
console.error(repo.name, 'failed to aquire symlink', 'with response:', response, err)
|
|
47
|
+
|
|
48
|
+
} else
|
|
49
|
+
runSymlink(repo.name, dest)
|
|
50
|
+
});
|
|
51
|
+
} else {
|
|
52
|
+
runSymlink(repo.name, dest)
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
catch (err) {
|
|
57
|
+
failed.push({ name: 'symlink', des: 'with response:' + response + err })
|
|
58
|
+
console.error(repo.name, 'failed to aquire symlink', 'with response:', response, err)
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
function runSymlink(name, dest) {
|
|
64
|
+
fs.symlink(cwdNodeModulesPath, dest, 'dir', (err) => {
|
|
65
|
+
reposLength -= 1
|
|
66
|
+
|
|
67
|
+
if (err)
|
|
68
|
+
console.log(err);
|
|
69
|
+
else {
|
|
70
|
+
console.log(name, "node_modules symlink added");
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
if (!reposLength) {
|
|
74
|
+
console.log('symlink complete')
|
|
75
|
+
return failed
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
})
|
|
79
|
+
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
async function install(repo, repos) {
|
|
84
|
+
let dpath = repo.absolutePath
|
|
85
|
+
if (!fs.existsSync(dpath)) {
|
|
86
|
+
failed.push({ name: 'install', des: 'path doesn\'t exist:' + dpath })
|
|
87
|
+
return console.error(dpath, 'not exist')
|
|
88
|
+
}
|
|
89
|
+
try {
|
|
90
|
+
console.log('installing', repo.name)
|
|
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
|
+
console.log(`${repo.name}: ${repo.packageManager} install succesful`.green)
|
|
105
|
+
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
}
|
|
109
|
+
catch (err) {
|
|
110
|
+
console.error(repo.name, 'did not install', err)
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
}
|
package/src/execute.js
CHANGED
|
@@ -1,66 +1,66 @@
|
|
|
1
|
-
const colors = require('colors');
|
|
2
|
-
const path = require("path");
|
|
3
|
-
const fs = require("fs");
|
|
4
|
-
const spawn = require('./spawn');
|
|
5
|
-
const util = require('node:util');
|
|
6
|
-
const exec = util.promisify(require('node:child_process').exec);
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
module.exports = async function execute(command, repos = [], config) {
|
|
10
|
-
let failed = [];
|
|
11
|
-
let args = command.replaceAll("'", '"').trim().split(' ')
|
|
12
|
-
let type = args[0]
|
|
13
|
-
args.shift()
|
|
14
|
-
|
|
15
|
-
let predefined = path.resolve(__dirname, 'commands', type + '.js');
|
|
16
|
-
|
|
17
|
-
if (fs.existsSync(predefined)) {
|
|
18
|
-
console.warn(`executing a predefined command in ${predefined}`.blue);
|
|
19
|
-
|
|
20
|
-
if (repos.length == 1)
|
|
21
|
-
console.log(`running on ${repos[0].name} repo`.blue)
|
|
22
|
-
else if (repos.length)
|
|
23
|
-
console.log('running on all repos'.blue)
|
|
24
|
-
|
|
25
|
-
failed = require(predefined)(repos, args)
|
|
26
|
-
|
|
27
|
-
} else {
|
|
28
|
-
|
|
29
|
-
for (let repo of repos) {
|
|
30
|
-
try {
|
|
31
|
-
if (repo.exclude && repo.exclude.includes(type))
|
|
32
|
-
continue
|
|
33
|
-
console.log(`${repo.name}: `.green, command)
|
|
34
|
-
let exitCode;
|
|
35
|
-
if (config.hideMessage) {
|
|
36
|
-
const { error } = await exec(command, {
|
|
37
|
-
cwd: repo.absolutePath,
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
if (error)
|
|
41
|
-
exitCode = 1
|
|
42
|
-
} else {
|
|
43
|
-
exitCode = await spawn(type, args, {
|
|
44
|
-
cwd: repo.absolutePath,
|
|
45
|
-
shell: true,
|
|
46
|
-
stdio: 'inherit'
|
|
47
|
-
})
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
if (exitCode !== 0)
|
|
51
|
-
failed.push({
|
|
52
|
-
name: repo.name,
|
|
53
|
-
des: 'command failed: ' + command
|
|
54
|
-
})
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
}
|
|
58
|
-
catch (err) {
|
|
59
|
-
console.error(`an error occured executing command in ${repo.name} repository`.red, err.message);;
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
return failed;
|
|
65
|
-
|
|
66
|
-
}
|
|
1
|
+
const colors = require('colors');
|
|
2
|
+
const path = require("path");
|
|
3
|
+
const fs = require("fs");
|
|
4
|
+
const spawn = require('./spawn');
|
|
5
|
+
const util = require('node:util');
|
|
6
|
+
const exec = util.promisify(require('node:child_process').exec);
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
module.exports = async function execute(command, repos = [], config) {
|
|
10
|
+
let failed = [];
|
|
11
|
+
let args = command.replaceAll("'", '"').trim().split(' ')
|
|
12
|
+
let type = args[0]
|
|
13
|
+
args.shift()
|
|
14
|
+
|
|
15
|
+
let predefined = path.resolve(__dirname, 'commands', type + '.js');
|
|
16
|
+
|
|
17
|
+
if (fs.existsSync(predefined)) {
|
|
18
|
+
console.warn(`executing a predefined command in ${predefined}`.blue);
|
|
19
|
+
|
|
20
|
+
if (repos.length == 1)
|
|
21
|
+
console.log(`running on ${repos[0].name} repo`.blue)
|
|
22
|
+
else if (repos.length)
|
|
23
|
+
console.log('running on all repos'.blue)
|
|
24
|
+
|
|
25
|
+
failed = require(predefined)(repos, args)
|
|
26
|
+
|
|
27
|
+
} else {
|
|
28
|
+
|
|
29
|
+
for (let repo of repos) {
|
|
30
|
+
try {
|
|
31
|
+
if (repo.exclude && repo.exclude.includes(type))
|
|
32
|
+
continue
|
|
33
|
+
console.log(`${repo.name}: `.green, command)
|
|
34
|
+
let exitCode;
|
|
35
|
+
if (config.hideMessage) {
|
|
36
|
+
const { error } = await exec(command, {
|
|
37
|
+
cwd: repo.absolutePath,
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
if (error)
|
|
41
|
+
exitCode = 1
|
|
42
|
+
} else {
|
|
43
|
+
exitCode = await spawn(type, args, {
|
|
44
|
+
cwd: repo.absolutePath,
|
|
45
|
+
shell: true,
|
|
46
|
+
stdio: 'inherit'
|
|
47
|
+
})
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
if (exitCode !== 0)
|
|
51
|
+
failed.push({
|
|
52
|
+
name: repo.name,
|
|
53
|
+
des: 'command failed: ' + command
|
|
54
|
+
})
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
}
|
|
58
|
+
catch (err) {
|
|
59
|
+
console.error(`an error occured executing command in ${repo.name} repository`.red, err.message);;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
return failed;
|
|
65
|
+
|
|
66
|
+
}
|
package/src/spawn.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
const child_process = require('child_process');
|
|
2
|
-
const spawn = child_process.spawn;
|
|
3
|
-
module.exports = async function spawnPromise() {
|
|
4
|
-
let proc = spawn.apply(child_process, arguments);
|
|
5
|
-
return new Promise((resolve, reject) => {
|
|
6
|
-
proc.on('error', (err) => reject(err))
|
|
7
|
-
proc.on('close', (code) => resolve(code));
|
|
8
|
-
})
|
|
9
|
-
}
|
|
1
|
+
const child_process = require('child_process');
|
|
2
|
+
const spawn = child_process.spawn;
|
|
3
|
+
module.exports = async function spawnPromise() {
|
|
4
|
+
let proc = spawn.apply(child_process, arguments);
|
|
5
|
+
return new Promise((resolve, reject) => {
|
|
6
|
+
proc.on('error', (err) => reject(err))
|
|
7
|
+
proc.on('close', (code) => resolve(code));
|
|
8
|
+
})
|
|
9
|
+
}
|