Revert "fix(nx): ng-add schematic updated for ng8"
This reverts commit 2d6194598a720785ff768b86c1e1f6954d94127b.
This commit is contained in:
parent
5b6edea866
commit
13ac19f0b6
@ -16,8 +16,8 @@ import {
|
|||||||
nxVersion,
|
nxVersion,
|
||||||
prettierVersion
|
prettierVersion
|
||||||
} from '../../utils/versions';
|
} from '../../utils/versions';
|
||||||
import { from, of } from 'rxjs';
|
import { from } from 'rxjs';
|
||||||
import { mapTo, tap, catchError } from 'rxjs/operators';
|
import { mapTo, tap } from 'rxjs/operators';
|
||||||
import { NodePackageInstallTask } from '@angular-devkit/schematics/tasks';
|
import { NodePackageInstallTask } from '@angular-devkit/schematics/tasks';
|
||||||
import {
|
import {
|
||||||
offsetFromRoot,
|
offsetFromRoot,
|
||||||
@ -33,7 +33,6 @@ import {
|
|||||||
import { DEFAULT_NRWL_PRETTIER_CONFIG } from '../workspace/workspace';
|
import { DEFAULT_NRWL_PRETTIER_CONFIG } from '../workspace/workspace';
|
||||||
import { JsonArray } from '@angular-devkit/core';
|
import { JsonArray } from '@angular-devkit/core';
|
||||||
import { updateWorkspace } from '../../utils/workspace';
|
import { updateWorkspace } from '../../utils/workspace';
|
||||||
import { writeToFile } from '../../utils/fileutils';
|
|
||||||
|
|
||||||
function updatePackageJson() {
|
function updatePackageJson() {
|
||||||
return updateJsonInTree('package.json', packageJson => {
|
return updateJsonInTree('package.json', packageJson => {
|
||||||
@ -211,21 +210,6 @@ function updateAngularCLIJson(options: Schema): Rule {
|
|||||||
'protractor.conf.js'
|
'protractor.conf.js'
|
||||||
);
|
);
|
||||||
defaultProject.targets.delete('e2e');
|
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
|
context?: SchematicContext
|
||||||
) {
|
) {
|
||||||
const from = filename;
|
const from = filename;
|
||||||
const to = path.join('apps', appName, getFilename(filename));
|
const to = path.join('apps', appName, filename);
|
||||||
renameSync(from, to, err => {
|
renameSync(from, to, err => {
|
||||||
if (!context) {
|
if (!context) {
|
||||||
return;
|
return;
|
||||||
} else if (!err) {
|
} else if (!err) {
|
||||||
context.logger.info(`Renamed ${from} -> ${to}`);
|
context.logger.info(`Renamed ${from} -> ${to}`);
|
||||||
} else {
|
} 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
|
// No context is passed because it should not be required to have a browserslist
|
||||||
moveOutOfSrc(options.name, 'browserslist');
|
moveOutOfSrc(options.name, 'browserslist');
|
||||||
|
|
||||||
moveOutOfSrc(
|
moveOutOfSrc(
|
||||||
options.name,
|
options.name,
|
||||||
app.architect.test.options.karmaConfig,
|
getFilename(app.architect.test.options.karmaConfig),
|
||||||
context
|
context
|
||||||
);
|
);
|
||||||
|
|
||||||
moveOutOfSrc(
|
moveOutOfSrc(
|
||||||
options.name,
|
options.name,
|
||||||
app.architect.build.options.tsConfig,
|
getFilename(app.architect.build.options.tsConfig),
|
||||||
context
|
context
|
||||||
);
|
);
|
||||||
|
|
||||||
moveOutOfSrc(
|
moveOutOfSrc(
|
||||||
options.name,
|
options.name,
|
||||||
app.architect.test.options.tsConfig,
|
getFilename(app.architect.test.options.tsConfig),
|
||||||
context
|
context
|
||||||
);
|
);
|
||||||
|
|
||||||
if (app.architect.server) {
|
if (app.architect.server) {
|
||||||
moveOutOfSrc(
|
moveOutOfSrc(
|
||||||
options.name,
|
options.name,
|
||||||
app.architect.server.options.tsConfig,
|
getFilename(app.architect.server.options.tsConfig),
|
||||||
context
|
context
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const oldAppSourceRoot = app.sourceRoot;
|
const oldAppSourceRoot = app.sourceRoot;
|
||||||
const newAppSourceRoot = join('apps', options.name, app.sourceRoot);
|
const newAppSourceRoot = join('apps', options.name, app.sourceRoot);
|
||||||
renameSync(oldAppSourceRoot, newAppSourceRoot, err => {
|
renameSync(oldAppSourceRoot, newAppSourceRoot, err => {
|
||||||
@ -425,7 +404,7 @@ function moveExistingFiles(options: Schema) {
|
|||||||
`Renamed ${oldAppSourceRoot} -> ${newAppSourceRoot}`
|
`Renamed ${oldAppSourceRoot} -> ${newAppSourceRoot}`
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
context.logger.error(`Tried to rename ${oldAppSourceRoot} -> ${newAppSourceRoot} but ${err.message}`);
|
context.logger.error(err.message);
|
||||||
throw err;
|
throw err;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -437,7 +416,7 @@ function moveExistingFiles(options: Schema) {
|
|||||||
if (!err) {
|
if (!err) {
|
||||||
context.logger.info(`Renamed ${oldE2eRoot} -> ${newE2eRoot}`);
|
context.logger.info(`Renamed ${oldE2eRoot} -> ${newE2eRoot}`);
|
||||||
} else {
|
} else {
|
||||||
context.logger.error(`Tried to rename ${oldE2eRoot} -> ${newE2eRoot} but ${err.message}`);
|
context.logger.error(err.message);
|
||||||
throw err;
|
throw err;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -499,9 +478,8 @@ function createAdditionalFiles(options: Schema): Rule {
|
|||||||
// if the user does not already have a prettier configuration
|
// if the user does not already have a prettier configuration
|
||||||
// of any kind, create one
|
// of any kind, create one
|
||||||
return from(resolveUserExistingPrettierConfig()).pipe(
|
return from(resolveUserExistingPrettierConfig()).pipe(
|
||||||
catchError(() => of(false)),
|
|
||||||
tap(existingPrettierConfig => {
|
tap(existingPrettierConfig => {
|
||||||
if (!existingPrettierConfig && !host.exists('.prettierrc')) {
|
if (!existingPrettierConfig) {
|
||||||
host.create(
|
host.create(
|
||||||
'.prettierrc',
|
'.prettierrc',
|
||||||
serializeJson(DEFAULT_NRWL_PRETTIER_CONFIG)
|
serializeJson(DEFAULT_NRWL_PRETTIER_CONFIG)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user