appwrite-utils-cli 0.10.61 → 0.10.62
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
CHANGED
@@ -147,6 +147,7 @@ This updated CLI ensures that developers have robust tools at their fingertips t
|
|
147
147
|
|
148
148
|
## Changelog
|
149
149
|
|
150
|
+
- 0.10.62: Made `Deploy Function(s)` also update the functions, as not all things (timeout, specification, etc.) are updated via deploy
|
150
151
|
- 0.10.61: Fixed ignore haha, also added `ignore` to the `Functions` config, to specify what to ignore when creating the `.tar.gz` file
|
151
152
|
- 0.10.051: Added `node_modules` and a few others to the ignore
|
152
153
|
- 0.10.05: Made deploy function into deploy function(s) -- so you can do more than one at a time
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import { Client } from "node-appwrite";
|
1
|
+
import { Client, type Models } from "node-appwrite";
|
2
2
|
import { type AppwriteFunction } from "appwrite-utils";
|
3
|
-
export declare const deployFunction: (client: Client, functionId: string, codePath: string, activate?: boolean, entrypoint?: string, commands?: string, ignored?: string[]) => Promise<
|
4
|
-
export declare const deployLocalFunction: (client: Client, functionName: string, functionConfig: AppwriteFunction, functionPath?: string) => Promise<
|
3
|
+
export declare const deployFunction: (client: Client, functionId: string, codePath: string, activate?: boolean, entrypoint?: string, commands?: string, ignored?: string[]) => Promise<Models.Deployment>;
|
4
|
+
export declare const deployLocalFunction: (client: Client, functionName: string, functionConfig: AppwriteFunction, functionPath?: string) => Promise<Models.Deployment>;
|
@@ -8,7 +8,7 @@ import {} from "appwrite-utils";
|
|
8
8
|
import chalk from "chalk";
|
9
9
|
import cliProgress from "cli-progress";
|
10
10
|
import { execSync } from "child_process";
|
11
|
-
import { createFunction, getFunction, updateFunctionSpecifications, } from "./methods.js";
|
11
|
+
import { createFunction, getFunction, updateFunction, updateFunctionSpecifications, } from "./methods.js";
|
12
12
|
import ignore from "ignore";
|
13
13
|
const findFunctionDirectory = (basePath, functionName) => {
|
14
14
|
const normalizedName = functionName.toLowerCase().replace(/\s+/g, "-");
|
@@ -92,8 +92,9 @@ export const deployFunction = async (client, functionId, codePath, activate = tr
|
|
92
92
|
};
|
93
93
|
export const deployLocalFunction = async (client, functionName, functionConfig, functionPath) => {
|
94
94
|
let functionExists = true;
|
95
|
+
let functionThatExists;
|
95
96
|
try {
|
96
|
-
await getFunction(client, functionConfig.$id);
|
97
|
+
functionThatExists = await getFunction(client, functionConfig.$id);
|
97
98
|
}
|
98
99
|
catch (error) {
|
99
100
|
functionExists = false;
|
@@ -126,10 +127,11 @@ export const deployLocalFunction = async (client, functionName, functionConfig,
|
|
126
127
|
}
|
127
128
|
// Only create function if it doesn't exist
|
128
129
|
if (!functionExists) {
|
129
|
-
await createFunction(client, functionConfig.$id, functionConfig.name, functionConfig.runtime, functionConfig.execute, functionConfig.events, functionConfig.schedule, functionConfig.timeout, functionConfig.enabled, functionConfig.logging, functionConfig.entrypoint, functionConfig.commands);
|
130
|
+
await createFunction(client, functionConfig.$id, functionConfig.name, functionConfig.runtime, functionConfig.execute, functionConfig.events, functionConfig.schedule, functionConfig.timeout, functionConfig.enabled, functionConfig.logging, functionConfig.entrypoint, functionConfig.commands, functionConfig.scopes, functionConfig.installationId, functionConfig.providerRepositoryId, functionConfig.providerBranch, functionConfig.providerSilentMode, functionConfig.providerRootDirectory, functionConfig.templateRepository, functionConfig.templateOwner, functionConfig.templateRootDirectory, functionConfig.templateVersion, functionConfig.specification);
|
130
131
|
}
|
131
|
-
|
132
|
-
|
132
|
+
else {
|
133
|
+
console.log(chalk.blue("Updating function..."));
|
134
|
+
await updateFunction(client, functionConfig.$id, functionConfig.name, functionConfig.runtime, functionConfig.execute, functionConfig.events, functionConfig.schedule, functionConfig.timeout, functionConfig.enabled, functionConfig.logging, functionConfig.entrypoint, functionConfig.commands, functionConfig.scopes, functionConfig.installationId, functionConfig.providerRepositoryId, functionConfig.providerBranch, functionConfig.providerSilentMode, functionConfig.providerRootDirectory, functionConfig.specification);
|
133
135
|
}
|
134
136
|
const deployPath = functionConfig.deployDir
|
135
137
|
? join(resolvedPath, functionConfig.deployDir)
|
package/package.json
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"name": "appwrite-utils-cli",
|
3
3
|
"description": "Appwrite Utility Functions to help with database management, data conversion, data import, migrations, and much more. Meant to be used as a CLI tool, I do not recommend installing this in frontend environments.",
|
4
|
-
"version": "0.10.
|
4
|
+
"version": "0.10.62",
|
5
5
|
"main": "src/main.ts",
|
6
6
|
"type": "module",
|
7
7
|
"repository": {
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import { Client, Functions, Runtime } from "node-appwrite";
|
1
|
+
import { Client, Functions, Runtime, type Models } from "node-appwrite";
|
2
2
|
import { InputFile } from "node-appwrite/file";
|
3
3
|
import { create as createTarball } from "tar";
|
4
4
|
import { join, relative } from "node:path";
|
@@ -11,6 +11,7 @@ import { execSync } from "child_process";
|
|
11
11
|
import {
|
12
12
|
createFunction,
|
13
13
|
getFunction,
|
14
|
+
updateFunction,
|
14
15
|
updateFunctionSpecifications,
|
15
16
|
} from "./methods.js";
|
16
17
|
import ignore from "ignore";
|
@@ -147,8 +148,9 @@ export const deployLocalFunction = async (
|
|
147
148
|
functionPath?: string
|
148
149
|
) => {
|
149
150
|
let functionExists = true;
|
151
|
+
let functionThatExists: Models.Function;
|
150
152
|
try {
|
151
|
-
await getFunction(client, functionConfig.$id);
|
153
|
+
functionThatExists = await getFunction(client, functionConfig.$id);
|
152
154
|
} catch (error) {
|
153
155
|
functionExists = false;
|
154
156
|
}
|
@@ -204,14 +206,40 @@ export const deployLocalFunction = async (
|
|
204
206
|
functionConfig.enabled,
|
205
207
|
functionConfig.logging,
|
206
208
|
functionConfig.entrypoint,
|
207
|
-
functionConfig.commands
|
209
|
+
functionConfig.commands,
|
210
|
+
functionConfig.scopes,
|
211
|
+
functionConfig.installationId,
|
212
|
+
functionConfig.providerRepositoryId,
|
213
|
+
functionConfig.providerBranch,
|
214
|
+
functionConfig.providerSilentMode,
|
215
|
+
functionConfig.providerRootDirectory,
|
216
|
+
functionConfig.templateRepository,
|
217
|
+
functionConfig.templateOwner,
|
218
|
+
functionConfig.templateRootDirectory,
|
219
|
+
functionConfig.templateVersion,
|
220
|
+
functionConfig.specification
|
208
221
|
);
|
209
|
-
}
|
210
|
-
|
211
|
-
|
212
|
-
await updateFunctionSpecifications(
|
222
|
+
} else {
|
223
|
+
console.log(chalk.blue("Updating function..."));
|
224
|
+
await updateFunction(
|
213
225
|
client,
|
214
226
|
functionConfig.$id,
|
227
|
+
functionConfig.name,
|
228
|
+
functionConfig.runtime as Runtime,
|
229
|
+
functionConfig.execute,
|
230
|
+
functionConfig.events,
|
231
|
+
functionConfig.schedule,
|
232
|
+
functionConfig.timeout,
|
233
|
+
functionConfig.enabled,
|
234
|
+
functionConfig.logging,
|
235
|
+
functionConfig.entrypoint,
|
236
|
+
functionConfig.commands,
|
237
|
+
functionConfig.scopes,
|
238
|
+
functionConfig.installationId,
|
239
|
+
functionConfig.providerRepositoryId,
|
240
|
+
functionConfig.providerBranch,
|
241
|
+
functionConfig.providerSilentMode,
|
242
|
+
functionConfig.providerRootDirectory,
|
215
243
|
functionConfig.specification
|
216
244
|
);
|
217
245
|
}
|