diff --git a/.env b/.env index 2d2e335186..a17d5ba06c 100644 --- a/.env +++ b/.env @@ -79,8 +79,8 @@ _APP_COMPUTE_RUNTIMES_NETWORK=runtimes _APP_EXECUTOR_SECRET=your-secret-key _APP_EXECUTOR_HOST=http://exc1/v1 _APP_FUNCTIONS_RUNTIMES=php-8.0,node-18.0,python-3.9,ruby-3.1 -_APP_SITES_RUNTIMES=static-1,node-22,flutter-3.24 -_APP_SITES_FRAMEWORKS=sveltekit,nextjs,nuxt,astro,remix,static,flutter # TODO: Angular +_APP_SITES_RUNTIMES=static-1,ssr-22,flutter-3.24 +_APP_SITES_FRAMEWORKS=sveltekit,nextjs,nuxt,astro,remix,flutter,other # TODO: Angular _APP_MAINTENANCE_INTERVAL=86400 _APP_MAINTENANCE_DELAY= _APP_MAINTENANCE_RETENTION_CACHE=2592000 diff --git a/app/cli.php b/app/cli.php index 23502ec402..4aad804f77 100644 --- a/app/cli.php +++ b/app/cli.php @@ -24,7 +24,7 @@ use Utopia\Registry\Registry; use Utopia\System\System; // overwriting runtimes to be architectur agnostic for CLI -Config::setParam('runtimes', (new Runtimes('v4'))->getAll(supported: false)); +Config::setParam('runtimes', (new Runtimes('v4rc'))->getAll(supported: false)); // require controllers after overwriting runtimes require_once __DIR__ . '/controllers/general.php'; diff --git a/app/config/frameworks.php b/app/config/frameworks.php index 35c9c9909c..d19262ff57 100644 --- a/app/config/frameworks.php +++ b/app/config/frameworks.php @@ -21,7 +21,7 @@ return [ 'nextjs' => [ 'key' => 'nextjs', 'name' => 'Next.js', - 'buildRuntime' => 'node-22', + 'buildRuntime' => 'ssr-22', 'runtimes' => getVersions($templateRuntimes['NODE']['versions'], 'node'), 'adapters' => [ 'ssr' => [ @@ -31,6 +31,7 @@ return [ 'outputDirectory' => './.next', 'startCommand' => 'sh helpers/next-js/server.sh', 'bundleCommand' => 'sh /usr/local/server/helpers/next-js/bundle.sh', + 'envCommand' => 'source /usr/local/server/helpers/next-js/env.sh', ], 'static' => [ 'key' => 'static', @@ -39,13 +40,14 @@ return [ 'outputDirectory' => './out', 'startCommand' => 'sh helpers/server.sh', 'bundleCommand' => '', + 'envCommand' => '', ] ] ], 'nuxt' => [ 'key' => 'nuxt', 'name' => 'Nuxt', - 'buildRuntime' => 'node-22', + 'buildRuntime' => 'ssr-22', 'runtimes' => getVersions($templateRuntimes['NODE']['versions'], 'node'), 'adapters' => [ 'ssr' => [ @@ -55,6 +57,7 @@ return [ 'outputDirectory' => './.output', 'startCommand' => 'sh helpers/nuxt/server.sh', 'bundleCommand' => 'sh /usr/local/server/helpers/nuxt/bundle.sh', + 'envCommand' => 'source /usr/local/server/helpers/nuxt/env.sh', ], 'static' => [ 'key' => 'static', @@ -63,13 +66,14 @@ return [ 'outputDirectory' => './dist', 'startCommand' => 'sh helpers/server.sh', 'bundleCommand' => '', + 'envCommand' => '', ] ] ], 'sveltekit' => [ 'key' => 'sveltekit', 'name' => 'SvelteKit', - 'buildRuntime' => 'node-22', + 'buildRuntime' => 'ssr-22', 'runtimes' => getVersions($templateRuntimes['NODE']['versions'], 'node'), 'adapters' => [ 'ssr' => [ @@ -79,6 +83,7 @@ return [ 'outputDirectory' => './build', 'startCommand' => 'sh helpers/sveltekit/server.sh', 'bundleCommand' => 'sh /usr/local/server/helpers/sveltekit/bundle.sh', + 'envCommand' => 'source /usr/local/server/helpers/sveltekit/env.sh', ], 'static' => [ 'key' => 'static', @@ -87,13 +92,14 @@ return [ 'outputDirectory' => './build', 'startCommand' => 'sh helpers/server.sh', 'bundleCommand' => '', + 'envCommand' => '', ] ] ], 'astro' => [ 'key' => 'astro', 'name' => 'Astro', - 'buildRuntime' => 'node-22', + 'buildRuntime' => 'ssr-22', 'runtimes' => getVersions($templateRuntimes['NODE']['versions'], 'node'), 'adapters' => [ 'ssr' => [ @@ -103,6 +109,7 @@ return [ 'outputDirectory' => './dist', 'startCommand' => 'sh helpers/astro/server.sh', 'bundleCommand' => 'sh /usr/local/server/helpers/astro/bundle.sh', + 'envCommand' => 'source /usr/local/server/helpers/astro/env.sh', ], 'static' => [ 'key' => 'static', @@ -111,13 +118,14 @@ return [ 'outputDirectory' => './dist', 'startCommand' => 'sh helpers/server.sh', 'bundleCommand' => '', + 'envCommand' => '', ] ] ], 'remix' => [ 'key' => 'remix', 'name' => 'Remix', - 'buildRuntime' => 'node-22', + 'buildRuntime' => 'ssr-22', 'runtimes' => getVersions($templateRuntimes['NODE']['versions'], 'node'), 'adapters' => [ 'ssr' => [ @@ -127,6 +135,7 @@ return [ 'outputDirectory' => './build', 'startCommand' => 'sh helpers/remix/server.sh', 'bundleCommand' => 'sh /usr/local/server/helpers/remix/bundle.sh', + 'envCommand' => 'source /usr/local/server/helpers/remix/env.sh', ], 'static' => [ 'key' => 'static', @@ -135,6 +144,7 @@ return [ 'outputDirectory' => './build/client', 'startCommand' => 'sh helpers/server.sh', 'bundleCommand' => '', + 'envCommand' => '', ] ] ], @@ -151,13 +161,14 @@ return [ 'outputDirectory' => './build/web', 'startCommand' => 'sh helpers/server.sh', 'bundleCommand' => '', + 'envCommand' => '', ], ], ], 'other' => [ 'key' => 'other', 'name' => 'Other', - 'buildRuntime' => 'node-22', + 'buildRuntime' => 'ssr-22', 'runtimes' => getVersions($templateRuntimes['NODE']['versions'], 'node'), 'adapters' => [ 'static' => [ @@ -167,6 +178,7 @@ return [ 'outputDirectory' => './', 'startCommand' => 'sh helpers/server.sh', 'bundleCommand' => '', + 'envCommand' => '', ], ] ], diff --git a/app/config/runtimes.php b/app/config/runtimes.php index 980613ebec..4260655342 100644 --- a/app/config/runtimes.php +++ b/app/config/runtimes.php @@ -6,4 +6,4 @@ use Appwrite\Runtimes\Runtimes; -return (new Runtimes('v4'))->getAll(); +return (new Runtimes('v4rc'))->getAll(); diff --git a/app/config/services.php b/app/config/services.php index c4fb98c59a..d3e221e2fa 100644 --- a/app/config/services.php +++ b/app/config/services.php @@ -173,6 +173,19 @@ return [ 'optional' => false, 'icon' => '', ], + 'sites' => [ + 'key' => 'sites', + 'name' => 'Sites', + 'subtitle' => 'The Sites Service allows you view, create and manage your web applications.', + 'description' => '/docs/services/sites.md', + 'controller' => 'api/sites.php', + 'sdk' => true, + 'docs' => true, + 'docsUrl' => 'https://appwrite.io/docs/sites', + 'tests' => false, + 'optional' => true, + 'icon' => '', // TODO: Update icon later + ], 'functions' => [ 'key' => 'functions', 'name' => 'Functions', diff --git a/app/config/site-templates.php b/app/config/site-templates.php index 79bccc0e2c..64696cedfa 100644 --- a/app/config/site-templates.php +++ b/app/config/site-templates.php @@ -13,7 +13,7 @@ const TEMPLATE_FRAMEWORKS = [ 'installCommand' => 'npm install', 'buildCommand' => 'npm run build', 'outputDirectory' => './build', - 'buildRuntime' => 'node-22', + 'buildRuntime' => 'ssr-22', 'adapter' => 'ssr', 'fallbackFile' => null, ], @@ -23,7 +23,7 @@ const TEMPLATE_FRAMEWORKS = [ 'installCommand' => 'npm install', 'buildCommand' => 'npm run build', 'outputDirectory' => './.next', - 'buildRuntime' => 'node-22', + 'buildRuntime' => 'ssr-22', 'adapter' => 'ssr', 'fallbackFile' => null, ], @@ -33,7 +33,7 @@ const TEMPLATE_FRAMEWORKS = [ 'installCommand' => 'npm install', 'buildCommand' => 'npm run build', 'outputDirectory' => './.output', - 'buildRuntime' => 'node-22', + 'buildRuntime' => 'ssr-22', 'adapter' => 'ssr', 'fallbackFile' => null, ], @@ -43,7 +43,7 @@ const TEMPLATE_FRAMEWORKS = [ 'installCommand' => 'npm install', 'buildCommand' => 'npm run build', 'outputDirectory' => './build', - 'buildRuntime' => 'node-22', + 'buildRuntime' => 'ssr-22', 'adapter' => 'ssr', 'fallbackFile' => null, ], @@ -53,7 +53,7 @@ const TEMPLATE_FRAMEWORKS = [ 'installCommand' => 'npm install', 'buildCommand' => 'npm run build', 'outputDirectory' => './dist', - 'buildRuntime' => 'node-22', + 'buildRuntime' => 'ssr-22', 'adapter' => 'ssr', 'fallbackFile' => null, ], @@ -135,12 +135,12 @@ return [ 'demoImage' => 'https://qa17.appwrite.org/console/images/sites/templates/astro-starter.png', 'frameworks' => [ getFramework('ASTRO', [ - 'providerRootDirectory' => './', + 'providerRootDirectory' => './astro/starter', ]), ], 'vcsProvider' => 'github', - 'providerRepositoryId' => 'astro-ssr-test-template', - 'providerOwner' => 'Meldiron', + 'providerRepositoryId' => 'templates-for-sites', + 'providerOwner' => 'appwrite', 'providerVersion' => '0.2.*', 'variables' => [], ], diff --git a/app/config/specs/open-api3-latest-console.json b/app/config/specs/open-api3-latest-console.json index 15e86fb6ce..c0636f5b20 100644 --- a/app/config/specs/open-api3-latest-console.json +++ b/app/config/specs/open-api3-latest-console.json @@ -9489,7 +9489,8 @@ "bun-1.1", "go-1.23", "static-1", - "flutter-3.24" + "flutter-3.24", + "ssr-22" ], "x-enum-name": null, "x-enum-keys": [] @@ -10147,7 +10148,8 @@ "bun-1.1", "go-1.23", "static-1", - "flutter-3.24" + "flutter-3.24", + "ssr-22" ], "x-enum-name": null, "x-enum-keys": [] @@ -25417,7 +25419,8 @@ "bun-1.1", "go-1.23", "static-1", - "flutter-3.24" + "flutter-3.24", + "ssr-22" ], "x-enum-name": null, "x-enum-keys": [] @@ -26021,7 +26024,8 @@ "bun-1.1", "go-1.23", "static-1", - "flutter-3.24" + "flutter-3.24", + "ssr-22" ], "x-enum-name": null, "x-enum-keys": [] diff --git a/app/config/specs/open-api3-latest-server.json b/app/config/specs/open-api3-latest-server.json index bd1b36a7dc..94b5075ade 100644 --- a/app/config/specs/open-api3-latest-server.json +++ b/app/config/specs/open-api3-latest-server.json @@ -8597,7 +8597,8 @@ "bun-1.1", "go-1.23", "static-1", - "flutter-3.24" + "flutter-3.24", + "ssr-22" ], "x-enum-name": null, "x-enum-keys": [] @@ -9021,7 +9022,8 @@ "bun-1.1", "go-1.23", "static-1", - "flutter-3.24" + "flutter-3.24", + "ssr-22" ], "x-enum-name": null, "x-enum-keys": [] @@ -17233,7 +17235,8 @@ "bun-1.1", "go-1.23", "static-1", - "flutter-3.24" + "flutter-3.24", + "ssr-22" ], "x-enum-name": null, "x-enum-keys": [] @@ -17602,7 +17605,8 @@ "bun-1.1", "go-1.23", "static-1", - "flutter-3.24" + "flutter-3.24", + "ssr-22" ], "x-enum-name": null, "x-enum-keys": [] diff --git a/app/config/specs/swagger2-latest-console.json b/app/config/specs/swagger2-latest-console.json index 2681bf0772..0365ec616a 100644 --- a/app/config/specs/swagger2-latest-console.json +++ b/app/config/specs/swagger2-latest-console.json @@ -9611,7 +9611,8 @@ "bun-1.1", "go-1.23", "static-1", - "flutter-3.24" + "flutter-3.24", + "ssr-22" ], "x-enum-name": null, "x-enum-keys": [] @@ -10288,7 +10289,8 @@ "bun-1.1", "go-1.23", "static-1", - "flutter-3.24" + "flutter-3.24", + "ssr-22" ], "x-enum-name": null, "x-enum-keys": [] @@ -25901,7 +25903,8 @@ "bun-1.1", "go-1.23", "static-1", - "flutter-3.24" + "flutter-3.24", + "ssr-22" ], "x-enum-name": null, "x-enum-keys": [] @@ -26521,7 +26524,8 @@ "bun-1.1", "go-1.23", "static-1", - "flutter-3.24" + "flutter-3.24", + "ssr-22" ], "x-enum-name": null, "x-enum-keys": [] diff --git a/app/config/specs/swagger2-latest-server.json b/app/config/specs/swagger2-latest-server.json index 199b94b202..f64f379d2d 100644 --- a/app/config/specs/swagger2-latest-server.json +++ b/app/config/specs/swagger2-latest-server.json @@ -8721,7 +8721,8 @@ "bun-1.1", "go-1.23", "static-1", - "flutter-3.24" + "flutter-3.24", + "ssr-22" ], "x-enum-name": null, "x-enum-keys": [] @@ -9168,7 +9169,8 @@ "bun-1.1", "go-1.23", "static-1", - "flutter-3.24" + "flutter-3.24", + "ssr-22" ], "x-enum-name": null, "x-enum-keys": [] @@ -17685,7 +17687,8 @@ "bun-1.1", "go-1.23", "static-1", - "flutter-3.24" + "flutter-3.24", + "ssr-22" ], "x-enum-name": null, "x-enum-keys": [] @@ -18074,7 +18077,8 @@ "bun-1.1", "go-1.23", "static-1", - "flutter-3.24" + "flutter-3.24", + "ssr-22" ], "x-enum-name": null, "x-enum-keys": [] diff --git a/app/init.php b/app/init.php index dfa849c002..bc95641a76 100644 --- a/app/init.php +++ b/app/init.php @@ -182,6 +182,7 @@ const DELETE_TYPE_DATABASES = 'databases'; const DELETE_TYPE_DOCUMENT = 'document'; const DELETE_TYPE_COLLECTIONS = 'collections'; const DELETE_TYPE_PROJECTS = 'projects'; +const DELETE_TYPE_SITES = 'sites'; const DELETE_TYPE_FUNCTIONS = 'functions'; const DELETE_TYPE_DEPLOYMENTS = 'deployments'; const DELETE_TYPE_USERS = 'users'; diff --git a/composer.lock b/composer.lock index dcc9b7a2e1..83d77ab9f0 100644 --- a/composer.lock +++ b/composer.lock @@ -1430,16 +1430,16 @@ }, { "name": "open-telemetry/gen-otlp-protobuf", - "version": "1.2.1", + "version": "1.5.0", "source": { "type": "git", "url": "https://github.com/opentelemetry-php/gen-otlp-protobuf.git", - "reference": "66c3b98e998a726691c92e6405a82e6e7b8b169d" + "reference": "585bafddd4ae6565de154610b10a787a455c9ba0" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/opentelemetry-php/gen-otlp-protobuf/zipball/66c3b98e998a726691c92e6405a82e6e7b8b169d", - "reference": "66c3b98e998a726691c92e6405a82e6e7b8b169d", + "url": "https://api.github.com/repos/opentelemetry-php/gen-otlp-protobuf/zipball/585bafddd4ae6565de154610b10a787a455c9ba0", + "reference": "585bafddd4ae6565de154610b10a787a455c9ba0", "shasum": "" }, "require": { @@ -1489,7 +1489,7 @@ "issues": "https://github.com/open-telemetry/opentelemetry-php/issues", "source": "https://github.com/open-telemetry/opentelemetry-php" }, - "time": "2024-10-30T11:49:49+00:00" + "time": "2025-01-15T23:07:07+00:00" }, { "name": "open-telemetry/sdk", @@ -3379,16 +3379,16 @@ }, { "name": "utopia-php/compression", - "version": "0.1.2", + "version": "0.1.3", "source": { "type": "git", "url": "https://github.com/utopia-php/compression.git", - "reference": "6062f70596415f8d5de40a589367b0eb2a435f98" + "reference": "66f093557ba66d98245e562036182016c7dcfe8a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/compression/zipball/6062f70596415f8d5de40a589367b0eb2a435f98", - "reference": "6062f70596415f8d5de40a589367b0eb2a435f98", + "url": "https://api.github.com/repos/utopia-php/compression/zipball/66f093557ba66d98245e562036182016c7dcfe8a", + "reference": "66f093557ba66d98245e562036182016c7dcfe8a", "shasum": "" }, "require": { @@ -3419,9 +3419,9 @@ ], "support": { "issues": "https://github.com/utopia-php/compression/issues", - "source": "https://github.com/utopia-php/compression/tree/0.1.2" + "source": "https://github.com/utopia-php/compression/tree/0.1.3" }, - "time": "2024-11-08T14:59:54+00:00" + "time": "2025-01-15T15:15:51+00:00" }, { "name": "utopia-php/config", @@ -4095,16 +4095,16 @@ }, { "name": "utopia-php/platform", - "version": "0.7.1", + "version": "0.7.2", "source": { "type": "git", "url": "https://github.com/utopia-php/platform.git", - "reference": "3433a0f1a54988f2a59c735f507745cb2c24638a" + "reference": "6f9243848f1c6466f6509fd01c7e18306a6d8caf" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/platform/zipball/3433a0f1a54988f2a59c735f507745cb2c24638a", - "reference": "3433a0f1a54988f2a59c735f507745cb2c24638a", + "url": "https://api.github.com/repos/utopia-php/platform/zipball/6f9243848f1c6466f6509fd01c7e18306a6d8caf", + "reference": "6f9243848f1c6466f6509fd01c7e18306a6d8caf", "shasum": "" }, "require": { @@ -4139,9 +4139,9 @@ ], "support": { "issues": "https://github.com/utopia-php/platform/issues", - "source": "https://github.com/utopia-php/platform/tree/0.7.1" + "source": "https://github.com/utopia-php/platform/tree/0.7.2" }, - "time": "2024-10-22T10:27:49+00:00" + "time": "2025-01-15T05:56:26+00:00" }, { "name": "utopia-php/pools", @@ -4807,16 +4807,16 @@ "packages-dev": [ { "name": "appwrite/sdk-generator", - "version": "0.39.29", + "version": "0.39.30", "source": { "type": "git", "url": "https://github.com/appwrite/sdk-generator.git", - "reference": "a9c3f6076ec162588dac7b0a741bc1a2c3d1a2b7" + "reference": "830198d501f51163514305befefb775106a7198b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/appwrite/sdk-generator/zipball/a9c3f6076ec162588dac7b0a741bc1a2c3d1a2b7", - "reference": "a9c3f6076ec162588dac7b0a741bc1a2c3d1a2b7", + "url": "https://api.github.com/repos/appwrite/sdk-generator/zipball/830198d501f51163514305befefb775106a7198b", + "reference": "830198d501f51163514305befefb775106a7198b", "shasum": "" }, "require": { @@ -4852,9 +4852,9 @@ "description": "Appwrite PHP library for generating API SDKs for multiple programming languages and platforms", "support": { "issues": "https://github.com/appwrite/sdk-generator/issues", - "source": "https://github.com/appwrite/sdk-generator/tree/0.39.29" + "source": "https://github.com/appwrite/sdk-generator/tree/0.39.30" }, - "time": "2025-01-07T05:28:35+00:00" + "time": "2025-01-20T06:10:03+00:00" }, { "name": "doctrine/annotations", @@ -5126,16 +5126,16 @@ }, { "name": "laravel/pint", - "version": "v1.19.0", + "version": "v1.20.0", "source": { "type": "git", "url": "https://github.com/laravel/pint.git", - "reference": "8169513746e1bac70c85d6ea1524d9225d4886f0" + "reference": "53072e8ea22213a7ed168a8a15b96fbb8b82d44b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laravel/pint/zipball/8169513746e1bac70c85d6ea1524d9225d4886f0", - "reference": "8169513746e1bac70c85d6ea1524d9225d4886f0", + "url": "https://api.github.com/repos/laravel/pint/zipball/53072e8ea22213a7ed168a8a15b96fbb8b82d44b", + "reference": "53072e8ea22213a7ed168a8a15b96fbb8b82d44b", "shasum": "" }, "require": { @@ -5188,7 +5188,7 @@ "issues": "https://github.com/laravel/pint/issues", "source": "https://github.com/laravel/pint" }, - "time": "2024-12-30T16:20:10+00:00" + "time": "2025-01-14T16:20:53+00:00" }, { "name": "matthiasmullie/minify", @@ -8589,5 +8589,5 @@ "platform-overrides": { "php": "8.3" }, - "plugin-api-version": "2.3.0" + "plugin-api-version": "2.6.0" } diff --git a/docker-compose.yml b/docker-compose.yml index bb7af40946..35bdf30256 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -201,7 +201,7 @@ services: appwrite-console: <<: *x-logging container_name: appwrite-console - image: appwrite/console:5.0.12 + image: appwrite/console:5.3.0-sites-rc.2 restart: unless-stopped networks: - appwrite @@ -880,7 +880,7 @@ services: hostname: exc1 <<: *x-logging stop_signal: SIGINT - image: openruntimes/executor:0.7.2 + image: openruntimes/executor:0.7.3 restart: unless-stopped networks: - appwrite @@ -893,7 +893,7 @@ services: # It's not possible to share mount file between 2 containers without host mount (copying is too slow) - /tmp:/tmp:rw environment: - - OPR_EXECUTOR_IMAGE_PULL=disabled + - OPR_EXECUTOR_IMAGE_PULL=enabled - OPR_EXECUTOR_INACTIVE_TRESHOLD=$_APP_COMPUTE_INACTIVE_THRESHOLD - OPR_EXECUTOR_MAINTENANCE_INTERVAL=$_APP_COMPUTE_MAINTENANCE_INTERVAL - OPR_EXECUTOR_NETWORK=$_APP_COMPUTE_RUNTIMES_NETWORK @@ -902,7 +902,7 @@ services: - OPR_EXECUTOR_ENV=$_APP_ENV - OPR_EXECUTOR_RUNTIMES=$_APP_FUNCTIONS_RUNTIMES,$_APP_SITES_RUNTIMES - OPR_EXECUTOR_SECRET=$_APP_EXECUTOR_SECRET - - OPR_EXECUTOR_RUNTIME_VERSIONS=v2,v4 + - OPR_EXECUTOR_RUNTIME_VERSIONS=v2,v4,v4rc - OPR_EXECUTOR_LOGGING_CONFIG=$_APP_LOGGING_CONFIG - OPR_EXECUTOR_STORAGE_DEVICE=$_APP_STORAGE_DEVICE - OPR_EXECUTOR_STORAGE_S3_ACCESS_KEY=$_APP_STORAGE_S3_ACCESS_KEY diff --git a/src/Appwrite/Platform/Modules/Functions/Workers/Builds.php b/src/Appwrite/Platform/Modules/Functions/Workers/Builds.php index 047038e99b..d4e1820f0f 100644 --- a/src/Appwrite/Platform/Modules/Functions/Workers/Builds.php +++ b/src/Appwrite/Platform/Modules/Functions/Workers/Builds.php @@ -881,6 +881,9 @@ class Builds extends Action if (!is_null($adapter) && isset($adapter['bundleCommand'])) { $commands[] = $adapter['bundleCommand']; } + if (!is_null($adapter) && isset($adapter['envCommand'])) { + $commands[] = $adapter['envCommand']; + } } $commands = array_filter($commands, fn ($command) => !empty($command)); diff --git a/src/Appwrite/Platform/Workers/Deletes.php b/src/Appwrite/Platform/Workers/Deletes.php index 676120b741..fcb8ef5e12 100644 --- a/src/Appwrite/Platform/Workers/Deletes.php +++ b/src/Appwrite/Platform/Workers/Deletes.php @@ -87,11 +87,14 @@ class Deletes extends Action case DELETE_TYPE_PROJECTS: $this->deleteProject($dbForConsole, $getProjectDB, $deviceForFiles, $deviceForSites, $deviceForFunctions, $deviceForBuilds, $deviceForCache, $document); break; + case DELETE_TYPE_SITES: + $this->deleteSite($dbForConsole, $getProjectDB, $deviceForSites, $deviceForFunctions, $deviceForBuilds, $document, $project); + break; case DELETE_TYPE_FUNCTIONS: $this->deleteFunction($dbForConsole, $getProjectDB, $deviceForFunctions, $deviceForBuilds, $document, $project); break; case DELETE_TYPE_DEPLOYMENTS: - $this->deleteDeployment($getProjectDB, $deviceForFunctions, $deviceForBuilds, $document, $project); + $this->deleteDeployment($dbForConsole, $getProjectDB, $deviceForFunctions, $deviceForBuilds, $document, $project); break; case DELETE_TYPE_USERS: $this->deleteUser($getProjectDB, $document, $project); @@ -732,6 +735,100 @@ class Deletes extends Action } } + /** + * @param callable $getProjectDB + * @param Device $deviceForSites + * @param Device $deviceForFunctions + * @param Device $deviceForBuilds + * @param Document $document function document + * @param Document $project + * @return void + * @throws Exception + */ + private function deleteSite(Database $dbForConsole, callable $getProjectDB, Device $deviceForSites, Device $deviceForFunctions, Device $deviceForBuilds, Document $document, Document $project): void + { + $dbForProject = $getProjectDB($project); + $siteId = $document->getId(); + $siteInternalId = $document->getInternalId(); + + /** + * Delete rules for site + */ + Console::info("Deleting rules for site " . $siteId); + $this->deleteByGroup('rules', [ + Query::equal('resourceType', ['site']), + Query::equal('resourceInternalId', [$siteInternalId]), + Query::equal('projectInternalId', [$project->getInternalId()]) + ], $dbForConsole, function (Document $document) use ($dbForConsole) { + $this->deleteRule($dbForConsole, $document); + }); + + /** + * Delete Variables + */ + Console::info("Deleting variables for site " . $siteId); + $this->deleteByGroup('variables', [ + Query::equal('resourceType', ['site']), + Query::equal('resourceInternalId', [$siteInternalId]) + ], $dbForProject); + + /** + * Delete Deployments + */ + Console::info("Deleting deployments for site " . $siteId); + $deploymentInternalIds = []; + $this->deleteByGroup('deployments', [ + Query::equal('resourceInternalId', [$siteInternalId]) + ], $dbForProject, function (Document $document) use ($deviceForFunctions, &$deploymentInternalIds) { + $deploymentInternalIds[] = $document->getInternalId(); + $this->deleteDeploymentFiles($deviceForFunctions, $document); + }); + + /** + * Delete rules for all deployments of the site + */ + //TODO: If functions also have previews in the future, change the logic here to use unique identifier for sites and functions + foreach ($deploymentInternalIds as $deploymentInternalId) { + Console::info("Deleting rules for site " . $siteId . "'s deployment " . $deploymentInternalId); + $this->deleteByGroup('rules', [ + Query::equal('resourceType', ['deployment']), + Query::equal('resourceInternalId', [$deploymentInternalId]), + Query::equal('projectInternalId', [$project->getInternalId()]) + ], $dbForConsole, function (Document $document) use ($dbForConsole) { + $this->deleteRule($dbForConsole, $document); + }); + } + + /** + * Delete builds + */ + Console::info("Deleting builds for site " . $siteId); + foreach ($deploymentInternalIds as $deploymentInternalId) { + $this->deleteByGroup('builds', [ + Query::equal('deploymentInternalId', [$deploymentInternalId]) + ], $dbForProject, function (Document $document) use ($deviceForBuilds) { + $this->deleteBuildFiles($deviceForBuilds, $document); + }); + } + + /** + * Delete VCS Repositories and VCS Comments + */ + Console::info("Deleting VCS repositories and comments linked to site " . $siteId); + $this->deleteByGroup('repositories', [ + Query::equal('projectInternalId', [$project->getInternalId()]), + Query::equal('resourceInternalId', [$siteInternalId]), + Query::equal('resourceType', ['site']), + ], $dbForConsole, function (Document $document) use ($dbForConsole) { + $providerRepositoryId = $document->getAttribute('providerRepositoryId', ''); + $projectInternalId = $document->getAttribute('projectInternalId', ''); + $this->deleteByGroup('vcsComments', [ + Query::equal('providerRepositoryId', [$providerRepositoryId]), + Query::equal('projectInternalId', [$projectInternalId]), + ], $dbForConsole); + }); + } + /** * @param callable $getProjectDB * @param Device $deviceForFunctions @@ -898,7 +995,7 @@ class Deletes extends Action * @return void * @throws Exception */ - private function deleteDeployment(callable $getProjectDB, Device $deviceForFunctions, Device $deviceForBuilds, Document $document, Document $project): void + private function deleteDeployment(Database $dbForConsole, callable $getProjectDB, Device $deviceForFunctions, Device $deviceForBuilds, Document $document, Document $project): void { $projectId = $project->getId(); $dbForProject = $getProjectDB($project); @@ -908,7 +1005,7 @@ class Deletes extends Action /** * Delete deployment files */ - $this->deleteDeploymentFiles($deviceForFunctions, $document); + $this->deleteDeploymentFiles($deviceForFunctions, $document); //TODO: For sites, this should be deviceForSites /** * Delete builds @@ -921,6 +1018,18 @@ class Deletes extends Action $this->deleteBuildFiles($deviceForBuilds, $document); }); + /** + * Delete rules associated with the deployment + */ + Console::info("Deleting rules for deployment " . $deploymentId); + $this->deleteByGroup('rules', [ + Query::equal('resourceType', ['deployment']), + Query::equal('resourceInternalId', [$deploymentInternalId]), + Query::equal('projectInternalId', [$project->getInternalId()]) + ], $dbForConsole, function (Document $document) use ($dbForConsole) { + $this->deleteRule($dbForConsole, $document); + }); + /** * Request executor to delete all deployment containers */ diff --git a/tests/e2e/Scopes/ProjectCustom.php b/tests/e2e/Scopes/ProjectCustom.php index 7f84ace6f2..c3cbc96887 100644 --- a/tests/e2e/Scopes/ProjectCustom.php +++ b/tests/e2e/Scopes/ProjectCustom.php @@ -74,6 +74,8 @@ trait ProjectCustom 'files.write', 'buckets.read', 'buckets.write', + 'sites.read', + 'sites.write', 'functions.read', 'functions.write', 'execution.read',