appwrite-utils-cli 0.0.32 → 0.0.34
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 +103 -97
- package/dist/migrations/backup.d.ts +2 -0
- package/dist/migrations/dataLoader.d.ts +40 -4
- package/dist/migrations/dataLoader.js +119 -126
- package/dist/migrations/importController.js +54 -50
- package/dist/migrations/schemaStrings.js +38 -38
- package/dist/migrations/users.js +4 -0
- package/package.json +54 -54
- package/src/main.ts +83 -83
- package/src/migrations/dataLoader.ts +140 -169
- package/src/migrations/importController.ts +62 -63
- package/src/migrations/openapi.ts +83 -83
- package/src/migrations/schemaStrings.ts +473 -473
- package/src/migrations/users.ts +4 -0
- package/src/utilsController.ts +194 -194
package/package.json
CHANGED
|
@@ -1,54 +1,54 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "appwrite-utils-cli",
|
|
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.
|
|
5
|
-
"main": "src/main.ts",
|
|
6
|
-
"type": "module",
|
|
7
|
-
"repository": {
|
|
8
|
-
"type": "git",
|
|
9
|
-
"url": "https://github.com/zachhandley/AppwriteUtils"
|
|
10
|
-
},
|
|
11
|
-
"author": "Zach Handley <zach@blackleafdigital.com> (https://zachhandley.com)",
|
|
12
|
-
"keywords": [
|
|
13
|
-
"appwrite",
|
|
14
|
-
"cli",
|
|
15
|
-
"utils",
|
|
16
|
-
"migrations",
|
|
17
|
-
"data",
|
|
18
|
-
"database",
|
|
19
|
-
"import",
|
|
20
|
-
"migration",
|
|
21
|
-
"utility"
|
|
22
|
-
],
|
|
23
|
-
"bin": {
|
|
24
|
-
"appwrite-init": "./dist/init.js",
|
|
25
|
-
"appwrite-migrate": "./dist/main.js"
|
|
26
|
-
},
|
|
27
|
-
"scripts": {
|
|
28
|
-
"build": "bun run tsc",
|
|
29
|
-
"init": "tsx --no-cache src/init.ts",
|
|
30
|
-
"migrate": "tsx --no-cache src/main.ts",
|
|
31
|
-
"deploy": "bun run build && npm publish --access public",
|
|
32
|
-
"postinstall": "echo 'This package is intended for CLI use only and should not be added as a dependency in other projects.'"
|
|
33
|
-
},
|
|
34
|
-
"dependencies": {
|
|
35
|
-
"@types/inquirer": "^9.0.7",
|
|
36
|
-
"appwrite-utils": "^0.2.
|
|
37
|
-
"commander": "^12.0.0",
|
|
38
|
-
"inquirer": "^9.2.20",
|
|
39
|
-
"js-yaml": "^4.1.0",
|
|
40
|
-
"lodash": "^4.17.21",
|
|
41
|
-
"luxon": "^3.4.4",
|
|
42
|
-
"nanostores": "^0.10.3",
|
|
43
|
-
"node-appwrite": "^12.0.1",
|
|
44
|
-
"tsx": "^4.9.3",
|
|
45
|
-
"winston": "^3.13.0",
|
|
46
|
-
"zod": "^3.22.4"
|
|
47
|
-
},
|
|
48
|
-
"devDependencies": {
|
|
49
|
-
"@types/js-yaml": "^4.0.9",
|
|
50
|
-
"@types/lodash": "^4.17.0",
|
|
51
|
-
"@types/luxon": "^3.4.2",
|
|
52
|
-
"typescript": "^5.0.0"
|
|
53
|
-
}
|
|
54
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "appwrite-utils-cli",
|
|
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.34",
|
|
5
|
+
"main": "src/main.ts",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "https://github.com/zachhandley/AppwriteUtils"
|
|
10
|
+
},
|
|
11
|
+
"author": "Zach Handley <zach@blackleafdigital.com> (https://zachhandley.com)",
|
|
12
|
+
"keywords": [
|
|
13
|
+
"appwrite",
|
|
14
|
+
"cli",
|
|
15
|
+
"utils",
|
|
16
|
+
"migrations",
|
|
17
|
+
"data",
|
|
18
|
+
"database",
|
|
19
|
+
"import",
|
|
20
|
+
"migration",
|
|
21
|
+
"utility"
|
|
22
|
+
],
|
|
23
|
+
"bin": {
|
|
24
|
+
"appwrite-init": "./dist/init.js",
|
|
25
|
+
"appwrite-migrate": "./dist/main.js"
|
|
26
|
+
},
|
|
27
|
+
"scripts": {
|
|
28
|
+
"build": "bun run tsc",
|
|
29
|
+
"init": "tsx --no-cache src/init.ts",
|
|
30
|
+
"migrate": "tsx --no-cache src/main.ts",
|
|
31
|
+
"deploy": "bun run build && npm publish --access public",
|
|
32
|
+
"postinstall": "echo 'This package is intended for CLI use only and should not be added as a dependency in other projects.'"
|
|
33
|
+
},
|
|
34
|
+
"dependencies": {
|
|
35
|
+
"@types/inquirer": "^9.0.7",
|
|
36
|
+
"appwrite-utils": "^0.2.5",
|
|
37
|
+
"commander": "^12.0.0",
|
|
38
|
+
"inquirer": "^9.2.20",
|
|
39
|
+
"js-yaml": "^4.1.0",
|
|
40
|
+
"lodash": "^4.17.21",
|
|
41
|
+
"luxon": "^3.4.4",
|
|
42
|
+
"nanostores": "^0.10.3",
|
|
43
|
+
"node-appwrite": "^12.0.1",
|
|
44
|
+
"tsx": "^4.9.3",
|
|
45
|
+
"winston": "^3.13.0",
|
|
46
|
+
"zod": "^3.22.4"
|
|
47
|
+
},
|
|
48
|
+
"devDependencies": {
|
|
49
|
+
"@types/js-yaml": "^4.0.9",
|
|
50
|
+
"@types/lodash": "^4.17.0",
|
|
51
|
+
"@types/luxon": "^3.4.2",
|
|
52
|
+
"typescript": "^5.0.0"
|
|
53
|
+
}
|
|
54
|
+
}
|
package/src/main.ts
CHANGED
|
@@ -1,83 +1,83 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import { program } from "commander";
|
|
3
|
-
import { UtilsController } from "./utilsController.js";
|
|
4
|
-
|
|
5
|
-
// Setup the main CLI program
|
|
6
|
-
program
|
|
7
|
-
.version("1.0.0")
|
|
8
|
-
.description("Utility CLI for Appwrite configurations and operations")
|
|
9
|
-
.option("--endpoint <endpoint>", "Set the Appwrite endpoint", undefined)
|
|
10
|
-
.option("--project <project>", "Set the Appwrite project ID", undefined)
|
|
11
|
-
.option("--key <key>", "Set the Appwrite API key", undefined)
|
|
12
|
-
.option("--backup", "Perform a backup before executing the command", false)
|
|
13
|
-
.option("--dev", "Run in development environment", false)
|
|
14
|
-
.option("--prod", "Run in production environment", false)
|
|
15
|
-
.option("--staging", "Run in staging environment", false)
|
|
16
|
-
.option("--sync", "Synchronize configurations", false)
|
|
17
|
-
.option("--wipe", "Wipe databases", false)
|
|
18
|
-
.option("--wipe-docs", "Wipe documents", false)
|
|
19
|
-
.option("--wipe-users", "Wipe users", false)
|
|
20
|
-
.option("--generate", "Generate schemas", false)
|
|
21
|
-
.option("--import", "Import data", false)
|
|
22
|
-
.option("--write-data", "Write data to file", false)
|
|
23
|
-
.option("-h, --help", "Display help for command", false);
|
|
24
|
-
|
|
25
|
-
program.on("--help", () => {
|
|
26
|
-
console.log("");
|
|
27
|
-
console.log("Examples:");
|
|
28
|
-
console.log(
|
|
29
|
-
" $ npx appwrite-utils-cli appwrite-migrate --sync --endpoint https://appwrite.example.com --project 123456 --key 7890"
|
|
30
|
-
);
|
|
31
|
-
console.log(
|
|
32
|
-
" $ npx appwrite-utils-cli appwrite-migrate --sync --dev --backup"
|
|
33
|
-
);
|
|
34
|
-
console.log(
|
|
35
|
-
" $ npx appwrite-utils-cli appwrite-migrate --wipe --wipe-docs --wipe-users --dev"
|
|
36
|
-
);
|
|
37
|
-
console.log(
|
|
38
|
-
" $ npx appwrite-utils-cli appwrite-migrate --generate --import --write-data --dev"
|
|
39
|
-
);
|
|
40
|
-
console.log(
|
|
41
|
-
" $ npx appwrite-utils-cli appwrite-migrate --sync --generate --import --write-data --dev --backup"
|
|
42
|
-
);
|
|
43
|
-
console.log(" $ npx appwrite-utils-cli appwrite-create");
|
|
44
|
-
console.log(
|
|
45
|
-
"For more information, visit https://github.com/zachhandley/appwrite-utils"
|
|
46
|
-
);
|
|
47
|
-
console.log("");
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
// Parse and handle options
|
|
51
|
-
program.action(async (options) => {
|
|
52
|
-
const currentUserDir = process.cwd();
|
|
53
|
-
const controller = new UtilsController(currentUserDir);
|
|
54
|
-
try {
|
|
55
|
-
// Convert Commander options to the format expected by UtilsController
|
|
56
|
-
const setupOptions = {
|
|
57
|
-
sync: options.sync,
|
|
58
|
-
runProd: options.prod,
|
|
59
|
-
runStaging: options.staging,
|
|
60
|
-
runDev: options.dev,
|
|
61
|
-
doBackup: options.backup,
|
|
62
|
-
wipeDatabases: options.wipe,
|
|
63
|
-
wipeDocumentStorage: options.wipeDocs,
|
|
64
|
-
wipeUsers: options.wipeUsers,
|
|
65
|
-
generateSchemas: options.generate,
|
|
66
|
-
generateMockData: false, // Assuming this needs to be set based on other conditions
|
|
67
|
-
importData: options.import,
|
|
68
|
-
checkDuplicates: false, // Assuming this needs to be set based on other conditions
|
|
69
|
-
shouldWriteFile: options.writeData,
|
|
70
|
-
endpoint: options.endpoint,
|
|
71
|
-
project: options.project,
|
|
72
|
-
key: options.key,
|
|
73
|
-
};
|
|
74
|
-
console.log("Running operation...", setupOptions);
|
|
75
|
-
|
|
76
|
-
await controller.run(setupOptions);
|
|
77
|
-
console.log("Operation completed successfully.");
|
|
78
|
-
} catch (error) {
|
|
79
|
-
console.error("Error during operation:", error);
|
|
80
|
-
}
|
|
81
|
-
});
|
|
82
|
-
|
|
83
|
-
program.parse(process.argv);
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { program } from "commander";
|
|
3
|
+
import { UtilsController } from "./utilsController.js";
|
|
4
|
+
|
|
5
|
+
// Setup the main CLI program
|
|
6
|
+
program
|
|
7
|
+
.version("1.0.0")
|
|
8
|
+
.description("Utility CLI for Appwrite configurations and operations")
|
|
9
|
+
.option("--endpoint <endpoint>", "Set the Appwrite endpoint", undefined)
|
|
10
|
+
.option("--project <project>", "Set the Appwrite project ID", undefined)
|
|
11
|
+
.option("--key <key>", "Set the Appwrite API key", undefined)
|
|
12
|
+
.option("--backup", "Perform a backup before executing the command", false)
|
|
13
|
+
.option("--dev", "Run in development environment", false)
|
|
14
|
+
.option("--prod", "Run in production environment", false)
|
|
15
|
+
.option("--staging", "Run in staging environment", false)
|
|
16
|
+
.option("--sync", "Synchronize configurations", false)
|
|
17
|
+
.option("--wipe", "Wipe databases", false)
|
|
18
|
+
.option("--wipe-docs", "Wipe documents", false)
|
|
19
|
+
.option("--wipe-users", "Wipe users", false)
|
|
20
|
+
.option("--generate", "Generate schemas", false)
|
|
21
|
+
.option("--import", "Import data", false)
|
|
22
|
+
.option("--write-data", "Write data to file", false)
|
|
23
|
+
.option("-h, --help", "Display help for command", false);
|
|
24
|
+
|
|
25
|
+
program.on("--help", () => {
|
|
26
|
+
console.log("");
|
|
27
|
+
console.log("Examples:");
|
|
28
|
+
console.log(
|
|
29
|
+
" $ npx appwrite-utils-cli appwrite-migrate --sync --endpoint https://appwrite.example.com --project 123456 --key 7890"
|
|
30
|
+
);
|
|
31
|
+
console.log(
|
|
32
|
+
" $ npx appwrite-utils-cli appwrite-migrate --sync --dev --backup"
|
|
33
|
+
);
|
|
34
|
+
console.log(
|
|
35
|
+
" $ npx appwrite-utils-cli appwrite-migrate --wipe --wipe-docs --wipe-users --dev"
|
|
36
|
+
);
|
|
37
|
+
console.log(
|
|
38
|
+
" $ npx appwrite-utils-cli appwrite-migrate --generate --import --write-data --dev"
|
|
39
|
+
);
|
|
40
|
+
console.log(
|
|
41
|
+
" $ npx appwrite-utils-cli appwrite-migrate --sync --generate --import --write-data --dev --backup"
|
|
42
|
+
);
|
|
43
|
+
console.log(" $ npx appwrite-utils-cli appwrite-create");
|
|
44
|
+
console.log(
|
|
45
|
+
"For more information, visit https://github.com/zachhandley/appwrite-utils"
|
|
46
|
+
);
|
|
47
|
+
console.log("");
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
// Parse and handle options
|
|
51
|
+
program.action(async (options) => {
|
|
52
|
+
const currentUserDir = process.cwd();
|
|
53
|
+
const controller = new UtilsController(currentUserDir);
|
|
54
|
+
try {
|
|
55
|
+
// Convert Commander options to the format expected by UtilsController
|
|
56
|
+
const setupOptions = {
|
|
57
|
+
sync: options.sync,
|
|
58
|
+
runProd: options.prod,
|
|
59
|
+
runStaging: options.staging,
|
|
60
|
+
runDev: options.dev,
|
|
61
|
+
doBackup: options.backup,
|
|
62
|
+
wipeDatabases: options.wipe,
|
|
63
|
+
wipeDocumentStorage: options.wipeDocs,
|
|
64
|
+
wipeUsers: options.wipeUsers,
|
|
65
|
+
generateSchemas: options.generate,
|
|
66
|
+
generateMockData: false, // Assuming this needs to be set based on other conditions
|
|
67
|
+
importData: options.import,
|
|
68
|
+
checkDuplicates: false, // Assuming this needs to be set based on other conditions
|
|
69
|
+
shouldWriteFile: options.writeData,
|
|
70
|
+
endpoint: options.endpoint,
|
|
71
|
+
project: options.project,
|
|
72
|
+
key: options.key,
|
|
73
|
+
};
|
|
74
|
+
console.log("Running operation...", setupOptions);
|
|
75
|
+
|
|
76
|
+
await controller.run(setupOptions);
|
|
77
|
+
console.log("Operation completed successfully.");
|
|
78
|
+
} catch (error) {
|
|
79
|
+
console.error("Error during operation:", error);
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
program.parse(process.argv);
|