@remotion/cloudrun 4.1.0-alpha2

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 (175) 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 +50 -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 +13 -0
  20. package/dist/api/download-file.js +30 -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 +36 -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/get-auth-client-for-url.d.ts +1 -0
  38. package/dist/api/helpers/get-auth-client-for-url.js +15 -0
  39. package/dist/api/helpers/get-cloud-run-client.d.ts +2 -0
  40. package/dist/api/helpers/get-cloud-run-client.js +15 -0
  41. package/dist/api/helpers/get-cloud-storage-client.d.ts +2 -0
  42. package/dist/api/helpers/get-cloud-storage-client.js +14 -0
  43. package/dist/api/helpers/get-cloudrun-endpoint.d.ts +14 -0
  44. package/dist/api/helpers/get-cloudrun-endpoint.js +36 -0
  45. package/dist/api/helpers/get-resource-manager-client.d.ts +2 -0
  46. package/dist/api/helpers/get-resource-manager-client.js +15 -0
  47. package/dist/api/iam-validation/testPermissions.d.ts +20 -0
  48. package/dist/api/iam-validation/testPermissions.js +48 -0
  49. package/dist/api/render-media-on-cloudrun.d.ts +70 -0
  50. package/dist/api/render-media-on-cloudrun.js +115 -0
  51. package/dist/api/render-still-on-cloudrun.d.ts +47 -0
  52. package/dist/api/render-still-on-cloudrun.js +68 -0
  53. package/dist/api/speculate-service-name.d.ts +13 -0
  54. package/dist/api/speculate-service-name.js +20 -0
  55. package/dist/api/upload-dir.d.ts +18 -0
  56. package/dist/api/upload-dir.js +81 -0
  57. package/dist/cli/args.d.ts +19 -0
  58. package/dist/cli/args.js +11 -0
  59. package/dist/cli/commands/permissions.d.ts +2 -0
  60. package/dist/cli/commands/permissions.js +23 -0
  61. package/dist/cli/commands/regions.d.ts +2 -0
  62. package/dist/cli/commands/regions.js +10 -0
  63. package/dist/cli/commands/render/helpers/renderArgsCheck.d.ts +9 -0
  64. package/dist/cli/commands/render/helpers/renderArgsCheck.js +75 -0
  65. package/dist/cli/commands/render/index.d.ts +2 -0
  66. package/dist/cli/commands/render/index.js +36 -0
  67. package/dist/cli/commands/render/renderMedia.d.ts +2 -0
  68. package/dist/cli/commands/render/renderMedia.js +156 -0
  69. package/dist/cli/commands/render/renderStill.d.ts +2 -0
  70. package/dist/cli/commands/render/renderStill.js +123 -0
  71. package/dist/cli/commands/services/deploy.d.ts +2 -0
  72. package/dist/cli/commands/services/deploy.js +129 -0
  73. package/dist/cli/commands/services/index.d.ts +5 -0
  74. package/dist/cli/commands/services/index.js +64 -0
  75. package/dist/cli/commands/services/ls.d.ts +2 -0
  76. package/dist/cli/commands/services/ls.js +40 -0
  77. package/dist/cli/commands/services/rm.d.ts +2 -0
  78. package/dist/cli/commands/services/rm.js +63 -0
  79. package/dist/cli/commands/services/rmall.d.ts +2 -0
  80. package/dist/cli/commands/services/rmall.js +52 -0
  81. package/dist/cli/commands/sites/create.d.ts +2 -0
  82. package/dist/cli/commands/sites/create.js +138 -0
  83. package/dist/cli/commands/sites/index.d.ts +4 -0
  84. package/dist/cli/commands/sites/index.js +60 -0
  85. package/dist/cli/commands/sites/ls.d.ts +2 -0
  86. package/dist/cli/commands/sites/ls.js +40 -0
  87. package/dist/cli/commands/sites/rm.d.ts +2 -0
  88. package/dist/cli/commands/sites/rm.js +59 -0
  89. package/dist/cli/commands/sites/rmall.d.ts +2 -0
  90. package/dist/cli/commands/sites/rmall.js +38 -0
  91. package/dist/cli/get-gcp-region.d.ts +2 -0
  92. package/dist/cli/get-gcp-region.js +19 -0
  93. package/dist/cli/help.d.ts +1 -0
  94. package/dist/cli/help.js +34 -0
  95. package/dist/cli/helpers/confirm.d.ts +4 -0
  96. package/dist/cli/helpers/confirm.js +12 -0
  97. package/dist/cli/helpers/date-string.d.ts +1 -0
  98. package/dist/cli/helpers/date-string.js +9 -0
  99. package/dist/cli/helpers/progress-bar.d.ts +23 -0
  100. package/dist/cli/helpers/progress-bar.js +81 -0
  101. package/dist/cli/helpers/quit.d.ts +1 -0
  102. package/dist/cli/helpers/quit.js +7 -0
  103. package/dist/cli/helpers/yes-or-no.d.ts +4 -0
  104. package/dist/cli/helpers/yes-or-no.js +44 -0
  105. package/dist/cli/index.d.ts +1 -0
  106. package/dist/cli/index.js +52 -0
  107. package/dist/cli/log.d.ts +21 -0
  108. package/dist/cli/log.js +5 -0
  109. package/dist/defaults.d.ts +1 -0
  110. package/dist/defaults.js +17 -0
  111. package/dist/index.d.ts +20 -0
  112. package/dist/index.js +31 -0
  113. package/dist/internals.d.ts +3 -0
  114. package/dist/internals.js +7 -0
  115. package/dist/pricing/gcp-regions.d.ts +5 -0
  116. package/dist/pricing/gcp-regions.js +77 -0
  117. package/dist/regions.d.ts +2 -0
  118. package/dist/regions.js +5 -0
  119. package/dist/shared/bundle-site.d.ts +2 -0
  120. package/dist/shared/bundle-site.js +5 -0
  121. package/dist/shared/constants.d.ts +13 -0
  122. package/dist/shared/constants.js +18 -0
  123. package/dist/shared/convert-to-serve-url.d.ts +4 -0
  124. package/dist/shared/convert-to-serve-url.js +14 -0
  125. package/dist/shared/docs-url.d.ts +1 -0
  126. package/dist/shared/docs-url.js +4 -0
  127. package/dist/shared/generate-service-name.d.ts +5 -0
  128. package/dist/shared/generate-service-name.js +20 -0
  129. package/dist/shared/get-etag.d.ts +1 -0
  130. package/dist/shared/get-etag.js +24 -0
  131. package/dist/shared/get-storage-operations.d.ts +10 -0
  132. package/dist/shared/get-storage-operations.js +36 -0
  133. package/dist/shared/make-storage-key.d.ts +1 -0
  134. package/dist/shared/make-storage-key.js +11 -0
  135. package/dist/shared/make-storage-url.d.ts +4 -0
  136. package/dist/shared/make-storage-url.js +7 -0
  137. package/dist/shared/random-hash.d.ts +3 -0
  138. package/dist/shared/random-hash.js +14 -0
  139. package/dist/shared/read-dir.d.ts +9 -0
  140. package/dist/shared/read-dir.js +57 -0
  141. package/dist/shared/sa-permissions.json +60 -0
  142. package/dist/shared/service-version-string.d.ts +1 -0
  143. package/dist/shared/service-version-string.js +8 -0
  144. package/dist/shared/validate-bucketname.d.ts +8 -0
  145. package/dist/shared/validate-bucketname.js +35 -0
  146. package/dist/shared/validate-cloudrun-url.d.ts +1 -0
  147. package/dist/shared/validate-cloudrun-url.js +10 -0
  148. package/dist/shared/validate-gcp-codec.d.ts +4 -0
  149. package/dist/shared/validate-gcp-codec.js +29 -0
  150. package/dist/shared/validate-gcp-region.d.ts +2 -0
  151. package/dist/shared/validate-gcp-region.js +10 -0
  152. package/dist/shared/validate-image-remotion-version.d.ts +1 -0
  153. package/dist/shared/validate-image-remotion-version.js +26 -0
  154. package/dist/shared/validate-privacy.d.ts +2 -0
  155. package/dist/shared/validate-privacy.js +12 -0
  156. package/dist/shared/validate-project-id.d.ts +1 -0
  157. package/dist/shared/validate-project-id.js +17 -0
  158. package/dist/shared/validate-region.d.ts +1 -0
  159. package/dist/shared/validate-region.js +15 -0
  160. package/dist/shared/validate-retries.d.ts +1 -0
  161. package/dist/shared/validate-retries.js +21 -0
  162. package/dist/shared/validate-serveurl.d.ts +1 -0
  163. package/dist/shared/validate-serveurl.js +30 -0
  164. package/dist/shared/validate-service-name.d.ts +1 -0
  165. package/dist/shared/validate-service-name.js +9 -0
  166. package/dist/shared/validate-site-name.d.ts +1 -0
  167. package/dist/shared/validate-site-name.js +17 -0
  168. package/package.json +59 -0
  169. package/readme.md +306 -0
  170. package/readmeImages/createSA.png +0 -0
  171. package/readmeImages/downloadEnv.jpg +0 -0
  172. package/readmeImages/downloadEnvFolder.png +0 -0
  173. package/readmeImages/saRole.png +0 -0
  174. package/readmeImages/selectCloudShell.jpg +0 -0
  175. package/tsconfig.tsbuildinfo +1 -0
