appwrite-utils-cli 0.0.281 → 0.0.282

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/dist/main.js CHANGED
@@ -34,7 +34,8 @@ program.on("--help", () => {
34
34
  });
35
35
  // Parse and handle options
36
36
  program.action(async (options) => {
37
- const controller = new UtilsController();
37
+ const currentUserDir = process.cwd();
38
+ const controller = new UtilsController(currentUserDir);
38
39
  try {
39
40
  // Convert Commander options to the format expected by UtilsController
40
41
  const setupOptions = {
@@ -8,9 +8,12 @@ import { register } from "tsx/esm/api"; // Import the register function
8
8
  * @returns The path to the file if found, or null if not found.
9
9
  */
10
10
  export const findAppwriteConfig = (dir) => {
11
+ if (dir === "node_modules") {
12
+ return null;
13
+ }
11
14
  const files = fs.readdirSync(dir, { withFileTypes: true });
12
15
  for (const file of files) {
13
- if (file.isDirectory()) {
16
+ if (file.isDirectory() && file.name !== "node_modules") {
14
17
  const result = findAppwriteConfig(path.join(dir, file.name));
15
18
  if (result)
16
19
  return result;
@@ -30,6 +33,7 @@ export const loadConfig = async (configDir) => {
30
33
  const unregister = register(); // Register tsx enhancement
31
34
  try {
32
35
  const configPath = path.resolve(configDir, "appwriteConfig.ts");
36
+ console.log(`Loading config from: ${configPath}`);
33
37
  const config = (await import(configPath)).default;
34
38
  const collectionsDir = path.resolve(configDir, "collections");
35
39
  const collectionFiles = fs.readdirSync(collectionsDir);
@@ -27,7 +27,7 @@ export declare class UtilsController {
27
27
  converterDefinitions: ConverterFunctions;
28
28
  validityRuleDefinitions: ValidationRules;
29
29
  afterImportActionsDefinitions: AfterImportActions;
30
- constructor();
30
+ constructor(currentUserDir: string);
31
31
  init(setupOptions: SetupOptions): Promise<void>;
32
32
  run(options: SetupOptions): Promise<void>;
33
33
  }
@@ -22,14 +22,17 @@ export class UtilsController {
22
22
  converterDefinitions = converterFunctions;
23
23
  validityRuleDefinitions = validationRules;
24
24
  afterImportActionsDefinitions = afterImportActions;
25
- constructor() {
26
- const basePath = process.cwd(); // Gets the current working directory
25
+ constructor(currentUserDir) {
26
+ const basePath = currentUserDir; // Gets the current working directory
27
27
  const appwriteConfigFound = findAppwriteConfig(basePath);
28
28
  if (!appwriteConfigFound) {
29
29
  throw new Error("Failed to find appwriteConfig.ts");
30
30
  }
31
31
  this.appwriteConfigPath = appwriteConfigFound;
32
32
  this.appwriteFolderPath = path.dirname(appwriteConfigFound);
33
+ if (!this.appwriteFolderPath) {
34
+ throw new Error("Failed to get appwriteFolderPath");
35
+ }
33
36
  }
34
37
  // async loadCustomDefinitions(): Promise<void> {
35
38
  // try {
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.0.281",
4
+ "version": "0.0.282",
5
5
  "main": "src/main.ts",
6
6
  "type": "module",
7
7
  "repository": {
package/src/main.ts CHANGED
@@ -49,7 +49,8 @@ program.on("--help", () => {
49
49
 
50
50
  // Parse and handle options
51
51
  program.action(async (options) => {
52
- const controller = new UtilsController();
52
+ const currentUserDir = process.cwd();
53
+ const controller = new UtilsController(currentUserDir);
53
54
  try {
54
55
  // Convert Commander options to the format expected by UtilsController
55
56
  const setupOptions = {
@@ -9,10 +9,13 @@ import { register } from "tsx/esm/api"; // Import the register function
9
9
  * @returns The path to the file if found, or null if not found.
10
10
  */
11
11
  export const findAppwriteConfig = (dir: string): string | null => {
12
+ if (dir === "node_modules") {
13
+ return null;
14
+ }
12
15
  const files = fs.readdirSync(dir, { withFileTypes: true });
13
16
 
14
17
  for (const file of files) {
15
- if (file.isDirectory()) {
18
+ if (file.isDirectory() && file.name !== "node_modules") {
16
19
  const result = findAppwriteConfig(path.join(dir, file.name));
17
20
  if (result) return result;
18
21
  } else if (file.name === "appwriteConfig.ts") {
@@ -35,6 +38,7 @@ export const loadConfig = async (
35
38
 
36
39
  try {
37
40
  const configPath = path.resolve(configDir, "appwriteConfig.ts");
41
+ console.log(`Loading config from: ${configPath}`);
38
42
  const config = (await import(configPath)).default as AppwriteConfig;
39
43
 
40
44
  const collectionsDir = path.resolve(configDir, "collections");
@@ -61,14 +61,17 @@ export class UtilsController {
61
61
  public validityRuleDefinitions: ValidationRules = validationRules;
62
62
  public afterImportActionsDefinitions: AfterImportActions = afterImportActions;
63
63
 
64
- constructor() {
65
- const basePath = process.cwd(); // Gets the current working directory
64
+ constructor(currentUserDir: string) {
65
+ const basePath = currentUserDir; // Gets the current working directory
66
66
  const appwriteConfigFound = findAppwriteConfig(basePath);
67
67
  if (!appwriteConfigFound) {
68
68
  throw new Error("Failed to find appwriteConfig.ts");
69
69
  }
70
70
  this.appwriteConfigPath = appwriteConfigFound;
71
71
  this.appwriteFolderPath = path.dirname(appwriteConfigFound);
72
+ if (!this.appwriteFolderPath) {
73
+ throw new Error("Failed to get appwriteFolderPath");
74
+ }
72
75
  }
73
76
 
74
77
  // async loadCustomDefinitions(): Promise<void> {