@remotion/cloudrun 4.0.18

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.
Files changed (193) hide show
  1. package/.turbo/turbo-build.log +13 -0
  2. package/LICENSE.md +41 -0
  3. package/dist/admin/bundle-installer.d.ts +1 -0
  4. package/dist/admin/bundle-installer.js +32 -0
  5. package/dist/admin/bundle-renderLogic.d.ts +1 -0
  6. package/dist/admin/bundle-renderLogic.js +39 -0
  7. package/dist/api/check-if-service-exists.d.ts +18 -0
  8. package/dist/api/check-if-service-exists.js +46 -0
  9. package/dist/api/create-bucket.d.ts +13 -0
  10. package/dist/api/create-bucket.js +18 -0
  11. package/dist/api/delete-service.d.ts +12 -0
  12. package/dist/api/delete-service.js +19 -0
  13. package/dist/api/delete-site.d.ts +13 -0
  14. package/dist/api/delete-site.js +30 -0
  15. package/dist/api/deploy-service.d.ts +28 -0
  16. package/dist/api/deploy-service.js +90 -0
  17. package/dist/api/deploy-site.d.ts +35 -0
  18. package/dist/api/deploy-site.js +78 -0
  19. package/dist/api/download-file.d.ts +12 -0
  20. package/dist/api/download-file.js +29 -0
  21. package/dist/api/get-buckets.d.ts +10 -0
  22. package/dist/api/get-buckets.js +23 -0
  23. package/dist/api/get-or-create-bucket.d.ts +17 -0
  24. package/dist/api/get-or-create-bucket.js +42 -0
  25. package/dist/api/get-regions.d.ts +7 -0
  26. package/dist/api/get-regions.js +13 -0
  27. package/dist/api/get-service-info.d.ts +23 -0
  28. package/dist/api/get-service-info.js +34 -0
  29. package/dist/api/get-services.d.ts +14 -0
  30. package/dist/api/get-services.js +49 -0
  31. package/dist/api/get-sites.d.ts +23 -0
  32. package/dist/api/get-sites.js +49 -0
  33. package/dist/api/helpers/IService.d.ts +2 -0
  34. package/dist/api/helpers/IService.js +2 -0
  35. package/dist/api/helpers/construct-service-deploy-request.d.ts +32 -0
  36. package/dist/api/helpers/construct-service-deploy-request.js +36 -0
  37. package/dist/api/helpers/extract-mem-from-url.d.ts +1 -0
  38. package/dist/api/helpers/extract-mem-from-url.js +9 -0
  39. package/dist/api/helpers/extract-time-from-url.d.ts +1 -0
  40. package/dist/api/helpers/extract-time-from-url.js +13 -0
  41. package/dist/api/helpers/get-auth-client-for-url.d.ts +1 -0
  42. package/dist/api/helpers/get-auth-client-for-url.js +15 -0
  43. package/dist/api/helpers/get-cloud-logging-client.d.ts +1 -0
  44. package/dist/api/helpers/get-cloud-logging-client.js +15 -0
  45. package/dist/api/helpers/get-cloud-run-client.d.ts +2 -0
  46. package/dist/api/helpers/get-cloud-run-client.js +15 -0
  47. package/dist/api/helpers/get-cloud-storage-client.d.ts +2 -0
  48. package/dist/api/helpers/get-cloud-storage-client.js +14 -0
  49. package/dist/api/helpers/get-cloudrun-endpoint.d.ts +6 -0
  50. package/dist/api/helpers/get-cloudrun-endpoint.js +28 -0
  51. package/dist/api/helpers/get-resource-manager-client.d.ts +2 -0
  52. package/dist/api/helpers/get-resource-manager-client.js +15 -0
  53. package/dist/api/helpers/parse-service-name.d.ts +8 -0
  54. package/dist/api/helpers/parse-service-name.js +24 -0
  55. package/dist/api/iam-validation/testPermissions.d.ts +20 -0
  56. package/dist/api/iam-validation/testPermissions.js +48 -0
  57. package/dist/api/render-media-on-cloudrun.d.ts +78 -0
  58. package/dist/api/render-media-on-cloudrun.js +144 -0
  59. package/dist/api/render-still-on-cloudrun.d.ts +49 -0
  60. package/dist/api/render-still-on-cloudrun.js +76 -0
  61. package/dist/api/speculate-service-name.d.ts +13 -0
  62. package/dist/api/speculate-service-name.js +20 -0
  63. package/dist/api/test/service-names.test.d.ts +1 -0
  64. package/dist/api/test/service-names.test.js +28 -0
  65. package/dist/api/upload-dir.d.ts +18 -0
  66. package/dist/api/upload-dir.js +81 -0
  67. package/dist/cli/args.d.ts +19 -0
  68. package/dist/cli/args.js +11 -0
  69. package/dist/cli/commands/permissions.d.ts +2 -0
  70. package/dist/cli/commands/permissions.js +23 -0
  71. package/dist/cli/commands/regions.d.ts +2 -0
  72. package/dist/cli/commands/regions.js +10 -0
  73. package/dist/cli/commands/render/helpers/renderArgsCheck.d.ts +9 -0
  74. package/dist/cli/commands/render/helpers/renderArgsCheck.js +75 -0
  75. package/dist/cli/commands/render/index.d.ts +2 -0
  76. package/dist/cli/commands/render/index.js +227 -0
  77. package/dist/cli/commands/render/renderMedia.d.ts +2 -0
  78. package/dist/cli/commands/render/renderMedia.js +156 -0
  79. package/dist/cli/commands/render/renderStill.d.ts +2 -0
  80. package/dist/cli/commands/render/renderStill.js +123 -0
  81. package/dist/cli/commands/services/deploy.d.ts +2 -0
  82. package/dist/cli/commands/services/deploy.js +129 -0
  83. package/dist/cli/commands/services/index.d.ts +5 -0
  84. package/dist/cli/commands/services/index.js +64 -0
  85. package/dist/cli/commands/services/ls.d.ts +2 -0
  86. package/dist/cli/commands/services/ls.js +40 -0
  87. package/dist/cli/commands/services/rm.d.ts +2 -0
  88. package/dist/cli/commands/services/rm.js +63 -0
  89. package/dist/cli/commands/services/rmall.d.ts +2 -0
  90. package/dist/cli/commands/services/rmall.js +52 -0
  91. package/dist/cli/commands/sites/create.d.ts +2 -0
  92. package/dist/cli/commands/sites/create.js +138 -0
  93. package/dist/cli/commands/sites/index.d.ts +4 -0
  94. package/dist/cli/commands/sites/index.js +60 -0
  95. package/dist/cli/commands/sites/ls.d.ts +2 -0
  96. package/dist/cli/commands/sites/ls.js +40 -0
  97. package/dist/cli/commands/sites/rm.d.ts +2 -0
  98. package/dist/cli/commands/sites/rm.js +59 -0
  99. package/dist/cli/commands/sites/rmall.d.ts +2 -0
  100. package/dist/cli/commands/sites/rmall.js +38 -0
  101. package/dist/cli/commands/still.d.ts +2 -0
  102. package/dist/cli/commands/still.js +129 -0
  103. package/dist/cli/get-gcp-region.d.ts +2 -0
  104. package/dist/cli/get-gcp-region.js +19 -0
  105. package/dist/cli/help.d.ts +1 -0
  106. package/dist/cli/help.js +38 -0
  107. package/dist/cli/helpers/confirm.d.ts +4 -0
  108. package/dist/cli/helpers/confirm.js +12 -0
  109. package/dist/cli/helpers/date-string.d.ts +1 -0
  110. package/dist/cli/helpers/date-string.js +9 -0
  111. package/dist/cli/helpers/progress-bar.d.ts +23 -0
  112. package/dist/cli/helpers/progress-bar.js +81 -0
  113. package/dist/cli/helpers/quit.d.ts +1 -0
  114. package/dist/cli/helpers/quit.js +7 -0
  115. package/dist/cli/helpers/yes-or-no.d.ts +4 -0
  116. package/dist/cli/helpers/yes-or-no.js +44 -0
  117. package/dist/cli/index.d.ts +1 -0
  118. package/dist/cli/index.js +56 -0
  119. package/dist/cli/log.d.ts +26 -0
  120. package/dist/cli/log.js +5 -0
  121. package/dist/defaults.d.ts +1 -0
  122. package/dist/defaults.js +17 -0
  123. package/dist/functions/helpers/get-composition-from-body.d.ts +2 -0
  124. package/dist/functions/helpers/get-composition-from-body.js +27 -0
  125. package/dist/functions/helpers/io.d.ts +11 -0
  126. package/dist/functions/helpers/io.js +17 -0
  127. package/dist/functions/helpers/payloads.d.ts +300 -0
  128. package/dist/functions/helpers/payloads.js +104 -0
  129. package/dist/functions/index.d.ts +3 -0
  130. package/dist/functions/index.js +39 -0
  131. package/dist/functions/render-media-single-thread.d.ts +3 -0
  132. package/dist/functions/render-media-single-thread.js +103 -0
  133. package/dist/functions/render-still-single-thread.d.ts +3 -0
  134. package/dist/functions/render-still-single-thread.js +82 -0
  135. package/dist/index.d.ts +20 -0
  136. package/dist/index.js +31 -0
  137. package/dist/internals.d.ts +3 -0
  138. package/dist/internals.js +7 -0
  139. package/dist/pricing/gcp-regions.d.ts +2 -0
  140. package/dist/pricing/gcp-regions.js +40 -0
  141. package/dist/regions.d.ts +2 -0
  142. package/dist/regions.js +5 -0
  143. package/dist/shared/bundle-site.d.ts +2 -0
  144. package/dist/shared/bundle-site.js +5 -0
  145. package/dist/shared/constants.d.ts +13 -0
  146. package/dist/shared/constants.js +18 -0
  147. package/dist/shared/convert-to-serve-url.d.ts +4 -0
  148. package/dist/shared/convert-to-serve-url.js +14 -0
  149. package/dist/shared/docs-url.d.ts +1 -0
  150. package/dist/shared/docs-url.js +4 -0
  151. package/dist/shared/generate-service-name.d.ts +5 -0
  152. package/dist/shared/generate-service-name.js +20 -0
  153. package/dist/shared/get-etag.d.ts +1 -0
  154. package/dist/shared/get-etag.js +24 -0
  155. package/dist/shared/get-storage-operations.d.ts +10 -0
  156. package/dist/shared/get-storage-operations.js +36 -0
  157. package/dist/shared/make-storage-key.d.ts +1 -0
  158. package/dist/shared/make-storage-key.js +11 -0
  159. package/dist/shared/make-storage-url.d.ts +4 -0
  160. package/dist/shared/make-storage-url.js +7 -0
  161. package/dist/shared/random-hash.d.ts +3 -0
  162. package/dist/shared/random-hash.js +14 -0
  163. package/dist/shared/read-dir.d.ts +9 -0
  164. package/dist/shared/read-dir.js +57 -0
  165. package/dist/shared/sa-permissions.json +64 -0
  166. package/dist/shared/service-version-string.d.ts +1 -0
  167. package/dist/shared/service-version-string.js +8 -0
  168. package/dist/shared/validate-bucketname.d.ts +8 -0
  169. package/dist/shared/validate-bucketname.js +35 -0
  170. package/dist/shared/validate-cloudrun-url.d.ts +1 -0
  171. package/dist/shared/validate-cloudrun-url.js +10 -0
  172. package/dist/shared/validate-gcp-codec.d.ts +4 -0
  173. package/dist/shared/validate-gcp-codec.js +29 -0
  174. package/dist/shared/validate-gcp-region.d.ts +2 -0
  175. package/dist/shared/validate-gcp-region.js +10 -0
  176. package/dist/shared/validate-image-remotion-version.d.ts +1 -0
  177. package/dist/shared/validate-image-remotion-version.js +26 -0
  178. package/dist/shared/validate-privacy.d.ts +2 -0
  179. package/dist/shared/validate-privacy.js +12 -0
  180. package/dist/shared/validate-project-id.d.ts +1 -0
  181. package/dist/shared/validate-project-id.js +17 -0
  182. package/dist/shared/validate-region.d.ts +1 -0
  183. package/dist/shared/validate-region.js +15 -0
  184. package/dist/shared/validate-retries.d.ts +1 -0
  185. package/dist/shared/validate-retries.js +21 -0
  186. package/dist/shared/validate-serveurl.d.ts +1 -0
  187. package/dist/shared/validate-serveurl.js +30 -0
  188. package/dist/shared/validate-service-name.d.ts +1 -0
  189. package/dist/shared/validate-service-name.js +9 -0
  190. package/dist/shared/validate-site-name.d.ts +1 -0
  191. package/dist/shared/validate-site-name.js +17 -0
  192. package/package.json +56 -0
  193. package/readme.md +3 -0
