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/run.ts
CHANGED
|
@@ -1,336 +1,416 @@
|
|
|
1
|
-
import { Tail } from
|
|
2
|
-
import { parse as parseDotenv } from
|
|
3
|
-
import chalk from
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
import
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
|
|
1
|
+
import { Tail } from "tail";
|
|
2
|
+
import { parse as parseDotenv } from "dotenv";
|
|
3
|
+
import chalk from "chalk";
|
|
4
|
+
import ignoreModule from "ignore";
|
|
5
|
+
const ignore: typeof ignoreModule =
|
|
6
|
+
(ignoreModule as any).default ?? ignoreModule;
|
|
7
|
+
import tar from "tar";
|
|
8
|
+
import fs from "fs";
|
|
9
|
+
import chokidar from "chokidar";
|
|
10
|
+
import inquirer from "inquirer";
|
|
11
|
+
import path from "path";
|
|
12
|
+
import { Command } from "commander";
|
|
13
|
+
import { localConfig, globalConfig } from "../config.js";
|
|
14
|
+
import { paginate } from "../paginate.js";
|
|
15
|
+
import { getFunctionsService } from "../services.js";
|
|
16
|
+
import { questionsRunFunctions } from "../questions.js";
|
|
17
|
+
import {
|
|
18
|
+
actionRunner,
|
|
19
|
+
success,
|
|
20
|
+
log,
|
|
21
|
+
warn,
|
|
22
|
+
error,
|
|
23
|
+
hint,
|
|
24
|
+
commandDescriptions,
|
|
25
|
+
drawTable,
|
|
26
|
+
} from "../parser.js";
|
|
27
|
+
import { systemHasCommand, isPortTaken, getAllFiles } from "../utils.js";
|
|
28
|
+
import {
|
|
29
|
+
runtimeNames,
|
|
30
|
+
systemTools,
|
|
31
|
+
JwtManager,
|
|
32
|
+
Queue,
|
|
33
|
+
} from "../emulation/utils.js";
|
|
34
|
+
import {
|
|
35
|
+
dockerStop,
|
|
36
|
+
dockerCleanup,
|
|
37
|
+
dockerStart,
|
|
38
|
+
dockerBuild,
|
|
39
|
+
dockerPull,
|
|
40
|
+
} from "../emulation/docker.js";
|
|
19
41
|
|
|
20
42
|
interface RunFunctionOptions {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
43
|
+
port?: string | number;
|
|
44
|
+
functionId?: string;
|
|
45
|
+
withVariables?: boolean;
|
|
46
|
+
reload?: boolean;
|
|
47
|
+
userId?: string;
|
|
26
48
|
}
|
|
27
49
|
|
|
28
|
-
const runFunction = async ({
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
50
|
+
const runFunction = async ({
|
|
51
|
+
port,
|
|
52
|
+
functionId,
|
|
53
|
+
withVariables,
|
|
54
|
+
reload,
|
|
55
|
+
userId,
|
|
56
|
+
}: RunFunctionOptions = {}): Promise<void> => {
|
|
57
|
+
// Selection
|
|
58
|
+
if (!functionId) {
|
|
59
|
+
const answers = await inquirer.prompt([questionsRunFunctions[0]]);
|
|
60
|
+
functionId = answers.function;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
const functions = localConfig.getFunctions();
|
|
64
|
+
const func = functions.find((f: any) => f.$id === functionId);
|
|
65
|
+
if (!func) {
|
|
66
|
+
throw new Error("Function '" + functionId + "' not found.");
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
const runtimeName = func.runtime.split("-").slice(0, -1).join("-");
|
|
70
|
+
const tool = systemTools[runtimeName];
|
|
71
|
+
|
|
72
|
+
// Configuration: Port
|
|
73
|
+
let portNum: number | null = null;
|
|
74
|
+
if (port) {
|
|
75
|
+
portNum = +port;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
if (isNaN(portNum!)) {
|
|
79
|
+
portNum = null;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
if (portNum) {
|
|
83
|
+
const taken = await isPortTaken(portNum);
|
|
84
|
+
|
|
85
|
+
if (taken) {
|
|
86
|
+
error(`Port ${portNum} is already in use by another process.`);
|
|
87
|
+
return;
|
|
33
88
|
}
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
portNum = +port;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
if (!portNum) {
|
|
92
|
+
let portFound = false;
|
|
93
|
+
portNum = 3000;
|
|
94
|
+
while (portNum < 3100) {
|
|
95
|
+
const taken = await isPortTaken(portNum);
|
|
96
|
+
if (!taken) {
|
|
97
|
+
portFound = true;
|
|
98
|
+
break;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
portNum++;
|
|
48
102
|
}
|
|
49
103
|
|
|
50
|
-
if(
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
const taken = await isPortTaken(portNum);
|
|
56
|
-
|
|
57
|
-
if(taken) {
|
|
58
|
-
error(`Port ${portNum} is already in use by another process.`);
|
|
59
|
-
return;
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
if(!portNum) {
|
|
64
|
-
let portFound = false;
|
|
65
|
-
portNum = 3000;
|
|
66
|
-
while(portNum < 3100) {
|
|
67
|
-
const taken = await isPortTaken(portNum);
|
|
68
|
-
if(!taken) {
|
|
69
|
-
portFound = true;
|
|
70
|
-
break;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
portNum++;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
if(!portFound) {
|
|
77
|
-
error("Could not find an available port. Please select a port with 'appwrite run --port YOUR_PORT' command.");
|
|
78
|
-
return;
|
|
79
|
-
}
|
|
104
|
+
if (!portFound) {
|
|
105
|
+
error(
|
|
106
|
+
"Could not find an available port. Please select a port with 'appwrite run --port YOUR_PORT' command.",
|
|
107
|
+
);
|
|
108
|
+
return;
|
|
80
109
|
}
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
// Configuration: Engine
|
|
113
|
+
if (!systemHasCommand("docker")) {
|
|
114
|
+
return error(
|
|
115
|
+
"Docker Engine is required for local development. Please install Docker using: https://docs.docker.com/engine/install/",
|
|
116
|
+
);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
// Settings
|
|
120
|
+
const settings = {
|
|
121
|
+
runtime: func.runtime,
|
|
122
|
+
entrypoint: func.entrypoint,
|
|
123
|
+
path: func.path,
|
|
124
|
+
commands: func.commands,
|
|
125
|
+
scopes: func.scopes ?? [],
|
|
126
|
+
};
|
|
127
|
+
|
|
128
|
+
drawTable([settings]);
|
|
129
|
+
log(
|
|
130
|
+
"If you wish to change your local settings, update the appwrite.config.json file and rerun the 'appwrite run' command.",
|
|
131
|
+
);
|
|
132
|
+
hint(
|
|
133
|
+
"Permissions, events, CRON and timeouts don't apply when running locally.",
|
|
134
|
+
);
|
|
135
|
+
|
|
136
|
+
await dockerCleanup(func.$id);
|
|
137
|
+
|
|
138
|
+
process.on("SIGINT", async () => {
|
|
139
|
+
log("Cleaning up ...");
|
|
140
|
+
await dockerCleanup(func.$id);
|
|
141
|
+
success("Local function successfully stopped.");
|
|
142
|
+
process.exit();
|
|
143
|
+
});
|
|
144
|
+
|
|
145
|
+
const logsPath = path.join(
|
|
146
|
+
localConfig.getDirname(),
|
|
147
|
+
func.path,
|
|
148
|
+
".appwrite/logs.txt",
|
|
149
|
+
);
|
|
150
|
+
const errorsPath = path.join(
|
|
151
|
+
localConfig.getDirname(),
|
|
152
|
+
func.path,
|
|
153
|
+
".appwrite/errors.txt",
|
|
154
|
+
);
|
|
155
|
+
|
|
156
|
+
if (!fs.existsSync(path.dirname(logsPath))) {
|
|
157
|
+
fs.mkdirSync(path.dirname(logsPath), { recursive: true });
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
if (!fs.existsSync(logsPath)) {
|
|
161
|
+
fs.writeFileSync(logsPath, "");
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
if (!fs.existsSync(errorsPath)) {
|
|
165
|
+
fs.writeFileSync(errorsPath, "");
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
const userVariables: Record<string, string> = {};
|
|
169
|
+
const allVariables: Record<string, string> = {};
|
|
170
|
+
|
|
171
|
+
if (withVariables) {
|
|
172
|
+
try {
|
|
173
|
+
const { variables: remoteVariables } = await paginate(
|
|
174
|
+
async () => (await getFunctionsService()).listVariables(func["$id"]),
|
|
175
|
+
{},
|
|
176
|
+
100,
|
|
177
|
+
"variables",
|
|
178
|
+
);
|
|
179
|
+
|
|
180
|
+
remoteVariables.forEach((v: any) => {
|
|
181
|
+
allVariables[v.key] = v.value;
|
|
182
|
+
userVariables[v.key] = v.value;
|
|
183
|
+
});
|
|
184
|
+
} catch (err: any) {
|
|
185
|
+
warn(
|
|
186
|
+
"Remote variables not fetched. Production environment variables will not be available. Reason: " +
|
|
187
|
+
err.message,
|
|
188
|
+
);
|
|
85
189
|
}
|
|
190
|
+
}
|
|
86
191
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
path: func.path,
|
|
92
|
-
commands: func.commands,
|
|
93
|
-
scopes: func.scopes ?? []
|
|
94
|
-
};
|
|
95
|
-
|
|
96
|
-
drawTable([settings]);
|
|
97
|
-
log("If you wish to change your local settings, update the appwrite.config.json file and rerun the 'appwrite run' command.");
|
|
98
|
-
hint("Permissions, events, CRON and timeouts dont apply when running locally.");
|
|
192
|
+
const functionPath = path.join(localConfig.getDirname(), func.path);
|
|
193
|
+
const envPath = path.join(functionPath, ".env");
|
|
194
|
+
if (fs.existsSync(envPath)) {
|
|
195
|
+
const env = parseDotenv(fs.readFileSync(envPath).toString() ?? "");
|
|
99
196
|
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
log('Cleaning up ...');
|
|
104
|
-
await dockerCleanup(func.$id);
|
|
105
|
-
success("Local function successfully stopped.");
|
|
106
|
-
process.exit();
|
|
197
|
+
Object.keys(env).forEach((key) => {
|
|
198
|
+
allVariables[key] = env[key];
|
|
199
|
+
userVariables[key] = env[key];
|
|
107
200
|
});
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
allVariables["APPWRITE_FUNCTION_API_ENDPOINT"] =
|
|
204
|
+
globalConfig.getFrom("endpoint");
|
|
205
|
+
allVariables["APPWRITE_FUNCTION_ID"] = func.$id;
|
|
206
|
+
allVariables["APPWRITE_FUNCTION_NAME"] = func.name;
|
|
207
|
+
allVariables["APPWRITE_FUNCTION_DEPLOYMENT"] = ""; // TODO: Implement when relevant
|
|
208
|
+
allVariables["APPWRITE_FUNCTION_PROJECT_ID"] =
|
|
209
|
+
localConfig.getProject().projectId;
|
|
210
|
+
allVariables["APPWRITE_FUNCTION_RUNTIME_NAME"] =
|
|
211
|
+
runtimeNames[runtimeName] ?? "";
|
|
212
|
+
allVariables["APPWRITE_FUNCTION_RUNTIME_VERSION"] = func.runtime;
|
|
213
|
+
|
|
214
|
+
try {
|
|
215
|
+
await JwtManager.setup(userId, func.scopes ?? []);
|
|
216
|
+
} catch (err: any) {
|
|
217
|
+
warn(
|
|
218
|
+
"Dynamic API key not generated. Header x-appwrite-key will not be set. Reason: " +
|
|
219
|
+
err.message,
|
|
220
|
+
);
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
const headers: Record<string, string> = {};
|
|
224
|
+
headers["x-appwrite-key"] = JwtManager.functionJwt ?? "";
|
|
225
|
+
headers["x-appwrite-trigger"] = "http";
|
|
226
|
+
headers["x-appwrite-event"] = "";
|
|
227
|
+
headers["x-appwrite-user-id"] = userId ?? "";
|
|
228
|
+
headers["x-appwrite-user-jwt"] = JwtManager.userJwt ?? "";
|
|
229
|
+
allVariables["OPEN_RUNTIMES_HEADERS"] = JSON.stringify(headers);
|
|
230
|
+
|
|
231
|
+
if (Object.keys(userVariables).length > 0) {
|
|
232
|
+
drawTable(
|
|
233
|
+
Object.keys(userVariables).map((key) => ({
|
|
234
|
+
key,
|
|
235
|
+
value: userVariables[key]
|
|
236
|
+
.split("")
|
|
237
|
+
.filter((_: string, i: number) => i < 16)
|
|
238
|
+
.map(() => "*")
|
|
239
|
+
.join(""),
|
|
240
|
+
})),
|
|
241
|
+
);
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
await dockerPull(func);
|
|
245
|
+
|
|
246
|
+
new Tail(logsPath).on("line", function (data: string) {
|
|
247
|
+
process.stdout.write(chalk.white(`${data}\n`));
|
|
248
|
+
});
|
|
249
|
+
new Tail(errorsPath).on("line", function (data: string) {
|
|
250
|
+
process.stdout.write(chalk.white(`${data}\n`));
|
|
251
|
+
});
|
|
252
|
+
|
|
253
|
+
if (reload) {
|
|
254
|
+
const ignorer = ignore();
|
|
255
|
+
ignorer.add(".appwrite");
|
|
256
|
+
ignorer.add("code.tar.gz");
|
|
257
|
+
|
|
258
|
+
if (func.ignore) {
|
|
259
|
+
ignorer.add(func.ignore);
|
|
260
|
+
} else if (fs.existsSync(path.join(functionPath, ".gitignore"))) {
|
|
261
|
+
ignorer.add(
|
|
262
|
+
fs.readFileSync(path.join(functionPath, ".gitignore")).toString(),
|
|
263
|
+
);
|
|
118
264
|
}
|
|
119
265
|
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
266
|
+
chokidar
|
|
267
|
+
.watch(".", {
|
|
268
|
+
cwd: path.join(localConfig.getDirname(), func.path),
|
|
269
|
+
ignoreInitial: true,
|
|
270
|
+
ignored: (xpath: string) => {
|
|
271
|
+
const relativePath = path.relative(functionPath, xpath);
|
|
272
|
+
|
|
273
|
+
if (!relativePath) {
|
|
274
|
+
return false;
|
|
275
|
+
}
|
|
276
|
+
return ignorer.ignores(relativePath);
|
|
277
|
+
},
|
|
278
|
+
})
|
|
279
|
+
.on("all", async (_event: string, filePath: string) => {
|
|
280
|
+
Queue.push(filePath);
|
|
281
|
+
});
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
Queue.events.on("reload", async ({ files }: { files: string[] }) => {
|
|
285
|
+
Queue.lock();
|
|
123
286
|
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
});
|
|
138
|
-
} catch(err: any) {
|
|
139
|
-
warn("Remote variables not fetched. Production environment variables will not be available. Reason: " + err.message);
|
|
287
|
+
try {
|
|
288
|
+
await dockerStop(func.$id);
|
|
289
|
+
|
|
290
|
+
const dependencyFile = files.find((filePath: string) =>
|
|
291
|
+
tool.dependencyFiles.includes(filePath),
|
|
292
|
+
);
|
|
293
|
+
if (tool.isCompiled || dependencyFile) {
|
|
294
|
+
log(`Rebuilding the function due to file changes ...`);
|
|
295
|
+
await dockerBuild(func, allVariables);
|
|
296
|
+
|
|
297
|
+
if (!Queue.isEmpty()) {
|
|
298
|
+
Queue.unlock();
|
|
299
|
+
return;
|
|
140
300
|
}
|
|
141
|
-
}
|
|
142
301
|
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
302
|
+
await dockerStart(func, allVariables, portNum!);
|
|
303
|
+
} else {
|
|
304
|
+
log(
|
|
305
|
+
"Hot-swapping function.. Files with change are " + files.join(", "),
|
|
306
|
+
);
|
|
307
|
+
|
|
308
|
+
const hotSwapPath = path.join(functionPath, ".appwrite/hot-swap");
|
|
309
|
+
const buildPath = path.join(functionPath, ".appwrite/build.tar.gz");
|
|
310
|
+
|
|
311
|
+
// Prepare temp folder
|
|
312
|
+
if (!fs.existsSync(hotSwapPath)) {
|
|
313
|
+
fs.mkdirSync(hotSwapPath, { recursive: true });
|
|
314
|
+
} else {
|
|
315
|
+
fs.rmSync(hotSwapPath, { recursive: true, force: true });
|
|
316
|
+
fs.mkdirSync(hotSwapPath, { recursive: true });
|
|
317
|
+
}
|
|
147
318
|
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
319
|
+
await tar.extract({
|
|
320
|
+
keep: true,
|
|
321
|
+
sync: true,
|
|
322
|
+
cwd: hotSwapPath,
|
|
323
|
+
file: buildPath,
|
|
151
324
|
});
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
allVariables['APPWRITE_FUNCTION_API_ENDPOINT'] = globalConfig.getFrom('endpoint');
|
|
155
|
-
allVariables['APPWRITE_FUNCTION_ID'] = func.$id;
|
|
156
|
-
allVariables['APPWRITE_FUNCTION_NAME'] = func.name;
|
|
157
|
-
allVariables['APPWRITE_FUNCTION_DEPLOYMENT'] = ''; // TODO: Implement when relevant
|
|
158
|
-
allVariables['APPWRITE_FUNCTION_PROJECT_ID'] = localConfig.getProject().projectId;
|
|
159
|
-
allVariables['APPWRITE_FUNCTION_RUNTIME_NAME'] = runtimeNames[runtimeName] ?? '';
|
|
160
|
-
allVariables['APPWRITE_FUNCTION_RUNTIME_VERSION'] = func.runtime;
|
|
161
|
-
|
|
162
|
-
try {
|
|
163
|
-
await JwtManager.setup(userId, func.scopes ?? []);
|
|
164
|
-
} catch(err: any) {
|
|
165
|
-
warn("Dynamic API key not generated. Header x-appwrite-key will not be set. Reason: " + err.message);
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
const headers: Record<string, string> = {};
|
|
169
|
-
headers['x-appwrite-key'] = JwtManager.functionJwt ?? '';
|
|
170
|
-
headers['x-appwrite-trigger'] = 'http';
|
|
171
|
-
headers['x-appwrite-event'] = '';
|
|
172
|
-
headers['x-appwrite-user-id'] = userId ?? '';
|
|
173
|
-
headers['x-appwrite-user-jwt'] = JwtManager.userJwt ?? '';
|
|
174
|
-
allVariables['OPEN_RUNTIMES_HEADERS'] = JSON.stringify(headers);
|
|
175
|
-
|
|
176
|
-
if(Object.keys(userVariables).length > 0) {
|
|
177
|
-
drawTable(Object.keys(userVariables).map((key) => ({
|
|
178
|
-
key,
|
|
179
|
-
value: userVariables[key].split("").filter((_: string, i: number) => i < 16).map(() => "*").join("")
|
|
180
|
-
})));
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
await dockerPull(func);
|
|
184
|
-
|
|
185
|
-
new Tail(logsPath).on("line", function(data: string) {
|
|
186
|
-
process.stdout.write(chalk.white(`${data}\n`));
|
|
187
|
-
});
|
|
188
|
-
new Tail(errorsPath).on("line", function(data: string) {
|
|
189
|
-
process.stdout.write(chalk.white(`${data}\n`));
|
|
190
|
-
});
|
|
191
325
|
|
|
192
|
-
if(reload) {
|
|
193
326
|
const ignorer = ignore();
|
|
194
|
-
ignorer.add(
|
|
195
|
-
ignorer.add('code.tar.gz');
|
|
196
|
-
|
|
327
|
+
ignorer.add(".appwrite");
|
|
197
328
|
if (func.ignore) {
|
|
198
|
-
|
|
199
|
-
} else if (fs.existsSync(path.join(functionPath,
|
|
200
|
-
|
|
329
|
+
ignorer.add(func.ignore);
|
|
330
|
+
} else if (fs.existsSync(path.join(functionPath, ".gitignore"))) {
|
|
331
|
+
ignorer.add(
|
|
332
|
+
fs.readFileSync(path.join(functionPath, ".gitignore")).toString(),
|
|
333
|
+
);
|
|
201
334
|
}
|
|
202
335
|
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
Queue.events.on('reload', async ({ files }: { files: string[] }) => {
|
|
220
|
-
Queue.lock();
|
|
221
|
-
|
|
222
|
-
try {
|
|
223
|
-
await dockerStop(func.$id);
|
|
224
|
-
|
|
225
|
-
const dependencyFile = files.find((filePath: string) => tool.dependencyFiles.includes(filePath));
|
|
226
|
-
if(tool.isCompiled || dependencyFile) {
|
|
227
|
-
log(`Rebuilding the function due to file changes ...`);
|
|
228
|
-
await dockerBuild(func, allVariables);
|
|
229
|
-
|
|
230
|
-
if(!Queue.isEmpty()) {
|
|
231
|
-
Queue.unlock();
|
|
232
|
-
return;
|
|
233
|
-
}
|
|
234
|
-
|
|
235
|
-
await dockerStart(func, allVariables, portNum!);
|
|
236
|
-
} else {
|
|
237
|
-
log('Hot-swapping function.. Files with change are ' + files.join(', '));
|
|
238
|
-
|
|
239
|
-
const hotSwapPath = path.join(functionPath, '.appwrite/hot-swap');
|
|
240
|
-
const buildPath = path.join(functionPath, '.appwrite/build.tar.gz');
|
|
241
|
-
|
|
242
|
-
// Prepare temp folder
|
|
243
|
-
if (!fs.existsSync(hotSwapPath)) {
|
|
244
|
-
fs.mkdirSync(hotSwapPath, { recursive: true });
|
|
245
|
-
} else {
|
|
246
|
-
fs.rmSync(hotSwapPath, { recursive: true, force: true });
|
|
247
|
-
fs.mkdirSync(hotSwapPath, { recursive: true });
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
await tar
|
|
251
|
-
.extract({
|
|
252
|
-
keep: true,
|
|
253
|
-
gzip: true,
|
|
254
|
-
sync: true,
|
|
255
|
-
cwd: hotSwapPath,
|
|
256
|
-
file: buildPath
|
|
257
|
-
});
|
|
258
|
-
|
|
259
|
-
const ignorer = ignore.default();
|
|
260
|
-
ignorer.add('.appwrite');
|
|
261
|
-
if (func.ignore) {
|
|
262
|
-
ignorer.add(func.ignore);
|
|
263
|
-
} else if (fs.existsSync(path.join(functionPath, '.gitignore'))) {
|
|
264
|
-
ignorer.add(fs.readFileSync(path.join(functionPath, '.gitignore')).toString());
|
|
265
|
-
}
|
|
266
|
-
|
|
267
|
-
const filesToCopy = getAllFiles(functionPath).map((file: string) => path.relative(functionPath, file)).filter((file: string) => !ignorer.ignores(file));
|
|
268
|
-
for(const f of filesToCopy) {
|
|
269
|
-
const filePath = path.join(hotSwapPath, f);
|
|
270
|
-
if (fs.existsSync(filePath)) {
|
|
271
|
-
fs.rmSync(filePath, { force: true });
|
|
272
|
-
}
|
|
273
|
-
|
|
274
|
-
const fileDir = path.dirname(filePath);
|
|
275
|
-
if (!fs.existsSync(fileDir)) {
|
|
276
|
-
fs.mkdirSync(fileDir, { recursive: true });
|
|
277
|
-
}
|
|
278
|
-
|
|
279
|
-
const sourcePath = path.join(functionPath, f);
|
|
280
|
-
fs.copyFileSync(sourcePath, filePath);
|
|
281
|
-
}
|
|
282
|
-
|
|
283
|
-
await tar
|
|
284
|
-
.create({
|
|
285
|
-
gzip: true,
|
|
286
|
-
sync: true,
|
|
287
|
-
cwd: hotSwapPath,
|
|
288
|
-
file: buildPath
|
|
289
|
-
}, ['.']);
|
|
290
|
-
|
|
291
|
-
await dockerStart(func, allVariables, portNum!);
|
|
292
|
-
}
|
|
293
|
-
} catch(err) {
|
|
294
|
-
console.error(err);
|
|
295
|
-
} finally {
|
|
296
|
-
Queue.unlock();
|
|
336
|
+
const filesToCopy = getAllFiles(functionPath)
|
|
337
|
+
.map((file: string) => path.relative(functionPath, file))
|
|
338
|
+
.filter((file: string) => !ignorer.ignores(file));
|
|
339
|
+
for (const f of filesToCopy) {
|
|
340
|
+
const filePath = path.join(hotSwapPath, f);
|
|
341
|
+
if (fs.existsSync(filePath)) {
|
|
342
|
+
fs.rmSync(filePath, { force: true });
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
const fileDir = path.dirname(filePath);
|
|
346
|
+
if (!fs.existsSync(fileDir)) {
|
|
347
|
+
fs.mkdirSync(fileDir, { recursive: true });
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
const sourcePath = path.join(functionPath, f);
|
|
351
|
+
fs.copyFileSync(sourcePath, filePath);
|
|
297
352
|
}
|
|
298
|
-
});
|
|
299
|
-
|
|
300
|
-
Queue.lock();
|
|
301
353
|
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
354
|
+
await tar.create(
|
|
355
|
+
{
|
|
356
|
+
gzip: true,
|
|
357
|
+
sync: true,
|
|
358
|
+
cwd: hotSwapPath,
|
|
359
|
+
file: buildPath,
|
|
360
|
+
},
|
|
361
|
+
["."],
|
|
362
|
+
);
|
|
363
|
+
|
|
364
|
+
await dockerStart(func, allVariables, portNum!);
|
|
365
|
+
}
|
|
366
|
+
} catch (err) {
|
|
367
|
+
console.error(err);
|
|
368
|
+
} finally {
|
|
369
|
+
Queue.unlock();
|
|
308
370
|
}
|
|
371
|
+
});
|
|
372
|
+
|
|
373
|
+
Queue.lock();
|
|
309
374
|
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
await dockerStart(func, allVariables, portNum!);
|
|
375
|
+
log("Building function using Docker ...");
|
|
376
|
+
await dockerBuild(func, allVariables);
|
|
313
377
|
|
|
378
|
+
if (!Queue.isEmpty()) {
|
|
314
379
|
Queue.unlock();
|
|
315
|
-
|
|
380
|
+
return;
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
log("Starting function using Docker ...");
|
|
384
|
+
hint("Function automatically restarts when you edit your code.");
|
|
385
|
+
await dockerStart(func, allVariables, portNum!);
|
|
386
|
+
|
|
387
|
+
Queue.unlock();
|
|
388
|
+
};
|
|
316
389
|
|
|
317
390
|
export const run = new Command("run")
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
391
|
+
.description(commandDescriptions["run"])
|
|
392
|
+
.configureHelp({
|
|
393
|
+
helpWidth: process.stdout.columns || 80,
|
|
394
|
+
})
|
|
395
|
+
.action(
|
|
396
|
+
actionRunner(async (_options: any, command: Command) => {
|
|
397
|
+
command.help();
|
|
398
|
+
}),
|
|
399
|
+
);
|
|
325
400
|
|
|
326
401
|
run
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
402
|
+
.command("function")
|
|
403
|
+
.alias("functions")
|
|
404
|
+
.description("Run functions in the current directory.")
|
|
405
|
+
.option(`--function-id <function-id>`, `ID of function to run`)
|
|
406
|
+
.option(`--port <port>`, `Local port`)
|
|
407
|
+
.option(`--user-id <user-id>`, `ID of user to impersonate`)
|
|
408
|
+
.option(
|
|
409
|
+
`--with-variables`,
|
|
410
|
+
`Run with function variables from function settings`,
|
|
411
|
+
)
|
|
412
|
+
.option(
|
|
413
|
+
`--no-reload`,
|
|
414
|
+
`Prevent live reloading of server when changes are made to function files`,
|
|
415
|
+
)
|
|
416
|
+
.action(actionRunner(runFunction));
|