Skip to content

Commit

Permalink
Bail out if app-config is not under pre-defined location
Browse files Browse the repository at this point in the history
  • Loading branch information
onurtemizkan committed Jan 31, 2025
1 parent f56bbc8 commit 6baf639
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions src/angular/sdk-setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// @ts-expect-error - magicast is ESM and TS complains about that. It works though
import { loadFile, writeFile } from 'magicast';

import * as fs from 'fs';
import * as path from 'path';

// @ts-expect-error - clack is ESM and TS complains about that. It works though
Expand All @@ -11,6 +12,8 @@ import chalk from 'chalk';
import { updateAppConfigMod } from './codemods/app-config';
import type { SemVer } from 'semver';
import { hasSentryContent } from '../utils/ast-utils';
import * as Sentry from '@sentry/node';

import type { namedTypes as t } from 'ast-types';

export async function updateAppConfig(
Expand All @@ -25,6 +28,25 @@ export async function updateAppConfig(
appConfigFilename,
);

if (!fs.existsSync(appConfigPath)) {
Sentry.setTag('angular-app-config-found', false);

clack.log.warn(
`File ${chalk.cyan(
appConfigFilename,
)} not found. Skipping adding Sentry functionality.`,
);

clack.log.warn(`Please refer to the documentation for manual setup:
${chalk.underline(
'https://docs.sentry.io/platforms/javascript/guides/angular/#configure',
)}`);

return;
}

Sentry.setTag('angular-app-config-found', true);

const appConfig = await loadFile(appConfigPath);

if (hasSentryContent(appConfig.$ast as t.Program)) {
Expand Down

0 comments on commit 6baf639

Please sign in to comment.