codify-plugin-lib 1.0.182-beta59 → 1.0.182-beta60
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.js +27 -0
- package/package.json +1 -1
- package/src/utils/index.ts +35 -0
package/dist/utils/index.d.ts
CHANGED
|
@@ -33,5 +33,6 @@ export declare const Utils: {
|
|
|
33
33
|
* @param packageName
|
|
34
34
|
*/
|
|
35
35
|
installViaPkgMgr(packageName: string): Promise<boolean>;
|
|
36
|
+
uninstallViaPkgMgr(packageName: string): Promise<boolean>;
|
|
36
37
|
linuxDistro(): Promise<"arch" | "centos" | "debian" | "fedora" | "rhel" | "ubuntu" | undefined>;
|
|
37
38
|
};
|
package/dist/utils/index.js
CHANGED
|
@@ -182,6 +182,33 @@ Brew can be installed using Codify:
|
|
|
182
182
|
}
|
|
183
183
|
return false;
|
|
184
184
|
},
|
|
185
|
+
async uninstallViaPkgMgr(packageName) {
|
|
186
|
+
const $ = getPty();
|
|
187
|
+
if (Utils.isMacOS()) {
|
|
188
|
+
await this.assertBrewInstalled();
|
|
189
|
+
const { status } = await $.spawnSafe(`brew uninstall --zap ${packageName}`, { interactive: true, env: { HOMEBREW_NO_AUTO_UPDATE: 1 } });
|
|
190
|
+
return status === SpawnStatus.SUCCESS;
|
|
191
|
+
}
|
|
192
|
+
if (Utils.isLinux()) {
|
|
193
|
+
const isAptInstalled = await $.spawnSafe('which apt');
|
|
194
|
+
if (isAptInstalled.status === SpawnStatus.SUCCESS) {
|
|
195
|
+
const { status } = await $.spawnSafe(`apt remove --purge ${packageName}`, { interactive: true, requiresRoot: true, env: { DEBIAN_FRONTEND: 'noninteractive' } });
|
|
196
|
+
return status === SpawnStatus.SUCCESS;
|
|
197
|
+
}
|
|
198
|
+
const isDnfInstalled = await $.spawnSafe('which dnf');
|
|
199
|
+
if (isDnfInstalled.status === SpawnStatus.SUCCESS) {
|
|
200
|
+
const { status } = await $.spawnSafe(`dnf autoremove ${packageName} -y`, { interactive: true, requiresRoot: true });
|
|
201
|
+
return status === SpawnStatus.SUCCESS;
|
|
202
|
+
}
|
|
203
|
+
const isYumInstalled = await $.spawnSafe('which yum');
|
|
204
|
+
if (isYumInstalled.status === SpawnStatus.SUCCESS) {
|
|
205
|
+
const { status } = await $.spawnSafe(`yum autoremove ${packageName} -y`, { interactive: true, requiresRoot: true });
|
|
206
|
+
return status === SpawnStatus.SUCCESS;
|
|
207
|
+
}
|
|
208
|
+
return false;
|
|
209
|
+
}
|
|
210
|
+
return false;
|
|
211
|
+
},
|
|
185
212
|
async linuxDistro() {
|
|
186
213
|
const osRelease = await fs.readFile('/etc/os-release', 'utf8');
|
|
187
214
|
const lines = osRelease.split('\n');
|
package/package.json
CHANGED
package/src/utils/index.ts
CHANGED
|
@@ -230,6 +230,41 @@ Brew can be installed using Codify:
|
|
|
230
230
|
return false;
|
|
231
231
|
},
|
|
232
232
|
|
|
233
|
+
async uninstallViaPkgMgr(packageName: string): Promise<boolean> {
|
|
234
|
+
const $ = getPty();
|
|
235
|
+
|
|
236
|
+
if (Utils.isMacOS()) {
|
|
237
|
+
await this.assertBrewInstalled();
|
|
238
|
+
const { status } = await $.spawnSafe(`brew uninstall --zap ${packageName}`, { interactive: true, env: { HOMEBREW_NO_AUTO_UPDATE: 1 } });
|
|
239
|
+
return status === SpawnStatus.SUCCESS;
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
if (Utils.isLinux()) {
|
|
243
|
+
const isAptInstalled = await $.spawnSafe('which apt');
|
|
244
|
+
if (isAptInstalled.status === SpawnStatus.SUCCESS) {
|
|
245
|
+
const { status } = await $.spawnSafe(`apt remove --purge ${packageName}`, { interactive: true, requiresRoot: true, env: { DEBIAN_FRONTEND: 'noninteractive' } });
|
|
246
|
+
return status === SpawnStatus.SUCCESS;
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
const isDnfInstalled = await $.spawnSafe('which dnf');
|
|
250
|
+
if (isDnfInstalled.status === SpawnStatus.SUCCESS) {
|
|
251
|
+
const { status } = await $.spawnSafe(`dnf autoremove ${packageName} -y`, { interactive: true, requiresRoot: true });
|
|
252
|
+
return status === SpawnStatus.SUCCESS;
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
const isYumInstalled = await $.spawnSafe('which yum');
|
|
256
|
+
if (isYumInstalled.status === SpawnStatus.SUCCESS) {
|
|
257
|
+
const { status } = await $.spawnSafe(`yum autoremove ${packageName} -y`, { interactive: true, requiresRoot: true });
|
|
258
|
+
return status === SpawnStatus.SUCCESS;
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
return false;
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
return false;
|
|
265
|
+
},
|
|
266
|
+
|
|
267
|
+
|
|
233
268
|
async linuxDistro(): Promise<'arch' | 'centos' | 'debian' | 'fedora' | 'rhel' | 'ubuntu' | undefined> {
|
|
234
269
|
const osRelease = await fs.readFile('/etc/os-release', 'utf8');
|
|
235
270
|
const lines = osRelease.split('\n');
|