Revert "fix(nx): ng-add schematic updated for ng8"

This reverts commit 2d6194598a720785ff768b86c1e1f6954d94127b.
This commit is contained in:
Victor Savkin 2019-11-04 15:36:16 -05:00
parent 5b6edea866
commit 13ac19f0b6

View File

@ -16,8 +16,8 @@ import {
nxVersion,
prettierVersion
} from '../../utils/versions';
import { from, of } from 'rxjs';
import { mapTo, tap, catchError } from 'rxjs/operators';
import { from } from 'rxjs';
import { mapTo, tap } from 'rxjs/operators';
import { NodePackageInstallTask } from '@angular-devkit/schematics/tasks';
import {
offsetFromRoot,
@ -33,7 +33,6 @@ import {
import { DEFAULT_NRWL_PRETTIER_CONFIG } from '../workspace/workspace';
import { JsonArray } from '@angular-devkit/core';
import { updateWorkspace } from '../../utils/workspace';
import { writeToFile } from '../../utils/fileutils';
function updatePackageJson() {
return updateJsonInTree('package.json', packageJson => {
@ -211,21 +210,6 @@ function updateAngularCLIJson(options: Schema): Rule {
'protractor.conf.js'
);
defaultProject.targets.delete('e2e');
} else if (workspace.projects.has(e2eName)) {
// updates the e2e project
const e2eProject = workspace.projects.get(e2eName);
e2eProject.root = e2eRoot;
e2eProject.sourceRoot = undefined;
if (e2eProject.targets.has('lint')) {
const lintOptions = e2eProject.targets.get('lint').options;
lintOptions.tsConfig = join(e2eRoot, 'tsconfig.json');
}
if (e2eProject.targets.has('e2e')) {
const e2eOptions = e2eProject.targets.get('e2e').options;
e2eOptions.protractorConfig = join(e2eRoot, 'protractor.conf.js');
}
}
});
}
@ -351,14 +335,14 @@ function moveOutOfSrc(
context?: SchematicContext
) {
const from = filename;
const to = path.join('apps', appName, getFilename(filename));
const to = path.join('apps', appName, filename);
renameSync(from, to, err => {
if (!context) {
return;
} else if (!err) {
context.logger.info(`Renamed ${from} -> ${to}`);
} else {
context.logger.warn(`Tried to rename ${from} -> ${to} but ${err.message}`);
context.logger.warn(err.message);
}
});
}
@ -390,33 +374,28 @@ function moveExistingFiles(options: Schema) {
// No context is passed because it should not be required to have a browserslist
moveOutOfSrc(options.name, 'browserslist');
moveOutOfSrc(
options.name,
app.architect.test.options.karmaConfig,
getFilename(app.architect.test.options.karmaConfig),
context
);
moveOutOfSrc(
options.name,
app.architect.build.options.tsConfig,
getFilename(app.architect.build.options.tsConfig),
context
);
moveOutOfSrc(
options.name,
app.architect.test.options.tsConfig,
getFilename(app.architect.test.options.tsConfig),
context
);
if (app.architect.server) {
moveOutOfSrc(
options.name,
app.architect.server.options.tsConfig,
getFilename(app.architect.server.options.tsConfig),
context
);
}
const oldAppSourceRoot = app.sourceRoot;
const newAppSourceRoot = join('apps', options.name, app.sourceRoot);
renameSync(oldAppSourceRoot, newAppSourceRoot, err => {
@ -425,7 +404,7 @@ function moveExistingFiles(options: Schema) {
`Renamed ${oldAppSourceRoot} -> ${newAppSourceRoot}`
);
} else {
context.logger.error(`Tried to rename ${oldAppSourceRoot} -> ${newAppSourceRoot} but ${err.message}`);
context.logger.error(err.message);
throw err;
}
});
@ -437,7 +416,7 @@ function moveExistingFiles(options: Schema) {
if (!err) {
context.logger.info(`Renamed ${oldE2eRoot} -> ${newE2eRoot}`);
} else {
context.logger.error(`Tried to rename ${oldE2eRoot} -> ${newE2eRoot} but ${err.message}`);
context.logger.error(err.message);
throw err;
}
});
@ -499,9 +478,8 @@ function createAdditionalFiles(options: Schema): Rule {
// if the user does not already have a prettier configuration
// of any kind, create one
return from(resolveUserExistingPrettierConfig()).pipe(
catchError(() => of(false)),
tap(existingPrettierConfig => {
if (!existingPrettierConfig && !host.exists('.prettierrc')) {
if (!existingPrettierConfig) {
host.create(
'.prettierrc',
serializeJson(DEFAULT_NRWL_PRETTIER_CONFIG)