* Deprecates a specific version of a package. * @throws With the process log output if the deprecation failed. * @param packageName The name of the package to deprecate. * @param version The version of the package to deprecate. * @param message The deprecation message. * @param regist
(
packageName: string,
version: string,
message: string,
registryUrl: string | undefined,
)
| 62 | * @param registryUrl The registry URL to use for the deprecation. |
| 63 | */ |
| 64 | static async deprecate( |
| 65 | packageName: string, |
| 66 | version: string, |
| 67 | message: string, |
| 68 | registryUrl: string | undefined, |
| 69 | ) { |
| 70 | const args = ['deprecate', `${packageName}@${version}`, message]; |
| 71 | |
| 72 | // If a custom registry URL has been specified, add the `--registry` flag. |
| 73 | if (registryUrl !== undefined) { |
| 74 | args.push('--registry', registryUrl); |
| 75 | } |
| 76 | |
| 77 | try { |
| 78 | await ChildProcess.spawn('npm', args, {mode: 'silent'}); |
| 79 | } catch (e) { |
| 80 | // TODO(alanagius): remove try/catch block once https://buganizer.corp.google.com/u/1/issues/512428441 is fixed. |
| 81 | Log.error(Array(80).join('#')); |
| 82 | Log.error(` ✘ An error occurred while deprecating "${packageName}".`); |
| 83 | Log.error(e); |
| 84 | Log.error(Array(80).join('#')); |
| 85 | } |
| 86 | } |
| 87 | |
| 88 | /** |
| 89 | * Sets the NPM tag to the specified version for the given package. |