@shopify/cli-kit 3.28.0 → 3.30.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 (106) hide show
  1. package/dist/api/admin.js +5 -11
  2. package/dist/api/admin.js.map +1 -1
  3. package/dist/api/common.d.ts +1 -1
  4. package/dist/api/common.js +7 -4
  5. package/dist/api/common.js.map +1 -1
  6. package/dist/api/graphql/find_org.js +2 -2
  7. package/dist/api/graphql/find_org.js.map +1 -1
  8. package/dist/api/identity.js +14 -4
  9. package/dist/api/identity.js.map +1 -1
  10. package/dist/api/partners.d.ts +0 -6
  11. package/dist/api/partners.js +0 -32
  12. package/dist/api/partners.js.map +1 -1
  13. package/dist/http/fetch.js +13 -0
  14. package/dist/http/fetch.js.map +1 -1
  15. package/dist/index.d.ts +0 -1
  16. package/dist/index.js +0 -1
  17. package/dist/index.js.map +1 -1
  18. package/dist/metadata.d.ts +2 -2
  19. package/dist/output.js +1 -3
  20. package/dist/output.js.map +1 -1
  21. package/dist/path.d.ts +4 -1
  22. package/dist/path.js +9 -1
  23. package/dist/path.js.map +1 -1
  24. package/dist/private/node/ui/components/Command.js.map +1 -1
  25. package/dist/private/node/ui/components/ConcurrentOutput.js +5 -1
  26. package/dist/private/node/ui/components/ConcurrentOutput.js.map +1 -1
  27. package/dist/{testing/fixtures/render-concurrent.d.ts → private/node/ui/components/ConcurrentOutput.test.d.ts} +0 -0
  28. package/dist/private/node/ui/components/ConcurrentOutput.test.js +53 -0
  29. package/dist/private/node/ui/components/ConcurrentOutput.test.js.map +1 -0
  30. package/dist/private/node/ui/components/FullScreen.js +2 -2
  31. package/dist/private/node/ui/components/FullScreen.js.map +1 -1
  32. package/dist/private/node/ui/components/Link.js.map +1 -1
  33. package/dist/private/node/ui/components/Prompt.d.ts +10 -0
  34. package/dist/private/node/ui/components/Prompt.js +23 -0
  35. package/dist/private/node/ui/components/Prompt.js.map +1 -0
  36. package/dist/private/node/ui/components/Prompt.test.d.ts +1 -0
  37. package/dist/private/node/ui/components/Prompt.test.js +71 -0
  38. package/dist/private/node/ui/components/Prompt.test.js.map +1 -0
  39. package/dist/private/node/ui/components/SelectInput.d.ts +12 -0
  40. package/dist/private/node/ui/components/SelectInput.js +93 -0
  41. package/dist/private/node/ui/components/SelectInput.js.map +1 -0
  42. package/dist/private/node/ui/components/SelectInput.test.d.ts +1 -0
  43. package/dist/private/node/ui/components/SelectInput.test.js +200 -0
  44. package/dist/private/node/ui/components/SelectInput.test.js.map +1 -0
  45. package/dist/private/node/ui/components/Table.d.ts +8 -0
  46. package/dist/private/node/ui/components/Table.js +17 -0
  47. package/dist/private/node/ui/components/Table.js.map +1 -0
  48. package/dist/private/node/ui/components/TextAnimation.js +1 -1
  49. package/dist/private/node/ui/components/TextAnimation.js.map +1 -1
  50. package/dist/private/node/ui.d.ts +2 -0
  51. package/dist/private/node/ui.js +14 -0
  52. package/dist/private/node/ui.js.map +1 -1
  53. package/dist/public/common/array.d.ts +1 -1
  54. package/dist/public/common/array.js.map +1 -1
  55. package/dist/public/node/base-command.d.ts +2 -2
  56. package/dist/public/node/base-command.js +2 -4
  57. package/dist/public/node/base-command.js.map +1 -1
  58. package/dist/public/node/checksum.d.ts +1 -1
  59. package/dist/public/node/checksum.js +1 -1
  60. package/dist/public/node/checksum.js.map +1 -1
  61. package/dist/public/node/cli.js.map +1 -1
  62. package/dist/public/node/dot-env.js.map +1 -1
  63. package/dist/public/node/error-handler.d.ts +5 -1
  64. package/dist/public/node/error-handler.js.map +1 -1
  65. package/dist/public/node/framework.js.map +1 -1
  66. package/dist/public/node/hooks/prerun.js.map +1 -1
  67. package/dist/public/node/node-package-manager.d.ts +1 -0
  68. package/dist/public/node/node-package-manager.js.map +1 -1
  69. package/dist/public/node/ruby.js +2 -2
  70. package/dist/public/node/ruby.js.map +1 -1
  71. package/dist/public/node/ui.d.ts +42 -0
  72. package/dist/public/node/ui.js +60 -6
  73. package/dist/public/node/ui.js.map +1 -1
  74. package/dist/session/exchange.js +4 -2
  75. package/dist/session/exchange.js.map +1 -1
  76. package/dist/session/validate.js +3 -13
  77. package/dist/session/validate.js.map +1 -1
  78. package/dist/session.d.ts +1 -1
  79. package/dist/session.js +3 -1
  80. package/dist/session.js.map +1 -1
  81. package/dist/string.d.ts +1 -0
  82. package/dist/string.js +3 -0
  83. package/dist/string.js.map +1 -1
  84. package/dist/system.d.ts +2 -2
  85. package/dist/system.js +17 -2
  86. package/dist/system.js.map +1 -1
  87. package/dist/testing/ui.d.ts +4 -8
  88. package/dist/testing/ui.js +17 -17
  89. package/dist/testing/ui.js.map +1 -1
  90. package/dist/tsconfig.tsbuildinfo +1 -1
  91. package/dist/ui/executor.js +7 -5
  92. package/dist/ui/executor.js.map +1 -1
  93. package/dist/ui/inquirer/autocomplete.js +13 -4
  94. package/dist/ui/inquirer/autocomplete.js.map +1 -1
  95. package/dist/ui.d.ts +6 -0
  96. package/dist/ui.js +0 -11
  97. package/dist/ui.js.map +1 -1
  98. package/package.json +35 -6
  99. package/dist/log.d.ts +0 -30
  100. package/dist/log.js +0 -169
  101. package/dist/log.js.map +0 -1
  102. package/dist/private/node/ui/error.d.ts +0 -2
  103. package/dist/private/node/ui/error.js +0 -8
  104. package/dist/private/node/ui/error.js.map +0 -1
  105. package/dist/testing/fixtures/render-concurrent.js +0 -26
  106. package/dist/testing/fixtures/render-concurrent.js.map +0 -1
package/dist/api/admin.js CHANGED
@@ -3,16 +3,6 @@ import { debug, content, token as outputToken } from '../output.js';
3
3
  import { Bug, Abort } from '../error.js';
4
4
  import { graphqlClient } from '../http/graphql.js';
5
5
  import { gql } from 'graphql-request';
