@shopify/cli-kit 3.5.0 → 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.
Files changed (55) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/dist/analytics.d.ts +11 -5
  3. package/dist/analytics.js +62 -72
  4. package/dist/analytics.js.map +1 -1
  5. package/dist/api/common.js +0 -2
  6. package/dist/api/common.js.map +1 -1
  7. package/dist/api/identity.js +0 -1
  8. package/dist/api/identity.js.map +1 -1
  9. package/dist/api/partners.js +0 -1
  10. package/dist/api/partners.js.map +1 -1
  11. package/dist/array.d.ts +1 -0
  12. package/dist/array.js +4 -0
  13. package/dist/array.js.map +1 -0
  14. package/dist/file.d.ts +1 -1
  15. package/dist/file.js +1 -1
  16. package/dist/file.js.map +1 -1
  17. package/dist/git.js +0 -1
  18. package/dist/git.js.map +1 -1
  19. package/dist/haiku.d.ts +6 -1
  20. package/dist/haiku.js +67 -6
  21. package/dist/haiku.js.map +1 -1
  22. package/dist/index.d.ts +2 -0
  23. package/dist/index.js +2 -0
  24. package/dist/index.js.map +1 -1
  25. package/dist/json.d.ts +6 -0
  26. package/dist/json.js +2 -0
  27. package/dist/json.js.map +1 -0
  28. package/dist/metadata.d.ts +51 -0
  29. package/dist/metadata.js +29 -0
  30. package/dist/metadata.js.map +1 -0
  31. package/dist/monorail.d.ts +38 -0
  32. package/dist/monorail.js +38 -0
  33. package/dist/monorail.js.map +1 -0
  34. package/dist/node/base-command.js +1 -1
  35. package/dist/node/base-command.js.map +1 -1
  36. package/dist/node/error-handler.d.ts +3 -1
  37. package/dist/node/error-handler.js +24 -5
  38. package/dist/node/error-handler.js.map +1 -1
  39. package/dist/node/hooks/postrun.js +3 -3
  40. package/dist/node/hooks/postrun.js.map +1 -1
  41. package/dist/plugins.d.ts +38 -2
  42. package/dist/plugins.js +11 -0
  43. package/dist/plugins.js.map +1 -1
  44. package/dist/session/authorize.js +16 -4
  45. package/dist/session/authorize.js.map +1 -1
  46. package/dist/session/exchange.js +0 -6
  47. package/dist/session/exchange.js.map +1 -1
  48. package/dist/string.d.ts +4 -0
  49. package/dist/string.js +13 -0
  50. package/dist/string.js.map +1 -1
  51. package/dist/tsconfig.tsbuildinfo +1 -1
  52. package/dist/ui.d.ts +1 -0
  53. package/dist/ui.js +22 -0
  54. package/dist/ui.js.map +1 -1
  55. package/package.json +4 -3
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
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=json.js.map
@@ -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 {};
@@ -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 {};
@@ -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;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AC,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"]}
@@ -4,7 +4,7 @@ import { Command } from '@oclif/core';
4
4
  // eslint-disable-next-line import/no-anonymous-default-export
5
5
  export default class extends Command {
6
6
  async catch(error) {
7
- errorHandler(error);
7
+ errorHandler(error, this.config);
8
8
  }
9
9
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
10
10
  async init() {
@@ -1 +1 @@
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,CAAC,CAAA;IACrB,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)\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"]}
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"]}
@@ -1,7 +1,8 @@
1
1
  import { Interfaces } from '@oclif/core';
2
+ import { Event } from '@bugsnag/js';
2
3
  export declare function errorHandler(error: Error & {
3
4
  exitCode?: number | undefined;
4
- }): Promise<never> | undefined;
5
+ }, config?: Interfaces.Config): Promise<never> | undefined;
5
6
  /**
6
7
  * If the given file path comes from within a plugin, return the relative path, plus the plugin name.
7
8
  *
@@ -21,3 +22,4 @@ export declare function cleanStackFrameFilePath({ currentFilePath, projectRoot,
21
22
  *
22
23
  */
23
24
  export declare function registerCleanBugsnagErrorsFromWithinPlugins(plugins: Interfaces.Plugin[]): Promise<void>;
25
+ export declare function addBugsnagMetadata(event: Event): void;
@@ -1,12 +1,13 @@
1
1
  import { AbortSilent, CancelExecution, mapper as errorMapper, shouldReport as shouldReportError, handler, cleanSingleStackTracePath, } from '../error.js';
2
- import { info } from '../output.js';
2
+ import { debug, info } from '../output.js';
3
3
  import { reportEvent } from '../analytics.js';
4
4
  import * as path from '../path.js';
5
+ import * as metadata from '../metadata.js';
5
6
  import { settings } from '@oclif/core';
6
7
  import StackTracey from 'stacktracey';
7
8
  import Bugsnag from '@bugsnag/js';
8
9
  import { realpath } from 'fs/promises';
9
- export function errorHandler(error) {
10
+ export function errorHandler(error, config) {
10
11
  if (error instanceof CancelExecution) {
11
12
  if (error.message && error.message !== '') {
12
13
  info(`✨ ${error.message}`);
@@ -20,14 +21,16 @@ export function errorHandler(error) {
20
21
  .then((error) => {
21
22
  return handler(error);
22
23
  })
23
- .then(reportError)
24
+ .then((mappedError) => reportError(mappedError, config))
24
25
  .then(() => {
25
26
  process.exit(1);
26
27
  });
27
28
  }
28
29
  }
29
- const reportError = async (error) => {
30
- await reportEvent({ errorMessage: error.message });
30
+ const reportError = async (error, config) => {
31
+ if (config !== undefined) {
32
+ await reportEvent({ config, errorMessage: error.message });
33
+ }
31
34
  if (settings.debug || !shouldReportError(error))
32
35
  return error;
33
36
  let reportableError;
@@ -111,6 +114,22 @@ export async function registerCleanBugsnagErrorsFromWithinPlugins(plugins) {
111
114
  stackFrame.file = cleanStackFrameFilePath({ currentFilePath: stackFrame.file, projectRoot, pluginLocations });
112
115
  });
113
116
  });
117
+ try {
118
+ addBugsnagMetadata(event);
119
+ // eslint-disable-next-line no-catch-all/no-catch-all
120
+ }
121
+ catch (metadataError) {
122
+ debug(`There was an error adding metadata to the Bugsnag report; Ignoring and carrying on ${metadataError}`);
123
+ }
124
+ });
125
+ }
126
+ export function addBugsnagMetadata(event) {
127
+ const publicData = metadata.getAllPublic();
128
+ const bugsnagMetadata = {
129
+ misc: publicData,
130
+ };
131
+ Object.entries(bugsnagMetadata).forEach(([section, values]) => {
132
+ event.addMetadata(section, values);
114
133
  });
115
134
  }
