Skip to content

Commit

Permalink
Merge pull request #4086 from remotion-dev/disable-git-source
Browse files Browse the repository at this point in the history
  • Loading branch information
JonnyBurger authored Jul 17, 2024
2 parents 31f9726 + f14d81d commit 8983866
Show file tree
Hide file tree
Showing 18 changed files with 324 additions and 166 deletions.
8 changes: 6 additions & 2 deletions packages/cli/src/bundle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ import {bundleOnCli} from './setup-cache';
import {shouldUseNonOverlayingLogger} from './should-use-non-overlaying-logger';
import {yesOrNo} from './yes-or-no';

const {publicPathOption, publicDirOption} = BrowserSafeApis.options;
const {publicPathOption, publicDirOption, disableGitSourceOption} =
BrowserSafeApis.options;

export const bundleCommand = async (
remotionRoot: string,
Expand Down Expand Up @@ -59,6 +60,9 @@ export const bundleCommand = async (

const publicPath = publicPathOption.getValue({commandLine: parsedCli}).value;
const publicDir = publicDirOption.getValue({commandLine: parsedCli}).value;
const disableGitSource = disableGitSourceOption.getValue({
commandLine: parsedCli,
}).value;

const outputPath = parsedCli['out-dir']
? path.resolve(process.cwd(), parsedCli['out-dir'])
Expand Down Expand Up @@ -91,7 +95,7 @@ export const bundleCommand = async (
rmSync(outputPath, {recursive: true});
}

const gitSource = getGitSource(remotionRoot);
const gitSource = getGitSource({remotionRoot, disableGitSource});

const output = await bundleOnCli({
fullPath: file,
Expand Down
12 changes: 11 additions & 1 deletion packages/cli/src/get-github-repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,17 @@ const getFromEnvVariables = (): GitSource | null => {
return null;
};

export const getGitSource = (remotionRoot: string): GitSource | null => {
export const getGitSource = ({
remotionRoot,
disableGitSource,
}: {
remotionRoot: string;
disableGitSource: boolean;
}): GitSource | null => {
if (disableGitSource) {
return null;
}

const fromEnv = getFromEnvVariables();
if (fromEnv) {
return getFromEnvVariables();
Expand Down
2 changes: 2 additions & 0 deletions packages/cli/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import {ffmpegCommand, ffprobeCommand} from './ffmpeg';
import {getCliOptions} from './get-cli-options';
import {getCompositionWithDimensionOverride} from './get-composition-with-dimension-override';
import {loadConfig} from './get-config-file-name';
import {getGitSource} from './get-github-repository';
import {gpuCommand} from './gpu';
import {supportsHyperlink} from './hyperlinks/is-supported';
import {makeHyperlink} from './hyperlinks/make-link';
Expand Down Expand Up @@ -171,4 +172,5 @@ export const CliInternals = {
printFact,
makeHyperlink,
supportsHyperlink,
getGitSource,
};
1 change: 1 addition & 0 deletions packages/cli/src/parsed-cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export const BooleanFlags = [
'no-open',
'ipv4',
BrowserSafeApis.options.beepOnFinishOption.cliFlag,
BrowserSafeApis.options.disableGitSourceOption.cliFlag,
'repro',
'compatible-only',
];
Expand Down
11 changes: 8 additions & 3 deletions packages/cli/src/studio.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ const getPort = () => {
return null;
};

const {binariesDirectoryOption, publicDirOption} = BrowserSafeApis.options;
const {binariesDirectoryOption, publicDirOption, disableGitSourceOption} =
BrowserSafeApis.options;

export const studioCommand = async (
remotionRoot: string,
Expand Down Expand Up @@ -96,16 +97,20 @@ export const studioCommand = async (
const keyboardShortcutsEnabled =
ConfigInternals.getKeyboardShortcutsEnabled();

const gitSource = getGitSource(remotionRoot);

const binariesDirectory = binariesDirectoryOption.getValue({
commandLine: parsedCli,
}).value;

const disableGitSource = disableGitSourceOption.getValue({
commandLine: parsedCli,
}).value;

const relativePublicDir = publicDirOption.getValue({
commandLine: parsedCli,
}).value;

const gitSource = getGitSource({remotionRoot, disableGitSource});

await StudioServerInternals.startStudio({
previewEntry: require.resolve('@remotion/studio/entry'),
browserArgs: parsedCli['browser-args'],
Expand Down
10 changes: 8 additions & 2 deletions packages/cli/src/test/get-github-repo.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,10 @@ test('Should get Gif Ref', () => {
});

test('Should get Git Source', () => {
const git = getGitSource(process.cwd());
const git = getGitSource({
remotionRoot: process.cwd(),
disableGitSource: false,
});
expect(git).not.toBeNull();
expect(git?.relativeFromGitRoot).toBe(`packages${path.sep}cli`);
});
Expand All @@ -64,7 +67,10 @@ test('Should recognize VERCEL', () => {
process.env.VERCEL_GIT_REPO_SLUG = 'remotion';
process.env.VERCEL_GIT_REPO_OWNER = 'remotion-dev';

const source = getGitSource('dontmatter');
const source = getGitSource({
remotionRoot: 'dontmatter',
disableGitSource: false,
});
expect(source).not.toBeNull();
expect(source?.name).toBe('remotion');
expect(source?.org).toBe('remotion-dev');
Expand Down
38 changes: 26 additions & 12 deletions packages/cloudrun/src/api/deploy-site.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
import type {GitSource, WebpackOverrideFn} from '@remotion/bundler';
import type {LogLevel} from '@remotion/renderer';
import {
BundlerInternals,
type GitSource,
type WebpackOverrideFn,
} from '@remotion/bundler';
import type {ToOptions} from '@remotion/renderer';
import type {BrowserSafeApis} from '@remotion/renderer/client';
import {NoReactAPIs} from '@remotion/renderer/pure';
import {cloudrunDeleteFile, cloudrunLs} from '../functions/helpers/io';
import {bundleSite} from '../shared/bundle-site';
import {getSitesKey} from '../shared/constants';
import {getStorageDiffOperations} from '../shared/get-storage-operations';
import {makeStorageServeUrl} from '../shared/make-storage-url';
Expand All @@ -25,21 +29,25 @@ type Options = {
gitSource?: GitSource | null;
};

type OptionalParameters = {
siteName: string;
options: Options;
} & ToOptions<typeof BrowserSafeApis.optionsMap.deploySiteCloudRun>;

export type RawDeploySiteInput = {
entryPoint: string;
bucketName: string;
siteName: string;
options: Options;
logLevel: LogLevel;
indent: boolean;
};
} & OptionalParameters;

export type DeploySiteInput = {
entryPoint: string;
bucketName: string;
siteName?: string;
options?: Options;
};
} & Partial<OptionalParameters>;

export type DeploySiteOutput = Promise<{
serveUrl: string;
Expand All @@ -51,7 +59,7 @@ export type DeploySiteOutput = Promise<{
};
}>;

const internalDeploySiteRaw = async ({
export const internalDeploySiteRaw = async ({
entryPoint,
bucketName,
siteName,
Expand All @@ -74,16 +82,22 @@ const internalDeploySiteRaw = async ({
bucketName,
prefix: subFolder,
}),
bundleSite({
BundlerInternals.internalBundle({
publicPath: `/${bucketName}/${subFolder}/`,
webpackOverride: options?.webpackOverride ?? ((f) => f),
enableCaching: options?.enableCaching ?? true,
publicDir: options?.publicDir,
rootDir: options?.rootDir,
ignoreRegisterRootWarning: options?.ignoreRegisterRootWarning,
publicDir: options?.publicDir ?? null,
rootDir: options?.rootDir ?? null,
ignoreRegisterRootWarning: options?.ignoreRegisterRootWarning ?? false,
onProgress: options?.onBundleProgress ?? (() => undefined),
entryPoint,
gitSource: options?.gitSource,
gitSource: options?.gitSource ?? null,
bufferStateDelayInMilliseconds: null,
maxTimelineTracks: null,
onDirectoryCreated: () => undefined,
onPublicDirCopyProgress: () => undefined,
onSymlinkDetected: () => undefined,
outDir: null,
}),
]);

Expand Down
20 changes: 17 additions & 3 deletions packages/cloudrun/src/cli/commands/sites/create.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import {CliInternals} from '@remotion/cli';
import {ConfigInternals} from '@remotion/cli/config';
import type {LogLevel} from '@remotion/renderer';
import {BrowserSafeApis} from '@remotion/renderer/client';
import {existsSync, lstatSync} from 'fs';
import {Internals} from 'remotion';
import {displaySiteInfo} from '.';
import {deploySite} from '../../../api/deploy-site';
import {internalDeploySiteRaw} from '../../../api/deploy-site';
import {getOrCreateBucket} from '../../../api/get-or-create-bucket';
import {BINARY_NAME} from '../../../shared/constants';
import {validateSiteName} from '../../../shared/validate-site-name';
Expand Down Expand Up @@ -137,7 +138,14 @@ export const sitesCreateSubcommand = async (
const bundleStart = Date.now();
let uploadStart = Date.now();

const {serveUrl, siteName, stats} = await deploySite({
const disableGitSource =
BrowserSafeApis.options.disableGitSourceOption.getValue({
commandLine: CliInternals.parsedCli,
}).value;

const gitSource = CliInternals.getGitSource({remotionRoot, disableGitSource});

const {serveUrl, siteName, stats} = await internalDeploySiteRaw({
entryPoint: file,
siteName: desiredSiteName,
bucketName,
Expand All @@ -162,8 +170,14 @@ export const sitesCreateSubcommand = async (
},
enableCaching: ConfigInternals.getWebpackCaching(),
webpackOverride: ConfigInternals.getWebpackOverrideFn() ?? ((f) => f),
gitSource: null,
gitSource,
bypassBucketNameValidation: true,
ignoreRegisterRootWarning: true,
publicDir: null,
rootDir: remotionRoot,
},
indent: false,
logLevel,
});

updateProgress(false);
Expand Down
4 changes: 4 additions & 0 deletions packages/docs/docs/cli/bundle.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,7 @@ Define the location of the resulting bundle. By default it is a folder called `.
### `--public-path`<AvailableFrom v="4.0.127"/>

<Options id="public-path" />

### `--disable-git-source`<AvailableFrom v="4.0.182" />

<Options id="disable-git-source" />
Loading

0 comments on commit 8983866

Please sign in to comment.