@shopify/cli-kit 3.44.1 → 3.45.0-pre.1

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 (93) hide show
  1. package/README.md +15 -7
  2. package/assets/cli-ruby/lib/project_types/extension/messages/messages.rb +0 -2
  3. package/assets/cli-ruby/lib/project_types/theme/commands/pull.rb +6 -0
  4. package/assets/cli-ruby/lib/project_types/theme/commands/push.rb +6 -0
  5. package/assets/cli-ruby/lib/shopify_cli/constants.rb +1 -0
  6. package/assets/cli-ruby/lib/shopify_cli/environment.rb +4 -0
  7. package/assets/cli-ruby/lib/shopify_cli/theme/dev_server/proxy.rb +3 -0
  8. package/assets/cli-ruby/lib/shopify_cli/theme/extension/dev_server.rb +3 -3
  9. package/assets/cli-ruby/lib/shopify_cli/theme/extension/host_theme.rb +4 -4
  10. package/assets/cli-ruby/lib/shopify_cli/theme/extension/syncer/extension_serve_job.rb +4 -6
  11. package/assets/cli-ruby/lib/shopify_cli/theme/extension/ui/host_theme_raw_progress_bar.rb +40 -0
  12. package/assets/cli-ruby/vendor/deps/cli-ui/lib/cli/ui/progress_plain.rb +50 -0
  13. package/assets/cli-ruby/vendor/deps/cli-ui/lib/cli/ui.rb +15 -14
  14. package/dist/private/node/api/graphql.js +12 -23
  15. package/dist/private/node/api/graphql.js.map +1 -1
  16. package/dist/private/node/api.d.ts +1 -1
  17. package/dist/private/node/api.js +28 -9
  18. package/dist/private/node/api.js.map +1 -1
  19. package/dist/private/node/constants.d.ts +0 -1
  20. package/dist/private/node/constants.js +0 -1
  21. package/dist/private/node/constants.js.map +1 -1
  22. package/dist/private/node/testing/ui.d.ts +11 -0
  23. package/dist/private/node/testing/ui.js +15 -1
  24. package/dist/private/node/testing/ui.js.map +1 -1
  25. package/dist/private/node/ui/alert.d.ts +5 -1
  26. package/dist/private/node/ui/alert.js +2 -2
  27. package/dist/private/node/ui/alert.js.map +1 -1
  28. package/dist/private/node/ui/components/AutocompletePrompt.js +38 -12
  29. package/dist/private/node/ui/components/AutocompletePrompt.js.map +1 -1
  30. package/dist/private/node/ui/components/AutocompletePrompt.test.js +56 -36
  31. package/dist/private/node/ui/components/AutocompletePrompt.test.js.map +1 -1
  32. package/dist/private/node/ui/components/ConcurrentOutput.d.ts +5 -1
  33. package/dist/private/node/ui/components/ConcurrentOutput.js +15 -13
  34. package/dist/private/node/ui/components/ConcurrentOutput.js.map +1 -1
  35. package/dist/private/node/ui/components/ConcurrentOutput.test.js +20 -11
  36. package/dist/private/node/ui/components/ConcurrentOutput.test.js.map +1 -1
  37. package/dist/private/node/ui/components/FullScreen.js +1 -1
  38. package/dist/private/node/ui/components/FullScreen.js.map +1 -1
  39. package/dist/private/node/ui/components/SelectInput.d.ts +7 -2
  40. package/dist/private/node/ui/components/SelectInput.js +73 -60
  41. package/dist/private/node/ui/components/SelectInput.js.map +1 -1
  42. package/dist/private/node/ui/components/SelectInput.test.js +72 -2
  43. package/dist/private/node/ui/components/SelectInput.test.js.map +1 -1
  44. package/dist/private/node/ui/components/SelectPrompt.js +38 -12
  45. package/dist/private/node/ui/components/SelectPrompt.js.map +1 -1
  46. package/dist/private/node/ui/components/SelectPrompt.test.js +52 -1
  47. package/dist/private/node/ui/components/SelectPrompt.test.js.map +1 -1
  48. package/dist/private/node/ui/components/Tasks.js +9 -1
  49. package/dist/private/node/ui/components/Tasks.js.map +1 -1
  50. package/dist/private/node/ui/components/TextAnimation.js +4 -4
  51. package/dist/private/node/ui/components/TextAnimation.js.map +1 -1
  52. package/dist/private/node/ui/components/TextPrompt.js +4 -4
  53. package/dist/private/node/ui/components/TextPrompt.js.map +1 -1
  54. package/dist/private/node/ui/hooks/use-layout.d.ts +6 -0
  55. package/dist/private/node/ui/hooks/use-layout.js +31 -12
  56. package/dist/private/node/ui/hooks/use-layout.js.map +1 -1
  57. package/dist/private/node/ui.d.ts +11 -3
  58. package/dist/private/node/ui.js +14 -10
  59. package/dist/private/node/ui.js.map +1 -1
  60. package/dist/public/common/object.d.ts +1 -1
  61. package/dist/public/common/object.js +1 -1
  62. package/dist/public/common/object.js.map +1 -1
  63. package/dist/public/common/version.d.ts +1 -1
  64. package/dist/public/common/version.js +1 -1
  65. package/dist/public/common/version.js.map +1 -1
  66. package/dist/public/node/base-command.d.ts +1 -4
  67. package/dist/public/node/base-command.js +17 -19
  68. package/dist/public/node/base-command.js.map +1 -1
  69. package/dist/public/node/context/local.d.ts +0 -7
  70. package/dist/public/node/context/local.js +0 -9
  71. package/dist/public/node/context/local.js.map +1 -1
  72. package/dist/public/node/environments.d.ts +7 -8
  73. package/dist/public/node/environments.js +23 -25
  74. package/dist/public/node/environments.js.map +1 -1
  75. package/dist/public/node/node-package-manager.d.ts +1 -1
  76. package/dist/public/node/node-package-manager.js.map +1 -1
  77. package/dist/public/node/output.d.ts +1 -1
  78. package/dist/public/node/output.js.map +1 -1
  79. package/dist/public/node/path.js +1 -1
  80. package/dist/public/node/path.js.map +1 -1
  81. package/dist/public/node/ruby.d.ts +1 -0
  82. package/dist/public/node/ruby.js +35 -15
  83. package/dist/public/node/ruby.js.map +1 -1
  84. package/dist/public/node/themes/theme-manager.d.ts +1 -1
  85. package/dist/public/node/themes/theme-manager.js.map +1 -1
  86. package/dist/public/node/ui.d.ts +182 -121
  87. package/dist/public/node/ui.js +172 -120
  88. package/dist/public/node/ui.js.map +1 -1
  89. package/dist/tsconfig.tsbuildinfo +1 -1
  90. package/package.json +20 -18
  91. package/dist/private/node/ui/components/TextWithBackground.d.ts +0 -12
  92. package/dist/private/node/ui/components/TextWithBackground.js +0 -39
  93. package/dist/private/node/ui/components/TextWithBackground.js.map +0 -1
@@ -1,22 +1,41 @@
1
1
  import { useStdout } from 'ink';
