Skip to content

Commit

Permalink
fix(generators): root package dependencies platform handling
Browse files Browse the repository at this point in the history
closes #28
  • Loading branch information
NathanWalker committed Sep 3, 2018
1 parent 5559bb9 commit 6202f2c
Show file tree
Hide file tree
Showing 7 changed files with 287 additions and 251 deletions.
4 changes: 2 additions & 2 deletions src/app.ionic/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
schematic,
noop,
} from '@angular-devkit/schematics';
import { stringUtils, prerun, getNpmScope, getPrefix, addRootDepsIonic, updatePackageScripts, updateAngularProjects, updateNxProjects, formatFiles } from '../utils';
import { stringUtils, prerun, getNpmScope, getPrefix, addRootDeps, updatePackageScripts, updateAngularProjects, updateNxProjects, formatFiles } from '../utils';
import { Schema as ApplicationOptions } from './schema';

export default function (options: ApplicationOptions) {
Expand All @@ -28,7 +28,7 @@ export default function (options: ApplicationOptions) {
// create app files
(tree: Tree, context: SchematicContext) => addAppFiles(options, appPath)(tree, context),
// add root package dependencies
(tree: Tree) => addRootDepsIonic(tree),
(tree: Tree) => addRootDeps(tree, {ionic: true}),
// add start/clean scripts
(tree: Tree) => {
const scripts = {};
Expand Down
2 changes: 1 addition & 1 deletion src/app.nativescript/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export default function (options: ApplicationOptions) {
path: `apps/${appPath}/app`,
}),
// add root package dependencies
(tree: Tree) => addRootDeps(tree),
(tree: Tree) => addRootDeps(tree, {nativescript: true}),
// add start/clean scripts
(tree: Tree) => {
const scripts = {};
Expand Down
2 changes: 1 addition & 1 deletion src/pipe/_files/__name__.pipe.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Pipe, PipeTransform } from '@angular/core';

@Pipe({
name: '<%= name %>'
name: '<%= utils.camelize(name) %>'
})
export class <%= utils.classify(name) %>Pipe implements PipeTransform {
transform(value: any): string {
Expand Down
50 changes: 49 additions & 1 deletion src/pipe/index_spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ describe("pipe schematic", () => {
},
tree
);
const options: GenerateOptions = { ...defaultOptions };
let options: GenerateOptions = { ...defaultOptions };
tree = schematicRunner.runSchematic("pipe", options, tree);
const files = tree.files;
// console.log(files.slice(91,files.length));
Expand All @@ -67,6 +67,54 @@ describe("pipe schematic", () => {
expect(content.indexOf(`name: 'truncate'`)).toBeGreaterThanOrEqual(0);
});

it("should create pipe in libs and handle camel case properly", () => {
// console.log('appTree:', appTree);
let tree = schematicRunner.runSchematic(
"xplat",
{
prefix: "tt"
},
appTree
);
tree = schematicRunner.runSchematic(
"app.nativescript",
{
name: "viewer",
prefix: "tt"
},
tree
);
tree = schematicRunner.runSchematic(
"feature",
{
name: "foo",
platforms: "nativescript,web"
},
tree
);
let options: GenerateOptions = {
...defaultOptions,
name: 'test-with-dashes'
};
tree = schematicRunner.runSchematic("pipe", options, tree);
const files = tree.files;
// console.log(files.slice(91,files.length));

// component
expect(
files.indexOf("/libs/features/ui/pipes/test-with-dashes.pipe.ts")
).toBeGreaterThanOrEqual(0);

// file content
let content = getFileContent(
tree,
"/libs/features/ui/pipes/test-with-dashes.pipe.ts"
);
// console.log(content);
expect(content.indexOf(`@Pipe({`)).toBeGreaterThanOrEqual(0);
expect(content.indexOf(`name: 'testWithDashes'`)).toBeGreaterThanOrEqual(0);
});

it("should THROW if feature module does not exist in libs", () => {
// console.log('appTree:', appTree);
let tree = schematicRunner.runSchematic(
Expand Down
Loading

0 comments on commit 6202f2c

Please sign in to comment.