Skip to content

Commit b6b810e

Browse files
committed
Merge branch 'refs/heads/feat-create-resources' into feat-pull-function
# Conflicts: # templates/cli/base/params.twig
2 parents 5e1020a + 9b71779 commit b6b810e

File tree

11 files changed

+500
-86
lines changed

11 files changed

+500
-86
lines changed

src/SDK/Language/CLI.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,11 @@ public function getFiles(): array
132132
'destination' => 'lib/validations.js',
133133
'template' => 'cli/lib/validations.js.twig',
134134
],
135+
[
136+
'scope' => 'default',
137+
'destination' => 'lib/spinner.js',
138+
'template' => 'cli/lib/spinner.js.twig',
139+
],
135140
[
136141
'scope' => 'default',
137142
'destination' => 'lib/parser.js',

templates/cli/base/params.twig

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,8 @@
1818

1919
if (func.ignore) {
2020
ignorer.add(func.ignore);
21-
log('Ignoring files using configuration from appwrite.json');
2221
} else if (fs.existsSync(pathLib.join({{ parameter.name | caseCamel | escapeKeyword }}, '.gitignore'))) {
2322
ignorer.add(fs.readFileSync(pathLib.join({{ parameter.name | caseCamel | escapeKeyword }}, '.gitignore')).toString());
24-
log('Ignoring files in .gitignore');
2523
}
2624

2725
const files = getAllFiles({{ parameter.name | caseCamel | escapeKeyword }}).map((file) => pathLib.relative({{ parameter.name | caseCamel | escapeKeyword }}, file)).filter((file) => !ignorer.ignores(file));

templates/cli/base/requests/file.twig

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{% for parameter in method.parameters.all %}
22
{% if parameter.type == 'file' %}
33
const size = {{ parameter.name | caseCamel | escapeKeyword }}.size;
4-
4+
55
const apiHeaders = {
66
{% for parameter in method.parameters.header %}
77
'{{ parameter.name }}': ${{ parameter.name | caseCamel | escapeKeyword }},
@@ -45,7 +45,7 @@
4545
}
4646

4747
let uploadableChunkTrimmed;
48-
48+
4949
if(currentPosition + 1 >= client.CHUNK_SIZE) {
5050
uploadableChunkTrimmed = uploadableChunk;
5151
} else {
@@ -99,17 +99,17 @@
9999
}
100100

101101
{% if method.packaging %}
102-
fs.unlinkSync(filePath);
102+
await fs.unlink(filePath,()=>{});
103103
{% endif %}
104104
{% if method.type == 'location' %}
105105
fs.writeFileSync(destination, response);
106106
{% endif %}
107-
107+
108108
if (parseOutput) {
109109
parse(response)
110110
success()
111111
}
112112

113113
return response;
114114
{% endif %}
115-
{% endfor %}
115+
{% endfor %}

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,7 @@ const createTopic = async () => {
100100
parseOutput: false
101101
})
102102

103-
// TODO: after https://github.com/appwrite/sdk-generator/pull/839
104-
// localConfig.addMessagingTopic(response);
103+
localConfig.addMessagingTopic(response);
105104
success();
106105
} catch (e) {
107106
error(e.getMessage ?? 'Unknown error occurred. Please try again');

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

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ 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");
56
const { teamsCreate, teamsList } = require("./teams");
67
const { projectsCreate } = require("./projects");
78
const { functionsList, functionsDownloadDeployment } = require("./functions");
@@ -162,6 +163,19 @@ const pullTeam = async () => {
162163
success();
163164
}
164165

166+
const pullMessagingTopic = async () => {
167+
const { topics } = await paginate(messagingListTopics, { parseOutput: false }, 100, 'topics');
168+
169+
log(`Found ${topics.length} topics`);
170+
171+
topics.forEach(async topic => {
172+
log(`Pulling ${topic.name} ...`);
173+
localConfig.addMessagingTopic(topic);
174+
});
175+
176+
success();
177+
}
178+
165179
pull
166180
.command("project")
167181
.description("Pulling your Appwrite project")
@@ -191,6 +205,11 @@ pull
191205
.description("Pulling your Appwrite teams")
192206
.action(actionRunner(pullTeam))
193207

208+
pull
209+
.command("topic")
210+
.description("Initialise your Appwrite messaging topics")
211+
.action(actionRunner(pullMessagingTopic))
212+
194213
module.exports = {
195214
pull,
196215
};

0 commit comments

Comments
 (0)