@@ -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>;
@@ -0,0 +1,59 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.sitesRmSubcommand = exports.SITES_RM_COMMAND = void 0;
4
+ const cli_1 = require("@remotion/cli");
5
+ const _1 = require(".");
6
+ const delete_site_1 = require("../../../api/delete-site");
7
+ const get_sites_1 = require("../../../api/get-sites");
8
+ const constants_1 = require("../../../shared/constants");
9
+ const get_gcp_region_1 = require("../../get-gcp-region");
10
+ const confirm_1 = require("../../helpers/confirm");
11
+ const quit_1 = require("../../helpers/quit");
12
+ const log_1 = require("../../log");
13
+ const ls_1 = require("./ls");
14
+ exports.SITES_RM_COMMAND = 'rm';
15
+ const sitesRmSubcommand = async (args) => {
16
+ if (args.length === 0) {
17
+ log_1.Log.error('No site name was passed. Run the command again and pass another argument <site-name>.');
18
+ log_1.Log.error(`To get a list of sites, run \`${constants_1.BINARY_NAME} ${_1.SITES_COMMAND} ${ls_1.SITES_LS_SUBCOMMAND}\``);
19
+ (0, quit_1.quit)(1);
20
+ }
21
+ if (args[0] === '()') {
22
+ log_1.Log.info('No sites to remove.');
23
+ return;
24
+ }
25
+ const region = (0, get_gcp_region_1.getGcpRegion)();
26
+ const infoOutput = cli_1.CliInternals.createOverwriteableCliOutput({
27
+ quiet: cli_1.CliInternals.quietFlagProvided(),
28
+ cancelSignal: null,
29
+ updatesDontOverwrite: false,
30
+ indent: false,
31
+ });
32
+ infoOutput.update(`Checking ${region} for sites...`, false);
33
+ const deployedSites = await (0, get_sites_1.getSites)(region);
34
+ for (const siteName of args) {
35
+ infoOutput.update('Getting site info...', false);
36
+ const site = deployedSites.sites.find((s) => s.id === siteName.trim());
37
+ if (!site) {
38
+ infoOutput.update('', false);
39
+ throw new Error(`${siteName.trim()} was not found in ${region}.`);
40
+ }
41
+ infoOutput.update((0, _1.displaySiteInfo)(site), false);
42
+ log_1.Log.info();
43
+ log_1.Log.info();
44
+ const confirmDelete = await (0, confirm_1.confirmCli)({
45
+ delMessage: 'Delete? (Y/n)',
46
+ allowForceFlag: true,
47
+ });
48
+ if (!confirmDelete) {
49
+ log_1.Log.info('Aborting.');
50
+ return;
51
+ }
52
+ await (0, delete_site_1.deleteSite)({
53
+ bucketName: site.bucketName,
54
+ siteName,
55
+ });
56
+ log_1.Log.info(`Deleted site ${siteName} from bucket ${site.bucketName}.`);
57
+ }
58
+ };
59
+ exports.sitesRmSubcommand = sitesRmSubcommand;
@@ -0,0 +1,2 @@
1
+ export declare const SITES_RMALL_COMMAND = "rmall";
2
+ export declare const sitesRmallSubcommand: () => Promise<void>;
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.sitesRmallSubcommand = exports.SITES_RMALL_COMMAND = void 0;
4
+ const _1 = require(".");
5
+ const delete_site_1 = require("../../../api/delete-site");
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 confirm_1 = require("../../helpers/confirm");
10
+ const log_1 = require("../../log");
11
+ exports.SITES_RMALL_COMMAND = 'rmall';
12
+ const sitesRmallSubcommand = async () => {
13
+ const allRegions = args_1.parsedCloudrunCli['all-regions'];
14
+ const region = allRegions ? 'all regions' : (0, get_gcp_region_1.getGcpRegion)();
15
+ log_1.Log.info(`Retrieving sites in ${region}.`);
16
+ const deployedSites = await (0, get_sites_1.getSites)(region);
17
+ for (const site of deployedSites.sites) {
18
+ log_1.Log.info();
19
+ log_1.Log.info((0, _1.displaySiteInfo)(site));
20
+ log_1.Log.info();
21
+ const confirmDelete = await (0, confirm_1.confirmCli)({
22
+ delMessage: 'Delete? (Y/n)',
23
+ allowForceFlag: true,
24
+ });
25
+ if (!confirmDelete) {
26
+ log_1.Log.info(`Skipping site - ${site.id}.`);
27
+ log_1.Log.info();
28
+ continue;
29
+ }
30
+ await (0, delete_site_1.deleteSite)({
31
+ bucketName: site.bucketName,
32
+ siteName: site.id,
33
+ });
34
+ log_1.Log.info(`Deleted site ${site.id} from bucket ${site.bucketName}.`);
35
+ log_1.Log.info();
36
+ }
37
+ };
38
+ exports.sitesRmallSubcommand = sitesRmallSubcommand;
@@ -0,0 +1,2 @@
1
+ import type { GcpRegion } from '../pricing/gcp-regions';
2
+ export declare const getGcpRegion: () => GcpRegion;
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getGcpRegion = void 0;
4
+ const constants_1 = require("../shared/constants");
5
+ const validate_gcp_region_1 = require("../shared/validate-gcp-region");
6
+ const args_1 = require("./args");
7
+ const getGcpRegion = () => {
8
+ if (args_1.parsedCloudrunCli.region) {
9
+ (0, validate_gcp_region_1.validateGcpRegion)(args_1.parsedCloudrunCli.region);
10
+ return args_1.parsedCloudrunCli.region;
11
+ }
12
+ const envVariable = process.env.REMOTION_GCP_REGION;
13
+ if (envVariable) {
14
+ (0, validate_gcp_region_1.validateGcpRegion)(envVariable);
15
+ return envVariable;
16
+ }
17
+ return constants_1.DEFAULT_REGION;
18
+ };
19
+ exports.getGcpRegion = getGcpRegion;
@@ -0,0 +1 @@
1
+ export declare const printHelp: () => void;
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.printHelp = void 0;
4
+ const cli_1 = require("@remotion/cli");
5
+ const constants_1 = require("../shared/constants");
6
+ const permissions_1 = require("./commands/permissions");
7
+ const regions_1 = require("./commands/regions");
8
+ const render_1 = require("./commands/render");
9
+ const services_1 = require("./commands/services");
10
+ const sites_1 = require("./commands/sites");
11
+ const log_1 = require("./log");
12
+ const packagejson = require('../../package.json');
13
+ const printHelp = () => {
14
+ log_1.Log.info(`${constants_1.BINARY_NAME} ${packagejson.version} © ${new Date().getFullYear()} The Remotion developers`);
15
+ log_1.Log.info();
16
+ log_1.Log.info('Available commands:');
17
+ log_1.Log.info('');
18
+ log_1.Log.info();
19
+ log_1.Log.info(`${constants_1.BINARY_NAME} ${render_1.RENDER_COMMAND}`);
20
+ log_1.Log.info(cli_1.CliInternals.chalk.gray('Render Remotion media/still on GCP Cloud Run.'));
21
+ log_1.Log.info();
22
+ log_1.Log.info(`${constants_1.BINARY_NAME} ${services_1.SERVICES_COMMAND}`);
23
+ log_1.Log.info(cli_1.CliInternals.chalk.gray('Deploy and manage Cloud Run services on GCP.'));
24
+ log_1.Log.info();
25
+ log_1.Log.info(`${constants_1.BINARY_NAME} ${sites_1.SITES_COMMAND}`);
26
+ log_1.Log.info(cli_1.CliInternals.chalk.gray('Deploy and manage Remotion projects.'));
27
+ log_1.Log.info();
28
+ log_1.Log.info(`${constants_1.BINARY_NAME} ${permissions_1.PERMISSIONS_COMMAND}`);
29
+ log_1.Log.info(cli_1.CliInternals.chalk.gray('View and validate required GCP permissions.'));
30
+ log_1.Log.info();
31
+ log_1.Log.info(`${constants_1.BINARY_NAME} ${regions_1.REGIONS_COMMAND}`);
32
+ log_1.Log.info(cli_1.CliInternals.chalk.gray('Show the list of GCP regions supported.'));
33
+ };
34
+ exports.printHelp = printHelp;
@@ -0,0 +1,4 @@
1
+ export declare const confirmCli: ({ delMessage, allowForceFlag, }: {
2
+ delMessage: string;
3
+ allowForceFlag: boolean;
4
+ }) => true | Promise<boolean>;
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.confirmCli = void 0;
4
+ const args_1 = require("../args");
5
+ const yes_or_no_1 = require("./yes-or-no");
6
+ const confirmCli = ({ delMessage, allowForceFlag, }) => {
7
+ if (allowForceFlag && args_1.forceFlagProvided) {
8
+ return true;
9
+ }
10
+ return (0, yes_or_no_1.yesOrNo)({ question: delMessage, defaultValue: true });
11
+ };
12
+ exports.confirmCli = confirmCli;
@@ -0,0 +1 @@
1
+ export declare const dateString: (date: Date) => string;
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.dateString = void 0;
4
+ const dateString = (date) => date.getFullYear() +
5
+ '-' +
6
+ String(date.getMonth() + 1).padStart(2, '0') +
7
+ '-' +
8
+ String(date.getDate()).padStart(2, '0');
9
+ exports.dateString = dateString;
@@ -0,0 +1,23 @@
1
+ export declare type BundleProgress = {
2
+ progress: number;
3
+ doneIn: number | null;
4
+ };
5
+ export declare const makeBundleProgress: ({ progress, doneIn }: BundleProgress) => string;
6
+ export declare type BucketCreationProgress = {
7
+ creationState: 'Checking for existing bucket' | 'Creating new bucket' | 'Created bucket' | 'Using existing bucket';
8
+ doneIn: number | null;
9
+ };
10
+ export declare const makeBucketProgress: ({ creationState, doneIn, }: BucketCreationProgress) => string;
11
+ declare type UploadStats = {
12
+ addedFiles: number;
13
+ removedFiles: number;
14
+ untouchedFiles: number;
15
+ };
16
+ export declare type DeployToStorageProgress = {
17
+ sizeUploaded: number;
18
+ totalSize: number | null;
19
+ doneIn: number | null;
20
+ stats: UploadStats | null;
21
+ };
22
+ export declare const makeDeployProgressBar: ({ sizeUploaded, totalSize, doneIn, stats, }: DeployToStorageProgress) => string;
23
+ export {};
@@ -0,0 +1,81 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.makeDeployProgressBar = exports.makeBucketProgress = exports.makeBundleProgress = void 0;
4
+ const cli_1 = require("@remotion/cli");
5
+ const remotion_1 = require("remotion");
6
+ const makeBundleProgress = ({ progress, doneIn }) => {
7
+ return [
8
+ `(1/3)`,
9
+ cli_1.CliInternals.makeProgressBar(progress / 100),
10
+ `${doneIn === null ? 'Bundling' : 'Bundled'} video`,
11
+ doneIn === null
12
+ ? `${Math.round(progress)}%`
13
+ : cli_1.CliInternals.chalk.gray(`${doneIn}ms`),
14
+ ].join(' ');
15
+ };
16
+ exports.makeBundleProgress = makeBundleProgress;
17
+ const makeBucketProgress = ({ creationState, doneIn, }) => {
18
+ let progress = 0;
19
+ let statesFinished = 0;
20
+ switch (creationState) {
21
+ case 'Checking for existing bucket':
22
+ progress = 1;
23
+ break;
24
+ case 'Creating new bucket':
25
+ progress = 2 / 3;
26
+ statesFinished = 2;
27
+ break;
28
+ case 'Created bucket':
29
+ progress = 3 / 3;
30
+ statesFinished = 3;
31
+ break;
32
+ case 'Using existing bucket':
33
+ progress = 3 / 3;
34
+ statesFinished = 3;
35
+ break;
36
+ default:
37
+ progress = 0;
38
+ break;
39
+ }
40
+ return [
41
+ `(2/3)`,
42
+ cli_1.CliInternals.makeProgressBar(progress),
43
+ creationState,
44
+ doneIn === null
45
+ ? `${statesFinished} / ${3}`
46
+ : cli_1.CliInternals.chalk.gray(`${doneIn}ms`),
47
+ ].join(' ');
48
+ };
49
+ exports.makeBucketProgress = makeBucketProgress;
50
+ const makeUploadDiff = ({ stats }) => {
51
+ if (!stats) {
52
+ return null;
53
+ }
54
+ if (stats.addedFiles === 0 && stats.removedFiles === 0) {
55
+ return cli_1.CliInternals.chalk.gray(`(Unchanged)`);
56
+ }
57
+ const total = stats.addedFiles + stats.removedFiles;
58
+ return cli_1.CliInternals.chalk.gray(`(${[
59
+ stats.addedFiles ? `+${stats.addedFiles}` : null,
60
+ stats.removedFiles ? `-${stats.removedFiles}` : null,
61
+ ]
62
+ .filter(remotion_1.Internals.truthy)
63
+ .join(',')} ${total === 1 ? 'file' : 'files'})`);
64
+ };
65
+ const makeDeployProgressBar = ({ sizeUploaded, totalSize, doneIn, stats, }) => {
66
+ const progress = totalSize === null ? 0 : sizeUploaded / totalSize;
67
+ return [
68
+ `(3/3)`,
69
+ cli_1.CliInternals.makeProgressBar(progress),
70
+ `${doneIn === null ? 'Uploading' : 'Uploaded'} to GCP Storage Bucket`,
71
+ doneIn === null
72
+ ? typeof totalSize === 'number'
73
+ ? `${cli_1.CliInternals.formatBytes(sizeUploaded)}/${cli_1.CliInternals.formatBytes(totalSize)}`
74
+ : ''
75
+ : cli_1.CliInternals.chalk.gray(`${doneIn}ms`),
76
+ makeUploadDiff({ stats }),
77
+ ]
78
+ .filter(remotion_1.Internals.truthy)
79
+ .join(' ');
80
+ };
81
+ exports.makeDeployProgressBar = makeDeployProgressBar;
@@ -0,0 +1 @@
1
+ export declare const quit: (exitCode: number) => never;
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.quit = void 0;
4
+ const quit = (exitCode) => {
5
+ process.exit(exitCode);
6
+ };
7
+ exports.quit = quit;
@@ -0,0 +1,4 @@
1
+ export declare const yesOrNo: ({ question, defaultValue, }: {
2
+ question: string;
3
+ defaultValue: boolean;
4
+ }) => Promise<boolean>;
@@ -0,0 +1,44 @@
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.yesOrNo = void 0;
7
+ const readline_1 = __importDefault(require("readline"));
8
+ const options = {
9
+ yes: ['yes', 'y'],
10
+ no: ['no', 'n'],
11
+ };
12
+ function defaultInvalidHandler({ yesValues, noValues, }) {
13
+ process.stdout.write('\nInvalid Response.\n');
14
+ process.stdout.write('Answer either yes : (' + yesValues.join(', ') + ') \n');
15
+ process.stdout.write('Or no: (' + noValues.join(', ') + ') \n\n');
16
+ }
17
+ const yesOrNo = ({ question, defaultValue, }) => {
18
+ const invalid = defaultInvalidHandler;
19
+ const yesValues = options.yes.map((v) => v.toLowerCase());
20
+ const noValues = options.no.map((v) => v.toLowerCase());
21
+ const rl = readline_1.default.createInterface({
22
+ input: process.stdin,
23
+ output: process.stdout,
24
+ });
25
+ return new Promise((resolve) => {
26
+ rl.question(question + ' ', async (answer) => {
27
+ rl.close();
28
+ const cleaned = answer.trim().toLowerCase();
29
+ if (cleaned === '' && defaultValue !== null)
30
+ return resolve(defaultValue);
31
+ if (yesValues.indexOf(cleaned) >= 0)
32
+ return resolve(true);
33
+ if (noValues.indexOf(cleaned) >= 0)
34
+ return resolve(false);
35
+ invalid({ question, yesValues, noValues });
36
+ const result = await (0, exports.yesOrNo)({
37
+ question,
38
+ defaultValue,
39
+ });
40
+ resolve(result);
41
+ });
42
+ });
43
+ };
44
+ exports.yesOrNo = yesOrNo;
@@ -0,0 +1 @@
1
+ export declare const executeCommand: (args: string[], remotionRoot: string) => Promise<void>;