6
- const UnauthorizedAccessError = (store) => {
7
- const adminLink = outputToken.link(`URL`, `https://${store}/admin`);
8
- const storeName = store.replace('.myshopify.com', '');
9
- return new Abort(content `Looks like you need access to this dev store (${outputToken.link(storeName, `https://${store}`)})`, content `• Log in to the store directly from this ${adminLink}. If you're the store owner, then that direct log in should solve your access issue.
10
- • If you're not the owner, create a dev store staff account for yourself. Then log in directly from the link above.
11
- `);
12
- };
13
- const UnknownError = () => {
14
- return new Bug(`Unknown error connecting to your store`);
15
- };
16
6
  export async function request(query, session, variables) {
17
7
  const api = 'Admin';
18
8
  return handlingErrors(api, async () => {
@@ -37,7 +27,11 @@ ${query}
37
27
  const data = await client
38
28
  .request(query, {})
39
29
  .catch((err) => {
40
- throw err.response.status === 403 ? UnauthorizedAccessError(session.storeFqdn) : UnknownError();
30
+ if (err.response.status === 403) {
31
+ const storeName = session.storeFqdn.replace('.myshopify.com', '');
32
+ throw new Abort(content `Looks like you don't have access this dev store: (${outputToken.link(storeName, `https://${session.storeFqdn}`)})`, content `If you're not the owner, create a dev store staff account for yourself`);
33
+ }
34
+ throw new Bug(`Unknown error connecting to your store`);
41
35
  });
42
36
  return data.publicApiVersions
43
37
  .filter((item) => item.supported)
@@ -1 +1 @@
1
- {"version":3,"file":"admin.js","sourceRoot":"","sources":["../../src/api/admin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,YAAY,EAAE,eAAe,EAAE,cAAc,EAAC,MAAM,aAAa,CAAA;AAEzE,OAAO,EAAC,KAAK,EAAE,OAAO,EAAE,KAAK,IAAI,WAAW,EAAC,MAAM,cAAc,CAAA;AACjE,OAAO,EAAC,GAAG,EAAE,KAAK,EAAC,MAAM,aAAa,CAAA;AACtC,OAAO,EAAC,aAAa,EAAC,MAAM,oBAAoB,CAAA;AAChD,OAAO,EAAC,GAAG,EAA6B,MAAM,iBAAiB,CAAA;AAE/D,MAAM,uBAAuB,GAAG,CAAC,KAAa,EAAE,EAAE;IAChD,MAAM,SAAS,GAAG,WAAW,CAAC,IAAI,CAAC,KAAK,EAAE,WAAW,KAAK,QAAQ,CAAC,CAAA;IACnE,MAAM,SAAS,GAAG,KAAK,CAAC,OAAO,CAAC,gBAAgB,EAAE,EAAE,CAAC,CAAA;IACrD,OAAO,IAAI,KAAK,CACd,OAAO,CAAA,iDAAiD,WAAW,CAAC,IAAI,CAAC,SAAS,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+B,GAAG;EACxC,KAAK;GACJ,CAAC,CAAA;IACF,MAAM,IAAI,GAAG,MAAM,MAAM;SACtB,OAAO,CAEL,KAAK,EAAE,EAAE,CAAC;SACZ,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE;QACb,MAAM,GAAG,CAAC,QAAQ,CAAC,MAAM,KAAK,GAAG,CAAC,CAAC,CAAC,uBAAuB,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,YAAY,EAAE,CAAA;IACjG,CAAC,CAAC,CAAA;IAEJ,OAAO,IAAI,CAAC,iBAAiB;SAC1B,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC;SAChC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC;SAC1B,IAAI,EAAE;SACN,OAAO,EAAE,CAAC,CAAC,CAAE,CAAA;AAClB,CAAC;AAED,SAAS,QAAQ,CAAC,KAAa,EAAE,OAA2B;IAC1D,MAAM,WAAW,GAAG,OAAO,IAAI,UAAU,CAAA;IACzC,OAAO,WAAW,KAAK,cAAc,WAAW,eAAe,CAAA;AACjE,CAAC;AAED,SAAS,eAAe;IACtB,OAAO,GAAG,CAAA;;;;;;;GAOT,CAAA;AACH,CAAC","sourcesContent":["import {buildHeaders, debugLogRequest, handlingErrors} from './common.js'\nimport {AdminSession} from '../session.js'\nimport {debug, content, token as outputToken} from '../output.js'\nimport {Bug, Abort} from '../error.js'\nimport {graphqlClient} from '../http/graphql.js'\nimport {gql, RequestDocument, Variables} from 'graphql-request'\n\nconst UnauthorizedAccessError = (store: string) => {\n const adminLink = outputToken.link(`URL`, `https://${store}/admin`)\n const storeName = store.replace('.myshopify.com', '')\n return new Abort(\n content`Looks like you need access to this dev store (${outputToken.link(storeName, `https://${store}`)})`,\n content`• Log in to the store directly from this ${adminLink}. If you're the store owner, then that direct log in should solve your access issue.\n• If you're not the owner, create a dev store staff account for yourself. Then log in directly from the link above.\n `,\n )\n}\n\nconst UnknownError = () => {\n return new Bug(`Unknown error connecting to your store`)\n}\n\nexport async function request<T>(query: RequestDocument, session: AdminSession, variables?: Variables): Promise<T> {\n const api = 'Admin'\n return handlingErrors(api, async () => {\n const version = await fetchApiVersion(session)\n const url = adminUrl(session.storeFqdn, version)\n const headers = await buildHeaders(session.token)\n const client = await graphqlClient({headers, url})\n debugLogRequest(api, query, variables, headers)\n const response = await client.request<T>(query, variables)\n return response\n })\n}\n\nasync function fetchApiVersion(session: AdminSession): Promise<string> {\n const url = adminUrl(session.storeFqdn, 'unstable')\n const query = apiVersionQuery()\n const headers = await buildHeaders(session.token)\n const client = await graphqlClient({url, headers})\n debug(`\nSending Admin GraphQL request to URL ${url} with query:\n${query}\n `)\n const data = await client\n .request<{\n publicApiVersions: {handle: string; supported: boolean}[]\n }>(query, {})\n .catch((err) => {\n throw err.response.status === 403 ? UnauthorizedAccessError(session.storeFqdn) : UnknownError()\n })\n\n return data.publicApiVersions\n .filter((item) => item.supported)\n .map((item) => item.handle)\n .sort()\n .reverse()[0]!\n}\n\nfunction adminUrl(store: string, version: string | undefined): string {\n const realVersion = version || 'unstable'\n return `https://${store}/admin/api/${realVersion}/graphql.json`\n}\n\nfunction apiVersionQuery(): string {\n return gql`\n query {\n publicApiVersions {\n handle\n supported\n }\n }\n `\n}\n"]}
1
+ {"version":3,"file":"admin.js","sourceRoot":"","sources":["../../src/api/admin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,YAAY,EAAE,eAAe,EAAE,cAAc,EAAC,MAAM,aAAa,CAAA;AAEzE,OAAO,EAAC,KAAK,EAAE,OAAO,EAAE,KAAK,IAAI,WAAW,EAAC,MAAM,cAAc,CAAA;AACjE,OAAO,EAAC,GAAG,EAAE,KAAK,EAAC,MAAM,aAAa,CAAA;AACtC,OAAO,EAAC,aAAa,EAAC,MAAM,oBAAoB,CAAA;AAChD,OAAO,EAAC,GAAG,EAA6B,MAAM,iBAAiB,CAAA;AAE/D,M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E;YAC/B,MAAM,SAAS,GAAG,OAAO,CAAC,SAAS,CAAC,OAAO,CAAC,gBAAgB,EAAE,EAAE,CAAC,CAAA;YACjE,MAAM,IAAI,KAAK,CACb,OAAO,CAAA,qDAAqD,WAAW,CAAC,IAAI,CAC1E,SAAS,EACT,WAAW,OAAO,CAAC,SAAS,EAAE,CAC/B,GAAG,EACJ,OAAO,CAAA,wEAAwE,CAChF,CAAA;SACF;QACD,MAAM,IAAI,GAAG,CAAC,wCAAwC,CAAC,CAAA;IACzD,CAAC,CAAC,CAAA;IAEJ,OAAO,IAAI,CAAC,iBAAiB;SAC1B,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC;SAChC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC;SAC1B,IAAI,EAAE;SACN,OAAO,EAAE,CAAC,CAAC,CAAE,CAAA;AAClB,CAAC;AAED,SAAS,QAAQ,CAAC,KAAa,EAAE,OAA2B;IAC1D,MAAM,WAAW,GAAG,OAAO,IAAI,UAAU,CAAA;IACzC,OAAO,WAAW,KAAK,cAAc,WAAW,eAAe,CAAA;AACjE,CAAC;AAED,SAAS,eAAe;IACtB,OAAO,GAAG,CAAA;;;;;;;GAOT,CAAA;AACH,CAAC","sourcesContent":["import {buildHeaders, debugLogRequest, handlingErrors} from './common.js'\nimport {AdminSession} from '../session.js'\nimport {debug, content, token as outputToken} from '../output.js'\nimport {Bug, Abort} from '../error.js'\nimport {graphqlClient} from '../http/graphql.js'\nimport {gql, RequestDocument, Variables} from 'graphql-request'\n\nexport async function request<T>(query: RequestDocument, session: AdminSession, variables?: Variables): Promise<T> {\n const api = 'Admin'\n return handlingErrors(api, async () => {\n const version = await fetchApiVersion(session)\n const url = adminUrl(session.storeFqdn, version)\n const headers = await buildHeaders(session.token)\n const client = await graphqlClient({headers, url})\n debugLogRequest(api, query, variables, headers)\n const response = await client.request<T>(query, variables)\n return response\n })\n}\n\nasync function fetchApiVersion(session: AdminSession): Promise<string> {\n const url = adminUrl(session.storeFqdn, 'unstable')\n const query = apiVersionQuery()\n const headers = await buildHeaders(session.token)\n const client = await graphqlClient({url, headers})\n debug(`\nSending Admin GraphQL request to URL ${url} with query:\n${query}\n `)\n const data = await client\n .request<{\n publicApiVersions: {handle: string; supported: boolean}[]\n }>(query, {})\n .catch((err) => {\n if (err.response.status === 403) {\n const storeName = session.storeFqdn.replace('.myshopify.com', '')\n throw new Abort(\n content`Looks like you don't have access this dev store: (${outputToken.link(\n storeName,\n `https://${session.storeFqdn}`,\n )})`,\n content`If you're not the owner, create a dev store staff account for yourself`,\n )\n }\n throw new Bug(`Unknown error connecting to your store`)\n })\n\n return data.publicApiVersions\n .filter((item) => item.supported)\n .map((item) => item.handle)\n .sort()\n .reverse()[0]!\n}\n\nfunction adminUrl(store: string, version: string | undefined): string {\n const realVersion = version || 'unstable'\n return `https://${store}/admin/api/${realVersion}/graphql.json`\n}\n\nfunction apiVersionQuery(): string {\n return gql`\n query {\n publicApiVersions {\n handle\n supported\n }\n }\n `\n}\n"]}
@@ -4,7 +4,7 @@ export declare class RequestClientError extends ExtendableError {
4
4
  statusCode: number;
5
5
  constructor(message: string, statusCode: number);
6
6
  }
7
- export declare function buildHeaders(token: string): Promise<{
7
+ export declare function buildHeaders(token?: string): Promise<{
8
8
  [key: string]: string;
9
9
  }>;
10
10
  /**
@@ -17,11 +17,14 @@ export async function buildHeaders(token) {
17
17
  // 'Sec-CH-UA': secCHUA, This header requires the Git sha.
18
18
  'Sec-CH-UA-PLATFORM': process.platform,
19
19
  'X-Request-Id': randomUUID(),
20
- authorization: `Bearer ${token}`,
21
- 'X-Shopify-Access-Token': `Bearer ${token}`,
22
20
  'Content-Type': 'application/json',
23
21
  ...(firstPartyDev() && { 'X-Shopify-Cli-Employee': '1' }),
24
22
  };
23
+ if (token) {
24
+ // eslint-disable-next-line dot-notation
25
+ headers['authorization'] = `Bearer ${token}`;
26
+ headers['X-Shopify-Access-Token'] = `Bearer ${token}`;
27
+ }
25
28
  return headers;
26
29
  }
27
30
  /**
@@ -44,9 +47,9 @@ export function sanitizedHeadersOutput(headers) {
44
47
  .join('\n');
45
48
  }
46
49
  export function debugLogRequest(api, query, variables, headers = {}) {
47
- debug(`
50
+ debug(content `
48
51
  Sending ${token.json(api)} GraphQL request:
49
- ${query}
52
+ ${token.raw(query.toString())}
50
53
 
51
54
  With variables:
52
55
  ${variables ? JSON.stringify(variables, null, 2) : ''}
@@ -1 +1 @@
1
- {"version":3,"file":"common.js","sourceRoot":"","sources":["../../src/api/common.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,aAAa,EAAC,MAAM,yBAAyB,CAAA;AACrD,OAAO,SAAS,MAAM,iBAAiB,CAAA;AACvC,OAAO,EAAC,gBAAgB,EAAE,OAAO,EAAE,KAAK,IAAI,WAAW,EAAE,KAAK,EAAE,KAAK,EAAC,MAAM,cAAc,CAAA;AAC1F,OAAO,EAAC,KAAK,EAAE,eAAe,EAAC,MAAM,aAAa,CAAA;AAClD,OAAO,EAAC,WAAW,EAA6B,MAAM,iBAAiB,CAAA;AACvE,OAAO,EAAC,UAAU,EAAC,MAAM,QAAQ,CAAA;AAEjC,MAAM,OAAO,kBAAmB,SAAQ,eAAe;IAErD,YAAmB,OAAe,EAAE,UAAkB;QACpD,KAAK,CAAC,OAAO,CAAC,CAAA;QACd,IAAI,CAAC,UAAU,GAAG,UAAU,CAAA;IAC9B,CAAC;CACF;AAED,MAAM,CAAC,KAAK,UAAU,YAAY,CAAC,KAAa;IAC9C,MAAM,SAAS,GAAG,kBAAkB,MAAM,SAAS,CAAC,QAAQ,CAAC,MAAM,EAAE,EAAE,CAAA;IAEvE,MAAM,OAAO,GAAG;QACd,YAAY,EAAE,SAAS;QACvB,0DAA0D;QAC1D,oBAAoB,EAAE,OAAO,CAAC,QAAQ;QACtC,cAAc,EAAE,UAAU,EAAE;QAC5B,aAAa,EAAE,UAAU,KAAK,EAAE;QAChC,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AC,KAAK,UAAU,cAAc,CAAI,GAAW,EAAE,MAAwB;IAC3E,IAAI;QACF,OAAO,MAAM,MAAM,EAAE,CAAA;KACtB;IAAC,OAAO,KAAK,EAAE;QACd,IAAI,KAAK,YAAY,WAAW,EAAE;YAChC,MAAM,YAAY,GAAG,gBAAgB,CAAC,OAAO,CAAA;QAC3C,KAAK,CAAC,GAAG,CACb,GAAG,CACJ,8DAA8D,GAAG,KAAK,CAAC,QAAQ,CAAC,MAAM,EAAE;;IAEvF,WAAW,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC;OACpC,CAAC,CAAA;YACF,IAAI,WAAkB,CAAA;YACtB,IAAI,KAAK,CAAC,QAAQ,CAAC,MAAM,GAAG,GAAG,EAAE;gBAC/B,WAAW,GAAG,IAAI,kBAAkB,CAAC,YAAY,EAAE,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAA;aAC1E;iBAAM;gBACL,WAAW,GAAG,IAAI,KAAK,CAAC,YAAY,CAAC,CAAA;aACtC;YACD,WAAW,CAAC,KAAK,GAAG,KAAK,CAAC,KAAK,CAAA;YAC/B,MAAM,WAAW,CAAA;SAClB;aAAM;YACL,MAAM,KAAK,CAAA;SACZ;KACF;AACH,CAAC","sourcesContent":["import {firstPartyDev} from '../environment/local.js'\nimport constants from '../constants.js'\nimport {stringifyMessage, content, token as outputToken, token, debug} from '../output.js'\nimport {Abort, ExtendableError} from '../error.js'\nimport {ClientError, RequestDocument, Variables} from 'graphql-request'\nimport {randomUUID} from 'crypto'\n\nexport class RequestClientError extends ExtendableError {\n statusCode: number\n public constructor(message: string, statusCode: number) {\n super(message)\n this.statusCode = statusCode\n }\n}\n\nexport async function buildHeaders(token: string): Promise<{[key: string]: string}> {\n const userAgent = `Shopify CLI; v=${await constants.versions.cliKit()}`\n\n const headers = {\n 'User-Agent': userAgent,\n // 'Sec-CH-UA': secCHUA, This header requires the Git sha.\n 'Sec-CH-UA-PLATFORM': process.platform,\n 'X-Request-Id': randomUUID(),\n authorization: `Bearer ${token}`,\n 'X-Shopify-Access-Token': `Bearer ${token}`,\n 'Content-Type': 'application/json',\n ...(firstPartyDev() && {'X-Shopify-Cli-Employee': '1'}),\n }\n\n return headers\n}\n\n/**\n * Removes the sensitive data from the headers and outputs them as a string.\n * @param headers - HTTP headers.\n * @returns A sanitized version of the headers as a string.\n */\nexport function sanitizedHeadersOutput(headers: {[key: string]: string}): string {\n const sanitized: {[key: string]: string} = {}\n const keywords = ['token', 'authorization']\n Object.keys(headers).forEach((header) => {\n if (keywords.find((keyword) => header.toLocaleLowerCase().includes(keyword)) === undefined) {\n sanitized[header] = headers[header]!\n }\n })\n return Object.keys(sanitized)\n .map((header) => {\n return ` - ${header}: ${sanitized[header]}`\n })\n .join('\\n')\n}\n\nexport function debugLogRequest<T>(\n api: string,\n query: RequestDocument,\n variables?: Variables,\n headers: {[key: string]: string} = {},\n) {\n debug(`\nSending ${token.json(api)} GraphQL request:\n${query}\n\nWith variables:\n${variables ? JSON.stringify(variables, null, 2) : ''}\n\nAnd headers:\n${sanitizedHeadersOutput(headers)}\n`)\n}\n\nexport async function handlingErrors<T>(api: string, action: () => Promise<T>): Promise<T> {\n try {\n return await action()\n } catch (error) {\n if (error instanceof ClientError) {\n const errorMessage = stringifyMessage(content`\n The ${token.raw(\n api,\n )} GraphQL API responded unsuccessfully with the HTTP status ${`${error.response.status}`} and errors:\n\n ${outputToken.json(error.response.errors)}\n `)\n let mappedError: Error\n if (error.response.status < 500) {\n mappedError = new RequestClientError(errorMessage, error.response.status)\n } else {\n mappedError = new Abort(errorMessage)\n }\n mappedError.stack = error.stack\n throw mappedError\n } else {\n throw error\n }\n }\n}\n"]}
1
+ {"version":3,"file":"common.js","sourceRoot":"","sources":["../../src/api/common.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,aAAa,EAAC,MAAM,yBAAyB,CAAA;AACrD,OAAO,SAAS,MAAM,iBAAiB,CAAA;AACvC,OAAO,EAAC,gBAAg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AC,QAAQ,CAAC,MAAM,CAAC;OACpC,CAAC,CAAA;YACF,IAAI,WAAkB,CAAA;YACtB,IAAI,KAAK,CAAC,QAAQ,CAAC,MAAM,GAAG,GAAG,EAAE;gBAC/B,WAAW,GAAG,IAAI,kBAAkB,CAAC,YAAY,EAAE,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAA;aAC1E;iBAAM;gBACL,WAAW,GAAG,IAAI,KAAK,CAAC,YAAY,CAAC,CAAA;aACtC;YACD,WAAW,CAAC,KAAK,GAAG,KAAK,CAAC,KAAK,CAAA;YAC/B,MAAM,WAAW,CAAA;SAClB;aAAM;YACL,MAAM,KAAK,CAAA;SACZ;KACF;AACH,CAAC","sourcesContent":["import {firstPartyDev} from '../environment/local.js'\nimport constants from '../constants.js'\nimport {stringifyMessage, content, token as outputToken, token, debug} from '../output.js'\nimport {Abort, ExtendableError} from '../error.js'\nimport {ClientError, RequestDocument, Variables} from 'graphql-request'\nimport {randomUUID} from 'crypto'\n\nexport class RequestClientError extends ExtendableError {\n statusCode: number\n public constructor(message: string, statusCode: number) {\n super(message)\n this.statusCode = statusCode\n }\n}\n\nexport async function buildHeaders(token?: string): Promise<{[key: string]: string}> {\n const userAgent = `Shopify CLI; v=${await constants.versions.cliKit()}`\n\n const headers: {[header: string]: string} = {\n 'User-Agent': userAgent,\n // 'Sec-CH-UA': secCHUA, This header requires the Git sha.\n 'Sec-CH-UA-PLATFORM': process.platform,\n 'X-Request-Id': randomUUID(),\n 'Content-Type': 'application/json',\n ...(firstPartyDev() && {'X-Shopify-Cli-Employee': '1'}),\n }\n if (token) {\n // eslint-disable-next-line dot-notation\n headers['authorization'] = `Bearer ${token}`\n headers['X-Shopify-Access-Token'] = `Bearer ${token}`\n }\n\n return headers\n}\n\n/**\n * Removes the sensitive data from the headers and outputs them as a string.\n * @param headers - HTTP headers.\n * @returns A sanitized version of the headers as a string.\n */\nexport function sanitizedHeadersOutput(headers: {[key: string]: string}): string {\n const sanitized: {[key: string]: string} = {}\n const keywords = ['token', 'authorization']\n Object.keys(headers).forEach((header) => {\n if (keywords.find((keyword) => header.toLocaleLowerCase().includes(keyword)) === undefined) {\n sanitized[header] = headers[header]!\n }\n })\n return Object.keys(sanitized)\n .map((header) => {\n return ` - ${header}: ${sanitized[header]}`\n })\n .join('\\n')\n}\n\nexport function debugLogRequest<T>(\n api: string,\n query: RequestDocument,\n variables?: Variables,\n headers: {[key: string]: string} = {},\n) {\n debug(content`\nSending ${token.json(api)} GraphQL request:\n${token.raw(query.toString())}\n\nWith variables:\n${variables ? JSON.stringify(variables, null, 2) : ''}\n\nAnd headers:\n${sanitizedHeadersOutput(headers)}\n`)\n}\n\nexport async function handlingErrors<T>(api: string, action: () => Promise<T>): Promise<T> {\n try {\n return await action()\n } catch (error) {\n if (error instanceof ClientError) {\n const errorMessage = stringifyMessage(content`\n The ${token.raw(\n api,\n )} GraphQL API responded unsuccessfully with the HTTP status ${`${error.response.status}`} and errors:\n\n ${outputToken.json(error.response.errors)}\n `)\n let mappedError: Error\n if (error.response.status < 500) {\n mappedError = new RequestClientError(errorMessage, error.response.status)\n } else {\n mappedError = new Abort(errorMessage)\n }\n mappedError.stack = error.stack\n throw mappedError\n } else {\n throw error\n }\n }\n}\n"]}
@@ -1,13 +1,13 @@
1
1
  import { gql } from 'graphql-request';
2
2
  export const FindOrganizationQuery = gql `
3
- query FindOrganization($id: ID!) {
3
+ query FindOrganization($id: ID!, $title: String) {
4
4
  organizations(id: $id, first: 1) {
5
5
  nodes {
6
6
  id
7
7
  businessName
8
8
  website
9
9
  appsNext
10
- apps(first: 100) {
10
+ apps(first: 100, title: $title) {
11
11
  nodes {
12
12
  id
13
13
  title
@@ -1 +1 @@
1
- {"version":3,"file":"find_org.js","sourceRoot":"","sources":["../../../src/api/graphql/find_org.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,GAAG,EAAC,MAAM,iBAAiB,CAAA;AAEnC,MAAM,CAAC,MAAM,qBAAqB,GAAG,GAAG,CAAA;;;;;;;;;;;;;;;;;;CAkBvC,CAAA","sourcesContent":["import {gql} from 'graphql-request'\n\nexport const FindOrganizationQuery = gql`\n query FindOrganization($id: ID!) {\n organizations(id: $id, first: 1) {\n nodes {\n id\n businessName\n website\n appsNext\n apps(first: 100) {\n nodes {\n id\n title\n apiKey\n }\n }\n }\n }\n }\n`\n\nexport interface FindOrganizationQuerySchema {\n organizations: {\n nodes: {\n id: string\n businessName: string\n website: string\n appsNext: boolean\n apps: {\n nodes: {\n id: string\n title: string\n apiKey: string\n }[]\n }\n }[]\n }\n}\n"]}
1
+ {"version":3,"file":"find_org.js","sourceRoot":"","sources":["../../../src/api/graphql/find_org.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,GAAG,EAAC,MAAM,iBAAiB,CAAA;AAEnC,MAAM,CAAC,MAAM,qBAAqB,GAAG,GAAG,CAAA;;;;;;;;;;;;;;;;;;CAkBvC,CAAA","sourcesContent":["import {gql} from 'graphql-request'\n\nexport const FindOrganizationQuery = gql`\n query FindOrganization($id: ID!, $title: String) {\n organizations(id: $id, first: 1) {\n nodes {\n id\n businessName\n website\n appsNext\n apps(first: 100, title: $title) {\n nodes {\n id\n title\n apiKey\n }\n }\n }\n }\n }\n`\n\nexport interface FindOrganizationQuerySchema {\n organizations: {\n nodes: {\n id: string\n businessName: string\n website: string\n appsNext: boolean\n apps: {\n nodes: {\n id: string\n title: string\n apiKey: string\n }[]\n }\n }[]\n }\n}\n"]}
@@ -11,10 +11,20 @@ export async function validateIdentityToken(token) {
11
11
  };
12
12
  debug(`Sending Identity Introspection request to URL: ${instrospectionURL}`);
13
13
  const response = await shopifyFetch(instrospectionURL, options);
14
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
15
- const json = await response.json();
16
- debug(`The identity token is valid: ${json.valid}`);
17
- return json.valid;
14
+ if (response.ok && response.headers.get('content-type')?.includes('json')) {
15
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
16
+ const json = await response.json();
17
+ debug(`The identity token is valid: ${json.valid}`);
18
+ return json.valid;
19
+ }
20
+ else {
21
+ const text = await response.text();
22
+ debug(`The Introspection request failed with:
23
+ - status: ${response.status}
24
+ - www-authenticate header: ${JSON.stringify(response.headers.get('www-authenticate'))}
25
+ - body: ${JSON.stringify(text)}`);
26
+ return false;
27
+ }
18
28
  // eslint-disable-next-line no-catch-all/no-catch-all
19
29
  }
20
30
  catch (error) {
@@ -1 +1 @@
1
- {"version":3,"file":"identity.js","sourceRoot":"","sources":["../../src/api/identity.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,QAAQ,EAAC,MAAM,wBAAwB,CAAA;AAC/C,OAAO,EAAC,KAAK,EAAC,MAAM,cAAc,CAAA;AAClC,OAAO,EAAC,YAAY,EAAC,MAAM,YAAY,CAAA;AAEvC,MAAM,CAAC,KAAK,UAAU,qBAAqB,CAAC,KAAa;IACvD,IAAI;QACF,MAAM,iBAAiB,GAAG,MAAM,yBAAyB,EAAE,CAAA;QAC3D,MAAM,OAAO,GAAG;YACd,MAAM,EAAE,MAAM;YACd,OAAO,EAAE,EAAC,aAAa,EAAE,UAAU,KAAK,EAAE,EAAE,cAAc,EAAE,kBAAkB,EAAC;YAC/E,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,EAAC,KAAK,EAAC,CAAC;SAC9B,CAAA;QACD,KAAK,CAAC,kDAAkD,iBAAiB,EAAE,CAAC,CAAA;QAE5E,MAAM,QAAQ,GAAG,MAAM,YAAY,CAAC,iBAAiB,EAAE,OAAO,CAAC,CAAA;QAC/D,8DAA8D;QAC9D,MAAM,IAAI,GAAQ,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAA;QAEvC,KAAK,CAAC,gCAAgC,IAAI,CAAC,KAAK,EAAE,CAAC,CAAA;QACnD,OAAO,IAAI,CAAC,KAAK,CAAA;QACjB,qDAAqD;KACtD;IAAC,OAAO,KAAK,EAAE;QACd,KAAK,CAAC,kCAAkC,KAAK,EAAE,CAAC,CAAA;QAChD,OAAO,KAAK,CAAA;KACb;AACH,CAAC;AAED,KAAK,UAAU,yBAAyB;IACtC,MAAM,QAAQ,GAAG,MAAM,YAAY,CAAC,WAAW,MAAM,QAAQ,EAAE,wCAAwC,CAAC,CAAA;IACxG,8DAA8D;IAC9D,MAAM,IAAI,GAAQ,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAA;IACvC,OAAO,IAAI,CAAC,sBAAsB,CAAA;AACpC,CAAC","sourcesContent":["import {identity} from '../environment/fqdn.js'\nimport {debug} from '../output.js'\nimport {shopifyFetch} from '../http.js'\n\nexport async function validateIdentityToken(token: string) {\n try {\n const instrospectionURL = await getInstrospectionEndpoint()\n const options = {\n method: 'POST',\n headers: {Authorization: `Bearer ${token}`, 'Content-Type': 'application/json'},\n body: JSON.stringify({token}),\n }\n debug(`Sending Identity Introspection request to URL: ${instrospectionURL}`)\n\n const response = await shopifyFetch(instrospectionURL, options)\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const json: any = await response.json()\n\n debug(`The identity token is valid: ${json.valid}`)\n return json.valid\n // eslint-disable-next-line no-catch-all/no-catch-all\n } catch (error) {\n debug(`The identity token is invalid: ${error}`)\n return false\n }\n}\n\nasync function getInstrospectionEndpoint(): Promise<string> {\n const response = await shopifyFetch(`https://${await identity()}/.well-known/openid-configuration.json`)\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const json: any = await response.json()\n return json.introspection_endpoint\n}\n"]}
1
+ {"version":3,"file":"identity.js","sourceRoot":"","sources":["../../src/api/identity.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,QAAQ,EAAC,MAAM,wBAAwB,CAAA;AAC/C,OAAO,EAAC,KAAK,EAAC,MAAM,cAAc,CAAA;AAClC,OAAO,EAAC,YAAY,EAAC,MAAM,YAAY,CAAA;AAEvC,MAAM,CAAC,KAAK,UAAU,qBAAqB,CAAC,KAAa;IACvD,IAAI;QACF,MAAM,iBAAiB,GAAG,MAAM,yBAAyB,EAAE,CAAA;QAC3D,MAAM,OAAO,GAAG;Y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AAA;IACvC,OAAO,IAAI,CAAC,sBAAsB,CAAA;AACpC,CAAC","sourcesContent":["import {identity} from '../environment/fqdn.js'\nimport {debug} from '../output.js'\nimport {shopifyFetch} from '../http.js'\n\nexport async function validateIdentityToken(token: string) {\n try {\n const instrospectionURL = await getInstrospectionEndpoint()\n const options = {\n method: 'POST',\n headers: {Authorization: `Bearer ${token}`, 'Content-Type': 'application/json'},\n body: JSON.stringify({token}),\n }\n debug(`Sending Identity Introspection request to URL: ${instrospectionURL}`)\n\n const response = await shopifyFetch(instrospectionURL, options)\n\n if (response.ok && response.headers.get('content-type')?.includes('json')) {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const json: any = await response.json()\n debug(`The identity token is valid: ${json.valid}`)\n return json.valid\n } else {\n const text = await response.text()\n debug(`The Introspection request failed with:\n - status: ${response.status}\n - www-authenticate header: ${JSON.stringify(response.headers.get('www-authenticate'))}\n - body: ${JSON.stringify(text)}`)\n return false\n }\n // eslint-disable-next-line no-catch-all/no-catch-all\n } catch (error) {\n debug(`The identity token is invalid: ${error}`)\n return false\n }\n}\n\nasync function getInstrospectionEndpoint(): Promise<string> {\n const response = await shopifyFetch(`https://${await identity()}/.well-known/openid-configuration.json`)\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const json: any = await response.json()\n return json.introspection_endpoint\n}\n"]}
@@ -1,11 +1,5 @@
1
1
  import { Variables, RequestDocument } from 'graphql-request';
2
2
  export declare function request<T>(query: RequestDocument, token: string, variables?: Variables): Promise<T>;
3
- /**
4
- * Check if the given token is revoked and no longer valid to interact with the Partners API.
5
- * @param token - The token to check
6
- * @returns True if the token is revoked, false otherwise
7
- */
8
- export declare function checkIfTokenIsRevoked(token: string): Promise<boolean>;
9
3
  /**
10
4
  * Function queries are proxied through the script service proxy.
11
5
  * To execute a query, we encapsulate it inside another query (including the variables)
@@ -2,7 +2,6 @@ import { buildHeaders, debugLogRequest, handlingErrors } from './common.js';
2
2
  import { ScriptServiceProxyQuery } from './graphql/index.js';
3
3
  import { partners as partnersFqdn } from '../environment/fqdn.js';
4
4
  import { graphqlClient } from '../http/graphql.js';
5
- import { ClientError, gql } from 'graphql-request';
6
5
  export async function request(query, token, variables) {
7
6
  const api = 'Partners';
8
7
  return handlingErrors(api, async () => {
@@ -15,37 +14,6 @@ export async function request(query, token, variables) {
15
14
  return response;
16
15
  });
17
16
  }
18
- /**
19
- * Check if the given token is revoked and no longer valid to interact with the Partners API.
20
- * @param token - The token to check
21
- * @returns True if the token is revoked, false otherwise
22
- */
23
- export async function checkIfTokenIsRevoked(token) {
24
- const query = gql `
25
- {
26
- organizations(first: 1) {
27
- nodes {
28
- id
29
- }
30
- }
31
- }
32
- `;
33
- const fqdn = await partnersFqdn();
34
- const url = `https://${fqdn}/api/cli/graphql`;
35
- const headers = await buildHeaders(token);
36
- const client = await graphqlClient({ headers, url });
37
- try {
38
- await client.request(query, {});
39
- return false;
40
- // eslint-disable-next-line no-catch-all/no-catch-all
41
- }
42
- catch (error) {
43
- if (error instanceof ClientError) {
44
- return error.response.status === 401;
45
- }
46
- return false;
47
- }
48
- }
49
17
  /**
50
18
  * Function queries are proxied through the script service proxy.
51
19
  * To execute a query, we encapsulate it inside another query (including the variables)
@@ -1 +1 @@
1
- {"version":3,"file":"partners.js","sourceRoot":"","sources":["../../src/api/partners.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,YAAY,EAAE,eAAe,EAAE,cAAc,EAAC,MAAM,aAAa,CAAA;AACzE,OAAO,EAAC,uBAAuB,EAAC,MAAM,oBAAoB,CAAA;AAC1D,OAAO,EAAC,QAAQ,IAAI,YAAY,EAAC,MAAM,wBAAwB,CAAA;AAC/D,OAAO,EAAC,aAAa,EAAC,MAAM,oBAAoB,CAAA;AAChD,OAAO,EAAY,WAAW,EAAE,GAAG,EAAkB,MAAM,iBAAiB,CAAA;AAE5E,MAAM,CAAC,KAAK,UAAU,OAAO,CAAI,KAAsB,EAAE,KAAa,EAAE,SAAqB;IAC3F,MAAM,GAA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KAAK,UAAU,oBAAoB,CACxC,MAAc,EACd,KAAc,EACd,KAAa,EACb,SAAmB;IAEnB,MAAM,cAAc,GAAG;QACrB,OAAO,EAAE,MAAM;QACf,KAAK;QACL,SAAS,EAAE,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC,IAAI,IAAI;KAC7C,CAAA;IACD,MAAM,UAAU,GAAG,uBAAuB,CAAA;IAC1C,MAAM,GAAG,GAAkB,MAAM,OAAO,CAAC,UAAU,EAAE,KAAK,EAAE,cAAc,CAAC,CAAA;IAC3E,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,kBAAkB,CAAC,CAAA;IAC/C,OAAO,IAAS,CAAA;AAClB,CAAC","sourcesContent":["import {buildHeaders, debugLogRequest, handlingErrors} from './common.js'\nimport {ScriptServiceProxyQuery} from './graphql/index.js'\nimport {partners as partnersFqdn} from '../environment/fqdn.js'\nimport {graphqlClient} from '../http/graphql.js'\nimport {Variables, ClientError, gql, RequestDocument} from 'graphql-request'\n\nexport async function request<T>(query: RequestDocument, token: string, variables?: Variables): Promise<T> {\n const api = 'Partners'\n return handlingErrors(api, async () => {\n const fqdn = await partnersFqdn()\n const url = `https://${fqdn}/api/cli/graphql`\n const headers = await buildHeaders(token)\n debugLogRequest(api, query, variables, headers)\n const client = await graphqlClient({headers, url})\n const response = await client.request<T>(query, variables)\n return response\n })\n}\n\n/**\n * Check if the given token is revoked and no longer valid to interact with the Partners API.\n * @param token - The token to check\n * @returns True if the token is revoked, false otherwise\n */\nexport async function checkIfTokenIsRevoked(token: string): Promise<boolean> {\n const query = gql`\n {\n organizations(first: 1) {\n nodes {\n id\n }\n }\n }\n `\n const fqdn = await partnersFqdn()\n const url = `https://${fqdn}/api/cli/graphql`\n const headers = await buildHeaders(token)\n const client = await graphqlClient({headers, url})\n try {\n await client.request(query, {})\n return false\n // eslint-disable-next-line no-catch-all/no-catch-all\n } catch (error) {\n if (error instanceof ClientError) {\n return error.response.status === 401\n }\n return false\n }\n}\n\ninterface ProxyResponse {\n scriptServiceProxy: string\n}\n\n/**\n * Function queries are proxied through the script service proxy.\n * To execute a query, we encapsulate it inside another query (including the variables)\n * This is done automatically, you just need to provide the query and the variables.\n *\n * @param apiKey - APIKey of the app where the query will be executed.\n * @param query - GraphQL query to execute.\n * @param token - Partners token\n * @param variables - GraphQL variables to pass to the query.\n * @returns The response of the query.\n */\nexport async function functionProxyRequest<T>(\n apiKey: string,\n query: unknown,\n token: string,\n variables?: unknown,\n): Promise<T> {\n const proxyVariables = {\n api_key: apiKey,\n query,\n variables: JSON.stringify(variables) || '{}',\n }\n const proxyQuery = ScriptServiceProxyQuery\n const res: ProxyResponse = await request(proxyQuery, token, proxyVariables)\n const json = JSON.parse(res.scriptServiceProxy)\n return json as T\n}\n"]}
1
+ {"version":3,"file":"partners.js","sourceRoot":"","sources":["../../src/api/partners.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,YAAY,EAAE,eAAe,EAAE,cAAc,EAAC,MAAM,aAAa,CAAA;AACzE,OAAO,EAAC,uBAAuB,EAAC,MAAM,oBAAoB,CAAA;AAC1D,OAAO,EAAC,QAAQ,IAAI,YAAY,EAAC,MAAM,wBAAwB,CAAA;AAC/D,OAAO,EAAC,aAAa,EAAC,MAAM,oBAAoB,CAAA;AAGhD,MAAM,CAAC,KAAK,UAAU,OAAO,CAAI,KAAsB,EAAE,KAAa,EAAE,SAAqB;IAC3F,MAAM,GAAG,GAAG,UAAU,CAAA;IACtB,OAAO,cAAc,CAAC,GAAG,EAAE,KAAK,IAAI,EAAE;QACpC,MAAM,IAAI,GAAG,MAAM,YAAY,EAAE,CAAA;QACjC,MAAM,GAAG,GAAG,WAAW,IAAI,kBAAkB,CAAA;QAC7C,MAAM,OAAO,GAAG,MAAM,YAAY,CAAC,KAAK,CAAC,CAAA;QACzC,eAAe,CAAC,GAAG,EAAE,KAAK,EAAE,SAAS,EAAE,OAAO,CAAC,CAAA;QAC/C,MAAM,MAAM,GAAG,MAAM,aAAa,CAAC,EAAC,OAAO,EAAE,GAAG,EAAC,CAAC,CAAA;QAClD,MAAM,QAAQ,GAAG,MAAM,MAAM,CAAC,OAAO,CAAI,KAAK,EAAE,SAAS,CAAC,CAAA;QAC1D,OAAO,QAAQ,CAAA;IACjB,CAAC,CAAC,CAAA;AACJ,CAAC;AAMD;;;;;;;;;;GAUG;AACH,MAAM,CAAC,KAAK,UAAU,oBAAoB,CACxC,MAAc,EACd,KAAc,EACd,KAAa,EACb,SAAmB;IAEnB,MAAM,cAAc,GAAG;QACrB,OAAO,EAAE,MAAM;QACf,KAAK;QACL,SAAS,EAAE,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC,IAAI,IAAI;KAC7C,CAAA;IACD,MAAM,UAAU,GAAG,uBAAuB,CAAA;IAC1C,MAAM,GAAG,GAAkB,MAAM,OAAO,CAAC,UAAU,EAAE,KAAK,EAAE,cAAc,CAAC,CAAA;IAC3E,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,kBAAkB,CAAC,CAAA;IAC/C,OAAO,IAAS,CAAA;AAClB,CAAC","sourcesContent":["import {buildHeaders, debugLogRequest, handlingErrors} from './common.js'\nimport {ScriptServiceProxyQuery} from './graphql/index.js'\nimport {partners as partnersFqdn} from '../environment/fqdn.js'\nimport {graphqlClient} from '../http/graphql.js'\nimport {Variables, RequestDocument} from 'graphql-request'\n\nexport async function request<T>(query: RequestDocument, token: string, variables?: Variables): Promise<T> {\n const api = 'Partners'\n return handlingErrors(api, async () => {\n const fqdn = await partnersFqdn()\n const url = `https://${fqdn}/api/cli/graphql`\n const headers = await buildHeaders(token)\n debugLogRequest(api, query, variables, headers)\n const client = await graphqlClient({headers, url})\n const response = await client.request<T>(query, variables)\n return response\n })\n}\n\ninterface ProxyResponse {\n scriptServiceProxy: string\n}\n\n/**\n * Function queries are proxied through the script service proxy.\n * To execute a query, we encapsulate it inside another query (including the variables)\n * This is done automatically, you just need to provide the query and the variables.\n *\n * @param apiKey - APIKey of the app where the query will be executed.\n * @param query - GraphQL query to execute.\n * @param token - Partners token\n * @param variables - GraphQL variables to pass to the query.\n * @returns The response of the query.\n */\nexport async function functionProxyRequest<T>(\n apiKey: string,\n query: unknown,\n token: string,\n variables?: unknown,\n): Promise<T> {\n const proxyVariables = {\n api_key: apiKey,\n query,\n variables: JSON.stringify(variables) || '{}',\n }\n const proxyQuery = ScriptServiceProxyQuery\n const res: ProxyResponse = await request(proxyQuery, token, proxyVariables)\n const json = JSON.parse(res.scriptServiceProxy)\n return json as T\n}\n"]}
@@ -1,4 +1,6 @@
1
1
  import { httpsAgent } from '../http.js';
2
+ import { buildHeaders, sanitizedHeadersOutput } from '../api/common.js';
3
+ import { content, debug } from '../output.js';
2
4
  import nodeFetch from 'node-fetch';
3
5
  /**
4
6
  * An interface that abstracts way node-fetch. When Node has built-in
@@ -21,6 +23,17 @@ export default async function fetch(url, init) {
21
23
  * (e.g. spin)
22
24
  */
23
25
  export async function shopifyFetch(url, init) {
26
+ const options = {
27
+ ...(init ?? {}),
28
+ headers: {
29
+ ...(await buildHeaders()),
30
+ ...(init?.headers ?? {}),
31
+ },
32
+ };
33
+ debug(content `
34
+ Sending ${options.method ?? 'GET'} request to URL ${url.toString()} and headers:
35
+ ${sanitizedHeadersOutput((options?.headers ?? {}))}
36
+ `);
24
37
  const response = await nodeFetch(url, { ...init, agent: await httpsAgent() });
25
38
  return response;
26
39
  }
@@ -1 +1 @@
1
- {"version":3,"file":"fetch.js","sourceRoot":"","sources":["../../src/http/fetch.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAC,MAAM,YAAY,CAAA;AACrC,OAAO,SAAS,MAAM,YAAY,CAAA;AAIlC;;;;;;;;;;GAUG;AACH,MAAM,CAAC,OAAO,CAAC,KAAK,UAAU,KAAK,CAAC,GAAgB,EAAE,IAAkB;IACtE,MAAM,QAAQ,GAAG,MAAM,SAAS,CAAC,GAAG,EAAE,IAAI,CAAC,CAAA;IAC3C,OAAO,QAAQ,CAAA;AACjB,CAAC;AAED;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,YAAY,CAAC,GAAgB,EAAE,IAAkB;IACrE,MAAM,QAAQ,GAAG,MAAM,SAAS,CAAC,GAAG,EAAE,EAAC,GAAG,IAAI,EAAE,KAAK,EAAE,MAAM,UAAU,EAAE,EAAC,CAAC,CAAA;IAC3E,OAAO,QAAQ,CAAA;AACjB,CAAC","sourcesContent":["import {httpsAgent} from '../http.js'\nimport nodeFetch from 'node-fetch'\nimport type {RequestInfo, RequestInit} from 'node-fetch'\n\ntype Response = ReturnType<typeof nodeFetch>\n/**\n * An interface that abstracts way node-fetch. When Node has built-in\n * support for \"fetch\" in the standard library, we can drop the node-fetch\n * dependency from here.\n * Note that we are exposing types from \"node-fetch\". The reason being is that\n * they are consistent with the Web API so if we drop node-fetch in the future\n * it won't require changes from the callers.\n * @param url - This defines the resource that you wish to fetch.\n * @param init - An object containing any custom settings that you want to apply to the request\n * @returns A promise that resolves with the response.\n */\nexport default async function fetch(url: RequestInfo, init?: RequestInit): Response {\n const response = await nodeFetch(url, init)\n return response\n}\n\n/**\n * A fetch function to use with Shopify services. The function ensures the right\n * TLS configuragion is used based on the environment in which the service is running\n * (e.g. spin)\n */\nexport async function shopifyFetch(url: RequestInfo, init?: RequestInit): Response {\n const response = await nodeFetch(url, {...init, agent: await httpsAgent()})\n return response\n}\n"]}
1
+ {"version":3,"file":"fetch.js","sourceRoot":"","sources":["../../src/http/fetch.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAC,MAAM,YAAY,CAAA;AACrC,OAAO,EAAC,YAAY,EAAE,sBAAsB,EAAC,MAAM,kBAAkB,CAAA;AACrE,OAAO,EAAC,OAAO,EAAE,KAAK,EAAC,MAAM,cAAc,CAAA;AAC3C,OAAO,SAAS,MAAM,YAAY,CAAA;AAIlC;;;;;;;;;;GAUG;AACH,MAAM,CAAC,OAAO,CAAC,KAAK,UAAU,KAAK,CAAC,GAAgB,EAAE,IAAkB;IACtE,MAAM,QAAQ,GAAG,MAAM,SAAS,CAAC,GAAG,EAAE,IAAI,CAAC,CAAA;IAC3C,OAAO,QAAQ,CAAA;AACjB,CAAC;AAED;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,YAAY,CAAC,GAAgB,EAAE,IAAkB;IACrE,MAAM,OAAO,GAAgB;QAC3B,GAAG,CAAC,IAAI,IAAI,EAAE,CAAC;QACf,OAAO,EAAE;YACP,GAAG,CAAC,MAAM,YAAY,EAAE,CAAC;YACzB,GAAG,CAAC,IAAI,EAAE,OAAO,IAAI,EAAE,CAAC;SACzB;KACF,CAAA;IAED,KAAK,CAAC,OAAO,CAAA;UACL,OAAO,CAAC,MAAM,IAAI,KAAK,mBAAmB,GAAG,CAAC,QAAQ,EAAE;EAChE,sBAAsB,CAAC,CAAC,OAAO,EAAE,OAAO,IAAI,EAAE,CAA+B,CAAC;CAC/E,CAAC,CAAA;IACA,MAAM,QAAQ,GAAG,MAAM,SAAS,CAAC,GAAG,EAAE,EAAC,GAAG,IAAI,EAAE,KAAK,EAAE,MAAM,UAAU,EAAE,EAAC,CAAC,CAAA;IAC3E,OAAO,QAAQ,CAAA;AACjB,CAAC","sourcesContent":["import {httpsAgent} from '../http.js'\nimport {buildHeaders, sanitizedHeadersOutput} from '../api/common.js'\nimport {content, debug} from '../output.js'\nimport nodeFetch from 'node-fetch'\nimport type {RequestInfo, RequestInit} from 'node-fetch'\n\ntype Response = ReturnType<typeof nodeFetch>\n/**\n * An interface that abstracts way node-fetch. When Node has built-in\n * support for \"fetch\" in the standard library, we can drop the node-fetch\n * dependency from here.\n * Note that we are exposing types from \"node-fetch\". The reason being is that\n * they are consistent with the Web API so if we drop node-fetch in the future\n * it won't require changes from the callers.\n * @param url - This defines the resource that you wish to fetch.\n * @param init - An object containing any custom settings that you want to apply to the request\n * @returns A promise that resolves with the response.\n */\nexport default async function fetch(url: RequestInfo, init?: RequestInit): Response {\n const response = await nodeFetch(url, init)\n return response\n}\n\n/**\n * A fetch function to use with Shopify services. The function ensures the right\n * TLS configuragion is used based on the environment in which the service is running\n * (e.g. spin)\n */\nexport async function shopifyFetch(url: RequestInfo, init?: RequestInit): Response {\n const options: RequestInit = {\n ...(init ?? {}),\n headers: {\n ...(await buildHeaders()),\n ...(init?.headers ?? {}),\n },\n }\n\n debug(content`\nSending ${options.method ?? 'GET'} request to URL ${url.toString()} and headers:\n${sanitizedHeadersOutput((options?.headers ?? {}) as {[header: string]: string})}\n`)\n const response = await nodeFetch(url, {...init, agent: await httpsAgent()})\n return response\n}\n"]}
package/dist/index.d.ts CHANGED
@@ -9,7 +9,6 @@ export * as file from './file.js';
9
9
  export * as git from './git.js';
10
10
  export * as http from './http.js';
11
11
  export * as id from './id.js';
12
- export * as log from './log.js';
13
12
  export * as npm from './npm.js';
14
13
  export * as os from './os.js';
15
14
  export * as output from './output.js';
package/dist/index.js CHANGED
@@ -9,7 +9,6 @@ export * as file from './file.js';
9
9
  export * as git from './git.js';
10
10
  export * as http from './http.js';
11
11
  export * as id from './id.js';
12
- export * as log from './log.js';
13
12
  export * as npm from './npm.js';
14
13
  export * as os from './os.js';
15
14
  export * as output from './output.js';
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,IAAI,MAAM,WAAW,CAAA;AACjC,OAAO,KAAK,GAAG,MAAM,UAAU,CAAA;AAC/B,OAAO,KAAK,IAAI,MAAM,WAAW,CAAA;AACjC,OAAO,KAAK,EAAE,MAAM,SAAS,CAAA;AAC7B,OAAO,KAAK,GAAG,MAAM,UAAU,CAAA;AAC/B,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,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,MAAM,MAAM,aAAa,CAAA;AACrC,OAAO,KAAK,YAAY,MAAM,qBAAqB,CAAA;AACnD,OAAO,KAAK,QAAQ,MAAM,eAAe,CAAA;AACzC,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 cli from './cli.js'\nexport * as environment from './environment.js'\nexport * as error from './error.js'\nexport * as file from './file.js'\nexport * as git from './git.js'\nexport * as http from './http.js'\nexport * as id from './id.js'\nexport * as log from './log.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 schema from './schema.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 vscode from './vscode.js'\nexport * as outputMocker from './testing/output.js'\nexport * as metadata from './metadata.js'\nexport * as monorail from './monorail.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,GAAG,MAAM,UAAU,CAAA;AAC/B,OAAO,KAAK,WAAW,MAAM,kBAAkB,CAAA;AAC/C,OAAO,KAAK,KAAK,MAAM,YAAY,CAAA;AACnC,OAAO,KAAK,IAAI,MAAM,WAAW,CAAA;AACjC,OAAO,KAAK,GAAG,MAAM,UAAU,CAAA;AAC/B,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,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,MAAM,MAAM,aAAa,CAAA;AACrC,OAAO,KAAK,YAAY,MAAM,qBAAqB,CAAA;AACnD,OAAO,KAAK,QAAQ,MAAM,eAAe,CAAA;AACzC,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 cli from './cli.js'\nexport * as environment from './environment.js'\nexport * as error from './error.js'\nexport * as file from './file.js'\nexport * as git from './git.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 schema from './schema.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 vscode from './vscode.js'\nexport * as outputMocker from './testing/output.js'\nexport * as metadata from './metadata.js'\nexport * as monorail from './monorail.js'\n"]}
@@ -40,14 +40,14 @@ export declare const getAllPublic: () => Partial<CmdFieldsFromMonorail>, getAllS
40
40
  startTopic?: string;
41
41
  startArgs: string[];
42
42
  };
43
- }>, addPublic: (getData: ProvideMetadata<CmdFieldsFromMonorail>, onError?: MetadataErrorHandling | undefined) => Promise<void>, addSensitive: (getData: ProvideMetadata<{
43
+ }>, addPublic: (getData: ProvideMetadata<CmdFieldsFromMonorail>, onError?: MetadataErrorHandling) => Promise<void>, addSensitive: (getData: ProvideMetadata<{
44
44
  commandStartOptions: {
45
45
  startTime: number;
46
46
  startCommand: string;
47
47
  startTopic?: string;
48
48
  startArgs: string[];
49
49
  };
50
- }>, onError?: MetadataErrorHandling | undefined) => Promise<void>;
50
+ }>, onError?: MetadataErrorHandling) => Promise<void>;
51
51
  export declare type Public = PublicSchema<typeof coreData>;
52
52
  export declare type Sensitive = SensitiveSchema<typeof coreData>;
53
53
  export {};
package/dist/output.js CHANGED
@@ -2,7 +2,6 @@
2
2
  import { isUnitTest, isVerbose } from './environment/local.js';
3
3
  import colors from './public/node/colors.js';
4
4
  import { ColorContentToken, CommandContentToken, ErrorContentToken, HeadingContentToken, ItalicContentToken, JsonContentToken, LinesDiffContentToken, LinkContentToken, PathContentToken, RawContentToken, SubHeadingContentToken, } from './content-tokens.js';
5
- import { logToFile } from './log.js';
6
5
  import stripAnsi from 'strip-ansi';
7
6
  import { Writable } from 'node:stream';
8
7
  export { default as logUpdate } from 'log-update';
@@ -271,7 +270,6 @@ export function outputWhereAppropriate(logLevel, logger, message) {
271
270
  logger(message);
272
271
  }
273
272
  }
274
- logToFile(message, logLevel.toUpperCase());
275
273
  }
276
274
  function withOrWithoutStyle(message) {
277
275
  if (shouldDisplayColors()) {
@@ -295,7 +293,7 @@ export function getOutputUpdateCLIReminder(packageManager, version) {
295
293
  const versionMessage = `💡 Version ${version} available!`;
296
294
  if (!packageManager || packageManager === 'unknown')
297
295
  return versionMessage;
298
- const updateCommand = token.packagejsonScript(packageManager, 'shopify', 'upgrade');
296
+ const updateCommand = token.packagejsonScript(packageManager, 'shopify upgrade');
299
297
  return content `${versionMessage} Run ${updateCommand}`.value;
300
298
  }
301
299
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"output.js","sourceRoot":"","sources":["../src/output.ts"],"names":[],"mappings":"AAAA,+BAA+B;AAC/B,OAAO,EAAC,UAAU,EAAE,SAAS,EAAC,MAAM,wBAAwB,CAAA;AAE5D,OAAO,MAAM,MAAM,yBAAyB,CAAA;AAC5C,OAAO,EACL,iBAAiB,EACjB,mBAAmB,EAEnB,iBAAiB,EACjB,mBAAmB,EACnB,kBAAkB,EAClB,gBAAgB,EAChB,qBAAqB,EACrB,gBAAgB,EAChB,gBAAgB,EAChB,eAAe,EACf,sBAAsB,GACvB,MAAM,qBAAqB,CAAA;AAC5B,OAAO,EAAC,SAAS,EAAC,MAAM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cAAc,CAAA;IAE1E,MAAM,aAAa,GAAG,KAAK,CAAC,iBAAiB,CAAC,cAAc,EAAE,SAAS,EAAE,SAAS,CAAC,CAAA;IACnF,OAAO,OAAO,CAAA,GAAG,cAAc,QAAQ,aAAa,EAAE,CAAC,KAAK,CAAA;AAC9D,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,OAAO,CAAC,KAAa,EAAE,IAAY;IACjD,MAAM,cAAc,GAAG,GAAG,KAAK,CAAC,WAAW,EAAE,GAAG,GAAG,CAAC,MAAM,CAAC,EAAE,GAAG,KAAK,CAAC,MAAM,CAAC,EAAE,CAAA;IAC/E,OAAO,OAAO,CAAA,GAAG,KAAK,CAAC,OAAO,CAAC,cAAc,CAAC,KAAK,IAAI,EAAE,CAAC,KAAK,CAAA;AACjE,CAAC;AAED,8BAA8B","sourcesContent":["/* eslint-disable no-console */\nimport {isUnitTest, isVerbose} from './environment/local.js'\nimport {PackageManager} from './public/node/node-package-manager.js'\nimport colors from './public/node/colors.js'\nimport {\n ColorContentToken,\n CommandContentToken,\n ContentToken,\n ErrorContentToken,\n HeadingContentToken,\n ItalicContentToken,\n JsonContentToken,\n LinesDiffContentToken,\n LinkContentToken,\n PathContentToken,\n RawContentToken,\n SubHeadingContentToken,\n} from './content-tokens.js'\nimport {logToFile} from './log.js'\nimport {AbortSignal} from 'abort-controller'\nimport stripAnsi from 'strip-ansi'\nimport {Writable} from 'node:stream'\nimport type {Change} from 'diff'\n\nexport {default as logUpdate} from 'log-update'\n\nexport type Logger = Writable | ((message: string) => void)\n\nexport class TokenizedString {\n value: string\n constructor(value: string) {\n this.value = value\n }\n}\n\nexport type Message = string | TokenizedString\n\nexport const token = {\n raw: (value: string) => {\n return new RawContentToken(value)\n },\n genericShellCommand: (value: Message) => {\n return new CommandContentToken(value)\n },\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n json: (value: any) => {\n return new JsonContentToken(value)\n },\n path: (value: Message) => {\n return new PathContentToken(value)\n },\n link: (value: Message, link: string) => {\n return new LinkContentToken(value, link)\n },\n heading: (value: Message) => {\n return new HeadingContentToken(value)\n },\n subheading: (value: Message) => {\n return new SubHeadingContentToken(value)\n },\n italic: (value: Message) => {\n return new ItalicContentToken(value)\n },\n errorText: (value: Message) => {\n return new ErrorContentToken(value)\n },\n cyan: (value: Message) => {\n return new ColorContentToken(value, colors.cyan)\n },\n yellow: (value: Message) => {\n return new ColorContentToken(value, colors.yellow)\n },\n magenta: (value: Message) => {\n return new ColorContentToken(value, colors.magenta)\n },\n green: (value: Message) => {\n return new ColorContentToken(value, colors.green)\n },\n packagejsonScript: (packageManager: PackageManager, scriptName: string, ...scriptArgs: string[]) => {\n return new CommandContentToken(formatPackageManagerCommand(packageManager, scriptName, ...scriptArgs))\n },\n successIcon: () => {\n return new ColorContentToken('✔', colors.green)\n },\n failIcon: () => {\n return new ErrorContentToken('✖')\n },\n linesDiff: (value: Change[]) => {\n return new LinesDiffContentToken(value)\n },\n}\n\nexport function formatPackageManagerCommand(\n packageManager: PackageManager,\n scriptName: string,\n ...scriptArgs: string[]\n): string {\n switch (packageManager) {\n case 'yarn': {\n const pieces = ['yarn', scriptName, ...scriptArgs]\n return pieces.join(' ')\n }\n case 'pnpm':\n case 'npm': {\n const pieces = [packageManager, 'run', scriptName]\n if (scriptArgs.length > 0) {\n pieces.push('--')\n pieces.push(...scriptArgs)\n }\n return pieces.join(' ')\n }\n }\n}\n\nexport function content(strings: TemplateStringsArray, ...keys: (ContentToken<unknown> | string)[]): TokenizedString {\n let output = ``\n strings.forEach((string, i) => {\n output += string\n if (i >= keys.length) {\n return\n }\n const token = keys[i]!\n\n if (typeof token === 'string') {\n output += token\n } else {\n const enumTokenOutput = token.output()\n\n if (Array.isArray(enumTokenOutput)) {\n enumTokenOutput.forEach((line: string) => {\n output += line\n })\n } else {\n output += enumTokenOutput\n }\n }\n })\n return new TokenizedString(output)\n}\n\n/** Log levels */\nexport type LogLevel = 'fatal' | 'error' | 'warn' | 'info' | 'debug' | 'trace' | 'silent'\n\n/**\n * It maps a level to a numeric value.\n * @param level - The level for which we'll return its numeric value.\n * @returns The numeric value of the level.\n */\nconst logLevelValue = (level: LogLevel): number => {\n switch (level) {\n case 'trace':\n return 10\n case 'debug':\n return 20\n case 'info':\n return 30\n case 'warn':\n return 40\n case 'error':\n return 50\n case 'fatal':\n return 60\n default:\n return 30\n }\n}\n\n/**\n *\n * @returns It returns the log level set by the user.\n */\nexport const currentLogLevel = (): LogLevel => {\n if (isVerbose()) {\n return 'debug'\n } else {\n return 'info'\n }\n}\n\nexport const shouldOutput = (logLevel: LogLevel): boolean => {\n if (isUnitTest()) {\n return false\n }\n const currentLogLevelValue = logLevelValue(currentLogLevel())\n const messageLogLevelValue = logLevelValue(logLevel)\n return messageLogLevelValue >= currentLogLevelValue\n}\n\n// eslint-disable-next-line import/no-mutable-exports\nexport let collectedLogs: {[key: string]: string[]} = {}\n\n/**\n * This is only used during UnitTesting.\n * If we are in a testing context, instead of printing the logs to the console,\n * we will store them in a variable that can be accessed from the tests.\n * @param key - The key of the log.\n * @param content - The content of the log.\n */\nexport const collectLog = (key: string, content: Message) => {\n const output = collectedLogs.output ?? []\n const data = collectedLogs[key] ?? []\n data.push(stripAnsi(stringifyMessage(content) ?? ''))\n output.push(stripAnsi(stringifyMessage(content) ?? ''))\n collectedLogs[key] = data\n collectedLogs.output = output\n}\n\nexport const clearCollectedLogs = () => {\n collectedLogs = {}\n}\n\n/**\n * Ouputs information to the user.\n * Info messages don't get additional formatting.\n * Note: Info messages are sent through the standard output.\n * @param content - The content to be output to the user.\n * @param logger - The logging function to use to output to the user.\n */\nexport const info = (content: Message, logger: Logger = consoleLog) => {\n const message = stringifyMessage(content)\n if (isUnitTest()) collectLog('info', content)\n outputWhereAppropriate('info', logger, message)\n}\n\n/**\n * Outputs a success message to the user.\n * Success messages receive a special formatting to make them stand out in the console.\n * Note: Success messages are sent through the standard output.\n * @param content - The content to be output to the user.\n * @param logger - The logging function to use to output to the user.\n */\nexport const success = (content: Message, logger: Logger = consoleLog) => {\n const message = colors.bold(`✅ Success! ${stringifyMessage(content)}.`)\n if (isUnitTest()) collectLog('success', content)\n outputWhereAppropriate('info', logger, message)\n}\n\n/**\n * Outputs a completed message to the user.\n * Completed message receive a special formatting to make them stand out in the console.\n * Note: Completed messages are sent through the standard output.\n * @param content - The content to be output to the user.\n * @param logger - The logging function to use to output to the user.\n */\nexport const completed = (content: Message, logger: Logger = consoleLog) => {\n const message = `${colors.green('✔')} ${stringifyMessage(content)}`\n if (isUnitTest()) collectLog('completed', content)\n outputWhereAppropriate('info', logger, message)\n}\n\n/**\n * Ouputs debug information to the user. By default these output is hidden unless the user calls the CLI with --verbose.\n * Debug messages don't get additional formatting.\n * Note: Debug messages are sent through the standard output.\n * @param content - The content to be output to the user.\n * @param logger - The logging function to use to output to the user.\n */\nexport const debug = (content: Message, logger: Logger = consoleLog) => {\n if (isUnitTest()) collectLog('debug', content)\n const message = colors.gray(stringifyMessage(content))\n outputWhereAppropriate('debug', logger, message)\n}\n\n/**\n * Outputs a warning message to the user.\n * Warning messages receive a special formatting to make them stand out in the console.\n * Note: Warning messages are sent through the standard output.\n * @param content - The content to be output to the user.\n * @param logger - The logging function to use to output to the user.\n */\nexport const warn = (content: Message, logger: Logger = consoleWarn) => {\n if (isUnitTest()) collectLog('warn', content)\n const message = colors.yellow(stringifyMessage(content))\n outputWhereAppropriate('warn', logger, message)\n}\n\n/**\n * Prints a new line in the terminal.\n */\nexport const newline = () => {\n console.log()\n}\n\nexport function stringifyMessage(message: Message): string {\n if (message instanceof TokenizedString) {\n return message.value\n } else {\n return message\n }\n}\n\nconst message = (content: Message, level: LogLevel = 'info') => {\n const stringifiedMessage = stringifyMessage(content)\n outputWhereAppropriate(level, consoleLog, stringifiedMessage)\n}\n\nexport interface OutputProcess {\n /** The prefix to include in the logs\n * [vite] Output coming from Vite\n */\n prefix: string\n /**\n * A callback to invoke the process. stdout and stderr should be used\n * to send standard output and error data that gets formatted with the\n * right prefix.\n */\n action: (stdout: Writable, stderr: Writable, signal: AbortSignal) => Promise<void>\n}\n\nexport function consoleLog(message: string): void {\n console.log(withOrWithoutStyle(message))\n}\n\nexport function consoleError(message: string): void {\n console.error(withOrWithoutStyle(message))\n}\n\nexport function consoleWarn(message: string): void {\n console.warn(withOrWithoutStyle(message))\n}\n\nexport function outputWhereAppropriate(logLevel: LogLevel, logger: Logger, message: string): void {\n if (shouldOutput(logLevel)) {\n if (logger instanceof Writable) {\n logger.write(message)\n } else {\n logger(message)\n }\n }\n logToFile(message, logLevel.toUpperCase())\n}\n\nfunction withOrWithoutStyle(message: string): string {\n if (shouldDisplayColors()) {\n return message\n } else {\n return unstyled(message)\n }\n}\n\nexport function unstyled(message: string): string {\n return stripAnsi(message)\n}\n\nexport function shouldDisplayColors(): boolean {\n return Boolean(process.stdout.isTTY || process.env.FORCE_COLOR)\n}\n\n/**\n * @param packageManager - The package manager that is being used.\n * @param version - The version to update to\n */\nexport function getOutputUpdateCLIReminder(\n packageManager: PackageManager | 'unknown' | undefined,\n version: string,\n): string {\n const versionMessage = `💡 Version ${version} available!`\n if (!packageManager || packageManager === 'unknown') return versionMessage\n\n const updateCommand = token.packagejsonScript(packageManager, 'shopify', 'upgrade')\n return content`${versionMessage} Run ${updateCommand}`.value\n}\n\n/**\n * Parse title and body to be a single formatted string\n * @param title - The title of the message. Will be formatted as a heading.\n * @param body - The body of the message. Will respect the original formatting.\n * @returns The formatted message.\n */\nexport function section(title: string, body: string): string {\n const formattedTitle = `${title.toUpperCase()}${' '.repeat(35 - title.length)}`\n return content`${token.heading(formattedTitle)}\\n${body}`.value\n}\n\n/* eslint-enable no-console */\n"]}
1
+ {"version":3,"file":"output.js","sourceRoot":"","sources":["../src/output.ts"],"names":[],"mappings":"AAAA,+BAA+B;AAC/B,OAAO,EAAC,UAAU,EAAE,SAAS,EAAC,MAAM,wBAAwB,CAAA;AAE5D,OAAO,MAAM,MAAM,yBAAyB,CAAA;AAC5C,OAAO,EACL,iBAAiB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AAG,cAAc,OAAO,aAAa,CAAA;IACzD,IAAI,CAAC,cAAc,IAAI,cAAc,KAAK,SAAS;QAAE,OAAO,cAAc,CAAA;IAE1E,MAAM,aAAa,GAAG,KAAK,CAAC,iBAAiB,CAAC,cAAc,EAAE,iBAAiB,CAAC,CAAA;IAChF,OAAO,OAAO,CAAA,GAAG,cAAc,QAAQ,aAAa,EAAE,CAAC,KAAK,CAAA;AAC9D,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,OAAO,CAAC,KAAa,EAAE,IAAY;IACjD,MAAM,cAAc,GAAG,GAAG,KAAK,CAAC,WAAW,EAAE,GAAG,GAAG,CAAC,MAAM,CAAC,EAAE,GAAG,KAAK,CAAC,MAAM,CAAC,EAAE,CAAA;IAC/E,OAAO,OAAO,CAAA,GAAG,KAAK,CAAC,OAAO,CAAC,cAAc,CAAC,KAAK,IAAI,EAAE,CAAC,KAAK,CAAA;AACjE,CAAC;AAED,8BAA8B","sourcesContent":["/* eslint-disable no-console */\nimport {isUnitTest, isVerbose} from './environment/local.js'\nimport {PackageManager} from './public/node/node-package-manager.js'\nimport colors from './public/node/colors.js'\nimport {\n ColorContentToken,\n CommandContentToken,\n ContentToken,\n ErrorContentToken,\n HeadingContentToken,\n ItalicContentToken,\n JsonContentToken,\n LinesDiffContentToken,\n LinkContentToken,\n PathContentToken,\n RawContentToken,\n SubHeadingContentToken,\n} from './content-tokens.js'\nimport {AbortSignal} from 'abort-controller'\nimport stripAnsi from 'strip-ansi'\nimport {Writable} from 'node:stream'\nimport type {Change} from 'diff'\n\nexport {default as logUpdate} from 'log-update'\n\nexport type Logger = Writable | ((message: string) => void)\n\nexport class TokenizedString {\n value: string\n constructor(value: string) {\n this.value = value\n }\n}\n\nexport type Message = string | TokenizedString\n\nexport const token = {\n raw: (value: string) => {\n return new RawContentToken(value)\n },\n genericShellCommand: (value: Message) => {\n return new CommandContentToken(value)\n },\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n json: (value: any) => {\n return new JsonContentToken(value)\n },\n path: (value: Message) => {\n return new PathContentToken(value)\n },\n link: (value: Message, link: string) => {\n return new LinkContentToken(value, link)\n },\n heading: (value: Message) => {\n return new HeadingContentToken(value)\n },\n subheading: (value: Message) => {\n return new SubHeadingContentToken(value)\n },\n italic: (value: Message) => {\n return new ItalicContentToken(value)\n },\n errorText: (value: Message) => {\n return new ErrorContentToken(value)\n },\n cyan: (value: Message) => {\n return new ColorContentToken(value, colors.cyan)\n },\n yellow: (value: Message) => {\n return new ColorContentToken(value, colors.yellow)\n },\n magenta: (value: Message) => {\n return new ColorContentToken(value, colors.magenta)\n },\n green: (value: Message) => {\n return new ColorContentToken(value, colors.green)\n },\n packagejsonScript: (packageManager: PackageManager, scriptName: string, ...scriptArgs: string[]) => {\n return new CommandContentToken(formatPackageManagerCommand(packageManager, scriptName, ...scriptArgs))\n },\n successIcon: () => {\n return new ColorContentToken('✔', colors.green)\n },\n failIcon: () => {\n return new ErrorContentToken('✖')\n },\n linesDiff: (value: Change[]) => {\n return new LinesDiffContentToken(value)\n },\n}\n\nexport function formatPackageManagerCommand(\n packageManager: PackageManager,\n scriptName: string,\n ...scriptArgs: string[]\n): string {\n switch (packageManager) {\n case 'yarn': {\n const pieces = ['yarn', scriptName, ...scriptArgs]\n return pieces.join(' ')\n }\n case 'pnpm':\n case 'npm': {\n const pieces = [packageManager, 'run', scriptName]\n if (scriptArgs.length > 0) {\n pieces.push('--')\n pieces.push(...scriptArgs)\n }\n return pieces.join(' ')\n }\n }\n}\n\nexport function content(strings: TemplateStringsArray, ...keys: (ContentToken<unknown> | string)[]): TokenizedString {\n let output = ``\n strings.forEach((string, i) => {\n output += string\n if (i >= keys.length) {\n return\n }\n const token = keys[i]!\n\n if (typeof token === 'string') {\n output += token\n } else {\n const enumTokenOutput = token.output()\n\n if (Array.isArray(enumTokenOutput)) {\n enumTokenOutput.forEach((line: string) => {\n output += line\n })\n } else {\n output += enumTokenOutput\n }\n }\n })\n return new TokenizedString(output)\n}\n\n/** Log levels */\nexport type LogLevel = 'fatal' | 'error' | 'warn' | 'info' | 'debug' | 'trace' | 'silent'\n\n/**\n * It maps a level to a numeric value.\n * @param level - The level for which we'll return its numeric value.\n * @returns The numeric value of the level.\n */\nconst logLevelValue = (level: LogLevel): number => {\n switch (level) {\n case 'trace':\n return 10\n case 'debug':\n return 20\n case 'info':\n return 30\n case 'warn':\n return 40\n case 'error':\n return 50\n case 'fatal':\n return 60\n default:\n return 30\n }\n}\n\n/**\n *\n * @returns It returns the log level set by the user.\n */\nexport const currentLogLevel = (): LogLevel => {\n if (isVerbose()) {\n return 'debug'\n } else {\n return 'info'\n }\n}\n\nexport const shouldOutput = (logLevel: LogLevel): boolean => {\n if (isUnitTest()) {\n return false\n }\n const currentLogLevelValue = logLevelValue(currentLogLevel())\n const messageLogLevelValue = logLevelValue(logLevel)\n return messageLogLevelValue >= currentLogLevelValue\n}\n\n// eslint-disable-next-line import/no-mutable-exports\nexport let collectedLogs: {[key: string]: string[]} = {}\n\n/**\n * This is only used during UnitTesting.\n * If we are in a testing context, instead of printing the logs to the console,\n * we will store them in a variable that can be accessed from the tests.\n * @param key - The key of the log.\n * @param content - The content of the log.\n */\nexport const collectLog = (key: string, content: Message) => {\n const output = collectedLogs.output ?? []\n const data = collectedLogs[key] ?? []\n data.push(stripAnsi(stringifyMessage(content) ?? ''))\n output.push(stripAnsi(stringifyMessage(content) ?? ''))\n collectedLogs[key] = data\n collectedLogs.output = output\n}\n\nexport const clearCollectedLogs = () => {\n collectedLogs = {}\n}\n\n/**\n * Ouputs information to the user.\n * Info messages don't get additional formatting.\n * Note: Info messages are sent through the standard output.\n * @param content - The content to be output to the user.\n * @param logger - The logging function to use to output to the user.\n */\nexport const info = (content: Message, logger: Logger = consoleLog) => {\n const message = stringifyMessage(content)\n if (isUnitTest()) collectLog('info', content)\n outputWhereAppropriate('info', logger, message)\n}\n\n/**\n * Outputs a success message to the user.\n * Success messages receive a special formatting to make them stand out in the console.\n * Note: Success messages are sent through the standard output.\n * @param content - The content to be output to the user.\n * @param logger - The logging function to use to output to the user.\n */\nexport const success = (content: Message, logger: Logger = consoleLog) => {\n const message = colors.bold(`✅ Success! ${stringifyMessage(content)}.`)\n if (isUnitTest()) collectLog('success', content)\n outputWhereAppropriate('info', logger, message)\n}\n\n/**\n * Outputs a completed message to the user.\n * Completed message receive a special formatting to make them stand out in the console.\n * Note: Completed messages are sent through the standard output.\n * @param content - The content to be output to the user.\n * @param logger - The logging function to use to output to the user.\n */\nexport const completed = (content: Message, logger: Logger = consoleLog) => {\n const message = `${colors.green('✔')} ${stringifyMessage(content)}`\n if (isUnitTest()) collectLog('completed', content)\n outputWhereAppropriate('info', logger, message)\n}\n\n/**\n * Ouputs debug information to the user. By default these output is hidden unless the user calls the CLI with --verbose.\n * Debug messages don't get additional formatting.\n * Note: Debug messages are sent through the standard output.\n * @param content - The content to be output to the user.\n * @param logger - The logging function to use to output to the user.\n */\nexport const debug = (content: Message, logger: Logger = consoleLog) => {\n if (isUnitTest()) collectLog('debug', content)\n const message = colors.gray(stringifyMessage(content))\n outputWhereAppropriate('debug', logger, message)\n}\n\n/**\n * Outputs a warning message to the user.\n * Warning messages receive a special formatting to make them stand out in the console.\n * Note: Warning messages are sent through the standard output.\n * @param content - The content to be output to the user.\n * @param logger - The logging function to use to output to the user.\n */\nexport const warn = (content: Message, logger: Logger = consoleWarn) => {\n if (isUnitTest()) collectLog('warn', content)\n const message = colors.yellow(stringifyMessage(content))\n outputWhereAppropriate('warn', logger, message)\n}\n\n/**\n * Prints a new line in the terminal.\n */\nexport const newline = () => {\n console.log()\n}\n\nexport function stringifyMessage(message: Message): string {\n if (message instanceof TokenizedString) {\n return message.value\n } else {\n return message\n }\n}\n\nconst message = (content: Message, level: LogLevel = 'info') => {\n const stringifiedMessage = stringifyMessage(content)\n outputWhereAppropriate(level, consoleLog, stringifiedMessage)\n}\n\nexport interface OutputProcess {\n /** The prefix to include in the logs\n * [vite] Output coming from Vite\n */\n prefix: string\n /**\n * A callback to invoke the process. stdout and stderr should be used\n * to send standard output and error data that gets formatted with the\n * right prefix.\n */\n action: (stdout: Writable, stderr: Writable, signal: AbortSignal) => Promise<void>\n}\n\nexport function consoleLog(message: string): void {\n console.log(withOrWithoutStyle(message))\n}\n\nexport function consoleError(message: string): void {\n console.error(withOrWithoutStyle(message))\n}\n\nexport function consoleWarn(message: string): void {\n console.warn(withOrWithoutStyle(message))\n}\n\nexport function outputWhereAppropriate(logLevel: LogLevel, logger: Logger, message: string): void {\n if (shouldOutput(logLevel)) {\n if (logger instanceof Writable) {\n logger.write(message)\n } else {\n logger(message)\n }\n }\n}\n\nfunction withOrWithoutStyle(message: string): string {\n if (shouldDisplayColors()) {\n return message\n } else {\n return unstyled(message)\n }\n}\n\nexport function unstyled(message: string): string {\n return stripAnsi(message)\n}\n\nexport function shouldDisplayColors(): boolean {\n return Boolean(process.stdout.isTTY || process.env.FORCE_COLOR)\n}\n\n/**\n * @param packageManager - The package manager that is being used.\n * @param version - The version to update to\n */\nexport function getOutputUpdateCLIReminder(\n packageManager: PackageManager | 'unknown' | undefined,\n version: string,\n): string {\n const versionMessage = `💡 Version ${version} available!`\n if (!packageManager || packageManager === 'unknown') return versionMessage\n\n const updateCommand = token.packagejsonScript(packageManager, 'shopify upgrade')\n return content`${versionMessage} Run ${updateCommand}`.value\n}\n\n/**\n * Parse title and body to be a single formatted string\n * @param title - The title of the message. Will be formatted as a heading.\n * @param body - The body of the message. Will respect the original formatting.\n * @returns The formatted message.\n */\nexport function section(title: string, body: string): string {\n const formattedTitle = `${title.toUpperCase()}${' '.repeat(35 - title.length)}`\n return content`${token.heading(formattedTitle)}\\n${body}`.value\n}\n\n/* eslint-enable no-console */\n"]}
package/dist/path.d.ts CHANGED
@@ -1,8 +1,11 @@
1
1
  import { OverloadParameters } from './typing/overloaded-parameters.js';
2
2
  import { relative, dirname, join, normalize, resolve, basename, extname, isAbsolute, parse } from 'pathe';
3
3
  import { findUp as internalFindUp } from 'find-up';
4
+ import fastGlob from 'fast-glob';
4
5
  export { join, relative, dirname, normalize, resolve, basename, extname, isAbsolute, parse };
5
- export { default as glob } from 'fast-glob';
6
+ declare type FastGlobOptions = Parameters<typeof fastGlob>;
7
+ declare type FastGlobOutput = ReturnType<typeof fastGlob>;
8
+ export declare function glob(...args: FastGlobOptions): FastGlobOutput;
6
9
  export { pathToFileURL } from 'node:url';
7
10
  export declare function findUp(matcher: OverloadParameters<typeof internalFindUp>[0], options: OverloadParameters<typeof internalFindUp>[1]): ReturnType<typeof internalFindUp>;
8
11
  /**
package/dist/path.js CHANGED
@@ -1,9 +1,17 @@
1
1
  import commondir from 'commondir';
2
2
  import { relative, dirname, join, normalize, resolve, basename, extname, isAbsolute, parse } from 'pathe';
3
3
  import { findUp as internalFindUp } from 'find-up';
4
+ import fastGlob from 'fast-glob';
4
5
  import { fileURLToPath } from 'url';
5
6
  export { join, relative, dirname, normalize, resolve, basename, extname, isAbsolute, parse };
6
- export { default as glob } from 'fast-glob';
7
+ export async function glob(...args) {
8
+ // eslint-disable-next-line prefer-const
9
+ let [pattern, options] = args;
10
+ if (options?.dot == null) {
11
+ options = { ...options, dot: true };
12
+ }
13
+ return fastGlob(pattern, options);
14
+ }
7
15
  export { pathToFileURL } from 'node:url';
8
16
  export async function findUp(matcher, options) {
9
17
  // findUp has odd typing
package/dist/path.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"path.js","sourceRoot":"","sources":["../src/path.ts"],"names":[],"mappings":"AACA,OAAO,SAAS,MAAM,WAAW,CAAA;AACjC,OAAO,EAAC,QAAQ,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,UAAU,EAAE,KAAK,EAAC,MAAM,OAAO,CAAA;AACvG,OAAO,EAAC,MAAM,IAAI,cAAc,EAAuB,MAAM,SAAS,CAAA;AACtE,OAAO,EAAC,aAAa,EAAC,MAAM,KAAK,CAAA;AAEjC,OAAO,EAAC,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,UAAU,EAAE,KAAK,EAAC,CAAA;AAE1F,OAAO,EAAC,OAAO,IAAI,IAAI,EAAC,MAAM,WAAW,CAAA;AACzC,OAAO,EAAC,aAAa,EAAC,MAAM,UAAU,CAAA;AAItC,MAAM,CAAC,KAAK,UAAU,MAAM,CAC1B,OAAqD,EACrD,OAAqD;IAErD,wBAAwB;IACxB,8DAA8D;IAC9D,MAAM,GAAG,GAAG,MAAM,cAAc,CAAC,OAAc,EAAE,OAAO,CAAC,CAAA;IACzD,OAAO,GAAG,CAAC,CAAC,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,CAAA;AACzC,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,UAAU,CAAC,IAAY;IACrC,MAAM,MAAM,GAAG,SAAS,CAAC,CAAC,IAAI,EAAE,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC,CAAA;IAC/C,MAAM,YAAY,GAAG,QAAQ,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,IAAI,CAAC,CAAA;IAClD,MAAM,kBAAkB,GAAG,YAAY,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,SAAS,KAAK,IAAI,CAAC,CAAC,MAAM,CAAA;IACnG,IAAI,MAAM,KAAK,GAAG,IAAI,YAAY,KAAK,EAAE,IAAI,kBAAkB,GAAG,CAAC,EAAE;QACnE,OAAO,IAAI,CAAA;KACZ;SAAM;QACL,OAAO,YAAY,CAAA;KACpB;AACH,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,eAAe,CAAC,SAAuB;IACrD,OAAO,OAAO,CAAC,aAAa,CAAC,SAAS,CAAC,CAAC,CAAA;AAC1C,CAAC","sourcesContent":["import {OverloadParameters} from './typing/overloaded-parameters.js'\nimport commondir from 'commondir'\nimport {relative, dirname, join, normalize, resolve, basename, extname, isAbsolute, parse} from 'pathe'\nimport {findUp as internalFindUp, Match as FindUpMatch} from 'find-up'\nimport {fileURLToPath} from 'url'\n\nexport {join, relative, dirname, normalize, resolve, basename, extname, isAbsolute, parse}\n\nexport {default as glob} from 'fast-glob'\nexport {pathToFileURL} from 'node:url'\n\ntype FindUpMatcher = (directory: string) => FindUpMatch | Promise<FindUpMatch>\n\nexport async function findUp(\n matcher: OverloadParameters<typeof internalFindUp>[0],\n options: OverloadParameters<typeof internalFindUp>[1],\n): ReturnType<typeof internalFindUp> {\n // findUp has odd typing\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const got = await internalFindUp(matcher as any, options)\n return got ? normalize(got) : undefined\n}\n\n/**\n * Given an absolute filesystem path, it makes it relative to\n * the current working directory. This is useful when logging paths\n * to allow the users to click on the file and let the OS open it\n * in the editor of choice.\n * @param path - Path to relativize\n * @returns Relativized path.\n */\nexport function relativize(path: string): string {\n const result = commondir([path, process.cwd()])\n const relativePath = relative(process.cwd(), path)\n const relativeComponents = relativePath.split('/').filter((component) => component === '..').length\n if (result === '/' || relativePath === '' || relativeComponents > 2) {\n return path\n } else {\n return relativePath\n }\n}\n\n/**\n * Given a module's import.meta.url it returns the directory containing the module.\n * @param moduleURL - The value of import.meta.url in the context of the caller module.\n * @returns The path to the directory containing the caller module.\n */\nexport function moduleDirectory(moduleURL: string | URL): string {\n return dirname(fileURLToPath(moduleURL))\n}\n"]}
1
+ {"version":3,"file":"path.js","sourceRoot":"","sources":["../src/path.ts"],"names":[],"mappings":"AACA,OAAO,SAAS,MAAM,WAAW,CAAA;AACjC,OAAO,EAAC,QAAQ,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,UAAU,EAAE,KAAK,EAAC,MAAM,OAAO,CAAA;AACvG,OAAO,EAAC,MAAM,IAAI,cAAc,EAAuB,MAAM,SAAS,CAAA;AACtE,OAAO,QAAQ,MAAM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IAAI,MAAM,KAAK,GAAG,IAAI,YAAY,KAAK,EAAE,IAAI,kBAAkB,GAAG,CAAC,EAAE;QACnE,OAAO,IAAI,CAAA;KACZ;SAAM;QACL,OAAO,YAAY,CAAA;KACpB;AACH,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,eAAe,CAAC,SAAuB;IACrD,OAAO,OAAO,CAAC,aAAa,CAAC,SAAS,CAAC,CAAC,CAAA;AAC1C,CAAC","sourcesContent":["import {OverloadParameters} from './typing/overloaded-parameters.js'\nimport commondir from 'commondir'\nimport {relative, dirname, join, normalize, resolve, basename, extname, isAbsolute, parse} from 'pathe'\nimport {findUp as internalFindUp, Match as FindUpMatch} from 'find-up'\nimport fastGlob from 'fast-glob'\nimport {fileURLToPath} from 'url'\n\nexport {join, relative, dirname, normalize, resolve, basename, extname, isAbsolute, parse}\n\ntype FastGlobOptions = Parameters<typeof fastGlob>\ntype FastGlobOutput = ReturnType<typeof fastGlob>\n\nexport async function glob(...args: FastGlobOptions): FastGlobOutput {\n // eslint-disable-next-line prefer-const\n let [pattern, options] = args\n if (options?.dot == null) {\n options = {...options, dot: true}\n }\n return fastGlob(pattern, options)\n}\nexport {pathToFileURL} from 'node:url'\n\ntype FindUpMatcher = (directory: string) => FindUpMatch | Promise<FindUpMatch>\n\nexport async function findUp(\n matcher: OverloadParameters<typeof internalFindUp>[0],\n options: OverloadParameters<typeof internalFindUp>[1],\n): ReturnType<typeof internalFindUp> {\n // findUp has odd typing\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const got = await internalFindUp(matcher as any, options)\n return got ? normalize(got) : undefined\n}\n\n/**\n * Given an absolute filesystem path, it makes it relative to\n * the current working directory. This is useful when logging paths\n * to allow the users to click on the file and let the OS open it\n * in the editor of choice.\n * @param path - Path to relativize\n * @returns Relativized path.\n */\nexport function relativize(path: string): string {\n const result = commondir([path, process.cwd()])\n const relativePath = relative(process.cwd(), path)\n const relativeComponents = relativePath.split('/').filter((component) => component === '..').length\n if (result === '/' || relativePath === '' || relativeComponents > 2) {\n return path\n } else {\n return relativePath\n }\n}\n\n/**\n * Given a module's import.meta.url it returns the directory containing the module.\n * @param moduleURL - The value of import.meta.url in the context of the caller module.\n * @returns The path to the directory containing the caller module.\n */\nexport function moduleDirectory(moduleURL: string | URL): string {\n return dirname(fileURLToPath(moduleURL))\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"Command.js","sourceRoot":"","sources":["../../../../../src/private/node/ui/components/Command.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAC,IAAI,EAAC,MAAM,KAAK,CAAA;AACxB,OAAO,KAAK,MAAM,OAAO,CAAA;AAMzB;;GAEG;AACH,MAAM,OAAO,GAAoB,CAAC,EAAC,OAAO,EAAiC,EAAe,EAAE;IAC1F,OAAO,oBAAC,IAAI;;QAAG,OAAO;YAAS,CAAA;AACjC,CAAC,CAAA;AAED,OAAO,EAAC,OAAO,EAAC,CAAA","sourcesContent":["import {Text} from 'ink'\nimport React from 'react'\n\ninterface Props {\n command: string\n}\n\n/**\n * `Command` displays a command as non-dimmed text.\n */\nconst Command: React.FC<Props> = ({command}: React.PropsWithChildren<Props>): JSX.Element => {\n return <Text>`{command}`</Text>\n}\n\nexport {Command}\n"]}
1
+ {"version":3,"file":"Command.js","sourceRoot":"","sources":["../../../../../src/private/node/ui/components/Command.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAC,IAAI,EAAC,MAAM,KAAK,CAAA;AACxB,OAAO,KAAK,MAAM,OAAO,CAAA;AAMzB;;GAEG;AACH,MAAM,OAAO,GAAoB,CAAC,EAAC,OAAO,EAAC,EAAe,EAAE;IAC1D,OAAO,oBAAC,IAAI;;QAAG,OAAO;YAAS,CAAA;AACjC,CAAC,CAAA;AAED,OAAO,EAAC,OAAO,EAAC,CAAA","sourcesContent":["import {Text} from 'ink'\nimport React from 'react'\n\ninterface Props {\n command: string\n}\n\n/**\n * `Command` displays a command as non-dimmed text.\n */\nconst Command: React.FC<Props> = ({command}): JSX.Element => {\n return <Text>`{command}`</Text>\n}\n\nexport {Command}\n"]}
@@ -1,3 +1,4 @@
1
+ import { isTruthy } from '../../../../environment/utilities.js';
1
2
  import React, { useEffect, useState } from 'react';
2
3
  import { Box, Static, Text, useApp } from 'ink';
3
4
  import stripAnsi from 'strip-ansi';
@@ -67,7 +68,10 @@ const ConcurrentOutput = ({ processes, abortController, showTimestamps = true })
67
68
  const stderr = writableStream(process, index);
68
69
  await process.action(stdout, stderr, abortController.signal);
69
70
  }));
70
- unmountInk();
71
+ // This is a workaround needed because Ink behaves differently in CI when
72
+ // unmounting. See https://github.com/vadimdemedes/ink/pull/266
73
+ if (!isTruthy(process.env.CI))
74
+ unmountInk();
71
75
  };
72
76
  useEffect(() => {
73
77
  runProcesses().catch((error) => {