appwrite-utils-cli 0.9.62 → 0.9.63
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.
@@ -2,7 +2,7 @@ import path from "path";
|
|
2
2
|
import fs from "fs";
|
3
3
|
import {} from "appwrite-utils";
|
4
4
|
import { register } from "tsx/esm/api"; // Import the register function
|
5
|
-
import {
|
5
|
+
import { pathToFileURL } from "node:url";
|
6
6
|
/**
|
7
7
|
* Recursively searches for a file named 'appwriteConfig.ts' starting from the given directory.
|
8
8
|
* @param dir The directory to start the search from.
|
@@ -15,12 +15,12 @@ export const findAppwriteConfig = (dir) => {
|
|
15
15
|
const files = fs.readdirSync(dir, { withFileTypes: true });
|
16
16
|
for (const file of files) {
|
17
17
|
if (file.isDirectory() && file.name !== "node_modules") {
|
18
|
-
const result = findAppwriteConfig(path.
|
18
|
+
const result = findAppwriteConfig(path.join(dir, file.name));
|
19
19
|
if (result)
|
20
20
|
return result;
|
21
21
|
}
|
22
22
|
else if (file.name === "appwriteConfig.ts") {
|
23
|
-
return path.
|
23
|
+
return path.join(dir, file.name);
|
24
24
|
}
|
25
25
|
}
|
26
26
|
return null;
|
@@ -35,13 +35,15 @@ export const loadConfig = async (configDir) => {
|
|
35
35
|
try {
|
36
36
|
const configPath = path.join(configDir, "appwriteConfig.ts");
|
37
37
|
console.log(`Loading config from: ${configPath}`);
|
38
|
-
const
|
38
|
+
const configUrl = pathToFileURL(configPath).href;
|
39
|
+
const config = (await import(configUrl)).default;
|
39
40
|
const collectionsDir = path.join(configDir, "collections");
|
40
41
|
const collectionFiles = fs.readdirSync(collectionsDir);
|
41
42
|
config.collections = [];
|
42
43
|
for (const file of collectionFiles) {
|
43
44
|
const filePath = path.join(collectionsDir, file);
|
44
|
-
const
|
45
|
+
const fileUrl = pathToFileURL(filePath).href;
|
46
|
+
const collectionModule = (await import(fileUrl)).default;
|
45
47
|
config.collections.push(collectionModule);
|
46
48
|
}
|
47
49
|
return config;
|
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.9.
|
4
|
+
"version": "0.9.63",
|
5
5
|
"main": "src/main.ts",
|
6
6
|
"type": "module",
|
7
7
|
"repository": {
|
package/src/utils/loadConfigs.ts
CHANGED
@@ -2,7 +2,7 @@ import path from "path";
|
|
2
2
|
import fs from "fs";
|
3
3
|
import { type AppwriteConfig, type Collection } from "appwrite-utils";
|
4
4
|
import { register } from "tsx/esm/api"; // Import the register function
|
5
|
-
import {
|
5
|
+
import { pathToFileURL } from "node:url";
|
6
6
|
|
7
7
|
/**
|
8
8
|
* Recursively searches for a file named 'appwriteConfig.ts' starting from the given directory.
|
@@ -17,10 +17,10 @@ export const findAppwriteConfig = (dir: string): string | null => {
|
|
17
17
|
|
18
18
|
for (const file of files) {
|
19
19
|
if (file.isDirectory() && file.name !== "node_modules") {
|
20
|
-
const result = findAppwriteConfig(path.
|
20
|
+
const result = findAppwriteConfig(path.join(dir, file.name));
|
21
21
|
if (result) return result;
|
22
22
|
} else if (file.name === "appwriteConfig.ts") {
|
23
|
-
return path.
|
23
|
+
return path.join(dir, file.name);
|
24
24
|
}
|
25
25
|
}
|
26
26
|
|
@@ -40,7 +40,8 @@ export const loadConfig = async (
|
|
40
40
|
try {
|
41
41
|
const configPath = path.join(configDir, "appwriteConfig.ts");
|
42
42
|
console.log(`Loading config from: ${configPath}`);
|
43
|
-
const
|
43
|
+
const configUrl = pathToFileURL(configPath).href;
|
44
|
+
const config = (await import(configUrl)).default as AppwriteConfig;
|
44
45
|
|
45
46
|
const collectionsDir = path.join(configDir, "collections");
|
46
47
|
const collectionFiles = fs.readdirSync(collectionsDir);
|
@@ -49,7 +50,8 @@ export const loadConfig = async (
|
|
49
50
|
|
50
51
|
for (const file of collectionFiles) {
|
51
52
|
const filePath = path.join(collectionsDir, file);
|
52
|
-
const
|
53
|
+
const fileUrl = pathToFileURL(filePath).href;
|
54
|
+
const collectionModule = (await import(fileUrl)).default as Collection;
|
53
55
|
config.collections.push(collectionModule);
|
54
56
|
}
|
55
57
|
|