cob-cli 2.34.0 → 2.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/lib/commands/getRepos.js
CHANGED
|
@@ -8,7 +8,7 @@ async function getRepos(token) {
|
|
|
8
8
|
console.log("Clone/update all accessible repos ...");
|
|
9
9
|
|
|
10
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" } } )
|
|
11
|
+
const response = await axios.get( "https://gitlab.com/api/v4/projects?membership=true\&private_token="+token+"\&per_page=100&&archived=false&search=server_", { headers: { Accept: "application/json", "Accept-Encoding": "identity" } } )
|
|
12
12
|
serverRepos = response.data
|
|
13
13
|
if (serverRepos.length == 0) throw new Error("\nError: ".red + " no server repo found\n");
|
|
14
14
|
|
package/lib/commands/init.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
require('colors');
|
|
2
2
|
const { getCurrentCommandEnviroment } = require("../task_lists/common_enviromentHandler");
|
|
3
3
|
const { newProjectTasks } = require("../task_lists/init_newProject");
|
|
4
|
-
const { existingProjectTasks } = require("../task_lists/init_existingProject");
|
|
5
4
|
const fs = require('fs-extra');
|
|
6
5
|
const axios = require('axios');
|
|
7
6
|
const git = require('simple-git');
|
|
@@ -14,29 +13,23 @@ async function init(servername,args) {
|
|
|
14
13
|
|
|
15
14
|
let initTasks;
|
|
16
15
|
if(await projectExistsInGitAccount(projectName,args.repoaccount) ) {
|
|
17
|
-
|
|
18
|
-
console.log("\nError:".red + " '--legacy' is an invalid option for an already existing repositories\n")
|
|
19
|
-
return
|
|
20
|
-
} else {
|
|
21
|
-
console.log("\nGetting project", repo.bold.blue, ":" );
|
|
22
|
-
initTasks = existingProjectTasks(repo);
|
|
23
|
-
}
|
|
16
|
+
console.log("\nRepo cloned!".green);
|
|
24
17
|
} else if( projectPathOkFor(projectName) && await notInsideGitRepo() && await validCobServer(cmdEnv.server)) {
|
|
25
18
|
console.log("\nCreating project", projectName.bold.blue );
|
|
26
19
|
initTasks = newProjectTasks(cmdEnv, projectName, repo, args )
|
|
20
|
+
initTasks.run()
|
|
21
|
+
.then( () => {
|
|
22
|
+
console.log("\nDone!".green, "\nTry:");
|
|
23
|
+
console.log("\tcd "+projectName)
|
|
24
|
+
console.log("\tcob-cli customize\n")
|
|
25
|
+
})
|
|
26
|
+
.catch(err => {
|
|
27
|
+
console.error("\n",err.message);
|
|
28
|
+
})
|
|
27
29
|
} else {
|
|
28
30
|
return //Error
|
|
29
31
|
}
|
|
30
32
|
|
|
31
|
-
initTasks.run()
|
|
32
|
-
.then( () => {
|
|
33
|
-
console.log("\nDone!".green, "\nTry:");
|
|
34
|
-
console.log("\tcd "+projectName)
|
|
35
|
-
console.log("\tcob-cli customize\n")
|
|
36
|
-
})
|
|
37
|
-
.catch(err => {
|
|
38
|
-
console.error("\n",err.message);
|
|
39
|
-
})
|
|
40
33
|
}
|
|
41
34
|
module.exports = init;
|
|
42
35
|
|
|
@@ -72,7 +65,9 @@ async function validCobServer(server) {
|
|
|
72
65
|
/* ************************************ */
|
|
73
66
|
async function projectExistsInGitAccount(projectName, repoaccount) {
|
|
74
67
|
try {
|
|
75
|
-
await git().
|
|
68
|
+
await git().clone(repoaccount + projectName);
|
|
76
69
|
return true;
|
|
77
|
-
} catch {
|
|
70
|
+
} catch (e) {
|
|
71
|
+
return false
|
|
72
|
+
}
|
|
78
73
|
}
|
|
@@ -97,6 +97,6 @@ function _upgrade1to2() {
|
|
|
97
97
|
|
|
98
98
|
/* ************************************ */
|
|
99
99
|
function _upgrade2to2_1() {
|
|
100
|
-
fs.writeFileSync(".gitignore", fs.readFileSync(path.resolve(__dirname,"../../
|
|
100
|
+
fs.writeFileSync(".gitignore", fs.readFileSync(path.resolve(__dirname,"../../gitignore.template"), 'utf8'))
|
|
101
101
|
setVersion()
|
|
102
102
|
}
|
|
@@ -24,7 +24,7 @@ function newProjectTasks(cmdEnv, projectName, repo, args) {
|
|
|
24
24
|
{ title: 'git remote add origin ' + repo + ".git", task: () => git().addRemote("origin", repo + ".git") },
|
|
25
25
|
{ title: "Get current config", task: () => copyFiles(cmdEnv,"serverLive","localCopy") },
|
|
26
26
|
{ title: "Preserve empty directories", task: () => execa('find',[".","-type","d","-empty","-exec","touch","{}/.gitkeep",";"] ) },
|
|
27
|
-
{ title: "add .gitignore", task: () => fs.copyFile(path.resolve(__dirname, '../../
|
|
27
|
+
{ title: "add .gitignore", task: () => fs.copyFile(path.resolve(__dirname, '../../gitignore.template'), '.gitignore') },
|
|
28
28
|
{ title: "initialize version file", task: () => setVersion() },
|
|
29
29
|
{ title: "initialize prod environment folder", task: () => cmdEnv.initialize() },
|
|
30
30
|
{ title: "git add .", task: () => git().add(".") },
|
package/package.json
CHANGED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
const Listr = require('listr');
|
|
2
|
-
const git = require('simple-git');
|
|
3
|
-
|
|
4
|
-
function existingProjectTasks(repo) {
|
|
5
|
-
return new Listr([
|
|
6
|
-
{ title: 'git clone ' + repo, task: () => git().clone(repo) }
|
|
7
|
-
]);
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
exports.existingProjectTasks = existingProjectTasks;
|