@metamask/snaps-cli 8.3.0 → 8.4.0

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.
Files changed (88) hide show
  1. package/CHANGELOG.md +38 -1
  2. package/dist/builders.cjs +11 -0
  3. package/dist/builders.cjs.map +1 -1
  4. package/dist/builders.d.cts +11 -0
  5. package/dist/builders.d.cts.map +1 -1
  6. package/dist/builders.d.mts +11 -0
  7. package/dist/builders.d.mts.map +1 -1
  8. package/dist/builders.mjs +11 -0
  9. package/dist/builders.mjs.map +1 -1
  10. package/dist/commands/build/build.cjs +15 -7
  11. package/dist/commands/build/build.cjs.map +1 -1
  12. package/dist/commands/build/build.d.cts +19 -3
  13. package/dist/commands/build/build.d.cts.map +1 -1
  14. package/dist/commands/build/build.d.mts +19 -3
  15. package/dist/commands/build/build.d.mts.map +1 -1
  16. package/dist/commands/build/build.mjs +15 -7
  17. package/dist/commands/build/build.mjs.map +1 -1
  18. package/dist/commands/build/index.cjs +15 -2
  19. package/dist/commands/build/index.cjs.map +1 -1
  20. package/dist/commands/build/index.d.cts.map +1 -1
  21. package/dist/commands/build/index.d.mts.map +1 -1
  22. package/dist/commands/build/index.mjs +15 -2
  23. package/dist/commands/build/index.mjs.map +1 -1
  24. package/dist/commands/manifest/implementation.cjs +1 -2
  25. package/dist/commands/manifest/implementation.cjs.map +1 -1
  26. package/dist/commands/manifest/implementation.d.cts.map +1 -1
  27. package/dist/commands/manifest/implementation.d.mts.map +1 -1
  28. package/dist/commands/manifest/implementation.mjs +1 -2
  29. package/dist/commands/manifest/implementation.mjs.map +1 -1
  30. package/dist/commands/sandbox/sandbox.cjs +4 -1
  31. package/dist/commands/sandbox/sandbox.cjs.map +1 -1
  32. package/dist/commands/sandbox/sandbox.d.cts.map +1 -1
  33. package/dist/commands/sandbox/sandbox.d.mts.map +1 -1
  34. package/dist/commands/sandbox/sandbox.mjs +4 -1
  35. package/dist/commands/sandbox/sandbox.mjs.map +1 -1
  36. package/dist/commands/watch/index.cjs +7 -4
  37. package/dist/commands/watch/index.cjs.map +1 -1
  38. package/dist/commands/watch/index.d.cts.map +1 -1
  39. package/dist/commands/watch/index.d.mts.map +1 -1
  40. package/dist/commands/watch/index.mjs +7 -4
  41. package/dist/commands/watch/index.mjs.map +1 -1
  42. package/dist/config.cjs +5 -0
  43. package/dist/config.cjs.map +1 -1
  44. package/dist/config.d.cts +71 -22
  45. package/dist/config.d.cts.map +1 -1
  46. package/dist/config.d.mts +71 -22
  47. package/dist/config.d.mts.map +1 -1
  48. package/dist/config.mjs +5 -0
  49. package/dist/config.mjs.map +1 -1
  50. package/dist/utils/cli.cjs +44 -4
  51. package/dist/utils/cli.cjs.map +1 -1
  52. package/dist/utils/cli.d.cts +9 -0
  53. package/dist/utils/cli.d.cts.map +1 -1
  54. package/dist/utils/cli.d.mts +9 -0
  55. package/dist/utils/cli.d.mts.map +1 -1
  56. package/dist/utils/cli.mjs +20 -1
  57. package/dist/utils/cli.mjs.map +1 -1
  58. package/dist/webpack/config.cjs +7 -1
  59. package/dist/webpack/config.cjs.map +1 -1
  60. package/dist/webpack/config.d.cts +16 -4
  61. package/dist/webpack/config.d.cts.map +1 -1
  62. package/dist/webpack/config.d.mts +16 -4
  63. package/dist/webpack/config.d.mts.map +1 -1
  64. package/dist/webpack/config.mjs +8 -2
  65. package/dist/webpack/config.mjs.map +1 -1
  66. package/dist/webpack/plugins.cjs +90 -2
  67. package/dist/webpack/plugins.cjs.map +1 -1
  68. package/dist/webpack/plugins.d.cts +36 -2
  69. package/dist/webpack/plugins.d.cts.map +1 -1
  70. package/dist/webpack/plugins.d.mts +36 -2
  71. package/dist/webpack/plugins.d.mts.map +1 -1
  72. package/dist/webpack/plugins.mjs +90 -3
  73. package/dist/webpack/plugins.mjs.map +1 -1
  74. package/dist/webpack/server.cjs +14 -3
  75. package/dist/webpack/server.cjs.map +1 -1
  76. package/dist/webpack/server.d.cts.map +1 -1
  77. package/dist/webpack/server.d.mts.map +1 -1
  78. package/dist/webpack/server.mjs +16 -5
  79. package/dist/webpack/server.mjs.map +1 -1
  80. package/dist/webpack/utils.cjs +29 -1
  81. package/dist/webpack/utils.cjs.map +1 -1
  82. package/dist/webpack/utils.d.cts +9 -1
  83. package/dist/webpack/utils.d.cts.map +1 -1
  84. package/dist/webpack/utils.d.mts +9 -1
  85. package/dist/webpack/utils.d.mts.map +1 -1
  86. package/dist/webpack/utils.mjs +27 -0
  87. package/dist/webpack/utils.mjs.map +1 -1
  88. package/package.json +7 -7
package/dist/config.d.mts CHANGED
@@ -190,6 +190,26 @@ export type SnapConfig = {
190
190
  vm?: boolean;
191
191
  zlib?: boolean;
192
192
  };
193
+ /**
194
+ * Options for preinstalled Snaps. These options are added to the preinstalled
195
+ * Snap bundle.
196
+ *
197
+ * These options do not affect regular Snaps that are installed by users.
198
+ */
199
+ preinstalled?: {
200
+ /**
201
+ * Whether to hide branding specific to Snaps in the client UI.
202
+ */
203
+ hideSnapBranding?: boolean;
204
+ /**
205
+ * Whether the Snap should be hidden from the user in the client UI.
206
+ */
207
+ hidden?: boolean;
208
+ /**
209
+ * Whether the Snap can be removed from the client.
210
+ */
211
+ removable?: boolean;
212
+ };
193
213
  /**
194
214
  * Support for TypeScript type-checking feature.
195
215
  *
@@ -285,6 +305,15 @@ export type SnapConfig = {
285
305
  type SnapsWebpackCustomizeWebpackConfigFunction = (config: WebpackConfiguration) => WebpackConfiguration;
286
306
  export declare const SnapsConfigStruct: import("@metamask/superstruct").Struct<{
287
307
  input: string;
308
+ manifest: {
309
+ path: string;
310
+ update: boolean;
311
+ };
312
+ preinstalled: {
313
+ hidden: boolean;
314
+ hideSnapBranding: boolean;
315
+ removable: boolean;
316
+ };
288
317
  sourceMap: boolean | "inline";
289
318
  evaluate: boolean;
290
319
  output: {
@@ -293,10 +322,6 @@ export declare const SnapsConfigStruct: import("@metamask/superstruct").Struct<{
293
322
  clean: boolean;
294
323
  minimize: boolean;
295
324
  };
296
- manifest: {
297
- path: string;
298
- update: boolean;
299
- };
300
325
  server: {
301
326
  port: number;
302
327
  root: string;
@@ -311,7 +336,6 @@ export declare const SnapsConfigStruct: import("@metamask/superstruct").Struct<{
311
336
  buffer: boolean;
312
337
  };
313
338
  polyfills: boolean | {
314
- stream: boolean;
315
339
  path: boolean;
316
340
  buffer: boolean;
317
341
  assert: boolean;
@@ -326,6 +350,7 @@ export declare const SnapsConfigStruct: import("@metamask/superstruct").Struct<{
326
350
  punycode: boolean;
327
351
  process: boolean;
328
352
  querystring: boolean;
353
+ stream: boolean;
329
354
  _stream_duplex: boolean;
330
355
  _stream_passthrough: boolean;
331
356
  _stream_readable: boolean;
@@ -401,7 +426,6 @@ export declare const SnapsConfigStruct: import("@metamask/superstruct").Struct<{
401
426
  buffer: import("@metamask/superstruct").Struct<boolean, null>;
402
427
  }>;
403
428
  polyfills: import("@metamask/superstruct").Struct<boolean | {
404
- stream: boolean;
405
429
  path: boolean;
406
430
  buffer: boolean;
407
431
  assert: boolean;
@@ -416,6 +440,7 @@ export declare const SnapsConfigStruct: import("@metamask/superstruct").Struct<{
416
440
  punycode: boolean;
417
441
  process: boolean;
418
442
  querystring: boolean;
443
+ stream: boolean;
419
444
  _stream_duplex: boolean;
420
445
  _stream_passthrough: boolean;
421
446
  _stream_readable: boolean;
@@ -430,7 +455,6 @@ export declare const SnapsConfigStruct: import("@metamask/superstruct").Struct<{
430
455
  vm: boolean;
431
456
  zlib: boolean;
432
457
  }, [head: import("@metamask/superstruct").Struct<boolean, null>, import("@metamask/superstruct").Struct<{
433
- stream: boolean;
434
458
  path: boolean;
435
459
  buffer: boolean;
436
460
  assert: boolean;
@@ -445,6 +469,7 @@ export declare const SnapsConfigStruct: import("@metamask/superstruct").Struct<{
445
469
  punycode: boolean;
446
470
  process: boolean;
447
471
  querystring: boolean;
472
+ stream: boolean;
448
473
  _stream_duplex: boolean;
449
474
  _stream_passthrough: boolean;
450
475
  _stream_readable: boolean;
@@ -488,6 +513,15 @@ export declare const SnapsConfigStruct: import("@metamask/superstruct").Struct<{
488
513
  vm: import("@metamask/superstruct").Struct<boolean, null>;
489
514
  zlib: import("@metamask/superstruct").Struct<boolean, null>;
490
515
  }>]>;
516
+ preinstalled: import("@metamask/superstruct").Struct<{
517
+ hidden: boolean;
518
+ hideSnapBranding: boolean;
519
+ removable: boolean;
520
+ }, {
521
+ hideSnapBranding: import("@metamask/superstruct").Struct<boolean, null>;
522
+ hidden: import("@metamask/superstruct").Struct<boolean, null>;
523
+ removable: import("@metamask/superstruct").Struct<boolean, null>;
524
+ }>;
491
525
  typescript: import("@metamask/superstruct").Struct<{
492
526
  enabled: boolean;
493
527
  configFile: string;
@@ -530,6 +564,15 @@ export declare function getConfig(config: unknown): ProcessedConfig;
530
564
  */
