@shopify/cli-kit 3.0.27 → 3.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/dist/analytics.d.ts +3 -1
  3. package/dist/analytics.js +19 -4
  4. package/dist/analytics.js.map +1 -1
  5. package/dist/api/graphql/find_store_by_domain.d.ts +21 -0
  6. package/dist/api/graphql/find_store_by_domain.js +24 -0
  7. package/dist/api/graphql/find_store_by_domain.js.map +1 -0
  8. package/dist/api/graphql/index.d.ts +1 -0
  9. package/dist/api/graphql/index.js +1 -0
  10. package/dist/api/graphql/index.js.map +1 -1
  11. package/dist/index.d.ts +0 -1
  12. package/dist/index.js +0 -1
  13. package/dist/index.js.map +1 -1
  14. package/dist/node/cli.js +14 -9
  15. package/dist/node/cli.js.map +1 -1
  16. package/dist/{colors.d.ts → node/colors.d.ts} +0 -0
  17. package/dist/{colors.js → node/colors.js} +0 -0
  18. package/dist/node/colors.js.map +1 -0
  19. package/dist/{dependency.d.ts → node/node-package-manager.d.ts} +92 -23
  20. package/dist/{dependency.js → node/node-package-manager.js} +56 -49
  21. package/dist/node/node-package-manager.js.map +1 -0
  22. package/dist/node/ruby.js +1 -1
  23. package/dist/node/ruby.js.map +1 -1
  24. package/dist/output.d.ts +9 -2
  25. package/dist/output.js +17 -7
  26. package/dist/output.js.map +1 -1
  27. package/dist/port.js +23 -1
  28. package/dist/port.js.map +1 -1
  29. package/dist/tsconfig.tsbuildinfo +1 -1
  30. package/dist/ui/autocomplete.js +1 -1
  31. package/dist/ui/autocomplete.js.map +1 -1
  32. package/dist/ui/input.js +1 -1
  33. package/dist/ui/input.js.map +1 -1
  34. package/dist/ui/select.js +1 -1
  35. package/dist/ui/select.js.map +1 -1
  36. package/dist/version.js +1 -1
  37. package/dist/version.js.map +1 -1
  38. package/package.json +7 -3
  39. package/dist/colors.js.map +0 -1
  40. package/dist/dependency.js.map +0 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,18 @@
1
1
  # @shopify/cli-kit
2
2
 
3
+ ## 3.1.0
4
+
5
+ ### Minor Changes
6
+
7
+ - d17770e8: Massage error stacktraces to be properly formatted on Bugsnag
8
+ - d17770e8: Not report unhandled errors that go straight to the Node runtime
9
+
10
+ ### Patch Changes
11
+
12
+ - 740f73ac: Added a retrying implementation to the method that obtains a random local port. Occasionally that third party logic failed in the middle of the execution of a command and abort the process. Running the command for a second time solved that temporary problem
13
+ - de8ee02d: [FEATURE] Add query to fetch shop by domain
14
+ - 45f0f0b9: Bump theme-check version
15
+
3
16
  ## 3.0.27
4
17
 
5
18
  ### Patch Changes
@@ -1,6 +1,6 @@
1
1
  interface startOptions {
2
2
  command: string;
3
- args: string;
3
+ args: string[];
4
4
  currentTime?: number;
5
5
  }
6
6
  export declare const start: ({ command, args, currentTime }: startOptions) => void;
@@ -8,4 +8,6 @@ interface ReportEventOptions {
8
8
  errorMessage?: string;
9
9
  }
10
10
  export declare const reportEvent: (options?: ReportEventOptions) => Promise<void>;
11
+ export declare type ProjectType = 'node' | 'php' | 'ruby' | undefined;
12
+ export declare function getProjectType(directory: string): Promise<ProjectType>;
11
13
  export {};
package/dist/analytics.js CHANGED
@@ -2,10 +2,10 @@
2
2
  import * as environment from './environment.js';
3
3
  import { fetch } from './http.js';
4
4
  import { platformAndArch } from './os.js';
5
- import { join, resolve } from './path.js';
5
+ import { exists as fileExists } from './file.js';
6
+ import { join as joinPath, resolve } from './path.js';
6
7
  import { version as rubyVersion } from './node/ruby.js';
7
8
  import { debug, content, token } from './output.js';
8
- import { getProjectType } from './dependency.js';
9
9
  import constants from './constants.js';
10
10
  import { cliKitStore } from './store.js';
11
11
  const url = 'https://monorail-edge.shopifysvc.com/v1/produce';
