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 | 1x 1x 1x 1x 1x 1x 4x 8x 1x 4x 4x | import { chain, Rule } from '@angular-devkit/schematics';
import { MapLike } from 'typescript';
import { updateDevDependency, updatePackageJson } from './utils/package-json';
import { tryRule } from './utils/rules';
const newScripts = [
{
command: 'bb-ang check-api',
name: 'api:check',
},
{
command: 'bb-ang extract-api',
name: 'api:extract',
},
];
const bbAng = {
name: '@bb-cli/bb-ang',
version: '~3.2.0',
};
const manualProcess = `
## Add command to the package scripts
In "package.json" file, define a new scripts for api check:
{
"name": "my-project",
"version": "0.0.0",
"license": "MIT",
"scripts": {
"build": "ng build",
"e2e": "ng e2e",
...
"${newScripts[0].name}": "${newScripts[0].command}",
"${newScripts[1].name}": "${newScripts[1].command}"
},
...
}
## Make sure the version of @bb-cli/bb-ang is ${bbAng.version}
For that install it as a dev dependency using the following command:
$ npm i --save-dev @bb-cli/bb-ang@${bbAng.version}
`;
function addApiCheckScript(scripts: MapLike<string> = {}): MapLike<string> {
return {
...scripts,
...newScripts.reduce((acc, script) => ({ ...acc, [script.name]: script.command }), {}),
};
}
export default function (): Rule {
return tryRule(
chain([
updateDevDependency(bbAng.name, bbAng.version),
updatePackageJson((packageJson) => ({
...packageJson,
scripts: addApiCheckScript(packageJson.scripts),
})),
]),
manualProcess,
);
}
|