@shopify/cli-kit 3.20.1 → 3.21.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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,16 @@
1
1
  # @shopify/cli-kit
2
2
 
3
+ ## 3.21.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 5cda6300: Enable external access to cli inside a spin instance
8
+
9
+ ### Patch Changes
10
+
11
+ - e4352f2e: Do not report handled tunnel plugin errors to Bugsnag
12
+ - c906187f: Add backticks surrounding command tokens
13
+
3
14
  ## 3.20.1
4
15
 
5
16
  ### Patch Changes
@@ -1,4 +1,11 @@
1
+ import { Result } from '../public/common/result.js';
1
2
  import { FanoutHookFunction, PluginReturnsForHook } from '../plugins.js';
3
+ import { ExtendableError } from '../error.js';
4
+ export declare type TunnelErrorType = 'invalid-provider' | 'tunnel-already-running' | 'wrong-credentials' | 'unknown';
5
+ export declare class TunnelError extends ExtendableError {
6
+ type: TunnelErrorType;
7
+ constructor(type: TunnelErrorType, message?: string);
8
+ }
2
9
  /**
3
10
  * Tunnel Plugins types
4
11
  *
@@ -11,9 +18,9 @@ export interface HookReturnPerTunnelPlugin {
11
18
  provider: string;
12
19
  };
13
20
  pluginReturns: {
14
- [pluginName: string]: {
15
- url: string | undefined;
16
- };
21
+ [pluginName: string]: Result<{
22
+ url: string;
23
+ }, TunnelError>;
17
24
  };
18
25
  };
19
26
  tunnel_provider: {
@@ -1,10 +1,18 @@
1
+ import { err } from '../public/common/result.js';
2
+ import { ExtendableError } from '../error.js';
3
+ export class TunnelError extends ExtendableError {
4
+ constructor(type, message) {
5
+ super(message);
6
+ this.type = type;
7
+ }
8
+ }
1
9
  export const defineProvider = (input) => {
2
10
  return async () => input;
3
11
  };
4
12
  export const startTunnel = (options) => {
5
13
  return async (inputs) => {
6
14
  if (inputs.provider !== options.provider)
7
- return { url: undefined };
15
+ return err(new TunnelError('invalid-provider'));
8
16
  return options.action(inputs.port);
9
17
  };
10
18
  };
@@ -1 +1 @@
1
- {"version":3,"file":"tunnel.js","sourceRoot":"","sources":["../../src/plugins/tunnel.ts"],"names":[],"mappings":"AA2BA,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,KAAqB,EAA0B,EAAE;IAC9E,OAAO,KAAK,IAAI,EAAE,CAAC,KAAK,CAAA;AAC1B,CAAC,CAAA;AACD,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,OAAsD,EAAuB,EAAE;IACzG,OAAO,KAAK,EAAE,MAAwC,EAA8B,EAAE;QACpF,IAAI,MAAM,CAAC,QAAQ,KAAK,OAAO,CAAC,QAAQ;YAAE,OAAO,EAAC,GAAG,EAAE,SAAS,EAAC,CAAA;QACjE,OAAO,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAA;IACpC,CAAC,CAAA;AACH,CAAC,CAAA","sourcesContent":["import {FanoutHookFunction, PluginReturnsForHook} from '../plugins.js'\n\n/**\n * Tunnel Plugins types\n *\n * Any plugin that provides tunnel functionality should implement `defineProvider`and `startTunnel`\n */\nexport interface HookReturnPerTunnelPlugin {\n tunnel_start: {\n options: {port: number; provider: string}\n pluginReturns: {\n [pluginName: string]: {url: string | undefined}\n }\n }\n tunnel_provider: {\n options: {[key: string]: never}\n pluginReturns: {\n [pluginName: string]: {name: string}\n }\n }\n}\n\nexport type TunnelProviderFunction = FanoutHookFunction<'tunnel_provider', ''>\nexport type TunnelStartFunction = FanoutHookFunction<'tunnel_start', ''>\nexport type TunnelStartReturn = PluginReturnsForHook<'tunnel_start', ''>\nexport type TunnelStartAction = (port: number) => Promise<TunnelStartReturn>\n\nexport const defineProvider = (input: {name: string}): TunnelProviderFunction => {\n return async () => input\n}\nexport const startTunnel = (options: {provider: string; action: TunnelStartAction}): TunnelStartFunction => {\n return async (inputs: {provider: string; port: number}): Promise<TunnelStartReturn> => {\n if (inputs.provider !== options.provider) return {url: undefined}\n return options.action(inputs.port)\n }\n}\n"]}
1
+ {"version":3,"file":"tunnel.js","sourceRoot":"","sources":["../../src/plugins/tunnel.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,GAAG,EAAS,MAAM,4BAA4B,CAAA;AAEtD,OAAO,EAAC,eAAe,EAAC,MAAM,aAAa,CAAA;AAG3C,MAAM,OAAO,WAAY,SAAQ,eAAe;IAE9C,YAAY,IAAqB,EAAE,OAAgB;QACjD,KAAK,CAAC,OAAO,CAAC,CAAA;QACd,IAAI,CAAC,IAAI,GAAG,IAAI,CAAA;IAClB,CAAC;CACF;AA2BD,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,KAAqB,EAA0B,EAAE;IAC9E,OAAO,KAAK,IAAI,EAAE,CAAC,KAAK,CAAA;AAC1B,CAAC,CAAA;AACD,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,OAAsD,EAAuB,EAAE;IACzG,OAAO,KAAK,EAAE,MAAwC,EAA8B,EAAE;QACpF,IAAI,MAAM,CAAC,QAAQ,KAAK,OAAO,CAAC,QAAQ;YAAE,OAAO,GAAG,CAAC,IAAI,WAAW,CAAC,kBAAkB,CAAC,CAAC,CAAA;QACzF,OAAO,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAA;IACpC,CAAC,CAAA;AACH,CAAC,CAAA","sourcesContent":["import {err, Result} from '../public/common/result.js'\nimport {FanoutHookFunction, PluginReturnsForHook} from '../plugins.js'\nimport {ExtendableError} from '../error.js'\n\nexport type TunnelErrorType = 'invalid-provider' | 'tunnel-already-running' | 'wrong-credentials' | 'unknown'\nexport class TunnelError extends ExtendableError {\n type: TunnelErrorType\n constructor(type: TunnelErrorType, message?: string) {\n super(message)\n this.type = type\n }\n}\n\n/**\n * Tunnel Plugins types\n *\n * Any plugin that provides tunnel functionality should implement `defineProvider`and `startTunnel`\n */\nexport interface HookReturnPerTunnelPlugin {\n tunnel_start: {\n options: {port: number; provider: string}\n pluginReturns: {\n [pluginName: string]: Result<{url: string}, TunnelError>\n }\n }\n tunnel_provider: {\n options: {[key: string]: never}\n pluginReturns: {\n [pluginName: string]: {name: string}\n }\n }\n}\n\nexport type TunnelProviderFunction = FanoutHookFunction<'tunnel_provider', ''>\nexport type TunnelStartFunction = FanoutHookFunction<'tunnel_start', ''>\nexport type TunnelStartReturn = PluginReturnsForHook<'tunnel_start', ''>\nexport type TunnelStartAction = (port: number) => Promise<TunnelStartReturn>\n\nexport const defineProvider = (input: {name: string}): TunnelProviderFunction => {\n return async () => input\n}\nexport const startTunnel = (options: {provider: string; action: TunnelStartAction}): TunnelStartFunction => {\n return async (inputs: {provider: string; port: number}): Promise<TunnelStartReturn> => {\n if (inputs.provider !== options.provider) return err(new TunnelError('invalid-provider'))\n return options.action(inputs.port)\n }\n}\n"]}
package/dist/plugins.d.ts CHANGED
@@ -2,6 +2,7 @@ import { JsonMap } from './json.js';
2
2
  import { PickByPrefix } from './typing/pick-by-prefix.js';
3
3
  import { MonorailEventPublic, MonorailEventSensitive } from './monorail.js';
4
4
  import { HookReturnPerTunnelPlugin } from './plugins/tunnel.js';
5
+ import { Result } from './public/common/result.js';
5
6
  import { Config, Interfaces } from '@oclif/core';
6
7
  /**
7
8
  * Convenience function to trigger a hook, and gather any successful responses. Failures are ignored.
@@ -35,7 +36,7 @@ interface HookReturnsPerPlugin extends HookReturnPerTunnelPlugin {
35
36
  [key: string]: unknown;
36
37
  };
37
38
  pluginReturns: {
38
- [key: string]: JsonMap;
39
+ [key: string]: JsonMap | Result<JsonMap, Error>;
39
40
  };
40
41
  };
41
42
  }
@@ -54,6 +55,11 @@ export declare function getListOfTunnelPlugins(config: Config): Promise<{
54
55
  plugins: string[];
55
56
  error?: string;
56
57
  }>;
58
+ export interface TunnelPluginError {
59
+ provider: string;
60
+ type: 'multiple-urls' | 'handled-error' | 'unknown' | 'no-provider';
61
+ message?: string;
62
+ }
57
63
  /**
58
64
  * Execute the 'tunnel_start' hook for the given provider.
59
65
  * Fails if there aren't plugins for that provider or if there are more than one.
@@ -63,8 +69,5 @@ export declare function getListOfTunnelPlugins(config: Config): Promise<{
63
69
  * @param provider - selected provider, must be unique
64
70
  * @returns tunnel URL from the selected provider
65
71
  */
66
- export declare function runTunnelPlugin(config: Config, port: number, provider: string): Promise<{
67
- url?: string;
68
- error?: string;
69
- }>;
72
+ export declare function runTunnelPlugin(config: Config, port: number, provider: string): Promise<Result<string, TunnelPluginError>>;
70
73
  export {};
package/dist/plugins.js CHANGED
@@ -1,4 +1,5 @@
1
1
  import { getArrayContainsDuplicates, getArrayRejectingUndefined } from './public/common/array.js';
2
+ import { err } from './public/common/result.js';
2
3
  /**
3
4
  * Convenience function to trigger a hook, and gather any successful responses. Failures are ignored.
4
5
  *
@@ -34,11 +35,15 @@ export async function getListOfTunnelPlugins(config) {
34
35
  */
35
36
  export async function runTunnelPlugin(config, port, provider) {
36
37
  const hooks = await fanoutHooks(config, 'tunnel_start', { port, provider });
37
- const urls = getArrayRejectingUndefined(Object.values(hooks).map((key) => key?.url));
38
- if (urls.length > 1)
39
- return { error: 'multiple-urls' };
40
- if (urls.length === 0)
41
- return { error: 'no-urls' };
42
- return { url: urls[0] };
38
+ const urlResults = Object.values(hooks).filter((tunnelResponse) => !tunnelResponse?.isErr() || tunnelResponse.error.type !== 'invalid-provider');
39
+ if (urlResults.length > 1)
40
+ return err({ provider, type: 'multiple-urls' });
41
+ if (urlResults.length === 0 || !urlResults[0])
42
+ return err({ provider, type: 'no-provider' });
43
+ return urlResults[0]
44
+ .map((data) => data.url)
45
+ .mapError((error) => error.type === 'unknown'
46
+ ? { provider, type: 'unknown', message: error.message }
47
+ : { provider, type: 'handled-error' });
43
48
  }
44
49
  //# sourceMappingURL=plugins.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"plugins.js","sourceRoot":"","sources":["../src/plugins.ts"],"names":[],"mappings":"AAIA,OAAO,EAAC,0BAA0B,EAAE,0BAA0B,EAAC,MAAM,0BAA0B,CAAA;AAG/F;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,WAAW,CAC/B,MAAyB,EACzB,KAAa,EACb,OAA4C,EAC5C,OAAgB;IAEhB,MAAM,GAAG,GAAG,MAAM,MAAM,CAAC,OAAO,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,CAAC,CAAA;IACzD,8DAA8D;IAC9D,OAAO,MAAM,CAAC,WAAW,CAAC,GAAG,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,EAAC,MAAM,EAAE,MAAM,EAAC,EAAE,EAAE,CAAC,CAAC,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,CAAQ,CAAA;AAClG,CAAC;AA4CD;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,sBAAsB,CAAC,MAAc;IACzD,MAAM,KAAK,GAAG,MAAM,WAAW,CAAC,MAAM,EAAE,iBAAiB,EAAE,EAAE,CAAC,CAAA;IAC9D,MAAM,KAAK,GAAG,0BAA0B,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC,CAAA;IACtF,IAAI,0BAA0B,CAAC,KAAK,CAAC;QAAE,OAAO,EAAC,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,+BAA+B,EAAC,CAAA;IACtG,OAAO,EAAC,OAAO,EAAE,KAAK,EAAC,CAAA;AACzB,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,CAAC,KAAK,UAAU,eAAe,CACnC,MAAc,EACd,IAAY,EACZ,QAAgB;IAEhB,MAAM,KAAK,GAAG,MAAM,WAAW,CAAC,MAAM,EAAE,cAAc,EAAE,EAAC,IAAI,EAAE,QAAQ,EAAC,CAAC,CAAA;IACzE,MAAM,IAAI,GAAG,0BAA0B,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC,CAAA;IACpF,IAAI,IAAI,CAAC,MAAM,GAAG,CAAC;QAAE,OAAO,EAAC,KAAK,EAAE,eAAe,EAAC,CAAA;IACpD,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,EAAC,KAAK,EAAE,SAAS,EAAC,CAAA;IAChD,OAAO,EAAC,GAAG,EAAE,IAAI,CAAC,CAAC,CAAC,EAAC,CAAA;AACvB,CAAC","sourcesContent":["import {JsonMap} from './json.js'\nimport {PickByPrefix} from './typing/pick-by-prefix.js'\nimport {MonorailEventPublic, MonorailEventSensitive} from './monorail.js'\nimport {HookReturnPerTunnelPlugin} from './plugins/tunnel.js'\nimport {getArrayContainsDuplicates, getArrayRejectingUndefined} from './public/common/array.js'\nimport {Config, Interfaces} from '@oclif/core'\n\n/**\n * Convenience function to trigger a hook, and gather any successful responses. Failures are ignored.\n *\n * Responses are organised into a dictionary, keyed by plug-in name. Only plug-ins that have hooks registered for the given event, and the hooks were run successfully, are included.\n */\nexport async function fanoutHooks<TPluginMap extends HookReturnsPerPlugin, TEvent extends string & keyof TPluginMap>(\n config: Interfaces.Config,\n event: TEvent,\n options: TPluginMap[typeof event]['options'],\n timeout?: number,\n): Promise<Partial<TPluginMap[typeof event]['pluginReturns']>> {\n const res = await config.runHook(event, options, timeout)\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n return Object.fromEntries(res.successes.map(({result, plugin}) => [plugin.name, result])) as any\n}\n\ntype AppSpecificMonorailFields = PickByPrefix<MonorailEventPublic, 'app_', 'project_type' | 'api_key' | 'partner_id'> &\n PickByPrefix<MonorailEventPublic, 'cmd_extensions_'> &\n PickByPrefix<MonorailEventPublic, 'cmd_scaffold_'>\n\ntype AppSpecificSensitiveMonorailFields = PickByPrefix<MonorailEventSensitive, 'app_'>\n\ninterface HookReturnsPerPlugin extends HookReturnPerTunnelPlugin {\n public_command_metadata: {\n options: {[key: string]: never}\n pluginReturns: {\n '@shopify/app': Partial<AppSpecificMonorailFields>\n [pluginName: string]: JsonMap\n }\n }\n sensitive_command_metadata: {\n options: {[key: string]: never}\n pluginReturns: {\n '@shopify/app': Partial<AppSpecificSensitiveMonorailFields>\n [pluginName: string]: JsonMap\n }\n }\n [hookName: string]: {\n options: {[key: string]: unknown}\n pluginReturns: {[key: string]: JsonMap}\n }\n}\n\nexport type PluginReturnsForHook<\n TEvent extends keyof TPluginMap,\n TPluginName extends keyof TPluginMap[TEvent]['pluginReturns'],\n TPluginMap extends HookReturnsPerPlugin = HookReturnsPerPlugin,\n> = TPluginMap[TEvent]['pluginReturns'][TPluginName]\n\nexport type FanoutHookFunction<\n TEvent extends keyof TPluginMap = string,\n TPluginName extends keyof TPluginMap[TEvent]['pluginReturns'] = string,\n TPluginMap extends HookReturnsPerPlugin = HookReturnsPerPlugin,\n> = (\n this: Interfaces.Hook.Context,\n options: TPluginMap[TEvent]['options'] & {config: Interfaces.Config},\n) => Promise<PluginReturnsForHook<TEvent, TPluginName, TPluginMap>>\n\n/**\n * Execute the 'tunnel_provider' hook, and return the list of available tunnel providers.\n * Fail if there are multiple plugins for the same provider\n *\n * @param config - oclif config used to execute hooks\n * @returns list of available tunnel plugins\n */\nexport async function getListOfTunnelPlugins(config: Config): Promise<{plugins: string[]; error?: string}> {\n const hooks = await fanoutHooks(config, 'tunnel_provider', {})\n const names = getArrayRejectingUndefined(Object.values(hooks).map((key) => key?.name))\n if (getArrayContainsDuplicates(names)) return {plugins: names, error: 'multiple-plugins-for-provider'}\n return {plugins: names}\n}\n\n/**\n * Execute the 'tunnel_start' hook for the given provider.\n * Fails if there aren't plugins for that provider or if there are more than one.\n *\n * @param config - oclif config used to execute hooks\n * @param port - port where the tunnel will be started\n * @param provider - selected provider, must be unique\n * @returns tunnel URL from the selected provider\n */\nexport async function runTunnelPlugin(\n config: Config,\n port: number,\n provider: string,\n): Promise<{url?: string; error?: string}> {\n const hooks = await fanoutHooks(config, 'tunnel_start', {port, provider})\n const urls = getArrayRejectingUndefined(Object.values(hooks).map((key) => key?.url))\n if (urls.length > 1) return {error: 'multiple-urls'}\n if (urls.length === 0) return {error: 'no-urls'}\n return {url: urls[0]}\n}\n"]}
1
+ {"version":3,"file":"plugins.js","sourceRoot":"","sources":["../src/plugins.ts"],"names":[],"mappings":"AAIA,OAAO,EAAC,0BAA0B,EAAE,0BAA0B,EAAC,MAAM,0BAA0B,CAAA;AAC/F,OAAO,EAAC,GAAG,EAAS,MAAM,2BAA2B,CAAA;AAGrD;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,WAAW,CAC/B,MAAyB,EACzB,KAAa,EACb,OAA4C,EAC5C,OAAgB;IAEhB,MAAM,GAAG,GAAG,MAAM,MAAM,CAAC,OAAO,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,CAAC,CAAA;IACzD,8DAA8D;IAC9D,OAAO,MAAM,CAAC,WAAW,CAAC,GAAG,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,EAAC,MAAM,EAAE,MAAM,EAAC,EAAE,EAAE,CAAC,CAAC,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,CAAQ,CAAA;AAClG,CAAC;AA4CD;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,sBAAsB,CAAC,MAAc;IACzD,MAAM,KAAK,GAAG,MAAM,WAAW,CAAC,MAAM,EAAE,iBAAiB,EAAE,EAAE,CAAC,CAAA;IAC9D,MAAM,KAAK,GAAG,0BAA0B,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC,CAAA;IACtF,IAAI,0BAA0B,CAAC,KAAK,CAAC;QAAE,OAAO,EAAC,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,+BAA+B,EAAC,CAAA;IACtG,OAAO,EAAC,OAAO,EAAE,KAAK,EAAC,CAAA;AACzB,CAAC;AAQD;;;;;;;;GAQG;AACH,MAAM,CAAC,KAAK,UAAU,eAAe,CACnC,MAAc,EACd,IAAY,EACZ,QAAgB;IAEhB,MAAM,KAAK,GAAG,MAAM,WAAW,CAAC,MAAM,EAAE,cAAc,EAAE,EAAC,IAAI,EAAE,QAAQ,EAAC,CAAC,CAAA;IACzE,MAAM,UAAU,GAAG,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,MAAM,CAC5C,CAAC,cAAc,EAAE,EAAE,CAAC,CAAC,cAAc,EAAE,KAAK,EAAE,IAAI,cAAc,CAAC,KAAK,CAAC,IAAI,KAAK,kBAAkB,CACjG,CAAA;IACD,IAAI,UAAU,CAAC,MAAM,GAAG,CAAC;QAAE,OAAO,GAAG,CAAC,EAAC,QAAQ,EAAE,IAAI,EAAE,eAAe,EAAC,CAAC,CAAA;IACxE,IAAI,UAAU,CAAC,MAAM,KAAK,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC;QAAE,OAAO,GAAG,CAAC,EAAC,QAAQ,EAAE,IAAI,EAAE,aAAa,EAAC,CAAC,CAAA;IAE1F,OAAO,UAAU,CAAC,CAAC,CAAC;SACjB,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC;SACvB,QAAQ,CAAC,CAAC,KAAK,EAAE,EAAE,CAClB,KAAK,CAAC,IAAI,KAAK,SAAS;QACtB,CAAC,CAAC,EAAC,QAAQ,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,KAAK,CAAC,OAAO,EAAC;QACrD,CAAC,CAAC,EAAC,QAAQ,EAAE,IAAI,EAAE,eAAe,EAAC,CACtC,CAAA;AACL,CAAC","sourcesContent":["import {JsonMap} from './json.js'\nimport {PickByPrefix} from './typing/pick-by-prefix.js'\nimport {MonorailEventPublic, MonorailEventSensitive} from './monorail.js'\nimport {HookReturnPerTunnelPlugin} from './plugins/tunnel.js'\nimport {getArrayContainsDuplicates, getArrayRejectingUndefined} from './public/common/array.js'\nimport {err, Result} from './public/common/result.js'\nimport {Config, Interfaces} from '@oclif/core'\n\n/**\n * Convenience function to trigger a hook, and gather any successful responses. Failures are ignored.\n *\n * Responses are organised into a dictionary, keyed by plug-in name. Only plug-ins that have hooks registered for the given event, and the hooks were run successfully, are included.\n */\nexport async function fanoutHooks<TPluginMap extends HookReturnsPerPlugin, TEvent extends string & keyof TPluginMap>(\n config: Interfaces.Config,\n event: TEvent,\n options: TPluginMap[typeof event]['options'],\n timeout?: number,\n): Promise<Partial<TPluginMap[typeof event]['pluginReturns']>> {\n const res = await config.runHook(event, options, timeout)\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n return Object.fromEntries(res.successes.map(({result, plugin}) => [plugin.name, result])) as any\n}\n\ntype AppSpecificMonorailFields = PickByPrefix<MonorailEventPublic, 'app_', 'project_type' | 'api_key' | 'partner_id'> &\n PickByPrefix<MonorailEventPublic, 'cmd_extensions_'> &\n PickByPrefix<MonorailEventPublic, 'cmd_scaffold_'>\n\ntype AppSpecificSensitiveMonorailFields = PickByPrefix<MonorailEventSensitive, 'app_'>\n\ninterface HookReturnsPerPlugin extends HookReturnPerTunnelPlugin {\n public_command_metadata: {\n options: {[key: string]: never}\n pluginReturns: {\n '@shopify/app': Partial<AppSpecificMonorailFields>\n [pluginName: string]: JsonMap\n }\n }\n sensitive_command_metadata: {\n options: {[key: string]: never}\n pluginReturns: {\n '@shopify/app': Partial<AppSpecificSensitiveMonorailFields>\n [pluginName: string]: JsonMap\n }\n }\n [hookName: string]: {\n options: {[key: string]: unknown}\n pluginReturns: {[key: string]: JsonMap | Result<JsonMap, Error>}\n }\n}\n\nexport type PluginReturnsForHook<\n TEvent extends keyof TPluginMap,\n TPluginName extends keyof TPluginMap[TEvent]['pluginReturns'],\n TPluginMap extends HookReturnsPerPlugin = HookReturnsPerPlugin,\n> = TPluginMap[TEvent]['pluginReturns'][TPluginName]\n\nexport type FanoutHookFunction<\n TEvent extends keyof TPluginMap = string,\n TPluginName extends keyof TPluginMap[TEvent]['pluginReturns'] = string,\n TPluginMap extends HookReturnsPerPlugin = HookReturnsPerPlugin,\n> = (\n this: Interfaces.Hook.Context,\n options: TPluginMap[TEvent]['options'] & {config: Interfaces.Config},\n) => Promise<PluginReturnsForHook<TEvent, TPluginName, TPluginMap>>\n\n/**\n * Execute the 'tunnel_provider' hook, and return the list of available tunnel providers.\n * Fail if there are multiple plugins for the same provider\n *\n * @param config - oclif config used to execute hooks\n * @returns list of available tunnel plugins\n */\nexport async function getListOfTunnelPlugins(config: Config): Promise<{plugins: string[]; error?: string}> {\n const hooks = await fanoutHooks(config, 'tunnel_provider', {})\n const names = getArrayRejectingUndefined(Object.values(hooks).map((key) => key?.name))\n if (getArrayContainsDuplicates(names)) return {plugins: names, error: 'multiple-plugins-for-provider'}\n return {plugins: names}\n}\n\nexport interface TunnelPluginError {\n provider: string\n type: 'multiple-urls' | 'handled-error' | 'unknown' | 'no-provider'\n message?: string\n}\n\n/**\n * Execute the 'tunnel_start' hook for the given provider.\n * Fails if there aren't plugins for that provider or if there are more than one.\n *\n * @param config - oclif config used to execute hooks\n * @param port - port where the tunnel will be started\n * @param provider - selected provider, must be unique\n * @returns tunnel URL from the selected provider\n */\nexport async function runTunnelPlugin(\n config: Config,\n port: number,\n provider: string,\n): Promise<Result<string, TunnelPluginError>> {\n const hooks = await fanoutHooks(config, 'tunnel_start', {port, provider})\n const urlResults = Object.values(hooks).filter(\n (tunnelResponse) => !tunnelResponse?.isErr() || tunnelResponse.error.type !== 'invalid-provider',\n )\n if (urlResults.length > 1) return err({provider, type: 'multiple-urls'})\n if (urlResults.length === 0 || !urlResults[0]) return err({provider, type: 'no-provider'})\n\n return urlResults[0]\n .map((data) => data.url)\n .mapError((error) =>\n error.type === 'unknown'\n ? {provider, type: 'unknown', message: error.message}\n : {provider, type: 'handled-error'},\n )\n}\n"]}
@@ -4,7 +4,10 @@ import React from 'react';
4
4
  * `Command` displays a command as non-dimmed text.
5
5
  */
6
6
  const Command = ({ command }) => {
7
- return React.createElement(Text, null, command);
7
+ return React.createElement(Text, null,
8
+ "`",
9
+ command,
10
+ "`");
8
11
  };
9
12
  export { Command };
10
13
  //# sourceMappingURL=Command.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Command.js","sourceRoot":"","sources":["../../../../../src/private/node/ui/components/Command.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAC,IAAI,EAAC,MAAM,KAAK,CAAA;AACxB,OAAO,KAAK,MAAM,OAAO,CAAA;AAMzB;;GAEG;AACH,MAAM,OAAO,GAAoB,CAAC,EAAC,OAAO,EAAiC,EAAe,EAAE;IAC1F,OAAO,oBAAC,IAAI,QAAE,OAAO,CAAQ,CAAA;AAC/B,CAAC,CAAA;AAED,OAAO,EAAC,OAAO,EAAC,CAAA","sourcesContent":["import {Text} from 'ink'\nimport React from 'react'\n\ninterface Props {\n command: string\n}\n\n/**\n * `Command` displays a command as non-dimmed text.\n */\nconst Command: React.FC<Props> = ({command}: React.PropsWithChildren<Props>): JSX.Element => {\n return <Text>{command}</Text>\n}\n\nexport {Command}\n"]}
1
+ {"version":3,"file":"Command.js","sourceRoot":"","sources":["../../../../../src/private/node/ui/components/Command.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAC,IAAI,EAAC,MAAM,KAAK,CAAA;AACxB,OAAO,KAAK,MAAM,OAAO,CAAA;AAMzB;;GAEG;AACH,MAAM,OAAO,GAAoB,CAAC,EAAC,OAAO,EAAiC,EAAe,EAAE;IAC1F,OAAO,oBAAC,IAAI;;QAAG,OAAO;YAAS,CAAA;AACjC,CAAC,CAAA;AAED,OAAO,EAAC,OAAO,EAAC,CAAA","sourcesContent":["import {Text} from 'ink'\nimport React from 'react'\n\ninterface Props {\n command: string\n}\n\n/**\n * `Command` displays a command as non-dimmed text.\n */\nconst Command: React.FC<Props> = ({command}: React.PropsWithChildren<Props>): JSX.Element => {\n return <Text>`{command}`</Text>\n}\n\nexport {Command}\n"]}
@@ -0,0 +1,88 @@
1
+ export declare type Result<TValue, TError> = Ok<TValue, TError> | Err<TValue, TError>;
2
+ /**
3
+ * Utility metho to create an `Ok` result from a `value`
4
+ *
5
+ * @param value - `value` used to crete the `Result`
6
+ * @returns an instance of a `Ok` `Result` inferring its type
7
+ */
8
+ export declare const ok: <TValue, TError = never>(value: TValue) => Ok<TValue, TError>;
9
+ /**
10
+ * Utility method to create an `Error` result from an `error`
11
+ *
12
+ * @param err - `error` used to crete the `Result`
13
+ * @returns an instance of an `Error` `Result` inferring its type
14
+ */
15
+ export declare const err: <TValue = never, TError = unknown>(err: TError) => Err<TValue, TError>;
16
+ export declare class Ok<TValue, TError> {
17
+ readonly value: TValue;
18
+ constructor(value: TValue);
19
+ /**
20
+ * Check if a `Result` is an `Err` inferring its type. `!isErr()` should be used before accessing the `value`
21
+ *
22
+ * @returns `false` as the `Resul` is `OK`
23
+ */
24
+ isErr(): this is Err<TValue, TError>;
25
+ /**
26
+ * Runs the `handler` method an return the same an unaltered copy of the `Result`. It could be used to log an
27
+ * output when the result is `Ok` without breaking the flow
28
+ *
29
+ * @param handler - method to be run when the result is `Ok`
30
+ * @returns a copy of the same `Result`
31
+ */
32
+ doOnOk(handler: (value: TValue) => void): Result<TValue, TError>;
33
+ /**
34
+ * A safe mode to get the `value` of the `Result`
35
+ *
36
+ * @returns the `value` of the `Result`
37
+ */
38
+ valueOrThrow(): TValue;
39
+ /**
40
+ * Maps the value to another one with a different type. It leaves the `Error` type unaltered
41
+ *
42
+ * @param mapper - The mapper method to apply an `OK` value
43
+ * @returns a new result with the new mapped value
44
+ */
45
+ map<TMappedValue>(mapper: (value: TValue) => TMappedValue): Result<TMappedValue, TError>;
46
+ /**
47
+ * Maps the error type to another one. It leaves the `Ok` type and value unaltered
48
+ *
49
+ * @param _mapper - This mapper method is not used for an `Ok` value
50
+ * @returns a new result with the new mapped error type and an value
51
+ */
52
+ mapError<TMappedError>(_mapper: (error: TError) => TMappedError): Result<TValue, TMappedError>;
53
+ }
54
+ export declare class Err<TValue, TError> {
55
+ readonly error: TError;
56
+ constructor(error: TError);
57
+ /**
58
+ * Check if a `Result` is an `Err` inferring its type. `!isErr()` should be used before accessing the `value`
59
+ *
60
+ * @returns `false` as the `Resul` is `OK`
61
+ */
62
+ isErr(): this is Err<TValue, TError>;
63
+ /**
64
+ * Return an unaltered copy of the `Error` without doing anything.
65
+ *
66
+ * @param _handler - This handler method is not used for an `Error`
67
+ * @returns a copy of the same `Error`
68
+ */
69
+ doOnOk(_handler: (value: TValue) => void): Result<TValue, TError>;
70
+ /**
71
+ * A safe mode to throw the `error` of the `Result`
72
+ */
73
+ valueOrThrow(): TValue;
74
+ /**
75
+ * Maps the value type to another one. It leaves the `Error` unaltered
76
+ *
77
+ * @param _mapper - This mapper method is not used for an `Error` value
78
+ * @returns a new result with the new value type and an unaltered error
79
+ */
80
+ map<TMappedValue>(_mapper: (valueOrThrow: TValue) => TMappedValue): Result<TMappedValue, TError>;
81
+ /**
82
+ * Maps the error to another one with a different type. It leaves the value type unaltered
83
+ *
84
+ * @param mapper - The mapper method to apply an `Error` value
85
+ * @returns a new result with the new mapped error
86
+ */
87
+ mapError<TMappedError>(mapper: (error: TError) => TMappedError): Result<TValue, TMappedError>;
88
+ }
@@ -0,0 +1,111 @@
1
+ /**
2
+ * Utility metho to create an `Ok` result from a `value`
3
+ *
4
+ * @param value - `value` used to crete the `Result`
5
+ * @returns an instance of a `Ok` `Result` inferring its type
6
+ */
7
+ export const ok = (value) => new Ok(value);
8
+ /**
9
+ * Utility method to create an `Error` result from an `error`
10
+ *
11
+ * @param err - `error` used to crete the `Result`
12
+ * @returns an instance of an `Error` `Result` inferring its type
13
+ */
14
+ export const err = (err) => new Err(err);
15
+ export class Ok {
16
+ constructor(value) {
17
+ this.value = value;
18
+ }
19
+ /**
20
+ * Check if a `Result` is an `Err` inferring its type. `!isErr()` should be used before accessing the `value`
21
+ *
22
+ * @returns `false` as the `Resul` is `OK`
23
+ */
24
+ isErr() {
25
+ return false;
26
+ }
27
+ /**
28
+ * Runs the `handler` method an return the same an unaltered copy of the `Result`. It could be used to log an
29
+ * output when the result is `Ok` without breaking the flow
30
+ *
31
+ * @param handler - method to be run when the result is `Ok`
32
+ * @returns a copy of the same `Result`
33
+ */
34
+ doOnOk(handler) {
35
+ handler(this.value);
36
+ return ok(this.value);
37
+ }
38
+ /**
39
+ * A safe mode to get the `value` of the `Result`
40
+ *
41
+ * @returns the `value` of the `Result`
42
+ */
43
+ valueOrThrow() {
44
+ return this.value;
45
+ }
46
+ /**
47
+ * Maps the value to another one with a different type. It leaves the `Error` type unaltered
48
+ *
49
+ * @param mapper - The mapper method to apply an `OK` value
50
+ * @returns a new result with the new mapped value
51
+ */
52
+ map(mapper) {
53
+ return ok(mapper(this.value));
54
+ }
55
+ /**
56
+ * Maps the error type to another one. It leaves the `Ok` type and value unaltered
57
+ *
58
+ * @param _mapper - This mapper method is not used for an `Ok` value
59
+ * @returns a new result with the new mapped error type and an value
60
+ */
61
+ mapError(_mapper) {
62
+ return ok(this.value);
63
+ }
64
+ }
65
+ export class Err {
66
+ constructor(error) {
67
+ this.error = error;
68
+ }
69
+ /**
70
+ * Check if a `Result` is an `Err` inferring its type. `!isErr()` should be used before accessing the `value`
71
+ *
72
+ * @returns `false` as the `Resul` is `OK`
73
+ */
74
+ isErr() {
75
+ return true;
76
+ }
77
+ /**
78
+ * Return an unaltered copy of the `Error` without doing anything.
79
+ *
80
+ * @param _handler - This handler method is not used for an `Error`
81
+ * @returns a copy of the same `Error`
82
+ */
83
+ doOnOk(_handler) {
84
+ return err(this.error);
85
+ }
86
+ /**
87
+ * A safe mode to throw the `error` of the `Result`
88
+ */
89
+ valueOrThrow() {
90
+ throw this.error;
91
+ }
92
+ /**
93
+ * Maps the value type to another one. It leaves the `Error` unaltered
94
+ *
95
+ * @param _mapper - This mapper method is not used for an `Error` value
96
+ * @returns a new result with the new value type and an unaltered error
97
+ */
98
+ map(_mapper) {
99
+ return err(this.error);
100
+ }
101
+ /**
102
+ * Maps the error to another one with a different type. It leaves the value type unaltered
103
+ *
104
+ * @param mapper - The mapper method to apply an `Error` value
105
+ * @returns a new result with the new mapped error
106
+ */
107
+ mapError(mapper) {
108
+ return err(mapper(this.error));
109
+ }
110
+ }
111
+ //# sourceMappingURL=result.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"result.js","sourceRoot":"","sources":["../../../src/public/common/result.ts"],"names":[],"mappings":"AAGA;;;;;GAKG;AACH,MAAM,CAAC,MAAM,EAAE,GAAG,CAAyB,KAAa,EAAsB,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,CAAA;AAE9F;;;;;GAKG;AACH,MAAM,CAAC,MAAM,GAAG,GAAG,CAAmC,GAAW,EAAuB,EAAE,CAAC,IAAI,GAAG,CAAC,GAAG,CAAC,CAAA;AAEvG,MAAM,OAAO,EAAE;IACb,YAAqB,KAAa;QAAb,UAAK,GAAL,KAAK,CAAQ;IAAG,CAAC;IAEtC;;;;OAIG;IACH,KAAK;QACH,OAAO,KAAK,CAAA;IACd,CAAC;IAED;;;;;;OAMG;IACH,MAAM,CAAC,OAAgC;QACrC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;QACnB,OAAO,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;IACvB,CAAC;IAED;;;;OAIG;IACH,YAAY;QACV,OAAO,IAAI,CAAC,KAAK,CAAA;IACnB,CAAC;IAED;;;;;OAKG;IACH,GAAG,CAAe,MAAuC;QACvD,OAAO,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAA;IAC/B,CAAC;IAED;;;;;OAKG;IACH,QAAQ,CAAe,OAAwC;QAC7D,OAAO,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;IACvB,CAAC;CACF;AAED,MAAM,OAAO,GAAG;IACd,YAAqB,KAAa;QAAb,UAAK,GAAL,KAAK,CAAQ;IAAG,CAAC;IAEtC;;;;OAIG;IACH,KAAK;QACH,OAAO,IAAI,CAAA;IACb,CAAC;IAED;;;;;OAKG;IACH,MAAM,CAAC,QAAiC;QACtC,OAAO,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;IACxB,CAAC;IAED;;OAEG;IACH,YAAY;QACV,MAAM,IAAI,CAAC,KAAK,CAAA;IAClB,CAAC;IAED;;;;;OAKG;IACH,GAAG,CAAe,OAA+C;QAC/D,OAAO,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;IACxB,CAAC;IAED;;;;;OAKG;IACH,QAAQ,CAAe,MAAuC;QAC5D,OAAO,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAA;IAChC,CAAC;CACF","sourcesContent":["/* eslint-disable node/handle-callback-err */\nexport type Result<TValue, TError> = Ok<TValue, TError> | Err<TValue, TError>\n\n/**\n * Utility metho to create an `Ok` result from a `value`\n *\n * @param value - `value` used to crete the `Result`\n * @returns an instance of a `Ok` `Result` inferring its type\n */\nexport const ok = <TValue, TError = never>(value: TValue): Ok<TValue, TError> => new Ok(value)\n\n/**\n * Utility method to create an `Error` result from an `error`\n *\n * @param err - `error` used to crete the `Result`\n * @returns an instance of an `Error` `Result` inferring its type\n */\nexport const err = <TValue = never, TError = unknown>(err: TError): Err<TValue, TError> => new Err(err)\n\nexport class Ok<TValue, TError> {\n constructor(readonly value: TValue) {}\n\n /**\n * Check if a `Result` is an `Err` inferring its type. `!isErr()` should be used before accessing the `value`\n *\n * @returns `false` as the `Resul` is `OK`\n */\n isErr(): this is Err<TValue, TError> {\n return false\n }\n\n /**\n * Runs the `handler` method an return the same an unaltered copy of the `Result`. It could be used to log an\n * output when the result is `Ok` without breaking the flow\n *\n * @param handler - method to be run when the result is `Ok`\n * @returns a copy of the same `Result`\n */\n doOnOk(handler: (value: TValue) => void): Result<TValue, TError> {\n handler(this.value)\n return ok(this.value)\n }\n\n /**\n * A safe mode to get the `value` of the `Result`\n *\n * @returns the `value` of the `Result`\n */\n valueOrThrow(): TValue {\n return this.value\n }\n\n /**\n * Maps the value to another one with a different type. It leaves the `Error` type unaltered\n *\n * @param mapper - The mapper method to apply an `OK` value\n * @returns a new result with the new mapped value\n */\n map<TMappedValue>(mapper: (value: TValue) => TMappedValue): Result<TMappedValue, TError> {\n return ok(mapper(this.value))\n }\n\n /**\n * Maps the error type to another one. It leaves the `Ok` type and value unaltered\n *\n * @param _mapper - This mapper method is not used for an `Ok` value\n * @returns a new result with the new mapped error type and an value\n */\n mapError<TMappedError>(_mapper: (error: TError) => TMappedError): Result<TValue, TMappedError> {\n return ok(this.value)\n }\n}\n\nexport class Err<TValue, TError> {\n constructor(readonly error: TError) {}\n\n /**\n * Check if a `Result` is an `Err` inferring its type. `!isErr()` should be used before accessing the `value`\n *\n * @returns `false` as the `Resul` is `OK`\n */\n isErr(): this is Err<TValue, TError> {\n return true\n }\n\n /**\n * Return an unaltered copy of the `Error` without doing anything.\n *\n * @param _handler - This handler method is not used for an `Error`\n * @returns a copy of the same `Error`\n */\n doOnOk(_handler: (value: TValue) => void): Result<TValue, TError> {\n return err(this.error)\n }\n\n /**\n * A safe mode to throw the `error` of the `Result`\n */\n valueOrThrow(): TValue {\n throw this.error\n }\n\n /**\n * Maps the value type to another one. It leaves the `Error` unaltered\n *\n * @param _mapper - This mapper method is not used for an `Error` value\n * @returns a new result with the new value type and an unaltered error\n */\n map<TMappedValue>(_mapper: (valueOrThrow: TValue) => TMappedValue): Result<TMappedValue, TError> {\n return err(this.error)\n }\n\n /**\n * Maps the error to another one with a different type. It leaves the value type unaltered\n *\n * @param mapper - The mapper method to apply an `Error` value\n * @returns a new result with the new mapped error\n */\n mapError<TMappedError>(mapper: (error: TError) => TMappedError): Result<TValue, TMappedError> {\n return err(mapper(this.error))\n }\n}\n"]}
@@ -35,12 +35,12 @@ declare type RenderAlertOptions = Omit<AlertProps, 'type'>;
35
35
  * │ Body │
36
36
  * │ │
37
37
  * │ Next steps │
38
- * │ • Run cd santorini-goods
39
- * │ • To preview your project, run npm app dev
40
- * │ • To add extensions, run npm generate extension
38
+ * │ • Run `cd santorini-goods`
39
+ * │ • To preview your project, run `npm app dev`
40
+ * │ • To add extensions, run `npm generate extension`
41
41
  * │ │
42
42
  * │ Reference │
43
- * │ • Run npm shopify help
43
+ * │ • Run `npm shopify help`
44
44
  * │ • Press 'return' to open the dev docs: │
45
45
  * │ https://shopify.dev │
46
46
  * │ │
@@ -72,12 +72,12 @@ export declare function renderInfo(options: RenderAlertOptions): void;
72
72
  * │ Body │
73
73
  * │ │
74
74
  * │ Next steps │
75
- * │ • Run cd santorini-goods │
76
- * │ • To preview your project, run npm app dev │
77
- * │ • To add extensions, run npm generate extension │
75
+ * │ • Run `cd santorini-goods`
76
+ * │ • To preview your project, run `npm app dev`
77
+ * │ • To add extensions, run `npm generate extension`
78
78
  * │ │
79
79
  * │ Reference │
80
- * │ • Run npm shopify help │
80
+ * │ • Run `npm shopify help`
81
81
  * │ • Press 'return' to open the dev docs: │
82
82
  * │ https://shopify.dev │
83
83
  * │ │
@@ -109,12 +109,12 @@ export declare function renderSuccess(options: RenderAlertOptions): void;
109
109
  * │ Body │
110
110
  * │ │
111
111
  * │ Next steps │
112
- * │ • Run cd santorini-goods
113
- * │ • To preview your project, run npm app dev
114
- * │ • To add extensions, run npm generate extension
112
+ * │ • Run `cd santorini-goods`
113
+ * │ • To preview your project, run `npm app dev`
114
+ * │ • To add extensions, run `npm generate extension`
115
115
  * │ │
116
116
  * │ Reference │
117
- * │ • Run npm shopify help
117
+ * │ • Run `npm shopify help`
118
118
  * │ • Press 'return' to open the dev docs: │
119
119
  * │ https://shopify.dev │
120
120
  * │ │
@@ -33,12 +33,12 @@ export async function renderConcurrent({ processes, abortController, showTimesta
33
33
  * │ Body │
34
34
  * │ │
35
35
  * │ Next steps │
36
- * │ • Run cd santorini-goods
37
- * │ • To preview your project, run npm app dev
38
- * │ • To add extensions, run npm generate extension
36
+ * │ • Run `cd santorini-goods`
37
+ * │ • To preview your project, run `npm app dev`
38
+ * │ • To add extensions, run `npm generate extension`
39
39
  * │ │
40
40
  * │ Reference │
41
- * │ • Run npm shopify help
41
+ * │ • Run `npm shopify help`
42
42
  * │ • Press 'return' to open the dev docs: │
43
43
  * │ https://shopify.dev │
44
44
  * │ │
@@ -72,12 +72,12 @@ export function renderInfo(options) {
72
72
  * │ Body │
73
73
  * │ │
74
74
  * │ Next steps │
75
- * │ • Run cd santorini-goods │
76
- * │ • To preview your project, run npm app dev │
77
- * │ • To add extensions, run npm generate extension │
75
+ * │ • Run `cd santorini-goods`
76
+ * │ • To preview your project, run `npm app dev`
77
+ * │ • To add extensions, run `npm generate extension`
78
78
  * │ │
79
79
  * │ Reference │
80
- * │ • Run npm shopify help │
80
+ * │ • Run `npm shopify help`
81
81
  * │ • Press 'return' to open the dev docs: │
82
82
  * │ https://shopify.dev │
83
83
  * │ │
@@ -111,12 +111,12 @@ export function renderSuccess(options) {
111
111
  * │ Body │
112
112
  * │ │
113
113
  * │ Next steps │
114
- * │ • Run cd santorini-goods
115
- * │ • To preview your project, run npm app dev
116
- * │ • To add extensions, run npm generate extension
114
+ * │ • Run `cd santorini-goods`
115
+ * │ • To preview your project, run `npm app dev`
116
+ * │ • To add extensions, run `npm generate extension`
117
117
  * │ │
118
118
  * │ Reference │
119
- * │ • Run npm shopify help
119
+ * │ • Run `npm shopify help`
120
120
  * │ • Press 'return' to open the dev docs: │
121
121
  * │ https://shopify.dev │
122
122
  * │ │
@@ -1 +1 @@
1
- {"version":3,"file":"ui.js","sourceRoot":"","sources":["../../../src/public/node/ui.tsx"],"names":[],"mappings":"AAAA,OAAO,gBAAgB,MAAM,sDAAsD,CAAA;AAEnF,OAAO,EAAC,MAAM,EAAC,MAAM,0BAA0B,CAAA;AAE/C,OAAO,EAAC,KAAK,EAAC,MAAM,gCAAgC,CAAA;AACpD,OAAO,EAAC,UAAU,EAAE,KAAK,EAAC,MAAM,gCAAgC,CAAA;AAGhE,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,EAAC,eAAe,EAAC,MAAM,kBAAkB,CAAA;AAQhD;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,gBAAgB,CAAC,EAAC,SAAS,EAAE,eAAe,EAAE,cAAc,GAAG,IAAI,EAA0B;IACjH,MAAM,EAAC,aAAa,EAAC,GAAG,MAAM,CAC5B,oBAAC,gBAAgB,IACf,SAAS,EAAE,SAAS,EACpB,eAAe,EAAE,eAAe,IAAI,IAAI,eAAe,EAAE,EACzD,cAAc,EAAE,cAAc,GAC9B,CACH,CAAA;IAED,OAAO,aAAa,EAAE,CAAA;AACxB,CAAC;AAID;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AACH,MAAM,UAAU,UAAU,CAAC,OAA2B;IACpD,KAAK,CAAC,EAAC,GAAG,OAAO,EAAE,IAAI,EAAE,MAAM,EAAC,CAAC,CAAA;AACnC,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AACH,MAAM,UAAU,aAAa,CAAC,OAA2B;IACvD,KAAK,CAAC,EAAC,GAAG,OAAO,EAAE,IAAI,EAAE,SAAS,EAAC,CAAC,CAAA;AACtC,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AACH,MAAM,UAAU,aAAa,CAAC,OAA2B;IACvD,KAAK,CAAC,EAAC,GAAG,OAAO,EAAE,IAAI,EAAE,SAAS,EAAC,CAAC,CAAA;AACtC,CAAC;AAED;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,gBAAgB,CAAC,KAAY;IAC3C,UAAU,CAAC,KAAK,CAAC,CAAA;AACnB,CAAC;AAED;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,WAAW,CAAC,OAAmB;IAC7C,KAAK,CAAC,OAAO,CAAC,CAAA;AAChB,CAAC","sourcesContent":["import ConcurrentOutput from '../../private/node/ui/components/ConcurrentOutput.js'\nimport {OutputProcess} from '../../output.js'\nimport {render} from '../../private/node/ui.js'\nimport {Fatal} from '../../error.js'\nimport {alert} from '../../private/node/ui/alert.js'\nimport {fatalError, error} from '../../private/node/ui/error.js'\nimport {AlertProps} from '../../private/node/ui/components/Alert.js'\nimport {ErrorProps} from '../../private/node/ui/components/Error.js'\nimport React from 'react'\nimport {AbortController} from 'abort-controller'\n\ninterface RenderConcurrentOptions {\n processes: OutputProcess[]\n abortController?: AbortController\n showTimestamps?: boolean\n}\n\n/**\n * Renders output from concurrent processes to the terminal with {@link ConcurrentOutput}.\n */\nexport async function renderConcurrent({processes, abortController, showTimestamps = true}: RenderConcurrentOptions) {\n const {waitUntilExit} = render(\n <ConcurrentOutput\n processes={processes}\n abortController={abortController ?? new AbortController()}\n showTimestamps={showTimestamps}\n />,\n )\n\n return waitUntilExit()\n}\n\ntype RenderAlertOptions = Omit<AlertProps, 'type'>\n\n/**\n * Renders an information banner to the console.\n *\n * Basic:\n *\n * ```\n * ╭─ info ───────────────────────────────────────────────────╮\n * │ │\n * │ Body │\n * │ │\n * ╰──────────────────────────────────────────────────────────╯\n * ```\n *\n * Complete:\n * ```\n * ╭─ info ───────────────────────────────────────────────────╮\n * │ │\n * │ Title │\n * │ │\n * │ Body │\n * │ │\n * │ Next steps │\n * │ • Run cd santorini-goods │\n * │ • To preview your project, run npm app dev │\n * │ • To add extensions, run npm generate extension │\n * │ │\n * │ Reference │\n * │ • Run npm shopify help │\n * │ • Press 'return' to open the dev docs: │\n * │ https://shopify.dev │\n * │ │\n * │ Link: https://shopify.com │\n * │ │\n * ╰──────────────────────────────────────────────────────────╯\n * ```\n */\nexport function renderInfo(options: RenderAlertOptions) {\n alert({...options, type: 'info'})\n}\n\n/**\n * Renders a success banner to the console.\n *\n * Basic:\n *\n * ```\n * ╭─ success ────────────────────────────────────────────────╮\n * │ │\n * │ Title │\n * │ │\n * ╰──────────────────────────────────────────────────────────╯\n * ```\n *\n * Complete:\n * ```\n * ╭─ success ────────────────────────────────────────────────╮\n * │ │\n * │ Title │\n * │ │\n * │ Body │\n * │ │\n * │ Next steps │\n * │ • Run cd santorini-goods │\n * │ • To preview your project, run npm app dev │\n * │ • To add extensions, run npm generate extension │\n * │ │\n * │ Reference │\n * │ • Run npm shopify help │\n * │ • Press 'return' to open the dev docs: │\n * │ https://shopify.dev │\n * │ │\n * │ Link: https://shopify.com │\n * │ │\n * ╰──────────────────────────────────────────────────────────╯\n * ```\n */\nexport function renderSuccess(options: RenderAlertOptions) {\n alert({...options, type: 'success'})\n}\n\n/**\n * Renders a warning banner to the console.\n *\n * Basic:\n *\n * ```\n * ╭─ warning ────────────────────────────────────────────────╮\n * │ │\n * │ Title │\n * │ │\n * ╰──────────────────────────────────────────────────────────╯\n * ```\n *\n * Complete:\n * ```\n * ╭─ warning ────────────────────────────────────────────────╮\n * │ │\n * │ Title │\n * │ │\n * │ Body │\n * │ │\n * │ Next steps │\n * │ • Run cd santorini-goods │\n * │ • To preview your project, run npm app dev │\n * │ • To add extensions, run npm generate extension │\n * │ │\n * │ Reference │\n * │ • Run npm shopify help │\n * │ • Press 'return' to open the dev docs: │\n * │ https://shopify.dev │\n * │ │\n * │ Link: https://shopify.com │\n * │ │\n * ╰──────────────────────────────────────────────────────────╯\n * ```\n */\nexport function renderWarning(options: RenderAlertOptions) {\n alert({...options, type: 'warning'})\n}\n\n/**\n * Renders a Fatal error to the console inside a banner.\n *\n * ```\n * ╭─ error ──────────────────────────────────────────────────╮\n * │ │\n * │ Couldn't connect to the Shopify Partner Dashboard. │\n * │ │\n * │ Check your internet connection and try again. │\n * │ │\n * ╰──────────────────────────────────────────────────────────╯\n * ```\n */\nexport function renderFatalError(error: Fatal) {\n fatalError(error)\n}\n\n/**\n * Renders a generic error to the console inside a banner.\n *\n * ```\n * ╭─ error ──────────────────────────────────────────────────╮\n * │ │\n * │ Something went wrong. │\n * │ │\n * │ Check your internet connection. │\n * │ │\n * ╰──────────────────────────────────────────────────────────╯\n * ```\n */\nexport function renderError(options: ErrorProps) {\n error(options)\n}\n"]}
1
+ {"version":3,"file":"ui.js","sourceRoot":"","sources":["../../../src/public/node/ui.tsx"],"names":[],"mappings":"AAAA,OAAO,gBAAgB,MAAM,sDAAsD,CAAA;AAEnF,OAAO,EAAC,MAAM,EAAC,MAAM,0BAA0B,CAAA;AAE/C,OAAO,EAAC,KAAK,EAAC,MAAM,gCAAgC,CAAA;AACpD,OAAO,EAAC,UAAU,EAAE,KAAK,EAAC,MAAM,gCAAgC,CAAA;AAGhE,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,EAAC,eAAe,EAAC,MAAM,kBAAkB,CAAA;AAQhD;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,gBAAgB,CAAC,EAAC,SAAS,EAAE,eAAe,EAAE,cAAc,GAAG,IAAI,EAA0B;IACjH,MAAM,EAAC,aAAa,EAAC,GAAG,MAAM,CAC5B,oBAAC,gBAAgB,IACf,SAAS,EAAE,SAAS,EACpB,eAAe,EAAE,eAAe,IAAI,IAAI,eAAe,EAAE,EACzD,cAAc,EAAE,cAAc,GAC9B,CACH,CAAA;IAED,OAAO,aAAa,EAAE,CAAA;AACxB,CAAC;AAID;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AACH,MAAM,UAAU,UAAU,CAAC,OAA2B;IACpD,KAAK,CAAC,EAAC,GAAG,OAAO,EAAE,IAAI,EAAE,MAAM,EAAC,CAAC,CAAA;AACnC,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AACH,MAAM,UAAU,aAAa,CAAC,OAA2B;IACvD,KAAK,CAAC,EAAC,GAAG,OAAO,EAAE,IAAI,EAAE,SAAS,EAAC,CAAC,CAAA;AACtC,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AACH,MAAM,UAAU,aAAa,CAAC,OAA2B;IACvD,KAAK,CAAC,EAAC,GAAG,OAAO,EAAE,IAAI,EAAE,SAAS,EAAC,CAAC,CAAA;AACtC,CAAC;AAED;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,gBAAgB,CAAC,KAAY;IAC3C,UAAU,CAAC,KAAK,CAAC,CAAA;AACnB,CAAC;AAED;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,WAAW,CAAC,OAAmB;IAC7C,KAAK,CAAC,OAAO,CAAC,CAAA;AAChB,CAAC","sourcesContent":["import ConcurrentOutput from '../../private/node/ui/components/ConcurrentOutput.js'\nimport {OutputProcess} from '../../output.js'\nimport {render} from '../../private/node/ui.js'\nimport {Fatal} from '../../error.js'\nimport {alert} from '../../private/node/ui/alert.js'\nimport {fatalError, error} from '../../private/node/ui/error.js'\nimport {AlertProps} from '../../private/node/ui/components/Alert.js'\nimport {ErrorProps} from '../../private/node/ui/components/Error.js'\nimport React from 'react'\nimport {AbortController} from 'abort-controller'\n\ninterface RenderConcurrentOptions {\n processes: OutputProcess[]\n abortController?: AbortController\n showTimestamps?: boolean\n}\n\n/**\n * Renders output from concurrent processes to the terminal with {@link ConcurrentOutput}.\n */\nexport async function renderConcurrent({processes, abortController, showTimestamps = true}: RenderConcurrentOptions) {\n const {waitUntilExit} = render(\n <ConcurrentOutput\n processes={processes}\n abortController={abortController ?? new AbortController()}\n showTimestamps={showTimestamps}\n />,\n )\n\n return waitUntilExit()\n}\n\ntype RenderAlertOptions = Omit<AlertProps, 'type'>\n\n/**\n * Renders an information banner to the console.\n *\n * Basic:\n *\n * ```\n * ╭─ info ───────────────────────────────────────────────────╮\n * │ │\n * │ Body │\n * │ │\n * ╰──────────────────────────────────────────────────────────╯\n * ```\n *\n * Complete:\n * ```\n * ╭─ info ───────────────────────────────────────────────────╮\n * │ │\n * │ Title │\n * │ │\n * │ Body │\n * │ │\n * │ Next steps │\n * │ • Run `cd santorini-goods` │\n * │ • To preview your project, run `npm app dev` │\n * │ • To add extensions, run `npm generate extension` │\n * │ │\n * │ Reference │\n * │ • Run `npm shopify help` │\n * │ • Press 'return' to open the dev docs: │\n * │ https://shopify.dev │\n * │ │\n * │ Link: https://shopify.com │\n * │ │\n * ╰──────────────────────────────────────────────────────────╯\n * ```\n */\nexport function renderInfo(options: RenderAlertOptions) {\n alert({...options, type: 'info'})\n}\n\n/**\n * Renders a success banner to the console.\n *\n * Basic:\n *\n * ```\n * ╭─ success ────────────────────────────────────────────────╮\n * │ │\n * │ Title │\n * │ │\n * ╰──────────────────────────────────────────────────────────╯\n * ```\n *\n * Complete:\n * ```\n * ╭─ success ────────────────────────────────────────────────╮\n * │ │\n * │ Title │\n * │ │\n * │ Body │\n * │ │\n * │ Next steps │\n * │ • Run `cd santorini-goods` │\n * │ • To preview your project, run `npm app dev` │\n * │ • To add extensions, run `npm generate extension` │\n * │ │\n * │ Reference │\n * │ • Run `npm shopify help` │\n * │ • Press 'return' to open the dev docs: │\n * │ https://shopify.dev │\n * │ │\n * │ Link: https://shopify.com │\n * │ │\n * ╰──────────────────────────────────────────────────────────╯\n * ```\n */\nexport function renderSuccess(options: RenderAlertOptions) {\n alert({...options, type: 'success'})\n}\n\n/**\n * Renders a warning banner to the console.\n *\n * Basic:\n *\n * ```\n * ╭─ warning ────────────────────────────────────────────────╮\n * │ │\n * │ Title │\n * │ │\n * ╰──────────────────────────────────────────────────────────╯\n * ```\n *\n * Complete:\n * ```\n * ╭─ warning ────────────────────────────────────────────────╮\n * │ │\n * │ Title │\n * │ │\n * │ Body │\n * │ │\n * │ Next steps │\n * │ • Run `cd santorini-goods` │\n * │ • To preview your project, run `npm app dev` │\n * │ • To add extensions, run `npm generate extension` │\n * │ │\n * │ Reference │\n * │ • Run `npm shopify help` │\n * │ • Press 'return' to open the dev docs: │\n * │ https://shopify.dev │\n * │ │\n * │ Link: https://shopify.com │\n * │ │\n * ╰──────────────────────────────────────────────────────────╯\n * ```\n */\nexport function renderWarning(options: RenderAlertOptions) {\n alert({...options, type: 'warning'})\n}\n\n/**\n * Renders a Fatal error to the console inside a banner.\n *\n * ```\n * ╭─ error ──────────────────────────────────────────────────╮\n * │ │\n * │ Couldn't connect to the Shopify Partner Dashboard. │\n * │ │\n * │ Check your internet connection and try again. │\n * │ │\n * ╰──────────────────────────────────────────────────────────╯\n * ```\n */\nexport function renderFatalError(error: Fatal) {\n fatalError(error)\n}\n\n/**\n * Renders a generic error to the console inside a banner.\n *\n * ```\n * ╭─ error ──────────────────────────────────────────────────╮\n * │ │\n * │ Something went wrong. │\n * │ │\n * │ Check your internet connection. │\n * │ │\n * ╰──────────────────────────────────────────────────────────╯\n * ```\n */\nexport function renderError(options: ErrorProps) {\n error(options)\n}\n"]}
@@ -1,6 +1,6 @@
1
1
  import { ApplicationToken, IdentityToken } from './schema.js';
2
2
  import { CodeAuthResult } from './authorize.js';
3
- import { Result } from '../common/result.js';
3
+ import { Result } from '../public/common/result.js';
4
4
  export declare class InvalidGrantError extends Error {
5
5
  }
6
6
  export interface ExchangeScopes {
@@ -3,7 +3,8 @@ import * as secureStore from './store.js';
3
3
  import { Abort } from '../error.js';
4
4
  import { identity as identityFqdn } from '../environment/fqdn.js';
5
5
  import { shopifyFetch } from '../http.js';
6
- import { err, ok } from '../common/result.js';
6
+ import { err, ok } from '../public/common/result.js';
7
+ import { AbortError } from '@shopify/cli-kit/node/error';
7
8
  export class InvalidGrantError extends Error {
8
9
  }
9
10
  const InvalidIdentityError = () => new Abort('\nError validating auth session', "We've cleared the current session, please try again");
@@ -124,9 +125,9 @@ async function tokenRequestErrorHandler(error) {
124
125
  // There's an scenario when Identity returns "invalid_request" when exchanging an identity token.
125
126
  // This means the token is invalid. We clear the session and throw an error to let the caller know.
126
127
  await secureStore.remove();
127
- return InvalidIdentityError();
128
+ return new AbortError('\nError validating auth session', "We've cleared the current session, please try again");
128
129
  }
129
- return new Abort(error);
130
+ return new AbortError(error);
130
131
  }
131
132
  async function tokenRequest(params) {
132
133
  const fqdn = await identityFqdn();