116
135
  //# sourceMappingURL=error-handler.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"error-handler.js","sourceRoot":"","sources":["../../src/node/error-handler.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,WAAW,EACX,eAAe,EACf,MAAM,IAAI,WAAW,EACrB,YAAY,IAAI,iBAAiB,EACjC,OAAO,EACP,yBAAyB,GAC1B,MAAM,aAAa,CAAA;AACpB,OAAO,EAAC,IAAI,EAAC,MAAM,cAAc,CAAA;AACjC,OAAO,EAAC,WAAW,EAAC,MAAM,iBAAiB,CAAA;AAC3C,OAAO,KAAK,IAAI,MAAM,YAAY,CAAA;AAClC,OAAO,EAAC,QAAQ,EAAa,MAAM,aAAa,CAAA;AAChD,OAAO,WAAW,MAAM,aAAa,CAAA;AACrC,OAAO,OAAO,MAAM,aAAa,CAAA;AACjC,OAAO,EAAC,QAAQ,EAAC,MAAM,aAAa,CAAA;AAEpC,MAAM,UAAU,YAAY,CAAC,KAA8C;IACzE,IAAI,KAAK,YAAY,eAAe,EAAE;QACpC,IAAI,KAAK,CAAC,OAAO,IAAI,KAAK,CAAC,OAAO,KAAK,EAAE,EAAE;YACzC,IAAI,CAAC,MAAM,KAAK,CAAC,OAAO,EAAE,CAAC,CAAA;SAC5B;KACF;SAAM,IAAI,KAAK,YAAY,WAAW,EAAE;QACvC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;KAChB;SAAM;QACL,OAAO,WAAW,CAAC,KAAK,CAAC;aACtB,IAAI,CAAC,CAAC,KAAY,EAAE,EAAE;YACrB,OAAO,OAAO,CAAC,KAAK,CAAC,CAAA;QACvB,CAAC,CAAC;aACD,IAAI,CAAC,WAAW,CAAC;aACjB,IAAI,CAAC,GAAG,EAAE;YACT,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;QACjB,CAAC,CAAC,CAAA;KACL;AACH,CAAC;AAED,MAA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;IAC9D,MAAM,wBAAwB,GAAY,OAAe,EAAE,OAAO,EAAE,OAAO,EAAE,WAAW,IAAI,OAAO,CAAC,GAAG,EAAE,CAAA;IACzG,MAAM,WAAW,GAAG,IAAI,CAAC,SAAS,CAAC,wBAAwB,CAAC,CAAA;IAC5D,MAAM,eAAe,GAAG,MAAM,OAAO,CAAC,GAAG,CACvC,OAAO,CAAC,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE;QAC3B,MAAM,cAAc,GAAG,MAAM,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,CAAA;QAClD,OAAO,EAAC,IAAI,EAAE,MAAM,CAAC,IAAI,EAAE,UAAU,EAAE,IAAI,CAAC,SAAS,CAAC,cAAc,CAAC,EAAC,CAAA;IACxE,CAAC,CAAC,CACH,CAAA;IACD,OAAO,CAAC,UAAU,CAAC,CAAC,KAAK,EAAE,EAAE;QAC3B,KAAK,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,EAAE;YAC7B,KAAK,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,UAAU,EAAE,EAAE;gBACtC,UAAU,CAAC,IAAI,GAAG,uBAAuB,CAAC,EAAC,eAAe,EAAE,UAAU,CAAC,IAAI,EAAE,WAAW,EAAE,eAAe,EAAC,CAAC,CAAA;YAC7G,CAAC,CAAC,CAAA;QACJ,CAAC,CAAC,CAAA;IACJ,CAAC,CAAC,CAAA;AACJ,CAAC","sourcesContent":["import {\n AbortSilent,\n CancelExecution,\n mapper as errorMapper,\n shouldReport as shouldReportError,\n handler,\n cleanSingleStackTracePath,\n} from '../error.js'\nimport {info} from '../output.js'\nimport {reportEvent} from '../analytics.js'\nimport * as path from '../path.js'\nimport {settings, Interfaces} from '@oclif/core'\nimport StackTracey from 'stacktracey'\nimport Bugsnag from '@bugsnag/js'\nimport {realpath} from 'fs/promises'\n\nexport function errorHandler(error: Error & {exitCode?: number | undefined}) {\n if (error instanceof CancelExecution) {\n if (error.message && error.message !== '') {\n info(`✨ ${error.message}`)\n }\n } else if (error instanceof AbortSilent) {\n process.exit(1)\n } else {\n return errorMapper(error)\n .then((error: Error) => {\n return handler(error)\n })\n .then(reportError)\n .then(() => {\n process.exit(1)\n })\n }\n}\n\nconst reportError = async (error: Error): Promise<Error> => {\n await reportEvent({errorMessage: error.message})\n if (settings.debug || !shouldReportError(error)) return error\n\n let reportableError: Error\n let stacktrace: string | undefined\n let report = false\n\n // eslint-disable-next-line no-prototype-builtins\n if (Error.prototype.isPrototypeOf(error)) {\n report = true\n reportableError = new Error(error.message)\n stacktrace = error.stack\n\n /**\n * Some errors that reach this point have an empty string. For example:\n * https://app.bugsnag.com/shopify/cli/errors/62cd5d31fd5040000814086c?filters[event.since]=30d&filters[error.status]=new&filters[release.seen_in]=3.1.0\n *\n * Because at this point we have neither the error message nor a stack trace reporting them\n * to Bugsnag is pointless and adds noise.\n */\n } else if (typeof error === 'string' && (error as string).trim().length !== 0) {\n report = true\n reportableError = new Error(error)\n stacktrace = reportableError.stack\n } else {\n report = false\n reportableError = new Error('Unknown error')\n }\n\n const formattedStacktrace = new StackTracey(stacktrace ?? '')\n .clean()\n .items.map((item) => {\n const filePath = cleanSingleStackTracePath(item.file)\n return ` at ${item.callee} (${filePath}:${item.line}:${item.column})`\n })\n .join('\\n')\n reportableError.stack = `Error: ${reportableError.message}\\n${formattedStacktrace}`\n\n if (report) {\n await new Promise((resolve, reject) => {\n Bugsnag.notify(reportableError, undefined, (error, event) => {\n if (error) {\n reject(error)\n } else {\n resolve(reportableError)\n }\n })\n })\n }\n return reportableError\n}\n\n/**\n * If the given file path comes from within a plugin, return the relative path, plus the plugin name.\n *\n * This gives us very consistent paths for errors thrown from plugin code.\n *\n */\nexport function cleanStackFrameFilePath({\n currentFilePath,\n projectRoot,\n pluginLocations,\n}: {\n currentFilePath: string\n projectRoot: string\n pluginLocations: {name: string; pluginPath: string}[]\n}): string {\n const fullLocation = path.isAbsolute(currentFilePath) ? currentFilePath : path.join(projectRoot, currentFilePath)\n\n const matchingPluginPath = pluginLocations.filter(({pluginPath}) => fullLocation.indexOf(pluginPath) === 0)[0]\n\n if (matchingPluginPath !== undefined) {\n // the plugin name (e.g. @shopify/cli-kit), plus the relative path of the error line from within the plugin's code (e.g. dist/something.js )\n return path.join(matchingPluginPath.name, path.relative(matchingPluginPath.pluginPath, fullLocation))\n }\n return currentFilePath\n}\n\n/**\n * Register a Bugsnag error listener to clean up stack traces for errors within plugin code.\n *\n */\nexport async function registerCleanBugsnagErrorsFromWithinPlugins(plugins: Interfaces.Plugin[]) {\n // Bugsnag have their own plug-ins that use this private field\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const bugsnagConfigProjectRoot: string = (Bugsnag as any)?._client?._config?.projectRoot ?? process.cwd()\n const projectRoot = path.normalize(bugsnagConfigProjectRoot)\n const pluginLocations = await Promise.all(\n plugins.map(async (plugin) => {\n const followSymlinks = await realpath(plugin.root)\n return {name: plugin.name, pluginPath: path.normalize(followSymlinks)}\n }),\n )\n Bugsnag.addOnError((event) => {\n event.errors.forEach((error) => {\n error.stacktrace.forEach((stackFrame) => {\n stackFrame.file = cleanStackFrameFilePath({currentFilePath: stackFrame.file, projectRoot, pluginLocations})\n })\n })\n })\n}\n"]}
