Skip to content

Commit fac6eef

Browse files
jorgeucanoSanderElias
authored andcommitted
fix: 🐛 fix install error (#174)
1 parent 925bcb4 commit fac6eef

File tree

2 files changed

+18
-13
lines changed

2 files changed

+18
-13
lines changed

schematics/scully/src/ng-add/index.ts

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,18 @@ export default (options: Schema): Rule => {
1515
addHttpClientModule(options),
1616
addPolyfill(options),
1717
injectIdleService(options),
18-
runScullySchmeatic(options),
18+
runScullySchematic(options),
1919
]);
2020
};
2121

2222
const addDependencies = (options: Schema) => (tree: Tree, context: SchematicContext) => {
2323
addPackageToPackageJson(tree, '@scullyio/scully', `${scullyVersion}`);
2424
const ngCoreVersionTag = getPackageVersionFromPackageJson(tree, '@angular/core');
25-
if (+ngCoreVersionTag.search((/(\^8|~8)/g)) === 0) {
26-
console.log('⚠ install ng-lib for Angular v8');
25+
if (+ngCoreVersionTag.search(/(\^8|~8)/g) === 0) {
26+
console.log('Install ng-lib for Angular v8');
2727
addPackageToPackageJson(tree, '@scullyio/ng-lib-8', `${scullyComponentVersion}`);
2828
} else {
29-
console.log('⚠ install ng-lib for Angular v9');
29+
console.log('Install ng-lib for Angular v9');
3030
addPackageToPackageJson(tree, '@scullyio/ng-lib', `${scullyComponentVersion}`);
3131
}
3232
context.logger.info('✅️ Added dependency');
@@ -38,13 +38,17 @@ const importHttpClientModule = (options: Schema) => (tree: Tree, context: Schema
3838
const recorder = tree.beginUpdate(mainFilePath);
3939

4040
const mainFileSource = getSourceFile(tree, mainFilePath);
41-
const importChange = insertImport(mainFileSource, mainFilePath, 'HttpClientModule', '@angular/common/http') as InsertChange;
41+
const importChange = insertImport(
42+
mainFileSource,
43+
mainFilePath,
44+
'HttpClientModule',
45+
'@angular/common/http'
46+
) as InsertChange;
4247
if (importChange.toAdd) {
4348
recorder.insertLeft(importChange.pos, importChange.toAdd);
4449
}
4550
tree.commitUpdate(recorder);
4651
return tree;
47-
4852
} catch (e) {
4953
console.log('error into import httpclient', e);
5054
}
@@ -77,9 +81,10 @@ const addPolyfill = (options: Schema) => (tree: Tree, context: SchematicContext)
7781
polyfills =
7882
polyfills +
7983
`\n/***************************************************************************************************
80-
\n* SCULLY IMPORTS
81-
\n*/
82-
\n// tslint:disable-next-line: align \nimport 'zone.js/dist/task-tracking';`;
84+
* SCULLY IMPORTS
85+
*/
86+
// tslint:disable-next-line: align
87+
import 'zone.js/dist/task-tracking';`;
8388
tree.overwrite(`${getSrc(tree)}/polyfills.ts`, polyfills);
8489
}
8590
};
@@ -129,7 +134,7 @@ const injectIdleService = (options: Schema) => (tree: Tree, context: SchematicCo
129134
}
130135
};
131136

132-
const runScullySchmeatic = (options: Schema) => (tree: Tree, context: SchematicContext) => {
137+
const runScullySchematic = (options: Schema) => (tree: Tree, context: SchematicContext) => {
133138
const nextRules: Rule[] = [];
134139
if (options.blog === true) {
135140
// @ts-ignore
@@ -138,8 +143,8 @@ const runScullySchmeatic = (options: Schema) => (tree: Tree, context: SchematicC
138143
// tslint:disable-next-line:no-shadowed-variable
139144
nextRules.push((tree: Tree, context: SchematicContext) => {
140145
const installTaskId = context.addTask(new NodePackageInstallTask());
141-
context.addTask(new RunSchematicTask('scully', options), [installTaskId]);
146+
context.addTask(new RunSchematicTask('run', options), [installTaskId]);
142147
});
143148

144-
chain(nextRules);
149+
return chain(nextRules);
145150
};

schematics/scully/src/utils/utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ export interface PackageJsonConfigPart<T> {
3939
export function addRouteToScullyConfig(scullyConfigJs: string, data: Data) {
4040
const baseRoute = data.route ? strings.dasherize(data.route) : strings.dasherize(data.name);
4141
const contentDirectoy = data.sourceDir ? strings.dasherize(data.sourceDir) : strings.dasherize(data.name);
42-
const addRoute = `\n '/${baseRoute}/:${data.slug}': {
42+
const addRoute = `\n '${baseRoute}:${data.slug}': {
4343
type: '${data.type}',
4444
${data.slug}: {
4545
folder: "./${contentDirectoy}"

0 commit comments

Comments
 (0)