Skip to content

Commit

Permalink
feat(remix): Pass org, project, url to upload-sourcemaps script.
Browse files Browse the repository at this point in the history
  • Loading branch information
onurtemizkan committed Sep 8, 2023
1 parent 523b7fa commit 68362aa
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 19 deletions.
19 changes: 8 additions & 11 deletions src/remix/remix-wizard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,8 @@ async function runRemixWizardWithTelemetry(
// We expect `@remix-run/dev` to be installed for every Remix project
await ensurePackageIsInstalled(packageJson, '@remix-run/dev', 'Remix');

const { selectedProject, authToken } = await getOrAskForProjectData(
options,
'javascript-remix',
);
const { selectedProject, authToken, sentryUrl } =
await getOrAskForProjectData(options, 'javascript-remix');

await traceStep('Install Sentry SDK', () =>
installPackage({
Expand All @@ -70,16 +68,15 @@ async function runRemixWizardWithTelemetry(
const isTS = isUsingTypeScript();
const isV2 = isRemixV2(remixConfig, packageJson);

await addSentryCliConfig(
authToken,
sourceMapsCliSetupConfig,
selectedProject.organization.slug,
selectedProject.name,
);
await addSentryCliConfig(authToken, sourceMapsCliSetupConfig);

await traceStep('Update build script for sourcemap uploads', async () => {
try {
await updateBuildScript();
await updateBuildScript({
org: selectedProject.organization.slug,
project: selectedProject.name,
url: sentryUrl,
});
} catch (e) {
clack.log
.warn(`Could not update build script to generate and upload sourcemaps.
Expand Down
10 changes: 8 additions & 2 deletions src/remix/sdk-setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,11 @@ export async function instrumentRootRoute(
/* eslint-enable @typescript-eslint/no-unsafe-member-access */
}

export async function updateBuildScript(): Promise<void> {
export async function updateBuildScript(args: {
org: string;
project: string;
url?: string;
}): Promise<void> {
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
// Add sourcemaps option to build script
const packageJsonPath = path.join(process.cwd(), 'package.json');
Expand All @@ -166,7 +170,9 @@ export async function updateBuildScript(): Promise<void> {

if (!packageJson.scripts.build) {
packageJson.scripts.build =
'remix build --sourcemap && sentry-upload-sourcemaps';
`remix build --sourcemap && sentry-upload-sourcemaps --org ${args.org} --project ${args.project}` +
(args.url ? ` --url ${args.url}` : '');

// eslint-disable-next-line @typescript-eslint/no-unsafe-call
} else if (packageJson.scripts.build.includes('remix build')) {
// eslint-disable-next-line @typescript-eslint/no-unsafe-call
Expand Down
6 changes: 0 additions & 6 deletions src/utils/clack-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -282,8 +282,6 @@ async function addOrgAndProjectToSentryCliRc(
export async function addSentryCliConfig(
authToken: string,
setupConfig: CliSetupConfig = sourceMapsCliSetupConfig,
orgSlug?: string,
projectSlug?: string,
): Promise<void> {
const configExists = fs.existsSync(
path.join(process.cwd(), setupConfig.filename),
Expand Down Expand Up @@ -351,10 +349,6 @@ export async function addSentryCliConfig(
}
}

if (orgSlug && projectSlug) {
await addOrgAndProjectToSentryCliRc(orgSlug, projectSlug, setupConfig);
}

await addAuthTokenFileToGitIgnore(setupConfig.filename);
}

Expand Down

0 comments on commit 68362aa

Please sign in to comment.