@shopify/cli-kit 3.78.2 → 3.79.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/dist/private/node/analytics.d.ts +1 -0
- package/dist/private/node/analytics.js +2 -0
- package/dist/private/node/analytics.js.map +1 -1
- package/dist/private/node/session/exchange.d.ts +20 -2
- package/dist/private/node/session/exchange.js +36 -9
- package/dist/private/node/session/exchange.js.map +1 -1
- package/dist/private/node/session/scopes.d.ts +6 -0
- package/dist/private/node/session/scopes.js +17 -0
- package/dist/private/node/session/scopes.js.map +1 -1
- package/dist/private/node/ui/components/TextAnimation.js +8 -3
- package/dist/private/node/ui/components/TextAnimation.js.map +1 -1
- package/dist/public/common/array.d.ts +19 -0
- package/dist/public/common/array.js +33 -0
- package/dist/public/common/array.js.map +1 -1
- package/dist/public/common/object.d.ts +11 -3
- package/dist/public/common/object.js +11 -0
- package/dist/public/common/object.js.map +1 -1
- package/dist/public/common/version.d.ts +1 -1
- package/dist/public/common/version.js +1 -1
- package/dist/public/common/version.js.map +1 -1
- package/dist/public/node/api/app-management.d.ts +6 -1
- package/dist/public/node/api/app-management.js +3 -1
- package/dist/public/node/api/app-management.js.map +1 -1
- package/dist/public/node/api/business-platform.d.ts +2 -2
- package/dist/public/node/api/business-platform.js.map +1 -1
- package/dist/public/node/api/graphql.d.ts +2 -0
- package/dist/public/node/api/graphql.js +1 -1
- package/dist/public/node/api/graphql.js.map +1 -1
- package/dist/public/node/api/partners.d.ts +5 -2
- package/dist/public/node/api/partners.js +6 -2
- package/dist/public/node/api/partners.js.map +1 -1
- package/dist/public/node/context/local.d.ts +0 -7
- package/dist/public/node/context/local.js +0 -10
- package/dist/public/node/context/local.js.map +1 -1
- package/dist/public/node/environment.js +2 -2
- package/dist/public/node/environment.js.map +1 -1
- package/dist/public/node/error-handler.js +4 -0
- package/dist/public/node/error-handler.js.map +1 -1
- package/dist/public/node/github.js +1 -1
- package/dist/public/node/github.js.map +1 -1
- package/dist/public/node/hidden-folder.d.ts +8 -0
- package/dist/public/node/hidden-folder.js +27 -0
- package/dist/public/node/hidden-folder.js.map +1 -0
- package/dist/public/node/http.d.ts +1 -1
- package/dist/public/node/http.js.map +1 -1
- package/dist/public/node/is-global.d.ts +0 -6
- package/dist/public/node/is-global.js +4 -20
- package/dist/public/node/is-global.js.map +1 -1
- package/dist/public/node/monorail.d.ts +1 -1
- package/dist/public/node/monorail.js +1 -1
- package/dist/public/node/monorail.js.map +1 -1
- package/dist/public/node/multiple-installation-warning.d.ts +10 -0
- package/dist/public/node/multiple-installation-warning.js +45 -0
- package/dist/public/node/multiple-installation-warning.js.map +1 -0
- package/dist/public/node/notifications-system.js +13 -11
- package/dist/public/node/notifications-system.js.map +1 -1
- package/dist/public/node/session.d.ts +1 -0
- package/dist/public/node/session.js +11 -1
- package/dist/public/node/session.js.map +1 -1
- package/dist/public/node/system.d.ts +6 -0
- package/dist/public/node/system.js +9 -0
- package/dist/public/node/system.js.map +1 -1
- package/dist/public/node/tcp.js +10 -1
- package/dist/public/node/tcp.js.map +1 -1
- package/dist/public/node/themes/api.js +1 -1
- package/dist/public/node/themes/api.js.map +1 -1
- package/dist/public/node/ui/components.d.ts +1 -0
- package/dist/public/node/ui/components.js +1 -0
- package/dist/public/node/ui/components.js.map +1 -1
- package/dist/public/node/version.js +13 -4
- package/dist/public/node/version.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +2 -1
|
@@ -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,+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;
|
|
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;AAEjE,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;IAC5B,MAAM,IAAI,GAAG,MAAM,iBAAiB,EAAE,CAAA;IACtC,MAAM,GAAG,GAAG,WAAW,IAAI,0CAA0C,KAAK,eAAe,CAAA;IACzF,OAAO;QACL,KAAK;QACL,GAAG;QACH,GAAG;QACH,eAAe,EAAE,EAAC,UAAU,EAAE,kBAAkB,EAAC;KAClD,CAAA;AACH,CAAC;AAED,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,KAAa,EAA2B,EAAE;IAC7E,OAAO,YAAY,CAAC,KAAK,CAAC,CAAA;AAC5B,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,uBAAuB,GAAG,KAAK,EAC1C,cAAsB,EACtB,MAAe,EACf,OAGC,EACgB,EAAE;IACnB,MAAM,IAAI,GAAG,MAAM,iBAAiB,EAAE,CAAA;IACtC,MAAM,GAAG,GAAG,WAAW,IAAI,0CAA0C,cAAc,gBAAgB,CAAA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orAndFiltersToAppLogsUrl} 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 {RequestModeInput} from '../http.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\nexport interface RequestOptions {\n requestMode: RequestModeInput\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 * @param requestOptions - Preferred behaviour for the request.\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 requestOptions?: RequestOptions,\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 preferredBehaviour: requestOptions?.requestMode,\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"]}
|
|
@@ -40,6 +40,6 @@ export declare function businessPlatformOrganizationsRequest<T>(query: string, t
|
|
|
40
40
|
* @param variables - GraphQL variables to pass to the query.
|
|
41
41
|
* @returns The response of the query of generic type <T>.
|
|
42
42
|
*/
|
|
43
|
-
export declare function businessPlatformOrganizationsRequestDoc<TResult>(query: TypedDocumentNode<TResult,
|
|
43
|
+
export declare function businessPlatformOrganizationsRequestDoc<TResult, TVariables extends Variables>(query: TypedDocumentNode<TResult, TVariables> | TypedDocumentNode<TResult, Exact<{
|
|
44
44
|
[key: string]: never;
|
|
45
|
-
}>>, token: string, organizationId: string, variables?:
|
|
45
|
+
}>>, token: string, organizationId: string, variables?: TVariables): Promise<TResult>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"business-platform.js","sourceRoot":"","sources":["../../../../src/public/node/api/business-platform.ts"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;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,oCAAoC,CACxD,KAAa,EACb,KAAa,EACb,cAAsB,EACtB,SAA4B;IAE5B,OAAO,cAAc,CAAI;QACvB,KAAK;QACL,GAAG,CAAC,MAAM,yBAAyB,CAAC,KAAK,EAAE,cAAc,CAAC,CAAC;QAC3D,SAAS;KACV,CAAC,CAAA;AACJ,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,CAAC,KAAK,UAAU,uCAAuC,CAC3D,
|
|
1
|
+
{"version":3,"file":"business-platform.js","sourceRoot":"","sources":["../../../../src/public/node/api/business-platform.ts"],"names":[],"mappings":"AAAA,OAAO,EAAwC,cAAc,EAAE,iBAAiB,EAAC,MAAM,cAAc,CAAA;AACrG,OAAO,EAAC,kBAAkB,EAAC,MAAM,eAAe,CAAA;AAChD,OAAO,EAAC,oBAAoB,EAAC,MAAM,oBAAoB,CAAA;AAIvD;;;;GAIG;AACH,KAAK,UAAU,YAAY,CAAC,KAAa;IACvC,MAAM,GAAG,GAAG,kBAAkB,CAAA;IAC9B,MAAM,IAAI,GAAG,MAAM,oBAAoB,EAAE,CAAA;IACzC,MAAM,GAAG,GAAG,WAAW,IAAI,mCAAmC,CAAA;IAC9D,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,uBAAuB,CAC3C,KAAa,EACb,KAAa,EACb,SAA4B,EAC5B,YAA2B;IAE3B,OAAO,cAAc,CAAI;QACvB,GAAG,CAAC,MAAM,YAAY,CAAC,KAAK,CAAC,CAAC;QAC9B,KAAK;QACL,SAAS;QACT,YAAY;KACb,CAAC,CAAA;AACJ,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,CAAC,KAAK,UAAU,0BAA0B,CAC9C,KAA6C,EAC7C,KAAa,EACb,SAAsB,EACtB,YAA2B;IAE3B,OAAO,iBAAiB,CAAsB;QAC5C,GAAG,CAAC,MAAM,YAAY,CAAC,KAAK,CAAC,CAAC;QAC9B,KAAK;QACL,SAAS;QACT,YAAY;KACb,CAAC,CAAA;AACJ,CAAC;AAED;;;;;GAKG;AACH,KAAK,UAAU,yBAAyB,CAAC,KAAa,EAAE,cAAsB;IAC5E,MAAM,GAAG,GAAG,kBAAkB,CAAA;IAC9B,MAAM,IAAI,GAAG,MAAM,oBAAoB,EAAE,CAAA;IACzC,MAAM,GAAG,GAAG,WAAW,IAAI,4CAA4C,cAAc,UAAU,CAAA;IAC/F,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,oCAAoC,CACxD,KAAa,EACb,KAAa,EACb,cAAsB,EACtB,SAA4B;IAE5B,OAAO,cAAc,CAAI;QACvB,KAAK;QACL,GAAG,CAAC,MAAM,yBAAyB,CAAC,KAAK,EAAE,cAAc,CAAC,CAAC;QAC3D,SAAS;KACV,CAAC,CAAA;AACJ,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,CAAC,KAAK,UAAU,uCAAuC,CAC3D,KAAyG,EACzG,KAAa,EACb,cAAsB,EACtB,SAAsB;IAEtB,OAAO,iBAAiB,CAAsB;QAC5C,KAAK;QACL,GAAG,CAAC,MAAM,yBAAyB,CAAC,KAAK,EAAE,cAAc,CAAC,CAAC;QAC3D,SAAS;KACV,CAAC,CAAA;AACJ,CAAC","sourcesContent":["import {CacheOptions, Exact, GraphQLVariables, graphqlRequest, graphqlRequestDoc} from './graphql.js'\nimport {handleDeprecations} from './partners.js'\nimport {businessPlatformFqdn} from '../context/fqdn.js'\nimport {TypedDocumentNode} from '@graphql-typed-document-node/core'\nimport {Variables} from 'graphql-request'\n\n/**\n * Sets up the request to the Business Platform Destinations API.\n *\n * @param token - Business Platform token.\n */\nasync function setupRequest(token: string) {\n const api = 'BusinessPlatform'\n const fqdn = await businessPlatformFqdn()\n const url = `https://${fqdn}/destinations/api/2020-07/graphql`\n return {\n token,\n api,\n url,\n responseOptions: {onResponse: handleDeprecations},\n }\n}\n\n/**\n * Executes a GraphQL query against the Business Platform Destinations API.\n *\n * @param query - GraphQL query to execute.\n * @param token - Business Platform 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 businessPlatformRequest<T>(\n query: string,\n token: string,\n variables?: GraphQLVariables,\n cacheOptions?: CacheOptions,\n): Promise<T> {\n return graphqlRequest<T>({\n ...(await setupRequest(token)),\n query,\n variables,\n cacheOptions,\n })\n}\n\n/**\n * Executes a GraphQL query against the Business Platform Destinations API. Uses typed documents.\n *\n * @param query - GraphQL query to execute.\n * @param token - Business Platform 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 <TResult>.\n */\nexport async function businessPlatformRequestDoc<TResult, TVariables extends Variables>(\n query: TypedDocumentNode<TResult, TVariables>,\n token: string,\n variables?: TVariables,\n cacheOptions?: CacheOptions,\n): Promise<TResult> {\n return graphqlRequestDoc<TResult, TVariables>({\n ...(await setupRequest(token)),\n query,\n variables,\n cacheOptions,\n })\n}\n\n/**\n * Sets up the request to the Business Platform Organizations API.\n *\n * @param token - Business Platform token.\n * @param organizationId - Organization ID as a numeric (non-GID) value.\n */\nasync function setupOrganizationsRequest(token: string, organizationId: string) {\n const api = 'BusinessPlatform'\n const fqdn = await businessPlatformFqdn()\n const url = `https://${fqdn}/organizations/api/unstable/organization/${organizationId}/graphql`\n return {\n token,\n api,\n url,\n responseOptions: {onResponse: handleDeprecations},\n }\n}\n\n/**\n * Executes a GraphQL query against the Business Platform Organizations API.\n *\n * @param query - GraphQL query to execute.\n * @param token - Business Platform token.\n * @param organizationId - Organization ID as a numeric (non-GID) value.\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 businessPlatformOrganizationsRequest<T>(\n query: string,\n token: string,\n organizationId: string,\n variables?: GraphQLVariables,\n): Promise<T> {\n return graphqlRequest<T>({\n query,\n ...(await setupOrganizationsRequest(token, organizationId)),\n variables,\n })\n}\n\n/**\n * Executes a GraphQL query against the Business Platform Organizations API. Uses typed documents.\n *\n * @param query - GraphQL query to execute.\n * @param token - Business Platform token.\n * @param organizationId - Organization ID as a numeric value.\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 businessPlatformOrganizationsRequestDoc<TResult, TVariables extends Variables>(\n query: TypedDocumentNode<TResult, TVariables> | TypedDocumentNode<TResult, Exact<{[key: string]: never}>>,\n token: string,\n organizationId: string,\n variables?: TVariables,\n): Promise<TResult> {\n return graphqlRequestDoc<TResult, TVariables>({\n query,\n ...(await setupOrganizationsRequest(token, organizationId)),\n variables,\n })\n}\n"]}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { ConfSchema, TimeInterval } from '../../../private/node/conf-store.js';
|
|
2
2
|
import { LocalStorage } from '../local-storage.js';
|
|
3
|
+
import { RequestModeInput } from '../http.js';
|
|
3
4
|
import { rawRequest, RequestDocument, Variables } from 'graphql-request';
|
|
4
5
|
import { TypedDocumentNode } from '@graphql-typed-document-node/core';
|
|
5
6
|
export type Exact<T extends {
|
|
@@ -25,6 +26,7 @@ interface GraphQLRequestBaseOptions<TResult> {
|
|
|
25
26
|
};
|
|
26
27
|
responseOptions?: GraphQLResponseOptions<TResult>;
|
|
27
28
|
cacheOptions?: CacheOptions;
|
|
29
|
+
preferredBehaviour?: RequestModeInput;
|
|
28
30
|
}
|
|
29
31
|
export type GraphQLRequestOptions<T> = GraphQLRequestBaseOptions<T> & {
|
|
30
32
|
query: RequestDocument;
|
|
@@ -20,7 +20,7 @@ async function performGraphQLRequest(options) {
|
|
|
20
20
|
...buildHeaders(token),
|
|
21
21
|
};
|
|
22
22
|
debugLogRequestInfo(api, queryAsString, url, variables, headers);
|
|
23
|
-
const requestBehaviour = requestMode('default');
|
|
23
|
+
const requestBehaviour = requestMode(options.preferredBehaviour ?? 'default');
|
|
24
24
|
const clientOptions = { agent: await httpsAgent(), headers };
|
|
25
25
|
const client = new GraphQLClient(url, clientOptions);
|
|
26
26
|
const performRequest = async () => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"graphql.js","sourceRoot":"","sources":["../../../../src/public/node/api/graphql.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,YAAY,EAAE,UAAU,EAAC,MAAM,sCAAsC,CAAA;AAC7E,OAAO,EAAC,mBAAmB,EAAE,YAAY,EAAC,MAAM,sCAAsC,CAAA;AACtF,OAAO,EAAC,iBAAiB,EAAE,YAAY,EAAC,MAAM,gBAAgB,CAAA;AAC9D,OAAO,EAAC,iBAAiB,EAAC,MAAM,8BAA8B,CAAA;AAC9D,OAAO,EAAC,oBAAoB,EAAC,MAAM,sCAAsC,CAAA;AACzE,OAAO,EAAC,aAAa,EAAC,MAAM,cAAc,CAAA;AAC1C,OAAO,EACL,yBAAyB,EAIzB,0BAA0B,GAC3B,MAAM,qCAAqC,CAAA;AAE5C,OAAO,EAAC,+BAA+B,EAAE,WAAW,EAAC,MAAM,YAAY,CAAA;AACvE,OAAO,EACL,aAAa,EAGb,sBAAsB,EAEtB,WAAW,GACZ,MAAM,iBAAiB,CAAA;AAExB,OAAO,EAAC,eAAe,EAAC,MAAM,iCAAiC,CAAA;AAkD/D;;;;GAIG;AACH,KAAK,UAAU,qBAAqB,CAAU,OAA8C;IAC1F,MAAM,EAAC,KAAK,EAAE,YAAY,EAAE,aAAa,EAAE,SAAS,EAAE,GAAG,EAAE,GAAG,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,YAAY,CAAC,SAAS,CAAC,CAAA;QAC5C,MAAM,iBAAiB,CAAC,GAAG,EAAE,CAAC,CAAC;YAC7B,+BAA+B,EAAE,SAAS,IAAI,SAAS;SACxD,CAAC,CAAC,CAAA;QACH,qDAAqD;IACvD,CAAC;IAAC,MAAM,CAAC;QACP,0CAA0C;IAC5C,CAAC;AACH,CAAC;AAED;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,cAAc,CAAI,OAAiC;IACvE,OAAO,qBAAqB,CAAI;QAC9B,GAAG,OAAO;QACV,aAAa,EAAE,OAAO,CAAC,KAAe;KACvC,CAAC,CAAA;AACJ,CAAC;AAED;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,iBAAiB,CACrC,OAAsD;IAEtD,OAAO,qBAAqB,CAAU;QACpC,GAAG,OAAO;QACV,aAAa,EAAE,sBAAsB,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,KAAK;KAC3D,CAAC,CAAA;AACJ,CAAC","sourcesContent":["import {buildHeaders, httpsAgent} from '../../../private/node/api/headers.js'\nimport {debugLogRequestInfo, errorHandler} from '../../../private/node/api/graphql.js'\nimport {addPublicMetadata, runWithTimer} from '../metadata.js'\nimport {retryAwareRequest} from '../../../private/node/api.js'\nimport {requestIdsCollection} from '../../../private/node/request-ids.js'\nimport {nonRandomUUID} from '../crypto.js'\nimport {\n cacheRetrieveOrRepopulate,\n ConfSchema,\n GraphQLRequestKey,\n TimeInterval,\n timeIntervalToMilliseconds,\n} from '../../../private/node/conf-store.js'\nimport {LocalStorage} from '../local-storage.js'\nimport {abortSignalFromRequestBehaviour, requestMode} from '../http.js'\nimport {\n GraphQLClient,\n rawRequest,\n RequestDocument,\n resolveRequestDocument,\n Variables,\n ClientError,\n} from 'graphql-request'\nimport {TypedDocumentNode} from '@graphql-typed-document-node/core'\nimport {CLI_KIT_VERSION} from '@shopify/cli-kit/common/version'\n\n// to replace TVariable type when there graphql query has no variables\nexport type Exact<T extends {[key: string]: unknown}> = {[K in keyof T]: T[K]}\n\nexport interface GraphQLVariables {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n [key: string]: any\n}\n\nexport type GraphQLResponse<T> = Awaited<ReturnType<typeof rawRequest<T>>>\n\nexport interface CacheOptions {\n cacheTTL: TimeInterval\n cacheExtraKey?: string\n cacheStore?: LocalStorage<ConfSchema>\n}\n\ninterface GraphQLRequestBaseOptions<TResult> {\n api: string\n url: string\n token?: string\n addedHeaders?: {[header: string]: string}\n responseOptions?: GraphQLResponseOptions<TResult>\n cacheOptions?: CacheOptions\n}\n\ntype PerformGraphQLRequestOptions<TResult> = GraphQLRequestBaseOptions<TResult> & {\n queryAsString: string\n variables?: Variables\n unauthorizedHandler?: () => Promise<void>\n}\n\nexport type GraphQLRequestOptions<T> = GraphQLRequestBaseOptions<T> & {\n query: RequestDocument\n variables?: Variables\n unauthorizedHandler?: () => Promise<void>\n}\n\nexport type GraphQLRequestDocOptions<TResult, TVariables> = GraphQLRequestBaseOptions<TResult> & {\n query: TypedDocumentNode<TResult, TVariables> | TypedDocumentNode<TResult, Exact<{[key: string]: never}>>\n variables?: TVariables\n unauthorizedHandler?: () => Promise<void>\n}\n\nexport interface GraphQLResponseOptions<T> {\n handleErrors?: boolean\n onResponse?: (response: GraphQLResponse<T>) => void\n}\n\n/**\n * Handles execution of a GraphQL query.\n *\n * @param options - GraphQL request options.\n */\nasync function performGraphQLRequest<TResult>(options: PerformGraphQLRequestOptions<TResult>) {\n const {token, addedHeaders, queryAsString, variables, api, url, responseOptions, unauthorizedHandler, cacheOptions} =\n options\n const headers = {\n ...addedHeaders,\n ...buildHeaders(token),\n }\n\n debugLogRequestInfo(api, queryAsString, url, variables, headers)\n\n const requestBehaviour = requestMode('default')\n\n const clientOptions = {agent: await httpsAgent(), headers}\n const client = new GraphQLClient(url, clientOptions)\n\n const performRequest = async () => {\n let fullResponse: GraphQLResponse<TResult>\n // there is a errorPolicy option which returns rather than throwing on errors, but we _do_ ultimately want to\n // throw.\n try {\n // mapping signal to any due to polyfill meaning types don't exactly match (but are functionally equivalent)\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n client.requestConfig.signal = abortSignalFromRequestBehaviour(requestBehaviour) as any\n fullResponse = await client.rawRequest<TResult>(queryAsString, variables)\n await logLastRequestIdFromResponse(fullResponse)\n return fullResponse\n } catch (error) {\n if (error instanceof ClientError) {\n // error.response does have a headers property like a normal response, but it's not typed as such.\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n await logLastRequestIdFromResponse(error.response as any)\n }\n throw error\n }\n }\n\n const executeWithTimer = () =>\n runWithTimer('cmd_all_timing_network_ms')(async () => {\n const response = await retryAwareRequest(\n {request: performRequest, url, ...requestBehaviour},\n responseOptions?.handleErrors === false ? undefined : errorHandler(api),\n unauthorizedHandler,\n )\n\n if (responseOptions?.onResponse) {\n responseOptions.onResponse(response)\n }\n return response.data\n })\n\n // If there is no cache config for this query, just execute it and return the result.\n if (cacheOptions === undefined) {\n return executeWithTimer()\n }\n\n const {cacheTTL, cacheExtraKey, cacheStore} = cacheOptions\n\n // The cache key is a combination of the hashed query and variables, with an optional extra key provided by the user.\n const queryHash = nonRandomUUID(queryAsString)\n const variablesHash = nonRandomUUID(JSON.stringify(variables ?? {}))\n const cacheKey: GraphQLRequestKey = `q-${queryHash}-${variablesHash}-${CLI_KIT_VERSION}-${cacheExtraKey ?? ''}`\n\n const result = await cacheRetrieveOrRepopulate(\n cacheKey,\n async () => {\n const result = await executeWithTimer()\n return JSON.stringify(result)\n },\n timeIntervalToMilliseconds(cacheTTL),\n cacheStore,\n )\n\n return JSON.parse(result) as TResult\n}\n\nasync function logLastRequestIdFromResponse(response: GraphQLResponse<unknown>) {\n try {\n const requestId = response.headers.get('x-request-id')\n requestIdsCollection.addRequestId(requestId)\n await addPublicMetadata(() => ({\n cmd_all_last_graphql_request_id: requestId ?? undefined,\n }))\n // eslint-disable-next-line no-catch-all/no-catch-all\n } catch {\n // no problem if unable to get request ID.\n }\n}\n\n/**\n * Executes a GraphQL query to an endpoint.\n *\n * @param options - GraphQL request options.\n * @returns The response of the query of generic type <T>.\n */\nexport async function graphqlRequest<T>(options: GraphQLRequestOptions<T>): Promise<T> {\n return performGraphQLRequest<T>({\n ...options,\n queryAsString: options.query as string,\n })\n}\n\n/**\n * Executes a GraphQL query to an endpoint. Uses typed documents.\n *\n * @param options - GraphQL request options.\n * @returns The response of the query of generic type <TResult>.\n */\nexport async function graphqlRequestDoc<TResult, TVariables extends Variables>(\n options: GraphQLRequestDocOptions<TResult, TVariables>,\n): Promise<TResult> {\n return performGraphQLRequest<TResult>({\n ...options,\n queryAsString: resolveRequestDocument(options.query).query,\n })\n}\n"]}
|
|
1
|
+
{"version":3,"file":"graphql.js","sourceRoot":"","sources":["../../../../src/public/node/api/graphql.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,YAAY,EAAE,UAAU,EAAC,MAAM,sCAAsC,CAAA;AAC7E,OAAO,EAAC,mBAAmB,EAAE,YAAY,EAAC,MAAM,sCAAsC,CAAA;AACtF,OAAO,EAAC,iBAAiB,EAAE,YAAY,EAAC,MAAM,gBAAgB,CAAA;AAC9D,OAAO,EAAC,iBAAiB,EAAC,MAAM,8BAA8B,CAAA;AAC9D,OAAO,EAAC,oBAAoB,EAAC,MAAM,sCAAsC,CAAA;AACzE,OAAO,EAAC,aAAa,EAAC,MAAM,cAAc,CAAA;AAC1C,OAAO,EACL,yBAAyB,EAIzB,0BAA0B,GAC3B,MAAM,qCAAqC,CAAA;AAE5C,OAAO,EAAC,+BAA+B,EAAE,WAAW,EAAmB,MAAM,YAAY,CAAA;AACzF,OAAO,EACL,aAAa,EAGb,sBAAsB,EAEtB,WAAW,GACZ,MAAM,iBAAiB,CAAA;AAExB,OAAO,EAAC,eAAe,EAAC,MAAM,iCAAiC,CAAA;AAmD/D;;;;GAIG;AACH,KAAK,UAAU,qBAAqB,CAAU,OAA8C;IAC1F,MAAM,EAAC,KAAK,EAAE,YAAY,EAAE,aAAa,EAAE,SAA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AC,GAAG,CAAC,cAAc,CAAC,CAAA;QACtD,oBAAoB,CAAC,YAAY,CAAC,SAAS,CAAC,CAAA;QAC5C,MAAM,iBAAiB,CAAC,GAAG,EAAE,CAAC,CAAC;YAC7B,+BAA+B,EAAE,SAAS,IAAI,SAAS;SACxD,CAAC,CAAC,CAAA;QACH,qDAAqD;IACvD,CAAC;IAAC,MAAM,CAAC;QACP,0CAA0C;IAC5C,CAAC;AACH,CAAC;AAED;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,cAAc,CAAI,OAAiC;IACvE,OAAO,qBAAqB,CAAI;QAC9B,GAAG,OAAO;QACV,aAAa,EAAE,OAAO,CAAC,KAAe;KACvC,CAAC,CAAA;AACJ,CAAC;AAED;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,iBAAiB,CACrC,OAAsD;IAEtD,OAAO,qBAAqB,CAAU;QACpC,GAAG,OAAO;QACV,aAAa,EAAE,sBAAsB,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,KAAK;KAC3D,CAAC,CAAA;AACJ,CAAC","sourcesContent":["import {buildHeaders, httpsAgent} from '../../../private/node/api/headers.js'\nimport {debugLogRequestInfo, errorHandler} from '../../../private/node/api/graphql.js'\nimport {addPublicMetadata, runWithTimer} from '../metadata.js'\nimport {retryAwareRequest} from '../../../private/node/api.js'\nimport {requestIdsCollection} from '../../../private/node/request-ids.js'\nimport {nonRandomUUID} from '../crypto.js'\nimport {\n cacheRetrieveOrRepopulate,\n ConfSchema,\n GraphQLRequestKey,\n TimeInterval,\n timeIntervalToMilliseconds,\n} from '../../../private/node/conf-store.js'\nimport {LocalStorage} from '../local-storage.js'\nimport {abortSignalFromRequestBehaviour, requestMode, RequestModeInput} from '../http.js'\nimport {\n GraphQLClient,\n rawRequest,\n RequestDocument,\n resolveRequestDocument,\n Variables,\n ClientError,\n} from 'graphql-request'\nimport {TypedDocumentNode} from '@graphql-typed-document-node/core'\nimport {CLI_KIT_VERSION} from '@shopify/cli-kit/common/version'\n\n// to replace TVariable type when there graphql query has no variables\nexport type Exact<T extends {[key: string]: unknown}> = {[K in keyof T]: T[K]}\n\nexport interface GraphQLVariables {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n [key: string]: any\n}\n\nexport type GraphQLResponse<T> = Awaited<ReturnType<typeof rawRequest<T>>>\n\nexport interface CacheOptions {\n cacheTTL: TimeInterval\n cacheExtraKey?: string\n cacheStore?: LocalStorage<ConfSchema>\n}\n\ninterface GraphQLRequestBaseOptions<TResult> {\n api: string\n url: string\n token?: string\n addedHeaders?: {[header: string]: string}\n responseOptions?: GraphQLResponseOptions<TResult>\n cacheOptions?: CacheOptions\n preferredBehaviour?: RequestModeInput\n}\n\ntype PerformGraphQLRequestOptions<TResult> = GraphQLRequestBaseOptions<TResult> & {\n queryAsString: string\n variables?: Variables\n unauthorizedHandler?: () => Promise<void>\n}\n\nexport type GraphQLRequestOptions<T> = GraphQLRequestBaseOptions<T> & {\n query: RequestDocument\n variables?: Variables\n unauthorizedHandler?: () => Promise<void>\n}\n\nexport type GraphQLRequestDocOptions<TResult, TVariables> = GraphQLRequestBaseOptions<TResult> & {\n query: TypedDocumentNode<TResult, TVariables> | TypedDocumentNode<TResult, Exact<{[key: string]: never}>>\n variables?: TVariables\n unauthorizedHandler?: () => Promise<void>\n}\n\nexport interface GraphQLResponseOptions<T> {\n handleErrors?: boolean\n onResponse?: (response: GraphQLResponse<T>) => void\n}\n\n/**\n * Handles execution of a GraphQL query.\n *\n * @param options - GraphQL request options.\n */\nasync function performGraphQLRequest<TResult>(options: PerformGraphQLRequestOptions<TResult>) {\n const {token, addedHeaders, queryAsString, variables, api, url, responseOptions, unauthorizedHandler, cacheOptions} =\n options\n const headers = {\n ...addedHeaders,\n ...buildHeaders(token),\n }\n\n debugLogRequestInfo(api, queryAsString, url, variables, headers)\n\n const requestBehaviour = requestMode(options.preferredBehaviour ?? 'default')\n\n const clientOptions = {agent: await httpsAgent(), headers}\n const client = new GraphQLClient(url, clientOptions)\n\n const performRequest = async () => {\n let fullResponse: GraphQLResponse<TResult>\n // there is a errorPolicy option which returns rather than throwing on errors, but we _do_ ultimately want to\n // throw.\n try {\n // mapping signal to any due to polyfill meaning types don't exactly match (but are functionally equivalent)\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n client.requestConfig.signal = abortSignalFromRequestBehaviour(requestBehaviour) as any\n fullResponse = await client.rawRequest<TResult>(queryAsString, variables)\n await logLastRequestIdFromResponse(fullResponse)\n return fullResponse\n } catch (error) {\n if (error instanceof ClientError) {\n // error.response does have a headers property like a normal response, but it's not typed as such.\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n await logLastRequestIdFromResponse(error.response as any)\n }\n throw error\n }\n }\n\n const executeWithTimer = () =>\n runWithTimer('cmd_all_timing_network_ms')(async () => {\n const response = await retryAwareRequest(\n {request: performRequest, url, ...requestBehaviour},\n responseOptions?.handleErrors === false ? undefined : errorHandler(api),\n unauthorizedHandler,\n )\n\n if (responseOptions?.onResponse) {\n responseOptions.onResponse(response)\n }\n return response.data\n })\n\n // If there is no cache config for this query, just execute it and return the result.\n if (cacheOptions === undefined) {\n return executeWithTimer()\n }\n\n const {cacheTTL, cacheExtraKey, cacheStore} = cacheOptions\n\n // The cache key is a combination of the hashed query and variables, with an optional extra key provided by the user.\n const queryHash = nonRandomUUID(queryAsString)\n const variablesHash = nonRandomUUID(JSON.stringify(variables ?? {}))\n const cacheKey: GraphQLRequestKey = `q-${queryHash}-${variablesHash}-${CLI_KIT_VERSION}-${cacheExtraKey ?? ''}`\n\n const result = await cacheRetrieveOrRepopulate(\n cacheKey,\n async () => {\n const result = await executeWithTimer()\n return JSON.stringify(result)\n },\n timeIntervalToMilliseconds(cacheTTL),\n cacheStore,\n )\n\n return JSON.parse(result) as TResult\n}\n\nasync function logLastRequestIdFromResponse(response: GraphQLResponse<unknown>) {\n try {\n const requestId = response.headers.get('x-request-id')\n requestIdsCollection.addRequestId(requestId)\n await addPublicMetadata(() => ({\n cmd_all_last_graphql_request_id: requestId ?? undefined,\n }))\n // eslint-disable-next-line no-catch-all/no-catch-all\n } catch {\n // no problem if unable to get request ID.\n }\n}\n\n/**\n * Executes a GraphQL query to an endpoint.\n *\n * @param options - GraphQL request options.\n * @returns The response of the query of generic type <T>.\n */\nexport async function graphqlRequest<T>(options: GraphQLRequestOptions<T>): Promise<T> {\n return performGraphQLRequest<T>({\n ...options,\n queryAsString: options.query as string,\n })\n}\n\n/**\n * Executes a GraphQL query to an endpoint. Uses typed documents.\n *\n * @param options - GraphQL request options.\n * @returns The response of the query of generic type <TResult>.\n */\nexport async function graphqlRequestDoc<TResult, TVariables extends Variables>(\n options: GraphQLRequestDocOptions<TResult, TVariables>,\n): Promise<TResult> {\n return performGraphQLRequest<TResult>({\n ...options,\n queryAsString: resolveRequestDocument(options.query).query,\n })\n}\n"]}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { GraphQLVariables, GraphQLResponse, CacheOptions } from './graphql.js';
|
|
2
|
+
import { RequestModeInput } from '../http.js';
|
|
2
3
|
import { Variables } from 'graphql-request';
|
|
3
4
|
import { TypedDocumentNode } from '@graphql-typed-document-node/core';
|
|
4
5
|
/**
|
|
@@ -8,9 +9,10 @@ import { TypedDocumentNode } from '@graphql-typed-document-node/core';
|
|
|
8
9
|
* @param token - Partners token.
|
|
9
10
|
* @param variables - GraphQL variables to pass to the query.
|
|
10
11
|
* @param cacheOptions - Cache options.
|
|
12
|
+
* @param preferredBehaviour - Preferred behaviour for the request.
|
|
11
13
|
* @returns The response of the query of generic type <T>.
|
|
12
14
|
*/
|
|
13
|
-
export declare function partnersRequest<T>(query: string, token: string, variables?: GraphQLVariables, cacheOptions?: CacheOptions): Promise<T>;
|
|
15
|
+
export declare function partnersRequest<T>(query: string, token: string, variables?: GraphQLVariables, cacheOptions?: CacheOptions, preferredBehaviour?: RequestModeInput): Promise<T>;
|
|
14
16
|
export declare const generateFetchAppLogUrl: (cursor?: string, filters?: {
|
|
15
17
|
status?: string;
|
|
16
18
|
source?: string;
|
|
@@ -21,9 +23,10 @@ export declare const generateFetchAppLogUrl: (cursor?: string, filters?: {
|
|
|
21
23
|
* @param query - GraphQL query to execute.
|
|
22
24
|
* @param token - Partners token.
|
|
23
25
|
* @param variables - GraphQL variables to pass to the query.
|
|
26
|
+
* @param preferredBehaviour - Preferred behaviour for the request.
|
|
24
27
|
* @returns The response of the query of generic type <TResult>.
|
|
25
28
|
*/
|
|
26
|
-
export declare function partnersRequestDoc<TResult, TVariables extends Variables>(query: TypedDocumentNode<TResult, TVariables>, token: string, variables?: TVariables): Promise<TResult>;
|
|
29
|
+
export declare function partnersRequestDoc<TResult, TVariables extends Variables>(query: TypedDocumentNode<TResult, TVariables>, token: string, variables?: TVariables, preferredBehaviour?: RequestModeInput): Promise<TResult>;
|
|
27
30
|
/**
|
|
28
31
|
* Sets the next deprecation date from [GraphQL response extensions](https://www.apollographql.com/docs/resources/graphql-glossary/#extensions)
|
|
29
32
|
* if `response.extensions.deprecations` objects contain a `supportedUntilDate` (ISO 8601-formatted string).
|
|
@@ -37,15 +37,17 @@ async function setupRequest(token) {
|
|
|
37
37
|
* @param token - Partners token.
|
|
38
38
|
* @param variables - GraphQL variables to pass to the query.
|
|
39
39
|
* @param cacheOptions - Cache options.
|
|
40
|
+
* @param preferredBehaviour - Preferred behaviour for the request.
|
|
40
41
|
* @returns The response of the query of generic type <T>.
|
|
41
42
|
*/
|
|
42
|
-
export async function partnersRequest(query, token, variables, cacheOptions) {
|
|
43
|
+
export async function partnersRequest(query, token, variables, cacheOptions, preferredBehaviour) {
|
|
43
44
|
const opts = await setupRequest(token);
|
|
44
45
|
const result = limiter.schedule(() => graphqlRequest({
|
|
45
46
|
...opts,
|
|
46
47
|
query,
|
|
47
48
|
variables,
|
|
48
49
|
cacheOptions,
|
|
50
|
+
preferredBehaviour,
|
|
49
51
|
}));
|
|
50
52
|
return result;
|
|
51
53
|
}
|
|
@@ -60,15 +62,17 @@ export const generateFetchAppLogUrl = async (cursor, filters) => {
|
|
|
60
62
|
* @param query - GraphQL query to execute.
|
|
61
63
|
* @param token - Partners token.
|
|
62
64
|
* @param variables - GraphQL variables to pass to the query.
|
|
65
|
+
* @param preferredBehaviour - Preferred behaviour for the request.
|
|
63
66
|
* @returns The response of the query of generic type <TResult>.
|
|
64
67
|
*/
|
|
65
|
-
export async function partnersRequestDoc(query, token, variables) {
|
|
68
|
+
export async function partnersRequestDoc(query, token, variables, preferredBehaviour) {
|
|
66
69
|
try {
|
|
67
70
|
const opts = await setupRequest(token);
|
|
68
71
|
const result = limiter.schedule(() => graphqlRequestDoc({
|
|
69
72
|
...opts,
|
|
70
73
|
query,
|
|
71
74
|
variables,
|
|
75
|
+
preferredBehaviour,
|
|
72
76
|
}));
|
|
73
77
|
return result;
|
|
74
78
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
@@ -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,+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;
|
|
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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AAK,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 {RequestModeInput} from '../http.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 * @param preferredBehaviour - Preferred behaviour for the request.\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 preferredBehaviour?: RequestModeInput,\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 preferredBehaviour,\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 * @param preferredBehaviour - Preferred behaviour for the request.\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 preferredBehaviour?: RequestModeInput,\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 preferredBehaviour,\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"]}
|
|
@@ -25,13 +25,6 @@ export declare function isDevelopment(env?: NodeJS.ProcessEnv): boolean;
|
|
|
25
25
|
* @returns True if SHOPIFY_FLAG_VERBOSE is truthy or the flag --verbose has been passed.
|
|
26
26
|
*/
|
|
27
27
|
export declare function isVerbose(env?: NodeJS.ProcessEnv): boolean;
|
|
28
|
-
/**
|
|
29
|
-
* It returns true if the App Management API is disabled.
|
|
30
|
-
* This should only be relevant when using a Partners token.
|
|
31
|
-
*
|
|
32
|
-
* @returns True if the App Management API is disabled.
|
|
33
|
-
*/
|
|
34
|
-
export declare function isAppManagementDisabled(): boolean;
|
|
35
28
|
/**
|
|
36
29
|
* Returns true if the environment in which the CLI is running is either
|
|
37
30
|
* a local environment (where dev is present) or a cloud environment (spin).
|
|
@@ -4,7 +4,6 @@ import { getCIMetadata, isSet } from '../../../private/node/context/utilities.js
|
|
|
4
4
|
import { defaultThemeKitAccessDomain, environmentVariables, pathConstants } from '../../../private/node/constants.js';
|
|
5
5
|
import { fileExists } from '../fs.js';
|
|
6
6
|
import { exec } from '../system.js';
|
|
7
|
-
import { getPartnersToken } from '../environment.js';
|
|
8
7
|
import isInteractive from 'is-interactive';
|
|
9
8
|
import macaddress from 'macaddress';
|
|
10
9
|
import { homedir } from 'os';
|
|
@@ -42,15 +41,6 @@ export function isDevelopment(env = process.env) {
|
|
|
42
41
|
export function isVerbose(env = process.env) {
|
|
43
42
|
return isTruthy(env[environmentVariables.verbose]) || process.argv.includes('--verbose');
|
|
44
43
|
}
|
|
45
|
-
/**
|
|
46
|
-
* It returns true if the App Management API is disabled.
|
|
47
|
-
* This should only be relevant when using a Partners token.
|
|
48
|
-
*
|
|
49
|
-
* @returns True if the App Management API is disabled.
|
|
50
|
-
*/
|
|
51
|
-
export function isAppManagementDisabled() {
|
|
52
|
-
return Boolean(getPartnersToken());
|
|
53
|
-
}
|
|
54
44
|
/**
|
|
55
45
|
* Returns true if the environment in which the CLI is running is either
|
|
56
46
|
* a local environment (where dev is present) or a cloud environment (spin).
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"local.js","sourceRoot":"","sources":["../../../../src/public/node/context/local.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,MAAM,EAAC,MAAM,WAAW,CAAA;AAChC,OAAO,EAAC,QAAQ,EAAC,MAAM,gBAAgB,CAAA;AACvC,OAAO,EAAC,aAAa,EAAE,KAAK,EAAW,MAAM,4CAA4C,CAAA;AACzF,OAAO,EAAC,2BAA2B,EAAE,oBAAoB,EAAE,aAAa,EAAC,MAAM,oCAAoC,CAAA;AACnH,OAAO,EAAC,UAAU,EAAC,MAAM,UAAU,CAAA;AACnC,OAAO,EAAC,IAAI,EAAC,MAAM,cAAc,CAAA;AACjC,OAAO,EAAC,gBAAgB,EAAC,MAAM,mBAAmB,CAAA;AAClD,OAAO,aAAa,MAAM,gBAAgB,CAAA;AAC1C,OAAO,UAAU,MAAM,YAAY,CAAA;AACnC,OAAO,EAAC,OAAO,EAAC,MAAM,IAAI,CAAA;AAE1B;;;;GAIG;AACH,MAAM,UAAU,qBAAqB;IACnC,OAAO,aAAa,EAAE,CAAA;AACxB,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,aAAa;IAC3B,OAAO,OAAO,EAAE,CAAA;AAClB,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,aAAa,CAAC,GAAG,GAAG,OAAO,CAAC,GAAG;IAC7C,OAAO,GAAG,CAAC,oBAAoB,CAAC,GAAG,CAAC,KAAK,aAAa,CAAA;AACxD,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,SAAS,CAAC,GAAG,GAAG,OAAO,CAAC,GAAG;IACzC,OAAO,QAAQ,CAAC,GAAG,CAAC,oBAAoB,CAAC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B,CAAC,CAAA;IAE7D,OAAO,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,2BAA2B,CAAA;AAC7D,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,mBAAmB,CAAC,GAAG,GAAG,OAAO,CAAC,GAAG;IACnD,MAAM,MAAM,GAAG,GAAG,CAAC,oBAAoB,CAAC,OAAO,CAAC,CAAA;IAEhD,OAAO,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,iDAAiD,CAAA;AACnF,CAAC","sourcesContent":["import {isSpin} from './spin.js'\nimport {isTruthy} from './utilities.js'\nimport {getCIMetadata, isSet, Metadata} from '../../../private/node/context/utilities.js'\nimport {defaultThemeKitAccessDomain, environmentVariables, pathConstants} from '../../../private/node/constants.js'\nimport {fileExists} from '../fs.js'\nimport {exec} from '../system.js'\nimport {getPartnersToken} from '../environment.js'\nimport isInteractive from 'is-interactive'\nimport macaddress from 'macaddress'\nimport {homedir} from 'os'\n\n/**\n * It returns true if the terminal is interactive.\n *\n * @returns True if the terminal is interactive.\n */\nexport function isTerminalInteractive(): boolean {\n return isInteractive()\n}\n\n/**\n * Returns the path to the user's home directory.\n *\n * @returns The path to the user's home directory.\n */\nexport function homeDirectory(): string {\n return homedir()\n}\n\n/**\n * Returns true if the CLI is running in debug mode.\n *\n * @param env - The environment variables from the environment of the current process.\n * @returns True if SHOPIFY_ENV is development.\n */\nexport function isDevelopment(env = process.env): boolean {\n return env[environmentVariables.env] === 'development'\n}\n\n/**\n * Returns true if the CLI is running in verbose mode.\n *\n * @param env - The environment variables from the environment of the current process.\n * @returns True if SHOPIFY_FLAG_VERBOSE is truthy or the flag --verbose has been passed.\n */\nexport function isVerbose(env = process.env): boolean {\n return isTruthy(env[environmentVariables.verbose]) || process.argv.includes('--verbose')\n}\n\n/**\n * It returns true if the App Management API is disabled.\n * This should only be relevant when using a Partners token.\n *\n * @returns True if the App Management API is disabled.\n */\nexport function isAppManagementDisabled(): boolean {\n return Boolean(getPartnersToken())\n}\n\n/**\n * Returns true if the environment in which the CLI is running is either\n * a local environment (where dev is present) or a cloud environment (spin).\n *\n * @param env - The environment variables from the environment of the current process.\n * @returns True if the CLI is used in a Shopify environment.\n */\nexport async function isShopify(env = process.env): Promise<boolean> {\n if (Object.prototype.hasOwnProperty.call(env, environmentVariables.runAsUser)) {\n return !isTruthy(env[environmentVariables.runAsUser])\n }\n const devInstalled = await fileExists(pathConstants.executables.dev)\n return devInstalled || isSpin(env)\n}\n\n/**\n * This variable is used when running unit tests to indicate that the CLI's business logic\n * is run as a subject of a unit test. We can use this variable to disable output through\n * the standard streams.\n *\n * @param env - The environment variables from the environment of the current process.\n * @returns True if the SHOPIFY_UNIT_TEST environment variable is truthy.\n */\nexport function isUnitTest(env = process.env): boolean {\n return isTruthy(env[environmentVariables.unitTest])\n}\n\n/**\n * Returns true if reporting analytics is enabled.\n *\n * @param env - The environment variables from the environment of the current process.\n * @returns True unless SHOPIFY_CLI_NO_ANALYTICS is truthy or debug mode is enabled.\n */\nexport function analyticsDisabled(env = process.env): boolean {\n return isTruthy(env[environmentVariables.noAnalytics]) || isDevelopment(env)\n}\n\n/**\n * Returns true if reporting analytics should always happen, regardless of DEBUG mode etc.\n *\n * @param env - The environment variables from the environment of the current process.\n * @returns True if SHOPIFY_CLI_ALWAYS_LOG_ANALYTICS is truthy.\n */\nexport function alwaysLogAnalytics(env = process.env): boolean {\n return isTruthy(env[environmentVariables.alwaysLogAnalytics])\n}\n\n/**\n * Returns true if reporting metrics should always happen, regardless of DEBUG mode etc.\n *\n * @param env - The environment variables from the environment of the current process.\n * @returns True if SHOPIFY_CLI_ALWAYS_LOG_METRICS is truthy.\n */\nexport function alwaysLogMetrics(env = process.env): boolean {\n return isTruthy(env[environmentVariables.alwaysLogMetrics])\n}\n\n/**\n * Returns true if the CLI User is 1P.\n *\n * @param env - The environment variables from the environment of the current process.\n * @returns True if SHOPIFY_CLI_1P is truthy.\n */\nexport function firstPartyDev(env = process.env): boolean {\n return isTruthy(env[environmentVariables.firstPartyDev])\n}\n\n/**\n * Returns true if the CLI should use theme bundling.\n *\n * @param env - The environment variables from the environment of the current process.\n * @returns False if SHOPIFY_CLI_NO_THEME_BUNDLING is truthy.\n */\nexport function useThemebundling(env = process.env): boolean {\n return !isTruthy(env[environmentVariables.noThemeBundling])\n}\n\n/**\n * Returns true if the embedded CLI will be used for theme commands.\n *\n * @param env - The environment variables from the environment of the current process.\n * @returns False if SHOPIFY_CLI_BUNDLED_THEME_CLI is truthy.\n */\nexport function useEmbeddedThemeCLI(env = process.env): boolean {\n return !isTruthy(env[environmentVariables.bundledThemeCLI])\n}\n\n/**\n * Return gitpodURL if we are running in gitpod.\n * Https://www.gitpod.io/docs/environment-variables#default-environment-variables.\n *\n * @param env - The environment variables from the environment of the current process.\n * @returns The gitpod URL.\n */\nexport function gitpodURL(env = process.env): string | undefined {\n return env[environmentVariables.gitpod]\n}\n\n/**\n * Return codespaceURL if we are running in codespaces.\n * Https://docs.github.com/en/codespaces/developing-in-codespaces/default-environment-variables-for-your-codespace#list-of-default-environment-variables.\n *\n * @param env - The environment variables from the environment of the current process.\n * @returns The codespace URL.\n */\nexport function codespaceURL(env = process.env): string | undefined {\n return env[environmentVariables.codespaceName]\n}\n\n/**\n * Return codespacePortForwardingDomain if we are running in codespaces.\n * Https://docs.github.com/en/codespaces/developing-in-codespaces/default-environment-variables-for-your-codespace#list-of-default-environment-variables.\n *\n * @param env - The environment variables from the environment of the current process.\n * @returns The codespace port forwarding domain.\n */\nexport function codespacePortForwardingDomain(env = process.env): string | undefined {\n return env[environmentVariables.codespacePortForwardingDomain]\n}\n\n/**\n * Checks if the CLI is run from a cloud environment.\n *\n * @param env - Environment variables used when the cli is launched.\n * @returns True in case the CLI is run from a cloud environment.\n */\nexport function isCloudEnvironment(env: NodeJS.ProcessEnv = process.env): boolean {\n return cloudEnvironment(env).platform !== 'localhost'\n}\n\n/**\n * The token used to run a theme command with a custom password.\n *\n * @param env - Environment variables used when the cli is launched.\n * @returns A string with the token.\n */\nexport function themeToken(env = process.env): string | undefined {\n return env[environmentVariables.themeToken]\n}\n\n/**\n * Returns the cloud environment platform name and if the platform support online IDE in case the CLI is run from one of\n * them. Platform name 'localhost' is returned otherwise.\n *\n * @param env - Environment variables used when the cli is launched.\n * @returns Cloud platform information.\n */\nexport function cloudEnvironment(env: NodeJS.ProcessEnv = process.env): {\n platform: 'spin' | 'codespaces' | 'gitpod' | 'cloudShell' | 'localhost'\n editor: boolean\n} {\n if (isSet(env[environmentVariables.codespaces])) {\n return {platform: 'codespaces', editor: true}\n }\n if (isSet(env[environmentVariables.gitpod])) {\n return {platform: 'gitpod', editor: true}\n }\n if (isSet(env[environmentVariables.cloudShell])) {\n return {platform: 'cloudShell', editor: true}\n }\n if (isSpin(env)) {\n return {platform: 'spin', editor: false}\n }\n return {platform: 'localhost', editor: false}\n}\n\n/**\n * Returns whether the environment has Git available.\n *\n * @returns A promise that resolves with the value.\n */\nexport async function hasGit(): Promise<boolean> {\n try {\n await exec('git', ['--version'])\n return true\n // eslint-disable-next-line no-catch-all/no-catch-all\n } catch {\n return false\n }\n}\n\n/**\n * Gets info on the CI platform the CLI is running on, if applicable.\n *\n * @param env - The environment variables from the environment of the current process.\n * @returns The CI platform info.\n */\nexport function ciPlatform(\n env = process.env,\n): {isCI: true; name: string; metadata: Metadata} | {isCI: false; name?: undefined; metadata?: undefined} {\n if (isTruthy(env.CI)) {\n let name = 'unknown'\n if (isSet(env.BITBUCKET_BUILD_NUMBER)) {\n name = 'bitbucket'\n } else if (isTruthy(env.CIRCLECI)) {\n name = 'circleci'\n } else if (isSet(env.GITHUB_ACTION)) {\n name = 'github'\n } else if (isTruthy(env.GITLAB_CI)) {\n name = 'gitlab'\n } else if (isSet(env.BUILDKITE)) {\n name = 'buildkite'\n }\n\n return {\n isCI: true,\n name,\n metadata: getCIMetadata(name, env),\n }\n } else if (isTruthy(env.TF_BUILD)) {\n return {\n isCI: true,\n name: 'azure',\n metadata: getCIMetadata('azure', env),\n }\n }\n return {\n isCI: false,\n }\n}\n\n/**\n * Returns the first mac address found.\n *\n * @returns Mac address.\n */\nexport function macAddress(): Promise<string> {\n return macaddress.one()\n}\n\n/**\n * Get the domain for theme kit access.\n *\n * It can be overridden via the SHOPIFY_CLI_THEME_KIT_ACCESS_DOMAIN environment\n * variable.\n *\n * @param env - The environment variables from the environment of the process.\n *\n * @returns The domain for theme kit access.\n */\nexport function getThemeKitAccessDomain(env = process.env): string {\n const domain = env[environmentVariables.themeKitAccessDomain]\n\n return isSet(domain) ? domain : defaultThemeKitAccessDomain\n}\n\n/**\n * Get the domain to send OTEL metrics to.\n *\n * It can be overridden via the SHOPIFY_CLI_OTEL_EXPORTER_OTLP_ENDPOINT environment variable.\n *\n * @param env - The environment variables from the environment of the current process.\n * @returns The domain to send OTEL metrics to.\n */\nexport function opentelemetryDomain(env = process.env): string {\n const domain = env[environmentVariables.otelURL]\n\n return isSet(domain) ? domain : 'https://otlp-http-production-cli.shopifysvc.com'\n}\n\nexport type CIMetadata = Metadata\n"]}
|
|
1
|
+
{"version":3,"file":"local.js","sourceRoot":"","sources":["../../../../src/public/node/context/local.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,MAAM,EAAC,MAAM,WAAW,CAAA;AAChC,OAAO,EAAC,QAAQ,EAAC,MAAM,gBAAgB,CAAA;AACvC,OAAO,EAAC,aAAa,EAAE,KAAK,EAAW,MAAM,4CAA4C,CAAA;AACzF,OAAO,EAAC,2BAA2B,EAAE,oBAAoB,EAAE,aAAa,EAAC,MAAM,oCAAoC,CAAA;AACnH,OAAO,EAAC,UAAU,EAAC,MAAM,UAAU,CAAA;AACnC,OAAO,EAAC,IAAI,EAAC,MAAM,cAAc,CAAA;AACjC,OAAO,aAAa,MAAM,gBAAgB,CAAA;AAC1C,OAAO,UAAU,MAAM,YAAY,CAAA;AACnC,OAAO,EAAC,OAAO,EAAC,MAAM,IAAI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EAAE,aAAa,CAAC,OAAO,EAAE,GAAG,CAAC;SACtC,CAAA;IACH,CAAC;IACD,OAAO;QACL,IAAI,EAAE,KAAK;KACZ,CAAA;AACH,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,UAAU;IACxB,OAAO,UAAU,CAAC,GAAG,EAAE,CAAA;AACzB,CAAC;AAED;;;;;;;;;GASG;AACH,MAAM,UAAU,uBAAuB,CAAC,GAAG,GAAG,OAAO,CAAC,GAAG;IACvD,MAAM,MAAM,GAAG,GAAG,CAAC,oBAAoB,CAAC,oBAAoB,CAAC,CAAA;IAE7D,OAAO,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,2BAA2B,CAAA;AAC7D,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,mBAAmB,CAAC,GAAG,GAAG,OAAO,CAAC,GAAG;IACnD,MAAM,MAAM,GAAG,GAAG,CAAC,oBAAoB,CAAC,OAAO,CAAC,CAAA;IAEhD,OAAO,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,iDAAiD,CAAA;AACnF,CAAC","sourcesContent":["import {isSpin} from './spin.js'\nimport {isTruthy} from './utilities.js'\nimport {getCIMetadata, isSet, Metadata} from '../../../private/node/context/utilities.js'\nimport {defaultThemeKitAccessDomain, environmentVariables, pathConstants} from '../../../private/node/constants.js'\nimport {fileExists} from '../fs.js'\nimport {exec} from '../system.js'\nimport isInteractive from 'is-interactive'\nimport macaddress from 'macaddress'\nimport {homedir} from 'os'\n\n/**\n * It returns true if the terminal is interactive.\n *\n * @returns True if the terminal is interactive.\n */\nexport function isTerminalInteractive(): boolean {\n return isInteractive()\n}\n\n/**\n * Returns the path to the user's home directory.\n *\n * @returns The path to the user's home directory.\n */\nexport function homeDirectory(): string {\n return homedir()\n}\n\n/**\n * Returns true if the CLI is running in debug mode.\n *\n * @param env - The environment variables from the environment of the current process.\n * @returns True if SHOPIFY_ENV is development.\n */\nexport function isDevelopment(env = process.env): boolean {\n return env[environmentVariables.env] === 'development'\n}\n\n/**\n * Returns true if the CLI is running in verbose mode.\n *\n * @param env - The environment variables from the environment of the current process.\n * @returns True if SHOPIFY_FLAG_VERBOSE is truthy or the flag --verbose has been passed.\n */\nexport function isVerbose(env = process.env): boolean {\n return isTruthy(env[environmentVariables.verbose]) || process.argv.includes('--verbose')\n}\n\n/**\n * Returns true if the environment in which the CLI is running is either\n * a local environment (where dev is present) or a cloud environment (spin).\n *\n * @param env - The environment variables from the environment of the current process.\n * @returns True if the CLI is used in a Shopify environment.\n */\nexport async function isShopify(env = process.env): Promise<boolean> {\n if (Object.prototype.hasOwnProperty.call(env, environmentVariables.runAsUser)) {\n return !isTruthy(env[environmentVariables.runAsUser])\n }\n const devInstalled = await fileExists(pathConstants.executables.dev)\n return devInstalled || isSpin(env)\n}\n\n/**\n * This variable is used when running unit tests to indicate that the CLI's business logic\n * is run as a subject of a unit test. We can use this variable to disable output through\n * the standard streams.\n *\n * @param env - The environment variables from the environment of the current process.\n * @returns True if the SHOPIFY_UNIT_TEST environment variable is truthy.\n */\nexport function isUnitTest(env = process.env): boolean {\n return isTruthy(env[environmentVariables.unitTest])\n}\n\n/**\n * Returns true if reporting analytics is enabled.\n *\n * @param env - The environment variables from the environment of the current process.\n * @returns True unless SHOPIFY_CLI_NO_ANALYTICS is truthy or debug mode is enabled.\n */\nexport function analyticsDisabled(env = process.env): boolean {\n return isTruthy(env[environmentVariables.noAnalytics]) || isDevelopment(env)\n}\n\n/**\n * Returns true if reporting analytics should always happen, regardless of DEBUG mode etc.\n *\n * @param env - The environment variables from the environment of the current process.\n * @returns True if SHOPIFY_CLI_ALWAYS_LOG_ANALYTICS is truthy.\n */\nexport function alwaysLogAnalytics(env = process.env): boolean {\n return isTruthy(env[environmentVariables.alwaysLogAnalytics])\n}\n\n/**\n * Returns true if reporting metrics should always happen, regardless of DEBUG mode etc.\n *\n * @param env - The environment variables from the environment of the current process.\n * @returns True if SHOPIFY_CLI_ALWAYS_LOG_METRICS is truthy.\n */\nexport function alwaysLogMetrics(env = process.env): boolean {\n return isTruthy(env[environmentVariables.alwaysLogMetrics])\n}\n\n/**\n * Returns true if the CLI User is 1P.\n *\n * @param env - The environment variables from the environment of the current process.\n * @returns True if SHOPIFY_CLI_1P is truthy.\n */\nexport function firstPartyDev(env = process.env): boolean {\n return isTruthy(env[environmentVariables.firstPartyDev])\n}\n\n/**\n * Returns true if the CLI should use theme bundling.\n *\n * @param env - The environment variables from the environment of the current process.\n * @returns False if SHOPIFY_CLI_NO_THEME_BUNDLING is truthy.\n */\nexport function useThemebundling(env = process.env): boolean {\n return !isTruthy(env[environmentVariables.noThemeBundling])\n}\n\n/**\n * Returns true if the embedded CLI will be used for theme commands.\n *\n * @param env - The environment variables from the environment of the current process.\n * @returns False if SHOPIFY_CLI_BUNDLED_THEME_CLI is truthy.\n */\nexport function useEmbeddedThemeCLI(env = process.env): boolean {\n return !isTruthy(env[environmentVariables.bundledThemeCLI])\n}\n\n/**\n * Return gitpodURL if we are running in gitpod.\n * Https://www.gitpod.io/docs/environment-variables#default-environment-variables.\n *\n * @param env - The environment variables from the environment of the current process.\n * @returns The gitpod URL.\n */\nexport function gitpodURL(env = process.env): string | undefined {\n return env[environmentVariables.gitpod]\n}\n\n/**\n * Return codespaceURL if we are running in codespaces.\n * Https://docs.github.com/en/codespaces/developing-in-codespaces/default-environment-variables-for-your-codespace#list-of-default-environment-variables.\n *\n * @param env - The environment variables from the environment of the current process.\n * @returns The codespace URL.\n */\nexport function codespaceURL(env = process.env): string | undefined {\n return env[environmentVariables.codespaceName]\n}\n\n/**\n * Return codespacePortForwardingDomain if we are running in codespaces.\n * Https://docs.github.com/en/codespaces/developing-in-codespaces/default-environment-variables-for-your-codespace#list-of-default-environment-variables.\n *\n * @param env - The environment variables from the environment of the current process.\n * @returns The codespace port forwarding domain.\n */\nexport function codespacePortForwardingDomain(env = process.env): string | undefined {\n return env[environmentVariables.codespacePortForwardingDomain]\n}\n\n/**\n * Checks if the CLI is run from a cloud environment.\n *\n * @param env - Environment variables used when the cli is launched.\n * @returns True in case the CLI is run from a cloud environment.\n */\nexport function isCloudEnvironment(env: NodeJS.ProcessEnv = process.env): boolean {\n return cloudEnvironment(env).platform !== 'localhost'\n}\n\n/**\n * The token used to run a theme command with a custom password.\n *\n * @param env - Environment variables used when the cli is launched.\n * @returns A string with the token.\n */\nexport function themeToken(env = process.env): string | undefined {\n return env[environmentVariables.themeToken]\n}\n\n/**\n * Returns the cloud environment platform name and if the platform support online IDE in case the CLI is run from one of\n * them. Platform name 'localhost' is returned otherwise.\n *\n * @param env - Environment variables used when the cli is launched.\n * @returns Cloud platform information.\n */\nexport function cloudEnvironment(env: NodeJS.ProcessEnv = process.env): {\n platform: 'spin' | 'codespaces' | 'gitpod' | 'cloudShell' | 'localhost'\n editor: boolean\n} {\n if (isSet(env[environmentVariables.codespaces])) {\n return {platform: 'codespaces', editor: true}\n }\n if (isSet(env[environmentVariables.gitpod])) {\n return {platform: 'gitpod', editor: true}\n }\n if (isSet(env[environmentVariables.cloudShell])) {\n return {platform: 'cloudShell', editor: true}\n }\n if (isSpin(env)) {\n return {platform: 'spin', editor: false}\n }\n return {platform: 'localhost', editor: false}\n}\n\n/**\n * Returns whether the environment has Git available.\n *\n * @returns A promise that resolves with the value.\n */\nexport async function hasGit(): Promise<boolean> {\n try {\n await exec('git', ['--version'])\n return true\n // eslint-disable-next-line no-catch-all/no-catch-all\n } catch {\n return false\n }\n}\n\n/**\n * Gets info on the CI platform the CLI is running on, if applicable.\n *\n * @param env - The environment variables from the environment of the current process.\n * @returns The CI platform info.\n */\nexport function ciPlatform(\n env = process.env,\n): {isCI: true; name: string; metadata: Metadata} | {isCI: false; name?: undefined; metadata?: undefined} {\n if (isTruthy(env.CI)) {\n let name = 'unknown'\n if (isSet(env.BITBUCKET_BUILD_NUMBER)) {\n name = 'bitbucket'\n } else if (isTruthy(env.CIRCLECI)) {\n name = 'circleci'\n } else if (isSet(env.GITHUB_ACTION)) {\n name = 'github'\n } else if (isTruthy(env.GITLAB_CI)) {\n name = 'gitlab'\n } else if (isSet(env.BUILDKITE)) {\n name = 'buildkite'\n }\n\n return {\n isCI: true,\n name,\n metadata: getCIMetadata(name, env),\n }\n } else if (isTruthy(env.TF_BUILD)) {\n return {\n isCI: true,\n name: 'azure',\n metadata: getCIMetadata('azure', env),\n }\n }\n return {\n isCI: false,\n }\n}\n\n/**\n * Returns the first mac address found.\n *\n * @returns Mac address.\n */\nexport function macAddress(): Promise<string> {\n return macaddress.one()\n}\n\n/**\n * Get the domain for theme kit access.\n *\n * It can be overridden via the SHOPIFY_CLI_THEME_KIT_ACCESS_DOMAIN environment\n * variable.\n *\n * @param env - The environment variables from the environment of the process.\n *\n * @returns The domain for theme kit access.\n */\nexport function getThemeKitAccessDomain(env = process.env): string {\n const domain = env[environmentVariables.themeKitAccessDomain]\n\n return isSet(domain) ? domain : defaultThemeKitAccessDomain\n}\n\n/**\n * Get the domain to send OTEL metrics to.\n *\n * It can be overridden via the SHOPIFY_CLI_OTEL_EXPORTER_OTLP_ENDPOINT environment variable.\n *\n * @param env - The environment variables from the environment of the current process.\n * @returns The domain to send OTEL metrics to.\n */\nexport function opentelemetryDomain(env = process.env): string {\n const domain = env[environmentVariables.otelURL]\n\n return isSet(domain) ? domain : 'https://otlp-http-production-cli.shopifysvc.com'\n}\n\nexport type CIMetadata = Metadata\n"]}
|
|
@@ -110,7 +110,7 @@ export function maxRequestTimeForNetworkCallsMs(environment = getEnvironmentVari
|
|
|
110
110
|
if (maxRequestTime && !isNaN(Number(maxRequestTime))) {
|
|
111
111
|
return Number(maxRequestTime);
|
|
112
112
|
}
|
|
113
|
-
//
|
|
114
|
-
return
|
|
113
|
+
// 30 seconds is the default
|
|
114
|
+
return 30 * 1000;
|
|
115
115
|
}
|
|
116
116
|
//# sourceMappingURL=environment.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"environment.js","s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S,CAAA;IACrD,OAAO;QACL,WAAW,EAAE,aAAa;QAC1B,YAAY;QACZ,MAAM,EAAE,aAAa,CAAC,aAAa,CAAC;KACrC,CAAA;AACH,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,iBAAiB,CAAC,WAAW,GAAG,uBAAuB,EAAE;IACvE,OAAO,YAAY,EAAE,IAAI,QAAQ,CAAC,WAAW,CAAC,oBAAoB,CAAC,IAAI,CAAC,CAAC,CAAA;AAC3E,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,mBAAmB;IACjC,OAAO,QAAQ,CAAC,uBAAuB,EAAE,CAAC,oBAAoB,CAAC,mBAAmB,CAAC,CAAC,CAAA;AACtF,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,qBAAqB,CAAC,WAAW,GAAG,uBAAuB,EAAE;IAC3E,OAAO,QAAQ,CAAC,WAAW,CAAC,oBAAoB,CAAC,qBAAqB,CAAC,CAAC,CAAA;AAC1E,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,+BAA+B,CAAC,WAAW,GAAG,uBAAuB,EAAE;IACrF,MAAM,cAAc,GAAG,WAAW,CAAC,oBAAoB,CAAC,6BAA6B,CAAC,CAAA;IACtF,IAAI,cAAc,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC,EAAE,CAAC;QACrD,OAAO,MAAM,CAAC,cAAc,CAAC,CAAA;IAC/B,CAAC;IACD,4BAA4B;IAC5B,OAAO,EAAE,GAAG,IAAI,CAAA;AAClB,CAAC","sourcesContent":["import {nonRandomUUID} from './crypto.js'\nimport {isTruthy} from './context/utilities.js'\nimport {sniffForJson} from './path.js'\nimport {environmentVariables, systemEnvironmentVariables} from '../../private/node/constants.js'\n\n/**\n * It returns the environment variables of the environment\n * where the Node process is running.\n *\n * This function exists to prevent the access of the process\n * global variable which is discouraged via the no-process-env\n * ESLint rule.\n *\n * @returns Current process environment variables.\n */\nexport function getEnvironmentVariables(): NodeJS.ProcessEnv {\n return process.env\n}\n\n/**\n * Returns the value of the SHOPIFY_CLI_PARTNERS_TOKEN environment variable.\n *\n * @returns Current process environment variables.\n */\nexport function getPartnersToken(): string | undefined {\n return getEnvironmentVariables()[environmentVariables.partnersToken]\n}\n\n/**\n * Check if the current proccess is running using the partners token.\n *\n * @returns True if the current proccess is running using the partners token.\n */\nexport function usePartnersToken(): boolean {\n return getPartnersToken() !== undefined\n}\n\n/**\n * Returns the value of the organization id from the environment variables.\n *\n * @returns True if the current proccess is running using the partners token.\n */\nexport function getOrganization(): string | undefined {\n return getEnvironmentVariables()[environmentVariables.organization]\n}\n\n/**\n * Return the backend port value.\n *\n * @returns The port as a number. Undefined otherwise.\n */\nexport function getBackendPort(): number | undefined {\n const backendPort = getEnvironmentVariables()[systemEnvironmentVariables.backendPort]\n if (backendPort && !isNaN(Number(backendPort))) {\n return Number(backendPort)\n }\n return undefined\n}\n\n/**\n * Returns the information of the identity & refresh tokens, provided by environment variables.\n *\n * @returns The identity token information in case it exists.\n */\nexport function getIdentityTokenInformation(): {accessToken: string; refreshToken: string; userId: string} | undefined {\n const identityToken = getEnvironmentVariables()[environmentVariables.identityToken]\n const refreshToken = getEnvironmentVariables()[environmentVariables.refreshToken]\n if (!identityToken || !refreshToken) return undefined\n return {\n accessToken: identityToken,\n refreshToken,\n userId: nonRandomUUID(identityToken),\n }\n}\n\n/**\n * Checks if the JSON output is enabled via flag (--json or -j) or environment variable (SHOPIFY_FLAG_JSON).\n *\n * @param environment - Process environment variables.\n * @returns True if the JSON output is enabled, false otherwise.\n */\nexport function jsonOutputEnabled(environment = getEnvironmentVariables()): boolean {\n return sniffForJson() || isTruthy(environment[environmentVariables.json])\n}\n\n/**\n * If true, the CLI should not use the Partners API.\n *\n * @returns True if the SHOPIFY_CLI_NEVER_USE_PARTNERS_API environment variable is set.\n */\nexport function blockPartnersAccess(): boolean {\n return isTruthy(getEnvironmentVariables()[environmentVariables.neverUsePartnersApi])\n}\n\n/**\n * If true, the CLI should not use the network level retry.\n *\n * If there is an error when calling a network API that looks like a DNS or connectivity issue, the CLI will by default\n * automatically retry the request.\n *\n * @param environment - Process environment variables.\n * @returns True if the SHOPIFY_CLI_SKIP_NETWORK_LEVEL_RETRY environment variable is set.\n */\nexport function skipNetworkLevelRetry(environment = getEnvironmentVariables()): boolean {\n return isTruthy(environment[environmentVariables.skipNetworkLevelRetry])\n}\n\n/**\n * Returns the default maximum request time for network calls in milliseconds.\n *\n * After this long, API requests may be cancelled by an AbortSignal. The limit can be overridden by setting the\n * SHOPIFY_CLI_MAX_REQUEST_TIME_FOR_NETWORK_CALLS environment variable.\n *\n * @param environment - Process environment variables.\n * @returns The maximum request time in milliseconds.\n */\nexport function maxRequestTimeForNetworkCallsMs(environment = getEnvironmentVariables()): number {\n const maxRequestTime = environment[environmentVariables.maxRequestTimeForNetworkCalls]\n if (maxRequestTime && !isNaN(Number(maxRequestTime))) {\n return Number(maxRequestTime)\n }\n //
|
|
1
|
+
{"version":3,"file":"environment.js","sourceRoot":"","sources":["../../../src/public/node/environment.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,aAAa,EAAC,MAAM,aAAa,CAAA;AACzC,OAAO,EAAC,QAAQ,EAAC,MAAM,wBAAwB,CAAA;AAC/C,OAAO,EAAC,YAAY,EAAC,MAAM,WAAW,CAAA;AACtC,OAAO,EAAC,oBAAoB,EAAE,0BAA0B,EAAC,MAAM,iCAAiC,CAAA;AAEhG;;;;;;;;;GASG;AACH,MAAM,UAAU,uBAAuB;IACrC,OAAO,OAAO,CAAC,GAAG,CAAA;AACpB,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,gBAAgB;IAC9B,OAAO,uBAAuB,EAAE,CAAC,oBAAoB,CAAC,aAAa,CAAC,CAAA;AACtE,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,gBAAgB;IAC9B,OAAO,gBAAgB,EAAE,KAAK,SAAS,CAAA;AACzC,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,eA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C;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,+BAA+B,CAAC,WAAW,GAAG,uBAAuB,EAAE;IACrF,MAAM,cAAc,GAAG,WAAW,CAAC,oBAAoB,CAAC,6BAA6B,CAAC,CAAA;IACtF,IAAI,cAAc,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC,EAAE,CAAC;QACrD,OAAO,MAAM,CAAC,cAAc,CAAC,CAAA;IAC/B,CAAC;IACD,4BAA4B;IAC5B,OAAO,EAAE,GAAG,IAAI,CAAA;AAClB,CAAC","sourcesContent":["import {nonRandomUUID} from './crypto.js'\nimport {isTruthy} from './context/utilities.js'\nimport {sniffForJson} from './path.js'\nimport {environmentVariables, systemEnvironmentVariables} from '../../private/node/constants.js'\n\n/**\n * It returns the environment variables of the environment\n * where the Node process is running.\n *\n * This function exists to prevent the access of the process\n * global variable which is discouraged via the no-process-env\n * ESLint rule.\n *\n * @returns Current process environment variables.\n */\nexport function getEnvironmentVariables(): NodeJS.ProcessEnv {\n return process.env\n}\n\n/**\n * Returns the value of the SHOPIFY_CLI_PARTNERS_TOKEN environment variable.\n *\n * @returns Current process environment variables.\n */\nexport function getPartnersToken(): string | undefined {\n return getEnvironmentVariables()[environmentVariables.partnersToken]\n}\n\n/**\n * Check if the current proccess is running using the partners token.\n *\n * @returns True if the current proccess is running using the partners token.\n */\nexport function usePartnersToken(): boolean {\n return getPartnersToken() !== undefined\n}\n\n/**\n * Returns the value of the organization id from the environment variables.\n *\n * @returns True if the current proccess is running using the partners token.\n */\nexport function getOrganization(): string | undefined {\n return getEnvironmentVariables()[environmentVariables.organization]\n}\n\n/**\n * Return the backend port value.\n *\n * @returns The port as a number. Undefined otherwise.\n */\nexport function getBackendPort(): number | undefined {\n const backendPort = getEnvironmentVariables()[systemEnvironmentVariables.backendPort]\n if (backendPort && !isNaN(Number(backendPort))) {\n return Number(backendPort)\n }\n return undefined\n}\n\n/**\n * Returns the information of the identity & refresh tokens, provided by environment variables.\n *\n * @returns The identity token information in case it exists.\n */\nexport function getIdentityTokenInformation(): {accessToken: string; refreshToken: string; userId: string} | undefined {\n const identityToken = getEnvironmentVariables()[environmentVariables.identityToken]\n const refreshToken = getEnvironmentVariables()[environmentVariables.refreshToken]\n if (!identityToken || !refreshToken) return undefined\n return {\n accessToken: identityToken,\n refreshToken,\n userId: nonRandomUUID(identityToken),\n }\n}\n\n/**\n * Checks if the JSON output is enabled via flag (--json or -j) or environment variable (SHOPIFY_FLAG_JSON).\n *\n * @param environment - Process environment variables.\n * @returns True if the JSON output is enabled, false otherwise.\n */\nexport function jsonOutputEnabled(environment = getEnvironmentVariables()): boolean {\n return sniffForJson() || isTruthy(environment[environmentVariables.json])\n}\n\n/**\n * If true, the CLI should not use the Partners API.\n *\n * @returns True if the SHOPIFY_CLI_NEVER_USE_PARTNERS_API environment variable is set.\n */\nexport function blockPartnersAccess(): boolean {\n return isTruthy(getEnvironmentVariables()[environmentVariables.neverUsePartnersApi])\n}\n\n/**\n * If true, the CLI should not use the network level retry.\n *\n * If there is an error when calling a network API that looks like a DNS or connectivity issue, the CLI will by default\n * automatically retry the request.\n *\n * @param environment - Process environment variables.\n * @returns True if the SHOPIFY_CLI_SKIP_NETWORK_LEVEL_RETRY environment variable is set.\n */\nexport function skipNetworkLevelRetry(environment = getEnvironmentVariables()): boolean {\n return isTruthy(environment[environmentVariables.skipNetworkLevelRetry])\n}\n\n/**\n * Returns the default maximum request time for network calls in milliseconds.\n *\n * After this long, API requests may be cancelled by an AbortSignal. The limit can be overridden by setting the\n * SHOPIFY_CLI_MAX_REQUEST_TIME_FOR_NETWORK_CALLS environment variable.\n *\n * @param environment - Process environment variables.\n * @returns The maximum request time in milliseconds.\n */\nexport function maxRequestTimeForNetworkCallsMs(environment = getEnvironmentVariables()): number {\n const maxRequestTime = environment[environmentVariables.maxRequestTimeForNetworkCalls]\n if (maxRequestTime && !isNaN(Number(maxRequestTime))) {\n return Number(maxRequestTime)\n }\n // 30 seconds is the default\n return 30 * 1000\n}\n"]}
|
|
@@ -241,6 +241,10 @@ function initializeBugsnag() {
|
|
|
241
241
|
autoTrackSessions: false,
|
|
242
242
|
autoDetectErrors: false,
|
|
243
243
|
enabledReleaseStages: ['production'],
|
|
244
|
+
endpoints: {
|
|
245
|
+
notify: 'https://error-analytics-production.shopifysvc.com',
|
|
246
|
+
sessions: 'https://error-analytics-sessions-production.shopifysvc.com',
|
|
247
|
+
},
|
|
244
248
|
});
|
|
245
249
|
}
|
|
246
250
|
//# sourceMappingURL=error-handler.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"error-handler.js","sourceRoot":"","sources":["../../../src/public/node/error-handler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,oBAAoB,EAAC,MAAM,gBAAgB,CAAA;AACpE,OAAO,KAAK,IAAI,MAAM,WAAW,CAAA;AACjC,OAAO,EAAC,WAAW,EAAC,MAAM,cAAc,CAAA;AACxC,OAAO,KAAK,QAAQ,MAAM,eAAe,CAAA;AACzC,OAAO,EACL,gBAAgB,EAChB,eAAe,EACf,WAAW,EACX,6BAA6B,EAC7B,OAAO,EACP,yBAAyB,GAC1B,MAAM,YAAY,CAAA;AACnB,OAAO,EAAC,kBAAkB,EAAC,MAAM,iCAAiC,CAAA;AAClE,OAAO,EAAC,WAAW,EAAE,UAAU,EAAC,MAAM,6BAA6B,CAAA;AACnE,OAAO,EAAC,aAAa,EAAE,kBAAkB,EAAC,MAAM,iCAAiC,CAAA;AACjF,OAAO,EAAC,eAAe,EAAC,MAAM,sBAAsB,CAAA;AACpD,OAAO,EAAC,gBAAgB,EAAC,MAAM,kCAAkC,CAAA;AACjE,OAAO,EAAC,QAAQ,EAAa,MAAM,aAAa,CAAA;AAChD,OAAO,WAAW,MAAM,aAAa,CAAA;AACrC,OAAO,OAAgB,MAAM,aAAa,CAAA;AAC1C,OAAO,EAAC,QAAQ,EAAC,MAAM,aAAa,CAAA;AAEpC,MAAM,CAAC,KAAK,UAAU,YAAY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,MAAM,CAAC,IAAI,eAAe,EAAE,CAAC;YACrD,eAAe,CAAC,GAAG,CAAC,GAAG,KAAK,CAAA;QAC9B,CAAC;aAAM,CAAC;YACN,QAAQ,CAAC,GAAG,CAAC,GAAG,KAAK,CAAA;QACvB,CAAC;IACH,CAAC,CAAC,CAAA;IAEF,kCAAkC;IAClC,MAAM,eAAe,GAAG;QACtB,aAAa,EAAE,OAAO;QACtB,OAAO,EAAE,WAAW;QACpB,WAAW,EAAE,eAAe;QAC5B,IAAI,EAAE,QAAQ;KACf,CAAA;IACD,MAAM,CAAC,OAAO,CAAC,eAAe,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,OAAO,EAAE,MAAM,CAAC,EAAE,EAAE;QAC5D,KAAK,CAAC,WAAW,CAAC,OAAO,EAAE,MAAM,CAAC,CAAA;IACpC,CAAC,CAAC,CAAA;AACJ,CAAC;AAED,SAAS,iBAAiB;IACxB,6DAA6D;IAC7D,aAAa;IACb,IAAI,OAAO,CAAC,SAAS,EAAE,EAAE,CAAC;QACxB,OAAM;IACR,CAAC;IACD,6DAA6D;IAC7D,aAAa;IACb,OAAO,CAAC,KAAK,CAAC;QACZ,OAAO,EAAE,MAAM;QACf,MAAM,EAAE,aAAa;QACrB,MAAM,EAAE,IAAI;QACZ,UAAU,EAAE,eAAe;QAC3B,iBAAiB,EAAE,KAAK;QACxB,gBAAgB,EAAE,KAAK;QACvB,oBAAoB,EAAE,CAAC,YAAY,CAAC;KACrC,CAAC,CAAA;AACJ,CAAC","sourcesContent":["import {CommandExitMode, reportAnalyticsEvent} from './analytics.js'\nimport * as path from './path.js'\nimport {fanoutHooks} from './plugins.js'\nimport * as metadata from './metadata.js'\nimport {\n AbortSilentError,\n CancelExecution,\n errorMapper,\n shouldReportErrorAsUnexpected,\n handler,\n cleanSingleStackTracePath,\n} from './error.js'\nimport {getEnvironmentData} from '../../private/node/analytics.js'\nimport {outputDebug, outputInfo} from '../../public/node/output.js'\nimport {bugsnagApiKey, reportingRateLimit} from '../../private/node/constants.js'\nimport {CLI_KIT_VERSION} from '../common/version.js'\nimport {runWithRateLimit} from '../../private/node/conf-store.js'\nimport {settings, Interfaces} from '@oclif/core'\nimport StackTracey from 'stacktracey'\nimport Bugsnag, {Event} from '@bugsnag/js'\nimport {realpath} from 'fs/promises'\n\nexport async function errorHandler(\n error: Error & {exitCode?: number | undefined},\n config?: Interfaces.Config,\n): Promise<void> {\n if (error instanceof CancelExecution) {\n if (error.message && error.message !== '') {\n outputInfo(`✨ ${error.message}`)\n }\n } else if (error instanceof AbortSilentError) {\n /* empty */\n } else {\n return errorMapper(error)\n .then((error) => {\n return handler(error)\n })\n .then((mappedError) => {\n return reportError(mappedError, config)\n })\n }\n}\n\nconst reportError = async (error: unknown, config?: Interfaces.Config): Promise<void> => {\n // categorise the error first\n let exitMode: CommandExitMode = 'expected_error'\n if (shouldReportErrorAsUnexpected(error)) exitMode = 'unexpected_error'\n\n if (config !== undefined) {\n // Log an analytics event when there's an error\n await reportAnalyticsEvent({config, errorMessage: error instanceof Error ? error.message : undefined, exitMode})\n }\n await sendErrorToBugsnag(error, exitMode)\n}\n\n/**\n * Sends an error to Bugsnag. This is configured automatically for uncaught errors from CLI commands, but can also be used to manually record an error.\n *\n * @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\n */\nexport async function sendErrorToBugsnag(\n error: unknown,\n exitMode: Omit<CommandExitMode, 'ok'>,\n): Promise<{reported: false; error: unknown; unhandled: unknown} | {error: Error; reported: true; unhandled: boolean}> {\n try {\n if (settings.debug) {\n outputDebug(`Skipping Bugsnag report`)\n return {reported: false, error, unhandled: undefined}\n }\n\n // If the error was unexpected, we flag it as \"unhandled\" in Bugsnag. This is a helpful distinction.\n const unhandled = exitMode === 'unexpected_error'\n\n let reportableError: Error\n let stacktrace: string | undefined\n let report = false\n\n if (error instanceof Error) {\n report = true\n reportableError = new Error(error.message)\n stacktrace = error.stack\n\n /**\n * Some errors that reach this point have an empty string. For example:\n * https://app.bugsnag.com/shopify/cli/errors/62cd5d31fd5040000814086c?filters[event.since]=30d&filters[error.status]=new&filters[release.seen_in]=3.1.0\n *\n * Because at this point we have neither the error message nor a stack trace reporting them\n * to Bugsnag is pointless and adds noise.\n */\n } else if (typeof error === 'string' && error.trim().length !== 0) {\n report = true\n reportableError = new Error(error)\n stacktrace = reportableError.stack\n } else {\n report = false\n reportableError = new Error('Unknown error')\n }\n\n const formattedStacktrace = new StackTracey(stacktrace ?? '')\n .clean()\n .items.map((item) => {\n const filePath = cleanSingleStackTracePath(item.file)\n return ` at ${item.callee} (${filePath}:${item.line}:${item.column})`\n })\n .join('\\n')\n reportableError.stack = `Error: ${reportableError.message}\\n${formattedStacktrace}`\n\n let withinRateLimit = false\n await runWithRateLimit({\n key: 'send-error-to-bugsnag',\n ...reportingRateLimit,\n task: async () => {\n withinRateLimit = true\n },\n })\n if (!withinRateLimit) {\n outputDebug(`Skipping Bugsnag report due to rate limiting`)\n report = false\n }\n\n if (report) {\n initializeBugsnag()\n await new Promise((resolve, reject) => {\n outputDebug(`Reporting ${unhandled ? 'unhandled' : 'handled'} error to Bugsnag: ${reportableError.message}`)\n const eventHandler = (event: Event) => {\n event.severity = 'error'\n event.unhandled = unhandled\n }\n const errorHandler = (error: unknown) => {\n if (error) {\n reject(error)\n } else {\n resolve(reportableError)\n }\n }\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n Bugsnag.notify(reportableError, eventHandler, errorHandler)\n })\n }\n return {error: reportableError, reported: report, unhandled}\n // eslint-disable-next-line no-catch-all/no-catch-all\n } catch (err) {\n outputDebug(`Error reporting to Bugsnag: ${err}`)\n return {error, reported: false, unhandled: undefined}\n }\n}\n\n/**\n * If the given file path is within a node_modules folder, remove prefix up\n * to and including the node_modules folder.\n *\n * This gives us very consistent paths for errors generated by the CLI.\n */\nexport function cleanStackFrameFilePath({\n currentFilePath,\n projectRoot,\n pluginLocations,\n}: {\n currentFilePath: string\n projectRoot: string\n pluginLocations: {name: string; pluginPath: string}[]\n}): string {\n const fullLocation = path.isAbsolutePath(currentFilePath)\n ? currentFilePath\n : path.joinPath(projectRoot, currentFilePath)\n\n const matchingPluginPath = pluginLocations.filter(({pluginPath}) => fullLocation.startsWith(pluginPath))[0]\n\n if (matchingPluginPath !== undefined) {\n // the plugin name (e.g. @shopify/cli-kit), plus the relative path of the error line from within the plugin's code (e.g. dist/something.js )\n return path.joinPath(matchingPluginPath.name, path.relativePath(matchingPluginPath.pluginPath, fullLocation))\n }\n\n // strip prefix up to node_modules folder, so we can normalize error reporting\n return currentFilePath.replace(/.*node_modules\\//, '')\n}\n\n/**\n * Register a Bugsnag error listener to clean up stack traces for errors within plugin code.\n *\n */\nexport async function registerCleanBugsnagErrorsFromWithinPlugins(config: Interfaces.Config): Promise<void> {\n // Bugsnag have their own plug-ins that use this private field\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const bugsnagConfigProjectRoot: string = (Bugsnag as any)?._client?._config?.projectRoot ?? path.cwd()\n const projectRoot = path.normalizePath(bugsnagConfigProjectRoot)\n const pluginLocations = await Promise.all(\n [...config.plugins].map(async ([_, plugin]) => {\n const followSymlinks = await realpath(plugin.root)\n return {name: plugin.name, pluginPath: path.normalizePath(followSymlinks)}\n }),\n )\n initializeBugsnag()\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n Bugsnag.addOnError(async (event) => {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n event.errors.forEach((error: any) => {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n error.stacktrace.forEach((stackFrame: any) => {\n stackFrame.file = cleanStackFrameFilePath({currentFilePath: stackFrame.file, projectRoot, pluginLocations})\n })\n })\n try {\n await addBugsnagMetadata(event, config)\n // eslint-disable-next-line no-catch-all/no-catch-all\n } catch (metadataError) {\n outputDebug(`There was an error adding metadata to the Bugsnag report; Ignoring and carrying on ${metadataError}`)\n }\n })\n}\n\n// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any\nexport async function addBugsnagMetadata(event: any, config: Interfaces.Config): Promise<void> {\n const publicData = metadata.getAllPublicMetadata()\n const {commandStartOptions} = metadata.getAllSensitiveMetadata()\n const {startCommand} = commandStartOptions ?? {}\n\n const {'@shopify/app': appPublic, ...otherPluginsPublic} = await fanoutHooks(config, 'public_command_metadata', {})\n\n const environment = await getEnvironmentData(config)\n\n const allMetadata = {\n command: startCommand,\n ...appPublic,\n ...publicData,\n ...environment,\n pluginData: otherPluginsPublic,\n }\n\n const appData = {} as {[key: string]: unknown}\n const commandData = {} as {[key: string]: unknown}\n const environmentData = {} as {[key: string]: unknown}\n const miscData = {} as {[key: string]: unknown}\n const appKeys = ['api_key', 'business_platform_id', 'partner_id', 'project_type']\n const commandKeys = ['command']\n const environmentKeys = ['cli_version', 'node_version', 'uname']\n\n Object.entries(allMetadata).forEach(([key, value]) => {\n if (key.startsWith('app_') || appKeys.includes(key)) {\n appData[key] = value\n } else if (key.startsWith('cmd_') || commandKeys.includes(key)) {\n commandData[key] = value\n } else if (key.startsWith('env_') || environmentKeys) {\n environmentData[key] = value\n } else {\n miscData[key] = value\n }\n })\n\n // app, command, environment, misc\n const bugsnagMetadata = {\n 'Shopify App': appData,\n Command: commandData,\n Environment: environmentData,\n Misc: miscData,\n }\n Object.entries(bugsnagMetadata).forEach(([section, values]) => {\n event.addMetadata(section, values)\n })\n}\n\nfunction initializeBugsnag() {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n if (Bugsnag.isStarted()) {\n return\n }\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n Bugsnag.start({\n appType: 'node',\n apiKey: bugsnagApiKey,\n logger: null,\n appVersion: CLI_KIT_VERSION,\n autoTrackSessions: false,\n autoDetectErrors: false,\n enabledReleaseStages: ['production'],\n })\n}\n"]}
|
|
1
|
+
{"version":3,"file":"error-handler.js","sourceRoot":"","sources":["../../../src/public/node/error-handler.ts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E,MAAM,CAAC,EAAE,EAAE;QAC5D,KAAK,CAAC,WAAW,CAAC,OAAO,EAAE,MAAM,CAAC,CAAA;IACpC,CAAC,CAAC,CAAA;AACJ,CAAC;AAED,SAAS,iBAAiB;IACxB,6DAA6D;IAC7D,aAAa;IACb,IAAI,OAAO,CAAC,SAAS,EAAE,EAAE,CAAC;QACxB,OAAM;IACR,CAAC;IACD,6DAA6D;IAC7D,aAAa;IACb,OAAO,CAAC,KAAK,CAAC;QACZ,OAAO,EAAE,MAAM;QACf,MAAM,EAAE,aAAa;QACrB,MAAM,EAAE,IAAI;QACZ,UAAU,EAAE,eAAe;QAC3B,iBAAiB,EAAE,KAAK;QACxB,gBAAgB,EAAE,KAAK;QACvB,oBAAoB,EAAE,CAAC,YAAY,CAAC;QACpC,SAAS,EAAE;YACT,MAAM,EAAE,mDAAmD;YAC3D,QAAQ,EAAE,4DAA4D;SACvE;KACF,CAAC,CAAA;AACJ,CAAC","sourcesContent":["import {CommandExitMode, reportAnalyticsEvent} from './analytics.js'\nimport * as path from './path.js'\nimport {fanoutHooks} from './plugins.js'\nimport * as metadata from './metadata.js'\nimport {\n AbortSilentError,\n CancelExecution,\n errorMapper,\n shouldReportErrorAsUnexpected,\n handler,\n cleanSingleStackTracePath,\n} from './error.js'\nimport {getEnvironmentData} from '../../private/node/analytics.js'\nimport {outputDebug, outputInfo} from '../../public/node/output.js'\nimport {bugsnagApiKey, reportingRateLimit} from '../../private/node/constants.js'\nimport {CLI_KIT_VERSION} from '../common/version.js'\nimport {runWithRateLimit} from '../../private/node/conf-store.js'\nimport {settings, Interfaces} from '@oclif/core'\nimport StackTracey from 'stacktracey'\nimport Bugsnag, {Event} from '@bugsnag/js'\nimport {realpath} from 'fs/promises'\n\nexport async function errorHandler(\n error: Error & {exitCode?: number | undefined},\n config?: Interfaces.Config,\n): Promise<void> {\n if (error instanceof CancelExecution) {\n if (error.message && error.message !== '') {\n outputInfo(`✨ ${error.message}`)\n }\n } else if (error instanceof AbortSilentError) {\n /* empty */\n } else {\n return errorMapper(error)\n .then((error) => {\n return handler(error)\n })\n .then((mappedError) => {\n return reportError(mappedError, config)\n })\n }\n}\n\nconst reportError = async (error: unknown, config?: Interfaces.Config): Promise<void> => {\n // categorise the error first\n let exitMode: CommandExitMode = 'expected_error'\n if (shouldReportErrorAsUnexpected(error)) exitMode = 'unexpected_error'\n\n if (config !== undefined) {\n // Log an analytics event when there's an error\n await reportAnalyticsEvent({config, errorMessage: error instanceof Error ? error.message : undefined, exitMode})\n }\n await sendErrorToBugsnag(error, exitMode)\n}\n\n/**\n * Sends an error to Bugsnag. This is configured automatically for uncaught errors from CLI commands, but can also be used to manually record an error.\n *\n * @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\n */\nexport async function sendErrorToBugsnag(\n error: unknown,\n exitMode: Omit<CommandExitMode, 'ok'>,\n): Promise<{reported: false; error: unknown; unhandled: unknown} | {error: Error; reported: true; unhandled: boolean}> {\n try {\n if (settings.debug) {\n outputDebug(`Skipping Bugsnag report`)\n return {reported: false, error, unhandled: undefined}\n }\n\n // If the error was unexpected, we flag it as \"unhandled\" in Bugsnag. This is a helpful distinction.\n const unhandled = exitMode === 'unexpected_error'\n\n let reportableError: Error\n let stacktrace: string | undefined\n let report = false\n\n if (error instanceof Error) {\n report = true\n reportableError = new Error(error.message)\n stacktrace = error.stack\n\n /**\n * Some errors that reach this point have an empty string. For example:\n * https://app.bugsnag.com/shopify/cli/errors/62cd5d31fd5040000814086c?filters[event.since]=30d&filters[error.status]=new&filters[release.seen_in]=3.1.0\n *\n * Because at this point we have neither the error message nor a stack trace reporting them\n * to Bugsnag is pointless and adds noise.\n */\n } else if (typeof error === 'string' && error.trim().length !== 0) {\n report = true\n reportableError = new Error(error)\n stacktrace = reportableError.stack\n } else {\n report = false\n reportableError = new Error('Unknown error')\n }\n\n const formattedStacktrace = new StackTracey(stacktrace ?? '')\n .clean()\n .items.map((item) => {\n const filePath = cleanSingleStackTracePath(item.file)\n return ` at ${item.callee} (${filePath}:${item.line}:${item.column})`\n })\n .join('\\n')\n reportableError.stack = `Error: ${reportableError.message}\\n${formattedStacktrace}`\n\n let withinRateLimit = false\n await runWithRateLimit({\n key: 'send-error-to-bugsnag',\n ...reportingRateLimit,\n task: async () => {\n withinRateLimit = true\n },\n })\n if (!withinRateLimit) {\n outputDebug(`Skipping Bugsnag report due to rate limiting`)\n report = false\n }\n\n if (report) {\n initializeBugsnag()\n await new Promise((resolve, reject) => {\n outputDebug(`Reporting ${unhandled ? 'unhandled' : 'handled'} error to Bugsnag: ${reportableError.message}`)\n const eventHandler = (event: Event) => {\n event.severity = 'error'\n event.unhandled = unhandled\n }\n const errorHandler = (error: unknown) => {\n if (error) {\n reject(error)\n } else {\n resolve(reportableError)\n }\n }\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n Bugsnag.notify(reportableError, eventHandler, errorHandler)\n })\n }\n return {error: reportableError, reported: report, unhandled}\n // eslint-disable-next-line no-catch-all/no-catch-all\n } catch (err) {\n outputDebug(`Error reporting to Bugsnag: ${err}`)\n return {error, reported: false, unhandled: undefined}\n }\n}\n\n/**\n * If the given file path is within a node_modules folder, remove prefix up\n * to and including the node_modules folder.\n *\n * This gives us very consistent paths for errors generated by the CLI.\n */\nexport function cleanStackFrameFilePath({\n currentFilePath,\n projectRoot,\n pluginLocations,\n}: {\n currentFilePath: string\n projectRoot: string\n pluginLocations: {name: string; pluginPath: string}[]\n}): string {\n const fullLocation = path.isAbsolutePath(currentFilePath)\n ? currentFilePath\n : path.joinPath(projectRoot, currentFilePath)\n\n const matchingPluginPath = pluginLocations.filter(({pluginPath}) => fullLocation.startsWith(pluginPath))[0]\n\n if (matchingPluginPath !== undefined) {\n // the plugin name (e.g. @shopify/cli-kit), plus the relative path of the error line from within the plugin's code (e.g. dist/something.js )\n return path.joinPath(matchingPluginPath.name, path.relativePath(matchingPluginPath.pluginPath, fullLocation))\n }\n\n // strip prefix up to node_modules folder, so we can normalize error reporting\n return currentFilePath.replace(/.*node_modules\\//, '')\n}\n\n/**\n * Register a Bugsnag error listener to clean up stack traces for errors within plugin code.\n *\n */\nexport async function registerCleanBugsnagErrorsFromWithinPlugins(config: Interfaces.Config): Promise<void> {\n // Bugsnag have their own plug-ins that use this private field\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const bugsnagConfigProjectRoot: string = (Bugsnag as any)?._client?._config?.projectRoot ?? path.cwd()\n const projectRoot = path.normalizePath(bugsnagConfigProjectRoot)\n const pluginLocations = await Promise.all(\n [...config.plugins].map(async ([_, plugin]) => {\n const followSymlinks = await realpath(plugin.root)\n return {name: plugin.name, pluginPath: path.normalizePath(followSymlinks)}\n }),\n )\n initializeBugsnag()\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n Bugsnag.addOnError(async (event) => {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n event.errors.forEach((error: any) => {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n error.stacktrace.forEach((stackFrame: any) => {\n stackFrame.file = cleanStackFrameFilePath({currentFilePath: stackFrame.file, projectRoot, pluginLocations})\n })\n })\n try {\n await addBugsnagMetadata(event, config)\n // eslint-disable-next-line no-catch-all/no-catch-all\n } catch (metadataError) {\n outputDebug(`There was an error adding metadata to the Bugsnag report; Ignoring and carrying on ${metadataError}`)\n }\n })\n}\n\n// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any\nexport async function addBugsnagMetadata(event: any, config: Interfaces.Config): Promise<void> {\n const publicData = metadata.getAllPublicMetadata()\n const {commandStartOptions} = metadata.getAllSensitiveMetadata()\n const {startCommand} = commandStartOptions ?? {}\n\n const {'@shopify/app': appPublic, ...otherPluginsPublic} = await fanoutHooks(config, 'public_command_metadata', {})\n\n const environment = await getEnvironmentData(config)\n\n const allMetadata = {\n command: startCommand,\n ...appPublic,\n ...publicData,\n ...environment,\n pluginData: otherPluginsPublic,\n }\n\n const appData = {} as {[key: string]: unknown}\n const commandData = {} as {[key: string]: unknown}\n const environmentData = {} as {[key: string]: unknown}\n const miscData = {} as {[key: string]: unknown}\n const appKeys = ['api_key', 'business_platform_id', 'partner_id', 'project_type']\n const commandKeys = ['command']\n const environmentKeys = ['cli_version', 'node_version', 'uname']\n\n Object.entries(allMetadata).forEach(([key, value]) => {\n if (key.startsWith('app_') || appKeys.includes(key)) {\n appData[key] = value\n } else if (key.startsWith('cmd_') || commandKeys.includes(key)) {\n commandData[key] = value\n } else if (key.startsWith('env_') || environmentKeys) {\n environmentData[key] = value\n } else {\n miscData[key] = value\n }\n })\n\n // app, command, environment, misc\n const bugsnagMetadata = {\n 'Shopify App': appData,\n Command: commandData,\n Environment: environmentData,\n Misc: miscData,\n }\n Object.entries(bugsnagMetadata).forEach(([section, values]) => {\n event.addMetadata(section, values)\n })\n}\n\nfunction initializeBugsnag() {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n if (Bugsnag.isStarted()) {\n return\n }\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n Bugsnag.start({\n appType: 'node',\n apiKey: bugsnagApiKey,\n logger: null,\n appVersion: CLI_KIT_VERSION,\n autoTrackSessions: false,\n autoDetectErrors: false,\n enabledReleaseStages: ['production'],\n endpoints: {\n notify: 'https://error-analytics-production.shopifysvc.com',\n sessions: 'https://error-analytics-sessions-production.shopifysvc.com',\n },\n })\n}\n"]}
|
|
@@ -82,7 +82,7 @@ export async function downloadGitHubRelease(repo, version, assetName, targetPath
|
|
|
82
82
|
const tempPath = joinPath(tmpDir, assetName);
|
|
83
83
|
let response;
|
|
84
84
|
try {
|
|
85
|
-
response = await fetch(url);
|
|
85
|
+
response = await fetch(url, undefined, 'slow-request');
|
|
86
86
|
if (!response.ok) {
|
|
87
87
|
throw new AbortError(`Failed to download ${assetName}: ${response.statusText}`);
|
|
88
88
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"github.js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AS,CAAC,QAAQ,EAAE,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAA;YAE9C,MAAM,KAAK,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAA;YAC5B,MAAM,KAAK,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,CAAA;YAChC,MAAM,QAAQ,CAAC,QAAQ,EAAE,UAAU,CAAC,CAAA;QACtC,CAAC,CAAC,CAAA;QACF,WAAW,CAAC,aAAa,CAAA,GAAG,WAAW,CAAC,WAAW,EAAE,4BAA4B,WAAW,CAAC,IAAI,CAAC,UAAU,CAAC,EAAE,CAAC,CAAA;IAClH,CAAC,CAAC,CAAA;AACJ,CAAC","sourcesContent":["/* eslint-disable @typescript-eslint/no-non-null-assertion */\nimport {err, ok, Result} from './result.js'\nimport {fetch, Response} from './http.js'\nimport {writeFile, mkdir, inTemporaryDirectory, moveFile, chmod} from './fs.js'\nimport {dirname, joinPath} from './path.js'\nimport {runWithTimer} from './metadata.js'\nimport {AbortError} from './error.js'\nimport {outputContent, outputDebug, outputToken} from '../../public/node/output.js'\n\nclass GitHubClientError extends Error {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n constructor(url: string, statusCode: number, bodyJson: any) {\n super(\n `The request to GitHub API URL ${url} failed with status code ${statusCode} and the following error message: ${bodyJson.message}`,\n )\n }\n}\n\nexport interface GithubRelease {\n id: number\n url: string\n tag_name: string\n name: string\n body: string\n draft: boolean\n prerelease: boolean\n created_at: string\n published_at: string\n tarball_url: string\n}\n\ninterface GetLatestGitHubReleaseOptions {\n filter: (release: GithubRelease) => boolean\n}\n\n/**\n * Given a GitHub repository it obtains the latest release.\n * @param owner - Repository owner (e.g., shopify)\n * @param repo - Repository name (e.g., cli)\n * @param options - Options\n */\nexport async function getLatestGitHubRelease(\n owner: string,\n repo: string,\n options: GetLatestGitHubReleaseOptions = {filter: () => true},\n): Promise<GithubRelease> {\n outputDebug(outputContent`Getting the latest release of GitHub repository ${owner}/${repo}...`)\n const url = `https://api.github.com/repos/${owner}/${repo}/releases`\n const fetchResult = await fetch(url)\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const jsonBody: any = await fetchResult.json()\n\n if (fetchResult.status !== 200) {\n throw new GitHubClientError(url, fetchResult.status, jsonBody)\n }\n\n return jsonBody.find(options.filter)\n}\n\ninterface ParseRepositoryURLOutput {\n full: string\n site: string\n user: string\n name: string\n ref: string\n subDirectory: string\n ssh: string\n http: string\n}\n\n/**\n * Given a GitHub repository URL, it parses it and returns its coomponents.\n * @param url - The GitHub repository URL\n */\nexport function parseGitHubRepositoryURL(url: string): Result<ParseRepositoryURLOutput, Error> {\n const match =\n /^(?:(?:https:\\/\\/)?([^:/]+\\.[^:/]+)\\/|git@([^:/]+)[:/]|([^/]+):)?([^/\\s]+)\\/([^/\\s#]+)(?:((?:\\/[^/\\s#]+)+))?(?:\\/)?(?:#(.+))?/.exec(\n url,\n )\n\n if (!match) {\n const exampleFormats = [\n 'github:user/repo',\n 'user/repo/subdirectory',\n 'git@github.com:user/repo',\n 'user/repo#dev',\n 'https://github.com/user/repo',\n ]\n\n return err(new Error(`Parsing the url ${url} failed. Supported formats are ${exampleFormats.join(', ')}.`))\n }\n\n const site = match[1] ?? match[2] ?? match[3] ?? 'github.com'\n const normalizedSite = site === 'github' ? 'github.com' : site\n const user = match[4]!\n const name = match[5]!.replace(/\\.git$/, '')\n // eslint-disable-next-line @typescript-eslint/no-non-null-asserted-optional-chain\n const subDirectory = match[6]?.slice(1)!\n const ref = match[7]!\n const branch = ref ? `#${ref}` : ''\n const ssh = `git@${normalizedSite}:${user}/${name}`\n const http = `https://${normalizedSite}/${user}/${name}`\n const full = ['https:/', normalizedSite, user, name, subDirectory].join('/').concat(branch)\n\n return ok({full, site: normalizedSite, user, name, ref, subDirectory, ssh, http})\n}\n\nexport interface GithubRepositoryReference {\n baseURL: string\n branch?: string\n filePath?: string\n}\n\n/**\n * Given a GitHub repository URL it parses it and extracts the branch, file path,\n * and base URL components\n * @param reference - A GitHub repository URL (e.g. https://github.com/Shopify/cli/blob/main/package.json)\n */\nexport function parseGitHubRepositoryReference(reference: string): GithubRepositoryReference {\n const url = new URL(reference)\n const branch = url.hash ? url.hash.slice(1) : undefined\n const [_, user, repo, ...repoPath] = url.pathname.split('/')\n const filePath = repoPath.length > 0 ? repoPath.join('/') : undefined\n\n return {\n baseURL: `${url.origin}/${user}/${repo}`,\n branch,\n filePath,\n }\n}\n\nexport async function downloadGitHubRelease(\n repo: string,\n version: string,\n assetName: string,\n targetPath: string,\n): Promise<void> {\n const url = `https://github.com/${repo}/releases/download/${version}/${assetName}`\n\n return runWithTimer('cmd_all_timing_network_ms')(async () => {\n outputDebug(outputContent`Downloading ${outputToken.link(assetName, url)}`)\n await inTemporaryDirectory(async (tmpDir) => {\n const tempPath = joinPath(tmpDir, assetName)\n let response: Response\n try {\n response = await fetch(url, undefined, 'slow-request')\n if (!response.ok) {\n throw new AbortError(`Failed to download ${assetName}: ${response.statusText}`)\n }\n } catch (error) {\n throw new AbortError(\n `Failed to download ${assetName}: ${error instanceof Error ? error.message : 'unknown error'}`,\n )\n }\n\n const buffer = await response.arrayBuffer()\n await writeFile(tempPath, Buffer.from(buffer))\n\n await chmod(tempPath, 0o755)\n await mkdir(dirname(targetPath))\n await moveFile(tempPath, targetPath)\n })\n outputDebug(outputContent`${outputToken.successIcon()} Successfully downloaded ${outputToken.path(targetPath)}`)\n })\n}\n"]}
|