(addValue: string, commandOptions: CommandOptions)
| 63 | } |
| 64 | |
| 65 | export async function rmCommand(addValue: string, commandOptions: CommandOptions) { |
| 66 | const {lockfile, config} = commandOptions; |
| 67 | if (config.packageOptions.source === 'remote-next') { |
| 68 | throw new Error( |
| 69 | `[remote-next] rm command has been deprecated. Manually remove dependencies from the "dependencies" object in your snowpack config file.`, |
| 70 | ); |
| 71 | } |
| 72 | if (config.packageOptions.source !== 'remote') { |
| 73 | throw new Error(`rm command requires packageOptions.source="remote".`); |
| 74 | } |
| 75 | const remotePackageSDK = createRemotePackageSDK(config); |
| 76 | let [pkgName] = pkgInfoFromString(addValue); |
| 77 | logger.info(`removing ${cyan(pkgName)} from project lockfile...`); |
| 78 | const newLockfile: LockfileManifest = convertSkypackImportMapToLockfile( |
| 79 | lockfile?.dependencies ?? {}, |
| 80 | await remotePackageSDK.generateImportMap( |
| 81 | {[pkgName]: null}, |
| 82 | lockfile |
| 83 | ? convertLockfileToSkypackImportMap(config.packageOptions.origin, lockfile) |
| 84 | : undefined, |
| 85 | ), |
| 86 | ); |
| 87 | delete newLockfile.dependencies[pkgName]; |
| 88 | await writeLockfile(path.join(config.root, LOCKFILE_NAME), newLockfile); |
| 89 | await getPackageSource(config).prepare(); |
| 90 | } |
no test coverage detected