@shopify/cli-kit 3.29.0 → 3.30.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/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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Ae;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,MAAM,CAAC,KAAK,UAAU,OAAO,CAAI,KAAsB,EAAE,OAAqB,EAAE,SAAqB;IACnG,MAAM,GAAG,GAAG,OAAO,CAAA;IACnB,OAAO,cAAc,CAAC,GAAG,EAAE,KAAK,IAAI,EAAE;QACpC,MAAM,OAAO,GAAG,MAAM,eAAe,CAAC,OAAO,CAAC,CAAA;QAC9C,MAAM,GAAG,GAAG,QAAQ,CAAC,OAAO,CAAC,SAAS,EAAE,OAAO,CAAC,CAAA;QAChD,MAAM,OAAO,GAAG,MAAM,YAAY,CAAC,OAAO,CAAC,KAAK,CAAC,CAAA;QACjD,MAAM,MAAM,GAAG,MAAM,aAAa,CAAC,EAAC,OAAO,EAAE,GAAG,EAAC,CAAC,CAAA;QAClD,eAAe,CAAC,GAAG,EAAE,KAAK,EAAE,SAAS,EAAE,OAAO,CAAC,CAAA;QAC/C,MAAM,QAAQ,GAAG,MAAM,MAAM,CAAC,OAAO,CAAI,KAAK,EAAE,SAAS,CAAC,CAAA;QAC1D,OAAO,QAAQ,CAAA;IACjB,CAAC,CAAC,CAAA;AACJ,CAAC;AAED,KAAK,UAAU,eAAe,CAAC,OAAqB;IAClD,MAAM,GAAG,GAAG,QAAQ,CA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AED,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"]}
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"]}
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()) {
@@ -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,UAAU,CAAA;AAElC,OAAO,SAAS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,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 {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,EACjB,mBAAmB,EAEnB,iBAAiB,EACjB,mBAAm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AC,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"]}
@@ -3,7 +3,7 @@
3
3
  * @param array - Array from which we'll select a random item.
4
4
  * @returns A random element from the array.
5
5
  */
6
- export declare function takeRandomFromArray<T>(array: T[]): T | undefined;
6
+ export declare function takeRandomFromArray<T>(array: T[]): T;
7
7
  /**
8
8
  * Returns a copy of the array deleting the elemements that are undefined.
9
9
  * @param array - The array whose undefined will be deleted.
@@ -1 +1 @@
1
- {"version":3,"file":"array.js","sourceRoot":"","sources":["../../../src/public/common/array.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,UAAU,mBAAmB,CAAI,KAAU;IAC/C,OAAO,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,CAAA;AACxD,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,0BAA0B,CAAI,KAAwB;IACpE,OAAO,KAAK,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,KAAK,SAAS,CAAmC,CAAA;AACrF,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,0BAA0B,CAAI,KAAU;IACtD,OAAO,KAAK,CAAC,MAAM,KAAK,IAAI,GAAG,CAAC,KAAK,CAAC,CAAC,IAAI,CAAA;AAC7C,CAAC","sourcesContent":["/**\n * Takes a random value from an array.\n * @param array - Array from which we'll select a random item.\n * @returns A random element from the array.\n */\nexport function takeRandomFromArray<T>(array: T[]) {\n return array[Math.floor(Math.random() * array.length)]\n}\n\n/**\n * Returns a copy of the array deleting the elemements that are undefined.\n * @param array - The array whose undefined will be deleted.\n * @returns A copy of the array with the undefined elements deleted.\n */\nexport function getArrayRejectingUndefined<T>(array: (T | undefined)[]): T[] {\n return array.filter((item) => item !== undefined) as Exclude<T, null | undefined>[]\n}\n\n/**\n * Returns true if an array contains duplicates.\n * @returns True if the array contains duplicates.\n */\nexport function getArrayContainsDuplicates<T>(array: T[]) {\n return array.length !== new Set(array).size\n}\n"]}
1
+ {"version":3,"file":"array.js","sourceRoot":"","sources":["../../../src/public/common/array.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,UAAU,mBAAmB,CAAI,KAAU;IAC/C,OAAO,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,KAAK,CAAC,MAAM,CAAC,CAAE,CAAA;AACzD,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,0BAA0B,CAAI,KAAwB;IACpE,OAAO,KAAK,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,KAAK,SAAS,CAAmC,CAAA;AACrF,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,0BAA0B,CAAI,KAAU;IACtD,OAAO,KAAK,CAAC,MAAM,KAAK,IAAI,GAAG,CAAC,KAAK,CAAC,CAAC,IAAI,CAAA;AAC7C,CAAC","sourcesContent":["/**\n * Takes a random value from an array.\n * @param array - Array from which we'll select a random item.\n * @returns A random element from the array.\n */\nexport function takeRandomFromArray<T>(array: T[]): T {\n return array[Math.floor(Math.random() * array.length)]!\n}\n\n/**\n * Returns a copy of the array deleting the elemements that are undefined.\n * @param array - The array whose undefined will be deleted.\n * @returns A copy of the array with the undefined elements deleted.\n */\nexport function getArrayRejectingUndefined<T>(array: (T | undefined)[]): T[] {\n return array.filter((item) => item !== undefined) as Exclude<T, null | undefined>[]\n}\n\n/**\n * Returns true if an array contains duplicates.\n * @returns True if the array contains duplicates.\n */\nexport function getArrayContainsDuplicates<T>(array: T[]): boolean {\n return array.length !== new Set(array).size\n}\n"]}
@@ -5,7 +5,6 @@ import { Abort } from '../../error.js';
5
5
  import { addPublic } from '../../metadata.js';
6
6
  import { content, info, token } from '../../output.js';
7
7
  import { hashString } from '../../string.js';
8
- import { initiateLogging } from '../../log.js';
9
8
  import { Command } from '@oclif/core';
10
9
  class BaseCommand extends Command {
11
10
  static analyticsNameOverride() {
@@ -20,7 +19,6 @@ class BaseCommand extends Command {
20
19
  // This function runs just prior to `run`
21
20
  await registerCleanBugsnagErrorsFromWithinPlugins(this.config);
22
21
  }
23
- await initiateLogging();
24
22
  return super.init();
25
23
  }
26
24
  async parse(options, argv) {
@@ -1 +1 @@
1
- {"version":3,"file":"base-command.js","sourceRoot":"","sources":["../../../src/public/node/base-command.ts"],"names":[],"mappings":"AAAA,OA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;oBACL,MAAM,IAAI,KAAK,CACb,OAAO,CAAA,qEAAqE,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,YAAY,CAC5G,CAAA;iBACF;aACF;iBAAM,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE;gBAC/B,KAAK,CAAC,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,KAAK,EAAE,EAAE,GAAG,OAAO,EAAE,CAAC,CAAC,CAAA;aAClE;iBAAM;gBACL,IAAI,CAAC,IAAI,CAAC,KAAK,KAAK,EAAE,EAAE,GAAG,KAAK,EAAE,CAAC,CAAA;aACpC;SACF;KACF;IACD,OAAO,IAAI,CAAA;AACb,CAAC;AAED,eAAe,WAAW,CAAA","sourcesContent":["import {errorHandler, registerCleanBugsnagErrorsFromWithinPlugins} from './error-handler.js'\nimport {loadPresetsFromDirectory} from './presets.js'\nimport {JsonMap} from '../../json.js'\nimport {isDevelopment} from '../../environment/local.js'\nimport {Abort} from '../../error.js'\nimport {addPublic} from '../../metadata.js'\nimport {content, info, token} from '../../output.js'\nimport {hashString} from '../../string.js'\nimport {initiateLogging} from '../../log.js'\nimport {Command, Interfaces} from '@oclif/core'\n\ninterface PresettableFlags {\n preset?: string\n path?: string\n}\n\nabstract class BaseCommand extends Command {\n public static analyticsNameOverride(): string | undefined {\n return undefined\n }\n\n async catch(error: Error & {exitCode?: number | undefined}) {\n await errorHandler(error, this.config)\n }\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n protected async init(): Promise<any> {\n if (!isDevelopment()) {\n // This function runs just prior to `run`\n await registerCleanBugsnagErrorsFromWithinPlugins(this.config)\n }\n await initiateLogging()\n return super.init()\n }\n\n protected async parse<\n TFlags extends Interfaces.FlagOutput & {path?: string; verbose?: boolean},\n TGlobalFlags extends Interfaces.FlagOutput,\n TArgs extends Interfaces.OutputArgs,\n >(\n options?: Interfaces.Input<TFlags, TGlobalFlags>,\n argv?: string[],\n ): Promise<Interfaces.ParserOutput<TFlags, TGlobalFlags, TArgs>> {\n let result = await super.parse<TFlags, TGlobalFlags, TArgs>(options, argv)\n result = await this.resultWithPreset<TFlags, TGlobalFlags, TArgs>(result, options, argv)\n await addFromParsedFlags(result.flags)\n return result\n }\n\n protected async resultWithPreset<\n TFlags extends Interfaces.FlagOutput & {path?: string; verbose?: boolean},\n TGlobalFlags extends Interfaces.FlagOutput,\n TArgs extends Interfaces.OutputArgs,\n >(\n originalResult: Interfaces.ParserOutput<TFlags, TGlobalFlags, TArgs>,\n options?: Interfaces.Input<TFlags, TGlobalFlags>,\n argv?: string[],\n ): Promise<Interfaces.ParserOutput<TFlags, TGlobalFlags, TArgs>> {\n // If no preset is specified, don't modify the results\n const flags = originalResult.flags as PresettableFlags\n if (!flags.preset) return originalResult\n\n // If the specified preset isn't found, don't modify the results\n const presets = await loadPresetsFromDirectory(await this.presetsPath(flags), {findUp: this.findUpForPresets()})\n const preset = presets[flags.preset]\n if (!preset) return originalResult\n\n // Parse using noDefaultsOptions to derive a list of flags specified as\n // command-line arguments.\n const noDefaultsResult = await super.parse<TFlags, TGlobalFlags, TArgs>(noDefaultsOptions(options), argv)\n\n // Add the preset's settings to argv and pass them to `super.parse`. This\n // invokes oclif's validation system without breaking the oclif black box.\n // Replace the original result with this one.\n const result = await super.parse<TFlags, TGlobalFlags, TArgs>(options, [\n // Need to specify argv default because we're merging with argsFromPreset.\n ...(argv || this.argv),\n ...argsFromPreset<TFlags, TGlobalFlags, TArgs>(preset, options, noDefaultsResult),\n ])\n\n // Report successful application of the preset.\n reportPresetApplication<TFlags, TGlobalFlags, TArgs>(noDefaultsResult.flags, result.flags, flags.preset, preset)\n\n return result\n }\n\n protected async presetsPath(rawFlags: {path?: string}): Promise<string> {\n return rawFlags.path || process.cwd()\n }\n\n protected findUpForPresets(): boolean {\n return true\n }\n}\n\nexport async function addFromParsedFlags(flags: {path?: string; verbose?: boolean}) {\n await addPublic(() => ({\n cmd_all_verbose: flags.verbose,\n cmd_all_path_override: flags.path !== undefined,\n cmd_all_path_override_hash: flags.path === undefined ? undefined : hashString(flags.path),\n }))\n}\n\n/**\n * Any flag which is:\n *\n * 1. Present in the final set of flags\n * 2. Specified in the preset\n * 3. Not specified by the user as a command line argument\n *\n * should be reported.\n *\n * It doesn't matter if the preset flag's value was the same as the default; from\n * the user's perspective, they want to know their preset was applied.\n */\nfunction reportPresetApplication<\n TFlags extends Interfaces.FlagOutput,\n TGlobalFlags extends Interfaces.FlagOutput,\n TArgs extends Interfaces.OutputArgs,\n>(\n noDefaultsFlags: Interfaces.ParserOutput<TFlags, TGlobalFlags, TArgs>['flags'],\n flagsWithPresets: Interfaces.ParserOutput<TFlags, TGlobalFlags, TArgs>['flags'],\n presetName: string,\n preset: JsonMap,\n): void {\n const changes: JsonMap = {}\n for (const [name, value] of Object.entries(flagsWithPresets)) {\n const userSpecifiedThisFlag = Object.prototype.hasOwnProperty.call(noDefaultsFlags, name)\n const presetContainsFlag = Object.prototype.hasOwnProperty.call(preset, name)\n if (!userSpecifiedThisFlag && presetContainsFlag) changes[name] = value\n }\n if (Object.keys(changes).length === 0) return\n info(content`Using applicable flags from the preset ${token.yellow(presetName)}:\n\n${Object.entries(changes)\n .map(([name, value]) => `• ${name} = ${value}`)\n .join('\\n')}\\n`)\n}\n\n/**\n * Strips the defaults from configured flags. For example, if flags contains:\n *\n * ```\n * someFlag: Flags.boolean({\n * description: 'some flag',\n * default: false\n * })\n * ```\n *\n * it becomes:\n *\n * ```\n * someFlag: Flags.boolean({\n * description: 'some flag'\n * })\n * ```\n *\n * If we parse using this configuration, the only specified flags will be those\n * the user actually passed on the command line.\n */\n\nfunction noDefaultsOptions<TFlags extends Interfaces.FlagOutput, TGlobalFlags extends Interfaces.FlagOutput>(\n options: Interfaces.Input<TFlags, TGlobalFlags> | undefined,\n): Interfaces.Input<TFlags, TGlobalFlags> | undefined {\n if (!options?.flags) return options\n return {\n ...options,\n flags: Object.fromEntries(\n Object.entries(options.flags).map(([label, settings]) => {\n const copiedSettings = {...(settings as {default?: unknown})}\n delete copiedSettings.default\n return [label, copiedSettings]\n }),\n ) as Interfaces.FlagInput<TFlags>,\n }\n}\n\n/**\n * Converts the preset's settings to arguments as though passed on the command\n * line, skipping any arguments the user specified on the command line.\n */\nfunction argsFromPreset<\n TFlags extends Interfaces.FlagOutput,\n TGlobalFlags extends Interfaces.FlagOutput,\n TArgs extends Interfaces.OutputArgs,\n>(\n preset: JsonMap,\n options: Interfaces.Input<TFlags, TGlobalFlags> | undefined,\n noDefaultsResult: Interfaces.ParserOutput<TFlags, TArgs>,\n): string[] {\n const args: string[] = []\n for (const [label, value] of Object.entries(preset)) {\n const flagIsRelevantToCommand = options?.flags && Object.prototype.hasOwnProperty.call(options.flags, label)\n const userSpecifiedThisFlag =\n noDefaultsResult.flags && Object.prototype.hasOwnProperty.call(noDefaultsResult.flags, label)\n if (flagIsRelevantToCommand && !userSpecifiedThisFlag) {\n if (typeof value === 'boolean') {\n if (value === true) {\n args.push(`--${label}`)\n } else {\n throw new Abort(\n content`Presets can only specify true for boolean flags. Attempted to set ${token.yellow(label)} to false.`,\n )\n }\n } else if (Array.isArray(value)) {\n value.forEach((element) => args.push(`--${label}`, `${element}`))\n } else {\n args.push(`--${label}`, `${value}`)\n }\n }\n }\n return args\n}\n\nexport default BaseCommand\n"]}
1
+ {"version":3,"file":"base-command.js","sourceRoot":"","sources":["../../../src/public/node/base-command.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,YAAY,EAAE,2CAA2C,EAAC,MAAM,oBAAoB,CAAA;AAC5F,OAAO,EAAC,wBAAwB,EAAC,MAAM,cAAc,CAAA;AAErD,OAAO,EAAC,aAAa,EAAC,MAAM,4BAA4B,CAAA;AACxD,OAAO,EAAC,KAAK,EAAC,MAAM,gBAAgB,CAAA;AACpC,OAAO,EAAC,SAAS,EAAC,MAAM,mBAAmB,CAAA;AAC3C,OAAO,EAAC,OAAO,EAAE,IAAI,EAAE,KAAK,EA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,KAAK,EAAE,CAAC,CAAA;aACpC;SACF;KACF;IACD,OAAO,IAAI,CAAA;AACb,CAAC;AAED,eAAe,WAAW,CAAA","sourcesContent":["import {errorHandler, registerCleanBugsnagErrorsFromWithinPlugins} from './error-handler.js'\nimport {loadPresetsFromDirectory} from './presets.js'\nimport {JsonMap} from '../../json.js'\nimport {isDevelopment} from '../../environment/local.js'\nimport {Abort} from '../../error.js'\nimport {addPublic} from '../../metadata.js'\nimport {content, info, token} from '../../output.js'\nimport {hashString} from '../../string.js'\nimport {Command, Interfaces} from '@oclif/core'\n\ninterface PresettableFlags {\n preset?: string\n path?: string\n}\n\nabstract class BaseCommand extends Command {\n public static analyticsNameOverride(): string | undefined {\n return undefined\n }\n\n async catch(error: Error & {exitCode?: number | undefined}): Promise<void> {\n await errorHandler(error, this.config)\n }\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n protected async init(): Promise<any> {\n if (!isDevelopment()) {\n // This function runs just prior to `run`\n await registerCleanBugsnagErrorsFromWithinPlugins(this.config)\n }\n return super.init()\n }\n\n protected async parse<\n TFlags extends Interfaces.FlagOutput & {path?: string; verbose?: boolean},\n TGlobalFlags extends Interfaces.FlagOutput,\n TArgs extends Interfaces.OutputArgs,\n >(\n options?: Interfaces.Input<TFlags, TGlobalFlags>,\n argv?: string[],\n ): Promise<Interfaces.ParserOutput<TFlags, TGlobalFlags, TArgs>> {\n let result = await super.parse<TFlags, TGlobalFlags, TArgs>(options, argv)\n result = await this.resultWithPreset<TFlags, TGlobalFlags, TArgs>(result, options, argv)\n await addFromParsedFlags(result.flags)\n return result\n }\n\n protected async resultWithPreset<\n TFlags extends Interfaces.FlagOutput & {path?: string; verbose?: boolean},\n TGlobalFlags extends Interfaces.FlagOutput,\n TArgs extends Interfaces.OutputArgs,\n >(\n originalResult: Interfaces.ParserOutput<TFlags, TGlobalFlags, TArgs>,\n options?: Interfaces.Input<TFlags, TGlobalFlags>,\n argv?: string[],\n ): Promise<Interfaces.ParserOutput<TFlags, TGlobalFlags, TArgs>> {\n // If no preset is specified, don't modify the results\n const flags = originalResult.flags as PresettableFlags\n if (!flags.preset) return originalResult\n\n // If the specified preset isn't found, don't modify the results\n const presets = await loadPresetsFromDirectory(await this.presetsPath(flags), {findUp: this.findUpForPresets()})\n const preset = presets[flags.preset]\n if (!preset) return originalResult\n\n // Parse using noDefaultsOptions to derive a list of flags specified as\n // command-line arguments.\n const noDefaultsResult = await super.parse<TFlags, TGlobalFlags, TArgs>(noDefaultsOptions(options), argv)\n\n // Add the preset's settings to argv and pass them to `super.parse`. This\n // invokes oclif's validation system without breaking the oclif black box.\n // Replace the original result with this one.\n const result = await super.parse<TFlags, TGlobalFlags, TArgs>(options, [\n // Need to specify argv default because we're merging with argsFromPreset.\n ...(argv || this.argv),\n ...argsFromPreset<TFlags, TGlobalFlags, TArgs>(preset, options, noDefaultsResult),\n ])\n\n // Report successful application of the preset.\n reportPresetApplication<TFlags, TGlobalFlags, TArgs>(noDefaultsResult.flags, result.flags, flags.preset, preset)\n\n return result\n }\n\n protected async presetsPath(rawFlags: {path?: string}): Promise<string> {\n return rawFlags.path || process.cwd()\n }\n\n protected findUpForPresets(): boolean {\n return true\n }\n}\n\nexport async function addFromParsedFlags(flags: {path?: string; verbose?: boolean}): Promise<void> {\n await addPublic(() => ({\n cmd_all_verbose: flags.verbose,\n cmd_all_path_override: flags.path !== undefined,\n cmd_all_path_override_hash: flags.path === undefined ? undefined : hashString(flags.path),\n }))\n}\n\n/**\n * Any flag which is:\n *\n * 1. Present in the final set of flags\n * 2. Specified in the preset\n * 3. Not specified by the user as a command line argument\n *\n * should be reported.\n *\n * It doesn't matter if the preset flag's value was the same as the default; from\n * the user's perspective, they want to know their preset was applied.\n */\nfunction reportPresetApplication<\n TFlags extends Interfaces.FlagOutput,\n TGlobalFlags extends Interfaces.FlagOutput,\n TArgs extends Interfaces.OutputArgs,\n>(\n noDefaultsFlags: Interfaces.ParserOutput<TFlags, TGlobalFlags, TArgs>['flags'],\n flagsWithPresets: Interfaces.ParserOutput<TFlags, TGlobalFlags, TArgs>['flags'],\n presetName: string,\n preset: JsonMap,\n): void {\n const changes: JsonMap = {}\n for (const [name, value] of Object.entries(flagsWithPresets)) {\n const userSpecifiedThisFlag = Object.prototype.hasOwnProperty.call(noDefaultsFlags, name)\n const presetContainsFlag = Object.prototype.hasOwnProperty.call(preset, name)\n if (!userSpecifiedThisFlag && presetContainsFlag) changes[name] = value\n }\n if (Object.keys(changes).length === 0) return\n info(content`Using applicable flags from the preset ${token.yellow(presetName)}:\n\n${Object.entries(changes)\n .map(([name, value]) => `• ${name} = ${value}`)\n .join('\\n')}\\n`)\n}\n\n/**\n * Strips the defaults from configured flags. For example, if flags contains:\n *\n * ```\n * someFlag: Flags.boolean({\n * description: 'some flag',\n * default: false\n * })\n * ```\n *\n * it becomes:\n *\n * ```\n * someFlag: Flags.boolean({\n * description: 'some flag'\n * })\n * ```\n *\n * If we parse using this configuration, the only specified flags will be those\n * the user actually passed on the command line.\n */\n\nfunction noDefaultsOptions<TFlags extends Interfaces.FlagOutput, TGlobalFlags extends Interfaces.FlagOutput>(\n options: Interfaces.Input<TFlags, TGlobalFlags> | undefined,\n): Interfaces.Input<TFlags, TGlobalFlags> | undefined {\n if (!options?.flags) return options\n return {\n ...options,\n flags: Object.fromEntries(\n Object.entries(options.flags).map(([label, settings]) => {\n const copiedSettings = {...(settings as {default?: unknown})}\n delete copiedSettings.default\n return [label, copiedSettings]\n }),\n ) as Interfaces.FlagInput<TFlags>,\n }\n}\n\n/**\n * Converts the preset's settings to arguments as though passed on the command\n * line, skipping any arguments the user specified on the command line.\n */\nfunction argsFromPreset<\n TFlags extends Interfaces.FlagOutput,\n TGlobalFlags extends Interfaces.FlagOutput,\n TArgs extends Interfaces.OutputArgs,\n>(\n preset: JsonMap,\n options: Interfaces.Input<TFlags, TGlobalFlags> | undefined,\n noDefaultsResult: Interfaces.ParserOutput<TFlags, TArgs>,\n): string[] {\n const args: string[] = []\n for (const [label, value] of Object.entries(preset)) {\n const flagIsRelevantToCommand = options?.flags && Object.prototype.hasOwnProperty.call(options.flags, label)\n const userSpecifiedThisFlag =\n noDefaultsResult.flags && Object.prototype.hasOwnProperty.call(noDefaultsResult.flags, label)\n if (flagIsRelevantToCommand && !userSpecifiedThisFlag) {\n if (typeof value === 'boolean') {\n if (value === true) {\n args.push(`--${label}`)\n } else {\n throw new Abort(\n content`Presets can only specify true for boolean flags. Attempted to set ${token.yellow(label)} to false.`,\n )\n }\n } else if (Array.isArray(value)) {\n value.forEach((element) => args.push(`--${label}`, `${element}`))\n } else {\n args.push(`--${label}`, `${value}`)\n }\n }\n }\n return args\n}\n\nexport default BaseCommand\n"]}
@@ -4,7 +4,7 @@ import { AbortError } from './error.js';
4
4
  * @param options - An options object that includes the file path, and the expected and actual MD5.
5
5
  * @returns An instance of Abort.
6
6
  */
7
- export declare const InvalidChecksumError: ({ file, expected, got }: {
7
+ export declare const InvalidChecksumError: ({ file, expected, got, }: {
8
8
  file: string;
9
9
  expected: string;
10
10
  got: string;
@@ -7,7 +7,7 @@ import md5File from 'md5-file';
7
7
  * @param options - An options object that includes the file path, and the expected and actual MD5.
8
8
  * @returns An instance of Abort.
9
9
  */
10
- export const InvalidChecksumError = ({ file, expected, got }) => {
10
+ export const InvalidChecksumError = ({ file, expected, got, }) => {
11
11
  return new AbortError(`The validation of ${file} failed. We expected the checksum ${expected}, but got ${got})`);
12
12
  };
13
13
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"checksum.js","sourceRoot":"","sources":["../../../src/public/node/checksum.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAC,MAAM,YAAY,CAAA;AACrC,OAAO,EAAC,KAAK,EAAC,MAAM,eAAe,CAAA;AACnC,OAAO,EAAC,KAAK,EAAE,KAAK,EAAC,MAAM,iBAAiB,CAAA;AAC5C,OAAO,OAAO,MAAM,UAAU,CAAA;AAE9B;;;;GAIG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,EAAC,IAAI,EAAE,QAAQ,EAAE,GAAG,EAAgD,EAAE,EAAE;IAC3G,OAAO,IAAI,UAAU,CAAC,qBAAqB,IAAI,qCAAqC,QAAQ,aAAa,GAAG,GAAG,CAAC,CAAA;AAClH,CAAC,CAAA;AACD;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,WAAW,CAAC,EAAC,IAAI,EAAE,UAAU,EAAqC;IACtF,KAAK,CAAC,wBAAwB,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,uBAAuB,KAAK,CAAC,IAAI,CAAC,KAAK,EAAE,UAAU,CAAC,EAAE,CAAC,CAAA;IACrG,MAAM,SAAS,GAAG,MAAM,OAAO,CAAC,IAAI,CAAC,CAAA;IACrC,MAAM,WAAW,GAAG,MAAM,KAAK,CAAC,UAAU,CAAC,CAAA;IAC3C,MAAM,WAAW,GAAG,MAAM,WAAW,CAAC,IAAI,EAAE,CAAA;IAC5C,MAAM,YAAY,GAAG,WAAW,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAE,CAAA;IAC/C,IAAI,CAAC,CAAC,YAAY,KAAK,SAAS,CAAC,EAAE;QACjC,MAAM,oBAAoB,CAAC;YACzB,IAAI;YACJ,GAAG,EAAE,SAAS;YACd,QAAQ,EAAE,YAAY;SACvB,CAAC,CAAA;KACH;AACH,CAAC","sourcesContent":["import {AbortError} from './error.js'\nimport {fetch} from '../../http.js'\nimport {debug, token} from '../../output.js'\nimport md5File from 'md5-file'\n\n/**\n * An error that's thrown when a file's MD5 doesn't match the expected value.\n * @param options - An options object that includes the file path, and the expected and actual MD5.\n * @returns An instance of Abort.\n */\nexport const InvalidChecksumError = ({file, expected, got}: {file: string; expected: string; got: string}) => {\n return new AbortError(`The validation of ${file} failed. We expected the checksum ${expected}, but got ${got})`)\n}\n/**\n * Given a local file and a URL pointing to a remote file representing the MD5 of a local file,\n * it validates the authenticity of the binary using an MD5 checksum.\n * @param options - The file to validate and the URL that points to the file containing the MD5.\n */\nexport async function validateMD5({file, md5FileURL}: {file: string; md5FileURL: string}) {\n debug(`Checking MD5 of file ${token.path(file)} against the MD5 in ${token.link('URL', md5FileURL)}`)\n const md5Digest = await md5File(file)\n const md5Response = await fetch(md5FileURL)\n const md5Contents = await md5Response.text()\n const canonicalMD5 = md5Contents.split(' ')[0]!\n if (!(canonicalMD5 === md5Digest)) {\n throw InvalidChecksumError({\n file,\n got: md5Digest,\n expected: canonicalMD5,\n })\n }\n}\n"]}
1
+ {"version":3,"file":"checksum.js","sourceRoot":"","sources":["../../../src/public/node/checksum.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAC,MAAM,YAAY,CAAA;AACrC,OAAO,EAAC,KAAK,EAAC,MAAM,eAAe,CAAA;AACnC,OAAO,EAAC,KAAK,EAAE,KAAK,EAAC,MAAM,iBAAiB,CAAA;AAC5C,OAAO,OAAO,MAAM,UAAU,CAAA;AAE9B;;;;GAIG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,EACnC,IAAI,EACJ,QAAQ,EACR,GAAG,GAKJ,EAAc,EAAE;IACf,OAAO,IAAI,UAAU,CAAC,qBAAqB,IAAI,qCAAqC,QAAQ,aAAa,GAAG,GAAG,CAAC,CAAA;AAClH,CAAC,CAAA;AACD;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,WAAW,CAAC,EAAC,IAAI,EAAE,UAAU,EAAqC;IACtF,KAAK,CAAC,wBAAwB,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,uBAAuB,KAAK,CAAC,IAAI,CAAC,KAAK,EAAE,UAAU,CAAC,EAAE,CAAC,CAAA;IACrG,MAAM,SAAS,GAAG,MAAM,OAAO,CAAC,IAAI,CAAC,CAAA;IACrC,MAAM,WAAW,GAAG,MAAM,KAAK,CAAC,UAAU,CAAC,CAAA;IAC3C,MAAM,WAAW,GAAG,MAAM,WAAW,CAAC,IAAI,EAAE,CAAA;IAC5C,MAAM,YAAY,GAAG,WAAW,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAE,CAAA;IAC/C,IAAI,CAAC,CAAC,YAAY,KAAK,SAAS,CAAC,EAAE;QACjC,MAAM,oBAAoB,CAAC;YACzB,IAAI;YACJ,GAAG,EAAE,SAAS;YACd,QAAQ,EAAE,YAAY;SACvB,CAAC,CAAA;KACH;AACH,CAAC","sourcesContent":["import {AbortError} from './error.js'\nimport {fetch} from '../../http.js'\nimport {debug, token} from '../../output.js'\nimport md5File from 'md5-file'\n\n/**\n * An error that's thrown when a file's MD5 doesn't match the expected value.\n * @param options - An options object that includes the file path, and the expected and actual MD5.\n * @returns An instance of Abort.\n */\nexport const InvalidChecksumError = ({\n file,\n expected,\n got,\n}: {\n file: string\n expected: string\n got: string\n}): AbortError => {\n return new AbortError(`The validation of ${file} failed. We expected the checksum ${expected}, but got ${got})`)\n}\n/**\n * Given a local file and a URL pointing to a remote file representing the MD5 of a local file,\n * it validates the authenticity of the binary using an MD5 checksum.\n * @param options - The file to validate and the URL that points to the file containing the MD5.\n */\nexport async function validateMD5({file, md5FileURL}: {file: string; md5FileURL: string}): Promise<void> {\n debug(`Checking MD5 of file ${token.path(file)} against the MD5 in ${token.link('URL', md5FileURL)}`)\n const md5Digest = await md5File(file)\n const md5Response = await fetch(md5FileURL)\n const md5Contents = await md5Response.text()\n const canonicalMD5 = md5Contents.split(' ')[0]!\n if (!(canonicalMD5 === md5Digest)) {\n throw InvalidChecksumError({\n file,\n got: md5Digest,\n expected: canonicalMD5,\n })\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"cli.js","sourceRoot":"","sources":["../../../src/public/node/cli.ts"],"names":[],"mappings":"AAWA,SAAS,yBAAyB,CAAC,OAA2C;IAC5E;;;;OAIG;IACH,IAAI,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,WAAW,CAAC,EAAE;QACtC,OAAO,CAAC,GAAG,CAAC,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,KAAK,IAAI,GAAG,C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AC,eAAe;QAClC,GAAG,eAAe,CAAC,YAAY;KAChC,CAAA;IACD,OAAO,gBAAgB,CAAC,cAAc,CAAC,CAAA;AACzC,CAAC;AAED,eAAe,MAAM,CAAA","sourcesContent":["/**\n * IMPORTANT NOTE: Imports in this module are dynamic to ensure that \"setupEnvironmentVariables\" can dynamically\n * set the DEBUG environment variable before the 'debug' package sets up its configuration when modules\n * are loaded statically.\n */\ninterface RunCLIOptions {\n /** The value of import.meta.url of the CLI executable module */\n moduleURL: string\n development: boolean\n}\n\nfunction setupEnvironmentVariables(options: Pick<RunCLIOptions, 'development'>) {\n /**\n * By setting DEBUG=* when --verbose is passed we are increasing the\n * verbosity of oclif. Oclif uses debug (https://www.npmjs.com/package/debug)\n * for logging, and it's configured through the DEBUG= environment variable.\n */\n if (process.argv.includes('--verbose')) {\n process.env.DEBUG = process.env.DEBUG ?? '*'\n }\n if (options.development) {\n process.env.SHOPIFY_CLI_ENV = process.env.SHOPIFY_CLI_ENV ?? 'development'\n }\n}\n\n/**\n * A function that abstracts away setting up the environment and running\n * a CLI\n * @param options - Options.\n */\nexport async function runCLI(options: RunCLIOptions) {\n setupEnvironmentVariables(options)\n /**\n * These imports need to be dynamic because if they are static\n * they are loaded before we set the DEBUG=* environment variable\n * and therefore it has no effect.\n */\n const {errorHandler} = await import('./error-handler.js')\n const {isDevelopment} = await import('../../environment/local.js')\n const {run, settings, flush} = await import('@oclif/core')\n\n if (isDevelopment()) {\n settings.debug = true\n }\n\n run(undefined, options.moduleURL)\n .then(() => flush())\n .catch(errorHandler)\n}\n\n/**\n * A function for create-x CLIs that automatically runs the \"init\" command.\n */\nexport async function runCreateCLI(options: RunCLIOptions) {\n setupEnvironmentVariables(options)\n\n const {findUpAndReadPackageJson} = await import('./node-package-manager.js')\n const {moduleDirectory} = await import('../../path.js')\n\n const packageJson = await findUpAndReadPackageJson(moduleDirectory(options.moduleURL))\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const packageName = (packageJson.content as any).name as string\n const name = packageName.replace('@shopify/create-', '')\n const initIndex = process.argv.findIndex((arg) => arg.includes('init'))\n if (initIndex === -1) {\n const initIndex =\n process.argv.findIndex((arg) => arg.match(new RegExp(`bin(\\\\/|\\\\\\\\)+(create-${name}|dev|run)`))) + 1\n process.argv.splice(initIndex, 0, 'init')\n }\n await runCLI(options)\n}\n\nexport async function useLocalCLIIfDetected(filepath: string): Promise<boolean> {\n const {isTruthy} = await import('../../environment/utilities.js')\n const constants = await import('../../constants.js')\n const {join} = await import('../../path.js')\n const {exec} = await import('../../system.js')\n\n // Temporary flag while we test out this feature and ensure it won't break anything!\n if (!isTruthy(process.env[constants.default.environmentVariables.enableCliRedirect])) return false\n\n // Setting an env variable in the child process prevents accidental recursion.\n if (isTruthy(process.env[constants.default.environmentVariables.skipCliRedirect])) return false\n\n // If already running via package manager, we can assume it's running correctly already.\n if (process.env.npm_config_user_agent) return false\n\n const cliPackage = await localCliPackage()\n if (!cliPackage) return false\n\n const correctExecutablePath = join(cliPackage.path, cliPackage.bin.shopify)\n if (correctExecutablePath === filepath) return false\n try {\n await exec(correctExecutablePath, process.argv.slice(2, process.argv.length), {\n stdio: 'inherit',\n env: {[constants.default.environmentVariables.skipCliRedirect]: '1'},\n })\n // eslint-disable-next-line no-catch-all/no-catch-all, @typescript-eslint/no-explicit-any\n } catch (processError: any) {\n process.exit(processError.exitCode)\n }\n return true\n}\n\ninterface CliPackageInfo {\n path: string\n bin: {shopify: string}\n}\n\ninterface PackageJSON {\n dependencies?: {[packageName: string]: CliPackageInfo}\n devDependencies?: {[packageName: string]: CliPackageInfo}\n peerDependencies?: {[packageName: string]: CliPackageInfo}\n}\n\nexport async function localCliPackage(): Promise<CliPackageInfo | undefined> {\n const {captureOutput} = await import('../../system.js')\n\n let npmListOutput = ''\n let localShopifyCLI: PackageJSON = {}\n try {\n npmListOutput = await captureOutput('npm', ['list', '@shopify/cli', '--json', '-l'])\n localShopifyCLI = JSON.parse(npmListOutput)\n // eslint-disable-next-line no-catch-all/no-catch-all\n } catch (err) {\n return\n }\n const dependenciesList = {\n ...localShopifyCLI.peerDependencies,\n ...localShopifyCLI.devDependencies,\n ...localShopifyCLI.dependencies,\n }\n return dependenciesList['@shopify/cli']\n}\n\nexport default runCLI\n"]}
1
+ {"version":3,"file":"cli.js","sourceRoot":"","sources":["../../../src/public/node/cli.ts"],"names":[],"mappings":"AAWA,SAAS,yBAAyB,CAAC,OAA2C;IAC5E;;;;OAIG;IACH,IAAI,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,WAAW,CAAC,EAAE;QACtC,OAAO,CAAC,GAAG,CAAC,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,KAAK,IAAI,GAAG,CAAA;KAC7C;IACD,IAAI,OAAO,CAAC,WAAW,EAAE;QACvB,OAAO,CAAC,GAAG,CAAC,eAAe,GAAG,OAAO,CAAC,GAAG,CAAC,eAAe,IAAI,aAAa,CAAA;KAC3E;AACH,CAAC;AAED;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,MAAM,CAAC,OAAsB;IACjD,yBAAyB,CAAC,OAAO,CAAC,CAAA;IAClC;;;;OAIG;IACH,MAAM,EAAC,YAAY,EAAC,GAAG,MAAM,MAAM,CAAC,oBAAoB,CAAC,CAAA;IACzD,MAAM,EAAC,aAAa,EAAC,GAAG,MAAM,MAAM,CAAC,4BAA4B,CAAC,CAAA;IAClE,MAAM,EAAC,GAAG,EAAE,QAAQ,EAAE,KAAK,EAAC,GAAG,MAAM,MAAM,CAAC,aAAa,CAAC,CAAA;IAE1D,IAAI,aAAa,EAAE,EAAE;QACnB,QAAQ,CAAC,KAAK,GAAG,IAAI,CAAA;KACtB;IAED,GAAG,CAAC,SAAS,EAAE,OAAO,CAAC,SAAS,CAAC;SAC9B,IAAI,CAAC,GAAG,EAAE,CAAC,KAAK,EAAE,CAAC;SACnB,KAAK,CAAC,YAAY,CAAC,CAAA;AACxB,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,Y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,MAAM,CAAC,iBAAiB,CAAC,CAAA;IAEvD,IAAI,aAAa,GAAG,EAAE,CAAA;IACtB,IAAI,eAAe,GAAgB,EAAE,CAAA;IACrC,IAAI;QACF,aAAa,GAAG,MAAM,aAAa,CAAC,KAAK,EAAE,CAAC,MAAM,EAAE,cAAc,EAAE,QAAQ,EAAE,IAAI,CAAC,CAAC,CAAA;QACpF,eAAe,GAAG,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC,CAAA;QAC3C,qDAAqD;KACtD;IAAC,OAAO,GAAG,EAAE;QACZ,OAAM;KACP;IACD,MAAM,gBAAgB,GAAG;QACvB,GAAG,eAAe,CAAC,gBAAgB;QACnC,GAAG,eAAe,CAAC,eAAe;QAClC,GAAG,eAAe,CAAC,YAAY;KAChC,CAAA;IACD,OAAO,gBAAgB,CAAC,cAAc,CAAC,CAAA;AACzC,CAAC;AAED,eAAe,MAAM,CAAA","sourcesContent":["/**\n * IMPORTANT NOTE: Imports in this module are dynamic to ensure that \"setupEnvironmentVariables\" can dynamically\n * set the DEBUG environment variable before the 'debug' package sets up its configuration when modules\n * are loaded statically.\n */\ninterface RunCLIOptions {\n /** The value of import.meta.url of the CLI executable module */\n moduleURL: string\n development: boolean\n}\n\nfunction setupEnvironmentVariables(options: Pick<RunCLIOptions, 'development'>) {\n /**\n * By setting DEBUG=* when --verbose is passed we are increasing the\n * verbosity of oclif. Oclif uses debug (https://www.npmjs.com/package/debug)\n * for logging, and it's configured through the DEBUG= environment variable.\n */\n if (process.argv.includes('--verbose')) {\n process.env.DEBUG = process.env.DEBUG ?? '*'\n }\n if (options.development) {\n process.env.SHOPIFY_CLI_ENV = process.env.SHOPIFY_CLI_ENV ?? 'development'\n }\n}\n\n/**\n * A function that abstracts away setting up the environment and running\n * a CLI\n * @param options - Options.\n */\nexport async function runCLI(options: RunCLIOptions): Promise<void> {\n setupEnvironmentVariables(options)\n /**\n * These imports need to be dynamic because if they are static\n * they are loaded before we set the DEBUG=* environment variable\n * and therefore it has no effect.\n */\n const {errorHandler} = await import('./error-handler.js')\n const {isDevelopment} = await import('../../environment/local.js')\n const {run, settings, flush} = await import('@oclif/core')\n\n if (isDevelopment()) {\n settings.debug = true\n }\n\n run(undefined, options.moduleURL)\n .then(() => flush())\n .catch(errorHandler)\n}\n\n/**\n * A function for create-x CLIs that automatically runs the \"init\" command.\n */\nexport async function runCreateCLI(options: RunCLIOptions): Promise<void> {\n setupEnvironmentVariables(options)\n\n const {findUpAndReadPackageJson} = await import('./node-package-manager.js')\n const {moduleDirectory} = await import('../../path.js')\n\n const packageJson = await findUpAndReadPackageJson(moduleDirectory(options.moduleURL))\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const packageName = (packageJson.content as any).name as string\n const name = packageName.replace('@shopify/create-', '')\n const initIndex = process.argv.findIndex((arg) => arg.includes('init'))\n if (initIndex === -1) {\n const initIndex =\n process.argv.findIndex((arg) => arg.match(new RegExp(`bin(\\\\/|\\\\\\\\)+(create-${name}|dev|run)`))) + 1\n process.argv.splice(initIndex, 0, 'init')\n }\n await runCLI(options)\n}\n\nexport async function useLocalCLIIfDetected(filepath: string): Promise<boolean> {\n const {isTruthy} = await import('../../environment/utilities.js')\n const constants = await import('../../constants.js')\n const {join} = await import('../../path.js')\n const {exec} = await import('../../system.js')\n\n // Temporary flag while we test out this feature and ensure it won't break anything!\n if (!isTruthy(process.env[constants.default.environmentVariables.enableCliRedirect])) return false\n\n // Setting an env variable in the child process prevents accidental recursion.\n if (isTruthy(process.env[constants.default.environmentVariables.skipCliRedirect])) return false\n\n // If already running via package manager, we can assume it's running correctly already.\n if (process.env.npm_config_user_agent) return false\n\n const cliPackage = await localCliPackage()\n if (!cliPackage) return false\n\n const correctExecutablePath = join(cliPackage.path, cliPackage.bin.shopify)\n if (correctExecutablePath === filepath) return false\n try {\n await exec(correctExecutablePath, process.argv.slice(2, process.argv.length), {\n stdio: 'inherit',\n env: {[constants.default.environmentVariables.skipCliRedirect]: '1'},\n })\n // eslint-disable-next-line no-catch-all/no-catch-all, @typescript-eslint/no-explicit-any\n } catch (processError: any) {\n process.exit(processError.exitCode)\n }\n return true\n}\n\ninterface CliPackageInfo {\n path: string\n bin: {shopify: string}\n}\n\ninterface PackageJSON {\n dependencies?: {[packageName: string]: CliPackageInfo}\n devDependencies?: {[packageName: string]: CliPackageInfo}\n peerDependencies?: {[packageName: string]: CliPackageInfo}\n}\n\nexport async function localCliPackage(): Promise<CliPackageInfo | undefined> {\n const {captureOutput} = await import('../../system.js')\n\n let npmListOutput = ''\n let localShopifyCLI: PackageJSON = {}\n try {\n npmListOutput = await captureOutput('npm', ['list', '@shopify/cli', '--json', '-l'])\n localShopifyCLI = JSON.parse(npmListOutput)\n // eslint-disable-next-line no-catch-all/no-catch-all\n } catch (err) {\n return\n }\n const dependenciesList = {\n ...localShopifyCLI.peerDependencies,\n ...localShopifyCLI.devDependencies,\n ...localShopifyCLI.dependencies,\n }\n return dependenciesList['@shopify/cli']\n}\n\nexport default runCLI\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"dot-env.js","sourceRoot":"","sources":["../../../src/public/node/dot-env.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAC,MAAM,YAAY,CAAA;AACrC,OAAO,EAAC,MAAM,EAAE,IAAI,IAAI,QAAQ,EAAE,KAAK,IAAI,SAAS,EAAC,MAAM,eAAe,CAAA;AAC1E,OAAO,EAAC,KAAK,EAAE,OAAO,IAAI,aAAa,EAAE,KAAK,EAAC,MAAM,iBAAiB,CAAA;AACtE,OAAO,EAAC,KAAK,EAAE,SAAS,EAAC,MAAM,SAAS,CAAA;AAExC;;;;GAIG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,IAAY,EAAE,EAAE;IAClD,OAAO,IAAI,UAAU,CAAC,2BAA2B,IAAI,kBAAkB,CAAC,CAAA;AAC1E,CAAC,CAAA;AAgBD;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,kBAAkB,CAAC,IAAY;IACnD,KAA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B,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;gBAC5B,WAAW,GAAG,MAAM,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAA;aACpC;SACF;QAED,WAAW,CAAC,IAAI,CAAC,WAAW,CAAC,CAAA;KAC9B;IAED,KAAK,MAAM,CAAC,QAAQ,EAAE,YAAY,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,aAAa,CAAC,EAAE;QACpE,IAAI,CAAC,kBAAkB,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE;YAC1C,WAAW,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,EAAE,YAAY,CAAC,CAAC,CAAA;SACjD;KACF;IAED,OAAO,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;AAC/B,CAAC","sourcesContent":["import {AbortError} from './error.js'\nimport {exists, read as readFile, write as writeFile} from '../../file.js'\nimport {debug, content as outputContent, token} from '../../output.js'\nimport {parse, stringify} from 'envfile'\n\n/**\n * Error that's thrown when the .env is not found.\n * @param path - Path to the .env file.\n * @returns An abort error.\n */\nexport const DotEnvNotFoundError = (path: string) => {\n return new AbortError(`The environment file at ${path} does not exist.`)\n}\n\n/**\n * This interface represents a .env file.\n */\nexport interface DotEnvFile {\n /**\n * Path to the .env file.\n */\n path: string\n /**\n * Variables of the .env file.\n */\n variables: {[name: string]: string}\n}\n\n/**\n * Reads and parses a .env file.\n * @param path - Path to the .env file\n * @returns An in-memory representation of the .env file.\n */\nexport async function readAndParseDotEnv(path: string): Promise<DotEnvFile> {\n debug(outputContent`Reading the .env file at ${token.path(path)}`)\n if (!(await exists(path))) {\n throw DotEnvNotFoundError(path)\n }\n const content = await readFile(path)\n return {\n path,\n variables: parse(content),\n }\n}\n\n/**\n * Writes a .env file to disk.\n * @param file - .env file to be written.\n */\nexport async function writeDotEnv(file: DotEnvFile) {\n await writeFile(file.path, stringify(file.variables))\n}\n\n/**\n * Given an .env file content, generates a new one with new values\n * without removing already existing lines.\n * @param envFileContent - .env file contents.\n * @param updatedValues - object containing new env variables values.\n */\nexport function patchEnvFile(\n envFileContent: string | null,\n updatedValues: {[key: string]: string | undefined},\n): string {\n const outputLines: string[] = []\n const lines = envFileContent === null ? [] : envFileContent.split('\\n')\n\n const alreadyPresentKeys: string[] = []\n\n const toLine = (key: string, value?: string) => `${key}=${value}`\n\n for (const line of lines) {\n const match = line.match(/^([^=:#]+?)[=:](.*)/)\n let lineToWrite = line\n\n if (match) {\n const key = match[1]!.trim()\n const newValue = updatedValues[key]\n if (newValue) {\n alreadyPresentKeys.push(key)\n lineToWrite = toLine(key, newValue)\n }\n }\n\n outputLines.push(lineToWrite)\n }\n\n for (const [patchKey, updatedValue] of Object.entries(updatedValues)) {\n if (!alreadyPresentKeys.includes(patchKey)) {\n outputLines.push(toLine(patchKey, updatedValue))\n }\n }\n\n return outputLines.join('\\n')\n}\n"]}
1
+ {"version":3,"file":"dot-env.js","sourceRoot":"","sources":["../../../src/public/node/dot-env.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAC,MAAM,YAAY,CAAA;AACrC,OAAO,EAAC,MAAM,EAAE,IAAI,IAAI,QAAQ,EAAE,KAAK,IAAI,SAAS,EAAC,MAAM,eAAe,CAAA;AAC1E,OAAO,EAAC,KAAK,EAAE,OAAO,IAAI,aAAa,EAAE,KAAK,EAAC,MAAM,iBAAiB,CAAA;AACtE,OAAO,EAAC,KAAK,EAAE,SAAS,EAAC,MAAM,SAAS,CAAA;AAExC;;;;GAIG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,IAAY,EAAc,EAAE;IAC9D,OAAO,IAAI,UAAU,CAAC,2BAA2B,IAAI,kBAAkB,CAAC,CAAA;AAC1E,CAAC,CAAA;AAgBD;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,kBAAkB,CAAC,IAAY;IACnD,KAAK,CAAC,aAAa,CAAA,4BAA4B,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;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QAAQ,CAAC,CAAA;aACpC;SACF;QAED,WAAW,CAAC,IAAI,CAAC,WAAW,CAAC,CAAA;KAC9B;IAED,KAAK,MAAM,CAAC,QAAQ,EAAE,YAAY,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,aAAa,CAAC,EAAE;QACpE,IAAI,CAAC,kBAAkB,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE;YAC1C,WAAW,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,EAAE,YAAY,CAAC,CAAC,CAAA;SACjD;KACF;IAED,OAAO,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;AAC/B,CAAC","sourcesContent":["import {AbortError} from './error.js'\nimport {exists, read as readFile, write as writeFile} from '../../file.js'\nimport {debug, content as outputContent, token} from '../../output.js'\nimport {parse, stringify} from 'envfile'\n\n/**\n * Error that's thrown when the .env is not found.\n * @param path - Path to the .env file.\n * @returns An abort error.\n */\nexport const DotEnvNotFoundError = (path: string): AbortError => {\n return new AbortError(`The environment file at ${path} does not exist.`)\n}\n\n/**\n * This interface represents a .env file.\n */\nexport interface DotEnvFile {\n /**\n * Path to the .env file.\n */\n path: string\n /**\n * Variables of the .env file.\n */\n variables: {[name: string]: string}\n}\n\n/**\n * Reads and parses a .env file.\n * @param path - Path to the .env file\n * @returns An in-memory representation of the .env file.\n */\nexport async function readAndParseDotEnv(path: string): Promise<DotEnvFile> {\n debug(outputContent`Reading the .env file at ${token.path(path)}`)\n if (!(await exists(path))) {\n throw DotEnvNotFoundError(path)\n }\n const content = await readFile(path)\n return {\n path,\n variables: parse(content),\n }\n}\n\n/**\n * Writes a .env file to disk.\n * @param file - .env file to be written.\n */\nexport async function writeDotEnv(file: DotEnvFile): Promise<void> {\n await writeFile(file.path, stringify(file.variables))\n}\n\n/**\n * Given an .env file content, generates a new one with new values\n * without removing already existing lines.\n * @param envFileContent - .env file contents.\n * @param updatedValues - object containing new env variables values.\n */\nexport function patchEnvFile(\n envFileContent: string | null,\n updatedValues: {[key: string]: string | undefined},\n): string {\n const outputLines: string[] = []\n const lines = envFileContent === null ? [] : envFileContent.split('\\n')\n\n const alreadyPresentKeys: string[] = []\n\n const toLine = (key: string, value?: string) => `${key}=${value}`\n\n for (const line of lines) {\n const match = line.match(/^([^=:#]+?)[=:](.*)/)\n let lineToWrite = line\n\n if (match) {\n const key = match[1]!.trim()\n const newValue = updatedValues[key]\n if (newValue) {\n alreadyPresentKeys.push(key)\n lineToWrite = toLine(key, newValue)\n }\n }\n\n outputLines.push(lineToWrite)\n }\n\n for (const [patchKey, updatedValue] of Object.entries(updatedValues)) {\n if (!alreadyPresentKeys.includes(patchKey)) {\n outputLines.push(toLine(patchKey, updatedValue))\n }\n }\n\n return outputLines.join('\\n')\n}\n"]}
@@ -1,8 +1,12 @@
1
+ import { AbortSilent, CancelExecution } from '../../error.js';
1
2
  import { Interfaces } from '@oclif/core';
2
3
  import { Event } from '@bugsnag/js';
4
+ export declare function errorHandler(error: (CancelExecution | AbortSilent) & {
5
+ exitCode?: number | undefined;
6
+ }, config?: Interfaces.Config): void;
3
7
  export declare function errorHandler(error: Error & {
4
8
  exitCode?: number | undefined;
5
- }, config?: Interfaces.Config): Promise<never> | undefined;
9
+ }, config?: Interfaces.Config): Promise<void>;
6
10
  /**
7
11
  * Sends an error to Bugsnag. This is configured automatically for uncaught errors from CLI commands, but can also be used to manually record an error.
8
12
  *
@@ -1 +1 @@
1
- {"version":3,"file":"error-handler.js","sourceRoot":"","sources":["../../../src/public/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,gBAAgB,CAAA;AACvB,OAAO,EAAC,KAAK,EAAE,IAAI,EAAC,MAAM,iBAAiB,CAAA;AAC3C,OAAO,EAAC,kBAAkB,EAAE,WAAW,EAAC,MAAM,oBAAoB,CAAA;AAClE,OAAO,KAAK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C,EAAE;YACnD,OAAO,CAAC,GAAG,CAAC,GAAG,KAAK,CAAA;SACrB;aAAM,IAAI,GAAG,CAAC,UAAU,CAAC,MAAM,CAAC,IAAI,WAAW,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE;YAC9D,WAAW,CAAC,GAAG,CAAC,GAAG,KAAK,CAAA;SACzB;aAAM,IAAI,GAAG,CAAC,UAAU,CAAC,MAAM,CAAC,IAAI,eAAe,EAAE;YACpD,eAAe,CAAC,GAAG,CAAC,GAAG,KAAK,CAAA;SAC7B;aAAM;YACL,QAAQ,CAAC,GAAG,CAAC,GAAG,KAAK,CAAA;SACtB;IACH,CAAC,CAAC,CAAA;IAEF,kCAAkC;IAClC,MAAM,eAAe,GAAG;QACtB,aAAa,EAAE,OAAO;QACtB,OAAO,EAAE,WAAW;QACpB,WAAW,EAAE,eAAe;QAC5B,IAAI,EAAE,QAAQ;KACf,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;AAED,KAAK,UAAU,iBAAiB;IAC9B,IAAI,OAAO,CAAC,SAAS,EAAE,EAAE;QACvB,OAAM;KACP;IACD,OAAO,CAAC,KAAK,CAAC;QACZ,OAAO,EAAE,MAAM;QACf,MAAM,EAAE,aAAa;QACrB,MAAM,EAAE,IAAI;QACZ,UAAU,EAAE,MAAM,SAAS,CAAC,QAAQ,CAAC,MAAM,EAAE;QAC7C,iBAAiB,EAAE,KAAK;QACxB,gBAAgB,EAAE,KAAK;KACxB,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 {getEnvironmentData, reportEvent} from '../../analytics.js'\nimport * as path from '../../path.js'\nimport * as metadata from '../../metadata.js'\nimport {fanoutHooks} from '../../plugins.js'\nimport constants, {bugsnagApiKey} from '../../constants.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) => {\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: unknown, config?: Interfaces.Config): Promise<void> => {\n if (config !== undefined) {\n // Log an analytics event when there's an error\n await reportEvent({config, errorMessage: error instanceof Error ? error.message : undefined})\n }\n await sendErrorToBugsnag(error)\n}\n\n/**\n * Sends an error to Bugsnag. This is configured automatically for uncaught errors from CLI commands, but can also be used to manually record an error.\n *\n * @returns the reported error (this may have been tweaked for better reporting), and a bool to indicate if the error was actually submitted or not\n */\nexport async function sendErrorToBugsnag(\n error: unknown,\n): Promise<{reported: false; error: unknown} | {error: Error; reported: true}> {\n if (settings.debug || !shouldReportError(error)) return {reported: false, error}\n\n let reportableError: Error\n let stacktrace: string | undefined\n let report = false\n\n if (error instanceof 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.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 initializeBugsnag()\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 {error: reportableError, reported: report}\n}\n\n/**\n * If the given file path is within a node_modules folder, remove prefix up\n * to and including the node_modules folder.\n *\n * This gives us very consistent paths for errors generated by the CLI.\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\n // strip prefix up to node_modules folder, so we can normalize error reporting\n return currentFilePath.replace(/.*node_modules\\//, '')\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(config: Interfaces.Config) {\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 config.plugins.map(async (plugin) => {\n const followSymlinks = await realpath(plugin.root)\n return {name: plugin.name, pluginPath: path.normalize(followSymlinks)}\n }),\n )\n await initializeBugsnag()\n Bugsnag.addOnError(async (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 await addBugsnagMetadata(event, config)\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 async function addBugsnagMetadata(event: Event, config: Interfaces.Config) {\n const publicData = metadata.getAllPublic()\n const {commandStartOptions} = metadata.getAllSensitive()\n const {startCommand} = commandStartOptions ?? {}\n\n const {'@shopify/app': appPublic, ...otherPluginsPublic} = await fanoutHooks(config, 'public_command_metadata', {})\n\n const environment = await getEnvironmentData(config)\n\n const allMetadata = {\n command: startCommand,\n ...appPublic,\n ...publicData,\n ...environment,\n pluginData: otherPluginsPublic,\n }\n\n const appData = {} as {[key: string]: unknown}\n const commandData = {} as {[key: string]: unknown}\n const environmentData = {} as {[key: string]: unknown}\n const miscData = {} as {[key: string]: unknown}\n const appKeys = ['api_key', 'partner_id', 'project_type']\n const commandKeys = ['command']\n const environmentKeys = ['cli_version', 'node_version', 'ruby_version', 'uname']\n\n Object.entries(allMetadata).forEach(([key, value]) => {\n if (key.startsWith('app_') || appKeys.includes(key)) {\n appData[key] = value\n } else if (key.startsWith('cmd_') || commandKeys.includes(key)) {\n commandData[key] = value\n } else if (key.startsWith('env_') || environmentKeys) {\n environmentData[key] = value\n } else {\n miscData[key] = value\n }\n })\n\n // app, command, environment, misc\n const bugsnagMetadata = {\n 'Shopify App': appData,\n Command: commandData,\n Environment: environmentData,\n Misc: miscData,\n }\n Object.entries(bugsnagMetadata).forEach(([section, values]) => {\n event.addMetadata(section, values)\n })\n}\n\nasync function initializeBugsnag() {\n if (Bugsnag.isStarted()) {\n return\n }\n Bugsnag.start({\n appType: 'node',\n apiKey: bugsnagApiKey,\n logger: null,\n appVersion: await constants.versions.cliKit(),\n autoTrackSessions: false,\n autoDetectErrors: false,\n })\n}\n"]}
1
+ {"version":3,"file":"error-handler.js","sourceRoot":"","sources":["../../../src/public/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,gBAAgB,CAAA;AACvB,OAAO,EAAC,KAAK,EAAE,IAAI,EAAC,MAAM,iBAAiB,CAAA;AAC3C,OAAO,EAAC,kBAAkB,EAAE,WAAW,EAAC,MAAM,oBAAoB,CAAA;AAClE,OAAO,KAAK,IAAI,MAAM,eAAe,CAAA;AACrC,OAAO,KAAK,QAAQ,MAAM,mBAAmB,CAAA;AAC7C,OAAO,EAAC,WAAW,EAAC,MAAM,kBAAkB,CAAA;AAC5C,OAAO,SAAS,EAAE,EAAC,aAAa,EAAC,MAAM,oBAAoB,CAAA;AAC3D,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;AAOpC,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,CAAC,CAAC,KAAK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,CAAA;AACJ,CAAC;AAED,KAAK,UAAU,iBAAiB;IAC9B,IAAI,OAAO,CAAC,SAAS,EAAE,EAAE;QACvB,OAAM;KACP;IACD,OAAO,CAAC,KAAK,CAAC;QACZ,OAAO,EAAE,MAAM;QACf,MAAM,EAAE,aAAa;QACrB,MAAM,EAAE,IAAI;QACZ,UAAU,EAAE,MAAM,SAAS,CAAC,QAAQ,CAAC,MAAM,EAAE;QAC7C,iBAAiB,EAAE,KAAK;QACxB,gBAAgB,EAAE,KAAK;KACxB,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 {getEnvironmentData, reportEvent} from '../../analytics.js'\nimport * as path from '../../path.js'\nimport * as metadata from '../../metadata.js'\nimport {fanoutHooks} from '../../plugins.js'\nimport constants, {bugsnagApiKey} from '../../constants.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(\n error: (CancelExecution | AbortSilent) & {exitCode?: number | undefined},\n config?: Interfaces.Config,\n): void\nexport function errorHandler(error: Error & {exitCode?: number | undefined}, config?: Interfaces.Config): Promise<void>\nexport function errorHandler(error: Error & {exitCode?: number | undefined}, config?: Interfaces.Config): unknown {\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) => {\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: unknown, config?: Interfaces.Config): Promise<void> => {\n if (config !== undefined) {\n // Log an analytics event when there's an error\n await reportEvent({config, errorMessage: error instanceof Error ? error.message : undefined})\n }\n await sendErrorToBugsnag(error)\n}\n\n/**\n * Sends an error to Bugsnag. This is configured automatically for uncaught errors from CLI commands, but can also be used to manually record an error.\n *\n * @returns the reported error (this may have been tweaked for better reporting), and a bool to indicate if the error was actually submitted or not\n */\nexport async function sendErrorToBugsnag(\n error: unknown,\n): Promise<{reported: false; error: unknown} | {error: Error; reported: true}> {\n if (settings.debug || !shouldReportError(error)) return {reported: false, error}\n\n let reportableError: Error\n let stacktrace: string | undefined\n let report = false\n\n if (error instanceof 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.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 initializeBugsnag()\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 {error: reportableError, reported: report}\n}\n\n/**\n * If the given file path is within a node_modules folder, remove prefix up\n * to and including the node_modules folder.\n *\n * This gives us very consistent paths for errors generated by the CLI.\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\n // strip prefix up to node_modules folder, so we can normalize error reporting\n return currentFilePath.replace(/.*node_modules\\//, '')\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(config: Interfaces.Config): Promise<void> {\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 config.plugins.map(async (plugin) => {\n const followSymlinks = await realpath(plugin.root)\n return {name: plugin.name, pluginPath: path.normalize(followSymlinks)}\n }),\n )\n await initializeBugsnag()\n Bugsnag.addOnError(async (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 await addBugsnagMetadata(event, config)\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 async function addBugsnagMetadata(event: Event, config: Interfaces.Config): Promise<void> {\n const publicData = metadata.getAllPublic()\n const {commandStartOptions} = metadata.getAllSensitive()\n const {startCommand} = commandStartOptions ?? {}\n\n const {'@shopify/app': appPublic, ...otherPluginsPublic} = await fanoutHooks(config, 'public_command_metadata', {})\n\n const environment = await getEnvironmentData(config)\n\n const allMetadata = {\n command: startCommand,\n ...appPublic,\n ...publicData,\n ...environment,\n pluginData: otherPluginsPublic,\n }\n\n const appData = {} as {[key: string]: unknown}\n const commandData = {} as {[key: string]: unknown}\n const environmentData = {} as {[key: string]: unknown}\n const miscData = {} as {[key: string]: unknown}\n const appKeys = ['api_key', 'partner_id', 'project_type']\n const commandKeys = ['command']\n const environmentKeys = ['cli_version', 'node_version', 'ruby_version', 'uname']\n\n Object.entries(allMetadata).forEach(([key, value]) => {\n if (key.startsWith('app_') || appKeys.includes(key)) {\n appData[key] = value\n } else if (key.startsWith('cmd_') || commandKeys.includes(key)) {\n commandData[key] = value\n } else if (key.startsWith('env_') || environmentKeys) {\n environmentData[key] = value\n } else {\n miscData[key] = value\n }\n })\n\n // app, command, environment, misc\n const bugsnagMetadata = {\n 'Shopify App': appData,\n Command: commandData,\n Environment: environmentData,\n Misc: miscData,\n }\n Object.entries(bugsnagMetadata).forEach(([section, values]) => {\n event.addMetadata(section, values)\n })\n}\n\nasync function initializeBugsnag() {\n if (Bugsnag.isStarted()) {\n return\n }\n Bugsnag.start({\n appType: 'node',\n apiKey: bugsnagApiKey,\n logger: null,\n appVersion: await constants.versions.cliKit(),\n autoTrackSessions: false,\n autoDetectErrors: false,\n })\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"framework.js","sourceRoot":"","sources":["../../../src/public/node/framework.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,IAAI,IAAI,QAAQ,EAAC,MAAM,eAAe,CAAA;AAC9C,OAAO,EAAC,UAAU,EAAE,YAAY,EAAC,MAAM,SAAS,CAAA;AA2ChD,MAAM,UAAU,GAAgB;IAC9B;QACE,IAAI,EAAE,OAAO;QACb,SAAS,EAAE;YACT,KAAK,EAAE;gBACL;oBACE,IAAI,EAAE,cAAc;oBACpB,YAAY,EAAE,sEAAsE;iBACrF;gBACD;oBACE,IAAI,EAAE,cAAc;oBACpB,YAAY,EAAE,4DAA4D;iBAC3E;aACF;SACF;KACF;IACD;QACE,IAAI,EAAE,QAAQ;QACd,SAA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AE;QACjC,OAAO,aAAa,CAAA;KACrB;IAED,MAAM,UAAU,GAAG,YAAY,CAAC,gBAAgB,EAAE,EAAC,QAAQ,EAAE,MAAM,EAAC,CAAC,CAAA;IAErE,aAAa,CAAC,gBAAgB,CAAC,GAAG,UAAU,CAAA;IAC5C,OAAO,aAAa,CAAA;AACtB,CAAC","sourcesContent":["import {join as pathJoin} from '../../path.js'\nimport {existsSync, readFileSync} from 'node:fs'\n\ninterface FrameworkDetectionPattern {\n /**\n * @example A file path\n * ```\n * \"package.json\"\n * ```\n */\n path: string\n /**\n * @example A matcher\n * ```\n * \"\\\"(dev)?(d|D)ependencies\\\":\\\\s*{[^}]*\\\"next\\\":\\\\s*\\\".+?\\\"[^}]*}\"\n * ```\n */\n matchContent?: string\n}\n\ninterface Framework {\n /**\n * Name of the framework\n * @example \"nextjs\"\n */\n name: string\n\n /**\n * Detectors used to find out the framework\n */\n detectors: {\n /**\n * Collection of detectors that must be matched for the framework\n * to be detected.\n */\n every?: FrameworkDetectionPattern[]\n /**\n * Collection of detectors where one match triggers the framework\n * to be detected.\n */\n some?: FrameworkDetectionPattern[]\n }\n}\n\nconst frameworks: Framework[] = [\n {\n name: 'remix',\n detectors: {\n every: [\n {\n path: 'package.json',\n matchContent: '\"(dev)?(d|D)ependencies\":\\\\s*{[^}]*\"@remix-run\\\\/.*\":\\\\s*\".+?\"[^}]*}',\n },\n {\n path: 'package.json',\n matchContent: '\"(dev)?(d|D)ependencies\":\\\\s*{[^}]*\"react\":\\\\s*\".+?\"[^}]*}',\n },\n ],\n },\n },\n {\n name: 'nextjs',\n detectors: {\n every: [\n {\n path: 'package.json',\n matchContent: '\"(dev)?(d|D)ependencies\":\\\\s*{[^}]*\"next\":\\\\s*\".+?\"[^}]*}',\n },\n {\n path: 'package.json',\n matchContent: '\"(dev)?(d|D)ependencies\":\\\\s*{[^}]*\"react\":\\\\s*\".+?\"[^}]*}',\n },\n ],\n },\n },\n {\n name: 'express',\n detectors: {\n every: [\n {\n path: 'package.json',\n matchContent: '\"(dev)?(d|D)ependencies\":\\\\s*{[^}]*\"express\":\\\\s*\".+?\"[^}]*}',\n },\n ],\n },\n },\n {\n name: 'rails',\n detectors: {\n every: [\n {\n path: 'Gemfile',\n matchContent: 'gem \"rails\"',\n },\n ],\n },\n },\n {\n name: 'flask',\n detectors: {\n every: [\n {\n path: 'Pipfile',\n matchContent: 'flask',\n },\n ],\n },\n },\n {\n name: 'django',\n detectors: {\n every: [\n {\n path: 'Pipfile',\n matchContent: 'django',\n },\n ],\n },\n },\n {\n name: 'laravel',\n detectors: {\n every: [\n {\n path: 'composer.json',\n matchContent: '\"require\":\\\\s*{[^}]*\"laravel/framework\":\\\\s*\".+?\"[^}]*}',\n },\n ],\n },\n },\n {\n name: 'symfony',\n detectors: {\n every: [\n {\n path: 'composer.json',\n matchContent: '\"require\":\\\\s*{[^}]*\"symfony\\\\/.*\":\\\\s*\".+?\"[^}]*}',\n },\n ],\n },\n },\n]\n\n/**\n * Tries to identify the using of a framework analyzing the existence and/or content of different files inside a\n * specific directory.\n *\n * @param rootDirectory - Directory from which the files required for each framework are searched\n * @returns The name of the framework used or 'unknown' otherwise\n */\nexport async function resolveFramework(rootDirectory: string) {\n const fwConfigFiles: {[key: string]: string | undefined} = {}\n\n const matchedFramework = frameworks.find(\n (framework) =>\n (!framework.detectors?.some ||\n framework.detectors?.some?.reduce(\n (_previousDetectorsMatch: boolean, detector) =>\n matchDetector(detector, loadFwConfigFile(rootDirectory, detector.path, fwConfigFiles)),\n false,\n )) &&\n (!framework.detectors?.every ||\n framework.detectors?.every?.reduce(\n (previousDetectorsMatch: boolean, detector) =>\n previousDetectorsMatch\n ? matchDetector(detector, loadFwConfigFile(rootDirectory, detector.path, fwConfigFiles))\n : false,\n true,\n )),\n )\n\n return matchedFramework ? matchedFramework.name : 'unknown'\n}\n\nfunction matchDetector(detector: FrameworkDetectionPattern, fwConfigFiles: {[key: string]: string | undefined} = {}) {\n if (!fwConfigFiles[detector.path]) return false\n\n return !detector.matchContent || new RegExp(detector.matchContent).test(fwConfigFiles[detector.path]!)\n}\n\nfunction loadFwConfigFile(\n rootPath: string,\n fwConfigFileName: string,\n fwConfigFiles: {[key: string]: string | undefined} = {},\n) {\n if (fwConfigFiles[fwConfigFileName]) {\n return fwConfigFiles\n }\n\n const fwConfigFilePath = pathJoin(rootPath, fwConfigFileName)\n if (!existsSync(fwConfigFilePath)) {\n return fwConfigFiles\n }\n\n const rawContent = readFileSync(fwConfigFilePath, {encoding: 'utf8'})\n\n fwConfigFiles[fwConfigFileName] = rawContent\n return fwConfigFiles\n}\n"]}
1
+ {"version":3,"file":"framework.js","sourceRoot":"","sources":["../../../src/public/node/framework.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,IAAI,IAAI,QAAQ,EAAC,MAAM,eAAe,CAAA;AAC9C,OAAO,EAAC,UAAU,EAAE,YAAY,EAAC,MAAM,SAAS,CAAA;AA2ChD,MAAM,UAAU,GAAgB;IAC9B;QACE,IAAI,EAAE,OAAO;QACb,SAAS,EAAE;YACT,KAAK,EAAE;gBACL;oBACE,IAAI,EAAE,cAAc;oBACpB,YAAY,EAAE,sEAAsE;iBACrF;gBACD;oBACE,IAAI,EAAE,cAAc;oBACpB,YAAY,EAAE,4DAA4D;iBAC3E;aACF;SACF;KACF;IACD;QACE,IAAI,EAAE,QAAQ;QACd,SAAS,EAAE;YACT,KAAK,EAAE;gBACL;oBACE,IAAI,EAAE,cAAc;oBACpB,YAAY,EAAE,2DAA2D;iBAC1E;gBACD;oBACE,IAAI,EAAE,cAAc;oBACpB,YAAY,EAAE,4DAA4D;iBAC3E;aACF;SACF;KACF;IACD;QACE,IAAI,EAAE,SAAS;QACf,SAAS,EAAE;YACT,KAAK,EAAE;gBACL;oBACE,IAAI,EAAE,cAAc;oBACpB,YAAY,EAAE,8DAA8D;iBAC7E;aACF;SACF;KACF;IACD;QACE,IAAI,EAAE,OAAO;QACb,SAAS,EAAE;YACT,KAAK,EAAE;gBACL;oBACE,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C,sBAAsB;gBACpB,CAAC,CAAC,aAAa,CAAC,QAAQ,EAAE,gBAAgB,CAAC,aAAa,EAAE,QAAQ,CAAC,IAAI,EAAE,aAAa,CAAC,CAAC;gBACxF,CAAC,CAAC,KAAK,EACX,IAAI,CACL,CAAC,CACP,CAAA;IAED,OAAO,gBAAgB,CAAC,CAAC,CAAC,gBAAgB,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,CAAA;AAC7D,CAAC;AAED,SAAS,aAAa,CAAC,QAAmC,EAAE,gBAAqD,EAAE;IACjH,IAAI,CAAC,aAAa,CAAC,QAAQ,CAAC,IAAI,CAAC;QAAE,OAAO,KAAK,CAAA;IAE/C,OAAO,CAAC,QAAQ,CAAC,YAAY,IAAI,IAAI,MAAM,CAAC,QAAQ,CAAC,YAAY,CAAC,CAAC,IAAI,CAAC,aAAa,CAAC,QAAQ,CAAC,IAAI,CAAE,CAAC,CAAA;AACxG,CAAC;AAED,SAAS,gBAAgB,CACvB,QAAgB,EAChB,gBAAwB,EACxB,gBAAqD,EAAE;IAEvD,IAAI,aAAa,CAAC,gBAAgB,CAAC,EAAE;QACnC,OAAO,aAAa,CAAA;KACrB;IAED,MAAM,gBAAgB,GAAG,QAAQ,CAAC,QAAQ,EAAE,gBAAgB,CAAC,CAAA;IAC7D,IAAI,CAAC,UAAU,CAAC,gBAAgB,CAAC,EAAE;QACjC,OAAO,aAAa,CAAA;KACrB;IAED,MAAM,UAAU,GAAG,YAAY,CAAC,gBAAgB,EAAE,EAAC,QAAQ,EAAE,MAAM,EAAC,CAAC,CAAA;IAErE,aAAa,CAAC,gBAAgB,CAAC,GAAG,UAAU,CAAA;IAC5C,OAAO,aAAa,CAAA;AACtB,CAAC","sourcesContent":["import {join as pathJoin} from '../../path.js'\nimport {existsSync, readFileSync} from 'node:fs'\n\ninterface FrameworkDetectionPattern {\n /**\n * @example A file path\n * ```\n * \"package.json\"\n * ```\n */\n path: string\n /**\n * @example A matcher\n * ```\n * \"\\\"(dev)?(d|D)ependencies\\\":\\\\s*{[^}]*\\\"next\\\":\\\\s*\\\".+?\\\"[^}]*}\"\n * ```\n */\n matchContent?: string\n}\n\ninterface Framework {\n /**\n * Name of the framework\n * @example \"nextjs\"\n */\n name: string\n\n /**\n * Detectors used to find out the framework\n */\n detectors: {\n /**\n * Collection of detectors that must be matched for the framework\n * to be detected.\n */\n every?: FrameworkDetectionPattern[]\n /**\n * Collection of detectors where one match triggers the framework\n * to be detected.\n */\n some?: FrameworkDetectionPattern[]\n }\n}\n\nconst frameworks: Framework[] = [\n {\n name: 'remix',\n detectors: {\n every: [\n {\n path: 'package.json',\n matchContent: '\"(dev)?(d|D)ependencies\":\\\\s*{[^}]*\"@remix-run\\\\/.*\":\\\\s*\".+?\"[^}]*}',\n },\n {\n path: 'package.json',\n matchContent: '\"(dev)?(d|D)ependencies\":\\\\s*{[^}]*\"react\":\\\\s*\".+?\"[^}]*}',\n },\n ],\n },\n },\n {\n name: 'nextjs',\n detectors: {\n every: [\n {\n path: 'package.json',\n matchContent: '\"(dev)?(d|D)ependencies\":\\\\s*{[^}]*\"next\":\\\\s*\".+?\"[^}]*}',\n },\n {\n path: 'package.json',\n matchContent: '\"(dev)?(d|D)ependencies\":\\\\s*{[^}]*\"react\":\\\\s*\".+?\"[^}]*}',\n },\n ],\n },\n },\n {\n name: 'express',\n detectors: {\n every: [\n {\n path: 'package.json',\n matchContent: '\"(dev)?(d|D)ependencies\":\\\\s*{[^}]*\"express\":\\\\s*\".+?\"[^}]*}',\n },\n ],\n },\n },\n {\n name: 'rails',\n detectors: {\n every: [\n {\n path: 'Gemfile',\n matchContent: 'gem \"rails\"',\n },\n ],\n },\n },\n {\n name: 'flask',\n detectors: {\n every: [\n {\n path: 'Pipfile',\n matchContent: 'flask',\n },\n ],\n },\n },\n {\n name: 'django',\n detectors: {\n every: [\n {\n path: 'Pipfile',\n matchContent: 'django',\n },\n ],\n },\n },\n {\n name: 'laravel',\n detectors: {\n every: [\n {\n path: 'composer.json',\n matchContent: '\"require\":\\\\s*{[^}]*\"laravel/framework\":\\\\s*\".+?\"[^}]*}',\n },\n ],\n },\n },\n {\n name: 'symfony',\n detectors: {\n every: [\n {\n path: 'composer.json',\n matchContent: '\"require\":\\\\s*{[^}]*\"symfony\\\\/.*\":\\\\s*\".+?\"[^}]*}',\n },\n ],\n },\n },\n]\n\n/**\n * Tries to identify the using of a framework analyzing the existence and/or content of different files inside a\n * specific directory.\n *\n * @param rootDirectory - Directory from which the files required for each framework are searched\n * @returns The name of the framework used or 'unknown' otherwise\n */\nexport async function resolveFramework(rootDirectory: string): Promise<string> {\n const fwConfigFiles: {[key: string]: string | undefined} = {}\n\n const matchedFramework = frameworks.find(\n (framework) =>\n (!framework.detectors?.some ||\n framework.detectors?.some?.reduce(\n (_previousDetectorsMatch: boolean, detector) =>\n matchDetector(detector, loadFwConfigFile(rootDirectory, detector.path, fwConfigFiles)),\n false,\n )) &&\n (!framework.detectors?.every ||\n framework.detectors?.every?.reduce(\n (previousDetectorsMatch: boolean, detector) =>\n previousDetectorsMatch\n ? matchDetector(detector, loadFwConfigFile(rootDirectory, detector.path, fwConfigFiles))\n : false,\n true,\n )),\n )\n\n return matchedFramework ? matchedFramework.name : 'unknown'\n}\n\nfunction matchDetector(detector: FrameworkDetectionPattern, fwConfigFiles: {[key: string]: string | undefined} = {}) {\n if (!fwConfigFiles[detector.path]) return false\n\n return !detector.matchContent || new RegExp(detector.matchContent).test(fwConfigFiles[detector.path]!)\n}\n\nfunction loadFwConfigFile(\n rootPath: string,\n fwConfigFileName: string,\n fwConfigFiles: {[key: string]: string | undefined} = {},\n) {\n if (fwConfigFiles[fwConfigFileName]) {\n return fwConfigFiles\n }\n\n const fwConfigFilePath = pathJoin(rootPath, fwConfigFileName)\n if (!existsSync(fwConfigFilePath)) {\n return fwConfigFiles\n }\n\n const rawContent = readFileSync(fwConfigFilePath, {encoding: 'utf8'})\n\n fwConfigFiles[fwConfigFileName] = rawContent\n return fwConfigFiles\n}\n"]}
@@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AACH,SAAS,kBAAkB,CAAC,WAAoB;IAC9C,IAAI,CAAC,WAAW,IAAI,CAAC,WAAW,CAAC,UAAU,CAAC,kBAAkB,CAAC,EAAE;QAC/D,OAAO,SAAS,CAAA;KACjB;IAED,OAAO,EAAC,OAAO,EAAE,WAAW,CAAC,SAAS,CAAC,WAAW,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,EAAC,CAAA;AACvE,CAAC;AAED;;;;;;GAMG;AACH,SAAS,UAAU,CAAC,GAAW;IAC7B,IAAI,GAAG,CAAC,WAAW,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE;QAC/B,OAAM;KACP;IACD,OAAO,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC,CAAA;AAC9D,CAAC;AAED;;;;;GAKG;AACH,SAAS,SAAS,CAAC,OAAiB;IAClC,MAAM,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE,CAC3C,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,UAAU,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC,CAC1E,CAAA;IACD,IAAI,aAAa,EAAE;QACjB,OAAO,aAAa,CAAC,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC,CAAA;KACxC;AACH,CAAC","sourcesContent":["import {start} from '../../../analytics.js'\nimport {debug} from '../../../output.js'\nimport Command from '../../../public/node/base-command.js'\nimport {Hook} from '@oclif/core'\n\nexport declare interface CommandContent {\n command: string\n topic?: string\n alias?: string\n}\n// This hook is called before each command run. More info: https://oclif.io/docs/hooks\nexport const hook: Hook.Prerun = async (options) => {\n const commandContent = parseCommandContent({\n id: options.Command.id,\n aliases: options.Command.aliases,\n pluginAlias: options.Command.plugin?.alias,\n })\n const args = options.argv\n debug(`Running command ${commandContent.command}`)\n await start({commandContent, args, commandClass: options.Command as unknown as typeof Command})\n}\n\nexport function parseCommandContent(cmdInfo: {id: string; aliases: string[]; pluginAlias?: string}) {\n let commandContent = parseCreateCommand(cmdInfo.pluginAlias)\n if (!commandContent) {\n commandContent = parseNormalCommand(cmdInfo.id, cmdInfo.aliases)\n }\n return commandContent\n}\n\nfunction parseNormalCommand(id: string, aliases: string[]): CommandContent {\n return {\n command: id.replace(/:/g, ' '),\n topic: parseTopic(id),\n alias: findAlias(aliases),\n }\n}\n\n/**\n * Create commands implement Init by default, so the name of the command must be extracted from\n * the plugin/module name. Neither alias or topic are supported\n *\n * @param commandClass - Oclif command configuration\n * @returns Command content with the name of the command or undefined otherwise\n */\nfunction parseCreateCommand(pluginAlias?: string): CommandContent | undefined {\n if (!pluginAlias || !pluginAlias.startsWith('@shopify/create-')) {\n return undefined\n }\n\n return {command: pluginAlias.substring(pluginAlias.indexOf('/') + 1)}\n}\n\n/**\n * Commands use this pattern topic:subtopic1:...:subtopicN:command. This method extract the topic and subtopic\n * information replacing the ':' separator with one space\n *\n * @param cmd - Complete command string to extract the topic information\n * @returns The topic name or undefined otherwise\n */\nfunction parseTopic(cmd: string) {\n if (cmd.lastIndexOf(':') === -1) {\n return\n }\n return cmd.slice(0, cmd.lastIndexOf(':')).replace(/:/g, ' ')\n}\n\n/**\n * Identifies if the command was launched using an alias instead of the oficial command name\n *\n * @param aliases - List of possible alias a command has\n * @returns The alias used or undefined otherwise\n */\nfunction findAlias(aliases: string[]) {\n const existingAlias = aliases.find((alias) =>\n alias.split(':').every((aliasToken) => process.argv.includes(aliasToken)),\n )\n if (existingAlias) {\n return existingAlias.replace(/:/g, ' ')\n }\n}\n"]}
1
+ {"version":3,"file":"prerun.js","sourceRoot":"","sources":["../../../../src/public/node/hooks/prerun.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,KAAK,EAAC,MAAM,uBAAuB,CAAA;AAC3C,OAAO,EAA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EAAC,OAAO,EAAE,WAAW,CAAC,SAAS,CAAC,WAAW,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,EAAC,CAAA;AACvE,CAAC;AAED;;;;;;GAMG;AACH,SAAS,UAAU,CAAC,GAAW;IAC7B,IAAI,GAAG,CAAC,WAAW,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE;QAC/B,OAAM;KACP;IACD,OAAO,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC,CAAA;AAC9D,CAAC;AAED;;;;;GAKG;AACH,SAAS,SAAS,CAAC,OAAiB;IAClC,MAAM,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE,CAC3C,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,UAAU,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC,CAC1E,CAAA;IACD,IAAI,aAAa,EAAE;QACjB,OAAO,aAAa,CAAC,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC,CAAA;KACxC;AACH,CAAC","sourcesContent":["import {start} from '../../../analytics.js'\nimport {debug} from '../../../output.js'\nimport Command from '../../../public/node/base-command.js'\nimport {Hook} from '@oclif/core'\n\nexport declare interface CommandContent {\n command: string\n topic?: string\n alias?: string\n}\n// This hook is called before each command run. More info: https://oclif.io/docs/hooks\nexport const hook: Hook.Prerun = async (options) => {\n const commandContent = parseCommandContent({\n id: options.Command.id,\n aliases: options.Command.aliases,\n pluginAlias: options.Command.plugin?.alias,\n })\n const args = options.argv\n debug(`Running command ${commandContent.command}`)\n await start({commandContent, args, commandClass: options.Command as unknown as typeof Command})\n}\n\nexport function parseCommandContent(cmdInfo: {id: string; aliases: string[]; pluginAlias?: string}): CommandContent {\n let commandContent = parseCreateCommand(cmdInfo.pluginAlias)\n if (!commandContent) {\n commandContent = parseNormalCommand(cmdInfo.id, cmdInfo.aliases)\n }\n return commandContent\n}\n\nfunction parseNormalCommand(id: string, aliases: string[]): CommandContent {\n return {\n command: id.replace(/:/g, ' '),\n topic: parseTopic(id),\n alias: findAlias(aliases),\n }\n}\n\n/**\n * Create commands implement Init by default, so the name of the command must be extracted from\n * the plugin/module name. Neither alias or topic are supported\n *\n * @param commandClass - Oclif command configuration\n * @returns Command content with the name of the command or undefined otherwise\n */\nfunction parseCreateCommand(pluginAlias?: string): CommandContent | undefined {\n if (!pluginAlias || !pluginAlias.startsWith('@shopify/create-')) {\n return undefined\n }\n\n return {command: pluginAlias.substring(pluginAlias.indexOf('/') + 1)}\n}\n\n/**\n * Commands use this pattern topic:subtopic1:...:subtopicN:command. This method extract the topic and subtopic\n * information replacing the ':' separator with one space\n *\n * @param cmd - Complete command string to extract the topic information\n * @returns The topic name or undefined otherwise\n */\nfunction parseTopic(cmd: string) {\n if (cmd.lastIndexOf(':') === -1) {\n return\n }\n return cmd.slice(0, cmd.lastIndexOf(':')).replace(/:/g, ' ')\n}\n\n/**\n * Identifies if the command was launched using an alias instead of the oficial command name\n *\n * @param aliases - List of possible alias a command has\n * @returns The alias used or undefined otherwise\n */\nfunction findAlias(aliases: string[]) {\n const existingAlias = aliases.find((alias) =>\n alias.split(':').every((aliasToken) => process.argv.includes(aliasToken)),\n )\n if (existingAlias) {\n return existingAlias.replace(/:/g, ' ')\n }\n}\n"]}