Skip to content

Commit

Permalink
cleanup(angular): remove remaining angular cli helpers and set versio…
Browse files Browse the repository at this point in the history
…n target for existing deprecations helpers (#10791)
  • Loading branch information
leosvelperez authored Jun 17, 2022
1 parent 6bca146 commit e507d7b
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 89 deletions.
Original file line number Diff line number Diff line change
@@ -1,13 +1,6 @@
import { Tree } from '@angular-devkit/schematics';
import { createEmptyWorkspace } from '@nrwl/workspace/testing';
import { runMigration } from '../../utils/testing';

function createAngularCLIPoweredWorkspace() {
const tree = createEmptyWorkspace(Tree.empty());
tree.delete('workspace.json');
tree.create('angular.json', '{}');
return tree;
}
import { readJson, writeJson } from '@nrwl/devkit';
import { createTreeWithEmptyWorkspace } from '@nrwl/devkit/testing';
import updateNgccPostinstall from './update-ngcc-postinstall';

describe('Remove ngcc flags from postinstall script', () => {
[
Expand All @@ -33,21 +26,17 @@ describe('Remove ngcc flags from postinstall script', () => {
},
].forEach((testEntry) => {
it(`should adjust ngcc for: "${testEntry.test}"`, async () => {
const tree = createAngularCLIPoweredWorkspace();

tree.overwrite(
'/package.json',
JSON.stringify({
scripts: {
postinstall: testEntry.test,
},
})
);
const tree = createTreeWithEmptyWorkspace(2);
tree.delete('workspace.json');
tree.write('angular.json', '{}');
writeJson(tree, 'package.json', {
scripts: { postinstall: testEntry.test },
});

const result = await runMigration('update-ngcc-postinstall', {}, tree);
await updateNgccPostinstall(tree);

const packageJson = JSON.parse(result.read('/package.json').toString());
expect(packageJson.scripts.postinstall).toEqual(testEntry.expected);
const { scripts } = readJson(tree, 'package.json');
expect(scripts.postinstall).toEqual(testEntry.expected);
});
});
});
Original file line number Diff line number Diff line change
@@ -1,24 +1,22 @@
import { chain, SchematicContext, Tree } from '@angular-devkit/schematics';
import { updateJsonInTree } from '@nrwl/workspace';
import { formatFiles } from '@nrwl/workspace';
import type { Tree } from '@nrwl/devkit';
import { formatFiles, updateJson } from '@nrwl/devkit';

const udpateNgccPostinstallScript = (host: Tree, context: SchematicContext) => {
updateJsonInTree('package.json', (json) => {
if (
json.scripts &&
json.scripts.postinstall &&
json.scripts.postinstall.includes('ngcc')
) {
// if exists, add execution of this script
export default async function (tree: Tree) {
let shouldFormat = false;

updateJson(tree, 'package.json', (json) => {
if (json.scripts?.postinstall?.includes('ngcc')) {
json.scripts.postinstall = json.scripts.postinstall.replace(
/(.*)(ngcc --properties es2015 browser module main --first-only --create-ivy-entry-points)(.*)/,
'$1ngcc --properties es2015 browser module main$3'
);
shouldFormat = true;
}

return json;
})(host, context);
};
});

export default function () {
return chain([udpateNgccPostinstallScript, formatFiles()]);
if (shouldFormat) {
await formatFiles(tree);
}
}
47 changes: 0 additions & 47 deletions packages/angular/src/utils/testing.ts

This file was deleted.

8 changes: 4 additions & 4 deletions packages/angular/testing/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,19 @@ import {
} from 'jasmine-marbles';

/**
* @deprecated Import from 'jasmine-marbles' instead
* @deprecated Import from 'jasmine-marbles' instead. Will be removed in Nx v15.
*/
export const cold = rxjsMarblesCold;
/**
* @deprecated Import from 'jasmine-marbles' instead
* @deprecated Import from 'jasmine-marbles' instead. Will be removed in Nx v15.
*/
export const hot = rxjsMarblesHot;
/**
* @deprecated Import from 'jasmine-marbles' instead
* @deprecated Import from 'jasmine-marbles' instead. Will be removed in Nx v15.
*/
export const getTestScheduler = rxjsMarblesTestScheduler;
/**
* @deprecated Import from 'jasmine-marbles' instead
* @deprecated Import from 'jasmine-marbles' instead. Will be removed in Nx v15.
*/
export const time = rxjsMarblesTime;

Expand Down

0 comments on commit e507d7b

Please sign in to comment.