2
- const MIN_WIDTH = 80;
2
+ import { useEffect, useState } from 'react';
3
+ const MIN_FULL_WIDTH = 20;
4
+ const MIN_FRACTION_WIDTH = 80;
3
5
  export default function useLayout() {
4
6
  const { stdout } = useStdout();
5
- const fullWidth = stdout?.columns ?? MIN_WIDTH;
6
- let oneThird;
7
- let twoThirds;
8
- if (fullWidth <= MIN_WIDTH) {
9
- oneThird = fullWidth;
10
- twoThirds = fullWidth;
7
+ const [layout, setLayout] = useState(calculateLayout(stdout));
8
+ useEffect(() => {
9
+ if (!stdout) {
10
+ return;
11
+ }
12
+ function onResize() {
13
+ setLayout(calculateLayout(stdout));
14
+ }
15
+ stdout.on('resize', onResize);
16
+ return () => {
17
+ stdout.off('resize', onResize);
18
+ };
19
+ }, []);
20
+ return layout;
21
+ }
22
+ export function calculateLayout(stdout) {
23
+ let fullWidth = stdout?.columns ?? MIN_FRACTION_WIDTH;
24
+ let oneThird = fullWidth;
25
+ let twoThirds = fullWidth;
26
+ if (fullWidth <= MIN_FULL_WIDTH) {
27
+ fullWidth = MIN_FULL_WIDTH;
28
+ oneThird = MIN_FULL_WIDTH;
29
+ twoThirds = MIN_FULL_WIDTH;
11
30
  }
12
- else {
13
- oneThird = column({ fullWidth, fraction: [1, 3], minWidth: MIN_WIDTH });
14
- twoThirds = column({ fullWidth, fraction: [2, 3], minWidth: MIN_WIDTH });
31
+ else if (fullWidth > MIN_FRACTION_WIDTH) {
32
+ oneThird = column({ fullWidth, fraction: [1, 3], minWidth: MIN_FRACTION_WIDTH });
33
+ twoThirds = column({ fullWidth, fraction: [2, 3], minWidth: MIN_FRACTION_WIDTH });
15
34
  }
16
35
  return {
17
- twoThirds,
18
- oneThird,
19
36
  fullWidth,
37
+ oneThird,
38
+ twoThirds,
20
39
  };
21
40
  }
22
41
  function column({ fullWidth, fraction, minWidth, }) {
@@ -1 +1 @@
1
- {"version":3,"file":"use-layout.js","sourceRoot":"","sources":["../../../../../src/private/node/ui/hooks/use-layout.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,SAAS,EAAC,MAAM,KAAK,CAAA;AAE7B,MAAM,SAAS,GAAG,EAAE,CAAA;AAQpB,MAAM,CAAC,OAAO,UAAU,SAAS;IAC/B,MAAM,EAAC,MAAM,EAAC,GAAG,SAAS,EAAE,CAAA;IAE5B,MAAM,SAAS,GAAG,MAAM,EAAE,OAAO,IAAI,SAAS,CAAA;IAC9C,IAAI,QAAQ,CAAA;IACZ,IAAI,SAAS,CAAA;IAEb,IAAI,SAAS,IAAI,SAAS,EAAE;QAC1B,QAAQ,GAAG,SAAS,CAAA;QACpB,SAAS,GAAG,SAAS,CAAA;KACtB;SAAM;QACL,QAAQ,GAAG,MAAM,CAAC,EAAC,SAAS,EAAE,QAAQ,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,QAAQ,EAAE,SAAS,EAAC,CAAC,CAAA;QACrE,SAAS,GAAG,MAAM,CAAC,EAAC,SAAS,EAAE,QAAQ,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,QAAQ,EAAE,SAAS,EAAC,CAAC,CAAA;KACvE;IAED,OAAO;QACL,SAAS;QACT,QAAQ;QACR,SAAS;KACV,CAAA;AACH,CAAC;AAED,SAAS,MAAM,CAAC,EACd,SAAS,EACT,QAAQ,EACR,QAAQ,GAKT;IACC,MAAM,eAAe,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,SAAS,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAA;IAE3E,IAAI,eAAe,GAAG,QAAQ,EAAE;QAC9B,OAAO,QAAQ,CAAA;KAChB;SAAM;QACL,OAAO,eAAe,CAAA;KACvB;AACH,CAAC","sourcesContent":["import {useStdout} from 'ink'\n\nconst MIN_WIDTH = 80\n\ninterface Layout {\n twoThirds: number\n oneThird: number\n fullWidth: number\n}\n\nexport default function useLayout(): Layout {\n const {stdout} = useStdout()\n\n const fullWidth = stdout?.columns ?? MIN_WIDTH\n let oneThird\n let twoThirds\n\n if (fullWidth <= MIN_WIDTH) {\n oneThird = fullWidth\n twoThirds = fullWidth\n } else {\n oneThird = column({fullWidth, fraction: [1, 3], minWidth: MIN_WIDTH})\n twoThirds = column({fullWidth, fraction: [2, 3], minWidth: MIN_WIDTH})\n }\n\n return {\n twoThirds,\n oneThird,\n fullWidth,\n }\n}\n\nfunction column({\n fullWidth,\n fraction,\n minWidth,\n}: {\n fullWidth: number\n fraction: [number, number]\n minWidth: number\n}): number {\n const fractionedWidth = Math.floor((fullWidth / fraction[1]) * fraction[0])\n\n if (fractionedWidth < minWidth) {\n return minWidth\n } else {\n return fractionedWidth\n }\n}\n"]}
1
+ {"version":3,"file":"use-layout.js","sourceRoot":"","sources":["../../../../../src/private/node/ui/hooks/use-layout.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,SAAS,EAAC,MAAM,KAAK,CAAA;AAC7B,OAAO,EAAC,SAAS,EAAE,QAAQ,EAAC,MAAM,OAAO,CAAA;AAEzC,MAAM,cAAc,GAAG,EAAE,CAAA;AACzB,MAAM,kBAAkB,GAAG,EAAE,CAAA;AAQ7B,MAAM,CAAC,OAAO,UAAU,SAAS;IAC/B,MAAM,EAAC,MAAM,EAAC,GAAG,SAAS,EAAE,CAAA;IAC5B,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,QAAQ,CAAC,eAAe,CAAC,MAAM,CAAC,CAAC,CAAA;IAE7D,SAAS,CAAC,GAAG,EAAE;QACb,IAAI,CAAC,MAAM,EAAE;YACX,OAAM;SACP;QAED,SAAS,QAAQ;YACf,SAAS,CAAC,eAAe,CAAC,MAAM,CAAC,CAAC,CAAA;QACpC,CAAC;QAED,MAAM,CAAC,EAAE,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAA;QAE7B,OAAO,GAAG,EAAE;YACV,MAAM,CAAC,GAAG,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAA;QAChC,CAAC,CAAA;IACH,CAAC,EAAE,EAAE,CAAC,CAAA;IAEN,OAAO,MAAM,CAAA;AACf,CAAC;AAED,MAAM,UAAU,eAAe,CAAC,MAAsC;IACpE,IAAI,SAAS,GAAG,MAAM,EAAE,OAAO,IAAI,kBAAkB,CAAA;IACrD,IAAI,QAAQ,GAAG,SAAS,CAAA;IACxB,IAAI,SAAS,GAAG,SAAS,CAAA;IAEzB,IAAI,SAAS,IAAI,cAAc,EAAE;QAC/B,SAAS,GAAG,cAAc,CAAA;QAC1B,QAAQ,GAAG,cAAc,CAAA;QACzB,SAAS,GAAG,cAAc,CAAA;KAC3B;SAAM,IAAI,SAAS,GAAG,kBAAkB,EAAE;QACzC,QAAQ,GAAG,MAAM,CAAC,EAAC,SAAS,EAAE,QAAQ,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,QAAQ,EAAE,kBAAkB,EAAC,CAAC,CAAA;QAC9E,SAAS,GAAG,MAAM,CAAC,EAAC,SAAS,EAAE,QAAQ,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,QAAQ,EAAE,kBAAkB,EAAC,CAAC,CAAA;KAChF;IAED,OAAO;QACL,SAAS;QACT,QAAQ;QACR,SAAS;KACV,CAAA;AACH,CAAC;AAED,SAAS,MAAM,CAAC,EACd,SAAS,EACT,QAAQ,EACR,QAAQ,GAKT;IACC,MAAM,eAAe,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,SAAS,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAA;IAE3E,IAAI,eAAe,GAAG,QAAQ,EAAE;QAC9B,OAAO,QAAQ,CAAA;KAChB;SAAM;QACL,OAAO,eAAe,CAAA;KACvB;AACH,CAAC","sourcesContent":["import {useStdout} from 'ink'\nimport {useEffect, useState} from 'react'\n\nconst MIN_FULL_WIDTH = 20\nconst MIN_FRACTION_WIDTH = 80\n\ninterface Layout {\n twoThirds: number\n oneThird: number\n fullWidth: number\n}\n\nexport default function useLayout(): Layout {\n const {stdout} = useStdout()\n const [layout, setLayout] = useState(calculateLayout(stdout))\n\n useEffect(() => {\n if (!stdout) {\n return\n }\n\n function onResize() {\n setLayout(calculateLayout(stdout))\n }\n\n stdout.on('resize', onResize)\n\n return () => {\n stdout.off('resize', onResize)\n }\n }, [])\n\n return layout\n}\n\nexport function calculateLayout(stdout: NodeJS.WriteStream | undefined) {\n let fullWidth = stdout?.columns ?? MIN_FRACTION_WIDTH\n let oneThird = fullWidth\n let twoThirds = fullWidth\n\n if (fullWidth <= MIN_FULL_WIDTH) {\n fullWidth = MIN_FULL_WIDTH\n oneThird = MIN_FULL_WIDTH\n twoThirds = MIN_FULL_WIDTH\n } else if (fullWidth > MIN_FRACTION_WIDTH) {\n oneThird = column({fullWidth, fraction: [1, 3], minWidth: MIN_FRACTION_WIDTH})\n twoThirds = column({fullWidth, fraction: [2, 3], minWidth: MIN_FRACTION_WIDTH})\n }\n\n return {\n fullWidth,\n oneThird,\n twoThirds,\n }\n}\n\nfunction column({\n fullWidth,\n fraction,\n minWidth,\n}: {\n fullWidth: number\n fraction: [number, number]\n minWidth: number\n}): number {\n const fractionedWidth = Math.floor((fullWidth / fraction[1]) * fraction[0])\n\n if (fractionedWidth < minWidth) {\n return minWidth\n } else {\n return fractionedWidth\n }\n}\n"]}
@@ -3,7 +3,12 @@ import { Logger, LogLevel } from '../../public/node/output.js';
3
3
  import { ReactElement } from 'react';
4
4
  import { Key, RenderOptions } from 'ink';
5
5
  import { EventEmitter } from 'events';
6
- export declare function renderOnce(element: JSX.Element, logLevel?: LogLevel, logger?: Logger): void;
6
+ interface RenderOnceOptions {
7
+ logLevel?: LogLevel;
8
+ logger?: Logger;
9
+ renderOptions?: RenderOptions;
10
+ }
11
+ export declare function renderOnce(element: JSX.Element, { logLevel, logger, renderOptions }: RenderOnceOptions): string | undefined;
7
12
  export declare function render(element: JSX.Element, options?: RenderOptions): Promise<void>;
8
13
  interface Instance {
9
14
  output: string | undefined;
@@ -11,13 +16,16 @@ interface Instance {
11
16
  }
12
17
  export declare class OutputStream extends EventEmitter {
13
18
  columns: number;
19
+ rows: number;
20
+ readonly frames: string[];
14
21
  private _lastFrame?;
15
22
  constructor(options: {
16
- columns: number;
23
+ columns?: number;
24
+ rows?: number;
17
25
  });
18
26
  write: (frame: string) => void;
19
27
  lastFrame: () => string | undefined;
20
28
  }
21
- export declare const renderString: (element: ReactElement) => Instance;
29
+ export declare const renderString: (element: ReactElement, renderOptions?: RenderOptions) => Instance;
22
30
  export declare function handleCtrlC(input: string, key: Key): void;
23
31
  export {};
@@ -3,14 +3,15 @@ import { isUnitTest } from '../../public/node/context/local.js';
3
3
  import { render as inkRender } from 'ink';
4
4
  import treeKill from 'tree-kill';
5
5
  import { EventEmitter } from 'events';
6
- export function renderOnce(element, logLevel = 'info', logger = consoleLog) {
7
- const { output, unmount } = renderString(element);
6
+ export function renderOnce(element, { logLevel = 'info', logger = consoleLog, renderOptions }) {
7
+ const { output, unmount } = renderString(element, renderOptions);
8
8
  if (output) {
9
9
  if (isUnitTest())
10
10
  collectLog(logLevel, output);
11
11
  outputWhereAppropriate(logLevel, logger, output);
12
12
  }
13
13
  unmount();
14
+ return output;
14
15
  }
15
16
  export function render(element, options) {
16
17
  const { waitUntilExit } = inkRender(element, options);
@@ -19,23 +20,26 @@ export function render(element, options) {
19
20
  export class OutputStream extends EventEmitter {
20
21
  constructor(options) {
21
22
  super();
23
+ this.frames = [];
22
24
  this.write = (frame) => {
25
+ this.frames.push(frame);
23
26
  this._lastFrame = frame;
24
27
  };
25
28
  this.lastFrame = () => {
26
29
  return this._lastFrame;
27
30
  };
28
- this.columns = options.columns;
31
+ this.columns = options.columns ?? 80;
32
+ this.rows = options.rows ?? 80;
29
33
  }
30
34
  }
31
- export const renderString = (element) => {
32
- const stdout = new OutputStream({ columns: process.stdout.columns });
33
- const stderr = new OutputStream({ columns: process.stderr.columns });
35
+ export const renderString = (element, renderOptions) => {
36
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
37
+ const stdout = renderOptions?.stdout ?? new OutputStream({ columns: process.stdout.columns });
38
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
39
+ const stderr = renderOptions?.stderr ?? new OutputStream({ columns: process.stderr.columns });
34
40
  const instance = inkRender(element, {
35
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
36
- stdout: stdout,
37
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
38
- stderr: stderr,
41
+ stdout,
42
+ stderr,
39
43
  debug: true,
40
44
  exitOnCtrlC: false,
41
45
  patchConsole: false,
@@ -1 +1 @@
1
- {"version":3,"file":"ui.js","sourceRoot":"","sources":["../../../src/private/node/ui.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAE,UAAU,EAAoB,sBAAsB,EAAC,MAAM,6BAA6B,CAAA;AAC5G,OAAO,EAAC,UAAU,EAAC,MAAM,oCAAoC,CAAA;AAE7D,OAAO,EAAM,MAAM,IAAI,SAAS,EAAgB,MAAM,KAAK,CAAA;AAC3D,OAAO,QAAQ,MAAM,WAAW,CAAA;AAChC,OAAO,EAAC,YAAY,EAAC,MAAM,QAAQ,CAAA;AAEnC,MAAM,UAAU,UAAU,CAAC,OAAoB,EAAE,WAAqB,MAAM,EAAE,SAAiB,UAAU;IACvG,MAAM,EAAC,MAAM,EAAE,OAAO,EAAC,GAAG,YAAY,CAAC,OAAO,CAAC,CAAA;IAE/C,IAAI,MAAM,EAAE;QACV,IAAI,UAAU,EAAE;YAAE,UAAU,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAA;QAC9C,sBAAsB,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,CAAC,CAAA;KACjD;IAED,OAAO,EAAE,CAAA;AACX,CAAC;AAED,MAAM,UAAU,MAAM,CAAC,OAAoB,EAAE,OAAuB;IAClE,MAAM,EAAC,aAAa,EAAC,GAAG,SAAS,CAAC,OAAO,EAAE,OAAO,CAAC,CAAA;IACnD,OAAO,aAAa,EAAE,CAAA;AACxB,CAAC;AAOD,MAAM,OAAO,YAAa,SAAQ,YAAY;IAI5C,YAAY,OAA0B;QACpC,KAAK,EAAE,CAAA;QAIT,UAAK,GAAG,CAAC,KAAa,EAAE,EAAE;YACxB,IAAI,CAAC,UAAU,GAAG,KAAK,CAAA;QACzB,CAAC,CAAA;QAED,cAAS,GAAG,GAAG,EAAE;YACf,OAAO,IAAI,CAAC,UAAU,CAAA;QACxB,CAAC,CAAA;QATC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC,OAAO,CAAA;IAChC,CAAC;CASF;AAED,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,OAAqB,EAAY,EAAE;IAC9D,MAAM,MAAM,GAAG,IAAI,YAAY,CAAC,EAAC,OAAO,EAAE,OAAO,CAAC,MAAM,CAAC,OAAO,EAAC,CAAC,CAAA;IAClE,MAAM,MAAM,GAAG,IAAI,YAAY,CAAC,EAAC,OAAO,EAAE,OAAO,CAAC,MAAM,CAAC,OAAO,EAAC,CAAC,CAAA;IAElE,MAAM,QAAQ,GAAG,SAAS,CAAC,OAAO,EAAE;QAClC,8DAA8D;QAC9D,MAAM,EAAE,MAAa;QACrB,8DAA8D;QAC9D,MAAM,EAAE,MAAa;QACrB,KAAK,EAAE,IAAI;QACX,WAAW,EAAE,KAAK;QAClB,YAAY,EAAE,KAAK;KACpB,CAAC,CAAA;IAEF,OAAO;QACL,MAAM,EAAE,MAAM,CAAC,SAAS,EAAE;QAC1B,OAAO,EAAE,QAAQ,CAAC,OAAO;KAC1B,CAAA;AACH,CAAC,CAAA;AAED,MAAM,UAAU,WAAW,CAAC,KAAa,EAAE,GAAQ;IACjD,IAAI,KAAK,KAAK,GAAG,IAAI,GAAG,CAAC,IAAI,EAAE;QAC7B,gEAAgE;QAChE,QAAQ,CAAC,OAAO,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAA;KAChC;AACH,CAAC","sourcesContent":["import {collectLog, consoleLog, Logger, LogLevel, outputWhereAppropriate} from '../../public/node/output.js'\nimport {isUnitTest} from '../../public/node/context/local.js'\nimport {ReactElement} from 'react'\nimport {Key, render as inkRender, RenderOptions} from 'ink'\nimport treeKill from 'tree-kill'\nimport {EventEmitter} from 'events'\n\nexport function renderOnce(element: JSX.Element, logLevel: LogLevel = 'info', logger: Logger = consoleLog) {\n const {output, unmount} = renderString(element)\n\n if (output) {\n if (isUnitTest()) collectLog(logLevel, output)\n outputWhereAppropriate(logLevel, logger, output)\n }\n\n unmount()\n}\n\nexport function render(element: JSX.Element, options?: RenderOptions) {\n const {waitUntilExit} = inkRender(element, options)\n return waitUntilExit()\n}\n\ninterface Instance {\n output: string | undefined\n unmount: () => void\n}\n\nexport class OutputStream extends EventEmitter {\n columns: number\n private _lastFrame?: string\n\n constructor(options: {columns: number}) {\n super()\n this.columns = options.columns\n }\n\n write = (frame: string) => {\n this._lastFrame = frame\n }\n\n lastFrame = () => {\n return this._lastFrame\n }\n}\n\nexport const renderString = (element: ReactElement): Instance => {\n const stdout = new OutputStream({columns: process.stdout.columns})\n const stderr = new OutputStream({columns: process.stderr.columns})\n\n const instance = inkRender(element, {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n stdout: stdout as any,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n stderr: stderr as any,\n debug: true,\n exitOnCtrlC: false,\n patchConsole: false,\n })\n\n return {\n output: stdout.lastFrame(),\n unmount: instance.unmount,\n }\n}\n\nexport function handleCtrlC(input: string, key: Key) {\n if (input === 'c' && key.ctrl) {\n // Exceptions thrown in hooks aren't caught by our errorHandler.\n treeKill(process.pid, 'SIGINT')\n }\n}\n"]}
1
+ {"version":3,"file":"ui.js","sourceRoot":"","sources":["../../../src/private/node/ui.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAE,UAAU,EAAoB,sBAAsB,EAAC,MAAM,6BAA6B,CAAA;AAC5G,OAAO,EAAC,UAAU,EAAC,MAAM,oCAAoC,CAAA;AAE7D,OAAO,EAAM,MAAM,IAAI,SAAS,EAAgB,MAAM,KAAK,CAAA;AAC3D,OAAO,QAAQ,MAAM,WAAW,CAAA;AAChC,OAAO,EAAC,YAAY,EAAC,MAAM,QAAQ,CAAA;AAQnC,MAAM,UAAU,UAAU,CACxB,OAAoB,EACpB,EAAC,QAAQ,GAAG,MAAM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AAC,OAAO,EAAC,CAAC,CAAA;IACpG,8DAA8D;IAC9D,MAAM,MAAM,GAAI,aAAa,EAAE,MAAc,IAAI,IAAI,YAAY,CAAC,EAAC,OAAO,EAAE,OAAO,CAAC,MAAM,CAAC,OAAO,EAAC,CAAC,CAAA;IAEpG,MAAM,QAAQ,GAAG,SAAS,CAAC,OAAO,EAAE;QAClC,MAAM;QACN,MAAM;QACN,KAAK,EAAE,IAAI;QACX,WAAW,EAAE,KAAK;QAClB,YAAY,EAAE,KAAK;KACpB,CAAC,CAAA;IAEF,OAAO;QACL,MAAM,EAAE,MAAM,CAAC,SAAS,EAAE;QAC1B,OAAO,EAAE,QAAQ,CAAC,OAAO;KAC1B,CAAA;AACH,CAAC,CAAA;AAED,MAAM,UAAU,WAAW,CAAC,KAAa,EAAE,GAAQ;IACjD,IAAI,KAAK,KAAK,GAAG,IAAI,GAAG,CAAC,IAAI,EAAE;QAC7B,gEAAgE;QAChE,QAAQ,CAAC,OAAO,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAA;KAChC;AACH,CAAC","sourcesContent":["import {collectLog, consoleLog, Logger, LogLevel, outputWhereAppropriate} from '../../public/node/output.js'\nimport {isUnitTest} from '../../public/node/context/local.js'\nimport {ReactElement} from 'react'\nimport {Key, render as inkRender, RenderOptions} from 'ink'\nimport treeKill from 'tree-kill'\nimport {EventEmitter} from 'events'\n\ninterface RenderOnceOptions {\n logLevel?: LogLevel\n logger?: Logger\n renderOptions?: RenderOptions\n}\n\nexport function renderOnce(\n element: JSX.Element,\n {logLevel = 'info', logger = consoleLog, renderOptions}: RenderOnceOptions,\n) {\n const {output, unmount} = renderString(element, renderOptions)\n\n if (output) {\n if (isUnitTest()) collectLog(logLevel, output)\n outputWhereAppropriate(logLevel, logger, output)\n }\n\n unmount()\n\n return output\n}\n\nexport function render(element: JSX.Element, options?: RenderOptions) {\n const {waitUntilExit} = inkRender(element, options)\n return waitUntilExit()\n}\n\ninterface Instance {\n output: string | undefined\n unmount: () => void\n}\n\nexport class OutputStream extends EventEmitter {\n columns: number\n rows: number\n readonly frames: string[] = []\n private _lastFrame?: string\n\n constructor(options: {columns?: number; rows?: number}) {\n super()\n this.columns = options.columns ?? 80\n this.rows = options.rows ?? 80\n }\n\n write = (frame: string) => {\n this.frames.push(frame)\n this._lastFrame = frame\n }\n\n lastFrame = () => {\n return this._lastFrame\n }\n}\n\nexport const renderString = (element: ReactElement, renderOptions?: RenderOptions): Instance => {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const stdout = (renderOptions?.stdout as any) ?? new OutputStream({columns: process.stdout.columns})\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const stderr = (renderOptions?.stderr as any) ?? new OutputStream({columns: process.stderr.columns})\n\n const instance = inkRender(element, {\n stdout,\n stderr,\n debug: true,\n exitOnCtrlC: false,\n patchConsole: false,\n })\n\n return {\n output: stdout.lastFrame(),\n unmount: instance.unmount,\n }\n}\n\nexport function handleCtrlC(input: string, key: Key) {\n if (input === 'c' && key.ctrl) {\n // Exceptions thrown in hooks aren't caught by our errorHandler.\n treeKill(process.pid, 'SIGINT')\n }\n}\n"]}
@@ -24,7 +24,7 @@ export declare function pickBy<T, S extends T>(object: Dictionary<T> | null | un
24
24
  * invoked with three arguments: (value, key, object).
25
25
  *
26
26
  * @param source - The object to iterate over.
27
- * @param callback - The function invoked per iteration.
27
+ * @param callback - The function invoked per iteration.
28
28
  * @returns Returns the new mapped object.
29
29
  */
30
30
  export declare function mapValues<T extends object, TResult>(source: T | null | undefined, callback: ObjectIterator<T, TResult>): {
@@ -33,7 +33,7 @@ export function pickBy(object, predicate) {
33
33
  * invoked with three arguments: (value, key, object).
34
34
  *
35
35
  * @param source - The object to iterate over.
36
- * @param callback - The function invoked per iteration.
36
+ * @param callback - The function invoked per iteration.
37
37
  * @returns Returns the new mapped object.
38
38
  */
39
39
  export function mapValues(source, callback) {
@@ -1 +1 @@
1
- {"version":3,"file":"object.js","sourceRoot":"","sources":["../../../src/public/common/object.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,kBAAkB,EAAC,MAAM,+BAA+B,CAAA;AAChE,OAAO,SAAS,MAAM,WAAW,CAAA;AAEjC,OAAO,EAAC,aAAa,EAAC,MAAM,QAAQ,CAAA;AAEpC,MAAM,OAAO,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;AAE9C;;;;;;;;GAQG;AACH,MAAM,UAAU,gBAAgB,CAC9B,GAAgB,EAChB,GAAgB,EAChB,qBAAyF,kBAAkB;IAE3G,OAAO,SAAS,CAAC,GAAG,EAAE,GAAG,EAAE,EAAC,UAAU,EAAE,kBAAkB,EAAC,CAAC,CAAA;AAC9D,CAAC;AAED;;;;;;;GAOG;AACH,gEAAgE;AAChE,MAAM,UAAU,MAAM,CACpB,MAAwC,EACxC,SAA+B;IAE/B,MAAM,YAAY,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAAA;IAChD,OAAO,YAAY,CAAC,MAAM,EAAE,SAAS,CAAC,CAAA;AACxC,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,SAAS,CACvB,MAA4B,EAC5B,QAAoC;IAEpC,MAAM,eAAe,GAAG,OAAO,CAAC,qBAAqB,CAAC,CAAA;IACtD,OAAO,eAAe,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAA;AAC1C,CAAC","sourcesContent":["import {unionArrayStrategy} from '../../private/common/array.js'\nimport deepMerge from 'deepmerge'\nimport {Dictionary, ObjectIterator, ValueKeyIteratee} from 'lodash'\nimport {createRequire} from 'module'\n\nconst require = createRequire(import.meta.url)\n\n/**\n * Deep merges the two objects and returns a new object with the merge result.\n *\n * @param lhs - One of the objects to be merged.\n * @param rhs - Another object to be merged.\n * @param arrayMergeStrategy - Strategy used to merge the array typed fields. Union strategy is used by default to avoid\n * duplicated elements.\n * @returns A Javascrip tobject with th emerged objects.\n */\nexport function deepMergeObjects<T1, T2>(\n lhs: Partial<T1>,\n rhs: Partial<T2>,\n arrayMergeStrategy: (destinationArray: unknown[], sourceArray: unknown[]) => unknown[] = unionArrayStrategy,\n): T1 & T2 {\n return deepMerge(lhs, rhs, {arrayMerge: arrayMergeStrategy})\n}\n\n/**\n * Creates an object composed of the `object` properties `predicate` returns\n * truthy for. The predicate is invoked with two arguments: (value, key).\n *\n * @param object - The source object.\n * @param predicate - The function invoked per property.\n * @returns Returns the new object.\n */\n// eslint-disable-next-line @typescript-eslint/naming-convention\nexport function pickBy<T, S extends T>(\n object: Dictionary<T> | null | undefined,\n predicate?: ValueKeyIteratee<T>,\n): Dictionary<S> {\n const lodashPickBy = require('lodash/pickBy.js')\n return lodashPickBy(object, predicate)\n}\n\n/**\n * Creates an object with the same keys as object and values generated by running each own\n * enumerable property of object through iteratee. The iteratee function is\n * invoked with three arguments: (value, key, object).\n *\n * @param source - The object to iterate over.\n * @param callback - The function invoked per iteration.\n * @returns Returns the new mapped object.\n */\nexport function mapValues<T extends object, TResult>(\n source: T | null | undefined,\n callback: ObjectIterator<T, TResult>,\n): {[P in keyof T]: TResult} {\n const lodashMapValues = require('lodash/mapValues.js')\n return lodashMapValues(source, callback)\n}\n"]}
1
+ {"version":3,"file":"object.js","sourceRoot":"","sources":["../../../src/public/common/object.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,kBAAkB,EAAC,MAAM,+BAA+B,CAAA;AAChE,OAAO,SAAS,MAAM,WAAW,CAAA;AAEjC,OAAO,EAAC,aAAa,EAAC,MAAM,QAAQ,CAAA;AAEpC,MAAM,OAAO,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;AAE9C;;;;;;;;GAQG;AACH,MAAM,UAAU,gBAAgB,CAC9B,GAAgB,EAChB,GAAgB,EAChB,qBAAyF,kBAAkB;IAE3G,OAAO,SAAS,CAAC,GAAG,EAAE,GAAG,EAAE,EAAC,UAAU,EAAE,kBAAkB,EAAC,CAAC,CAAA;AAC9D,CAAC;AAED;;;;;;;GAOG;AACH,gEAAgE;AAChE,MAAM,UAAU,MAAM,CACpB,MAAwC,EACxC,SAA+B;IAE/B,MAAM,YAAY,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAAA;IAChD,OAAO,YAAY,CAAC,MAAM,EAAE,SAAS,CAAC,CAAA;AACxC,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,SAAS,CACvB,MAA4B,EAC5B,QAAoC;IAEpC,MAAM,eAAe,GAAG,OAAO,CAAC,qBAAqB,CAAC,CAAA;IACtD,OAAO,eAAe,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAA;AAC1C,CAAC","sourcesContent":["import {unionArrayStrategy} from '../../private/common/array.js'\nimport deepMerge from 'deepmerge'\nimport {Dictionary, ObjectIterator, ValueKeyIteratee} from 'lodash'\nimport {createRequire} from 'module'\n\nconst require = createRequire(import.meta.url)\n\n/**\n * Deep merges the two objects and returns a new object with the merge result.\n *\n * @param lhs - One of the objects to be merged.\n * @param rhs - Another object to be merged.\n * @param arrayMergeStrategy - Strategy used to merge the array typed fields. Union strategy is used by default to avoid\n * duplicated elements.\n * @returns A Javascrip tobject with th emerged objects.\n */\nexport function deepMergeObjects<T1, T2>(\n lhs: Partial<T1>,\n rhs: Partial<T2>,\n arrayMergeStrategy: (destinationArray: unknown[], sourceArray: unknown[]) => unknown[] = unionArrayStrategy,\n): T1 & T2 {\n return deepMerge(lhs, rhs, {arrayMerge: arrayMergeStrategy})\n}\n\n/**\n * Creates an object composed of the `object` properties `predicate` returns\n * truthy for. The predicate is invoked with two arguments: (value, key).\n *\n * @param object - The source object.\n * @param predicate - The function invoked per property.\n * @returns Returns the new object.\n */\n// eslint-disable-next-line @typescript-eslint/naming-convention\nexport function pickBy<T, S extends T>(\n object: Dictionary<T> | null | undefined,\n predicate?: ValueKeyIteratee<T>,\n): Dictionary<S> {\n const lodashPickBy = require('lodash/pickBy.js')\n return lodashPickBy(object, predicate)\n}\n\n/**\n * Creates an object with the same keys as object and values generated by running each own\n * enumerable property of object through iteratee. The iteratee function is\n * invoked with three arguments: (value, key, object).\n *\n * @param source - The object to iterate over.\n * @param callback - The function invoked per iteration.\n * @returns Returns the new mapped object.\n */\nexport function mapValues<T extends object, TResult>(\n source: T | null | undefined,\n callback: ObjectIterator<T, TResult>,\n): {[P in keyof T]: TResult} {\n const lodashMapValues = require('lodash/mapValues.js')\n return lodashMapValues(source, callback)\n}\n"]}
@@ -1 +1 @@
1
- export declare const CLI_KIT_VERSION = "3.44.1";
1
+ export declare const CLI_KIT_VERSION = "3.45.0-pre.1";
@@ -1,2 +1,2 @@
1
- export const CLI_KIT_VERSION = '3.44.1';
1
+ export const CLI_KIT_VERSION = '3.45.0-pre.1';
2
2
  //# sourceMappingURL=version.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"version.js","sourceRoot":"","sources":["../../../src/public/common/version.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,eAAe,GAAG,QAAQ,CAAA","sourcesContent":["export const CLI_KIT_VERSION = '3.44.1'\n"]}
1
+ {"version":3,"file":"version.js","sourceRoot":"","sources":["../../../src/public/common/version.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,eAAe,GAAG,cAAc,CAAA","sourcesContent":["export const CLI_KIT_VERSION = '3.45.0-pre.1'\n"]}
@@ -17,10 +17,7 @@ declare abstract class BaseCommand extends Command {
17
17
  path?: string;
18
18
  verbose?: boolean;
19
19
  }, TGlobalFlags extends FlagOutput, TArgs extends ArgOutput>(originalResult: ParserOutput<TFlags, TGlobalFlags, TArgs>, options?: Input<TFlags, TGlobalFlags, TArgs>, argv?: string[]): Promise<ParserOutput<TFlags, TGlobalFlags, TArgs>>;
20
- protected environmentsPath(rawFlags: {
21
- path?: string;
22
- }): Promise<string>;
23
- protected findUpForEnvironments(): boolean;
20
+ protected environmentsFilename(): string | undefined;
24
21
  }
25
22
  export declare function addFromParsedFlags(flags: {
26
23
  path?: string;
@@ -1,9 +1,9 @@
1
1
  import { errorHandler, registerCleanBugsnagErrorsFromWithinPlugins } from './error-handler.js';
2
- import { loadEnvironmentsFromDirectory } from './environments.js';
2
+ import { loadEnvironment } from './environments.js';
3
3
  import { isDevelopment } from './context/local.js';
4
4
  import { addPublicMetadata } from './metadata.js';
5
5
  import { AbortError } from './error.js';
6
- import { cwd } from './path.js';
6
+ import { renderInfo } from './ui.js';
7
7
  import { outputContent, outputInfo, outputToken } from '../../public/node/output.js';
8
8
  import { hashString } from '../../public/node/crypto.js';
9
9
  import { isTruthy } from '../../private/node/context/utilities.js';
@@ -44,13 +44,11 @@ class BaseCommand extends Command {
44
44
  async resultWithEnvironment(originalResult, options, argv) {
45
45
  // If no environment is specified, don't modify the results
46
46
  const flags = originalResult.flags;
47
- if (!flags.environment)
47
+ const environmentsFileName = this.environmentsFilename();
48
+ if (!flags.environment || !environmentsFileName)
48
49
  return originalResult;
49
50
  // If the specified environment isn't found, don't modify the results
50
- const environments = await loadEnvironmentsFromDirectory(await this.environmentsPath(flags), {
51
- findUp: this.findUpForEnvironments(),
52
- });
53
- const environment = environments[flags.environment];
51
+ const environment = await loadEnvironment(flags.environment, environmentsFileName, { from: flags.path });
54
52
  if (!environment)
55
53
  return originalResult;
56
54
  // Parse using noDefaultsOptions to derive a list of flags specified as
@@ -68,11 +66,9 @@ class BaseCommand extends Command {
68
66
  reportEnvironmentApplication(noDefaultsResult.flags, result.flags, flags.environment, environment);
69
67
  return result;
70
68
  }
71
- async environmentsPath(rawFlags) {
72
- return rawFlags.path || cwd();
73
- }
74
- findUpForEnvironments() {
75
- return true;
69
+ environmentsFilename() {
70
+ // To be re-implemented if needed
71
+ return undefined;
76
72
  }
77
73
  }
78
74
  export async function addFromParsedFlags(flags) {
@@ -99,16 +95,18 @@ function reportEnvironmentApplication(noDefaultsFlags, flagsWithEnvironments, en
99
95
  for (const [name, value] of Object.entries(flagsWithEnvironments)) {
100
96
  const userSpecifiedThisFlag = Object.prototype.hasOwnProperty.call(noDefaultsFlags, name);
101
97
  const environmentContainsFlag = Object.prototype.hasOwnProperty.call(environment, name);
102
- if (!userSpecifiedThisFlag && environmentContainsFlag)
103
- changes[name] = value;
98
+ if (!userSpecifiedThisFlag && environmentContainsFlag) {
99
+ const valueToReport = name === 'password' ? `********${value.substr(-4)}` : value;
100
+ changes[name] = valueToReport;
101
+ }
104
102
  }
105
103
  if (Object.keys(changes).length === 0)
106
104
  return;
107
- outputInfo(outputContent `Using applicable flags from the environment ${outputToken.yellow(environmentName)}:
108
-
109
- ${Object.entries(changes)
110
- .map(([name, value]) => `• ${name} = ${value}`)
111
- .join('\n')}\n`);
105
+ const items = Object.entries(changes).map(([name, value]) => `${name}: ${value}`);
106
+ renderInfo({
107
+ headline: ['Using applicable flags from', { userInput: environmentName }, 'environment:'],
108
+ body: [{ list: { items } }],
109
+ });
112
110
  }
113
111
  /**
114
112
  * Strips the defaults from configured flags. For example, if flags contains:
@@ -1 +1 @@
1
- {"version":3,"file":"base-command.js","sourceRoot":"","sources":["../../../src/public/node/base-command.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,YAAY,EAAE,2CAA2C,EAAC,MAAM,oBAAoB,CAAA;AAC5F,OAAO,EAAC,6BAA6B,EAAC,MAAM,mBAAmB,CAAA;AAC/D,OAAO,EAAC,aAAa,EAAC,MAAM,oBAAoB,CAAA;AAChD,OAAO,EAAC,iBAAiB,EAAC,MAAM,eAAe,CAAA;AAC/C,OAAO,EAAC,UAAU,EAAC,MAAM,YAAY,CAAA;AACrC,OAAO,EAAC,GAAG,EAAC,MAAM,WAAW,CAAA;AAE7B,OAAO,EAAC,aAAa,EAAE,UAAU,EAAE,WAAW,EAAC,MAAM,6BAA6B,CAAA;AAClF,OAAO,EAAC,UAAU,EAAC,MAAM,6BAA6B,CAAA;AACtD,OAAO,EAAC,QAAQ,EAAC,MAAM,yCAAyC,CAAA;AAChE,OAAO,EAAC,OAAO,EAAC,MAAM,aAAa,CAAA;AAQnC,MAAe,WAAY,SAAQ,OAAO;IACjC,MAAM,CAAC,qBAAqB;QACjC,OAAO,S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,CAAC,IAAI,CAAC,KAAK,KAAK,EAAE,EAAE,GAAG,OAAO,EAAE,CAAC,CAAC,CAAA;aAClE;iBAAM;gBACL,IAAI,CAAC,IAAI,CAAC,KAAK,KAAK,EAAE,EAAE,GAAG,KAAK,EAAE,CAAC,CAAA;aACpC;SACF;KACF;IACD,OAAO,IAAI,CAAA;AACb,CAAC;AAED,eAAe,WAAW,CAAA","sourcesContent":["import {errorHandler, registerCleanBugsnagErrorsFromWithinPlugins} from './error-handler.js'\nimport {loadEnvironmentsFromDirectory} from './environments.js'\nimport {isDevelopment} from './context/local.js'\nimport {addPublicMetadata} from './metadata.js'\nimport {AbortError} from './error.js'\nimport {cwd} from './path.js'\nimport {JsonMap} from '../../private/common/json.js'\nimport {outputContent, outputInfo, outputToken} from '../../public/node/output.js'\nimport {hashString} from '../../public/node/crypto.js'\nimport {isTruthy} from '../../private/node/context/utilities.js'\nimport {Command} from '@oclif/core'\nimport {FlagOutput, Input, ParserOutput, FlagInput, ArgOutput} from '@oclif/core/lib/interfaces/parser.js'\n\ninterface EnvironmentFlags {\n environment?: string\n path?: string\n}\n\nabstract class BaseCommand extends Command {\n public static analyticsNameOverride(): string | undefined {\n return undefined\n }\n\n async catch(error: Error & {exitCode?: number | undefined}): Promise<void> {\n errorHandler(error, this.config)\n }\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n protected async init(): Promise<any> {\n this.exitWithTimestampWhenEnvVariablePresent()\n if (!isDevelopment()) {\n // This function runs just prior to `run`\n await registerCleanBugsnagErrorsFromWithinPlugins(this.config)\n }\n return super.init()\n }\n\n // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types\n protected exitWithTimestampWhenEnvVariablePresent() {\n if (isTruthy(process.env.SHOPIFY_CLI_ENV_STARTUP_PERFORMANCE_RUN)) {\n outputInfo(`\n SHOPIFY_CLI_TIMESTAMP_START\n { \"timestamp\": ${Date.now()} }\n SHOPIFY_CLI_TIMESTAMP_END\n `)\n process.exit(0)\n }\n }\n\n protected async parse<\n TFlags extends FlagOutput & {path?: string; verbose?: boolean},\n TGlobalFlags extends FlagOutput,\n TArgs extends ArgOutput,\n >(\n options?: Input<TFlags, TGlobalFlags, TArgs>,\n argv?: string[],\n ): Promise<ParserOutput<TFlags, TGlobalFlags, TArgs> & {argv: string[]}> {\n let result = await super.parse<TFlags, TGlobalFlags, TArgs>(options, argv)\n result = await this.resultWithEnvironment<TFlags, TGlobalFlags, TArgs>(result, options, argv)\n await addFromParsedFlags(result.flags)\n return {...result, ...{argv: result.argv as string[]}}\n }\n\n protected async resultWithEnvironment<\n TFlags extends FlagOutput & {path?: string; verbose?: boolean},\n TGlobalFlags extends FlagOutput,\n TArgs extends ArgOutput,\n >(\n originalResult: ParserOutput<TFlags, TGlobalFlags, TArgs>,\n options?: Input<TFlags, TGlobalFlags, TArgs>,\n argv?: string[],\n ): Promise<ParserOutput<TFlags, TGlobalFlags, TArgs>> {\n // If no environment is specified, don't modify the results\n const flags = originalResult.flags as EnvironmentFlags\n if (!flags.environment) return originalResult\n\n // If the specified environment isn't found, don't modify the results\n const environments = await loadEnvironmentsFromDirectory(await this.environmentsPath(flags), {\n findUp: this.findUpForEnvironments(),\n })\n const environment = environments[flags.environment]\n if (!environment) return originalResult\n\n // Parse using noDefaultsOptions to derive a list of flags specified as\n // command-line arguments.\n const noDefaultsResult = await super.parse<TFlags, TGlobalFlags, TArgs>(noDefaultsOptions(options), argv)\n\n // Add the environment's settings to argv and pass them to `super.parse`. This\n // invokes oclif's validation system without breaking the oclif black box.\n // Replace the original result with this one.\n const result = await super.parse<TFlags, TGlobalFlags, TArgs>(options, [\n // Need to specify argv default because we're merging with argsFromEnvironment.\n ...(argv || this.argv),\n ...argsFromEnvironment<TFlags, TGlobalFlags, TArgs>(environment, options, noDefaultsResult),\n ])\n\n // Report successful application of the environment.\n reportEnvironmentApplication<TFlags, TGlobalFlags, TArgs>(\n noDefaultsResult.flags,\n result.flags,\n flags.environment,\n environment,\n )\n\n return result\n }\n\n protected async environmentsPath(rawFlags: {path?: string}): Promise<string> {\n return rawFlags.path || cwd()\n }\n\n protected findUpForEnvironments(): boolean {\n return true\n }\n}\n\nexport async function addFromParsedFlags(flags: {path?: string; verbose?: boolean}): Promise<void> {\n await addPublicMetadata(() => ({\n cmd_all_verbose: flags.verbose,\n cmd_all_path_override: flags.path !== undefined,\n cmd_all_path_override_hash: flags.path === undefined ? undefined : hashString(flags.path),\n }))\n}\n\n/**\n * Any flag which is:\n *\n * 1. Present in the final set of flags\n * 2. Specified in the environment\n * 3. Not specified by the user as a command line argument\n *\n * should be reported.\n *\n * It doesn't matter if the environment flag's value was the same as the default; from\n * the user's perspective, they want to know their environment was applied.\n */\nfunction reportEnvironmentApplication<\n TFlags extends FlagOutput,\n TGlobalFlags extends FlagOutput,\n TArgs extends ArgOutput,\n>(\n noDefaultsFlags: ParserOutput<TFlags, TGlobalFlags, TArgs>['flags'],\n flagsWithEnvironments: ParserOutput<TFlags, TGlobalFlags, TArgs>['flags'],\n environmentName: string,\n environment: JsonMap,\n): void {\n const changes: JsonMap = {}\n for (const [name, value] of Object.entries(flagsWithEnvironments)) {\n const userSpecifiedThisFlag = Object.prototype.hasOwnProperty.call(noDefaultsFlags, name)\n const environmentContainsFlag = Object.prototype.hasOwnProperty.call(environment, name)\n if (!userSpecifiedThisFlag && environmentContainsFlag) changes[name] = value\n }\n if (Object.keys(changes).length === 0) return\n outputInfo(outputContent`Using applicable flags from the environment ${outputToken.yellow(environmentName)}:\n\n${Object.entries(changes)\n .map(([name, value]) => `• ${name} = ${value}`)\n .join('\\n')}\\n`)\n}\n\n/**\n * Strips the defaults from configured flags. For example, if flags contains:\n *\n * ```\n * someFlag: Flags.boolean({\n * description: 'some flag',\n * default: false\n * })\n * ```\n *\n * it becomes:\n *\n * ```\n * someFlag: Flags.boolean({\n * description: 'some flag'\n * })\n * ```\n *\n * If we parse using this configuration, the only specified flags will be those\n * the user actually passed on the command line.\n */\nfunction noDefaultsOptions<TFlags extends FlagOutput, TGlobalFlags extends FlagOutput, TArgs extends ArgOutput>(\n options: Input<TFlags, TGlobalFlags, TArgs> | undefined,\n): Input<TFlags, TGlobalFlags, TArgs> | undefined {\n if (!options?.flags) return options\n return {\n ...options,\n flags: Object.fromEntries(\n Object.entries(options.flags).map(([label, settings]) => {\n const copiedSettings = {...(settings as {default?: unknown})}\n delete copiedSettings.default\n return [label, copiedSettings]\n }),\n ) as FlagInput<TFlags>,\n }\n}\n\n/**\n * Converts the environment's settings to arguments as though passed on the command\n * line, skipping any arguments the user specified on the command line.\n */\nfunction argsFromEnvironment<TFlags extends FlagOutput, TGlobalFlags extends FlagOutput, TArgs extends ArgOutput>(\n environment: JsonMap,\n options: Input<TFlags, TGlobalFlags, TArgs> | undefined,\n noDefaultsResult: ParserOutput<TFlags, TArgs>,\n): string[] {\n const args: string[] = []\n for (const [label, value] of Object.entries(environment)) {\n const flagIsRelevantToCommand = options?.flags && Object.prototype.hasOwnProperty.call(options.flags, label)\n const userSpecifiedThisFlag =\n noDefaultsResult.flags && Object.prototype.hasOwnProperty.call(noDefaultsResult.flags, label)\n if (flagIsRelevantToCommand && !userSpecifiedThisFlag) {\n if (typeof value === 'boolean') {\n if (value === true) {\n args.push(`--${label}`)\n } else {\n throw new AbortError(\n outputContent`Environments can only specify true for boolean flags. Attempted to set ${outputToken.yellow(\n label,\n )} to false.`,\n )\n }\n } else if (Array.isArray(value)) {\n value.forEach((element) => args.push(`--${label}`, `${element}`))\n } else {\n args.push(`--${label}`, `${value}`)\n }\n }\n }\n return args\n}\n\nexport default BaseCommand\n"]}
1
+ {"version":3,"file":"base-command.js","sourceRoot":"","sources":["../../../src/public/node/base-command.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,YAAY,EAAE,2CAA2C,EAAC,MAAM,oBAAoB,CAAA;AAC5F,OAAO,EAAC,eAAe,EAAC,MAAM,mBAAmB,CAAA;AACjD,OAAO,EAAC,aAAa,EAAC,MAAM,oBAAoB,CAAA;AAChD,OAAO,EAAC,iBA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AqB,GACzB,gBAAgB,CAAC,KAAK,IAAI,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,gBAAgB,CAAC,KAAK,EAAE,KAAK,CAAC,CAAA;QAC/F,IAAI,uBAAuB,IAAI,CAAC,qBAAqB,EAAE;YACrD,IAAI,OAAO,KAAK,KAAK,SAAS,EAAE;gBAC9B,IAAI,KAAK,KAAK,IAAI,EAAE;oBAClB,IAAI,CAAC,IAAI,CAAC,KAAK,KAAK,EAAE,CAAC,CAAA;iBACxB;qBAAM;oBACL,MAAM,IAAI,UAAU,CAClB,aAAa,CAAA,0EAA0E,WAAW,CAAC,MAAM,CACvG,KAAK,CACN,YAAY,CACd,CAAA;iBACF;aACF;iBAAM,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE;gBAC/B,KAAK,CAAC,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,KAAK,EAAE,EAAE,GAAG,OAAO,EAAE,CAAC,CAAC,CAAA;aAClE;iBAAM;gBACL,IAAI,CAAC,IAAI,CAAC,KAAK,KAAK,EAAE,EAAE,GAAG,KAAK,EAAE,CAAC,CAAA;aACpC;SACF;KACF;IACD,OAAO,IAAI,CAAA;AACb,CAAC;AAED,eAAe,WAAW,CAAA","sourcesContent":["import {errorHandler, registerCleanBugsnagErrorsFromWithinPlugins} from './error-handler.js'\nimport {loadEnvironment} from './environments.js'\nimport {isDevelopment} from './context/local.js'\nimport {addPublicMetadata} from './metadata.js'\nimport {AbortError} from './error.js'\nimport {renderInfo} from './ui.js'\nimport {JsonMap} from '../../private/common/json.js'\nimport {outputContent, outputInfo, outputToken} from '../../public/node/output.js'\nimport {hashString} from '../../public/node/crypto.js'\nimport {isTruthy} from '../../private/node/context/utilities.js'\nimport {Command} from '@oclif/core'\nimport {FlagOutput, Input, ParserOutput, FlagInput, ArgOutput} from '@oclif/core/lib/interfaces/parser.js'\n\ninterface EnvironmentFlags {\n environment?: string\n path?: string\n}\n\nabstract class BaseCommand extends Command {\n public static analyticsNameOverride(): string | undefined {\n return undefined\n }\n\n async catch(error: Error & {exitCode?: number | undefined}): Promise<void> {\n errorHandler(error, this.config)\n }\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n protected async init(): Promise<any> {\n this.exitWithTimestampWhenEnvVariablePresent()\n if (!isDevelopment()) {\n // This function runs just prior to `run`\n await registerCleanBugsnagErrorsFromWithinPlugins(this.config)\n }\n return super.init()\n }\n\n // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types\n protected exitWithTimestampWhenEnvVariablePresent() {\n if (isTruthy(process.env.SHOPIFY_CLI_ENV_STARTUP_PERFORMANCE_RUN)) {\n outputInfo(`\n SHOPIFY_CLI_TIMESTAMP_START\n { \"timestamp\": ${Date.now()} }\n SHOPIFY_CLI_TIMESTAMP_END\n `)\n process.exit(0)\n }\n }\n\n protected async parse<\n TFlags extends FlagOutput & {path?: string; verbose?: boolean},\n TGlobalFlags extends FlagOutput,\n TArgs extends ArgOutput,\n >(\n options?: Input<TFlags, TGlobalFlags, TArgs>,\n argv?: string[],\n ): Promise<ParserOutput<TFlags, TGlobalFlags, TArgs> & {argv: string[]}> {\n let result = await super.parse<TFlags, TGlobalFlags, TArgs>(options, argv)\n result = await this.resultWithEnvironment<TFlags, TGlobalFlags, TArgs>(result, options, argv)\n await addFromParsedFlags(result.flags)\n return {...result, ...{argv: result.argv as string[]}}\n }\n\n protected async resultWithEnvironment<\n TFlags extends FlagOutput & {path?: string; verbose?: boolean},\n TGlobalFlags extends FlagOutput,\n TArgs extends ArgOutput,\n >(\n originalResult: ParserOutput<TFlags, TGlobalFlags, TArgs>,\n options?: Input<TFlags, TGlobalFlags, TArgs>,\n argv?: string[],\n ): Promise<ParserOutput<TFlags, TGlobalFlags, TArgs>> {\n // If no environment is specified, don't modify the results\n const flags = originalResult.flags as EnvironmentFlags\n const environmentsFileName = this.environmentsFilename()\n if (!flags.environment || !environmentsFileName) return originalResult\n\n // If the specified environment isn't found, don't modify the results\n const environment = await loadEnvironment(flags.environment, environmentsFileName, {from: flags.path})\n if (!environment) return originalResult\n\n // Parse using noDefaultsOptions to derive a list of flags specified as\n // command-line arguments.\n const noDefaultsResult = await super.parse<TFlags, TGlobalFlags, TArgs>(noDefaultsOptions(options), argv)\n\n // Add the environment's settings to argv and pass them to `super.parse`. This\n // invokes oclif's validation system without breaking the oclif black box.\n // Replace the original result with this one.\n const result = await super.parse<TFlags, TGlobalFlags, TArgs>(options, [\n // Need to specify argv default because we're merging with argsFromEnvironment.\n ...(argv || this.argv),\n ...argsFromEnvironment<TFlags, TGlobalFlags, TArgs>(environment, options, noDefaultsResult),\n ])\n\n // Report successful application of the environment.\n reportEnvironmentApplication<TFlags, TGlobalFlags, TArgs>(\n noDefaultsResult.flags,\n result.flags,\n flags.environment,\n environment,\n )\n\n return result\n }\n\n protected environmentsFilename(): string | undefined {\n // To be re-implemented if needed\n return undefined\n }\n}\n\nexport async function addFromParsedFlags(flags: {path?: string; verbose?: boolean}): Promise<void> {\n await addPublicMetadata(() => ({\n cmd_all_verbose: flags.verbose,\n cmd_all_path_override: flags.path !== undefined,\n cmd_all_path_override_hash: flags.path === undefined ? undefined : hashString(flags.path),\n }))\n}\n\n/**\n * Any flag which is:\n *\n * 1. Present in the final set of flags\n * 2. Specified in the environment\n * 3. Not specified by the user as a command line argument\n *\n * should be reported.\n *\n * It doesn't matter if the environment flag's value was the same as the default; from\n * the user's perspective, they want to know their environment was applied.\n */\nfunction reportEnvironmentApplication<\n TFlags extends FlagOutput,\n TGlobalFlags extends FlagOutput,\n TArgs extends ArgOutput,\n>(\n noDefaultsFlags: ParserOutput<TFlags, TGlobalFlags, TArgs>['flags'],\n flagsWithEnvironments: ParserOutput<TFlags, TGlobalFlags, TArgs>['flags'],\n environmentName: string,\n environment: JsonMap,\n): void {\n const changes: JsonMap = {}\n for (const [name, value] of Object.entries(flagsWithEnvironments)) {\n const userSpecifiedThisFlag = Object.prototype.hasOwnProperty.call(noDefaultsFlags, name)\n const environmentContainsFlag = Object.prototype.hasOwnProperty.call(environment, name)\n if (!userSpecifiedThisFlag && environmentContainsFlag) {\n const valueToReport = name === 'password' ? `********${value.substr(-4)}` : value\n changes[name] = valueToReport\n }\n }\n if (Object.keys(changes).length === 0) return\n\n const items = Object.entries(changes).map(([name, value]) => `${name}: ${value}`)\n renderInfo({\n headline: ['Using applicable flags from', {userInput: environmentName}, 'environment:'],\n body: [{list: {items}}],\n })\n}\n\n/**\n * Strips the defaults from configured flags. For example, if flags contains:\n *\n * ```\n * someFlag: Flags.boolean({\n * description: 'some flag',\n * default: false\n * })\n * ```\n *\n * it becomes:\n *\n * ```\n * someFlag: Flags.boolean({\n * description: 'some flag'\n * })\n * ```\n *\n * If we parse using this configuration, the only specified flags will be those\n * the user actually passed on the command line.\n */\nfunction noDefaultsOptions<TFlags extends FlagOutput, TGlobalFlags extends FlagOutput, TArgs extends ArgOutput>(\n options: Input<TFlags, TGlobalFlags, TArgs> | undefined,\n): Input<TFlags, TGlobalFlags, TArgs> | undefined {\n if (!options?.flags) return options\n return {\n ...options,\n flags: Object.fromEntries(\n Object.entries(options.flags).map(([label, settings]) => {\n const copiedSettings = {...(settings as {default?: unknown})}\n delete copiedSettings.default\n return [label, copiedSettings]\n }),\n ) as FlagInput<TFlags>,\n }\n}\n\n/**\n * Converts the environment's settings to arguments as though passed on the command\n * line, skipping any arguments the user specified on the command line.\n */\nfunction argsFromEnvironment<TFlags extends FlagOutput, TGlobalFlags extends FlagOutput, TArgs extends ArgOutput>(\n environment: JsonMap,\n options: Input<TFlags, TGlobalFlags, TArgs> | undefined,\n noDefaultsResult: ParserOutput<TFlags, TArgs>,\n): string[] {\n const args: string[] = []\n for (const [label, value] of Object.entries(environment)) {\n const flagIsRelevantToCommand = options?.flags && Object.prototype.hasOwnProperty.call(options.flags, label)\n const userSpecifiedThisFlag =\n noDefaultsResult.flags && Object.prototype.hasOwnProperty.call(noDefaultsResult.flags, label)\n if (flagIsRelevantToCommand && !userSpecifiedThisFlag) {\n if (typeof value === 'boolean') {\n if (value === true) {\n args.push(`--${label}`)\n } else {\n throw new AbortError(\n outputContent`Environments can only specify true for boolean flags. Attempted to set ${outputToken.yellow(\n label,\n )} to false.`,\n )\n }\n } else if (Array.isArray(value)) {\n value.forEach((element) => args.push(`--${label}`, `${element}`))\n } else {\n args.push(`--${label}`, `${value}`)\n }\n }\n }\n return args\n}\n\nexport default BaseCommand\n"]}
@@ -77,13 +77,6 @@ export declare function useDeviceAuth(env?: NodeJS.ProcessEnv): boolean;
77
77
  * @returns True if SHOPIFY_NO_THEME_BUNDLING is truthy.
78
78
  */
79
79
  export declare function useThemebundling(env?: NodeJS.ProcessEnv): boolean;
80
- /**
81
- * Returns true if the CLI enable JavaScript functions.
82
- *
83
- * @param env - The environment variables from the environment of the current process.
84
- * @returns True if SHOPIFY_CLI_FUNCTIONS_JAVASCRIPT is truthy.
85
- */
86
- export declare function areJavaScriptFunctionsEnabled(env?: NodeJS.ProcessEnv): boolean;
87
80
  /**
88
81
  * Return gitpodURL if we are running in gitpod.
89
82
  * Https://www.gitpod.io/docs/environment-variables#default-environment-variables.
@@ -110,15 +110,6 @@ export function useDeviceAuth(env = process.env) {
110
110
  export function useThemebundling(env = process.env) {
111
111
  return isTruthy(env[environmentVariables.themeBundling]);
112
112
  }
113
- /**
114
- * Returns true if the CLI enable JavaScript functions.
115
- *
116
- * @param env - The environment variables from the environment of the current process.
117
- * @returns True if SHOPIFY_CLI_FUNCTIONS_JAVASCRIPT is truthy.
118
- */
119
- export function areJavaScriptFunctionsEnabled(env = process.env) {
120
- return isTruthy(env[environmentVariables.javascriptFunctions]);
121
- }
122
113
  /**
123
114
  * Return gitpodURL if we are running in gitpod.
124
115
  * Https://www.gitpod.io/docs/environment-variables#default-environment-variables.
@@ -1 +1 @@
1
- {"version":3,"file":"local.js","sourceRoot":"","sources":["../../../../src/public/node/context/local.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC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AAC,KAAK,EAAE,CAAC,WAAW,CAAC,CAAC,CAAA;QAChC,OAAO,IAAI,CAAA;QACX,qDAAqD;KACtD;IAAC,MAAM;QACN,OAAO,KAAK,CAAA;KACb;AACH,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,UAAU,CAAC,GAAG,GAAG,OAAO,CAAC,GAAG;IAC1C,IAAI,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE;QACpB,IAAI,IAAI,GAAG,SAAS,CAAA;QACpB,IAAI,QAAQ,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE;YAC1B,IAAI,GAAG,UAAU,CAAA;SAClB;aAAM,IAAI,KAAK,CAAC,GAAG,CAAC,aAAa,CAAC,EAAE;YACnC,IAAI,GAAG,QAAQ,CAAA;SAChB;aAAM,IAAI,QAAQ,CAAC,GAAG,CAAC,SAAS,CAAC,EAAE;YAClC,IAAI,GAAG,QAAQ,CAAA;SAChB;QAED,OAAO;YACL,IAAI,EAAE,IAAI;YACV,IAAI;SACL,CAAA;KACF;IACD,OAAO;QACL,IAAI,EAAE,KAAK;KACZ,CAAA;AACH,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,UAAU;IACxB,OAAO,UAAU,CAAC,GAAG,EAAE,CAAA;AACzB,CAAC","sourcesContent":["import {isSpin} from './spin.js'\nimport {isTruthy, isSet} from '../../../private/node/context/utilities.js'\nimport {environmentVariables, pathConstants} from '../../../private/node/constants.js'\nimport {fileExists} from '../fs.js'\nimport {exec} from '../system.js'\nimport isInteractive from 'is-interactive'\nimport macaddress from 'macaddress'\nimport {homedir} from 'os'\n\n/**\n * It returns true if the terminal is interactive.\n *\n * @returns True if the terminal is interactive.\n */\nexport function isTerminalInteractive(): boolean {\n return isInteractive()\n}\n\n/**\n * Returns the path to the user's home directory.\n *\n * @returns The path to the user's home directory.\n */\nexport function homeDirectory(): string {\n return homedir()\n}\n\n/**\n * Returns true if the CLI is running in debug mode.\n *\n * @param env - The environment variables from the environment of the current process.\n * @returns True if SHOPIFY_ENV is development.\n */\nexport function isDevelopment(env = process.env): boolean {\n return env[environmentVariables.env] === 'development'\n}\n\n/**\n * Returns true if the CLI is running in verbose mode.\n *\n * @param env - The environment variables from the environment of the current process.\n * @returns True if SHOPIFY_FLAG_VERBOSE is truthy or the flag --verbose has been passed.\n */\nexport function isVerbose(env = process.env): boolean {\n return isTruthy(env[environmentVariables.verbose]) || process.argv.includes('--verbose')\n}\n\n/**\n * Returns true if the environment in which the CLI is running is either\n * a local environment (where dev is present) or a cloud environment (spin).\n *\n * @param env - The environment variables from the environment of the current process.\n * @returns True if the CLI is used in a Shopify environment.\n */\nexport async function isShopify(env = process.env): Promise<boolean> {\n if (Object.prototype.hasOwnProperty.call(env, environmentVariables.runAsUser)) {\n return !isTruthy(env[environmentVariables.runAsUser])\n }\n const devInstalled = await fileExists(pathConstants.executables.dev)\n return devInstalled || isSpin(env)\n}\n\n/**\n * This variable is used when running unit tests to indicate that the CLI's business logic\n * is run as a subject of a unit test. We can use this variable to disable output through\n * the standard streams.\n *\n * @param env - The environment variables from the environment of the current process.\n * @returns True if the SHOPIFY_UNIT_TEST environment variable is truthy.\n */\nexport function isUnitTest(env = process.env): boolean {\n return isTruthy(env[environmentVariables.unitTest])\n}\n\n/**\n * Returns true if reporting analytics is enabled.\n *\n * @param env - The environment variables from the environment of the current process.\n * @returns True unless SHOPIFY_CLI_NO_ANALYTICS is truthy or debug mode is enabled.\n */\nexport function analyticsDisabled(env = process.env): boolean {\n return isTruthy(env[environmentVariables.noAnalytics]) || isDevelopment(env)\n}\n\n/**\n * Returns true if reporting analytics should always happen, regardless of DEBUG mode etc.\n *\n * @param env - The environment variables from the environment of the current process.\n * @returns True if SHOPIFY_CLI_ALWAYS_LOG_ANALYTICS is truthy.\n */\nexport function alwaysLogAnalytics(env = process.env): boolean {\n return isTruthy(env[environmentVariables.alwaysLogAnalytics])\n}\n\n/**\n * Returns true if the CLI User is 1P.\n *\n * @param env - The environment variables from the environment of the current process.\n * @returns True if SHOPIFY_CLI_1P is truthy.\n */\nexport function firstPartyDev(env = process.env): boolean {\n return isTruthy(env[environmentVariables.firstPartyDev])\n}\n\n/**\n * Returns true if the CLI should use device auth.\n *\n * @param env - The environment variables from the environment of the current process.\n * @returns True if SHOPIFY_CLI_DEVICE_AUTH is truthy or the CLI is run from a cloud environment.\n */\nexport function useDeviceAuth(env = process.env): boolean {\n return isTruthy(env[environmentVariables.deviceAuth]) || isCloudEnvironment(env)\n}\n\n/**\n * Returns true if the CLI should use theme bundling.\n *\n * @param env - The environment variables from the environment of the current process.\n * @returns True if SHOPIFY_NO_THEME_BUNDLING is truthy.\n */\nexport function useThemebundling(env = process.env): boolean {\n return isTruthy(env[environmentVariables.themeBundling])\n}\n\n/**\n * Returns true if the CLI enable JavaScript functions.\n *\n * @param env - The environment variables from the environment of the current process.\n * @returns True if SHOPIFY_CLI_FUNCTIONS_JAVASCRIPT is truthy.\n */\nexport function areJavaScriptFunctionsEnabled(env = process.env): boolean {\n return isTruthy(env[environmentVariables.javascriptFunctions])\n}\n\n/**\n * Return gitpodURL if we are running in gitpod.\n * Https://www.gitpod.io/docs/environment-variables#default-environment-variables.\n *\n * @param env - The environment variables from the environment of the current process.\n * @returns The gitpod URL.\n */\nexport function gitpodURL(env = process.env): string | undefined {\n return env[environmentVariables.gitpod]\n}\n\n/**\n * Return codespaceURL if we are running in codespaces.\n * Https://docs.github.com/en/codespaces/developing-in-codespaces/default-environment-variables-for-your-codespace#list-of-default-environment-variables.\n *\n * @param env - The environment variables from the environment of the current process.\n * @returns The codespace URL.\n */\nexport function codespaceURL(env = process.env): string | undefined {\n return env[environmentVariables.codespaceName]\n}\n\n/**\n * Checks if the CLI is run from a cloud environment.\n *\n * @param env - Environment variables used when the cli is launched.\n * @returns True in case the CLI is run from a cloud environment.\n */\nexport function isCloudEnvironment(env: NodeJS.ProcessEnv = process.env): boolean {\n return cloudEnvironment(env).platform !== 'localhost'\n}\n\n/**\n * Returns the cloud environment platform name and if the platform support online IDE in case the CLI is run from one of\n * them. Platform name 'localhost' is returned otherwise.\n *\n * @param env - Environment variables used when the cli is launched.\n * @returns Cloud platform information.\n */\nexport function cloudEnvironment(env: NodeJS.ProcessEnv = process.env): {\n platform: 'spin' | 'codespaces' | 'gitpod' | 'localhost'\n editor: boolean\n} {\n if (isSet(env[environmentVariables.codespaces])) {\n return {platform: 'codespaces', editor: true}\n }\n if (isSet(env[environmentVariables.gitpod])) {\n return {platform: 'gitpod', editor: true}\n }\n if (isSpin(env)) {\n return {platform: 'spin', editor: false}\n }\n return {platform: 'localhost', editor: false}\n}\n\n/**\n * Returns whether the environment has Git available.\n *\n * @returns A promise that resolves with the value.\n */\nexport async function hasGit(): Promise<boolean> {\n try {\n await exec('git', ['--version'])\n return true\n // eslint-disable-next-line no-catch-all/no-catch-all\n } catch {\n return false\n }\n}\n\n/**\n * Gets info on the CI platform the CLI is running on, if applicable.\n *\n * @param env - The environment variables from the environment of the current process.\n * @returns The CI platform info.\n */\nexport function ciPlatform(env = process.env): {isCI: true; name: string} | {isCI: false; name?: undefined} {\n if (isTruthy(env.CI)) {\n let name = 'unknown'\n if (isTruthy(env.CIRCLECI)) {\n name = 'circleci'\n } else if (isSet(env.GITHUB_ACTION)) {\n name = 'github'\n } else if (isTruthy(env.GITLAB_CI)) {\n name = 'gitlab'\n }\n\n return {\n isCI: true,\n name,\n }\n }\n return {\n isCI: false,\n }\n}\n\n/**\n * Returns the first mac address found.\n *\n * @returns Mac address.\n */\nexport function macAddress(): Promise<string> {\n return macaddress.one()\n}\n"]}
1
+ {"version":3,"file":"local.js","sourceRoot":"","sources":["../../../../src/public/node/context/local.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,MAAM,EAAC,MAAM,WAAW,CAAA;AAChC,OAAO,EAAC,QAAQ,EAAE,KAAK,EAAC,MAAM,4CAA4C,CAAA;AAC1E,OAAO,EAAC,oBAAoB,EAAE,aAAa,EAAC,MAAM,oCAAoC,CAAA;AACtF,OAAO,EAAC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AAQ,CAAC,EAAE;YAC1B,IAAI,GAAG,UAAU,CAAA;SAClB;aAAM,IAAI,KAAK,CAAC,GAAG,CAAC,aAAa,CAAC,EAAE;YACnC,IAAI,GAAG,QAAQ,CAAA;SAChB;aAAM,IAAI,QAAQ,CAAC,GAAG,CAAC,SAAS,CAAC,EAAE;YAClC,IAAI,GAAG,QAAQ,CAAA;SAChB;QAED,OAAO;YACL,IAAI,EAAE,IAAI;YACV,IAAI;SACL,CAAA;KACF;IACD,OAAO;QACL,IAAI,EAAE,KAAK;KACZ,CAAA;AACH,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,UAAU;IACxB,OAAO,UAAU,CAAC,GAAG,EAAE,CAAA;AACzB,CAAC","sourcesContent":["import {isSpin} from './spin.js'\nimport {isTruthy, isSet} from '../../../private/node/context/utilities.js'\nimport {environmentVariables, pathConstants} from '../../../private/node/constants.js'\nimport {fileExists} from '../fs.js'\nimport {exec} from '../system.js'\nimport isInteractive from 'is-interactive'\nimport macaddress from 'macaddress'\nimport {homedir} from 'os'\n\n/**\n * It returns true if the terminal is interactive.\n *\n * @returns True if the terminal is interactive.\n */\nexport function isTerminalInteractive(): boolean {\n return isInteractive()\n}\n\n/**\n * Returns the path to the user's home directory.\n *\n * @returns The path to the user's home directory.\n */\nexport function homeDirectory(): string {\n return homedir()\n}\n\n/**\n * Returns true if the CLI is running in debug mode.\n *\n * @param env - The environment variables from the environment of the current process.\n * @returns True if SHOPIFY_ENV is development.\n */\nexport function isDevelopment(env = process.env): boolean {\n return env[environmentVariables.env] === 'development'\n}\n\n/**\n * Returns true if the CLI is running in verbose mode.\n *\n * @param env - The environment variables from the environment of the current process.\n * @returns True if SHOPIFY_FLAG_VERBOSE is truthy or the flag --verbose has been passed.\n */\nexport function isVerbose(env = process.env): boolean {\n return isTruthy(env[environmentVariables.verbose]) || process.argv.includes('--verbose')\n}\n\n/**\n * Returns true if the environment in which the CLI is running is either\n * a local environment (where dev is present) or a cloud environment (spin).\n *\n * @param env - The environment variables from the environment of the current process.\n * @returns True if the CLI is used in a Shopify environment.\n */\nexport async function isShopify(env = process.env): Promise<boolean> {\n if (Object.prototype.hasOwnProperty.call(env, environmentVariables.runAsUser)) {\n return !isTruthy(env[environmentVariables.runAsUser])\n }\n const devInstalled = await fileExists(pathConstants.executables.dev)\n return devInstalled || isSpin(env)\n}\n\n/**\n * This variable is used when running unit tests to indicate that the CLI's business logic\n * is run as a subject of a unit test. We can use this variable to disable output through\n * the standard streams.\n *\n * @param env - The environment variables from the environment of the current process.\n * @returns True if the SHOPIFY_UNIT_TEST environment variable is truthy.\n */\nexport function isUnitTest(env = process.env): boolean {\n return isTruthy(env[environmentVariables.unitTest])\n}\n\n/**\n * Returns true if reporting analytics is enabled.\n *\n * @param env - The environment variables from the environment of the current process.\n * @returns True unless SHOPIFY_CLI_NO_ANALYTICS is truthy or debug mode is enabled.\n */\nexport function analyticsDisabled(env = process.env): boolean {\n return isTruthy(env[environmentVariables.noAnalytics]) || isDevelopment(env)\n}\n\n/**\n * Returns true if reporting analytics should always happen, regardless of DEBUG mode etc.\n *\n * @param env - The environment variables from the environment of the current process.\n * @returns True if SHOPIFY_CLI_ALWAYS_LOG_ANALYTICS is truthy.\n */\nexport function alwaysLogAnalytics(env = process.env): boolean {\n return isTruthy(env[environmentVariables.alwaysLogAnalytics])\n}\n\n/**\n * Returns true if the CLI User is 1P.\n *\n * @param env - The environment variables from the environment of the current process.\n * @returns True if SHOPIFY_CLI_1P is truthy.\n */\nexport function firstPartyDev(env = process.env): boolean {\n return isTruthy(env[environmentVariables.firstPartyDev])\n}\n\n/**\n * Returns true if the CLI should use device auth.\n *\n * @param env - The environment variables from the environment of the current process.\n * @returns True if SHOPIFY_CLI_DEVICE_AUTH is truthy or the CLI is run from a cloud environment.\n */\nexport function useDeviceAuth(env = process.env): boolean {\n return isTruthy(env[environmentVariables.deviceAuth]) || isCloudEnvironment(env)\n}\n\n/**\n * Returns true if the CLI should use theme bundling.\n *\n * @param env - The environment variables from the environment of the current process.\n * @returns True if SHOPIFY_NO_THEME_BUNDLING is truthy.\n */\nexport function useThemebundling(env = process.env): boolean {\n return isTruthy(env[environmentVariables.themeBundling])\n}\n\n/**\n * Return gitpodURL if we are running in gitpod.\n * Https://www.gitpod.io/docs/environment-variables#default-environment-variables.\n *\n * @param env - The environment variables from the environment of the current process.\n * @returns The gitpod URL.\n */\nexport function gitpodURL(env = process.env): string | undefined {\n return env[environmentVariables.gitpod]\n}\n\n/**\n * Return codespaceURL if we are running in codespaces.\n * Https://docs.github.com/en/codespaces/developing-in-codespaces/default-environment-variables-for-your-codespace#list-of-default-environment-variables.\n *\n * @param env - The environment variables from the environment of the current process.\n * @returns The codespace URL.\n */\nexport function codespaceURL(env = process.env): string | undefined {\n return env[environmentVariables.codespaceName]\n}\n\n/**\n * Checks if the CLI is run from a cloud environment.\n *\n * @param env - Environment variables used when the cli is launched.\n * @returns True in case the CLI is run from a cloud environment.\n */\nexport function isCloudEnvironment(env: NodeJS.ProcessEnv = process.env): boolean {\n return cloudEnvironment(env).platform !== 'localhost'\n}\n\n/**\n * Returns the cloud environment platform name and if the platform support online IDE in case the CLI is run from one of\n * them. Platform name 'localhost' is returned otherwise.\n *\n * @param env - Environment variables used when the cli is launched.\n * @returns Cloud platform information.\n */\nexport function cloudEnvironment(env: NodeJS.ProcessEnv = process.env): {\n platform: 'spin' | 'codespaces' | 'gitpod' | 'localhost'\n editor: boolean\n} {\n if (isSet(env[environmentVariables.codespaces])) {\n return {platform: 'codespaces', editor: true}\n }\n if (isSet(env[environmentVariables.gitpod])) {\n return {platform: 'gitpod', editor: true}\n }\n if (isSpin(env)) {\n return {platform: 'spin', editor: false}\n }\n return {platform: 'localhost', editor: false}\n}\n\n/**\n * Returns whether the environment has Git available.\n *\n * @returns A promise that resolves with the value.\n */\nexport async function hasGit(): Promise<boolean> {\n try {\n await exec('git', ['--version'])\n return true\n // eslint-disable-next-line no-catch-all/no-catch-all\n } catch {\n return false\n }\n}\n\n/**\n * Gets info on the CI platform the CLI is running on, if applicable.\n *\n * @param env - The environment variables from the environment of the current process.\n * @returns The CI platform info.\n */\nexport function ciPlatform(env = process.env): {isCI: true; name: string} | {isCI: false; name?: undefined} {\n if (isTruthy(env.CI)) {\n let name = 'unknown'\n if (isTruthy(env.CIRCLECI)) {\n name = 'circleci'\n } else if (isSet(env.GITHUB_ACTION)) {\n name = 'github'\n } else if (isTruthy(env.GITLAB_CI)) {\n name = 'gitlab'\n }\n\n return {\n isCI: true,\n name,\n }\n }\n return {\n isCI: false,\n }\n}\n\n/**\n * Returns the first mac address found.\n *\n * @returns Mac address.\n */\nexport function macAddress(): Promise<string> {\n return macaddress.one()\n}\n"]}
@@ -1,15 +1,14 @@
1
1
  import { JsonMap } from '../../private/common/json.js';
2
- export declare const environmentsFilename = "shopify.environments.toml";
3
2
  export interface Environments {
4
3
  [name: string]: JsonMap;
5
4
  }
5
+ interface LoadEnvironmentOptions {
6
+ from?: string;
7
+ }
6
8
  /**
7
- * Loads environments from a directory.
8
- * @param dir - The directory to load environments from.
9
- * @param opts - Options for loading environments, including:
10
- * - findUp: whether to search upwards for an environments file.
9
+ * Loads environments from a file.
10
+ * @param dir - The file path to load environments from.
11
11
  * @returns The loaded environments.
12
12
  */
13
- export declare function loadEnvironmentsFromDirectory(dir: string, opts?: {
14
- findUp: boolean;
15
- }): Promise<Environments>;
13
+ export declare function loadEnvironment(environmentName: string, fileName: string, options?: LoadEnvironmentOptions): Promise<JsonMap | undefined>;
14
+ export {};
@@ -1,33 +1,31 @@
1
1
  import { decodeToml } from './toml.js';
2
- import { fileExists, readFile, findPathUp } from './fs.js';
3
- import { joinPath } from './path.js';
4
- export const environmentsFilename = 'shopify.environments.toml';
2
+ import { findPathUp, readFile } from './fs.js';
3
+ import { outputWarn } from './output.js';
4
+ import { cwd } from './path.js';
5
5
  /**
6
- * Loads environments from a directory.
7
- * @param dir - The directory to load environments from.
8
- * @param opts - Options for loading environments, including:
9
- * - findUp: whether to search upwards for an environments file.
6
+ * Loads environments from a file.
7
+ * @param dir - The file path to load environments from.
10
8
  * @returns The loaded environments.
11
9
  */
12
- export async function loadEnvironmentsFromDirectory(dir, opts) {
13
- let environmentsFilePath;
14
- if (opts?.findUp) {
15
- environmentsFilePath = await findPathUp(environmentsFilename, {
16
- cwd: dir,
17
- type: 'file',
18
- });
10
+ export async function loadEnvironment(environmentName, fileName, options) {
11
+ const basePath = options?.from && options?.from !== '.' ? options.from : cwd();
12
+ const filePath = await findPathUp(fileName, {
13
+ cwd: basePath,
14
+ type: 'file',
15
+ });
16
+ if (!filePath) {
17
+ outputWarn(`Environment file not found`);
18
+ return undefined;
19
19
  }
20
- else {
21
- const allowedEnvironmentsFilePath = joinPath(dir, environmentsFilename);
22
- if (await fileExists(allowedEnvironmentsFilePath)) {
23
- environmentsFilePath = allowedEnvironmentsFilePath;
24
- }
25
- }
26
- if (environmentsFilePath) {
27
- return decodeToml(await readFile(environmentsFilePath));
28
- }
29
- else {
30
- return {};
20
+ const environmentsJson = decodeToml(await readFile(filePath));
21
+ const environments = environmentsJson.environments;
22
+ if (!environments) {
23
+ outputWarn(`No environments found in ${filePath}`);
24
+ return undefined;
31
25
  }
26
+ const environment = environments[environmentName];
27
+ if (!environment)
28
+ outputWarn(`Environment ${environmentName} not found`);
29
+ return environment;
32
30
  }
33
31
  //# sourceMappingURL=environments.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"environments.js","sourceRoot":"","sources":["../../../src/public/node/environments.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAC,MAAM,WAAW,CAAA;AACpC,OAAO,EAAC,UAAU,EAAE,QAAQ,EAAE,UAAU,EAAC,MAAM,SAAS,CAAA;AACxD,OAAO,EAAC,QAAQ,EAAC,MAAM,WAAW,CAAA;AAGlC,MAAM,CAAC,MAAM,oBAAoB,GAAG,2BAA2B,CAAA;AAK/D;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,6BAA6B,CAAC,GAAW,EAAE,IAAwB;IACvF,IAAI,oBAAwC,CAAA;IAC5C,IAAI,IAAI,EAAE,MAAM,EAAE;QAChB,oBAAoB,GAAG,MAAM,UAAU,CAAC,oBAAoB,EAAE;YAC5D,GAAG,EAAE,GAAG;YACR,IAAI,EAAE,MAAM;SACb,CAAC,CAAA;KACH;SAAM;QACL,MAAM,2BAA2B,GAAG,QAAQ,CAAC,GAAG,EAAE,oBAAoB,CAAC,CAAA;QACvE,IAAI,MAAM,UAAU,CAAC,2BAA2B,CAAC,EAAE;YACjD,oBAAoB,GAAG,2BAA2B,CAAA;SACnD;KACF;IACD,IAAI,oBAAoB,EAAE;QACxB,OAAO,UAAU,CAAC,MAAM,QAAQ,CAAC,oBAAoB,CAAC,CAAiB,CAAA;KACxE;SAAM;QACL,OAAO,EAAE,CAAA;KACV;AACH,CAAC","sourcesContent":["import {decodeToml} from './toml.js'\nimport {fileExists, readFile, findPathUp} from './fs.js'\nimport {joinPath} from './path.js'\nimport {JsonMap} from '../../private/common/json.js'\n\nexport const environmentsFilename = 'shopify.environments.toml'\n\nexport interface Environments {\n [name: string]: JsonMap\n}\n/**\n * Loads environments from a directory.\n * @param dir - The directory to load environments from.\n * @param opts - Options for loading environments, including:\n * - findUp: whether to search upwards for an environments file.\n * @returns The loaded environments.\n */\nexport async function loadEnvironmentsFromDirectory(dir: string, opts?: {findUp: boolean}): Promise<Environments> {\n let environmentsFilePath: string | undefined\n if (opts?.findUp) {\n environmentsFilePath = await findPathUp(environmentsFilename, {\n cwd: dir,\n type: 'file',\n })\n } else {\n const allowedEnvironmentsFilePath = joinPath(dir, environmentsFilename)\n if (await fileExists(allowedEnvironmentsFilePath)) {\n environmentsFilePath = allowedEnvironmentsFilePath\n }\n }\n if (environmentsFilePath) {\n return decodeToml(await readFile(environmentsFilePath)) as Environments\n } else {\n return {}\n }\n}\n"]}
1
+ {"version":3,"file":"environments.js","sourceRoot":"","sources":["../../../src/public/node/environments.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAC,MAAM,WAAW,CAAA;AACpC,OAAO,EAAC,UAAU,EAAE,QAAQ,EAAC,MAAM,SAAS,CAAA;AAC5C,OAAO,EAAC,UAAU,EAAC,MAAM,aAAa,CAAA;AACtC,OAAO,EAAC,GAAG,EAAC,MAAM,WAAW,CAAA;AAU7B;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,eAAe,CACnC,eAAuB,EACvB,QAAgB,EAChB,OAAgC;IAEhC,MAAM,QAAQ,GAAG,OAAO,EAAE,IAAI,IAAI,OAAO,EAAE,IAAI,KAAK,GAAG,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,EAAE,CAAA;IAC9E,MAAM,QAAQ,GAAG,MAAM,UAAU,CAAC,QAAQ,EAAE;QAC1C,GAAG,EAAE,QAAQ;QACb,IAAI,EAAE,MAAM;KACb,CAAC,CAAA;IACF,IAAI,CAAC,QAAQ,EAAE;QACb,UAAU,CAAC,4BAA4B,CAAC,CAAA;QACxC,OAAO,SAAS,CAAA;KACjB;IACD,MAAM,gBAAgB,GAAG,UAAU,CAAC,MAAM,QAAQ,CAAC,QAAQ,CAAC,CAAiB,CAAA;IAC7E,MAAM,YAAY,GAAG,gBAAgB,CAAC,YAAY,CAAA;IAClD,IAAI,CAAC,YAAY,EAAE;QACjB,UAAU,CAAC,4BAA4B,QAAQ,EAAE,CAAC,CAAA;QAClD,OAAO,SAAS,CAAA;KACjB;IACD,MAAM,WAAW,GAAG,YAAY,CAAC,eAAe,CAAY,CAAA;IAC5D,IAAI,CAAC,WAAW;QAAE,UAAU,CAAC,eAAe,eAAe,YAAY,CAAC,CAAA;IACxE,OAAO,WAAW,CAAA;AACpB,CAAC","sourcesContent":["import {decodeToml} from './toml.js'\nimport {findPathUp, readFile} from './fs.js'\nimport {outputWarn} from './output.js'\nimport {cwd} from './path.js'\nimport {JsonMap} from '../../private/common/json.js'\n\nexport interface Environments {\n [name: string]: JsonMap\n}\n\ninterface LoadEnvironmentOptions {\n from?: string\n}\n/**\n * Loads environments from a file.\n * @param dir - The file path to load environments from.\n * @returns The loaded environments.\n */\nexport async function loadEnvironment(\n environmentName: string,\n fileName: string,\n options?: LoadEnvironmentOptions,\n): Promise<JsonMap | undefined> {\n const basePath = options?.from && options?.from !== '.' ? options.from : cwd()\n const filePath = await findPathUp(fileName, {\n cwd: basePath,\n type: 'file',\n })\n if (!filePath) {\n outputWarn(`Environment file not found`)\n return undefined\n }\n const environmentsJson = decodeToml(await readFile(filePath)) as Environments\n const environments = environmentsJson.environments\n if (!environments) {\n outputWarn(`No environments found in ${filePath}`)\n return undefined\n }\n const environment = environments[environmentName] as JsonMap\n if (!environment) outputWarn(`Environment ${environmentName} not found`)\n return environment\n}\n"]}
@@ -25,7 +25,7 @@ export type DependencyType = 'dev' | 'prod' | 'peer';
25
25
  * A union that represents the package managers available.
26
26
  */
27
27
  export declare const packageManager: readonly ["yarn", "npm", "pnpm"];
28
- export type PackageManager = typeof packageManager[number];
28
+ export type PackageManager = (typeof packageManager)[number];
29
29
  /**
30
30
  * Returns an abort error that's thrown when a directory that's expected to have
31
31
  * a package.json doesn't have it.