appwrite-utils-cli 1.0.6 โ 1.0.7
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 +2 -0
- package/dist/config/yamlConfig.js +0 -9
- package/dist/interactiveCLI.js +17 -17
- package/dist/utils/loadConfigs.js +5 -5
- package/package.json +1 -1
- package/src/config/yamlConfig.ts +0 -9
- package/src/interactiveCLI.ts +17 -17
- package/src/utils/loadConfigs.ts +6 -5
package/README.md
CHANGED
@@ -327,6 +327,8 @@ This updated CLI ensures that developers have robust tools at their fingertips t
|
|
327
327
|
|
328
328
|
## Changelog
|
329
329
|
|
330
|
+
### 1.0.7 - Forgot to remove debug logs
|
331
|
+
|
330
332
|
### 1.0.6 - Cross-Language Constants Generation
|
331
333
|
|
332
334
|
**๐ Enhanced Developer Experience with Multi-Language Constants**
|
@@ -243,17 +243,13 @@ export const findYamlConfig = (startDir) => {
|
|
243
243
|
path.join(startDir, "appwrite.yaml"),
|
244
244
|
path.join(startDir, "appwrite.yml"),
|
245
245
|
];
|
246
|
-
console.log(`DEBUG: Checking YAML paths in ${startDir}:`);
|
247
246
|
for (const configPath of possiblePaths) {
|
248
|
-
console.log(` - ${configPath}: ${fs.existsSync(configPath)}`);
|
249
247
|
if (fs.existsSync(configPath)) {
|
250
248
|
return configPath;
|
251
249
|
}
|
252
250
|
}
|
253
251
|
// Recursively search subdirectories for .appwrite folders
|
254
|
-
console.log(`DEBUG: Starting recursive search from ${startDir}`);
|
255
252
|
const yamlConfigInSubdirs = findYamlConfigRecursive(startDir);
|
256
|
-
console.log(`DEBUG: Recursive search result: ${yamlConfigInSubdirs}`);
|
257
253
|
if (yamlConfigInSubdirs) {
|
258
254
|
return yamlConfigInSubdirs;
|
259
255
|
}
|
@@ -316,23 +312,18 @@ const shouldIgnoreDirectory = (dirName) => {
|
|
316
312
|
const findYamlConfigRecursive = (dir, depth = 0) => {
|
317
313
|
// Limit search depth to prevent infinite recursion
|
318
314
|
if (depth > 5) {
|
319
|
-
console.log(`DEBUG: Stopping search at depth ${depth} in ${dir}`);
|
320
315
|
return null;
|
321
316
|
}
|
322
317
|
if (shouldIgnoreDirectory(path.basename(dir))) {
|
323
|
-
console.log(`DEBUG: Ignoring directory ${dir}`);
|
324
318
|
return null;
|
325
319
|
}
|
326
320
|
try {
|
327
321
|
const entries = fs.readdirSync(dir, { withFileTypes: true });
|
328
|
-
console.log(`DEBUG: Searching directory ${dir} at depth ${depth}, found ${entries.length} entries`);
|
329
322
|
for (const entry of entries) {
|
330
323
|
if (entry.isDirectory() && !shouldIgnoreDirectory(entry.name)) {
|
331
324
|
const fullPath = path.join(dir, entry.name);
|
332
|
-
console.log(`DEBUG: Checking subdirectory: ${fullPath}`);
|
333
325
|
// Check if this is an .appwrite directory
|
334
326
|
if (entry.name === ".appwrite") {
|
335
|
-
console.log(`DEBUG: Found .appwrite directory at ${fullPath}`);
|
336
327
|
const configPaths = [
|
337
328
|
path.join(fullPath, "appwriteConfig.yaml"),
|
338
329
|
path.join(fullPath, "appwriteConfig.yml"),
|
package/dist/interactiveCLI.js
CHANGED
@@ -24,24 +24,24 @@ import { findYamlConfig, addFunctionToYamlConfig } from "./config/yamlConfig.js"
|
|
24
24
|
var CHOICES;
|
25
25
|
(function (CHOICES) {
|
26
26
|
CHOICES["MIGRATE_CONFIG"] = "\uD83D\uDD04 Migrate TypeScript config to YAML (.appwrite structure)";
|
27
|
-
CHOICES["CREATE_COLLECTION_CONFIG"] = "Create collection config file";
|
28
|
-
CHOICES["CREATE_FUNCTION"] = "Create a new function, from scratch or using a template";
|
29
|
-
CHOICES["DEPLOY_FUNCTION"] = "Deploy function(s)";
|
30
|
-
CHOICES["DELETE_FUNCTION"] = "Delete function";
|
31
|
-
CHOICES["SETUP_DIRS_FILES"] = "Setup directories and files";
|
32
|
-
CHOICES["SETUP_DIRS_FILES_WITH_EXAMPLE_DATA"] = "Setup directories and files with example data";
|
33
|
-
CHOICES["SYNC_DB"] = "Push local config to Appwrite";
|
34
|
-
CHOICES["SYNCHRONIZE_CONFIGURATIONS"] = "Synchronize configurations - Pull from Appwrite and write to local config";
|
35
|
-
CHOICES["TRANSFER_DATA"] = "Transfer data";
|
36
|
-
CHOICES["BACKUP_DATABASE"] = "Backup database";
|
37
|
-
CHOICES["WIPE_DATABASE"] = "Wipe database";
|
38
|
-
CHOICES["WIPE_COLLECTIONS"] = "Wipe collections";
|
39
|
-
CHOICES["GENERATE_SCHEMAS"] = "Generate schemas";
|
27
|
+
CHOICES["CREATE_COLLECTION_CONFIG"] = "\uD83D\uDCC4 Create collection config file";
|
28
|
+
CHOICES["CREATE_FUNCTION"] = "\u26A1 Create a new function, from scratch or using a template";
|
29
|
+
CHOICES["DEPLOY_FUNCTION"] = "\uD83D\uDE80 Deploy function(s)";
|
30
|
+
CHOICES["DELETE_FUNCTION"] = "\uD83D\uDDD1\uFE0F Delete function";
|
31
|
+
CHOICES["SETUP_DIRS_FILES"] = "\uD83D\uDCC1 Setup directories and files";
|
32
|
+
CHOICES["SETUP_DIRS_FILES_WITH_EXAMPLE_DATA"] = "\uD83D\uDCC1\u2728 Setup directories and files with example data";
|
33
|
+
CHOICES["SYNC_DB"] = "\u2B06\uFE0F Push local config to Appwrite";
|
34
|
+
CHOICES["SYNCHRONIZE_CONFIGURATIONS"] = "\uD83D\uDD04 Synchronize configurations - Pull from Appwrite and write to local config";
|
35
|
+
CHOICES["TRANSFER_DATA"] = "\uD83D\uDCE6 Transfer data";
|
36
|
+
CHOICES["BACKUP_DATABASE"] = "\uD83D\uDCBE Backup database";
|
37
|
+
CHOICES["WIPE_DATABASE"] = "\uD83E\uDDF9 Wipe database";
|
38
|
+
CHOICES["WIPE_COLLECTIONS"] = "\uD83E\uDDF9 Wipe collections";
|
39
|
+
CHOICES["GENERATE_SCHEMAS"] = "\uD83C\uDFD7\uFE0F Generate schemas";
|
40
40
|
CHOICES["GENERATE_CONSTANTS"] = "\uD83D\uDCCB Generate cross-language constants (TypeScript, Python, PHP, Dart, etc.)";
|
41
|
-
CHOICES["IMPORT_DATA"] = "Import data";
|
42
|
-
CHOICES["RELOAD_CONFIG"] = "Reload configuration files";
|
43
|
-
CHOICES["UPDATE_FUNCTION_SPEC"] = "Update function specifications";
|
44
|
-
CHOICES["EXIT"] = "Exit";
|
41
|
+
CHOICES["IMPORT_DATA"] = "\uD83D\uDCE5 Import data";
|
42
|
+
CHOICES["RELOAD_CONFIG"] = "\uD83D\uDD04 Reload configuration files";
|
43
|
+
CHOICES["UPDATE_FUNCTION_SPEC"] = "\u2699\uFE0F Update function specifications";
|
44
|
+
CHOICES["EXIT"] = "\uD83D\uDC4B Exit";
|
45
45
|
})(CHOICES || (CHOICES = {}));
|
46
46
|
export class InteractiveCLI {
|
47
47
|
currentDir;
|
@@ -7,6 +7,7 @@ import chalk from "chalk";
|
|
7
7
|
import { findYamlConfig, loadYamlConfig } from "../config/yamlConfig.js";
|
8
8
|
import yaml from "js-yaml";
|
9
9
|
import { z } from "zod";
|
10
|
+
import { MessageFormatter } from "../shared/messageFormatter.js";
|
10
11
|
/**
|
11
12
|
* Recursively searches for configuration files starting from the given directory.
|
12
13
|
* Priority: 1) YAML configs in .appwrite directories, 2) appwriteConfig.ts files in subdirectories
|
@@ -79,7 +80,6 @@ const findAppwriteConfigTS = (dir, depth = 0) => {
|
|
79
80
|
// First check current directory for appwriteConfig.ts
|
80
81
|
for (const entry of entries) {
|
81
82
|
if (entry.isFile() && entry.name === "appwriteConfig.ts") {
|
82
|
-
console.log(`Found appwriteConfig.ts at: ${path.join(dir, entry.name)}`);
|
83
83
|
return path.join(dir, entry.name);
|
84
84
|
}
|
85
85
|
}
|
@@ -94,7 +94,6 @@ const findAppwriteConfigTS = (dir, depth = 0) => {
|
|
94
94
|
}
|
95
95
|
catch (error) {
|
96
96
|
// Ignore directory access errors
|
97
|
-
console.log(`Error accessing directory ${dir}:`, error);
|
98
97
|
}
|
99
98
|
return null;
|
100
99
|
};
|
@@ -134,7 +133,6 @@ export const loadConfigWithPath = async (configDir) => {
|
|
134
133
|
if (fs.existsSync(configPath)) {
|
135
134
|
const unregister = register(); // Register tsx enhancement
|
136
135
|
try {
|
137
|
-
console.log(`Loading TypeScript config from: ${configPath}`);
|
138
136
|
const configUrl = pathToFileURL(configPath).href;
|
139
137
|
const configModule = (await import(configUrl));
|
140
138
|
config = configModule.default?.default || configModule.default || configModule;
|
@@ -214,7 +212,6 @@ export const loadConfig = async (configDir) => {
|
|
214
212
|
// First try to find and load YAML config
|
215
213
|
const yamlConfigPath = findYamlConfig(configDir);
|
216
214
|
if (yamlConfigPath) {
|
217
|
-
console.log(`Loading YAML config from: ${yamlConfigPath}`);
|
218
215
|
config = await loadYamlConfig(yamlConfigPath);
|
219
216
|
actualConfigPath = yamlConfigPath;
|
220
217
|
}
|
@@ -225,7 +222,6 @@ export const loadConfig = async (configDir) => {
|
|
225
222
|
if (fs.existsSync(configPath)) {
|
226
223
|
const unregister = register(); // Register tsx enhancement
|
227
224
|
try {
|
228
|
-
console.log(`Loading TypeScript config from: ${configPath}`);
|
229
225
|
const configUrl = pathToFileURL(configPath).href;
|
230
226
|
const configModule = (await import(configUrl));
|
231
227
|
config = configModule.default?.default || configModule.default || configModule;
|
@@ -300,6 +296,10 @@ export const loadConfig = async (configDir) => {
|
|
300
296
|
else {
|
301
297
|
config.collections = config.collections || [];
|
302
298
|
}
|
299
|
+
// Log successful config loading
|
300
|
+
if (actualConfigPath) {
|
301
|
+
MessageFormatter.success(`Loaded config from: ${actualConfigPath}`, { prefix: "Config" });
|
302
|
+
}
|
303
303
|
return config;
|
304
304
|
};
|
305
305
|
export const findFunctionsDir = (dir, depth = 0) => {
|
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": "1.0.
|
4
|
+
"version": "1.0.7",
|
5
5
|
"main": "src/main.ts",
|
6
6
|
"type": "module",
|
7
7
|
"repository": {
|
package/src/config/yamlConfig.ts
CHANGED
@@ -256,18 +256,14 @@ export const findYamlConfig = (startDir: string): string | null => {
|
|
256
256
|
path.join(startDir, "appwrite.yml"),
|
257
257
|
];
|
258
258
|
|
259
|
-
console.log(`DEBUG: Checking YAML paths in ${startDir}:`);
|
260
259
|
for (const configPath of possiblePaths) {
|
261
|
-
console.log(` - ${configPath}: ${fs.existsSync(configPath)}`);
|
262
260
|
if (fs.existsSync(configPath)) {
|
263
261
|
return configPath;
|
264
262
|
}
|
265
263
|
}
|
266
264
|
|
267
265
|
// Recursively search subdirectories for .appwrite folders
|
268
|
-
console.log(`DEBUG: Starting recursive search from ${startDir}`);
|
269
266
|
const yamlConfigInSubdirs = findYamlConfigRecursive(startDir);
|
270
|
-
console.log(`DEBUG: Recursive search result: ${yamlConfigInSubdirs}`);
|
271
267
|
if (yamlConfigInSubdirs) {
|
272
268
|
return yamlConfigInSubdirs;
|
273
269
|
}
|
@@ -336,27 +332,22 @@ const shouldIgnoreDirectory = (dirName: string): boolean => {
|
|
336
332
|
const findYamlConfigRecursive = (dir: string, depth: number = 0): string | null => {
|
337
333
|
// Limit search depth to prevent infinite recursion
|
338
334
|
if (depth > 5) {
|
339
|
-
console.log(`DEBUG: Stopping search at depth ${depth} in ${dir}`);
|
340
335
|
return null;
|
341
336
|
}
|
342
337
|
|
343
338
|
if (shouldIgnoreDirectory(path.basename(dir))) {
|
344
|
-
console.log(`DEBUG: Ignoring directory ${dir}`);
|
345
339
|
return null;
|
346
340
|
}
|
347
341
|
|
348
342
|
try {
|
349
343
|
const entries = fs.readdirSync(dir, { withFileTypes: true });
|
350
|
-
console.log(`DEBUG: Searching directory ${dir} at depth ${depth}, found ${entries.length} entries`);
|
351
344
|
|
352
345
|
for (const entry of entries) {
|
353
346
|
if (entry.isDirectory() && !shouldIgnoreDirectory(entry.name)) {
|
354
347
|
const fullPath = path.join(dir, entry.name);
|
355
|
-
console.log(`DEBUG: Checking subdirectory: ${fullPath}`);
|
356
348
|
|
357
349
|
// Check if this is an .appwrite directory
|
358
350
|
if (entry.name === ".appwrite") {
|
359
|
-
console.log(`DEBUG: Found .appwrite directory at ${fullPath}`);
|
360
351
|
const configPaths = [
|
361
352
|
path.join(fullPath, "appwriteConfig.yaml"),
|
362
353
|
path.join(fullPath, "appwriteConfig.yml"),
|
package/src/interactiveCLI.ts
CHANGED
@@ -52,24 +52,24 @@ import { findYamlConfig, addFunctionToYamlConfig } from "./config/yamlConfig.js"
|
|
52
52
|
|
53
53
|
enum CHOICES {
|
54
54
|
MIGRATE_CONFIG = "๐ Migrate TypeScript config to YAML (.appwrite structure)",
|
55
|
-
CREATE_COLLECTION_CONFIG = "Create collection config file",
|
56
|
-
CREATE_FUNCTION = "Create a new function, from scratch or using a template",
|
57
|
-
DEPLOY_FUNCTION = "Deploy function(s)",
|
58
|
-
DELETE_FUNCTION = "Delete function",
|
59
|
-
SETUP_DIRS_FILES = "Setup directories and files",
|
60
|
-
SETUP_DIRS_FILES_WITH_EXAMPLE_DATA = "Setup directories and files with example data",
|
61
|
-
SYNC_DB = "Push local config to Appwrite",
|
62
|
-
SYNCHRONIZE_CONFIGURATIONS = "Synchronize configurations - Pull from Appwrite and write to local config",
|
63
|
-
TRANSFER_DATA = "Transfer data",
|
64
|
-
BACKUP_DATABASE = "Backup database",
|
65
|
-
WIPE_DATABASE = "Wipe database",
|
66
|
-
WIPE_COLLECTIONS = "Wipe collections",
|
67
|
-
GENERATE_SCHEMAS = "Generate schemas",
|
55
|
+
CREATE_COLLECTION_CONFIG = "๐ Create collection config file",
|
56
|
+
CREATE_FUNCTION = "โก Create a new function, from scratch or using a template",
|
57
|
+
DEPLOY_FUNCTION = "๐ Deploy function(s)",
|
58
|
+
DELETE_FUNCTION = "๐๏ธ Delete function",
|
59
|
+
SETUP_DIRS_FILES = "๐ Setup directories and files",
|
60
|
+
SETUP_DIRS_FILES_WITH_EXAMPLE_DATA = "๐โจ Setup directories and files with example data",
|
61
|
+
SYNC_DB = "โฌ๏ธ Push local config to Appwrite",
|
62
|
+
SYNCHRONIZE_CONFIGURATIONS = "๐ Synchronize configurations - Pull from Appwrite and write to local config",
|
63
|
+
TRANSFER_DATA = "๐ฆ Transfer data",
|
64
|
+
BACKUP_DATABASE = "๐พ Backup database",
|
65
|
+
WIPE_DATABASE = "๐งน Wipe database",
|
66
|
+
WIPE_COLLECTIONS = "๐งน Wipe collections",
|
67
|
+
GENERATE_SCHEMAS = "๐๏ธ Generate schemas",
|
68
68
|
GENERATE_CONSTANTS = "๐ Generate cross-language constants (TypeScript, Python, PHP, Dart, etc.)",
|
69
|
-
IMPORT_DATA = "Import data",
|
70
|
-
RELOAD_CONFIG = "Reload configuration files",
|
71
|
-
UPDATE_FUNCTION_SPEC = "Update function specifications",
|
72
|
-
EXIT = "Exit",
|
69
|
+
IMPORT_DATA = "๐ฅ Import data",
|
70
|
+
RELOAD_CONFIG = "๐ Reload configuration files",
|
71
|
+
UPDATE_FUNCTION_SPEC = "โ๏ธ Update function specifications",
|
72
|
+
EXIT = "๐ Exit",
|
73
73
|
}
|
74
74
|
|
75
75
|
export class InteractiveCLI {
|
package/src/utils/loadConfigs.ts
CHANGED
@@ -7,6 +7,7 @@ import chalk from "chalk";
|
|
7
7
|
import { findYamlConfig, loadYamlConfig } from "../config/yamlConfig.js";
|
8
8
|
import yaml from "js-yaml";
|
9
9
|
import { z } from "zod";
|
10
|
+
import { MessageFormatter } from "../shared/messageFormatter.js";
|
10
11
|
|
11
12
|
/**
|
12
13
|
* Recursively searches for configuration files starting from the given directory.
|
@@ -88,7 +89,6 @@ const findAppwriteConfigTS = (dir: string, depth: number = 0): string | null =>
|
|
88
89
|
// First check current directory for appwriteConfig.ts
|
89
90
|
for (const entry of entries) {
|
90
91
|
if (entry.isFile() && entry.name === "appwriteConfig.ts") {
|
91
|
-
console.log(`Found appwriteConfig.ts at: ${path.join(dir, entry.name)}`);
|
92
92
|
return path.join(dir, entry.name);
|
93
93
|
}
|
94
94
|
}
|
@@ -102,7 +102,6 @@ const findAppwriteConfigTS = (dir: string, depth: number = 0): string | null =>
|
|
102
102
|
}
|
103
103
|
} catch (error) {
|
104
104
|
// Ignore directory access errors
|
105
|
-
console.log(`Error accessing directory ${dir}:`, error);
|
106
105
|
}
|
107
106
|
|
108
107
|
return null;
|
@@ -149,7 +148,6 @@ export const loadConfigWithPath = async (
|
|
149
148
|
const unregister = register(); // Register tsx enhancement
|
150
149
|
|
151
150
|
try {
|
152
|
-
console.log(`Loading TypeScript config from: ${configPath}`);
|
153
151
|
const configUrl = pathToFileURL(configPath).href;
|
154
152
|
const configModule = (await import(configUrl));
|
155
153
|
config = configModule.default?.default || configModule.default || configModule;
|
@@ -239,7 +237,6 @@ export const loadConfig = async (
|
|
239
237
|
// First try to find and load YAML config
|
240
238
|
const yamlConfigPath = findYamlConfig(configDir);
|
241
239
|
if (yamlConfigPath) {
|
242
|
-
console.log(`Loading YAML config from: ${yamlConfigPath}`);
|
243
240
|
config = await loadYamlConfig(yamlConfigPath);
|
244
241
|
actualConfigPath = yamlConfigPath;
|
245
242
|
}
|
@@ -253,7 +250,6 @@ export const loadConfig = async (
|
|
253
250
|
const unregister = register(); // Register tsx enhancement
|
254
251
|
|
255
252
|
try {
|
256
|
-
console.log(`Loading TypeScript config from: ${configPath}`);
|
257
253
|
const configUrl = pathToFileURL(configPath).href;
|
258
254
|
const configModule = (await import(configUrl));
|
259
255
|
config = configModule.default?.default || configModule.default || configModule;
|
@@ -332,6 +328,11 @@ export const loadConfig = async (
|
|
332
328
|
config.collections = config.collections || [];
|
333
329
|
}
|
334
330
|
|
331
|
+
// Log successful config loading
|
332
|
+
if (actualConfigPath) {
|
333
|
+
MessageFormatter.success(`Loaded config from: ${actualConfigPath}`, { prefix: "Config" });
|
334
|
+
}
|
335
|
+
|
335
336
|
return config;
|
336
337
|
};
|
337
338
|
|