@shopify/cli-kit 3.62.0 → 3.63.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/public/common/lang.d.ts +0 -1
- package/dist/public/common/lang.js +0 -1
- package/dist/public/common/lang.js.map +1 -1
- package/dist/public/common/retry.d.ts +1 -0
- package/dist/public/common/retry.js +1 -0
- package/dist/public/common/retry.js.map +1 -1
- package/dist/public/common/ts/deep-required.d.ts +1 -1
- package/dist/public/common/ts/deep-required.js.map +1 -1
- package/dist/public/common/ts/pick-by-prefix.d.ts +1 -1
- package/dist/public/common/ts/pick-by-prefix.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/business-platform.d.ts +11 -0
- package/dist/public/node/api/business-platform.js +33 -8
- package/dist/public/node/api/business-platform.js.map +1 -1
- package/dist/public/node/api/graphql.d.ts +19 -4
- package/dist/public/node/api/graphql.js +30 -7
- package/dist/public/node/api/graphql.js.map +1 -1
- package/dist/public/node/api/partners.d.ts +11 -0
- package/dist/public/node/api/partners.js +36 -8
- package/dist/public/node/api/partners.js.map +1 -1
- package/dist/public/node/base-command.d.ts +2 -1
- package/dist/public/node/base-command.js +2 -0
- package/dist/public/node/base-command.js.map +1 -1
- package/dist/public/node/dot-env.js.map +1 -1
- package/dist/public/node/fs.d.ts +0 -1
- package/dist/public/node/git.d.ts +2 -0
- package/dist/public/node/git.js +2 -0
- package/dist/public/node/git.js.map +1 -1
- package/dist/public/node/monorail.d.ts +1 -1
- package/dist/public/node/monorail.js.map +1 -1
- package/dist/public/node/ruby.d.ts +2 -0
- package/dist/public/node/ruby.js +2 -0
- package/dist/public/node/ruby.js.map +1 -1
- package/dist/public/node/system.d.ts +1 -0
- package/dist/public/node/system.js +1 -0
- package/dist/public/node/system.js.map +1 -1
- package/dist/public/node/tcp.d.ts +1 -1
- package/dist/public/node/tcp.js +1 -1
- package/dist/public/node/tcp.js.map +1 -1
- package/dist/public/node/tree-kill.js +0 -1
- package/dist/public/node/tree-kill.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +4 -3
|
@@ -12,7 +12,6 @@ import lodashIsEqual from 'lodash/isEqual.js';
|
|
|
12
12
|
* @param value - The value to compare.
|
|
13
13
|
* @param other - The other value to compare.
|
|
14
14
|
* @returns Returns `true` if the values are equivalent, else `false`.
|
|
15
|
-
* @example
|
|
16
15
|
*/
|
|
17
16
|
export function isEqual(value, other) {
|
|
18
17
|
return lodashIsEqual(value, other);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lang.js","sourceRoot":"","sources":["../../../src/public/common/lang.ts"],"names":[],"mappings":"AAAA,OAAO,aAAa,MAAM,mBAAmB,CAAA;AAE7C
|
|
1
|
+
{"version":3,"file":"lang.js","sourceRoot":"","sources":["../../../src/public/common/lang.ts"],"names":[],"mappings":"AAAA,OAAO,aAAa,MAAM,mBAAmB,CAAA;AAE7C;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,OAAO,CAAC,KAAc,EAAE,KAAc;IACpD,OAAO,aAAa,CAAC,KAAK,EAAE,KAAK,CAAC,CAAA;AACpC,CAAC","sourcesContent":["import lodashIsEqual from 'lodash/isEqual.js'\n\n/**\n * Performs a deep comparison between two values to determine if they are\n * equivalent.\n *\n * **Note:** This method supports comparing arrays, array buffers, booleans,\n * date objects, error objects, maps, numbers, `Object` objects, regexes,\n * sets, strings, symbols, and typed arrays. `Object` objects are compared\n * by their own, not inherited, enumerable properties. Functions and DOM\n * nodes are **not** supported.\n *\n * @param value - The value to compare.\n * @param other - The other value to compare.\n * @returns Returns `true` if the values are equivalent, else `false`.\n */\nexport function isEqual(value: unknown, other: unknown): boolean {\n return lodashIsEqual(value, other)\n}\n"]}
|
|
@@ -10,5 +10,6 @@
|
|
|
10
10
|
* @param performAction - The action to perform.
|
|
11
11
|
* @param recoveryProcedure - The recovery procedure to perform if the action
|
|
12
12
|
* fails the first time.
|
|
13
|
+
* @returns The result of the action.
|
|
13
14
|
*/
|
|
14
15
|
export declare function performActionWithRetryAfterRecovery<T>(performAction: () => Promise<T>, recoveryProcedure: () => Promise<unknown>): Promise<T>;
|
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
* @param performAction - The action to perform.
|
|
11
11
|
* @param recoveryProcedure - The recovery procedure to perform if the action
|
|
12
12
|
* fails the first time.
|
|
13
|
+
* @returns The result of the action.
|
|
13
14
|
*/
|
|
14
15
|
export async function performActionWithRetryAfterRecovery(performAction, recoveryProcedure) {
|
|
15
16
|
let returnVal;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"retry.js","sourceRoot":"","sources":["../../../src/public/common/retry.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"retry.js","sourceRoot":"","sources":["../../../src/public/common/retry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,MAAM,CAAC,KAAK,UAAU,mCAAmC,CACvD,aAA+B,EAC/B,iBAAyC;IAEzC,IAAI,SAAwB,CAAA;IAC5B,IAAI;QACF,SAAS,GAAG,MAAM,aAAa,EAAE,CAAA;QACjC,OAAO,SAAS,CAAA;QAChB,qDAAqD;KACtD;IAAC,OAAO,GAAG,EAAE;QACZ,6DAA6D;QAC7D,MAAM,iBAAiB,EAAE,CAAA;QACzB,OAAO,aAAa,EAAE,CAAA;KACvB;AACH,CAAC","sourcesContent":["/**\n * Perform an action optimistically. If it fails the first time, first initiate\n * a provided recovery procedure, then retry the action. If it fails again,\n * throw the error.\n *\n * This is useful for actions that may fail due to recoverable errors, such as\n * an expired token that can be refreshed. In this case, the recovery procedure\n * would refresh the token.\n *\n * @param performAction - The action to perform.\n * @param recoveryProcedure - The recovery procedure to perform if the action\n * fails the first time.\n * @returns The result of the action.\n */\nexport async function performActionWithRetryAfterRecovery<T>(\n performAction: () => Promise<T>,\n recoveryProcedure: () => Promise<unknown>,\n): Promise<T> {\n let returnVal: T | undefined\n try {\n returnVal = await performAction()\n return returnVal\n // eslint-disable-next-line no-catch-all/no-catch-all\n } catch (err) {\n // Run the provided recovery procedure, then retry the action\n await recoveryProcedure()\n return performAction()\n }\n}\n"]}
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* type T = DeepRequired<{optionalKey?: string, nullableValue: string | null, undefinableValue: string | undefined}>
|
|
6
6
|
* T = {optionalKey: string, nullableValue: string, undefinableValue: string}
|
|
7
7
|
* ```
|
|
8
|
-
|
|
8
|
+
*
|
|
9
9
|
*/
|
|
10
10
|
export type DeepRequired<T> = {
|
|
11
11
|
[TKey in keyof Required<T>]: NonNullable<Required<T>[TKey]>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deep-required.js","sourceRoot":"","sources":["../../../../src/public/common/ts/deep-required.ts"],"names":[],"mappings":"","sourcesContent":["/**\n * Converts a mapping type to be non-optional.\n *\n * ```ts\n * type T = DeepRequired<{optionalKey?: string, nullableValue: string | null, undefinableValue: string | undefined}>\n * T = {optionalKey: string, nullableValue: string, undefinableValue: string}\n * ```\n
|
|
1
|
+
{"version":3,"file":"deep-required.js","sourceRoot":"","sources":["../../../../src/public/common/ts/deep-required.ts"],"names":[],"mappings":"","sourcesContent":["/**\n * Converts a mapping type to be non-optional.\n *\n * ```ts\n * type T = DeepRequired<{optionalKey?: string, nullableValue: string | null, undefinableValue: string | undefined}>\n * T = {optionalKey: string, nullableValue: string, undefinableValue: string}\n * ```\n *\n */\nexport type DeepRequired<T> = {\n [TKey in keyof Required<T>]: NonNullable<Required<T>[TKey]>\n}\n"]}
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*
|
|
7
7
|
* T = {foo_1: number, foo_2: number, included: string, also: number}
|
|
8
8
|
* ```
|
|
9
|
-
*
|
|
9
|
+
*
|
|
10
10
|
*/
|
|
11
11
|
export type PickByPrefix<TMapping, TPrefix extends string, TKeys extends keyof TMapping = never> = {
|
|
12
12
|
[TKey in keyof TMapping as TKey extends `${TPrefix}${infer _TSuffix}` | TKeys ? TKey : never]: TMapping[TKey];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pick-by-prefix.js","sourceRoot":"","sources":["../../../../src/public/common/ts/pick-by-prefix.ts"],"names":[],"mappings":"","sourcesContent":["/**\n * Produces a subset of a mapping type, where the keys either match some prefix string, or are in a list of exact matches.\n *\n * ```ts\n * type T = PickByPrefix<{foo_1: number, foo_2: number, nope: string, included: string, also: number}, 'foo_', 'included' | 'also'>.\n *\n * T = {foo_1: number, foo_2: number, included: string, also: number}\n * ```\n
|
|
1
|
+
{"version":3,"file":"pick-by-prefix.js","sourceRoot":"","sources":["../../../../src/public/common/ts/pick-by-prefix.ts"],"names":[],"mappings":"","sourcesContent":["/**\n * Produces a subset of a mapping type, where the keys either match some prefix string, or are in a list of exact matches.\n *\n * ```ts\n * type T = PickByPrefix<{foo_1: number, foo_2: number, nope: string, included: string, also: number}, 'foo_', 'included' | 'also'>.\n *\n * T = {foo_1: number, foo_2: number, included: string, also: number}\n * ```\n *\n */\nexport type PickByPrefix<TMapping, TPrefix extends string, TKeys extends keyof TMapping = never> = {\n [TKey in keyof TMapping as TKey extends `${TPrefix}${infer _TSuffix}` | TKeys ? TKey : never]: TMapping[TKey]\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const CLI_KIT_VERSION = "3.
|
|
1
|
+
export declare const CLI_KIT_VERSION = "3.63.1";
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export const CLI_KIT_VERSION = '3.
|
|
1
|
+
export const CLI_KIT_VERSION = '3.63.1';
|
|
2
2
|
//# sourceMappingURL=version.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version.js","sourceRoot":"","sources":["../../../src/public/common/version.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,eAAe,GAAG,QAAQ,CAAA","sourcesContent":["export const CLI_KIT_VERSION = '3.
|
|
1
|
+
{"version":3,"file":"version.js","sourceRoot":"","sources":["../../../src/public/common/version.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,eAAe,GAAG,QAAQ,CAAA","sourcesContent":["export const CLI_KIT_VERSION = '3.63.1'\n"]}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { GraphQLVariables } from './graphql.js';
|
|
2
|
+
import { TypedDocumentNode } from '@graphql-typed-document-node/core';
|
|
3
|
+
import { Variables } from 'graphql-request';
|
|
2
4
|
/**
|
|
3
5
|
* Executes a GraphQL query against the Business Platform Destinations API.
|
|
4
6
|
*
|
|
@@ -8,3 +10,12 @@ import { GraphQLVariables } from './graphql.js';
|
|
|
8
10
|
* @returns The response of the query of generic type <T>.
|
|
9
11
|
*/
|
|
10
12
|
export declare function businessPlatformRequest<T>(query: string, token: string, variables?: GraphQLVariables): Promise<T>;
|
|
13
|
+
/**
|
|
14
|
+
* Executes a GraphQL query against the Business Platform Destinations API. Uses typed documents.
|
|
15
|
+
*
|
|
16
|
+
* @param query - GraphQL query to execute.
|
|
17
|
+
* @param token - Business Platform token.
|
|
18
|
+
* @param variables - GraphQL variables to pass to the query.
|
|
19
|
+
* @returns The response of the query of generic type <TResult>.
|
|
20
|
+
*/
|
|
21
|
+
export declare function businessPlatformRequestDoc<TResult, TVariables extends Variables>(query: TypedDocumentNode<TResult, TVariables>, token: string, variables?: TVariables): Promise<TResult>;
|
|
@@ -1,6 +1,22 @@
|
|
|
1
|
-
import { graphqlRequest } from './graphql.js';
|
|
1
|
+
import { graphqlRequest, graphqlRequestDoc } from './graphql.js';
|
|
2
2
|
import { handleDeprecations } from './partners.js';
|
|
3
3
|
import { businessPlatformFqdn } from '../context/fqdn.js';
|
|
4
|
+
/**
|
|
5
|
+
* Sets up the request to the Business Platform Destinations API.
|
|
6
|
+
*
|
|
7
|
+
* @param token - Business Platform token.
|
|
8
|
+
*/
|
|
9
|
+
async function setupRequest(token) {
|
|
10
|
+
const api = 'BusinessPlatform';
|
|
11
|
+
const fqdn = await businessPlatformFqdn();
|
|
12
|
+
const url = `https://${fqdn}/destinations/api/2020-07/graphql`;
|
|
13
|
+
return {
|
|
14
|
+
token,
|
|
15
|
+
api,
|
|
16
|
+
url,
|
|
17
|
+
responseOptions: { onResponse: handleDeprecations },
|
|
18
|
+
};
|
|
19
|
+
}
|
|
4
20
|
/**
|
|
5
21
|
* Executes a GraphQL query against the Business Platform Destinations API.
|
|
6
22
|
*
|
|
@@ -10,16 +26,25 @@ import { businessPlatformFqdn } from '../context/fqdn.js';
|
|
|
10
26
|
* @returns The response of the query of generic type <T>.
|
|
11
27
|
*/
|
|
12
28
|
export async function businessPlatformRequest(query, token, variables) {
|
|
13
|
-
const api = 'BusinessPlatform';
|
|
14
|
-
const fqdn = await businessPlatformFqdn();
|
|
15
|
-
const url = `https://${fqdn}/destinations/api/2020-07/graphql`;
|
|
16
29
|
return graphqlRequest({
|
|
30
|
+
...(await setupRequest(token)),
|
|
31
|
+
query,
|
|
32
|
+
variables,
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Executes a GraphQL query against the Business Platform Destinations API. Uses typed documents.
|
|
37
|
+
*
|
|
38
|
+
* @param query - GraphQL query to execute.
|
|
39
|
+
* @param token - Business Platform token.
|
|
40
|
+
* @param variables - GraphQL variables to pass to the query.
|
|
41
|
+
* @returns The response of the query of generic type <TResult>.
|
|
42
|
+
*/
|
|
43
|
+
export async function businessPlatformRequestDoc(query, token, variables) {
|
|
44
|
+
return graphqlRequestDoc({
|
|
45
|
+
...(await setupRequest(token)),
|
|
17
46
|
query,
|
|
18
|
-
api,
|
|
19
|
-
url,
|
|
20
|
-
token,
|
|
21
47
|
variables,
|
|
22
|
-
responseOptions: { onResponse: handleDeprecations },
|
|
23
48
|
});
|
|
24
49
|
}
|
|
25
50
|
//# sourceMappingURL=business-platform.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"business-platform.js","sourceRoot":"","sources":["../../../../src/public/node/api/business-platform.ts"],"names":[],"mappings":"AAAA,OAAO,EAAmB,cAAc,EAAC,MAAM,cAAc,CAAA;
|
|
1
|
+
{"version":3,"file":"business-platform.js","sourceRoot":"","sources":["../../../../src/public/node/api/business-platform.ts"],"names":[],"mappings":"AAAA,OAAO,EAAmB,cAAc,EAAE,iBAAiB,EAAC,MAAM,cAAc,CAAA;AAChF,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;;;;;;;GAOG;AACH,MAAM,CAAC,KAAK,UAAU,uBAAuB,CAC3C,KAAa,EACb,KAAa,EACb,SAA4B;IAE5B,OAAO,cAAc,CAAI;QACvB,GAAG,CAAC,MAAM,YAAY,CAAC,KAAK,CAAC,CAAC;QAC9B,KAAK;QACL,SAAS;KACV,CAAC,CAAA;AACJ,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,CAAC,KAAK,UAAU,0BAA0B,CAC9C,KAA6C,EAC7C,KAAa,EACb,SAAsB;IAEtB,OAAO,iBAAiB,CAAsB;QAC5C,GAAG,CAAC,MAAM,YAAY,CAAC,KAAK,CAAC,CAAC;QAC9B,KAAK;QACL,SAAS;KACV,CAAC,CAAA;AACJ,CAAC","sourcesContent":["import {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 * @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): Promise<T> {\n return graphqlRequest<T>({\n ...(await setupRequest(token)),\n query,\n variables,\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 * @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): Promise<TResult> {\n return graphqlRequestDoc<TResult, TVariables>({\n ...(await setupRequest(token)),\n query,\n variables,\n })\n}\n"]}
|
|
@@ -1,19 +1,26 @@
|
|
|
1
1
|
import { rawRequest, RequestDocument, Variables } from 'graphql-request';
|
|
2
|
+
import { TypedDocumentNode } from '@graphql-typed-document-node/core';
|
|
2
3
|
export interface GraphQLVariables {
|
|
3
4
|
[key: string]: any;
|
|
4
5
|
}
|
|
5
6
|
export type GraphQLResponse<T> = Awaited<ReturnType<typeof rawRequest<T>>>;
|
|
6
|
-
|
|
7
|
-
query: RequestDocument;
|
|
7
|
+
interface GraphQLRequestBaseOptions<TResult> {
|
|
8
8
|
api: string;
|
|
9
9
|
url: string;
|
|
10
10
|
token?: string;
|
|
11
11
|
addedHeaders?: {
|
|
12
12
|
[header: string]: string;
|
|
13
13
|
};
|
|
14
|
-
|
|
15
|
-
responseOptions?: GraphQLResponseOptions<T>;
|
|
14
|
+
responseOptions?: GraphQLResponseOptions<TResult>;
|
|
16
15
|
}
|
|
16
|
+
export type GraphQLRequestOptions<T> = GraphQLRequestBaseOptions<T> & {
|
|
17
|
+
query: RequestDocument;
|
|
18
|
+
variables?: Variables;
|
|
19
|
+
};
|
|
20
|
+
export type GraphQLRequestDocOptions<TResult, TVariables> = GraphQLRequestBaseOptions<TResult> & {
|
|
21
|
+
query: TypedDocumentNode<TResult, TVariables>;
|
|
22
|
+
variables?: TVariables;
|
|
23
|
+
};
|
|
17
24
|
export interface GraphQLResponseOptions<T> {
|
|
18
25
|
handleErrors?: boolean;
|
|
19
26
|
onResponse?: (response: GraphQLResponse<T>) => void;
|
|
@@ -25,3 +32,11 @@ export interface GraphQLResponseOptions<T> {
|
|
|
25
32
|
* @returns The response of the query of generic type <T>.
|
|
26
33
|
*/
|
|
27
34
|
export declare function graphqlRequest<T>(options: GraphQLRequestOptions<T>): Promise<T>;
|
|
35
|
+
/**
|
|
36
|
+
* Executes a GraphQL query to an endpoint. Uses typed documents.
|
|
37
|
+
*
|
|
38
|
+
* @param options - GraphQL request options.
|
|
39
|
+
* @returns The response of the query of generic type <TResult>.
|
|
40
|
+
*/
|
|
41
|
+
export declare function graphqlRequestDoc<TResult, TVariables extends Variables>(options: GraphQLRequestDocOptions<TResult, TVariables>): Promise<TResult>;
|
|
42
|
+
export {};
|
|
@@ -2,28 +2,51 @@ import { buildHeaders, httpsAgent } from '../../../private/node/api/headers.js';
|
|
|
2
2
|
import { debugLogRequestInfo, errorHandler } from '../../../private/node/api/graphql.js';
|
|
3
3
|
import { debugLogResponseInfo } from '../../../private/node/api.js';
|
|
4
4
|
import { runWithTimer } from '../metadata.js';
|
|
5
|
-
import { GraphQLClient } from 'graphql-request';
|
|
5
|
+
import { GraphQLClient, resolveRequestDocument } from 'graphql-request';
|
|
6
6
|
/**
|
|
7
|
-
*
|
|
7
|
+
* Handles execution of a GraphQL query.
|
|
8
8
|
*
|
|
9
9
|
* @param options - GraphQL request options.
|
|
10
|
-
* @returns The response of the query of generic type <T>.
|
|
11
10
|
*/
|
|
12
|
-
|
|
13
|
-
const {
|
|
11
|
+
async function performGraphQLRequest(options) {
|
|
12
|
+
const { token, addedHeaders, queryAsString, variables, api, url, responseOptions } = options;
|
|
14
13
|
const headers = {
|
|
15
14
|
...addedHeaders,
|
|
16
15
|
...buildHeaders(token),
|
|
17
16
|
};
|
|
18
|
-
debugLogRequestInfo(api,
|
|
17
|
+
debugLogRequestInfo(api, queryAsString, variables, headers);
|
|
19
18
|
const clientOptions = { agent: await httpsAgent(), headers };
|
|
20
19
|
const client = new GraphQLClient(url, clientOptions);
|
|
21
20
|
return runWithTimer('cmd_all_timing_network_ms')(async () => {
|
|
22
|
-
const response = await debugLogResponseInfo({ request: client.rawRequest(
|
|
21
|
+
const response = await debugLogResponseInfo({ request: client.rawRequest(queryAsString, variables), url }, responseOptions?.handleErrors === false ? undefined : errorHandler(api));
|
|
23
22
|
if (responseOptions?.onResponse) {
|
|
24
23
|
responseOptions.onResponse(response);
|
|
25
24
|
}
|
|
26
25
|
return response.data;
|
|
27
26
|
});
|
|
28
27
|
}
|
|
28
|
+
/**
|
|
29
|
+
* Executes a GraphQL query to an endpoint.
|
|
30
|
+
*
|
|
31
|
+
* @param options - GraphQL request options.
|
|
32
|
+
* @returns The response of the query of generic type <T>.
|
|
33
|
+
*/
|
|
34
|
+
export async function graphqlRequest(options) {
|
|
35
|
+
return performGraphQLRequest({
|
|
36
|
+
...options,
|
|
37
|
+
queryAsString: options.query,
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Executes a GraphQL query to an endpoint. Uses typed documents.
|
|
42
|
+
*
|
|
43
|
+
* @param options - GraphQL request options.
|
|
44
|
+
* @returns The response of the query of generic type <TResult>.
|
|
45
|
+
*/
|
|
46
|
+
export async function graphqlRequestDoc(options) {
|
|
47
|
+
return performGraphQLRequest({
|
|
48
|
+
...options,
|
|
49
|
+
queryAsString: resolveRequestDocument(options.query).query,
|
|
50
|
+
});
|
|
51
|
+
}
|
|
29
52
|
//# sourceMappingURL=graphql.js.map
|
|
@@ -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,oBAAoB,EAAC,MAAM,8BAA8B,CAAA;AACjE,OAAO,EAAC,YAAY,EAAC,MAAM,gBAAgB,CAAA;AAC3C,OAAO,EAAC,aAAa,
|
|
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,oBAAoB,EAAC,MAAM,8BAA8B,CAAA;AACjE,OAAO,EAAC,YAAY,EAAC,MAAM,gBAAgB,CAAA;AAC3C,OAAO,EAAC,aAAa,EAA+B,sBAAsB,EAAY,MAAM,iBAAiB,CAAA;AAsC7G;;;;GAIG;AACH,KAAK,UAAU,qBAAqB,CAAU,OAA8C;IAC1F,MAAM,EAAC,KAAK,EAAE,YAAY,EAAE,aAAa,EAAE,SAAS,EAAE,GAAG,EAAE,GAAG,EAAE,eAAe,EAAC,GAAG,OAAO,CAAA;IAC1F,MAAM,OAAO,GAAG;QACd,GAAG,YAAY;QACf,GAAG,YAAY,CAAC,KAAK,CAAC;KACvB,CAAA;IAED,mBAAmB,CAAC,GAAG,EAAE,aAAa,EAAE,SAAS,EAAE,OAAO,CAAC,CAAA;IAC3D,MAAM,aAAa,GAAG,EAAC,KAAK,EAAE,MAAM,UAAU,EAAE,EAAE,OAAO,EAAC,CAAA;IAC1D,MAAM,MAAM,GAAG,IAAI,aAAa,CAAC,GAAG,EAAE,aAAa,CAAC,CAAA;IAEpD,OAAO,YAAY,CAAC,2BAA2B,CAAC,CAAC,KAAK,IAAI,EAAE;QAC1D,MAAM,QAAQ,GAAG,MAAM,oBAAoB,CACzC,EAAC,OAAO,EAAE,MAAM,CAAC,UAAU,CAAU,aAAa,EAAE,SAAS,CAAC,EAAE,GAAG,EAAC,EACpE,eAAe,EAAE,YAAY,KAAK,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,YAAY,CAAC,GAAG,CAAC,CACxE,CAAA;QAED,IAAI,eAAe,EAAE,UAAU,EAAE;YAC/B,eAAe,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAA;SACrC;QAED,OAAO,QAAQ,CAAC,IAAI,CAAA;IACtB,CAAC,CAAC,CAAA;AACJ,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 {debugLogResponseInfo} from '../../../private/node/api.js'\nimport {runWithTimer} from '../metadata.js'\nimport {GraphQLClient, rawRequest, RequestDocument, resolveRequestDocument, Variables} from 'graphql-request'\nimport {TypedDocumentNode} from '@graphql-typed-document-node/core'\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\ninterface GraphQLRequestBaseOptions<TResult> {\n api: string\n url: string\n token?: string\n addedHeaders?: {[header: string]: string}\n responseOptions?: GraphQLResponseOptions<TResult>\n}\n\ntype PerformGraphQLRequestOptions<TResult> = GraphQLRequestBaseOptions<TResult> & {\n queryAsString: string\n variables?: Variables\n}\n\nexport type GraphQLRequestOptions<T> = GraphQLRequestBaseOptions<T> & {\n query: RequestDocument\n variables?: Variables\n}\n\nexport type GraphQLRequestDocOptions<TResult, TVariables> = GraphQLRequestBaseOptions<TResult> & {\n query: TypedDocumentNode<TResult, TVariables>\n variables?: TVariables\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} = options\n const headers = {\n ...addedHeaders,\n ...buildHeaders(token),\n }\n\n debugLogRequestInfo(api, queryAsString, variables, headers)\n const clientOptions = {agent: await httpsAgent(), headers}\n const client = new GraphQLClient(url, clientOptions)\n\n return runWithTimer('cmd_all_timing_network_ms')(async () => {\n const response = await debugLogResponseInfo(\n {request: client.rawRequest<TResult>(queryAsString, variables), url},\n responseOptions?.handleErrors === false ? undefined : errorHandler(api),\n )\n\n if (responseOptions?.onResponse) {\n responseOptions.onResponse(response)\n }\n\n return response.data\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,6 @@
|
|
|
1
1
|
import { GraphQLVariables, GraphQLResponse } from './graphql.js';
|
|
2
|
+
import { TypedDocumentNode } from '@graphql-typed-document-node/core';
|
|
3
|
+
import { Variables } from 'graphql-request';
|
|
2
4
|
/**
|
|
3
5
|
* Executes a GraphQL query against the Partners API.
|
|
4
6
|
*
|
|
@@ -8,6 +10,15 @@ import { GraphQLVariables, GraphQLResponse } from './graphql.js';
|
|
|
8
10
|
* @returns The response of the query of generic type <T>.
|
|
9
11
|
*/
|
|
10
12
|
export declare function partnersRequest<T>(query: string, token: string, variables?: GraphQLVariables): Promise<T>;
|
|
13
|
+
/**
|
|
14
|
+
* Executes a GraphQL query against the Partners API. Uses typed documents.
|
|
15
|
+
*
|
|
16
|
+
* @param query - GraphQL query to execute.
|
|
17
|
+
* @param token - Partners token.
|
|
18
|
+
* @param variables - GraphQL variables to pass to the query.
|
|
19
|
+
* @returns The response of the query of generic type <TResult>.
|
|
20
|
+
*/
|
|
21
|
+
export declare function partnersRequestDoc<TResult, TVariables extends Variables>(query: TypedDocumentNode<TResult, TVariables>, token: string, variables?: TVariables): Promise<TResult>;
|
|
11
22
|
export interface FunctionUploadUrlGenerateResponse {
|
|
12
23
|
functionUploadUrlGenerate: {
|
|
13
24
|
generatedUrlDetails: {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { graphqlRequest } from './graphql.js';
|
|
1
|
+
import { graphqlRequest, graphqlRequestDoc } from './graphql.js';
|
|
2
2
|
import { partnersFqdn } from '../context/fqdn.js';
|
|
3
3
|
import { setNextDeprecationDate } from '../../../private/node/context/deprecations-store.js';
|
|
4
4
|
import { gql } from 'graphql-request';
|
|
@@ -10,6 +10,22 @@ const limiter = new Bottleneck({
|
|
|
10
10
|
minTime: 150,
|
|
11
11
|
maxConcurrent: 10,
|
|
12
12
|
});
|
|
13
|
+
/**
|
|
14
|
+
* Sets up the request to the Partners API.
|
|
15
|
+
*
|
|
16
|
+
* @param token - Partners token.
|
|
17
|
+
*/
|
|
18
|
+
async function setupRequest(token) {
|
|
19
|
+
const api = 'Partners';
|
|
20
|
+
const fqdn = await partnersFqdn();
|
|
21
|
+
const url = `https://${fqdn}/api/cli/graphql`;
|
|
22
|
+
return {
|
|
23
|
+
token,
|
|
24
|
+
api,
|
|
25
|
+
url,
|
|
26
|
+
responseOptions: { onResponse: handleDeprecations },
|
|
27
|
+
};
|
|
28
|
+
}
|
|
13
29
|
/**
|
|
14
30
|
* Executes a GraphQL query against the Partners API.
|
|
15
31
|
*
|
|
@@ -19,16 +35,28 @@ const limiter = new Bottleneck({
|
|
|
19
35
|
* @returns The response of the query of generic type <T>.
|
|
20
36
|
*/
|
|
21
37
|
export async function partnersRequest(query, token, variables) {
|
|
22
|
-
const
|
|
23
|
-
const fqdn = await partnersFqdn();
|
|
24
|
-
const url = `https://${fqdn}/api/cli/graphql`;
|
|
38
|
+
const opts = await setupRequest(token);
|
|
25
39
|
const result = limiter.schedule(() => graphqlRequest({
|
|
40
|
+
...opts,
|
|
41
|
+
query,
|
|
42
|
+
variables,
|
|
43
|
+
}));
|
|
44
|
+
return result;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Executes a GraphQL query against the Partners API. Uses typed documents.
|
|
48
|
+
*
|
|
49
|
+
* @param query - GraphQL query to execute.
|
|
50
|
+
* @param token - Partners token.
|
|
51
|
+
* @param variables - GraphQL variables to pass to the query.
|
|
52
|
+
* @returns The response of the query of generic type <TResult>.
|
|
53
|
+
*/
|
|
54
|
+
export async function partnersRequestDoc(query, token, variables) {
|
|
55
|
+
const opts = await setupRequest(token);
|
|
56
|
+
const result = limiter.schedule(() => graphqlRequestDoc({
|
|
57
|
+
...opts,
|
|
26
58
|
query,
|
|
27
|
-
api,
|
|
28
|
-
url,
|
|
29
|
-
token,
|
|
30
59
|
variables,
|
|
31
|
-
responseOptions: { onResponse: handleDeprecations },
|
|
32
60
|
}));
|
|
33
61
|
return result;
|
|
34
62
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"partners.js","sourceRoot":"","sources":["../../../../src/public/node/api/partners.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,cAAc,
|
|
1
|
+
{"version":3,"file":"partners.js","sourceRoot":"","sources":["../../../../src/public/node/api/partners.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,cAAc,EAAqC,iBAAiB,EAAC,MAAM,cAAc,CAAA;AACjG,OAAO,EAAC,YAAY,EAAC,MAAM,oBAAoB,CAAA;AAC/C,OAAO,EAAC,sBAAsB,EAAC,MAAM,qDAAqD,CAAA;AAE1F,OAAO,EAAY,GAAG,EAAC,MAAM,iBAAiB,CAAA;AAC9C,OAAO,UAAU,MAAM,YAAY,CAAA;AAEnC,sEAAsE;AACtE,yEAAyE;AACzE,iDAAiD;AACjD,MAAM,OAAO,GAAG,IAAI,UAAU,CAAC;IAC7B,OAAO,EAAE,GAAG;IACZ,aAAa,EAAE,EAAE;CAClB,CAAC,CAAA;AAEF;;;;GAIG;AACH,KAAK,UAAU,YAAY,CAAC,KAAa;IACvC,MAAM,GAAG,GAAG,UAAU,CAAA;IACtB,MAAM,IAAI,GAAG,MAAM,YAAY,EAAE,CAAA;IACjC,MAAM,GAAG,GAAG,WAAW,IAAI,kBAAkB,CAAA;IAC7C,OAAO;QACL,KAAK;QACL,GAAG;QACH,GAAG;QACH,eAAe,EAAE,EAAC,UAAU,EAAE,kBAAkB,EAAC;KAClD,CAAA;AACH,CAAC;AAED;;;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C,CAAC,CAAA;SAChE;KACF;IAED,sBAAsB,CAAC,gBAAgB,CAAC,CAAA;AAC1C,CAAC","sourcesContent":["import {graphqlRequest, GraphQLVariables, GraphQLResponse, graphqlRequestDoc} from './graphql.js'\nimport {partnersFqdn} from '../context/fqdn.js'\nimport {setNextDeprecationDate} from '../../../private/node/context/deprecations-store.js'\nimport {TypedDocumentNode} from '@graphql-typed-document-node/core'\nimport {Variables, gql} from 'graphql-request'\nimport Bottleneck from 'bottleneck'\n\n// API Rate limiter for partners API (Limit is 10 requests per second)\n// Jobs are launched every 150ms to add an extra 50ms margin per request.\n// Only 10 requests can be executed concurrently.\nconst limiter = new Bottleneck({\n minTime: 150,\n maxConcurrent: 10,\n})\n\n/**\n * Sets up the request to the Partners API.\n *\n * @param token - Partners token.\n */\nasync function setupRequest(token: string) {\n const api = 'Partners'\n const fqdn = await partnersFqdn()\n const url = `https://${fqdn}/api/cli/graphql`\n return {\n token,\n api,\n url,\n responseOptions: {onResponse: handleDeprecations},\n }\n}\n\n/**\n * Executes a GraphQL query against the Partners API.\n *\n * @param query - GraphQL query to execute.\n * @param token - Partners token.\n * @param variables - GraphQL variables to pass to the query.\n * @returns The response of the query of generic type <T>.\n */\nexport async function partnersRequest<T>(query: string, token: string, variables?: GraphQLVariables): Promise<T> {\n const opts = await setupRequest(token)\n const result = limiter.schedule(() =>\n graphqlRequest<T>({\n ...opts,\n query,\n variables,\n }),\n )\n\n return result\n}\n\n/**\n * Executes a GraphQL query against the Partners API. Uses typed documents.\n *\n * @param query - GraphQL query to execute.\n * @param token - Partners token.\n * @param variables - GraphQL variables to pass to the query.\n * @returns The response of the query of generic type <TResult>.\n */\nexport async function partnersRequestDoc<TResult, TVariables extends Variables>(\n query: TypedDocumentNode<TResult, TVariables>,\n token: string,\n variables?: TVariables,\n): Promise<TResult> {\n const opts = await setupRequest(token)\n const result = limiter.schedule(() =>\n graphqlRequestDoc<TResult, TVariables>({\n ...opts,\n query,\n variables,\n }),\n )\n\n return result\n}\n\nexport interface FunctionUploadUrlGenerateResponse {\n functionUploadUrlGenerate: {\n generatedUrlDetails: {\n url: string\n moduleId: string\n headers: {[key: string]: string}\n maxBytes: number\n maxSize: string\n }\n }\n}\n\n/**\n * Request a URL from partners to which we will upload our function.\n *\n * @param token - Partners token.\n * @returns The response of the query.\n */\nexport async function getFunctionUploadUrl(token: string): Promise<FunctionUploadUrlGenerateResponse> {\n const res: FunctionUploadUrlGenerateResponse = await partnersRequest(FunctionUploadUrlGenerateMutation, token)\n return res\n}\n\nexport const FunctionUploadUrlGenerateMutation = gql`\n mutation functionUploadUrlGenerateMutation {\n functionUploadUrlGenerate {\n generatedUrlDetails {\n url\n moduleId\n headers\n maxBytes\n maxSize\n }\n }\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"]}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Command } from '@oclif/core';
|
|
2
|
-
import { FlagOutput, Input, ParserOutput, ArgOutput } from '@oclif/core/lib/interfaces/parser.js';
|
|
2
|
+
import { FlagOutput, Input, ParserOutput, FlagInput, ArgOutput } from '@oclif/core/lib/interfaces/parser.js';
|
|
3
3
|
declare abstract class BaseCommand extends Command {
|
|
4
|
+
static baseFlags: FlagInput<{}>;
|
|
4
5
|
static descriptionWithoutMarkdown(): string | undefined;
|
|
5
6
|
static analyticsNameOverride(): string | undefined;
|
|
6
7
|
static analyticsStopCommand(): string | undefined;
|
|
@@ -115,6 +115,8 @@ This flag is required in non-interactive terminal environments, such as a CI env
|
|
|
115
115
|
return result;
|
|
116
116
|
}
|
|
117
117
|
}
|
|
118
|
+
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
119
|
+
BaseCommand.baseFlags = {};
|
|
118
120
|
export async function addFromParsedFlags(flags) {
|
|
119
121
|
await addPublicMetadata(() => ({
|
|
120
122
|
cmd_all_verbose: flags.verbose,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base-command.js","sourceRoot":"","sources":["../../../src/public/node/base-command.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,YAAY,EAAE,2CAA2C,EAAC,MAAM,oBAAoB,CAAA;AAC5F,OAAO,EAAC,eAAe,EAAC,MAAM,mBAAmB,CAAA;AACjD,OAAO,EAAC,aAAa,EAAC,MAAM,oBAAoB,CAAA;AAChD,OAAO,EAAC,iBAAiB,EAAC,MAAM,eAAe,CAAA;AAC/C,OAAO,EAAC,UAAU,EAAC,MAAM,YAAY,CAAA;AACrC,OAAO,EAAC,UAAU,EAAE,aAAa,EAAC,MAAM,SAAS,CAAA;AACjD,OAAO,EAAC,aAAa,EAAE,UAAU,EAAE,WAAW,EAAC,MAAM,aAAa,CAAA;AAClE,OAAO,EAAC,uBAAuB,EAAC,MAAM,aAAa,CAAA;AACnD,OAAO,EAAC,UAAU,EAAC,MAAM,aAAa,CAAA;AACtC,OAAO,EAAC,QAAQ,EAAC,MAAM,wBAAwB,CAAA;AAE/C,OAAO,EAAC,UAAU,EAAC,MAAM,qBAAqB,CAAA;AAC9C,OAAO,EAAC,OAAO,EAAE,MAAM,EAAC,MAAM,aAAa,CAAA;AAQ3C,MAAe,WAAY,SAAQ,OAAO;IACxC,gEAAgE;IACzD,MAAM,CAAC,0BAA0B;QACtC,8DAA8D;QAC9D,OAAO,CAAE,IAAY,CAAC,uBAAuB,IAAI,EAAE,CAAC,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EAAE,CAAC,CAAA;iBACxB;qBAAM;oBACL,MAAM,IAAI,UAAU,CAClB,aAAa,CAAA,0EAA0E,WAAW,CAAC,MAAM,CACvG,KAAK,CACN,YAAY,CACd,CAAA;iBACF;aACF;iBAAM,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE;gBAC/B,KAAK,CAAC,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,KAAK,EAAE,EAAE,GAAG,OAAO,EAAE,CAAC,CAAC,CAAA;aAClE;iBAAM;gBACL,IAAI,CAAC,IAAI,CAAC,KAAK,KAAK,EAAE,EAAE,GAAG,KAAK,EAAE,CAAC,CAAA;aACpC;SACF;KACF;IACD,OAAO,IAAI,CAAA;AACb,CAAC;AAED,eAAe,WAAW,CAAA","sourcesContent":["import {errorHandler, registerCleanBugsnagErrorsFromWithinPlugins} from './error-handler.js'\nimport {loadEnvironment} from './environments.js'\nimport {isDevelopment} from './context/local.js'\nimport {addPublicMetadata} from './metadata.js'\nimport {AbortError} from './error.js'\nimport {renderInfo, renderWarning} from './ui.js'\nimport {outputContent, outputInfo, outputToken} from './output.js'\nimport {terminalSupportsRawMode} from './system.js'\nimport {hashString} from './crypto.js'\nimport {isTruthy} from './context/utilities.js'\nimport {JsonMap} from '../../private/common/json.js'\nimport {underscore} from '../common/string.js'\nimport {Command, Errors} from '@oclif/core'\nimport {FlagOutput, Input, ParserOutput, FlagInput, ArgOutput} from '@oclif/core/lib/interfaces/parser.js'\n\ninterface EnvironmentFlags {\n environment?: string\n path?: string\n}\n\nabstract class BaseCommand extends Command {\n // Replace markdown links to plain text like: \"link label\" (url)\n public static descriptionWithoutMarkdown(): string | undefined {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n return ((this as any).descriptionWithMarkdown ?? '').replace(/(\\[)(.*?)(])(\\()(.*?)(\\))/gm, '\"$2\" ($5)')\n }\n\n public static analyticsNameOverride(): string | undefined {\n return undefined\n }\n\n public static analyticsStopCommand(): string | undefined {\n return undefined\n }\n\n async catch(error: Error & {skipOclifErrorHandling: boolean}): Promise<void> {\n error.skipOclifErrorHandling = true\n await errorHandler(error, this.config)\n return Errors.handle(error)\n }\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n protected async init(): Promise<any> {\n this.exitWithTimestampWhenEnvVariablePresent()\n if (!isDevelopment()) {\n // This function runs just prior to `run`\n await registerCleanBugsnagErrorsFromWithinPlugins(this.config)\n }\n this.showNpmFlagWarning()\n return super.init()\n }\n\n // NPM creates an environment variable for every flag passed to a script.\n // This function checks for the presence of any of the available CLI flags\n // and warns the user to use the `--` separator.\n protected showNpmFlagWarning(): void {\n const commandVariables = this.constructor as unknown as {flags: JsonMap}\n const commandFlags = Object.keys(commandVariables.flags || {})\n const possibleNpmEnvVars = commandFlags.map((key) => `npm_config_${underscore(key).replace(/^no_/, '')}`)\n\n if (possibleNpmEnvVars.some((flag) => process.env[flag] !== undefined)) {\n renderWarning({\n body: [\n 'NPM scripts require an extra',\n {command: '--'},\n 'separator to pass the flags. Example:',\n {command: 'npm run dev -- --reset'},\n ],\n })\n }\n }\n\n // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types\n protected exitWithTimestampWhenEnvVariablePresent() {\n if (isTruthy(process.env.SHOPIFY_CLI_ENV_STARTUP_PERFORMANCE_RUN)) {\n outputInfo(`\n SHOPIFY_CLI_TIMESTAMP_START\n { \"timestamp\": ${Date.now()} }\n SHOPIFY_CLI_TIMESTAMP_END\n `)\n process.exit(0)\n }\n }\n\n protected async parse<\n TFlags extends FlagOutput & {path?: string; verbose?: boolean},\n TGlobalFlags extends FlagOutput,\n TArgs extends ArgOutput,\n >(\n options?: Input<TFlags, TGlobalFlags, TArgs>,\n argv?: string[],\n ): Promise<ParserOutput<TFlags, TGlobalFlags, TArgs> & {argv: string[]}> {\n let result = await super.parse<TFlags, TGlobalFlags, TArgs>(options, argv)\n result = await this.resultWithEnvironment<TFlags, TGlobalFlags, TArgs>(result, options, argv)\n await addFromParsedFlags(result.flags)\n return {...result, ...{argv: result.argv as string[]}}\n }\n\n protected environmentsFilename(): string | undefined {\n // To be re-implemented if needed\n return undefined\n }\n\n protected failMissingNonTTYFlags(flags: FlagOutput, requiredFlags: string[]): void {\n if (terminalSupportsRawMode()) return\n\n requiredFlags.forEach((name: string) => {\n if (!(name in flags)) {\n throw new AbortError(\n outputContent`Flag not specified:\n\n${outputToken.cyan(name)}\n\nThis flag is required in non-interactive terminal environments, such as a CI environment, or when piping input from another process.`,\n 'To resolve this, specify the option in the command, or run the command in an interactive environment such as your local terminal.',\n )\n }\n })\n }\n\n private async resultWithEnvironment<\n TFlags extends FlagOutput & {path?: string; verbose?: boolean},\n TGlobalFlags extends FlagOutput,\n TArgs extends ArgOutput,\n >(\n originalResult: ParserOutput<TFlags, TGlobalFlags, TArgs>,\n options?: Input<TFlags, TGlobalFlags, TArgs>,\n argv?: string[],\n ): Promise<ParserOutput<TFlags, TGlobalFlags, TArgs>> {\n // If no environment is specified, don't modify the results\n const flags = originalResult.flags as EnvironmentFlags\n const environmentsFileName = this.environmentsFilename()\n if (!flags.environment || !environmentsFileName) return originalResult\n\n // If the specified environment isn't found, don't modify the results\n const environment = await loadEnvironment(flags.environment, environmentsFileName, {from: flags.path})\n if (!environment) return originalResult\n\n // Parse using noDefaultsOptions to derive a list of flags specified as\n // command-line arguments.\n const noDefaultsResult = await super.parse<TFlags, TGlobalFlags, TArgs>(noDefaultsOptions(options), argv)\n\n // Add the environment's settings to argv and pass them to `super.parse`. This\n // invokes oclif's validation system without breaking the oclif black box.\n // Replace the original result with this one.\n const result = await super.parse<TFlags, TGlobalFlags, TArgs>(options, [\n // Need to specify argv default because we're merging with argsFromEnvironment.\n ...(argv || this.argv),\n ...argsFromEnvironment<TFlags, TGlobalFlags, TArgs>(environment, options, noDefaultsResult),\n ])\n\n // Report successful application of the environment.\n reportEnvironmentApplication<TFlags, TGlobalFlags, TArgs>(\n noDefaultsResult.flags,\n result.flags,\n flags.environment,\n environment,\n )\n\n return result\n }\n}\n\nexport async function addFromParsedFlags(flags: {path?: string; verbose?: boolean}): Promise<void> {\n await addPublicMetadata(() => ({\n cmd_all_verbose: flags.verbose,\n cmd_all_path_override: flags.path !== undefined,\n cmd_all_path_override_hash: flags.path === undefined ? undefined : hashString(flags.path),\n }))\n}\n\n/**\n * Any flag which is:\n *\n * 1. Present in the final set of flags\n * 2. Specified in the environment\n * 3. Not specified by the user as a command line argument\n *\n * should be reported.\n *\n * It doesn't matter if the environment flag's value was the same as the default; from\n * the user's perspective, they want to know their environment was applied.\n */\nfunction reportEnvironmentApplication<\n TFlags extends FlagOutput,\n TGlobalFlags extends FlagOutput,\n TArgs extends ArgOutput,\n>(\n noDefaultsFlags: ParserOutput<TFlags, TGlobalFlags, TArgs>['flags'],\n flagsWithEnvironments: ParserOutput<TFlags, TGlobalFlags, TArgs>['flags'],\n environmentName: string,\n environment: JsonMap,\n): void {\n const changes: JsonMap = {}\n for (const [name, value] of Object.entries(flagsWithEnvironments)) {\n const userSpecifiedThisFlag = Object.prototype.hasOwnProperty.call(noDefaultsFlags, name)\n const environmentContainsFlag = Object.prototype.hasOwnProperty.call(environment, name)\n if (!userSpecifiedThisFlag && environmentContainsFlag) {\n const valueToReport = name === 'password' ? `********${value.substr(-4)}` : value\n changes[name] = valueToReport\n }\n }\n if (Object.keys(changes).length === 0) return\n\n const items = Object.entries(changes).map(([name, value]) => `${name}: ${value}`)\n renderInfo({\n headline: ['Using applicable flags from', {userInput: environmentName}, 'environment:'],\n body: [{list: {items}}],\n })\n}\n\n/**\n * Strips the defaults from configured flags. For example, if flags contains:\n *\n * ```\n * someFlag: Flags.boolean({\n * description: 'some flag',\n * default: false\n * })\n * ```\n *\n * it becomes:\n *\n * ```\n * someFlag: Flags.boolean({\n * description: 'some flag'\n * })\n * ```\n *\n * If we parse using this configuration, the only specified flags will be those\n * the user actually passed on the command line.\n */\nfunction noDefaultsOptions<TFlags extends FlagOutput, TGlobalFlags extends FlagOutput, TArgs extends ArgOutput>(\n options: Input<TFlags, TGlobalFlags, TArgs> | undefined,\n): Input<TFlags, TGlobalFlags, TArgs> | undefined {\n if (!options?.flags) return options\n return {\n ...options,\n flags: Object.fromEntries(\n Object.entries(options.flags).map(([label, settings]) => {\n const copiedSettings = {...(settings as {default?: unknown})}\n delete copiedSettings.default\n return [label, copiedSettings]\n }),\n ) as FlagInput<TFlags>,\n }\n}\n\n/**\n * Converts the environment's settings to arguments as though passed on the command\n * line, skipping any arguments the user specified on the command line.\n */\nfunction argsFromEnvironment<TFlags extends FlagOutput, TGlobalFlags extends FlagOutput, TArgs extends ArgOutput>(\n environment: JsonMap,\n options: Input<TFlags, TGlobalFlags, TArgs> | undefined,\n noDefaultsResult: ParserOutput<TFlags, TArgs>,\n): string[] {\n const args: string[] = []\n for (const [label, value] of Object.entries(environment)) {\n const flagIsRelevantToCommand = options?.flags && Object.prototype.hasOwnProperty.call(options.flags, label)\n const userSpecifiedThisFlag =\n noDefaultsResult.flags && Object.prototype.hasOwnProperty.call(noDefaultsResult.flags, label)\n if (flagIsRelevantToCommand && !userSpecifiedThisFlag) {\n if (typeof value === 'boolean') {\n if (value === true) {\n args.push(`--${label}`)\n } else {\n throw new AbortError(\n outputContent`Environments can only specify true for boolean flags. Attempted to set ${outputToken.yellow(\n label,\n )} to false.`,\n )\n }\n } else if (Array.isArray(value)) {\n value.forEach((element) => args.push(`--${label}`, `${element}`))\n } else {\n args.push(`--${label}`, `${value}`)\n }\n }\n }\n return args\n}\n\nexport default BaseCommand\n"]}
|
|
1
|
+
{"version":3,"file":"base-command.js","sourceRoot":"","sources":["../../../src/public/node/base-command.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,YAAY,EAAE,2CAA2C,EAAC,MAAM,oBAAoB,CAAA;AAC5F,OAAO,EAAC,eAAe,EAAC,MAAM,mBAAmB,CAAA;AACjD,OAAO,EAAC,aAAa,EAAC,MAAM,oBAAoB,CAAA;AAChD,OAAO,EAAC,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inPlugins} from './error-handler.js'\nimport {loadEnvironment} from './environments.js'\nimport {isDevelopment} from './context/local.js'\nimport {addPublicMetadata} from './metadata.js'\nimport {AbortError} from './error.js'\nimport {renderInfo, renderWarning} from './ui.js'\nimport {outputContent, outputInfo, outputToken} from './output.js'\nimport {terminalSupportsRawMode} from './system.js'\nimport {hashString} from './crypto.js'\nimport {isTruthy} from './context/utilities.js'\nimport {JsonMap} from '../../private/common/json.js'\nimport {underscore} from '../common/string.js'\nimport {Command, Errors} from '@oclif/core'\nimport {FlagOutput, Input, ParserOutput, FlagInput, ArgOutput} from '@oclif/core/lib/interfaces/parser.js'\n\ninterface EnvironmentFlags {\n environment?: string\n path?: string\n}\n\nabstract class BaseCommand extends Command {\n // eslint-disable-next-line @typescript-eslint/ban-types\n static baseFlags: FlagInput<{}> = {}\n\n // Replace markdown links to plain text like: \"link label\" (url)\n public static descriptionWithoutMarkdown(): string | undefined {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n return ((this as any).descriptionWithMarkdown ?? '').replace(/(\\[)(.*?)(])(\\()(.*?)(\\))/gm, '\"$2\" ($5)')\n }\n\n public static analyticsNameOverride(): string | undefined {\n return undefined\n }\n\n public static analyticsStopCommand(): string | undefined {\n return undefined\n }\n\n async catch(error: Error & {skipOclifErrorHandling: boolean}): Promise<void> {\n error.skipOclifErrorHandling = true\n await errorHandler(error, this.config)\n return Errors.handle(error)\n }\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n protected async init(): Promise<any> {\n this.exitWithTimestampWhenEnvVariablePresent()\n if (!isDevelopment()) {\n // This function runs just prior to `run`\n await registerCleanBugsnagErrorsFromWithinPlugins(this.config)\n }\n this.showNpmFlagWarning()\n return super.init()\n }\n\n // NPM creates an environment variable for every flag passed to a script.\n // This function checks for the presence of any of the available CLI flags\n // and warns the user to use the `--` separator.\n protected showNpmFlagWarning(): void {\n const commandVariables = this.constructor as unknown as {flags: JsonMap}\n const commandFlags = Object.keys(commandVariables.flags || {})\n const possibleNpmEnvVars = commandFlags.map((key) => `npm_config_${underscore(key).replace(/^no_/, '')}`)\n\n if (possibleNpmEnvVars.some((flag) => process.env[flag] !== undefined)) {\n renderWarning({\n body: [\n 'NPM scripts require an extra',\n {command: '--'},\n 'separator to pass the flags. Example:',\n {command: 'npm run dev -- --reset'},\n ],\n })\n }\n }\n\n // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types\n protected exitWithTimestampWhenEnvVariablePresent() {\n if (isTruthy(process.env.SHOPIFY_CLI_ENV_STARTUP_PERFORMANCE_RUN)) {\n outputInfo(`\n SHOPIFY_CLI_TIMESTAMP_START\n { \"timestamp\": ${Date.now()} }\n SHOPIFY_CLI_TIMESTAMP_END\n `)\n process.exit(0)\n }\n }\n\n protected async parse<\n TFlags extends FlagOutput & {path?: string; verbose?: boolean},\n TGlobalFlags extends FlagOutput,\n TArgs extends ArgOutput,\n >(\n options?: Input<TFlags, TGlobalFlags, TArgs>,\n argv?: string[],\n ): Promise<ParserOutput<TFlags, TGlobalFlags, TArgs> & {argv: string[]}> {\n let result = await super.parse<TFlags, TGlobalFlags, TArgs>(options, argv)\n result = await this.resultWithEnvironment<TFlags, TGlobalFlags, TArgs>(result, options, argv)\n await addFromParsedFlags(result.flags)\n return {...result, ...{argv: result.argv as string[]}}\n }\n\n protected environmentsFilename(): string | undefined {\n // To be re-implemented if needed\n return undefined\n }\n\n protected failMissingNonTTYFlags(flags: FlagOutput, requiredFlags: string[]): void {\n if (terminalSupportsRawMode()) return\n\n requiredFlags.forEach((name: string) => {\n if (!(name in flags)) {\n throw new AbortError(\n outputContent`Flag not specified:\n\n${outputToken.cyan(name)}\n\nThis flag is required in non-interactive terminal environments, such as a CI environment, or when piping input from another process.`,\n 'To resolve this, specify the option in the command, or run the command in an interactive environment such as your local terminal.',\n )\n }\n })\n }\n\n private async resultWithEnvironment<\n TFlags extends FlagOutput & {path?: string; verbose?: boolean},\n TGlobalFlags extends FlagOutput,\n TArgs extends ArgOutput,\n >(\n originalResult: ParserOutput<TFlags, TGlobalFlags, TArgs>,\n options?: Input<TFlags, TGlobalFlags, TArgs>,\n argv?: string[],\n ): Promise<ParserOutput<TFlags, TGlobalFlags, TArgs>> {\n // If no environment is specified, don't modify the results\n const flags = originalResult.flags as EnvironmentFlags\n const environmentsFileName = this.environmentsFilename()\n if (!flags.environment || !environmentsFileName) return originalResult\n\n // If the specified environment isn't found, don't modify the results\n const environment = await loadEnvironment(flags.environment, environmentsFileName, {from: flags.path})\n if (!environment) return originalResult\n\n // Parse using noDefaultsOptions to derive a list of flags specified as\n // command-line arguments.\n const noDefaultsResult = await super.parse<TFlags, TGlobalFlags, TArgs>(noDefaultsOptions(options), argv)\n\n // Add the environment's settings to argv and pass them to `super.parse`. This\n // invokes oclif's validation system without breaking the oclif black box.\n // Replace the original result with this one.\n const result = await super.parse<TFlags, TGlobalFlags, TArgs>(options, [\n // Need to specify argv default because we're merging with argsFromEnvironment.\n ...(argv || this.argv),\n ...argsFromEnvironment<TFlags, TGlobalFlags, TArgs>(environment, options, noDefaultsResult),\n ])\n\n // Report successful application of the environment.\n reportEnvironmentApplication<TFlags, TGlobalFlags, TArgs>(\n noDefaultsResult.flags,\n result.flags,\n flags.environment,\n environment,\n )\n\n return result\n }\n}\n\nexport async function addFromParsedFlags(flags: {path?: string; verbose?: boolean}): Promise<void> {\n await addPublicMetadata(() => ({\n cmd_all_verbose: flags.verbose,\n cmd_all_path_override: flags.path !== undefined,\n cmd_all_path_override_hash: flags.path === undefined ? undefined : hashString(flags.path),\n }))\n}\n\n/**\n * Any flag which is:\n *\n * 1. Present in the final set of flags\n * 2. Specified in the environment\n * 3. Not specified by the user as a command line argument\n *\n * should be reported.\n *\n * It doesn't matter if the environment flag's value was the same as the default; from\n * the user's perspective, they want to know their environment was applied.\n */\nfunction reportEnvironmentApplication<\n TFlags extends FlagOutput,\n TGlobalFlags extends FlagOutput,\n TArgs extends ArgOutput,\n>(\n noDefaultsFlags: ParserOutput<TFlags, TGlobalFlags, TArgs>['flags'],\n flagsWithEnvironments: ParserOutput<TFlags, TGlobalFlags, TArgs>['flags'],\n environmentName: string,\n environment: JsonMap,\n): void {\n const changes: JsonMap = {}\n for (const [name, value] of Object.entries(flagsWithEnvironments)) {\n const userSpecifiedThisFlag = Object.prototype.hasOwnProperty.call(noDefaultsFlags, name)\n const environmentContainsFlag = Object.prototype.hasOwnProperty.call(environment, name)\n if (!userSpecifiedThisFlag && environmentContainsFlag) {\n const valueToReport = name === 'password' ? `********${value.substr(-4)}` : value\n changes[name] = valueToReport\n }\n }\n if (Object.keys(changes).length === 0) return\n\n const items = Object.entries(changes).map(([name, value]) => `${name}: ${value}`)\n renderInfo({\n headline: ['Using applicable flags from', {userInput: environmentName}, 'environment:'],\n body: [{list: {items}}],\n })\n}\n\n/**\n * Strips the defaults from configured flags. For example, if flags contains:\n *\n * ```\n * someFlag: Flags.boolean({\n * description: 'some flag',\n * default: false\n * })\n * ```\n *\n * it becomes:\n *\n * ```\n * someFlag: Flags.boolean({\n * description: 'some flag'\n * })\n * ```\n *\n * If we parse using this configuration, the only specified flags will be those\n * the user actually passed on the command line.\n */\nfunction noDefaultsOptions<TFlags extends FlagOutput, TGlobalFlags extends FlagOutput, TArgs extends ArgOutput>(\n options: Input<TFlags, TGlobalFlags, TArgs> | undefined,\n): Input<TFlags, TGlobalFlags, TArgs> | undefined {\n if (!options?.flags) return options\n return {\n ...options,\n flags: Object.fromEntries(\n Object.entries(options.flags).map(([label, settings]) => {\n const copiedSettings = {...(settings as {default?: unknown})}\n delete copiedSettings.default\n return [label, copiedSettings]\n }),\n ) as FlagInput<TFlags>,\n }\n}\n\n/**\n * Converts the environment's settings to arguments as though passed on the command\n * line, skipping any arguments the user specified on the command line.\n */\nfunction argsFromEnvironment<TFlags extends FlagOutput, TGlobalFlags extends FlagOutput, TArgs extends ArgOutput>(\n environment: JsonMap,\n options: Input<TFlags, TGlobalFlags, TArgs> | undefined,\n noDefaultsResult: ParserOutput<TFlags, TArgs>,\n): string[] {\n const args: string[] = []\n for (const [label, value] of Object.entries(environment)) {\n const flagIsRelevantToCommand = options?.flags && Object.prototype.hasOwnProperty.call(options.flags, label)\n const userSpecifiedThisFlag =\n noDefaultsResult.flags && Object.prototype.hasOwnProperty.call(noDefaultsResult.flags, label)\n if (flagIsRelevantToCommand && !userSpecifiedThisFlag) {\n if (typeof value === 'boolean') {\n if (value === true) {\n args.push(`--${label}`)\n } else {\n throw new AbortError(\n outputContent`Environments can only specify true for boolean flags. Attempted to set ${outputToken.yellow(\n label,\n )} to false.`,\n )\n }\n } else if (Array.isArray(value)) {\n value.forEach((element) => args.push(`--${label}`, `${element}`))\n } else {\n args.push(`--${label}`, `${value}`)\n }\n }\n }\n return args\n}\n\nexport default BaseCommand\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dot-env.js","sourceRoot":"","sources":["../../../src/public/node/dot-env.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAC,MAAM,YAAY,CAAA;AACrC,OAAO,EAAC,UAAU,EAAE,QAAQ,EAAE,SAAS,EAAC,MAAM,SAAS,CAAA;AACvD,OAAO,EAAC,WAAW,EAAE,aAAa,EAAE,WAAW,EAAC,MAAM,6BAA6B,CAAA;AACnF,OAAO,EAAC,KAAK,EAAC,MAAM,QAAQ,CAAA;AAgB5B;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,kBAAkB,CAAC,IAAY;IACnD,WAAW,CAAC,aAAa,CAAA,4BAA4B,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;IAC9E,IAAI,CAAC,CAAC,MAAM,UAAU,CAAC,IAAI,CAAC,CAAC,EAAE;QAC7B,MAAM,IAAI,UAAU,CAAC,2BAA2B,IAAI,kBAAkB,CAAC,CAAA;KACxE;IACD,MAAM,OAAO,GAAG,MAAM,QAAQ,CAAC,IAAI,CAAC,CAAA;IACpC,OAAO;QACL,IAAI;QACJ,SAAS,EAAE,KAAK,CAAC,OA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AAC,IAAI,MAAM,CAAC,OAAO,CAAC,aAAa,CAAC,EAAE;QACpE,IAAI,CAAC,kBAAkB,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE;YAC1C,WAAW,CAAC,IAAI,CAAC,oBAAoB,CAAC,QAAQ,EAAE,YAAY,CAAC,CAAC,CAAA;SAC/D;KACF;IAED,OAAO,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;AAC/B,CAAC;AAED,MAAM,UAAU,oBAAoB,CAAC,GAAW,EAAE,KAAc,EAAE,KAAc;IAC9E,IAAI,KAAK,EAAE;QACT,OAAO,GAAG,GAAG,IAAI,KAAK,GAAG,KAAK,GAAG,KAAK,EAAE,CAAA;KACzC;IACD,IAAI,KAAK,IAAI,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE;QACjC,MAAM,cAAc,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAA;QAE5E,IAAI,CAAC,cAAc,EAAE;YACnB,MAAM,IAAI,UAAU,CAAC,mFAAmF,KAAK,EAAE,CAAC,CAAA;SACjH;QAED,OAAO,GAAG,GAAG,IAAI,cAAc,GAAG,KAAK,GAAG,cAAc,EAAE,CAAA;KAC3D;IACD,OAAO,GAAG,GAAG,IAAI,KAAK,EAAE,CAAA;AAC1B,CAAC","sourcesContent":["import {AbortError} from './error.js'\nimport {fileExists, readFile, writeFile} from './fs.js'\nimport {outputDebug, outputContent, outputToken} from '../../public/node/output.js'\nimport {parse} from 'dotenv'\n\n/**\n * This interface represents a .env file.\n */\nexport interface DotEnvFile {\n /**\n * Path to the .env file.\n */\n path: string\n /**\n * Variables of the .env file.\n */\n variables: {[name: string]: string}\n}\n\n/**\n * Reads and parses a .env file.\n * @param path - Path to the .env file\n * @returns An in-memory representation of the .env file.\n */\nexport async function readAndParseDotEnv(path: string): Promise<DotEnvFile> {\n outputDebug(outputContent`Reading the .env file at ${outputToken.path(path)}`)\n if (!(await fileExists(path))) {\n throw new AbortError(`The environment file at ${path} does not exist.`)\n }\n const content = await readFile(path)\n return {\n path,\n variables: parse(content),\n }\n}\n\n/**\n * Writes a .env file to disk.\n * @param file - .env file to be written.\n */\nexport async function writeDotEnv(file: DotEnvFile): Promise<void> {\n const fileContent = Object.entries(file.variables)\n .map(([key, value]) => createDotEnvFileLine(key, value))\n .join('\\n')\n\n await writeFile(file.path, fileContent)\n}\n\n/**\n * Given an .env file content, generates a new one with new values\n * without removing already existing lines.\n * @param envFileContent - .env file contents.\n * @param updatedValues - object containing new env variables values.\n */\nexport function patchEnvFile(\n envFileContent: string | null,\n updatedValues: {[key: string]: string | undefined},\n): string {\n const outputLines: string[] = []\n const envFileLines = envFileContent === null ? [] : envFileContent.split('\\n')\n\n const alreadyPresentKeys: string[] = []\n\n let multilineVariable:\n | {\n key: string\n value: string\n quote: string\n }\n | undefined\n\n for (const line of envFileLines) {\n if (multilineVariable) {\n if (line.endsWith(multilineVariable.quote)) {\n let lineToWrite = createDotEnvFileLine(\n multilineVariable.key,\n multilineVariable.value + line.slice(0, -1),\n multilineVariable.quote,\n )\n const newValue = updatedValues[multilineVariable.key]\n if (newValue) {\n alreadyPresentKeys.push(multilineVariable.key)\n lineToWrite = createDotEnvFileLine(multilineVariable.key, newValue)\n }\n outputLines.push(lineToWrite)\n multilineVariable = undefined\n } else {\n multilineVariable.value += `${line}\\n`\n }\n continue\n }\n\n const match = line.match(/^([^=:#]+?)[=:](.*)/)\n let lineToWrite = line\n\n if (match) {\n const key = match[1]!.trim()\n const value = (match[2] || '').trim()\n\n if (/^[\"'`]/.test(value) && !value.endsWith(value[0]!)) {\n multilineVariable = {\n key,\n value: `${value.slice(1)}\\n`,\n quote: value[0]!,\n }\n continue\n }\n\n const newValue = updatedValues[key]\n if (newValue) {\n alreadyPresentKeys.push(key)\n lineToWrite = createDotEnvFileLine(key, newValue)\n }\n }\n\n outputLines.push(lineToWrite)\n }\n\n if (multilineVariable) {\n throw new AbortError(`Multi-line environment variable '${multilineVariable.key}' is not properly enclosed.`)\n }\n\n for (const [patchKey, updatedValue] of Object.entries(updatedValues)) {\n if (!alreadyPresentKeys.includes(patchKey)) {\n outputLines.push(createDotEnvFileLine(patchKey, updatedValue))\n }\n }\n\n return outputLines.join('\\n')\n}\n\nexport function createDotEnvFileLine(key: string, value?: string, quote?: string): string {\n if (quote) {\n return `${key}=${quote}${value}${quote}`\n }\n if (value && value.includes('\\n')) {\n const quoteCharacter = ['\"', \"'\", '`'].find((char) => !value.includes(char))\n\n if (!quoteCharacter) {\n throw new AbortError(`The environment file patch has an env value that can't be surrounded by quotes: ${value}`)\n }\n\n return `${key}=${quoteCharacter}${value}${quoteCharacter}`\n }\n return `${key}=${value}`\n}\n"]}
|
package/dist/public/node/fs.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
/// <reference types="node" resolution-mode="require"/>
|
|
2
2
|
/// <reference types="node" resolution-mode="require"/>
|
|
3
|
-
/// <reference types="node" resolution-mode="require"/>
|
|
4
3
|
import { RandomNameFamily } from '../common/string.js';
|
|
5
4
|
import { OverloadParameters } from '../../private/common/ts/overloaded-parameters.js';
|
|
6
5
|
import { findUp as internalFindUp } from 'find-up';
|
|
@@ -14,6 +14,7 @@ export declare function initializeGitRepository(directory: string, initialBranch
|
|
|
14
14
|
*
|
|
15
15
|
* @param directory - The absolute path to the directory containing the files.
|
|
16
16
|
* @param files - The list of files to check against.
|
|
17
|
+
* @returns Files ignored by the lockfile.
|
|
17
18
|
*/
|
|
18
19
|
export declare function checkIfIgnoredInGitRepository(directory: string, files: string[]): Promise<string[]>;
|
|
19
20
|
export interface GitIgnoreTemplate {
|
|
@@ -109,5 +110,6 @@ export declare function ensureIsClean(directory?: string): Promise<void>;
|
|
|
109
110
|
* Returns true if the .git directory tree is clean (no uncommitted changes).
|
|
110
111
|
*
|
|
111
112
|
* @param directory - The directory to check.
|
|
113
|
+
* @returns True is the .git directory is clean.
|
|
112
114
|
*/
|
|
113
115
|
export declare function isClean(directory?: string): Promise<boolean>;
|