Skip to content

Commit 2bb8da3

Browse files
committed
refactor(cli): Project pull to update project name
1 parent a48c3e2 commit 2bb8da3

File tree

1 file changed

+17
-10
lines changed

1 file changed

+17
-10
lines changed

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

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,15 @@ const fs = require("fs");
22
const tar = require("tar");
33
const { Command } = require("commander");
44
const inquirer = require("inquirer");
5-
const { messagingCreateTopic, messagingListTopics } = require("./messaging");
6-
const { teamsCreate, teamsList } = require("./teams");
7-
const { projectsCreate } = require("./projects");
5+
const { messagingListTopics } = require("./messaging");
6+
const { teamsList } = require("./teams");
7+
const { projectsList } = require("./projects");
88
const { functionsList, functionsDownloadDeployment } = require("./functions");
99
const { databasesGet, databasesListCollections, databasesList } = require("./databases");
1010
const { storageListBuckets } = require("./storage");
11-
const { sdkForConsole } = require("../sdks");
1211
const { localConfig } = require("../config");
1312
const { paginate } = require("../paginate");
14-
const { questionsPullProject, questionsPullCollection, questionsPullFunctions } = require("../questions");
13+
const { questionsPullCollection, questionsPullFunctions } = require("../questions");
1514
const { success, log, actionRunner, commandDescriptions } = require("../parser");
1615

1716
const pull = new Command("pull")
@@ -24,11 +23,19 @@ const pull = new Command("pull")
2423
}));
2524

2625
const pullProject = async () => {
27-
const answers = await inquirer.prompt(questionsPullProject)
28-
if (!answers.project) process.exit(1)
26+
try {
27+
let response = await projectsList({
28+
parseOutput: false,
29+
queries: [JSON.stringify({ method: 'equal', attribute: '$id', values: [localConfig.getProject().projectId] })]
2930

30-
localConfig.setProject(answers.project.id, answers.project.name);
31-
success();
31+
})
32+
if(response.total === 1){
33+
localConfig.setProject(response.projects[0].$id, response.projects[0].name);
34+
}
35+
success();
36+
} catch (e) {
37+
throw e;
38+
}
3239
}
3340

3441
const pullFunctions = async ({ all, yes } = {}) => {
@@ -178,7 +185,7 @@ const pullMessagingTopic = async () => {
178185

179186
pull
180187
.command("project")
181-
.description("Pulling your Appwrite project")
188+
.description("Pulling your Appwrite project name")
182189
.action(actionRunner(pullProject));
183190

184191
pull

0 commit comments

Comments
 (0)