@@ -0,0 +1,129 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.cloudRunDeploySubcommand = exports.CLOUD_RUN_DEPLOY_SUBCOMMAND = void 0;
4
+ const cli_1 = require("@remotion/cli");
5
+ const version_1 = require("remotion/version");
6
+ const _1 = require(".");
7
+ const deploy_service_1 = require("../../../api/deploy-service");
8
+ const constants_1 = require("../../../shared/constants");
9
+ const generate_service_name_1 = require("../../../shared/generate-service-name");
10
+ const validate_gcp_region_1 = require("../../../shared/validate-gcp-region");
11
+ const validate_image_remotion_version_1 = require("../../../shared/validate-image-remotion-version");
12
+ const args_1 = require("../../args");
13
+ const get_gcp_region_1 = require("../../get-gcp-region");
14
+ const quit_1 = require("../../helpers/quit");
15
+ const log_1 = require("../../log");
16
+ exports.CLOUD_RUN_DEPLOY_SUBCOMMAND = 'deploy';
17
+ const cloudRunDeploySubcommand = async () => {
18
+ var _a, _b, _c, _d, _e;
19
+ const region = (0, get_gcp_region_1.getGcpRegion)();
20
+ const projectID = process.env.REMOTION_GCP_PROJECT_ID;
21
+ const memoryLimit = String((_a = args_1.parsedCloudrunCli.memoryLimit) !== null && _a !== void 0 ? _a : '2Gi');
22
+ const cpuLimit = String((_b = args_1.parsedCloudrunCli.cpuLimit) !== null && _b !== void 0 ? _b : '1.0');
23
+ const minInstances = String((_c = args_1.parsedCloudrunCli.minInstances) !== null && _c !== void 0 ? _c : constants_1.DEFAULT_MIN_INSTANCES);
24
+ const maxInstances = String((_d = args_1.parsedCloudrunCli.maxInstances) !== null && _d !== void 0 ? _d : constants_1.DEFAULT_MAX_INSTANCES);
25
+ const timeoutSeconds = (_e = args_1.parsedCloudrunCli.timeoutSeconds) !== null && _e !== void 0 ? _e : constants_1.DEFAULT_TIMEOUT;
26
+ if (!cli_1.CliInternals.quietFlagProvided()) {
27
+ log_1.Log.info(cli_1.CliInternals.chalk.gray(`
28
+ Validating Deployment of Cloud Run Service:
29
+
30
+ ${[
31
+ 'Remotion Version: '.padEnd(_1.LEFT_COL, ' ') + ' ' + version_1.VERSION,
32
+ 'Memory Limit: '.padEnd(_1.LEFT_COL, ' ') + ' ' + memoryLimit,
33
+ 'CPU Limit: '.padEnd(_1.LEFT_COL, ' ') + ' ' + cpuLimit,
34
+ 'Minimum Instances: '.padEnd(_1.LEFT_COL, ' ') + ' ' + minInstances,
35
+ 'Maximum Instances: '.padEnd(_1.LEFT_COL, ' ') + ' ' + maxInstances,
36
+ 'CPU Limit: '.padEnd(_1.LEFT_COL, ' ') + ' ' + cpuLimit,
37
+ 'Timeout: '.padEnd(_1.LEFT_COL, ' ') + ' ' + timeoutSeconds,
38
+ 'Project Name: '.padEnd(_1.LEFT_COL, ' ') + ' ' + projectID,
39
+ 'Region: '.padEnd(_1.LEFT_COL, ' ') + ' ' + region,
40
+ ].join('\n')}
41
+ `.trim()));
42
+ log_1.Log.info();
43
+ }
44
+ (0, validate_gcp_region_1.validateGcpRegion)(region);
45
+ await (0, validate_image_remotion_version_1.validateImageRemotionVersion)();
46
+ if (projectID === undefined) {
47
+ log_1.Log.error(`REMOTION_GCP_PROJECT_ID not found in the .env file.`);
48
+ (0, quit_1.quit)(0);
49
+ }
50
+ // if no existing service, deploy new service
51
+ if (!cli_1.CliInternals.quietFlagProvided()) {
52
+ log_1.Log.info(cli_1.CliInternals.chalk.white('\nDeploying Cloud Run Service...'));
53
+ }
54
+ try {
55
+ const deployResult = await (0, deploy_service_1.deployService)({
56
+ performImageVersionValidation: false,
57
+ memoryLimit,
58
+ cpuLimit,
59
+ timeoutSeconds,
60
+ projectID,
61
+ region,
62
+ });
63
+ if (!deployResult.fullName) {
64
+ log_1.Log.error('full service name not returned from Cloud Run API.');
65
+ throw new Error(JSON.stringify(deployResult));
66
+ }
67
+ if (!deployResult.shortName) {
68
+ log_1.Log.error('short service name not returned from Cloud Run API.');
69
+ throw new Error(JSON.stringify(deployResult));
70
+ }
71
+ if (!deployResult.alreadyExists && !deployResult.uri) {
72
+ log_1.Log.error('service uri not returned from Cloud Run API.');
73
+ }
74
+ const consoleUrl = `https://console.cloud.google.com/run/detail/${region}/${deployResult.shortName}/logs`;
75
+ if (deployResult.alreadyExists) {
76
+ log_1.Log.info();
77
+ if (cli_1.CliInternals.quietFlagProvided()) {
78
+ cli_1.CliInternals.Log.info(deployResult.shortName);
79
+ }
80
+ else {
81
+ log_1.Log.info(cli_1.CliInternals.chalk.blueBright(`
82
+ Service already exists, skipping deployment;
83
+
84
+ ${(0, _1.displayServiceInfo)({
85
+ serviceName: deployResult.shortName,
86
+ timeoutInSeconds: timeoutSeconds,
87
+ memoryLimit,
88
+ cpuLimit,
89
+ remotionVersion: version_1.VERSION,
90
+ uri: deployResult.uri,
91
+ region,
92
+ consoleUrl,
93
+ })}
94
+ `.trim()));
95
+ }
96
+ }
97
+ else {
98
+ log_1.Log.info();
99
+ if (cli_1.CliInternals.quietFlagProvided()) {
100
+ cli_1.CliInternals.Log.info(deployResult.shortName);
101
+ }
102
+ else {
103
+ log_1.Log.info(cli_1.CliInternals.chalk.blueBright(`
104
+ Cloud Run Deployed!
105
+
106
+ ${(0, _1.displayServiceInfo)({
107
+ serviceName: deployResult.shortName,
108
+ timeoutInSeconds: timeoutSeconds,
109
+ memoryLimit,
110
+ cpuLimit,
111
+ remotionVersion: version_1.VERSION,
112
+ uri: deployResult.uri,
113
+ region,
114
+ consoleUrl,
115
+ })}
116
+ `.trim()));
117
+ }
118
+ }
119
+ }
120
+ catch (e) {
121
+ log_1.Log.error(cli_1.CliInternals.chalk.red(`Failed to deploy service - ${(0, generate_service_name_1.generateServiceName)({
122
+ memoryLimit,
123
+ cpuLimit,
124
+ timeoutSeconds,
125
+ })}.`));
126
+ throw e;
127
+ }
128
+ };
129
+ exports.cloudRunDeploySubcommand = cloudRunDeploySubcommand;
@@ -0,0 +1,5 @@
1
+ import type { ServiceInfo } from '../../../api/get-service-info';
2
+ export declare const SERVICES_COMMAND = "services";
3
+ export declare const LEFT_COL = 20;
4
+ export declare const displayServiceInfo: (service: ServiceInfo) => string;
5
+ export declare const servicesCommand: (args: string[]) => Promise<void> | undefined;
@@ -0,0 +1,64 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.servicesCommand = exports.displayServiceInfo = exports.LEFT_COL = exports.SERVICES_COMMAND = void 0;
4
+ const cli_1 = require("@remotion/cli");
5
+ const constants_1 = require("../../../shared/constants");
6
+ const quit_1 = require("../../helpers/quit");
7
+ const log_1 = require("../../log");
8
+ const deploy_1 = require("./deploy");
9
+ const ls_1 = require("./ls");
10
+ const rm_1 = require("./rm");
11
+ const rmall_1 = require("./rmall");
12
+ exports.SERVICES_COMMAND = 'services';
13
+ exports.LEFT_COL = 20;
14
+ const displayServiceInfo = (service) => {
15
+ return [
16
+ 'Service name: '.padEnd(exports.LEFT_COL, ' ') + ' ' + service.serviceName,
17
+ 'Version: '.padEnd(exports.LEFT_COL, ' ') + ' ' + service.remotionVersion,
18
+ 'CPU Limit: '.padEnd(exports.LEFT_COL, ' ') + ' ' + service.cpuLimit,
19
+ 'Memory Limit: '.padEnd(exports.LEFT_COL, ' ') + ' ' + service.memoryLimit,
20
+ 'Timeout: '.padEnd(exports.LEFT_COL, ' ') + ' ' + service.timeoutInSeconds + 'sec',
21
+ 'Region: '.padEnd(exports.LEFT_COL, ' ') + ' ' + service.region,
22
+ 'Service URL: '.padEnd(exports.LEFT_COL, ' ') + ' ' + service.uri,
23
+ 'GCP Console URL: '.padEnd(exports.LEFT_COL, ' ') + ' ' + service.consoleUrl,
24
+ ].join('\n');
25
+ };
26
+ exports.displayServiceInfo = displayServiceInfo;
27
+ const printCloudRunHelp = () => {
28
+ log_1.Log.info(`${constants_1.BINARY_NAME} ${exports.SERVICES_COMMAND} <subcommand>`);
29
+ log_1.Log.info();
30
+ log_1.Log.info('Available subcommands:');
31
+ cli_1.CliInternals.Log.info('');
32
+ cli_1.CliInternals.Log.info(`${constants_1.BINARY_NAME} ${exports.SERVICES_COMMAND} ${ls_1.SERVICES_LS_SUBCOMMAND}`);
33
+ cli_1.CliInternals.Log.info(cli_1.CliInternals.chalk.gray('Lists the services currently deployed'));
34
+ log_1.Log.info('');
35
+ log_1.Log.info(`${constants_1.BINARY_NAME} ${exports.SERVICES_COMMAND} ${deploy_1.CLOUD_RUN_DEPLOY_SUBCOMMAND}`);
36
+ log_1.Log.info(cli_1.CliInternals.chalk.gray('Deploy a new Cloud Run service'));
37
+ cli_1.CliInternals.Log.info('');
38
+ cli_1.CliInternals.Log.info(`${constants_1.BINARY_NAME} ${exports.SERVICES_COMMAND} ${rm_1.SERVICES_RM_SUBCOMMAND} <service-name>`);
39
+ cli_1.CliInternals.Log.info(cli_1.CliInternals.chalk.gray('Delete a Cloud Run service'));
40
+ cli_1.CliInternals.Log.info('');
41
+ cli_1.CliInternals.Log.info(`${constants_1.BINARY_NAME} ${exports.SERVICES_COMMAND} ${rmall_1.SERVICES_RMALL_SUBCOMMAND}`);
42
+ cli_1.CliInternals.Log.info(cli_1.CliInternals.chalk.gray('Delete all services in selected region'));
43
+ };
44
+ const servicesCommand = (args) => {
45
+ if (args[0] === ls_1.SERVICES_LS_SUBCOMMAND) {
46
+ return (0, ls_1.servicesLsCommand)();
47
+ }
48
+ if (args[0] === rm_1.SERVICES_RM_SUBCOMMAND) {
49
+ return (0, rm_1.servicesRmCommand)(args.slice(1));
50
+ }
51
+ if (args[0] === rmall_1.SERVICES_RMALL_SUBCOMMAND) {
52
+ return (0, rmall_1.servicesRmallCommand)();
53
+ }
54
+ if (args[0] === deploy_1.CLOUD_RUN_DEPLOY_SUBCOMMAND) {
55
+ return (0, deploy_1.cloudRunDeploySubcommand)();
56
+ }
57
+ if (args[0]) {
58
+ log_1.Log.error(`Subcommand ${args[0]} not found.`);
59
+ printCloudRunHelp();
60
+ (0, quit_1.quit)(1);
61
+ }
62
+ printCloudRunHelp();
63
+ };
64
+ exports.servicesCommand = servicesCommand;
@@ -0,0 +1,2 @@
1
+ export declare const SERVICES_LS_SUBCOMMAND = "ls";
2
+ export declare const servicesLsCommand: () => Promise<void>;
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.servicesLsCommand = exports.SERVICES_LS_SUBCOMMAND = void 0;
4
+ const cli_1 = require("@remotion/cli");
5
+ const _1 = require(".");
6
+ const get_services_1 = require("../../../api/get-services");
7
+ const get_gcp_region_1 = require("../../get-gcp-region");
8
+ const log_1 = require("../../log");
9
+ exports.SERVICES_LS_SUBCOMMAND = 'ls';
10
+ const servicesLsCommand = async () => {
11
+ const region = (0, get_gcp_region_1.getGcpRegion)();
12
+ const fetchingOutput = cli_1.CliInternals.createOverwriteableCliOutput({
13
+ quiet: cli_1.CliInternals.quietFlagProvided(),
14
+ cancelSignal: null,
15
+ updatesDontOverwrite: false,
16
+ indent: false,
17
+ });
18
+ fetchingOutput.update(`Getting services in ${region}...`, false);
19
+ const services = await (0, get_services_1.getServices)({
20
+ region,
21
+ compatibleOnly: false,
22
+ });
23
+ if (cli_1.CliInternals.quietFlagProvided()) {
24
+ if (services.length === 0) {
25
+ log_1.Log.info('()');
26
+ return;
27
+ }
28
+ log_1.Log.info(services.map((f) => f.serviceName).join(' '));
29
+ return;
30
+ }
31
+ fetchingOutput.update('Getting service info...', false);
32
+ const pluralized = services.length === 1 ? 'service' : 'services';
33
+ fetchingOutput.update(`${services.length} ${pluralized} in ${region}`, false);
34
+ log_1.Log.info();
35
+ for (const service of services) {
36
+ log_1.Log.info();
37
+ log_1.Log.info((0, _1.displayServiceInfo)(service));
38
+ }
39
+ };
40
+ exports.servicesLsCommand = servicesLsCommand;
@@ -0,0 +1,2 @@
1
+ export declare const SERVICES_RM_SUBCOMMAND = "rm";
2
+ export declare const servicesRmCommand: (args: string[]) => Promise<void>;
@@ -0,0 +1,63 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.servicesRmCommand = exports.SERVICES_RM_SUBCOMMAND = void 0;
4
+ const cli_1 = require("@remotion/cli");
5
+ const delete_service_1 = require("../../../api/delete-service");
6
+ const get_service_info_1 = require("../../../api/get-service-info");
7
+ const constants_1 = require("../../../shared/constants");
8
+ const get_gcp_region_1 = require("../../get-gcp-region");
9
+ const confirm_1 = require("../../helpers/confirm");
10
+ const quit_1 = require("../../helpers/quit");
11
+ const log_1 = require("../../log");
12
+ const index_1 = require("./index");
13
+ const ls_1 = require("./ls");
14
+ exports.SERVICES_RM_SUBCOMMAND = 'rm';
15
+ const servicesRmCommand = async (args) => {
16
+ if (args.length === 0) {
17
+ log_1.Log.error('No service name passed.');
18
+ log_1.Log.error('Pass another argument which is the name of the service you would like to remove.');
19
+ log_1.Log.info(`You can run \`${constants_1.BINARY_NAME} ${index_1.SERVICES_COMMAND} ${ls_1.SERVICES_LS_SUBCOMMAND}\` to see a list of deployed Cloud Run services.`);
20
+ (0, quit_1.quit)(1);
21
+ }
22
+ if (args[0] === '()') {
23
+ log_1.Log.info('No services to remove.');
24
+ return;
25
+ }
26
+ const region = (0, get_gcp_region_1.getGcpRegion)();
27
+ for (const serviceName of args) {
28
+ const infoOutput = cli_1.CliInternals.createOverwriteableCliOutput({
29
+ quiet: cli_1.CliInternals.quietFlagProvided(),
30
+ cancelSignal: null,
31
+ updatesDontOverwrite: false,
32
+ indent: false,
33
+ });
34
+ infoOutput.update('Getting service info...', false);
35
+ const info = await (0, get_service_info_1.getServiceInfo)({
36
+ region,
37
+ serviceName,
38
+ });
39
+ infoOutput.update((0, index_1.displayServiceInfo)(info), false);
40
+ log_1.Log.info();
41
+ const confirmDelete = await (0, confirm_1.confirmCli)({
42
+ delMessage: 'Delete? (Y/n)',
43
+ allowForceFlag: true,
44
+ });
45
+ if (!confirmDelete) {
46
+ log_1.Log.info(`Skipping service - ${info.serviceName}.`);
47
+ continue;
48
+ }
49
+ const output = cli_1.CliInternals.createOverwriteableCliOutput({
50
+ quiet: cli_1.CliInternals.quietFlagProvided(),
51
+ cancelSignal: null,
52
+ updatesDontOverwrite: false,
53
+ indent: false,
54
+ });
55
+ output.update('Deleting...', false);
56
+ await (0, delete_service_1.deleteService)({
57
+ serviceName,
58
+ region,
59
+ });
60
+ output.update('Deleted!\n', false);
61
+ }
62
+ };
63
+ exports.servicesRmCommand = servicesRmCommand;
@@ -0,0 +1,2 @@
1
+ export declare const SERVICES_RMALL_SUBCOMMAND = "rmall";
2
+ export declare const servicesRmallCommand: () => Promise<void>;
@@ -0,0 +1,52 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.servicesRmallCommand = exports.SERVICES_RMALL_SUBCOMMAND = void 0;
4
+ const cli_1 = require("@remotion/cli");
5
+ const delete_service_1 = require("../../../api/delete-service");
6
+ const get_services_1 = require("../../../api/get-services");
7
+ const get_gcp_region_1 = require("../../get-gcp-region");
8
+ const confirm_1 = require("../../helpers/confirm");
9
+ const log_1 = require("../../log");
10
+ const index_1 = require("./index");
11
+ exports.SERVICES_RMALL_SUBCOMMAND = 'rmall';
12
+ const servicesRmallCommand = async () => {
13
+ const region = (0, get_gcp_region_1.getGcpRegion)();
14
+ const fetchingOutput = cli_1.CliInternals.createOverwriteableCliOutput({
15
+ quiet: cli_1.CliInternals.quietFlagProvided(),
16
+ cancelSignal: null,
17
+ updatesDontOverwrite: false,
18
+ indent: false,
19
+ });
20
+ fetchingOutput.update(`Getting services in ${region}...`, false);
21
+ const services = await (0, get_services_1.getServices)({
22
+ region,
23
+ compatibleOnly: false,
24
+ });
25
+ const pluralized = services.length === 1 ? 'service' : 'services';
26
+ fetchingOutput.update(`${services.length} ${pluralized} in ${region}`, false);
27
+ log_1.Log.info();
28
+ log_1.Log.info();
29
+ for (const serv of services) {
30
+ log_1.Log.info((0, index_1.displayServiceInfo)(serv));
31
+ log_1.Log.info();
32
+ const confirmDelete = await (0, confirm_1.confirmCli)({
33
+ delMessage: 'Delete? (Y/n)',
34
+ allowForceFlag: true,
35
+ });
36
+ if (!confirmDelete) {
37
+ log_1.Log.info(`Skipping service - ${serv.serviceName}.`);
38
+ log_1.Log.info();
39
+ continue;
40
+ }
41
+ const output = cli_1.CliInternals.createOverwriteableCliOutput({
42
+ quiet: cli_1.CliInternals.quietFlagProvided(),
43
+ cancelSignal: null,
44
+ updatesDontOverwrite: false,
45
+ indent: false,
46
+ });
47
+ output.update('Deleting...', false);
48
+ await (0, delete_service_1.deleteService)({ region: serv.region, serviceName: serv.serviceName });
49
+ output.update('Deleted!\n', false);
50
+ }
51
+ };
52
+ exports.servicesRmallCommand = servicesRmallCommand;
@@ -0,0 +1,2 @@
1
+ export declare const SITES_CREATE_SUBCOMMAND = "create";
2
+ export declare const sitesCreateSubcommand: (args: string[], remotionRoot: string) => Promise<void>;
@@ -0,0 +1,138 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.sitesCreateSubcommand = exports.SITES_CREATE_SUBCOMMAND = void 0;
4
+ const cli_1 = require("@remotion/cli");
5
+ const config_1 = require("@remotion/cli/config");
6
+ const fs_1 = require("fs");
7
+ const remotion_1 = require("remotion");
8
+ const _1 = require(".");
9
+ const deploy_site_1 = require("../../../api/deploy-site");
10
+ const get_or_create_bucket_1 = require("../../../api/get-or-create-bucket");
11
+ const constants_1 = require("../../../shared/constants");
12
+ const validate_site_name_1 = require("../../../shared/validate-site-name");
13
+ const args_1 = require("../../args");
14
+ const get_gcp_region_1 = require("../../get-gcp-region");
15
+ const progress_bar_1 = require("../../helpers/progress-bar");
16
+ const quit_1 = require("../../helpers/quit");
17
+ const log_1 = require("../../log");
18
+ exports.SITES_CREATE_SUBCOMMAND = 'create';
19
+ const sitesCreateSubcommand = async (args, remotionRoot) => {
20
+ var _a, _b;
21
+ const { file, reason } = cli_1.CliInternals.findEntryPoint(args, remotionRoot);
22
+ if (!file) {
23
+ log_1.Log.error('No entry file passed.');
24
+ log_1.Log.info('Pass an additional argument specifying the entry file of your Remotion project:');
25
+ log_1.Log.info();
26
+ log_1.Log.info(`${constants_1.BINARY_NAME} deploy <entry-file.ts>`);
27
+ (0, quit_1.quit)(1);
28
+ return;
29
+ }
30
+ log_1.Log.verbose('Entry point:', file, 'Reason:', reason);
31
+ if (!(0, fs_1.existsSync)(file)) {
32
+ log_1.Log.error(`No file exists at ${file}. Make sure the path exists and try again.`);
33
+ (0, quit_1.quit)(1);
34
+ }
35
+ if ((0, fs_1.lstatSync)(file).isDirectory()) {
36
+ log_1.Log.error(`You passed a path ${file} but it is a directory. Pass a file instead.`);
37
+ (0, quit_1.quit)(1);
38
+ }
39
+ const desiredSiteName = (_a = args_1.parsedCloudrunCli['site-name']) !== null && _a !== void 0 ? _a : undefined;
40
+ if (desiredSiteName !== undefined) {
41
+ (0, validate_site_name_1.validateSiteName)(desiredSiteName);
42
+ }
43
+ const progressBar = cli_1.CliInternals.createOverwriteableCliOutput({
44
+ quiet: cli_1.CliInternals.quietFlagProvided(),
45
+ cancelSignal: null,
46
+ updatesDontOverwrite: false,
47
+ indent: false,
48
+ });
49
+ const multiProgress = {
50
+ bundleProgress: {
51
+ doneIn: null,
52
+ progress: 0,
53
+ },
54
+ bucketProgress: {
55
+ doneIn: null,
56
+ creationState: 'Checking for existing bucket',
57
+ },
58
+ deployProgress: {
59
+ doneIn: null,
60
+ totalSize: null,
61
+ sizeUploaded: 0,
62
+ stats: null,
63
+ },
64
+ };
65
+ const updateProgress = () => {
66
+ progressBar.update([
67
+ (0, progress_bar_1.makeBundleProgress)(multiProgress.bundleProgress),
68
+ (0, progress_bar_1.makeBucketProgress)(multiProgress.bucketProgress),
69
+ (0, progress_bar_1.makeDeployProgressBar)(multiProgress.deployProgress),
70
+ ].join('\n'), false);
71
+ };
72
+ const bucketStart = Date.now();
73
+ const region = (0, get_gcp_region_1.getGcpRegion)();
74
+ const { bucketName } = await (0, get_or_create_bucket_1.getOrCreateBucket)({
75
+ region,
76
+ updateBucketState: (state) => {
77
+ multiProgress.bucketProgress.creationState = state;
78
+ updateProgress();
79
+ },
80
+ });
81
+ multiProgress.bucketProgress.doneIn = Date.now() - bucketStart;
82
+ updateProgress();
83
+ const bundleStart = Date.now();
84
+ const { serveUrl, siteName, stats } = await (0, deploy_site_1.deploySite)({
85
+ entryPoint: file,
86
+ siteName: desiredSiteName,
87
+ bucketName,
88
+ options: {
89
+ onBundleProgress: (progress) => {
90
+ multiProgress.bundleProgress = {
91
+ progress,
92
+ doneIn: progress === 100 ? Date.now() - bundleStart : null,
93
+ };
94
+ },
95
+ onUploadProgress: (p) => {
96
+ multiProgress.deployProgress = {
97
+ sizeUploaded: p.sizeUploaded,
98
+ totalSize: p.totalSize,
99
+ doneIn: null,
100
+ stats: null,
101
+ };
102
+ updateProgress();
103
+ },
104
+ enableCaching: config_1.ConfigInternals.getWebpackCaching(),
105
+ webpackOverride: (_b = config_1.ConfigInternals.getWebpackOverrideFn()) !== null && _b !== void 0 ? _b : ((f) => f),
106
+ },
107
+ });
108
+ updateProgress();
109
+ const uploadStart = Date.now();
110
+ const uploadDuration = Date.now() - uploadStart;
111
+ multiProgress.deployProgress = {
112
+ sizeUploaded: 1,
113
+ totalSize: 1,
114
+ doneIn: uploadDuration,
115
+ stats: {
116
+ addedFiles: stats.uploadedFiles,
117
+ removedFiles: stats.deletedFiles,
118
+ untouchedFiles: stats.untouchedFiles,
119
+ },
120
+ };
121
+ updateProgress();
122
+ log_1.Log.info();
123
+ log_1.Log.info();
124
+ log_1.Log.info('Deployed to GCP Storage!');
125
+ log_1.Log.info();
126
+ log_1.Log.info((0, _1.displaySiteInfo)({
127
+ bucketName,
128
+ id: siteName,
129
+ serveUrl,
130
+ bucketRegion: region,
131
+ }));
132
+ log_1.Log.info();
133
+ log_1.Log.info(cli_1.CliInternals.chalk.blueBright('ℹ️ If you make changes to your code, you need to redeploy the site. You can overwrite the existing site by running:'));
134
+ log_1.Log.info(cli_1.CliInternals.chalk.blueBright(['npx remotion cloudrun sites create', args[0], `--site-name=${siteName}`]
135
+ .filter(remotion_1.Internals.truthy)
136
+ .join(' ')));
137
+ };
138
+ exports.sitesCreateSubcommand = sitesCreateSubcommand;
@@ -0,0 +1,4 @@
1
+ import type { Site } from '../../../api/get-sites';
2
+ export declare const SITES_COMMAND = "sites";
3
+ export declare const displaySiteInfo: (site: Site) => string;
4
+ export declare const sitesCommand: (args: string[], remotionRoot: string) => Promise<void> | undefined;
@@ -0,0 +1,60 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.sitesCommand = exports.displaySiteInfo = exports.SITES_COMMAND = void 0;
4
+ const cli_1 = require("@remotion/cli");
5
+ const constants_1 = require("../../../shared/constants");
6
+ const quit_1 = require("../../helpers/quit");
7
+ const log_1 = require("../../log");
8
+ const create_1 = require("./create");
9
+ const ls_1 = require("./ls");
10
+ const rm_1 = require("./rm");
11
+ const rmall_1 = require("./rmall");
12
+ exports.SITES_COMMAND = 'sites';
13
+ const displaySiteInfo = (site) => {
14
+ const LEFT_COL = 16;
15
+ return [
16
+ 'Site: '.padEnd(LEFT_COL, ' ') + ' ' + site.id,
17
+ 'Bucket: '.padEnd(LEFT_COL, ' ') + ' ' + site.bucketName,
18
+ 'Region: '.padEnd(LEFT_COL, ' ') + ' ' + site.bucketRegion,
19
+ 'Serve Url: '.padEnd(LEFT_COL, ' ') + ' ' + site.serveUrl,
20
+ ].join('\n');
21
+ };
22
+ exports.displaySiteInfo = displaySiteInfo;
23
+ const printSitesHelp = () => {
24
+ log_1.Log.info(`${constants_1.BINARY_NAME} ${exports.SITES_COMMAND} <subcommand>`);
25
+ log_1.Log.info();
26
+ log_1.Log.info('Available subcommands:');
27
+ log_1.Log.info('');
28
+ log_1.Log.info(`${constants_1.BINARY_NAME} ${exports.SITES_COMMAND} ${create_1.SITES_CREATE_SUBCOMMAND}`);
29
+ log_1.Log.info(cli_1.CliInternals.chalk.gray('Creates a new site based on a Remotion project'));
30
+ cli_1.CliInternals.Log.info();
31
+ cli_1.CliInternals.Log.info(`${constants_1.BINARY_NAME} ${exports.SITES_COMMAND} ${ls_1.SITES_LS_SUBCOMMAND}`);
32
+ cli_1.CliInternals.Log.info(cli_1.CliInternals.chalk.gray('Lists the sites currently deployed'));
33
+ cli_1.CliInternals.Log.info();
34
+ cli_1.CliInternals.Log.info(`${constants_1.BINARY_NAME} ${exports.SITES_COMMAND} ${rm_1.SITES_RM_COMMAND} <site-id>`);
35
+ cli_1.CliInternals.Log.info(cli_1.CliInternals.chalk.gray('Remove a site from the Cloud Storage bucket.'));
36
+ cli_1.CliInternals.Log.info();
37
+ cli_1.CliInternals.Log.info(`${constants_1.BINARY_NAME} ${exports.SITES_COMMAND} ${rmall_1.SITES_RMALL_COMMAND}`);
38
+ cli_1.CliInternals.Log.info(cli_1.CliInternals.chalk.gray('Remove all sites from the Cloud Storage bucket.'));
39
+ };
40
+ const sitesCommand = (args, remotionRoot) => {
41
+ if (args[0] === ls_1.SITES_LS_SUBCOMMAND) {
42
+ return (0, ls_1.sitesLsSubcommand)();
43
+ }
44
+ if (args[0] === rm_1.SITES_RM_COMMAND) {
45
+ return (0, rm_1.sitesRmSubcommand)(args.slice(1));
46
+ }
47
+ if (args[0] === rmall_1.SITES_RMALL_COMMAND) {
48
+ return (0, rmall_1.sitesRmallSubcommand)();
49
+ }
50
+ if (args[0] === create_1.SITES_CREATE_SUBCOMMAND) {
51
+ return (0, create_1.sitesCreateSubcommand)(args.slice(1), remotionRoot);
52
+ }
53
+ if (args[0]) {
54
+ log_1.Log.error(`Subcommand ${args[0]} not found.`);
55
+ printSitesHelp();
56
+ (0, quit_1.quit)(1);
57
+ }
58
+ printSitesHelp();
59
+ };
60
+ exports.sitesCommand = sitesCommand;
@@ -0,0 +1,2 @@
1
+ export declare const SITES_LS_SUBCOMMAND = "ls";
2
+ export declare const sitesLsSubcommand: () => Promise<void>;
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.sitesLsSubcommand = exports.SITES_LS_SUBCOMMAND = void 0;
4
+ const cli_1 = require("@remotion/cli");
5
+ const _1 = require(".");
6
+ const get_sites_1 = require("../../../api/get-sites");
7
+ const args_1 = require("../../args");
8
+ const get_gcp_region_1 = require("../../get-gcp-region");
9
+ const log_1 = require("../../log");
10
+ exports.SITES_LS_SUBCOMMAND = 'ls';
11
+ const sitesLsSubcommand = async () => {
12
+ // check if --allRegions flag is provided
13
+ // if so, list all sites
14
+ // else, list only the sites that are in the current project
15
+ const allRegions = args_1.parsedCloudrunCli['all-regions'];
16
+ const region = allRegions ? 'all regions' : (0, get_gcp_region_1.getGcpRegion)();
17
+ const { sites, buckets } = await (0, get_sites_1.getSites)(region);
18
+ if (buckets.length > 1 && !cli_1.CliInternals.quietFlagProvided() && !allRegions) {
19
+ log_1.Log.warn(`Warning: You have more than one Remotion Cloud Storage bucket in ${region}, but only one is needed. This can lead to conflicts. Remove all but one of them.`);
20
+ }
21
+ const sitesPluralized = sites.length === 1 ? 'site' : 'sites';
22
+ if (!cli_1.CliInternals.quietFlagProvided()) {
23
+ log_1.Log.info(`${sites.length} ${sitesPluralized} in ${region}, in the ${process.env.REMOTION_GCP_PROJECT_ID} project.`);
24
+ }
25
+ if (cli_1.CliInternals.quietFlagProvided()) {
26
+ if (sites.length === 0) {
27
+ log_1.Log.info('()');
28
+ return;
29
+ }
30
+ return log_1.Log.info(sites.map((s) => s.id).join(' '));
31
+ }
32
+ if (sites.length > 0) {
33
+ log_1.Log.info();
34
+ for (const site of sites) {
35
+ log_1.Log.info((0, _1.displaySiteInfo)(site));
36
+ log_1.Log.info();
37
+ }
38
+ }
39
+ };
40
+ exports.sitesLsSubcommand = sitesLsSubcommand;
@@ -0,0 +1,2 @@
1
+ export declare const SITES_RM_COMMAND = "rm";
2
+ export declare const sitesRmSubcommand: (args: string[]) => Promise<void>;