All files / src/migrations 2.16.1.ts

100% Statements 12/12
100% Branches 0/0
100% Functions 5/5
100% Lines 11/11

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 581x 1x 1x   1x                     1x                     1x                                         1x 3x   3x 6x 6x          
import { updateScript, checkScript } from './utils/package-json';
import { tryRule } from './utils/rules';
import { chain, Rule } from '@angular-devkit/schematics';
 
const expectedScripts = [
  {
    command: 'bb-ang build-apps --output-hashing --build-memory=4096 && bb-ang create-provisioning-package',
    name: 'package:apps',
  },
  {
    command: undefined,
    name: 'postpackage:apps',
  },
];
 
const newScripts = [
  {
    command: 'bb-ang build-apps --output-hashing --build-memory=4096',
    name: 'package:apps',
  },
  {
    command: 'bb-ang create-provisioning-package',
    name: 'postpackage:apps',
  },
];
 
const manualProcess = `
1. Update the "${newScripts[0].name}" script in "package.json" to:
 
{
  ...
  scripts: {
    ...
    "${newScripts[0].name}": "${newScripts[0].command}"
  }
}
 
2. Add the "${newScripts[1].name}" script to "package.json":
 
{
  ...
  scripts: {
    ...
    "${newScripts[1].name}": "${newScripts[1].command}"
  }
}`;
 
export default function (): Rule {
  return tryRule(
    () =>
      chain([
        ...expectedScripts.map((script) => checkScript(script.name, script.command)),
        ...newScripts.map((script) => updateScript(script.name, () => script.command)),
      ]),
    manualProcess,
  );
}