@shopify/cli-kit 3.4.0 → 3.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (73) hide show
  1. package/CHANGELOG.md +15 -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/constants.js +0 -2
  15. package/dist/constants.js.map +1 -1
  16. package/dist/file.d.ts +1 -1
  17. package/dist/file.js +1 -1
  18. package/dist/file.js.map +1 -1
  19. package/dist/git.js +0 -1
  20. package/dist/git.js.map +1 -1
  21. package/dist/haiku.d.ts +6 -1
  22. package/dist/haiku.js +67 -6
  23. package/dist/haiku.js.map +1 -1
  24. package/dist/index.d.ts +2 -0
  25. package/dist/index.js +2 -0
  26. package/dist/index.js.map +1 -1
  27. package/dist/json.d.ts +6 -0
  28. package/dist/json.js +2 -0
  29. package/dist/json.js.map +1 -0
  30. package/dist/metadata.d.ts +51 -0
  31. package/dist/metadata.js +29 -0
  32. package/dist/metadata.js.map +1 -0
  33. package/dist/monorail.d.ts +38 -0
  34. package/dist/monorail.js +38 -0
  35. package/dist/monorail.js.map +1 -0
  36. package/dist/node/archiver.d.ts +4 -1
  37. package/dist/node/archiver.js +22 -13
  38. package/dist/node/archiver.js.map +1 -1
  39. package/dist/node/base-command.js +1 -1
  40. package/dist/node/base-command.js.map +1 -1
  41. package/dist/node/error-handler.d.ts +3 -1
  42. package/dist/node/error-handler.js +24 -5
  43. package/dist/node/error-handler.js.map +1 -1
  44. package/dist/node/hooks/postrun.js +3 -3
  45. package/dist/node/hooks/postrun.js.map +1 -1
  46. package/dist/output.js +0 -2
  47. package/dist/output.js.map +1 -1
  48. package/dist/path.d.ts +3 -3
  49. package/dist/path.js +2 -4
  50. package/dist/path.js.map +1 -1
  51. package/dist/plugins.d.ts +38 -2
  52. package/dist/plugins.js +11 -0
  53. package/dist/plugins.js.map +1 -1
  54. package/dist/session/authorize.js +16 -4
  55. package/dist/session/authorize.js.map +1 -1
  56. package/dist/session/exchange.js +0 -6
  57. package/dist/session/exchange.js.map +1 -1
  58. package/dist/store.js +0 -2
  59. package/dist/store.js.map +1 -1
  60. package/dist/string.d.ts +4 -0
  61. package/dist/string.js +13 -0
  62. package/dist/string.js.map +1 -1
  63. package/dist/tsconfig.tsbuildinfo +1 -1
  64. package/dist/typing/overloaded-parameters.d.ts +6 -0
  65. package/dist/typing/overloaded-parameters.js +2 -0
  66. package/dist/typing/overloaded-parameters.js.map +1 -0
  67. package/dist/typing/simple-definitions.d.ts +4 -0
  68. package/dist/typing/simple-definitions.js +2 -0
  69. package/dist/typing/simple-definitions.js.map +1 -0
  70. package/dist/ui.d.ts +1 -0
  71. package/dist/ui.js +22 -0
  72. package/dist/ui.js.map +1 -1
  73. package/package.json +28 -23
