appwrite-utils-cli 0.10.5 → 0.10.61

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,8 @@ This updated CLI ensures that developers have robust tools at their fingertips t
147
147
 
148
148
  ## Changelog
149
149
 
150
+ - 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
+ - 0.10.051: Added `node_modules` and a few others to the ignore
150
152
  - 0.10.05: Made deploy function into deploy function(s) -- so you can do more than one at a time
151
153
  - 0.10.04: Fixed stupid progress bar not updating -- also fixed double text
152
154
  - 0.10.03: Fixed `syncDb` to push the configurations properly, accidentally hurt it during `synchronizeConfigurations`
@@ -1,4 +1,4 @@
1
1
  import { Client } 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) => Promise<import("node-appwrite").Models.Deployment>;
3
+ export declare const deployFunction: (client: Client, functionId: string, codePath: string, activate?: boolean, entrypoint?: string, commands?: string, ignored?: string[]) => Promise<import("node-appwrite").Models.Deployment>;
4
4
  export declare const deployLocalFunction: (client: Client, functionName: string, functionConfig: AppwriteFunction, functionPath?: string) => Promise<import("node-appwrite").Models.Deployment>;
@@ -1,7 +1,7 @@
1
1
  import { Client, Functions, Runtime } from "node-appwrite";
2
2
  import { InputFile } from "node-appwrite/file";
3
3
  import { create as createTarball } from "tar";
4
- import { join } from "node:path";
4
+ import { join, relative } from "node:path";
5
5
  import fs from "node:fs";
6
6
  import { platform } from "node:os";
7
7
  import {} from "appwrite-utils";
@@ -9,6 +9,7 @@ import chalk from "chalk";
9
9
  import cliProgress from "cli-progress";
10
10
  import { execSync } from "child_process";
11
11
  import { createFunction, getFunction, updateFunctionSpecifications, } from "./methods.js";
12
+ import ignore from "ignore";
12
13
  const findFunctionDirectory = (basePath, functionName) => {
13
14
  const normalizedName = functionName.toLowerCase().replace(/\s+/g, "-");
14
15
  const dirs = fs.readdirSync(basePath, { withFileTypes: true });
@@ -26,9 +27,12 @@ const findFunctionDirectory = (basePath, functionName) => {
26
27
  }
27
28
  return undefined;
28
29
  };
