Skip to content

🎥 Make videos programmatically with React

ensure no lambda version mismatch gets published

Jonny Burgerd86c49078a77
diff --git a/packages/lambda/.npmignore b/packages/lambda/.npmignore
index 6fdeec6a7f..c0e8b8f216 100644
--- a/packages/lambda/.npmignore
+++ b/packages/lambda/.npmignore
@@ -6,3 +6,4 @@ tsconfig.tsbuildinfo
jest.config.js
*.tgz
.turbo
+ensure-version-match.js
diff --git a/packages/lambda/ensure-version-match.js b/packages/lambda/ensure-version-match.js
new file mode 100644
index 0000000000..20841fc1df
--- /dev/null
+++ b/packages/lambda/ensure-version-match.js
@@ -0,0 +1,19 @@
+const cp = require('node:child_process');
+const fs = require('node:fs');
+
+cp.execSync('unzip -o remotionlambda.zip -d extracted');
+const contents = fs.readFileSync('extracted/index.js', 'utf-8');
+fs.rmSync('extracted', {recursive: true});
+const [, inLambda] = contents.match(/CURRENT_VERSION = "(.*)"/);
+
+const inConstants = fs.readFileSync('dist/shared/constants.js', 'utf-8');
+const [, inPkg] = inConstants.match(/CURRENT_VERSION = '(.*)'/);
+
+if (inLambda !== inPkg) {
+ console.error(
+ `Version in Lambda is ${inLambda}, and in package ${inPkg}. Align the versions.`
+ );
+ process.exit(1);
+}
+
+console.log(`Lambda version ${inLambda} aligns.`);
diff --git a/packages/lambda/package.json b/packages/lambda/package.json
index d892d0896b..9fba5e29ff 100644
--- a/packages/lambda/package.json
+++ b/packages/lambda/package.json
@@ -9,6 +9,7 @@
},
"module": "true",
"scripts": {
+ "prepublish": "node ensure-version-match.js",
"testintegration": "jest src/test/integration --runInBand",
"lint": "eslint src --ext ts,tsx",
"test": "jest src/test/unit",