codify-plugin-lib 1.0.182-beta63 → 1.0.182-beta64

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.
@@ -8,6 +8,25 @@ export declare enum Shell {
8
8
  CSH = "csh",
9
9
  FISH = "fish"
10
10
  }
11
+ export declare enum LinuxDistro {
12
+ ARCH = "arch",
13
+ CENTOS = "centos",
14
+ DEBIAN = "debian",
15
+ FEDORA = "fedora",
16
+ RHEL = "rhel",
17
+ UBUNTU = "ubuntu",
18
+ ALPINE = "alpine",
19
+ AMAZON_LINUX = "amzn",
20
+ OPENSUSE = "opensuse",
21
+ SUSE = "sles",
22
+ MANJARO = "manjaro",
23
+ MINT = "linuxmint",
24
+ POP_OS = "pop",
25
+ ELEMENTARY_OS = "elementary",
26
+ KALI = "kali",
27
+ GENTOO = "gentoo",
28
+ SLACKWARE = "slackware"
29
+ }
11
30
  export interface SystemInfo {
12
31
  os: OS;
13
32
  shell: Shell;
@@ -34,5 +53,11 @@ export declare const Utils: {
34
53
  */
35
54
  installViaPkgMgr(packageName: string): Promise<void>;
36
55
  uninstallViaPkgMgr(packageName: string): Promise<boolean>;
37
- linuxDistro(): Promise<"arch" | "centos" | "debian" | "fedora" | "rhel" | "ubuntu" | undefined>;
56
+ getLinuxDistro(): Promise<LinuxDistro | undefined>;
57
+ isUbuntu(): Promise<boolean>;
58
+ isDebian(): Promise<boolean>;
59
+ isArch(): Promise<boolean>;
60
+ isCentOS(): Promise<boolean>;
61
+ isFedora(): Promise<boolean>;
62
+ isRHEL(): Promise<boolean>;
38
63
  };
@@ -14,6 +14,26 @@ export var Shell;
14
14
  Shell["CSH"] = "csh";
15
15
  Shell["FISH"] = "fish";
16
16
  })(Shell || (Shell = {}));
17
+ export var LinuxDistro;
18
+ (function (LinuxDistro) {
19
+ LinuxDistro["ARCH"] = "arch";
20
+ LinuxDistro["CENTOS"] = "centos";
21
+ LinuxDistro["DEBIAN"] = "debian";
22
+ LinuxDistro["FEDORA"] = "fedora";
23
+ LinuxDistro["RHEL"] = "rhel";
24
+ LinuxDistro["UBUNTU"] = "ubuntu";
25
+ LinuxDistro["ALPINE"] = "alpine";
26
+ LinuxDistro["AMAZON_LINUX"] = "amzn";
27
+ LinuxDistro["OPENSUSE"] = "opensuse";
28
+ LinuxDistro["SUSE"] = "sles";
29
+ LinuxDistro["MANJARO"] = "manjaro";
30
+ LinuxDistro["MINT"] = "linuxmint";
31
+ LinuxDistro["POP_OS"] = "pop";
32
+ LinuxDistro["ELEMENTARY_OS"] = "elementary";
33
+ LinuxDistro["KALI"] = "kali";
34
+ LinuxDistro["GENTOO"] = "gentoo";
35
+ LinuxDistro["SLACKWARE"] = "slackware";
36
+ })(LinuxDistro || (LinuxDistro = {}));
17
37
  export const Utils = {
18
38
  getUser() {
19
39
  return os.userInfo().username;
@@ -219,14 +239,33 @@ Brew can be installed using Codify:
219
239
  }
220
240
  return false;
221
241
  },
