@@ -4,7 +4,7 @@ const { Command } = require("commander");
4
4
const inquirer = require("inquirer");
5
5
const { messagingListTopics } = require("./messaging");
6
6
const { teamsList } = require("./teams");
7
- const { projectsList } = require("./projects");
7
+ const { projectsGet } = require("./projects");
8
8
const { functionsList, functionsDownloadDeployment } = require("./functions");
9
9
const { databasesGet, databasesListCollections, databasesList } = require("./databases");
10
10
const { storageListBuckets } = require("./storage");
@@ -24,43 +24,31 @@ const pull = new Command("pull")
24
24
25
25
const pullProject = async () => {
26
26
try {
27
- let response = await projectsList ({
27
+ let response = await projectsGet ({
28
28
parseOutput: false,
29
- queries: [JSON.stringify({ method: 'equal', attribute: '$id', values: [ localConfig.getProject().projectId] })]
29
+ projectId: localConfig.getProject().projectId
30
30
31
31
})
32
- if(response.total === 1){
33
- localConfig.setProject(response.projects[0].$id, response.projects[0].name);
34
- }
32
+
33
+ localConfig.setProject(response.$id, response.name);
35
34
success();
36
35
} catch (e) {
37
36
throw e;
38
37
}
39
38
}
40
39
41
- const pullFunctions = async ({ all, yes } = {}) => {
42
- let functions = [];
43
- let questions = questionsPullFunctions;
44
-
40
+ const pullFunctions = async ({ all } = {}) => {
45
41
const localFunctions = localConfig.getFunctions();
46
42
47
- if (all) {
48
- questions = yes ? [] : questionsPullFunctions[1];
49
- functions = (await paginate(functionsList, { parseOutput: false }, 100, 'functions')).functions;
50
- }
51
-
52
- const answers = await inquirer.prompt(questions);
43
+ const functions = all
44
+ ? (await paginate(functionsList, { parseOutput: false }, 100, 'functions')).functions
45
+ : (await inquirer.prompt(questionsPullFunctions)).functions;
53
46
54
- const overridingLocalChanges = yes ?? answers.override.toLowerCase() === "yes";
55
- const selectedFunctions = functions.length === 0 ? answers.functions : functions;
47
+ log(`Pulling ${functions.length} functions`);
56
48
57
- for (let func of selectedFunctions ) {
49
+ for (let func of functions ) {
58
50
const functionExistLocally = localFunctions.find((localFunc) => localFunc['$id'] === func['$id']) !== undefined;
59
51
60
- if (!overridingLocalChanges && functionExistLocally) {
61
- log(`Skipping locally found implementation of ${func['name']}`)
62
- continue;
63
- }
64
52
if (functionExistLocally) {
65
53
localConfig.updateFunction(func['$id'], func);
66
54
} else {
@@ -74,7 +62,7 @@ const pullFunctions = async ({ all, yes } = {}) => {
74
62
continue
75
63
}
76
64
77
- const compressedFileName = `${+new Date()}.tar.gz`
65
+ const compressedFileName = `${func['$id']}-${ +new Date()}.tar.gz`
78
66
79
67
await functionsDownloadDeployment({
80
68
functionId: func['$id'],
@@ -92,7 +80,7 @@ const pullFunctions = async ({ all, yes } = {}) => {
92
80
});
93
81
94
82
fs.rmSync(compressedFileName);
95
- success(`Pulled ${func['name']} code and definition `)
83
+ success(`Pulled ${func['name']} code and settings `)
96
84
}
97
85
}
98
86
@@ -111,7 +99,6 @@ const pullCollection = async ({ all, databaseId } = {}) => {
111
99
112
100
if (databaseIds.length < = 0) {
113
101
let answers = await inquirer.prompt(questionsPullCollection)
114
- if (!answers.databases) process.exit(1)
115
102
databaseIds.push(...answers.databases);
116
103
}
117
104
@@ -185,31 +172,30 @@ const pullMessagingTopic = async () => {
185
172
186
173
pull
187
174
.command("project")
188
- .description("Pulling your Appwrite project name")
175
+ .description("Pulling your {{ spec . title | caseUcfirst }} project name")
189
176
.action(actionRunner(pullProject));
190
177
191
178
pull
192
179
.command("function")
193
- .description(`Pulling your Appwrite functions`)
194
- .option(`--yes`, `Flag to confirm all warnings`)
180
+ .description(`Pulling your {{ spec .title | caseUcfirst }} functions`)
195
181
.option(`--all`, `Flag to pull all functions`)
196
182
.action(actionRunner(pullFunctions));
197
183
198
184
pull
199
185
.command("collection")
200
- .description("Pulling your Appwrite collections")
186
+ .description("Pulling your {{ spec . title | caseUcfirst }} collections")
201
187
.option(`--databaseId <databaseId >`, `Database ID`)
202
188
.option(`--all`, `Flag to pull all databases`)
203
189
.action(actionRunner(pullCollection))
204
190
205
191
pull
206
192
.command("bucket")
207
- .description("Pulling your Appwrite buckets")
193
+ .description("Pulling your {{ spec . title | caseUcfirst }} buckets")
208
194
.action(actionRunner(pullBucket))
209
195
210
196
pull
211
197
.command("team")
212
- .description("Pulling your Appwrite teams")
198
+ .description("Pulling your {{ spec . title | caseUcfirst }} teams")
213
199
.action(actionRunner(pullTeam))
214
200
215
201
pull
0 commit comments