Skip to content

Commit

Permalink
feat(@schematics/angular): remove ivy-ngcc postinstall script from ne…
Browse files Browse the repository at this point in the history
…w application
  • Loading branch information
Alan Agius authored and mgechev committed Apr 1, 2019
1 parent 888bb27 commit f84abfc
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 41 deletions.
35 changes: 0 additions & 35 deletions packages/schematics/angular/application/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -175,40 +175,6 @@ function mergeWithRootTsLint(parentHost: Tree) {
};
}

function addPostInstallScript() {
return (host: Tree) => {
const pkgJsonPath = '/package.json';
const buffer = host.read(pkgJsonPath);
if (!buffer) {
throw new SchematicsException('Could not read package.json.');
}

const packageJsonAst = parseJsonAst(buffer.toString(), JsonParseMode.Strict);
if (packageJsonAst.kind !== 'object') {
throw new SchematicsException('Invalid package.json. Was expecting an object.');
}

const scriptsNode = findPropertyInAstObject(packageJsonAst, 'scripts');
if (scriptsNode && scriptsNode.kind === 'object') {
const recorder = host.beginUpdate(pkgJsonPath);
const postInstall = findPropertyInAstObject(scriptsNode, 'postinstall');

if (!postInstall) {
// postinstall script not found, add it.
insertPropertyInAstObjectInOrder(
recorder,
scriptsNode,
'postinstall',
'ivy-ngcc',
4,
);
}

host.commitUpdate(recorder);
}
};
}

function addAppToWorkspaceFile(options: ApplicationOptions, workspace: WorkspaceSchema): Rule {
// TODO: use JsonAST
// const workspacePath = '/angular.json';
Expand Down Expand Up @@ -453,7 +419,6 @@ export default function (options: ApplicationOptions): Rule {
move(sourceDir),
]), MergeStrategy.Overwrite),
options.minimal ? noop() : schematic('e2e', e2eOptions),
options.enableIvy ? addPostInstallScript() : noop(),
options.skipPackageJson ? noop() : addDependenciesToPackageJson(options),
options.lintFix ? applyLintFix(appDir) : noop(),
]);
Expand Down
6 changes: 0 additions & 6 deletions packages/schematics/angular/application/index_spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -217,12 +217,6 @@ describe('Application Schematic', () => {
expect(pkg.devDependencies['typescript']).toEqual(latestVersions.TypeScript);
});

it(`should add a postinstall in package.json when 'enableIvy'`, () => {
const tree = schematicRunner.runSchematic('application', { ...defaultOptions, enableIvy: true }, workspaceTree);
const pkg = JSON.parse(tree.readContent('/package.json'));
expect(pkg.scripts.postinstall).toEqual('ivy-ngcc');
});

it(`should not override existing users dependencies`, () => {
const oldPackageJson = workspaceTree.readContent('package.json');
workspaceTree.overwrite('package.json', oldPackageJson.replace(
Expand Down

0 comments on commit f84abfc

Please sign in to comment.