parent
7a6237bc50
commit
4142db0828
|
@ -8,12 +8,12 @@
|
|||
* @fileoverview Schematics for ng-new project that builds with Bazel.
|
||||
*/
|
||||
|
||||
import { SchematicContext, apply, applyTemplates, chain, mergeWith, move, Rule, schematic, Tree, url, SchematicsException, UpdateRecorder, } from '@angular-devkit/schematics';
|
||||
import { parseJsonAst, JsonAstObject, strings, JsonValue } from '@angular-devkit/core';
|
||||
import { findPropertyInAstObject, insertPropertyInAstObjectInOrder } from '@schematics/angular/utility/json-utils';
|
||||
import { validateProjectName } from '@schematics/angular/utility/validation';
|
||||
import { getWorkspacePath } from '@schematics/angular/utility/config';
|
||||
import { Schema } from './schema';
|
||||
import {SchematicContext, apply, applyTemplates, chain, mergeWith, move, Rule, schematic, Tree, url, SchematicsException, UpdateRecorder,} from '@angular-devkit/schematics';
|
||||
import {parseJsonAst, JsonAstObject, strings, JsonValue} from '@angular-devkit/core';
|
||||
import {findPropertyInAstObject, insertPropertyInAstObjectInOrder} from '@schematics/angular/utility/json-utils';
|
||||
import {validateProjectName} from '@schematics/angular/utility/validation';
|
||||
import {getWorkspacePath} from '@schematics/angular/utility/config';
|
||||
import {Schema} from './schema';
|
||||
|
||||
/**
|
||||
* Packages that build under Bazel require additional dev dependencies. This
|
||||
|
@ -40,7 +40,7 @@ function addDevDependenciesToPackageJson(options: Schema) {
|
|||
}
|
||||
const angularCoreVersion = angularCoreNode.value as string;
|
||||
|
||||
const devDependencies: { [ k: string ]: string } = {
|
||||
const devDependencies: {[k: string]: string} = {
|
||||
'@angular/bazel': angularCoreVersion,
|
||||
// TODO(kyliau): Consider moving this to latest-versions.ts
|
||||
'@bazel/bazel': '^0.22.1',
|
||||
|
@ -51,7 +51,7 @@ function addDevDependenciesToPackageJson(options: Schema) {
|
|||
|
||||
const recorder = host.beginUpdate(packageJson);
|
||||
for (const packageName of Object.keys(devDependencies)) {
|
||||
const version = devDependencies[ packageName ];
|
||||
const version = devDependencies[packageName];
|
||||
const indent = 4;
|
||||
insertPropertyInAstObjectInOrder(recorder, devDeps, packageName, version, indent);
|
||||
}
|
||||
|
@ -109,7 +109,7 @@ function replacePropertyInAstObject(
|
|||
if (property === null) {
|
||||
throw new Error(`Property ${propertyName} does not exist in JSON object`);
|
||||
}
|
||||
const { start, text } = property;
|
||||
const {start, text} = property;
|
||||
recorder.remove(start.offset, text.length);
|
||||
const indentStr = '\n' +
|
||||
' '.repeat(indent);
|
||||
|
@ -119,7 +119,7 @@ function replacePropertyInAstObject(
|
|||
|
||||
function updateAngularJsonToUseBazelBuilder(options: Schema): Rule {
|
||||
return (host: Tree, context: SchematicContext) => {
|
||||
const { name } = options;
|
||||
const {name} = options;
|
||||
const workspacePath = getWorkspacePath(host);
|
||||
if (!workspacePath) {
|
||||
throw new Error('Could not find angular.json');
|
||||
|
@ -169,7 +169,7 @@ function updateAngularJsonToUseBazelBuilder(options: Schema): Rule {
|
|||
replacePropertyInAstObject(
|
||||
recorder, architect, 'test', {
|
||||
builder: '@angular/bazel:build',
|
||||
options: { 'bazelCommand': 'test', 'targetLabel': '//src/...' },
|
||||
options: {'bazelCommand': 'test', 'targetLabel': '//src/...'},
|
||||
},
|
||||
indent);
|
||||
|
||||
|
@ -216,7 +216,7 @@ function backupAngularJson(): Rule {
|
|||
};
|
||||
}
|
||||
|
||||
export default function (options: Schema): Rule {
|
||||
export default function(options: Schema): Rule {
|
||||
return (host: Tree) => {
|
||||
validateProjectName(options.name);
|
||||
|
||||
|
|
|
@ -8,11 +8,11 @@
|
|||
* @fileoverview Schematics for ng-new project that builds with Bazel.
|
||||
*/
|
||||
|
||||
import { Rule, Tree, chain, externalSchematic, schematic } from '@angular-devkit/schematics';
|
||||
import { validateProjectName } from '@schematics/angular/utility/validation';
|
||||
import { Schema } from './schema';
|
||||
import {Rule, Tree, chain, externalSchematic, schematic} from '@angular-devkit/schematics';
|
||||
import {validateProjectName} from '@schematics/angular/utility/validation';
|
||||
import {Schema} from './schema';
|
||||
|
||||
export default function (options: Schema): Rule {
|
||||
export default function(options: Schema): Rule {
|
||||
return (host: Tree) => {
|
||||
validateProjectName(options.name);
|
||||
|
||||
|
|
Loading…
Reference in New Issue