MCPcopy
hub / github.com/FredKSchott/snowpack / rmCommand

Function rmCommand

snowpack/src/commands/add-rm.ts:65–90  ·  view source on GitHub ↗
(addValue: string, commandOptions: CommandOptions)

Source from the content-addressed store, hash-verified

63}
64
65export 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}

Callers 1

cliFunction · 0.90

Calls 9

createRemotePackageSDKFunction · 0.90
writeLockfileFunction · 0.90
getPackageSourceFunction · 0.90
pkgInfoFromStringFunction · 0.85
infoMethod · 0.80
generateImportMapMethod · 0.80
prepareMethod · 0.65

Tested by

no test coverage detected