1
+ {"version":3,"file":"error-handler.js","sourceRoot":"","sources":["../../src/node/error-handler.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,WAAW,EACX,eAAe,EACf,MAAM,IAAI,WAAW,EACrB,YAAY,IAAI,iBAAiB,EACjC,OAAO,EACP,yBAAyB,GAC1B,MAAM,aAAa,CAAA;AACpB,OAAO,EAAC,KAAK,EAAE,IAAI,EAAC,MAAM,cAAc,CAAA;AACxC,OAAO,EAAC,WAAW,EAAC,MAAM,iBAAiB,CAAA;AAC3C,OAAO,KAAK,IAAI,MAAM,YAAY,CAAA;AAClC,OAAO,KAAK,QAAQ,MAAM,gBAAgB,CAAA;AAC1C,OAAO,EAAC,QAAQ,EAAa,MAAM,aAAa,CAAA;AACh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OAAO,EAAC,IAAI,EAAE,MAAM,CAAC,IAAI,EAAE,UAAU,EAAE,IAAI,CAAC,SAAS,CAAC,cAAc,CAAC,EAAC,CAAA;IACxE,CAAC,CAAC,CACH,CAAA;IACD,OAAO,CAAC,UAAU,CAAC,CAAC,KAAK,EAAE,EAAE;QAC3B,KAAK,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,EAAE;YAC7B,KAAK,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,UAAU,EAAE,EAAE;gBACtC,UAAU,CAAC,IAAI,GAAG,uBAAuB,CAAC,EAAC,eAAe,EAAE,UAAU,CAAC,IAAI,EAAE,WAAW,EAAE,eAAe,EAAC,CAAC,CAAA;YAC7G,CAAC,CAAC,CAAA;QACJ,CAAC,CAAC,CAAA;QACF,IAAI;YACF,kBAAkB,CAAC,KAAK,CAAC,CAAA;YACzB,qDAAqD;SACtD;QAAC,OAAO,aAAa,EAAE;YACtB,KAAK,CAAC,sFAAsF,aAAa,EAAE,CAAC,CAAA;SAC7G;IACH,CAAC,CAAC,CAAA;AACJ,CAAC;AAED,MAAM,UAAU,kBAAkB,CAAC,KAAY;IAC7C,MAAM,UAAU,GAAG,QAAQ,CAAC,YAAY,EAAE,CAAA;IAC1C,MAAM,eAAe,GAAG;QACtB,IAAI,EAAE,UAAU;KACjB,CAAA;IACD,MAAM,CAAC,OAAO,CAAC,eAAe,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,OAAO,EAAE,MAAM,CAAC,EAAE,EAAE;QAC5D,KAAK,CAAC,WAAW,CAAC,OAAO,EAAE,MAAM,CAAC,CAAA;IACpC,CAAC,CAAC,CAAA;AACJ,CAAC","sourcesContent":["import {\n AbortSilent,\n CancelExecution,\n mapper as errorMapper,\n shouldReport as shouldReportError,\n handler,\n cleanSingleStackTracePath,\n} from '../error.js'\nimport {debug, info} from '../output.js'\nimport {reportEvent} from '../analytics.js'\nimport * as path from '../path.js'\nimport * as metadata from '../metadata.js'\nimport {settings, Interfaces} from '@oclif/core'\nimport StackTracey from 'stacktracey'\nimport Bugsnag, {Event} from '@bugsnag/js'\nimport {realpath} from 'fs/promises'\n\nexport function errorHandler(error: Error & {exitCode?: number | undefined}, config?: Interfaces.Config) {\n if (error instanceof CancelExecution) {\n if (error.message && error.message !== '') {\n info(`✨ ${error.message}`)\n }\n } else if (error instanceof AbortSilent) {\n process.exit(1)\n } else {\n return errorMapper(error)\n .then((error: Error) => {\n return handler(error)\n })\n .then((mappedError) => reportError(mappedError, config))\n .then(() => {\n process.exit(1)\n })\n }\n}\n\nconst reportError = async (error: Error, config?: Interfaces.Config): Promise<Error> => {\n if (config !== undefined) {\n await reportEvent({config, errorMessage: error.message})\n }\n if (settings.debug || !shouldReportError(error)) return error\n\n let reportableError: Error\n let stacktrace: string | undefined\n let report = false\n\n // eslint-disable-next-line no-prototype-builtins\n if (Error.prototype.isPrototypeOf(error)) {\n report = true\n reportableError = new Error(error.message)\n stacktrace = error.stack\n\n /**\n * Some errors that reach this point have an empty string. For example:\n * https://app.bugsnag.com/shopify/cli/errors/62cd5d31fd5040000814086c?filters[event.since]=30d&filters[error.status]=new&filters[release.seen_in]=3.1.0\n *\n * Because at this point we have neither the error message nor a stack trace reporting them\n * to Bugsnag is pointless and adds noise.\n */\n } else if (typeof error === 'string' && (error as string).trim().length !== 0) {\n report = true\n reportableError = new Error(error)\n stacktrace = reportableError.stack\n } else {\n report = false\n reportableError = new Error('Unknown error')\n }\n\n const formattedStacktrace = new StackTracey(stacktrace ?? '')\n .clean()\n .items.map((item) => {\n const filePath = cleanSingleStackTracePath(item.file)\n return ` at ${item.callee} (${filePath}:${item.line}:${item.column})`\n })\n .join('\\n')\n reportableError.stack = `Error: ${reportableError.message}\\n${formattedStacktrace}`\n\n if (report) {\n await new Promise((resolve, reject) => {\n Bugsnag.notify(reportableError, undefined, (error, event) => {\n if (error) {\n reject(error)\n } else {\n resolve(reportableError)\n }\n })\n })\n }\n return reportableError\n}\n\n/**\n * If the given file path comes from within a plugin, return the relative path, plus the plugin name.\n *\n * This gives us very consistent paths for errors thrown from plugin code.\n *\n */\nexport function cleanStackFrameFilePath({\n currentFilePath,\n projectRoot,\n pluginLocations,\n}: {\n currentFilePath: string\n projectRoot: string\n pluginLocations: {name: string; pluginPath: string}[]\n}): string {\n const fullLocation = path.isAbsolute(currentFilePath) ? currentFilePath : path.join(projectRoot, currentFilePath)\n\n const matchingPluginPath = pluginLocations.filter(({pluginPath}) => fullLocation.indexOf(pluginPath) === 0)[0]\n\n if (matchingPluginPath !== undefined) {\n // the plugin name (e.g. @shopify/cli-kit), plus the relative path of the error line from within the plugin's code (e.g. dist/something.js )\n return path.join(matchingPluginPath.name, path.relative(matchingPluginPath.pluginPath, fullLocation))\n }\n return currentFilePath\n}\n\n/**\n * Register a Bugsnag error listener to clean up stack traces for errors within plugin code.\n *\n */\nexport async function registerCleanBugsnagErrorsFromWithinPlugins(plugins: Interfaces.Plugin[]) {\n // Bugsnag have their own plug-ins that use this private field\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const bugsnagConfigProjectRoot: string = (Bugsnag as any)?._client?._config?.projectRoot ?? process.cwd()\n const projectRoot = path.normalize(bugsnagConfigProjectRoot)\n const pluginLocations = await Promise.all(\n plugins.map(async (plugin) => {\n const followSymlinks = await realpath(plugin.root)\n return {name: plugin.name, pluginPath: path.normalize(followSymlinks)}\n }),\n )\n Bugsnag.addOnError((event) => {\n event.errors.forEach((error) => {\n error.stacktrace.forEach((stackFrame) => {\n stackFrame.file = cleanStackFrameFilePath({currentFilePath: stackFrame.file, projectRoot, pluginLocations})\n })\n })\n try {\n addBugsnagMetadata(event)\n // eslint-disable-next-line no-catch-all/no-catch-all\n } catch (metadataError) {\n debug(`There was an error adding metadata to the Bugsnag report; Ignoring and carrying on ${metadataError}`)\n }\n })\n}\n\nexport function addBugsnagMetadata(event: Event) {\n const publicData = metadata.getAllPublic()\n const bugsnagMetadata = {\n misc: publicData,\n }\n Object.entries(bugsnagMetadata).forEach(([section, values]) => {\n event.addMetadata(section, values)\n })\n}\n"]}
@@ -1,9 +1,9 @@
1
1
  import { reportEvent } from '../../analytics.js';
2
2
  import { debug } from '../../output.js';
3
3
  // This hook is called after each successful command run. More info: https://oclif.io/docs/hooks
4
- export const hookPost = async (options) => {
5
- await reportEvent();
6
- const command = options.Command?.id?.replace(/:/g, ' ');
4
+ export const hookPost = async ({ config, Command }) => {
5
+ await reportEvent({ config });
6
+ const command = Command?.id?.replace(/:/g, ' ');
7
7
  debug(`Completed command ${command}`);
8
8
  };
9
9
  //# sourceMappingURL=postrun.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"postrun.js","sourceRoot":"","sources":["../../../src/node/hooks/postrun.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,WAAW,EAAC,MAAM,oBAAoB,CAAA;AAC9C,OAAO,EAAC,KAAK,EAAC,MAAM,iBAAiB,CAAA;AAGrC,gGAAgG;AAChG,MAAM,CAAC,MAAM,QAAQ,GAAiB,KAAK,EAAE,OAAO,EAAE,EAAE;IACtD,MAAM,WAAW,EAAE,CAAA;IACnB,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,EAAE,EAAE,EAAE,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC,CAAA;IACvD,KAAK,CAAC,qBAAqB,OAAO,EAAE,CAAC,CAAA;AACvC,CAAC,CAAA","sourcesContent":["import {reportEvent} from '../../analytics.js'\nimport {debug} from '../../output.js'\nimport {Hook} from '@oclif/core'\n\n// This hook is called after each successful command run. More info: https://oclif.io/docs/hooks\nexport const hookPost: Hook.Postrun = async (options) => {\n await reportEvent()\n const command = options.Command?.id?.replace(/:/g, ' ')\n debug(`Completed command ${command}`)\n}\n"]}
1
+ {"version":3,"file":"postrun.js","sourceRoot":"","sources":["../../../src/node/hooks/postrun.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,WAAW,EAAC,MAAM,oBAAoB,CAAA;AAC9C,OAAO,EAAC,KAAK,EAAC,MAAM,iBAAiB,CAAA;AAGrC,gGAAgG;AAChG,MAAM,CAAC,MAAM,QAAQ,GAAiB,KAAK,EAAE,EAAC,MAAM,EAAE,OAAO,EAAC,EAAE,EAAE;IAChE,MAAM,WAAW,CAAC,EAAC,MAAM,EAAC,CAAC,CAAA;IAC3B,MAAM,OAAO,GAAG,OAAO,EAAE,EAAE,EAAE,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC,CAAA;IAC/C,KAAK,CAAC,qBAAqB,OAAO,EAAE,CAAC,CAAA;AACvC,CAAC,CAAA","sourcesContent":["import {reportEvent} from '../../analytics.js'\nimport {debug} from '../../output.js'\nimport {Hook} from '@oclif/core'\n\n// This hook is called after each successful command run. More info: https://oclif.io/docs/hooks\nexport const hookPost: Hook.Postrun = async ({config, Command}) => {\n await reportEvent({config})\n const command = Command?.id?.replace(/:/g, ' ')\n debug(`Completed command ${command}`)\n}\n"]}
package/dist/plugins.d.ts CHANGED
@@ -1,9 +1,45 @@
1
- import { Plugin } from '@oclif/core/lib/interfaces';
1
+ import { Schemas } from './monorail.js';
2
+ import { Interfaces } from '@oclif/core';
2
3
  interface TunnelPlugin {
3
4
  start: (options: TunnelStartOptions) => Promise<string>;
4
5
  }
5
6
  interface TunnelStartOptions {
6
7
  port: number;
7
8
  }
8
- export declare function lookupTunnelPlugin(plugins: Plugin[]): Promise<TunnelPlugin | undefined>;
9
+ export declare function lookupTunnelPlugin(plugins: Interfaces.Plugin[]): Promise<TunnelPlugin | undefined>;
10
+ /**
11
+ * Convenience function to trigger a hook, and gather any successful responses. Failures are ignored.
12
+ *
13
+ * Responses are organised into a dictionary, keyed by plug-in name. Only plug-ins that have hooks registered for the given event, and the hooks were run successfully, are included.
14
+ */
15
+ export declare function fanoutHooks<TPluginMap extends HookReturnsPerPlugin, TEvent extends string & keyof TPluginMap>(config: Interfaces.Config, event: TEvent, options: TPluginMap[typeof event]['options'], timeout?: number): Promise<Partial<TPluginMap[typeof event]['pluginReturns']>>;
16
+ interface HookReturnsPerPlugin {
17
+ public_command_metadata: {
18
+ options: {
19
+ [key: string]: never;
20
+ };
21
+ pluginReturns: {
22
+ '@shopify/app': Partial<Pick<Schemas['app_cli3_command/1.0']['public'], 'project_type' | 'api_key' | 'partner_id'> & {
23
+ [key: string]: unknown;
24
+ }>;
25
+ [pluginName: string]: {
26
+ [key: string]: unknown;
27
+ };
28
+ };
29
+ };
30
+ [hookName: string]: {
31
+ options: {
32
+ [key: string]: unknown;
33
+ };
34
+ pluginReturns: {
35
+ [key: string]: {
36
+ [key: string]: unknown;
37
+ };
38
+ };
39
+ };
40
+ }
41
+ declare type PluginReturnsForHook<TEvent extends keyof TPluginMap, TPluginName extends keyof TPluginMap[TEvent]['pluginReturns'], TPluginMap extends HookReturnsPerPlugin = HookReturnsPerPlugin> = TPluginMap[TEvent]['pluginReturns'][TPluginName];
42
+ export declare type FanoutHookFunction<TEvent extends keyof TPluginMap = string, TPluginName extends keyof TPluginMap[TEvent]['pluginReturns'] = string, TPluginMap extends HookReturnsPerPlugin = HookReturnsPerPlugin> = (this: Interfaces.Hook.Context, options: TPluginMap[TEvent]['options'] & {
43
+ config: Interfaces.Config;
44
+ }) => Promise<Partial<PluginReturnsForHook<TEvent, TPluginName, TPluginMap>>>;
9
45
  export {};
package/dist/plugins.js CHANGED
@@ -1,3 +1,4 @@
1
+ /* eslint-disable @typescript-eslint/naming-convention */
1
2
  import { join, pathToFileURL } from './path.js';
2
3
  import { debug, content } from './output.js';
3
4
  const TUNNEL_PLUGINS = ['@shopify/plugin-ngrok'];
@@ -9,4 +10,14 @@ export async function lookupTunnelPlugin(plugins) {
9
10
  const tunnelPath = pathToFileURL(join(tunnelPlugin.root, 'dist/tunnel.js')).toString();
10
11
  return import(tunnelPath).catch(() => undefined);
11
12
  }
13
+ /**
14
+ * Convenience function to trigger a hook, and gather any successful responses. Failures are ignored.
15
+ *
16
+ * Responses are organised into a dictionary, keyed by plug-in name. Only plug-ins that have hooks registered for the given event, and the hooks were run successfully, are included.
17
+ */
18
+ export async function fanoutHooks(config, event, options, timeout) {
19
+ const res = await config.runHook(event, options, timeout);
20
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
21
+ return Object.fromEntries(res.successes.map(({ result, plugin }) => [plugin.name, result]));
22
+ }
12
23
  //# sourceMappingURL=plugins.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"plugins.js","sourceRoot":"","sources":["../src/plugins.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,IAAI,EAAE,aAAa,EAAC,MAAM,WAAW,CAAA;AAC7C,OAAO,EAAC,KAAK,EAAE,OAAO,EAAC,MAAM,aAAa,CAAA;AAG1C,MAAM,cAAc,GAAG,CAAC,uBAAuB,CAAC,CAAA;AAUhD,MAAM,CAAC,KAAK,UAAU,kBAAkB,CAAC,OAAiB;IACxD,KAAK,CAAC,OAAO,CAAA,uCAAuC,CAAC,CAAA;IACrD,MAAM,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,cAAc,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAA;IACnF,IAAI,CAAC,YAAY;QAAE,OAAO,SAAS,CAAA;IACnC,MAAM,UAAU,GAAG,aAAa,CAAC,IAAI,CAAC,YAAY,CAAC,IAAI,EAAE,gBAAgB,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAA;IACtF,OAAO,MAAM,CAAC,UAAU,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,CAAA;AAClD,CAAC","sourcesContent":["import {join, pathToFileURL} from './path.js'\nimport {debug, content} from './output.js'\nimport {Plugin} from '@oclif/core/lib/interfaces'\n\nconst TUNNEL_PLUGINS = ['@shopify/plugin-ngrok']\n\ninterface TunnelPlugin {\n start: (options: TunnelStartOptions) => Promise<string>\n}\n\ninterface TunnelStartOptions {\n port: number\n}\n\nexport async function lookupTunnelPlugin(plugins: Plugin[]): Promise<TunnelPlugin | undefined> {\n debug(content`Looking up the Ngrok tunnel plugin...`)\n const tunnelPlugin = plugins.find((plugin) => TUNNEL_PLUGINS.includes(plugin.name))\n if (!tunnelPlugin) return undefined\n const tunnelPath = pathToFileURL(join(tunnelPlugin.root, 'dist/tunnel.js')).toString()\n return import(tunnelPath).catch(() => undefined)\n}\n"]}
1
+ {"version":3,"file":"plugins.js","sourceRoot":"","sources":["../src/plugins.ts"],"names":[],"mappings":"AAAA,yDAAyD;AACzD,OAAO,EAAC,IAAI,EAAE,aAAa,EAAC,MAAM,WAAW,CAAA;AAC7C,OAAO,EAAC,KAAK,EAAE,OAAO,EAAC,MAAM,aAAa,CAAA;AAI1C,MAAM,cAAc,GAAG,CAAC,uBAAuB,CAAC,CAAA;AAUhD,MAAM,CAAC,KAAK,UAAU,kBAAkB,CAAC,OAA4B;IACnE,KAAK,CAAC,OAAO,CAAA,uCAAuC,CAAC,CAAA;IACrD,MAAM,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,cAAc,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAA;IACnF,IAAI,CAAC,YAAY;QAAE,OAAO,SAAS,CAAA;IACnC,MAAM,UAAU,GAAG,aAAa,CAAC,IAAI,CAAC,YAAY,CAAC,IAAI,EAAE,gBAAgB,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAA;IACtF,OAAO,MAAM,CAAC,UAAU,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,CAAA;AAClD,CAAC;AAED;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,WAAW,CAC/B,MAAyB,EACzB,KAAa,EACb,OAA4C,EAC5C,OAAgB;IAEhB,MAAM,GAAG,GAAG,MAAM,MAAM,CAAC,OAAO,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,CAAC,CAAA;IACzD,8DAA8D;IAC9D,OAAO,MAAM,CAAC,WAAW,CAAC,GAAG,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,EAAC,MAAM,EAAE,MAAM,EAAC,EAAE,EAAE,CAAC,CAAC,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,CAAQ,CAAA;AAClG,CAAC","sourcesContent":["/* eslint-disable @typescript-eslint/naming-convention */\nimport {join, pathToFileURL} from './path.js'\nimport {debug, content} from './output.js'\nimport {Schemas} from './monorail.js'\nimport {Interfaces} from '@oclif/core'\n\nconst TUNNEL_PLUGINS = ['@shopify/plugin-ngrok']\n\ninterface TunnelPlugin {\n start: (options: TunnelStartOptions) => Promise<string>\n}\n\ninterface TunnelStartOptions {\n port: number\n}\n\nexport async function lookupTunnelPlugin(plugins: Interfaces.Plugin[]): Promise<TunnelPlugin | undefined> {\n debug(content`Looking up the Ngrok tunnel plugin...`)\n const tunnelPlugin = plugins.find((plugin) => TUNNEL_PLUGINS.includes(plugin.name))\n if (!tunnelPlugin) return undefined\n const tunnelPath = pathToFileURL(join(tunnelPlugin.root, 'dist/tunnel.js')).toString()\n return import(tunnelPath).catch(() => undefined)\n}\n\n/**\n * Convenience function to trigger a hook, and gather any successful responses. Failures are ignored.\n *\n * Responses are organised into a dictionary, keyed by plug-in name. Only plug-ins that have hooks registered for the given event, and the hooks were run successfully, are included.\n */\nexport async function fanoutHooks<TPluginMap extends HookReturnsPerPlugin, TEvent extends string & keyof TPluginMap>(\n config: Interfaces.Config,\n event: TEvent,\n options: TPluginMap[typeof event]['options'],\n timeout?: number,\n): Promise<Partial<TPluginMap[typeof event]['pluginReturns']>> {\n const res = await config.runHook(event, options, timeout)\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n return Object.fromEntries(res.successes.map(({result, plugin}) => [plugin.name, result])) as any\n}\n\ninterface HookReturnsPerPlugin {\n public_command_metadata: {\n options: {[key: string]: never}\n pluginReturns: {\n '@shopify/app': Partial<\n Pick<Schemas['app_cli3_command/1.0']['public'], 'project_type' | 'api_key' | 'partner_id'> & {\n [key: string]: unknown\n }\n >\n [pluginName: string]: {[key: string]: unknown}\n }\n }\n [hookName: string]: {\n options: {[key: string]: unknown}\n pluginReturns: {[key: string]: {[key: string]: unknown}}\n }\n}\n\ntype PluginReturnsForHook<\n TEvent extends keyof TPluginMap,\n TPluginName extends keyof TPluginMap[TEvent]['pluginReturns'],\n TPluginMap extends HookReturnsPerPlugin = HookReturnsPerPlugin,\n> = TPluginMap[TEvent]['pluginReturns'][TPluginName]\n\nexport type FanoutHookFunction<\n TEvent extends keyof TPluginMap = string,\n TPluginName extends keyof TPluginMap[TEvent]['pluginReturns'] = string,\n TPluginMap extends HookReturnsPerPlugin = HookReturnsPerPlugin,\n> = (\n this: Interfaces.Hook.Context,\n options: TPluginMap[TEvent]['options'] & {config: Interfaces.Config},\n) => Promise<Partial<PluginReturnsForHook<TEvent, TPluginName, TPluginMap>>>\n"]}
@@ -2,10 +2,12 @@ import { listenRedirect } from './redirect-listener.js';
2
2
  import { clientId } from './identity.js';
3
3
  import { generateRandomChallengePair, randomHex } from '../string.js';
4
4
  import { open } from '../system.js';
5
- import { Abort } from '../error.js';
5
+ import { Abort, CancelExecution } from '../error.js';
6
6
  import { identity as identityFqdn } from '../environment/fqdn.js';
7
7
  import * as output from '../output.js';
8
- import { keypress } from '../ui.js';
8
+ import { keypress, terminateBlockingPortProcessPrompt } from '../ui.js';
9
+ import { checkPort as isPortAvailable } from 'get-port-please';
10
+ import { killPortProcess } from 'kill-port-process';
9
11
  export const MismatchStateError = new Abort("The state received from the authentication doesn't match the one that initiated the authentication process.");
10
12
  export async function authorize(scopes, state = randomHex(30)) {
11
13
  const port = 3456;
@@ -13,9 +15,9 @@ export async function authorize(scopes, state = randomHex(30)) {
13
15
  const redirectUri = `http://${host}:${port}`;
14
16
  const fqdn = await identityFqdn();
15
17
  const identityClientId = await clientId();
18
+ await validateRedirectionPortAvailability(port);
16
19
  let url = `http://${fqdn}/oauth/authorize`;
17
20
  const { codeVerifier, codeChallenge } = generateRandomChallengePair();
18
- /* eslint-disable @typescript-eslint/naming-convention */
19
21
  const params = {
20
22
  client_id: identityClientId,
21
23
  scope: scopes.join(' '),
@@ -25,7 +27,6 @@ export async function authorize(scopes, state = randomHex(30)) {
25
27
  code_challenge_method: 'S256',
26
28
  code_challenge: codeChallenge,
27
29
  };
28
- /* eslint-enable @typescript-eslint/naming-convention */
29
30
  output.info('\nTo run this command, log in to Shopify Partners.');
30
31
  output.info('👉 Press any key to open the login page on your browser');
31
32
  await keypress();
@@ -37,4 +38,15 @@ export async function authorize(scopes, state = randomHex(30)) {
37
38
  }
38
39
  return { code: result.code, codeVerifier };
39
40
  }
41
+ async function validateRedirectionPortAvailability(port) {
42
+ if (await isPortAvailable(port)) {
43
+ return;
44
+ }
45
+ if (await terminateBlockingPortProcessPrompt(port, 'Authentication')) {
46
+ await killPortProcess(port);
47
+ }
48
+ else {
49
+ throw new CancelExecution();
50
+ }
51
+ }
40
52
  //# sourceMappingURL=authorize.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"authorize.js","sourceRoot":"","sources":["../../src/session/authorize.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,cAAc,EAAC,MAAM,wBAAwB,CAAA;AACrD,OAAO,EAAC,QAAQ,EAAC,MAAM,eAAe,CAAA;AACtC,OAAO,EAAC,2BAA2B,EAAE,SAAS,EAAC,MAAM,cAAc,CAAA;AACnE,OAAO,EAAC,IAAI,EAAC,MAAM,cAAc,CAAA;AACjC,OAAO,EAAC,KAAK,EAAC,MAAM,aAAa,CAAA;AACjC,OAAO,EAAC,QAAQ,IAAI,YAAY,EAAC,MAAM,wBAAwB,CAAA;AAC/D,OAAO,KAAK,MAAM,MAAM,cAAc,CAAA;AACtC,OAAO,EAAC,QAAQ,EAAC,MAAM,UAAU,CAAA;AAEjC,MAAM,CAAC,MAAM,kBAAkB,GAAG,IAAI,KAAK,CACzC,6GAA6G,CAC9G,CAAA;AAOD,MAAM,CAAC,KAAK,UAAU,SAAS,CAAC,MAAgB,EAAE,QAAgB,SAAS,CAAC,EAAE,CAAC;IAC7E,MAAM,IAAI,GAAG,IAAI,CAAA;IACjB,MAAM,IAAI,GAAG,WAAW,CAAA;IACxB,MAAM,WAAW,GAAG,UAAU,IAAI,IAAI,IAAI,EAAE,CAAA;IAC5C,MAAM,IAAI,GAAG,MAAM,YAAY,EAAE,CAAA;IACjC,MAAM,gBAAgB,GAAG,MAAM,QAAQ,EAAE,CAAA;IAEzC,IAAI,GAAG,GAAG,UAAU,IAAI,kBAAkB,CAAA;IAE1C,MAAM,EAAC,YAAY,EAAE,aAAa,EAAC,GAAG,2BAA2B,EAAE,CAAA;IAEnE,yDAAyD;IACzD,MAAM,MAAM,GAAG;QACb,SAAS,EAAE,gBAAgB;QAC3B,KAAK,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC;QACvB,YAAY,EAAE,WAAW;QACzB,KAAK;QACL,aAAa,EAAE,MAAM;QACrB,qBAAqB,EAAE,MAAM;QAC7B,cAAc,EAAE,aAAa;KAC9B,CAAA;IACD,wDAAwD;IAExD,MAAM,CAAC,IAAI,CAAC,oDAAoD,CAAC,CAAA;IACjE,MAAM,CAAC,IAAI,CAAC,yDAAyD,CAAC,CAAA;IACtE,MAAM,QAAQ,EAAE,CAAA;IAEhB,GAAG,GAAG,GAAG,GAAG,IAAI,IAAI,eAAe,CAAC,MAAM,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAA;IACxD,IAAI,CAAC,GAAG,CAAC,CAAA;IAET,MAAM,MAAM,GAAG,MAAM,cAAc,CAAC,IAAI,EAAE,IAAI,EAAE,GAAG,CAAC,CAAA;IAEpD,IAAI,MAAM,CAAC,KAAK,KAAK,KAAK,EAAE;QAC1B,MAAM,kBAAkB,CAAA;KACzB;IAED,OAAO,EAAC,IAAI,EAAE,MAAM,CAAC,IAAI,EAAE,YAAY,EAAC,CAAA;AAC1C,CAAC","sourcesContent":["import {listenRedirect} from './redirect-listener.js'\nimport {clientId} from './identity.js'\nimport {generateRandomChallengePair, randomHex} from '../string.js'\nimport {open} from '../system.js'\nimport {Abort} from '../error.js'\nimport {identity as identityFqdn} from '../environment/fqdn.js'\nimport * as output from '../output.js'\nimport {keypress} from '../ui.js'\n\nexport const MismatchStateError = new Abort(\n \"The state received from the authentication doesn't match the one that initiated the authentication process.\",\n)\n\nexport interface CodeAuthResult {\n code: string\n codeVerifier: string\n}\n\nexport async function authorize(scopes: string[], state: string = randomHex(30)): Promise<CodeAuthResult> {\n const port = 3456\n const host = '127.0.0.1'\n const redirectUri = `http://${host}:${port}`\n const fqdn = await identityFqdn()\n const identityClientId = await clientId()\n\n let url = `http://${fqdn}/oauth/authorize`\n\n const {codeVerifier, codeChallenge} = generateRandomChallengePair()\n\n /* eslint-disable @typescript-eslint/naming-convention */\n const params = {\n client_id: identityClientId,\n scope: scopes.join(' '),\n redirect_uri: redirectUri,\n state,\n response_type: 'code',\n code_challenge_method: 'S256',\n code_challenge: codeChallenge,\n }\n /* eslint-enable @typescript-eslint/naming-convention */\n\n output.info('\\nTo run this command, log in to Shopify Partners.')\n output.info('👉 Press any key to open the login page on your browser')\n await keypress()\n\n url = `${url}?${new URLSearchParams(params).toString()}`\n open(url)\n\n const result = await listenRedirect(host, port, url)\n\n if (result.state !== state) {\n throw MismatchStateError\n }\n\n return {code: result.code, codeVerifier}\n}\n"]}
1
+ {"version":3,"file":"authorize.js","sourceRoot":"","sources":["../../src/session/authorize.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,cAAc,EAAC,MAAM,wBAAwB,CAAA;AACrD,OAAO,EAAC,QAAQ,EAAC,MAAM,eAAe,CAAA;AACtC,OAAO,EAAC,2BAA2B,EAAE,SAAS,EAAC,MAAM,cAAc,CAAA;AACnE,OAAO,EAAC,IAAI,EAAC,MAAM,cAAc,CAAA;AACjC,OAAO,EAAC,KAAK,EAAE,eAAe,EAAC,MAAM,aAAa,CAAA;AAClD,OAAO,EAAC,QAAQ,IAAI,YAAY,EAAC,MAAM,wBAAwB,CAAA;AAC/D,OAAO,KAAK,MAAM,MAAM,cAAc,CAAA;AACt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CAAA;IAET,MAAM,MAAM,GAAG,MAAM,cAAc,CAAC,IAAI,EAAE,IAAI,EAAE,GAAG,CAAC,CAAA;IAEpD,IAAI,MAAM,CAAC,KAAK,KAAK,KAAK,EAAE;QAC1B,MAAM,kBAAkB,CAAA;KACzB;IAED,OAAO,EAAC,IAAI,EAAE,MAAM,CAAC,IAAI,EAAE,YAAY,EAAC,CAAA;AAC1C,CAAC;AAED,KAAK,UAAU,mCAAmC,CAAC,IAAY;IAC7D,IAAI,MAAM,eAAe,CAAC,IAAI,CAAC,EAAE;QAC/B,OAAM;KACP;IAED,IAAI,MAAM,kCAAkC,CAAC,IAAI,EAAE,gBAAgB,CAAC,EAAE;QACpE,MAAM,eAAe,CAAC,IAAI,CAAC,CAAA;KAC5B;SAAM;QACL,MAAM,IAAI,eAAe,EAAE,CAAA;KAC5B;AACH,CAAC","sourcesContent":["import {listenRedirect} from './redirect-listener.js'\nimport {clientId} from './identity.js'\nimport {generateRandomChallengePair, randomHex} from '../string.js'\nimport {open} from '../system.js'\nimport {Abort, CancelExecution} from '../error.js'\nimport {identity as identityFqdn} from '../environment/fqdn.js'\nimport * as output from '../output.js'\nimport {keypress, terminateBlockingPortProcessPrompt} from '../ui.js'\nimport {checkPort as isPortAvailable} from 'get-port-please'\nimport {killPortProcess} from 'kill-port-process'\n\nexport const MismatchStateError = new Abort(\n \"The state received from the authentication doesn't match the one that initiated the authentication process.\",\n)\n\nexport interface CodeAuthResult {\n code: string\n codeVerifier: string\n}\n\nexport async function authorize(scopes: string[], state: string = randomHex(30)): Promise<CodeAuthResult> {\n const port = 3456\n const host = '127.0.0.1'\n const redirectUri = `http://${host}:${port}`\n const fqdn = await identityFqdn()\n const identityClientId = await clientId()\n\n await validateRedirectionPortAvailability(port)\n\n let url = `http://${fqdn}/oauth/authorize`\n\n const {codeVerifier, codeChallenge} = generateRandomChallengePair()\n\n const params = {\n client_id: identityClientId,\n scope: scopes.join(' '),\n redirect_uri: redirectUri,\n state,\n response_type: 'code',\n code_challenge_method: 'S256',\n code_challenge: codeChallenge,\n }\n\n output.info('\\nTo run this command, log in to Shopify Partners.')\n output.info('👉 Press any key to open the login page on your browser')\n await keypress()\n\n url = `${url}?${new URLSearchParams(params).toString()}`\n open(url)\n\n const result = await listenRedirect(host, port, url)\n\n if (result.state !== state) {\n throw MismatchStateError\n }\n\n return {code: result.code, codeVerifier}\n}\n\nasync function validateRedirectionPortAvailability(port: number) {\n if (await isPortAvailable(port)) {\n return\n }\n\n if (await terminateBlockingPortProcessPrompt(port, 'Authentication')) {\n await killPortProcess(port)\n } else {\n throw new CancelExecution()\n }\n}\n"]}
@@ -16,7 +16,6 @@ const InvalidIdentityError = new Abort('\nError validating auth session', "We've
16
16
  */
17
17
  export async function exchangeCodeForAccessToken(codeData) {
18
18
  const clientId = await getIdentityClientId();
19
- /* eslint-disable @typescript-eslint/naming-convention */
20
19
  const params = {
21
20
  grant_type: 'authorization_code',
22
21
  code: codeData.code,
@@ -24,7 +23,6 @@ export async function exchangeCodeForAccessToken(codeData) {
24
23
  client_id: clientId,
25
24
  code_verifier: codeData.codeVerifier,
26
25
  };
27
- /* eslint-enable @typescript-eslint/naming-convention */
28
26
  return tokenRequest(params).then(buildIdentityToken);
29
27
  }
30
28
  /**
@@ -56,14 +54,12 @@ export async function exchangeAccessForApplicationTokens(identityToken, scopes,
56
54
  */
57
55
  export async function refreshAccessToken(currentToken) {
58
56
  const clientId = await getIdentityClientId();
59
- /* eslint-disable @typescript-eslint/naming-convention */
60
57
  const params = {
61
58
  grant_type: 'refresh_token',
62
59
  access_token: currentToken.accessToken,
63
60
  refresh_token: currentToken.refreshToken,
64
61
  client_id: clientId,
65
62
  };
66
- /* eslint-enable @typescript-eslint/naming-convention */
67
63
  return tokenRequest(params).then(buildIdentityToken);
68
64
  }
69
65
  /**
@@ -80,7 +76,6 @@ export async function exchangeCustomPartnerToken(token) {
80
76
  async function requestAppToken(api, token, scopes = [], store) {
81
77
  const appId = applicationId(api);
82
78
  const clientId = await getIdentityClientId();
83
- /* eslint-disable @typescript-eslint/naming-convention */
84
79
  const params = {
85
80
  grant_type: 'urn:ietf:params:oauth:grant-type:token-exchange',
86
81
  requested_token_type: 'urn:ietf:params:oauth:token-type:access_token',
@@ -91,7 +86,6 @@ async function requestAppToken(api, token, scopes = [], store) {
91
86
  subject_token: token,
92
87
  ...(api === 'admin' && { destination: `https://${store}/admin` }),
93
88
  };
94
- /* eslint-enable @typescript-eslint/naming-convention */
95
89
  let identifier = appId;
96
90
  if (api === 'admin' && store) {
97
91
  identifier = `${store}-${appId}`;