diff --git a/.gitignore b/.gitignore index ea06d8997..47d221c8d 100644 --- a/.gitignore +++ b/.gitignore @@ -29,4 +29,5 @@ schemas_nested/ schemas_final/ temp/ -!/extra/admin-api/Utilities/Spacebar.AdminApi.TestClient/wwwroot/lib/bootstrap/dist/ \ No newline at end of file +!/extra/admin-api/Utilities/Spacebar.AdminApi.TestClient/wwwroot/lib/bootstrap/dist/ +*.qcow2 \ No newline at end of file diff --git a/assets/openapi.json b/assets/openapi.json index efd3a4cdc..fbadb7ab9 100644 Binary files a/assets/openapi.json and b/assets/openapi.json differ diff --git a/default.nix b/default.nix index 7763d61c7..8f4280d80 100644 --- a/default.nix +++ b/default.nix @@ -41,7 +41,7 @@ pkgs.buildNpmPackage { npmDeps = pkgs.importNpmLock { npmRoot = filteredSrc; }; npmConfigHook = pkgs.importNpmLock.npmConfigHook; - npmBuildScript = "build:src"; + npmBuildScript = "build:src:tsgo"; makeCacheWritable = true; nativeBuildInputs = with pkgs; [ (pkgs.python3.withPackages (ps: with ps; [ setuptools ])) diff --git a/flake.lock b/flake.lock index 1805babff..5a9df8191 100644 Binary files a/flake.lock and b/flake.lock differ diff --git a/nix/modules/default/default.nix b/nix/modules/default/default.nix index e3a65fb7f..d39919c32 100644 --- a/nix/modules/default/default.nix +++ b/nix/modules/default/default.nix @@ -235,6 +235,7 @@ in serviceConfig = { ExecStart = "${cfg.package}/bin/apply-migrations"; Type = "oneshot"; + RemainAfterExit = true; }; }; diff --git a/nix/tests/test-bundle-starts.nix b/nix/tests/test-bundle-starts.nix index 421517bcb..daebe5a1a 100644 --- a/nix/tests/test-bundle-starts.nix +++ b/nix/tests/test-bundle-starts.nix @@ -24,16 +24,50 @@ in cdnEndpoint = sb.mkEndpoint "cdn.sb.localhost" 3003 false; nginx.enable = true; serverName = "sb.localhost"; + extraEnvironment = { + DATABASE = "postgres://postgres:postgres@127.0.0.1/spacebar"; + LOG_REQUESTS = "-"; # Log all requests + LOG_VALIDATION_ERRORS = true; + }; }; in lib.trace ("Testing with config: " + builtins.toJSON cfg) cfg; services.nginx.enable = true; + services.postgresql = { + enable = true; + initdbArgs = [ + "--encoding=UTF8" + "--locale=C.UTF-8" + "--data-checksums" + "--allow-group-access" + ]; + enableTCPIP = true; + authentication = pkgs.lib.mkOverride 10 '' + # TYPE, DATABASE, USER, ADDRESS, METHOD + local all all trust + host all all 127.0.0.1/32 trust + host all all ::1/128 trust + host all all 0.0.0.0/0 md5 + ''; + initialScript = pkgs.writeText "backend-initScript" '' + CREATE ROLE spacebar WITH LOGIN PASSWORD 'spacebar' CREATEDB; + CREATE DATABASE spacebar; + GRANT ALL PRIVILEGES ON DATABASE spacebar TO spacebar; + ''; + }; }; testScript = '' + machine.wait_for_unit("spacebar-apply-migrations") machine.wait_for_unit("spacebar-api") machine.wait_for_unit("spacebar-cdn") machine.wait_for_unit("spacebar-gateway") - # machine.succeed("curl -f http://api.sb.localhost/.well-known/spacebar/client") + # Wait for unit doesn't mean the service is actually ready to accept connections + machine.wait_for_open_port(80) + machine.wait_for_open_port(3001) + machine.wait_for_open_port(3002) + machine.wait_for_open_port(3003) + # If well known works, its probably fine(tm)? + machine.succeed("curl -f http://api.sb.localhost/.well-known/spacebar/client") ''; } diff --git a/nix/trimNodeModules.sh b/nix/trimNodeModules.sh index debb27386..db057b117 100755 --- a/nix/trimNodeModules.sh +++ b/nix/trimNodeModules.sh @@ -1,5 +1,9 @@ # shellcheck shell=bash +# We don't care about CLI scripts: +for f in ./node_modules/.bin/*; do + rm -f "$(realpath $f)" $f +done # sources echo "Removing source files..." find ./node_modules -name '*.ts' -type f -delete @@ -30,17 +34,15 @@ find ./node_modules -name '*.ar-file-list' -type f -delete find ./node_modules -name '*.stamp' -type f -delete find ./node_modules -name '*musl.node' -type f -delete rm -rf ./node_modules/typescript +rm -rf ./node_modules/@typescript/native-preview rm -rf ./node_modules/ts-node rm -rf ./node_modules/node-gyp +rm -rf ./node_modules/node-gyp-build-optional-packages rm -rf ./node_modules/discord-protos/{discord_protos,scripts} -# We don't care about CLI scripts: -for f in ./node_modules/.bin/*; do - rm -vf "$(realpath $f)" $f -done # rm -rf ./node_modules/typescript-json-schema rm -rf ./node_modules/node-gyp -find ./node_modules -name '@types' -type d -exec rm -rfv {} + +find ./node_modules -name '@types' -type d -exec rm -rf {} + echo "Removing random common files..." find ./node_modules -name 'test' -type d -exec rm -rf {} + @@ -117,4 +119,5 @@ if false; then fi echo "Removing empty directories..." -find node_modules -maxdepth 1 -type d -empty -delete \ No newline at end of file +find node_modules -maxdepth 1 -type d -empty -delete +echo "Trimming complete." \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 4bc76d8b6..ae5e58252 100644 Binary files a/package-lock.json and b/package-lock.json differ diff --git a/package.json b/package.json index d2fee2947..9f71997d6 100644 --- a/package.json +++ b/package.json @@ -11,6 +11,8 @@ "start:gateway": "node --enable-source-maps dist/gateway/start.js", "build": "npm run build:src && npm run generate:schema && npm run generate:openapi", "build:src": "tsc -b -v", + "build:tsgo": "npm run build:src:tsgo && npm run generate:schema && npm run generate:openapi", + "build:src:tsgo": "rm -rf dist/* && tsgo -b -v && mv -v dist/src/* dist/ && rm -rfv dist/src", "watch": "tsc -w -b .", "test": "node scripts/test.js", "lint": "eslint .", @@ -62,6 +64,7 @@ "@types/ws": "^8.18.1", "@typescript-eslint/eslint-plugin": "^8.51.0", "@typescript-eslint/parser": "^8.51.0", + "@typescript/native-preview": "^7.0.0-dev.20260119.1", "eslint": "^9.39.2", "globals": "^16.5.0", "husky": "^9.1.7", diff --git a/src/apply-migrations.ts b/src/apply-migrations.ts index 5c8060240..94f86320e 100644 --- a/src/apply-migrations.ts +++ b/src/apply-migrations.ts @@ -11,5 +11,7 @@ process.env.DB_LOGGING = "true"; import { closeDatabase, initDatabase } from "@spacebar/util"; initDatabase().then(() => { - closeDatabase().then((r) => {}); + closeDatabase().then((r) => { + console.log("Successfully applied migrations!"); + }); });