package/dist/haiku.js CHANGED
@@ -1,8 +1,69 @@
1
- import Haikunator from 'haikunator';
2
- const haikunator = new Haikunator();
3
- export function generate(suffix) {
4
- const generated = haikunator.haikunate();
5
- const [adjective, noun, token] = generated.split('-');
6
- return [adjective, noun, suffix, token].join('-');
1
+ import { randomPick } from './array.js';
2
+ import { exists } from './file.js';
3
+ import { join } from './path.js';
4
+ export const SAFE_ADJECTIVES = [
5
+ 'commercial',
6
+ 'profitable',
7
+ 'amortizable',
8
+ 'branded',
9
+ 'integrated',
10
+ 'synergistic',
11
+ 'consolidated',
12
+ 'diversified',
13
+ 'lean',
14
+ 'niche',
15
+ 'premium',
16
+ 'luxury',
17
+ 'scalable',
18
+ 'optimized',
19
+ 'empowered',
20
+ 'international',
21
+ 'beneficial',
22
+ 'fruitful',
23
+ 'extensive',
24
+ 'lucrative',
25
+ 'modern',
26
+ ];
27
+ export const SAFE_NOUNS = [
28
+ 'account',
29
+ 'consumer',
30
+ 'customer',
31
+ 'enterprise',
32
+ 'business',
33
+ 'venture',
34
+ 'marketplace',
35
+ 'revenue',
36
+ 'vertical',
37
+ 'portfolio',
38
+ 'negotiation',
39
+ 'shipping',
40
+ 'demand',
41
+ 'supply',
42
+ 'growth',
43
+ 'merchant',
44
+ 'investment',
45
+ 'shareholder',
46
+ 'conversion',
47
+ 'capital',
48
+ 'projection',
49
+ 'upside',
50
+ 'trade',
51
+ 'deal',
52
+ 'merchandise',
53
+ 'transaction',
54
+ 'sale',
55
+ ];
56
+ function generateRandomName() {
57
+ return `${randomPick(SAFE_ADJECTIVES)}-${randomPick(SAFE_NOUNS)}`;
58
+ }
59
+ export async function generate({ suffix, directory }) {
60
+ const generated = `${generateRandomName()}-${suffix}`;
61
+ const isAppDirectoryTaken = await exists(join(directory, generated));
62
+ if (isAppDirectoryTaken) {
63
+ return generate({ suffix, directory });
64
+ }
65
+ else {
66
+ return generated;
67
+ }
7
68
  }
8
69
  //# sourceMappingURL=haiku.js.map
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;AAEnC,MAAM,UAAU,GAAG,IAAI,UAAU,EAAE,CAAA;AAEnC,MAAM,UAAU,QAAQ,CAAC,MAAc;IACrC,MAAM,SAAS,GAAG,UAAU,CAAC,SAAS,EAAE,CAAA;IACxC,MAAM,CAAC,SAAS,EAAE,IAAI,EAAE,KAAK,CAAC,GAAG,SAAS,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;IACrD,OAAO,CAAC,SAAS,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;AACnD,CAAC","sourcesContent":["import Haikunator from 'haikunator'\n\nconst haikunator = new Haikunator()\n\nexport function generate(suffix: string): string {\n const generated = haikunator.haikunate()\n const [adjective, noun, token] = generated.split('-')\n return [adjective, noun, suffix, token].join('-')\n}\n"]}
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/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
@@ -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;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,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
  */
@@ -1,24 +1,33 @@
1
1
  import { debug, content, token } from '../output.js';
2
- import { zip as crossZip } from 'cross-zip';
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 cwd = process.cwd();
11
- process.chdir(inputDirectory);
12
- await new Promise((resolve, reject) => {
13
- crossZip('./', outputZipPath, (error) => {
14
- process.chdir(cwd);
15
- if (error) {
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,GAAG,IAAI,QAAQ,EAAC,MAAM,WAAW,CAAA;AAEzC;;;;GAIG;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,GAAG,GAAG,OAAO,CAAC,GAAG,EAAE,CAAA;IACzB,OAAO,CAAC,KAAK,CAAC,cAAc,CAAC,CAAA;IAE7B,MAAM,IAAI,OAAO,CAAO,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QAC1C,QAAQ,CAAC,IAAI,EAAE,aAAa,EAAE,CAAC,KAAK,EAAE,EAAE;YACtC,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;YAClB,IAAI,KAAK,EAAE;gBACT,MAAM,CAAC,KAAK,CAAC,CAAA;aACd;iBAAM;gBACL,OAAO,EAAE,CAAA;aACV;QACH,CAAC,CAAC,CAAA;IACJ,CAAC,CAAC,CAAA;AACJ,CAAC","sourcesContent":["import {debug, content, token} from '../output.js'\nimport {zip as crossZip} from 'cross-zip'\n\n/**\n * It zips a directory.\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 cwd = process.cwd()\n process.chdir(inputDirectory)\n\n await new Promise<void>((resolve, reject) => {\n crossZip('./', outputZipPath, (error) => {\n process.chdir(cwd)\n if (error) {\n reject(error)\n } else {\n resolve()\n }\n })\n })\n}\n"]}
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;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,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"]}
@@ -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,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AAA;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;AAChD,OAAO,WAAW,MAAM,aAAa,CAAA;AACrC,OAAO,OAAgB,MAAM,aAAa,CAAA;AAC1C,OAAO,EAAC,QAAQ,EAAC,MAAM,aAAa,CAAA;AAEpC,MAAM,UAAU,YAAY,CAAC,KAA8C,EAAE,MAA0B;IACrG,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,CA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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/output.js CHANGED
@@ -10,8 +10,6 @@ import { colors } from './node/colors.js';
10
10
  import terminalLink from 'terminal-link';
11
11
  import StackTracey from 'stacktracey';
12
12
  import { AbortController } from 'abort-controller';
13
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
14
- // @ts-ignore
15
13
  import cjs from 'color-json';
16
14
  import stripAnsi from 'strip-ansi';
17
15
  import { Writable } from 'node:stream';