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

feat(@schematics/angular): editor option #463

Closed
wants to merge 3 commits into from
Closed
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
1 change: 1 addition & 0 deletions packages/schematics/angular/ng-new/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: '',
Expand Down
4 changes: 4 additions & 0 deletions packages/schematics/angular/ng-new/schema.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,4 +67,8 @@ export interface Schema {
* Skip creating spec files.
*/
skipTests?: boolean;
/**
* Specifies the editor used, for specific configuration.
*/
editor?: ('vscode');
}
5 changes: 5 additions & 0 deletions packages/schematics/angular/ng-new/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,11 @@
"type": "boolean",
"default": false,
"alias": "S"
},
"editor": {
"description": "Specifies the editor used, for specific configuration.",
"enum": ["vscode"],
"type": "string"
}
},
"required": [
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"tslint.alwaysShowRuleFailuresAsWarnings": true
}
3 changes: 3 additions & 0 deletions packages/schematics/angular/workspace/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ import {
SchematicContext,
Tree,
apply,
filter,
mergeWith,
noop,
template,
url,
} from '@angular-devkit/schematics';
Expand All @@ -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,
Expand Down
8 changes: 8 additions & 0 deletions packages/schematics/angular/workspace/index_spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
});
4 changes: 4 additions & 0 deletions packages/schematics/angular/workspace/schema.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}
5 changes: 5 additions & 0 deletions packages/schematics/angular/workspace/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": [
Expand Down