@@ -31,8 +31,6 @@ const systemTools = {
31
31
// TODO: Add all runtime needs
32
32
};
33
33
34
- // TODO: Logs dont work
35
-
36
34
const Queue = {
37
35
files: [],
38
36
locked: false,
@@ -217,7 +215,7 @@ async function dockerCleanup() {
217
215
}
218
216
}
219
217
220
- const runFunction = async ({ port, engine, functionId } = {}) => {
218
+ const runFunction = async ({ port, engine, functionId, noVariables, noReload } = {}) => {
221
219
// Selection
222
220
if(!functionId) {
223
221
const answers = await inquirer.prompt(questionsRunFunctions[0]);
@@ -320,21 +318,22 @@ const runFunction = async ({ port, engine, functionId } = {}) => {
320
318
}
321
319
322
320
let variables = [];
323
- if (globalConfig.getEndpoint() === '' || globalConfig.getCookie() === '') {
324
- // TODO: Flag to disable
325
- error("No user is signed in. To sign in, run: appwrite login. Function will run locally, but will not have your function's environment variables set.");
326
- } else {
327
- const { variables: remoteVariables } = await paginate(functionsListVariables, {
328
- functionId: func['$id'],
329
- parseOutput: false
330
- }, 100, 'variables');
331
-
332
- remoteVariables.forEach((v) => {
333
- variables.push({
334
- key: v.key,
335
- value: v.value
321
+ if(!noVariables) {
322
+ if (globalConfig.getEndpoint() === '' || globalConfig.getCookie() === '') {
323
+ error("No user is signed in. To sign in, run: appwrite login. Function will run locally, but will not have your function's environment variables set.");
324
+ } else {
325
+ const { variables: remoteVariables } = await paginate(functionsListVariables, {
326
+ functionId: func['$id'],
327
+ parseOutput: false
328
+ }, 100, 'variables');
329
+
330
+ remoteVariables.forEach((v) => {
331
+ variables.push({
332
+ key: v.key,
333
+ value: v.value
334
+ });
336
335
});
337
- });
336
+ }
338
337
}
339
338
340
339
await dockerPull(func);
@@ -348,13 +347,15 @@ const runFunction = async ({ port, engine, functionId } = {}) => {
348
347
console.log(data);
349
348
});
350
349
351
- chokidar.watch('.', {
352
- cwd: path.join(process.cwd(), func.path),
353
- ignoreInitial: true,
354
- ignored: [ ...(func.ignore ?? []), 'code.tar.gz', '.appwrite', '.appwrite/', '.appwrite/*', '.appwrite/**', '.appwrite/*.*', '.appwrite/**/*.*' ]
355
- }).on('all', async (_event, filePath) => {
356
- Queue.push(filePath);
357
- });
350
+ if(!noReload) {
351
+ chokidar.watch('.', {
352
+ cwd: path.join(process.cwd(), func.path),
353
+ ignoreInitial: true,
354
+ ignored: [ ...(func.ignore ?? []), 'code.tar.gz', '.appwrite', '.appwrite/', '.appwrite/*', '.appwrite/**', '.appwrite/*.*', '.appwrite/**/*.*' ]
355
+ }).on('all', async (_event, filePath) => {
356
+ Queue.push(filePath);
357
+ });
358
+ }
358
359
359
360
Queue.events.on('reload', async ({ files }) => {
360
361
Queue.lock();
459
460
.option(`--functionId <functionId >`, `Function ID`)
460
461
.option(`--port <port >`, `Local port`)
461
462
.option(`--engine <engine >`, `Local engine, "system" or "docker"`)
462
- // TODO: Option to disable auto reloading
463
- // TODO: Option to enable write operations to function folder
463
+ .option(`--noVariables`, `Prevent pulling variables from function settings`)
464
+ .option(`--noReload`, `Prevent live reloading of server when changes are made to function files`)
464
465
.action(actionRunner(runFunction));
465
466
466
467
module.exports = {
0 commit comments