Skip to content

Commit 6fda9e5

Browse files
authored
Merge pull request #1196 from appwrite/fix-pull-deprecated-cli
skip pulling deperecated resources in pull --all
2 parents 71369fc + e69aa69 commit 6fda9e5

File tree

1 file changed

+16
-10
lines changed

1 file changed

+16
-10
lines changed

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

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -295,15 +295,16 @@ const pullSites = async ({ code, withVariables }) => {
295295
const pullCollection = async () => {
296296
warn("appwrite pull collection has been deprecated. Please consider using 'appwrite pull tables' instead");
297297
log("Fetching collections ...");
298-
let total = 0;
298+
let totalDatabases = 0;
299+
let totalCollections = 0;
299300

300301
const fetchResponse = await databasesList({
301302
queries: [JSON.stringify({ method: 'limit', values: [1] })],
302303
parseOutput: false
303304
});
304305
if (fetchResponse["databases"].length <= 0) {
305306
log("No collections found.");
306-
success(`Successfully pulled ${chalk.bold(total)} collections.`);
307+
success(`Successfully pulled ${chalk.bold(totalCollections)} collections from ${chalk.bold(totalDatabases)} databases.`);
307308
return;
308309
}
309310

@@ -323,7 +324,7 @@ const pullCollection = async () => {
323324
parseOutput: false
324325
});
325326

326-
total++;
327+
totalDatabases++;
327328
log(`Pulling all collections from ${chalk.bold(database['name'])} database ...`);
328329

329330
localConfig.addDatabase(database);
@@ -334,6 +335,7 @@ const pullCollection = async () => {
334335
}, 100, 'collections');
335336

336337
for (const collection of collections) {
338+
totalCollections++;
337339
localConfig.addCollection({
338340
...collection,
339341
'$createdAt': undefined,
@@ -342,20 +344,21 @@ const pullCollection = async () => {
342344
}
343345
}
344346

345-
success(`Successfully pulled ${chalk.bold(total)} collections.`);
347+
success(`Successfully pulled ${chalk.bold(totalCollections)} collections from ${chalk.bold(totalDatabases)} databases.`);
346348
}
347349

348350
const pullTable = async () => {
349351
log("Fetching tables ...");
350-
let total = 0;
352+
let totalTablesDBs = 0;
353+
let totalTables = 0;
351354

352355
const fetchResponse = await tablesDBList({
353356
queries: [JSON.stringify({ method: 'limit', values: [1] })],
354357
parseOutput: false
355358
});
356359
if (fetchResponse["databases"].length <= 0) {
357360
log("No tables found.");
358-
success(`Successfully pulled ${chalk.bold(total)} tables.`);
361+
success(`Successfully pulled ${chalk.bold(totalTables)} tables from ${chalk.bold(totalTablesDBs)} tables databases.`);
359362
return;
360363
}
361364

@@ -375,7 +378,7 @@ const pullTable = async () => {
375378
parseOutput: false
376379
});
377380

378-
total++;
381+
totalTablesDBs++;
379382
log(`Pulling all tables from ${chalk.bold(database['name'])} database ...`);
380383

381384
localConfig.addTablesDB(database);
@@ -386,6 +389,7 @@ const pullTable = async () => {
386389
}, 100, 'tables');
387390

388391
for (const table of tables) {
392+
totalTables++;
389393
localConfig.addTable({
390394
...table,
391395
'$createdAt': undefined,
@@ -394,7 +398,7 @@ const pullTable = async () => {
394398
}
395399
}
396400

397-
success(`Successfully pulled ${chalk.bold(total)} tables.`);
401+
success(`Successfully pulled ${chalk.bold(totalTables)} tables from ${chalk.bold(totalTablesDBs)} tables databases.`);
398402
}
399403

400404
const pullBucket = async () => {
@@ -474,14 +478,16 @@ const pullMessagingTopic = async () => {
474478

475479
const pull = new Command("pull")
476480
.description(commandDescriptions['pull'])
477-
.action(actionRunner(pullResources));
481+
.action(actionRunner(() => pullResources({ skipDeprecated: true })));
478482

479483
pull
480484
.command("all")
481485
.description("Pull all resource.")
482486
.action(actionRunner(() => {
483487
cliConfig.all = true;
484-
return pullResources();
488+
return pullResources({
489+
skipDeprecated: true
490+
});
485491
}));
486492

487493
pull

0 commit comments

Comments
 (0)