cob-cli 2.33.0 → 2.34.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/bin/cob-cli.js +7 -0
- package/lib/commands/customize.js +4 -4
- package/lib/commands/getRepos.js +40 -0
- package/lib/webpack/webpack.config.js +3 -12
- package/package.json +1 -1
package/bin/cob-cli.js
CHANGED
|
@@ -5,6 +5,7 @@ require("./handleAutoComplete");
|
|
|
5
5
|
|
|
6
6
|
const program = require('commander');
|
|
7
7
|
|
|
8
|
+
const getRepos = require("../lib/commands/getRepos");
|
|
8
9
|
const init = require("../lib/commands/init");
|
|
9
10
|
const customize = require("../lib/commands/customize");
|
|
10
11
|
const test = require("../lib/commands/test");
|
|
@@ -20,6 +21,12 @@ program
|
|
|
20
21
|
.option('--setup','add autocomplete to system profiles')
|
|
21
22
|
.option('--cleanup', 'remove autocomplete from system profiles')
|
|
22
23
|
|
|
24
|
+
program
|
|
25
|
+
.command('getRepos')
|
|
26
|
+
.description('clone (or update) all cob accessible repositories on gitlab,')
|
|
27
|
+
.arguments('<token>', 'private token for gitlab (whit api read permission)')
|
|
28
|
+
.action( getRepos );
|
|
29
|
+
|
|
23
30
|
program
|
|
24
31
|
.command('init')
|
|
25
32
|
.usage("<servername>")
|
|
@@ -20,18 +20,18 @@ async function customize(filter, args) {
|
|
|
20
20
|
if (args.cache && (filter || args.local || args.update)) throw new Error("\nError: ".red + " incompatible options. Use --cache as single argument\n");
|
|
21
21
|
if (args.update && filter ) throw new Error("\nError: ".red + " incompatible options. Use --update without a <filter> \n");
|
|
22
22
|
|
|
23
|
+
if (!args.cache) checkRepoVersion();
|
|
24
|
+
if (!args.cache && !args.force) await checkWorkingCopyCleanliness();
|
|
25
|
+
|
|
23
26
|
const customizations = await getCustomizationsList(filter, args)
|
|
24
27
|
if(!args.local) {
|
|
25
28
|
await downloadCustomizationFiles(customizations,args)
|
|
26
|
-
// For --cache argument all work is done, just return
|
|
27
29
|
if(args.cache) {
|
|
28
30
|
console.log( colors.green("\nDone"), " - All configuration were downloaded to your local cache and you can now use the --local flag for any customization" );
|
|
31
|
+
// For --cache argument all work is done, just return
|
|
29
32
|
return
|
|
30
33
|
}
|
|
31
34
|
}
|
|
32
|
-
|
|
33
|
-
checkRepoVersion();
|
|
34
|
-
if (!args.force) await checkWorkingCopyCleanliness();
|
|
35
35
|
await applyCustomizations(customizations)
|
|
36
36
|
|
|
37
37
|
console.log( colors.green("\nDone"), "\nCheck changes to your git working tree and try:" );
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
const colors = require("colors");
|
|
2
|
+
const path = require("path");
|
|
3
|
+
const axios = require("axios");
|
|
4
|
+
const git = require("simple-git");
|
|
5
|
+
const fs = require("fs-extra");
|
|
6
|
+
|
|
7
|
+
async function getRepos(token) {
|
|
8
|
+
console.log("Clone/update all accessible repos ...");
|
|
9
|
+
|
|
10
|
+
try {
|
|
11
|
+
const response = await axios.get( "https://gitlab.com/api/v4/projects?membership=true\&private_token="+token+"\&search=server_", { headers: { Accept: "application/json", "Accept-Encoding": "identity" } } )
|
|
12
|
+
serverRepos = response.data
|
|
13
|
+
if (serverRepos.length == 0) throw new Error("\nError: ".red + " no server repo found\n");
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
const baseDir = process.cwd();
|
|
17
|
+
|
|
18
|
+
for (const serverRepo of serverRepos) {
|
|
19
|
+
if (!fs.existsSync(path.resolve(".",serverRepo.name))) {
|
|
20
|
+
console.log(" git clone " + serverRepo.ssh_url_to_repo);
|
|
21
|
+
await git().clone(serverRepo.ssh_url_to_repo);
|
|
22
|
+
|
|
23
|
+
} else {
|
|
24
|
+
console.log(" git pull " + serverRepo.ssh_url_to_repo);
|
|
25
|
+
process.chdir(serverRepo.name);
|
|
26
|
+
try {
|
|
27
|
+
await git().pull();
|
|
28
|
+
} catch (error) {
|
|
29
|
+
console.warn("Warning: ",serverRepo.name," -> ",error)
|
|
30
|
+
}
|
|
31
|
+
process.chdir(baseDir);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
console.log( colors.green("\nDone"));
|
|
36
|
+
} catch (err) {
|
|
37
|
+
console.error("\n", err.message);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
module.exports = getRepos;
|
|
@@ -23,21 +23,12 @@ module.exports = env => {
|
|
|
23
23
|
hot:false,
|
|
24
24
|
port: 8040,
|
|
25
25
|
host: "0.0.0.0",
|
|
26
|
-
devMiddleware: {
|
|
27
|
-
stats: {
|
|
28
|
-
maxModules: 0 // Set the maximum number of modules to be shown
|
|
29
|
-
}
|
|
30
|
-
},
|
|
31
26
|
setupMiddlewares: (middlewares, devServer) => {
|
|
32
|
-
middlewares.
|
|
33
|
-
name: '
|
|
34
|
-
// `path` is optional
|
|
35
|
-
path: '*',
|
|
27
|
+
middlewares.unshift({
|
|
28
|
+
name: 'redirect-localhost:8080/-to-localhost:8080/record/',
|
|
36
29
|
middleware: (req, res, next) => {
|
|
37
30
|
// Permite usar / ou /DASH_BOARD/ quando acedido directamente
|
|
38
|
-
if(req.url != "/")
|
|
39
|
-
return next();
|
|
40
|
-
}
|
|
31
|
+
if(req.url != "/") return next();
|
|
41
32
|
res.redirect(`/recordm/`);
|
|
42
33
|
},
|
|
43
34
|
});
|
package/package.json
CHANGED