@shopify/cli-kit 3.3.1 → 3.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +30 -0
- package/dist/api/admin.js +20 -34
- package/dist/api/admin.js.map +1 -1
- package/dist/api/common.d.ts +11 -1
- package/dist/api/common.js +50 -4
- package/dist/api/common.js.map +1 -1
- package/dist/api/identity.js +3 -3
- package/dist/api/identity.js.map +1 -1
- package/dist/api/partners.d.ts +0 -5
- package/dist/api/partners.js +22 -42
- package/dist/api/partners.js.map +1 -1
- package/dist/constants.d.ts +1 -0
- package/dist/constants.js +1 -0
- package/dist/constants.js.map +1 -1
- package/dist/environment/local.d.ts +1 -0
- package/dist/environment/local.js +3 -0
- package/dist/environment/local.js.map +1 -1
- package/dist/environment/service.d.ts +2 -1
- package/dist/environment/service.js +16 -0
- package/dist/environment/service.js.map +1 -1
- package/dist/error.d.ts +5 -0
- package/dist/error.js +10 -4
- package/dist/error.js.map +1 -1
- package/dist/file.d.ts +2 -0
- package/dist/file.js +13 -1
- package/dist/file.js.map +1 -1
- package/dist/git.js +12 -4
- package/dist/git.js.map +1 -1
- package/dist/http/fetch.d.ts +9 -2
- package/dist/http/fetch.js +11 -2
- package/dist/http/fetch.js.map +1 -1
- package/dist/http/graphql.d.ts +15 -0
- package/dist/http/graphql.js +12 -0
- package/dist/http/graphql.js.map +1 -0
- package/dist/http.d.ts +24 -0
- package/dist/http.js +27 -0
- package/dist/http.js.map +1 -1
- package/dist/network/service.d.ts +1 -1
- package/dist/network/service.js.map +1 -1
- package/dist/node/base-command.d.ts +1 -0
- package/dist/node/base-command.js +10 -1
- package/dist/node/base-command.js.map +1 -1
- package/dist/node/cli.d.ts +0 -2
- package/dist/node/cli.js +0 -4
- package/dist/node/cli.js.map +1 -1
- package/dist/node/error-handler.d.ts +20 -0
- package/dist/node/error-handler.js +40 -3
- package/dist/node/error-handler.js.map +1 -1
- package/dist/node/hooks/init.d.ts +2 -0
- package/dist/node/hooks/init.js +7 -0
- package/dist/node/hooks/init.js.map +1 -0
- package/dist/node/hooks/postrun.js +4 -1
- package/dist/node/hooks/postrun.js.map +1 -1
- package/dist/node/hooks/prerun.js +2 -0
- package/dist/node/hooks/prerun.js.map +1 -1
- package/dist/node/ruby.d.ts +7 -2
- package/dist/node/ruby.js +24 -12
- package/dist/node/ruby.js.map +1 -1
- package/dist/output.d.ts +18 -11
- package/dist/output.js +96 -26
- package/dist/output.js.map +1 -1
- package/dist/session/exchange.js +2 -2
- package/dist/session/exchange.js.map +1 -1
- package/dist/session/validate.js +3 -0
- package/dist/session/validate.js.map +1 -1
- package/dist/session.js +7 -1
- package/dist/session.js.map +1 -1
- package/dist/string.js +3 -1
- package/dist/string.js.map +1 -1
- package/dist/system.d.ts +4 -3
- package/dist/system.js +5 -2
- package/dist/system.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/ui.d.ts +11 -0
- package/dist/ui.js +35 -5
- package/dist/ui.js.map +1 -1
- package/package.json +2 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,35 @@
|
|
|
1
1
|
# @shopify/cli-kit
|
|
2
2
|
|
|
3
|
+
## 3.4.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 0da6c7e8: • Run CLI2 commands from passed-in directory, defaulting to current working directory
|
|
8
|
+
• Fill in flags for theme check
|
|
9
|
+
• Add --path to theme check
|
|
10
|
+
• Add --verbose to theme check
|
|
11
|
+
|
|
12
|
+
### Patch Changes
|
|
13
|
+
|
|
14
|
+
- 08366831: Better logging:
|
|
15
|
+
• include Prompt and List input/output
|
|
16
|
+
• distinguish commands via UUID and log lines for command start/finish
|
|
17
|
+
• use a command line flag to specify log stream to view (cli, create-app, create-hydrogen)
|
|
18
|
+
- feae2499: Fix support for using a private template repo when git credentials are not setup
|
|
19
|
+
- 19ab3f99: Report 5xx reponses coming from the Partners' API as aborts
|
|
20
|
+
|
|
21
|
+
## 3.3.3
|
|
22
|
+
|
|
23
|
+
### Patch Changes
|
|
24
|
+
|
|
25
|
+
- e89dfa81: • Update Ruby CLI to latest
|
|
26
|
+
• Fix: Await Ruby subprocess
|
|
27
|
+
• Add path flag to init for better development flow
|
|
28
|
+
• Add verbose flag to see more output from the Node CLI
|
|
29
|
+
• Set up logging and CLI-kit store separately for the theme CLI
|
|
30
|
+
|
|
31
|
+
## 3.3.2
|
|
32
|
+
|
|
3
33
|
## 3.3.1
|
|
4
34
|
|
|
5
35
|
## 3.3.0
|
package/dist/api/admin.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { buildHeaders,
|
|
1
|
+
import { buildHeaders, debugLogRequest, handlingErrors } from './common.js';
|
|
2
2
|
import { debug, content, token as outputToken } from '../output.js';
|
|
3
3
|
import { Bug, Abort } from '../error.js';
|
|
4
|
-
import {
|
|
4
|
+
import { graphqlClient } from '../http/graphql.js';
|
|
5
|
+
import { gql } from 'graphql-request';
|
|
5
6
|
const UnauthorizedAccessError = (store) => {
|
|
6
7
|
const adminLink = outputToken.link(`URL`, `https://${store}/admin`);
|
|
7
8
|
const storeName = store.replace('.myshopify.com', '');
|
|
@@ -13,48 +14,33 @@ const UnknownError = () => {
|
|
|
13
14
|
return new Bug(`Unknown error connecting to your store`);
|
|
14
15
|
};
|
|
15
16
|
export async function request(query, session, variables) {
|
|
16
|
-
const
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
`);
|
|
29
|
-
try {
|
|
30
|
-
const response = await graphqlRequest(url, query, variables, headers);
|
|
17
|
+
const api = 'Admin';
|
|
18
|
+
return handlingErrors(api, async () => {
|
|
19
|
+
const version = await fetchApiVersion(session);
|
|
20
|
+
const url = adminUrl(session.storeFqdn, version);
|
|
21
|
+
const headers = await buildHeaders(session.token);
|
|
22
|
+
const client = await graphqlClient({
|
|
23
|
+
headers,
|
|
24
|
+
url,
|
|
25
|
+
service: 'shopify',
|
|
26
|
+
});
|
|
27
|
+
debugLogRequest(api, query, variables, headers);
|
|
28
|
+
const response = await client.request(query, variables);
|
|
31
29
|
return response;
|
|
32
|
-
}
|
|
33
|
-
catch (error) {
|
|
34
|
-
if (error instanceof ClientError) {
|
|
35
|
-
const errorMessage = content `
|
|
36
|
-
The Admin GraphQL API responded unsuccessfully with the HTTP status ${`${error.response.status}`} and errors:
|
|
37
|
-
|
|
38
|
-
${outputToken.json(error.response.errors)}
|
|
39
|
-
`;
|
|
40
|
-
const abortError = new Abort(errorMessage.value);
|
|
41
|
-
abortError.stack = error.stack;
|
|
42
|
-
throw abortError;
|
|
43
|
-
}
|
|
44
|
-
else {
|
|
45
|
-
throw error;
|
|
46
|
-
}
|
|
47
|
-
}
|
|
30
|
+
});
|
|
48
31
|
}
|
|
49
32
|
async function fetchApiVersion(session) {
|
|
50
33
|
const url = adminUrl(session.storeFqdn, 'unstable');
|
|
51
34
|
const query = apiVersionQuery();
|
|
52
35
|
const headers = await buildHeaders(session.token);
|
|
36
|
+
const client = await graphqlClient({ url, headers, service: 'shopify' });
|
|
53
37
|
debug(`
|
|
54
38
|
Sending Admin GraphQL request to URL ${url} with query:
|
|
55
39
|
${query}
|
|
56
40
|
`);
|
|
57
|
-
const data = await
|
|
41
|
+
const data = await client
|
|
42
|
+
.request(query, {})
|
|
43
|
+
.catch((err) => {
|
|
58
44
|
throw err.response.status === 403 ? UnauthorizedAccessError(session.storeFqdn) : UnknownError();
|
|
59
45
|
});
|
|
60
46
|
return data.publicApiVersions
|
package/dist/api/admin.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"admin.js","sourceRoot":"","sources":["../../src/api/admin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,YAAY,EAAE,
|
|
1
|
+
{"version":3,"file":"admin.js","sourceRoot":"","sources":["../../src/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AAE,CAAC,CAAC,CAAC,CAAA;AACjB,CAAC;AAED,SAAS,QAAQ,CAAC,KAAa,EAAE,OAA2B;IAC1D,MAAM,WAAW,GAAG,OAAO,IAAI,UAAU,CAAA;IACzC,OAAO,WAAW,KAAK,cAAc,WAAW,eAAe,CAAA;AACjE,CAAC;AAED,SAAS,eAAe;IACtB,OAAO,GAAG,CAAA;;;;;;;GAOT,CAAA;AACH,CAAC","sourcesContent":["import {buildHeaders, debugLogRequest, handlingErrors} from './common.js'\nimport {AdminSession} from '../session.js'\nimport {debug, content, token as outputToken} from '../output.js'\nimport {Bug, Abort} from '../error.js'\nimport {graphqlClient} from '../http/graphql.js'\nimport {gql, RequestDocument, Variables} from 'graphql-request'\n\nconst UnauthorizedAccessError = (store: string) => {\n const adminLink = outputToken.link(`URL`, `https://${store}/admin`)\n const storeName = store.replace('.myshopify.com', '')\n return new Abort(\n content`Looks like you need access to this dev store (${outputToken.link(storeName, `https://${store}`)})`,\n content`• Log in to the store directly from this ${adminLink}. If you're the store owner, then that direct log in should solve your access issue.\n• If you're not the owner, create a dev store staff account for yourself. Then log in directly from the link above.\n `,\n )\n}\n\nconst UnknownError = () => {\n return new Bug(`Unknown error connecting to your store`)\n}\n\nexport async function request<T>(query: RequestDocument, session: AdminSession, variables?: Variables): Promise<T> {\n const api = 'Admin'\n return handlingErrors(api, async () => {\n const version = await fetchApiVersion(session)\n const url = adminUrl(session.storeFqdn, version)\n const headers = await buildHeaders(session.token)\n const client = await graphqlClient({\n headers,\n url,\n service: 'shopify',\n })\n debugLogRequest(api, query, variables, headers)\n const response = await client.request<T>(query, variables)\n return response\n })\n}\n\nasync function fetchApiVersion(session: AdminSession): Promise<string> {\n const url = adminUrl(session.storeFqdn, 'unstable')\n const query = apiVersionQuery()\n const headers = await buildHeaders(session.token)\n const client = await graphqlClient({url, headers, service: 'shopify'})\n debug(`\nSending Admin GraphQL request to URL ${url} with query:\n${query}\n `)\n const data = await client\n .request<{\n publicApiVersions: {handle: string; supported: boolean}[]\n }>(query, {})\n .catch((err) => {\n throw err.response.status === 403 ? UnauthorizedAccessError(session.storeFqdn) : UnknownError()\n })\n\n return data.publicApiVersions\n .filter((item) => item.supported)\n .map((item) => item.handle)\n .sort()\n .reverse()[0]\n}\n\nfunction adminUrl(store: string, version: string | undefined): string {\n const realVersion = version || 'unstable'\n return `https://${store}/admin/api/${realVersion}/graphql.json`\n}\n\nfunction apiVersionQuery(): string {\n return gql`\n query {\n publicApiVersions {\n handle\n supported\n }\n }\n `\n}\n"]}
|
package/dist/api/common.d.ts
CHANGED
|
@@ -1,11 +1,21 @@
|
|
|
1
|
+
import { ExtendableError } from '../error.js';
|
|
2
|
+
import { RequestDocument, Variables } from 'graphql-request';
|
|
3
|
+
export declare class RequestClientError extends ExtendableError {
|
|
4
|
+
statusCode: number;
|
|
5
|
+
constructor(message: string, statusCode: number);
|
|
6
|
+
}
|
|
1
7
|
export declare function buildHeaders(token: string): Promise<{
|
|
2
8
|
[key: string]: string;
|
|
3
9
|
}>;
|
|
4
10
|
/**
|
|
5
|
-
*
|
|
11
|
+
* Removes the sensitive data from the headers and outputs them as a string.
|
|
6
12
|
* @param headers {{[key: string]: string}} HTTP headers.
|
|
7
13
|
* @returns {string} A sanitized version of the headers as a string.
|
|
8
14
|
*/
|
|
9
15
|
export declare function sanitizedHeadersOutput(headers: {
|
|
10
16
|
[key: string]: string;
|
|
11
17
|
}): string;
|
|
18
|
+
export declare function debugLogRequest<T>(api: string, query: RequestDocument, variables?: Variables, headers?: {
|
|
19
|
+
[key: string]: string;
|
|
20
|
+
}): Promise<void>;
|
|
21
|
+
export declare function handlingErrors<T>(api: string, action: () => Promise<T>): Promise<T>;
|
package/dist/api/common.js
CHANGED
|
@@ -1,9 +1,17 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { firstPartyDev } from '../environment/local.js';
|
|
2
2
|
import constants from '../constants.js';
|
|
3
|
+
import { stringifyMessage, content, token as outputToken, token, debug } from '../output.js';
|
|
4
|
+
import { Abort, ExtendableError } from '../error.js';
|
|
5
|
+
import { ClientError } from 'graphql-request';
|
|
3
6
|
import { randomUUID } from 'crypto';
|
|
7
|
+
export class RequestClientError extends ExtendableError {
|
|
8
|
+
constructor(message, statusCode) {
|
|
9
|
+
super(message);
|
|
10
|
+
this.statusCode = statusCode;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
4
13
|
export async function buildHeaders(token) {
|
|
5
14
|
const userAgent = `Shopify CLI; v=${await constants.versions.cliKit()}`;
|
|
6
|
-
const isEmployee = await isShopify();
|
|
7
15
|
const headers = {
|
|
8
16
|
/* eslint-disable @typescript-eslint/naming-convention */
|
|
9
17
|
'User-Agent': userAgent,
|
|
@@ -13,13 +21,13 @@ export async function buildHeaders(token) {
|
|
|
13
21
|
authorization: `Bearer ${token}`,
|
|
14
22
|
'X-Shopify-Access-Token': `Bearer ${token}`,
|
|
15
23
|
'Content-Type': 'application/json',
|
|
16
|
-
|
|
24
|
+
...(firstPartyDev() && { 'X-Shopify-Cli-Employee': '1' }),
|
|
17
25
|
/* eslint-enable @typescript-eslint/naming-convention */
|
|
18
26
|
};
|
|
19
27
|
return headers;
|
|
20
28
|
}
|
|
21
29
|
/**
|
|
22
|
-
*
|
|
30
|
+
* Removes the sensitive data from the headers and outputs them as a string.
|
|
23
31
|
* @param headers {{[key: string]: string}} HTTP headers.
|
|
24
32
|
* @returns {string} A sanitized version of the headers as a string.
|
|
25
33
|
*/
|
|
@@ -37,4 +45,42 @@ export function sanitizedHeadersOutput(headers) {
|
|
|
37
45
|
})
|
|
38
46
|
.join('\n');
|
|
39
47
|
}
|
|
48
|
+
export async function debugLogRequest(api, query, variables, headers = {}) {
|
|
49
|
+
debug(`
|
|
50
|
+
Sending ${token.raw(api)} GraphQL request:
|
|
51
|
+
${query}
|
|
52
|
+
|
|
53
|
+
With variables:
|
|
54
|
+
${variables ? JSON.stringify(variables, null, 2) : ''}
|
|
55
|
+
|
|
56
|
+
And headers:
|
|
57
|
+
${sanitizedHeadersOutput(headers)}
|
|
58
|
+
`);
|
|
59
|
+
}
|
|
60
|
+
export async function handlingErrors(api, action) {
|
|
61
|
+
try {
|
|
62
|
+
return await action();
|
|
63
|
+
}
|
|
64
|
+
catch (error) {
|
|
65
|
+
if (error instanceof ClientError) {
|
|
66
|
+
const errorMessage = stringifyMessage(content `
|
|
67
|
+
The ${token.raw(api)} GraphQL API responded unsuccessfully with the HTTP status ${`${error.response.status}`} and errors:
|
|
68
|
+
|
|
69
|
+
${outputToken.json(error.response.errors)}
|
|
70
|
+
`);
|
|
71
|
+
let mappedError;
|
|
72
|
+
if (error.response.status < 500) {
|
|
73
|
+
mappedError = new RequestClientError(errorMessage, error.response.status);
|
|
74
|
+
}
|
|
75
|
+
else {
|
|
76
|
+
mappedError = new Abort(errorMessage);
|
|
77
|
+
}
|
|
78
|
+
mappedError.stack = error.stack;
|
|
79
|
+
throw mappedError;
|
|
80
|
+
}
|
|
81
|
+
else {
|
|
82
|
+
throw error;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
40
86
|
//# sourceMappingURL=common.js.map
|
package/dist/api/common.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"common.js","sourceRoot":"","sources":["../../src/api/common.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,
|
|
1
|
+
{"version":3,"file":"common.js","sourceRoot":"","sources":["../../src/api/common.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,aAAa,EAAC,MAAM,yBAAyB,CAAA;AACrD,OAAO,SAAS,MAAM,iBAAiB,CAAA;AACvC,OAAO,EAAC,gBAAgB,EAAE,OAAO,EAAE,KAAK,IAAI,WAAW,EAAE,KAAK,EAAE,KAAK,EAAC,MAAM,cAAc,CAAA;AAC1F,OAAO,EAAC,KAAK,EAAE,eAAe,EAAC,MAAM,aAAa,CAAA;AAClD,OAAO,EAAC,WAAW,EAA6B,MAAM,iBAAiB,CAAA;AACvE,OAAO,EAAC,UAAU,EAAC,MAA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CAAA;YAC/B,MAAM,WAAW,CAAA;SAClB;aAAM;YACL,MAAM,KAAK,CAAA;SACZ;KACF;AACH,CAAC","sourcesContent":["import {firstPartyDev} from '../environment/local.js'\nimport constants from '../constants.js'\nimport {stringifyMessage, content, token as outputToken, token, debug} from '../output.js'\nimport {Abort, ExtendableError} from '../error.js'\nimport {ClientError, RequestDocument, Variables} from 'graphql-request'\nimport {randomUUID} from 'crypto'\n\nexport class RequestClientError extends ExtendableError {\n statusCode: number\n public constructor(message: string, statusCode: number) {\n super(message)\n this.statusCode = statusCode\n }\n}\n\nexport async function buildHeaders(token: string): Promise<{[key: string]: string}> {\n const userAgent = `Shopify CLI; v=${await constants.versions.cliKit()}`\n\n const headers = {\n /* eslint-disable @typescript-eslint/naming-convention */\n 'User-Agent': userAgent,\n // 'Sec-CH-UA': secCHUA, This header requires the Git sha.\n 'Sec-CH-UA-PLATFORM': process.platform,\n 'X-Request-Id': randomUUID(),\n authorization: `Bearer ${token}`,\n 'X-Shopify-Access-Token': `Bearer ${token}`,\n 'Content-Type': 'application/json',\n ...(firstPartyDev() && {'X-Shopify-Cli-Employee': '1'}),\n /* eslint-enable @typescript-eslint/naming-convention */\n }\n\n return headers\n}\n\n/**\n * Removes the sensitive data from the headers and outputs them as a string.\n * @param headers {{[key: string]: string}} HTTP headers.\n * @returns {string} A sanitized version of the headers as a string.\n */\nexport function sanitizedHeadersOutput(headers: {[key: string]: string}): string {\n const sanitized: {[key: string]: string} = {}\n const keywords = ['token', 'authorization']\n Object.keys(headers).forEach((header) => {\n if (keywords.find((keyword) => header.toLocaleLowerCase().includes(keyword)) === undefined) {\n sanitized[header] = headers[header]\n }\n })\n return Object.keys(sanitized)\n .map((header) => {\n return ` - ${header}: ${sanitized[header]}`\n })\n .join('\\n')\n}\n\nexport async function debugLogRequest<T>(\n api: string,\n query: RequestDocument,\n variables?: Variables,\n headers: {[key: string]: string} = {},\n) {\n debug(`\nSending ${token.raw(api)} GraphQL request:\n${query}\n\nWith variables:\n${variables ? JSON.stringify(variables, null, 2) : ''}\n\nAnd headers:\n${sanitizedHeadersOutput(headers)}\n`)\n}\n\nexport async function handlingErrors<T>(api: string, action: () => Promise<T>): Promise<T> {\n try {\n return await action()\n } catch (error) {\n if (error instanceof ClientError) {\n const errorMessage = stringifyMessage(content`\n The ${token.raw(\n api,\n )} GraphQL API responded unsuccessfully with the HTTP status ${`${error.response.status}`} and errors:\n\n ${outputToken.json(error.response.errors)}\n `)\n let mappedError: Error\n if (error.response.status < 500) {\n mappedError = new RequestClientError(errorMessage, error.response.status)\n } else {\n mappedError = new Abort(errorMessage)\n }\n mappedError.stack = error.stack\n throw mappedError\n } else {\n throw error\n }\n }\n}\n"]}
|
package/dist/api/identity.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { identity } from '../environment/fqdn.js';
|
|
2
2
|
import { debug } from '../output.js';
|
|
3
|
-
import {
|
|
3
|
+
import { shopifyFetch } from '../http.js';
|
|
4
4
|
export async function validateIdentityToken(token) {
|
|
5
5
|
try {
|
|
6
6
|
const instrospectionURL = await getInstrospectionEndpoint();
|
|
@@ -11,7 +11,7 @@ export async function validateIdentityToken(token) {
|
|
|
11
11
|
body: JSON.stringify({ token }),
|
|
12
12
|
};
|
|
13
13
|
debug(`Sending Identity Introspection request to URL: ${instrospectionURL}`);
|
|
14
|
-
const response = await
|
|
14
|
+
const response = await shopifyFetch('shopify', instrospectionURL, options);
|
|
15
15
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
16
16
|
const json = await response.json();
|
|
17
17
|
debug(`The identity token is valid: ${json.valid}`);
|
|
@@ -24,7 +24,7 @@ export async function validateIdentityToken(token) {
|
|
|
24
24
|
}
|
|
25
25
|
}
|
|
26
26
|
async function getInstrospectionEndpoint() {
|
|
27
|
-
const response = await
|
|
27
|
+
const response = await shopifyFetch('identity', `https://${await identity()}/.well-known/openid-configuration.json`);
|
|
28
28
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
29
29
|
const json = await response.json();
|
|
30
30
|
return json.introspection_endpoint;
|
package/dist/api/identity.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"identity.js","sourceRoot":"","sources":["../../src/api/identity.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,QAAQ,EAAC,MAAM,wBAAwB,CAAA;AAC/C,OAAO,EAAC,KAAK,EAAC,MAAM,cAAc,CAAA;AAClC,OAAO,EAAC,
|
|
1
|
+
{"version":3,"file":"identity.js","sourceRoot":"","sources":["../../src/api/identity.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,QAAQ,EAAC,MAAM,wBAAwB,CAAA;AAC/C,OAAO,EAAC,KAAK,EAAC,MAAM,cAAc,CAAA;AAClC,OAAO,EAAC,YAAY,EAAC,MAAM,YAAY,CAAA;AAEvC,MAAM,CAAC,KAAK,UAAU,qBAAqB,CAAC,KAAa;IACvD,IAAI;QACF,MAAM,iBAAiB,GAAG,MAAM,yBAAyB,EAAE,CAAA;QAC3D,MAAM,OAAO,GAAG;YACd,MAAM,EAAE,MAAM;YACd,gEAAgE;YAChE,OAAO,EAAE,EAAC,aAAa,EAAE,UAAU,KAAK,EAAE,EAAE,cAAc,EAAE,kBAAkB,EAAC;YAC/E,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,EAAC,KAAK,EAAC,CAAC;SAC9B,CAAA;QACD,KAAK,CAAC,kDAAkD,iBAAiB,EAAE,CAAC,CAAA;QAE5E,MAAM,QAAQ,GAAG,MAAM,YAAY,CAAC,SAAS,EAAE,iBAAiB,EAAE,OAAO,CAAC,CAAA;QAC1E,8DAA8D;QAC9D,MAAM,IAAI,GAAQ,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAA;QAEvC,KAAK,CAAC,gCAAgC,IAAI,CAAC,KAAK,EAAE,CAAC,CAAA;QACnD,OAAO,IAAI,CAAC,KAAK,CAAA;QACjB,qDAAqD;KACtD;IAAC,OAAO,KAAK,EAAE;QACd,KAAK,CAAC,kCAAkC,KAAK,EAAE,CAAC,CAAA;QAChD,OAAO,KAAK,CAAA;KACb;AACH,CAAC;AAED,KAAK,UAAU,yBAAyB;IACtC,MAAM,QAAQ,GAAG,MAAM,YAAY,CAAC,UAAU,EAAE,WAAW,MAAM,QAAQ,EAAE,wCAAwC,CAAC,CAAA;IACpH,8DAA8D;IAC9D,MAAM,IAAI,GAAQ,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAA;IACvC,OAAO,IAAI,CAAC,sBAAsB,CAAA;AACpC,CAAC","sourcesContent":["import {identity} from '../environment/fqdn.js'\nimport {debug} from '../output.js'\nimport {shopifyFetch} from '../http.js'\n\nexport async function validateIdentityToken(token: string) {\n try {\n const instrospectionURL = await getInstrospectionEndpoint()\n const options = {\n method: 'POST',\n // eslint-disable-next-line @typescript-eslint/naming-convention\n headers: {Authorization: `Bearer ${token}`, 'Content-Type': 'application/json'},\n body: JSON.stringify({token}),\n }\n debug(`Sending Identity Introspection request to URL: ${instrospectionURL}`)\n\n const response = await shopifyFetch('shopify', instrospectionURL, options)\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const json: any = await response.json()\n\n debug(`The identity token is valid: ${json.valid}`)\n return json.valid\n // eslint-disable-next-line no-catch-all/no-catch-all\n } catch (error) {\n debug(`The identity token is invalid: ${error}`)\n return false\n }\n}\n\nasync function getInstrospectionEndpoint(): Promise<string> {\n const response = await shopifyFetch('identity', `https://${await identity()}/.well-known/openid-configuration.json`)\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const json: any = await response.json()\n return json.introspection_endpoint\n}\n"]}
|
package/dist/api/partners.d.ts
CHANGED
|
@@ -1,9 +1,4 @@
|
|
|
1
|
-
import { ExtendableError } from '../error.js';
|
|
2
1
|
import { Variables, RequestDocument } from 'graphql-request';
|
|
3
|
-
export declare class RequestClientError extends ExtendableError {
|
|
4
|
-
statusCode: number;
|
|
5
|
-
constructor(message: string, statusCode: number);
|
|
6
|
-
}
|
|
7
2
|
export declare function request<T>(query: RequestDocument, token: string, variables?: Variables): Promise<T>;
|
|
8
3
|
/**
|
|
9
4
|
* Check if the given token is revoked and no longer valid to interact with the Partners API.
|
package/dist/api/partners.js
CHANGED
|
@@ -1,48 +1,23 @@
|
|
|
1
|
-
import { buildHeaders,
|
|
1
|
+
import { buildHeaders, debugLogRequest, handlingErrors } from './common.js';
|
|
2
2
|
import { ScriptServiceProxyQuery } from './graphql/index.js';
|
|
3
3
|
import { partners as partnersFqdn } from '../environment/fqdn.js';
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import { request as graphqlRequest, ClientError, gql } from 'graphql-request';
|
|
7
|
-
export class RequestClientError extends ExtendableError {
|
|
8
|
-
constructor(message, statusCode) {
|
|
9
|
-
super(message);
|
|
10
|
-
this.statusCode = statusCode;
|
|
11
|
-
}
|
|
12
|
-
}
|
|
4
|
+
import { graphqlClient } from '../http/graphql.js';
|
|
5
|
+
import { ClientError, gql } from 'graphql-request';
|
|
13
6
|
export async function request(query, token, variables) {
|
|
14
|
-
const
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
`);
|
|
27
|
-
try {
|
|
28
|
-
const response = await graphqlRequest(url, query, variables, headers);
|
|
7
|
+
const api = 'Partners';
|
|
8
|
+
return handlingErrors(api, async () => {
|
|
9
|
+
const fqdn = await partnersFqdn();
|
|
10
|
+
const url = `https://${fqdn}/api/cli/graphql`;
|
|
11
|
+
const headers = await buildHeaders(token);
|
|
12
|
+
debugLogRequest(api, query, variables, headers);
|
|
13
|
+
const client = await graphqlClient({
|
|
14
|
+
headers,
|
|
15
|
+
service: 'partners',
|
|
16
|
+
url,
|
|
17
|
+
});
|
|
18
|
+
const response = await client.request(query, variables);
|
|
29
19
|
return response;
|
|
30
|
-
}
|
|
31
|
-
catch (error) {
|
|
32
|
-
if (error instanceof ClientError) {
|
|
33
|
-
const errorMessage = stringifyMessage(content `
|
|
34
|
-
The Partners GraphQL API responded unsuccessfully with the HTTP status ${`${error.response.status}`} and errors:
|
|
35
|
-
|
|
36
|
-
${outputToken.json(error.response.errors)}
|
|
37
|
-
`);
|
|
38
|
-
const mappedError = new RequestClientError(errorMessage, error.response.status);
|
|
39
|
-
mappedError.stack = error.stack;
|
|
40
|
-
throw mappedError;
|
|
41
|
-
}
|
|
42
|
-
else {
|
|
43
|
-
throw error;
|
|
44
|
-
}
|
|
45
|
-
}
|
|
20
|
+
});
|
|
46
21
|
}
|
|
47
22
|
/**
|
|
48
23
|
* Check if the given token is revoked and no longer valid to interact with the Partners API.
|
|
@@ -62,8 +37,13 @@ export async function checkIfTokenIsRevoked(token) {
|
|
|
62
37
|
const fqdn = await partnersFqdn();
|
|
63
38
|
const url = `https://${fqdn}/api/cli/graphql`;
|
|
64
39
|
const headers = await buildHeaders(token);
|
|
40
|
+
const client = await graphqlClient({
|
|
41
|
+
headers,
|
|
42
|
+
url,
|
|
43
|
+
service: 'partners',
|
|
44
|
+
});
|
|
65
45
|
try {
|
|
66
|
-
await
|
|
46
|
+
await client.request(query, {});
|
|
67
47
|
return false;
|
|
68
48
|
// eslint-disable-next-line no-catch-all/no-catch-all
|
|
69
49
|
}
|
package/dist/api/partners.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"partners.js","sourceRoot":"","sources":["../../src/api/partners.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,YAAY,EAAE,
|
|
1
|
+
{"version":3,"file":"partners.js","sourceRoot":"","sources":["../../src/api/partners.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,YAAY,EAAE,eAAe,EAAE,cAAc,EAAC,MAAM,aAAa,CAAA;AACzE,OAAO,EAAC,uBAAuB,EAAC,MAAM,oBAAoB,CAAA;AAC1D,OAAO,EAAC,QAAQ,IAAI,YAAY,EAAC,MAAM,wBAAwB,CAAA;AAC/D,OAA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O,KAAK,CAAA;QACZ,qDAAqD;KACtD;IAAC,OAAO,KAAK,EAAE;QACd,IAAI,KAAK,YAAY,WAAW,EAAE;YAChC,OAAO,KAAK,CAAC,QAAQ,CAAC,MAAM,KAAK,GAAG,CAAA;SACrC;QACD,OAAO,KAAK,CAAA;KACb;AACH,CAAC;AAMD;;;;;;;;;;GAUG;AACH,MAAM,CAAC,KAAK,UAAU,oBAAoB,CACxC,MAAc,EACd,KAAc,EACd,KAAa,EACb,SAAmB;IAEnB,MAAM,cAAc,GAAG;QACrB,gEAAgE;QAChE,OAAO,EAAE,MAAM;QACf,KAAK;QACL,SAAS,EAAE,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC,IAAI,IAAI;KAC7C,CAAA;IACD,MAAM,UAAU,GAAG,uBAAuB,CAAA;IAC1C,MAAM,GAAG,GAAkB,MAAM,OAAO,CAAC,UAAU,EAAE,KAAK,EAAE,cAAc,CAAC,CAAA;IAC3E,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,kBAAkB,CAAC,CAAA;IAC/C,OAAO,IAAS,CAAA;AAClB,CAAC","sourcesContent":["import {buildHeaders, debugLogRequest, handlingErrors} from './common.js'\nimport {ScriptServiceProxyQuery} from './graphql/index.js'\nimport {partners as partnersFqdn} from '../environment/fqdn.js'\nimport {graphqlClient} from '../http/graphql.js'\nimport {Variables, ClientError, gql, RequestDocument} from 'graphql-request'\n\nexport async function request<T>(query: RequestDocument, token: string, variables?: Variables): Promise<T> {\n const api = 'Partners'\n return handlingErrors(api, async () => {\n const fqdn = await partnersFqdn()\n const url = `https://${fqdn}/api/cli/graphql`\n const headers = await buildHeaders(token)\n debugLogRequest(api, query, variables, headers)\n const client = await graphqlClient({\n headers,\n service: 'partners',\n url,\n })\n const response = await client.request<T>(query, variables)\n return response\n })\n}\n\n/**\n * Check if the given token is revoked and no longer valid to interact with the Partners API.\n * @param token {string} - The token to check\n * @returns {Promise<boolean>} - True if the token is revoked, false otherwise\n */\nexport async function checkIfTokenIsRevoked(token: string): Promise<boolean> {\n const query = gql`\n {\n organizations(first: 1) {\n nodes {\n id\n }\n }\n }\n `\n const fqdn = await partnersFqdn()\n const url = `https://${fqdn}/api/cli/graphql`\n const headers = await buildHeaders(token)\n const client = await graphqlClient({\n headers,\n url,\n service: 'partners',\n })\n try {\n await client.request(query, {})\n return false\n // eslint-disable-next-line no-catch-all/no-catch-all\n } catch (error) {\n if (error instanceof ClientError) {\n return error.response.status === 401\n }\n return false\n }\n}\n\ninterface ProxyResponse {\n scriptServiceProxy: string\n}\n\n/**\n * Function queries are proxied through the script service proxy.\n * To execute a query, we encapsulate it inside another query (including the variables)\n * This is done automatically, you just need to provide the query and the variables.\n *\n * @param apiKey {string} APIKey of the app where the query will be executed.\n * @param query {any} GraphQL query to execute.\n * @param token {string} Partners token\n * @param variables {any} GraphQL variables to pass to the query.\n * @returns {Promise<T>} The response of the query.\n */\nexport async function functionProxyRequest<T>(\n apiKey: string,\n query: unknown,\n token: string,\n variables?: unknown,\n): Promise<T> {\n const proxyVariables = {\n // eslint-disable-next-line @typescript-eslint/naming-convention\n api_key: apiKey,\n query,\n variables: JSON.stringify(variables) || '{}',\n }\n const proxyQuery = ScriptServiceProxyQuery\n const res: ProxyResponse = await request(proxyQuery, token, proxyVariables)\n const json = JSON.parse(res.scriptServiceProxy)\n return json as T\n}\n"]}
|
package/dist/constants.d.ts
CHANGED
package/dist/constants.js
CHANGED
package/dist/constants.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,6DAA6D;AAC7D,aAAa;AACb,OAAO,EAAC,IAAI,IAAI,QAAQ,EAAC,MAAM,WAAW,CAAA;AAC1C,OAAO,EAAC,oBAAoB,EAAC,MAAM,cAAc,CAAA;AACjD,OAAO,QAAQ,MAAM,WAAW,CAAA;AAEhC,MAAM,UAAU,GAAG,aAAa,CAAA;AAEhC,MA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W,EAAE,sBAAsB;QACnC,UAAU,EAAE,qBAAqB;QACjC,WAAW,EAAE,sBAAsB;QACnC,IAAI,EAAE,MAAM;QACZ,YAAY,EAAE,eAAe;QAC7B,aAAa,EAAE,gBAAgB;QAC/B,aAAa,EAAE,gBAAgB;QAC/B,QAAQ,EAAE,WAAW;QACrB,aAAa,EAAE,4BAA4B;QAC3C,OAAO,EAAE,sBAAsB;QAC/B,WAAW,EAAE,0BAA0B;QACvC,aAAa,EAAE,oBAAoB;KACpC;IACD,KAAK,EAAE;QACL,WAAW,EAAE;YACX,GAAG,EAAE,kBAAkB;SACxB;QACD,WAAW,EAAE;YACX,KAAK,EAAE;gBACL,IAAI,EAAE,GAAG,EAAE;oBACT,OAAO,WAAW,EAAE,CAAA;gBACtB,CAAC;gBACD,MAAM,EAAE;oBACN,IAAI,EAAE,GAAG,EAAE;wBACT,OAAO,QAAQ,CAAC,WAAW,EAAE,EAAE,QAAQ,CAAC,CAAA;oBAC1C,CAAC;oBACD,QAAQ,EAAE,GAAG,EAAE;wBACb,OAAO,QAAQ,CAAC,WAAW,EAAE,EAAE,QAAQ,EAAE,UAAU,CAAC,CAAA;oBACtD,CAAC;iBACF;aACF;SACF;KACF;IACD,QAAQ,EAAE;QACR,MAAM,EAAE,KAAK,IAAI,EAAE;YACjB,OAAO,oBAAoB,CAAC,EAAC,aAAa,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,EAAC,CAAC,CAAA;QAC/D,CAAC;KACF;IACD,QAAQ,EAAE;QACR,OAAO,EAAE,aAAa;KACvB;IACD,OAAO,EAAE;QACP,6BAA6B,EAAE,CAAC;KACjC;CACF,CAAA;AAED,MAAM,CAAC,MAAM,aAAa,GAAG,kCAAkC,CAAA;AAE/D,eAAe,SAAS,CAAA","sourcesContent":["// eslint-disable-next-line @typescript-eslint/ban-ts-comment\n// @ts-ignore\nimport {join as pathJoin} from './path.js'\nimport {findPackageVersionUp} from './version.js'\nimport envPaths from 'env-paths'\n\nconst identifier = 'shopify-cli'\n\nconst cacheFolder = () => {\n if (process.env.XDG_CACHE_HOME) return process.env.XDG_CACHE_HOME\n return envPaths(identifier).cache\n}\n\nconst constants = {\n environmentVariables: {\n unitTest: 'SHOPIFY_UNIT_TEST',\n shopifyConfig: 'SHOPIFY_CONFIG',\n runAsUser: 'SHOPIFY_RUN_AS_USER',\n partnersEnv: 'SHOPIFY_PARTNERS_ENV',\n shopifyEnv: 'SHOPIFY_SHOPIFY_ENV',\n identityEnv: 'SHOPIFY_IDENTITY_ENV',\n spin: 'SPIN',\n spinInstance: 'SPIN_INSTANCE',\n spinWorkspace: 'SPIN_WORKSPACE',\n spinNamespace: 'SPIN_NAMESPACE',\n spinHost: 'SPIN_HOST',\n partnersToken: 'SHOPIFY_CLI_PARTNERS_TOKEN',\n verbose: 'SHOPIFY_FLAG_VERBOSE',\n noAnalytics: 'SHOPIFY_CLI_NO_ANALYTICS',\n firstPartyDev: 'SHOPIFY_CLI_1P_DEV',\n },\n paths: {\n executables: {\n dev: '/opt/dev/bin/dev',\n },\n directories: {\n cache: {\n path: () => {\n return cacheFolder()\n },\n vendor: {\n path: () => {\n return pathJoin(cacheFolder(), 'vendor')\n },\n binaries: () => {\n return pathJoin(cacheFolder(), 'vendor', 'binaries')\n },\n },\n },\n },\n },\n versions: {\n cliKit: async () => {\n return findPackageVersionUp({fromModuleURL: import.meta.url})\n },\n },\n keychain: {\n service: 'shopify-cli',\n },\n session: {\n expirationTimeMarginInMinutes: 4,\n },\n}\n\nexport const bugsnagApiKey = '9e1e6889176fd0c795d5c659225e0fae'\n\nexport default constants\n"]}
|
|
@@ -41,6 +41,7 @@ export declare function isUnitTest(env?: NodeJS.ProcessEnv): boolean;
|
|
|
41
41
|
* @returns true unless SHOPIFY_CLI_NO_ANALYTICS is truthy or debug mode is enabled.
|
|
42
42
|
*/
|
|
43
43
|
export declare function analyticsDisabled(env?: NodeJS.ProcessEnv): boolean;
|
|
44
|
+
export declare function firstPartyDev(env?: NodeJS.ProcessEnv): boolean;
|
|
44
45
|
/**
|
|
45
46
|
* Returns whether the environment has Git available.
|
|
46
47
|
* @returns {Promise<boolean>} A promise that resolves with the value.
|
|
@@ -65,6 +65,9 @@ export function isUnitTest(env = process.env) {
|
|
|
65
65
|
export function analyticsDisabled(env = process.env) {
|
|
66
66
|
return isTruthy(env[constants.environmentVariables.noAnalytics]) || isDebug(env);
|
|
67
67
|
}
|
|
68
|
+
export function firstPartyDev(env = process.env) {
|
|
69
|
+
return isTruthy(env[constants.environmentVariables.firstPartyDev]);
|
|
70
|
+
}
|
|
68
71
|
/**
|
|
69
72
|
* Returns whether the environment has Git available.
|
|
70
73
|
* @returns {Promise<boolean>} A promise that resolves with the value.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"local.js","sourceRoot":"","sources":["../../src/environment/local.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,QAAQ,EAAC,MAAM,gBAAgB,CAAA;AACvC,OAAO,EAAC,MAAM,EAAC,MAAM,WAAW,CAAA;AAChC,OAAO,SAAS,MAAM,iBAAiB,CAAA;AACvC,OAAO,EAAC,MAAM,IAAI,UAAU,EAAC,MAAM,YAAY,CAAA;AAC/C,OAAO,EAAC,IAAI,EAAC,MAAM,cAAc,CAAA;AACjC,OAAO,aAAa,MAAM,gBAAgB,CAAA;AAC1C,OAAO,EAAC,OAAO,EAAC,MAAM,SAAS,CAAA;AAE/B;;;GAGG;AACH,MAAM,UAAU,qBAAqB;IACnC,OAAO,aAAa,EAAE,CAAA;AACxB,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,aAAa;IAC3B,OAAO,OAAO,EAAE,CAAA;AAClB,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,OAAO,CAAC,GAAG,GAAG,OAAO,CAAC,GAAG;IACvC,OAAO,GAAG,CAAC,SAAS,CAAC,oBAAoB,CAAC,aAAa,CAAC,KAAK,OAAO,CAAA;AACtE,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,SAAS,CA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ACb;AACH,CAAC","sourcesContent":["import {isTruthy} from './utilities.js'\nimport {isSpin} from './spin.js'\nimport constants from '../constants.js'\nimport {exists as fileExists} from '../file.js'\nimport {exec} from '../system.js'\nimport isInteractive from 'is-interactive'\nimport {homedir} from 'node:os'\n\n/**\n * It returns true if the terminal is interactive.\n * @returns {boolean} 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 * @returns {string} 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 * @param env The environment variables from the environment of the current process.\n * @returns true if SHOPIFY_CONFIG is debug\n */\nexport function isDebug(env = process.env): boolean {\n return env[constants.environmentVariables.shopifyConfig] === 'debug'\n}\n\n/**\n * Returns true if the CLI is running in verbose mode.\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[constants.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 * @returns {boolean} 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, constants.environmentVariables.runAsUser)) {\n return !isTruthy(env[constants.environmentVariables.runAsUser])\n }\n const devInstalled = await fileExists(constants.paths.executables.dev)\n return devInstalled || isSpin()\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 * @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[constants.environmentVariables.unitTest])\n}\n\n/**\n * Returns true if reporting analytics is enabled.\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[constants.environmentVariables.noAnalytics]) || isDebug(env)\n}\n\n/**\n * Returns whether the environment has Git available.\n * @returns {Promise<boolean>} 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"]}
|
|
1
|
+
{"version":3,"file":"local.js","sourceRoot":"","sources":["../../src/environment/local.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,QAAQ,EAAC,MAAM,gBAAgB,CAAA;AACvC,OAAO,EAAC,MAAM,EAAC,MAAM,WAAW,CAAA;AAChC,OAAO,SAAS,MAAM,iBAAiB,CAAA;AACvC,OAAO,EAAC,MAAM,IAAI,UAAU,EAAC,MAAM,YAAY,CAAA;AAC/C,OAAO,EAAC,IAAI,EAAC,MAAM,cAAc,CAAA;AACjC,OAAO,aAAa,MAAM,gBAAgB,CAAA;AAC1C,OAAO,EAAC,OAAO,EAAC,MAAM,SAAS,CAAA;AAE/B;;;GAGG;AACH,MAAM,UAAU,qBAAqB;IACnC,OAAO,aAAa,EAAE,CAAA;AACxB,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,aAAa;IAC3B,OAAO,OAAO,EAAE,CAAA;AAClB,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,OAAO,CAAC,GAAG,GAAG,OAAO,CAAC,GAAG;IACvC,OAAO,GAAG,CAAC,SAAS,CAAC,oBAAoB,CAAC,aAAa,CAAC,KAAK,OAAO,CAAA;AACtE,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,SAAS,CAAC,GAAG,GAAG,OAAO,CAAC,GAAG;IACzC,OAAO,QAAQ,CAAC,GAAG,CAAC,SAAS,CAAC,oBAAoB,CAAC,OAAO,CAAC,CAAC,IAAI,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,W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ACb;AACH,CAAC","sourcesContent":["import {isTruthy} from './utilities.js'\nimport {isSpin} from './spin.js'\nimport constants from '../constants.js'\nimport {exists as fileExists} from '../file.js'\nimport {exec} from '../system.js'\nimport isInteractive from 'is-interactive'\nimport {homedir} from 'node:os'\n\n/**\n * It returns true if the terminal is interactive.\n * @returns {boolean} 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 * @returns {string} 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 * @param env The environment variables from the environment of the current process.\n * @returns true if SHOPIFY_CONFIG is debug\n */\nexport function isDebug(env = process.env): boolean {\n return env[constants.environmentVariables.shopifyConfig] === 'debug'\n}\n\n/**\n * Returns true if the CLI is running in verbose mode.\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[constants.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 * @returns {boolean} 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, constants.environmentVariables.runAsUser)) {\n return !isTruthy(env[constants.environmentVariables.runAsUser])\n }\n const devInstalled = await fileExists(constants.paths.executables.dev)\n return devInstalled || isSpin()\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 * @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[constants.environmentVariables.unitTest])\n}\n\n/**\n * Returns true if reporting analytics is enabled.\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[constants.environmentVariables.noAnalytics]) || isDebug(env)\n}\n\nexport function firstPartyDev(env = process.env): boolean {\n return isTruthy(env[constants.environmentVariables.firstPartyDev])\n}\n\n/**\n * Returns whether the environment has Git available.\n * @returns {Promise<boolean>} 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"]}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
-
import { Environment } from '../network/service.js';
|
|
2
|
+
import { Environment, Service } from '../network/service.js';
|
|
3
|
+
export declare function environmentForService(service: Service): Promise<Environment>;
|
|
3
4
|
/**
|
|
4
5
|
* Returns the environment to be used for the interactions with the partners' CLI API.
|
|
5
6
|
* @param env The environment variables from the environment of the current process.
|
|
@@ -1,5 +1,21 @@
|
|
|
1
|
+
import { partners as partnersEnvironment, shopify as shopifyEnvironment, identity as identityEnvironment, } from './service.js';
|
|
1
2
|
import { Environment } from '../network/service.js';
|
|
2
3
|
import constants from '../constants.js';
|
|
4
|
+
export async function environmentForService(service) {
|
|
5
|
+
let environment;
|
|
6
|
+
switch (service) {
|
|
7
|
+
case 'identity':
|
|
8
|
+
environment = await identityEnvironment();
|
|
9
|
+
break;
|
|
10
|
+
case 'partners':
|
|
11
|
+
environment = await partnersEnvironment();
|
|
12
|
+
break;
|
|
13
|
+
case 'shopify':
|
|
14
|
+
environment = await shopifyEnvironment();
|
|
15
|
+
break;
|
|
16
|
+
}
|
|
17
|
+
return environment;
|
|
18
|
+
}
|
|
3
19
|
/**
|
|
4
20
|
* Given an environment variable that represents the environment to use for a given serve,
|
|
5
21
|
* it returns the environment as a enum;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"service.js","sourceRoot":"","sources":["../../src/environment/service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,WAAW,
|
|
1
|
+
{"version":3,"file":"service.js","sourceRoot":"","sources":["../../src/environment/service.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,IAAI,mBAAmB,EAC/B,OAAO,IAAI,kBAAkB,EAC7B,QAAQ,IAAI,mBAAmB,GAChC,MAAM,cAAc,CAAA;AACrB,OAAO,EAAC,WAAW,EAAU,MAAM,uBAAuB,CAAA;AAC1D,OAAO,SAAS,MAAM,iBAAiB,CAAA;AAEvC,MAAM,CAAC,KAAK,UAAU,qBAAqB,CAAC,OAAgB;IAC1D,IAAI,WAAwB,CAAA;IAC5B,QAAQ,OAAO,EAAE;QACf,KAAK,UAAU;YACb,WAAW,GAAG,MAAM,mBAAmB,EAAE,CAAA;YACzC,MAAK;QACP,KAAK,UAAU;YACb,WAAW,GAAG,MAAM,mBAAmB,EAAE,CAAA;YACzC,MAAK;QACP,KAAK,SAAS;YACZ,WAAW,GAAG,MAAM,kBAAkB,EAAE,CAAA;YACxC,MAAK;KACR;IACD,OAAO,WAAW,CAAA;AACpB,CAAC;AAED;;;;;GAKG;AACH,SAAS,OAAO,CAAC,KAAyB;IACxC,IAAI,KAAK,KAAK,OAAO,EAAE;QACrB,OAAO,WAAW,CAAC,KAAK,CAAA;KACzB;SAAM,IAAI,KAAK,KAAK,MAAM,EAAE;QAC3B,OAAO,WAAW,CAAC,IAAI,CAAA;KACxB;SAAM;QACL,OAAO,WAAW,CAAC,UAAU,CAAA;KAC9B;AACH,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,QAAQ,CAAC,GAAG,GAAG,OAAO,CAAC,GAAG;IACxC,OAAO,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC,oBAAoB,CAAC,WAAW,CAAC,CAAC,CAAA;AACjE,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,OAAO,CAAC,GAAG,GAAG,OAAO,CAAC,GAAG;IACvC,OAAO,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC,oBAAoB,CAAC,UAAU,CAAC,CAAC,CAAA;AAChE,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,QAAQ,CAAC,GAAG,GAAG,OAAO,CAAC,GAAG;IACxC,OAAO,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC,oBAAoB,CAAC,WAAW,CAAC,CAAC,CAAA;AACjE,CAAC","sourcesContent":["import {\n partners as partnersEnvironment,\n shopify as shopifyEnvironment,\n identity as identityEnvironment,\n} from './service.js'\nimport {Environment, Service} from '../network/service.js'\nimport constants from '../constants.js'\n\nexport async function environmentForService(service: Service): Promise<Environment> {\n let environment: Environment\n switch (service) {\n case 'identity':\n environment = await identityEnvironment()\n break\n case 'partners':\n environment = await partnersEnvironment()\n break\n case 'shopify':\n environment = await shopifyEnvironment()\n break\n }\n return environment\n}\n\n/**\n * Given an environment variable that represents the environment to use for a given serve,\n * it returns the environment as a enum;\n * @param value The environment variable value.\n * @returns {Environment} representing the environment to use.\n */\nfunction service(value: undefined | string): Environment {\n if (value === 'local') {\n return Environment.Local\n } else if (value === 'spin') {\n return Environment.Spin\n } else {\n return Environment.Production\n }\n}\n\n/**\n * Returns the environment to be used for the interactions with the partners' CLI API.\n * @param env The environment variables from the environment of the current process.\n */\nexport function partners(env = process.env): Environment {\n return service(env[constants.environmentVariables.partnersEnv])\n}\n\n/**\n * Returns the environment to be used for the interactions with the admin API.\n * @param env The environment variables from the environment of the current process.\n */\nexport function shopify(env = process.env): Environment {\n return service(env[constants.environmentVariables.shopifyEnv])\n}\n\n/**\n * Returns the environment to be used for the interactions with identity.\n * @param env The environment variables from the environment of the current process.\n */\nexport function identity(env = process.env): Environment {\n return service(env[constants.environmentVariables.identityEnv])\n}\n"]}
|
package/dist/error.d.ts
CHANGED
|
@@ -42,3 +42,8 @@ export declare function handler(error: Error): Promise<Error>;
|
|
|
42
42
|
export declare function mapper(error: Error): Promise<Error>;
|
|
43
43
|
export declare function isFatal(error: Error): boolean;
|
|
44
44
|
export declare function shouldReport(error: Error): boolean;
|
|
45
|
+
/**
|
|
46
|
+
* Stack traces usually have file:// - we strip that and also remove the Windows drive designation
|
|
47
|
+
*
|
|
48
|
+
*/
|
|
49
|
+
export declare function cleanSingleStackTracePath(filePath: string): string;
|
package/dist/error.js
CHANGED
|
@@ -1,11 +1,8 @@
|
|
|
1
1
|
import { stringifyMessage, error as outputError } from './output.js';
|
|
2
|
+
import { normalize } from './path.js';
|
|
2
3
|
import { Errors } from '@oclif/core';
|
|
3
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
4
|
-
// @ts-ignore
|
|
5
|
-
import sourceMapSupport from 'source-map-support';
|
|
6
4
|
export { ExtendableError } from 'ts-error';
|
|
7
5
|
export { AbortSignal } from 'abort-controller';
|
|
8
|
-
sourceMapSupport.install();
|
|
9
6
|
var FatalErrorType;
|
|
10
7
|
(function (FatalErrorType) {
|
|
11
8
|
FatalErrorType[FatalErrorType["Abort"] = 0] = "Abort";
|
|
@@ -92,4 +89,13 @@ export function shouldReport(error) {
|
|
|
92
89
|
}
|
|
93
90
|
return false;
|
|
94
91
|
}
|
|
92
|
+
/**
|
|
93
|
+
* Stack traces usually have file:// - we strip that and also remove the Windows drive designation
|
|
94
|
+
*
|
|
95
|
+
*/
|
|
96
|
+
export function cleanSingleStackTracePath(filePath) {
|
|
97
|
+
return normalize(filePath)
|
|
98
|
+
.replace('file:/', '/')
|
|
99
|
+
.replace(/^\/?[A-Z]:/, '');
|
|
100
|
+
}
|
|
95
101
|
//# sourceMappingURL=error.js.map
|