Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: improve package installation and deno caching #786

Merged
merged 1 commit into from
Jul 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ jspm_packages
.npm

.deno
.deno-cache

# Optional REPL history
.node_repl_history
Expand Down
7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"test:node": "NODE_ENV=test ts-node ./tests/runner.ts",
"test:deno": "cd deno-runtime && deno task test",
"gen-doc": "typedoc",
"postinstall": "cd deno-runtime && deno cache main.ts && deno test --no-check --no-run"
"postinstall": "node scripts/postinstall.js"
},
"repository": {
"type": "git",
Expand All @@ -32,10 +32,11 @@
],
"files": [
"client/**",
"server/**",
"definition/**",
"deno-runtime/**",
"lib/**",
"deno-runtime/**"
"scripts/**",
"server/**"
],
"author": {
"name": "Rocket.Chat",
Expand Down
16 changes: 16 additions & 0 deletions scripts/postinstall.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
const childProcess = require('child_process');
const path = require('path');

// Find executable installed by deno-bin
const executablePath = path.join(require.resolve('deno-bin'), '..', 'bin', 'deno');

const rootPath = path.join(__dirname, '..');
const DENO_DIR = path.join(rootPath, '.deno-cache');

childProcess.spawnSync(executablePath, ['cache', 'main.ts'], {
cwd: path.join(rootPath, 'deno-runtime'),
env: {
DENO_DIR,
},
stdio: 'inherit',
});
3 changes: 2 additions & 1 deletion src/server/runtime/deno/AppsEngineDenoRuntime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ export class DenoRuntimeSubprocessController extends EventEmitter {
const denoWrapperPath = getDenoWrapperPath();
// During development, the appsEngineDir is enough to run the deno process
const appsEngineDir = path.dirname(path.join(denoWrapperPath, '..'));
const DENO_DIR = path.join(appsEngineDir, '.deno-cache');
// When running in production, we're likely inside a node_modules which the Deno
// process must be able to read in order to include files that use NPM packages
const parentNodeModulesDir = path.dirname(path.join(appsEngineDir, '..'));
Expand All @@ -150,7 +151,7 @@ export class DenoRuntimeSubprocessController extends EventEmitter {
this.appPackage.info.id,
];

this.deno = child_process.spawn(denoExePath, options, { env: null });
this.deno = child_process.spawn(denoExePath, options, { env: { DENO_DIR } });
this.messenger.setReceiver(this.deno);
this.livenessManager.attach(this.deno);

Expand Down
2 changes: 1 addition & 1 deletion tsconfig-lint.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
"compilerOptions": {
"allowJs": true
},
"include": ["./src/**/*", "./tests/**/*", "./gulpfile.js"]
"include": ["./scripts/*", "./src/**/*", "./tests/**/*", "./gulpfile.js"]
}
Loading