diff --git a/packages/schematics/angular/ng-new/index.ts b/packages/schematics/angular/ng-new/index.ts index 7e44a9682a..8ccf55f8bc 100644 --- a/packages/schematics/angular/ng-new/index.ts +++ b/packages/schematics/angular/ng-new/index.ts @@ -40,6 +40,7 @@ export default function (options: NgNewOptions): Rule { name: options.name, version: options.version, newProjectRoot: options.newProjectRoot || 'projects', + editor: options.editor, }; const applicationOptions: ApplicationOptions = { projectRoot: '', diff --git a/packages/schematics/angular/ng-new/schema.d.ts b/packages/schematics/angular/ng-new/schema.d.ts index dfdc8f1082..03791fe23a 100644 --- a/packages/schematics/angular/ng-new/schema.d.ts +++ b/packages/schematics/angular/ng-new/schema.d.ts @@ -67,4 +67,8 @@ export interface Schema { * Skip creating spec files. */ skipTests?: boolean; + /** + * Specifies the editor used, for specific configuration. + */ + editor?: ('vscode'); } diff --git a/packages/schematics/angular/ng-new/schema.json b/packages/schematics/angular/ng-new/schema.json index 9a53a97e89..e3608028e0 100644 --- a/packages/schematics/angular/ng-new/schema.json +++ b/packages/schematics/angular/ng-new/schema.json @@ -111,6 +111,11 @@ "type": "boolean", "default": false, "alias": "S" + }, + "editor": { + "description": "Specifies the editor used, for specific configuration.", + "enum": ["vscode"], + "type": "string" } }, "required": [ diff --git a/packages/schematics/angular/workspace/files/__dot__vscode/settings.json b/packages/schematics/angular/workspace/files/__dot__vscode/settings.json new file mode 100644 index 0000000000..d7af577958 --- /dev/null +++ b/packages/schematics/angular/workspace/files/__dot__vscode/settings.json @@ -0,0 +1,3 @@ +{ + "tslint.alwaysShowRuleFailuresAsWarnings": true +} diff --git a/packages/schematics/angular/workspace/index.ts b/packages/schematics/angular/workspace/index.ts index 98f9aa0069..8047766c71 100644 --- a/packages/schematics/angular/workspace/index.ts +++ b/packages/schematics/angular/workspace/index.ts @@ -11,7 +11,9 @@ import { SchematicContext, Tree, apply, + filter, mergeWith, + noop, template, url, } from '@angular-devkit/schematics'; @@ -22,6 +24,7 @@ export default function (options: WorkspaceOptions): Rule { return (host: Tree, context: SchematicContext) => { return mergeWith(apply(url('./files'), [ + options.editor === 'vscode' ? noop() : filter(path => path.indexOf('vscode') === -1), template({ utils: strings, ...options, diff --git a/packages/schematics/angular/workspace/index_spec.ts b/packages/schematics/angular/workspace/index_spec.ts index 669403396c..33070f24ec 100644 --- a/packages/schematics/angular/workspace/index_spec.ts +++ b/packages/schematics/angular/workspace/index_spec.ts @@ -55,4 +55,12 @@ describe('Workspace Schematic', () => { expect(pkg.dependencies['zone.js']).toEqual(latestVersions.ZoneJs); expect(pkg.devDependencies['typescript']).toEqual(latestVersions.TypeScript); }); + + it('should create VS Code settings', () => { + const options = { ...defaultOptions, editor: 'vscode' }; + + const tree = schematicRunner.runSchematic('workspace', options); + const files = tree.files; + expect(files.indexOf('/.vscode/settings.json')).toBeGreaterThanOrEqual(0); + }); }); diff --git a/packages/schematics/angular/workspace/schema.d.ts b/packages/schematics/angular/workspace/schema.d.ts index 0db451ca11..cd810ac8cd 100644 --- a/packages/schematics/angular/workspace/schema.d.ts +++ b/packages/schematics/angular/workspace/schema.d.ts @@ -35,4 +35,8 @@ export interface Schema { * The version of the Angular CLI to use. */ version?: string; + /** + * Specifies the editor used, for specific configuration. + */ + editor?: ('vscode'); } diff --git a/packages/schematics/angular/workspace/schema.json b/packages/schematics/angular/workspace/schema.json index 81e2a50423..0b7b4b285a 100644 --- a/packages/schematics/angular/workspace/schema.json +++ b/packages/schematics/angular/workspace/schema.json @@ -65,6 +65,11 @@ "type": "string", "description": "The version of the Angular CLI to use.", "visible": false + }, + "editor": { + "description": "Specifies the editor used, for specific configuration.", + "enum": ["vscode"], + "type": "string" } }, "required": [