appwrite-cli 12.0.0 → 13.0.0-rc.1
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/CHANGELOG.md +8 -0
- package/README.md +2 -2
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +145 -0
- package/dist/index.js.map +1 -0
- package/dist/lib/client.d.ts +89 -0
- package/dist/lib/client.d.ts.map +1 -0
- package/dist/lib/client.js +227 -0
- package/dist/lib/client.js.map +1 -0
- package/dist/lib/commands/account.d.ts +379 -0
- package/dist/lib/commands/account.d.ts.map +1 -0
- package/dist/lib/commands/account.js +1228 -0
- package/dist/lib/commands/account.js.map +1 -0
- package/dist/lib/commands/console.d.ts +20 -0
- package/dist/lib/commands/console.d.ts.map +1 -0
- package/dist/lib/commands/console.js +78 -0
- package/dist/lib/commands/console.js.map +1 -0
- package/dist/lib/commands/databases.d.ts +732 -0
- package/dist/lib/commands/databases.d.ts.map +1 -0
- package/dist/lib/commands/databases.js +2196 -0
- package/dist/lib/commands/databases.js.map +1 -0
- package/dist/lib/commands/functions.d.ts +310 -0
- package/dist/lib/commands/functions.d.ts.map +1 -0
- package/dist/lib/commands/functions.js +1100 -0
- package/dist/lib/commands/functions.js.map +1 -0
- package/dist/lib/commands/generic.d.ts +17 -0
- package/dist/lib/commands/generic.d.ts.map +1 -0
- package/dist/lib/commands/generic.js +279 -0
- package/dist/lib/commands/generic.js.map +1 -0
- package/dist/lib/commands/graphql.d.ts +19 -0
- package/dist/lib/commands/graphql.d.ts.map +1 -0
- package/dist/lib/commands/graphql.js +77 -0
- package/dist/lib/commands/graphql.js.map +1 -0
- package/dist/lib/commands/health.d.ts +153 -0
- package/dist/lib/commands/health.d.ts.map +1 -0
- package/dist/lib/commands/health.js +464 -0
- package/dist/lib/commands/health.js.map +1 -0
- package/dist/lib/commands/init.d.ts +3 -0
- package/dist/lib/commands/init.d.ts.map +1 -0
- package/dist/lib/commands/init.js +518 -0
- package/dist/lib/commands/init.js.map +1 -0
- package/dist/lib/commands/locale.d.ts +53 -0
- package/dist/lib/commands/locale.d.ts.map +1 -0
- package/dist/lib/commands/locale.js +165 -0
- package/dist/lib/commands/locale.js.map +1 -0
- package/dist/lib/commands/messaging.d.ts +588 -0
- package/dist/lib/commands/messaging.d.ts.map +1 -0
- package/dist/lib/commands/messaging.js +2042 -0
- package/dist/lib/commands/messaging.js.map +1 -0
- package/dist/lib/commands/migrations.d.ts +150 -0
- package/dist/lib/commands/migrations.d.ts.map +1 -0
- package/dist/lib/commands/migrations.js +524 -0
- package/dist/lib/commands/migrations.js.map +1 -0
- package/dist/lib/commands/organizations.d.ts +11 -0
- package/dist/lib/commands/organizations.d.ts.map +1 -0
- package/dist/lib/commands/organizations.js +31 -0
- package/dist/lib/commands/organizations.js.map +1 -0
- package/dist/lib/commands/project.d.ts +53 -0
- package/dist/lib/commands/project.d.ts.map +1 -0
- package/dist/lib/commands/project.js +176 -0
- package/dist/lib/commands/project.js.map +1 -0
- package/dist/lib/commands/projects.d.ts +516 -0
- package/dist/lib/commands/projects.d.ts.map +1 -0
- package/dist/lib/commands/projects.js +1590 -0
- package/dist/lib/commands/projects.js.map +1 -0
- package/dist/lib/commands/proxy.d.ts +71 -0
- package/dist/lib/commands/proxy.d.ts.map +1 -0
- package/dist/lib/commands/proxy.js +240 -0
- package/dist/lib/commands/proxy.js.map +1 -0
- package/dist/lib/commands/pull.d.ts +8 -0
- package/dist/lib/commands/pull.d.ts.map +1 -0
- package/dist/lib/commands/pull.js +455 -0
- package/dist/lib/commands/pull.js.map +1 -0
- package/dist/lib/commands/push.d.ts +4 -0
- package/dist/lib/commands/push.d.ts.map +1 -0
- package/dist/lib/commands/push.js +2154 -0
- package/dist/lib/commands/push.js.map +1 -0
- package/dist/lib/commands/run.d.ts +3 -0
- package/dist/lib/commands/run.d.ts.map +1 -0
- package/dist/lib/commands/run.js +287 -0
- package/dist/lib/commands/run.js.map +1 -0
- package/dist/lib/commands/sites.d.ts +296 -0
- package/dist/lib/commands/sites.d.ts.map +1 -0
- package/dist/lib/commands/sites.js +1046 -0
- package/dist/lib/commands/sites.js.map +1 -0
- package/dist/lib/commands/storage.d.ts +170 -0
- package/dist/lib/commands/storage.d.ts.map +1 -0
- package/dist/lib/commands/storage.js +651 -0
- package/dist/lib/commands/storage.js.map +1 -0
- package/dist/lib/commands/tables-db.d.ts +728 -0
- package/dist/lib/commands/tables-db.d.ts.map +1 -0
- package/dist/lib/commands/tables-db.js +2198 -0
- package/dist/lib/commands/tables-db.js.map +1 -0
- package/dist/lib/commands/teams.d.ts +129 -0
- package/dist/lib/commands/teams.d.ts.map +1 -0
- package/dist/lib/commands/teams.js +403 -0
- package/dist/lib/commands/teams.js.map +1 -0
- package/dist/lib/commands/tokens.d.ts +48 -0
- package/dist/lib/commands/tokens.d.ts.map +1 -0
- package/dist/lib/commands/tokens.js +156 -0
- package/dist/lib/commands/tokens.js.map +1 -0
- package/dist/lib/commands/types.d.ts +3 -0
- package/dist/lib/commands/types.d.ts.map +1 -0
- package/dist/lib/commands/types.js +155 -0
- package/dist/lib/commands/types.js.map +1 -0
- package/dist/lib/commands/update.d.ts +3 -0
- package/dist/lib/commands/update.d.ts.map +1 -0
- package/dist/lib/commands/update.js +202 -0
- package/dist/lib/commands/update.js.map +1 -0
- package/dist/lib/commands/users.d.ts +382 -0
- package/dist/lib/commands/users.d.ts.map +1 -0
- package/dist/lib/commands/users.js +1195 -0
- package/dist/lib/commands/users.js.map +1 -0
- package/dist/lib/commands/vcs.d.ts +92 -0
- package/dist/lib/commands/vcs.d.ts.map +1 -0
- package/dist/lib/commands/vcs.js +276 -0
- package/dist/lib/commands/vcs.js.map +1 -0
- package/dist/lib/config.d.ts +118 -0
- package/dist/lib/config.d.ts.map +1 -0
- package/{lib → dist/lib}/config.js +204 -325
- package/dist/lib/config.js.map +1 -0
- package/dist/lib/emulation/docker.d.ts +15 -0
- package/dist/lib/emulation/docker.d.ts.map +1 -0
- package/dist/lib/emulation/docker.js +220 -0
- package/dist/lib/emulation/docker.js.map +1 -0
- package/dist/lib/emulation/utils.d.ts +29 -0
- package/dist/lib/emulation/utils.d.ts.map +1 -0
- package/dist/lib/emulation/utils.js +168 -0
- package/dist/lib/emulation/utils.js.map +1 -0
- package/dist/lib/exception.d.ts +8 -0
- package/dist/lib/exception.d.ts.map +1 -0
- package/dist/lib/exception.js +16 -0
- package/dist/lib/exception.js.map +1 -0
- package/dist/lib/id.d.ts +7 -0
- package/dist/lib/id.d.ts.map +1 -0
- package/dist/lib/id.js +32 -0
- package/dist/lib/id.js.map +1 -0
- package/dist/lib/paginate.d.ts +10 -0
- package/dist/lib/paginate.d.ts.map +1 -0
- package/{lib → dist/lib}/paginate.js +9 -15
- package/dist/lib/paginate.js.map +1 -0
- package/dist/lib/parser.d.ts +18 -0
- package/dist/lib/parser.d.ts.map +1 -0
- package/dist/lib/parser.js +237 -0
- package/dist/lib/parser.js.map +1 -0
- package/dist/lib/questions.d.ts +59 -0
- package/dist/lib/questions.d.ts.map +1 -0
- package/dist/lib/questions.js +995 -0
- package/dist/lib/questions.js.map +1 -0
- package/dist/lib/sdks.d.ts +4 -0
- package/dist/lib/sdks.d.ts.map +1 -0
- package/dist/lib/sdks.js +51 -0
- package/dist/lib/sdks.js.map +1 -0
- package/dist/lib/spinner.d.ts +28 -0
- package/dist/lib/spinner.d.ts.map +1 -0
- package/{lib → dist/lib}/spinner.js +34 -45
- package/dist/lib/spinner.js.map +1 -0
- package/dist/lib/type-generation/attribute.d.ts +17 -0
- package/dist/lib/type-generation/attribute.d.ts.map +1 -0
- package/dist/lib/type-generation/attribute.js +19 -0
- package/dist/lib/type-generation/attribute.js.map +1 -0
- package/dist/lib/type-generation/languages/csharp.d.ts +7 -0
- package/dist/lib/type-generation/languages/csharp.d.ts.map +1 -0
- package/dist/lib/type-generation/languages/csharp.js +180 -0
- package/dist/lib/type-generation/languages/csharp.js.map +1 -0
- package/dist/lib/type-generation/languages/dart.d.ts +8 -0
- package/dist/lib/type-generation/languages/dart.d.ts.map +1 -0
- package/dist/lib/type-generation/languages/dart.js +197 -0
- package/dist/lib/type-generation/languages/dart.js.map +1 -0
- package/dist/lib/type-generation/languages/java.d.ts +7 -0
- package/dist/lib/type-generation/languages/java.d.ts.map +1 -0
- package/dist/lib/type-generation/languages/java.js +140 -0
- package/dist/lib/type-generation/languages/java.js.map +1 -0
- package/dist/lib/type-generation/languages/javascript.d.ts +9 -0
- package/dist/lib/type-generation/languages/javascript.d.ts.map +1 -0
- package/dist/lib/type-generation/languages/javascript.js +108 -0
- package/dist/lib/type-generation/languages/javascript.js.map +1 -0
- package/dist/lib/type-generation/languages/kotlin.d.ts +7 -0
- package/dist/lib/type-generation/languages/kotlin.d.ts.map +1 -0
- package/dist/lib/type-generation/languages/kotlin.js +95 -0
- package/dist/lib/type-generation/languages/kotlin.js.map +1 -0
- package/dist/lib/type-generation/languages/language.d.ts +43 -0
- package/dist/lib/type-generation/languages/language.d.ts.map +1 -0
- package/dist/lib/type-generation/languages/language.js +82 -0
- package/dist/lib/type-generation/languages/language.js.map +1 -0
- package/dist/lib/type-generation/languages/php.d.ts +7 -0
- package/dist/lib/type-generation/languages/php.d.ts.map +1 -0
- package/dist/lib/type-generation/languages/php.js +116 -0
- package/dist/lib/type-generation/languages/php.js.map +1 -0
- package/dist/lib/type-generation/languages/swift.d.ts +7 -0
- package/dist/lib/type-generation/languages/swift.d.ts.map +1 -0
- package/dist/lib/type-generation/languages/swift.js +179 -0
- package/dist/lib/type-generation/languages/swift.js.map +1 -0
- package/dist/lib/type-generation/languages/typescript.d.ts +9 -0
- package/dist/lib/type-generation/languages/typescript.d.ts.map +1 -0
- package/dist/lib/type-generation/languages/typescript.js +112 -0
- package/dist/lib/type-generation/languages/typescript.js.map +1 -0
- package/dist/lib/types.d.ts +133 -0
- package/dist/lib/types.d.ts.map +1 -0
- package/dist/lib/types.js +3 -0
- package/dist/lib/types.js.map +1 -0
- package/dist/lib/utils.d.ts +15 -0
- package/dist/lib/utils.d.ts.map +1 -0
- package/{lib → dist/lib}/utils.js +74 -120
- package/dist/lib/utils.js.map +1 -0
- package/dist/lib/validations.d.ts +2 -0
- package/dist/lib/validations.d.ts.map +1 -0
- package/dist/lib/validations.js +20 -0
- package/dist/lib/validations.js.map +1 -0
- package/docs/examples/databases/upsert-document.md +1 -2
- package/index.ts +152 -0
- package/install.ps1 +2 -5
- package/install.sh +1 -2
- package/lib/client.ts +259 -0
- package/lib/commands/{account.js → account.ts} +410 -664
- package/lib/commands/console.ts +112 -0
- package/lib/commands/{databases.js → databases.ts} +818 -1136
- package/lib/commands/{functions.js → functions.ts} +381 -526
- package/lib/commands/{generic.js → generic.ts} +47 -39
- package/lib/commands/graphql.ts +110 -0
- package/lib/commands/{health.js → health.ts} +168 -284
- package/lib/commands/{init.js → init.ts} +68 -66
- package/lib/commands/{locale.js → locale.ts} +75 -121
- package/lib/commands/{messaging.js → messaging.ts} +699 -937
- package/lib/commands/{migrations.js → migrations.ts} +182 -258
- package/lib/commands/organizations.ts +46 -0
- package/lib/commands/{project.js → project.ts} +75 -111
- package/lib/commands/{projects.js → projects.ts} +587 -843
- package/lib/commands/{proxy.js → proxy.ts} +94 -140
- package/lib/commands/{pull.js → pull.ts} +54 -44
- package/lib/commands/{push.js → push.ts} +235 -191
- package/lib/commands/{run.js → run.ts} +61 -55
- package/lib/commands/{sites.js → sites.ts} +364 -504
- package/lib/commands/{storage.js → storage.ts} +216 -292
- package/lib/commands/{tables-db.js → tables-db.ts} +817 -1126
- package/lib/commands/{teams.js → teams.ts} +162 -236
- package/lib/commands/{tokens.js → tokens.ts} +70 -99
- package/lib/commands/{types.js → types.ts} +37 -35
- package/lib/commands/{update.js → update.ts} +25 -27
- package/lib/commands/{users.js → users.ts} +426 -644
- package/lib/commands/{vcs.js → vcs.ts} +122 -173
- package/lib/config.ts +854 -0
- package/lib/emulation/{docker.js → docker.ts} +39 -38
- package/lib/emulation/utils.ts +193 -0
- package/lib/exception.ts +20 -0
- package/lib/{id.js → id.ts} +5 -5
- package/lib/paginate.ts +63 -0
- package/lib/parser.ts +238 -0
- package/lib/{questions.js → questions.ts} +148 -156
- package/lib/sdks.ts +55 -0
- package/lib/spinner.ts +118 -0
- package/lib/type-generation/attribute.ts +17 -0
- package/lib/type-generation/languages/{csharp.js → csharp.ts} +59 -48
- package/lib/type-generation/languages/{dart.js → dart.ts} +91 -80
- package/lib/type-generation/languages/{java.js → java.ts} +58 -47
- package/lib/type-generation/languages/javascript.ts +111 -0
- package/lib/type-generation/languages/kotlin.ts +96 -0
- package/lib/type-generation/languages/language.ts +119 -0
- package/lib/type-generation/languages/{php.js → php.ts} +55 -48
- package/lib/type-generation/languages/{swift.js → swift.ts} +59 -48
- package/lib/type-generation/languages/typescript.ts +116 -0
- package/lib/types.ts +150 -0
- package/lib/utils.ts +322 -0
- package/lib/validations.ts +17 -0
- package/package.json +21 -12
- package/scoop/appwrite.config.json +3 -3
- package/tsconfig.json +30 -0
- package/index.js +0 -147
- package/lib/client.js +0 -254
- package/lib/commands/console.js +0 -127
- package/lib/commands/graphql.js +0 -126
- package/lib/commands/organizations.js +0 -48
- package/lib/emulation/utils.js +0 -186
- package/lib/exception.js +0 -9
- package/lib/parser.js +0 -250
- package/lib/sdks.js +0 -60
- package/lib/type-generation/attribute.js +0 -16
- package/lib/type-generation/languages/javascript.js +0 -102
- package/lib/type-generation/languages/kotlin.js +0 -85
- package/lib/type-generation/languages/language.js +0 -125
- package/lib/type-generation/languages/typescript.js +0 -107
- package/lib/validations.js +0 -17
|
@@ -1,23 +1,31 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
1
|
+
import { Tail } from 'tail';
|
|
2
|
+
import { parse as parseDotenv } from 'dotenv';
|
|
3
|
+
import chalk from 'chalk';
|
|
4
|
+
import ignore = require('ignore');
|
|
5
|
+
import tar = require('tar');
|
|
6
|
+
import fs = require('fs');
|
|
7
|
+
import chokidar from 'chokidar';
|
|
8
|
+
import inquirer from 'inquirer';
|
|
9
|
+
import path = require('path');
|
|
10
|
+
import { Command } from 'commander';
|
|
11
|
+
import { localConfig, globalConfig } from '../config';
|
|
12
|
+
import { paginate } from '../paginate';
|
|
13
|
+
import { functionsListVariables } from './functions';
|
|
14
|
+
import { questionsRunFunctions } from '../questions';
|
|
15
|
+
import { actionRunner, success, log, warn, error, hint, commandDescriptions, drawTable } from '../parser';
|
|
16
|
+
import { systemHasCommand, isPortTaken, getAllFiles } from '../utils';
|
|
17
|
+
import { runtimeNames, systemTools, JwtManager, Queue } from '../emulation/utils';
|
|
18
|
+
import { dockerStop, dockerCleanup, dockerStart, dockerBuild, dockerPull } from '../emulation/docker';
|
|
19
|
+
|
|
20
|
+
interface RunFunctionOptions {
|
|
21
|
+
port?: string | number;
|
|
22
|
+
functionId?: string;
|
|
23
|
+
withVariables?: boolean;
|
|
24
|
+
reload?: boolean;
|
|
25
|
+
userId?: string;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const runFunction = async ({ port, functionId, withVariables, reload, userId }: RunFunctionOptions = {}): Promise<void> => {
|
|
21
29
|
// Selection
|
|
22
30
|
if(!functionId) {
|
|
23
31
|
const answers = await inquirer.prompt(questionsRunFunctions[0]);
|
|
@@ -25,7 +33,7 @@ const runFunction = async ({ port, functionId, withVariables, reload, userId } =
|
|
|
25
33
|
}
|
|
26
34
|
|
|
27
35
|
const functions = localConfig.getFunctions();
|
|
28
|
-
const func = functions.find((f) => f.$id === functionId);
|
|
36
|
+
const func = functions.find((f: any) => f.$id === functionId);
|
|
29
37
|
if (!func) {
|
|
30
38
|
throw new Error("Function '" + functionId + "' not found.")
|
|
31
39
|
}
|
|
@@ -34,34 +42,35 @@ const runFunction = async ({ port, functionId, withVariables, reload, userId } =
|
|
|
34
42
|
const tool = systemTools[runtimeName];
|
|
35
43
|
|
|
36
44
|
// Configuration: Port
|
|
45
|
+
let portNum: number | null = null;
|
|
37
46
|
if(port) {
|
|
38
|
-
|
|
47
|
+
portNum = +port;
|
|
39
48
|
}
|
|
40
49
|
|
|
41
|
-
if(isNaN(
|
|
42
|
-
|
|
50
|
+
if(isNaN(portNum!)) {
|
|
51
|
+
portNum = null;
|
|
43
52
|
}
|
|
44
53
|
|
|
45
|
-
if(
|
|
46
|
-
const taken = await isPortTaken(
|
|
54
|
+
if(portNum) {
|
|
55
|
+
const taken = await isPortTaken(portNum);
|
|
47
56
|
|
|
48
57
|
if(taken) {
|
|
49
|
-
error(`Port ${
|
|
58
|
+
error(`Port ${portNum} is already in use by another process.`);
|
|
50
59
|
return;
|
|
51
60
|
}
|
|
52
61
|
}
|
|
53
62
|
|
|
54
|
-
if(!
|
|
63
|
+
if(!portNum) {
|
|
55
64
|
let portFound = false;
|
|
56
|
-
|
|
57
|
-
while(
|
|
58
|
-
const taken = await isPortTaken(
|
|
65
|
+
portNum = 3000;
|
|
66
|
+
while(portNum < 3100) {
|
|
67
|
+
const taken = await isPortTaken(portNum);
|
|
59
68
|
if(!taken) {
|
|
60
69
|
portFound = true;
|
|
61
70
|
break;
|
|
62
71
|
}
|
|
63
72
|
|
|
64
|
-
|
|
73
|
+
portNum++;
|
|
65
74
|
}
|
|
66
75
|
|
|
67
76
|
if(!portFound) {
|
|
@@ -112,8 +121,8 @@ const runFunction = async ({ port, functionId, withVariables, reload, userId } =
|
|
|
112
121
|
fs.writeFileSync(errorsPath, '');
|
|
113
122
|
}
|
|
114
123
|
|
|
115
|
-
const userVariables = {};
|
|
116
|
-
const allVariables = {};
|
|
124
|
+
const userVariables: Record<string, string> = {};
|
|
125
|
+
const allVariables: Record<string, string> = {};
|
|
117
126
|
|
|
118
127
|
if(withVariables) {
|
|
119
128
|
try {
|
|
@@ -122,11 +131,11 @@ const runFunction = async ({ port, functionId, withVariables, reload, userId } =
|
|
|
122
131
|
parseOutput: false
|
|
123
132
|
}, 100, 'variables');
|
|
124
133
|
|
|
125
|
-
remoteVariables.forEach((v) => {
|
|
134
|
+
remoteVariables.forEach((v: any) => {
|
|
126
135
|
allVariables[v.key] = v.value;
|
|
127
136
|
userVariables[v.key] = v.value;
|
|
128
137
|
});
|
|
129
|
-
} catch(err) {
|
|
138
|
+
} catch(err: any) {
|
|
130
139
|
warn("Remote variables not fetched. Production environment variables will not be available. Reason: " + err.message);
|
|
131
140
|
}
|
|
132
141
|
}
|
|
@@ -152,11 +161,11 @@ const runFunction = async ({ port, functionId, withVariables, reload, userId } =
|
|
|
152
161
|
|
|
153
162
|
try {
|
|
154
163
|
await JwtManager.setup(userId, func.scopes ?? []);
|
|
155
|
-
} catch(err) {
|
|
164
|
+
} catch(err: any) {
|
|
156
165
|
warn("Dynamic API key not generated. Header x-appwrite-key will not be set. Reason: " + err.message);
|
|
157
166
|
}
|
|
158
167
|
|
|
159
|
-
const headers = {};
|
|
168
|
+
const headers: Record<string, string> = {};
|
|
160
169
|
headers['x-appwrite-key'] = JwtManager.functionJwt ?? '';
|
|
161
170
|
headers['x-appwrite-trigger'] = 'http';
|
|
162
171
|
headers['x-appwrite-event'] = '';
|
|
@@ -167,16 +176,16 @@ const runFunction = async ({ port, functionId, withVariables, reload, userId } =
|
|
|
167
176
|
if(Object.keys(userVariables).length > 0) {
|
|
168
177
|
drawTable(Object.keys(userVariables).map((key) => ({
|
|
169
178
|
key,
|
|
170
|
-
value: userVariables[key].split("").filter((_, i) => i < 16).map(() => "*").join("")
|
|
179
|
+
value: userVariables[key].split("").filter((_: string, i: number) => i < 16).map(() => "*").join("")
|
|
171
180
|
})));
|
|
172
181
|
}
|
|
173
182
|
|
|
174
183
|
await dockerPull(func);
|
|
175
184
|
|
|
176
|
-
new Tail(logsPath).on("line", function(data) {
|
|
185
|
+
new Tail(logsPath).on("line", function(data: string) {
|
|
177
186
|
process.stdout.write(chalk.white(`${data}\n`));
|
|
178
187
|
});
|
|
179
|
-
new Tail(errorsPath).on("line", function(data) {
|
|
188
|
+
new Tail(errorsPath).on("line", function(data: string) {
|
|
180
189
|
process.stdout.write(chalk.white(`${data}\n`));
|
|
181
190
|
});
|
|
182
191
|
|
|
@@ -194,7 +203,7 @@ const runFunction = async ({ port, functionId, withVariables, reload, userId } =
|
|
|
194
203
|
chokidar.watch('.', {
|
|
195
204
|
cwd: path.join(localConfig.getDirname(), func.path),
|
|
196
205
|
ignoreInitial: true,
|
|
197
|
-
ignored: (xpath) => {
|
|
206
|
+
ignored: (xpath: string) => {
|
|
198
207
|
const relativePath = path.relative(functionPath, xpath);
|
|
199
208
|
|
|
200
209
|
if(!relativePath) {
|
|
@@ -202,18 +211,18 @@ const runFunction = async ({ port, functionId, withVariables, reload, userId } =
|
|
|
202
211
|
}
|
|
203
212
|
return ignorer.ignores(relativePath);
|
|
204
213
|
}
|
|
205
|
-
}).on('all', async (_event, filePath) => {
|
|
214
|
+
}).on('all', async (_event: string, filePath: string) => {
|
|
206
215
|
Queue.push(filePath);
|
|
207
216
|
});
|
|
208
217
|
}
|
|
209
218
|
|
|
210
|
-
Queue.events.on('reload', async ({ files }) => {
|
|
219
|
+
Queue.events.on('reload', async ({ files }: { files: string[] }) => {
|
|
211
220
|
Queue.lock();
|
|
212
221
|
|
|
213
222
|
try {
|
|
214
223
|
await dockerStop(func.$id);
|
|
215
224
|
|
|
216
|
-
const dependencyFile = files.find((filePath) => tool.dependencyFiles.includes(filePath));
|
|
225
|
+
const dependencyFile = files.find((filePath: string) => tool.dependencyFiles.includes(filePath));
|
|
217
226
|
if(tool.isCompiled || dependencyFile) {
|
|
218
227
|
log(`Rebuilding the function due to file changes ...`);
|
|
219
228
|
await dockerBuild(func, allVariables);
|
|
@@ -223,7 +232,7 @@ const runFunction = async ({ port, functionId, withVariables, reload, userId } =
|
|
|
223
232
|
return;
|
|
224
233
|
}
|
|
225
234
|
|
|
226
|
-
await dockerStart(func, allVariables,
|
|
235
|
+
await dockerStart(func, allVariables, portNum!);
|
|
227
236
|
} else {
|
|
228
237
|
log('Hot-swapping function.. Files with change are ' + files.join(', '));
|
|
229
238
|
|
|
@@ -247,7 +256,7 @@ const runFunction = async ({ port, functionId, withVariables, reload, userId } =
|
|
|
247
256
|
file: buildPath
|
|
248
257
|
});
|
|
249
258
|
|
|
250
|
-
const ignorer = ignore();
|
|
259
|
+
const ignorer = ignore.default();
|
|
251
260
|
ignorer.add('.appwrite');
|
|
252
261
|
if (func.ignore) {
|
|
253
262
|
ignorer.add(func.ignore);
|
|
@@ -255,7 +264,7 @@ const runFunction = async ({ port, functionId, withVariables, reload, userId } =
|
|
|
255
264
|
ignorer.add(fs.readFileSync(path.join(functionPath, '.gitignore')).toString());
|
|
256
265
|
}
|
|
257
266
|
|
|
258
|
-
const filesToCopy = getAllFiles(functionPath).map((file) => path.relative(functionPath, file)).filter((file) => !ignorer.ignores(file));
|
|
267
|
+
const filesToCopy = getAllFiles(functionPath).map((file: string) => path.relative(functionPath, file)).filter((file: string) => !ignorer.ignores(file));
|
|
259
268
|
for(const f of filesToCopy) {
|
|
260
269
|
const filePath = path.join(hotSwapPath, f);
|
|
261
270
|
if (fs.existsSync(filePath)) {
|
|
@@ -279,7 +288,7 @@ const runFunction = async ({ port, functionId, withVariables, reload, userId } =
|
|
|
279
288
|
file: buildPath
|
|
280
289
|
}, ['.']);
|
|
281
290
|
|
|
282
|
-
await dockerStart(func, allVariables,
|
|
291
|
+
await dockerStart(func, allVariables, portNum!);
|
|
283
292
|
}
|
|
284
293
|
} catch(err) {
|
|
285
294
|
console.error(err);
|
|
@@ -300,17 +309,17 @@ const runFunction = async ({ port, functionId, withVariables, reload, userId } =
|
|
|
300
309
|
|
|
301
310
|
log('Starting function using Docker ...');
|
|
302
311
|
hint('Function automatically restarts when you edit your code.');
|
|
303
|
-
await dockerStart(func, allVariables,
|
|
312
|
+
await dockerStart(func, allVariables, portNum!);
|
|
304
313
|
|
|
305
314
|
Queue.unlock();
|
|
306
315
|
}
|
|
307
316
|
|
|
308
|
-
const run = new Command("run")
|
|
317
|
+
export const run = new Command("run")
|
|
309
318
|
.description(commandDescriptions['run'])
|
|
310
319
|
.configureHelp({
|
|
311
320
|
helpWidth: process.stdout.columns || 80
|
|
312
321
|
})
|
|
313
|
-
.action(actionRunner(async (_options, command) => {
|
|
322
|
+
.action(actionRunner(async (_options: any, command: Command) => {
|
|
314
323
|
command.help();
|
|
315
324
|
}));
|
|
316
325
|
|
|
@@ -325,6 +334,3 @@ run
|
|
|
325
334
|
.option(`--no-reload`, `Prevent live reloading of server when changes are made to function files`)
|
|
326
335
|
.action(actionRunner(runFunction));
|
|
327
336
|
|
|
328
|
-
module.exports = {
|
|
329
|
-
run
|
|
330
|
-
}
|