mirror of
https://github.com/angular/angular-cli.git
synced 2025-05-14 01:08:29 +08:00
Revert "feat(@angular/cli): Add VsCode extension recommendations"
This reverts commit d9166b04fccc708bc3856a6b243a8752120f312d.
This commit is contained in:
parent
71428bd9cb
commit
4a093e5e38
@ -29,11 +29,6 @@
|
||||
"version": "7.0.3",
|
||||
"factory": "./update-7/index#updateDevkitBuildNgPackagr",
|
||||
"description": "Update an Angular CLI project to version 7."
|
||||
},
|
||||
"migration-07": {
|
||||
"version": "8.0.0",
|
||||
"factory": "./update-vscode-recommendations/update-8.0.0",
|
||||
"description": "Update an Angular CLI project to version 8.0.0"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,41 +0,0 @@
|
||||
/**
|
||||
* @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 { Rule, Tree } from '@angular-devkit/schematics';
|
||||
|
||||
export function readJsonInTree<T>(host: Tree, path: string): T {
|
||||
if (!host.exists(path)) {
|
||||
throw new Error(`Cannot find ${path}`);
|
||||
}
|
||||
|
||||
const json = host.read(path);
|
||||
if (!json) {
|
||||
throw new Error(`Cannot read ${path}`);
|
||||
}
|
||||
|
||||
return JSON.parse(json.toString('utf-8'));
|
||||
}
|
||||
|
||||
export function serializeJson<T>(json: T): string {
|
||||
return `${JSON.stringify(json, null, 2)}\n`;
|
||||
}
|
||||
|
||||
export function updateJsonInTree<T, O = T>(
|
||||
path: string,
|
||||
callback: (json: T) => O,
|
||||
): Rule {
|
||||
return (host: Tree): Tree => {
|
||||
if (!host.exists(path)) {
|
||||
host.create(path, serializeJson(callback({} as T)));
|
||||
|
||||
return host;
|
||||
}
|
||||
host.overwrite(path, serializeJson(callback(readJsonInTree(host, path))));
|
||||
|
||||
return host;
|
||||
};
|
||||
}
|
@ -1,27 +0,0 @@
|
||||
/**
|
||||
* @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 { Rule, chain } from '@angular-devkit/schematics';
|
||||
import { updateJsonInTree } from './ast-utils';
|
||||
|
||||
export default function (): Rule {
|
||||
return chain([addExtensionRecommendations]);
|
||||
}
|
||||
|
||||
const addExtensionRecommendations = updateJsonInTree(
|
||||
'.vscode/extensions.json',
|
||||
(json: { recommendations?: string[] }) => {
|
||||
['angular.ng-template', 'ms-vscode.vscode-typescript-tslint-plugin'].forEach(extension => {
|
||||
json.recommendations = json.recommendations || [];
|
||||
if (!json.recommendations.includes(extension)) {
|
||||
json.recommendations.push(extension);
|
||||
}
|
||||
});
|
||||
|
||||
return json;
|
||||
},
|
||||
);
|
@ -1,62 +0,0 @@
|
||||
/**
|
||||
* @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 { Tree } from '@angular-devkit/schematics';
|
||||
import { SchematicTestRunner } from '@angular-devkit/schematics/testing';
|
||||
import { readJsonInTree, serializeJson, updateJsonInTree } from './ast-utils';
|
||||
|
||||
describe('Update 8.0.0', () => {
|
||||
let initialTree: Tree;
|
||||
let schematicRunner: SchematicTestRunner;
|
||||
|
||||
beforeEach(() => {
|
||||
initialTree = Tree.empty();
|
||||
|
||||
initialTree.create(
|
||||
'package.json',
|
||||
serializeJson({
|
||||
devDependencies: { '@angular/cli': '7.1.0', typescript: '~3.1.0' },
|
||||
}),
|
||||
);
|
||||
|
||||
schematicRunner = new SchematicTestRunner(
|
||||
'migrations',
|
||||
require.resolve('../migration-collection.json'),
|
||||
);
|
||||
});
|
||||
|
||||
it('should add vscode extension recommendations', async () => {
|
||||
const result = await schematicRunner
|
||||
.runSchematicAsync('migration-07', {}, initialTree)
|
||||
.toPromise();
|
||||
|
||||
expect(readJsonInTree(result, '.vscode/extensions.json')).toEqual({
|
||||
recommendations: ['angular.ng-template', 'ms-vscode.vscode-typescript-tslint-plugin'],
|
||||
});
|
||||
});
|
||||
|
||||
it('should add to existing vscode extension recommendations', async () => {
|
||||
initialTree = await schematicRunner
|
||||
.callRule(
|
||||
updateJsonInTree('.vscode/extensions.json', () => ({
|
||||
recommendations: [
|
||||
'eamodio.gitlens', 'angular.ng-template', 'ms-vscode.vscode-typescript-tslint-plugin'],
|
||||
})),
|
||||
initialTree,
|
||||
)
|
||||
.toPromise();
|
||||
|
||||
const result = await schematicRunner
|
||||
.runSchematicAsync('migration-07', {}, initialTree)
|
||||
.toPromise();
|
||||
|
||||
expect(readJsonInTree(result, '.vscode/extensions.json')).toEqual({
|
||||
recommendations: [
|
||||
'eamodio.gitlens', 'angular.ng-template', 'ms-vscode.vscode-typescript-tslint-plugin'],
|
||||
});
|
||||
});
|
||||
});
|
@ -1,6 +0,0 @@
|
||||
{
|
||||
"recommendations": [
|
||||
"angular.ng-template",
|
||||
"ms-vscode.vscode-typescript-tslint-plugin"
|
||||
]
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user