Skip to content
This repository was archived by the owner on Apr 4, 2025. It is now read-only.

App root schematics #149

Merged
merged 2 commits into from
Sep 14, 2017
Merged
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,3 @@ export class PurifyPlugin {
});
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -203,4 +203,3 @@ describe('scrub-file', () => {
});
});
});

1 change: 0 additions & 1 deletion packages/angular_devkit/schematics/src/rules/call.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,4 +68,3 @@ export function callRule(rule: Rule,
}
});
}

1 change: 0 additions & 1 deletion packages/angular_devkit/schematics/src/sink/dryrun.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,4 +114,3 @@ export class DryRunSink extends FileSystemSink {
return Observable.empty<void>();
}
}

1 change: 0 additions & 1 deletion packages/angular_devkit/schematics/src/tree/action_spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,4 +77,3 @@ describe('Action', () => {
});
});
});

1 change: 0 additions & 1 deletion packages/angular_devkit/schematics/tools/description.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,3 @@ export declare type FileSystemSchematicDesc
= SchematicDescription<FileSystemCollectionDescription, FileSystemSchematicDescription>;
export declare type FileSystemSchematicContext
= TypedSchematicContext<FileSystemCollectionDescription, FileSystemSchematicDescription>;

Original file line number Diff line number Diff line change
Expand Up @@ -118,4 +118,3 @@ export class RegistryEngineHost extends FileSystemEngineHostBase {
return desc as FileSystemSchematicDesc;
}
}

1 change: 1 addition & 0 deletions packages/schematics/angular/class/schema.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

