| 10 Dec 2023 |
Emma [it/its] ⚡️ | I wonder if Use paths relative to project, resource or sources roots is a good option to turn on? | 20:37:02 |
Emma [it/its] ⚡️ |  Download Screenshot from 2023-12-10 21-37-16.png | 20:37:22 |
Emma [it/its] ⚡️ | (for imports, that is) | 20:38:14 |
Lily Foster | In reply to @emma:conduit.rory.gay https://github.com/spacebarchat/server/blob/master/package.json so this doesn't remove the openapi.json file, but this diff seems to build and run similarly in testing:
diff --git a/flake.nix b/flake.nix
index 71760eff..1391bca1 100644
--- a/flake.nix
+++ b/flake.nix
@@ -15,46 +15,10 @@
pname = "spacebar-server-ts";
src = ./.;
name = "spacebar-server-ts";
- nativeBuildInputs = with pkgs; [ python3 ];
npmDepsHash = "sha256-axzbsD+jOViIQ9+qFSX41j6harBL9vyaXDKdOSaPW8M=";
- makeCacheWritable = true;
postPatch = ''
substituteInPlace package.json --replace 'npx patch-package' '${pkgs.nodePackages.patch-package}/bin/patch-package'
'';
- installPhase = ''
- runHook preInstall
- set -x
- #remove packages not needed for production, or at least try to...
- npm prune --omit dev --no-save $npmInstallFlags "''${npmInstallFlagsArray[@]}" $npmFlags "''${npmFlagsArray[@]}"
- find node_modules -maxdepth 1 -type d -empty -delete
-
- mkdir -p $out/node_modules/
- cp -r node_modules/* $out/node_modules/
- cp -r dist/ $out/node_modules/@spacebar
- for i in dist/**/start.js
- do
- makeWrapper ${pkgs.nodejs-slim}/bin/node $out/bin/start-`dirname ''${i/dist\//}` --prefix NODE_PATH : $out/node_modules --add-flags $out/node_modules/@spacebar`dirname ''${i/dist/}`/start.js
- done
- set +x
- substituteInPlace package.json --replace 'dist/' 'node_modules/@spacebar/'
- find $out/node_modules/@spacebar/ -type f -name "*.js" | while read srcFile; do
- echo Patching imports in ''${srcFile/$out\/node_modules\/@spacebar//}...
- substituteInPlace $srcFile --replace 'require("./' 'require(__dirname + "/'
- substituteInPlace $srcFile --replace 'require("../' 'require(__dirname + "/../'
- substituteInPlace $srcFile --replace ', "assets"' ', "..", "assets"'
- #substituteInPlace $srcFile --replace 'require("@spacebar/' 'require("
- done
- set -x
- cp -r assets/ $out/
- cp package.json $out/
- rm -v $out/assets/openapi.json
- #rm -v $out/assets/schemas.json
-
- #debug utils:
- #cp $out/node_modules/@spacebar/ $out/build_output -r
- set +x
- runHook postInstall
- '';
};
devShell = pkgs.mkShell {
buildInputs = with pkgs; [
diff --git a/package.json b/package.json
index 83ec9dcc..e0dcf4c9 100644
--- a/package.json
+++ b/package.json
@@ -37,6 +37,16 @@
"imports": {
"#*": "./dist/*/index.js"
},
+ "files": [
+ "dist",
+ "assets"
+ ],
+ "bin": {
+ "start-bundle": "dist/bundle/start.js",
+ "start-api": "dist/api/start.js",
+ "start-cdn": "dist/cdn/start.js",
+ "start-gateway": "dist/gateway/start.js"
+ },
"homepage": "https://spacebar.chat",
"devDependencies": {
"@types/amqplib": "^0.8.2",
| 20:38:21 |
Lily Foster | In reply to @emma:conduit.rory.gay I wonder if Use paths relative to project, resource or sources roots is a good option to turn on? for your IDE? | 20:38:55 |
Emma [it/its] ⚡️ | yes | 20:39:08 |
Lily Foster | Uhh, idk, maybe? I'm not 100% what that setting does or whether it would be appropriate for the semantics of your project | 20:40:33 |
Emma [it/its] ⚡️ | me neither | 20:40:44 |
Emma [it/its] ⚡️ | let me try to apply that patch | 21:00:02 |
Emma [it/its] ⚡️ | In reply to @lily:lily.flowers
so this doesn't remove the openapi.json file, but this diff seems to build and run similarly in testing:
diff --git a/flake.nix b/flake.nix
index 71760eff..1391bca1 100644
--- a/flake.nix
+++ b/flake.nix
@@ -15,46 +15,10 @@
pname = "spacebar-server-ts";
src = ./.;
name = "spacebar-server-ts";
- nativeBuildInputs = with pkgs; [ python3 ];
npmDepsHash = "sha256-axzbsD+jOViIQ9+qFSX41j6harBL9vyaXDKdOSaPW8M=";
- makeCacheWritable = true;
postPatch = ''
substituteInPlace package.json --replace 'npx patch-package' '${pkgs.nodePackages.patch-package}/bin/patch-package'
'';
- installPhase = ''
- runHook preInstall
- set -x
- #remove packages not needed for production, or at least try to...
- npm prune --omit dev --no-save $npmInstallFlags "''${npmInstallFlagsArray[@]}" $npmFlags "''${npmFlagsArray[@]}"
- find node_modules -maxdepth 1 -type d -empty -delete
-
- mkdir -p $out/node_modules/
- cp -r node_modules/* $out/node_modules/
- cp -r dist/ $out/node_modules/@spacebar
- for i in dist/**/start.js
- do
- makeWrapper ${pkgs.nodejs-slim}/bin/node $out/bin/start-`dirname ''${i/dist\//}` --prefix NODE_PATH : $out/node_modules --add-flags $out/node_modules/@spacebar`dirname ''${i/dist/}`/start.js
- done
- set +x
- substituteInPlace package.json --replace 'dist/' 'node_modules/@spacebar/'
- find $out/node_modules/@spacebar/ -type f -name "*.js" | while read srcFile; do
- echo Patching imports in ''${srcFile/$out\/node_modules\/@spacebar//}...
- substituteInPlace $srcFile --replace 'require("./' 'require(__dirname + "/'
- substituteInPlace $srcFile --replace 'require("../' 'require(__dirname + "/../'
- substituteInPlace $srcFile --replace ', "assets"' ', "..", "assets"'
- #substituteInPlace $srcFile --replace 'require("@spacebar/' 'require("
- done
- set -x
- cp -r assets/ $out/
- cp package.json $out/
- rm -v $out/assets/openapi.json
- #rm -v $out/assets/schemas.json
-
- #debug utils:
- #cp $out/node_modules/@spacebar/ $out/build_output -r
- set +x
- runHook postInstall
- '';
};
devShell = pkgs.mkShell {
buildInputs = with pkgs; [
diff --git a/package.json b/package.json
index 83ec9dcc..e0dcf4c9 100644
--- a/package.json
+++ b/package.json
@@ -37,6 +37,16 @@
"imports": {
"#*": "./dist/*/index.js"
},
+ "files": [
+ "dist",
+ "assets"
+ ],
+ "bin": {
+ "start-bundle": "dist/bundle/start.js",
+ "start-api": "dist/api/start.js",
+ "start-cdn": "dist/cdn/start.js",
+ "start-gateway": "dist/gateway/start.js"
+ },
"homepage": "https://spacebar.chat",
"devDependencies": {
"@types/amqplib": "^0.8.2",
are you sure this works? | 21:01:01 |
Emma [it/its] ⚡️ | i thought makeCacheWritable was needed for node-patch? | 21:01:24 |
Lily Foster | In reply to @emma:conduit.rory.gay are you sure this works? i did also do a nix flake update that i excluded in the diff | 21:04:23 |
Lily Foster | In reply to @emma:conduit.rory.gay i thought makeCacheWritable was needed for node-patch? i don't think so? i mean you can add it back too if it is needed | 21:04:47 |
Lily Foster | In reply to @lily:lily.flowers i did also do a nix flake update that i excluded in the diff but yes, i tried to test it and doing start-bundle did this, so i assumed it was likely working:
[I] lily@bina ~/t/server (dev/nix)> /nix/store/k9bvv7ba8izvphkdpdy22l3iiv7vn4lp-spacebar-server-ts/bin/start-bundle
███████╗██████╗ █████╗ ██████╗███████╗██████╗ █████╗ ██████╗
██╔════╝██╔══██╗██╔══██╗██╔════╝██╔════╝██╔══██╗██╔══██╗██╔══██╗
███████╗██████╔╝███████║██║ █████╗ ██████╔╝███████║██████╔╝
╚════██║██╔═══╝ ██╔══██║██║ ██╔══╝ ██╔══██╗██╔══██║██╔══██╗
███████║██║ ██║ ██║╚██████╗███████╗██████╔╝██║ ██║██║ ██║
╚══════╝╚═╝ ╚═╝ ╚═╝ ╚═════╝╚══════╝╚═════╝ ╚═╝ ╚═╝╚═╝ ╚═╝
spacebar-server | Pre-release (0d134e1)
Commit Hash: 0d134e151b2e29bc619c22318769cddde32d93a1 (0d134e1)
Cores: 16 (Using 1 thread(s).)
[Path] running in /nix/store/k9bvv7ba8izvphkdpdy22l3iiv7vn4lp-spacebar-server-ts/lib/node_modules/spacebar-server/dist/bundle
[CPU] 12th Gen Intel(R) Core(TM) i7-1260P Cores x16
[System] linux x64
[Process] running with PID: 22747
[Process] starting with 1 threads
[Database] You are running sqlite! Please keep in mind that we recommend setting up a dedicated database!
[Database] Connecting to sqlite db
[Database] This appears to be a fresh database. Synchronising.
[Database] Connected
[Config] Loading configuration...
[Connections] Loading configuration...
[Server] listening on port 3001
| 21:05:30 |
Emma [it/its] ⚡️ | hm, when i try to run it gets to "starting with 1 threads" and then throws
TypeError: Class extends value undefined is not a constructor or null | 21:15:19 |
Emma [it/its] ⚡️ | nvm, apparently because i told WebStorm to re-order imports... | 21:16:07 |
Emma [it/its] ⚡️ | do you have experience with TypeORM by chance? | 21:22:50 |
Emma [it/its] ⚡️ | if so, do you have any idea why reordering imports of entities would break stuff? | 21:23:04 |
Lily Foster | In reply to @emma:conduit.rory.gay do you have experience with TypeORM by chance? I do not, no. sorry :( | 21:26:36 |
Emma [it/its] ⚡️ | kinda wish i had a solution for that one but its so weird | 21:26:56 |
Lily Foster | In reply to @lily:lily.flowers
so this doesn't remove the openapi.json file, but this diff seems to build and run similarly in testing:
diff --git a/flake.nix b/flake.nix
index 71760eff..1391bca1 100644
--- a/flake.nix
+++ b/flake.nix
@@ -15,46 +15,10 @@
pname = "spacebar-server-ts";
src = ./.;
name = "spacebar-server-ts";
- nativeBuildInputs = with pkgs; [ python3 ];
npmDepsHash = "sha256-axzbsD+jOViIQ9+qFSX41j6harBL9vyaXDKdOSaPW8M=";
- makeCacheWritable = true;
postPatch = ''
substituteInPlace package.json --replace 'npx patch-package' '${pkgs.nodePackages.patch-package}/bin/patch-package'
'';
- installPhase = ''
- runHook preInstall
- set -x
- #remove packages not needed for production, or at least try to...
- npm prune --omit dev --no-save $npmInstallFlags "''${npmInstallFlagsArray[@]}" $npmFlags "''${npmFlagsArray[@]}"
- find node_modules -maxdepth 1 -type d -empty -delete
-
- mkdir -p $out/node_modules/
- cp -r node_modules/* $out/node_modules/
- cp -r dist/ $out/node_modules/@spacebar
- for i in dist/**/start.js
- do
- makeWrapper ${pkgs.nodejs-slim}/bin/node $out/bin/start-`dirname ''${i/dist\//}` --prefix NODE_PATH : $out/node_modules --add-flags $out/node_modules/@spacebar`dirname ''${i/dist/}`/start.js
- done
- set +x
- substituteInPlace package.json --replace 'dist/' 'node_modules/@spacebar/'
- find $out/node_modules/@spacebar/ -type f -name "*.js" | while read srcFile; do
- echo Patching imports in ''${srcFile/$out\/node_modules\/@spacebar//}...
- substituteInPlace $srcFile --replace 'require("./' 'require(__dirname + "/'
- substituteInPlace $srcFile --replace 'require("../' 'require(__dirname + "/../'
- substituteInPlace $srcFile --replace ', "assets"' ', "..", "assets"'
- #substituteInPlace $srcFile --replace 'require("@spacebar/' 'require("
- done
- set -x
- cp -r assets/ $out/
- cp package.json $out/
- rm -v $out/assets/openapi.json
- #rm -v $out/assets/schemas.json
-
- #debug utils:
- #cp $out/node_modules/@spacebar/ $out/build_output -r
- set +x
- runHook postInstall
- '';
};
devShell = pkgs.mkShell {
buildInputs = with pkgs; [
diff --git a/package.json b/package.json
index 83ec9dcc..e0dcf4c9 100644
--- a/package.json
+++ b/package.json
@@ -37,6 +37,16 @@
"imports": {
"#*": "./dist/*/index.js"
},
+ "files": [
+ "dist",
+ "assets"
+ ],
+ "bin": {
+ "start-bundle": "dist/bundle/start.js",
+ "start-api": "dist/api/start.js",
+ "start-cdn": "dist/cdn/start.js",
+ "start-gateway": "dist/gateway/start.js"
+ },
"homepage": "https://spacebar.chat",
"devDependencies": {
"@types/amqplib": "^0.8.2",
you might also want to add a substituteInPlace src/bundle/start.ts --replace 'execSync("git rev-parse HEAD").toString().trim()' '"${self.rev or "dirty"}"' to postPatch as well, so that way the pre-release commit hash shows up correctly and doesn't depend on running it from a git repo | 21:32:17 |
Emma [it/its] ⚡️ | didnt we just get rid of postPatch? | 21:32:43 |
Lily Foster | In reply to @emma:conduit.rory.gay didnt we just get rid of postPatch? no, i left it there in my diff | 21:34:24 |
Emma [it/its] ⚡️ | oh, the diff claimed it was removedd as far as i saw | 21:34:44 |
Lily Foster | i mostly just got rid of installPhase and used npm to handle the logic | 21:34:44 |
Emma [it/its] ⚡️ | oh wait nvm i confused it for installPhase | 21:34:56 |
Lily Foster | ah, yeah. it happens :) | 21:35:08 |
Emma [it/its] ⚡️ | thanks for the git patch thing btw ^^ | 21:35:21 |
Lily Foster | In reply to @emma:conduit.rory.gay thanks for the git patch thing btw ^^ i'm happy to help! i just noticed i was getting a fatal: not a git repository when running the start-bundle bin and found where git rev-parse HEAD was happening | 21:36:46 |
Emma [it/its] ⚡️ | ah | 21:36:58 |