penguins-eggs 10.0.31 → 10.0.32

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.
@@ -1498,5 +1498,5 @@
1498
1498
  ]
1499
1499
  }
1500
1500
  },
1501
- "version": "10.0.31"
1501
+ "version": "10.0.32"
1502
1502
  }
package/README.md CHANGED
@@ -491,7 +491,7 @@ EXAMPLES
491
491
  $ eggs adapt
492
492
  ```
493
493
 
494
- _See code: [src/commands/adapt.ts](https://github.com/pieroproietti/penguins-eggs/blob/v10.0.31/src/commands/adapt.ts)_
494
+ _See code: [src/commands/adapt.ts](https://github.com/pieroproietti/penguins-eggs/blob/v10.0.32/src/commands/adapt.ts)_
495
495
 
496
496
  ## `eggs analyze`
497
497
 
@@ -512,7 +512,7 @@ EXAMPLES
512
512
  sudo eggs analyze
513
513
  ```
514
514
 
515
- _See code: [src/commands/analyze.ts](https://github.com/pieroproietti/penguins-eggs/blob/v10.0.31/src/commands/analyze.ts)_
515
+ _See code: [src/commands/analyze.ts](https://github.com/pieroproietti/penguins-eggs/blob/v10.0.32/src/commands/analyze.ts)_
516
516
 
517
517
  ## `eggs autocomplete [SHELL]`
518
518
 
@@ -543,7 +543,7 @@ EXAMPLES
543
543
  $ eggs autocomplete --refresh-cache
544
544
  ```
545
545
 
546
- _See code: [@oclif/plugin-autocomplete](https://github.com/oclif/plugin-autocomplete/blob/v3.2.0/src/commands/autocomplete/index.ts)_
546
+ _See code: [@oclif/plugin-autocomplete](https://github.com/oclif/plugin-autocomplete/blob/v3.2.2/src/commands/autocomplete/index.ts)_
547
547
 
548
548
  ## `eggs calamares`
549
549
 
@@ -576,7 +576,7 @@ EXAMPLES
576
576
  sudo eggs calamares --remove
577
577
  ```
578
578
 
579
- _See code: [src/commands/calamares.ts](https://github.com/pieroproietti/penguins-eggs/blob/v10.0.31/src/commands/calamares.ts)_
579
+ _See code: [src/commands/calamares.ts](https://github.com/pieroproietti/penguins-eggs/blob/v10.0.32/src/commands/calamares.ts)_
580
580
 
581
581
  ## `eggs config`
582
582
 
@@ -603,7 +603,7 @@ EXAMPLES
603
603
  sudo eggs config --clean --nointeractive
604
604
  ```
605
605
 
606
- _See code: [src/commands/config.ts](https://github.com/pieroproietti/penguins-eggs/blob/v10.0.31/src/commands/config.ts)_
606
+ _See code: [src/commands/config.ts](https://github.com/pieroproietti/penguins-eggs/blob/v10.0.32/src/commands/config.ts)_
607
607
 
608
608
  ## `eggs cuckoo`
609
609
 
@@ -623,7 +623,7 @@ EXAMPLES
623
623
  sudo eggs cuckoo
624
624
  ```
625
625
 
626
- _See code: [src/commands/cuckoo.ts](https://github.com/pieroproietti/penguins-eggs/blob/v10.0.31/src/commands/cuckoo.ts)_
626
+ _See code: [src/commands/cuckoo.ts](https://github.com/pieroproietti/penguins-eggs/blob/v10.0.32/src/commands/cuckoo.ts)_
627
627
 
628
628
  ## `eggs dad`
629
629
 
@@ -651,7 +651,7 @@ EXAMPLES
651
651
  sudo dad --default
652
652
  ```
653
653
 
654
- _See code: [src/commands/dad.ts](https://github.com/pieroproietti/penguins-eggs/blob/v10.0.31/src/commands/dad.ts)_
654
+ _See code: [src/commands/dad.ts](https://github.com/pieroproietti/penguins-eggs/blob/v10.0.32/src/commands/dad.ts)_
655
655
 
656
656
  ## `eggs export deb`
657
657
 
@@ -678,7 +678,7 @@ EXAMPLES
678
678
  $ eggs export deb --all
679
679
  ```
680
680
 
681
- _See code: [src/commands/export/deb.ts](https://github.com/pieroproietti/penguins-eggs/blob/v10.0.31/src/commands/export/deb.ts)_
681
+ _See code: [src/commands/export/deb.ts](https://github.com/pieroproietti/penguins-eggs/blob/v10.0.32/src/commands/export/deb.ts)_
682
682
 
683
683
  ## `eggs export iso`
684
684
 
@@ -703,7 +703,7 @@ EXAMPLES
703
703
  $ eggs export iso --clean
704
704
  ```
705
705
 
706
- _See code: [src/commands/export/iso.ts](https://github.com/pieroproietti/penguins-eggs/blob/v10.0.31/src/commands/export/iso.ts)_
706
+ _See code: [src/commands/export/iso.ts](https://github.com/pieroproietti/penguins-eggs/blob/v10.0.32/src/commands/export/iso.ts)_
707
707
 
708
708
  ## `eggs help [COMMAND]`
709
709
 
@@ -723,7 +723,7 @@ DESCRIPTION
723
723
  Display help for eggs.
724
724
  ```
725
725
 
726
- _See code: [@oclif/plugin-help](https://github.com/oclif/plugin-help/blob/v6.2.8/src/commands/help.ts)_
726
+ _See code: [@oclif/plugin-help](https://github.com/oclif/plugin-help/blob/v6.2.10/src/commands/help.ts)_
727
727
 
728
728
  ## `eggs install`
729
729
 
@@ -764,7 +764,7 @@ EXAMPLES
764
764
  sudo eggs install --chroot
765
765
  ```
766
766
 
767
- _See code: [src/commands/install.ts](https://github.com/pieroproietti/penguins-eggs/blob/v10.0.31/src/commands/install.ts)_
767
+ _See code: [src/commands/install.ts](https://github.com/pieroproietti/penguins-eggs/blob/v10.0.32/src/commands/install.ts)_
768
768
 
769
769
  ## `eggs kill`
770
770
 
@@ -787,7 +787,7 @@ EXAMPLES
787
787
  sudo eggs kill
788
788
  ```
789
789
 
790
- _See code: [src/commands/kill.ts](https://github.com/pieroproietti/penguins-eggs/blob/v10.0.31/src/commands/kill.ts)_
790
+ _See code: [src/commands/kill.ts](https://github.com/pieroproietti/penguins-eggs/blob/v10.0.32/src/commands/kill.ts)_
791
791
 
792
792
  ## `eggs krill`
793
793
 
@@ -847,7 +847,7 @@ EXAMPLES
847
847
  $ eggs auto
848
848
  ```
849
849
 
850
- _See code: [src/commands/love.ts](https://github.com/pieroproietti/penguins-eggs/blob/v10.0.31/src/commands/love.ts)_
850
+ _See code: [src/commands/love.ts](https://github.com/pieroproietti/penguins-eggs/blob/v10.0.32/src/commands/love.ts)_
851
851
 
852
852
  ## `eggs mom`
853
853
 
@@ -867,7 +867,7 @@ EXAMPLES
867
867
  $ eggs mom
868
868
  ```
869
869
 
870
- _See code: [src/commands/mom.ts](https://github.com/pieroproietti/penguins-eggs/blob/v10.0.31/src/commands/mom.ts)_
870
+ _See code: [src/commands/mom.ts](https://github.com/pieroproietti/penguins-eggs/blob/v10.0.32/src/commands/mom.ts)_
871
871
 
872
872
  ## `eggs produce`
873
873
 
@@ -924,7 +924,7 @@ EXAMPLES
924
924
  sudo eggs produce --excludes home # exclude ~/*
925
925
  ```
926
926
 
927
- _See code: [src/commands/produce.ts](https://github.com/pieroproietti/penguins-eggs/blob/v10.0.31/src/commands/produce.ts)_
927
+ _See code: [src/commands/produce.ts](https://github.com/pieroproietti/penguins-eggs/blob/v10.0.32/src/commands/produce.ts)_
928
928
 
929
929
  ## `eggs status`
930
930
 
@@ -945,7 +945,7 @@ EXAMPLES
945
945
  $ eggs status
946
946
  ```
947
947
 
948
- _See code: [src/commands/status.ts](https://github.com/pieroproietti/penguins-eggs/blob/v10.0.31/src/commands/status.ts)_
948
+ _See code: [src/commands/status.ts](https://github.com/pieroproietti/penguins-eggs/blob/v10.0.32/src/commands/status.ts)_
949
949
 
950
950
  ## `eggs syncfrom`
951
951
 
@@ -971,7 +971,7 @@ EXAMPLES
971
971
  sudo eggs syncfrom --file /path/to/luks-volume
972
972
  ```
973
973
 
974
- _See code: [src/commands/syncfrom.ts](https://github.com/pieroproietti/penguins-eggs/blob/v10.0.31/src/commands/syncfrom.ts)_
974
+ _See code: [src/commands/syncfrom.ts](https://github.com/pieroproietti/penguins-eggs/blob/v10.0.32/src/commands/syncfrom.ts)_
975
975
 
976
976
  ## `eggs syncto`
977
977
 
@@ -998,7 +998,7 @@ EXAMPLES
998
998
  sudo eggs syncto --excludes
999
999
  ```
1000
1000
 
1001
- _See code: [src/commands/syncto.ts](https://github.com/pieroproietti/penguins-eggs/blob/v10.0.31/src/commands/syncto.ts)_
1001
+ _See code: [src/commands/syncto.ts](https://github.com/pieroproietti/penguins-eggs/blob/v10.0.32/src/commands/syncto.ts)_
1002
1002
 
1003
1003
  ## `eggs tools clean`
1004
1004
 
@@ -1020,7 +1020,7 @@ EXAMPLES
1020
1020
  sudo eggs tools clean
1021
1021
  ```
1022
1022
 
1023
- _See code: [src/commands/tools/clean.ts](https://github.com/pieroproietti/penguins-eggs/blob/v10.0.31/src/commands/tools/clean.ts)_
1023
+ _See code: [src/commands/tools/clean.ts](https://github.com/pieroproietti/penguins-eggs/blob/v10.0.32/src/commands/tools/clean.ts)_
1024
1024
 
1025
1025
  ## `eggs tools ppa`
1026
1026
 
@@ -1046,7 +1046,7 @@ EXAMPLES
1046
1046
  sudo eggs tools ppa --remove
1047
1047
  ```
1048
1048
 
1049
- _See code: [src/commands/tools/ppa.ts](https://github.com/pieroproietti/penguins-eggs/blob/v10.0.31/src/commands/tools/ppa.ts)_
1049
+ _See code: [src/commands/tools/ppa.ts](https://github.com/pieroproietti/penguins-eggs/blob/v10.0.32/src/commands/tools/ppa.ts)_
1050
1050
 
1051
1051
  ## `eggs tools skel`
1052
1052
 
@@ -1070,7 +1070,7 @@ EXAMPLES
1070
1070
  sudo eggs tools skel --user user-to-be-copied
1071
1071
  ```
1072
1072
 
1073
- _See code: [src/commands/tools/skel.ts](https://github.com/pieroproietti/penguins-eggs/blob/v10.0.31/src/commands/tools/skel.ts)_
1073
+ _See code: [src/commands/tools/skel.ts](https://github.com/pieroproietti/penguins-eggs/blob/v10.0.32/src/commands/tools/skel.ts)_
1074
1074
 
1075
1075
  ## `eggs tools stat`
1076
1076
 
@@ -1096,7 +1096,7 @@ EXAMPLES
1096
1096
  $ eggs tools stat --year
1097
1097
  ```
1098
1098
 
1099
- _See code: [src/commands/tools/stat.ts](https://github.com/pieroproietti/penguins-eggs/blob/v10.0.31/src/commands/tools/stat.ts)_
1099
+ _See code: [src/commands/tools/stat.ts](https://github.com/pieroproietti/penguins-eggs/blob/v10.0.32/src/commands/tools/stat.ts)_
1100
1100
 
1101
1101
  ## `eggs tools yolk`
1102
1102
 
@@ -1117,7 +1117,7 @@ EXAMPLES
1117
1117
  sudo eggs tools yolk
1118
1118
  ```
1119
1119
 
1120
- _See code: [src/commands/tools/yolk.ts](https://github.com/pieroproietti/penguins-eggs/blob/v10.0.31/src/commands/tools/yolk.ts)_
1120
+ _See code: [src/commands/tools/yolk.ts](https://github.com/pieroproietti/penguins-eggs/blob/v10.0.32/src/commands/tools/yolk.ts)_
1121
1121
 
1122
1122
  ## `eggs update`
1123
1123
 
@@ -1138,7 +1138,7 @@ EXAMPLES
1138
1138
  $ eggs update
1139
1139
  ```
1140
1140
 
1141
- _See code: [src/commands/update.ts](https://github.com/pieroproietti/penguins-eggs/blob/v10.0.31/src/commands/update.ts)_
1141
+ _See code: [src/commands/update.ts](https://github.com/pieroproietti/penguins-eggs/blob/v10.0.32/src/commands/update.ts)_
1142
1142
 
1143
1143
  ## `eggs version`
1144
1144
 
@@ -1158,7 +1158,7 @@ FLAG DESCRIPTIONS
1158
1158
  Additionally shows the architecture, node version, operating system, and versions of plugins that the CLI is using.
1159
1159
  ```
1160
1160
 
1161
- _See code: [@oclif/plugin-version](https://github.com/oclif/plugin-version/blob/v2.2.10/src/commands/version.ts)_
1161
+ _See code: [@oclif/plugin-version](https://github.com/oclif/plugin-version/blob/v2.2.11/src/commands/version.ts)_
1162
1162
 
1163
1163
  ## `eggs wardrobe get [REPO]`
1164
1164
 
@@ -1184,7 +1184,7 @@ EXAMPLES
1184
1184
  $ eggs wardrobe get your-wardrobe
1185
1185
  ```
1186
1186
 
1187
- _See code: [src/commands/wardrobe/get.ts](https://github.com/pieroproietti/penguins-eggs/blob/v10.0.31/src/commands/wardrobe/get.ts)_
1187
+ _See code: [src/commands/wardrobe/get.ts](https://github.com/pieroproietti/penguins-eggs/blob/v10.0.32/src/commands/wardrobe/get.ts)_
1188
1188
 
1189
1189
  ## `eggs wardrobe list [REPO]`
1190
1190
 
@@ -1213,7 +1213,7 @@ EXAMPLES
1213
1213
  $ eggs wardrobe list --distro arch
1214
1214
  ```
1215
1215
 
1216
- _See code: [src/commands/wardrobe/list.ts](https://github.com/pieroproietti/penguins-eggs/blob/v10.0.31/src/commands/wardrobe/list.ts)_
1216
+ _See code: [src/commands/wardrobe/list.ts](https://github.com/pieroproietti/penguins-eggs/blob/v10.0.32/src/commands/wardrobe/list.ts)_
1217
1217
 
1218
1218
  ## `eggs wardrobe show [REPO]`
1219
1219
 
@@ -1243,7 +1243,7 @@ EXAMPLES
1243
1243
  $ eggs wardrobe show accessories/
1244
1244
  ```
1245
1245
 
1246
- _See code: [src/commands/wardrobe/show.ts](https://github.com/pieroproietti/penguins-eggs/blob/v10.0.31/src/commands/wardrobe/show.ts)_
1246
+ _See code: [src/commands/wardrobe/show.ts](https://github.com/pieroproietti/penguins-eggs/blob/v10.0.32/src/commands/wardrobe/show.ts)_
1247
1247
 
1248
1248
  ## `eggs wardrobe wear [REPO]`
1249
1249
 
@@ -1274,7 +1274,7 @@ EXAMPLES
1274
1274
  sudo eggs wardrobe wear wagtail/waydroid
1275
1275
  ```
1276
1276
 
1277
- _See code: [src/commands/wardrobe/wear.ts](https://github.com/pieroproietti/penguins-eggs/blob/v10.0.31/src/commands/wardrobe/wear.ts)_
1277
+ _See code: [src/commands/wardrobe/wear.ts](https://github.com/pieroproietti/penguins-eggs/blob/v10.0.32/src/commands/wardrobe/wear.ts)_
1278
1278
  <!-- commandsstop -->
1279
1279
 
1280
1280
  # penGUI
@@ -1,7 +1,7 @@
1
1
  # eggs: isolinux.main.alpine.cfg
2
2
  #
3
3
  path
4
- include isolinux.theme.cfg
4
+ #include isolinux.theme.cfg
5
5
  DEFAULT vesamenu.c32
6
6
 
7
7
  TIMEOUT 100
@@ -9,24 +9,20 @@ PROMPT 0
9
9
 
10
10
  LABEL alpine
11
11
  MENU LABEL {{{fullname}}}
12
- SAY "Booting {{{fullname}}} Alpine"
13
12
  LINUX {{{vmlinuz}}}
14
- INITRD {{{initrdImg}}}
15
- FDTDIR /live/dtbs-lts
16
- APPEND modules=loop,squashfs,sd-mod,usb-storage,cdrom
13
+ append initrd={{{initrdImg}}} {{{kernel_parameters}}}
17
14
 
18
15
  LABEL Safe
19
16
  MENU LABEL {{{fullname}}} Safe Mode
20
17
  SAY "Booting {{{fullname}}} GNU/Linux (kernel {{{kernel}}})"
21
18
  LINUX {{{vmlinuz}}}
22
- append initrd={{{initrdImg}}} {{{kernel_parameters}}} auto noprompt priority=critical nomodeset apparmor=0 net.ifnames=0 noapic noapm nodma nomce nolapic nosmp vga=normal mitigations=off amd_pstate.enable=0 intel_pstate=disable loglevel=0 nowatchdog elevator=noop slab_nomerge init_on_alloc=1 init_on_free=1 page_alloc.shuffle=1 pti=on vsyscall=none debugfs=off oops=panic module.sig_enforce=1 lockdown=confidentiality mce=0 loglevel=0 fsck.mode=skip quiet splash
23
-
19
+ append initrd={{{initrdImg}}} {{{kernel_parameters}}}
24
20
 
25
21
  label Text
26
22
  menu label {{{fullname}}} Text Mode
27
23
  say "Booting {{{fullname}}} GNU/Linux (kernel {{{kernel}}})"
28
24
  linux {{{vmlinuz}}}
29
- append initrd={{{initrdImg}}} {{{kernel_parameters}}} auto noprompt priority=critical init 3 mitigations=off amd_pstate.enable=0 intel_pstate=disable loglevel=0 nowatchdog elevator=noop slab_nomerge init_on_alloc=1 init_on_free=1 page_alloc.shuffle=1 pti=on vsyscall=none debugfs=off oops=panic module.sig_enforce=1 lockdown=confidentiality mce=0 loglevel=0 fsck.mode=skip quiet splash
25
+ append initrd={{{initrdImg}}} {{{kernel_parameters}}}
30
26
 
31
27
  label local
32
28
  menu label Boot from local disk
@@ -713,8 +713,6 @@ export default class Ovary {
713
713
  // mkinitfs
714
714
  const pathConf = path.resolve(__dirname, `../../mkinitfs/live.conf`);
715
715
  await exec(`mkinitfs -c ${pathConf} -o ${this.settings.iso_work}live/${initrdImg}`, Utils.setEcho(true));
716
- const sidecars = path.resolve(__dirname, `../../mkinitfs/*.sh`);
717
- await exec(`cp ${sidecars} ${this.settings.iso_work}live/`);
718
716
  }
719
717
  /**
720
718
  * initrdArch()
@@ -862,10 +860,17 @@ export default class Ovary {
862
860
  }
863
861
  // GRUB_CMDLINE_LINUX='ipv6.disable=1'
864
862
  const { distroId } = this.settings.distro;
865
- let kp = `boot=live components locales=${process.env.LANG}`;
866
- if (this.familyId === 'archlinux') {
863
+ let kp = "";
864
+ if (this.familyId === 'debian') {
865
+ kp += `boot=live components locales=${process.env.LANG}`;
866
+ }
867
+ else if (this.familyId === 'archlinux') {
868
+ kp += `boot=live components locales=${process.env.LANG}`;
867
869
  kp += isMiso(distroId) ? ` misobasedir=manjaro misolabel=${this.volid}` : ` archisobasedir=arch archisolabel=${this.volid}`;
868
870
  }
871
+ else if (this.familyId === 'alpine') {
872
+ kp += `alpinelivelabel=${this.volid} alpinelivesquashfs=/mnt/live/filesystem.squashfs`;
873
+ }
869
874
  kp += ` cow_spacesize=4G`;
870
875
  return kp;
871
876
  }
@@ -0,0 +1,8 @@
1
+ /**
2
+ * ./src/index.ts
3
+ * penguins-eggs v.10.0.0 / ecmascript 2020
4
+ * author: Piero Proietti
5
+ * email: piero.proietti@gmail.com
6
+ * license: MIT
7
+ */
8
+ export { run } from '@oclif/core';
@@ -0,0 +1,8 @@
1
+ /**
2
+ * ./src/index.ts
3
+ * penguins-eggs v.10.0.0 / ecmascript 2020
4
+ * author: Piero Proietti
5
+ * email: piero.proietti@gmail.com
6
+ * license: MIT
7
+ */
8
+ export { run } from '@oclif/core';
package/dist/index.d.ts CHANGED
@@ -1,8 +1,54 @@
1
+ import { Errors, Interfaces } from '@oclif/core';
2
+ type CaptureOptions = {
3
+ print?: boolean;
4
+ stripAnsi?: boolean;
5
+ };
6
+ type CaptureResult<T> = {
7
+ error?: Error & Partial<Errors.CLIError>;
8
+ result?: T;
9
+ stderr: string;
10
+ stdout: string;
11
+ };
1
12
  /**
2
- * ./src/index.ts
3
- * penguins-eggs v.10.0.0 / ecmascript 2020
4
- * author: Piero Proietti
5
- * email: piero.proietti@gmail.com
6
- * license: MIT
13
+ * Capture the stderr and stdout output of a function
14
+ * @param fn async function to run
15
+ * @param opts options
16
+ * - print: Whether to print the output to the console
17
+ * - stripAnsi: Whether to strip ANSI codes from the output
18
+ * @returns {Promise<CaptureResult<T>>} Captured output
19
+ * - error: Error object if the function throws an error
20
+ * - result: Result of the function if it returns a value and succeeds
21
+ * - stderr: Captured stderr output
22
+ * - stdout: Captured stdout output
7
23
  */
8
- export { run } from '@oclif/core';
24
+ export declare function captureOutput<T>(fn: () => Promise<unknown>, opts?: CaptureOptions): Promise<CaptureResult<T>>;
25
+ /**
26
+ * Capture the stderr and stdout output of a command in your CLI
27
+ * @param args Command arguments, e.g. `['my:command', '--flag']` or `'my:command --flag'`
28
+ * @param loadOpts options for loading oclif `Config`
29
+ * @param captureOpts options for capturing the output
30
+ * - print: Whether to print the output to the console
31
+ * - stripAnsi: Whether to strip ANSI codes from the output
32
+ * @returns {Promise<CaptureResult<T>>} Captured output
33
+ * - error: Error object if the command throws an error
34
+ * - result: Result of the command if it returns a value and succeeds
35
+ * - stderr: Captured stderr output
36
+ * - stdout: Captured stdout output
37
+ */
38
+ export declare function runCommand<T>(args: string | string[], loadOpts?: Interfaces.LoadOptions, captureOpts?: CaptureOptions): Promise<CaptureResult<T>>;
39
+ /**
40
+ * Capture the stderr and stdout output of a hook in your CLI
41
+ * @param hook Hook name
42
+ * @param options options to pass to the hook
43
+ * @param loadOpts options for loading oclif `Config`
44
+ * @param captureOpts options for capturing the output
45
+ * - print: Whether to print the output to the console
46
+ * - stripAnsi: Whether to strip ANSI codes from the output
47
+ * @returns {Promise<CaptureResult<T>>} Captured output
48
+ * - error: Error object if the hook throws an error
49
+ * - result: Result of the hook if it returns a value and succeeds
50
+ * - stderr: Captured stderr output
51
+ * - stdout: Captured stdout output
52
+ */
53
+ export declare function runHook<T>(hook: string, options: Record<string, unknown>, loadOpts?: Interfaces.LoadOptions, captureOpts?: CaptureOptions): Promise<CaptureResult<T>>;
54
+ export {};
package/dist/index.js CHANGED
@@ -1,8 +1,147 @@
1
+ import { Config, Errors, run } from '@oclif/core';
2
+ import makeDebug from 'debug';
3
+ import { dirname } from 'node:path';
4
+ const debug = makeDebug('oclif-test');
5
+ function traverseFilePathUntil(filename, predicate) {
6
+ let current = filename;
7
+ while (!predicate(current)) {
8
+ current = dirname(current);
9
+ }
10
+ return current;
11
+ }
12
+ function findRoot() {
13
+ return (process.env.OCLIF_TEST_ROOT ??
14
+ // eslint-disable-next-line unicorn/prefer-module
15
+ Object.values(require.cache).find((m) => m?.children.includes(module))?.filename ??
16
+ traverseFilePathUntil(
17
+ // eslint-disable-next-line unicorn/prefer-module
18
+ require.main?.path ?? module.path, (p) => !(p.includes('node_modules') || p.includes('.pnpm') || p.includes('.yarn'))));
19
+ }
20
+ function makeLoadOptions(loadOpts) {
21
+ return loadOpts ?? { root: findRoot() };
22
+ }
1
23
  /**
2
- * ./src/index.ts
3
- * penguins-eggs v.10.0.0 / ecmascript 2020
4
- * author: Piero Proietti
5
- * email: piero.proietti@gmail.com
6
- * license: MIT
24
+ * Split a string into an array of strings, preserving quoted substrings
25
+ *
26
+ * @example
27
+ * splitString('foo bar --name "foo"') // ['foo bar', '--name', 'foo']
28
+ * splitString('foo bar --name "foo bar"') // ['foo bar', '--name', 'foo bar']
29
+ * splitString('foo bar --name="foo bar"') // ['foo bar', '--name=foo bar']
30
+ * splitString('foo bar --name=foo bar') // ['foo bar', '--name=foo', 'bar']
31
+ *
32
+ * @param str input string
33
+ * @returns array of strings with quotes removed
7
34
  */
8
- export { run } from '@oclif/core';
35
+ function splitString(str) {
36
+ return (str.match(/(?:[^\s"]+|"[^"]*")+/g) ?? []).map((s) => s.replaceAll(/^"|"$|(?<==)"/g, ''));
37
+ }
38
+ /**
39
+ * Capture the stderr and stdout output of a function
40
+ * @param fn async function to run
41
+ * @param opts options
42
+ * - print: Whether to print the output to the console
43
+ * - stripAnsi: Whether to strip ANSI codes from the output
44
+ * @returns {Promise<CaptureResult<T>>} Captured output
45
+ * - error: Error object if the function throws an error
46
+ * - result: Result of the function if it returns a value and succeeds
47
+ * - stderr: Captured stderr output
48
+ * - stdout: Captured stdout output
49
+ */
50
+ export async function captureOutput(fn, opts) {
51
+ const print = opts?.print ?? false;
52
+ const stripAnsi = opts?.stripAnsi ?? true;
53
+ const originals = {
54
+ NODE_ENV: process.env.NODE_ENV,
55
+ stderr: process.stderr.write,
56
+ stdout: process.stdout.write,
57
+ };
58
+ const output = {
59
+ stderr: [],
60
+ stdout: [],
61
+ };
62
+ //const toString = (str: Uint8Array | string): string => (stripAnsi ? ansis.strip(str.toString()) : str.toString())
63
+ const toString = (str) => (stripAnsi ? str.toString() : str.toString());
64
+ const getStderr = () => output.stderr.map((b) => toString(b)).join('');
65
+ const getStdout = () => output.stdout.map((b) => toString(b)).join('');
66
+ const mock = (std) => (str, encoding, cb) => {
67
+ output[std].push(str);
68
+ if (print) {
69
+ if (encoding !== null && typeof encoding === 'function') {
70
+ cb = encoding;
71
+ encoding = undefined;
72
+ }
73
+ originals[std].apply(process[std], [str, encoding, cb]);
74
+ }
75
+ else if (typeof cb === 'function')
76
+ cb();
77
+ return true;
78
+ };
79
+ process.stdout.write = mock('stdout');
80
+ process.stderr.write = mock('stderr');
81
+ process.env.NODE_ENV = 'test';
82
+ try {
83
+ const result = await fn();
84
+ return {
85
+ result: result,
86
+ stderr: getStderr(),
87
+ stdout: getStdout(),
88
+ };
89
+ }
90
+ catch (error) {
91
+ return {
92
+ ...(error instanceof Errors.CLIError && { error: { ...error, message: toString(error.message) } }),
93
+ ...(error instanceof Error && { error: { ...error, message: toString(error.message) } }),
94
+ stderr: getStderr(),
95
+ stdout: getStdout(),
96
+ };
97
+ }
98
+ finally {
99
+ process.stderr.write = originals.stderr;
100
+ process.stdout.write = originals.stdout;
101
+ process.env.NODE_ENV = originals.NODE_ENV;
102
+ }
103
+ }
104
+ /**
105
+ * Capture the stderr and stdout output of a command in your CLI
106
+ * @param args Command arguments, e.g. `['my:command', '--flag']` or `'my:command --flag'`
107
+ * @param loadOpts options for loading oclif `Config`
108
+ * @param captureOpts options for capturing the output
109
+ * - print: Whether to print the output to the console
110
+ * - stripAnsi: Whether to strip ANSI codes from the output
111
+ * @returns {Promise<CaptureResult<T>>} Captured output
112
+ * - error: Error object if the command throws an error
113
+ * - result: Result of the command if it returns a value and succeeds
114
+ * - stderr: Captured stderr output
115
+ * - stdout: Captured stdout output
116
+ */
117
+ export async function runCommand(args, loadOpts, captureOpts) {
118
+ const loadOptions = makeLoadOptions(loadOpts);
119
+ const argsArray = splitString((Array.isArray(args) ? args : [args]).join(' '));
120
+ const [id, ...rest] = argsArray;
121
+ const finalArgs = id === '.' ? rest : argsArray;
122
+ debug('loadOpts: %O', loadOptions);
123
+ debug('args: %O', finalArgs);
124
+ return captureOutput(async () => run(finalArgs, loadOptions), captureOpts);
125
+ }
126
+ /**
127
+ * Capture the stderr and stdout output of a hook in your CLI
128
+ * @param hook Hook name
129
+ * @param options options to pass to the hook
130
+ * @param loadOpts options for loading oclif `Config`
131
+ * @param captureOpts options for capturing the output
132
+ * - print: Whether to print the output to the console
133
+ * - stripAnsi: Whether to strip ANSI codes from the output
134
+ * @returns {Promise<CaptureResult<T>>} Captured output
135
+ * - error: Error object if the hook throws an error
136
+ * - result: Result of the hook if it returns a value and succeeds
137
+ * - stderr: Captured stderr output
138
+ * - stdout: Captured stdout output
139
+ */
140
+ export async function runHook(hook, options, loadOpts, captureOpts) {
141
+ const loadOptions = makeLoadOptions(loadOpts);
142
+ debug('loadOpts: %O', loadOptions);
143
+ return captureOutput(async () => {
144
+ const config = await Config.load(loadOptions);
145
+ return config.runHook(hook, options);
146
+ }, captureOpts);
147
+ }
@@ -7,4 +7,8 @@
7
7
  * https://stackoverflow.com/questions/23876782/how-do-i-split-a-typescript-class-into-multiple-files
8
8
  */
9
9
  import Sequence from '../sequence.js';
10
+ /**
11
+ *
12
+ * @param this
13
+ */
10
14
  export default function bootloaderConfig(this: Sequence): Promise<void>;