appwrite-utils-cli 0.10.63 → 0.10.65

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.65: Fixed the stupid local functions not caring about the ignore string, and added `__pycache__` and `.venv` to default ignores
151
+ - 0.10.64: Fixed `Deploy Function(s)` not ignoring things properly
150
152
  - 0.10.63: My `collectLocalFunctions` function was failing to add the `scopes` and a few others to the function, accidentally, fixed now
151
153
  - 0.10.62: Made `Deploy Function(s)` also update the functions, as not all things (timeout, specification, etc.) are updated via deploy
152
154
  - 0.10.61: Fixed ignore haha, also added `ignore` to the `Functions` config, to specify what to ignore when creating the `.tar.gz` file
@@ -27,12 +27,28 @@ 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 = "npm install", ignored = ["node_modules", ".git", ".vscode", ".DS_Store"]) => {
30
+ export const deployFunction = async (client, functionId, codePath, activate = true, entrypoint = "index.js", commands = "npm install", ignored = [
31
+ "node_modules",
32
+ ".git",
33
+ ".vscode",
34
+ ".DS_Store",
35
+ "__pycache__",
36
+ ".venv",
37
+ ]) => {
31
38
  const functions = new Functions(client);
32
39
  console.log(chalk.blue("Preparing function deployment..."));
33
40
  // Convert ignored patterns to lowercase for case-insensitive comparison
34
41
  const ignoredLower = ignored.map((pattern) => pattern.toLowerCase());
35
42
  const tarPath = join(process.cwd(), `function-${functionId}.tar.gz`);
43
+ // Verify codePath exists and is a directory
44
+ if (!fs.existsSync(codePath)) {
45
+ throw new Error(`Function directory not found at ${codePath}`);
46
+ }
47
+ const stats = await fs.promises.stat(codePath);
48
+ if (!stats.isDirectory()) {
49
+ throw new Error(`${codePath} is not a directory`);
50
+ }
51
+ console.log(chalk.blue(`Creating tarball from ${codePath}`));
36
52
  const progressBar = new cliProgress.SingleBar({
37
53
  format: "Uploading |" +
38
54
  chalk.cyan("{bar}") +
@@ -47,10 +63,17 @@ export const deployFunction = async (client, functionId, codePath, activate = tr
47
63
  cwd: codePath,
48
64
  filter: (path, stat) => {
49
65
  const relativePath = relative(codePath, join(codePath, path)).toLowerCase();
50
- return !ignoredLower.some((pattern) => relativePath.startsWith(pattern) ||
51
- relativePath.includes(`/${pattern}`));
66
+ // Skip if path matches any ignored pattern
67
+ if (ignoredLower.some((pattern) => relativePath.startsWith(pattern) ||
68
+ relativePath.includes(`/${pattern}`) ||
69
+ relativePath.includes(`\\${pattern}`))) {
70
+ console.log(chalk.gray(`Ignoring ${path}`));
71
+ return false;
72
+ }
73
+ return true;
52
74
  },
53
- }, ["."]);
75
+ }, ["."] // This now only includes contents of codePath since we set cwd to codePath
76
+ );
54
77
  const fileBuffer = await fs.promises.readFile(tarPath);
55
78
  const fileObject = InputFile.fromBuffer(new Uint8Array(fileBuffer), `function-${functionId}.tar.gz`);
56
79
  try {
@@ -514,6 +514,7 @@ export class InteractiveCLI {
514
514
  events: f.events || [],
515
515
  schedule: f.schedule || "",
516
516
  timeout: f.timeout || 15,
517
+ ignore: f.ignore || [],
517
518
  enabled: f.enabled !== false,
518
519
  logging: f.logging !== false,
519
520
  entrypoint: f.entrypoint || "src/index.ts",
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.63",
4
+ "version": "0.10.65",
5
5
  "main": "src/main.ts",
6
6
  "type": "module",
7
7
  "repository": {
@@ -47,7 +47,14 @@ export const deployFunction = async (
47
47
  activate: boolean = true,
48
48
  entrypoint: string = "index.js",
49
49
  commands: string = "npm install",
50
- ignored: string[] = ["node_modules", ".git", ".vscode", ".DS_Store"]
50
+ ignored: string[] = [
51
+ "node_modules",
52
+ ".git",
53
+ ".vscode",
54
+ ".DS_Store",
55
+ "__pycache__",
56
+ ".venv",
57
+ ]
51
58
  ) => {
52
59
  const functions = new Functions(client);
53
60
  console.log(chalk.blue("Preparing function deployment..."));
@@ -57,6 +64,18 @@ export const deployFunction = async (
57
64
 
58
65
  const tarPath = join(process.cwd(), `function-${functionId}.tar.gz`);
59
66
 
67
+ // Verify codePath exists and is a directory
68
+ if (!fs.existsSync(codePath)) {
69
+ throw new Error(`Function directory not found at ${codePath}`);
70
+ }
71
+
72
+ const stats = await fs.promises.stat(codePath);
73
+ if (!stats.isDirectory()) {
74
+ throw new Error(`${codePath} is not a directory`);
75
+ }
76
+
77
+ console.log(chalk.blue(`Creating tarball from ${codePath}`));
78
+
60
79
  const progressBar = new cliProgress.SingleBar({
61
80
  format:
62
81
  "Uploading |" +
@@ -77,14 +96,22 @@ export const deployFunction = async (
77
96
  codePath,
78
97
  join(codePath, path)
79
98
  ).toLowerCase();
80
- return !ignoredLower.some(
81
- (pattern) =>
82
- relativePath.startsWith(pattern) ||
83
- relativePath.includes(`/${pattern}`)
84
- );
99
+ // Skip if path matches any ignored pattern
100
+ if (
101
+ ignoredLower.some(
102
+ (pattern) =>
103
+ relativePath.startsWith(pattern) ||
104
+ relativePath.includes(`/${pattern}`) ||
105
+ relativePath.includes(`\\${pattern}`)
106
+ )
107
+ ) {
108
+ console.log(chalk.gray(`Ignoring ${path}`));
109
+ return false;
110
+ }
111
+ return true;
85
112
  },
86
113
  },
87
- ["."]
114
+ ["."] // This now only includes contents of codePath since we set cwd to codePath
88
115
  );
89
116
 
90
117
  const fileBuffer = await fs.promises.readFile(tarPath);
@@ -712,6 +712,7 @@ export class InteractiveCLI {
712
712
  events: f.events || [],
713
713
  schedule: f.schedule || "",
714
714
  timeout: f.timeout || 15,
715
+ ignore: f.ignore || [],
715
716
  enabled: f.enabled !== false,
716
717
  logging: f.logging !== false,
717
718
  entrypoint: f.entrypoint || "src/index.ts",