@remotion/cloudrun 4.1.0-alpha10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.turbo/turbo-build.log +13 -0
- package/LICENSE.md +41 -0
- package/dist/admin/bundle-installer.d.ts +1 -0
- package/dist/admin/bundle-installer.js +32 -0
- package/dist/admin/bundle-renderLogic.d.ts +1 -0
- package/dist/admin/bundle-renderLogic.js +39 -0
- package/dist/api/check-if-service-exists.d.ts +18 -0
- package/dist/api/check-if-service-exists.js +49 -0
- package/dist/api/create-bucket.d.ts +13 -0
- package/dist/api/create-bucket.js +18 -0
- package/dist/api/delete-service.d.ts +12 -0
- package/dist/api/delete-service.js +19 -0
- package/dist/api/delete-site.d.ts +13 -0
- package/dist/api/delete-site.js +30 -0
- package/dist/api/deploy-service.d.ts +28 -0
- package/dist/api/deploy-service.js +90 -0
- package/dist/api/deploy-site.d.ts +35 -0
- package/dist/api/deploy-site.js +78 -0
- package/dist/api/download-file.d.ts +13 -0
- package/dist/api/download-file.js +30 -0
- package/dist/api/get-buckets.d.ts +10 -0
- package/dist/api/get-buckets.js +23 -0
- package/dist/api/get-or-create-bucket.d.ts +17 -0
- package/dist/api/get-or-create-bucket.js +42 -0
- package/dist/api/get-regions.d.ts +7 -0
- package/dist/api/get-regions.js +13 -0
- package/dist/api/get-service-info.d.ts +23 -0
- package/dist/api/get-service-info.js +34 -0
- package/dist/api/get-services.d.ts +14 -0
- package/dist/api/get-services.js +49 -0
- package/dist/api/get-sites.d.ts +23 -0
- package/dist/api/get-sites.js +49 -0
- package/dist/api/helpers/IService.d.ts +2 -0
- package/dist/api/helpers/IService.js +2 -0
- package/dist/api/helpers/construct-service-deploy-request.d.ts +32 -0
- package/dist/api/helpers/construct-service-deploy-request.js +36 -0
- package/dist/api/helpers/extract-mem-from-url.d.ts +1 -0
- package/dist/api/helpers/extract-mem-from-url.js +9 -0
- package/dist/api/helpers/extract-time-from-url.d.ts +1 -0
- package/dist/api/helpers/extract-time-from-url.js +13 -0
- package/dist/api/helpers/get-auth-client-for-url.d.ts +1 -0
- package/dist/api/helpers/get-auth-client-for-url.js +15 -0
- package/dist/api/helpers/get-cloud-logging-client.d.ts +1 -0
- package/dist/api/helpers/get-cloud-logging-client.js +15 -0
- package/dist/api/helpers/get-cloud-run-client.d.ts +2 -0
- package/dist/api/helpers/get-cloud-run-client.js +15 -0
- package/dist/api/helpers/get-cloud-storage-client.d.ts +2 -0
- package/dist/api/helpers/get-cloud-storage-client.js +14 -0
- package/dist/api/helpers/get-cloudrun-endpoint.d.ts +14 -0
- package/dist/api/helpers/get-cloudrun-endpoint.js +36 -0
- package/dist/api/helpers/get-resource-manager-client.d.ts +2 -0
- package/dist/api/helpers/get-resource-manager-client.js +15 -0
- package/dist/api/helpers/parse-service-name.d.ts +8 -0
- package/dist/api/helpers/parse-service-name.js +24 -0
- package/dist/api/iam-validation/testPermissions.d.ts +20 -0
- package/dist/api/iam-validation/testPermissions.js +48 -0
- package/dist/api/render-media-on-cloudrun.d.ts +78 -0
- package/dist/api/render-media-on-cloudrun.js +144 -0
- package/dist/api/render-still-on-cloudrun.d.ts +49 -0
- package/dist/api/render-still-on-cloudrun.js +76 -0
- package/dist/api/speculate-service-name.d.ts +13 -0
- package/dist/api/speculate-service-name.js +20 -0
- package/dist/api/test/service-names.test.d.ts +1 -0
- package/dist/api/test/service-names.test.js +28 -0
- package/dist/api/upload-dir.d.ts +18 -0
- package/dist/api/upload-dir.js +81 -0
- package/dist/cli/args.d.ts +19 -0
- package/dist/cli/args.js +11 -0
- package/dist/cli/commands/permissions.d.ts +2 -0
- package/dist/cli/commands/permissions.js +23 -0
- package/dist/cli/commands/regions.d.ts +2 -0
- package/dist/cli/commands/regions.js +10 -0
- package/dist/cli/commands/render/helpers/renderArgsCheck.d.ts +9 -0
- package/dist/cli/commands/render/helpers/renderArgsCheck.js +75 -0
- package/dist/cli/commands/render/index.d.ts +2 -0
- package/dist/cli/commands/render/index.js +228 -0
- package/dist/cli/commands/services/deploy.d.ts +2 -0
- package/dist/cli/commands/services/deploy.js +129 -0
- package/dist/cli/commands/services/index.d.ts +5 -0
- package/dist/cli/commands/services/index.js +64 -0
- package/dist/cli/commands/services/ls.d.ts +2 -0
- package/dist/cli/commands/services/ls.js +40 -0
- package/dist/cli/commands/services/rm.d.ts +2 -0
- package/dist/cli/commands/services/rm.js +63 -0
- package/dist/cli/commands/services/rmall.d.ts +2 -0
- package/dist/cli/commands/services/rmall.js +52 -0
- package/dist/cli/commands/sites/create.d.ts +2 -0
- package/dist/cli/commands/sites/create.js +138 -0
- package/dist/cli/commands/sites/index.d.ts +4 -0
- package/dist/cli/commands/sites/index.js +60 -0
- package/dist/cli/commands/sites/ls.d.ts +2 -0
- package/dist/cli/commands/sites/ls.js +40 -0
- package/dist/cli/commands/sites/rm.d.ts +2 -0
- package/dist/cli/commands/sites/rm.js +59 -0
- package/dist/cli/commands/sites/rmall.d.ts +2 -0
- package/dist/cli/commands/sites/rmall.js +38 -0
- package/dist/cli/commands/still.d.ts +2 -0
- package/dist/cli/commands/still.js +129 -0
- package/dist/cli/get-gcp-region.d.ts +2 -0
- package/dist/cli/get-gcp-region.js +19 -0
- package/dist/cli/help.d.ts +1 -0
- package/dist/cli/help.js +38 -0
- package/dist/cli/helpers/confirm.d.ts +4 -0
- package/dist/cli/helpers/confirm.js +12 -0
- package/dist/cli/helpers/date-string.d.ts +1 -0
- package/dist/cli/helpers/date-string.js +9 -0
- package/dist/cli/helpers/progress-bar.d.ts +23 -0
- package/dist/cli/helpers/progress-bar.js +81 -0
- package/dist/cli/helpers/quit.d.ts +1 -0
- package/dist/cli/helpers/quit.js +7 -0
- package/dist/cli/helpers/yes-or-no.d.ts +4 -0
- package/dist/cli/helpers/yes-or-no.js +44 -0
- package/dist/cli/index.d.ts +1 -0
- package/dist/cli/index.js +56 -0
- package/dist/cli/log.d.ts +26 -0
- package/dist/cli/log.js +5 -0
- package/dist/defaults.d.ts +1 -0
- package/dist/defaults.js +17 -0
- package/dist/functions/helpers/get-composition-from-body.d.ts +2 -0
- package/dist/functions/helpers/get-composition-from-body.js +27 -0
- package/dist/functions/helpers/io.d.ts +11 -0
- package/dist/functions/helpers/io.js +17 -0
- package/dist/functions/helpers/payloads.d.ts +300 -0
- package/dist/functions/helpers/payloads.js +104 -0
- package/dist/functions/index.d.ts +3 -0
- package/dist/functions/index.js +39 -0
- package/dist/functions/render-media-single-thread.d.ts +3 -0
- package/dist/functions/render-media-single-thread.js +103 -0
- package/dist/functions/render-still-single-thread.d.ts +3 -0
- package/dist/functions/render-still-single-thread.js +82 -0
- package/dist/index.d.ts +20 -0
- package/dist/index.js +31 -0
- package/dist/internals.d.ts +3 -0
- package/dist/internals.js +7 -0
- package/dist/pricing/gcp-regions.d.ts +5 -0
- package/dist/pricing/gcp-regions.js +77 -0
- package/dist/regions.d.ts +2 -0
- package/dist/regions.js +5 -0
- package/dist/shared/bundle-site.d.ts +2 -0
- package/dist/shared/bundle-site.js +5 -0
- package/dist/shared/constants.d.ts +13 -0
- package/dist/shared/constants.js +18 -0
- package/dist/shared/convert-to-serve-url.d.ts +4 -0
- package/dist/shared/convert-to-serve-url.js +14 -0
- package/dist/shared/docs-url.d.ts +1 -0
- package/dist/shared/docs-url.js +4 -0
- package/dist/shared/generate-service-name.d.ts +5 -0
- package/dist/shared/generate-service-name.js +20 -0
- package/dist/shared/get-etag.d.ts +1 -0
- package/dist/shared/get-etag.js +24 -0
- package/dist/shared/get-storage-operations.d.ts +10 -0
- package/dist/shared/get-storage-operations.js +36 -0
- package/dist/shared/make-storage-key.d.ts +1 -0
- package/dist/shared/make-storage-key.js +11 -0
- package/dist/shared/make-storage-url.d.ts +4 -0
- package/dist/shared/make-storage-url.js +7 -0
- package/dist/shared/random-hash.d.ts +3 -0
- package/dist/shared/random-hash.js +14 -0
- package/dist/shared/read-dir.d.ts +9 -0
- package/dist/shared/read-dir.js +57 -0
- package/dist/shared/sa-permissions.json +64 -0
- package/dist/shared/service-version-string.d.ts +1 -0
- package/dist/shared/service-version-string.js +8 -0
- package/dist/shared/validate-bucketname.d.ts +8 -0
- package/dist/shared/validate-bucketname.js +35 -0
- package/dist/shared/validate-cloudrun-url.d.ts +1 -0
- package/dist/shared/validate-cloudrun-url.js +10 -0
- package/dist/shared/validate-gcp-codec.d.ts +4 -0
- package/dist/shared/validate-gcp-codec.js +29 -0
- package/dist/shared/validate-gcp-region.d.ts +2 -0
- package/dist/shared/validate-gcp-region.js +10 -0
- package/dist/shared/validate-image-remotion-version.d.ts +1 -0
- package/dist/shared/validate-image-remotion-version.js +26 -0
- package/dist/shared/validate-privacy.d.ts +2 -0
- package/dist/shared/validate-privacy.js +12 -0
- package/dist/shared/validate-project-id.d.ts +1 -0
- package/dist/shared/validate-project-id.js +17 -0
- package/dist/shared/validate-region.d.ts +1 -0
- package/dist/shared/validate-region.js +15 -0
- package/dist/shared/validate-retries.d.ts +1 -0
- package/dist/shared/validate-retries.js +21 -0
- package/dist/shared/validate-serveurl.d.ts +1 -0
- package/dist/shared/validate-serveurl.js +30 -0
- package/dist/shared/validate-service-name.d.ts +1 -0
- package/dist/shared/validate-service-name.js +9 -0
- package/dist/shared/validate-site-name.d.ts +1 -0
- package/dist/shared/validate-site-name.js +17 -0
- package/package.json +57 -0
- package/readme.md +3 -0
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
|
|
2
|
+
> @remotion/cloudrun@4.0.10 build /Users/jonathanburger/remotion/packages/cloudrun
|
|
3
|
+
> tsc -d && cp src/shared/sa-permissions.json dist/shared/sa-permissions.json && pnpm run buildContainer && pnpm run tarInstaller
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
> @remotion/cloudrun@4.0.10 buildContainer /Users/jonathanburger/remotion/packages/cloudrun
|
|
7
|
+
> ts-node src/admin/bundle-renderLogic.ts
|
|
8
|
+
|
|
9
|
+
distribution bundled.
|
|
10
|
+
|
|
11
|
+
> @remotion/cloudrun@4.0.10 tarInstaller /Users/jonathanburger/remotion/packages/cloudrun
|
|
12
|
+
> ts-node src/admin/bundle-installer.ts
|
|
13
|
+
|
package/LICENSE.md
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# Remotion License
|
|
2
|
+
|
|
3
|
+
Depending on the type of your legal entity, you are granted permission to use Remotion for your project. Individuals and small companies are allowed to use Remotion to create videos for free (even commercial), while a company license is required for for-profit organizations of a certain size. This two-tier system was designed to ensure funding for this project while still allowing the source code to be available and the program to be free for most. Read below for the exact terms of use.
|
|
4
|
+
|
|
5
|
+
- [Free license](#free-license)
|
|
6
|
+
- [Company license](#company-license)
|
|
7
|
+
|
|
8
|
+
## Free license
|
|
9
|
+
|
|
10
|
+
Copyright © 2023 [Remotion](https://www.remotion.dev/)
|
|
11
|
+
|
|
12
|
+
### Eligibility
|
|
13
|
+
|
|
14
|
+
You are eligible to use Remotion for free if you are:
|
|
15
|
+
|
|
16
|
+
- an individual
|
|
17
|
+
- a for-profit organization with up to 3 employees
|
|
18
|
+
- a non-profit or not-for-profit organization
|
|
19
|
+
- evaluating whether Remotion is a good fit, and are not yet using it in a commercial way
|
|
20
|
+
|
|
21
|
+
### Allowed use cases
|
|
22
|
+
|
|
23
|
+
Permission is hereby granted, free of charge, to any person eligible for the "Free license", to use the software non-commercially or commercially for the purpose of creating videos and images and to modify the software to their own liking, for the purpose of fulfilling their custom use case or to contribute bug fixes or improvements back to Remotion.
|
|
24
|
+
|
|
25
|
+
### Disallowed use cases
|
|
26
|
+
|
|
27
|
+
It is not allowed to copy or modify Remotion code for the purpose of selling, renting, licensing, relicensing, or sublicensing your own derivate of Remotion.
|
|
28
|
+
|
|
29
|
+
### Warranty notice
|
|
30
|
+
|
|
31
|
+
The software is provided "as is", without warranty of any kind, express or implied, including but not limited to the warranties of merchantability, fitness for a particular purpose, and non-infringement. In no event shall the author or copyright holders be liable for any claim, damages or other liability, whether in an action of contract, tort or otherwise, arising from, out of or in connection with the software or the use or other dealings in the software.
|
|
32
|
+
|
|
33
|
+
### Support
|
|
34
|
+
|
|
35
|
+
Support is provided on a best-we-can-do basis via GitHub Issues and Discord.
|
|
36
|
+
|
|
37
|
+
## Company license
|
|
38
|
+
|
|
39
|
+
You are required to obtain a company license to use Remotion if you are not within the group of entities eligible for a free license. This license will enable you to use Remotion for the allowed use cases specified in the free license, and give you access to prioritized support (read the [Support Policy](/docs/support)).
|
|
40
|
+
|
|
41
|
+
Visit [companies.remotion.dev](https://companies.remotion.dev) for pricing and to buy a license.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const bundler_1 = require("@remotion/bundler");
|
|
7
|
+
const child_process_1 = require("child_process");
|
|
8
|
+
const fs_1 = require("fs");
|
|
9
|
+
const path_1 = __importDefault(require("path"));
|
|
10
|
+
const bundleInstaller = async () => {
|
|
11
|
+
const outdir = path_1.default.join(__dirname, '..', `build-installer`);
|
|
12
|
+
(0, fs_1.mkdirSync)(outdir, { recursive: true });
|
|
13
|
+
const bundlemjs = path_1.default.join(outdir, 'install.mjs');
|
|
14
|
+
await bundler_1.BundlerInternals.esbuild.build({
|
|
15
|
+
platform: 'node',
|
|
16
|
+
target: 'node18',
|
|
17
|
+
bundle: true,
|
|
18
|
+
outfile: bundlemjs,
|
|
19
|
+
format: 'esm',
|
|
20
|
+
entryPoints: [path_1.default.resolve(__dirname, '../gcpInstaller/install.mts')],
|
|
21
|
+
});
|
|
22
|
+
const tfoutfile = path_1.default.join(outdir, 'main.tf');
|
|
23
|
+
(0, fs_1.copyFileSync)(path_1.default.resolve(__dirname, '../gcpInstaller/main.tf'), tfoutfile);
|
|
24
|
+
const sapermissionsoutfile = path_1.default.join(outdir, 'sa-permissions.json');
|
|
25
|
+
(0, fs_1.copyFileSync)(path_1.default.resolve(__dirname, '../shared/sa-permissions.json'), sapermissionsoutfile);
|
|
26
|
+
(0, child_process_1.execSync)(`tar -cf ../gcpInstaller/gcpInstaller.tar -C . ${path_1.default.relative(outdir, bundlemjs)} ${path_1.default.relative(outdir, tfoutfile)} ${path_1.default.relative(outdir, sapermissionsoutfile)}`, {
|
|
27
|
+
stdio: 'inherit',
|
|
28
|
+
cwd: outdir,
|
|
29
|
+
});
|
|
30
|
+
(0, fs_1.rmSync)(outdir, { recursive: true });
|
|
31
|
+
};
|
|
32
|
+
bundleInstaller();
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const bundler_1 = require("@remotion/bundler");
|
|
7
|
+
const compositor_linux_x64_gnu_1 = require("@remotion/compositor-linux-x64-gnu");
|
|
8
|
+
const fs_1 = __importDefault(require("fs"));
|
|
9
|
+
const path_1 = __importDefault(require("path"));
|
|
10
|
+
const bundleRenderLogic = async () => {
|
|
11
|
+
var _a;
|
|
12
|
+
const outdir = path_1.default.join(__dirname, '../../container/dist');
|
|
13
|
+
fs_1.default.mkdirSync(outdir, {
|
|
14
|
+
recursive: true,
|
|
15
|
+
});
|
|
16
|
+
const outfile = path_1.default.join(outdir, 'index.js');
|
|
17
|
+
((_a = fs_1.default.rmSync) !== null && _a !== void 0 ? _a : fs_1.default.rmdirSync)(outdir, { recursive: true });
|
|
18
|
+
fs_1.default.mkdirSync(outdir, { recursive: true });
|
|
19
|
+
const template = require.resolve(path_1.default.join(__dirname, '../functions/index'));
|
|
20
|
+
await bundler_1.BundlerInternals.esbuild.build({
|
|
21
|
+
platform: 'node',
|
|
22
|
+
target: 'node18',
|
|
23
|
+
bundle: true,
|
|
24
|
+
outfile,
|
|
25
|
+
entryPoints: [template],
|
|
26
|
+
treeShaking: true,
|
|
27
|
+
external: [
|
|
28
|
+
'./compositor',
|
|
29
|
+
'./compositor.exe',
|
|
30
|
+
'./ffmpeg/remotion/bin/ffmpeg',
|
|
31
|
+
'./ffmpeg/remotion/bin/ffprobe',
|
|
32
|
+
],
|
|
33
|
+
});
|
|
34
|
+
const compositorFile = `${outdir}/compositor`;
|
|
35
|
+
fs_1.default.copyFileSync(compositor_linux_x64_gnu_1.binaryPath, compositorFile);
|
|
36
|
+
fs_1.default.cpSync(compositor_linux_x64_gnu_1.ffmpegCwd, `${outdir}/ffmpeg`, { recursive: true });
|
|
37
|
+
console.log('distribution bundled.');
|
|
38
|
+
};
|
|
39
|
+
bundleRenderLogic();
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { protos } from '@google-cloud/run';
|
|
2
|
+
export declare type CheckIfServiceExistsInput = {
|
|
3
|
+
projectID: string;
|
|
4
|
+
memoryLimit: string;
|
|
5
|
+
cpuLimit: string;
|
|
6
|
+
timeoutSeconds: number;
|
|
7
|
+
region: string;
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* @description Lists Cloud Run services in the project, and checks for a matching name.
|
|
11
|
+
* @param projectID GCP Project ID of Cloud Run service to check for.
|
|
12
|
+
* @param memoryLimit Memory limit of Cloud Run service to check for.
|
|
13
|
+
* @param cpuLimit CPU limit of Cloud Run service to check for.
|
|
14
|
+
* @param timeoutSeconds Timeout of Cloud Run service to check for.
|
|
15
|
+
* @param region The region of Cloud Run service to check for.
|
|
16
|
+
* @returns {Promise<protos.google.cloud.run.v2.IService>} Returns Service object.
|
|
17
|
+
*/
|
|
18
|
+
export declare const checkIfServiceExists: ({ memoryLimit, cpuLimit, timeoutSeconds, projectID, region, }: CheckIfServiceExistsInput) => Promise<protos.google.cloud.run.v2.IService | undefined>;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.checkIfServiceExists = void 0;
|
|
4
|
+
const cli_1 = require("@remotion/cli");
|
|
5
|
+
const log_1 = require("../cli/log");
|
|
6
|
+
const generate_service_name_1 = require("../shared/generate-service-name");
|
|
7
|
+
const validate_gcp_region_1 = require("../shared/validate-gcp-region");
|
|
8
|
+
const validate_project_id_1 = require("../shared/validate-project-id");
|
|
9
|
+
const get_cloud_run_client_1 = require("./helpers/get-cloud-run-client");
|
|
10
|
+
/**
|
|
11
|
+
* @description Lists Cloud Run services in the project, and checks for a matching name.
|
|
12
|
+
* @param projectID GCP Project ID of Cloud Run service to check for.
|
|
13
|
+
* @param memoryLimit Memory limit of Cloud Run service to check for.
|
|
14
|
+
* @param cpuLimit CPU limit of Cloud Run service to check for.
|
|
15
|
+
* @param timeoutSeconds Timeout of Cloud Run service to check for.
|
|
16
|
+
* @param region The region of Cloud Run service to check for.
|
|
17
|
+
* @returns {Promise<protos.google.cloud.run.v2.IService>} Returns Service object.
|
|
18
|
+
*/
|
|
19
|
+
const checkIfServiceExists = async ({ memoryLimit, cpuLimit, timeoutSeconds, projectID, region, }) => {
|
|
20
|
+
(0, validate_gcp_region_1.validateGcpRegion)(region);
|
|
21
|
+
(0, validate_project_id_1.validateProjectID)(projectID);
|
|
22
|
+
const parent = `projects/${projectID}/locations/${region}`;
|
|
23
|
+
const serviceName = (0, generate_service_name_1.generateServiceName)({
|
|
24
|
+
memoryLimit,
|
|
25
|
+
cpuLimit,
|
|
26
|
+
timeoutSeconds,
|
|
27
|
+
});
|
|
28
|
+
const cloudRunClient = (0, get_cloud_run_client_1.getCloudRunClient)();
|
|
29
|
+
// Run request
|
|
30
|
+
try {
|
|
31
|
+
const iterable = cloudRunClient.listServicesAsync({ parent });
|
|
32
|
+
for await (const response of iterable) {
|
|
33
|
+
if (response.name === `${parent}/services/${serviceName}`) {
|
|
34
|
+
return response;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
catch (e) {
|
|
39
|
+
if (e.code === 7) {
|
|
40
|
+
log_1.Log.error(cli_1.CliInternals.chalk.red(`Issue with ${parent}. The project either doesn't exist, or you don't have access to it.
|
|
41
|
+
`));
|
|
42
|
+
throw e;
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
45
|
+
throw e;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
exports.checkIfServiceExists = checkIfServiceExists;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { GcpRegion } from '../pricing/gcp-regions';
|
|
2
|
+
declare type CreateBucketInput = {
|
|
3
|
+
region: GcpRegion;
|
|
4
|
+
bucketName: string;
|
|
5
|
+
};
|
|
6
|
+
/**
|
|
7
|
+
* @description Creates a bucket for GCP Cloud Run.
|
|
8
|
+
* @param params.region The region for the bucket to be deployed to.
|
|
9
|
+
* @param params.bucketName The name of the bucket.
|
|
10
|
+
* @returns {Promise<void>} Nothing. Throws if the bucket creation failed.
|
|
11
|
+
*/
|
|
12
|
+
export declare const createBucket: ({ region, bucketName }: CreateBucketInput) => Promise<void>;
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createBucket = void 0;
|
|
4
|
+
const get_cloud_storage_client_1 = require("./helpers/get-cloud-storage-client");
|
|
5
|
+
/**
|
|
6
|
+
* @description Creates a bucket for GCP Cloud Run.
|
|
7
|
+
* @param params.region The region for the bucket to be deployed to.
|
|
8
|
+
* @param params.bucketName The name of the bucket.
|
|
9
|
+
* @returns {Promise<void>} Nothing. Throws if the bucket creation failed.
|
|
10
|
+
*/
|
|
11
|
+
const createBucket = async ({ region, bucketName }) => {
|
|
12
|
+
const cloudStorageClient = (0, get_cloud_storage_client_1.getCloudStorageClient)();
|
|
13
|
+
// metadata: https://googleapis.dev/nodejs/storage/latest/global.html#CreateBucketRequest
|
|
14
|
+
await cloudStorageClient.createBucket(bucketName, {
|
|
15
|
+
location: region,
|
|
16
|
+
});
|
|
17
|
+
};
|
|
18
|
+
exports.createBucket = createBucket;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export declare type DeleteServiceInput = {
|
|
2
|
+
serviceName: string;
|
|
3
|
+
region: string;
|
|
4
|
+
};
|
|
5
|
+
/**
|
|
6
|
+
* @description Deletes a service from GCP Cloud Run
|
|
7
|
+
* @see [Documentation](https://remotion.dev/docs/cloudrun/deleteservice)
|
|
8
|
+
* @param params.serviceName The name of the service to delete.
|
|
9
|
+
* @param params.region The region of the service to delete.
|
|
10
|
+
* @returns {Promise<void>} Nothing. Throws if the service failed to delete.
|
|
11
|
+
*/
|
|
12
|
+
export declare const deleteService: (params: DeleteServiceInput) => Promise<void>;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.deleteService = void 0;
|
|
4
|
+
const get_cloud_run_client_1 = require("./helpers/get-cloud-run-client");
|
|
5
|
+
/**
|
|
6
|
+
* @description Deletes a service from GCP Cloud Run
|
|
7
|
+
* @see [Documentation](https://remotion.dev/docs/cloudrun/deleteservice)
|
|
8
|
+
* @param params.serviceName The name of the service to delete.
|
|
9
|
+
* @param params.region The region of the service to delete.
|
|
10
|
+
* @returns {Promise<void>} Nothing. Throws if the service failed to delete.
|
|
11
|
+
*/
|
|
12
|
+
const deleteService = async (params) => {
|
|
13
|
+
const cloudRunClient = (0, get_cloud_run_client_1.getCloudRunClient)();
|
|
14
|
+
// Run request
|
|
15
|
+
await cloudRunClient.deleteService({
|
|
16
|
+
name: `projects/${process.env.REMOTION_GCP_PROJECT_ID}/locations/${params.region}/services/${params.serviceName}`,
|
|
17
|
+
});
|
|
18
|
+
};
|
|
19
|
+
exports.deleteService = deleteService;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export declare type DeleteSiteInput = {
|
|
2
|
+
bucketName: string;
|
|
3
|
+
siteName: string;
|
|
4
|
+
};
|
|
5
|
+
/**
|
|
6
|
+
*
|
|
7
|
+
* @description Deletes a deployed site from your Cloud Run bucket. The opposite of deploySite().
|
|
8
|
+
* @see [Documentation](https://remotion.dev/docs/cloudrun/deletesite)
|
|
9
|
+
* @param params.bucketName The name of the Cloud Storage bucket where the site resides in.
|
|
10
|
+
* @param params.siteName The ID of the site to delete.
|
|
11
|
+
* @returns {Promise<void>} Nothing. Throws if the site failed to delete.
|
|
12
|
+
*/
|
|
13
|
+
export declare const deleteSite: ({ bucketName, siteName, }: DeleteSiteInput) => Promise<void>;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.deleteSite = void 0;
|
|
4
|
+
const get_cloud_storage_client_1 = require("./helpers/get-cloud-storage-client");
|
|
5
|
+
/**
|
|
6
|
+
*
|
|
7
|
+
* @description Deletes a deployed site from your Cloud Run bucket. The opposite of deploySite().
|
|
8
|
+
* @see [Documentation](https://remotion.dev/docs/cloudrun/deletesite)
|
|
9
|
+
* @param params.bucketName The name of the Cloud Storage bucket where the site resides in.
|
|
10
|
+
* @param params.siteName The ID of the site to delete.
|
|
11
|
+
* @returns {Promise<void>} Nothing. Throws if the site failed to delete.
|
|
12
|
+
*/
|
|
13
|
+
const deleteSite = ({ bucketName, siteName, }) => {
|
|
14
|
+
return new Promise((resolve, reject) => {
|
|
15
|
+
const cloudStorageClient = (0, get_cloud_storage_client_1.getCloudStorageClient)();
|
|
16
|
+
cloudStorageClient.bucket(bucketName).deleteFiles({
|
|
17
|
+
prefix: `sites/${siteName}`,
|
|
18
|
+
}, (err) => {
|
|
19
|
+
if (err) {
|
|
20
|
+
// Reject the Promise with the error
|
|
21
|
+
reject(err);
|
|
22
|
+
}
|
|
23
|
+
else {
|
|
24
|
+
// Resolve the Promise with the desired result
|
|
25
|
+
resolve();
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
});
|
|
29
|
+
};
|
|
30
|
+
exports.deleteSite = deleteSite;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export declare type DeployServiceInput = {
|
|
2
|
+
performImageVersionValidation?: boolean;
|
|
3
|
+
memoryLimit?: string;
|
|
4
|
+
cpuLimit?: string;
|
|
5
|
+
timeoutSeconds?: number;
|
|
6
|
+
minInstances?: number;
|
|
7
|
+
maxInstances?: number;
|
|
8
|
+
projectID: string;
|
|
9
|
+
region: string;
|
|
10
|
+
};
|
|
11
|
+
export declare type DeployServiceOutput = {
|
|
12
|
+
fullName: string | null | undefined;
|
|
13
|
+
shortName: string | null | undefined;
|
|
14
|
+
uri: string;
|
|
15
|
+
alreadyExists: boolean;
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* @description Creates a Cloud Run service in your project that will be able to render a video in GCP.
|
|
19
|
+
* @link https://remotion.dev/docs/cloudrun/deployservice
|
|
20
|
+
* @param params.performImageVersionValidation Validate that an image exists in the public Artifact Registry that matches the Remotion Version. Default true
|
|
21
|
+
* @param params.memoryLimit Memory limit of Cloud Run service to deploy.
|
|
22
|
+
* @param params.cpuLimit CPU limit of Cloud Run service to deploy.
|
|
23
|
+
* @param params.timeoutSeconds After how many seconds the Cloud Run service should be killed if it does not end itself.
|
|
24
|
+
* @param params.projectID GCP Project ID to deploy the Cloud Run service to.
|
|
25
|
+
* @param params.region GCP region to deploy the Cloud Run service to.
|
|
26
|
+
* @returns {Promise<DeployServiceOutput>} See documentation for detailed structure
|
|
27
|
+
*/
|
|
28
|
+
export declare const deployService: ({ performImageVersionValidation, memoryLimit, cpuLimit, timeoutSeconds, minInstances, maxInstances, projectID, region, }: DeployServiceInput) => Promise<DeployServiceOutput>;
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.deployService = void 0;
|
|
4
|
+
const constants_1 = require("../shared/constants");
|
|
5
|
+
const generate_service_name_1 = require("../shared/generate-service-name");
|
|
6
|
+
const validate_gcp_region_1 = require("../shared/validate-gcp-region");
|
|
7
|
+
const validate_image_remotion_version_1 = require("../shared/validate-image-remotion-version");
|
|
8
|
+
const validate_project_id_1 = require("../shared/validate-project-id");
|
|
9
|
+
const check_if_service_exists_1 = require("./check-if-service-exists");
|
|
10
|
+
const construct_service_deploy_request_1 = require("./helpers/construct-service-deploy-request");
|
|
11
|
+
const get_cloud_run_client_1 = require("./helpers/get-cloud-run-client");
|
|
12
|
+
/**
|
|
13
|
+
* @description Creates a Cloud Run service in your project that will be able to render a video in GCP.
|
|
14
|
+
* @link https://remotion.dev/docs/cloudrun/deployservice
|
|
15
|
+
* @param params.performImageVersionValidation Validate that an image exists in the public Artifact Registry that matches the Remotion Version. Default true
|
|
16
|
+
* @param params.memoryLimit Memory limit of Cloud Run service to deploy.
|
|
17
|
+
* @param params.cpuLimit CPU limit of Cloud Run service to deploy.
|
|
18
|
+
* @param params.timeoutSeconds After how many seconds the Cloud Run service should be killed if it does not end itself.
|
|
19
|
+
* @param params.projectID GCP Project ID to deploy the Cloud Run service to.
|
|
20
|
+
* @param params.region GCP region to deploy the Cloud Run service to.
|
|
21
|
+
* @returns {Promise<DeployServiceOutput>} See documentation for detailed structure
|
|
22
|
+
*/
|
|
23
|
+
const deployService = async ({ performImageVersionValidation = true, memoryLimit, cpuLimit, timeoutSeconds, minInstances, maxInstances, projectID, region, }) => {
|
|
24
|
+
(0, validate_gcp_region_1.validateGcpRegion)(region);
|
|
25
|
+
(0, validate_project_id_1.validateProjectID)(projectID);
|
|
26
|
+
if (performImageVersionValidation) {
|
|
27
|
+
(0, validate_image_remotion_version_1.validateImageRemotionVersion)();
|
|
28
|
+
}
|
|
29
|
+
if (!memoryLimit) {
|
|
30
|
+
memoryLimit = '2Gi';
|
|
31
|
+
}
|
|
32
|
+
if (!cpuLimit) {
|
|
33
|
+
cpuLimit = '1.0';
|
|
34
|
+
}
|
|
35
|
+
if (!timeoutSeconds) {
|
|
36
|
+
timeoutSeconds = constants_1.DEFAULT_TIMEOUT;
|
|
37
|
+
}
|
|
38
|
+
if (!minInstances) {
|
|
39
|
+
minInstances = constants_1.DEFAULT_MIN_INSTANCES;
|
|
40
|
+
}
|
|
41
|
+
if (!maxInstances) {
|
|
42
|
+
maxInstances = constants_1.DEFAULT_MAX_INSTANCES;
|
|
43
|
+
}
|
|
44
|
+
const parent = `projects/${projectID}/locations/${region}`;
|
|
45
|
+
const cloudRunClient = (0, get_cloud_run_client_1.getCloudRunClient)();
|
|
46
|
+
const existingService = await (0, check_if_service_exists_1.checkIfServiceExists)({
|
|
47
|
+
memoryLimit,
|
|
48
|
+
cpuLimit,
|
|
49
|
+
timeoutSeconds,
|
|
50
|
+
projectID,
|
|
51
|
+
region,
|
|
52
|
+
});
|
|
53
|
+
const serviceName = (0, generate_service_name_1.generateServiceName)({
|
|
54
|
+
memoryLimit,
|
|
55
|
+
cpuLimit,
|
|
56
|
+
timeoutSeconds,
|
|
57
|
+
});
|
|
58
|
+
if (existingService) {
|
|
59
|
+
return {
|
|
60
|
+
fullName: `projects/${projectID}/locations/${region}/services/${serviceName}`,
|
|
61
|
+
shortName: serviceName,
|
|
62
|
+
uri: existingService.uri,
|
|
63
|
+
alreadyExists: true,
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
const request = {
|
|
67
|
+
parent,
|
|
68
|
+
service: {
|
|
69
|
+
// service structure: https://googleapis.dev/nodejs/run/latest/google.cloud.run.v2.IService.html
|
|
70
|
+
template: (0, construct_service_deploy_request_1.constructServiceTemplate)({
|
|
71
|
+
memoryLimit,
|
|
72
|
+
cpuLimit,
|
|
73
|
+
timeoutSeconds,
|
|
74
|
+
minInstances,
|
|
75
|
+
maxInstances,
|
|
76
|
+
}),
|
|
77
|
+
},
|
|
78
|
+
serviceId: serviceName,
|
|
79
|
+
};
|
|
80
|
+
// Run request
|
|
81
|
+
const [operation] = await cloudRunClient.createService(request);
|
|
82
|
+
const [response] = await operation.promise();
|
|
83
|
+
return {
|
|
84
|
+
fullName: response.name,
|
|
85
|
+
shortName: serviceName,
|
|
86
|
+
uri: response.uri,
|
|
87
|
+
alreadyExists: false,
|
|
88
|
+
};
|
|
89
|
+
};
|
|
90
|
+
exports.deployService = deployService;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { WebpackOverrideFn } from '@remotion/bundler';
|
|
2
|
+
import type { UploadDirProgress } from './upload-dir';
|
|
3
|
+
export declare type DeploySiteInput = {
|
|
4
|
+
entryPoint: string;
|
|
5
|
+
bucketName: string;
|
|
6
|
+
siteName?: string;
|
|
7
|
+
options?: {
|
|
8
|
+
onBundleProgress?: (progress: number) => void;
|
|
9
|
+
onUploadProgress?: (upload: UploadDirProgress) => void;
|
|
10
|
+
webpackOverride?: WebpackOverrideFn;
|
|
11
|
+
ignoreRegisterRootWarning?: boolean;
|
|
12
|
+
enableCaching?: boolean;
|
|
13
|
+
publicDir?: string | null;
|
|
14
|
+
rootDir?: string;
|
|
15
|
+
bypassBucketNameValidation?: boolean;
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
export declare type DeploySiteOutput = Promise<{
|
|
19
|
+
serveUrl: string;
|
|
20
|
+
siteName: string;
|
|
21
|
+
stats: {
|
|
22
|
+
uploadedFiles: number;
|
|
23
|
+
deletedFiles: number;
|
|
24
|
+
untouchedFiles: number;
|
|
25
|
+
};
|
|
26
|
+
}>;
|
|
27
|
+
/**
|
|
28
|
+
* @description Deploys a Remotion project to a GCP storage bucket to prepare it for rendering on Cloud Run.
|
|
29
|
+
* @link https://remotion.dev/docs/lambda/deploysite
|
|
30
|
+
* @param {string} params.entryPoint An absolute path to the entry file of your Remotion project.
|
|
31
|
+
* @param {string} params.bucketName The name of the bucket to deploy your project into.
|
|
32
|
+
* @param {string} params.siteName The name of the folder in which the project gets deployed to.
|
|
33
|
+
* @param {object} params.options Further options, see documentation page for this function.
|
|
34
|
+
*/
|
|
35
|
+
export declare const deploySite: ({ entryPoint, bucketName, siteName, options, }: DeploySiteInput) => DeploySiteOutput;
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.deploySite = void 0;
|
|
4
|
+
const io_1 = require("../functions/helpers/io");
|
|
5
|
+
const bundle_site_1 = require("../shared/bundle-site");
|
|
6
|
+
const constants_1 = require("../shared/constants");
|
|
7
|
+
const get_storage_operations_1 = require("../shared/get-storage-operations");
|
|
8
|
+
const make_storage_url_1 = require("../shared/make-storage-url");
|
|
9
|
+
const random_hash_1 = require("../shared/random-hash");
|
|
10
|
+
const validate_bucketname_1 = require("../shared/validate-bucketname");
|
|
11
|
+
const validate_site_name_1 = require("../shared/validate-site-name");
|
|
12
|
+
const get_cloud_storage_client_1 = require("./helpers/get-cloud-storage-client");
|
|
13
|
+
const upload_dir_1 = require("./upload-dir");
|
|
14
|
+
/**
|
|
15
|
+
* @description Deploys a Remotion project to a GCP storage bucket to prepare it for rendering on Cloud Run.
|
|
16
|
+
* @link https://remotion.dev/docs/lambda/deploysite
|
|
17
|
+
* @param {string} params.entryPoint An absolute path to the entry file of your Remotion project.
|
|
18
|
+
* @param {string} params.bucketName The name of the bucket to deploy your project into.
|
|
19
|
+
* @param {string} params.siteName The name of the folder in which the project gets deployed to.
|
|
20
|
+
* @param {object} params.options Further options, see documentation page for this function.
|
|
21
|
+
*/
|
|
22
|
+
const deploySite = async ({ entryPoint, bucketName, siteName, options, }) => {
|
|
23
|
+
var _a, _b, _c, _d;
|
|
24
|
+
(0, validate_bucketname_1.validateBucketName)(bucketName, { mustStartWithRemotion: true });
|
|
25
|
+
const siteId = siteName !== null && siteName !== void 0 ? siteName : (0, random_hash_1.randomHash)();
|
|
26
|
+
(0, validate_site_name_1.validateSiteName)(siteId);
|
|
27
|
+
const cloudStorageClient = (0, get_cloud_storage_client_1.getCloudStorageClient)();
|
|
28
|
+
// check if bucket exists
|
|
29
|
+
await cloudStorageClient.bucket(bucketName).get();
|
|
30
|
+
const subFolder = (0, constants_1.getSitesKey)(siteId);
|
|
31
|
+
// gcpLs is a function that lists all files in a bucket
|
|
32
|
+
const [files, bundled] = await Promise.all([
|
|
33
|
+
(0, io_1.cloudrunLs)({
|
|
34
|
+
bucketName,
|
|
35
|
+
prefix: subFolder,
|
|
36
|
+
}),
|
|
37
|
+
(0, bundle_site_1.bundleSite)({
|
|
38
|
+
publicPath: `/${bucketName}/${subFolder}/`,
|
|
39
|
+
webpackOverride: (_a = options === null || options === void 0 ? void 0 : options.webpackOverride) !== null && _a !== void 0 ? _a : ((f) => f),
|
|
40
|
+
enableCaching: (_b = options === null || options === void 0 ? void 0 : options.enableCaching) !== null && _b !== void 0 ? _b : true,
|
|
41
|
+
publicDir: options === null || options === void 0 ? void 0 : options.publicDir,
|
|
42
|
+
rootDir: options === null || options === void 0 ? void 0 : options.rootDir,
|
|
43
|
+
ignoreRegisterRootWarning: options === null || options === void 0 ? void 0 : options.ignoreRegisterRootWarning,
|
|
44
|
+
onProgress: (_c = options === null || options === void 0 ? void 0 : options.onBundleProgress) !== null && _c !== void 0 ? _c : (() => undefined),
|
|
45
|
+
entryPoint,
|
|
46
|
+
}),
|
|
47
|
+
]);
|
|
48
|
+
const { toDelete, toUpload, existingCount } = await (0, get_storage_operations_1.getStorageDiffOperations)({
|
|
49
|
+
objects: files,
|
|
50
|
+
bundle: bundled,
|
|
51
|
+
prefix: subFolder,
|
|
52
|
+
});
|
|
53
|
+
await Promise.all([
|
|
54
|
+
(0, upload_dir_1.uploadDir)({
|
|
55
|
+
bucket: bucketName,
|
|
56
|
+
localDir: bundled,
|
|
57
|
+
onProgress: (_d = options === null || options === void 0 ? void 0 : options.onUploadProgress) !== null && _d !== void 0 ? _d : (() => undefined),
|
|
58
|
+
keyPrefix: subFolder,
|
|
59
|
+
toUpload,
|
|
60
|
+
}),
|
|
61
|
+
Promise.all(toDelete.map((d) => {
|
|
62
|
+
return (0, io_1.cloudrunDeleteFile)({
|
|
63
|
+
bucketName,
|
|
64
|
+
key: d.name,
|
|
65
|
+
});
|
|
66
|
+
})),
|
|
67
|
+
]);
|
|
68
|
+
return {
|
|
69
|
+
serveUrl: (0, make_storage_url_1.makeStorageServeUrl)({ bucketName, subFolder }),
|
|
70
|
+
siteName: siteId,
|
|
71
|
+
stats: {
|
|
72
|
+
uploadedFiles: toUpload.length,
|
|
73
|
+
deletedFiles: toDelete.length,
|
|
74
|
+
untouchedFiles: existingCount,
|
|
75
|
+
},
|
|
76
|
+
};
|
|
77
|
+
};
|
|
78
|
+
exports.deploySite = deploySite;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @description Downloads a file from a GCP storage bucket.
|
|
3
|
+
* @see [Documentation](https://remotion.dev/docs/lambda/downloadmedia)
|
|
4
|
+
* @param params.bucketName The name of the bucket to download the file from.
|
|
5
|
+
* @param params.gsutilURI The Google Cloud Storage URL of the file to download.
|
|
6
|
+
* @param params.downloadName The name of the file once downloaded.
|
|
7
|
+
* @returns {void}
|
|
8
|
+
*/
|
|
9
|
+
export declare const downloadFile: ({ bucketName, gsutilURI, downloadName, }: {
|
|
10
|
+
bucketName: string;
|
|
11
|
+
gsutilURI: string;
|
|
12
|
+
downloadName: string;
|
|
13
|
+
}) => Promise<string>;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.downloadFile = void 0;
|
|
7
|
+
const fs_1 = __importDefault(require("fs"));
|
|
8
|
+
const get_cloud_storage_client_1 = require("./helpers/get-cloud-storage-client");
|
|
9
|
+
/**
|
|
10
|
+
* @description Downloads a file from a GCP storage bucket.
|
|
11
|
+
* @see [Documentation](https://remotion.dev/docs/lambda/downloadmedia)
|
|
12
|
+
* @param params.bucketName The name of the bucket to download the file from.
|
|
13
|
+
* @param params.gsutilURI The Google Cloud Storage URL of the file to download.
|
|
14
|
+
* @param params.downloadName The name of the file once downloaded.
|
|
15
|
+
* @returns {void}
|
|
16
|
+
*/
|
|
17
|
+
const downloadFile = async ({ bucketName, gsutilURI, downloadName, }) => {
|
|
18
|
+
const cloudStorageClient = (0, get_cloud_storage_client_1.getCloudStorageClient)();
|
|
19
|
+
const fileName = gsutilURI.replace(`gs://${bucketName}/`, '');
|
|
20
|
+
// check if out folder exists, if not, create it
|
|
21
|
+
if (!fs_1.default.existsSync('out')) {
|
|
22
|
+
fs_1.default.mkdirSync('out');
|
|
23
|
+
}
|
|
24
|
+
const destination = `out/${downloadName}`;
|
|
25
|
+
await cloudStorageClient.bucket(bucketName).file(fileName).download({
|
|
26
|
+
destination,
|
|
27
|
+
});
|
|
28
|
+
return destination;
|
|
29
|
+
};
|
|
30
|
+
exports.downloadFile = downloadFile;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { Bucket } from '@google-cloud/storage';
|
|
2
|
+
import type { GcpRegion } from '../pricing/gcp-regions';
|
|
3
|
+
/**
|
|
4
|
+
* @description Get a list of all buckets that were created by Remotion.
|
|
5
|
+
* @param params.region GCP region to check. If not passed, all regions will be checked.
|
|
6
|
+
* @returns {Promise<Bucket[]>} List of buckets returned by GCP.
|
|
7
|
+
*/
|
|
8
|
+
export declare const getRemotionStorageBuckets: (region: GcpRegion | 'all regions') => Promise<{
|
|
9
|
+
remotionBuckets: Bucket[];
|
|
10
|
+
}>;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getRemotionStorageBuckets = void 0;
|
|
4
|
+
const constants_1 = require("../shared/constants");
|
|
5
|
+
const get_cloud_storage_client_1 = require("./helpers/get-cloud-storage-client");
|
|
6
|
+
/**
|
|
7
|
+
* @description Get a list of all buckets that were created by Remotion.
|
|
8
|
+
* @param params.region GCP region to check. If not passed, all regions will be checked.
|
|
9
|
+
* @returns {Promise<Bucket[]>} List of buckets returned by GCP.
|
|
10
|
+
*/
|
|
11
|
+
const getRemotionStorageBuckets = async (region) => {
|
|
12
|
+
const cloudStorageClient = (0, get_cloud_storage_client_1.getCloudStorageClient)();
|
|
13
|
+
const [buckets] = await cloudStorageClient.getBuckets();
|
|
14
|
+
if (!buckets) {
|
|
15
|
+
return { remotionBuckets: [] };
|
|
16
|
+
}
|
|
17
|
+
let remotionBuckets = buckets.filter((b) => { var _a; return (_a = b.name) === null || _a === void 0 ? void 0 : _a.startsWith(constants_1.REMOTION_BUCKET_PREFIX); });
|
|
18
|
+
if (region !== 'all regions') {
|
|
19
|
+
remotionBuckets = buckets.filter((b) => b.metadata.location === region.toUpperCase());
|
|
20
|
+
}
|
|
21
|
+
return { remotionBuckets };
|
|
22
|
+
};
|
|
23
|
+
exports.getRemotionStorageBuckets = getRemotionStorageBuckets;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { GcpRegion } from '../pricing/gcp-regions';
|
|
2
|
+
export declare type GetOrCreateBucketInput = {
|
|
3
|
+
region: GcpRegion;
|
|
4
|
+
updateBucketState?: (state: 'Checking for existing bucket' | 'Creating new bucket' | 'Created bucket' | 'Using existing bucket') => void;
|
|
5
|
+
};
|
|
6
|
+
export declare type GetOrCreateBucketOutput = {
|
|
7
|
+
bucketName: string;
|
|
8
|
+
alreadyExisted: boolean;
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* @description Creates a bucket for Remotion Cloud Run in your GCP Project, in a particular region. If one already exists, it will get returned instead.
|
|
12
|
+
* @link https://remotion.dev/docs/cloudrun/getorcreatebucket
|
|
13
|
+
* @param params.region The region in which you want your Storage bucket to reside in.
|
|
14
|
+
* @param params.updateBucketState A function that gets called whenever the state of the bucket changes. This is useful for CLI updates.
|
|
15
|
+
* @returns {Promise<GetOrCreateBucketOutput>} An object containing the `bucketName`.
|
|
16
|
+
*/
|
|
17
|
+
export declare const getOrCreateBucket: (params: GetOrCreateBucketInput) => Promise<GetOrCreateBucketOutput>;
|