Skip to content

Commit

Permalink
fix: lint
Browse files Browse the repository at this point in the history
  • Loading branch information
Badisi committed Apr 13, 2024
1 parent f997dfa commit 117a67f
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 19 deletions.
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion projects/lib/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
"@angular/router": ">= 15"
},
"dependencies": {
"@hug/ngx-schematics-utilities": "^9.0.0",
"@hug/ngx-schematics-utilities": "^9.0.1",
"@sentry/angular-ivy": "^7.110.0",
"@sentry/cli": "2.31.0",
"tslib": "^2.6.2"
Expand Down
23 changes: 11 additions & 12 deletions projects/lib/schematics/ng-add/index.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
import { tags } from '@angular-devkit/core';
import { chain, Rule } from '@angular-devkit/schematics';
import {
addImportToFile, addImportToNgModule, addProviderToBootstrapApplication, application,
ChainableProjectContext, createOrUpdateFile, getProjectMainPath, isProjectStandalone, logAction, schematic, workspace
addImportToFile, addImportToNgModule, addProviderToBootstrapApplication, application, ChainableApplicationContext,
createOrUpdateFile, logAction, schematic, workspace
} from '@hug/ngx-schematics-utilities';

import { NgAddOptions } from './ng-add-options';

export const initSentry = (context: ChainableProjectContext, options: NgAddOptions): Rule => {
const mainTsPath = getProjectMainPath(context.tree, context.project.name);
const mainTsContent = context.tree.read(mainTsPath)?.toString('utf-8') ?? '';
export const initSentry = ({ tree, project }: ChainableApplicationContext, options: NgAddOptions): Rule => {
const mainTsContent = tree.read(project.mainFilePath)?.toString('utf-8') ?? '';
const rules: Rule[] = [];

// Initialize Sentry in main.ts
Expand All @@ -33,21 +32,21 @@ export const initSentry = (context: ChainableProjectContext, options: NgAddOptio
newContent += mainTsContent.substring(insertAtPosition);

rules.push(
createOrUpdateFile(mainTsPath, newContent),
createOrUpdateFile(project.mainFilePath, newContent),
logAction('Have a look at `main.ts` file and update Sentry configuration according to your needs')
);
}
rules.push(
addImportToFile(mainTsPath, 'isDevMode', '@angular/core'),
addImportToFile(mainTsPath, 'packageJson', '../package.json', true)
addImportToFile(project.mainFilePath, 'isDevMode', '@angular/core'),
addImportToFile(project.mainFilePath, 'packageJson', '../package.json', true)
);

// Provide library
rules.push(addImportToFile(mainTsPath, 'initSentry', '@hug/ngx-sentry'));
if (isProjectStandalone(context.tree, context.project.name)) {
rules.push(addProviderToBootstrapApplication(mainTsPath, 'provideSentry()', '@hug/ngx-sentry'));
rules.push(addImportToFile(project.mainFilePath, 'initSentry', '@hug/ngx-sentry'));
if (project.isStandalone) {
rules.push(addProviderToBootstrapApplication(project.mainFilePath, 'provideSentry()', '@hug/ngx-sentry'));
} else {
const appModulePath = context.project.pathFromSourceRoot('app/app.module.ts');
const appModulePath = project.pathFromSourceRoot('app/app.module.ts');
rules.push(addImportToNgModule(appModulePath, 'NgxSentryModule.forRoot()', '@hug/ngx-sentry'));
}

Expand Down
4 changes: 2 additions & 2 deletions projects/lib/schematics/ng-add/ng-add.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { UnitTestTree } from '@angular-devkit/schematics/testing';
import { getProjectFromWorkspace, ProjectDefinition } from '@hug/ngx-schematics-utilities';
import { ApplicationDefinition, getProjectFromWorkspace } from '@hug/ngx-schematics-utilities';

import { appTest1, appTest2, getCleanAppTree, runner } from '../schematics.spec';
import { NgAddOptions } from './ng-add-options';
Expand All @@ -12,7 +12,7 @@ const joc = jasmine.objectContaining;
let defaultOptions: NgAddOptions;
let tree: UnitTestTree;
let nbFiles: number;
let project: ProjectDefinition;
let project: ApplicationDefinition;

beforeEach(async () => {
tree = await getCleanAppTree(useWorkspace, useStandalone);
Expand Down

0 comments on commit 117a67f

Please sign in to comment.