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
package/lib/commands/init.ts
CHANGED
|
@@ -1,429 +1,514 @@
|
|
|
1
|
-
import fs
|
|
2
|
-
import path
|
|
3
|
-
import childProcess
|
|
4
|
-
import { Command } from
|
|
5
|
-
import inquirer from
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import
|
|
9
|
-
import {
|
|
10
|
-
import { databasesCreateCollection } from './databases';
|
|
11
|
-
import { pullResources } from './pull';
|
|
12
|
-
import ID from '../id';
|
|
13
|
-
import { localConfig, globalConfig } from '../config';
|
|
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";
|
|
14
10
|
import {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
} from
|
|
27
|
-
import {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
11
|
+
questionsCreateFunction,
|
|
12
|
+
questionsCreateFunctionSelectTemplate,
|
|
13
|
+
questionsCreateSite,
|
|
14
|
+
questionsCreateBucket,
|
|
15
|
+
questionsCreateMessagingTopic,
|
|
16
|
+
questionsCreateCollection,
|
|
17
|
+
questionsCreateTable,
|
|
18
|
+
questionsInitProject,
|
|
19
|
+
questionsInitProjectAutopull,
|
|
20
|
+
questionsInitResources,
|
|
21
|
+
questionsCreateTeam,
|
|
22
|
+
} from "../questions.js";
|
|
23
|
+
import {
|
|
24
|
+
cliConfig,
|
|
25
|
+
success,
|
|
26
|
+
log,
|
|
27
|
+
hint,
|
|
28
|
+
error,
|
|
29
|
+
actionRunner,
|
|
30
|
+
commandDescriptions,
|
|
31
|
+
} from "../parser.js";
|
|
32
|
+
import { sdkForConsole } from "../sdks.js";
|
|
33
|
+
import { isCloud } from "../utils.js";
|
|
34
|
+
import { Account } from "@appwrite.io/console";
|
|
35
|
+
import { DEFAULT_ENDPOINT, EXECUTABLE_NAME } from "../constants.js";
|
|
32
36
|
|
|
33
37
|
const initResources = async (): Promise<void> => {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
38
|
+
const actions: Record<string, (options?: any) => Promise<void>> = {
|
|
39
|
+
function: initFunction,
|
|
40
|
+
site: initSite,
|
|
41
|
+
table: initTable,
|
|
42
|
+
bucket: initBucket,
|
|
43
|
+
team: initTeam,
|
|
44
|
+
message: initTopic,
|
|
45
|
+
collection: initCollection,
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
const answers = await inquirer.prompt([questionsInitResources[0]]);
|
|
49
|
+
|
|
50
|
+
const action = actions[answers.resource];
|
|
51
|
+
if (action !== undefined) {
|
|
52
|
+
await action({ returnOnZero: true });
|
|
53
|
+
}
|
|
50
54
|
};
|
|
51
55
|
|
|
52
56
|
interface InitProjectOptions {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
57
|
+
organizationId?: string;
|
|
58
|
+
projectId?: string;
|
|
59
|
+
projectName?: string;
|
|
56
60
|
}
|
|
57
61
|
|
|
58
|
-
const initProject = async ({
|
|
59
|
-
|
|
62
|
+
const initProject = async ({
|
|
63
|
+
organizationId,
|
|
64
|
+
projectId,
|
|
65
|
+
projectName,
|
|
66
|
+
}: InitProjectOptions = {}): Promise<void> => {
|
|
67
|
+
let response: any = {};
|
|
68
|
+
|
|
69
|
+
try {
|
|
70
|
+
if (globalConfig.getEndpoint() === "" || globalConfig.getCookie() === "") {
|
|
71
|
+
throw new Error(
|
|
72
|
+
`Missing endpoint or cookie configuration. Please run '${EXECUTABLE_NAME} login' first.`,
|
|
73
|
+
);
|
|
74
|
+
}
|
|
75
|
+
const client = await sdkForConsole();
|
|
76
|
+
const accountClient = new Account(client);
|
|
77
|
+
|
|
78
|
+
await accountClient.get();
|
|
79
|
+
} catch (e) {
|
|
80
|
+
error(
|
|
81
|
+
`Error Session not found. Please run '${EXECUTABLE_NAME} login' to create a session`,
|
|
82
|
+
);
|
|
83
|
+
process.exit(1);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
let answers: any = {};
|
|
87
|
+
|
|
88
|
+
if (!organizationId && !projectId && !projectName) {
|
|
89
|
+
answers = await inquirer.prompt(questionsInitProject);
|
|
90
|
+
if (answers.override === false) {
|
|
91
|
+
process.exit(1);
|
|
92
|
+
}
|
|
93
|
+
} else {
|
|
94
|
+
answers.start = "existing";
|
|
95
|
+
answers.project = {};
|
|
96
|
+
answers.organization = {};
|
|
97
|
+
|
|
98
|
+
answers.organization =
|
|
99
|
+
organizationId ??
|
|
100
|
+
(await inquirer.prompt([questionsInitProject[2]])).organization;
|
|
101
|
+
answers.project.name =
|
|
102
|
+
projectName ?? (await inquirer.prompt([questionsInitProject[3]])).project;
|
|
103
|
+
answers.project =
|
|
104
|
+
projectId ?? (await inquirer.prompt([questionsInitProject[4]])).id;
|
|
60
105
|
|
|
61
106
|
try {
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
error("Error Session not found. Please run 'appwrite login' to create a session");
|
|
73
|
-
process.exit(1);
|
|
107
|
+
const projectsService = await getProjectsService();
|
|
108
|
+
await projectsService.get(projectId);
|
|
109
|
+
} catch (e: any) {
|
|
110
|
+
if (e.code === 404) {
|
|
111
|
+
answers.start = "new";
|
|
112
|
+
answers.id = answers.project;
|
|
113
|
+
answers.project = answers.project.name;
|
|
114
|
+
} else {
|
|
115
|
+
throw e;
|
|
116
|
+
}
|
|
74
117
|
}
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
} catch (e: any) {
|
|
95
|
-
if (e.code === 404) {
|
|
96
|
-
answers.start = 'new';
|
|
97
|
-
answers.id = answers.project;
|
|
98
|
-
answers.project = answers.project.name;
|
|
99
|
-
} else {
|
|
100
|
-
throw e;
|
|
101
|
-
}
|
|
102
|
-
}
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
localConfig.clear(); // Clear the config to avoid any conflicts
|
|
121
|
+
const url = new URL(DEFAULT_ENDPOINT);
|
|
122
|
+
|
|
123
|
+
if (answers.start === "new") {
|
|
124
|
+
const projectsService = await getProjectsService();
|
|
125
|
+
response = await projectsService.create(
|
|
126
|
+
answers.id,
|
|
127
|
+
answers.project,
|
|
128
|
+
answers.organization,
|
|
129
|
+
answers.region,
|
|
130
|
+
);
|
|
131
|
+
|
|
132
|
+
localConfig.setProject(response["$id"]);
|
|
133
|
+
if (answers.region) {
|
|
134
|
+
localConfig.setEndpoint(
|
|
135
|
+
`https://${answers.region}.${url.host}${url.pathname}`,
|
|
136
|
+
);
|
|
103
137
|
}
|
|
104
|
-
|
|
105
|
-
localConfig.
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
projectId: answers.id,
|
|
111
|
-
name: answers.project,
|
|
112
|
-
teamId: answers.organization,
|
|
113
|
-
parseOutput: false
|
|
114
|
-
})
|
|
115
|
-
|
|
116
|
-
localConfig.setProject(response['$id']);
|
|
117
|
-
if (answers.region) {
|
|
118
|
-
localConfig.setEndpoint(`https://${answers.region}.${url.host}${url.pathname}`);
|
|
119
|
-
}
|
|
120
|
-
} else {
|
|
121
|
-
localConfig.setProject(answers.project["$id"]);
|
|
122
|
-
if(isCloud()) {
|
|
123
|
-
localConfig.setEndpoint(`https://${answers.project["region"]}.${url.host}${url.pathname}`);
|
|
124
|
-
}
|
|
138
|
+
} else {
|
|
139
|
+
localConfig.setProject(answers.project["$id"]);
|
|
140
|
+
if (isCloud()) {
|
|
141
|
+
localConfig.setEndpoint(
|
|
142
|
+
`https://${answers.project["region"]}.${url.host}${url.pathname}`,
|
|
143
|
+
);
|
|
125
144
|
}
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
success(
|
|
148
|
+
`Project successfully ${answers.start === "existing" ? "linked" : "created"}. Details are now stored in appwrite.config.json file.`,
|
|
149
|
+
);
|
|
150
|
+
|
|
151
|
+
if (answers.start === "existing") {
|
|
152
|
+
answers = await inquirer.prompt(questionsInitProjectAutopull);
|
|
153
|
+
if (answers.autopull) {
|
|
154
|
+
cliConfig.all = true;
|
|
155
|
+
cliConfig.force = true;
|
|
156
|
+
await pullResources({
|
|
157
|
+
skipDeprecated: true,
|
|
158
|
+
});
|
|
159
|
+
} else {
|
|
160
|
+
log(
|
|
161
|
+
`You can run '${EXECUTABLE_NAME} pull all' to synchronize all of your existing resources.`,
|
|
162
|
+
);
|
|
140
163
|
}
|
|
164
|
+
}
|
|
141
165
|
|
|
142
|
-
|
|
143
|
-
}
|
|
166
|
+
hint(
|
|
167
|
+
`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.`,
|
|
168
|
+
);
|
|
169
|
+
};
|
|
144
170
|
|
|
145
171
|
const initBucket = async (): Promise<void> => {
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
172
|
+
const answers = await inquirer.prompt(questionsCreateBucket);
|
|
173
|
+
|
|
174
|
+
localConfig.addBucket({
|
|
175
|
+
$id: answers.id === "unique()" ? ID.unique() : answers.id,
|
|
176
|
+
name: answers.bucket,
|
|
177
|
+
fileSecurity: answers.fileSecurity.toLowerCase() === "yes",
|
|
178
|
+
enabled: true,
|
|
179
|
+
});
|
|
180
|
+
success("Initialing bucket");
|
|
181
|
+
log(
|
|
182
|
+
`Next you can use '${EXECUTABLE_NAME} push bucket' to deploy the changes.`,
|
|
183
|
+
);
|
|
156
184
|
};
|
|
157
185
|
|
|
158
186
|
const initTeam = async (): Promise<void> => {
|
|
159
|
-
|
|
187
|
+
const answers = await inquirer.prompt(questionsCreateTeam);
|
|
160
188
|
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
189
|
+
localConfig.addTeam({
|
|
190
|
+
$id: answers.id === "unique()" ? ID.unique() : answers.id,
|
|
191
|
+
name: answers.team,
|
|
192
|
+
});
|
|
165
193
|
|
|
166
|
-
|
|
167
|
-
|
|
194
|
+
success("Initialing team");
|
|
195
|
+
log(`Next you can use '${EXECUTABLE_NAME} push team' to deploy the changes.`);
|
|
168
196
|
};
|
|
169
197
|
|
|
170
198
|
const initTable = async (): Promise<void> => {
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
localConfig.addTable({
|
|
190
|
-
$id: answers.id === 'unique()' ? ID.unique() : answers.id,
|
|
191
|
-
$permissions: [],
|
|
192
|
-
databaseId: databaseId,
|
|
193
|
-
name: answers.table,
|
|
194
|
-
enabled: true,
|
|
195
|
-
rowSecurity: answers.rowSecurity.toLowerCase() === 'yes',
|
|
196
|
-
columns: [],
|
|
197
|
-
indexes: [],
|
|
199
|
+
const answers = await inquirer.prompt(questionsCreateTable);
|
|
200
|
+
const newDatabase = (answers.method ?? "").toLowerCase() !== "existing";
|
|
201
|
+
|
|
202
|
+
if (!newDatabase) {
|
|
203
|
+
answers.databaseId = answers.database;
|
|
204
|
+
answers.databaseName = localConfig.getTablesDB(answers.database).name;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
const databaseId =
|
|
208
|
+
answers.databaseId === "unique()" ? ID.unique() : answers.databaseId;
|
|
209
|
+
|
|
210
|
+
if (newDatabase || !localConfig.getTablesDB(answers.databaseId)) {
|
|
211
|
+
localConfig.addTablesDB({
|
|
212
|
+
$id: databaseId,
|
|
213
|
+
name: answers.databaseName,
|
|
214
|
+
enabled: true,
|
|
198
215
|
});
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
localConfig.addTable({
|
|
219
|
+
$id: answers.id === "unique()" ? ID.unique() : answers.id,
|
|
220
|
+
$permissions: [],
|
|
221
|
+
databaseId: databaseId,
|
|
222
|
+
name: answers.table,
|
|
223
|
+
enabled: true,
|
|
224
|
+
rowSecurity: answers.rowSecurity.toLowerCase() === "yes",
|
|
225
|
+
columns: [],
|
|
226
|
+
indexes: [],
|
|
227
|
+
});
|
|
228
|
+
|
|
229
|
+
success("Initialing table");
|
|
230
|
+
log(
|
|
231
|
+
`Next you can use '${EXECUTABLE_NAME} push table' to deploy the changes.`,
|
|
232
|
+
);
|
|
202
233
|
};
|
|
203
234
|
|
|
204
235
|
const initCollection = async (): Promise<void> => {
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
localConfig.addCollection({
|
|
224
|
-
$id: answers.id === 'unique()' ? ID.unique() : answers.id,
|
|
225
|
-
databaseId: databaseId,
|
|
226
|
-
name: answers.collection,
|
|
227
|
-
documentSecurity: answers.documentSecurity.toLowerCase() === 'yes',
|
|
228
|
-
attributes: [],
|
|
229
|
-
indexes: [],
|
|
230
|
-
enabled: true,
|
|
236
|
+
const answers = await inquirer.prompt(questionsCreateCollection);
|
|
237
|
+
const newDatabase = (answers.method ?? "").toLowerCase() !== "existing";
|
|
238
|
+
|
|
239
|
+
if (!newDatabase) {
|
|
240
|
+
answers.databaseId = answers.database;
|
|
241
|
+
answers.databaseName = localConfig.getDatabase(answers.database).name;
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
const databaseId =
|
|
245
|
+
answers.databaseId === "unique()" ? ID.unique() : answers.databaseId;
|
|
246
|
+
|
|
247
|
+
if (newDatabase || !localConfig.getDatabase(answers.databaseId)) {
|
|
248
|
+
localConfig.addDatabase({
|
|
249
|
+
$id: databaseId,
|
|
250
|
+
name: answers.databaseName,
|
|
251
|
+
enabled: true,
|
|
231
252
|
});
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
localConfig.addCollection({
|
|
256
|
+
$id: answers.id === "unique()" ? ID.unique() : answers.id,
|
|
257
|
+
databaseId: databaseId,
|
|
258
|
+
name: answers.collection,
|
|
259
|
+
documentSecurity: answers.documentSecurity.toLowerCase() === "yes",
|
|
260
|
+
attributes: [],
|
|
261
|
+
indexes: [],
|
|
262
|
+
enabled: true,
|
|
263
|
+
});
|
|
264
|
+
|
|
265
|
+
success("Initialing collection");
|
|
266
|
+
log(
|
|
267
|
+
`Next you can use '${EXECUTABLE_NAME} push collection' to deploy the changes.`,
|
|
268
|
+
);
|
|
235
269
|
};
|
|
236
270
|
|
|
237
271
|
const initTopic = async (): Promise<void> => {
|
|
238
|
-
|
|
272
|
+
const answers = await inquirer.prompt(questionsCreateMessagingTopic);
|
|
239
273
|
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
274
|
+
localConfig.addMessagingTopic({
|
|
275
|
+
$id: answers.id === "unique()" ? ID.unique() : answers.id,
|
|
276
|
+
name: answers.topic,
|
|
277
|
+
});
|
|
243
278
|
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
279
|
+
success("Initialing topic");
|
|
280
|
+
log(
|
|
281
|
+
`Next you can use '${EXECUTABLE_NAME} push topic' to deploy the changes.`,
|
|
282
|
+
);
|
|
248
283
|
};
|
|
249
284
|
|
|
250
285
|
const initFunction = async (): Promise<void> => {
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
// TODO: Add CI/CD support (ID, name, runtime)
|
|
254
|
-
const answers = await inquirer.prompt(questionsCreateFunction)
|
|
255
|
-
const functionFolder = path.join(process.cwd(), 'functions');
|
|
256
|
-
|
|
257
|
-
if (!fs.existsSync(functionFolder)) {
|
|
258
|
-
fs.mkdirSync(functionFolder, {
|
|
259
|
-
recursive: true
|
|
260
|
-
});
|
|
261
|
-
}
|
|
262
|
-
|
|
263
|
-
const functionId = answers.id === 'unique()' ? ID.unique() : answers.id;
|
|
264
|
-
const functionName = answers.name;
|
|
265
|
-
const functionDir = path.join(functionFolder, functionName);
|
|
266
|
-
const templatesDir = path.join(functionFolder, `${functionId}-templates`);
|
|
267
|
-
const runtimeDir = path.join(templatesDir, answers.runtime.name);
|
|
268
|
-
|
|
269
|
-
if (fs.existsSync(functionDir)) {
|
|
270
|
-
throw new Error(`( ${functionName} ) already exists in the current directory. Please choose another name.`);
|
|
271
|
-
}
|
|
272
|
-
|
|
273
|
-
if (!answers.runtime.entrypoint) {
|
|
274
|
-
log(`Entrypoint for this runtime not found. You will be asked to configure entrypoint when you first push the function.`);
|
|
275
|
-
}
|
|
276
|
-
|
|
277
|
-
if (!answers.runtime.commands) {
|
|
278
|
-
log(`Installation command for this runtime not found. You will be asked to configure the install command when you first push the function.`);
|
|
279
|
-
}
|
|
280
|
-
|
|
281
|
-
fs.mkdirSync(functionDir, { mode: 0o777 });
|
|
282
|
-
fs.mkdirSync(templatesDir, { mode: 0o777 });
|
|
283
|
-
const repo = "https://github.com/appwrite/templates";
|
|
284
|
-
const api = `https://api.github.com/repos/appwrite/templates/contents/${answers.runtime.name}`
|
|
285
|
-
let selected: { template: string } = { template: 'starter' };
|
|
286
|
-
|
|
287
|
-
const sparse = (selected ? `${answers.runtime.name}/${selected.template}` : answers.runtime.name).toLowerCase();
|
|
286
|
+
process.chdir(localConfig.configDirectoryPath);
|
|
288
287
|
|
|
289
|
-
|
|
288
|
+
// TODO: Add CI/CD support (ID, name, runtime)
|
|
289
|
+
const answers = await inquirer.prompt(questionsCreateFunction);
|
|
290
|
+
const functionFolder = path.join(process.cwd(), "functions");
|
|
290
291
|
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
292
|
+
if (!fs.existsSync(functionFolder)) {
|
|
293
|
+
fs.mkdirSync(functionFolder, {
|
|
294
|
+
recursive: true,
|
|
295
|
+
});
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
const functionId = answers.id === "unique()" ? ID.unique() : answers.id;
|
|
299
|
+
const functionName = answers.name;
|
|
300
|
+
const functionDir = path.join(functionFolder, functionName);
|
|
301
|
+
const templatesDir = path.join(functionFolder, `${functionId}-templates`);
|
|
302
|
+
const runtimeDir = path.join(templatesDir, answers.runtime.name);
|
|
303
|
+
|
|
304
|
+
if (fs.existsSync(functionDir)) {
|
|
305
|
+
throw new Error(
|
|
306
|
+
`( ${functionName} ) already exists in the current directory. Please choose another name.`,
|
|
307
|
+
);
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
if (!answers.runtime.entrypoint) {
|
|
311
|
+
log(
|
|
312
|
+
`Entrypoint for this runtime not found. You will be asked to configure entrypoint when you first push the function.`,
|
|
313
|
+
);
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
if (!answers.runtime.commands) {
|
|
317
|
+
log(
|
|
318
|
+
`Installation command for this runtime not found. You will be asked to configure the install command when you first push the function.`,
|
|
319
|
+
);
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
fs.mkdirSync(functionDir, { mode: 0o777 });
|
|
323
|
+
fs.mkdirSync(templatesDir, { mode: 0o777 });
|
|
324
|
+
const repo = "https://github.com/appwrite/templates";
|
|
325
|
+
const api = `https://api.github.com/repos/appwrite/templates/contents/${answers.runtime.name}`;
|
|
326
|
+
let selected: { template: string } = { template: "starter" };
|
|
327
|
+
|
|
328
|
+
const sparse = (
|
|
329
|
+
selected
|
|
330
|
+
? `${answers.runtime.name}/${selected.template}`
|
|
331
|
+
: answers.runtime.name
|
|
332
|
+
).toLowerCase();
|
|
333
|
+
|
|
334
|
+
let gitInitCommands = `git clone --single-branch --depth 1 --sparse ${repo} .`; // depth prevents fetching older commits reducing the amount fetched
|
|
335
|
+
|
|
336
|
+
let gitPullCommands = `git sparse-checkout add ${sparse}`;
|
|
337
|
+
|
|
338
|
+
/* Force use CMD as powershell does not support && */
|
|
339
|
+
if (process.platform === "win32") {
|
|
340
|
+
gitInitCommands = 'cmd /c "' + gitInitCommands + '"';
|
|
341
|
+
gitPullCommands = 'cmd /c "' + gitPullCommands + '"';
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
/* Execute the child process but do not print any std output */
|
|
345
|
+
try {
|
|
346
|
+
childProcess.execSync(gitInitCommands, {
|
|
347
|
+
stdio: "pipe",
|
|
348
|
+
cwd: templatesDir,
|
|
349
|
+
});
|
|
350
|
+
childProcess.execSync(gitPullCommands, {
|
|
351
|
+
stdio: "pipe",
|
|
352
|
+
cwd: templatesDir,
|
|
353
|
+
});
|
|
354
|
+
} catch (err: any) {
|
|
355
|
+
/* Specialised errors with recommended actions to take */
|
|
356
|
+
if (err.message.includes("error: unknown option")) {
|
|
357
|
+
throw new Error(
|
|
358
|
+
`${err.message} \n\nSuggestion: Try updating your git to the latest version, then trying to run this command again.`,
|
|
359
|
+
);
|
|
360
|
+
} else if (
|
|
361
|
+
err.message.includes(
|
|
362
|
+
"is not recognized as an internal or external command,",
|
|
363
|
+
) ||
|
|
364
|
+
err.message.includes("command not found")
|
|
365
|
+
) {
|
|
366
|
+
throw new Error(
|
|
367
|
+
`${err.message} \n\nSuggestion: It appears that git is not installed, try installing git then trying to run this command again.`,
|
|
368
|
+
);
|
|
369
|
+
} else {
|
|
370
|
+
throw err;
|
|
297
371
|
}
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
fs.rmSync(path.join(templatesDir, ".git"), { recursive: true });
|
|
375
|
+
if (!selected) {
|
|
376
|
+
const templates: string[] = [];
|
|
377
|
+
templates.push(
|
|
378
|
+
...fs
|
|
379
|
+
.readdirSync(runtimeDir, { withFileTypes: true })
|
|
380
|
+
.filter((item) => item.isDirectory() && item.name !== "starter")
|
|
381
|
+
.map((dirent) => dirent.name),
|
|
382
|
+
);
|
|
383
|
+
selected = { template: "starter" };
|
|
384
|
+
|
|
385
|
+
if (templates.length > 1) {
|
|
386
|
+
selected = await inquirer.prompt(
|
|
387
|
+
questionsCreateFunctionSelectTemplate(templates),
|
|
388
|
+
);
|
|
312
389
|
}
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
const copyRecursiveSync = (src: string, dest: string): void => {
|
|
393
|
+
let exists = fs.existsSync(src);
|
|
394
|
+
let stats = exists && fs.statSync(src);
|
|
395
|
+
let isDirectory = exists && stats && stats.isDirectory();
|
|
396
|
+
if (isDirectory) {
|
|
397
|
+
if (!fs.existsSync(dest)) {
|
|
398
|
+
fs.mkdirSync(dest);
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
fs.readdirSync(src).forEach(function (childItemName) {
|
|
402
|
+
copyRecursiveSync(
|
|
403
|
+
path.join(src, childItemName),
|
|
404
|
+
path.join(dest, childItemName),
|
|
405
|
+
);
|
|
406
|
+
});
|
|
407
|
+
} else {
|
|
408
|
+
fs.copyFileSync(src, dest);
|
|
325
409
|
}
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
commands: answers.runtime.commands || '',
|
|
368
|
-
ignore: answers.runtime.ignore || null,
|
|
369
|
-
path: `functions/${functionName}`,
|
|
370
|
-
};
|
|
371
|
-
|
|
372
|
-
localConfig.addFunction(data);
|
|
373
|
-
success("Initialing function");
|
|
374
|
-
log("Next you can use 'appwrite run function' to develop a function locally. To deploy the function, use 'appwrite push function'");
|
|
375
|
-
}
|
|
410
|
+
};
|
|
411
|
+
copyRecursiveSync(path.join(runtimeDir, selected.template), functionDir);
|
|
412
|
+
|
|
413
|
+
fs.rmSync(templatesDir, { recursive: true, force: true });
|
|
414
|
+
|
|
415
|
+
const readmePath = path.join(
|
|
416
|
+
process.cwd(),
|
|
417
|
+
"functions",
|
|
418
|
+
functionName,
|
|
419
|
+
"README.md",
|
|
420
|
+
);
|
|
421
|
+
const readmeFile = fs.readFileSync(readmePath).toString();
|
|
422
|
+
const newReadmeFile = readmeFile.split("\n");
|
|
423
|
+
newReadmeFile[0] = `# ${answers.name}`;
|
|
424
|
+
newReadmeFile.splice(1, 2);
|
|
425
|
+
fs.writeFileSync(readmePath, newReadmeFile.join("\n"));
|
|
426
|
+
|
|
427
|
+
let data = {
|
|
428
|
+
$id: functionId,
|
|
429
|
+
name: answers.name,
|
|
430
|
+
runtime: answers.runtime.id,
|
|
431
|
+
specification: answers.specification,
|
|
432
|
+
execute: ["any"],
|
|
433
|
+
events: [],
|
|
434
|
+
scopes: ["users.read"],
|
|
435
|
+
schedule: "",
|
|
436
|
+
timeout: 15,
|
|
437
|
+
enabled: true,
|
|
438
|
+
logging: true,
|
|
439
|
+
entrypoint: answers.runtime.entrypoint || "",
|
|
440
|
+
commands: answers.runtime.commands || "",
|
|
441
|
+
ignore: answers.runtime.ignore || null,
|
|
442
|
+
path: `functions/${functionName}`,
|
|
443
|
+
};
|
|
444
|
+
|
|
445
|
+
localConfig.addFunction(data);
|
|
446
|
+
success("Initialing function");
|
|
447
|
+
log(
|
|
448
|
+
`Next you can use '${EXECUTABLE_NAME} run function' to develop a function locally. To deploy the function, use '${EXECUTABLE_NAME} push function'`,
|
|
449
|
+
);
|
|
450
|
+
};
|
|
376
451
|
|
|
377
452
|
const initSite = async (): Promise<void> => {
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
const answers = await inquirer.prompt(questionsCreateSite);
|
|
381
|
-
const siteFolder = path.join(process.cwd(), 'sites');
|
|
382
|
-
|
|
383
|
-
if (!fs.existsSync(siteFolder)) {
|
|
384
|
-
fs.mkdirSync(siteFolder, {
|
|
385
|
-
recursive: true
|
|
386
|
-
});
|
|
387
|
-
}
|
|
453
|
+
process.chdir(localConfig.configDirectoryPath);
|
|
388
454
|
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
const siteDir = path.join(siteFolder, siteName);
|
|
392
|
-
const templatesDir = path.join(siteFolder, `${siteId}-templates`);
|
|
455
|
+
const answers = await inquirer.prompt(questionsCreateSite);
|
|
456
|
+
const siteFolder = path.join(process.cwd(), "sites");
|
|
393
457
|
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
458
|
+
if (!fs.existsSync(siteFolder)) {
|
|
459
|
+
fs.mkdirSync(siteFolder, {
|
|
460
|
+
recursive: true,
|
|
461
|
+
});
|
|
462
|
+
}
|
|
463
|
+
|
|
464
|
+
const siteId = answers.id === "unique()" ? ID.unique() : answers.id;
|
|
465
|
+
const siteName = answers.name;
|
|
466
|
+
const siteDir = path.join(siteFolder, siteName);
|
|
467
|
+
const templatesDir = path.join(siteFolder, `${siteId}-templates`);
|
|
468
|
+
|
|
469
|
+
if (fs.existsSync(siteDir)) {
|
|
470
|
+
throw new Error(
|
|
471
|
+
`( ${siteName} ) already exists in the current directory. Please choose another name.`,
|
|
472
|
+
);
|
|
473
|
+
}
|
|
474
|
+
|
|
475
|
+
let templateDetails: any;
|
|
476
|
+
try {
|
|
477
|
+
const sitesService = await getSitesService();
|
|
478
|
+
const response = await sitesService.listTemplates(
|
|
479
|
+
[answers.framework.key],
|
|
480
|
+
["starter"],
|
|
481
|
+
1,
|
|
482
|
+
);
|
|
483
|
+
if (response.total == 0) {
|
|
484
|
+
throw new Error(
|
|
485
|
+
`No starter template found for framework ${answers.framework.key}`,
|
|
486
|
+
);
|
|
412
487
|
}
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
488
|
+
templateDetails = response.templates[0];
|
|
489
|
+
} catch (err: any) {
|
|
490
|
+
throw new Error(
|
|
491
|
+
`Failed to fetch template for framework ${answers.framework.key}: ${err.message}`,
|
|
492
|
+
);
|
|
493
|
+
}
|
|
494
|
+
|
|
495
|
+
fs.mkdirSync(siteDir, { mode: 0o777 });
|
|
496
|
+
fs.mkdirSync(templatesDir, { mode: 0o777 });
|
|
497
|
+
const repo = `https://github.com/${templateDetails.providerOwner}/${templateDetails.providerRepositoryId}`;
|
|
498
|
+
let selected = {
|
|
499
|
+
template: templateDetails.frameworks[0].providerRootDirectory,
|
|
500
|
+
};
|
|
501
|
+
|
|
502
|
+
let gitCloneCommands = "";
|
|
503
|
+
|
|
504
|
+
const sparse = selected.template.startsWith("./")
|
|
505
|
+
? selected.template.substring(2)
|
|
506
|
+
: selected.template;
|
|
507
|
+
|
|
508
|
+
log("Fetching site code ...");
|
|
509
|
+
|
|
510
|
+
if (selected.template === "./") {
|
|
511
|
+
gitCloneCommands = `
|
|
427
512
|
mkdir -p .
|
|
428
513
|
cd .
|
|
429
514
|
git init
|
|
@@ -432,8 +517,8 @@ const initSite = async (): Promise<void> => {
|
|
|
432
517
|
git fetch --depth=1 origin refs/tags/$(git ls-remote --tags origin "${templateDetails.providerVersion}" | tail -n 1 | awk -F '/' '{print $3}')
|
|
433
518
|
git checkout FETCH_HEAD
|
|
434
519
|
`.trim();
|
|
435
|
-
|
|
436
|
-
|
|
520
|
+
} else {
|
|
521
|
+
gitCloneCommands = `
|
|
437
522
|
mkdir -p .
|
|
438
523
|
cd .
|
|
439
524
|
git init
|
|
@@ -446,167 +531,194 @@ const initSite = async (): Promise<void> => {
|
|
|
446
531
|
git fetch --depth=1 origin refs/tags/$(git ls-remote --tags origin "${templateDetails.providerVersion}" | tail -n 1 | awk -F '/' '{print $3}')
|
|
447
532
|
git checkout FETCH_HEAD
|
|
448
533
|
`.trim();
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
if (err.message.includes('error: unknown option')) {
|
|
462
|
-
throw new Error(`${err.message} \n\nSuggestion: Try updating your git to the latest version, then trying to run this command again.`)
|
|
463
|
-
} else if (err.message.includes('is not recognized as an internal or external command,') || err.message.includes('command not found')) {
|
|
464
|
-
throw new Error(`${err.message} \n\nSuggestion: It appears that git is not installed, try installing git then trying to run this command again.`)
|
|
465
|
-
} else {
|
|
466
|
-
throw err;
|
|
467
|
-
}
|
|
468
|
-
}
|
|
469
|
-
|
|
470
|
-
fs.rmSync(path.join(templatesDir, ".git"), { recursive: true });
|
|
471
|
-
|
|
472
|
-
const copyRecursiveSync = (src: string, dest: string): void => {
|
|
473
|
-
let exists = fs.existsSync(src);
|
|
474
|
-
let stats = exists && fs.statSync(src);
|
|
475
|
-
let isDirectory = exists && stats && stats.isDirectory();
|
|
476
|
-
if (isDirectory) {
|
|
477
|
-
if (!fs.existsSync(dest)) {
|
|
478
|
-
fs.mkdirSync(dest);
|
|
479
|
-
}
|
|
480
|
-
|
|
481
|
-
fs.readdirSync(src).forEach(function (childItemName) {
|
|
482
|
-
copyRecursiveSync(path.join(src, childItemName), path.join(dest, childItemName));
|
|
483
|
-
});
|
|
484
|
-
} else {
|
|
485
|
-
fs.copyFileSync(src, dest);
|
|
486
|
-
}
|
|
487
|
-
};
|
|
488
|
-
copyRecursiveSync(selected.template === './' ? templatesDir : path.join(templatesDir, selected.template), siteDir);
|
|
489
|
-
|
|
490
|
-
fs.rmSync(templatesDir, { recursive: true, force: true });
|
|
491
|
-
|
|
492
|
-
const readmePath = path.join(process.cwd(), 'sites', siteName, 'README.md');
|
|
493
|
-
const readmeFile = fs.readFileSync(readmePath).toString();
|
|
494
|
-
const newReadmeFile = readmeFile.split('\n');
|
|
495
|
-
newReadmeFile[0] = `# ${answers.key}`;
|
|
496
|
-
newReadmeFile.splice(1, 2);
|
|
497
|
-
fs.writeFileSync(readmePath, newReadmeFile.join('\n'));
|
|
498
|
-
|
|
499
|
-
let vars = (templateDetails.variables ?? []).map((variable: any) => {
|
|
500
|
-
let value = variable.value;
|
|
501
|
-
const replacements: Record<string, string> = {
|
|
502
|
-
'{apiEndpoint}': globalConfig.getEndpoint(),
|
|
503
|
-
'{projectId}': localConfig.getProject().projectId,
|
|
504
|
-
'{projectName}': localConfig.getProject().projectName,
|
|
505
|
-
};
|
|
506
|
-
|
|
507
|
-
for (const placeholder in replacements) {
|
|
508
|
-
if (value?.includes(placeholder)) {
|
|
509
|
-
value = value.replace(placeholder, replacements[placeholder]);
|
|
510
|
-
}
|
|
511
|
-
}
|
|
512
|
-
|
|
513
|
-
return {
|
|
514
|
-
key: variable.name,
|
|
515
|
-
value: value
|
|
516
|
-
};
|
|
534
|
+
}
|
|
535
|
+
|
|
536
|
+
/* Force use CMD as powershell does not support && */
|
|
537
|
+
if (process.platform === "win32") {
|
|
538
|
+
gitCloneCommands = 'cmd /c "' + gitCloneCommands + '"';
|
|
539
|
+
}
|
|
540
|
+
|
|
541
|
+
/* Execute the child process but do not print any std output */
|
|
542
|
+
try {
|
|
543
|
+
childProcess.execSync(gitCloneCommands, {
|
|
544
|
+
stdio: "pipe",
|
|
545
|
+
cwd: templatesDir,
|
|
517
546
|
});
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
vars: vars
|
|
536
|
-
};
|
|
537
|
-
|
|
538
|
-
if (!data.buildRuntime) {
|
|
539
|
-
log(`Build runtime for this framework not found. You will be asked to configure build runtime when you first push the site.`);
|
|
540
|
-
}
|
|
541
|
-
|
|
542
|
-
if (!data.installCommand) {
|
|
543
|
-
log(`Installation command for this framework not found. You will be asked to configure the install command when you first push the site.`);
|
|
547
|
+
} catch (err: any) {
|
|
548
|
+
/* Specialised errors with recommended actions to take */
|
|
549
|
+
if (err.message.includes("error: unknown option")) {
|
|
550
|
+
throw new Error(
|
|
551
|
+
`${err.message} \n\nSuggestion: Try updating your git to the latest version, then trying to run this command again.`,
|
|
552
|
+
);
|
|
553
|
+
} else if (
|
|
554
|
+
err.message.includes(
|
|
555
|
+
"is not recognized as an internal or external command,",
|
|
556
|
+
) ||
|
|
557
|
+
err.message.includes("command not found")
|
|
558
|
+
) {
|
|
559
|
+
throw new Error(
|
|
560
|
+
`${err.message} \n\nSuggestion: It appears that git is not installed, try installing git then trying to run this command again.`,
|
|
561
|
+
);
|
|
562
|
+
} else {
|
|
563
|
+
throw err;
|
|
544
564
|
}
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
565
|
+
}
|
|
566
|
+
|
|
567
|
+
fs.rmSync(path.join(templatesDir, ".git"), { recursive: true });
|
|
568
|
+
|
|
569
|
+
const copyRecursiveSync = (src: string, dest: string): void => {
|
|
570
|
+
let exists = fs.existsSync(src);
|
|
571
|
+
let stats = exists && fs.statSync(src);
|
|
572
|
+
let isDirectory = exists && stats && stats.isDirectory();
|
|
573
|
+
if (isDirectory) {
|
|
574
|
+
if (!fs.existsSync(dest)) {
|
|
575
|
+
fs.mkdirSync(dest);
|
|
576
|
+
}
|
|
577
|
+
|
|
578
|
+
fs.readdirSync(src).forEach(function (childItemName) {
|
|
579
|
+
copyRecursiveSync(
|
|
580
|
+
path.join(src, childItemName),
|
|
581
|
+
path.join(dest, childItemName),
|
|
582
|
+
);
|
|
583
|
+
});
|
|
584
|
+
} else {
|
|
585
|
+
fs.copyFileSync(src, dest);
|
|
548
586
|
}
|
|
587
|
+
};
|
|
588
|
+
copyRecursiveSync(
|
|
589
|
+
selected.template === "./"
|
|
590
|
+
? templatesDir
|
|
591
|
+
: path.join(templatesDir, selected.template),
|
|
592
|
+
siteDir,
|
|
593
|
+
);
|
|
594
|
+
|
|
595
|
+
fs.rmSync(templatesDir, { recursive: true, force: true });
|
|
596
|
+
|
|
597
|
+
const readmePath = path.join(process.cwd(), "sites", siteName, "README.md");
|
|
598
|
+
const readmeFile = fs.readFileSync(readmePath).toString();
|
|
599
|
+
const newReadmeFile = readmeFile.split("\n");
|
|
600
|
+
newReadmeFile[0] = `# ${answers.name}`;
|
|
601
|
+
newReadmeFile.splice(1, 2);
|
|
602
|
+
fs.writeFileSync(readmePath, newReadmeFile.join("\n"));
|
|
603
|
+
|
|
604
|
+
let vars = (templateDetails.variables ?? []).map((variable: any) => {
|
|
605
|
+
let value = variable.value;
|
|
606
|
+
const replacements: Record<string, string> = {
|
|
607
|
+
"{apiEndpoint}": globalConfig.getEndpoint(),
|
|
608
|
+
"{projectId}": localConfig.getProject().projectId,
|
|
609
|
+
"{projectName}": localConfig.getProject().projectName,
|
|
610
|
+
};
|
|
549
611
|
|
|
550
|
-
|
|
551
|
-
|
|
612
|
+
for (const placeholder in replacements) {
|
|
613
|
+
if (value?.includes(placeholder)) {
|
|
614
|
+
value = value.replace(placeholder, replacements[placeholder]);
|
|
615
|
+
}
|
|
552
616
|
}
|
|
553
617
|
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
618
|
+
return {
|
|
619
|
+
key: variable.name,
|
|
620
|
+
value: value,
|
|
621
|
+
};
|
|
622
|
+
});
|
|
623
|
+
|
|
624
|
+
let data = {
|
|
625
|
+
$id: siteId,
|
|
626
|
+
name: answers.name,
|
|
627
|
+
framework: answers.framework.key,
|
|
628
|
+
adapter: templateDetails.frameworks[0].adapter || "",
|
|
629
|
+
buildRuntime: templateDetails.frameworks[0].buildRuntime || "",
|
|
630
|
+
installCommand: templateDetails.frameworks[0].installCommand || "",
|
|
631
|
+
buildCommand: templateDetails.frameworks[0].buildCommand || "",
|
|
632
|
+
outputDirectory: templateDetails.frameworks[0].outputDirectory || "",
|
|
633
|
+
fallbackFile: templateDetails.frameworks[0].fallbackFile || "",
|
|
634
|
+
specification: answers.specification,
|
|
635
|
+
enabled: true,
|
|
636
|
+
timeout: 30,
|
|
637
|
+
logging: true,
|
|
638
|
+
ignore: answers.framework.ignore || null,
|
|
639
|
+
path: `sites/${siteName}`,
|
|
640
|
+
vars: vars,
|
|
641
|
+
};
|
|
642
|
+
|
|
643
|
+
if (!data.buildRuntime) {
|
|
644
|
+
log(
|
|
645
|
+
`Build runtime for this framework not found. You will be asked to configure build runtime when you first push the site.`,
|
|
646
|
+
);
|
|
647
|
+
}
|
|
648
|
+
|
|
649
|
+
if (!data.installCommand) {
|
|
650
|
+
log(
|
|
651
|
+
`Installation command for this framework not found. You will be asked to configure the install command when you first push the site.`,
|
|
652
|
+
);
|
|
653
|
+
}
|
|
654
|
+
|
|
655
|
+
if (!data.buildCommand) {
|
|
656
|
+
log(
|
|
657
|
+
`Build command for this framework not found. You will be asked to configure the build command when you first push the site.`,
|
|
658
|
+
);
|
|
659
|
+
}
|
|
660
|
+
|
|
661
|
+
if (!data.outputDirectory) {
|
|
662
|
+
log(
|
|
663
|
+
`Output directory for this framework not found. You will be asked to configure the output directory when you first push the site.`,
|
|
664
|
+
);
|
|
665
|
+
}
|
|
666
|
+
|
|
667
|
+
localConfig.addSite(data);
|
|
668
|
+
success("Initializing site");
|
|
669
|
+
log(`Next you can use '${EXECUTABLE_NAME} push site' to deploy the changes.`);
|
|
557
670
|
};
|
|
558
671
|
|
|
559
672
|
export const init = new Command("init")
|
|
560
|
-
|
|
561
|
-
|
|
673
|
+
.description(commandDescriptions["init"])
|
|
674
|
+
.action(actionRunner(initResources));
|
|
562
675
|
|
|
563
676
|
init
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
677
|
+
.command("project")
|
|
678
|
+
.description("Init a new Appwrite project")
|
|
679
|
+
.option("--organization-id <organization-id>", "Appwrite organization ID")
|
|
680
|
+
.option("--project-id <project-id>", "Appwrite project ID")
|
|
681
|
+
.option("--project-name <project-name>", "Appwrite project ID")
|
|
682
|
+
.action(actionRunner(initProject));
|
|
570
683
|
|
|
571
684
|
init
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
685
|
+
.command("function")
|
|
686
|
+
.alias("functions")
|
|
687
|
+
.description("Init a new Appwrite function")
|
|
688
|
+
.action(actionRunner(initFunction));
|
|
576
689
|
|
|
577
690
|
init
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
691
|
+
.command("site")
|
|
692
|
+
.alias("sites")
|
|
693
|
+
.description("Init a new Appwrite site")
|
|
694
|
+
.action(actionRunner(initSite));
|
|
582
695
|
|
|
583
696
|
init
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
697
|
+
.command("bucket")
|
|
698
|
+
.alias("buckets")
|
|
699
|
+
.description("Init a new Appwrite bucket")
|
|
700
|
+
.action(actionRunner(initBucket));
|
|
588
701
|
|
|
589
702
|
init
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
703
|
+
.command("team")
|
|
704
|
+
.alias("teams")
|
|
705
|
+
.description("Init a new Appwrite team")
|
|
706
|
+
.action(actionRunner(initTeam));
|
|
594
707
|
|
|
595
708
|
init
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
709
|
+
.command("collection")
|
|
710
|
+
.alias("collections")
|
|
711
|
+
.description("Init a new Appwrite collection")
|
|
712
|
+
.action(actionRunner(initCollection));
|
|
600
713
|
|
|
601
714
|
init
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
715
|
+
.command("table")
|
|
716
|
+
.alias("tables")
|
|
717
|
+
.description("Init a new Appwrite table")
|
|
718
|
+
.action(actionRunner(initTable));
|
|
606
719
|
|
|
607
720
|
init
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
721
|
+
.command("topic")
|
|
722
|
+
.alias("topics")
|
|
723
|
+
.description("Init a new Appwrite topic")
|
|
724
|
+
.action(actionRunner(initTopic));
|