Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 | 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 249x 21x 21x 21x 3x 249x 3x 3x 1x 3x 3x | import { updateScript, addDependency } from './utils/package-json';
import { tryRule } from './utils/rules';
import { Rule, Tree, chain } from '@angular-devkit/schematics';
import { getWorkspace, readFileOrThrow } from '../utils/backbase/package-utils';
import * as ts from 'typescript';
import { createSourceFile, Node } from 'typescript';
import { ReplaceChange, Change } from '../utils/angular/change';
import { insert } from '../utils/nrwl/ast-utils';
const OLD_MODULE = '@backbase/foundation-ang/ui';
const NEW_MODULE = '@backbase/ui-ang';
const uiAng = {
name: '@backbase/ui-ang',
version: '4.152.0',
};
const manualProcess = `
## Change the "update" script in "package.json"
Change the update script to:
{
...
scripts: {
...
"update": "ng update @bb-cli/schematics@^3 @backbase/foundation-ang@^5"
}
}
## Install '@backbase/ui-ang'
Install ${uiAng.name} version ${uiAng.version} as a dependency using the following command:
npm install --save ${uiAng.name}@${uiAng.version} @ng-select/ng-select@^2.19.0 @angular/cdk@8.0.0 bignumber.js@^9.0.0
## Import directly from '@backbase/ui-ang'
All import from the '@backbase/foundation-ang/ui' entry point should be changed to import directly from '@backbase/ui-ang'.
For example, an import declaration such as this:
import { AccountCardModule } from '@backbase/foundation-ang/ui'
should become:
import { AccountCardModule } from '@backbase/ui-ang'
`;
function importFromUIAng(): Rule {
return async (tree: Tree) => {
const workspace = await getWorkspace(tree);
workspace.projects.forEach((project) => {
Iif (!project.sourceRoot) return;
tree.getDir(project.sourceRoot).visit((path) => {
Iif (!path.endsWith('.ts')) return;
const changes: Array<Change> = changesToFile(path);
if (changes.length > 0) {
insert(tree, path, changes);
}
});
});
return () => tree;
function changesToFile(path: string): Array<Change> {
const rootNode = createSourceFile(path, readFileOrThrow(tree, path), ts.ScriptTarget.Latest);
const changes: Array<Change> = [];
function visitor(node: Node) {
if (ts.isImportDeclaration(node)) {
const moduleSpecifierText = node.moduleSpecifier.getText(rootNode.getSourceFile());
const moduleName = moduleSpecifierText.substr(1).substr(0, moduleSpecifierText.length - 2); // remove quotes
if (moduleName === OLD_MODULE) {
changes.push(new ReplaceChange(path, node.moduleSpecifier.pos + 1, OLD_MODULE, NEW_MODULE));
}
}
ts.forEachChild(node, visitor);
}
ts.forEachChild(rootNode, visitor);
return changes;
}
};
}
export default function (): Rule {
return tryRule(
chain([
updateScript('update', () => `ng update @bb-cli/schematics@^3 @backbase/foundation-ang@^5`),
addDependency(uiAng.name, uiAng.version),
addDependency('@ng-select/ng-select', '^2.19.0'),
addDependency('@angular/cdk', '8.0.0'),
addDependency('bignumber.js', '^9.0.0'),
importFromUIAng(),
]),
manualProcess,
);
}
|