222
- async linuxDistro() {
242
+ async getLinuxDistro() {
223
243
  const osRelease = await fs.readFile('/etc/os-release', 'utf8');
224
244
  const lines = osRelease.split('\n');
225
245
  for (const line of lines) {
226
246
  if (line.startsWith('ID=')) {
227
- return line.slice(3).trim();
247
+ const distroId = line.slice(3).trim().replace(/"/g, '');
248
+ return Object.values(LinuxDistro).includes(distroId) ? distroId : undefined;
228
249
  }
229
250
  }
230
251
  return undefined;
231
- }
252
+ },
253
+ async isUbuntu() {
254
+ return (await this.getLinuxDistro()) === LinuxDistro.UBUNTU;
255
+ },
256
+ async isDebian() {
257
+ return (await this.getLinuxDistro()) === LinuxDistro.DEBIAN;
258
+ },
259
+ async isArch() {
260
+ return (await this.getLinuxDistro()) === LinuxDistro.ARCH;
261
+ },
262
+ async isCentOS() {
263
+ return (await this.getLinuxDistro()) === LinuxDistro.CENTOS;
264
+ },
265
+ async isFedora() {
266
+ return (await this.getLinuxDistro()) === LinuxDistro.FEDORA;
267
+ },
268
+ async isRHEL() {
269
+ return (await this.getLinuxDistro()) === LinuxDistro.RHEL;
270
+ },
232
271
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "codify-plugin-lib",
3
- "version": "1.0.182-beta63",
3
+ "version": "1.0.182-beta64",
4
4
  "description": "Library plugin library",
5
5
  "main": "dist/index.js",
6
6
  "typings": "dist/index.d.ts",
@@ -18,6 +18,26 @@ export enum Shell {
18
18
  FISH = 'fish',
19
19
  }
20
20
 
21
+ export enum LinuxDistro {
22
+ ARCH = 'arch',
23
+ CENTOS = 'centos',
24
+ DEBIAN = 'debian',
25
+ FEDORA = 'fedora',
26
+ RHEL = 'rhel',
27
+ UBUNTU = 'ubuntu',
28
+ ALPINE = 'alpine',
29
+ AMAZON_LINUX = 'amzn',
30
+ OPENSUSE = 'opensuse',
31
+ SUSE = 'sles',
32
+ MANJARO = 'manjaro',
33
+ MINT = 'linuxmint',
34
+ POP_OS = 'pop',
35
+ ELEMENTARY_OS = 'elementary',
36
+ KALI = 'kali',
37
+ GENTOO = 'gentoo',
38
+ SLACKWARE = 'slackware',
39
+ }
40
+
21
41
  export interface SystemInfo {
22
42
  os: OS;
23
43
  shell: Shell;
@@ -277,18 +297,42 @@ Brew can be installed using Codify:
277
297
  return false;
278
298
  },
279
299
 
280
-
281
- async linuxDistro(): Promise<'arch' | 'centos' | 'debian' | 'fedora' | 'rhel' | 'ubuntu' | undefined> {
300
+ async getLinuxDistro(): Promise<LinuxDistro | undefined> {
282
301
  const osRelease = await fs.readFile('/etc/os-release', 'utf8');
283
302
  const lines = osRelease.split('\n');
284
303
  for (const line of lines) {
285
304
  if (line.startsWith('ID=')) {
286
- return line.slice(3).trim() as any;
305
+ const distroId = line.slice(3).trim().replace(/"/g, '');
306
+ return Object.values(LinuxDistro).includes(distroId as LinuxDistro) ? distroId as LinuxDistro : undefined;
287
307
  }
288
308
  }
289
309
 
290
310
  return undefined;
291
- }
311
+ },
312
+
313
+ async isUbuntu(): Promise<boolean> {
314
+ return (await this.getLinuxDistro()) === LinuxDistro.UBUNTU;
315
+ },
316
+
317
+ async isDebian(): Promise<boolean> {
318
+ return (await this.getLinuxDistro()) === LinuxDistro.DEBIAN;
319
+ },
320
+
321
+ async isArch(): Promise<boolean> {
322
+ return (await this.getLinuxDistro()) === LinuxDistro.ARCH;
323
+ },
324
+
325
+ async isCentOS(): Promise<boolean> {
326
+ return (await this.getLinuxDistro()) === LinuxDistro.CENTOS;
327
+ },
328
+
329
+ async isFedora(): Promise<boolean> {
330
+ return (await this.getLinuxDistro()) === LinuxDistro.FEDORA;
331
+ },
332
+
333
+ async isRHEL(): Promise<boolean> {
334
+ return (await this.getLinuxDistro()) === LinuxDistro.RHEL;
335
+ },
292
336
  };
293
337
 
294
338