29
- export const deployFunction = async (client, functionId, codePath, activate = true, entrypoint = "index.js", commands = "npm install") => {
30
+ export const deployFunction = async (client, functionId, codePath, activate = true, entrypoint = "index.js", commands = "npm install", ignored = ["node_modules", ".git", ".vscode", ".DS_Store"]) => {
30
31
  const functions = new Functions(client);
31
- console.log(chalk.blue("📦 Preparing function deployment..."));
32
+ console.log(chalk.blue("Preparing function deployment..."));
33
+ // Convert ignored patterns to lowercase for case-insensitive comparison
34
+ const ignoredLower = ignored.map((pattern) => pattern.toLowerCase());
35
+ const tarPath = join(process.cwd(), `function-${functionId}.tar.gz`);
32
36
  const progressBar = new cliProgress.SingleBar({
33
37
  format: "Uploading |" +
34
38
  chalk.cyan("{bar}") +
@@ -37,11 +41,15 @@ export const deployFunction = async (client, functionId, codePath, activate = tr
37
41
  barIncompleteChar: "░",
38
42
  hideCursor: true,
39
43
  });
40
- const tarPath = join(process.cwd(), `function-${functionId}.tar.gz`);
41
44
  await createTarball({
42
45
  gzip: true,
43
46
  file: tarPath,
44
47
  cwd: codePath,
48
+ filter: (path, stat) => {
49
+ const relativePath = relative(codePath, join(codePath, path)).toLowerCase();
50
+ return !ignoredLower.some((pattern) => relativePath.startsWith(pattern) ||
51
+ relativePath.includes(`/${pattern}`));
52
+ },
45
53
  }, ["."]);
46
54
  const fileBuffer = await fs.promises.readFile(tarPath);
47
55
  const fileObject = InputFile.fromBuffer(new Uint8Array(fileBuffer), `function-${functionId}.tar.gz`);
@@ -126,5 +134,5 @@ export const deployLocalFunction = async (client, functionName, functionConfig,
126
134
  const deployPath = functionConfig.deployDir
127
135
  ? join(resolvedPath, functionConfig.deployDir)
128
136
  : resolvedPath;
129
- return deployFunction(client, functionConfig.$id, deployPath, true, functionConfig.entrypoint, functionConfig.commands);
137
+ return deployFunction(client, functionConfig.$id, deployPath, true, functionConfig.entrypoint, functionConfig.commands, functionConfig.ignore);
130
138
  };
package/dist/main.js CHANGED
File without changes
package/package.json CHANGED
@@ -1,57 +1,58 @@
1
- {
2
- "name": "appwrite-utils-cli",
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.05",
5
- "main": "src/main.ts",
6
- "type": "module",
7
- "repository": {
8
- "type": "git",
9
- "url": "https://github.com/zachhandley/AppwriteUtils"
10
- },
11
- "author": "Zach Handley <zach@blackleafdigital.com> (https://zachhandley.com)",
12
- "keywords": [
13
- "appwrite",
14
- "cli",
15
- "utils",
16
- "migrations",
17
- "data",
18
- "database",
19
- "import",
20
- "migration",
21
- "utility"
22
- ],
23
- "bin": {
24
- "appwrite-migrate": "./dist/main.js"
25
- },
26
- "scripts": {
27
- "build": "bun run tsc",
28
- "start": "tsx --no-cache src/main.ts",
29
- "deploy": "bun run build && npm publish --access public",
30
- "postinstall": "echo 'This package is intended for CLI use only and should not be added as a dependency in other projects.'"
31
- },
32
- "dependencies": {
33
- "@types/inquirer": "^9.0.7",
34
- "appwrite-utils": "^0.3.97",
35
- "chalk": "^5.3.0",
36
- "cli-progress": "^3.12.0",
37
- "commander": "^12.1.0",
38
- "inquirer": "^9.3.6",
39
- "js-yaml": "^4.1.0",
40
- "lodash": "^4.17.21",
41
- "luxon": "^3.5.0",
42
- "nanostores": "^0.10.3",
43
- "node-appwrite": "^14.1.0",
44
- "tar": "^7.4.3",
45
- "tsx": "^4.17.0",
46
- "ulidx": "^2.4.0",
47
- "winston": "^3.14.2",
48
- "zod": "^3.23.8"
49
- },
50
- "devDependencies": {
51
- "@types/cli-progress": "^3.11.6",
52
- "@types/js-yaml": "^4.0.9",
53
- "@types/lodash": "^4.17.7",
54
- "@types/luxon": "^3.4.2",
55
- "typescript": "^5.5.4"
56
- }
57
- }
1
+ {
2
+ "name": "appwrite-utils-cli",
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.61",
5
+ "main": "src/main.ts",
6
+ "type": "module",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "https://github.com/zachhandley/AppwriteUtils"
10
+ },
11
+ "author": "Zach Handley <zach@blackleafdigital.com> (https://zachhandley.com)",
12
+ "keywords": [
13
+ "appwrite",
14
+ "cli",
15
+ "utils",
16
+ "migrations",
17
+ "data",
18
+ "database",
19
+ "import",
20
+ "migration",
21
+ "utility"
22
+ ],
23
+ "bin": {
24
+ "appwrite-migrate": "./dist/main.js"
25
+ },
26
+ "scripts": {
27
+ "build": "bun run tsc",
28
+ "start": "tsx --no-cache src/main.ts",
29
+ "deploy": "bun run build && npm publish --access public",
30
+ "postinstall": "echo 'This package is intended for CLI use only and should not be added as a dependency in other projects.'"
31
+ },
32
+ "dependencies": {
33
+ "@types/inquirer": "^9.0.7",
34
+ "appwrite-utils": "^0.3.98",
35
+ "chalk": "^5.3.0",
36
+ "cli-progress": "^3.12.0",
37
+ "commander": "^12.1.0",
38
+ "ignore": "^6.0.2",
39
+ "inquirer": "^9.3.6",
40
+ "js-yaml": "^4.1.0",
41
+ "lodash": "^4.17.21",
42
+ "luxon": "^3.5.0",
43
+ "nanostores": "^0.10.3",
44
+ "node-appwrite": "^14.1.0",
45
+ "tar": "^7.4.3",
46
+ "tsx": "^4.17.0",
47
+ "ulidx": "^2.4.0",
48
+ "winston": "^3.14.2",
49
+ "zod": "^3.23.8"
50
+ },
51
+ "devDependencies": {
52
+ "@types/cli-progress": "^3.11.6",
53
+ "@types/js-yaml": "^4.0.9",
54
+ "@types/lodash": "^4.17.7",
55
+ "@types/luxon": "^3.4.2",
56
+ "typescript": "^5.5.4"
57
+ }
58
+ }
@@ -1,7 +1,7 @@
1
1
  import { Client, Functions, Runtime } from "node-appwrite";
2
2
  import { InputFile } from "node-appwrite/file";
3
3
  import { create as createTarball } from "tar";
4
- import { join } from "node:path";
4
+ import { join, relative } from "node:path";
5
5
  import fs from "node:fs";
6
6
  import { platform } from "node:os";
7
7
  import { type AppwriteFunction, type Specification } from "appwrite-utils";
@@ -13,6 +13,7 @@ import {
13
13
  getFunction,
14
14
  updateFunctionSpecifications,
15
15
  } from "./methods.js";
16
+ import ignore from "ignore";
16
17
 
17
18
  const findFunctionDirectory = (
18
19
  basePath: string,
@@ -44,10 +45,16 @@ export const deployFunction = async (
44
45
  codePath: string,
45
46
  activate: boolean = true,
46
47
  entrypoint: string = "index.js",
47
- commands: string = "npm install"
48
+ commands: string = "npm install",
49
+ ignored: string[] = ["node_modules", ".git", ".vscode", ".DS_Store"]
48
50
  ) => {
49
51
  const functions = new Functions(client);
50
- console.log(chalk.blue("📦 Preparing function deployment..."));
52
+ console.log(chalk.blue("Preparing function deployment..."));
53
+
54
+ // Convert ignored patterns to lowercase for case-insensitive comparison
55
+ const ignoredLower = ignored.map((pattern) => pattern.toLowerCase());
56
+
57
+ const tarPath = join(process.cwd(), `function-${functionId}.tar.gz`);
51
58
 
52
59
  const progressBar = new cliProgress.SingleBar({
53
60
  format:
@@ -59,12 +66,22 @@ export const deployFunction = async (
59
66
  hideCursor: true,
60
67
  });
61
68
 
62
- const tarPath = join(process.cwd(), `function-${functionId}.tar.gz`);
63
69
  await createTarball(
64
70
  {
65
71
  gzip: true,
66
72
  file: tarPath,
67
73
  cwd: codePath,
74
+ filter: (path, stat) => {
75
+ const relativePath = relative(
76
+ codePath,
77
+ join(codePath, path)
78
+ ).toLowerCase();
79
+ return !ignoredLower.some(
80
+ (pattern) =>
81
+ relativePath.startsWith(pattern) ||
82
+ relativePath.includes(`/${pattern}`)
83
+ );
84
+ },
68
85
  },
69
86
  ["."]
70
87
  );
@@ -209,6 +226,7 @@ export const deployLocalFunction = async (
209
226
  deployPath,
210
227
  true,
211
228
  functionConfig.entrypoint,
212
- functionConfig.commands
229
+ functionConfig.commands,
230
+ functionConfig.ignore
213
231
  );
214
232
  };