appwrite-utils-cli 0.9.998 → 0.9.999
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 +1 -0
- package/dist/interactiveCLI.js +38 -10
- package/package.json +1 -1
- package/src/interactiveCLI.ts +50 -11
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.9.999: Fixed Functions, looks for `./functions` in addition to `appwriteConfigFolder/functions`
|
150
151
|
- 0.9.998: Fixed transfer finally, added `--targetDbId` and `--sourceDbId` as aliases
|
151
152
|
- 0.9.994: Added function deployment management, in BETA, and fixed document transfer between databases
|
152
153
|
- 0.9.993: Fixed `updateFunctionSpecifications` resetting functions to default with undefined values (oops)
|
package/dist/interactiveCLI.js
CHANGED
@@ -292,27 +292,55 @@ export class InteractiveCLI {
|
|
292
292
|
console.log(chalk.green("✨ Function created successfully!"));
|
293
293
|
}
|
294
294
|
async findFunctionInSubdirectories(basePath, functionName) {
|
295
|
-
|
295
|
+
// Common locations to check first
|
296
|
+
const commonPaths = [
|
297
|
+
join(process.cwd(), "functions", functionName), // ./functions/functionName
|
298
|
+
join(process.cwd(), functionName), // ./functionName
|
299
|
+
join(basePath, "functions", functionName), // appwriteFolder/functions/functionName
|
300
|
+
join(basePath, functionName), // appwriteFolder/functionName
|
301
|
+
];
|
302
|
+
// Check common locations first
|
303
|
+
for (const path of commonPaths) {
|
304
|
+
try {
|
305
|
+
const stats = await fs.promises.stat(path);
|
306
|
+
if (stats.isDirectory()) {
|
307
|
+
console.log(chalk.green(`Found function at common location: ${path}`));
|
308
|
+
return path;
|
309
|
+
}
|
310
|
+
}
|
311
|
+
catch (error) {
|
312
|
+
// Path doesn't exist, continue to next
|
313
|
+
}
|
314
|
+
}
|
315
|
+
// If not found in common locations, do recursive search
|
316
|
+
console.log(chalk.yellow("Function not found in common locations, searching subdirectories..."));
|
317
|
+
const queue = [process.cwd(), basePath];
|
318
|
+
const searched = new Set();
|
296
319
|
while (queue.length > 0) {
|
297
320
|
const currentPath = queue.shift();
|
321
|
+
if (searched.has(currentPath))
|
322
|
+
continue;
|
323
|
+
searched.add(currentPath);
|
298
324
|
try {
|
299
325
|
const entries = await fs.promises.readdir(currentPath, {
|
300
326
|
withFileTypes: true,
|
301
327
|
});
|
302
|
-
// Check if function exists in current directory
|
303
|
-
const functionPath = join(currentPath, functionName);
|
304
|
-
if (fs.existsSync(functionPath)) {
|
305
|
-
return functionPath;
|
306
|
-
}
|
307
|
-
// Add subdirectories to queue
|
308
328
|
for (const entry of entries) {
|
309
|
-
|
310
|
-
|
329
|
+
const fullPath = join(currentPath, entry.name);
|
330
|
+
// Skip node_modules and hidden directories
|
331
|
+
if (entry.isDirectory() &&
|
332
|
+
!entry.name.startsWith(".") &&
|
333
|
+
entry.name !== "node_modules") {
|
334
|
+
if (entry.name === functionName) {
|
335
|
+
console.log(chalk.green(`Found function at: ${fullPath}`));
|
336
|
+
return fullPath;
|
337
|
+
}
|
338
|
+
queue.push(fullPath);
|
311
339
|
}
|
312
340
|
}
|
313
341
|
}
|
314
342
|
catch (error) {
|
315
|
-
console.log(chalk.yellow(`
|
343
|
+
console.log(chalk.yellow(`Error reading directory ${currentPath}:`, error));
|
316
344
|
}
|
317
345
|
}
|
318
346
|
return null;
|
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.999",
|
5
5
|
"main": "src/main.ts",
|
6
6
|
"type": "module",
|
7
7
|
"repository": {
|
package/src/interactiveCLI.ts
CHANGED
@@ -391,31 +391,70 @@ export class InteractiveCLI {
|
|
391
391
|
basePath: string,
|
392
392
|
functionName: string
|
393
393
|
): Promise<string | null> {
|
394
|
-
|
394
|
+
// Common locations to check first
|
395
|
+
const commonPaths = [
|
396
|
+
join(process.cwd(), "functions", functionName), // ./functions/functionName
|
397
|
+
join(process.cwd(), functionName), // ./functionName
|
398
|
+
join(basePath, "functions", functionName), // appwriteFolder/functions/functionName
|
399
|
+
join(basePath, functionName), // appwriteFolder/functionName
|
400
|
+
];
|
401
|
+
|
402
|
+
// Check common locations first
|
403
|
+
for (const path of commonPaths) {
|
404
|
+
try {
|
405
|
+
const stats = await fs.promises.stat(path);
|
406
|
+
if (stats.isDirectory()) {
|
407
|
+
console.log(
|
408
|
+
chalk.green(`Found function at common location: ${path}`)
|
409
|
+
);
|
410
|
+
return path;
|
411
|
+
}
|
412
|
+
} catch (error) {
|
413
|
+
// Path doesn't exist, continue to next
|
414
|
+
}
|
415
|
+
}
|
416
|
+
|
417
|
+
// If not found in common locations, do recursive search
|
418
|
+
console.log(
|
419
|
+
chalk.yellow(
|
420
|
+
"Function not found in common locations, searching subdirectories..."
|
421
|
+
)
|
422
|
+
);
|
423
|
+
|
424
|
+
const queue = [process.cwd(), basePath];
|
425
|
+
const searched = new Set<string>();
|
395
426
|
|
396
427
|
while (queue.length > 0) {
|
397
428
|
const currentPath = queue.shift()!;
|
398
429
|
|
430
|
+
if (searched.has(currentPath)) continue;
|
431
|
+
searched.add(currentPath);
|
432
|
+
|
399
433
|
try {
|
400
434
|
const entries = await fs.promises.readdir(currentPath, {
|
401
435
|
withFileTypes: true,
|
402
436
|
});
|
403
437
|
|
404
|
-
// Check if function exists in current directory
|
405
|
-
const functionPath = join(currentPath, functionName);
|
406
|
-
if (fs.existsSync(functionPath)) {
|
407
|
-
return functionPath;
|
408
|
-
}
|
409
|
-
|
410
|
-
// Add subdirectories to queue
|
411
438
|
for (const entry of entries) {
|
412
|
-
|
413
|
-
|
439
|
+
const fullPath = join(currentPath, entry.name);
|
440
|
+
|
441
|
+
// Skip node_modules and hidden directories
|
442
|
+
if (
|
443
|
+
entry.isDirectory() &&
|
444
|
+
!entry.name.startsWith(".") &&
|
445
|
+
entry.name !== "node_modules"
|
446
|
+
) {
|
447
|
+
if (entry.name === functionName) {
|
448
|
+
console.log(chalk.green(`Found function at: ${fullPath}`));
|
449
|
+
return fullPath;
|
450
|
+
}
|
451
|
+
|
452
|
+
queue.push(fullPath);
|
414
453
|
}
|
415
454
|
}
|
416
455
|
} catch (error) {
|
417
456
|
console.log(
|
418
|
-
chalk.yellow(`
|
457
|
+
chalk.yellow(`Error reading directory ${currentPath}:`, error)
|
419
458
|
);
|
420
459
|
}
|
421
460
|
}
|