@shopify/cli-kit 3.3.3 → 3.6.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 +31 -0
- package/dist/analytics.d.ts +11 -5
- package/dist/analytics.js +62 -72
- package/dist/analytics.js.map +1 -1
- 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 -6
- package/dist/api/common.js.map +1 -1
- package/dist/api/identity.js +3 -4
- package/dist/api/identity.js.map +1 -1
- package/dist/api/partners.d.ts +0 -5
- package/dist/api/partners.js +22 -43
- package/dist/api/partners.js.map +1 -1
- package/dist/array.d.ts +1 -0
- package/dist/array.js +4 -0
- package/dist/array.js.map +1 -0
- package/dist/constants.d.ts +1 -0
- package/dist/constants.js +1 -2
- 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 +3 -1
- package/dist/file.js +14 -2
- package/dist/file.js.map +1 -1
- package/dist/git.js +12 -5
- package/dist/git.js.map +1 -1
- package/dist/haiku.d.ts +6 -1
- package/dist/haiku.js +67 -6
- package/dist/haiku.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/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/json.d.ts +6 -0
- package/dist/json.js +2 -0
- package/dist/json.js.map +1 -0
- package/dist/metadata.d.ts +51 -0
- package/dist/metadata.js +29 -0
- package/dist/metadata.js.map +1 -0
- package/dist/monorail.d.ts +38 -0
- package/dist/monorail.js +38 -0
- package/dist/monorail.js.map +1 -0
- package/dist/network/service.d.ts +1 -1
- package/dist/network/service.js.map +1 -1
- package/dist/node/archiver.d.ts +4 -1
- package/dist/node/archiver.js +22 -13
- package/dist/node/archiver.js.map +1 -1
- package/dist/node/base-command.d.ts +1 -0
- package/dist/node/base-command.js +11 -2
- 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 +23 -1
- package/dist/node/error-handler.js +64 -8
- 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 +5 -2
- 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 +22 -7
- package/dist/node/ruby.js.map +1 -1
- package/dist/output.d.ts +18 -11
- package/dist/output.js +96 -28
- package/dist/output.js.map +1 -1
- package/dist/path.d.ts +3 -3
- package/dist/path.js +2 -4
- package/dist/path.js.map +1 -1
- package/dist/plugins.d.ts +38 -2
- package/dist/plugins.js +11 -0
- package/dist/plugins.js.map +1 -1
- package/dist/session/authorize.js +16 -4
- package/dist/session/authorize.js.map +1 -1
- package/dist/session/exchange.js +2 -8
- 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/store.js +0 -2
- package/dist/store.js.map +1 -1
- package/dist/string.d.ts +4 -0
- package/dist/string.js +13 -0
- package/dist/string.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/typing/overloaded-parameters.d.ts +6 -0
- package/dist/typing/overloaded-parameters.js +2 -0
- package/dist/typing/overloaded-parameters.js.map +1 -0
- package/dist/typing/simple-definitions.d.ts +4 -0
- package/dist/typing/simple-definitions.js +2 -0
- package/dist/typing/simple-definitions.js.map +1 -0
- package/dist/ui.d.ts +12 -0
- package/dist/ui.js +57 -5
- package/dist/ui.js.map +1 -1
- package/package.json +28 -22
package/dist/haiku.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"haiku.js","sourceRoot":"","sources":["../src/haiku.ts"],"names":[],"mappings":"AAAA,OAAO,UAAU,MAAM,YAAY,CAAA;
|
|
1
|
+
{"version":3,"file":"haiku.js","sourceRoot":"","sources":["../src/haiku.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAC,MAAM,YAAY,CAAA;AACrC,OAAO,EAAC,MAAM,EAAC,MAAM,WAAW,CAAA;AAChC,OAAO,EAAC,IAAI,EAAC,MAAM,WAAW,CAAA;AAE9B,MAAM,CAAC,MAAM,eAAe,GAAG;IAC7B,YAAY;IACZ,YAAY;IACZ,aAAa;IACb,SAAS;IACT,YAAY;IACZ,aAAa;IACb,cAAc;IACd,aAAa;IACb,MAAM;IACN,OAAO;IACP,SAAS;IACT,QAAQ;IACR,UAAU;IACV,WAAW;IACX,WAAW;IACX,eAAe;IACf,YAAY;IACZ,UAAU;IACV,WAAW;IACX,WAAW;IACX,QAAQ;CACT,CAAA;AAED,MAAM,CAAC,MAAM,UAAU,GAAG;IACxB,SAAS;IACT,UAAU;IACV,UAAU;IACV,YAAY;IACZ,UAAU;IACV,SAAS;IACT,aAAa;IACb,SAAS;IACT,UAAU;IACV,WAAW;IACX,aAAa;IACb,UAAU;IACV,QAAQ;IACR,QAAQ;IACR,QAAQ;IACR,UAAU;IACV,YAAY;IACZ,aAAa;IACb,YAAY;IACZ,SAAS;IACT,YAAY;IACZ,QAAQ;IACR,OAAO;IACP,MAAM;IACN,aAAa;IACb,aAAa;IACb,MAAM;CACP,CAAA;AAED,SAAS,kBAAkB;IACzB,OAAO,GAAG,UAAU,CAAC,eAAe,CAAC,IAAI,UAAU,CAAC,UAAU,CAAC,EAAE,CAAA;AACnE,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,QAAQ,CAAC,EAAC,MAAM,EAAE,SAAS,EAAsC;IACrF,MAAM,SAAS,GAAG,GAAG,kBAAkB,EAAE,IAAI,MAAM,EAAE,CAAA;IACrD,MAAM,mBAAmB,GAAG,MAAM,MAAM,CAAC,IAAI,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC,CAAA;IAEpE,IAAI,mBAAmB,EAAE;QACvB,OAAO,QAAQ,CAAC,EAAC,MAAM,EAAE,SAAS,EAAC,CAAC,CAAA;KACrC;SAAM;QACL,OAAO,SAAS,CAAA;KACjB;AACH,CAAC","sourcesContent":["import {randomPick} from './array.js'\nimport {exists} from './file.js'\nimport {join} from './path.js'\n\nexport const SAFE_ADJECTIVES = [\n 'commercial',\n 'profitable',\n 'amortizable',\n 'branded',\n 'integrated',\n 'synergistic',\n 'consolidated',\n 'diversified',\n 'lean',\n 'niche',\n 'premium',\n 'luxury',\n 'scalable',\n 'optimized',\n 'empowered',\n 'international',\n 'beneficial',\n 'fruitful',\n 'extensive',\n 'lucrative',\n 'modern',\n]\n\nexport const SAFE_NOUNS = [\n 'account',\n 'consumer',\n 'customer',\n 'enterprise',\n 'business',\n 'venture',\n 'marketplace',\n 'revenue',\n 'vertical',\n 'portfolio',\n 'negotiation',\n 'shipping',\n 'demand',\n 'supply',\n 'growth',\n 'merchant',\n 'investment',\n 'shareholder',\n 'conversion',\n 'capital',\n 'projection',\n 'upside',\n 'trade',\n 'deal',\n 'merchandise',\n 'transaction',\n 'sale',\n]\n\nfunction generateRandomName() {\n return `${randomPick(SAFE_ADJECTIVES)}-${randomPick(SAFE_NOUNS)}`\n}\n\nexport async function generate({suffix, directory}: {suffix: string; directory: string}): Promise<string> {\n const generated = `${generateRandomName()}-${suffix}`\n const isAppDirectoryTaken = await exists(join(directory, generated))\n\n if (isAppDirectoryTaken) {\n return generate({suffix, directory})\n } else {\n return generated\n }\n}\n"]}
|
package/dist/http/fetch.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Service } from '../network/service.js';
|
|
1
2
|
import nodeFetch from 'node-fetch';
|
|
2
3
|
import type { RequestInfo, RequestInit } from 'node-fetch';
|
|
3
4
|
declare type Response = ReturnType<typeof nodeFetch>;
|
|
@@ -12,5 +13,11 @@ declare type Response = ReturnType<typeof nodeFetch>;
|
|
|
12
13
|
* @param init {RequestInit} An object containing any custom settings that you want to apply to the request
|
|
13
14
|
* @returns A promise that resolves with the response.
|
|
14
15
|
*/
|
|
15
|
-
|
|
16
|
-
|
|
16
|
+
export default function fetch(url: RequestInfo, init?: RequestInit): Response;
|
|
17
|
+
/**
|
|
18
|
+
* A fetch function to use with Shopify services. The function ensures the right
|
|
19
|
+
* TLS configuragion is used based on the environment in which the service is running
|
|
20
|
+
* (e.g. spin)
|
|
21
|
+
*/
|
|
22
|
+
export declare function shopifyFetch(service: Service, url: RequestInfo, init?: RequestInit): Response;
|
|
23
|
+
export {};
|
package/dist/http/fetch.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { httpsAgent } from '../http.js';
|
|
1
2
|
import nodeFetch from 'node-fetch';
|
|
2
3
|
/**
|
|
3
4
|
* An interface that abstracts way node-fetch. When Node has built-in
|
|
@@ -10,9 +11,17 @@ import nodeFetch from 'node-fetch';
|
|
|
10
11
|
* @param init {RequestInit} An object containing any custom settings that you want to apply to the request
|
|
11
12
|
* @returns A promise that resolves with the response.
|
|
12
13
|
*/
|
|
13
|
-
async function fetch(url, init) {
|
|
14
|
+
export default async function fetch(url, init) {
|
|
14
15
|
const response = await nodeFetch(url, init);
|
|
15
16
|
return response;
|
|
16
17
|
}
|
|
17
|
-
|
|
18
|
+
/**
|
|
19
|
+
* A fetch function to use with Shopify services. The function ensures the right
|
|
20
|
+
* TLS configuragion is used based on the environment in which the service is running
|
|
21
|
+
* (e.g. spin)
|
|
22
|
+
*/
|
|
23
|
+
export async function shopifyFetch(service, url, init) {
|
|
24
|
+
const response = await nodeFetch(url, { ...init, agent: await httpsAgent(service) });
|
|
25
|
+
return response;
|
|
26
|
+
}
|
|
18
27
|
//# sourceMappingURL=fetch.js.map
|
package/dist/http/fetch.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fetch.js","sourceRoot":"","sources":["../../src/http/fetch.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"fetch.js","sourceRoot":"","sources":["../../src/http/fetch.ts"],"names":[],"mappings":"AAEA,OAAO,EAAC,UAAU,EAAC,MAAM,YAAY,CAAA;AACrC,OAAO,SAAS,MAAM,YAAY,CAAA;AAIlC;;;;;;;;;;GAUG;AACH,MAAM,CAAC,OAAO,CAAC,KAAK,UAAU,KAAK,CAAC,GAAgB,EAAE,IAAkB;IACtE,MAAM,QAAQ,GAAG,MAAM,SAAS,CAAC,GAAG,EAAE,IAAI,CAAC,CAAA;IAC3C,OAAO,QAAQ,CAAA;AACjB,CAAC;AAED;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,YAAY,CAAC,OAAgB,EAAE,GAAgB,EAAE,IAAkB;IACvF,MAAM,QAAQ,GAAG,MAAM,SAAS,CAAC,GAAG,EAAE,EAAC,GAAG,IAAI,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC,OAAO,CAAC,EAAC,CAAC,CAAA;IAClF,OAAO,QAAQ,CAAA;AACjB,CAAC","sourcesContent":["import {Service} from '../network/service.js'\n\nimport {httpsAgent} from '../http.js'\nimport nodeFetch from 'node-fetch'\nimport type {RequestInfo, RequestInit} from 'node-fetch'\n\ntype Response = ReturnType<typeof nodeFetch>\n/**\n * An interface that abstracts way node-fetch. When Node has built-in\n * support for \"fetch\" in the standard library, we can drop the node-fetch\n * dependency from here.\n * Note that we are exposing types from \"node-fetch\". The reason being is that\n * they are consistent with the Web API so if we drop node-fetch in the future\n * it won't require changes from the callers.\n * @param url {RequestInfo} This defines the resource that you wish to fetch.\n * @param init {RequestInit} An object containing any custom settings that you want to apply to the request\n * @returns A promise that resolves with the response.\n */\nexport default async function fetch(url: RequestInfo, init?: RequestInit): Response {\n const response = await nodeFetch(url, init)\n return response\n}\n\n/**\n * A fetch function to use with Shopify services. The function ensures the right\n * TLS configuragion is used based on the environment in which the service is running\n * (e.g. spin)\n */\nexport async function shopifyFetch(service: Service, url: RequestInfo, init?: RequestInit): Response {\n const response = await nodeFetch(url, {...init, agent: await httpsAgent(service)})\n return response\n}\n"]}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Service } from '../network/service.js';
|
|
2
|
+
import { GraphQLClient } from 'graphql-request';
|
|
3
|
+
interface GraphqlClientOptions {
|
|
4
|
+
url: string;
|
|
5
|
+
service: Service;
|
|
6
|
+
headers: {
|
|
7
|
+
[key: string]: string;
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Creates a GraphQLClient instance with the right HTTPs agent baed on the service
|
|
12
|
+
* the client will interact with.
|
|
13
|
+
*/
|
|
14
|
+
export declare function graphqlClient(options: GraphqlClientOptions): Promise<GraphQLClient>;
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { httpsAgent } from '../http.js';
|
|
2
|
+
import { GraphQLClient } from 'graphql-request';
|
|
3
|
+
/**
|
|
4
|
+
* Creates a GraphQLClient instance with the right HTTPs agent baed on the service
|
|
5
|
+
* the client will interact with.
|
|
6
|
+
*/
|
|
7
|
+
export async function graphqlClient(options) {
|
|
8
|
+
const clientOptions = { agent: await httpsAgent(options.service), headers: options.headers };
|
|
9
|
+
const client = new GraphQLClient(options.url, clientOptions);
|
|
10
|
+
return client;
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=graphql.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"graphql.js","sourceRoot":"","sources":["../../src/http/graphql.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,UAAU,EAAC,MAAM,YAAY,CAAA;AACrC,OAAO,EAAC,aAAa,EAAC,MAAM,iBAAiB,CAAA;AAQ7C;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,aAAa,CAAC,OAA6B;IAC/D,MAAM,aAAa,GAAG,EAAC,KAAK,EAAE,MAAM,UAAU,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,OAAO,EAAE,OAAO,CAAC,OAAO,EAAC,CAAA;IAC1F,MAAM,MAAM,GAAG,IAAI,aAAa,CAAC,OAAO,CAAC,GAAG,EAAE,aAAa,CAAC,CAAA;IAC5D,OAAO,MAAM,CAAA;AACf,CAAC","sourcesContent":["import {Service} from '../network/service.js'\nimport {httpsAgent} from '../http.js'\nimport {GraphQLClient} from 'graphql-request'\n\ninterface GraphqlClientOptions {\n url: string\n service: Service\n headers: {[key: string]: string}\n}\n\n/**\n * Creates a GraphQLClient instance with the right HTTPs agent baed on the service\n * the client will interact with.\n */\nexport async function graphqlClient(options: GraphqlClientOptions) {\n const clientOptions = {agent: await httpsAgent(options.service), headers: options.headers}\n const client = new GraphQLClient(options.url, clientOptions)\n return client\n}\n"]}
|
package/dist/http.d.ts
CHANGED
|
@@ -1,2 +1,26 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { Service } from './network/service.js';
|
|
3
|
+
import https from 'https';
|
|
1
4
|
export { default as fetch } from './http/fetch.js';
|
|
5
|
+
export { shopifyFetch } from './http/fetch.js';
|
|
2
6
|
export { default as formData } from './http/formdata.js';
|
|
7
|
+
/**
|
|
8
|
+
* This utility function returns the https.Agent to use for a given service. The agent
|
|
9
|
+
* includes the right configuration based on the service's environment. For example,
|
|
10
|
+
* if the service is running in a Spin environment, the attribute "rejectUnauthorized" is
|
|
11
|
+
* set to false
|
|
12
|
+
*/
|
|
13
|
+
export declare function httpsAgent(service: Service): Promise<https.Agent>;
|
|
14
|
+
/**
|
|
15
|
+
* Spin stores the CA certificate in the keychain and it should be used when sending HTTP
|
|
16
|
+
* requests to Spin instances. However, Node doesn't read certificates from the Keychain
|
|
17
|
+
* by default, which leads to Shopifolks running into issues that they workaround by setting the
|
|
18
|
+
* NODE_TLS_REJECT_UNAUTHORIZED=0 environment variable, which applies to all the HTTP
|
|
19
|
+
* requests sent from the CLI (context: https://github.com/nodejs/node/issues/39657)
|
|
20
|
+
* This utility function allows controlling the behavior in a per-service level by returning
|
|
21
|
+
* the value of for the "rejectUnauthorized" attribute that's used in the https agent.
|
|
22
|
+
*
|
|
23
|
+
* @returns {Promise<boolean>} A promise that resolves with a boolean indicating whether
|
|
24
|
+
* unauthorized requests should be rejected or not.
|
|
25
|
+
*/
|
|
26
|
+
export declare function shouldRejectUnauthorizedRequests(service: Service): Promise<boolean>;
|
package/dist/http.js
CHANGED
|
@@ -1,3 +1,30 @@
|
|
|
1
|
+
import { environmentForService } from './environment/service.js';
|
|
2
|
+
import https from 'https';
|
|
1
3
|
export { default as fetch } from './http/fetch.js';
|
|
4
|
+
export { shopifyFetch } from './http/fetch.js';
|
|
2
5
|
export { default as formData } from './http/formdata.js';
|
|
6
|
+
/**
|
|
7
|
+
* This utility function returns the https.Agent to use for a given service. The agent
|
|
8
|
+
* includes the right configuration based on the service's environment. For example,
|
|
9
|
+
* if the service is running in a Spin environment, the attribute "rejectUnauthorized" is
|
|
10
|
+
* set to false
|
|
11
|
+
*/
|
|
12
|
+
export async function httpsAgent(service) {
|
|
13
|
+
return new https.Agent({ rejectUnauthorized: await shouldRejectUnauthorizedRequests(service) });
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Spin stores the CA certificate in the keychain and it should be used when sending HTTP
|
|
17
|
+
* requests to Spin instances. However, Node doesn't read certificates from the Keychain
|
|
18
|
+
* by default, which leads to Shopifolks running into issues that they workaround by setting the
|
|
19
|
+
* NODE_TLS_REJECT_UNAUTHORIZED=0 environment variable, which applies to all the HTTP
|
|
20
|
+
* requests sent from the CLI (context: https://github.com/nodejs/node/issues/39657)
|
|
21
|
+
* This utility function allows controlling the behavior in a per-service level by returning
|
|
22
|
+
* the value of for the "rejectUnauthorized" attribute that's used in the https agent.
|
|
23
|
+
*
|
|
24
|
+
* @returns {Promise<boolean>} A promise that resolves with a boolean indicating whether
|
|
25
|
+
* unauthorized requests should be rejected or not.
|
|
26
|
+
*/
|
|
27
|
+
export async function shouldRejectUnauthorizedRequests(service) {
|
|
28
|
+
return (await environmentForService(service)) !== 'spin';
|
|
29
|
+
}
|
|
3
30
|
//# sourceMappingURL=http.js.map
|
package/dist/http.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"http.js","sourceRoot":"","sources":["../src/http.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"http.js","sourceRoot":"","sources":["../src/http.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,qBAAqB,EAAC,MAAM,0BAA0B,CAAA;AAC9D,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,OAAO,EAAC,OAAO,IAAI,KAAK,EAAC,MAAM,iBAAiB,CAAA;AAChD,OAAO,EAAC,YAAY,EAAC,MAAM,iBAAiB,CAAA;AAC5C,OAAO,EAAC,OAAO,IAAI,QAAQ,EAAC,MAAM,oBAAoB,CAAA;AAEtD;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,UAAU,CAAC,OAAgB;IAC/C,OAAO,IAAI,KAAK,CAAC,KAAK,CAAC,EAAC,kBAAkB,EAAE,MAAM,gCAAgC,CAAC,OAAO,CAAC,EAAC,CAAC,CAAA;AAC/F,CAAC;AAED;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,KAAK,UAAU,gCAAgC,CAAC,OAAgB;IACrE,OAAO,CAAC,MAAM,qBAAqB,CAAC,OAAO,CAAC,CAAC,KAAK,MAAM,CAAA;AAC1D,CAAC","sourcesContent":["import {Service} from './network/service.js'\nimport {environmentForService} from './environment/service.js'\nimport https from 'https'\n\nexport {default as fetch} from './http/fetch.js'\nexport {shopifyFetch} from './http/fetch.js'\nexport {default as formData} from './http/formdata.js'\n\n/**\n * This utility function returns the https.Agent to use for a given service. The agent\n * includes the right configuration based on the service's environment. For example,\n * if the service is running in a Spin environment, the attribute \"rejectUnauthorized\" is\n * set to false\n */\nexport async function httpsAgent(service: Service) {\n return new https.Agent({rejectUnauthorized: await shouldRejectUnauthorizedRequests(service)})\n}\n\n/**\n * Spin stores the CA certificate in the keychain and it should be used when sending HTTP\n * requests to Spin instances. However, Node doesn't read certificates from the Keychain\n * by default, which leads to Shopifolks running into issues that they workaround by setting the\n * NODE_TLS_REJECT_UNAUTHORIZED=0 environment variable, which applies to all the HTTP\n * requests sent from the CLI (context: https://github.com/nodejs/node/issues/39657)\n * This utility function allows controlling the behavior in a per-service level by returning\n * the value of for the \"rejectUnauthorized\" attribute that's used in the https agent.\n *\n * @returns {Promise<boolean>} A promise that resolves with a boolean indicating whether\n * unauthorized requests should be rejected or not.\n */\nexport async function shouldRejectUnauthorizedRequests(service: Service): Promise<boolean> {\n return (await environmentForService(service)) !== 'spin'\n}\n"]}
|
package/dist/index.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ export { default as constants } from './constants.js';
|
|
|
2
2
|
export * as abort from './abort.js';
|
|
3
3
|
export * as analytics from './analytics.js';
|
|
4
4
|
export * as api from './api.js';
|
|
5
|
+
export * as array from './array.js';
|
|
5
6
|
export * as cli from './cli.js';
|
|
6
7
|
export * as environment from './environment.js';
|
|
7
8
|
export * as error from './error.js';
|
|
@@ -31,3 +32,4 @@ export * as version from './version.js';
|
|
|
31
32
|
export * as vscode from './vscode.js';
|
|
32
33
|
export * as yaml from './yaml.js';
|
|
33
34
|
export * as outputMocker from './testing/output.js';
|
|
35
|
+
export * as metadata from './metadata.js';
|
package/dist/index.js
CHANGED
|
@@ -2,6 +2,7 @@ export { default as constants } from './constants.js';
|
|
|
2
2
|
export * as abort from './abort.js';
|
|
3
3
|
export * as analytics from './analytics.js';
|
|
4
4
|
export * as api from './api.js';
|
|
5
|
+
export * as array from './array.js';
|
|
5
6
|
export * as cli from './cli.js';
|
|
6
7
|
export * as environment from './environment.js';
|
|
7
8
|
export * as error from './error.js';
|
|
@@ -31,4 +32,5 @@ export * as version from './version.js';
|
|
|
31
32
|
export * as vscode from './vscode.js';
|
|
32
33
|
export * as yaml from './yaml.js';
|
|
33
34
|
export * as outputMocker from './testing/output.js';
|
|
35
|
+
export * as metadata from './metadata.js';
|
|
34
36
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,OAAO,IAAI,SAAS,EAAC,MAAM,gBAAgB,CAAA;AACnD,OAAO,KAAK,KAAK,MAAM,YAAY,CAAA;AACnC,OAAO,KAAK,SAAS,MAAM,gBAAgB,CAAA;AAC3C,OAAO,KAAK,GAAG,MAAM,UAAU,CAAA;AAC/B,OAAO,KAAK,GAAG,MAAM,UAAU,CAAA;AAC/B,OAAO,KAAK,WAAW,MAAM,kBAAkB,CAAA;AAC/C,OAAO,KAAK,KAAK,MAAM,YAAY,CAAA;AACnC,OAAO,KAAK,OAAO,MAAM,SAAS,CAAA;AAClC,OAAO,KAAK,IAAI,MAAM,WAAW,CAAA;AACjC,OAAO,KAAK,GAAG,MAAM,UAAU,CAAA;AAC/B,OAAO,KAAK,MAAM,MAAM,aAAa,CAAA;AACrC,OAAO,KAAK,KAAK,MAAM,YAAY,CAAA;AACnC,OAAO,KAAK,IAAI,MAAM,WAAW,CAAA;AACjC,OAAO,KAAK,EAAE,MAAM,SAAS,CAAA;AAC7B,OAAO,KAAK,GAAG,MAAM,UAAU,CAAA;AAC/B,OAAO,KAAK,EAAE,MAAM,SAAS,CAAA;AAC7B,OAAO,KAAK,MAAM,MAAM,aAAa,CAAA;AACrC,OAAO,KAAK,IAAI,MAAM,WAAW,CAAA;AACjC,OAAO,KAAK,OAAO,MAAM,cAAc,CAAA;AACvC,OAAO,KAAK,IAAI,MAAM,WAAW,CAAA;AACjC,OAAO,KAAK,MAAM,MAAM,aAAa,CAAA;AACrC,OAAO,KAAK,MAAM,MAAM,aAAa,CAAA;AACrC,OAAO,KAAK,OAAO,MAAM,cAAc,CAAA;AACvC,OAAO,KAAK,KAAK,MAAM,YAAY,CAAA;AACnC,OAAO,KAAK,MAAM,MAAM,aAAa,CAAA;AACrC,OAAO,KAAK,MAAM,MAAM,aAAa,CAAA;AACrC,OAAO,KAAK,QAAQ,MAAM,eAAe,CAAA;AACzC,OAAO,KAAK,IAAI,MAAM,WAAW,CAAA;AACjC,OAAO,KAAK,EAAE,MAAM,SAAS,CAAA;AAC7B,OAAO,KAAK,OAAO,MAAM,cAAc,CAAA;AACvC,OAAO,KAAK,MAAM,MAAM,aAAa,CAAA;AACrC,OAAO,KAAK,IAAI,MAAM,WAAW,CAAA;AACjC,OAAO,KAAK,YAAY,MAAM,qBAAqB,CAAA","sourcesContent":["export {default as constants} from './constants.js'\nexport * as abort from './abort.js'\nexport * as analytics from './analytics.js'\nexport * as api from './api.js'\nexport * as cli from './cli.js'\nexport * as environment from './environment.js'\nexport * as error from './error.js'\nexport * as fastify from 'fastify'\nexport * as file from './file.js'\nexport * as git from './git.js'\nexport * as github from './github.js'\nexport * as haiku from './haiku.js'\nexport * as http from './http.js'\nexport * as id from './id.js'\nexport * as npm from './npm.js'\nexport * as os from './os.js'\nexport * as output from './output.js'\nexport * as path from './path.js'\nexport * as plugins from './plugins.js'\nexport * as port from './port.js'\nexport * as schema from './schema.js'\nexport * as semver from './semver.js'\nexport * as session from './session.js'\nexport * as store from './store.js'\nexport * as string from './string.js'\nexport * as system from './system.js'\nexport * as template from './template.js'\nexport * as toml from './toml.js'\nexport * as ui from './ui.js'\nexport * as version from './version.js'\nexport * as vscode from './vscode.js'\nexport * as yaml from './yaml.js'\nexport * as outputMocker from './testing/output.js'\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,OAAO,IAAI,SAAS,EAAC,MAAM,gBAAgB,CAAA;AACnD,OAAO,KAAK,KAAK,MAAM,YAAY,CAAA;AACnC,OAAO,KAAK,SAAS,MAAM,gBAAgB,CAAA;AAC3C,OAAO,KAAK,GAAG,MAAM,UAAU,CAAA;AAC/B,OAAO,KAAK,KAAK,MAAM,YAAY,CAAA;AACnC,OAAO,KAAK,GAAG,MAAM,UAAU,CAAA;AAC/B,OAAO,KAAK,WAAW,MAAM,kBAAkB,CAAA;AAC/C,OAAO,KAAK,KAAK,MAAM,YAAY,CAAA;AACnC,OAAO,KAAK,OAAO,MAAM,SAAS,CAAA;AAClC,OAAO,KAAK,IAAI,MAAM,WAAW,CAAA;AACjC,OAAO,KAAK,GAAG,MAAM,UAAU,CAAA;AAC/B,OAAO,KAAK,MAAM,MAAM,aAAa,CAAA;AACrC,OAAO,KAAK,KAAK,MAAM,YAAY,CAAA;AACnC,OAAO,KAAK,IAAI,MAAM,WAAW,CAAA;AACjC,OAAO,KAAK,EAAE,MAAM,SAAS,CAAA;AAC7B,OAAO,KAAK,GAAG,MAAM,UAAU,CAAA;AAC/B,OAAO,KAAK,EAAE,MAAM,SAAS,CAAA;AAC7B,OAAO,KAAK,MAAM,MAAM,aAAa,CAAA;AACrC,OAAO,KAAK,IAAI,MAAM,WAAW,CAAA;AACjC,OAAO,KAAK,OAAO,MAAM,cAAc,CAAA;AACvC,OAAO,KAAK,IAAI,MAAM,WAAW,CAAA;AACjC,OAAO,KAAK,MAAM,MAAM,aAAa,CAAA;AACrC,OAAO,KAAK,MAAM,MAAM,aAAa,CAAA;AACrC,OAAO,KAAK,OAAO,MAAM,cAAc,CAAA;AACvC,OAAO,KAAK,KAAK,MAAM,YAAY,CAAA;AACnC,OAAO,KAAK,MAAM,MAAM,aAAa,CAAA;AACrC,OAAO,KAAK,MAAM,MAAM,aAAa,CAAA;AACrC,OAAO,KAAK,QAAQ,MAAM,eAAe,CAAA;AACzC,OAAO,KAAK,IAAI,MAAM,WAAW,CAAA;AACjC,OAAO,KAAK,EAAE,MAAM,SAAS,CAAA;AAC7B,OAAO,KAAK,OAAO,MAAM,cAAc,CAAA;AACvC,OAAO,KAAK,MAAM,MAAM,aAAa,CAAA;AACrC,OAAO,KAAK,IAAI,MAAM,WAAW,CAAA;AACjC,OAAO,KAAK,YAAY,MAAM,qBAAqB,CAAA;AACnD,OAAO,KAAK,QAAQ,MAAM,eAAe,CAAA","sourcesContent":["export {default as constants} from './constants.js'\nexport * as abort from './abort.js'\nexport * as analytics from './analytics.js'\nexport * as api from './api.js'\nexport * as array from './array.js'\nexport * as cli from './cli.js'\nexport * as environment from './environment.js'\nexport * as error from './error.js'\nexport * as fastify from 'fastify'\nexport * as file from './file.js'\nexport * as git from './git.js'\nexport * as github from './github.js'\nexport * as haiku from './haiku.js'\nexport * as http from './http.js'\nexport * as id from './id.js'\nexport * as npm from './npm.js'\nexport * as os from './os.js'\nexport * as output from './output.js'\nexport * as path from './path.js'\nexport * as plugins from './plugins.js'\nexport * as port from './port.js'\nexport * as schema from './schema.js'\nexport * as semver from './semver.js'\nexport * as session from './session.js'\nexport * as store from './store.js'\nexport * as string from './string.js'\nexport * as system from './system.js'\nexport * as template from './template.js'\nexport * as toml from './toml.js'\nexport * as ui from './ui.js'\nexport * as version from './version.js'\nexport * as vscode from './vscode.js'\nexport * as yaml from './yaml.js'\nexport * as outputMocker from './testing/output.js'\nexport * as metadata from './metadata.js'\n"]}
|
package/dist/json.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export interface JsonMap {
|
|
2
|
+
[key: string]: AnyJson;
|
|
3
|
+
}
|
|
4
|
+
declare type JsonArray = undefined[] | null[] | boolean[] | number[] | string[] | JsonMap[] | Date[];
|
|
5
|
+
export declare type AnyJson = undefined | null | boolean | number | string | JsonMap | Date | JsonArray | JsonArray[];
|
|
6
|
+
export {};
|
package/dist/json.js
ADDED
package/dist/json.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"json.js","sourceRoot":"","sources":["../src/json.ts"],"names":[],"mappings":"","sourcesContent":["export interface JsonMap {\n [key: string]: AnyJson\n}\ntype JsonArray = undefined[] | null[] | boolean[] | number[] | string[] | JsonMap[] | Date[]\nexport type AnyJson = undefined | null | boolean | number | string | JsonMap | Date | JsonArray | JsonArray[]\n"]}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { AnyJson } from './json.js';
|
|
2
|
+
export interface RuntimeMetadataManager<TPublic extends AnyJson, TSensitive extends AnyJson> {
|
|
3
|
+
/** Add some public metadata -- this should not contain any PII */
|
|
4
|
+
addPublic: (data: Partial<TPublic>) => void;
|
|
5
|
+
/** Add some potentially sensitive metadata -- this may include PII, but unnecessary data should never be tracked (this is a good fit for command args for instance) */
|
|
6
|
+
addSensitive: (data: Partial<TSensitive>) => void;
|
|
7
|
+
/** Get a snapshot of the tracked public data */
|
|
8
|
+
getAllPublic: () => Partial<TPublic>;
|
|
9
|
+
/** Get a snapshot of the tracked sensitive data */
|
|
10
|
+
getAllSensitive: () => Partial<TSensitive>;
|
|
11
|
+
}
|
|
12
|
+
export declare type PublicSchema<T> = T extends RuntimeMetadataManager<infer TPublic, infer _TSensitive> ? TPublic : never;
|
|
13
|
+
export declare type SensitiveSchema<T> = T extends RuntimeMetadataManager<infer _TPublic, infer TSensitive> ? TSensitive : never;
|
|
14
|
+
/**
|
|
15
|
+
* Creates a container for metadata collected at runtime.
|
|
16
|
+
*
|
|
17
|
+
* The container provides async-safe functions for extracting the gathered metadata, and for setting it.
|
|
18
|
+
*
|
|
19
|
+
*/
|
|
20
|
+
export declare function createRuntimeMetadataContainer<TPublic extends AnyJson, TSensitive extends AnyJson = {
|
|
21
|
+
[key: string]: never;
|
|
22
|
+
}>(): RuntimeMetadataManager<TPublic, TSensitive>;
|
|
23
|
+
declare const coreData: RuntimeMetadataManager<{
|
|
24
|
+
placeholder: string;
|
|
25
|
+
}, {
|
|
26
|
+
commandStartOptions: {
|
|
27
|
+
startTime: number;
|
|
28
|
+
startCommand: string;
|
|
29
|
+
startArgs: string[];
|
|
30
|
+
};
|
|
31
|
+
}>;
|
|
32
|
+
export declare const getAllPublic: () => Partial<{
|
|
33
|
+
placeholder: string;
|
|
34
|
+
}>, getAllSensitive: () => Partial<{
|
|
35
|
+
commandStartOptions: {
|
|
36
|
+
startTime: number;
|
|
37
|
+
startCommand: string;
|
|
38
|
+
startArgs: string[];
|
|
39
|
+
};
|
|
40
|
+
}>, addPublic: (data: Partial<{
|
|
41
|
+
placeholder: string;
|
|
42
|
+
}>) => void, addSensitive: (data: Partial<{
|
|
43
|
+
commandStartOptions: {
|
|
44
|
+
startTime: number;
|
|
45
|
+
startCommand: string;
|
|
46
|
+
startArgs: string[];
|
|
47
|
+
};
|
|
48
|
+
}>) => void;
|
|
49
|
+
export declare type Public = PublicSchema<typeof coreData>;
|
|
50
|
+
export declare type Sensitive = SensitiveSchema<typeof coreData>;
|
|
51
|
+
export {};
|
package/dist/metadata.js
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Creates a container for metadata collected at runtime.
|
|
3
|
+
*
|
|
4
|
+
* The container provides async-safe functions for extracting the gathered metadata, and for setting it.
|
|
5
|
+
*
|
|
6
|
+
*/
|
|
7
|
+
export function createRuntimeMetadataContainer() {
|
|
8
|
+
const raw = {
|
|
9
|
+
sensitive: {},
|
|
10
|
+
public: {},
|
|
11
|
+
};
|
|
12
|
+
return {
|
|
13
|
+
addPublic: (data) => {
|
|
14
|
+
Object.assign(raw.public, data);
|
|
15
|
+
},
|
|
16
|
+
addSensitive: (data) => {
|
|
17
|
+
Object.assign(raw.sensitive, data);
|
|
18
|
+
},
|
|
19
|
+
getAllPublic: () => {
|
|
20
|
+
return { ...raw.public };
|
|
21
|
+
},
|
|
22
|
+
getAllSensitive: () => {
|
|
23
|
+
return { ...raw.sensitive };
|
|
24
|
+
},
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
const coreData = createRuntimeMetadataContainer();
|
|
28
|
+
export const { getAllPublic, getAllSensitive, addPublic, addSensitive } = coreData;
|
|
29
|
+
//# sourceMappingURL=metadata.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"metadata.js","sourceRoot":"","sources":["../src/metadata.ts"],"names":[],"mappings":"AAgBA;;;;;GAKG;AACH,MAAM,UAAU,8BAA8B;IAI5C,MAAM,GAAG,GAA+D;QACtE,SAAS,EAAE,EAAE;QACb,MAAM,EAAE,EAAE;KACX,CAAA;IACD,OAAO;QACL,SAAS,EAAE,CAAC,IAAsB,EAAE,EAAE;YACpC,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,MAAM,EAAE,IAAI,CAAC,CAAA;QACjC,CAAC;QACD,YAAY,EAAE,CAAC,IAAyB,EAAE,EAAE;YAC1C,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,SAAS,EAAE,IAAI,CAAC,CAAA;QACpC,CAAC;QACD,YAAY,EAAE,GAAG,EAAE;YACjB,OAAO,EAAC,GAAG,GAAG,CAAC,MAAM,EAAC,CAAA;QACxB,CAAC;QACD,eAAe,EAAE,GAAG,EAAE;YACpB,OAAO,EAAC,GAAG,GAAG,CAAC,SAAS,EAAC,CAAA;QAC3B,CAAC;KACF,CAAA;AACH,CAAC;AAED,MAAM,QAAQ,GAAG,8BAA8B,EAS5C,CAAA;AAEH,MAAM,CAAC,MAAM,EAAC,YAAY,EAAE,eAAe,EAAE,SAAS,EAAE,YAAY,EAAC,GAAG,QAAQ,CAAA","sourcesContent":["import {AnyJson} from './json.js'\n\nexport interface RuntimeMetadataManager<TPublic extends AnyJson, TSensitive extends AnyJson> {\n /** Add some public metadata -- this should not contain any PII */\n addPublic: (data: Partial<TPublic>) => void\n /** Add some potentially sensitive metadata -- this may include PII, but unnecessary data should never be tracked (this is a good fit for command args for instance) */\n addSensitive: (data: Partial<TSensitive>) => void\n /** Get a snapshot of the tracked public data */\n getAllPublic: () => Partial<TPublic>\n /** Get a snapshot of the tracked sensitive data */\n getAllSensitive: () => Partial<TSensitive>\n}\n\nexport type PublicSchema<T> = T extends RuntimeMetadataManager<infer TPublic, infer _TSensitive> ? TPublic : never\nexport type SensitiveSchema<T> = T extends RuntimeMetadataManager<infer _TPublic, infer TSensitive> ? TSensitive : never\n\n/**\n * Creates a container for metadata collected at runtime.\n *\n * The container provides async-safe functions for extracting the gathered metadata, and for setting it.\n *\n */\nexport function createRuntimeMetadataContainer<\n TPublic extends AnyJson,\n TSensitive extends AnyJson = {[key: string]: never},\n>(): RuntimeMetadataManager<TPublic, TSensitive> {\n const raw: {sensitive: Partial<TSensitive>; public: Partial<TPublic>} = {\n sensitive: {},\n public: {},\n }\n return {\n addPublic: (data: Partial<TPublic>) => {\n Object.assign(raw.public, data)\n },\n addSensitive: (data: Partial<TSensitive>) => {\n Object.assign(raw.sensitive, data)\n },\n getAllPublic: () => {\n return {...raw.public}\n },\n getAllSensitive: () => {\n return {...raw.sensitive}\n },\n }\n}\n\nconst coreData = createRuntimeMetadataContainer<\n {placeholder: string},\n {\n commandStartOptions: {\n startTime: number\n startCommand: string\n startArgs: string[]\n }\n }\n>()\n\nexport const {getAllPublic, getAllSensitive, addPublic, addSensitive} = coreData\n\nexport type Public = PublicSchema<typeof coreData>\nexport type Sensitive = SensitiveSchema<typeof coreData>\n"]}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { JsonMap } from './json.js';
|
|
2
|
+
declare type Optional<T> = T | null;
|
|
3
|
+
export interface Schemas {
|
|
4
|
+
'app_cli3_command/1.0': {
|
|
5
|
+
sensitive: {
|
|
6
|
+
args: string;
|
|
7
|
+
error_message?: Optional<string>;
|
|
8
|
+
metadata?: Optional<string>;
|
|
9
|
+
};
|
|
10
|
+
public: {
|
|
11
|
+
partner_id?: Optional<number>;
|
|
12
|
+
command: string;
|
|
13
|
+
project_type?: Optional<string>;
|
|
14
|
+
time_start: number;
|
|
15
|
+
time_end: number;
|
|
16
|
+
total_time: number;
|
|
17
|
+
success: boolean;
|
|
18
|
+
api_key?: Optional<string>;
|
|
19
|
+
cli_version: string;
|
|
20
|
+
uname: string;
|
|
21
|
+
ruby_version: string;
|
|
22
|
+
node_version: string;
|
|
23
|
+
is_employee: boolean;
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
[schemaId: string]: {
|
|
27
|
+
sensitive: JsonMap;
|
|
28
|
+
public: JsonMap;
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
declare type MonorailResult = {
|
|
32
|
+
type: 'ok';
|
|
33
|
+
} | {
|
|
34
|
+
type: 'error';
|
|
35
|
+
message: string;
|
|
36
|
+
};
|
|
37
|
+
export declare function publishEvent<TSchemaId extends keyof Schemas, TPayload extends Schemas[TSchemaId]>(schemaId: TSchemaId, publicData: TPayload['public'], sensitiveData: TPayload['sensitive']): Promise<MonorailResult>;
|
|
38
|
+
export {};
|
package/dist/monorail.js
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/naming-convention */
|
|
2
|
+
import { fetch } from './http.js';
|
|
3
|
+
import { debug, content, token } from './output.js';
|
|
4
|
+
const url = 'https://monorail-edge.shopifysvc.com/v1/produce';
|
|
5
|
+
export async function publishEvent(schemaId, publicData, sensitiveData) {
|
|
6
|
+
try {
|
|
7
|
+
const currentTime = new Date().getTime();
|
|
8
|
+
const payload = { ...publicData, ...sensitiveData };
|
|
9
|
+
const body = JSON.stringify({ schema_id: schemaId, payload });
|
|
10
|
+
const headers = buildHeaders(currentTime);
|
|
11
|
+
const response = await fetch(url, { method: 'POST', body, headers });
|
|
12
|
+
if (response.status === 200) {
|
|
13
|
+
debug(content `Analytics event sent: ${token.json(payload)}`);
|
|
14
|
+
return { type: 'ok' };
|
|
15
|
+
}
|
|
16
|
+
else {
|
|
17
|
+
debug(`Failed to report usage analytics: ${response.statusText}`);
|
|
18
|
+
return { type: 'error', message: response.statusText };
|
|
19
|
+
}
|
|
20
|
+
// eslint-disable-next-line no-catch-all/no-catch-all
|
|
21
|
+
}
|
|
22
|
+
catch (error) {
|
|
23
|
+
let message = 'Failed to report usage analytics';
|
|
24
|
+
if (error instanceof Error) {
|
|
25
|
+
message = message.concat(`: ${error.message}`);
|
|
26
|
+
}
|
|
27
|
+
debug(message);
|
|
28
|
+
return { type: 'error', message };
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
const buildHeaders = (currentTime) => {
|
|
32
|
+
return {
|
|
33
|
+
'Content-Type': 'application/json; charset=utf-8',
|
|
34
|
+
'X-Monorail-Edge-Event-Created-At-Ms': currentTime.toString(),
|
|
35
|
+
'X-Monorail-Edge-Event-Sent-At-Ms': currentTime.toString(),
|
|
36
|
+
};
|
|
37
|
+
};
|
|
38
|
+
//# sourceMappingURL=monorail.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"monorail.js","sourceRoot":"","sources":["../src/monorail.ts"],"names":[],"mappings":"AAAA,yDAAyD;AACzD,OAAO,EAAC,KAAK,EAAC,MAAM,WAAW,CAAA;AAC/B,OAAO,EAAC,KAAK,EAAE,OAAO,EAAE,KAAK,EAAC,MAAM,aAAa,CAAA;AAGjD,MAAM,GAAG,GAAG,iDAAiD,CAAA;AA4B7D,MAAM,CAAC,KAAK,UAAU,YAAY,CAChC,QAAmB,EACnB,UAA8B,EAC9B,aAAoC;IAEpC,IAAI;QACF,MAAM,WAAW,GAAG,IAAI,IAAI,EAAE,CAAC,OAAO,EAAE,CAAA;QACxC,MAAM,OAAO,GAAG,EAAC,GAAG,UAAU,EAAE,GAAG,aAAa,EAAC,CAAA;QACjD,MAAM,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC,EAAC,SAAS,EAAE,QAAQ,EAAE,OAAO,EAAC,CAAC,CAAA;QAC3D,MAAM,OAAO,GAAG,YAAY,CAAC,WAAW,CAAC,CAAA;QAEzC,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,GAAG,EAAE,EAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,EAAC,CAAC,CAAA;QAElE,IAAI,QAAQ,CAAC,MAAM,KAAK,GAAG,EAAE;YAC3B,KAAK,CAAC,OAAO,CAAA,yBAAyB,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC,CAAA;YAC5D,OAAO,EAAC,IAAI,EAAE,IAAI,EAAC,CAAA;SACpB;aAAM;YACL,KAAK,CAAC,qCAAqC,QAAQ,CAAC,UAAU,EAAE,CAAC,CAAA;YACjE,OAAO,EAAC,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,QAAQ,CAAC,UAAU,EAAC,CAAA;SACrD;QACD,qDAAqD;KACtD;IAAC,OAAO,KAAK,EAAE;QACd,IAAI,OAAO,GAAG,kCAAkC,CAAA;QAChD,IAAI,KAAK,YAAY,KAAK,EAAE;YAC1B,OAAO,GAAG,OAAO,CAAC,MAAM,CAAC,KAAK,KAAK,CAAC,OAAO,EAAE,CAAC,CAAA;SAC/C;QACD,KAAK,CAAC,OAAO,CAAC,CAAA;QACd,OAAO,EAAC,IAAI,EAAE,OAAO,EAAE,OAAO,EAAC,CAAA;KAChC;AACH,CAAC;AAED,MAAM,YAAY,GAAG,CAAC,WAAmB,EAAE,EAAE;IAC3C,OAAO;QACL,cAAc,EAAE,iCAAiC;QACjD,qCAAqC,EAAE,WAAW,CAAC,QAAQ,EAAE;QAC7D,kCAAkC,EAAE,WAAW,CAAC,QAAQ,EAAE;KAC3D,CAAA;AACH,CAAC,CAAA","sourcesContent":["/* eslint-disable @typescript-eslint/naming-convention */\nimport {fetch} from './http.js'\nimport {debug, content, token} from './output.js'\nimport {JsonMap} from './json.js'\n\nconst url = 'https://monorail-edge.shopifysvc.com/v1/produce'\n\ntype Optional<T> = T | null\n\nexport interface Schemas {\n 'app_cli3_command/1.0': {\n sensitive: {args: string; error_message?: Optional<string>; metadata?: Optional<string>}\n public: {\n partner_id?: Optional<number>\n command: string\n project_type?: Optional<string>\n time_start: number\n time_end: number\n total_time: number\n success: boolean\n api_key?: Optional<string>\n cli_version: string\n uname: string\n ruby_version: string\n node_version: string\n is_employee: boolean\n }\n }\n [schemaId: string]: {sensitive: JsonMap; public: JsonMap}\n}\n\ntype MonorailResult = {type: 'ok'} | {type: 'error'; message: string}\n\nexport async function publishEvent<TSchemaId extends keyof Schemas, TPayload extends Schemas[TSchemaId]>(\n schemaId: TSchemaId,\n publicData: TPayload['public'],\n sensitiveData: TPayload['sensitive'],\n): Promise<MonorailResult> {\n try {\n const currentTime = new Date().getTime()\n const payload = {...publicData, ...sensitiveData}\n const body = JSON.stringify({schema_id: schemaId, payload})\n const headers = buildHeaders(currentTime)\n\n const response = await fetch(url, {method: 'POST', body, headers})\n\n if (response.status === 200) {\n debug(content`Analytics event sent: ${token.json(payload)}`)\n return {type: 'ok'}\n } else {\n debug(`Failed to report usage analytics: ${response.statusText}`)\n return {type: 'error', message: response.statusText}\n }\n // eslint-disable-next-line no-catch-all/no-catch-all\n } catch (error) {\n let message = 'Failed to report usage analytics'\n if (error instanceof Error) {\n message = message.concat(`: ${error.message}`)\n }\n debug(message)\n return {type: 'error', message}\n }\n}\n\nconst buildHeaders = (currentTime: number) => {\n return {\n 'Content-Type': 'application/json; charset=utf-8',\n 'X-Monorail-Edge-Event-Created-At-Ms': currentTime.toString(),\n 'X-Monorail-Edge-Event-Sent-At-Ms': currentTime.toString(),\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"service.js","sourceRoot":"","sources":["../../src/network/service.ts"],"names":[],"mappings":"AAOA;;;;GAIG;AACH,MAAM,CAAN,IAAY,WAIX;AAJD,WAAY,WAAW;IACrB,8BAAe,CAAA;IACf,wCAAyB,CAAA;IACzB,4BAAa,CAAA;AACf,CAAC,EAJW,WAAW,KAAX,WAAW,QAItB","sourcesContent":["/**\n * Enum for the differnet APIs the CLI can interact with.\n * @readonly\n * @enum {number}\n */\nexport type Service = 'shopify' | '
|
|
1
|
+
{"version":3,"file":"service.js","sourceRoot":"","sources":["../../src/network/service.ts"],"names":[],"mappings":"AAOA;;;;GAIG;AACH,MAAM,CAAN,IAAY,WAIX;AAJD,WAAY,WAAW;IACrB,8BAAe,CAAA;IACf,wCAAyB,CAAA;IACzB,4BAAa,CAAA;AACf,CAAC,EAJW,WAAW,KAAX,WAAW,QAItB","sourcesContent":["/**\n * Enum for the differnet APIs the CLI can interact with.\n * @readonly\n * @enum {number}\n */\nexport type Service = 'shopify' | 'partners' | 'identity'\n\n/**\n * Enum that represents the environment to use for a given service.\n * @readonly\n * @enum {number}\n */\nexport enum Environment {\n Local = 'local',\n Production = 'production',\n Spin = 'spin',\n}\n"]}
|
package/dist/node/archiver.d.ts
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* It zips a directory.
|
|
2
|
+
* It zips a directory normalizing the paths to be forward-slash. Note that unzipping
|
|
3
|
+
* the zip generated by this function from a Windows environment won't work because paths
|
|
4
|
+
* need to be made backward-slash.
|
|
5
|
+
*
|
|
3
6
|
* @param inputDirectory {string} The absolute path to the directory to be zipped.
|
|
4
7
|
* @param outputZipPath {string} The absolute path to the output zip file.
|
|
5
8
|
*/
|
package/dist/node/archiver.js
CHANGED
|
@@ -1,24 +1,33 @@
|
|
|
1
1
|
import { debug, content, token } from '../output.js';
|
|
2
|
-
import {
|
|
2
|
+
import { glob, relative as relativePath } from '../path.js';
|
|
3
|
+
import archiver from 'archiver';
|
|
4
|
+
import { createWriteStream } from 'node:fs';
|
|
3
5
|
/**
|
|
4
|
-
* It zips a directory.
|
|
6
|
+
* It zips a directory normalizing the paths to be forward-slash. Note that unzipping
|
|
7
|
+
* the zip generated by this function from a Windows environment won't work because paths
|
|
8
|
+
* need to be made backward-slash.
|
|
9
|
+
*
|
|
5
10
|
* @param inputDirectory {string} The absolute path to the directory to be zipped.
|
|
6
11
|
* @param outputZipPath {string} The absolute path to the output zip file.
|
|
7
12
|
*/
|
|
8
13
|
export async function zip(inputDirectory, outputZipPath) {
|
|
9
14
|
debug(content `Zipping ${token.path(inputDirectory)} into ${token.path(outputZipPath)}`);
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
reject(error);
|
|
17
|
-
}
|
|
18
|
-
else {
|
|
19
|
-
resolve();
|
|
20
|
-
}
|
|
15
|
+
const pathsToZip = await glob('**/*', { cwd: inputDirectory, absolute: true, dot: true, followSymbolicLinks: false });
|
|
16
|
+
return new Promise((resolve, reject) => {
|
|
17
|
+
const archive = archiver('zip');
|
|
18
|
+
const output = createWriteStream(outputZipPath);
|
|
19
|
+
output.on('close', function () {
|
|
20
|
+
resolve();
|
|
21
21
|
});
|
|
22
|
+
archive.on('error', function (error) {
|
|
23
|
+
reject(error);
|
|
24
|
+
});
|
|
25
|
+
archive.pipe(output);
|
|
26
|
+
for (const filePath of pathsToZip) {
|
|
27
|
+
const fileRelativePath = relativePath(inputDirectory, filePath);
|
|
28
|
+
archive.file(filePath, { name: fileRelativePath });
|
|
29
|
+
}
|
|
30
|
+
archive.finalize();
|
|
22
31
|
});
|
|
23
32
|
}
|
|
24
33
|
//# sourceMappingURL=archiver.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"archiver.js","sourceRoot":"","sources":["../../src/node/archiver.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,KAAK,EAAE,OAAO,EAAE,KAAK,EAAC,MAAM,cAAc,CAAA;AAClD,OAAO,EAAC,
|
|
1
|
+
{"version":3,"file":"archiver.js","sourceRoot":"","sources":["../../src/node/archiver.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,KAAK,EAAE,OAAO,EAAE,KAAK,EAAC,MAAM,cAAc,CAAA;AAClD,OAAO,EAAC,IAAI,EAAE,QAAQ,IAAI,YAAY,EAAC,MAAM,YAAY,CAAA;AACzD,OAAO,QAAQ,MAAM,UAAU,CAAA;AAC/B,OAAO,EAAC,iBAAiB,EAAC,MAAM,SAAS,CAAA;AACzC;;;;;;;GAOG;AACH,MAAM,CAAC,KAAK,UAAU,GAAG,CAAC,cAAsB,EAAE,aAAqB;IACrE,KAAK,CAAC,OAAO,CAAA,WAAW,KAAK,CAAC,IAAI,CAAC,cAAc,CAAC,SAAS,KAAK,CAAC,IAAI,CAAC,aAAa,CAAC,EAAE,CAAC,CAAA;IACvF,MAAM,UAAU,GAAG,MAAM,IAAI,CAAC,MAAM,EAAE,EAAC,GAAG,EAAE,cAAc,EAAE,QAAQ,EAAE,IAAI,EAAE,GAAG,EAAE,IAAI,EAAE,mBAAmB,EAAE,KAAK,EAAC,CAAC,CAAA;IACnH,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACrC,MAAM,OAAO,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAA;QAC/B,MAAM,MAAM,GAAG,iBAAiB,CAAC,aAAa,CAAC,CAAA;QAE/C,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE;YACjB,OAAO,EAAE,CAAA;QACX,CAAC,CAAC,CAAA;QACF,OAAO,CAAC,EAAE,CAAC,OAAO,EAAE,UAAU,KAAK;YACjC,MAAM,CAAC,KAAK,CAAC,CAAA;QACf,CAAC,CAAC,CAAA;QACF,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;QAEpB,KAAK,MAAM,QAAQ,IAAI,UAAU,EAAE;YACjC,MAAM,gBAAgB,GAAG,YAAY,CAAC,cAAc,EAAE,QAAQ,CAAC,CAAA;YAC/D,OAAO,CAAC,IAAI,CAAC,QAAQ,EAAE,EAAC,IAAI,EAAE,gBAAgB,EAAC,CAAC,CAAA;SACjD;QAED,OAAO,CAAC,QAAQ,EAAE,CAAA;IACpB,CAAC,CAAC,CAAA;AACJ,CAAC","sourcesContent":["import {debug, content, token} from '../output.js'\nimport {glob, relative as relativePath} from '../path.js'\nimport archiver from 'archiver'\nimport {createWriteStream} from 'node:fs'\n/**\n * It zips a directory normalizing the paths to be forward-slash. Note that unzipping\n * the zip generated by this function from a Windows environment won't work because paths\n * need to be made backward-slash.\n *\n * @param inputDirectory {string} The absolute path to the directory to be zipped.\n * @param outputZipPath {string} The absolute path to the output zip file.\n */\nexport async function zip(inputDirectory: string, outputZipPath: string): Promise<void> {\n debug(content`Zipping ${token.path(inputDirectory)} into ${token.path(outputZipPath)}`)\n const pathsToZip = await glob('**/*', {cwd: inputDirectory, absolute: true, dot: true, followSymbolicLinks: false})\n return new Promise((resolve, reject) => {\n const archive = archiver('zip')\n const output = createWriteStream(outputZipPath)\n\n output.on('close', function () {\n resolve()\n })\n archive.on('error', function (error) {\n reject(error)\n })\n archive.pipe(output)\n\n for (const filePath of pathsToZip) {\n const fileRelativePath = relativePath(inputDirectory, filePath)\n archive.file(filePath, {name: fileRelativePath})\n }\n\n archive.finalize()\n })\n}\n"]}
|
|
@@ -1,9 +1,18 @@
|
|
|
1
|
-
import { errorHandler } from './error-handler.js';
|
|
1
|
+
import { errorHandler, registerCleanBugsnagErrorsFromWithinPlugins } from './error-handler.js';
|
|
2
|
+
import { isDebug } from '../environment/local.js';
|
|
2
3
|
import { Command } from '@oclif/core';
|
|
3
4
|
// eslint-disable-next-line import/no-anonymous-default-export
|
|
4
5
|
export default class extends Command {
|
|
5
6
|
async catch(error) {
|
|
6
|
-
errorHandler(error);
|
|
7
|
+
errorHandler(error, this.config);
|
|
8
|
+
}
|
|
9
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
10
|
+
async init() {
|
|
11
|
+
if (!isDebug()) {
|
|
12
|
+
// This function runs just prior to `run`
|
|
13
|
+
registerCleanBugsnagErrorsFromWithinPlugins(this.config.plugins);
|
|
14
|
+
}
|
|
15
|
+
return super.init();
|
|
7
16
|
}
|
|
8
17
|
}
|
|
9
18
|
//# sourceMappingURL=base-command.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base-command.js","sourceRoot":"","sources":["../../src/node/base-command.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,YAAY,EAAC,MAAM,oBAAoB,CAAA;AAC/C,OAAO,EAAC,OAAO,EAAC,MAAM,aAAa,CAAA;AAEnC,8DAA8D;AAC9D,MAAM,CAAC,OAAO,MAAgB,SAAQ,OAAO;IAC3C,KAAK,CAAC,KAAK,CAAC,KAA8C;QACxD,YAAY,CAAC,KAAK,CAAC,CAAA;IACrB,CAAC;CACF","sourcesContent":["import {errorHandler} from './error-handler.js'\nimport {Command} from '@oclif/core'\n\n// eslint-disable-next-line import/no-anonymous-default-export\nexport default abstract class extends Command {\n async catch(error: Error & {exitCode?: number | undefined}) {\n errorHandler(error)\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"base-command.js","sourceRoot":"","sources":["../../src/node/base-command.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,YAAY,EAAE,2CAA2C,EAAC,MAAM,oBAAoB,CAAA;AAC5F,OAAO,EAAC,OAAO,EAAC,MAAM,yBAAyB,CAAA;AAC/C,OAAO,EAAC,OAAO,EAAC,MAAM,aAAa,CAAA;AAEnC,8DAA8D;AAC9D,MAAM,CAAC,OAAO,MAAgB,SAAQ,OAAO;IAC3C,KAAK,CAAC,KAAK,CAAC,KAA8C;QACxD,YAAY,CAAC,KAAK,EAAE,IAAI,CAAC,MAAM,CAAC,CAAA;IAClC,CAAC;IAED,8DAA8D;IACpD,KAAK,CAAC,IAAI;QAClB,IAAI,CAAC,OAAO,EAAE,EAAE;YACd,yCAAyC;YACzC,2CAA2C,CAAC,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,CAAA;SACjE;QACD,OAAO,KAAK,CAAC,IAAI,EAAE,CAAA;IACrB,CAAC;CACF","sourcesContent":["import {errorHandler, registerCleanBugsnagErrorsFromWithinPlugins} from './error-handler.js'\nimport {isDebug} from '../environment/local.js'\nimport {Command} from '@oclif/core'\n\n// eslint-disable-next-line import/no-anonymous-default-export\nexport default abstract class extends Command {\n async catch(error: Error & {exitCode?: number | undefined}) {\n errorHandler(error, this.config)\n }\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n protected async init(): Promise<any> {\n if (!isDebug()) {\n // This function runs just prior to `run`\n registerCleanBugsnagErrorsFromWithinPlugins(this.config.plugins)\n }\n return super.init()\n }\n}\n"]}
|
package/dist/node/cli.d.ts
CHANGED
package/dist/node/cli.js
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
// CLI
|
|
2
2
|
import { findUpAndReadPackageJson } from './node-package-manager.js';
|
|
3
3
|
import { errorHandler } from './error-handler.js';
|
|
4
|
-
import { initializeCliKitStore } from '../store.js';
|
|
5
|
-
import { initiateLogging } from '../output.js';
|
|
6
4
|
import { isDebug } from '../environment/local.js';
|
|
7
5
|
import constants, { bugsnagApiKey } from '../constants.js';
|
|
8
6
|
import { moduleDirectory } from '../path.js';
|
|
@@ -14,8 +12,6 @@ import Bugsnag from '@bugsnag/js';
|
|
|
14
12
|
* @param module {RunCLIOptions} Options.
|
|
15
13
|
*/
|
|
16
14
|
export async function runCLI(options) {
|
|
17
|
-
await initializeCliKitStore();
|
|
18
|
-
initiateLogging({ filename: options.logFilename });
|
|
19
15
|
if (isDebug()) {
|
|
20
16
|
settings.debug = true;
|
|
21
17
|
}
|
package/dist/node/cli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../../src/node/cli.ts"],"names":[],"mappings":"AAAA,MAAM;AACN,OAAO,EAAC,wBAAwB,EAAC,MAAM,2BAA2B,CAAA;AAClE,OAAO,EAAC,YAAY,EAAC,MAAM,oBAAoB,CAAA;AAC/C,OAAO,EAAC,
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../../src/node/cli.ts"],"names":[],"mappings":"AAAA,MAAM;AACN,OAAO,EAAC,wBAAwB,EAAC,MAAM,2BAA2B,CAAA;AAClE,OAAO,EAAC,YAAY,EAAC,MAAM,oBAAoB,CAAA;AAC/C,OAAO,EAAC,OAAO,EAAC,MAAM,yBAAyB,CAAA;AAC/C,OAAO,SAAS,EAAE,EAAC,aAAa,EAAC,MAAM,iBAAiB,CAAA;AACxD,OAAO,EAAC,eAAe,EAAC,MAAM,YAAY,CAAA;AAC1C,OAAO,EAAC,GAAG,EAAE,QAAQ,EAAE,KAAK,EAAC,MAAM,aAAa,CAAA;AAChD,OAAO,OAAO,MAAM,aAAa,CAAA;AAOjC;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,MAAM,CAAC,OAAsB;IACjD,IAAI,OAAO,EAAE,EAAE;QACb,QAAQ,CAAC,KAAK,GAAG,IAAI,CAAA;KACtB;SAAM;QACL,OAAO,CAAC,KAAK,CAAC;YACZ,OAAO,EAAE,MAAM;YACf,MAAM,EAAE,aAAa;YACrB,MAAM,EAAE,IAAI;YACZ,UAAU,EAAE,MAAM,SAAS,CAAC,QAAQ,CAAC,MAAM,EAAE;YAC7C,iBAAiB,EAAE,KAAK;YACxB,gBAAgB,EAAE,KAAK;SACxB,CAAC,CAAA;KACH;IAED,GAAG,CAAC,SAAS,EAAE,OAAO,CAAC,SAAS,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,YAAY,CAAC,CAAA;AACnE,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,YAAY,CAAC,OAAsB;IACvD,MAAM,WAAW,GAAG,MAAM,wBAAwB,CAAC,eAAe,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,CAAA;IACtF,8DAA8D;IAC9D,MAAM,WAAW,GAAI,WAAW,CAAC,OAAe,CAAC,IAAc,CAAA;IAC/D,MAAM,IAAI,GAAG,WAAW,CAAC,OAAO,CAAC,kBAAkB,EAAE,EAAE,CAAC,CAAA;IACxD,MAAM,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAA;IACvE,IAAI,SAAS,KAAK,CAAC,CAAC,EAAE;QACpB,MAAM,SAAS,GACb,OAAO,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,MAAM,CAAC,yBAAyB,IAAI,WAAW,CAAC,CAAC,CAAC,GAAG,CAAC,CAAA;QACtG,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,SAAS,EAAE,CAAC,EAAE,MAAM,CAAC,CAAA;KAC1C;IACD,MAAM,MAAM,CAAC,OAAO,CAAC,CAAA;AACvB,CAAC;AAED,eAAe,MAAM,CAAA","sourcesContent":["// CLI\nimport {findUpAndReadPackageJson} from './node-package-manager.js'\nimport {errorHandler} from './error-handler.js'\nimport {isDebug} from '../environment/local.js'\nimport constants, {bugsnagApiKey} from '../constants.js'\nimport {moduleDirectory} from '../path.js'\nimport {run, settings, flush} from '@oclif/core'\nimport Bugsnag from '@bugsnag/js'\n\ninterface RunCLIOptions {\n /** The value of import.meta.url of the CLI executable module */\n moduleURL: string\n}\n\n/**\n * A function that abstracts away setting up the environment and running\n * a CLI\n * @param module {RunCLIOptions} Options.\n */\nexport async function runCLI(options: RunCLIOptions) {\n if (isDebug()) {\n settings.debug = true\n } else {\n Bugsnag.start({\n appType: 'node',\n apiKey: bugsnagApiKey,\n logger: null,\n appVersion: await constants.versions.cliKit(),\n autoTrackSessions: false,\n autoDetectErrors: false,\n })\n }\n\n run(undefined, options.moduleURL).then(flush).catch(errorHandler)\n}\n\n/**\n * A function for create-x CLIs that automatically runs the \"init\" command.\n * @param options\n */\nexport async function runCreateCLI(options: RunCLIOptions) {\n const packageJson = await findUpAndReadPackageJson(moduleDirectory(options.moduleURL))\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const packageName = (packageJson.content as any).name as string\n const name = packageName.replace('@shopify/create-', '')\n const initIndex = process.argv.findIndex((arg) => arg.includes('init'))\n if (initIndex === -1) {\n const initIndex =\n process.argv.findIndex((arg) => arg.match(new RegExp(`bin(\\\\/|\\\\\\\\)+(create-${name}|dev|run)`))) + 1\n process.argv.splice(initIndex, 0, 'init')\n }\n await runCLI(options)\n}\n\nexport default runCLI\n"]}
|