531
565
  export declare function loadConfig(path: string): Promise<{
532
566
  input: string;
567
+ manifest: {
568
+ path: string;
569
+ update: boolean;
570
+ };
571
+ preinstalled: {
572
+ hidden: boolean;
573
+ hideSnapBranding: boolean;
574
+ removable: boolean;
575
+ };
533
576
  sourceMap: boolean | "inline";
534
577
  evaluate: boolean;
535
578
  output: {
@@ -538,10 +581,6 @@ export declare function loadConfig(path: string): Promise<{
538
581
  clean: boolean;
539
582
  minimize: boolean;
540
583
  };
541
- manifest: {
542
- path: string;
543
- update: boolean;
544
- };
545
584
  server: {
546
585
  port: number;
547
586
  root: string;
@@ -556,7 +595,6 @@ export declare function loadConfig(path: string): Promise<{
556
595
  buffer: boolean;
557
596
  };
558
597
  polyfills: boolean | {
559
- stream: boolean;
560
598
  path: boolean;
561
599
  buffer: boolean;
562
600
  assert: boolean;
@@ -571,6 +609,7 @@ export declare function loadConfig(path: string): Promise<{
571
609
  punycode: boolean;
572
610
  process: boolean;
573
611
  querystring: boolean;
612
+ stream: boolean;
574
613
  _stream_duplex: boolean;
575
614
  _stream_passthrough: boolean;
576
615
  _stream_readable: boolean;
@@ -608,6 +647,15 @@ export declare function loadConfig(path: string): Promise<{
608
647
  */
609
648
  export declare function resolveConfig(path: string): Promise<{
610
649
  input: string;
650
+ manifest: {
651
+ path: string;
652
+ update: boolean;
653
+ };
654
+ preinstalled: {
655
+ hidden: boolean;
656
+ hideSnapBranding: boolean;
657
+ removable: boolean;
658
+ };
611
659
  sourceMap: boolean | "inline";
612
660
  evaluate: boolean;
613
661
  output: {
@@ -616,10 +664,6 @@ export declare function resolveConfig(path: string): Promise<{
616
664
  clean: boolean;
617
665
  minimize: boolean;
618
666
  };
619
- manifest: {
620
- path: string;
621
- update: boolean;
622
- };
623
667
  server: {
624
668
  port: number;
625
669
  root: string;
@@ -634,7 +678,6 @@ export declare function resolveConfig(path: string): Promise<{
634
678
  buffer: boolean;
635
679
  };
636
680
  polyfills: boolean | {
637
- stream: boolean;
638
681
  path: boolean;
639
682
  buffer: boolean;
640
683
  assert: boolean;
@@ -649,6 +692,7 @@ export declare function resolveConfig(path: string): Promise<{
649
692
  punycode: boolean;
650
693
  process: boolean;
651
694
  querystring: boolean;
695
+ stream: boolean;
652
696
  _stream_duplex: boolean;
653
697
  _stream_passthrough: boolean;
654
698
  _stream_readable: boolean;
@@ -686,6 +730,15 @@ export declare function resolveConfig(path: string): Promise<{
686
730
  */
687
731
  export declare function getConfigByArgv(argv: YargsArgs, cwd?: string): Promise<{
688
732
  input: string;
733
+ manifest: {
734
+ path: string;
735
+ update: boolean;
736
+ };
737
+ preinstalled: {
738
+ hidden: boolean;
739
+ hideSnapBranding: boolean;
740
+ removable: boolean;
741
+ };
689
742
  sourceMap: boolean | "inline";
690
743
  evaluate: boolean;
691
744
  output: {
@@ -694,10 +747,6 @@ export declare function getConfigByArgv(argv: YargsArgs, cwd?: string): Promise<
694
747
  clean: boolean;
695
748
  minimize: boolean;
696
749
  };
697
- manifest: {
698
- path: string;
699
- update: boolean;
700
- };
701
750
  server: {
702
751
  port: number;
703
752
  root: string;
@@ -712,7 +761,6 @@ export declare function getConfigByArgv(argv: YargsArgs, cwd?: string): Promise<
712
761
  buffer: boolean;
713
762
  };
714
763
  polyfills: boolean | {
715
- stream: boolean;
716
764
  path: boolean;
717
765
  buffer: boolean;
718
766
  assert: boolean;
@@ -727,6 +775,7 @@ export declare function getConfigByArgv(argv: YargsArgs, cwd?: string): Promise<
727
775
  punycode: boolean;
728
776
  process: boolean;
729
777
  querystring: boolean;
778
+ stream: boolean;
730
779
  _stream_duplex: boolean;
731
780
  _stream_passthrough: boolean;
732
781
  _stream_readable: boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"config.d.mts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAoBA,OAAO,KAAK,EAAE,KAAK,EAAE,8BAA8B;AAOnD,OAAO,KAAK,EAAE,aAAa,IAAI,oBAAoB,EAAE,gBAAgB;AAIrE,OAAO,KAAK,EAAE,SAAS,EAAE,4BAAsB;AAK/C;;;GAGG;AACH,MAAM,MAAM,UAAU,GAAG;IACvB;;;OAGG;IACH,KAAK,EAAE,MAAM,CAAC;IAEd;;;;;;OAMG;IACH,SAAS,CAAC,EAAE,OAAO,GAAG,QAAQ,CAAC;IAE/B;;;;;OAKG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IAEnB,MAAM,CAAC,EAAE;QACP;;;;;;;;WAQG;QACH,IAAI,CAAC,EAAE,MAAM,CAAC;QAEd;;;;WAIG;QACH,QAAQ,CAAC,EAAE,MAAM,CAAC;QAElB;;;;;;WAMG;QACH,KAAK,CAAC,EAAE,OAAO,CAAC;QAEhB;;;;;WAKG;QACH,QAAQ,CAAC,EAAE,OAAO,CAAC;KACpB,CAAC;IAEF,QAAQ,CAAC,EAAE;QACT;;;;;WAKG;QACH,IAAI,CAAC,EAAE,MAAM,CAAC;QAEd;;;;;;;WAOG;QACH,MAAM,CAAC,EAAE,OAAO,CAAC;KAClB,CAAC;IAEF,MAAM,CAAC,EAAE;QACP;;;;;;WAMG;QACH,OAAO,CAAC,EAAE,OAAO,CAAC;QAElB;;;;;WAKG;QACH,IAAI,CAAC,EAAE,MAAM,CAAC;QAEd;;;;WAIG;QACH,IAAI,CA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,0CAA0C,GAAG,CAChD,MAAM,EAAE,oBAAoB,KACzB,oBAAoB,CAAC;AAW1B,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA0H5B,CAAC;AAEH,MAAM,MAAM,eAAe,GAAG,KAAK,CAAC,OAAO,iBAAiB,CAAC,CAAC;AAE9D;;;;;;GAMG;AACH,wBAAgB,SAAS,CAAC,MAAM,EAAE,OAAO,GAAG,eAAe,CAO1D;AAED;;;;;;;;;;;GAWG;AACH,wBAAsB,UAAU,CAAC,IAAI,EAAE,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuC5C;AAED;;;;;;;;GAQG;AACH,wBAAsB,aAAa,CAAC,IAAI,EAAE,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAW/C;AAED;;;;;;;;GAQG;AACH,wBAAsB,eAAe,CACnC,IAAI,EAAE,SAAS,EACf,GAAG,GAAE,MAAsB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAa5B"}
package/dist/config.mjs CHANGED
@@ -79,6 +79,11 @@ export const SnapsConfigStruct = object({
79
79
  zlib: defaulted(boolean(), false),
80
80
  }),
81
81
  ]), false),
82
+ preinstalled: defaulted(object({
83
+ hideSnapBranding: defaulted(boolean(), false),
84
+ hidden: defaulted(boolean(), false),
85
+ removable: defaulted(boolean(), false),
86
+ }), {}),
82
87
  typescript: defaulted(object({
83
88
  enabled: defaulted(boolean(), false),
84
89
  configFile: defaulted(file(), 'tsconfig.json'),
@@ -1 +1 @@
1
- {"version":3,"file":"config.mjs","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,4BAA4B;AACrD,OAAO,EACL,gBAAgB,EAChB,MAAM,EACN,MAAM,EACN,gBAAgB,EACjB,mCAAmC;AACpC,OAAO,EACL,KAAK,EACL,OAAO,EACP,SAAS,EACT,MAAM,EACN,IAAI,EACJ,MAAM,EACN,MAAM,EACN,QAAQ,EACR,MAAM,EACN,MAAM,EACN,OAAO,EACR,8BAA8B;AAE/B,OAAO,EAAE,WAAW,EAAE,wBAAwB;AAC9C,OAAO,EAAE,SAAS,EAAE,kBAAkB;;;AAEtC,OAAO,EAAE,QAAQ,EAAE,oBAAoB;AACvC,OAAO,MAAM,eAAe;AAC5B,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,aAAa;AAGxC,OAAO,EAAE,WAAW,EAAE,qBAAiB;AACvC,OAAO,EAAE,IAAI,EAAE,sBAAkB;AAEjC,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,0BAAgB;AAEtD,MAAM,YAAY,GAAG,CAAC,WAAW,EAAE,cAAc,CAAC,CAAC;AA4TnD,6EAA6E;AAC7E,6EAA6E;AAC7E,oBAAoB;AACpB,MAAM,gDAAgD,GACpD,MAAM,CACJ,UAAU,EACV,IAAI,EAAE,CAAC,SAAS,CACjB,CAAC;AAEJ,MAAM,CAAC,MAAM,iBAAiB,GAAG,MAAM,CAAC;IACtC,KAAK,EAAE,SAAS,CAAC,IAAI,EAAE,EAAE,OAAO,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,cAAc,CAAC,CAAC;IAChE,SAAS,EAAE,SAAS,CAAC,KAAK,CAAC,CAAC,OAAO,EAAE,EAAE,OAAO,CAAC,QAAQ,CAAC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AAE,CAAC;QACf,IAAI,KAAK,YAAY,gBAAgB,EAAE,CAAC;YACtC,MAAM,IAAI,WAAW,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;QACvC,CAAC;QAED,MAAM,IAAI,WAAW,CACnB,uCAAuC,IAAI,SAAS,MAAM,CACxD,KAAK,CAAC,OAAO,CACd,EAAE,CACJ,CAAC;IACJ,CAAC;AACH,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,CAAC,KAAK,UAAU,aAAa,CAAC,IAAY;IAC9C,KAAK,MAAM,UAAU,IAAI,YAAY,EAAE,CAAC;QACtC,MAAM,QAAQ,GAAG,OAAO,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC;QAC3C,IAAI,MAAM,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC;YAC3B,OAAO,MAAM,UAAU,CAAC,QAAQ,CAAC,CAAC;QACpC,CAAC;IACH,CAAC;IAED,MAAM,IAAI,WAAW,CACnB,sGAAsG,IAAI,KAAK,CAChH,CAAC;AACJ,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,CAAC,KAAK,UAAU,eAAe,CACnC,IAAe,EACf,MAAc,OAAO,CAAC,GAAG,EAAE;IAE3B,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC;QAChB,IAAI,CAAC,CAAC,MAAM,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC;YACjC,MAAM,IAAI,WAAW,CACnB,oCAAoC,IAAI,CAAC,MAAM,wCAAwC,CACxF,CAAC;QACJ,CAAC;QAED,OAAO,MAAM,UAAU,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IACvC,CAAC;IAED,OAAO,MAAM,aAAa,CAAC,GAAG,CAAC,CAAC;AAClC,CAAC","sourcesContent":["import { literal, union } from '@metamask/snaps-sdk';\nimport {\n createFromStruct,\n indent,\n isFile,\n SnapsStructError,\n} from '@metamask/snaps-utils/node';\nimport {\n array,\n boolean,\n defaulted,\n define,\n func,\n number,\n object,\n optional,\n record,\n string,\n unknown,\n} from '@metamask/superstruct';\nimport type { Infer } from '@metamask/superstruct';\nimport { hasProperty } from '@metamask/utils';\nimport { transform } from '@swc/core';\nimport { dim } from 'chalk';\nimport { readFile } from 'fs/promises';\nimport Module from 'module';\nimport { dirname, resolve } from 'path';\nimport type { Configuration as WebpackConfiguration } from 'webpack';\n\nimport { ConfigError } from './errors';\nimport { file } from './structs';\nimport type { YargsArgs } from './types/yargs';\nimport { CONFIG_FILE, TS_CONFIG_FILE } from './utils';\n\nconst CONFIG_FILES = [CONFIG_FILE, TS_CONFIG_FILE];\n\n/**\n * The configuration for the Snaps CLI, stored as `snap.config.js` or\n * `snap.config.ts` in the root of the project.\n */\nexport type SnapConfig = {\n /**\n * The path to the snap entry point. This should be a JavaScript or TypeScript\n * file.\n */\n input: string;\n\n /**\n * Whether to generate source maps for the snap. If `true`, source maps will\n * be generated as separate files. If `'inline'`, source maps will be\n * inlined in the generated JavaScript bundle.\n *\n * @default true\n */\n sourceMap?: boolean | 'inline';\n\n /**\n * Whether to attempt to evaluate the snap in SES. This can catch some errors\n * that would otherwise only be caught at runtime.\n *\n * @default true\n */\n evaluate?: boolean;\n\n output?: {\n /**\n * The path to the directory where the snap will be built. This directory\n * will be created if it doesn't exist.\n *\n * If the path is relative, it will be resolved relative to the current\n * working directory.\n *\n * @default 'dist'\n */\n path?: string;\n\n /**\n * The name of the JavaScript bundle file.\n *\n * @default 'bundle.js'\n */\n filename?: string;\n\n /**\n * Whether to clean the output directory before building the snap. If\n * `true`, the output directory will be deleted and recreated. Otherwise,\n * the output directory will be left as-is.\n *\n * @default false\n */\n clean?: boolean;\n\n /**\n * Whether to minimize the snap bundle. If `true`, the bundle will be\n * minified. Otherwise, the bundle will be left as-is.\n *\n * @default true\n */\n minimize?: boolean;\n };\n\n manifest?: {\n /**\n * The path to the snap manifest file. If the path is relative, it will be\n * resolved relative to the current working directory.\n *\n * @default 'snap.manifest.json'\n */\n path?: string;\n\n /**\n * Whether to automatically update the manifest. If `true`, the manifest\n * will be updated with the latest shasum of the snap bundle, and some\n * common fields will be updated if they are missing or incorrect. If\n * `false`, the manifest will be left as-is.\n *\n * @default true\n */\n update?: boolean;\n };\n\n server?: {\n /**\n * Whether to enable the local server. If `true`, the snap will be served\n * from a local server, when running the `watch` command. If `false`, the\n * snap will not be served.\n *\n * @default true\n */\n enabled?: boolean;\n\n /**\n * The root directory to serve the snap from. If the path is relative, it\n * will be resolved relative to the current working directory.\n *\n * @default `process.cwd()`\n */\n root?: string;\n\n /**\n * The port to run the server on.\n *\n * @default 8081\n */\n port?: number;\n };\n\n /**\n * The environment variables to set when building the snap. These will be\n * available in the snap as `process.env`. In addition to these environment\n * variables, the following environment variables will always be set:\n *\n * - `NODE_DEBUG`: `false`\n * - `NODE_ENV`: `'production'`\n * - `DEBUG`: `false`\n *\n * Any environment variables specified here will override these defaults. You\n * can also override any variables here by setting them in your shell when\n * running the CLI.\n */\n environment?: Record<string, unknown>;\n\n /**\n * Options that control the logging output of the CLI.\n */\n stats?: {\n /**\n * Whether to enable verbose logging.\n *\n * @default false\n */\n verbose?: boolean;\n\n /**\n * Whether to log warnings about unresolved built-in modules. If `false`,\n * warnings will not be logged.\n */\n builtIns?:\n | {\n /**\n * The built-in modules to ignore when resolving modules. If a module\n * is ignored, no warning will be logged if it is not resolved.\n */\n ignore?: string[];\n }\n | false;\n\n /**\n * Whether to log warnings about the use of the `Buffer` global. If `false`,\n * warnings will not be logged. If `true`, the CLI will warn if the `Buffer`\n * global is used, but not provided by Webpack's `DefinePlugin`.\n */\n buffer?: boolean;\n };\n\n /**\n * Whether to provide polyfills for node builtins. If `true`, all the available\n * polyfills will be provided. If `false` no polyfills will be provided. If a\n * configuration object is passed only the polyfills set to `true` will be provided.\n *\n * @default false\n * @example\n * ```ts\n * polyfills: true\n *\n * // or\n *\n * polyfills: {\n * assert: true,\n * buffer: true\n * }\n * ```\n */\n polyfills?:\n | boolean\n | {\n assert?: boolean;\n buffer?: boolean;\n console?: boolean;\n constants?: boolean;\n crypto?: boolean;\n domain?: boolean;\n events?: boolean;\n http?: boolean;\n https?: boolean;\n os?: boolean;\n path?: boolean;\n punycode?: boolean;\n process?: boolean;\n querystring?: boolean;\n stream?: boolean;\n /* eslint-disable @typescript-eslint/naming-convention */\n _stream_duplex?: boolean;\n _stream_passthrough?: boolean;\n _stream_readable?: boolean;\n _stream_transform?: boolean;\n _stream_writable?: boolean;\n string_decoder?: boolean;\n /* eslint-enable @typescript-eslint/naming-convention */\n sys?: boolean;\n timers?: boolean;\n tty?: boolean;\n url?: boolean;\n util?: boolean;\n vm?: boolean;\n zlib?: boolean;\n };\n\n /**\n * Support for TypeScript type-checking feature.\n *\n * @example\n * {\n * enabled: true;\n * configFile: './path/to/tsconfig.json'\n * }\n */\n typescript?: {\n /**\n * Whether to enable TypeScript type-checking feature.\n *\n * @default false\n */\n enabled?: boolean;\n /**\n * Path to tsconfig.json file for the Snap.\n *\n * @default 'tsconfig.json'\n */\n configFile?: string;\n };\n\n /**\n * Optional features to enable in the CLI.\n *\n * @example\n * {\n * features: {\n * images: true,\n * }\n * }\n */\n features?: {\n /**\n * Whether to enable support for images. If `true`, the Webpack\n * configuration will be modified to support images. If `false`, the\n * Webpack configuration will not be modified.\n *\n * @default true\n */\n images?: boolean;\n };\n\n /**\n * A function to customize the Webpack configuration used to build the snap.\n * This function will be called with the default Webpack configuration, and\n * should return the modified configuration. If not specified, the default\n * configuration will be used.\n *\n * It's recommended to use the `webpack-merge` package to merge the default\n * configuration with your customizations. The merge function is exported as\n * `merge` from the `@metamask/snaps-cli` package.\n *\n * @example\n * ```ts\n * import type { SnapsConfig } from '@metamask/snaps-cli';\n * import { merge } from '@metamask/snaps-cli';\n *\n * const config: SnapsConfig = {\n * bundler: 'webpack',\n * entry: 'src/index.ts',\n * customizeWebpackConfig: (config) => merge(config, {\n * module: {\n * rules: [\n * {\n * test: /\\.wasm$/,\n * type: 'assets/resource',\n * },\n * ],\n * },\n * }),\n * };\n *\n * export default config;\n * ```\n */\n customizeWebpackConfig?: (\n config: WebpackConfiguration,\n ) => WebpackConfiguration;\n\n /**\n * Experimental features that can be enabled. These features are not\n * guaranteed to be stable, and may be removed or changed in a future release.\n */\n experimental?: {\n /**\n * Whether to enable WebAssembly support. If `true`, the Webpack\n * configuration will be modified to support WebAssembly. If `false`, the\n * Webpack configuration will not be modified.\n *\n * @default false\n */\n wasm?: boolean;\n };\n};\n\ntype SnapsWebpackCustomizeWebpackConfigFunction = (\n config: WebpackConfiguration,\n) => WebpackConfiguration;\n\n// This struct is essentially the same as the `func` struct, but it's defined\n// separately so that we include the function type in the inferred TypeScript\n// type definitions.\nconst SnapsWebpackCustomizeWebpackConfigFunctionStruct =\n define<SnapsWebpackCustomizeWebpackConfigFunction>(\n 'function',\n func().validator,\n );\n\nexport const SnapsConfigStruct = object({\n input: defaulted(file(), resolve(process.cwd(), 'src/index.js')),\n sourceMap: defaulted(union([boolean(), literal('inline')]), false),\n evaluate: defaulted(boolean(), true),\n\n output: defaulted(\n object({\n path: defaulted(file(), resolve(process.cwd(), 'dist')),\n filename: defaulted(string(), 'bundle.js'),\n clean: defaulted(boolean(), false),\n minimize: defaulted(boolean(), true),\n }),\n {},\n ),\n\n manifest: defaulted(\n object({\n path: defaulted(file(), resolve(process.cwd(), 'snap.manifest.json')),\n update: defaulted(boolean(), true),\n }),\n {},\n ),\n\n server: defaulted(\n object({\n enabled: defaulted(boolean(), true),\n root: defaulted(file(), process.cwd()),\n port: defaulted(number(), 8081),\n }),\n {},\n ),\n\n environment: defaulted(record(string(), unknown()), {}),\n\n stats: defaulted(\n object({\n verbose: defaulted(boolean(), false),\n builtIns: defaulted(\n union([\n object({ ignore: defaulted(array(string()), []) }),\n literal(false),\n ]),\n {},\n ),\n buffer: defaulted(boolean(), true),\n }),\n {},\n ),\n\n polyfills: defaulted(\n union([\n boolean(),\n object({\n assert: defaulted(boolean(), false),\n buffer: defaulted(boolean(), false),\n console: defaulted(boolean(), false),\n constants: defaulted(boolean(), false),\n crypto: defaulted(boolean(), false),\n domain: defaulted(boolean(), false),\n events: defaulted(boolean(), false),\n http: defaulted(boolean(), false),\n https: defaulted(boolean(), false),\n os: defaulted(boolean(), false),\n path: defaulted(boolean(), false),\n punycode: defaulted(boolean(), false),\n process: defaulted(boolean(), false),\n querystring: defaulted(boolean(), false),\n stream: defaulted(boolean(), false),\n /* eslint-disable @typescript-eslint/naming-convention */\n _stream_duplex: defaulted(boolean(), false),\n _stream_passthrough: defaulted(boolean(), false),\n _stream_readable: defaulted(boolean(), false),\n _stream_transform: defaulted(boolean(), false),\n _stream_writable: defaulted(boolean(), false),\n string_decoder: defaulted(boolean(), false),\n /* eslint-enable @typescript-eslint/naming-convention */\n sys: defaulted(boolean(), false),\n timers: defaulted(boolean(), false),\n tty: defaulted(boolean(), false),\n url: defaulted(boolean(), false),\n util: defaulted(boolean(), false),\n vm: defaulted(boolean(), false),\n zlib: defaulted(boolean(), false),\n }),\n ]),\n false,\n ),\n\n typescript: defaulted(\n object({\n enabled: defaulted(boolean(), false),\n configFile: defaulted(file(), 'tsconfig.json'),\n }),\n {},\n ),\n\n features: defaulted(\n object({\n images: defaulted(boolean(), true),\n }),\n {},\n ),\n\n customizeWebpackConfig: optional(\n SnapsWebpackCustomizeWebpackConfigFunctionStruct,\n ),\n\n experimental: defaulted(\n object({\n wasm: defaulted(boolean(), false),\n }),\n {},\n ),\n});\n\nexport type ProcessedConfig = Infer<typeof SnapsConfigStruct>;\n\n/**\n * Get a validated snap config. This validates the config and adds default\n * values for any missing properties.\n *\n * @param config - The config to validate.\n * @returns The validated config.\n */\nexport function getConfig(config: unknown): ProcessedConfig {\n const prefix = 'The snap config file is invalid';\n const suffix = dim(\n 'Refer to the documentation for more information: https://docs.metamask.io/snaps/reference/cli/options/',\n );\n\n return createFromStruct(config, SnapsConfigStruct, prefix, suffix);\n}\n\n/**\n * Load a snap config from a file. This supports both JavaScript and TypeScript\n * config files, in the CommonJS module format and the ES module format.\n *\n * This assumes that the config file exports a default object, either through\n * `module.exports` or `export default`.\n *\n * @param path - The full path to the config file.\n * @returns The validated config.\n * @throws If the config file is invalid, or if the config file does not have a\n * default export.\n */\nexport async function loadConfig(path: string) {\n try {\n const contents = await readFile(path, 'utf8');\n const source = await transform(contents, {\n swcrc: false,\n jsc: {\n parser: {\n syntax: 'typescript',\n },\n },\n module: {\n type: 'commonjs',\n },\n });\n\n const config = new Module(path);\n\n // @ts-expect-error - This function is not typed.\n config.paths = Module._nodeModulePaths(dirname(path));\n\n // @ts-expect-error - This function is not typed.\n config._compile(source.code, path);\n\n if (!hasProperty(config.exports, 'default')) {\n return getConfig(config.exports);\n }\n\n return getConfig(config.exports.default);\n } catch (error) {\n if (error instanceof SnapsStructError) {\n throw new ConfigError(error.message);\n }\n\n throw new ConfigError(\n `Unable to load snap config file at \"${path}\".\\n\\n${indent(\n error.message,\n )}`,\n );\n }\n}\n\n/**\n * Resolve a snap config. This function will look for a `snap.config.js` or\n * `snap.config.ts` file in the current or specified directory.\n *\n * @param path - The path to resolve the snap config from. Defaults to the\n * current working directory.\n * @returns The resolved and validated snap config.\n * @throws If a snap config could not be found.\n */\nexport async function resolveConfig(path: string) {\n for (const configFile of CONFIG_FILES) {\n const filePath = resolve(path, configFile);\n if (await isFile(filePath)) {\n return await loadConfig(filePath);\n }\n }\n\n throw new ConfigError(\n `Could not find a \"snap.config.js\" or \"snap.config.ts\" file in the current or specified directory (\"${path}\").`,\n );\n}\n\n/**\n * Get a snap config from the CLI arguments. This will either load the config\n * from the specified config file, or resolve the config from the current\n * working directory.\n *\n * @param argv - The CLI arguments.\n * @param cwd - The current working directory. Defaults to `process.cwd()`.\n * @returns The resolved and validated snap config.\n */\nexport async function getConfigByArgv(\n argv: YargsArgs,\n cwd: string = process.cwd(),\n) {\n if (argv.config) {\n if (!(await isFile(argv.config))) {\n throw new ConfigError(\n `Could not find a config file at \"${argv.config}\". Make sure that the path is correct.`,\n );\n }\n\n return await loadConfig(argv.config);\n }\n\n return await res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AC","sourcesContent":["import { literal, union } from '@metamask/snaps-sdk';\nimport {\n createFromStruct,\n indent,\n isFile,\n SnapsStructError,\n} from '@metamask/snaps-utils/node';\nimport {\n array,\n boolean,\n defaulted,\n define,\n func,\n number,\n object,\n optional,\n record,\n string,\n unknown,\n} from '@metamask/superstruct';\nimport type { Infer } from '@metamask/superstruct';\nimport { hasProperty } from '@metamask/utils';\nimport { transform } from '@swc/core';\nimport { dim } from 'chalk';\nimport { readFile } from 'fs/promises';\nimport Module from 'module';\nimport { dirname, resolve } from 'path';\nimport type { Configuration as WebpackConfiguration } from 'webpack';\n\nimport { ConfigError } from './errors';\nimport { file } from './structs';\nimport type { YargsArgs } from './types/yargs';\nimport { CONFIG_FILE, TS_CONFIG_FILE } from './utils';\n\nconst CONFIG_FILES = [CONFIG_FILE, TS_CONFIG_FILE];\n\n/**\n * The configuration for the Snaps CLI, stored as `snap.config.js` or\n * `snap.config.ts` in the root of the project.\n */\nexport type SnapConfig = {\n /**\n * The path to the snap entry point. This should be a JavaScript or TypeScript\n * file.\n */\n input: string;\n\n /**\n * Whether to generate source maps for the snap. If `true`, source maps will\n * be generated as separate files. If `'inline'`, source maps will be\n * inlined in the generated JavaScript bundle.\n *\n * @default true\n */\n sourceMap?: boolean | 'inline';\n\n /**\n * Whether to attempt to evaluate the snap in SES. This can catch some errors\n * that would otherwise only be caught at runtime.\n *\n * @default true\n */\n evaluate?: boolean;\n\n output?: {\n /**\n * The path to the directory where the snap will be built. This directory\n * will be created if it doesn't exist.\n *\n * If the path is relative, it will be resolved relative to the current\n * working directory.\n *\n * @default 'dist'\n */\n path?: string;\n\n /**\n * The name of the JavaScript bundle file.\n *\n * @default 'bundle.js'\n */\n filename?: string;\n\n /**\n * Whether to clean the output directory before building the snap. If\n * `true`, the output directory will be deleted and recreated. Otherwise,\n * the output directory will be left as-is.\n *\n * @default false\n */\n clean?: boolean;\n\n /**\n * Whether to minimize the snap bundle. If `true`, the bundle will be\n * minified. Otherwise, the bundle will be left as-is.\n *\n * @default true\n */\n minimize?: boolean;\n };\n\n manifest?: {\n /**\n * The path to the snap manifest file. If the path is relative, it will be\n * resolved relative to the current working directory.\n *\n * @default 'snap.manifest.json'\n */\n path?: string;\n\n /**\n * Whether to automatically update the manifest. If `true`, the manifest\n * will be updated with the latest shasum of the snap bundle, and some\n * common fields will be updated if they are missing or incorrect. If\n * `false`, the manifest will be left as-is.\n *\n * @default true\n */\n update?: boolean;\n };\n\n server?: {\n /**\n * Whether to enable the local server. If `true`, the snap will be served\n * from a local server, when running the `watch` command. If `false`, the\n * snap will not be served.\n *\n * @default true\n */\n enabled?: boolean;\n\n /**\n * The root directory to serve the snap from. If the path is relative, it\n * will be resolved relative to the current working directory.\n *\n * @default `process.cwd()`\n */\n root?: string;\n\n /**\n * The port to run the server on.\n *\n * @default 8081\n */\n port?: number;\n };\n\n /**\n * The environment variables to set when building the snap. These will be\n * available in the snap as `process.env`. In addition to these environment\n * variables, the following environment variables will always be set:\n *\n * - `NODE_DEBUG`: `false`\n * - `NODE_ENV`: `'production'`\n * - `DEBUG`: `false`\n *\n * Any environment variables specified here will override these defaults. You\n * can also override any variables here by setting them in your shell when\n * running the CLI.\n */\n environment?: Record<string, unknown>;\n\n /**\n * Options that control the logging output of the CLI.\n */\n stats?: {\n /**\n * Whether to enable verbose logging.\n *\n * @default false\n */\n verbose?: boolean;\n\n /**\n * Whether to log warnings about unresolved built-in modules. If `false`,\n * warnings will not be logged.\n */\n builtIns?:\n | {\n /**\n * The built-in modules to ignore when resolving modules. If a module\n * is ignored, no warning will be logged if it is not resolved.\n */\n ignore?: string[];\n }\n | false;\n\n /**\n * Whether to log warnings about the use of the `Buffer` global. If `false`,\n * warnings will not be logged. If `true`, the CLI will warn if the `Buffer`\n * global is used, but not provided by Webpack's `DefinePlugin`.\n */\n buffer?: boolean;\n };\n\n /**\n * Whether to provide polyfills for node builtins. If `true`, all the available\n * polyfills will be provided. If `false` no polyfills will be provided. If a\n * configuration object is passed only the polyfills set to `true` will be provided.\n *\n * @default false\n * @example\n * ```ts\n * polyfills: true\n *\n * // or\n *\n * polyfills: {\n * assert: true,\n * buffer: true\n * }\n * ```\n */\n polyfills?:\n | boolean\n | {\n assert?: boolean;\n buffer?: boolean;\n console?: boolean;\n constants?: boolean;\n crypto?: boolean;\n domain?: boolean;\n events?: boolean;\n http?: boolean;\n https?: boolean;\n os?: boolean;\n path?: boolean;\n punycode?: boolean;\n process?: boolean;\n querystring?: boolean;\n stream?: boolean;\n /* eslint-disable @typescript-eslint/naming-convention */\n _stream_duplex?: boolean;\n _stream_passthrough?: boolean;\n _stream_readable?: boolean;\n _stream_transform?: boolean;\n _stream_writable?: boolean;\n string_decoder?: boolean;\n /* eslint-enable @typescript-eslint/naming-convention */\n sys?: boolean;\n timers?: boolean;\n tty?: boolean;\n url?: boolean;\n util?: boolean;\n vm?: boolean;\n zlib?: boolean;\n };\n\n /**\n * Options for preinstalled Snaps. These options are added to the preinstalled\n * Snap bundle.\n *\n * These options do not affect regular Snaps that are installed by users.\n */\n preinstalled?: {\n /**\n * Whether to hide branding specific to Snaps in the client UI.\n */\n hideSnapBranding?: boolean;\n\n /**\n * Whether the Snap should be hidden from the user in the client UI.\n */\n hidden?: boolean;\n\n /**\n * Whether the Snap can be removed from the client.\n */\n removable?: boolean;\n };\n\n /**\n * Support for TypeScript type-checking feature.\n *\n * @example\n * {\n * enabled: true;\n * configFile: './path/to/tsconfig.json'\n * }\n */\n typescript?: {\n /**\n * Whether to enable TypeScript type-checking feature.\n *\n * @default false\n */\n enabled?: boolean;\n /**\n * Path to tsconfig.json file for the Snap.\n *\n * @default 'tsconfig.json'\n */\n configFile?: string;\n };\n\n /**\n * Optional features to enable in the CLI.\n *\n * @example\n * {\n * features: {\n * images: true,\n * }\n * }\n */\n features?: {\n /**\n * Whether to enable support for images. If `true`, the Webpack\n * configuration will be modified to support images. If `false`, the\n * Webpack configuration will not be modified.\n *\n * @default true\n */\n images?: boolean;\n };\n\n /**\n * A function to customize the Webpack configuration used to build the snap.\n * This function will be called with the default Webpack configuration, and\n * should return the modified configuration. If not specified, the default\n * configuration will be used.\n *\n * It's recommended to use the `webpack-merge` package to merge the default\n * configuration with your customizations. The merge function is exported as\n * `merge` from the `@metamask/snaps-cli` package.\n *\n * @example\n * ```ts\n * import type { SnapsConfig } from '@metamask/snaps-cli';\n * import { merge } from '@metamask/snaps-cli';\n *\n * const config: SnapsConfig = {\n * bundler: 'webpack',\n * entry: 'src/index.ts',\n * customizeWebpackConfig: (config) => merge(config, {\n * module: {\n * rules: [\n * {\n * test: /\\.wasm$/,\n * type: 'assets/resource',\n * },\n * ],\n * },\n * }),\n * };\n *\n * export default config;\n * ```\n */\n customizeWebpackConfig?: (\n config: WebpackConfiguration,\n ) => WebpackConfiguration;\n\n /**\n * Experimental features that can be enabled. These features are not\n * guaranteed to be stable, and may be removed or changed in a future release.\n */\n experimental?: {\n /**\n * Whether to enable WebAssembly support. If `true`, the Webpack\n * configuration will be modified to support WebAssembly. If `false`, the\n * Webpack configuration will not be modified.\n *\n * @default false\n */\n wasm?: boolean;\n };\n};\n\ntype SnapsWebpackCustomizeWebpackConfigFunction = (\n config: WebpackConfiguration,\n) => WebpackConfiguration;\n\n// This struct is essentially the same as the `func` struct, but it's defined\n// separately so that we include the function type in the inferred TypeScript\n// type definitions.\nconst SnapsWebpackCustomizeWebpackConfigFunctionStruct =\n define<SnapsWebpackCustomizeWebpackConfigFunction>(\n 'function',\n func().validator,\n );\n\nexport const SnapsConfigStruct = object({\n input: defaulted(file(), resolve(process.cwd(), 'src/index.js')),\n sourceMap: defaulted(union([boolean(), literal('inline')]), false),\n evaluate: defaulted(boolean(), true),\n\n output: defaulted(\n object({\n path: defaulted(file(), resolve(process.cwd(), 'dist')),\n filename: defaulted(string(), 'bundle.js'),\n clean: defaulted(boolean(), false),\n minimize: defaulted(boolean(), true),\n }),\n {},\n ),\n\n manifest: defaulted(\n object({\n path: defaulted(file(), resolve(process.cwd(), 'snap.manifest.json')),\n update: defaulted(boolean(), true),\n }),\n {},\n ),\n\n server: defaulted(\n object({\n enabled: defaulted(boolean(), true),\n root: defaulted(file(), process.cwd()),\n port: defaulted(number(), 8081),\n }),\n {},\n ),\n\n environment: defaulted(record(string(), unknown()), {}),\n\n stats: defaulted(\n object({\n verbose: defaulted(boolean(), false),\n builtIns: defaulted(\n union([\n object({ ignore: defaulted(array(string()), []) }),\n literal(false),\n ]),\n {},\n ),\n buffer: defaulted(boolean(), true),\n }),\n {},\n ),\n\n polyfills: defaulted(\n union([\n boolean(),\n object({\n assert: defaulted(boolean(), false),\n buffer: defaulted(boolean(), false),\n console: defaulted(boolean(), false),\n constants: defaulted(boolean(), false),\n crypto: defaulted(boolean(), false),\n domain: defaulted(boolean(), false),\n events: defaulted(boolean(), false),\n http: defaulted(boolean(), false),\n https: defaulted(boolean(), false),\n os: defaulted(boolean(), false),\n path: defaulted(boolean(), false),\n punycode: defaulted(boolean(), false),\n process: defaulted(boolean(), false),\n querystring: defaulted(boolean(), false),\n stream: defaulted(boolean(), false),\n /* eslint-disable @typescript-eslint/naming-convention */\n _stream_duplex: defaulted(boolean(), false),\n _stream_passthrough: defaulted(boolean(), false),\n _stream_readable: defaulted(boolean(), false),\n _stream_transform: defaulted(boolean(), false),\n _stream_writable: defaulted(boolean(), false),\n string_decoder: defaulted(boolean(), false),\n /* eslint-enable @typescript-eslint/naming-convention */\n sys: defaulted(boolean(), false),\n timers: defaulted(boolean(), false),\n tty: defaulted(boolean(), false),\n url: defaulted(boolean(), false),\n util: defaulted(boolean(), false),\n vm: defaulted(boolean(), false),\n zlib: defaulted(boolean(), false),\n }),\n ]),\n false,\n ),\n\n preinstalled: defaulted(\n object({\n hideSnapBranding: defaulted(boolean(), false),\n hidden: defaulted(boolean(), false),\n removable: defaulted(boolean(), false),\n }),\n {},\n ),\n\n typescript: defaulted(\n object({\n enabled: defaulted(boolean(), false),\n configFile: defaulted(file(), 'tsconfig.json'),\n }),\n {},\n ),\n\n features: defaulted(\n object({\n images: defaulted(boolean(), true),\n }),\n {},\n ),\n\n customizeWebpackConfig: optional(\n SnapsWebpackCustomizeWebpackConfigFunctionStruct,\n ),\n\n experimental: defaulted(\n object({\n wasm: defaulted(boolean(), false),\n }),\n {},\n ),\n});\n\nexport type ProcessedConfig = Infer<typeof SnapsConfigStruct>;\n\n/**\n * Get a validated snap config. This validates the config and adds default\n * values for any missing properties.\n *\n * @param config - The config to validate.\n * @returns The validated config.\n */\nexport function getConfig(config: unknown): ProcessedConfig {\n const prefix = 'The snap config file is invalid';\n const suffix = dim(\n 'Refer to the documentation for more information: https://docs.metamask.io/snaps/reference/cli/options/',\n );\n\n return createFromStruct(config, SnapsConfigStruct, prefix, suffix);\n}\n\n/**\n * Load a snap config from a file. This supports both JavaScript and TypeScript\n * config files, in the CommonJS module format and the ES module format.\n *\n * This assumes that the config file exports a default object, either through\n * `module.exports` or `export default`.\n *\n * @param path - The full path to the config file.\n * @returns The validated config.\n * @throws If the config file is invalid, or if the config file does not have a\n * default export.\n */\nexport async function loadConfig(path: string) {\n try {\n const contents = await readFile(path, 'utf8');\n const source = await transform(contents, {\n swcrc: false,\n jsc: {\n parser: {\n syntax: 'typescript',\n },\n },\n module: {\n type: 'commonjs',\n },\n });\n\n const config = new Module(path);\n\n // @ts-expect-error - This function is not typed.\n config.paths = Module._nodeModulePaths(dirname(path));\n\n // @ts-expect-error - This function is not typed.\n config._compile(source.code, path);\n\n if (!hasProperty(config.exports, 'default')) {\n return getConfig(config.exports);\n }\n\n return getConfig(config.exports.default);\n } catch (error) {\n if (error instanceof SnapsStructError) {\n throw new ConfigError(error.message);\n }\n\n throw new ConfigError(\n `Unable to load snap config file at \"${path}\".\\n\\n${indent(\n error.message,\n )}`,\n );\n }\n}\n\n/**\n * Resolve a snap config. This function will look for a `snap.config.js` or\n * `snap.config.ts` file in the current or specified directory.\n *\n * @param path - The path to resolve the snap config from. Defaults to the\n * current working directory.\n * @returns The resolved and validated snap config.\n * @throws If a snap config could not be found.\n */\nexport async function resolveConfig(path: string) {\n for (const configFile of CONFIG_FILES) {\n const filePath = resolve(path, configFile);\n if (await isFile(filePath)) {\n return await loadConfig(filePath);\n }\n }\n\n throw new ConfigError(\n `Could not find a \"snap.config.js\" or \"snap.config.ts\" file in the current or specified directory (\"${path}\").`,\n );\n}\n\n/**\n * Get a snap config from the CLI arguments. This will either load the config\n * from the specified config file, or resolve the config from the current\n * working directory.\n *\n * @param argv - The CLI arguments.\n * @param cwd - The current working directory. Defaults to `process.cwd()`.\n * @returns The resolved and validated snap config.\n */\nexport async function getConfigByArgv(\n argv: YargsArgs,\n cwd: string = process.cwd(),\n) {\n if (argv.config) {\n if (!(await isFile(argv.config))) {\n throw new ConfigError(\n `Could not find a config file at \"${argv.config}\". Make sure that the path is correct.`,\n );\n }\n\n return await loadConfig(argv.config);\n }\n\n return await resolveConfig(cwd);\n}\n"]}
@@ -1,10 +1,30 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
4
24
  };
5
25
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.trimPathString = exports.sanitizeInputs = exports.TS_CONFIG_FILE = exports.CONFIG_FILE = void 0;
7
- const path_1 = __importDefault(require("path"));
26
+ exports.getConfigWithManifest = exports.trimPathString = exports.sanitizeInputs = exports.TS_CONFIG_FILE = exports.CONFIG_FILE = void 0;
27
+ const path_1 = __importStar(require("path"));
8
28
  exports.CONFIG_FILE = 'snap.config.js';
9
29
  exports.TS_CONFIG_FILE = 'snap.config.ts';
10
30
  // CLI arguments whose values are file paths.
@@ -49,4 +69,24 @@ function trimPathString(pathString) {
49
69
  return pathString.replace(/^[./]+|[./]+$/gu, '');
50
70
  }
51
71
  exports.trimPathString = trimPathString;
72
+ /**
73
+ * Get a config object with an updated manifest path if provided.
74
+ *
75
+ * @param config - The processed config object.
76
+ * @param manifestPath - The manifest path.
77
+ * @returns The processed config object with the updated manifest path.
78
+ */
79
+ function getConfigWithManifest(config, manifestPath) {
80
+ if (manifestPath) {
81
+ return {
82
+ ...config,
83
+ manifest: {
84
+ ...config.manifest,
85
+ path: (0, path_1.resolve)(process.cwd(), manifestPath),
86
+ },
87
+ };
88
+ }
89
+ return config;
90
+ }
91
+ exports.getConfigWithManifest = getConfigWithManifest;
52
92
  //# sourceMappingURL=cli.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"cli.cjs","sourceRoot":"","sources":["../../src/utils/cli.ts"],"names":[],"mappings":";;;;;;AAAA,gDAAwB;AAEX,QAAA,WAAW,GAAG,gBAAgB,CAAC;AAC/B,QAAA,cAAc,GAAG,gBAAgB,CAAC;AAE/C,6CAA6C;AAC7C,MAAM,aAAa,GAAG,IAAI,GAAG,CAAC;IAC5B,KAAK;IACL,GAAG;IACH,MAAM;IACN,GAAG;IACH,QAAQ;IACR,GAAG;IACH,MAAM;IACN,GAAG;CACJ,CAAC,CAAC;AAEH;;;;;GAKG;AACH,SAAgB,cAAc,CAAC,IAA6B;IAC1D,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,EAAE;QAChC,IAAI,OAAO,IAAI,CAAC,GAAG,CAAC,KAAK,QAAQ,EAAE,CAAC;YAClC,2CAA2C;YAC3C,IAAI,IAAI,CAAC,GAAG,CAAC,KAAK,IAAI,EAAE,CAAC;gBACvB,IAAI,CAAC,GAAG,CAAC,GAAG,GAAG,CAAC;YAClB,CAAC;YAED,IAAI,aAAa,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC;gBAC3B,IAAI,CAAC,GAAG,CAAC,GAAG,cAAI,CAAC,SAAS,CAAC,IAAI,CAAC,GAAG,CAAW,CAAC,CAAC;YAClD,CAAC;QACH,CAAC;IACH,CAAC,CAAC,CAAC;AACL,CAAC;AAbD,wCAaC;AAED;;;;;;GAMG;AACH,SAAgB,cAAc,CAAC,UAAkB;IAC/C,OAAO,UAAU,CAAC,OAAO,CAAC,iBAAiB,EAAE,EAAE,CAAC,CAAC;AACnD,CAAC;AAFD,wCAEC","sourcesContent":["import path from 'path';\n\nexport const CONFIG_FILE = 'snap.config.js';\nexport const TS_CONFIG_FILE = 'snap.config.ts';\n\n// CLI arguments whose values are file paths.\nconst pathArguments = new Set([\n 'src',\n 's',\n 'dist',\n 'd',\n 'bundle',\n 'b',\n 'root',\n 'r',\n]);\n\n/**\n * Sanitizes inputs. Currently normalizes \"./\" paths to \".\".\n * Yargs handles other path normalization as specified in builders.\n *\n * @param argv - Arguments as an object generated by yargs.\n */\nexport function sanitizeInputs(argv: Record<string, unknown>) {\n Object.keys(argv).forEach((key) => {\n if (typeof argv[key] === 'string') {\n // Node's path.normalize() does not do this\n if (argv[key] === './') {\n argv[key] = '.';\n }\n\n if (pathArguments.has(key)) {\n argv[key] = path.normalize(argv[key] as string);\n }\n }\n });\n}\n\n/**\n * Trims leading and trailing periods \".\" and forward slashes \"/\" from the\n * given path string.\n *\n * @param pathString - The path string to trim.\n * @returns The trimmed path string.\n */\nexport function trimPathString(pathString: string): string {\n return pathString.replace(/^[./]+|[./]+$/gu, '');\n}\n"]}
1
+ {"version":3,"file":"cli.cjs","sourceRoot":"","sources":["../../src/utils/cli.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,6CAAqC;AAIxB,QAAA,WAAW,GAAG,gBAAgB,CAAC;AAC/B,QAAA,cAAc,GAAG,gBAAgB,CAAC;AAE/C,6CAA6C;AAC7C,MAAM,aAAa,GAAG,IAAI,GAAG,CAAC;IAC5B,KAAK;IACL,GAAG;IACH,MAAM;IACN,GAAG;IACH,QAAQ;IACR,GAAG;IACH,MAAM;IACN,GAAG;CACJ,CAAC,CAAC;AAEH;;;;;GAKG;AACH,SAAgB,cAAc,CAAC,IAA6B;IAC1D,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,EAAE;QAChC,IAAI,OAAO,IAAI,CAAC,GAAG,CAAC,KAAK,QAAQ,EAAE,CAAC;YAClC,2CAA2C;YAC3C,IAAI,IAAI,CAAC,GAAG,CAAC,KAAK,IAAI,EAAE,CAAC;gBACvB,IAAI,CAAC,GAAG,CAAC,GAAG,GAAG,CAAC;YAClB,CAAC;YAED,IAAI,aAAa,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC;gBAC3B,IAAI,CAAC,GAAG,CAAC,GAAG,cAAI,CAAC,SAAS,CAAC,IAAI,CAAC,GAAG,CAAW,CAAC,CAAC;YAClD,CAAC;QACH,CAAC;IACH,CAAC,CAAC,CAAC;AACL,CAAC;AAbD,wCAaC;AAED;;;;;;GAMG;AACH,SAAgB,cAAc,CAAC,UAAkB;IAC/C,OAAO,UAAU,CAAC,OAAO,CAAC,iBAAiB,EAAE,EAAE,CAAC,CAAC;AACnD,CAAC;AAFD,wCAEC;AAED;;;;;;GAMG;AACH,SAAgB,qBAAqB,CACnC,MAAuB,EACvB,YAAqB;IAErB,IAAI,YAAY,EAAE,CAAC;QACjB,OAAO;YACL,GAAG,MAAM;YACT,QAAQ,EAAE;gBACR,GAAG,MAAM,CAAC,QAAQ;gBAClB,IAAI,EAAE,IAAA,cAAO,EAAC,OAAO,CAAC,GAAG,EAAE,EAAE,YAAY,CAAC;aAC3C;SACF,CAAC;IACJ,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC;AAfD,sDAeC","sourcesContent":["import path, { resolve } from 'path';\n\nimport type { ProcessedConfig } from '../config';\n\nexport const CONFIG_FILE = 'snap.config.js';\nexport const TS_CONFIG_FILE = 'snap.config.ts';\n\n// CLI arguments whose values are file paths.\nconst pathArguments = new Set([\n 'src',\n 's',\n 'dist',\n 'd',\n 'bundle',\n 'b',\n 'root',\n 'r',\n]);\n\n/**\n * Sanitizes inputs. Currently normalizes \"./\" paths to \".\".\n * Yargs handles other path normalization as specified in builders.\n *\n * @param argv - Arguments as an object generated by yargs.\n */\nexport function sanitizeInputs(argv: Record<string, unknown>) {\n Object.keys(argv).forEach((key) => {\n if (typeof argv[key] === 'string') {\n // Node's path.normalize() does not do this\n if (argv[key] === './') {\n argv[key] = '.';\n }\n\n if (pathArguments.has(key)) {\n argv[key] = path.normalize(argv[key] as string);\n }\n }\n });\n}\n\n/**\n * Trims leading and trailing periods \".\" and forward slashes \"/\" from the\n * given path string.\n *\n * @param pathString - The path string to trim.\n * @returns The trimmed path string.\n */\nexport function trimPathString(pathString: string): string {\n return pathString.replace(/^[./]+|[./]+$/gu, '');\n}\n\n/**\n * Get a config object with an updated manifest path if provided.\n *\n * @param config - The processed config object.\n * @param manifestPath - The manifest path.\n * @returns The processed config object with the updated manifest path.\n */\nexport function getConfigWithManifest(\n config: ProcessedConfig,\n manifestPath?: string,\n): ProcessedConfig {\n if (manifestPath) {\n return {\n ...config,\n manifest: {\n ...config.manifest,\n path: resolve(process.cwd(), manifestPath),\n },\n };\n }\n\n return config;\n}\n"]}
@@ -1,3 +1,4 @@
1
+ import type { ProcessedConfig } from "../config.cjs";
1
2
  export declare const CONFIG_FILE = "snap.config.js";
2
3
  export declare const TS_CONFIG_FILE = "snap.config.ts";
3
4
  /**
@@ -15,4 +16,12 @@ export declare function sanitizeInputs(argv: Record<string, unknown>): void;
15
16
  * @returns The trimmed path string.
16
17
  */
17
18
  export declare function trimPathString(pathString: string): string;
19
+ /**
20
+ * Get a config object with an updated manifest path if provided.
21
+ *
22
+ * @param config - The processed config object.
23
+ * @param manifestPath - The manifest path.
24
+ * @returns The processed config object with the updated manifest path.
25
+ */
26
+ export declare function getConfigWithManifest(config: ProcessedConfig, manifestPath?: string): ProcessedConfig;
18
27
  //# sourceMappingURL=cli.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"cli.d.cts","sourceRoot":"","sources":["../../src/utils/cli.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,WAAW,mBAAmB,CAAC;AAC5C,eAAO,MAAM,cAAc,mBAAmB,CAAC;AAc/C;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,QAa3D;AAED;;;;;;GAMG;AACH,wBAAgB,cAAc,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,CAEzD"}
1
+ {"version":3,"file":"cli.d.cts","sourceRoot":"","sources":["../../src/utils/cli.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAE,sBAAkB;AAEjD,eAAO,MAAM,WAAW,mBAAmB,CAAC;AAC5C,eAAO,MAAM,cAAc,mBAAmB,CAAC;AAc/C;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,QAa3D;AAED;;;;;;GAMG;AACH,wBAAgB,cAAc,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,CAEzD;AAED;;;;;;GAMG;AACH,wBAAgB,qBAAqB,CACnC,MAAM,EAAE,eAAe,EACvB,YAAY,CAAC,EAAE,MAAM,GACpB,eAAe,CAYjB"}
@@ -1,3 +1,4 @@
1
+ import type { ProcessedConfig } from "../config.mjs";
1
2
  export declare const CONFIG_FILE = "snap.config.js";
2
3
  export declare const TS_CONFIG_FILE = "snap.config.ts";
3
4
  /**
@@ -15,4 +16,12 @@ export declare function sanitizeInputs(argv: Record<string, unknown>): void;
15
16
  * @returns The trimmed path string.
16
17
  */
17
18
  export declare function trimPathString(pathString: string): string;
19
+ /**
20
+ * Get a config object with an updated manifest path if provided.
21
+ *
22
+ * @param config - The processed config object.
23
+ * @param manifestPath - The manifest path.
24
+ * @returns The processed config object with the updated manifest path.
25
+ */
26
+ export declare function getConfigWithManifest(config: ProcessedConfig, manifestPath?: string): ProcessedConfig;
18
27
  //# sourceMappingURL=cli.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"cli.d.mts","sourceRoot":"","sources":["../../src/utils/cli.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,WAAW,mBAAmB,CAAC;AAC5C,eAAO,MAAM,cAAc,mBAAmB,CAAC;AAc/C;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,QAa3D;AAED;;;;;;GAMG;AACH,wBAAgB,cAAc,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,CAEzD"}
1
+ {"version":3,"file":"cli.d.mts","sourceRoot":"","sources":["../../src/utils/cli.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAE,sBAAkB;AAEjD,eAAO,MAAM,WAAW,mBAAmB,CAAC;AAC5C,eAAO,MAAM,cAAc,mBAAmB,CAAC;AAc/C;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,QAa3D;AAED;;;;;;GAMG;AACH,wBAAgB,cAAc,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,CAEzD;AAED;;;;;;GAMG;AACH,wBAAgB,qBAAqB,CACnC,MAAM,EAAE,eAAe,EACvB,YAAY,CAAC,EAAE,MAAM,GACpB,eAAe,CAYjB"}
@@ -1,4 +1,4 @@
1
- import path from "path";
1
+ import path, { resolve } from "path";
2
2
  export const CONFIG_FILE = 'snap.config.js';
3
3
  export const TS_CONFIG_FILE = 'snap.config.ts';
4
4
  // CLI arguments whose values are file paths.
@@ -41,4 +41,23 @@ export function sanitizeInputs(argv) {
41
41
  export function trimPathString(pathString) {
42
42
  return pathString.replace(/^[./]+|[./]+$/gu, '');
43
43
  }
44
+ /**
45
+ * Get a config object with an updated manifest path if provided.
46
+ *
47
+ * @param config - The processed config object.
48
+ * @param manifestPath - The manifest path.
49
+ * @returns The processed config object with the updated manifest path.
50
+ */
51
+ export function getConfigWithManifest(config, manifestPath) {
52
+ if (manifestPath) {
53
+ return {
54
+ ...config,
55
+ manifest: {
56
+ ...config.manifest,
57
+ path: resolve(process.cwd(), manifestPath),
58
+ },
59
+ };
60
+ }
61
+ return config;
62
+ }
44
63
  //# sourceMappingURL=cli.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"cli.mjs","sourceRoot":"","sources":["../../src/utils/cli.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,aAAa;AAExB,MAAM,CAAC,MAAM,WAAW,GAAG,gBAAgB,CAAC;AAC5C,MAAM,CAAC,MAAM,cAAc,GAAG,gBAAgB,CAAC;AAE/C,6CAA6C;AAC7C,MAAM,aAAa,GAAG,IAAI,GAAG,CAAC;IAC5B,KAAK;IACL,GAAG;IACH,MAAM;IACN,GAAG;IACH,QAAQ;IACR,GAAG;IACH,MAAM;IACN,GAAG;CACJ,CAAC,CAAC;AAEH;;;;;GAKG;AACH,MAAM,UAAU,cAAc,CAAC,IAA6B;IAC1D,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,EAAE;QAChC,IAAI,OAAO,IAAI,CAAC,GAAG,CAAC,KAAK,QAAQ,EAAE,CAAC;YAClC,2CAA2C;YAC3C,IAAI,IAAI,CAAC,GAAG,CAAC,KAAK,IAAI,EAAE,CAAC;gBACvB,IAAI,CAAC,GAAG,CAAC,GAAG,GAAG,CAAC;YAClB,CAAC;YAED,IAAI,aAAa,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC;gBAC3B,IAAI,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,GAAG,CAAW,CAAC,CAAC;YAClD,CAAC;QACH,CAAC;IACH,CAAC,CAAC,CAAC;AACL,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,cAAc,CAAC,UAAkB;IAC/C,OAAO,UAAU,CAAC,OAAO,CAAC,iBAAiB,EAAE,EAAE,CAAC,CAAC;AACnD,CAAC","sourcesContent":["import path from 'path';\n\nexport const CONFIG_FILE = 'snap.config.js';\nexport const TS_CONFIG_FILE = 'snap.config.ts';\n\n// CLI arguments whose values are file paths.\nconst pathArguments = new Set([\n 'src',\n 's',\n 'dist',\n 'd',\n 'bundle',\n 'b',\n 'root',\n 'r',\n]);\n\n/**\n * Sanitizes inputs. Currently normalizes \"./\" paths to \".\".\n * Yargs handles other path normalization as specified in builders.\n *\n * @param argv - Arguments as an object generated by yargs.\n */\nexport function sanitizeInputs(argv: Record<string, unknown>) {\n Object.keys(argv).forEach((key) => {\n if (typeof argv[key] === 'string') {\n // Node's path.normalize() does not do this\n if (argv[key] === './') {\n argv[key] = '.';\n }\n\n if (pathArguments.has(key)) {\n argv[key] = path.normalize(argv[key] as string);\n }\n }\n });\n}\n\n/**\n * Trims leading and trailing periods \".\" and forward slashes \"/\" from the\n * given path string.\n *\n * @param pathString - The path string to trim.\n * @returns The trimmed path string.\n */\nexport function trimPathString(pathString: string): string {\n return pathString.replace(/^[./]+|[./]+$/gu, '');\n}\n"]}
1
+ {"version":3,"file":"cli.mjs","sourceRoot":"","sources":["../../src/utils/cli.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,EAAE,EAAE,OA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3C;SACF,CAAC;IACJ,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["import path, { resolve } from 'path';\n\nimport type { ProcessedConfig } from '../config';\n\nexport const CONFIG_FILE = 'snap.config.js';\nexport const TS_CONFIG_FILE = 'snap.config.ts';\n\n// CLI arguments whose values are file paths.\nconst pathArguments = new Set([\n 'src',\n 's',\n 'dist',\n 'd',\n 'bundle',\n 'b',\n 'root',\n 'r',\n]);\n\n/**\n * Sanitizes inputs. Currently normalizes \"./\" paths to \".\".\n * Yargs handles other path normalization as specified in builders.\n *\n * @param argv - Arguments as an object generated by yargs.\n */\nexport function sanitizeInputs(argv: Record<string, unknown>) {\n Object.keys(argv).forEach((key) => {\n if (typeof argv[key] === 'string') {\n // Node's path.normalize() does not do this\n if (argv[key] === './') {\n argv[key] = '.';\n }\n\n if (pathArguments.has(key)) {\n argv[key] = path.normalize(argv[key] as string);\n }\n }\n });\n}\n\n/**\n * Trims leading and trailing periods \".\" and forward slashes \"/\" from the\n * given path string.\n *\n * @param pathString - The path string to trim.\n * @returns The trimmed path string.\n */\nexport function trimPathString(pathString: string): string {\n return pathString.replace(/^[./]+|[./]+$/gu, '');\n}\n\n/**\n * Get a config object with an updated manifest path if provided.\n *\n * @param config - The processed config object.\n * @param manifestPath - The manifest path.\n * @returns The processed config object with the updated manifest path.\n */\nexport function getConfigWithManifest(\n config: ProcessedConfig,\n manifestPath?: string,\n): ProcessedConfig {\n if (manifestPath) {\n return {\n ...config,\n manifest: {\n ...config.manifest,\n path: resolve(process.cwd(), manifestPath),\n },\n };\n }\n\n return config;\n}\n"]}
@@ -284,7 +284,7 @@ async function getDefaultConfiguration(config, options = {
284
284
  */
285
285
  options.watch &&
286
286
  new plugins_1.SnapsWatchPlugin({
287
- files: [config.manifest.path],
287
+ manifestPath: config.manifest.path,
288
288
  }, options.spinner),
289
289
  options.analyze &&
290
290
  new webpack_bundle_analyzer_1.BundleAnalyzerPlugin({
@@ -292,6 +292,12 @@ async function getDefaultConfiguration(config, options = {
292
292
  logLevel: 'silent',
293
293
  openAnalyzer: false,
294
294
  }),
295
+ options.preinstalled &&
296
+ new plugins_1.PreinstalledSnapsBundlePlugin({
297
+ manifestPath: config.manifest.path,
298
+ outputName: config.output.filename,
299
+ preinstalledOptions: options.preinstalledOptions,
300
+ }, options.spinner),
295
301
  /**
296
302
  * The `ProviderPlugin` is a Webpack plugin that automatically load
297
303
  * modules instead of having to import or require them everywhere.