export interface Schema {
name: string;
appRoot?: string;
path?: string;
sourceDir?: string;
/**
Expand Down
3 changes: 3 additions & 0 deletions packages/schematics/angular/class/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
"name": {
"type": "string"
},
"appRoot": {
"type": "string"
},
"path": {
"type": "string",
"default": "app"
Expand Down
1 change: 1 addition & 0 deletions packages/schematics/angular/component/schema.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

export interface Schema {
path?: string;
appRoot?: string;
sourceDir?: string;
name: string;
/**
Expand Down
3 changes: 3 additions & 0 deletions packages/schematics/angular/component/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
"type": "string",
"default": "app"
},
"appRoot": {
"type": "string"
},
"sourceDir": {
"type": "string",
"default": "src",
Expand Down
1 change: 1 addition & 0 deletions packages/schematics/angular/directive/schema.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
export interface Schema {
name: string;
path?: string;
appRoot?: string;
/**
* The prefix to apply to generated selectors.
*/
Expand Down
3 changes: 3 additions & 0 deletions packages/schematics/angular/directive/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
"type": "string",
"default": "app"
},
"appRoot": {
"type": "string"
},
"prefix": {
"type": "string",
"description": "The prefix to apply to generated selectors.",
Expand Down
1 change: 1 addition & 0 deletions packages/schematics/angular/enum/schema.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@
export interface Schema {
name: string;
path?: string;
appRoot?: string;
sourceDir?: string;
}
3 changes: 3 additions & 0 deletions packages/schematics/angular/enum/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
"type": "string",
"default": "app"
},
"appRoot": {
"type": "string"
},
"sourceDir": {
"type": "string",
"default": "src"
Expand Down
1 change: 1 addition & 0 deletions packages/schematics/angular/guard/schema.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,6 @@ export interface Schema {
*/
module?: string;
path?: string;
appRoot?: string;
sourceDir?: string;
}
3 changes: 3 additions & 0 deletions packages/schematics/angular/guard/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@
"type": "string",
"default": "app"
},
"appRoot": {
"type": "string"
},
"sourceDir": {
"type": "string",
"default": "src"
Expand Down
1 change: 1 addition & 0 deletions packages/schematics/angular/interface/schema.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
export interface Schema {
name: string;
path?: string;
appRoot?: string;
sourceDir?: string;
/**
* Specifies the prefix to use.
Expand Down
3 changes: 3 additions & 0 deletions packages/schematics/angular/interface/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
"type": "string",
"default": "app"
},
"appRoot": {
"type": "string"
},
"sourceDir": {
"type": "string",
"default": "src"
Expand Down
2 changes: 2 additions & 0 deletions packages/schematics/angular/module/schema.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@
export interface Schema {
name: string;
path?: string;
appRoot?: string;
sourceDir?: string;
routing?: boolean;
routingScope?: ('Child' | 'Root');
spec?: boolean;
flat?: boolean;
commonModule?: boolean;
Expand Down
3 changes: 3 additions & 0 deletions packages/schematics/angular/module/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
"type": "string",
"default": "app"
},
"appRoot": {
"type": "string"
},
"sourceDir": {
"type": "string",
"default": "src"
Expand Down
1 change: 1 addition & 0 deletions packages/schematics/angular/pipe/schema.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
export interface Schema {
name: string;
path?: string;
appRoot?: string;
sourceDir?: string;
/**
* Flag to indicate if a dir is created.
Expand Down
3 changes: 3 additions & 0 deletions packages/schematics/angular/pipe/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
"type": "string",
"default": "app"
},
"appRoot": {
"type": "string"
},
"sourceDir": {
"type": "string",
"default": "src"
Expand Down
1 change: 1 addition & 0 deletions packages/schematics/angular/service/schema.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
export interface Schema {
name: string;
path?: string;
appRoot?: string;
sourceDir?: string;
/**
* Flag to indicate if a dir is created.
Expand Down
3 changes: 3 additions & 0 deletions packages/schematics/angular/service/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
"type": "string",
"default": "app"
},
"appRoot": {
"type": "string"
},
"sourceDir": {
"type": "string",
"default": "src"
Expand Down
1 change: 0 additions & 1 deletion packages/schematics/angular/utility/ast-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -399,4 +399,3 @@ export function addBootstrapToModule(source: ts.SourceFile,
importPath: string): Change[] {
return _addSymbolToNgModuleMetadata(source, modulePath, 'bootstrap', classifiedName, importPath);
}

3 changes: 2 additions & 1 deletion packages/schematics/angular/utility/find-module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export interface ModuleOptions {
sourceDir?: string;
path?: string;
skipImport?: boolean;
appRoot?: string;
}


Expand All @@ -35,7 +36,7 @@ export function findModuleFromOptions(host: Tree,
return normalizePath(findModule(host, pathToCheck));
} else {
const modulePath = normalizePath(
options.sourceDir + '/' + options.path + '/' + options.module);
options.sourceDir + '/' + (options.appRoot || options.path) + '/' + options.module);
const moduleBaseName = normalizePath(modulePath).split('/').pop();

if (host.exists(modulePath)) {
Expand Down
1 change: 0 additions & 1 deletion packages/schematics/angular/utility/route-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,4 +87,3 @@ export function insertImport(source: ts.SourceFile, fileToEdit: string, symbolNa
ts.SyntaxKind.StringLiteral,
);
}

59 changes: 59 additions & 0 deletions rules/singleEofLineRule.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
import * as Lint from 'tslint';
import * as ts from 'typescript';


export class Rule extends Lint.Rules.AbstractRule {
public static metadata: Lint.IRuleMetadata = {
ruleName: 'single-eof-line',
type: 'style',
description: `Ensure the file ends with a single new line.`,
rationale: `This is similar to eofline, but ensure an exact count instead of just any new
line.`,
options: null,
optionsDescription: `Two integers indicating minimum and maximum number of new lines.`,
typescriptOnly: false,
};

public static FAILURE_STRING = 'You need to have a single blank line at end of file.';

public apply(sourceFile: ts.SourceFile): Lint.RuleFailure[] {
const length = sourceFile.text.length;
if (length === 0) {
// Allow empty files.
return [];
}

const matchEof = /\r?\n((\r?\n)*)$/.exec(sourceFile.text);
if (!matchEof) {
const lines = sourceFile.getLineStarts();
const fix = Lint.Replacement.appendText(
length,
sourceFile.text[lines[1] - 2] === '\r' ? '\r\n' : '\n',
);

return [
new Lint.RuleFailure(sourceFile, length, length, Rule.FAILURE_STRING, this.ruleName, fix),
];
} else if (matchEof[1]) {
const lines = sourceFile.getLineStarts();
const fix = Lint.Replacement.replaceFromTo(
matchEof.index,
length,
sourceFile.text[lines[1] - 2] === '\r' ? '\r\n' : '\n',
);

return [
new Lint.RuleFailure(sourceFile, length, length, Rule.FAILURE_STRING, this.ruleName, fix),
];
}

return [];
}
}
2 changes: 2 additions & 0 deletions tslint.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
"import-groups": true,
"non-null-operator": true,
"no-global-tslint-disable": true,
"single-eof-line": true,


"import-blacklist": [
true,
Expand Down