@@ -75,9 +75,9 @@ const buildPayload = async (errorMessage, currentTime) => {
75
75
  return {
76
76
  schema_id: 'app_cli3_command/1.0',
77
77
  payload: {
78
- project_type: await getProjectType(join(directory, 'web')),
78
+ project_type: await getProjectType(joinPath(directory, 'web')),
79
79
  command: startCommand,
80
- args: startArgs,
80
+ args: startArgs.join(' '),
81
81
  time_start: startTime,
82
82
  time_end: currentTime,
83
83
  total_time: totalTime(currentTime),
@@ -93,4 +93,19 @@ const buildPayload = async (errorMessage, currentTime) => {
93
93
  },
94
94
  };
95
95
  };
96
+ export async function getProjectType(directory) {
97
+ const nodeConfigFile = joinPath(directory, 'package.json');
98
+ const rubyConfigFile = joinPath(directory, 'Gemfile');
99
+ const phpConfigFile = joinPath(directory, 'composer.json');
100
+ if (await fileExists(nodeConfigFile)) {
101
+ return 'node';
102
+ }
103
+ else if (await fileExists(rubyConfigFile)) {
104
+ return 'ruby';
105
+ }
106
+ else if (await fileExists(phpConfigFile)) {
107
+ return 'php';
108
+ }
109
+ return undefined;
110
+ }
96
111
  //# sourceMappingURL=analytics.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"analytics.js","sourceRoot":"","sources":["../src/analytics.ts"],"names":[],"mappings":"AAAA,yDAAyD;AACzD,OAAO,KAAK,WAAW,MAAM,kBAAkB,CAAA;AAC/C,OAAO,EAAC,KAAK,EAAC,MAAM,WAAW,CAAA;AAC/B,OAAO,EAAC,eAAe,EAAC,MAAM,SAAS,CAAA;AACvC,OAAO,EAAC,IAAI,EAAE,OAAO,EAAC,MAAM,WAAW,CAAA;AACvC,OAAO,EAAC,OAAO,IAAI,WAAW,EAAC,MAAM,gBAAgB,CAAA;AACrD,OAAO,EAAC,KAAK,EAAE,OAAO,EAAE,KAAK,EAAC,MAAM,aAAa,CAAA;AACjD,OAAO,EAAC,cAAc,EAAC,MAAM,iBAAiB,CAAA;AAC9C,OAAO,SAAS,MAAM,gBAAgB,CAAA;AACtC,OAAO,EAAC,WAAW,EAAC,MAAM,YAAY,CAAA;AAEtC,MAAM,GAAG,GAAG,iDAAiD,CAAA;AAC7D,IAAI,SAA6B,CAAA;AACjC,IAAI,YAAoB,CAAA;AACxB,IAAI,SAAiB,CAAA;AAQrB,MA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M,cAAc,CAAC,IAAI,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC;YAC1D,OAAO,EAAE,YAAY;YACrB,IAAI,EAAE,SAAS;YACf,UAAU,EAAE,SAAS;YACrB,QAAQ,EAAE,WAAW;YACrB,UAAU,EAAE,SAAS,CAAC,WAAW,CAAC;YAClC,OAAO,EAAE,YAAY,KAAK,SAAS;YACnC,aAAa,EAAE,YAAY;YAC3B,KAAK,EAAE,GAAG,QAAQ,IAAI,IAAI,EAAE;YAC5B,WAAW,EAAE,MAAM,SAAS,CAAC,QAAQ,CAAC,MAAM,EAAE;YAC9C,YAAY,EAAE,CAAC,MAAM,WAAW,EAAE,CAAC,IAAI,EAAE;YACzC,YAAY,EAAE,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,CAAC;YAC9C,WAAW,EAAE,MAAM,WAAW,CAAC,KAAK,CAAC,SAAS,EAAE;YAChD,OAAO,EAAE,OAAO,EAAE,KAAK;YACvB,UAAU,EAAE,cAAc;SAC3B;KACF,CAAA;AACH,CAAC,CAAA","sourcesContent":["/* eslint-disable @typescript-eslint/naming-convention */\nimport * as environment from './environment.js'\nimport {fetch} from './http.js'\nimport {platformAndArch} from './os.js'\nimport {join, resolve} from './path.js'\nimport {version as rubyVersion} from './node/ruby.js'\nimport {debug, content, token} from './output.js'\nimport {getProjectType} from './dependency.js'\nimport constants from './constants.js'\nimport {cliKitStore} from './store.js'\n\nconst url = 'https://monorail-edge.shopifysvc.com/v1/produce'\nlet startTime: number | undefined\nlet startCommand: string\nlet startArgs: string\n\ninterface startOptions {\n command: string\n args: string\n currentTime?: number\n}\n\nexport const start = ({command, args, currentTime = new Date().getTime()}: startOptions) => {\n startCommand = command\n startArgs = args\n startTime = currentTime\n}\n\ninterface ReportEventOptions {\n errorMessage?: string\n}\n\nexport const reportEvent = async (options: ReportEventOptions = {}) => {\n if (environment.local.analyticsDisabled()) return\n if (startCommand === undefined) return\n\n try {\n const currentTime = new Date().getTime()\n const payload = await buildPayload(options.errorMessage, currentTime)\n const body = JSON.stringify(payload)\n const headers = buildHeaders(currentTime)\n\n const response = await fetch(url, {method: 'POST', body, headers})\n if (response.status === 200) {\n debug(content`Analytics event sent: ${token.json(payload)}`)\n } else {\n debug(`Failed to report usage analytics: ${response.statusText}`)\n }\n // eslint-disable-next-line no-catch-all/no-catch-all\n } catch (error) {\n let message = 'Failed to report usage analytics'\n if (error instanceof Error) {\n message = message.concat(`: ${error.message}`)\n }\n debug(message)\n }\n}\n\nconst totalTime = (currentTime: number): number | undefined => {\n if (startTime === undefined) return undefined\n return currentTime - startTime\n}\n\nconst buildHeaders = (currentTime: number) => {\n return {\n 'Content-Type': 'application/json; charset=utf-8',\n 'X-Monorail-Edge-Event-Created-At-Ms': currentTime.toString(),\n 'X-Monorail-Edge-Event-Sent-At-Ms': currentTime.toString(),\n }\n}\n\nconst buildPayload = async (errorMessage: string | undefined, currentTime: number) => {\n let directory = process.cwd()\n const pathFlagIndex = startArgs.indexOf('--path')\n if (pathFlagIndex >= 0) {\n directory = resolve(startArgs[pathFlagIndex + 1])\n }\n const appInfo = cliKitStore().getAppInfo(directory)\n const {platform, arch} = platformAndArch()\n\n const rawPartnerId = appInfo?.orgId\n let partnerIdAsInt: number | undefined\n if (rawPartnerId !== undefined) {\n partnerIdAsInt = parseInt(rawPartnerId, 10)\n if (isNaN(partnerIdAsInt)) {\n partnerIdAsInt = undefined\n }\n }\n\n return {\n schema_id: 'app_cli3_command/1.0',\n payload: {\n project_type: await getProjectType(join(directory, 'web')),\n command: startCommand,\n args: startArgs,\n time_start: startTime,\n time_end: currentTime,\n total_time: totalTime(currentTime),\n success: errorMessage === undefined,\n error_message: errorMessage,\n uname: `${platform} ${arch}`,\n cli_version: await constants.versions.cliKit(),\n ruby_version: (await rubyVersion()) || '',\n node_version: process.version.replace('v', ''),\n is_employee: await environment.local.isShopify(),\n api_key: appInfo?.appId,\n partner_id: partnerIdAsInt,\n },\n }\n}\n"]}
1
+ {"version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,CAAC;YAC9C,WAAW,EAAE,MAAM,WAAW,CAAC,KAAK,CAAC,SAAS,EAAE;YAChD,OAAO,EAAE,OAAO,EAAE,KAAK;YACvB,UAAU,EAAE,cAAc;SAC3B;KACF,CAAA;AACH,CAAC,CAAA;AAID,MAAM,CAAC,KAAK,UAAU,cAAc,CAAC,SAAiB;IACpD,MAAM,cAAc,GAAG,QAAQ,CAAC,SAAS,EAAE,cAAc,CAAC,CAAA;IAC1D,MAAM,cAAc,GAAG,QAAQ,CAAC,SAAS,EAAE,SAAS,CAAC,CAAA;IACrD,MAAM,aAAa,GAAG,QAAQ,CAAC,SAAS,EAAE,eAAe,CAAC,CAAA;IAE1D,IAAI,MAAM,UAAU,CAAC,cAAc,CAAC,EAAE;QACpC,OAAO,MAAM,CAAA;KACd;SAAM,IAAI,MAAM,UAAU,CAAC,cAAc,CAAC,EAAE;QAC3C,OAAO,MAAM,CAAA;KACd;SAAM,IAAI,MAAM,UAAU,CAAC,aAAa,CAAC,EAAE;QAC1C,OAAO,KAAK,CAAA;KACb;IACD,OAAO,SAAS,CAAA;AAClB,CAAC","sourcesContent":["/* eslint-disable @typescript-eslint/naming-convention */\nimport * as environment from './environment.js'\nimport {fetch} from './http.js'\nimport {platformAndArch} from './os.js'\nimport {exists as fileExists} from './file.js'\nimport {join as joinPath, resolve} from './path.js'\nimport {version as rubyVersion} from './node/ruby.js'\nimport {debug, content, token} from './output.js'\nimport constants from './constants.js'\nimport {cliKitStore} from './store.js'\n\nconst url = 'https://monorail-edge.shopifysvc.com/v1/produce'\nlet startTime: number | undefined\nlet startCommand: string\nlet startArgs: string[]\n\ninterface startOptions {\n command: string\n args: string[]\n currentTime?: number\n}\n\nexport const start = ({command, args, currentTime = new Date().getTime()}: startOptions) => {\n startCommand = command\n startArgs = args\n startTime = currentTime\n}\n\ninterface ReportEventOptions {\n errorMessage?: string\n}\n\nexport const reportEvent = async (options: ReportEventOptions = {}) => {\n if (environment.local.analyticsDisabled()) return\n if (startCommand === undefined) return\n\n try {\n const currentTime = new Date().getTime()\n const payload = await buildPayload(options.errorMessage, currentTime)\n const body = JSON.stringify(payload)\n const headers = buildHeaders(currentTime)\n\n const response = await fetch(url, {method: 'POST', body, headers})\n if (response.status === 200) {\n debug(content`Analytics event sent: ${token.json(payload)}`)\n } else {\n debug(`Failed to report usage analytics: ${response.statusText}`)\n }\n // eslint-disable-next-line no-catch-all/no-catch-all\n } catch (error) {\n let message = 'Failed to report usage analytics'\n if (error instanceof Error) {\n message = message.concat(`: ${error.message}`)\n }\n debug(message)\n }\n}\n\nconst totalTime = (currentTime: number): number | undefined => {\n if (startTime === undefined) return undefined\n return currentTime - startTime\n}\n\nconst buildHeaders = (currentTime: number) => {\n return {\n 'Content-Type': 'application/json; charset=utf-8',\n 'X-Monorail-Edge-Event-Created-At-Ms': currentTime.toString(),\n 'X-Monorail-Edge-Event-Sent-At-Ms': currentTime.toString(),\n }\n}\n\nconst buildPayload = async (errorMessage: string | undefined, currentTime: number) => {\n let directory = process.cwd()\n const pathFlagIndex = startArgs.indexOf('--path')\n if (pathFlagIndex >= 0) {\n directory = resolve(startArgs[pathFlagIndex + 1])\n }\n const appInfo = cliKitStore().getAppInfo(directory)\n const {platform, arch} = platformAndArch()\n\n const rawPartnerId = appInfo?.orgId\n let partnerIdAsInt: number | undefined\n if (rawPartnerId !== undefined) {\n partnerIdAsInt = parseInt(rawPartnerId, 10)\n if (isNaN(partnerIdAsInt)) {\n partnerIdAsInt = undefined\n }\n }\n\n return {\n schema_id: 'app_cli3_command/1.0',\n payload: {\n project_type: await getProjectType(joinPath(directory, 'web')),\n command: startCommand,\n args: startArgs.join(' '),\n time_start: startTime,\n time_end: currentTime,\n total_time: totalTime(currentTime),\n success: errorMessage === undefined,\n error_message: errorMessage,\n uname: `${platform} ${arch}`,\n cli_version: await constants.versions.cliKit(),\n ruby_version: (await rubyVersion()) || '',\n node_version: process.version.replace('v', ''),\n is_employee: await environment.local.isShopify(),\n api_key: appInfo?.appId,\n partner_id: partnerIdAsInt,\n },\n }\n}\n\nexport type ProjectType = 'node' | 'php' | 'ruby' | undefined\n\nexport async function getProjectType(directory: string): Promise<ProjectType> {\n const nodeConfigFile = joinPath(directory, 'package.json')\n const rubyConfigFile = joinPath(directory, 'Gemfile')\n const phpConfigFile = joinPath(directory, 'composer.json')\n\n if (await fileExists(nodeConfigFile)) {\n return 'node'\n } else if (await fileExists(rubyConfigFile)) {\n return 'ruby'\n } else if (await fileExists(phpConfigFile)) {\n return 'php'\n }\n return undefined\n}\n"]}
@@ -0,0 +1,21 @@
1
+ export declare const FindStoreByDomainQuery: string;
2
+ export interface FindStoreByDomainSchema {
3
+ organizations: {
4
+ nodes: {
5
+ id: string;
6
+ businessName: string;
7
+ website: string;
8
+ appsNext: boolean;
9
+ stores: {
10
+ nodes: {
11
+ shopId: string;
12
+ link: string;
13
+ shopDomain: string;
14
+ shopName: string;
15
+ transferDisabled: boolean;
16
+ convertableToPartnerTest: boolean;
17
+ }[];
18
+ };
19
+ }[];
20
+ };
21
+ }
@@ -0,0 +1,24 @@
1
+ import { gql } from 'graphql-request';
2
+ export const FindStoreByDomainQuery = gql `
3
+ query FindOrganization($id: ID!, $shopDomain: String) {
4
+ organizations(id: $id, first: 1) {
5
+ nodes {
6
+ id
7
+ businessName
8
+ website
9
+ appsNext
10
+ stores(shopDomain: $shopDomain, first: 1, archived: false) {
11
+ nodes {
12
+ shopId
13
+ link
14
+ shopDomain
15
+ shopName
16
+ transferDisabled
17
+ convertableToPartnerTest
18
+ }
19
+ }
20
+ }
21
+ }
22
+ }
23
+ `;
24
+ //# sourceMappingURL=find_store_by_domain.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"find_store_by_domain.js","sourceRoot":"","sources":["../../../src/api/graphql/find_store_by_domain.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,GAAG,EAAC,MAAM,iBAAiB,CAAA;AAEnC,MAAM,CAAC,MAAM,sBAAsB,GAAG,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;CAqBxC,CAAA","sourcesContent":["import {gql} from 'graphql-request'\n\nexport const FindStoreByDomainQuery = gql`\n query FindOrganization($id: ID!, $shopDomain: String) {\n organizations(id: $id, first: 1) {\n nodes {\n id\n businessName\n website\n appsNext\n stores(shopDomain: $shopDomain, first: 1, archived: false) {\n nodes {\n shopId\n link\n shopDomain\n shopName\n transferDisabled\n convertableToPartnerTest\n }\n }\n }\n }\n }\n`\n\nexport interface FindStoreByDomainSchema {\n organizations: {\n nodes: {\n id: string\n businessName: string\n website: string\n appsNext: boolean\n stores: {\n nodes: {\n shopId: string\n link: string\n shopDomain: string\n shopName: string\n transferDisabled: boolean\n convertableToPartnerTest: boolean\n }[]\n }\n }[]\n }\n}\n"]}
@@ -19,3 +19,4 @@ export * from './functions/app_function_set.js';
19
19
  export * from './functions/compile_module.js';
20
20
  export * from './functions/module_compilation_status.js';
21
21
  export * from './find_org_basic.js';
22
+ export * from './find_store_by_domain.js';
@@ -19,4 +19,5 @@ export * from './functions/app_function_set.js';
19
19
  export * from './functions/compile_module.js';
20
20
  export * from './functions/module_compilation_status.js';
21
21
  export * from './find_org_basic.js';
22
+ export * from './find_store_by_domain.js';
22
23
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/api/graphql/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAA;AAC7B,cAAc,eAAe,CAAA;AAC7B,cAAc,iBAAiB,CAAA;AAC/B,cAAc,kBAAkB,CAAA;AAChC,cAAc,eAAe,CAAA;AAC7B,cAAc,mBAAmB,CAAA;AACjC,cAAc,iCAAiC,CAAA;AAC/C,cAAc,wBAAwB,CAAA;AACtC,cAAc,wBAAwB,CAAA;AACtC,cAAc,gCAAgC,CAAA;AAC9C,cAAc,uBAAuB,CAAA;AACrC,cAAc,+BAA+B,CAAA;AAC7C,cAAc,sCAAsC,CAAA;AACpD,cAAc,qBAAqB,CAAA;AACnC,cAAc,uCAAuC,CAAA;AACrD,cAAc,kCAAkC,CAAA;AAChD,cAAc,2CAA2C,CAAA;AACzD,cAAc,iCAAiC,CAAA;AAC/C,cAAc,+BAA+B,CAAA;AAC7C,cAAc,0CAA0C,CAAA;AACxD,cAAc,qBAAqB,CAAA","sourcesContent":["export * from './find_org.js'\nexport * from './all_orgs.js'\nexport * from './create_app.js'\nexport * from './update_urls.js'\nexport * from './find_app.js'\nexport * from './update_draft.js'\nexport * from './generate_signed_upload_url.js'\nexport * from './create_deployment.js'\nexport * from './all_stores_by_org.js'\nexport * from './convert_dev_to_test_store.js'\nexport * from './extension_create.js'\nexport * from './extension_specifications.js'\nexport * from './all_app_extension_registrations.js'\nexport * from './get_variant_id.js'\nexport * from './functions/function_service_proxy.js'\nexport * from './functions/get_app_functions.js'\nexport * from './functions/module_upload_url_generate.js'\nexport * from './functions/app_function_set.js'\nexport * from './functions/compile_module.js'\nexport * from './functions/module_compilation_status.js'\nexport * from './find_org_basic.js'\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/api/graphql/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAA;AAC7B,cAAc,eAAe,CAAA;AAC7B,cAAc,iBAAiB,CAAA;AAC/B,cAAc,kBAAkB,CAAA;AAChC,cAAc,eAAe,CAAA;AAC7B,cAAc,mBAAmB,CAAA;AACjC,cAAc,iCAAiC,CAAA;AAC/C,cAAc,wBAAwB,CAAA;AACtC,cAAc,wBAAwB,CAAA;AACtC,cAAc,gCAAgC,CAAA;AAC9C,cAAc,uBAAuB,CAAA;AACrC,cAAc,+BAA+B,CAAA;AAC7C,cAAc,sCAAsC,CAAA;AACpD,cAAc,qBAAqB,CAAA;AACnC,cAAc,uCAAuC,CAAA;AACrD,cAAc,kCAAkC,CAAA;AAChD,cAAc,2CAA2C,CAAA;AACzD,cAAc,iCAAiC,CAAA;AAC/C,cAAc,+BAA+B,CAAA;AAC7C,cAAc,0CAA0C,CAAA;AACxD,cAAc,qBAAqB,CAAA;AACnC,cAAc,2BAA2B,CAAA","sourcesContent":["export * from './find_org.js'\nexport * from './all_orgs.js'\nexport * from './create_app.js'\nexport * from './update_urls.js'\nexport * from './find_app.js'\nexport * from './update_draft.js'\nexport * from './generate_signed_upload_url.js'\nexport * from './create_deployment.js'\nexport * from './all_stores_by_org.js'\nexport * from './convert_dev_to_test_store.js'\nexport * from './extension_create.js'\nexport * from './extension_specifications.js'\nexport * from './all_app_extension_registrations.js'\nexport * from './get_variant_id.js'\nexport * from './functions/function_service_proxy.js'\nexport * from './functions/get_app_functions.js'\nexport * from './functions/module_upload_url_generate.js'\nexport * from './functions/app_function_set.js'\nexport * from './functions/compile_module.js'\nexport * from './functions/module_compilation_status.js'\nexport * from './find_org_basic.js'\nexport * from './find_store_by_domain.js'\n"]}
package/dist/index.d.ts CHANGED
@@ -3,7 +3,6 @@ export * as abort from './abort.js';
3
3
  export * as analytics from './analytics.js';
4
4
  export * as api from './api.js';
5
5
  export * as cli from './cli.js';
6
- export * as dependency from './dependency.js';
7
6
  export * as environment from './environment.js';
8
7
  export * as error from './error.js';
9
8
  export * as fastify from 'fastify';
package/dist/index.js CHANGED
@@ -3,7 +3,6 @@ export * as abort from './abort.js';
3
3
  export * as analytics from './analytics.js';
4
4
  export * as api from './api.js';
5
5
  export * as cli from './cli.js';
6
- export * as dependency from './dependency.js';
7
6
  export * as environment from './environment.js';
8
7
  export * as error from './error.js';
9
8
  export * as fastify from 'fastify';
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;AA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AAA","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 dependency from './dependency.js'\nexport * as environment from './environment.js'\nexport * as error from './error.js'\nexport * as fastify from 'fastify'\nexport * as file from './file.js'\nexport * as git from './git.js'\nexport * as github from './github.js'\nexport * as haiku from './haiku.js'\nexport * as http from './http.js'\nexport * as id from './id.js'\nexport * as npm from './npm.js'\nexport * as os from './os.js'\nexport * as output from './output.js'\nexport * as path from './path.js'\nexport * as plugins from './plugins.js'\nexport * as port from './port.js'\nexport * as schema from './schema.js'\nexport * as semver from './semver.js'\nexport * as session from './session.js'\nexport * as store from './store.js'\nexport * as string from './string.js'\nexport * as system from './system.js'\nexport * as template from './template.js'\nexport * as toml from './toml.js'\nexport * as ui from './ui.js'\nexport * as version from './version.js'\nexport * as vscode from './vscode.js'\nexport * as yaml from './yaml.js'\nexport * as outputMocker from './testing/output.js'\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,OAAO,IAAI,SAAS,EAAC,MAAM,gBAAgB,CAAA;AACnD,OAAO,KAAK,KAAK,MAAM,YAAY,CAAA;AACnC,OAAO,KAAK,SAAS,MAAM,gBAAgB,CAAA;AAC3C,OAAO,KAAK,GAAG,MAAM,UAAU,CAAA;AAC/B,OAAO,KAAK,GAAG,MAAM,UAAU,CAAA;AAC/B,OAAO,KAAK,WAAW,MAAM,kBAAkB,CAAA;AAC/C,OAAO,KAAK,KAAK,MAAM,YAAY,CAAA;AACnC,OAAO,KAAK,OAAO,MAAM,SAAS,CAAA;AAClC,OAAO,KAAK,IAAI,MAAM,WAAW,CAAA;AACjC,OAAO,KAAK,GAAG,MAAM,UAAU,CAAA;AAC/B,OAAO,KAAK,MAAM,MAAM,aAAa,CAAA;AACrC,OAAO,KAAK,KAAK,MAAM,YAAY,CAAA;AACnC,OAAO,KAAK,IAAI,MAAM,WAAW,CAAA;AACjC,OAAO,KAAK,EAAE,MAAM,SAAS,CAAA;AAC7B,OAAO,KAAK,GAAG,MAAM,UAAU,CAAA;AAC/B,OAAO,KAAK,EAAE,MAAM,SAAS,CAAA;AAC7B,OAAO,KAAK,MAAM,MAAM,aAAa,CAAA;AACrC,OAAO,KAAK,IAAI,MAAM,WAAW,CAAA;AACjC,OAAO,KAAK,OAAO,MAAM,cAAc,CAAA;AACvC,OAAO,KAAK,IAAI,MAAM,WAAW,CAAA;AACjC,OAAO,KAAK,MAAM,MAAM,aAAa,CAAA;AACrC,OAAO,KAAK,MAAM,MAAM,aAAa,CAAA;AACrC,OAAO,KAAK,OAAO,MAAM,cAAc,CAAA;AACvC,OAAO,KAAK,KAAK,MAAM,YAAY,CAAA;AACnC,OAAO,KAAK,MAAM,MAAM,aAAa,CAAA;AACrC,OAAO,KAAK,MAAM,MAAM,aAAa,CAAA;AACrC,OAAO,KAAK,QAAQ,MAAM,eAAe,CAAA;AACzC,OAAO,KAAK,IAAI,MAAM,WAAW,CAAA;AACjC,OAAO,KAAK,EAAE,MAAM,SAAS,CAAA;AAC7B,OAAO,KAAK,OAAO,MAAM,cAAc,CAAA;AACvC,OAAO,KAAK,MAAM,MAAM,aAAa,CAAA;AACrC,OAAO,KAAK,IAAI,MAAM,WAAW,CAAA;AACjC,OAAO,KAAK,YAAY,MAAM,qBAAqB,CAAA","sourcesContent":["export {default as constants} from './constants.js'\nexport * as abort from './abort.js'\nexport * as analytics from './analytics.js'\nexport * as api from './api.js'\nexport * as cli from './cli.js'\nexport * as environment from './environment.js'\nexport * as error from './error.js'\nexport * as fastify from 'fastify'\nexport * as file from './file.js'\nexport * as git from './git.js'\nexport * as github from './github.js'\nexport * as haiku from './haiku.js'\nexport * as http from './http.js'\nexport * as id from './id.js'\nexport * as npm from './npm.js'\nexport * as os from './os.js'\nexport * as output from './output.js'\nexport * as path from './path.js'\nexport * as plugins from './plugins.js'\nexport * as port from './port.js'\nexport * as schema from './schema.js'\nexport * as semver from './semver.js'\nexport * as session from './session.js'\nexport * as store from './store.js'\nexport * as string from './string.js'\nexport * as system from './system.js'\nexport * as template from './template.js'\nexport * as toml from './toml.js'\nexport * as ui from './ui.js'\nexport * as version from './version.js'\nexport * as vscode from './vscode.js'\nexport * as yaml from './yaml.js'\nexport * as outputMocker from './testing/output.js'\n"]}
package/dist/node/cli.js CHANGED
@@ -1,12 +1,13 @@
1
1
  // CLI
2
+ import { findUpAndReadPackageJson } from './node-package-manager.js';
2
3
  import { initializeCliKitStore } from '../store.js';
3
4
  import { initiateLogging } from '../output.js';
4
5
  import { isDebug } from '../environment/local.js';
5
6
  import constants, { bugsnagApiKey } from '../constants.js';
6
7
  import { reportEvent } from '../analytics.js';
7
8
  import { mapper as errorMapper, handler as errorHandler, AbortSilent, shouldReport as shouldReportError, } from '../error.js';
8
- import { findUpAndReadPackageJson } from '../dependency.js';
9
- import { moduleDirectory } from '../path.js';
9
+ import { moduleDirectory, normalize } from '../path.js';
10
+ import StackTracey from 'stacktracey';
10
11
  import { run, settings, flush } from '@oclif/core';
11
12
  import Bugsnag from '@bugsnag/js';
12
13
  /**
@@ -22,10 +23,12 @@ export async function runCLI(options) {
22
23
  }
23
24
  else {
24
25
  Bugsnag.start({
26
+ appType: 'node',
25
27
  apiKey: bugsnagApiKey,
26
28
  logger: null,
27
29
  appVersion: await constants.versions.cliKit(),
28
30
  autoTrackSessions: false,
31
+ autoDetectErrors: false,
29
32
  });
30
33
  }
31
34
  run(undefined, options.moduleURL)
@@ -36,10 +39,10 @@ export async function runCLI(options) {
36
39
  }
37
40
  // eslint-disable-next-line promise/no-nesting
38
41
  return errorMapper(error)
39
- .then(reportError)
40
42
  .then((error) => {
41
43
  return errorHandler(error);
42
44
  })
45
+ .then(reportError)
43
46
  .then(() => {
44
47
  process.exit(1);
45
48
  });
@@ -69,12 +72,14 @@ const reportError = async (errorToReport) => {
69
72
  // eslint-disable-next-line no-prototype-builtins
70
73
  if (Error.prototype.isPrototypeOf(errorToReport)) {
71
74
  mappedError = new Error(errorToReport.message);
72
- if (errorToReport.stack) {
73
- // For mac/linux, remove `file:///` from stacktrace
74
- // For windows, remove `file:///C:/` from stacktrace
75
- const regex = '\\((.*node_modules.)(@shopify.)?';
76
- mappedError.stack = errorToReport.stack.replace(new RegExp(regex, 'g'), '(');
77
- }
75
+ const mappedStacktrace = new StackTracey(errorToReport)
76
+ .clean()
77
+ .items.map((item) => {
78
+ const filePath = normalize(item.file).replace('file:/', '/').replace('C:/', '');
79
+ return ` at ${item.callee} (${filePath}:${item.line}:${item.column})`;
80
+ })
81
+ .join('\n');
82
+ mappedError.stack = `Error: ${errorToReport.message}\n${mappedStacktrace}`;
78
83
  }
79
84
  else if (typeof errorToReport === 'string') {
80
85
  mappedError = new Error(errorToReport);
@@ -1 +1 @@
1
- {"version":3,"file":"cli.js","sourceRoot":"","sources":["../../src/node/cli.ts"],"names":[],"mappings":"AAAA,MAAM;AACN,OAAO,EAAC,qBAAqB,EAAC,MAAM,aAAa,CAAA;AACjD,OAAO,EAAC,eAAe,EAAC,MAAM,cAAc,CAAA;AAC5C,OAAO,EAAC,OAAO,EAAC,MAAM,yBAAyB,CAAA;AAC/C,OAAO,SAAS,EAAE,EAAC,aAAa,EAAC,MAAM,iBAAiB,CAAA;AACxD,OAAO,EAAC,WAAW,EAAC,MAAM,iBAAiB,CAAA;AAC3C,OAAO,EACL,MAAM,IAAI,WAAW,EACrB,OAAO,IAAI,YAAY,EACvB,WAAW,EACX,YAAY,IAAI,iBAAiB,GAClC,MAAM,aAAa,CAAA;AACpB,OAAO,EAAC,wBAAwB,EAAC,MAAM,kBAAkB,CAAA;AACzD,OAAO,EAAC,eAAe,EAAC,MAAM,YAAY,CAAA;AAC1C,OAAO,EAAC,GAAG,EAAE,QAAQ,EAAE,KAAK,EAAC,MAAM,aAAa,CAAA;AAChD,OAAO,OAAO,MAAM,aAAa,CAAA;AASjC;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAA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WAAW,GAAG,IAAI,KAAK,CAAC,aAAa,CAAC,CAAA;KACvC;SAAM;QACL,WAAW,GAAG,IAAI,KAAK,CAAC,eAAe,CAAC,CAAA;KACzC;IAED,MAAM,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACpC,OAAO,CAAC,MAAM,CAAC,WAAW,EAAE,SAAS,EAAE,OAAO,CAAC,CAAA;IACjD,CAAC,CAAC,CAAA;IACF,OAAO,WAAW,CAAA;AACpB,CAAC,CAAA;AAED,eAAe,MAAM,CAAA","sourcesContent":["// CLI\nimport {initializeCliKitStore} from '../store.js'\nimport {initiateLogging} from '../output.js'\nimport {isDebug} from '../environment/local.js'\nimport constants, {bugsnagApiKey} from '../constants.js'\nimport {reportEvent} from '../analytics.js'\nimport {\n mapper as errorMapper,\n handler as errorHandler,\n AbortSilent,\n shouldReport as shouldReportError,\n} from '../error.js'\nimport {findUpAndReadPackageJson} from '../dependency.js'\nimport {moduleDirectory} from '../path.js'\nimport {run, settings, flush} from '@oclif/core'\nimport Bugsnag from '@bugsnag/js'\n\ninterface RunCLIOptions {\n /** The value of import.meta.url of the CLI executable module */\n moduleURL: string\n /** The logs file name */\n logFilename: string\n}\n\n/**\n * A function that abstracts away setting up the environment and running\n * a CLI\n * @param module {RunCLIOptions} Options.\n */\nexport async function runCLI(options: RunCLIOptions) {\n await initializeCliKitStore()\n initiateLogging({filename: options.logFilename})\n if (isDebug()) {\n settings.debug = true\n } else {\n Bugsnag.start({\n apiKey: bugsnagApiKey,\n logger: null,\n appVersion: await constants.versions.cliKit(),\n autoTrackSessions: false,\n })\n }\n\n run(undefined, options.moduleURL)\n .then(flush)\n .catch((error: Error): Promise<void | Error> => {\n if (error instanceof AbortSilent) {\n process.exit(1)\n }\n // eslint-disable-next-line promise/no-nesting\n return errorMapper(error)\n .then(reportError)\n .then((error: Error) => {\n return errorHandler(error)\n })\n .then(() => {\n process.exit(1)\n })\n })\n}\n\n/**\n * A function for create-x CLIs that automatically runs the \"init\" command.\n * @param options\n */\nexport async function runCreateCLI(options: RunCLIOptions) {\n const packageJson = await findUpAndReadPackageJson(moduleDirectory(options.moduleURL))\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const packageName = (packageJson.content as any).name as string\n const name = packageName.replace('@shopify/create-', '')\n const initIndex = process.argv.findIndex((arg) => arg.includes('init'))\n if (initIndex === -1) {\n const initIndex =\n process.argv.findIndex((arg) => arg.match(new RegExp(`bin(\\\\/|\\\\\\\\)+(create-${name}|dev|run)`))) + 1\n process.argv.splice(initIndex, 0, 'init')\n }\n await runCLI(options)\n}\n\nconst reportError = async (errorToReport: Error): Promise<Error> => {\n await reportEvent({errorMessage: errorToReport.message})\n if (settings.debug || !shouldReportError(errorToReport)) return errorToReport\n\n let mappedError: Error\n\n // eslint-disable-next-line no-prototype-builtins\n if (Error.prototype.isPrototypeOf(errorToReport)) {\n mappedError = new Error(errorToReport.message)\n if (errorToReport.stack) {\n // For mac/linux, remove `file:///` from stacktrace\n // For windows, remove `file:///C:/` from stacktrace\n const regex = '\\\\((.*node_modules.)(@shopify.)?'\n mappedError.stack = errorToReport.stack.replace(new RegExp(regex, 'g'), '(')\n }\n } else if (typeof errorToReport === 'string') {\n mappedError = new Error(errorToReport)\n } else {\n mappedError = new Error('Unknown error')\n }\n\n await new Promise((resolve, reject) => {\n Bugsnag.notify(mappedError, undefined, resolve)\n })\n return mappedError\n}\n\nexport default runCLI\n"]}
1
+ {"version":3,"file":"cli.js","sourceRoot":"","sources":["../../src/node/cli.ts"],"names":[],"mappings":"AAAA,MAAM;AACN,OAAO,EAAC,wBAAwB,EAAC,MAAM,2BAA2B,CAAA;AAClE,OAAO,EAAC,qBAAqB,EAAC,MAAM,aAAa,CAAA;AACjD,OAAO,EAAC,eAAe,EAAC,MAAM,cAAc,CAAA;AAC5C,OAAO,EAAC,OAAO,EAAC,MAAM,yBAAyB,CAAA;AAC/C,OAAO,SAAS,EAAE,EAAC,aAAa,EAAC,MAAM,iBAA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AAA;IAE7E,IAAI,WAAkB,CAAA;IAEtB,iDAAiD;IACjD,IAAI,KAAK,CAAC,SAAS,CAAC,aAAa,CAAC,aAAa,CAAC,EAAE;QAChD,WAAW,GAAG,IAAI,KAAK,CAAC,aAAa,CAAC,OAAO,CAAC,CAAA;QAC9C,MAAM,gBAAgB,GAAG,IAAI,WAAW,CAAC,aAAa,CAAC;aACpD,KAAK,EAAE;aACP,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE;YAClB,MAAM,QAAQ,GAAG,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAA;YAC/E,OAAO,UAAU,IAAI,CAAC,MAAM,KAAK,QAAQ,IAAI,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,MAAM,GAAG,CAAA;QAC1E,CAAC,CAAC;aACD,IAAI,CAAC,IAAI,CAAC,CAAA;QACb,WAAW,CAAC,KAAK,GAAG,UAAU,aAAa,CAAC,OAAO,KAAK,gBAAgB,EAAE,CAAA;KAC3E;SAAM,IAAI,OAAO,aAAa,KAAK,QAAQ,EAAE;QAC5C,WAAW,GAAG,IAAI,KAAK,CAAC,aAAa,CAAC,CAAA;KACvC;SAAM;QACL,WAAW,GAAG,IAAI,KAAK,CAAC,eAAe,CAAC,CAAA;KACzC;IAED,MAAM,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACpC,OAAO,CAAC,MAAM,CAAC,WAAW,EAAE,SAAS,EAAE,OAAO,CAAC,CAAA;IACjD,CAAC,CAAC,CAAA;IACF,OAAO,WAAW,CAAA;AACpB,CAAC,CAAA;AAED,eAAe,MAAM,CAAA","sourcesContent":["// CLI\nimport {findUpAndReadPackageJson} from './node-package-manager.js'\nimport {initializeCliKitStore} from '../store.js'\nimport {initiateLogging} from '../output.js'\nimport {isDebug} from '../environment/local.js'\nimport constants, {bugsnagApiKey} from '../constants.js'\nimport {reportEvent} from '../analytics.js'\nimport {\n mapper as errorMapper,\n handler as errorHandler,\n AbortSilent,\n shouldReport as shouldReportError,\n} from '../error.js'\nimport {moduleDirectory, normalize} from '../path.js'\nimport StackTracey from 'stacktracey'\nimport {run, settings, flush} from '@oclif/core'\nimport Bugsnag from '@bugsnag/js'\n\ninterface RunCLIOptions {\n /** The value of import.meta.url of the CLI executable module */\n moduleURL: string\n /** The logs file name */\n logFilename: string\n}\n\n/**\n * A function that abstracts away setting up the environment and running\n * a CLI\n * @param module {RunCLIOptions} Options.\n */\nexport async function runCLI(options: RunCLIOptions) {\n await initializeCliKitStore()\n initiateLogging({filename: options.logFilename})\n if (isDebug()) {\n settings.debug = true\n } else {\n Bugsnag.start({\n appType: 'node',\n apiKey: bugsnagApiKey,\n logger: null,\n appVersion: await constants.versions.cliKit(),\n autoTrackSessions: false,\n autoDetectErrors: false,\n })\n }\n\n run(undefined, options.moduleURL)\n .then(flush)\n .catch((error: Error): Promise<void | Error> => {\n if (error instanceof AbortSilent) {\n process.exit(1)\n }\n // eslint-disable-next-line promise/no-nesting\n return errorMapper(error)\n .then((error: Error) => {\n return errorHandler(error)\n })\n .then(reportError)\n .then(() => {\n process.exit(1)\n })\n })\n}\n\n/**\n * A function for create-x CLIs that automatically runs the \"init\" command.\n * @param options\n */\nexport async function runCreateCLI(options: RunCLIOptions) {\n const packageJson = await findUpAndReadPackageJson(moduleDirectory(options.moduleURL))\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const packageName = (packageJson.content as any).name as string\n const name = packageName.replace('@shopify/create-', '')\n const initIndex = process.argv.findIndex((arg) => arg.includes('init'))\n if (initIndex === -1) {\n const initIndex =\n process.argv.findIndex((arg) => arg.match(new RegExp(`bin(\\\\/|\\\\\\\\)+(create-${name}|dev|run)`))) + 1\n process.argv.splice(initIndex, 0, 'init')\n }\n await runCLI(options)\n}\n\nconst reportError = async (errorToReport: Error): Promise<Error> => {\n await reportEvent({errorMessage: errorToReport.message})\n if (settings.debug || !shouldReportError(errorToReport)) return errorToReport\n\n let mappedError: Error\n\n // eslint-disable-next-line no-prototype-builtins\n if (Error.prototype.isPrototypeOf(errorToReport)) {\n mappedError = new Error(errorToReport.message)\n const mappedStacktrace = new StackTracey(errorToReport)\n .clean()\n .items.map((item) => {\n const filePath = normalize(item.file).replace('file:/', '/').replace('C:/', '')\n return ` at ${item.callee} (${filePath}:${item.line}:${item.column})`\n })\n .join('\\n')\n mappedError.stack = `Error: ${errorToReport.message}\\n${mappedStacktrace}`\n } else if (typeof errorToReport === 'string') {\n mappedError = new Error(errorToReport)\n } else {\n mappedError = new Error('Unknown error')\n }\n\n await new Promise((resolve, reject) => {\n Bugsnag.notify(mappedError, undefined, resolve)\n })\n return mappedError\n}\n\nexport default runCLI\n"]}
File without changes
File without changes
@@ -0,0 +1 @@
1
+ {"version":3,"file":"colors.js","sourceRoot":"","sources":["../../src/node/colors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,aAAa,EAAC,MAAM,QAAQ,CAAA;AAEpC;;;GAGG;AACH,MAAM,OAAO,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;AAC9C,MAAM,CAAC,MAAM,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC,CAAA","sourcesContent":["import {createRequire} from 'module'\n\n/**\n * ansi-colors is a commonjs dependency that can be imported as a module.\n * This file is a wrapper to require and export ansi-colors.\n */\nconst require = createRequire(import.meta.url)\nexport const colors = require('ansi-colors')\n"]}
@@ -1,37 +1,57 @@
1
1
  /// <reference types="node" />
2
2
  /// <reference types="node" />
3
- import { Abort, Bug } from './error.js';
3
+ import { Abort, Bug } from '../error.js';
4
4
  import { AbortSignal } from 'abort-controller';
5
5
  import type { Writable } from 'node:stream';
6
- export declare const genericConfigurationFileNames: {
7
- readonly yarn: {
8
- readonly lockfile: "yarn.lock";
9
- };
10
- readonly pnpm: {
11
- readonly lockfile: "pnpm-lock.yaml";
12
- };
13
- };
14
- export declare const dependencyManager: readonly ["yarn", "npm", "pnpm"];
15
- export declare type DependencyManager = typeof dependencyManager[number];
6
+ /** The name of the Yarn lock file */
7
+ export declare const yarnLockfile = "yarn.lock";
8
+ /** The name of the pnpm lock file */
9
+ export declare const pnpmLockfile = "pnpm-lock.yaml";
10
+ /** An array containing the lockfiles from all the package managers */
11
+ export declare const lockfiles: string[];
12
+ /**
13
+ * A union type that represents the type of dependencies in the package.json
14
+ * - dev: devDependencies
15
+ * - prod: dependencies
16
+ * - peer: peerDependencies
17
+ */
18
+ export declare type DependencyType = 'dev' | 'prod' | 'peer';
19
+ /**
20
+ * A union that represents the package managers available.
21
+ */
22
+ export declare const packageManager: readonly ["yarn", "npm", "pnpm"];
23
+ export declare type PackageManager = typeof packageManager[number];
24
+ /**
25
+ * Returns an abort error that's thrown when a directory that's expected to have
26
+ * a package.json doesn't have it.
27
+ * @param directory {string} The path to the directory that should contain a package.json
28
+ * @returns {Abort} An abort error.
29
+ */
16
30
  export declare const PackageJsonNotFoundError: (directory: string) => Abort;
31
+ /**
32
+ * Returns a bug error that's thrown when the lookup of the package.json traversing the directory
33
+ * hierarchy up can't find a package.json
34
+ * @param directory {string} The directory from which the traverse has been done
35
+ * @returns {Abort} An abort error.
36
+ */
17
37
  export declare const FindUpAndReadPackageJsonNotFoundError: (directory: string) => Bug;
18
38
  /**
19
39
  * Returns the dependency manager used to run the create workflow.
20
40
  * @param env {Object} The environment variables of the process in which the CLI runs.
21
41
  * @returns The dependency manager
22
42
  */
23
- export declare function dependencyManagerUsedForCreating(env?: NodeJS.ProcessEnv): DependencyManager;
43
+ export declare function packageManagerUsedForCreating(env?: NodeJS.ProcessEnv): PackageManager;
24
44
  /**
25
45
  * Returns the dependency manager used by an existing project.
26
46
  * @param directory {string} The root directory of the project.
27
47
  * @returns The dependency manager
28
48
  */
29
- export declare function getDependencyManager(directory: string): Promise<DependencyManager>;
49
+ export declare function getPackageManager(directory: string): Promise<PackageManager>;
30
50
  interface InstallNPMDependenciesRecursivelyOptions {
31
51
  /**
32
52
  * The dependency manager to use to install the dependencies.
33
53
  */
34
- dependencyManager: DependencyManager;
54
+ packageManager: PackageManager;
35
55
  /**
36
56
  * The directory from where we'll find package.json's recursively
37
57
  */
@@ -51,13 +71,13 @@ export declare function installNPMDependenciesRecursively(options: InstallNPMDep
51
71
  /**
52
72
  * Installs the dependencies in the given directory.
53
73
  * @param directory {string} The directory that contains the package.json
54
- * @param dependencyManager {DependencyManager} The dependency manager to use to install the dependencies.
74
+ * @param packageManager {PackageManager} The package manager to use to install the dependencies.
55
75
  * @param stdout {Writable} Standard output stream.
56
76
  * @param stderr {Writable} Standard error stream.
57
77
  * @param signal {AbortSignal} Abort signal.
58
78
  * @returns stderr {Writable} Standard error stream.
59
79
  */
60
- export declare function install(directory: string, dependencyManager: DependencyManager, stdout?: Writable, stderr?: Writable, signal?: AbortSignal): Promise<void>;
80
+ export declare function installNodeModules(directory: string, packageManager: PackageManager, stdout?: Writable, stderr?: Writable, signal?: AbortSignal): Promise<void>;
61
81
  /**
62
82
  * Returns the name of the package configured in its package.json
63
83
  * @param packageJsonPath {string} Path to the package.json file
@@ -72,25 +92,55 @@ export declare function getPackageName(packageJsonPath: string): Promise<string>
72
92
  export declare function getDependencies(packageJsonPath: string): Promise<{
73
93
  [key: string]: string;
74
94
  }>;
95
+ /**
96
+ * Given an NPM dependency, it checks if there's a more recent version, and if there is, it returns its value.
97
+ * @param dependency {string} The dependency name (e.g. react)
98
+ * @param currentVersion {string} The current version.
99
+ * @returns {Promise<string>} A promise that resolves with a more recent version or undefined if there's no more recent version.
100
+ */
75
101
  export declare function checkForNewVersion(dependency: string, currentVersion: string): Promise<string | undefined>;
76
- export declare function getOutputUpdateCLIReminder(dependencyManager: DependencyManager, version: string): string;
77
- interface PackageJSONContents {
102
+ /**
103
+ * An interface that represents a package.json
104
+ */
105
+ interface PackageJson {
106
+ /**
107
+ * The absolute path to the package.json
108
+ */
109
+ path: string;
110
+ /**
111
+ * The name attribute of the package.json
112
+ */
78
113
  name: string;
114
+ /**
115
+ * The version attribute of the package.json
116
+ */
79
117
  version?: string;
118
+ /**
119
+ * The dependencies attribute of the package.json
120
+ */
80
121
  dependencies?: {
81
122
  [key: string]: string;
82
123
  };
124
+ /**
125
+ * The devDependencies attribute of the package.json
126
+ */
83
127
  devDependencies?: {
84
128
  [key: string]: string;
85
129
  };
86
130
  }
87
- export declare function packageJSONContents(packageJsonPath: string): Promise<PackageJSONContents>;
88
- export declare type DependencyType = 'dev' | 'prod' | 'peer';
131
+ /**
132
+ * Reads and parses a package.json
133
+ * @param packageJsonPath {string} Path to the package.json
134
+ * @returns {Promise<PackageJson>} An promise that resolves with an in-memory representation
135
+ * of the package.json or rejects with an error if the file is not found or the content is
136
+ * not decodable.
137
+ */
138
+ export declare function readAndParsePackageJson(packageJsonPath: string): Promise<PackageJson>;
89
139
  interface AddNPMDependenciesIfNeededOptions {
90
140
  /** How dependencies should be added */
91
141
  type: DependencyType;
92
142
  /** The dependency manager to use to add dependencies */
93
- dependencyManager: DependencyManager;
143
+ packageManager: PackageManager;
94
144
  /** The directory that contains the package.json where dependencies will be added */
95
145
  directory: string;
96
146
  /** Standard output coming from the underlying installation process */
@@ -100,8 +150,29 @@ interface AddNPMDependenciesIfNeededOptions {
100
150
  /** Abort signal to stop the process */
101
151
  signal?: AbortSignal;
102
152
  }
153
+ /**
154
+ * An interface that represents a dependency name with its version
155
+ */
103
156
  export interface DependencyVersion {
157
+ /**
158
+ * The name of the NPM dependency as it's reflected in the package.json:
159
+ *
160
+ * @example
161
+ * In the example below name would be "react"
162
+ * {
163
+ * "react": "1.2.3"
164
+ * }
165
+ */
104
166
  name: string;
167
+ /**
168
+ * The version of the NPM dependency as it's reflected in the package.json:
169
+ *
170
+ * @example
171
+ * In the example below version would be "1.2.3"
172
+ * {
173
+ * "react": "1.2.3"
174
+ * }
175
+ */
105
176
  version: string | undefined;
106
177
  }
107
178
  /**
@@ -112,8 +183,6 @@ export interface DependencyVersion {
112
183
  export declare function addNPMDependenciesIfNeeded(dependencies: DependencyVersion[], options: AddNPMDependenciesIfNeededOptions, force?: boolean): Promise<void>;
113
184
  export declare function addNPMDependenciesWithoutVersionIfNeeded(dependencies: string[], options: AddNPMDependenciesIfNeededOptions): Promise<void>;
114
185
  export declare function addLatestNPMDependencies(dependencies: string[], options: AddNPMDependenciesIfNeededOptions): Promise<void>;
115
- export declare type ProjectType = 'node' | 'php' | 'ruby' | undefined;
116
- export declare function getProjectType(directory: string): Promise<ProjectType>;
117
186
  /**
118
187
  * Given a directory it traverses the directory up looking for a package.json and if found, it reads it
119
188
  * decodes the JSON, and returns its content as a Javascript object.