appwrite-cli 13.0.0-rc.1 → 13.0.0-rc.3
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/.github/workflows/publish.yml +68 -0
- package/CHANGELOG.md +10 -1
- package/LICENSE.md +1 -1
- package/README.md +3 -3
- package/cli.ts +152 -0
- package/dist/bundle.cjs +95813 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +145 -0
- package/dist/cli.js.map +1 -0
- package/dist/index.d.ts +10 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7 -142
- package/dist/index.js.map +1 -1
- package/dist/lib/client.d.ts +2 -3
- package/dist/lib/client.d.ts.map +1 -1
- package/dist/lib/client.js +57 -45
- package/dist/lib/client.js.map +1 -1
- package/dist/lib/commands/config.d.ts +562 -0
- package/dist/lib/commands/config.d.ts.map +1 -0
- package/dist/lib/commands/config.js +416 -0
- package/dist/lib/commands/config.js.map +1 -0
- package/dist/lib/commands/db.d.ts +34 -0
- package/dist/lib/commands/db.d.ts.map +1 -0
- package/dist/lib/commands/db.js +247 -0
- package/dist/lib/commands/db.js.map +1 -0
- package/dist/lib/commands/errors.d.ts +68 -0
- package/dist/lib/commands/errors.d.ts.map +1 -0
- package/dist/lib/commands/errors.js +72 -0
- package/dist/lib/commands/errors.js.map +1 -0
- package/dist/lib/commands/generic.d.ts +2 -2
- package/dist/lib/commands/generic.d.ts.map +1 -1
- package/dist/lib/commands/generic.js +170 -157
- package/dist/lib/commands/generic.js.map +1 -1
- package/dist/lib/commands/init.d.ts +1 -1
- package/dist/lib/commands/init.d.ts.map +1 -1
- package/dist/lib/commands/init.js +201 -192
- package/dist/lib/commands/init.js.map +1 -1
- package/dist/lib/commands/pull.d.ts +105 -3
- package/dist/lib/commands/pull.d.ts.map +1 -1
- package/dist/lib/commands/pull.js +530 -370
- package/dist/lib/commands/pull.js.map +1 -1
- package/dist/lib/commands/push.d.ts +106 -0
- package/dist/lib/commands/push.d.ts.map +1 -1
- package/dist/lib/commands/push.js +1432 -1830
- package/dist/lib/commands/push.js.map +1 -1
- package/dist/lib/commands/run.d.ts +1 -1
- package/dist/lib/commands/run.d.ts.map +1 -1
- package/dist/lib/commands/run.js +129 -127
- package/dist/lib/commands/run.js.map +1 -1
- package/dist/lib/commands/schema.d.ts +59 -0
- package/dist/lib/commands/schema.d.ts.map +1 -0
- package/dist/lib/commands/schema.js +86 -0
- package/dist/lib/commands/schema.js.map +1 -0
- package/dist/lib/commands/services/account.d.ts +3 -0
- package/dist/lib/commands/services/account.d.ts.map +1 -0
- package/dist/lib/commands/services/account.js +328 -0
- package/dist/lib/commands/services/account.js.map +1 -0
- package/dist/lib/commands/services/console.d.ts +3 -0
- package/dist/lib/commands/services/console.d.ts.map +1 -0
- package/dist/lib/commands/services/console.js +28 -0
- package/dist/lib/commands/services/console.js.map +1 -0
- package/dist/lib/commands/services/databases.d.ts +3 -0
- package/dist/lib/commands/services/databases.d.ts.map +1 -0
- package/dist/lib/commands/services/databases.js +620 -0
- package/dist/lib/commands/services/databases.js.map +1 -0
- package/dist/lib/commands/services/functions.d.ts +3 -0
- package/dist/lib/commands/services/functions.d.ts.map +1 -0
- package/dist/lib/commands/services/functions.js +266 -0
- package/dist/lib/commands/services/functions.js.map +1 -0
- package/dist/lib/commands/services/graphql.d.ts +3 -0
- package/dist/lib/commands/services/graphql.d.ts.map +1 -0
- package/dist/lib/commands/services/graphql.js +28 -0
- package/dist/lib/commands/services/graphql.js.map +1 -0
- package/dist/lib/commands/services/health.d.ts +3 -0
- package/dist/lib/commands/services/health.d.ts.map +1 -0
- package/dist/lib/commands/services/health.js +123 -0
- package/dist/lib/commands/services/health.js.map +1 -0
- package/dist/lib/commands/services/locale.d.ts +3 -0
- package/dist/lib/commands/services/locale.d.ts.map +1 -0
- package/dist/lib/commands/services/locale.js +52 -0
- package/dist/lib/commands/services/locale.js.map +1 -0
- package/dist/lib/commands/services/messaging.d.ts +3 -0
- package/dist/lib/commands/services/messaging.d.ts.map +1 -0
- package/dist/lib/commands/services/messaging.js +505 -0
- package/dist/lib/commands/services/messaging.js.map +1 -0
- package/dist/lib/commands/services/migrations.d.ts +3 -0
- package/dist/lib/commands/services/migrations.d.ts.map +1 -0
- package/dist/lib/commands/services/migrations.js +135 -0
- package/dist/lib/commands/services/migrations.js.map +1 -0
- package/dist/lib/commands/services/project.d.ts +3 -0
- package/dist/lib/commands/services/project.d.ts.map +1 -0
- package/dist/lib/commands/services/project.js +54 -0
- package/dist/lib/commands/services/project.js.map +1 -0
- package/dist/lib/commands/services/projects.d.ts +3 -0
- package/dist/lib/commands/services/projects.d.ts.map +1 -0
- package/dist/lib/commands/services/projects.js +415 -0
- package/dist/lib/commands/services/projects.js.map +1 -0
- package/dist/lib/commands/services/proxy.d.ts +3 -0
- package/dist/lib/commands/services/proxy.d.ts.map +1 -0
- package/dist/lib/commands/services/proxy.js +68 -0
- package/dist/lib/commands/services/proxy.js.map +1 -0
- package/dist/lib/commands/services/sites.d.ts +3 -0
- package/dist/lib/commands/services/sites.d.ts.map +1 -0
- package/dist/lib/commands/services/sites.js +250 -0
- package/dist/lib/commands/services/sites.js.map +1 -0
- package/dist/lib/commands/services/storage.d.ts +3 -0
- package/dist/lib/commands/services/storage.d.ts.map +1 -0
- package/dist/lib/commands/services/storage.js +175 -0
- package/dist/lib/commands/services/storage.js.map +1 -0
- package/dist/lib/commands/services/tables-db.d.ts +3 -0
- package/dist/lib/commands/services/tables-db.d.ts.map +1 -0
- package/dist/lib/commands/services/tables-db.js +613 -0
- package/dist/lib/commands/services/tables-db.js.map +1 -0
- package/dist/lib/commands/services/teams.d.ts +3 -0
- package/dist/lib/commands/services/teams.d.ts.map +1 -0
- package/dist/lib/commands/services/teams.js +123 -0
- package/dist/lib/commands/services/teams.js.map +1 -0
- package/dist/lib/commands/services/tokens.d.ts +3 -0
- package/dist/lib/commands/services/tokens.d.ts.map +1 -0
- package/dist/lib/commands/services/tokens.js +49 -0
- package/dist/lib/commands/services/tokens.js.map +1 -0
- package/dist/lib/commands/services/users.d.ts +3 -0
- package/dist/lib/commands/services/users.d.ts.map +1 -0
- package/dist/lib/commands/services/users.js +312 -0
- package/dist/lib/commands/services/users.js.map +1 -0
- package/dist/lib/commands/services/vcs.d.ts +3 -0
- package/dist/lib/commands/services/vcs.d.ts.map +1 -0
- package/dist/lib/commands/services/vcs.js +87 -0
- package/dist/lib/commands/services/vcs.js.map +1 -0
- package/dist/lib/commands/types.d.ts +1 -1
- package/dist/lib/commands/types.d.ts.map +1 -1
- package/dist/lib/commands/types.js +53 -57
- package/dist/lib/commands/types.js.map +1 -1
- package/dist/lib/commands/update.d.ts +1 -1
- package/dist/lib/commands/update.d.ts.map +1 -1
- package/dist/lib/commands/update.js +69 -69
- package/dist/lib/commands/update.js.map +1 -1
- package/dist/lib/commands/utils/attributes.d.ts +47 -0
- package/dist/lib/commands/utils/attributes.d.ts.map +1 -0
- package/dist/lib/commands/utils/attributes.js +514 -0
- package/dist/lib/commands/utils/attributes.js.map +1 -0
- package/dist/lib/commands/utils/change-approval.d.ts +25 -0
- package/dist/lib/commands/utils/change-approval.d.ts.map +1 -0
- package/dist/lib/commands/utils/change-approval.js +129 -0
- package/dist/lib/commands/utils/change-approval.js.map +1 -0
- package/dist/lib/commands/utils/database-sync.d.ts +10 -0
- package/dist/lib/commands/utils/database-sync.d.ts.map +1 -0
- package/dist/lib/commands/utils/database-sync.js +136 -0
- package/dist/lib/commands/utils/database-sync.js.map +1 -0
- package/dist/lib/commands/utils/deployment.d.ts +34 -0
- package/dist/lib/commands/utils/deployment.d.ts.map +1 -0
- package/dist/lib/commands/utils/deployment.js +109 -0
- package/dist/lib/commands/utils/deployment.js.map +1 -0
- package/dist/lib/commands/utils/error-formatter.d.ts +19 -0
- package/dist/lib/commands/utils/error-formatter.d.ts.map +1 -0
- package/dist/lib/commands/utils/error-formatter.js +333 -0
- package/dist/lib/commands/utils/error-formatter.js.map +1 -0
- package/dist/lib/commands/utils/pools.d.ts +16 -0
- package/dist/lib/commands/utils/pools.d.ts.map +1 -0
- package/dist/lib/commands/utils/pools.js +198 -0
- package/dist/lib/commands/utils/pools.js.map +1 -0
- package/dist/lib/config.d.ts +41 -40
- package/dist/lib/config.d.ts.map +1 -1
- package/dist/lib/config.js +264 -239
- package/dist/lib/config.js.map +1 -1
- package/dist/lib/constants.d.ts +14 -0
- package/dist/lib/constants.d.ts.map +1 -0
- package/dist/lib/constants.js +19 -0
- package/dist/lib/constants.js.map +1 -0
- package/dist/lib/emulation/docker.d.ts +4 -12
- package/dist/lib/emulation/docker.d.ts.map +1 -1
- package/dist/lib/emulation/docker.js +159 -142
- package/dist/lib/emulation/docker.js.map +1 -1
- package/dist/lib/emulation/utils.d.ts +1 -1
- package/dist/lib/emulation/utils.d.ts.map +1 -1
- package/dist/lib/emulation/utils.js +55 -58
- package/dist/lib/emulation/utils.js.map +1 -1
- package/dist/lib/id.d.ts +1 -1
- package/dist/lib/id.d.ts.map +1 -1
- package/dist/lib/id.js +13 -18
- package/dist/lib/id.js.map +1 -1
- package/dist/lib/paginate.d.ts +3 -4
- package/dist/lib/paginate.d.ts.map +1 -1
- package/dist/lib/paginate.js +7 -10
- package/dist/lib/paginate.js.map +1 -1
- package/dist/lib/parser.d.ts +1 -1
- package/dist/lib/parser.d.ts.map +1 -1
- package/dist/lib/parser.js +92 -103
- package/dist/lib/parser.js.map +1 -1
- package/dist/lib/questions.d.ts +1 -1
- package/dist/lib/questions.d.ts.map +1 -1
- package/dist/lib/questions.js +381 -385
- package/dist/lib/questions.js.map +1 -1
- package/dist/lib/sdks.d.ts +1 -1
- package/dist/lib/sdks.d.ts.map +1 -1
- package/dist/lib/sdks.js +39 -30
- package/dist/lib/sdks.js.map +1 -1
- package/dist/lib/services.d.ts +13 -0
- package/dist/lib/services.d.ts.map +1 -0
- package/dist/lib/services.js +47 -0
- package/dist/lib/services.js.map +1 -0
- package/dist/lib/spinner.d.ts +1 -1
- package/dist/lib/spinner.d.ts.map +1 -1
- package/dist/lib/spinner.js +25 -27
- package/dist/lib/spinner.js.map +1 -1
- package/dist/lib/type-generation/attribute.d.ts +1 -1
- package/dist/lib/type-generation/attribute.d.ts.map +1 -1
- package/dist/lib/type-generation/attribute.js +14 -17
- package/dist/lib/type-generation/attribute.js.map +1 -1
- package/dist/lib/type-generation/languages/csharp.d.ts +1 -1
- package/dist/lib/type-generation/languages/csharp.d.ts.map +1 -1
- package/dist/lib/type-generation/languages/csharp.js +34 -34
- package/dist/lib/type-generation/languages/csharp.js.map +1 -1
- package/dist/lib/type-generation/languages/dart.d.ts +1 -1
- package/dist/lib/type-generation/languages/dart.d.ts.map +1 -1
- package/dist/lib/type-generation/languages/dart.js +57 -57
- package/dist/lib/type-generation/languages/dart.js.map +1 -1
- package/dist/lib/type-generation/languages/java.d.ts +1 -1
- package/dist/lib/type-generation/languages/java.d.ts.map +1 -1
- package/dist/lib/type-generation/languages/java.js +35 -35
- package/dist/lib/type-generation/languages/java.js.map +1 -1
- package/dist/lib/type-generation/languages/javascript.d.ts +1 -1
- package/dist/lib/type-generation/languages/javascript.d.ts.map +1 -1
- package/dist/lib/type-generation/languages/javascript.js +45 -44
- package/dist/lib/type-generation/languages/javascript.js.map +1 -1
- package/dist/lib/type-generation/languages/kotlin.d.ts +1 -1
- package/dist/lib/type-generation/languages/kotlin.d.ts.map +1 -1
- package/dist/lib/type-generation/languages/kotlin.js +35 -35
- package/dist/lib/type-generation/languages/kotlin.js.map +1 -1
- package/dist/lib/type-generation/languages/language.d.ts.map +1 -1
- package/dist/lib/type-generation/languages/language.js +32 -37
- package/dist/lib/type-generation/languages/language.js.map +1 -1
- package/dist/lib/type-generation/languages/php.d.ts +1 -1
- package/dist/lib/type-generation/languages/php.d.ts.map +1 -1
- package/dist/lib/type-generation/languages/php.js +34 -34
- package/dist/lib/type-generation/languages/php.js.map +1 -1
- package/dist/lib/type-generation/languages/swift.d.ts +1 -1
- package/dist/lib/type-generation/languages/swift.d.ts.map +1 -1
- package/dist/lib/type-generation/languages/swift.js +35 -35
- package/dist/lib/type-generation/languages/swift.js.map +1 -1
- package/dist/lib/type-generation/languages/typescript.d.ts +1 -1
- package/dist/lib/type-generation/languages/typescript.d.ts.map +1 -1
- package/dist/lib/type-generation/languages/typescript.js +49 -46
- package/dist/lib/type-generation/languages/typescript.js.map +1 -1
- package/dist/lib/types.d.ts +38 -108
- package/dist/lib/types.d.ts.map +1 -1
- package/dist/lib/types.js +1 -2
- package/dist/lib/utils.d.ts +3 -0
- package/dist/lib/utils.d.ts.map +1 -1
- package/dist/lib/utils.js +142 -98
- package/dist/lib/utils.js.map +1 -1
- package/dist/lib/validations.d.ts.map +1 -1
- package/dist/lib/validations.js +2 -6
- package/dist/lib/validations.js.map +1 -1
- package/dist/package.json +68 -0
- package/index.ts +25 -149
- package/install.ps1 +2 -2
- package/install.sh +1 -1
- package/lib/client.ts +261 -220
- package/lib/commands/config.ts +494 -0
- package/lib/commands/db.ts +324 -0
- package/lib/commands/errors.ts +93 -0
- package/lib/commands/generic.ts +371 -269
- package/lib/commands/init.ts +631 -519
- package/lib/commands/pull.ts +827 -453
- package/lib/commands/push.ts +2191 -2349
- package/lib/commands/run.ts +382 -302
- package/lib/commands/schema.ts +122 -0
- package/lib/commands/services/account.ts +647 -0
- package/lib/commands/services/console.ts +52 -0
- package/lib/commands/services/databases.ts +1163 -0
- package/lib/commands/services/functions.ts +536 -0
- package/lib/commands/services/graphql.ts +50 -0
- package/lib/commands/services/health.ts +260 -0
- package/lib/commands/services/locale.ts +102 -0
- package/lib/commands/services/messaging.ts +1052 -0
- package/lib/commands/services/migrations.ts +249 -0
- package/lib/commands/services/project.ts +112 -0
- package/lib/commands/services/projects.ts +785 -0
- package/lib/commands/services/proxy.ts +135 -0
- package/lib/commands/services/sites.ts +505 -0
- package/lib/commands/services/storage.ts +338 -0
- package/lib/commands/services/tables-db.ts +1150 -0
- package/lib/commands/services/teams.ts +232 -0
- package/lib/commands/services/tokens.ts +94 -0
- package/lib/commands/services/users.ts +616 -0
- package/lib/commands/services/vcs.ts +165 -0
- package/lib/commands/types.ts +145 -118
- package/lib/commands/update.ts +189 -159
- package/lib/commands/utils/attributes.ts +719 -0
- package/lib/commands/utils/change-approval.ts +186 -0
- package/lib/commands/utils/database-sync.ts +180 -0
- package/lib/commands/utils/deployment.ts +184 -0
- package/lib/commands/utils/error-formatter.ts +417 -0
- package/lib/commands/utils/pools.ts +355 -0
- package/lib/config.ts +766 -687
- package/lib/constants.ts +22 -0
- package/lib/emulation/docker.ts +277 -216
- package/lib/emulation/utils.ts +188 -174
- package/lib/id.ts +23 -23
- package/lib/paginate.ts +69 -55
- package/lib/parser.ts +220 -189
- package/lib/questions.ts +1024 -948
- package/lib/sdks.ts +84 -51
- package/lib/services.ts +72 -0
- package/lib/spinner.ts +112 -99
- package/lib/type-generation/attribute.ts +15 -14
- package/lib/type-generation/languages/csharp.ts +71 -60
- package/lib/type-generation/languages/dart.ts +106 -93
- package/lib/type-generation/languages/java.ts +69 -58
- package/lib/type-generation/languages/javascript.ts +84 -73
- package/lib/type-generation/languages/kotlin.ts +71 -60
- package/lib/type-generation/languages/language.ts +103 -95
- package/lib/type-generation/languages/php.ts +67 -56
- package/lib/type-generation/languages/swift.ts +71 -60
- package/lib/type-generation/languages/typescript.ts +93 -76
- package/lib/types.ts +50 -125
- package/lib/utils.ts +304 -233
- package/lib/validations.ts +17 -14
- package/package.json +31 -22
- package/scoop/appwrite.config.json +3 -3
- package/tsconfig.json +7 -13
- package/.github/workflows/autoclose.yml +0 -11
- package/.github/workflows/npm-publish.yml +0 -49
- package/dist/lib/commands/account.d.ts +0 -379
- package/dist/lib/commands/account.d.ts.map +0 -1
- package/dist/lib/commands/account.js +0 -1228
- package/dist/lib/commands/account.js.map +0 -1
- package/dist/lib/commands/console.d.ts +0 -20
- package/dist/lib/commands/console.d.ts.map +0 -1
- package/dist/lib/commands/console.js +0 -78
- package/dist/lib/commands/console.js.map +0 -1
- package/dist/lib/commands/databases.d.ts +0 -732
- package/dist/lib/commands/databases.d.ts.map +0 -1
- package/dist/lib/commands/databases.js +0 -2196
- package/dist/lib/commands/databases.js.map +0 -1
- package/dist/lib/commands/functions.d.ts +0 -310
- package/dist/lib/commands/functions.d.ts.map +0 -1
- package/dist/lib/commands/functions.js +0 -1100
- package/dist/lib/commands/functions.js.map +0 -1
- package/dist/lib/commands/graphql.d.ts +0 -19
- package/dist/lib/commands/graphql.d.ts.map +0 -1
- package/dist/lib/commands/graphql.js +0 -77
- package/dist/lib/commands/graphql.js.map +0 -1
- package/dist/lib/commands/health.d.ts +0 -153
- package/dist/lib/commands/health.d.ts.map +0 -1
- package/dist/lib/commands/health.js +0 -464
- package/dist/lib/commands/health.js.map +0 -1
- package/dist/lib/commands/locale.d.ts +0 -53
- package/dist/lib/commands/locale.d.ts.map +0 -1
- package/dist/lib/commands/locale.js +0 -165
- package/dist/lib/commands/locale.js.map +0 -1
- package/dist/lib/commands/messaging.d.ts +0 -588
- package/dist/lib/commands/messaging.d.ts.map +0 -1
- package/dist/lib/commands/messaging.js +0 -2042
- package/dist/lib/commands/messaging.js.map +0 -1
- package/dist/lib/commands/migrations.d.ts +0 -150
- package/dist/lib/commands/migrations.d.ts.map +0 -1
- package/dist/lib/commands/migrations.js +0 -524
- package/dist/lib/commands/migrations.js.map +0 -1
- package/dist/lib/commands/organizations.d.ts +0 -11
- package/dist/lib/commands/organizations.d.ts.map +0 -1
- package/dist/lib/commands/organizations.js +0 -31
- package/dist/lib/commands/organizations.js.map +0 -1
- package/dist/lib/commands/project.d.ts +0 -53
- package/dist/lib/commands/project.d.ts.map +0 -1
- package/dist/lib/commands/project.js +0 -176
- package/dist/lib/commands/project.js.map +0 -1
- package/dist/lib/commands/projects.d.ts +0 -516
- package/dist/lib/commands/projects.d.ts.map +0 -1
- package/dist/lib/commands/projects.js +0 -1590
- package/dist/lib/commands/projects.js.map +0 -1
- package/dist/lib/commands/proxy.d.ts +0 -71
- package/dist/lib/commands/proxy.d.ts.map +0 -1
- package/dist/lib/commands/proxy.js +0 -240
- package/dist/lib/commands/proxy.js.map +0 -1
- package/dist/lib/commands/sites.d.ts +0 -296
- package/dist/lib/commands/sites.d.ts.map +0 -1
- package/dist/lib/commands/sites.js +0 -1046
- package/dist/lib/commands/sites.js.map +0 -1
- package/dist/lib/commands/storage.d.ts +0 -170
- package/dist/lib/commands/storage.d.ts.map +0 -1
- package/dist/lib/commands/storage.js +0 -651
- package/dist/lib/commands/storage.js.map +0 -1
- package/dist/lib/commands/tables-db.d.ts +0 -728
- package/dist/lib/commands/tables-db.d.ts.map +0 -1
- package/dist/lib/commands/tables-db.js +0 -2198
- package/dist/lib/commands/tables-db.js.map +0 -1
- package/dist/lib/commands/teams.d.ts +0 -129
- package/dist/lib/commands/teams.d.ts.map +0 -1
- package/dist/lib/commands/teams.js +0 -403
- package/dist/lib/commands/teams.js.map +0 -1
- package/dist/lib/commands/tokens.d.ts +0 -48
- package/dist/lib/commands/tokens.d.ts.map +0 -1
- package/dist/lib/commands/tokens.js +0 -156
- package/dist/lib/commands/tokens.js.map +0 -1
- package/dist/lib/commands/users.d.ts +0 -382
- package/dist/lib/commands/users.d.ts.map +0 -1
- package/dist/lib/commands/users.js +0 -1195
- package/dist/lib/commands/users.js.map +0 -1
- package/dist/lib/commands/vcs.d.ts +0 -92
- package/dist/lib/commands/vcs.d.ts.map +0 -1
- package/dist/lib/commands/vcs.js +0 -276
- package/dist/lib/commands/vcs.js.map +0 -1
- package/dist/lib/exception.d.ts +0 -8
- package/dist/lib/exception.d.ts.map +0 -1
- package/dist/lib/exception.js +0 -16
- package/dist/lib/exception.js.map +0 -1
- package/lib/commands/account.ts +0 -1867
- package/lib/commands/console.ts +0 -112
- package/lib/commands/databases.ts +0 -3272
- package/lib/commands/functions.ts +0 -1587
- package/lib/commands/graphql.ts +0 -110
- package/lib/commands/health.ts +0 -753
- package/lib/commands/locale.ts +0 -270
- package/lib/commands/messaging.ts +0 -2878
- package/lib/commands/migrations.ts +0 -754
- package/lib/commands/organizations.ts +0 -46
- package/lib/commands/project.ts +0 -266
- package/lib/commands/projects.ts +0 -2370
- package/lib/commands/proxy.ts +0 -357
- package/lib/commands/sites.ts +0 -1514
- package/lib/commands/storage.ts +0 -919
- package/lib/commands/tables-db.ts +0 -3260
- package/lib/commands/teams.ts +0 -609
- package/lib/commands/tokens.ts +0 -232
- package/lib/commands/users.ts +0 -1804
- package/lib/commands/vcs.ts +0 -428
- package/lib/exception.ts +0 -20
|
@@ -1,24 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
};
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
const questions_1 = require("../questions");
|
|
17
|
-
const parser_1 = require("../parser");
|
|
18
|
-
const account_1 = require("./account");
|
|
19
|
-
const sites_1 = require("./sites");
|
|
20
|
-
const sdks_1 = require("../sdks");
|
|
21
|
-
const utils_1 = require("../utils");
|
|
1
|
+
import fs from "fs";
|
|
2
|
+
import path from "path";
|
|
3
|
+
import childProcess from "child_process";
|
|
4
|
+
import { Command } from "commander";
|
|
5
|
+
import inquirer from "inquirer";
|
|
6
|
+
import { getProjectsService, getSitesService } from "../services.js";
|
|
7
|
+
import { pullResources } from "./pull.js";
|
|
8
|
+
import ID from "../id.js";
|
|
9
|
+
import { localConfig, globalConfig } from "../config.js";
|
|
10
|
+
import { questionsCreateFunction, questionsCreateFunctionSelectTemplate, questionsCreateSite, questionsCreateBucket, questionsCreateMessagingTopic, questionsCreateCollection, questionsCreateTable, questionsInitProject, questionsInitProjectAutopull, questionsInitResources, questionsCreateTeam, } from "../questions.js";
|
|
11
|
+
import { cliConfig, success, log, hint, error, actionRunner, commandDescriptions, } from "../parser.js";
|
|
12
|
+
import { sdkForConsole } from "../sdks.js";
|
|
13
|
+
import { isCloud } from "../utils.js";
|
|
14
|
+
import { Account } from "@appwrite.io/console";
|
|
15
|
+
import { DEFAULT_ENDPOINT, EXECUTABLE_NAME } from "../constants.js";
|
|
22
16
|
const initResources = async () => {
|
|
23
17
|
const actions = {
|
|
24
18
|
function: initFunction,
|
|
@@ -27,50 +21,53 @@ const initResources = async () => {
|
|
|
27
21
|
bucket: initBucket,
|
|
28
22
|
team: initTeam,
|
|
29
23
|
message: initTopic,
|
|
30
|
-
collection: initCollection
|
|
24
|
+
collection: initCollection,
|
|
31
25
|
};
|
|
32
|
-
const answers = await
|
|
26
|
+
const answers = await inquirer.prompt([questionsInitResources[0]]);
|
|
33
27
|
const action = actions[answers.resource];
|
|
34
28
|
if (action !== undefined) {
|
|
35
29
|
await action({ returnOnZero: true });
|
|
36
30
|
}
|
|
37
31
|
};
|
|
38
|
-
const initProject = async ({ organizationId, projectId, projectName } = {}) => {
|
|
32
|
+
const initProject = async ({ organizationId, projectId, projectName, } = {}) => {
|
|
39
33
|
let response = {};
|
|
40
34
|
try {
|
|
41
|
-
if (
|
|
42
|
-
throw '';
|
|
35
|
+
if (globalConfig.getEndpoint() === "" || globalConfig.getCookie() === "") {
|
|
36
|
+
throw new Error(`Missing endpoint or cookie configuration. Please run '${EXECUTABLE_NAME} login' first.`);
|
|
43
37
|
}
|
|
44
|
-
const client = await
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
sdk: client
|
|
48
|
-
});
|
|
38
|
+
const client = await sdkForConsole();
|
|
39
|
+
const accountClient = new Account(client);
|
|
40
|
+
await accountClient.get();
|
|
49
41
|
}
|
|
50
42
|
catch (e) {
|
|
51
|
-
|
|
43
|
+
error(`Error Session not found. Please run '${EXECUTABLE_NAME} login' to create a session`);
|
|
52
44
|
process.exit(1);
|
|
53
45
|
}
|
|
54
46
|
let answers = {};
|
|
55
47
|
if (!organizationId && !projectId && !projectName) {
|
|
56
|
-
answers = await
|
|
48
|
+
answers = await inquirer.prompt(questionsInitProject);
|
|
57
49
|
if (answers.override === false) {
|
|
58
50
|
process.exit(1);
|
|
59
51
|
}
|
|
60
52
|
}
|
|
61
53
|
else {
|
|
62
|
-
answers.start =
|
|
54
|
+
answers.start = "existing";
|
|
63
55
|
answers.project = {};
|
|
64
56
|
answers.organization = {};
|
|
65
|
-
answers.organization =
|
|
66
|
-
|
|
67
|
-
|
|
57
|
+
answers.organization =
|
|
58
|
+
organizationId ??
|
|
59
|
+
(await inquirer.prompt([questionsInitProject[2]])).organization;
|
|
60
|
+
answers.project.name =
|
|
61
|
+
projectName ?? (await inquirer.prompt([questionsInitProject[3]])).project;
|
|
62
|
+
answers.project =
|
|
63
|
+
projectId ?? (await inquirer.prompt([questionsInitProject[4]])).id;
|
|
68
64
|
try {
|
|
69
|
-
|
|
65
|
+
const projectsService = await getProjectsService();
|
|
66
|
+
await projectsService.get(projectId);
|
|
70
67
|
}
|
|
71
68
|
catch (e) {
|
|
72
69
|
if (e.code === 404) {
|
|
73
|
-
answers.start =
|
|
70
|
+
answers.start = "new";
|
|
74
71
|
answers.id = answers.project;
|
|
75
72
|
answers.project = answers.project.name;
|
|
76
73
|
}
|
|
@@ -79,137 +76,133 @@ const initProject = async ({ organizationId, projectId, projectName } = {}) => {
|
|
|
79
76
|
}
|
|
80
77
|
}
|
|
81
78
|
}
|
|
82
|
-
|
|
83
|
-
const url = new URL(
|
|
84
|
-
if (answers.start ===
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
teamId: answers.organization,
|
|
89
|
-
parseOutput: false
|
|
90
|
-
});
|
|
91
|
-
config_1.localConfig.setProject(response['$id']);
|
|
79
|
+
localConfig.clear(); // Clear the config to avoid any conflicts
|
|
80
|
+
const url = new URL(DEFAULT_ENDPOINT);
|
|
81
|
+
if (answers.start === "new") {
|
|
82
|
+
const projectsService = await getProjectsService();
|
|
83
|
+
response = await projectsService.create(answers.id, answers.project, answers.organization, answers.region);
|
|
84
|
+
localConfig.setProject(response["$id"]);
|
|
92
85
|
if (answers.region) {
|
|
93
|
-
|
|
86
|
+
localConfig.setEndpoint(`https://${answers.region}.${url.host}${url.pathname}`);
|
|
94
87
|
}
|
|
95
88
|
}
|
|
96
89
|
else {
|
|
97
|
-
|
|
98
|
-
if (
|
|
99
|
-
|
|
90
|
+
localConfig.setProject(answers.project["$id"]);
|
|
91
|
+
if (isCloud()) {
|
|
92
|
+
localConfig.setEndpoint(`https://${answers.project["region"]}.${url.host}${url.pathname}`);
|
|
100
93
|
}
|
|
101
94
|
}
|
|
102
|
-
|
|
103
|
-
if (answers.start ===
|
|
104
|
-
answers = await
|
|
95
|
+
success(`Project successfully ${answers.start === "existing" ? "linked" : "created"}. Details are now stored in appwrite.config.json file.`);
|
|
96
|
+
if (answers.start === "existing") {
|
|
97
|
+
answers = await inquirer.prompt(questionsInitProjectAutopull);
|
|
105
98
|
if (answers.autopull) {
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
await
|
|
109
|
-
skipDeprecated: true
|
|
99
|
+
cliConfig.all = true;
|
|
100
|
+
cliConfig.force = true;
|
|
101
|
+
await pullResources({
|
|
102
|
+
skipDeprecated: true,
|
|
110
103
|
});
|
|
111
104
|
}
|
|
112
105
|
else {
|
|
113
|
-
|
|
106
|
+
log(`You can run '${EXECUTABLE_NAME} pull all' to synchronize all of your existing resources.`);
|
|
114
107
|
}
|
|
115
108
|
}
|
|
116
|
-
|
|
109
|
+
hint(`Next you can use '${EXECUTABLE_NAME} init' to create resources in your project, or use '${EXECUTABLE_NAME} pull' and '${EXECUTABLE_NAME} push' to synchronize your project.`);
|
|
117
110
|
};
|
|
118
111
|
const initBucket = async () => {
|
|
119
|
-
const answers = await
|
|
120
|
-
|
|
121
|
-
$id: answers.id ===
|
|
112
|
+
const answers = await inquirer.prompt(questionsCreateBucket);
|
|
113
|
+
localConfig.addBucket({
|
|
114
|
+
$id: answers.id === "unique()" ? ID.unique() : answers.id,
|
|
122
115
|
name: answers.bucket,
|
|
123
|
-
fileSecurity: answers.fileSecurity.toLowerCase() ===
|
|
116
|
+
fileSecurity: answers.fileSecurity.toLowerCase() === "yes",
|
|
124
117
|
enabled: true,
|
|
125
118
|
});
|
|
126
|
-
|
|
127
|
-
|
|
119
|
+
success("Initialing bucket");
|
|
120
|
+
log(`Next you can use '${EXECUTABLE_NAME} push bucket' to deploy the changes.`);
|
|
128
121
|
};
|
|
129
122
|
const initTeam = async () => {
|
|
130
|
-
const answers = await
|
|
131
|
-
|
|
132
|
-
$id: answers.id ===
|
|
133
|
-
name: answers.
|
|
123
|
+
const answers = await inquirer.prompt(questionsCreateTeam);
|
|
124
|
+
localConfig.addTeam({
|
|
125
|
+
$id: answers.id === "unique()" ? ID.unique() : answers.id,
|
|
126
|
+
name: answers.team,
|
|
134
127
|
});
|
|
135
|
-
|
|
136
|
-
|
|
128
|
+
success("Initialing team");
|
|
129
|
+
log(`Next you can use '${EXECUTABLE_NAME} push team' to deploy the changes.`);
|
|
137
130
|
};
|
|
138
131
|
const initTable = async () => {
|
|
139
|
-
const answers = await
|
|
140
|
-
const newDatabase = (answers.method ??
|
|
132
|
+
const answers = await inquirer.prompt(questionsCreateTable);
|
|
133
|
+
const newDatabase = (answers.method ?? "").toLowerCase() !== "existing";
|
|
141
134
|
if (!newDatabase) {
|
|
142
135
|
answers.databaseId = answers.database;
|
|
143
|
-
answers.databaseName =
|
|
136
|
+
answers.databaseName = localConfig.getTablesDB(answers.database).name;
|
|
144
137
|
}
|
|
145
|
-
const databaseId = answers.databaseId ===
|
|
146
|
-
if (newDatabase || !
|
|
147
|
-
|
|
138
|
+
const databaseId = answers.databaseId === "unique()" ? ID.unique() : answers.databaseId;
|
|
139
|
+
if (newDatabase || !localConfig.getTablesDB(answers.databaseId)) {
|
|
140
|
+
localConfig.addTablesDB({
|
|
148
141
|
$id: databaseId,
|
|
149
142
|
name: answers.databaseName,
|
|
150
|
-
enabled: true
|
|
143
|
+
enabled: true,
|
|
151
144
|
});
|
|
152
145
|
}
|
|
153
|
-
|
|
154
|
-
$id: answers.id ===
|
|
146
|
+
localConfig.addTable({
|
|
147
|
+
$id: answers.id === "unique()" ? ID.unique() : answers.id,
|
|
155
148
|
$permissions: [],
|
|
156
149
|
databaseId: databaseId,
|
|
157
150
|
name: answers.table,
|
|
158
151
|
enabled: true,
|
|
159
|
-
rowSecurity: answers.rowSecurity.toLowerCase() ===
|
|
152
|
+
rowSecurity: answers.rowSecurity.toLowerCase() === "yes",
|
|
160
153
|
columns: [],
|
|
161
154
|
indexes: [],
|
|
162
155
|
});
|
|
163
|
-
|
|
164
|
-
|
|
156
|
+
success("Initialing table");
|
|
157
|
+
log(`Next you can use '${EXECUTABLE_NAME} push table' to deploy the changes.`);
|
|
165
158
|
};
|
|
166
159
|
const initCollection = async () => {
|
|
167
|
-
const answers = await
|
|
168
|
-
const newDatabase = (answers.method ??
|
|
160
|
+
const answers = await inquirer.prompt(questionsCreateCollection);
|
|
161
|
+
const newDatabase = (answers.method ?? "").toLowerCase() !== "existing";
|
|
169
162
|
if (!newDatabase) {
|
|
170
163
|
answers.databaseId = answers.database;
|
|
171
|
-
answers.databaseName =
|
|
164
|
+
answers.databaseName = localConfig.getDatabase(answers.database).name;
|
|
172
165
|
}
|
|
173
|
-
const databaseId = answers.databaseId ===
|
|
174
|
-
if (newDatabase || !
|
|
175
|
-
|
|
166
|
+
const databaseId = answers.databaseId === "unique()" ? ID.unique() : answers.databaseId;
|
|
167
|
+
if (newDatabase || !localConfig.getDatabase(answers.databaseId)) {
|
|
168
|
+
localConfig.addDatabase({
|
|
176
169
|
$id: databaseId,
|
|
177
170
|
name: answers.databaseName,
|
|
178
|
-
enabled: true
|
|
171
|
+
enabled: true,
|
|
179
172
|
});
|
|
180
173
|
}
|
|
181
|
-
|
|
182
|
-
$id: answers.id ===
|
|
174
|
+
localConfig.addCollection({
|
|
175
|
+
$id: answers.id === "unique()" ? ID.unique() : answers.id,
|
|
183
176
|
databaseId: databaseId,
|
|
184
177
|
name: answers.collection,
|
|
185
|
-
documentSecurity: answers.documentSecurity.toLowerCase() ===
|
|
178
|
+
documentSecurity: answers.documentSecurity.toLowerCase() === "yes",
|
|
186
179
|
attributes: [],
|
|
187
180
|
indexes: [],
|
|
188
181
|
enabled: true,
|
|
189
182
|
});
|
|
190
|
-
|
|
191
|
-
|
|
183
|
+
success("Initialing collection");
|
|
184
|
+
log(`Next you can use '${EXECUTABLE_NAME} push collection' to deploy the changes.`);
|
|
192
185
|
};
|
|
193
186
|
const initTopic = async () => {
|
|
194
|
-
const answers = await
|
|
195
|
-
|
|
196
|
-
$id: answers.id ===
|
|
187
|
+
const answers = await inquirer.prompt(questionsCreateMessagingTopic);
|
|
188
|
+
localConfig.addMessagingTopic({
|
|
189
|
+
$id: answers.id === "unique()" ? ID.unique() : answers.id,
|
|
197
190
|
name: answers.topic,
|
|
198
191
|
});
|
|
199
|
-
|
|
200
|
-
|
|
192
|
+
success("Initialing topic");
|
|
193
|
+
log(`Next you can use '${EXECUTABLE_NAME} push topic' to deploy the changes.`);
|
|
201
194
|
};
|
|
202
195
|
const initFunction = async () => {
|
|
203
|
-
process.chdir(
|
|
196
|
+
process.chdir(localConfig.configDirectoryPath);
|
|
204
197
|
// TODO: Add CI/CD support (ID, name, runtime)
|
|
205
|
-
const answers = await
|
|
206
|
-
const functionFolder = path.join(process.cwd(),
|
|
198
|
+
const answers = await inquirer.prompt(questionsCreateFunction);
|
|
199
|
+
const functionFolder = path.join(process.cwd(), "functions");
|
|
207
200
|
if (!fs.existsSync(functionFolder)) {
|
|
208
201
|
fs.mkdirSync(functionFolder, {
|
|
209
|
-
recursive: true
|
|
202
|
+
recursive: true,
|
|
210
203
|
});
|
|
211
204
|
}
|
|
212
|
-
const functionId = answers.id ===
|
|
205
|
+
const functionId = answers.id === "unique()" ? ID.unique() : answers.id;
|
|
213
206
|
const functionName = answers.name;
|
|
214
207
|
const functionDir = path.join(functionFolder, functionName);
|
|
215
208
|
const templatesDir = path.join(functionFolder, `${functionId}-templates`);
|
|
@@ -218,35 +211,44 @@ const initFunction = async () => {
|
|
|
218
211
|
throw new Error(`( ${functionName} ) already exists in the current directory. Please choose another name.`);
|
|
219
212
|
}
|
|
220
213
|
if (!answers.runtime.entrypoint) {
|
|
221
|
-
|
|
214
|
+
log(`Entrypoint for this runtime not found. You will be asked to configure entrypoint when you first push the function.`);
|
|
222
215
|
}
|
|
223
216
|
if (!answers.runtime.commands) {
|
|
224
|
-
|
|
217
|
+
log(`Installation command for this runtime not found. You will be asked to configure the install command when you first push the function.`);
|
|
225
218
|
}
|
|
226
219
|
fs.mkdirSync(functionDir, { mode: 0o777 });
|
|
227
220
|
fs.mkdirSync(templatesDir, { mode: 0o777 });
|
|
228
221
|
const repo = "https://github.com/appwrite/templates";
|
|
229
222
|
const api = `https://api.github.com/repos/appwrite/templates/contents/${answers.runtime.name}`;
|
|
230
|
-
let selected = { template:
|
|
231
|
-
const sparse = (selected
|
|
223
|
+
let selected = { template: "starter" };
|
|
224
|
+
const sparse = (selected
|
|
225
|
+
? `${answers.runtime.name}/${selected.template}`
|
|
226
|
+
: answers.runtime.name).toLowerCase();
|
|
232
227
|
let gitInitCommands = `git clone --single-branch --depth 1 --sparse ${repo} .`; // depth prevents fetching older commits reducing the amount fetched
|
|
233
228
|
let gitPullCommands = `git sparse-checkout add ${sparse}`;
|
|
234
229
|
/* Force use CMD as powershell does not support && */
|
|
235
|
-
if (process.platform ===
|
|
230
|
+
if (process.platform === "win32") {
|
|
236
231
|
gitInitCommands = 'cmd /c "' + gitInitCommands + '"';
|
|
237
232
|
gitPullCommands = 'cmd /c "' + gitPullCommands + '"';
|
|
238
233
|
}
|
|
239
234
|
/* Execute the child process but do not print any std output */
|
|
240
235
|
try {
|
|
241
|
-
childProcess.execSync(gitInitCommands, {
|
|
242
|
-
|
|
236
|
+
childProcess.execSync(gitInitCommands, {
|
|
237
|
+
stdio: "pipe",
|
|
238
|
+
cwd: templatesDir,
|
|
239
|
+
});
|
|
240
|
+
childProcess.execSync(gitPullCommands, {
|
|
241
|
+
stdio: "pipe",
|
|
242
|
+
cwd: templatesDir,
|
|
243
|
+
});
|
|
243
244
|
}
|
|
244
245
|
catch (err) {
|
|
245
246
|
/* Specialised errors with recommended actions to take */
|
|
246
|
-
if (err.message.includes(
|
|
247
|
+
if (err.message.includes("error: unknown option")) {
|
|
247
248
|
throw new Error(`${err.message} \n\nSuggestion: Try updating your git to the latest version, then trying to run this command again.`);
|
|
248
249
|
}
|
|
249
|
-
else if (err.message.includes(
|
|
250
|
+
else if (err.message.includes("is not recognized as an internal or external command,") ||
|
|
251
|
+
err.message.includes("command not found")) {
|
|
250
252
|
throw new Error(`${err.message} \n\nSuggestion: It appears that git is not installed, try installing git then trying to run this command again.`);
|
|
251
253
|
}
|
|
252
254
|
else {
|
|
@@ -256,12 +258,13 @@ const initFunction = async () => {
|
|
|
256
258
|
fs.rmSync(path.join(templatesDir, ".git"), { recursive: true });
|
|
257
259
|
if (!selected) {
|
|
258
260
|
const templates = [];
|
|
259
|
-
templates.push(...fs
|
|
260
|
-
.
|
|
261
|
-
.
|
|
262
|
-
|
|
261
|
+
templates.push(...fs
|
|
262
|
+
.readdirSync(runtimeDir, { withFileTypes: true })
|
|
263
|
+
.filter((item) => item.isDirectory() && item.name !== "starter")
|
|
264
|
+
.map((dirent) => dirent.name));
|
|
265
|
+
selected = { template: "starter" };
|
|
263
266
|
if (templates.length > 1) {
|
|
264
|
-
selected = await
|
|
267
|
+
selected = await inquirer.prompt(questionsCreateFunctionSelectTemplate(templates));
|
|
265
268
|
}
|
|
266
269
|
}
|
|
267
270
|
const copyRecursiveSync = (src, dest) => {
|
|
@@ -282,12 +285,12 @@ const initFunction = async () => {
|
|
|
282
285
|
};
|
|
283
286
|
copyRecursiveSync(path.join(runtimeDir, selected.template), functionDir);
|
|
284
287
|
fs.rmSync(templatesDir, { recursive: true, force: true });
|
|
285
|
-
const readmePath = path.join(process.cwd(),
|
|
288
|
+
const readmePath = path.join(process.cwd(), "functions", functionName, "README.md");
|
|
286
289
|
const readmeFile = fs.readFileSync(readmePath).toString();
|
|
287
|
-
const newReadmeFile = readmeFile.split(
|
|
290
|
+
const newReadmeFile = readmeFile.split("\n");
|
|
288
291
|
newReadmeFile[0] = `# ${answers.name}`;
|
|
289
292
|
newReadmeFile.splice(1, 2);
|
|
290
|
-
fs.writeFileSync(readmePath, newReadmeFile.join(
|
|
293
|
+
fs.writeFileSync(readmePath, newReadmeFile.join("\n"));
|
|
291
294
|
let data = {
|
|
292
295
|
$id: functionId,
|
|
293
296
|
name: answers.name,
|
|
@@ -300,25 +303,25 @@ const initFunction = async () => {
|
|
|
300
303
|
timeout: 15,
|
|
301
304
|
enabled: true,
|
|
302
305
|
logging: true,
|
|
303
|
-
entrypoint: answers.runtime.entrypoint ||
|
|
304
|
-
commands: answers.runtime.commands ||
|
|
306
|
+
entrypoint: answers.runtime.entrypoint || "",
|
|
307
|
+
commands: answers.runtime.commands || "",
|
|
305
308
|
ignore: answers.runtime.ignore || null,
|
|
306
309
|
path: `functions/${functionName}`,
|
|
307
310
|
};
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
+
localConfig.addFunction(data);
|
|
312
|
+
success("Initialing function");
|
|
313
|
+
log(`Next you can use '${EXECUTABLE_NAME} run function' to develop a function locally. To deploy the function, use '${EXECUTABLE_NAME} push function'`);
|
|
311
314
|
};
|
|
312
315
|
const initSite = async () => {
|
|
313
|
-
process.chdir(
|
|
314
|
-
const answers = await
|
|
315
|
-
const siteFolder = path.join(process.cwd(),
|
|
316
|
+
process.chdir(localConfig.configDirectoryPath);
|
|
317
|
+
const answers = await inquirer.prompt(questionsCreateSite);
|
|
318
|
+
const siteFolder = path.join(process.cwd(), "sites");
|
|
316
319
|
if (!fs.existsSync(siteFolder)) {
|
|
317
320
|
fs.mkdirSync(siteFolder, {
|
|
318
|
-
recursive: true
|
|
321
|
+
recursive: true,
|
|
319
322
|
});
|
|
320
323
|
}
|
|
321
|
-
const siteId = answers.id ===
|
|
324
|
+
const siteId = answers.id === "unique()" ? ID.unique() : answers.id;
|
|
322
325
|
const siteName = answers.name;
|
|
323
326
|
const siteDir = path.join(siteFolder, siteName);
|
|
324
327
|
const templatesDir = path.join(siteFolder, `${siteId}-templates`);
|
|
@@ -327,12 +330,8 @@ const initSite = async () => {
|
|
|
327
330
|
}
|
|
328
331
|
let templateDetails;
|
|
329
332
|
try {
|
|
330
|
-
const
|
|
331
|
-
|
|
332
|
-
useCases: ['starter'],
|
|
333
|
-
limit: 1,
|
|
334
|
-
parseOutput: false
|
|
335
|
-
});
|
|
333
|
+
const sitesService = await getSitesService();
|
|
334
|
+
const response = await sitesService.listTemplates([answers.framework.key], ["starter"], 1);
|
|
336
335
|
if (response.total == 0) {
|
|
337
336
|
throw new Error(`No starter template found for framework ${answers.framework.key}`);
|
|
338
337
|
}
|
|
@@ -344,11 +343,15 @@ const initSite = async () => {
|
|
|
344
343
|
fs.mkdirSync(siteDir, { mode: 0o777 });
|
|
345
344
|
fs.mkdirSync(templatesDir, { mode: 0o777 });
|
|
346
345
|
const repo = `https://github.com/${templateDetails.providerOwner}/${templateDetails.providerRepositoryId}`;
|
|
347
|
-
let selected = {
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
346
|
+
let selected = {
|
|
347
|
+
template: templateDetails.frameworks[0].providerRootDirectory,
|
|
348
|
+
};
|
|
349
|
+
let gitCloneCommands = "";
|
|
350
|
+
const sparse = selected.template.startsWith("./")
|
|
351
|
+
? selected.template.substring(2)
|
|
352
|
+
: selected.template;
|
|
353
|
+
log("Fetching site code ...");
|
|
354
|
+
if (selected.template === "./") {
|
|
352
355
|
gitCloneCommands = `
|
|
353
356
|
mkdir -p .
|
|
354
357
|
cd .
|
|
@@ -375,19 +378,23 @@ const initSite = async () => {
|
|
|
375
378
|
`.trim();
|
|
376
379
|
}
|
|
377
380
|
/* Force use CMD as powershell does not support && */
|
|
378
|
-
if (process.platform ===
|
|
381
|
+
if (process.platform === "win32") {
|
|
379
382
|
gitCloneCommands = 'cmd /c "' + gitCloneCommands + '"';
|
|
380
383
|
}
|
|
381
384
|
/* Execute the child process but do not print any std output */
|
|
382
385
|
try {
|
|
383
|
-
childProcess.execSync(gitCloneCommands, {
|
|
386
|
+
childProcess.execSync(gitCloneCommands, {
|
|
387
|
+
stdio: "pipe",
|
|
388
|
+
cwd: templatesDir,
|
|
389
|
+
});
|
|
384
390
|
}
|
|
385
391
|
catch (err) {
|
|
386
392
|
/* Specialised errors with recommended actions to take */
|
|
387
|
-
if (err.message.includes(
|
|
393
|
+
if (err.message.includes("error: unknown option")) {
|
|
388
394
|
throw new Error(`${err.message} \n\nSuggestion: Try updating your git to the latest version, then trying to run this command again.`);
|
|
389
395
|
}
|
|
390
|
-
else if (err.message.includes(
|
|
396
|
+
else if (err.message.includes("is not recognized as an internal or external command,") ||
|
|
397
|
+
err.message.includes("command not found")) {
|
|
391
398
|
throw new Error(`${err.message} \n\nSuggestion: It appears that git is not installed, try installing git then trying to run this command again.`);
|
|
392
399
|
}
|
|
393
400
|
else {
|
|
@@ -411,20 +418,22 @@ const initSite = async () => {
|
|
|
411
418
|
fs.copyFileSync(src, dest);
|
|
412
419
|
}
|
|
413
420
|
};
|
|
414
|
-
copyRecursiveSync(selected.template ===
|
|
421
|
+
copyRecursiveSync(selected.template === "./"
|
|
422
|
+
? templatesDir
|
|
423
|
+
: path.join(templatesDir, selected.template), siteDir);
|
|
415
424
|
fs.rmSync(templatesDir, { recursive: true, force: true });
|
|
416
|
-
const readmePath = path.join(process.cwd(),
|
|
425
|
+
const readmePath = path.join(process.cwd(), "sites", siteName, "README.md");
|
|
417
426
|
const readmeFile = fs.readFileSync(readmePath).toString();
|
|
418
|
-
const newReadmeFile = readmeFile.split(
|
|
419
|
-
newReadmeFile[0] = `# ${answers.
|
|
427
|
+
const newReadmeFile = readmeFile.split("\n");
|
|
428
|
+
newReadmeFile[0] = `# ${answers.name}`;
|
|
420
429
|
newReadmeFile.splice(1, 2);
|
|
421
|
-
fs.writeFileSync(readmePath, newReadmeFile.join(
|
|
430
|
+
fs.writeFileSync(readmePath, newReadmeFile.join("\n"));
|
|
422
431
|
let vars = (templateDetails.variables ?? []).map((variable) => {
|
|
423
432
|
let value = variable.value;
|
|
424
433
|
const replacements = {
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
434
|
+
"{apiEndpoint}": globalConfig.getEndpoint(),
|
|
435
|
+
"{projectId}": localConfig.getProject().projectId,
|
|
436
|
+
"{projectName}": localConfig.getProject().projectName,
|
|
428
437
|
};
|
|
429
438
|
for (const placeholder in replacements) {
|
|
430
439
|
if (value?.includes(placeholder)) {
|
|
@@ -433,86 +442,86 @@ const initSite = async () => {
|
|
|
433
442
|
}
|
|
434
443
|
return {
|
|
435
444
|
key: variable.name,
|
|
436
|
-
value: value
|
|
445
|
+
value: value,
|
|
437
446
|
};
|
|
438
447
|
});
|
|
439
448
|
let data = {
|
|
440
449
|
$id: siteId,
|
|
441
450
|
name: answers.name,
|
|
442
451
|
framework: answers.framework.key,
|
|
443
|
-
adapter: templateDetails.frameworks[0].adapter ||
|
|
444
|
-
buildRuntime: templateDetails.frameworks[0].buildRuntime ||
|
|
445
|
-
installCommand: templateDetails.frameworks[0].installCommand ||
|
|
446
|
-
buildCommand: templateDetails.frameworks[0].buildCommand ||
|
|
447
|
-
outputDirectory: templateDetails.frameworks[0].outputDirectory ||
|
|
448
|
-
fallbackFile: templateDetails.frameworks[0].fallbackFile ||
|
|
452
|
+
adapter: templateDetails.frameworks[0].adapter || "",
|
|
453
|
+
buildRuntime: templateDetails.frameworks[0].buildRuntime || "",
|
|
454
|
+
installCommand: templateDetails.frameworks[0].installCommand || "",
|
|
455
|
+
buildCommand: templateDetails.frameworks[0].buildCommand || "",
|
|
456
|
+
outputDirectory: templateDetails.frameworks[0].outputDirectory || "",
|
|
457
|
+
fallbackFile: templateDetails.frameworks[0].fallbackFile || "",
|
|
449
458
|
specification: answers.specification,
|
|
450
459
|
enabled: true,
|
|
451
460
|
timeout: 30,
|
|
452
461
|
logging: true,
|
|
453
462
|
ignore: answers.framework.ignore || null,
|
|
454
463
|
path: `sites/${siteName}`,
|
|
455
|
-
vars: vars
|
|
464
|
+
vars: vars,
|
|
456
465
|
};
|
|
457
466
|
if (!data.buildRuntime) {
|
|
458
|
-
|
|
467
|
+
log(`Build runtime for this framework not found. You will be asked to configure build runtime when you first push the site.`);
|
|
459
468
|
}
|
|
460
469
|
if (!data.installCommand) {
|
|
461
|
-
|
|
470
|
+
log(`Installation command for this framework not found. You will be asked to configure the install command when you first push the site.`);
|
|
462
471
|
}
|
|
463
472
|
if (!data.buildCommand) {
|
|
464
|
-
|
|
473
|
+
log(`Build command for this framework not found. You will be asked to configure the build command when you first push the site.`);
|
|
465
474
|
}
|
|
466
475
|
if (!data.outputDirectory) {
|
|
467
|
-
|
|
476
|
+
log(`Output directory for this framework not found. You will be asked to configure the output directory when you first push the site.`);
|
|
468
477
|
}
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
478
|
+
localConfig.addSite(data);
|
|
479
|
+
success("Initializing site");
|
|
480
|
+
log(`Next you can use '${EXECUTABLE_NAME} push site' to deploy the changes.`);
|
|
472
481
|
};
|
|
473
|
-
|
|
474
|
-
.description(
|
|
475
|
-
.action(
|
|
476
|
-
|
|
482
|
+
export const init = new Command("init")
|
|
483
|
+
.description(commandDescriptions["init"])
|
|
484
|
+
.action(actionRunner(initResources));
|
|
485
|
+
init
|
|
477
486
|
.command("project")
|
|
478
487
|
.description("Init a new Appwrite project")
|
|
479
488
|
.option("--organization-id <organization-id>", "Appwrite organization ID")
|
|
480
489
|
.option("--project-id <project-id>", "Appwrite project ID")
|
|
481
490
|
.option("--project-name <project-name>", "Appwrite project ID")
|
|
482
|
-
.action(
|
|
483
|
-
|
|
491
|
+
.action(actionRunner(initProject));
|
|
492
|
+
init
|
|
484
493
|
.command("function")
|
|
485
494
|
.alias("functions")
|
|
486
495
|
.description("Init a new Appwrite function")
|
|
487
|
-
.action(
|
|
488
|
-
|
|
496
|
+
.action(actionRunner(initFunction));
|
|
497
|
+
init
|
|
489
498
|
.command("site")
|
|
490
499
|
.alias("sites")
|
|
491
500
|
.description("Init a new Appwrite site")
|
|
492
|
-
.action(
|
|
493
|
-
|
|
501
|
+
.action(actionRunner(initSite));
|
|
502
|
+
init
|
|
494
503
|
.command("bucket")
|
|
495
504
|
.alias("buckets")
|
|
496
505
|
.description("Init a new Appwrite bucket")
|
|
497
|
-
.action(
|
|
498
|
-
|
|
506
|
+
.action(actionRunner(initBucket));
|
|
507
|
+
init
|
|
499
508
|
.command("team")
|
|
500
509
|
.alias("teams")
|
|
501
510
|
.description("Init a new Appwrite team")
|
|
502
|
-
.action(
|
|
503
|
-
|
|
511
|
+
.action(actionRunner(initTeam));
|
|
512
|
+
init
|
|
504
513
|
.command("collection")
|
|
505
514
|
.alias("collections")
|
|
506
515
|
.description("Init a new Appwrite collection")
|
|
507
|
-
.action(
|
|
508
|
-
|
|
516
|
+
.action(actionRunner(initCollection));
|
|
517
|
+
init
|
|
509
518
|
.command("table")
|
|
510
519
|
.alias("tables")
|
|
511
520
|
.description("Init a new Appwrite table")
|
|
512
|
-
.action(
|
|
513
|
-
|
|
521
|
+
.action(actionRunner(initTable));
|
|
522
|
+
init
|
|
514
523
|
.command("topic")
|
|
515
524
|
.alias("topics")
|
|
516
525
|
.description("Init a new Appwrite topic")
|
|
517
|
-
.action(
|
|
526
|
+
.action(actionRunner(initTopic));
|
|
518
527
|
//# sourceMappingURL=init.js.map
|