Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions schematics/scully/src/ng-add/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,12 @@ export default (options: Schema): Rule => {
runScullySchematic(options),
]);
};

const addDependencies = () => (tree: Tree, context: SchematicContext) => {
addPackageToPackageJson(tree, '@scullyio/scully', `${scullyVersion}`);
const ngCoreVersionTag = getPackageVersionFromPackageJson(tree, '@angular/core');
if (+ngCoreVersionTag.search(/(\^8|~8)/g) === 0) {
context.logger.info('Install ng-lib for Angular v8');
addPackageToPackageJson(tree, '@scullyio/ng-lib-8', `${scullyComponentVersion}`);
addPackageToPackageJson(tree, '@scullyio/ng-lib-v8', `${scullyComponentVersion}`);
} else {
context.logger.info('Install ng-lib for Angular v9');
addPackageToPackageJson(tree, '@scullyio/ng-lib', `${scullyComponentVersion}`);
Expand Down Expand Up @@ -97,9 +96,14 @@ const injectIdleService = () => (tree: Tree, context: SchematicContext) => {
if (appComponent.includes('IdleMonitorService')) {
context.logger.info(`⚠️️ Skipping ${appComponentPath}`);
} else {
const idleImport = `import {IdleMonitorService} from '@scullyio/ng-lib';`;
const ngCoreVersionTag = getPackageVersionFromPackageJson(tree, '@angular/core');
let v8 = '';
if (+ngCoreVersionTag.search(/(\^8|~8)/g) === 0) {
v8 = '-v8';
}
const idleImport = `import {IdleMonitorService} from '@scullyio/ng-lib${v8}';`;
// add
const idImport = `${idleImport} \n ${appComponent}`;
const idImport = `${idleImport}\n${appComponent}`;
const idle = 'private idle: IdleMonitorService';
let output = '';
// check if exist
Expand Down