appwrite-cli 6.0.0-rc.4 → 6.0.0-rc.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -4
- package/install.ps1 +2 -2
- package/install.sh +1 -1
- package/lib/client.js +2 -2
- package/lib/commands/account.js +65 -65
- package/lib/commands/avatars.js +9 -9
- package/lib/commands/databases.js +140 -140
- package/lib/commands/functions.js +69 -69
- package/lib/commands/generic.js +4 -3
- package/lib/commands/health.js +22 -22
- package/lib/commands/init.js +4 -3
- package/lib/commands/locale.js +7 -7
- package/lib/commands/messaging.js +160 -160
- package/lib/commands/migrations.js +28 -28
- package/lib/commands/project.js +11 -11
- package/lib/commands/projects.js +122 -122
- package/lib/commands/proxy.js +10 -10
- package/lib/commands/pull.js +4 -4
- package/lib/commands/push.js +310 -98
- package/lib/commands/run.js +63 -21
- package/lib/commands/storage.js +44 -44
- package/lib/commands/teams.js +29 -29
- package/lib/commands/users.js +99 -99
- package/lib/commands/vcs.js +27 -27
- package/lib/config.js +22 -10
- package/lib/emulation/docker.js +81 -10
- package/lib/parser.js +3 -14
- package/lib/questions.js +16 -20
- package/lib/spinner.js +1 -0
- package/package.json +3 -2
- package/scoop/appwrite.json +3 -3
package/lib/emulation/docker.js
CHANGED
|
@@ -1,10 +1,14 @@
|
|
|
1
|
+
const tar = require("tar");
|
|
2
|
+
const ignore = require("ignore");
|
|
3
|
+
const net = require('net');
|
|
1
4
|
const chalk = require('chalk');
|
|
2
5
|
const childProcess = require('child_process');
|
|
3
6
|
const { localConfig } = require("../config");
|
|
4
7
|
const path = require('path');
|
|
5
8
|
const fs = require('fs');
|
|
6
|
-
const { log, success, hint } = require("../parser");
|
|
9
|
+
const { log, error, success, hint } = require("../parser");
|
|
7
10
|
const { openRuntimesVersion, systemTools, Queue } = require("./utils");
|
|
11
|
+
const { getAllFiles } = require("../utils");
|
|
8
12
|
|
|
9
13
|
async function dockerStop(id) {
|
|
10
14
|
const stopProcess = childProcess.spawn('docker', ['rm', '--force', id], {
|
|
@@ -47,9 +51,34 @@ async function dockerBuild(func, variables) {
|
|
|
47
51
|
|
|
48
52
|
const id = func.$id;
|
|
49
53
|
|
|
54
|
+
const ignorer = ignore();
|
|
55
|
+
ignorer.add('.appwrite');
|
|
56
|
+
if (func.ignore) {
|
|
57
|
+
ignorer.add(func.ignore);
|
|
58
|
+
} else if (fs.existsSync(path.join(functionDir, '.gitignore'))) {
|
|
59
|
+
ignorer.add(fs.readFileSync(path.join(functionDir, '.gitignore')).toString());
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
const files = getAllFiles(functionDir).map((file) => path.relative(functionDir, file)).filter((file) => !ignorer.ignores(file));
|
|
63
|
+
const tmpBuildPath = path.join(functionDir, '.appwrite/tmp-build');
|
|
64
|
+
if (!fs.existsSync(tmpBuildPath)) {
|
|
65
|
+
fs.mkdirSync(tmpBuildPath, { recursive: true });
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
for(const f of files) {
|
|
69
|
+
const filePath = path.join(tmpBuildPath, f);
|
|
70
|
+
const fileDir = path.dirname(filePath);
|
|
71
|
+
if (!fs.existsSync(fileDir)) {
|
|
72
|
+
fs.mkdirSync(fileDir, { recursive: true });
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
const sourcePath = path.join(functionDir, f);
|
|
76
|
+
fs.copyFileSync(sourcePath, filePath);
|
|
77
|
+
}
|
|
78
|
+
|
|
50
79
|
const params = [ 'run' ];
|
|
51
80
|
params.push('--name', id);
|
|
52
|
-
params.push('-v', `${
|
|
81
|
+
params.push('-v', `${tmpBuildPath}/:/mnt/code:rw`);
|
|
53
82
|
params.push('-e', 'APPWRITE_ENV=development');
|
|
54
83
|
params.push('-e', 'OPEN_RUNTIMES_ENV=development');
|
|
55
84
|
params.push('-e', 'OPEN_RUNTIMES_SECRET=');
|
|
@@ -91,12 +120,11 @@ async function dockerBuild(func, variables) {
|
|
|
91
120
|
|
|
92
121
|
await new Promise((res) => { buildProcess.on('close', res) });
|
|
93
122
|
|
|
94
|
-
clearInterval(
|
|
95
|
-
|
|
123
|
+
clearInterval(killInterval);
|
|
96
124
|
if(!Queue.isEmpty()) {
|
|
97
125
|
return;
|
|
98
126
|
}
|
|
99
|
-
|
|
127
|
+
|
|
100
128
|
const copyPath = path.join(process.cwd(), func.path, '.appwrite', 'build.tar.gz');
|
|
101
129
|
const copyDir = path.dirname(copyPath);
|
|
102
130
|
if (!fs.existsSync(copyDir)) {
|
|
@@ -120,18 +148,21 @@ async function dockerBuild(func, variables) {
|
|
|
120
148
|
if (fs.existsSync(tempPath)) {
|
|
121
149
|
fs.rmSync(tempPath, { force: true });
|
|
122
150
|
}
|
|
151
|
+
|
|
152
|
+
fs.rmSync(tmpBuildPath, { recursive: true, force: true });
|
|
123
153
|
}
|
|
124
154
|
|
|
125
155
|
async function dockerStart(func, variables, port) {
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
156
|
+
// Pack function files
|
|
157
|
+
const functionDir = path.join(process.cwd(), func.path);
|
|
158
|
+
|
|
159
|
+
const runtimeChunks = func.runtime.split("-");
|
|
160
|
+
const runtimeVersion = runtimeChunks.pop();
|
|
161
|
+
const runtimeName = runtimeChunks.join("-");
|
|
129
162
|
const imageName = `openruntimes/${runtimeName}:${openRuntimesVersion}-${runtimeVersion}`;
|
|
130
163
|
|
|
131
164
|
const tool = systemTools[runtimeName];
|
|
132
165
|
|
|
133
|
-
const functionDir = path.join(process.cwd(), func.path);
|
|
134
|
-
|
|
135
166
|
const id = func.$id;
|
|
136
167
|
|
|
137
168
|
const params = [ 'run' ];
|
|
@@ -168,6 +199,13 @@ async function dockerStart(func, variables, port) {
|
|
|
168
199
|
process.stdout.write(chalk.blackBright(data));
|
|
169
200
|
});
|
|
170
201
|
|
|
202
|
+
try {
|
|
203
|
+
await waitUntilPortOpen(port);
|
|
204
|
+
} catch(err) {
|
|
205
|
+
error("Failed to start function with error: " + err.message ? err.message : err.toString());
|
|
206
|
+
return;
|
|
207
|
+
}
|
|
208
|
+
|
|
171
209
|
success(`Visit http://localhost:${port}/ to execute your function.`);
|
|
172
210
|
}
|
|
173
211
|
|
|
@@ -186,6 +224,39 @@ async function dockerCleanup(functionId) {
|
|
|
186
224
|
}
|
|
187
225
|
}
|
|
188
226
|
|
|
227
|
+
function waitUntilPortOpen(port, iteration = 0) {
|
|
228
|
+
return new Promise((resolve, reject) => {
|
|
229
|
+
const client = new net.Socket();
|
|
230
|
+
|
|
231
|
+
client.once('connect', () => {
|
|
232
|
+
client.removeAllListeners('connect');
|
|
233
|
+
client.removeAllListeners('error');
|
|
234
|
+
client.end();
|
|
235
|
+
client.destroy();
|
|
236
|
+
client.unref();
|
|
237
|
+
|
|
238
|
+
resolve();
|
|
239
|
+
});
|
|
240
|
+
|
|
241
|
+
client.once('error', async (err) => {
|
|
242
|
+
client.removeAllListeners('connect');
|
|
243
|
+
client.removeAllListeners('error');
|
|
244
|
+
client.end();
|
|
245
|
+
client.destroy();
|
|
246
|
+
client.unref();
|
|
247
|
+
|
|
248
|
+
if(iteration > 100) {
|
|
249
|
+
reject(err);
|
|
250
|
+
} else {
|
|
251
|
+
await new Promise((res) => setTimeout(res, 100));
|
|
252
|
+
waitUntilPortOpen(port, iteration + 1).then(resolve).catch(reject);
|
|
253
|
+
}
|
|
254
|
+
});
|
|
255
|
+
|
|
256
|
+
client.connect({port, host: '127.0.0.1'}, function() {});
|
|
257
|
+
});
|
|
258
|
+
}
|
|
259
|
+
|
|
189
260
|
module.exports = {
|
|
190
261
|
dockerPull,
|
|
191
262
|
dockerBuild,
|
package/lib/parser.js
CHANGED
|
@@ -90,20 +90,9 @@ const drawTable = (data) => {
|
|
|
90
90
|
if (row[key] === null) {
|
|
91
91
|
rowValues.push("-");
|
|
92
92
|
} else if (Array.isArray(row[key])) {
|
|
93
|
-
|
|
94
|
-
case 1:
|
|
95
|
-
if (typeof row[key][0] === 'object') {
|
|
96
|
-
rowValues.push(`array(${row[key].length})`);
|
|
97
|
-
} else {
|
|
98
|
-
rowValues.push(row[key][0]);
|
|
99
|
-
}
|
|
100
|
-
break;
|
|
101
|
-
default:
|
|
102
|
-
rowValues.push(`array(${row[key].length})`);
|
|
103
|
-
break;
|
|
104
|
-
}
|
|
93
|
+
rowValues.push(JSON.stringify(row[key]));
|
|
105
94
|
} else if (typeof row[key] === 'object') {
|
|
106
|
-
rowValues.push(
|
|
95
|
+
rowValues.push(JSON.stringify(row[key]));
|
|
107
96
|
} else {
|
|
108
97
|
rowValues.push(row[key]);
|
|
109
98
|
}
|
|
@@ -131,7 +120,7 @@ const parseError = (err) => {
|
|
|
131
120
|
} catch {
|
|
132
121
|
}
|
|
133
122
|
|
|
134
|
-
const version = '6.0.0-rc.
|
|
123
|
+
const version = '6.0.0-rc.6';
|
|
135
124
|
const stepsToReproduce = `Running \`appwrite ${cliConfig.reportData.data.args.join(' ')}\``;
|
|
136
125
|
const yourEnvironment = `CLI version: ${version}\nOperation System: ${os.type()}\nAppwrite version: ${appwriteVersion}\nIs Cloud: ${isCloud}`;
|
|
137
126
|
|
package/lib/questions.js
CHANGED
|
@@ -247,11 +247,10 @@ const questionsPullFunctions = [
|
|
|
247
247
|
if (functions.length === 0) {
|
|
248
248
|
throw "We couldn't find any functions in your Appwrite project";
|
|
249
249
|
}
|
|
250
|
-
|
|
251
250
|
return functions.map(func => {
|
|
252
251
|
return {
|
|
253
252
|
name: `${func.name} (${func.$id})`,
|
|
254
|
-
value: func
|
|
253
|
+
value: { ...func }
|
|
255
254
|
}
|
|
256
255
|
});
|
|
257
256
|
}
|
|
@@ -634,12 +633,10 @@ const questionsPushFunctions = [
|
|
|
634
633
|
name: "functions",
|
|
635
634
|
message: "Which functions would you like to push?",
|
|
636
635
|
validate: (value) => validateRequired('function', value),
|
|
636
|
+
when: () => localConfig.getFunctions().length > 0,
|
|
637
637
|
choices: () => {
|
|
638
638
|
let functions = localConfig.getFunctions();
|
|
639
639
|
checkDeployConditions(localConfig)
|
|
640
|
-
if (functions.length === 0) {
|
|
641
|
-
throw new Error("No functions found Use 'appwrite pull functions' to synchronize existing one, or use 'appwrite init function' to create a new one.");
|
|
642
|
-
}
|
|
643
640
|
let choices = functions.map((func, idx) => {
|
|
644
641
|
return {
|
|
645
642
|
name: `${func.name} (${func.$id})`,
|
|
@@ -662,13 +659,11 @@ const questionsPushCollections = [
|
|
|
662
659
|
name: "collections",
|
|
663
660
|
message: "Which collections would you like to push?",
|
|
664
661
|
validate: (value) => validateRequired('collection', value),
|
|
662
|
+
when: () => localConfig.getCollections().length > 0,
|
|
665
663
|
choices: () => {
|
|
666
664
|
let collections = localConfig.getCollections();
|
|
667
665
|
checkDeployConditions(localConfig)
|
|
668
666
|
|
|
669
|
-
if (collections.length === 0) {
|
|
670
|
-
throw new Error("No collections found in the current directory. Use 'appwrite pull collections' to synchronize existing one, or use 'appwrite init collection' to create a new one.");
|
|
671
|
-
}
|
|
672
667
|
return collections.map(collection => {
|
|
673
668
|
return {
|
|
674
669
|
name: `${collection.name} (${collection['databaseId']} - ${collection['$id']})`,
|
|
@@ -676,13 +671,16 @@ const questionsPushCollections = [
|
|
|
676
671
|
}
|
|
677
672
|
});
|
|
678
673
|
}
|
|
679
|
-
}
|
|
674
|
+
}
|
|
675
|
+
];
|
|
676
|
+
|
|
677
|
+
const questionPushChanges = [
|
|
680
678
|
{
|
|
681
679
|
type: "input",
|
|
682
680
|
name: "changes",
|
|
683
681
|
message: `Would you like to apply these changes? Type "YES" to confirm.`
|
|
684
682
|
}
|
|
685
|
-
]
|
|
683
|
+
];
|
|
686
684
|
|
|
687
685
|
const questionsPushBuckets = [
|
|
688
686
|
{
|
|
@@ -690,12 +688,11 @@ const questionsPushBuckets = [
|
|
|
690
688
|
name: "buckets",
|
|
691
689
|
message: "Which buckets would you like to push?",
|
|
692
690
|
validate: (value) => validateRequired('bucket', value),
|
|
691
|
+
when: () => localConfig.getBuckets().length > 0,
|
|
693
692
|
choices: () => {
|
|
694
693
|
let buckets = localConfig.getBuckets();
|
|
695
694
|
checkDeployConditions(localConfig)
|
|
696
|
-
|
|
697
|
-
throw new Error("No buckets found in the current directory. Use 'appwrite pull buckets' to synchronize existing one, or use 'appwrite init bucket' to create a new one.");
|
|
698
|
-
}
|
|
695
|
+
|
|
699
696
|
return buckets.map(bucket => {
|
|
700
697
|
return {
|
|
701
698
|
name: `${bucket.name} (${bucket['$id']})`,
|
|
@@ -711,11 +708,10 @@ const questionsPushMessagingTopics = [
|
|
|
711
708
|
type: "checkbox",
|
|
712
709
|
name: "topics",
|
|
713
710
|
message: "Which messaging topic would you like to push?",
|
|
711
|
+
when: () => localConfig.getMessagingTopics().length > 0,
|
|
714
712
|
choices: () => {
|
|
715
713
|
let topics = localConfig.getMessagingTopics();
|
|
716
|
-
|
|
717
|
-
throw new Error("No topics found in the current directory. Use 'appwrite pull topics' to synchronize existing one, or use 'appwrite init topic' to create a new one.");
|
|
718
|
-
}
|
|
714
|
+
|
|
719
715
|
return topics.map(topic => {
|
|
720
716
|
return {
|
|
721
717
|
name: `${topic.name} (${topic['$id']})`,
|
|
@@ -752,12 +748,11 @@ const questionsPushTeams = [
|
|
|
752
748
|
name: "teams",
|
|
753
749
|
message: "Which teams would you like to push?",
|
|
754
750
|
validate: (value) => validateRequired('team', value),
|
|
751
|
+
when: () => localConfig.getTeams().length > 0,
|
|
755
752
|
choices: () => {
|
|
756
753
|
let teams = localConfig.getTeams();
|
|
757
754
|
checkDeployConditions(localConfig);
|
|
758
|
-
|
|
759
|
-
throw new Error("No teams found in the current directory. Use 'appwrite pull teams' to synchronize existing one, or use 'appwrite init team' to create a new one.");
|
|
760
|
-
}
|
|
755
|
+
|
|
761
756
|
return teams.map(team => {
|
|
762
757
|
return {
|
|
763
758
|
name: `${team.name} (${team['$id']})`,
|
|
@@ -866,5 +861,6 @@ module.exports = {
|
|
|
866
861
|
questionsRunFunctions,
|
|
867
862
|
questionGetEndpoint,
|
|
868
863
|
questionsInitResources,
|
|
869
|
-
questionsCreateTeam
|
|
864
|
+
questionsCreateTeam,
|
|
865
|
+
questionPushChanges
|
|
870
866
|
};
|
package/lib/spinner.js
CHANGED
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "appwrite-cli",
|
|
3
3
|
"homepage": "https://appwrite.io/support",
|
|
4
4
|
"description": "Appwrite is an open-source self-hosted backend server that abstract and simplify complex and repetitive development tasks behind a very simple REST API",
|
|
5
|
-
"version": "6.0.0-rc.
|
|
5
|
+
"version": "6.0.0-rc.6",
|
|
6
6
|
"license": "BSD-3-Clause",
|
|
7
7
|
"main": "index.js",
|
|
8
8
|
"bin": {
|
|
@@ -34,7 +34,8 @@
|
|
|
34
34
|
"tar": "^6.1.11",
|
|
35
35
|
"ignore": "^5.2.0",
|
|
36
36
|
"chokidar": "^3.6.0",
|
|
37
|
-
"tail": "^2.2.6"
|
|
37
|
+
"tail": "^2.2.6",
|
|
38
|
+
"dotenv": "^16.3.1"
|
|
38
39
|
},
|
|
39
40
|
"devDependencies": {
|
|
40
41
|
"pkg": "5.8.1"
|
package/scoop/appwrite.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://raw.githubusercontent.com/ScoopInstaller/Scoop/master/schema.json",
|
|
3
|
-
"version": "6.0.0-rc.
|
|
3
|
+
"version": "6.0.0-rc.6",
|
|
4
4
|
"description": "The Appwrite CLI is a command-line application that allows you to interact with Appwrite and perform server-side tasks using your terminal.",
|
|
5
5
|
"homepage": "https://github.com/appwrite/sdk-for-cli",
|
|
6
6
|
"license": "BSD-3-Clause",
|
|
7
7
|
"architecture": {
|
|
8
8
|
"64bit": {
|
|
9
|
-
"url": "https://github.com/appwrite/sdk-for-cli/releases/download/6.0.0-rc.
|
|
9
|
+
"url": "https://github.com/appwrite/sdk-for-cli/releases/download/6.0.0-rc.6/appwrite-cli-win-x64.exe",
|
|
10
10
|
"bin": [
|
|
11
11
|
[
|
|
12
12
|
"appwrite-cli-win-x64.exe",
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
]
|
|
16
16
|
},
|
|
17
17
|
"arm64": {
|
|
18
|
-
"url": "https://github.com/appwrite/sdk-for-cli/releases/download/6.0.0-rc.
|
|
18
|
+
"url": "https://github.com/appwrite/sdk-for-cli/releases/download/6.0.0-rc.6/appwrite-cli-win-arm64.exe",
|
|
19
19
|
"bin": [
|
|
20
20
|
[
|
|
21
21
|
"appwrite-cli-win-arm64.exe",
|