appwrite-utils-cli 0.10.6 → 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,7 @@ 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
150
151
  - 0.10.051: Added `node_modules` and a few others to the ignore
151
152
  - 0.10.05: Made deploy function into deploy function(s) -- so you can do more than one at a time
152
153
  - 0.10.04: Fixed stupid progress bar not updating -- also fixed double text
@@ -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";
@@ -27,18 +27,12 @@ const findFunctionDirectory = (basePath, functionName) => {
27
27
  }
28
28
  return undefined;
29
29
  };
30
- export const deployFunction = async (client, functionId, codePath, activate = true, entrypoint = "index.js", commands) => {
30
+ export const deployFunction = async (client, functionId, codePath, activate = true, entrypoint = "index.js", commands = "npm install", ignored = ["node_modules", ".git", ".vscode", ".DS_Store"]) => {
31
31
  const functions = new Functions(client);
32
32
  console.log(chalk.blue("Preparing function deployment..."));
33
- // Setup ignore rules
34
- const ig = ignore.default();
35
- ig.add(["node_modules", ".git", ".vscode", ".DS_Store"]); // Common directories to ignore
36
- // Read .gitignore if it exists
37
- const gitignorePath = join(codePath, ".gitignore");
38
- if (fs.existsSync(gitignorePath)) {
39
- const gitignoreContent = fs.readFileSync(gitignorePath, "utf8");
40
- ig.add(gitignoreContent);
41
- }
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`);
42
36
  const progressBar = new cliProgress.SingleBar({
43
37
  format: "Uploading |" +
44
38
  chalk.cyan("{bar}") +
@@ -47,12 +41,15 @@ export const deployFunction = async (client, functionId, codePath, activate = tr
47
41
  barIncompleteChar: "░",
48
42
  hideCursor: true,
49
43
  });
50
- const tarPath = join(process.cwd(), `function-${functionId}.tar.gz`);
51
44
  await createTarball({
52
45
  gzip: true,
53
46
  file: tarPath,
54
47
  cwd: codePath,
55
- filter: (path) => !ig.ignores(path), // Use ignore to filter files
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
+ },
56
53
  }, ["."]);
57
54
  const fileBuffer = await fs.promises.readFile(tarPath);
58
55
  const fileObject = InputFile.fromBuffer(new Uint8Array(fileBuffer), `function-${functionId}.tar.gz`);
@@ -137,5 +134,5 @@ export const deployLocalFunction = async (client, functionName, functionConfig,
137
134
  const deployPath = functionConfig.deployDir
138
135
  ? join(resolvedPath, functionConfig.deployDir)
139
136
  : resolvedPath;
140
- 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);
141
138
  };
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.06",
4
+ "version": "0.10.61",
5
5
  "main": "src/main.ts",
6
6
  "type": "module",
7
7
  "repository": {
@@ -31,7 +31,7 @@
31
31
  },
32
32
  "dependencies": {
33
33
  "@types/inquirer": "^9.0.7",
34
- "appwrite-utils": "^0.3.97",
34
+ "appwrite-utils": "^0.3.98",
35
35
  "chalk": "^5.3.0",
36
36
  "cli-progress": "^3.12.0",
37
37
  "commander": "^12.1.0",
@@ -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";
@@ -45,21 +45,16 @@ export const deployFunction = async (
45
45
  codePath: string,
46
46
  activate: boolean = true,
47
47
  entrypoint: string = "index.js",
48
- commands?: string
48
+ commands: string = "npm install",
49
+ ignored: string[] = ["node_modules", ".git", ".vscode", ".DS_Store"]
49
50
  ) => {
50
51
  const functions = new Functions(client);
51
52
  console.log(chalk.blue("Preparing function deployment..."));
52
53
 
53
- // Setup ignore rules
54
- const ig = ignore.default();
55
- ig.add(["node_modules", ".git", ".vscode", ".DS_Store"]); // Common directories to ignore
54
+ // Convert ignored patterns to lowercase for case-insensitive comparison
55
+ const ignoredLower = ignored.map((pattern) => pattern.toLowerCase());
56
56
 
57
- // Read .gitignore if it exists
58
- const gitignorePath = join(codePath, ".gitignore");
59
- if (fs.existsSync(gitignorePath)) {
60
- const gitignoreContent = fs.readFileSync(gitignorePath, "utf8");
61
- ig.add(gitignoreContent);
62
- }
57
+ const tarPath = join(process.cwd(), `function-${functionId}.tar.gz`);
63
58
 
64
59
  const progressBar = new cliProgress.SingleBar({
65
60
  format:
@@ -71,14 +66,22 @@ export const deployFunction = async (
71
66
  hideCursor: true,
72
67
  });
73
68
 
74
- const tarPath = join(process.cwd(), `function-${functionId}.tar.gz`);
75
-
76
69
  await createTarball(
77
70
  {
78
71
  gzip: true,
79
72
  file: tarPath,
80
73
  cwd: codePath,
81
- filter: (path) => !ig.ignores(path), // Use ignore to filter files
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
+ },
82
85
  },
83
86
  ["."]
84
87
  );
@@ -223,6 +226,7 @@ export const deployLocalFunction = async (
223
226
  deployPath,
224
227
  true,
225
228
  functionConfig.entrypoint,
226
- functionConfig.commands
229
+ functionConfig.commands,
230
+ functionConfig.ignore
227
231
  );
228
232
  };