Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function addProject(options: NormalizedSchema): Rule {
return updateWorkspaceInTree(json => {
const architect: { [key: string]: any } = {};
architect.build = {
builder: '@nrwl/web:build',
options: {
outputPath: join(normalize('dist'), options.appProjectRoot),
index: join(normalize(options.appProjectRoot), 'src/index.html'),
main: join(normalize(options.appProjectRoot), 'src/main.ts'),
polyfills: join(normalize(options.appProjectRoot), 'src/polyfills.ts'),
tsConfig: join(normalize(options.appProjectRoot), 'tsconfig.app.json'),
assets: [
join(normalize(options.appProjectRoot), 'src/favicon.ico'),
join(normalize(options.appProjectRoot), 'src/assets')
],
styles: [
join(normalize(options.appProjectRoot), `src/styles.${options.style}`)
delete json.devDependencies['@nrwl/builders'];
context.logger.info(`Removing @nrwl/schematics as a dependency`);
context.logger.info(`Removing @nrwl/builders as a dependency`);
context.logger.info(`Removing @nrwl/nx as a dependency`);
return json;
}
);
const updateUpdateScript = updateJsonInTree('package.json', json => {
json.scripts = json.scripts || {};
json.scripts.update = 'ng update @nrwl/workspace';
return json;
});
const updateBuilders = updateWorkspaceInTree(json => {
if (!json.projects) {
return json;
}
Object.entries(json.projects).forEach(([projectKey, project]) => {
if (!project.architect) {
return;
}
Object.entries(project.architect).forEach(([targetKey, target]) => {
if (target.builder === '@nrwl/builders:jest') {
json.projects[projectKey].architect[targetKey].builder =
'@nrwl/jest:jest';
}
if (target.builder === '@nrwl/builders:cypress') {
json.projects[projectKey].architect[targetKey].builder =
'@nrwl/cypress:cypress';
function addProject(options: NormalizedSchema): Rule {
if (!options.publishable) {
return noop();
}
return updateWorkspaceInTree(json => {
const architect = json.projects[options.name].architect;
if (architect) {
architect.build = {
builder: '@nrwl/node:package',
options: {
outputPath: `dist/libs/${options.projectDirectory}`,
tsConfig: `${options.projectRoot}/tsconfig.lib.json`,
packageJson: `${options.projectRoot}/package.json`,
main: `${options.projectRoot}/src/index.ts`,
assets: [`${options.projectRoot}/**/*.md`]
}
};
}
return json;
});
}
function addProject(options: NormalizedSchema): Rule {
return updateWorkspaceInTree(json => {
const architect: { [key: string]: any } = {};
architect.lint = generateProjectLint(
normalize(options.projectRoot),
join(normalize(options.projectRoot), 'tsconfig.lib.json'),
options.linter
);
if (options.publishable) {
architect.build = {
builder: '@nrwl/web:bundle',
options: {
outputPath: `dist/libs/${options.projectDirectory}`,
tsConfig: `${options.projectRoot}/tsconfig.lib.json`,
project: `${options.projectRoot}/package.json`,
entryFile: `${options.projectRoot}/src/index.ts`,
function updateWorkspaceJson(options: JestProjectSchema): Rule {
return updateWorkspaceInTree(json => {
const projectConfig = json.projects[options.project];
projectConfig.architect.test = {
builder: '@nrwl/jest:jest',
options: {
jestConfig: join(normalize(projectConfig.root), 'jest.config.js'),
tsConfig: join(normalize(projectConfig.root), 'tsconfig.spec.json')
}
};
if (options.setupFile !== 'none') {
projectConfig.architect.test.options.setupFile = join(
normalize(projectConfig.root),
'src/test-setup.ts'
);
}
if (projectConfig.architect.lint) {
projectConfig.architect.lint.options.tsConfig = [
function updateworkspaceJson(options: KarmaProjectSchema): Rule {
return updateWorkspaceInTree(json => {
const projectConfig = json.projects[options.project];
projectConfig.architect.test = {
builder: '@angular-devkit/build-angular:karma',
options: {
main: join(normalize(projectConfig.sourceRoot), 'test.ts'),
tsConfig: join(normalize(projectConfig.root), 'tsconfig.spec.json'),
karmaConfig: join(normalize(projectConfig.root), 'karma.conf.js')
}
};
if (projectConfig.projectType === 'application') {
projectConfig.architect.test.options = {
...projectConfig.architect.test.options,
polyfills: join(normalize(projectConfig.sourceRoot), 'polyfills.ts'),
styles: [],
scripts: [],
createOrUpdate(
host,
`${project.root}/tsconfig.e2e.json`,
serializeJson(tsConfig)
);
host.delete(`${project.root}/src/tsconfig.e2e.json`);
} else {
createDefaultE2eTsConfig(host, project);
}
}
});
return host;
}
const updateworkspaceJson = updateWorkspaceInTree(json => {
json.newProjectRoot = '';
json.cli = {
...json.cli,
defaultCollection: '@nrwl/schematics'
};
delete json.projects.$workspaceRoot;
delete json.projects['$workspaceRoot-e2e'];
const prefix = json.schematics['@nrwl/schematics:component'].prefix;
delete json.schematics;
json.defaultProject = pathToName(json.defaultProject);
const projects = {};
Object.entries(json.projects).forEach(([key, project]) => {
const type = !project.architect.build
? 'e2e'
import { chain, Rule, Tree } from '@angular-devkit/schematics';
import { updateJsonInTree, insert } from '@nrwl/workspace';
import { formatFiles, updateWorkspaceInTree } from '@nrwl/workspace';
import * as ts from 'typescript';
import {
getSourceNodes,
ReplaceChange
} from '@nrwl/workspace/src/utils/ast-utils';
const setDefaults = updateWorkspaceInTree(json => {
if (!json.schematics) {
json.schematics = {};
}
if (!json.schematics['@nrwl/schematics:library']) {
json.schematics['@nrwl/schematics:library'] = {};
}
if (!json.schematics['@nrwl/schematics:library'].framework) {
json.schematics['@nrwl/schematics:library'].framework = 'angular';
}
return json;
});
const updateDependencies = updateJsonInTree('package.json', json => {
json.devDependencies = json.devDependencies || {};
if (json.devDependencies['jest']) {
json.devDependencies['jest'] = '24.1.0';