@shopify/cli-kit 3.77.1 → 3.78.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.
@@ -1 +1 @@
1
- export declare const CLI_KIT_VERSION = "3.77.1";
1
+ export declare const CLI_KIT_VERSION = "3.78.1";
@@ -1,2 +1,2 @@
1
- export const CLI_KIT_VERSION = '3.77.1';
1
+ export const CLI_KIT_VERSION = '3.78.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.77.1'\n"]}
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.78.1'\n"]}
@@ -1,5 +1,6 @@
1
1
  import { graphqlRequestDoc } from './graphql.js';
2
- import { normalizeStoreFqdn } from '../context/fqdn.js';
2
+ import { appDevFqdn, normalizeStoreFqdn } from '../context/fqdn.js';
3
+ import { serviceEnvironment } from '../../../private/node/context/service.js';
3
4
  import Bottleneck from 'bottleneck';
4
5
  // API Rate limiter
5
6
  // Jobs are launched every 150ms
@@ -21,12 +22,15 @@ const limiter = new Bottleneck({
21
22
  export async function appDevRequest(query, shopFqdn, token, variables) {
22
23
  const api = 'App Dev';
23
24
  const normalizedShopFqdn = await normalizeStoreFqdn(shopFqdn);
24
- const url = `https://${normalizedShopFqdn}/app_dev/unstable/graphql.json`;
25
+ const fqdn = await appDevFqdn(normalizedShopFqdn);
26
+ const url = `https://${fqdn}/app_dev/unstable/graphql.json`;
27
+ const addedHeaders = serviceEnvironment() === 'local' ? { 'x-forwarded-host': normalizedShopFqdn } : undefined;
25
28
  const result = limiter.schedule(() => graphqlRequestDoc({
26
29
  query,
27
30
  api,
28
31
  url,
29
32
  token,
33
+ addedHeaders,
30
34
  variables,
31
35
  }));
32
36
  return result;
@@ -1 +1 @@
1
- {"version":3,"file":"app-dev.js","sourceRoot":"","sources":["../../../../src/public/node/api/app-dev.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,iBAAiB,EAAC,MAAM,cAAc,CAAA;AAC9C,OAAO,EAAC,kBAAkB,EAAC,MAAM,oBAAoB,CAAA;AACrD,OAAO,UAAU,MAAM,YAAY,CAAA;AAInC,mBAAmB;AACnB,gCAAgC;AAChC,iDAAiD;AACjD,MAAM,OAAO,GAAG,IAAI,UAAU,CAAC;IAC7B,OAAO,EAAE,GAAG;IACZ,aAAa,EAAE,EAAE;CAClB,CAAC,CAAA;AAEF;;;;;;;;;GASG;AACH,MAAM,CAAC,KAAK,UAAU,aAAa,CACjC,KAA6C,EAC7C,QAAgB,EAChB,KAAa,EACb,SAAsB;IAEtB,MAAM,GAAG,GAAG,SAAS,CAAA;IACrB,MAAM,kBAAkB,GAAG,MAAM,kBAAkB,CAAC,QAAQ,CAAC,CAAA;IAC7D,MAAM,GAAG,GAAG,WAAW,kBAAkB,gCAAgC,CAAA;IACzE,MAAM,MAAM,GAAG,OAAO,CAAC,QAAQ,CAAU,GAAG,EAAE,CAC5C,iBAAiB,CAAsB;QACrC,KAAK;QACL,GAAG;QACH,GAAG;QACH,KAAK;QACL,SAAS;KACV,CAAC,CACH,CAAA;IAED,OAAO,MAAM,CAAA;AACf,CAAC","sourcesContent":["import {graphqlRequestDoc} from './graphql.js'\nimport {normalizeStoreFqdn} from '../context/fqdn.js'\nimport Bottleneck from 'bottleneck'\nimport {Variables} from 'graphql-request'\nimport {TypedDocumentNode} from '@graphql-typed-document-node/core'\n\n// API Rate limiter\n// Jobs are launched every 150ms\n// Only 10 requests can be executed concurrently.\nconst limiter = new Bottleneck({\n minTime: 150,\n maxConcurrent: 10,\n})\n\n/**\n * Executes an org-scoped GraphQL query against the App Management API.\n * Uses typed documents.\n *\n * @param query - GraphQL query to execute.\n * @param shopFqdn - The shop fqdn.\n * @param token - Partners token.\n * @param variables - GraphQL variables to pass to the query.\n * @returns The response of the query of generic type <T>.\n */\nexport async function appDevRequest<TResult, TVariables extends Variables>(\n query: TypedDocumentNode<TResult, TVariables>,\n shopFqdn: string,\n token: string,\n variables?: TVariables,\n): Promise<TResult> {\n const api = 'App Dev'\n const normalizedShopFqdn = await normalizeStoreFqdn(shopFqdn)\n const url = `https://${normalizedShopFqdn}/app_dev/unstable/graphql.json`\n const result = limiter.schedule<TResult>(() =>\n graphqlRequestDoc<TResult, TVariables>({\n query,\n api,\n url,\n token,\n variables,\n }),\n )\n\n return result\n}\n"]}
1
+ {"version":3,"file":"app-dev.js","sourceRoot":"","sources":["../../../../src/public/node/api/app-dev.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,iBAAiB,EAAC,MAAM,cAAc,CAAA;AAC9C,OAAO,EAAC,UAAU,EAAE,kBAAkB,EAAC,MAAM,oBAAoB,CAAA;AACjE,OAAO,EAAC,kBAAkB,EAAC,MAAM,0CAA0C,CAAA;AAC3E,OAAO,UAAU,MAAM,YAAY,CAAA;AAInC,mBAAmB;AACnB,gCAAgC;AAChC,iDAAiD;AACjD,MAAM,OAAO,GAAG,IAAI,UAAU,CAAC;IAC7B,OAAO,EAAE,GAAG;IACZ,aAAa,EAAE,EAAE;CAClB,CAAC,CAAA;AAEF;;;;;;;;;GASG;AACH,MAAM,CAAC,KAAK,UAAU,aAAa,CACjC,KAA6C,EAC7C,QAAgB,EAChB,KAAa,EACb,SAAsB;IAEtB,MAAM,GAAG,GAAG,SAAS,CAAA;IACrB,MAAM,kBAAkB,GAAG,MAAM,kBAAkB,CAAC,QAAQ,CAAC,CAAA;IAC7D,MAAM,IAAI,GAAG,MAAM,UAAU,CAAC,kBAAkB,CAAC,CAAA;IACjD,MAAM,GAAG,GAAG,WAAW,IAAI,gCAAgC,CAAA;IAE3D,MAAM,YAAY,GAAG,kBAAkB,EAAE,KAAK,OAAO,CAAC,CAAC,CAAC,EAAC,kBAAkB,EAAE,kBAAkB,EAAC,CAAC,CAAC,CAAC,SAAS,CAAA;IAE5G,MAAM,MAAM,GAAG,OAAO,CAAC,QAAQ,CAAU,GAAG,EAAE,CAC5C,iBAAiB,CAAsB;QACrC,KAAK;QACL,GAAG;QACH,GAAG;QACH,KAAK;QACL,YAAY;QACZ,SAAS;KACV,CAAC,CACH,CAAA;IAED,OAAO,MAAM,CAAA;AACf,CAAC","sourcesContent":["import {graphqlRequestDoc} from './graphql.js'\nimport {appDevFqdn, normalizeStoreFqdn} from '../context/fqdn.js'\nimport {serviceEnvironment} from '../../../private/node/context/service.js'\nimport Bottleneck from 'bottleneck'\nimport {Variables} from 'graphql-request'\nimport {TypedDocumentNode} from '@graphql-typed-document-node/core'\n\n// API Rate limiter\n// Jobs are launched every 150ms\n// Only 10 requests can be executed concurrently.\nconst limiter = new Bottleneck({\n minTime: 150,\n maxConcurrent: 10,\n})\n\n/**\n * Executes an org-scoped GraphQL query against the App Management API.\n * Uses typed documents.\n *\n * @param query - GraphQL query to execute.\n * @param shopFqdn - The shop fqdn.\n * @param token - Partners token.\n * @param variables - GraphQL variables to pass to the query.\n * @returns The response of the query of generic type <T>.\n */\nexport async function appDevRequest<TResult, TVariables extends Variables>(\n query: TypedDocumentNode<TResult, TVariables>,\n shopFqdn: string,\n token: string,\n variables?: TVariables,\n): Promise<TResult> {\n const api = 'App Dev'\n const normalizedShopFqdn = await normalizeStoreFqdn(shopFqdn)\n const fqdn = await appDevFqdn(normalizedShopFqdn)\n const url = `https://${fqdn}/app_dev/unstable/graphql.json`\n\n const addedHeaders = serviceEnvironment() === 'local' ? {'x-forwarded-host': normalizedShopFqdn} : undefined\n\n const result = limiter.schedule<TResult>(() =>\n graphqlRequestDoc<TResult, TVariables>({\n query,\n api,\n url,\n token,\n addedHeaders,\n variables,\n }),\n )\n\n return result\n}\n"]}
@@ -1,6 +1,13 @@
1
1
  import { CacheOptions, GraphQLResponse } from './graphql.js';
2
2
  import { TypedDocumentNode } from '@graphql-typed-document-node/core';
3
3
  import { Variables } from 'graphql-request';
4
+ export declare const appManagementHeaders: (token: string) => {
5
+ [key: string]: string;
6
+ };
7
+ export declare const appManagementAppLogsUrl: (organizationId: string, cursor?: string, filters?: {
8
+ status?: string;
9
+ source?: string;
10
+ }) => Promise<string>;
4
11
  /**
5
12
  * Executes an org-scoped GraphQL query against the App Management API. Uses typed documents.
6
13
  *
@@ -1,6 +1,8 @@
1
1
  import { graphqlRequestDoc } from './graphql.js';
2
+ import { addCursorAndFiltersToAppLogsUrl } from './utilities.js';
2
3
  import { appManagementFqdn } from '../context/fqdn.js';
3
4
  import { setNextDeprecationDate } from '../../../private/node/context/deprecations-store.js';
5
+ import { buildHeaders } from '../../../private/node/api/headers.js';
4
6
  import Bottleneck from 'bottleneck';
5
7
  // API Rate limiter for partners API (Limit is 10 requests per second)
6
8
  // Jobs are launched every 150ms to add an extra 50ms margin per request.
@@ -20,6 +22,14 @@ async function setupRequest(orgId, token) {
20
22
  responseOptions: { onResponse: handleDeprecations },
21
23
  };
22
24
  }
25
+ export const appManagementHeaders = (token) => {
26
+ return buildHeaders(token);
27
+ };
28
+ export const appManagementAppLogsUrl = async (organizationId, cursor, filters) => {
29
+ const fqdn = await appManagementFqdn();
30
+ const url = `https://${fqdn}/app_management/unstable/organizations/${organizationId}/app_logs/poll`;
31
+ return addCursorAndFiltersToAppLogsUrl(url, cursor, filters);
32
+ };
23
33
  /**
24
34
  * Executes an org-scoped GraphQL query against the App Management API. Uses typed documents.
25
35
  *
@@ -1 +1 @@
1
- {"version":3,"file":"app-management.js","sourceRoot":"","sources":["../../../../src/public/node/api/app-management.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgC,iBAAiB,EAAC,MAAM,cAAc,CAAA;AAC7E,OAAO,EAAC,iBAAiB,EAAC,MAAM,oBAAoB,CAAA;AACpD,OAAO,EAAC,sBAAsB,EAAC,MAAM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AM,gBAAgB,GAAW,EAAE,CAAA;IACnC,KAAK,MAAM,WAAW,IAAK,QAAQ,CAAC,UAA+B,CAAC,YAAY,EAAE,CAAC;QACjF,IAAI,WAAW,CAAC,kBAAkB,EAAE,CAAC;YACnC,gBAAgB,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,WAAW,CAAC,kBAAkB,CAAC,CAAC,CAAA;QACjE,CAAC;IACH,CAAC;IAED,sBAAsB,CAAC,gBAAgB,CAAC,CAAA;AAC1C,CAAC","sourcesContent":["import {CacheOptions, GraphQLResponse, graphqlRequestDoc} from './graphql.js'\nimport {appManagementFqdn} from '../context/fqdn.js'\nimport {setNextDeprecationDate} from '../../../private/node/context/deprecations-store.js'\nimport Bottleneck from 'bottleneck'\nimport {TypedDocumentNode} from '@graphql-typed-document-node/core'\nimport {Variables} from 'graphql-request'\n\n// API Rate limiter for partners API (Limit is 10 requests per second)\n// Jobs are launched every 150ms to add an extra 50ms margin per request.\n// Only 10 requests can be executed concurrently.\nconst limiter = new Bottleneck({\n minTime: 150,\n maxConcurrent: 10,\n})\n\nasync function setupRequest(orgId: string, token: string) {\n const api = 'App Management'\n const fqdn = await appManagementFqdn()\n const url = `https://${fqdn}/app_management/unstable/organizations/${orgId}/graphql.json`\n return {\n token,\n api,\n url,\n responseOptions: {onResponse: handleDeprecations},\n }\n}\n\n/**\n * Executes an org-scoped GraphQL query against the App Management API. Uses typed documents.\n *\n * @param orgId - The organization ID.\n * @param query - GraphQL query to execute.\n * @param token - Partners token.\n * @param variables - GraphQL variables to pass to the query.\n * @param cacheOptions - Cache options for the request. If not present, the request will not be cached.\n * @returns The response of the query of generic type <T>.\n */\nexport async function appManagementRequestDoc<TResult, TVariables extends Variables>(\n orgId: string,\n query: TypedDocumentNode<TResult, TVariables>,\n token: string,\n variables?: TVariables,\n cacheOptions?: CacheOptions,\n): Promise<TResult> {\n // For app management, we need to cache the response based on the orgId.\n const cacheExtraKey = (cacheOptions?.cacheExtraKey ?? '') + orgId\n const newCacheOptions = cacheOptions ? {...cacheOptions, cacheExtraKey} : undefined\n\n const result = limiter.schedule<TResult>(async () =>\n graphqlRequestDoc<TResult, TVariables>({\n ...(await setupRequest(orgId, token)),\n query,\n variables,\n cacheOptions: newCacheOptions,\n }),\n )\n\n return result\n}\n\ninterface Deprecation {\n supportedUntilDate?: string\n}\n\ninterface WithDeprecations {\n deprecations: Deprecation[]\n}\n\n/**\n * Sets the next deprecation date from [GraphQL response extensions](https://www.apollographql.com/docs/resources/graphql-glossary/#extensions)\n * if `response.extensions.deprecations` objects contain a `supportedUntilDate` (ISO 8601-formatted string).\n *\n * @param response - The response of the query.\n */\nexport function handleDeprecations<T>(response: GraphQLResponse<T>): void {\n if (!response.extensions) return\n\n const deprecationDates: Date[] = []\n for (const deprecation of (response.extensions as WithDeprecations).deprecations) {\n if (deprecation.supportedUntilDate) {\n deprecationDates.push(new Date(deprecation.supportedUntilDate))\n }\n }\n\n setNextDeprecationDate(deprecationDates)\n}\n"]}
1
+ {"version":3,"file":"app-management.js","sourceRoot":"","sources":["../../../../src/public/node/api/app-management.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgC,iBAAiB,EAAC,MAAM,cAAc,CAAA;AAC7E,OAAO,EAAC,+BAA+B,EAAC,MAAM,gBAAgB,CAAA;AAC9D,OAAO,EAAC,iBAAiB,EAAC,MAAM,oBAAoB,CAAA;AACpD,OAAO,EAAC,sBAAsB,EAAC,MAAM,qDAAqD,CAAA;AAC1F,OAAO,EAAC,YAAY,EAAC,MAAM,sCAAsC,CAAA;AACjE,OAAO,UAAU,MAAM,YAAY,CAAA;AAInC,sEAAsE;AACtE,yEAAyE;AACzE,iDAAiD;AACjD,MAAM,OAAO,GAAG,IAAI,UAAU,CAAC;IAC7B,OAAO,EAAE,GAAG;IACZ,aAAa,EAAE,EAAE;CAClB,CAAC,CAAA;AAEF,KAAK,UAAU,YAAY,CAAC,KAAa,EAAE,KAAa;IACtD,MAAM,GAAG,GAAG,gBAAgB,CAAA;IA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;AACf,CAAC;AAUD;;;;;GAKG;AACH,MAAM,UAAU,kBAAkB,CAAI,QAA4B;IAChE,IAAI,CAAC,QAAQ,CAAC,UAAU;QAAE,OAAM;IAEhC,MAAM,gBAAgB,GAAW,EAAE,CAAA;IACnC,KAAK,MAAM,WAAW,IAAK,QAAQ,CAAC,UAA+B,CAAC,YAAY,EAAE,CAAC;QACjF,IAAI,WAAW,CAAC,kBAAkB,EAAE,CAAC;YACnC,gBAAgB,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,WAAW,CAAC,kBAAkB,CAAC,CAAC,CAAA;QACjE,CAAC;IACH,CAAC;IAED,sBAAsB,CAAC,gBAAgB,CAAC,CAAA;AAC1C,CAAC","sourcesContent":["import {CacheOptions, GraphQLResponse, graphqlRequestDoc} from './graphql.js'\nimport {addCursorAndFiltersToAppLogsUrl} from './utilities.js'\nimport {appManagementFqdn} from '../context/fqdn.js'\nimport {setNextDeprecationDate} from '../../../private/node/context/deprecations-store.js'\nimport {buildHeaders} from '../../../private/node/api/headers.js'\nimport Bottleneck from 'bottleneck'\nimport {TypedDocumentNode} from '@graphql-typed-document-node/core'\nimport {Variables} from 'graphql-request'\n\n// API Rate limiter for partners API (Limit is 10 requests per second)\n// Jobs are launched every 150ms to add an extra 50ms margin per request.\n// Only 10 requests can be executed concurrently.\nconst limiter = new Bottleneck({\n minTime: 150,\n maxConcurrent: 10,\n})\n\nasync function setupRequest(orgId: string, token: string) {\n const api = 'App Management'\n const fqdn = await appManagementFqdn()\n const url = `https://${fqdn}/app_management/unstable/organizations/${orgId}/graphql.json`\n return {\n token,\n api,\n url,\n responseOptions: {onResponse: handleDeprecations},\n }\n}\n\nexport const appManagementHeaders = (token: string): {[key: string]: string} => {\n return buildHeaders(token)\n}\n\nexport const appManagementAppLogsUrl = async (\n organizationId: string,\n cursor?: string,\n filters?: {\n status?: string\n source?: string\n },\n): Promise<string> => {\n const fqdn = await appManagementFqdn()\n const url = `https://${fqdn}/app_management/unstable/organizations/${organizationId}/app_logs/poll`\n return addCursorAndFiltersToAppLogsUrl(url, cursor, filters)\n}\n\n/**\n * Executes an org-scoped GraphQL query against the App Management API. Uses typed documents.\n *\n * @param orgId - The organization ID.\n * @param query - GraphQL query to execute.\n * @param token - Partners token.\n * @param variables - GraphQL variables to pass to the query.\n * @param cacheOptions - Cache options for the request. If not present, the request will not be cached.\n * @returns The response of the query of generic type <T>.\n */\nexport async function appManagementRequestDoc<TResult, TVariables extends Variables>(\n orgId: string,\n query: TypedDocumentNode<TResult, TVariables>,\n token: string,\n variables?: TVariables,\n cacheOptions?: CacheOptions,\n): Promise<TResult> {\n // For app management, we need to cache the response based on the orgId.\n const cacheExtraKey = (cacheOptions?.cacheExtraKey ?? '') + orgId\n const newCacheOptions = cacheOptions ? {...cacheOptions, cacheExtraKey} : undefined\n\n const result = limiter.schedule<TResult>(async () =>\n graphqlRequestDoc<TResult, TVariables>({\n ...(await setupRequest(orgId, token)),\n query,\n variables,\n cacheOptions: newCacheOptions,\n }),\n )\n\n return result\n}\n\ninterface Deprecation {\n supportedUntilDate?: string\n}\n\ninterface WithDeprecations {\n deprecations: Deprecation[]\n}\n\n/**\n * Sets the next deprecation date from [GraphQL response extensions](https://www.apollographql.com/docs/resources/graphql-glossary/#extensions)\n * if `response.extensions.deprecations` objects contain a `supportedUntilDate` (ISO 8601-formatted string).\n *\n * @param response - The response of the query.\n */\nexport function handleDeprecations<T>(response: GraphQLResponse<T>): void {\n if (!response.extensions) return\n\n const deprecationDates: Date[] = []\n for (const deprecation of (response.extensions as WithDeprecations).deprecations) {\n if (deprecation.supportedUntilDate) {\n deprecationDates.push(new Date(deprecation.supportedUntilDate))\n }\n }\n\n setNextDeprecationDate(deprecationDates)\n}\n"]}
@@ -1,6 +1,6 @@
1
1
  import { GraphQLVariables, GraphQLResponse, CacheOptions } from './graphql.js';
2
- import { TypedDocumentNode } from '@graphql-typed-document-node/core';
3
2
  import { Variables } from 'graphql-request';
3
+ import { TypedDocumentNode } from '@graphql-typed-document-node/core';
4
4
  /**
5
5
  * Executes a GraphQL query against the Partners API.
6
6
  *
@@ -11,6 +11,10 @@ import { Variables } from 'graphql-request';
11
11
  * @returns The response of the query of generic type <T>.
12
12
  */
13
13
  export declare function partnersRequest<T>(query: string, token: string, variables?: GraphQLVariables, cacheOptions?: CacheOptions): Promise<T>;
14
+ export declare const generateFetchAppLogUrl: (cursor?: string, filters?: {
15
+ status?: string;
16
+ source?: string;
17
+ }) => Promise<string>;
14
18
  /**
15
19
  * Executes a GraphQL query against the Partners API. Uses typed documents.
16
20
  *
@@ -1,6 +1,11 @@
1
1
  import { graphqlRequest, graphqlRequestDoc } from './graphql.js';
2
+ import { addCursorAndFiltersToAppLogsUrl } from './utilities.js';
2
3
  import { partnersFqdn } from '../context/fqdn.js';
3
4
  import { setNextDeprecationDate } from '../../../private/node/context/deprecations-store.js';
5
+ import { getPackageManager } from '../node-package-manager.js';
6
+ import { cwd } from '../path.js';
7
+ import { AbortError } from '../error.js';
8
+ import { formatPackageManagerCommand } from '../output.js';
4
9
  import Bottleneck from 'bottleneck';
5
10
  // API Rate limiter for partners API (Limit is 10 requests per second)
6
11
  // Jobs are launched every 150ms to add an extra 50ms margin per request.
@@ -44,6 +49,11 @@ export async function partnersRequest(query, token, variables, cacheOptions) {
44
49
  }));
45
50
  return result;
46
51
  }
52
+ export const generateFetchAppLogUrl = async (cursor, filters) => {
53
+ const fqdn = await partnersFqdn();
54
+ const url = `https://${fqdn}/app_logs/poll`;
55
+ return addCursorAndFiltersToAppLogsUrl(url, cursor, filters);
56
+ };
47
57
  /**
48
58
  * Executes a GraphQL query against the Partners API. Uses typed documents.
49
59
  *
@@ -53,13 +63,25 @@ export async function partnersRequest(query, token, variables, cacheOptions) {
53
63
  * @returns The response of the query of generic type <TResult>.
54
64
  */
55
65
  export async function partnersRequestDoc(query, token, variables) {
56
- const opts = await setupRequest(token);
57
- const result = limiter.schedule(() => graphqlRequestDoc({
58
- ...opts,
59
- query,
60
- variables,
61
- }));
62
- return result;
66
+ try {
67
+ const opts = await setupRequest(token);
68
+ const result = limiter.schedule(() => graphqlRequestDoc({
69
+ ...opts,
70
+ query,
71
+ variables,
72
+ }));
73
+ return result;
74
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
75
+ }
76
+ catch (error) {
77
+ if (error.errors?.[0]?.extensions?.type === 'unsupported_client_version') {
78
+ const packageManager = await getPackageManager(cwd());
79
+ throw new AbortError(['Upgrade your CLI version to run this command.'], null, [
80
+ ['Run', { command: formatPackageManagerCommand(packageManager, 'shopify upgrade') }],
81
+ ]);
82
+ }
83
+ throw error;
84
+ }
63
85
  }
64
86
  /**
65
87
  * Sets the next deprecation date from [GraphQL response extensions](https://www.apollographql.com/docs/resources/graphql-glossary/#extensions)
@@ -1 +1 @@
1
- {"version":3,"file":"partners.js","sourceRoot":"","sources":["../../../../src/public/node/api/partners.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,cAAc,EAAqC,iBAAiB,EAAe,MAAM,cAAc,CAAA;AAC/G,OAAO,EAAC,YAAY,EAAC,MAAM,oBAAoB,CAAA;AAC/C,OAAO,EAAC,sBAAsB,EAAC,MAAM,qDAAqD,CAAA;AAG1F,OAAO,UAAU,MAAM,YAAY,CAAA;AAEnC,sEAAsE;AACtE,yEAAyE;AACzE,iDAAiD;AACjD,MAAM,OAAO,GAAG,IAAI,UAAU,CAAC;IAC7B,OAAO,EAAE,GAAG;IACZ,aAAa,EAAE,EAAE;CAClB,CAAC,CAAA;AAEF;;;;GAIG;AACH,KAAK,UAAU,YAAY,CAAC,KAAa;IACvC,MAAM,GAAG,GAAG,UAAU,CAAA;IACtB,MAAM,IAAI,GAAG,MAAM,YAAY,EAAE,CAAA;IACjC,MAAM,GAAG,GAAG,WAAW,IAAI,kBAAkB,CAAA;IAC7C,OAAO;QACL,KAAK;QACL,GAAG;QACH,GAAG;QACH,eAAe,EAAE,EAAC,UAAU,EAAE,kBAAkB,EAAC;KAClD,CAAA;AACH,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,CAAC,KAAK,UAAU,eAAe,CACnC,KAAa,EACb,KAAa,EACb,SAA4B,EAC5B,YAA2B;IAE3B,MAAM,IAAI,GAAG,MAAM,YAAY,CAAC,KAAK,CAAC,CAAA;IACtC,MAAM,MAAM,GAAG,OAAO,CAAC,QAAQ,CAAC,GAAG,EAAE,CACnC,cAAc,CAAI;QAChB,GAAG,IAAI;QACP,KAAK;QACL,SAAS;QACT,YAAY;KACb,CAAC,CACH,CAAA;IAED,OAAO,MAAM,CAAA;AACf,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,CAAC,KAAK,UAAU,kBAAkB,CACtC,KAA6C,EAC7C,KAAa,EACb,SAAsB;IAEtB,MAAM,IAAI,GAAG,MAAM,YAAY,CAAC,KAAK,CAAC,CAAA;IACtC,MAAM,MAAM,GAAG,OAAO,CAAC,QAAQ,CAAC,GAAG,EAAE,CACnC,iBAAiB,CAAsB;QACrC,GAAG,IAAI;QACP,KAAK;QACL,SAAS;KACV,CAAC,CACH,CAAA;IAED,OAAO,MAAM,CAAA;AACf,CAAC;AAUD;;;;;GAKG;AACH,MAAM,UAAU,kBAAkB,CAAI,QAA4B;IAChE,IAAI,CAAC,QAAQ,CAAC,UAAU;QAAE,OAAM;IAEhC,MAAM,gBAAgB,GAAW,EAAE,CAAA;IACnC,KAAK,MAAM,WAAW,IAAK,QAAQ,CAAC,UAA+B,CAAC,YAAY,EAAE,CAAC;QACjF,IAAI,WAAW,CAAC,kBAAkB,EAAE,CAAC;YACnC,gBAAgB,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,WAAW,CAAC,kBAAkB,CAAC,CAAC,CAAA;QACjE,CAAC;IACH,CAAC;IAED,sBAAsB,CAAC,gBAAgB,CAAC,CAAA;AAC1C,CAAC","sourcesContent":["import {graphqlRequest, GraphQLVariables, GraphQLResponse, graphqlRequestDoc, CacheOptions} from './graphql.js'\nimport {partnersFqdn} from '../context/fqdn.js'\nimport {setNextDeprecationDate} from '../../../private/node/context/deprecations-store.js'\nimport {TypedDocumentNode} from '@graphql-typed-document-node/core'\nimport {Variables} from 'graphql-request'\nimport Bottleneck from 'bottleneck'\n\n// API Rate limiter for partners API (Limit is 10 requests per second)\n// Jobs are launched every 150ms to add an extra 50ms margin per request.\n// Only 10 requests can be executed concurrently.\nconst limiter = new Bottleneck({\n minTime: 150,\n maxConcurrent: 10,\n})\n\n/**\n * Sets up the request to the Partners API.\n *\n * @param token - Partners token.\n */\nasync function setupRequest(token: string) {\n const api = 'Partners'\n const fqdn = await partnersFqdn()\n const url = `https://${fqdn}/api/cli/graphql`\n return {\n token,\n api,\n url,\n responseOptions: {onResponse: handleDeprecations},\n }\n}\n\n/**\n * Executes a GraphQL query against the Partners API.\n *\n * @param query - GraphQL query to execute.\n * @param token - Partners token.\n * @param variables - GraphQL variables to pass to the query.\n * @param cacheOptions - Cache options.\n * @returns The response of the query of generic type <T>.\n */\nexport async function partnersRequest<T>(\n query: string,\n token: string,\n variables?: GraphQLVariables,\n cacheOptions?: CacheOptions,\n): Promise<T> {\n const opts = await setupRequest(token)\n const result = limiter.schedule(() =>\n graphqlRequest<T>({\n ...opts,\n query,\n variables,\n cacheOptions,\n }),\n )\n\n return result\n}\n\n/**\n * Executes a GraphQL query against the Partners API. Uses typed documents.\n *\n * @param query - GraphQL query to execute.\n * @param token - Partners token.\n * @param variables - GraphQL variables to pass to the query.\n * @returns The response of the query of generic type <TResult>.\n */\nexport async function partnersRequestDoc<TResult, TVariables extends Variables>(\n query: TypedDocumentNode<TResult, TVariables>,\n token: string,\n variables?: TVariables,\n): Promise<TResult> {\n const opts = await setupRequest(token)\n const result = limiter.schedule(() =>\n graphqlRequestDoc<TResult, TVariables>({\n ...opts,\n query,\n variables,\n }),\n )\n\n return result\n}\n\ninterface Deprecation {\n supportedUntilDate?: string\n}\n\ninterface WithDeprecations {\n deprecations: Deprecation[]\n}\n\n/**\n * Sets the next deprecation date from [GraphQL response extensions](https://www.apollographql.com/docs/resources/graphql-glossary/#extensions)\n * if `response.extensions.deprecations` objects contain a `supportedUntilDate` (ISO 8601-formatted string).\n *\n * @param response - The response of the query.\n */\nexport function handleDeprecations<T>(response: GraphQLResponse<T>): void {\n if (!response.extensions) return\n\n const deprecationDates: Date[] = []\n for (const deprecation of (response.extensions as WithDeprecations).deprecations) {\n if (deprecation.supportedUntilDate) {\n deprecationDates.push(new Date(deprecation.supportedUntilDate))\n }\n }\n\n setNextDeprecationDate(deprecationDates)\n}\n"]}
1
+ {"version":3,"file":"partners.js","sourceRoot":"","sources":["../../../../src/public/node/api/partners.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,cAAc,EAAqC,iBAAiB,EAAe,MAAM,cAAc,CAAA;AAC/G,OAAO,EAAC,+BAA+B,EAAC,MAAM,gBAAgB,CAAA;AAC9D,OAAO,EAAC,YAAY,EAAC,MAAM,oBAAoB,CAAA;AAC/C,OAAO,EAAC,sBAAsB,EAAC,MAAM,qDAAqD,CAAA;AAC1F,OAAO,EAAC,iBAAiB,EAAC,MAAM,4BAA4B,CAAA;AAC5D,OAAO,EAAC,GAAG,EAAC,MAAM,YAAY,CAAA;AAC9B,OAAO,EAAC,UAAU,EAAC,MAAM,aAAa,CAAA;AACtC,OAAO,EAAC,2BAA2B,EAAC,MAAM,cAAc,CAAA;AACxD,OAAO,UAAU,MAAM,YAAY,CAAA;AAInC,sEAAsE;AACtE,yEAAyE;AACzE,iDAAiD;AACjD,MAAM,OAAO,GAAG,IAAI,UAAU,CAAC;IAC7B,OAAO,EAAE,GAAG;IACZ,aAAa,EAAE,EAAE;CAClB,CAAC,CAAA;AAEF;;;;GAIG;AACH,KAAK,UAAU,YAAY,CAAC,KAAa;IACvC,MAAM,GAAG,GAAG,UAAU,CAAA;IACtB,MAAM,IAAI,GAAG,MAAM,YAAY,EAAE,CAAA;IACjC,MAAM,GAAG,GAAG,WAAW,IAAI,kBAAkB,CAAA;IAC7C,OAAO;QACL,KAAK;QACL,GAAG;QACH,GAAG;QACH,eAAe,EAA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AC,CAAA;YAErD,MAAM,IAAI,UAAU,CAAC,CAAC,+CAA+C,CAAC,EAAE,IAAI,EAAE;gBAC5E,CAAC,KAAK,EAAE,EAAC,OAAO,EAAE,2BAA2B,CAAC,cAAc,EAAE,iBAAiB,CAAC,EAAC,CAAC;aACnF,CAAC,CAAA;QACJ,CAAC;QAED,MAAM,KAAK,CAAA;IACb,CAAC;AACH,CAAC;AAUD;;;;;GAKG;AACH,MAAM,UAAU,kBAAkB,CAAI,QAA4B;IAChE,IAAI,CAAC,QAAQ,CAAC,UAAU;QAAE,OAAM;IAEhC,MAAM,gBAAgB,GAAW,EAAE,CAAA;IACnC,KAAK,MAAM,WAAW,IAAK,QAAQ,CAAC,UAA+B,CAAC,YAAY,EAAE,CAAC;QACjF,IAAI,WAAW,CAAC,kBAAkB,EAAE,CAAC;YACnC,gBAAgB,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,WAAW,CAAC,kBAAkB,CAAC,CAAC,CAAA;QACjE,CAAC;IACH,CAAC;IAED,sBAAsB,CAAC,gBAAgB,CAAC,CAAA;AAC1C,CAAC","sourcesContent":["import {graphqlRequest, GraphQLVariables, GraphQLResponse, graphqlRequestDoc, CacheOptions} from './graphql.js'\nimport {addCursorAndFiltersToAppLogsUrl} from './utilities.js'\nimport {partnersFqdn} from '../context/fqdn.js'\nimport {setNextDeprecationDate} from '../../../private/node/context/deprecations-store.js'\nimport {getPackageManager} from '../node-package-manager.js'\nimport {cwd} from '../path.js'\nimport {AbortError} from '../error.js'\nimport {formatPackageManagerCommand} from '../output.js'\nimport Bottleneck from 'bottleneck'\nimport {Variables} from 'graphql-request'\nimport {TypedDocumentNode} from '@graphql-typed-document-node/core'\n\n// API Rate limiter for partners API (Limit is 10 requests per second)\n// Jobs are launched every 150ms to add an extra 50ms margin per request.\n// Only 10 requests can be executed concurrently.\nconst limiter = new Bottleneck({\n minTime: 150,\n maxConcurrent: 10,\n})\n\n/**\n * Sets up the request to the Partners API.\n *\n * @param token - Partners token.\n */\nasync function setupRequest(token: string) {\n const api = 'Partners'\n const fqdn = await partnersFqdn()\n const url = `https://${fqdn}/api/cli/graphql`\n return {\n token,\n api,\n url,\n responseOptions: {onResponse: handleDeprecations},\n }\n}\n\n/**\n * Executes a GraphQL query against the Partners API.\n *\n * @param query - GraphQL query to execute.\n * @param token - Partners token.\n * @param variables - GraphQL variables to pass to the query.\n * @param cacheOptions - Cache options.\n * @returns The response of the query of generic type <T>.\n */\nexport async function partnersRequest<T>(\n query: string,\n token: string,\n variables?: GraphQLVariables,\n cacheOptions?: CacheOptions,\n): Promise<T> {\n const opts = await setupRequest(token)\n const result = limiter.schedule(() =>\n graphqlRequest<T>({\n ...opts,\n query,\n variables,\n cacheOptions,\n }),\n )\n\n return result\n}\n\nexport const generateFetchAppLogUrl = async (\n cursor?: string,\n filters?: {\n status?: string\n source?: string\n },\n): Promise<string> => {\n const fqdn = await partnersFqdn()\n const url = `https://${fqdn}/app_logs/poll`\n return addCursorAndFiltersToAppLogsUrl(url, cursor, filters)\n}\n\n/**\n * Executes a GraphQL query against the Partners API. Uses typed documents.\n *\n * @param query - GraphQL query to execute.\n * @param token - Partners token.\n * @param variables - GraphQL variables to pass to the query.\n * @returns The response of the query of generic type <TResult>.\n */\nexport async function partnersRequestDoc<TResult, TVariables extends Variables>(\n query: TypedDocumentNode<TResult, TVariables>,\n token: string,\n variables?: TVariables,\n): Promise<TResult> {\n try {\n const opts = await setupRequest(token)\n const result = limiter.schedule(() =>\n graphqlRequestDoc<TResult, TVariables>({\n ...opts,\n query,\n variables,\n }),\n )\n\n return result\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n } catch (error: any) {\n if (error.errors?.[0]?.extensions?.type === 'unsupported_client_version') {\n const packageManager = await getPackageManager(cwd())\n\n throw new AbortError(['Upgrade your CLI version to run this command.'], null, [\n ['Run', {command: formatPackageManagerCommand(packageManager, 'shopify upgrade')}],\n ])\n }\n\n throw error\n }\n}\n\ninterface Deprecation {\n supportedUntilDate?: string\n}\n\ninterface WithDeprecations {\n deprecations: Deprecation[]\n}\n\n/**\n * Sets the next deprecation date from [GraphQL response extensions](https://www.apollographql.com/docs/resources/graphql-glossary/#extensions)\n * if `response.extensions.deprecations` objects contain a `supportedUntilDate` (ISO 8601-formatted string).\n *\n * @param response - The response of the query.\n */\nexport function handleDeprecations<T>(response: GraphQLResponse<T>): void {\n if (!response.extensions) return\n\n const deprecationDates: Date[] = []\n for (const deprecation of (response.extensions as WithDeprecations).deprecations) {\n if (deprecation.supportedUntilDate) {\n deprecationDates.push(new Date(deprecation.supportedUntilDate))\n }\n }\n\n setNextDeprecationDate(deprecationDates)\n}\n"]}
@@ -0,0 +1,4 @@
1
+ export declare const addCursorAndFiltersToAppLogsUrl: (baseUrl: string, cursor?: string, filters?: {
2
+ status?: string;
3
+ source?: string;
4
+ }) => string;
@@ -0,0 +1,14 @@
1
+ export const addCursorAndFiltersToAppLogsUrl = (baseUrl, cursor, filters) => {
2
+ const url = new URL(baseUrl);
3
+ if (cursor) {
4
+ url.searchParams.append('cursor', cursor);
5
+ }
6
+ if (filters?.status) {
7
+ url.searchParams.append('status', filters.status);
8
+ }
9
+ if (filters?.source) {
10
+ url.searchParams.append('source', filters.source);
11
+ }
12
+ return url.toString();
13
+ };
14
+ //# sourceMappingURL=utilities.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utilities.js","sourceRoot":"","sources":["../../../../src/public/node/api/utilities.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,+BAA+B,GAAG,CAC7C,OAAe,EACf,MAAe,EACf,OAGC,EACO,EAAE;IACV,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,OAAO,CAAC,CAAA;IAE5B,IAAI,MAAM,EAAE,CAAC;QACX,GAAG,CAAC,YAAY,CAAC,MAAM,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAA;IAC3C,CAAC;IAED,IAAI,OAAO,EAAE,MAAM,EAAE,CAAC;QACpB,GAAG,CAAC,YAAY,CAAC,MAAM,CAAC,QAAQ,EAAE,OAAO,CAAC,MAAM,CAAC,CAAA;IACnD,CAAC;IAED,IAAI,OAAO,EAAE,MAAM,EAAE,CAAC;QACpB,GAAG,CAAC,YAAY,CAAC,MAAM,CAAC,QAAQ,EAAE,OAAO,CAAC,MAAM,CAAC,CAAA;IACnD,CAAC;IAED,OAAO,GAAG,CAAC,QAAQ,EAAE,CAAA;AACvB,CAAC,CAAA","sourcesContent":["export const addCursorAndFiltersToAppLogsUrl = (\n baseUrl: string,\n cursor?: string,\n filters?: {\n status?: string\n source?: string\n },\n): string => {\n const url = new URL(baseUrl)\n\n if (cursor) {\n url.searchParams.append('cursor', cursor)\n }\n\n if (filters?.status) {\n url.searchParams.append('status', filters.status)\n }\n\n if (filters?.source) {\n url.searchParams.append('source', filters.source)\n }\n\n return url.toString()\n}\n"]}
@@ -8,9 +8,9 @@ interface ZipOptions {
8
8
  */
9
9
  outputZipPath: string;
10
10
  /**
11
- * Pattern to match when adding files to zip, uses glob expressions.
11
+ * Pattern(s) to match when adding files to zip, uses glob expressions.
12
12
  */
13
- matchFilePattern?: string;
13
+ matchFilePattern?: string | string[];
14
14
  }
15
15
  /**
16
16
  * It zips a directory and by default normalizes the paths to be forward-slash.
@@ -1 +1 @@
1
- {"version":3,"file":"archiver.js","sourceRoot":"","sources":["../../../src/public/node/archiver.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,YAAY,EAAC,MAAM,WAAW,CAAA;AACtC,OAAO,EAAC,IAAI,EAAC,MAAM,SAAS,CAAA;AAC5B,OAAO,EAAC,WAAW,EAAE,aAAa,EAAE,WAAW,EAAC,MAAM,6BAA6B,CAAA;AACnF,OAAO,QAAQ,MAAM,UAAU,CAAA;AAC/B,OAAO,EAAC,iBAAiB,EAAC,MAAM,IAAI,CAAA;AAmBpC;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,GAAG,CAAC,OAAmB;IAC3C,MAAM,EAAC,cAAc,EAAE,aAAa,EAAE,gBAAgB,GAAG,MAAM,EAAC,GAAG,OAAO,CAAA;IAC1E,WAAW,CAAC,aAAa,CAAA,WAAW,WAAW,CAAC,IAAI,CAAC,cAAc,CAAC,SAAS,WAAW,CAAC,IAAI,CAAC,aAAa,CAAC,EAAE,CAAC,CAAA;IAC/G,MAAM,UAAU,GAAG,MAAM,IAAI,CAAC,gBAAgB,EAAE;QAC9C,GAAG,EAAE,cAAc;QACnB,QAAQ,EAAE,IAAI;QACd,GAAG,EAAE,IAAI;QACT,mBAAmB,EAAE,KAAK;KAC3B,CAAC,CAAA;IAEF,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACrC,MAAM,OAAO,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAA;QAE/B,MAAM,MAAM,GAAG,iBAAiB,CAAC,aAAa,CAAC,CAAA;QAC/C,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE,GAAG,EAAE;YACtB,OAAO,EAAE,CAAA;QACX,CAAC,CAAC,CAAA;QACF,OAAO,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,KAAK,EAAE,EAAE;YAC5B,MAAM,CAAC,KAAK,CAAC,CAAA;QACf,CAAC,CAAC,CAAA;QACF,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;QAEpB,KAAK,MAAM,QAAQ,IAAI,UAAU,EAAE,CAAC;YAClC,MAAM,gBAAgB,GAAG,YAAY,CAAC,cAAc,EAAE,QAAQ,CAAC,CAAA;YAC/D,OAAO,CAAC,IAAI,CAAC,QAAQ,EAAE,EAAC,IAAI,EAAE,gBAAgB,EAAC,CAAC,CAAA;QAClD,CAAC;QAED,mEAAmE;QACnE,OAAO,CAAC,QAAQ,EAAE,CAAA;IACpB,CAAC,CAAC,CAAA;AACJ,CAAC","sourcesContent":["import {relativePath} from './path.js'\nimport {glob} from './fs.js'\nimport {outputDebug, outputContent, outputToken} from '../../public/node/output.js'\nimport archiver from 'archiver'\nimport {createWriteStream} from 'fs'\n\ninterface ZipOptions {\n /**\n * The absolute path to the directory to be zipped.\n */\n inputDirectory: string\n\n /**\n * The absolute path to the output zip file.\n */\n outputZipPath: string\n\n /**\n * Pattern to match when adding files to zip, uses glob expressions.\n */\n matchFilePattern?: string\n}\n\n/**\n * It zips a directory and by default normalizes the paths to be forward-slash.\n * Even with forward-slash paths, zip files should still be able to be opened on\n * Windows.\n *\n * @param options - ZipOptions.\n */\nexport async function zip(options: ZipOptions): Promise<void> {\n const {inputDirectory, outputZipPath, matchFilePattern = '**/*'} = options\n outputDebug(outputContent`Zipping ${outputToken.path(inputDirectory)} into ${outputToken.path(outputZipPath)}`)\n const pathsToZip = await glob(matchFilePattern, {\n cwd: inputDirectory,\n absolute: true,\n dot: true,\n followSymbolicLinks: false,\n })\n\n return new Promise((resolve, reject) => {\n const archive = archiver('zip')\n\n const output = createWriteStream(outputZipPath)\n output.on('close', () => {\n resolve()\n })\n archive.on('error', (error) => {\n reject(error)\n })\n archive.pipe(output)\n\n for (const filePath of pathsToZip) {\n const fileRelativePath = relativePath(inputDirectory, filePath)\n archive.file(filePath, {name: fileRelativePath})\n }\n\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\n archive.finalize()\n })\n}\n"]}
1
+ {"version":3,"file":"archiver.js","sourceRoot":"","sources":["../../../src/public/node/archiver.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,YAAY,EAAC,MAAM,WAAW,CAAA;AACtC,OAAO,EAAC,IAAI,EAAC,MAAM,SAAS,CAAA;AAC5B,OAAO,EAAC,WAAW,EAAE,aAAa,EAAE,WAAW,EAAC,MAAM,6BAA6B,CAAA;AACnF,OAAO,QAAQ,MAAM,UAAU,CAAA;AAC/B,OAAO,EAAC,iBAAiB,EAAC,MAAM,IAAI,CAAA;AAmBpC;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,GAAG,CAAC,OAAmB;IAC3C,MAAM,EAAC,cAAc,EAAE,aAAa,EAAE,gBAAgB,GAAG,MAAM,EAAC,GAAG,OAAO,CAAA;IAC1E,WAAW,CAAC,aAAa,CAAA,WAAW,WAAW,CAAC,IAAI,CAAC,cAAc,CAAC,SAAS,WAAW,CAAC,IAAI,CAAC,aAAa,CAAC,EAAE,CAAC,CAAA;IAC/G,MAAM,UAAU,GAAG,MAAM,IAAI,CAAC,gBAAgB,EAAE;QAC9C,GAAG,EAAE,cAAc;QACnB,QAAQ,EAAE,IAAI;QACd,GAAG,EAAE,IAAI;QACT,mBAAmB,EAAE,KAAK;KAC3B,CAAC,CAAA;IAEF,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACrC,MAAM,OAAO,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAA;QAE/B,MAAM,MAAM,GAAG,iBAAiB,CAAC,aAAa,CAAC,CAAA;QAC/C,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE,GAAG,EAAE;YACtB,OAAO,EAAE,CAAA;QACX,CAAC,CAAC,CAAA;QACF,OAAO,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,KAAK,EAAE,EAAE;YAC5B,MAAM,CAAC,KAAK,CAAC,CAAA;QACf,CAAC,CAAC,CAAA;QACF,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;QAEpB,KAAK,MAAM,QAAQ,IAAI,UAAU,EAAE,CAAC;YAClC,MAAM,gBAAgB,GAAG,YAAY,CAAC,cAAc,EAAE,QAAQ,CAAC,CAAA;YAC/D,OAAO,CAAC,IAAI,CAAC,QAAQ,EAAE,EAAC,IAAI,EAAE,gBAAgB,EAAC,CAAC,CAAA;QAClD,CAAC;QAED,mEAAmE;QACnE,OAAO,CAAC,QAAQ,EAAE,CAAA;IACpB,CAAC,CAAC,CAAA;AACJ,CAAC","sourcesContent":["import {relativePath} from './path.js'\nimport {glob} from './fs.js'\nimport {outputDebug, outputContent, outputToken} from '../../public/node/output.js'\nimport archiver from 'archiver'\nimport {createWriteStream} from 'fs'\n\ninterface ZipOptions {\n /**\n * The absolute path to the directory to be zipped.\n */\n inputDirectory: string\n\n /**\n * The absolute path to the output zip file.\n */\n outputZipPath: string\n\n /**\n * Pattern(s) to match when adding files to zip, uses glob expressions.\n */\n matchFilePattern?: string | string[]\n}\n\n/**\n * It zips a directory and by default normalizes the paths to be forward-slash.\n * Even with forward-slash paths, zip files should still be able to be opened on\n * Windows.\n *\n * @param options - ZipOptions.\n */\nexport async function zip(options: ZipOptions): Promise<void> {\n const {inputDirectory, outputZipPath, matchFilePattern = '**/*'} = options\n outputDebug(outputContent`Zipping ${outputToken.path(inputDirectory)} into ${outputToken.path(outputZipPath)}`)\n const pathsToZip = await glob(matchFilePattern, {\n cwd: inputDirectory,\n absolute: true,\n dot: true,\n followSymbolicLinks: false,\n })\n\n return new Promise((resolve, reject) => {\n const archive = archiver('zip')\n\n const output = createWriteStream(outputZipPath)\n output.on('close', () => {\n resolve()\n })\n archive.on('error', (error) => {\n reject(error)\n })\n archive.pipe(output)\n\n for (const filePath of pathsToZip) {\n const fileRelativePath = relativePath(inputDirectory, filePath)\n archive.file(filePath, {name: fileRelativePath})\n }\n\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\n archive.finalize()\n })\n}\n"]}
@@ -15,6 +15,13 @@ export declare function partnersFqdn(): Promise<string>;
15
15
  * @returns Fully-qualified domain of the App Management service we should interact with.
16
16
  */
17
17
  export declare function appManagementFqdn(): Promise<string>;
18
+ /**
19
+ * It returns the App Dev API service we should interact with.
20
+ *
21
+ * @param storeFqdn - The store FQDN.
22
+ * @returns Fully-qualified domain of the App Dev service we should interact with.
23
+ */
24
+ export declare function appDevFqdn(storeFqdn: string): Promise<string>;
18
25
  /**
19
26
  * It returns the Developer Dashboard domain we should interact with.
20
27
  *
@@ -44,6 +44,21 @@ export async function appManagementFqdn() {
44
44
  return productionFqdn;
45
45
  }
46
46
  }
47
+ /**
48
+ * It returns the App Dev API service we should interact with.
49
+ *
50
+ * @param storeFqdn - The store FQDN.
51
+ * @returns Fully-qualified domain of the App Dev service we should interact with.
52
+ */
53
+ export async function appDevFqdn(storeFqdn) {
54
+ const environment = serviceEnvironment();
55
+ switch (environment) {
56
+ case 'local':
57
+ return new DevServerCore().host('app');
58
+ default:
59
+ return storeFqdn;
60
+ }
61
+ }
47
62
  /**
48
63
  * It returns the Developer Dashboard domain we should interact with.
49
64
  *
@@ -1 +1 @@
1
- {"version":3,"file":"fqdn.js","sourceRoot":"","sources":["../../../../src/public/node/context/fqdn.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,QAAQ,EAAC,MAAM,WAAW,CAAA;AAClC,OAAO,EAAC,UAAU,EAAE,QAAQ,EAAC,MAAM,aAAa,CAAA;AAChD,OAAO,EAAC,kBAAkB,EAAC,MAAM,0CAA0C,CAAA;AAC3E,OAAO,EAAC,SAAS,EAAE,aAAa,EAAC,MAAM,+BAA+B,CAAA;AACtE,OAAO,EAAC,mBAAmB,EAAC,MAAM,mBAAmB,CAAA;AAErD,MAAM,CAAC,MAAM,kCAAkC,GAAG,IAAI,UAAU,CAC9D,iGAAiG,CAClG,CAAA;AACD,MAAM,CAAC,MAAM,kCAAkC,GAAG,IAAI,UAAU,CAC9D,iGAAiG,CAClG,CAAA;AACD,MAAM,CAAC,MAAM,iCAAiC,GAAG,IAAI,UAAU,CAC7D,gGAAgG,CACjG,CAAA;AACD,MAAM,CAAC,MAAM,yBAAyB,GAAG,IAAI,UAAU,CACrD,2EAA2E,CAC5E,CAAA;AAED;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,YAAY;IAChC,IAAI,mBAAmB,EAAE,EAAE,CAAC;QAC1B,MAAM,IAAI,QAAQ,CAAC,yFAAyF,CAAC,CAAA;IAC/G,CAAC;IACD,MAAM,WAAW,GAAG,kBAAkB,EAAE,CAAA;IACxC,MAAM,cAAc,GAAG,sBAAsB,CAAA;IAC7C,QAAQ,WAAW,EAAE,CAAC;QACpB,KAAK,OAAO;YACV,OAAO,IAAI,SAAS,CAAC,UAAU,CAAC,CAAC,IAAI,EAAE,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ACpE,CAAC","sourcesContent":["import {spinFqdn} from './spin.js'\nimport {AbortError, BugError} from '../error.js'\nimport {serviceEnvironment} from '../../../private/node/context/service.js'\nimport {DevServer, DevServerCore} from '../vendor/dev_server/index.js'\nimport {blockPartnersAccess} from '../environment.js'\n\nexport const CouldntObtainPartnersSpinFQDNError = new AbortError(\n \"Couldn't obtain the Spin FQDN for Partners when the CLI is not running from a Spin environment.\",\n)\nexport const CouldntObtainIdentitySpinFQDNError = new AbortError(\n \"Couldn't obtain the Spin FQDN for Identity when the CLI is not running from a Spin environment.\",\n)\nexport const CouldntObtainShopifySpinFQDNError = new AbortError(\n \"Couldn't obtain the Spin FQDN for Shopify when the CLI is not running from a Spin environment.\",\n)\nexport const NotProvidedStoreFQDNError = new AbortError(\n \"Couldn't obtain the Shopify FQDN because the store FQDN was not provided.\",\n)\n\n/**\n * It returns the Partners' API service we should interact with.\n *\n * @returns Fully-qualified domain of the partners service we should interact with.\n */\nexport async function partnersFqdn(): Promise<string> {\n if (blockPartnersAccess()) {\n throw new BugError('Partners API is blocked by the SHOPIFY_CLI_NEVER_USE_PARTNERS_API environment variable.')\n }\n const environment = serviceEnvironment()\n const productionFqdn = 'partners.shopify.com'\n switch (environment) {\n case 'local':\n return new DevServer('partners').host()\n case 'spin':\n return `partners.${await spinFqdn()}`\n default:\n return productionFqdn\n }\n}\n\n/**\n * It returns the App Management API service we should interact with.\n *\n * @returns Fully-qualified domain of the App Management service we should interact with.\n */\nexport async function appManagementFqdn(): Promise<string> {\n const environment = serviceEnvironment()\n const productionFqdn = 'app.shopify.com'\n switch (environment) {\n case 'local':\n return new DevServerCore().host('app')\n case 'spin':\n return `app.shopify.${await spinFqdn()}`\n default:\n return productionFqdn\n }\n}\n\n/**\n * It returns the Developer Dashboard domain we should interact with.\n *\n * @returns Fully-qualified domain of the Developer Dashboard we should interact with.\n */\nexport async function developerDashboardFqdn(): Promise<string> {\n const environment = serviceEnvironment()\n const productionFqdn = 'dev.shopify.com'\n switch (environment) {\n case 'local':\n return new DevServerCore().host('dev')\n case 'spin':\n return `dev.shopify.${await spinFqdn()}`\n default:\n return productionFqdn\n }\n}\n\n/**\n * It returns the BusinessPlatform' API service we should interact with.\n *\n * @returns Fully-qualified domain of the partners service we should interact with.\n */\nexport async function businessPlatformFqdn(): Promise<string> {\n const environment = serviceEnvironment()\n const productionFqdn = 'destinations.shopifysvc.com'\n switch (environment) {\n case 'local':\n return new DevServer('business-platform').host()\n case 'spin':\n return `business-platform.${await spinFqdn()}`\n default:\n return productionFqdn\n }\n}\n\n/**\n * It returns the Identity service we should interact with.\n *\n * @returns Fully-qualified domain of the Identity service we should interact with.\n */\nexport async function identityFqdn(): Promise<string> {\n const environment = serviceEnvironment()\n const productionFqdn = 'accounts.shopify.com'\n switch (environment) {\n case 'local':\n return new DevServer('identity').host()\n case 'spin':\n return `identity.${await spinFqdn()}`\n default:\n return productionFqdn\n }\n}\n\n/**\n * Normalize the store name to be used in the CLI.\n * It will add the .myshopify.com domain if it's not present.\n * It will add the spin domain if it's not present and we're in a Spin environment.\n *\n * @param store - Store name.\n * @returns Normalized store name.\n */\nexport async function normalizeStoreFqdn(store: string): Promise<string> {\n const storeFqdn = store.replace(/^https?:\\/\\//, '').replace(/\\/$/, '')\n const addDomain = async (storeFqdn: string) => {\n switch (serviceEnvironment()) {\n case 'local':\n return new DevServerCore().host(storeFqdn)\n case 'spin':\n return `${storeFqdn}.shopify.${await spinFqdn()}`\n default:\n return `${storeFqdn}.myshopify.com`\n }\n }\n const containDomain = (storeFqdn: string) =>\n storeFqdn.includes('.myshopify.com') ||\n storeFqdn.includes('spin.dev') ||\n storeFqdn.includes('shopify.io') ||\n storeFqdn.includes('.shop.dev')\n return containDomain(storeFqdn) ? storeFqdn : addDomain(storeFqdn)\n}\n"]}
1
+ {"version":3,"file":"fqdn.js","sourceRoot":"","sources":["../../../../src/public/node/context/fqdn.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,QAAQ,EAAC,MAAM,WAAW,CAAA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serviceEnvironment} from '../../../private/node/context/service.js'\nimport {DevServer, DevServerCore} from '../vendor/dev_server/index.js'\nimport {blockPartnersAccess} from '../environment.js'\n\nexport const CouldntObtainPartnersSpinFQDNError = new AbortError(\n \"Couldn't obtain the Spin FQDN for Partners when the CLI is not running from a Spin environment.\",\n)\nexport const CouldntObtainIdentitySpinFQDNError = new AbortError(\n \"Couldn't obtain the Spin FQDN for Identity when the CLI is not running from a Spin environment.\",\n)\nexport const CouldntObtainShopifySpinFQDNError = new AbortError(\n \"Couldn't obtain the Spin FQDN for Shopify when the CLI is not running from a Spin environment.\",\n)\nexport const NotProvidedStoreFQDNError = new AbortError(\n \"Couldn't obtain the Shopify FQDN because the store FQDN was not provided.\",\n)\n\n/**\n * It returns the Partners' API service we should interact with.\n *\n * @returns Fully-qualified domain of the partners service we should interact with.\n */\nexport async function partnersFqdn(): Promise<string> {\n if (blockPartnersAccess()) {\n throw new BugError('Partners API is blocked by the SHOPIFY_CLI_NEVER_USE_PARTNERS_API environment variable.')\n }\n const environment = serviceEnvironment()\n const productionFqdn = 'partners.shopify.com'\n switch (environment) {\n case 'local':\n return new DevServer('partners').host()\n case 'spin':\n return `partners.${await spinFqdn()}`\n default:\n return productionFqdn\n }\n}\n\n/**\n * It returns the App Management API service we should interact with.\n *\n * @returns Fully-qualified domain of the App Management service we should interact with.\n */\nexport async function appManagementFqdn(): Promise<string> {\n const environment = serviceEnvironment()\n const productionFqdn = 'app.shopify.com'\n switch (environment) {\n case 'local':\n return new DevServerCore().host('app')\n case 'spin':\n return `app.shopify.${await spinFqdn()}`\n default:\n return productionFqdn\n }\n}\n\n/**\n * It returns the App Dev API service we should interact with.\n *\n * @param storeFqdn - The store FQDN.\n * @returns Fully-qualified domain of the App Dev service we should interact with.\n */\nexport async function appDevFqdn(storeFqdn: string): Promise<string> {\n const environment = serviceEnvironment()\n switch (environment) {\n case 'local':\n return new DevServerCore().host('app')\n default:\n return storeFqdn\n }\n}\n/**\n * It returns the Developer Dashboard domain we should interact with.\n *\n * @returns Fully-qualified domain of the Developer Dashboard we should interact with.\n */\nexport async function developerDashboardFqdn(): Promise<string> {\n const environment = serviceEnvironment()\n const productionFqdn = 'dev.shopify.com'\n switch (environment) {\n case 'local':\n return new DevServerCore().host('dev')\n case 'spin':\n return `dev.shopify.${await spinFqdn()}`\n default:\n return productionFqdn\n }\n}\n\n/**\n * It returns the BusinessPlatform' API service we should interact with.\n *\n * @returns Fully-qualified domain of the partners service we should interact with.\n */\nexport async function businessPlatformFqdn(): Promise<string> {\n const environment = serviceEnvironment()\n const productionFqdn = 'destinations.shopifysvc.com'\n switch (environment) {\n case 'local':\n return new DevServer('business-platform').host()\n case 'spin':\n return `business-platform.${await spinFqdn()}`\n default:\n return productionFqdn\n }\n}\n\n/**\n * It returns the Identity service we should interact with.\n *\n * @returns Fully-qualified domain of the Identity service we should interact with.\n */\nexport async function identityFqdn(): Promise<string> {\n const environment = serviceEnvironment()\n const productionFqdn = 'accounts.shopify.com'\n switch (environment) {\n case 'local':\n return new DevServer('identity').host()\n case 'spin':\n return `identity.${await spinFqdn()}`\n default:\n return productionFqdn\n }\n}\n\n/**\n * Normalize the store name to be used in the CLI.\n * It will add the .myshopify.com domain if it's not present.\n * It will add the spin domain if it's not present and we're in a Spin environment.\n *\n * @param store - Store name.\n * @returns Normalized store name.\n */\nexport async function normalizeStoreFqdn(store: string): Promise<string> {\n const storeFqdn = store.replace(/^https?:\\/\\//, '').replace(/\\/$/, '')\n const addDomain = async (storeFqdn: string) => {\n switch (serviceEnvironment()) {\n case 'local':\n return new DevServerCore().host(storeFqdn)\n case 'spin':\n return `${storeFqdn}.shopify.${await spinFqdn()}`\n default:\n return `${storeFqdn}.myshopify.com`\n }\n }\n const containDomain = (storeFqdn: string) =>\n storeFqdn.includes('.myshopify.com') ||\n storeFqdn.includes('spin.dev') ||\n storeFqdn.includes('shopify.io') ||\n storeFqdn.includes('.shop.dev')\n return containDomain(storeFqdn) ? storeFqdn : addDomain(storeFqdn)\n}\n"]}
@@ -48,78 +48,85 @@ const reportError = async (error, config) => {
48
48
  * @returns the reported error (this may have been tweaked for better reporting), and a bool to indicate if the error was actually submitted or not
49
49
  */
50
50
  export async function sendErrorToBugsnag(error, exitMode) {
51
- if (settings.debug) {
52
- outputDebug(`Skipping Bugsnag report`);
53
- return { reported: false, error, unhandled: undefined };
54
- }
55
- // If the error was unexpected, we flag it as "unhandled" in Bugsnag. This is a helpful distinction.
56
- const unhandled = exitMode === 'unexpected_error';
57
- let reportableError;
58
- let stacktrace;
59
- let report = false;
60
- if (error instanceof Error) {
61
- report = true;
62
- reportableError = new Error(error.message);
63
- stacktrace = error.stack;
64
- /**
65
- * Some errors that reach this point have an empty string. For example:
66
- * https://app.bugsnag.com/shopify/cli/errors/62cd5d31fd5040000814086c?filters[event.since]=30d&filters[error.status]=new&filters[release.seen_in]=3.1.0
67
- *
68
- * Because at this point we have neither the error message nor a stack trace reporting them
69
- * to Bugsnag is pointless and adds noise.
70
- */
71
- }
72
- else if (typeof error === 'string' && error.trim().length !== 0) {
73
- report = true;
74
- reportableError = new Error(error);
75
- stacktrace = reportableError.stack;
76
- }
77
- else {
78
- report = false;
79
- reportableError = new Error('Unknown error');
80
- }
81
- const formattedStacktrace = new StackTracey(stacktrace ?? '')
82
- .clean()
83
- .items.map((item) => {
84
- const filePath = cleanSingleStackTracePath(item.file);
85
- return ` at ${item.callee} (${filePath}:${item.line}:${item.column})`;
86
- })
87
- .join('\n');
88
- reportableError.stack = `Error: ${reportableError.message}\n${formattedStacktrace}`;
89
- let withinRateLimit = false;
90
- await runWithRateLimit({
91
- key: 'send-error-to-bugsnag',
92
- ...reportingRateLimit,
93
- task: async () => {
94
- withinRateLimit = true;
95
- },
96
- });
97
- if (!withinRateLimit) {
98
- outputDebug(`Skipping Bugsnag report due to rate limiting`);
99
- report = false;
100
- }
101
- if (report) {
102
- initializeBugsnag();
103
- await new Promise((resolve, reject) => {
104
- outputDebug(`Reporting ${unhandled ? 'unhandled' : 'handled'} error to Bugsnag: ${reportableError.message}`);
105
- const eventHandler = (event) => {
106
- event.severity = 'error';
107
- event.unhandled = unhandled;
108
- };
109
- const errorHandler = (error) => {
110
- if (error) {
111
- reject(error);
112
- }
113
- else {
114
- resolve(reportableError);
115
- }
116
- };
117
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
118
- // @ts-ignore
119
- Bugsnag.notify(reportableError, eventHandler, errorHandler);
51
+ try {
52
+ if (settings.debug) {
53
+ outputDebug(`Skipping Bugsnag report`);
54
+ return { reported: false, error, unhandled: undefined };
55
+ }
56
+ // If the error was unexpected, we flag it as "unhandled" in Bugsnag. This is a helpful distinction.
57
+ const unhandled = exitMode === 'unexpected_error';
58
+ let reportableError;
59
+ let stacktrace;
60
+ let report = false;
61
+ if (error instanceof Error) {
62
+ report = true;
63
+ reportableError = new Error(error.message);
64
+ stacktrace = error.stack;
65
+ /**
66
+ * Some errors that reach this point have an empty string. For example:
67
+ * https://app.bugsnag.com/shopify/cli/errors/62cd5d31fd5040000814086c?filters[event.since]=30d&filters[error.status]=new&filters[release.seen_in]=3.1.0
68
+ *
69
+ * Because at this point we have neither the error message nor a stack trace reporting them
70
+ * to Bugsnag is pointless and adds noise.
71
+ */
72
+ }
73
+ else if (typeof error === 'string' && error.trim().length !== 0) {
74
+ report = true;
75
+ reportableError = new Error(error);
76
+ stacktrace = reportableError.stack;
77
+ }
78
+ else {
79
+ report = false;
80
+ reportableError = new Error('Unknown error');
81
+ }
82
+ const formattedStacktrace = new StackTracey(stacktrace ?? '')
83
+ .clean()
84
+ .items.map((item) => {
85
+ const filePath = cleanSingleStackTracePath(item.file);
86
+ return ` at ${item.callee} (${filePath}:${item.line}:${item.column})`;
87
+ })
88
+ .join('\n');
89
+ reportableError.stack = `Error: ${reportableError.message}\n${formattedStacktrace}`;
90
+ let withinRateLimit = false;
91
+ await runWithRateLimit({
92
+ key: 'send-error-to-bugsnag',
93
+ ...reportingRateLimit,
94
+ task: async () => {
95
+ withinRateLimit = true;
96
+ },
120
97
  });
98
+ if (!withinRateLimit) {
99
+ outputDebug(`Skipping Bugsnag report due to rate limiting`);
100
+ report = false;
101
+ }
102
+ if (report) {
103
+ initializeBugsnag();
104
+ await new Promise((resolve, reject) => {
105
+ outputDebug(`Reporting ${unhandled ? 'unhandled' : 'handled'} error to Bugsnag: ${reportableError.message}`);
106
+ const eventHandler = (event) => {
107
+ event.severity = 'error';
108
+ event.unhandled = unhandled;
109
+ };
110
+ const errorHandler = (error) => {
111
+ if (error) {
112
+ reject(error);
113
+ }
114
+ else {
115
+ resolve(reportableError);
116
+ }
117
+ };
118
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
119
+ // @ts-ignore
120
+ Bugsnag.notify(reportableError, eventHandler, errorHandler);
121
+ });
122
+ }
123
+ return { error: reportableError, reported: report, unhandled };
124
+ // eslint-disable-next-line no-catch-all/no-catch-all
125
+ }
126
+ catch (err) {
127
+ outputDebug(`Error reporting to Bugsnag: ${err}`);
128
+ return { error, reported: false, unhandled: undefined };
121
129
  }
122
- return { error: reportableError, reported: report, unhandled };
123
130
  }
124
131
  /**
125
132
  * If the given file path is within a node_modules folder, remove prefix up