Skip to content

Commit d0cc1c2

Browse files
committed
feat(cli): Adapting pull to cliConfig
1 parent 8eac05a commit d0cc1c2

File tree

1 file changed

+12
-14
lines changed

1 file changed

+12
-14
lines changed

templates/cli/lib/commands/pull.js.twig

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ const { storageListBuckets } = require("./storage");
1111
const { localConfig } = require("../config");
1212
const { paginate } = require("../paginate");
1313
const { questionsPullCollection, questionsPullFunctions } = require("../questions");
14-
const { success, log, actionRunner, commandDescriptions } = require("../parser");
14+
const { cliConfig, success, log, actionRunner, commandDescriptions } = require("../parser");
1515

1616
const pullProject = async () => {
1717
try {
@@ -30,10 +30,10 @@ const pullProject = async () => {
3030
}
3131
}
3232

33-
const pullFunctions = async ({ all } = {}) => {
33+
const pullFunctions = async () => {
3434
const localFunctions = localConfig.getFunctions();
3535

36-
const functions = all
36+
const functions = cliConfig.all
3737
? (await paginate(functionsList, { parseOutput: false }, 100, 'functions')).functions
3838
: (await inquirer.prompt(questionsPullFunctions)).functions;
3939

@@ -74,22 +74,21 @@ const pullFunctions = async ({ all } = {}) => {
7474

7575
fs.rmSync(compressedFileName);
7676
success(`Pulled ${func['name']} code and settings`)
77-
}
7877
}
7978
}
8079

8180
const pullCollection = async () => {
82-
const databasesIds = (await inquirer.prompt(questionsPullCollection)).databases;
81+
let databases = cliConfig.ids;
8382

84-
for (let id of databasesIds) {
85-
const databaseId = id.value ? id.value : id;
86-
87-
if (databaseIds.length <= 0) {
88-
let answers = await inquirer.prompt(questionsPullCollection)
89-
databaseIds.push(...answers.databases);
83+
if (databases.length === 0) {
84+
if (cliConfig.all) {
85+
databases = (await paginate(databasesList, { parseOutput: false }, 100, 'databases')).databases.map(database=>database.$id);
86+
} else{
87+
databases = (await inquirer.prompt(questionsPullCollection)).databases;
88+
}
9089
}
9190

92-
for (const databaseId of databaseIds) {
91+
for (const databaseId of databases) {
9392
const database = await databasesGet({
9493
databaseId,
9594
parseOutput: false
@@ -113,9 +112,9 @@ const pullCollection = async () => {
113112
});
114113
});
115114

115+
success();
116116
}
117117

118-
success();
119118
}
120119

121120
const pullBucket = async () => {
@@ -172,7 +171,6 @@ pull
172171
pull
173172
.command("functions")
174173
.description(`Pulling your {{ spec.title|caseUcfirst }} functions`)
175-
.option(`--all`, `Flag to pull all functions`)
176174
.action(actionRunner(pullFunctions));
177175

178176
pull

0 commit comments

Comments
 (0)