Skip to content

Commit 6ba782c

Browse files
committed
update deno.lock and check deno version on build
1 parent 44938fd commit 6ba782c

2 files changed

Lines changed: 113 additions & 75 deletions

File tree

packages/apps-engine/deno-runtime/deno.lock

Lines changed: 69 additions & 69 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/apps-engine/scripts/deno-cache.js

Lines changed: 44 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,59 @@
11
const childProcess = require('child_process');
2+
const fs = require('fs');
23
const path = require('path');
34

5+
const SHELL_ERR_CMD_NOT_FOUND = 127;
6+
7+
/**
8+
* Matches 'deno 2.3.1' or 'Deno 2.7.11-alpha3.24' or even 'some deno and-anything in between 1.43.5' (as long as everything is in the same line)
9+
* and extracts the correct version string from those ('2.3.1', '2.7.11' and '1.43.5' respectively).
10+
*
11+
* Doesn't match 'denoing 2.3.1' or 'deno2.3.1' or 'mydeno 2.7.11alpha3.24' or 'deno\n1.43.5'
12+
*/
13+
const extractDenoVersion = (input) => /\bdeno\b.*\b(?<version>\d+\.\d+\.\d+)(?<prerelease>-[\w.-]+)?\b/i.exec(input)?.groups?.version;
14+
415
try {
5-
childProcess.execSync('deno info');
16+
const toolVersionsPath = path.resolve(__dirname, '..', '..', '..', '.tool-versions');
17+
const denoToolVersion = extractDenoVersion(fs.readFileSync(toolVersionsPath).toString());
18+
19+
if (!denoToolVersion) {
20+
throw new Error(`Invalid Deno version in ${toolVersionsPath}, aborting...`);
21+
}
22+
23+
const installedVersion = extractDenoVersion(childProcess.execSync('deno --version').toString());
24+
25+
if (!installedVersion) {
26+
throw new Error(
27+
`Couldn't determine version of installed Deno. Try validating the version with 'deno --version' and make sure it is a valid Deno installation`,
28+
);
29+
}
30+
31+
if (installedVersion !== denoToolVersion) {
32+
throw new Error(`Incorrect Deno version. Required '${denoToolVersion}', found '${installedVersion}'`);
33+
}
634
} catch (e) {
7-
console.error(
8-
'Could not execute "deno" in the system. It is now a requirement for the Apps-Engine framework, and Rocket.Chat apps will not work without it.\n',
9-
'Make sure to install Deno and run the installation process for the Apps-Engine again. More info on https://docs.deno.com/runtime/manual/getting_started/installation',
10-
);
35+
if (e.status === SHELL_ERR_CMD_NOT_FOUND) {
36+
console.error(
37+
new Error(
38+
[
39+
'Could not execute "deno" in the system. It is now a requirement for the Apps-Engine framework, and Rocket.Chat apps will not work without it.',
40+
'Make sure to install Deno and run the installation process for the Apps-Engine again. More info on https://docs.deno.com/runtime/manual/getting_started/installation',
41+
].join('\n'),
42+
{ cause: e },
43+
),
44+
);
45+
} else {
46+
console.error(e);
47+
}
48+
1149
process.exit(1);
1250
}
1351

1452
const rootPath = path.join(__dirname, '..');
1553
const denoRuntimePath = path.join(rootPath, 'deno-runtime');
1654
const DENO_DIR = process.env.DENO_DIR ?? path.join(rootPath, '.deno-cache');
1755

18-
childProcess.execSync('deno cache main.ts', {
56+
childProcess.execSync('deno install --frozen --entrypoint main.ts', {
1957
cwd: denoRuntimePath,
2058
env: {
2159
...process.env,

0 commit comments

Comments
 (0)