Skip to content

🎥 Make videos programmatically with React

make console test use getProjectId()

Alex Fernandez4b46d26ecca6
diff --git a/packages/cloudrun/src/api/test/make-console.test.ts b/packages/cloudrun/src/api/test/make-console.test.ts
new file mode 100644
index 0000000000..e885e1b3a2
--- /dev/null
+++ b/packages/cloudrun/src/api/test/make-console.test.ts
@@ -0,0 +1,37 @@
+import {beforeEach, expect, test} from 'vitest';
+import {makeConsoleUrl} from '../../cli/helpers/make-console-url';
+import {isInCloudTask} from '../../functions/helpers/is-in-cloud-task';
+
+beforeEach(() => {
+ delete process.env.GCLOUD_PROJECT;
+ delete process.env.REMOTION_GCP_PROJECT_ID;
+ delete process.env.K_CONFIGURATION;
+});
+
+test('app is in cloud tasks', () => {
+ process.env.GCLOUD_PROJECT = 'remotion-test-cloudtask';
+ process.env.K_CONFIGURATION = 'config';
+ const isInCloud = isInCloudTask();
+
+ expect(isInCloud).toBe(true);
+
+ const consoleUrl = makeConsoleUrl('asia-east1', 'test-name');
+
+ expect(consoleUrl).toBe(
+ 'https://console.cloud.google.com/run/detail/asia-east1/test-name/logs?project=remotion-test-cloudtask',
+ );
+});
+
+test('app is not in cloud tasks', () => {
+ process.env.GCLOUD_PROJECT = 'remotion-test';
+ process.env.K_CONFIGURATION = 'config';
+ const isInCloud = isInCloudTask();
+
+ expect(isInCloud).toBe(true);
+
+ const consoleUrl = makeConsoleUrl('asia-east1', 'test-name');
+
+ expect(consoleUrl).toBe(
+ 'https://console.cloud.google.com/run/detail/asia-east1/test-name/logs?project=remotion-test',
+ );
+});
diff --git a/packages/cloudrun/src/cli/helpers/make-console-url.ts b/packages/cloudrun/src/cli/helpers/make-console-url.ts
index 4d4ed00f43..69b34ee0c2 100644
--- a/packages/cloudrun/src/cli/helpers/make-console-url.ts
+++ b/packages/cloudrun/src/cli/helpers/make-console-url.ts
@@ -1,5 +1,6 @@
+import {getProjectId} from '../../functions/helpers/is-in-cloud-task';
import type {GcpRegion} from '../../pricing/gcp-regions';
export const makeConsoleUrl = (region: GcpRegion, shortName: string) => {
- return `https://console.cloud.google.com/run/detail/${region}/${shortName}/logs?project=${process.env.REMOTION_GCP_PROJECT_ID}`;
+ return `https://console.cloud.google.com/run/detail/${region}/${shortName}/logs?project=${getProjectId()}`;
};
diff --git a/packages/renderer/build.mjs b/packages/renderer/build.mjs
index cbc92e4291..7018f31b79 100644
--- a/packages/renderer/build.mjs
+++ b/packages/renderer/build.mjs
@@ -38,7 +38,7 @@ export const getTarget = () => {
return 'x86_64-pc-windows-gnu';
default:
throw new Error(
- `Unsupported architecture on Windows: ${process.arch}`
+ `Unsupported architecture on Windows: ${process.arch}`,
);
}
@@ -73,7 +73,7 @@ export const getTarget = () => {
default:
throw new Error(
- `Unsupported OS: ${process.platform}, architecture: ${process.arch}`
+ `Unsupported OS: ${process.platform}, architecture: ${process.arch}`,
);
}
};
@@ -140,14 +140,14 @@ const cloudrun = process.argv.includes('--cloudrun');
const lambda = process.argv.includes('--lambda');
if (!existsSync('toolchains') && all) {
throw new Error(
- 'Run "node install-toolchain.mjs" if you want to build all platforms'
+ 'Run "node install-toolchain.mjs" if you want to build all platforms',
);
}
for (const toolchain of toolchains) {
if (!existsSync(path.join('toolchains', toolchain)) && all) {
throw new Error(
- `Toolchain for ${toolchain} not found. Run "node install-toolchain.mjs" if you want to build all platforms`
+ `Toolchain for ${toolchain} not found. Run "node install-toolchain.mjs" if you want to build all platforms`,
);
}
}
@@ -159,7 +159,7 @@ const rustFfmpegSys = packages.find((p) => p.name === 'ffmpeg-sys-next');
if (!rustFfmpegSys) {
console.error(
- 'Could not find ffmpeg-sys-next when running cargo metadata --format-version=1'
+ 'Could not find ffmpeg-sys-next when running cargo metadata --format-version=1',
);
process.exit(1);
}
@@ -211,7 +211,7 @@ for (const arch of archs) {
? undefined
: path.join(
process.cwd(),
- 'toolchains/x86_64_gnu_toolchain/bin/x86_64-unknown-linux-gnu-gcc'
+ 'toolchains/x86_64_gnu_toolchain/bin/x86_64-unknown-linux-gnu-gcc',
),
CARGO_TARGET_X86_64_UNKNOWN_LINUX_MUSL_LINKER:
nativeArch === 'x86_64-unknown-linux-musl'
@@ -225,13 +225,13 @@ for (const arch of archs) {
copyDestinations[arch].dir,
'ffmpeg',
'remotion',
- 'lib'
+ 'lib',
);
const binDir = path.join(
copyDestinations[arch].dir,
'ffmpeg',
'remotion',
- 'bin'
+ 'bin',
);
const files = readdirSync(libDir);
for (const file of files) {
@@ -264,7 +264,7 @@ for (const arch of archs) {
path.join(copyDestinations[arch].dir, 'ffmpeg', 'remotion', 'include'),
{
recursive: true,
- }
+ },
);
rmSync(path.join(copyDestinations[arch].dir, 'ffmpeg', 'bindings.rs'), {
recursive: true,
@@ -278,12 +278,12 @@ for (const arch of archs) {
const filename = JSON.parse(output.toString('utf-8'))[0].filename.replace(
/^@remotion\//,
- 'remotion-'
+ 'remotion-',
);
const tgzPath = path.join(
process.cwd(),
copyDestinations[arch].dir,
- filename
+ filename,
);
const filesize = lstatSync(tgzPath).size;