@shopify/cli-hydrogen 3.31.1 → 3.32.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/README.md CHANGED
@@ -54,7 +54,7 @@ If you encounter issues using the CLI or have feedback you'd like to share with
54
54
 
55
55
  ## Contribute 👩🏽‍💻
56
56
 
57
- If you'd like to contribute to the project, check out the [contributors docs](/docs) and the [steps to get started](/docs/get-started.md).
57
+ If you'd like to contribute to the project, check out the [contributors docs](/docs) and the [steps to get started](/docs/cli/get-started.md).
58
58
 
59
59
  <p>&nbsp;</p>
60
60
 
@@ -1,9 +1,10 @@
1
1
  import { CreateDeploymentQuery, } from './graphql/create_deployment.js';
2
2
  import { UnrecoverableError, WebPageNotAvailable, TooManyRequestsError } from './error.js';
3
3
  import { UploadDeploymentQuery } from './graphql/upload_deployment.js';
4
- import { api, http, file } from '@shopify/cli-kit';
4
+ import { http, file } from '@shopify/cli-kit';
5
5
  import { zip } from '@shopify/cli-kit/node/archiver';
6
6
  import { ClientError } from 'graphql-request';
7
+ import { uploadOxygenDeploymentFile, oxygenRequest } from '@shopify/cli-kit/node/api/oxygen';
7
8
  export const createDeployment = async (config) => {
8
9
  const variables = {
9
10
  input: {
@@ -15,7 +16,7 @@ export const createDeployment = async (config) => {
15
16
  },
16
17
  };
17
18
  try {
18
- const response = await api.oxygen.request(config.oxygenAddress, CreateDeploymentQuery, config.deploymentToken, variables);
19
+ const response = await oxygenRequest(config.oxygenAddress, CreateDeploymentQuery, config.deploymentToken, variables);
19
20
  if (response.createDeployment?.error) {
20
21
  if (response.createDeployment.error.unrecoverable) {
21
22
  throw UnrecoverableError(response.createDeployment.error.debugInfo);
@@ -43,7 +44,7 @@ export const uploadDeployment = async (config, deploymentID) => {
43
44
  formData.append('operations', buildOperationsString(deploymentID));
44
45
  formData.append('map', JSON.stringify({ '0': ['variables.file'] }));
45
46
  formData.append('0', file.createReadStream(distZipPath), { filename: distZipPath });
46
- const response = await api.oxygen.uploadDeploymentFile(config.oxygenAddress, config.deploymentToken, formData);
47
+ const response = await uploadOxygenDeploymentFile(config.oxygenAddress, config.deploymentToken, formData);
47
48
  if (!response.ok) {
48
49
  if (response.status === 429) {
49
50
  throw TooManyRequestsError();
@@ -1 +1 @@
1
- {"version":3,"file":"upload.js","sourceRoot":"","sources":["../../../../src/cli/services/deploy/upload.ts"],"names":[],"mappings":"AACA,OAAO,EAGL,qBAAqB,GACtB,MAAM,gCAAgC,CAAA;AACvC,OAAO,EAAC,kBAAkB,EAAE,mBAAmB,EAAE,oBAAoB,EAAC,MAAM,YAAY,CAAA;AACxF,OAAO,EAAC,qBAAqB,EAAC,MAAM,gCAAgC,CAAA;AACpE,OAAO,EAAC,GAAG,EAAE,IAAI,EAAE,IAAI,EAAC,MAAM,kBAAkB,CAAA;AAChD,OAAO,EAAC,GAAG,EAAC,MAAM,gCAAgC,CAAA;AAClD,OAAO,EAAC,WAAW,EAAC,MAAM,iBAAiB,CAAA;AAE3C,MAAM,CAAC,MAAM,gBAAgB,GAAG,KAAK,EAAE,MAAuB,EAAqC,EAAE;IACnG,MAAM,SAAS,GAAG;QAChB,KAAK,EAAE;YACL,MAAM,EAAE,MAAM,CAAC,SAAS;YACxB,UAAU,EAAE,MAAM,CAAC,SAAS;YAC5B,YAAY,EAAE,MAAM,CAAC,YAAY;YACjC,aAAa,EAAE,MAAM,CAAC,aAAa;YACnC,eAAe,EAAE,MAAM,CAAC,SAAS;SAClC;KACF,CAAA;IAED,IAAI;QACF,MAAM,QAAQ,GAAgC,MAAM,GAAG,CAAC,MAAM,CAAC,OAAO,CACpE,MAAM,CAAC,aAAa,EACpB,qBAAqB,EACrB,MAAM,CAAC,eAAe,EACtB,SAAS,CACV,CAAA;QAED,IAAI,QAAQ,CAAC,gBAAgB,EAAE,KAAK,EAAE;YACpC,IAAI,QAAQ,CAAC,gBAAgB,CAAC,KAAK,CAAC,aAAa,EAAE;gBACjD,MAAM,kBAAkB,CAAC,QAAQ,CAA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D,IAAI,MAAM,CAAC,MAAM,KAAK,GAAG;QAAE,MAAM,mBAAmB,EAAE,CAAA;AACxD,CAAC,CAAA;AAED,MAAM,qBAAqB,GAAG,CAAC,YAAoB,EAAU,EAAE;IAC7D,OAAO,IAAI,CAAC,SAAS,CAAC;QACpB,KAAK,EAAE,qBAAqB;QAC5B,SAAS,EAAE,EAAC,YAAY,EAAE,IAAI,EAAE,IAAI,EAAC;KACtC,CAAC,CAAA;AACJ,CAAC,CAAA","sourcesContent":["import {ReqDeployConfig, UploadDeploymentResponse} from './types.js'\nimport {\n CreateDeploymentResponse,\n CreateDeploymentQuerySchema,\n CreateDeploymentQuery,\n} from './graphql/create_deployment.js'\nimport {UnrecoverableError, WebPageNotAvailable, TooManyRequestsError} from './error.js'\nimport {UploadDeploymentQuery} from './graphql/upload_deployment.js'\nimport {api, http, file} from '@shopify/cli-kit'\nimport {zip} from '@shopify/cli-kit/node/archiver'\nimport {ClientError} from 'graphql-request'\n\nexport const createDeployment = async (config: ReqDeployConfig): Promise<CreateDeploymentResponse> => {\n const variables = {\n input: {\n branch: config.commitRef,\n commitHash: config.commitSha,\n commitAuthor: config.commitAuthor,\n commitMessage: config.commitMessage,\n commitTimestamp: config.timestamp,\n },\n }\n\n try {\n const response: CreateDeploymentQuerySchema = await api.oxygen.request(\n config.oxygenAddress,\n CreateDeploymentQuery,\n config.deploymentToken,\n variables,\n )\n\n if (response.createDeployment?.error) {\n if (response.createDeployment.error.unrecoverable) {\n throw UnrecoverableError(response.createDeployment.error.debugInfo)\n }\n\n throw new Error(`Failed to create deployment. ${response.createDeployment.error.debugInfo}`)\n }\n\n return response.createDeployment\n } catch (error) {\n if (error instanceof ClientError) {\n if (error.response.status === 429) {\n throw TooManyRequestsError()\n }\n }\n\n throw error\n }\n}\n\nexport const uploadDeployment = async (config: ReqDeployConfig, deploymentID: string): Promise<string> => {\n let deploymentData: UploadDeploymentResponse | undefined\n\n await file.inTemporaryDirectory(async (tmpDir) => {\n const distPath = config.pathToBuild ? config.pathToBuild : `${config.path}/dist`\n const distZipPath = `${tmpDir}/dist.zip`\n await zip(distPath, distZipPath)\n\n const formData = http.formData()\n formData.append('operations', buildOperationsString(deploymentID))\n formData.append('map', JSON.stringify({'0': ['variables.file']}))\n formData.append('0', file.createReadStream(distZipPath), {filename: distZipPath})\n\n const response = await api.oxygen.uploadDeploymentFile(config.oxygenAddress, config.deploymentToken, formData)\n if (!response.ok) {\n if (response.status === 429) {\n throw TooManyRequestsError()\n }\n if (response.status !== 200 && response.status !== 202) {\n throw new Error(`Failed to upload deployment. ${await response.json()}`)\n }\n }\n\n deploymentData = (await response.json()) as UploadDeploymentResponse\n })\n\n if (!deploymentData) {\n throw new Error('Failed to upload deployment.')\n }\n const deploymentError = deploymentData.data?.uploadDeployment?.error\n if (deploymentError) {\n if (deploymentError.unrecoverable) {\n throw UnrecoverableError(deploymentError.debugInfo)\n }\n\n throw new Error(`Failed to upload deployment: ${deploymentError.debugInfo}`)\n }\n\n return deploymentData.data.uploadDeployment.deployment.previewURL\n}\n\nexport const healthCheck = async (pingUrl: string) => {\n const url = `${pingUrl}/__health`\n const result = await http.fetch(url, {method: 'GET'})\n if (result.status !== 200) throw WebPageNotAvailable()\n}\n\nconst buildOperationsString = (deploymentID: string): string => {\n return JSON.stringify({\n query: UploadDeploymentQuery,\n variables: {deploymentID, file: null},\n })\n}\n"]}
1
+ {"version":3,"file":"upload.js","sourceRoot":"","sources":["../../../../src/cli/services/deploy/upload.ts"],"names":[],"mappings":"AACA,OAAO,EAGL,qBAAqB,GACtB,MAAM,gCAAgC,CAAA;AACvC,OAAO,EAAC,kBAAkB,EAAE,mBAAmB,EAAE,oBAAoB,EAAC,MAAM,YAAY,CAAA;AACxF,OAAO,EAAC,qBAAqB,EAAC,MAAM,gCAAgC,CAAA;AACpE,OAAO,EAAC,IAAI,EAAE,IAAI,EAAC,MAAM,kBAAkB,CAAA;AAC3C,OAAO,EAAC,GAAG,EAAC,MAAM,gCAAgC,CAAA;AA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C,CAAA;IAEF,IAAI,CAAC,cAAc,EAAE;QACnB,MAAM,IAAI,KAAK,CAAC,8BAA8B,CAAC,CAAA;KAChD;IACD,MAAM,eAAe,GAAG,cAAc,CAAC,IAAI,EAAE,gBAAgB,EAAE,KAAK,CAAA;IACpE,IAAI,eAAe,EAAE;QACnB,IAAI,eAAe,CAAC,aAAa,EAAE;YACjC,MAAM,kBAAkB,CAAC,eAAe,CAAC,SAAS,CAAC,CAAA;SACpD;QAED,MAAM,IAAI,KAAK,CAAC,gCAAgC,eAAe,CAAC,SAAS,EAAE,CAAC,CAAA;KAC7E;IAED,OAAO,cAAc,CAAC,IAAI,CAAC,gBAAgB,CAAC,UAAU,CAAC,UAAU,CAAA;AACnE,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,WAAW,GAAG,KAAK,EAAE,OAAe,EAAE,EAAE;IACnD,MAAM,GAAG,GAAG,GAAG,OAAO,WAAW,CAAA;IACjC,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,GAAG,EAAE,EAAC,MAAM,EAAE,KAAK,EAAC,CAAC,CAAA;IACrD,IAAI,MAAM,CAAC,MAAM,KAAK,GAAG;QAAE,MAAM,mBAAmB,EAAE,CAAA;AACxD,CAAC,CAAA;AAED,MAAM,qBAAqB,GAAG,CAAC,YAAoB,EAAU,EAAE;IAC7D,OAAO,IAAI,CAAC,SAAS,CAAC;QACpB,KAAK,EAAE,qBAAqB;QAC5B,SAAS,EAAE,EAAC,YAAY,EAAE,IAAI,EAAE,IAAI,EAAC;KACtC,CAAC,CAAA;AACJ,CAAC,CAAA","sourcesContent":["import {ReqDeployConfig, UploadDeploymentResponse} from './types.js'\nimport {\n CreateDeploymentResponse,\n CreateDeploymentQuerySchema,\n CreateDeploymentQuery,\n} from './graphql/create_deployment.js'\nimport {UnrecoverableError, WebPageNotAvailable, TooManyRequestsError} from './error.js'\nimport {UploadDeploymentQuery} from './graphql/upload_deployment.js'\nimport {http, file} from '@shopify/cli-kit'\nimport {zip} from '@shopify/cli-kit/node/archiver'\nimport {ClientError} from 'graphql-request'\nimport {uploadOxygenDeploymentFile, oxygenRequest} from '@shopify/cli-kit/node/api/oxygen'\n\nexport const createDeployment = async (config: ReqDeployConfig): Promise<CreateDeploymentResponse> => {\n const variables = {\n input: {\n branch: config.commitRef,\n commitHash: config.commitSha,\n commitAuthor: config.commitAuthor,\n commitMessage: config.commitMessage,\n commitTimestamp: config.timestamp,\n },\n }\n\n try {\n const response: CreateDeploymentQuerySchema = await oxygenRequest(\n config.oxygenAddress,\n CreateDeploymentQuery,\n config.deploymentToken,\n variables,\n )\n\n if (response.createDeployment?.error) {\n if (response.createDeployment.error.unrecoverable) {\n throw UnrecoverableError(response.createDeployment.error.debugInfo)\n }\n\n throw new Error(`Failed to create deployment. ${response.createDeployment.error.debugInfo}`)\n }\n\n return response.createDeployment\n } catch (error) {\n if (error instanceof ClientError) {\n if (error.response.status === 429) {\n throw TooManyRequestsError()\n }\n }\n\n throw error\n }\n}\n\nexport const uploadDeployment = async (config: ReqDeployConfig, deploymentID: string): Promise<string> => {\n let deploymentData: UploadDeploymentResponse | undefined\n\n await file.inTemporaryDirectory(async (tmpDir) => {\n const distPath = config.pathToBuild ? config.pathToBuild : `${config.path}/dist`\n const distZipPath = `${tmpDir}/dist.zip`\n await zip(distPath, distZipPath)\n\n const formData = http.formData()\n formData.append('operations', buildOperationsString(deploymentID))\n formData.append('map', JSON.stringify({'0': ['variables.file']}))\n formData.append('0', file.createReadStream(distZipPath), {filename: distZipPath})\n\n const response = await uploadOxygenDeploymentFile(config.oxygenAddress, config.deploymentToken, formData)\n if (!response.ok) {\n if (response.status === 429) {\n throw TooManyRequestsError()\n }\n if (response.status !== 200 && response.status !== 202) {\n throw new Error(`Failed to upload deployment. ${await response.json()}`)\n }\n }\n\n deploymentData = (await response.json()) as UploadDeploymentResponse\n })\n\n if (!deploymentData) {\n throw new Error('Failed to upload deployment.')\n }\n const deploymentError = deploymentData.data?.uploadDeployment?.error\n if (deploymentError) {\n if (deploymentError.unrecoverable) {\n throw UnrecoverableError(deploymentError.debugInfo)\n }\n\n throw new Error(`Failed to upload deployment: ${deploymentError.debugInfo}`)\n }\n\n return deploymentData.data.uploadDeployment.deployment.previewURL\n}\n\nexport const healthCheck = async (pingUrl: string) => {\n const url = `${pingUrl}/__health`\n const result = await http.fetch(url, {method: 'GET'})\n if (result.status !== 200) throw WebPageNotAvailable()\n}\n\nconst buildOperationsString = (deploymentID: string): string => {\n return JSON.stringify({\n query: UploadDeploymentQuery,\n variables: {deploymentID, file: null},\n })\n}\n"]}
@@ -1,6 +1,7 @@
1
1
  import { checkHydrogenVersion } from './dev/check-version.js';
2
2
  import { createServer } from 'vite';
3
- import { analytics, error as kitError } from '@shopify/cli-kit';
3
+ import { error as kitError } from '@shopify/cli-kit';
4
+ import { reportAnalyticsEvent } from '@shopify/cli-kit/node/analytics';
4
5
  async function dev({ commandConfig, directory, force, host, open }) {
5
6
  try {
6
7
  await checkHydrogenVersion(directory);
@@ -15,7 +16,7 @@ async function dev({ commandConfig, directory, force, host, open }) {
15
16
  await server.listen();
16
17
  server.printUrls();
17
18
  server.config.logger.info('');
18
- await analytics.reportEvent({ config: commandConfig });
19
+ await reportAnalyticsEvent({ config: commandConfig });
19
20
  await closeEvent(server);
20
21
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
21
22
  }
@@ -1 +1 @@
1
- {"version":3,"file":"dev.js","sourceRoot":"","sources":["../../../src/cli/services/dev.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,oBAAoB,EAAC,MAAM,wBAAwB,CAAA;AAC3D,OAAO,EAAC,YAAY,EAAgB,MAAM,MAAM,CAAA;AAChD,OAAO,EAAC,SAAS,EAAE,KAAK,IAAI,QAAQ,EAAC,MAAM,kBAAkB,CAAA;AAW7D,KAAK,UAAU,GAAG,CAAC,EAAC,aAAa,EAAE,SAAS,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,EAAa;IAC1E,IAAI;QACF,MAAM,oBAAoB,CAAC,SAAS,CAAC,CAAA;QAErC,MAAM,MAAM,GAAG,MAAM,YAAY,CAAC;YAChC,IAAI,EAAE,SAAS;YACf,MAAM,EAAE;gBACN,IAAI;gBACJ,KAAK;gBACL,IAAI;aACL;SACF,CAAC,CAAA;QACF,MAAM,MAAM,CAAC,MAAM,EAAE,CAAA;QACrB,MAAM,CAAC,SAAS,EAAE,CAAA;QAClB,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;QAC7B,MAAM,SAAS,CAAC,WAAW,CAAC,EAAC,MAAM,EAAE,aAAa,EAAC,CAAC,CAAA;QACpD,MAAM,UAAU,CAAC,MAAM,CAAC,CAAA;QACxB,8DAA8D;KAC/D;IAAC,OAAO,KAAU,EAAE;QACnB,MAAM,UAAU,GAAG,IAAI,QAAQ,CAAC,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,CAAA;QACpD,UAAU,CAAC,KAAK,GAAG,KAAK,CAAC,KAAK,CAAA;QAC9B,MAAM,UAAU,CAAA;KACjB;AACH,CAAC;AAED,SAAS,UAAU,CAAC,MAAqB;IACvC,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;QAC7B,MAAM,CAAC,EAAE,CAAC,EAAE,CAAC,OAAO,EAAE,GAAG,EAAE;YACzB,OAAO,OAAO,EAAE,CAAA;QAClB,CAAC,CAAC,CAAA;IACJ,CAAC,CAAC,CAAA;AACJ,CAAC;AAED,eAAe,GAAG,CAAA","sourcesContent":["import {checkHydrogenVersion} from './dev/check-version.js'\nimport {createServer, ViteDevServer} from 'vite'\nimport {analytics, error as kitError} from '@shopify/cli-kit'\nimport {Config} from '@oclif/core'\n\ninterface DevOptions {\n commandConfig: Config\n directory: string\n force: boolean\n host: boolean\n open: boolean\n}\n\nasync function dev({commandConfig, directory, force, host, open}: DevOptions) {\n try {\n await checkHydrogenVersion(directory)\n\n const server = await createServer({\n root: directory,\n server: {\n open,\n force,\n host,\n },\n })\n await server.listen()\n server.printUrls()\n server.config.logger.info('')\n await analytics.reportEvent({config: commandConfig})\n await closeEvent(server)\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n } catch (error: any) {\n const abortError = new kitError.Abort(error.message)\n abortError.stack = error.stack\n throw abortError\n }\n}\n\nfunction closeEvent(server: ViteDevServer): Promise<void> {\n return new Promise((resolve) => {\n server.ws.on('close', () => {\n return resolve()\n })\n })\n}\n\nexport default dev\n"]}
1
+ {"version":3,"file":"dev.js","sourceRoot":"","sources":["../../../src/cli/services/dev.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,oBAAoB,EAAC,MAAM,wBAAwB,CAAA;AAC3D,OAAO,EAAC,YAAY,EAAgB,MAAM,MAAM,CAAA;AAChD,OAAO,EAAC,KAAK,IAAI,QAAQ,EAAC,MAAM,kBAAkB,CAAA;AAClD,OAAO,EAAC,oBAAoB,EAAC,MAAM,iCAAiC,CAAA;AAWpE,KAAK,UAAU,GAAG,CAAC,EAAC,aAAa,EAAE,SAAS,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,EAAa;IAC1E,IAAI;QACF,MAAM,oBAAoB,CAAC,SAAS,CAAC,CAAA;QAErC,MAAM,MAAM,GAAG,MAAM,YAAY,CAAC;YAChC,IAAI,EAAE,SAAS;YACf,MAAM,EAAE;gBACN,IAAI;gBACJ,KAAK;gBACL,IAAI;aACL;SACF,CAAC,CAAA;QACF,MAAM,MAAM,CAAC,MAAM,EAAE,CAAA;QACrB,MAAM,CAAC,SAAS,EAAE,CAAA;QAClB,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;QAC7B,MAAM,oBAAoB,CAAC,EAAC,MAAM,EAAE,aAAa,EAAC,CAAC,CAAA;QACnD,MAAM,UAAU,CAAC,MAAM,CAAC,CAAA;QACxB,8DAA8D;KAC/D;IAAC,OAAO,KAAU,EAAE;QACnB,MAAM,UAAU,GAAG,IAAI,QAAQ,CAAC,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,CAAA;QACpD,UAAU,CAAC,KAAK,GAAG,KAAK,CAAC,KAAK,CAAA;QAC9B,MAAM,UAAU,CAAA;KACjB;AACH,CAAC;AAED,SAAS,UAAU,CAAC,MAAqB;IACvC,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;QAC7B,MAAM,CAAC,EAAE,CAAC,EAAE,CAAC,OAAO,EAAE,GAAG,EAAE;YACzB,OAAO,OAAO,EAAE,CAAA;QAClB,CAAC,CAAC,CAAA;IACJ,CAAC,CAAC,CAAA;AACJ,CAAC;AAED,eAAe,GAAG,CAAA","sourcesContent":["import {checkHydrogenVersion} from './dev/check-version.js'\nimport {createServer, ViteDevServer} from 'vite'\nimport {error as kitError} from '@shopify/cli-kit'\nimport {reportAnalyticsEvent} from '@shopify/cli-kit/node/analytics'\nimport {Config} from '@oclif/core'\n\ninterface DevOptions {\n commandConfig: Config\n directory: string\n force: boolean\n host: boolean\n open: boolean\n}\n\nasync function dev({commandConfig, directory, force, host, open}: DevOptions) {\n try {\n await checkHydrogenVersion(directory)\n\n const server = await createServer({\n root: directory,\n server: {\n open,\n force,\n host,\n },\n })\n await server.listen()\n server.printUrls()\n server.config.logger.info('')\n await reportAnalyticsEvent({config: commandConfig})\n await closeEvent(server)\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n } catch (error: any) {\n const abortError = new kitError.Abort(error.message)\n abortError.stack = error.stack\n throw abortError\n }\n}\n\nfunction closeEvent(server: ViteDevServer): Promise<void> {\n return new Promise((resolve) => {\n server.ws.on('close', () => {\n return resolve()\n })\n })\n}\n\nexport default dev\n"]}
@@ -1,7 +1,8 @@
1
1
  import { genericConfigurationFileNames } from '../constants.js';
2
- import { ui, vscode, npm, file, path, error, environment } from '@shopify/cli-kit';
2
+ import { ui, npm, file, path, error, environment } from '@shopify/cli-kit';
3
3
  import { addNPMDependenciesWithoutVersionIfNeeded } from '@shopify/cli-kit/node/node-package-manager';
4
- import stream from 'node:stream';
4
+ import { addRecommendedExtensions, isVSCode } from '@shopify/cli-kit/node/vscode';
5
+ import stream from 'stream';
5
6
  export async function addESLint({ app, force, install }) {
6
7
  const list = ui.newListr([
7
8
  {
@@ -62,9 +63,9 @@ export async function addESLint({ app, force, install }) {
62
63
  },
63
64
  {
64
65
  title: 'Adding editor plugin recommendations',
65
- skip: async () => !(await vscode.isVSCode(app.directory)),
66
+ skip: async () => !(await isVSCode(app.directory)),
66
67
  task: async (_, task) => {
67
- await vscode.addRecommendedExtensions(app.directory, ['dbaeumer.vscode-eslint']);
68
+ await addRecommendedExtensions(app.directory, ['dbaeumer.vscode-eslint']);
68
69
  task.title = 'Editor plugin recommendations added';
69
70
  },
70
71
  },
@@ -1 +1 @@
1
- {"version":3,"file":"eslint.js","sourceRoot":"","sources":["../../../src/cli/services/eslint.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,6BAA6B,EAAC,MAAM,iBAAiB,CAAA;AAC7D,OAAO,EAAC,EAAE,EAAE,MAAM,EAAE,GAAG,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,WAAW,EAAC,MAAM,kBAAkB,CAAA;AAChF,OAAO,EAAC,wCAAwC,EAAC,MAAM,4CAA4C,CAAA;AACnG,OAAO,MAAM,MAAM,aAAa,CAAA;AAQhC,MAAM,CAAC,KAAK,UAAU,SAAS,CAAC,EAAC,GAAG,EAAE,KAAK,EAAE,OAAO,EAAmB;IACrE,MAAM,IAAI,GAAG,EAAE,CAAC,QAAQ,CACtB;QACE;YACE,KAAK,EAAE,oCAAoC;YAC3C,IAAI,EAAE,GAAG,EAAE,CAAC,CAAC,OAAO;YACpB,IAAI,EAAE,KAAK,EAAE,CAAC,EAAE,IAAI,EAAE,EAAE;gBACtB,MAAM,oBAAoB,GAAG,CAAC,QAAQ,EAAE,wBAAwB,EAAE,UAAU,EAAE,0BAA0B,CAAC,CAAA;gBACzG,MAAM,wCAAwC,CAAC,oBAAoB,EAAE;oBACnE,cAAc,E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AC,CACjD,CAAA;IACD,MAAM,IAAI,CAAC,GAAG,EAAE,CAAA;AAClB,CAAC","sourcesContent":["import {HydrogenApp} from '../models/hydrogen.js'\nimport {genericConfigurationFileNames} from '../constants.js'\nimport {ui, vscode, npm, file, path, error, environment} from '@shopify/cli-kit'\nimport {addNPMDependenciesWithoutVersionIfNeeded} from '@shopify/cli-kit/node/node-package-manager'\nimport stream from 'node:stream'\n\ninterface AddESlintOptions {\n app: HydrogenApp\n force: boolean\n install: boolean\n}\n\nexport async function addESLint({app, force, install}: AddESlintOptions) {\n const list = ui.newListr(\n [\n {\n title: 'Installing additional dependencies',\n skip: () => !install,\n task: async (_, task) => {\n const requiredDependencies = ['eslint', 'eslint-plugin-hydrogen', 'prettier', '@shopify/prettier-config']\n await addNPMDependenciesWithoutVersionIfNeeded(requiredDependencies, {\n packageManager: app.packageManager,\n type: 'prod',\n directory: app.directory,\n stderr: new stream.Writable({\n write(chunk, encoding, next) {\n task.output = chunk.toString()\n next()\n },\n }),\n stdout: new stream.Writable({\n write(chunk, encoding, next) {\n task.output = chunk.toString()\n next()\n },\n }),\n })\n task.title = 'Dependencies installed'\n },\n },\n\n {\n title: 'Adding ESLint configuration',\n task: async (_, task) => {\n const eslintConfigPath = path.join(app.directory, genericConfigurationFileNames.eslint)\n\n if (await file.exists(eslintConfigPath)) {\n if (force) {\n await file.remove(eslintConfigPath)\n } else {\n throw new error.Abort('ESLint config already exists.', 'Use --force to override existing config.')\n }\n }\n\n const extended = [`'plugin:hydrogen/recommended'`]\n\n if (app.language === 'TypeScript') {\n extended.push(`'plugin:hydrogen/typescript'`)\n }\n\n const eslintConfig = await file.format(\n ['module.exports = {', 'extends: [', `${extended.join(',')}`, ' ],', ' };'].join('\\n'),\n {path: genericConfigurationFileNames.eslint},\n )\n\n await file.write(eslintConfigPath, eslintConfig)\n\n task.title = 'ESLint configuration added'\n },\n },\n {\n title: 'Updating package.json',\n task: async (_, task) => {\n const packageJSON = await npm.readPackageJSON(app.directory)\n\n packageJSON.scripts.lint = `eslint --ext .js,.ts,.jsx,.tsx src/`\n\n packageJSON.prettier = '@shopify/prettier-config'\n\n await npm.writePackageJSON(app.directory, packageJSON)\n\n task.title = 'Package.json updated'\n },\n },\n {\n title: 'Adding editor plugin recommendations',\n skip: async () => !(await vscode.isVSCode(app.directory)),\n task: async (_, task) => {\n await vscode.addRecommendedExtensions(app.directory, ['dbaeumer.vscode-eslint'])\n task.title = 'Editor plugin recommendations added'\n },\n },\n ],\n {rendererSilent: environment.local.isUnitTest()},\n )\n await list.run()\n}\n"]}
1
+ {"version":3,"file":"eslint.js","sourceRoot":"","sources":["../../../src/cli/services/eslint.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,6BAA6B,EAAC,MAAM,iBAAiB,CAAA;AAC7D,OAAO,EAAC,EAAE,EAAE,GAAG,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,WAAW,EAAC,MAAM,kBAAkB,CAAA;AACxE,OAAO,EAAC,wCAAwC,EAAC,MAAM,4CAA4C,CAAA;AACnG,OAAO,EAAC,wBAAwB,EAAE,QAAQ,EAAC,MAAM,8BAA8B,CAAA;AAC/E,OAAO,MAAM,MAAM,QAAQ,CAAA;AAQ3B,MAAM,CAAC,KAAK,UAAU,SAAS,CAAC,EAAC,GAAG,EAAE,KAAK,EAAE,OAAO,EAAmB;IACrE,MAAM,IAAI,GAAG,EAAE,CAAC,QAAQ,CACtB;QACE;YACE,KAAK,EAAE,oCAAoC;YAC3C,IAAI,EAAE,GAAG,EAAE,CAAC,CAAC,OAAO;YACpB,IAAI,EAAE,KAAK,EAAE,CAAC,EAAE,IAAI,EAAE,EAAE;gBACtB,MAAM,oBAAoB,GAAG,CAAC,QAAQ,EAAE,wBAAwB,EAAE,UAAU,EAAE,0BAA0B,CAAC,CAAA;gBACzG,MAAM,wCAAwC,CAAC,oBAAoB,EAAE;oBACnE,cAAc,EAAE,GAAG,CAAC,cAAc;oBAClC,IAAI,EAAE,MAAM;oBACZ,SA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ydrogenApp} from '../models/hydrogen.js'\nimport {genericConfigurationFileNames} from '../constants.js'\nimport {ui, npm, file, path, error, environment} from '@shopify/cli-kit'\nimport {addNPMDependenciesWithoutVersionIfNeeded} from '@shopify/cli-kit/node/node-package-manager'\nimport {addRecommendedExtensions, isVSCode} from '@shopify/cli-kit/node/vscode'\nimport stream from 'stream'\n\ninterface AddESlintOptions {\n app: HydrogenApp\n force: boolean\n install: boolean\n}\n\nexport async function addESLint({app, force, install}: AddESlintOptions) {\n const list = ui.newListr(\n [\n {\n title: 'Installing additional dependencies',\n skip: () => !install,\n task: async (_, task) => {\n const requiredDependencies = ['eslint', 'eslint-plugin-hydrogen', 'prettier', '@shopify/prettier-config']\n await addNPMDependenciesWithoutVersionIfNeeded(requiredDependencies, {\n packageManager: app.packageManager,\n type: 'prod',\n directory: app.directory,\n stderr: new stream.Writable({\n write(chunk, encoding, next) {\n task.output = chunk.toString()\n next()\n },\n }),\n stdout: new stream.Writable({\n write(chunk, encoding, next) {\n task.output = chunk.toString()\n next()\n },\n }),\n })\n task.title = 'Dependencies installed'\n },\n },\n\n {\n title: 'Adding ESLint configuration',\n task: async (_, task) => {\n const eslintConfigPath = path.join(app.directory, genericConfigurationFileNames.eslint)\n\n if (await file.exists(eslintConfigPath)) {\n if (force) {\n await file.remove(eslintConfigPath)\n } else {\n throw new error.Abort('ESLint config already exists.', 'Use --force to override existing config.')\n }\n }\n\n const extended = [`'plugin:hydrogen/recommended'`]\n\n if (app.language === 'TypeScript') {\n extended.push(`'plugin:hydrogen/typescript'`)\n }\n\n const eslintConfig = await file.format(\n ['module.exports = {', 'extends: [', `${extended.join(',')}`, ' ],', ' };'].join('\\n'),\n {path: genericConfigurationFileNames.eslint},\n )\n\n await file.write(eslintConfigPath, eslintConfig)\n\n task.title = 'ESLint configuration added'\n },\n },\n {\n title: 'Updating package.json',\n task: async (_, task) => {\n const packageJSON = await npm.readPackageJSON(app.directory)\n\n packageJSON.scripts.lint = `eslint --ext .js,.ts,.jsx,.tsx src/`\n\n packageJSON.prettier = '@shopify/prettier-config'\n\n await npm.writePackageJSON(app.directory, packageJSON)\n\n task.title = 'Package.json updated'\n },\n },\n {\n title: 'Adding editor plugin recommendations',\n skip: async () => !(await isVSCode(app.directory)),\n task: async (_, task) => {\n await addRecommendedExtensions(app.directory, ['dbaeumer.vscode-eslint'])\n task.title = 'Editor plugin recommendations added'\n },\n },\n ],\n {rendererSilent: environment.local.isUnitTest()},\n )\n await list.run()\n}\n"]}
@@ -1,4 +1,6 @@
1
- import { output, string, os } from '@shopify/cli-kit';
1
+ import { output } from '@shopify/cli-kit';
2
+ import { platformAndArch } from '@shopify/cli-kit/node/os';
3
+ import { capitalize, linesToColumns } from '@shopify/cli-kit/common/string';
2
4
  export function info(app, { showPrivateData }) {
3
5
  const appInfo = new HydrogenAppInfo(app);
4
6
  return appInfo.output({ showPrivateData });
@@ -25,7 +27,7 @@ class AppInfo {
25
27
  ['Project location', this.app.directory],
26
28
  ['Language', this.app.language],
27
29
  ];
28
- const projectInfo = this.linesToColumns(lines);
30
+ const projectInfo = linesToColumns(lines);
29
31
  return [title, projectInfo];
30
32
  }
31
33
  storefrontSettingsSection({ showPrivateData }) {
@@ -44,7 +46,7 @@ class AppInfo {
44
46
  let errorContent = `\n${errors.map(this.formattedError).join('\n')}`;
45
47
  if (errorContent.trim() === '')
46
48
  errorContent = '';
47
- return [title, `${this.linesToColumns(storefrontInfo)}${errorContent}`];
49
+ return [title, `${linesToColumns(storefrontInfo)}${errorContent}`];
48
50
  }
49
51
  eslintSection() {
50
52
  const errors = [];
@@ -56,7 +58,7 @@ class AppInfo {
56
58
  let errorContent = `\n${errors.map(this.formattedError).join('\n')}`;
57
59
  if (errorContent.trim() === '')
58
60
  errorContent = '';
59
- return [title, `${this.linesToColumns(dependencyResults)}${errorContent}`];
61
+ return [title, `${linesToColumns(dependencyResults)}${errorContent}`];
60
62
  }
61
63
  configurationCheck(key, configObject = this.app.configuration) {
62
64
  const keys = Array.isArray(key) ? key : [key];
@@ -65,7 +67,7 @@ class AppInfo {
65
67
  const result = keys.reduce((acc, key) => {
66
68
  const found = configObject[key];
67
69
  if (typeof found === 'string') {
68
- const result = [string.capitalize(key.toString()), found];
70
+ const result = [capitalize(key.toString()), found];
69
71
  return [...acc, result];
70
72
  }
71
73
  const result = [key, NOT_CONFIGURED_TEXT];
@@ -93,7 +95,7 @@ class AppInfo {
93
95
  }
94
96
  systemInfoSection() {
95
97
  const title = 'Tooling and System';
96
- const { platform, arch } = os.platformAndArch();
98
+ const { platform, arch } = platformAndArch();
97
99
  const lines = [
98
100
  ...this.dependencyCheck(['@shopify/hydrogen', '@shopify/cli-hydrogen', '@shopify/cli']),
99
101
  ['Package manager', this.app.packageManager],
@@ -101,25 +103,7 @@ class AppInfo {
101
103
  ['Shell', process.env.SHELL || 'unknown'],
102
104
  ['Node.js version', process.version],
103
105
  ];
104
- return [title, this.linesToColumns(lines)];
105
- }
106
- linesToColumns(lines) {
107
- const widths = [];
108
- for (let i = 0; lines[0] && i < lines[0].length; i++) {
109
- const columnRows = lines.map((line) => line[i]);
110
- widths.push(Math.max(...columnRows.map((row) => output.unstyled(row).length)));
111
- }
112
- const paddedLines = lines
113
- .map((line) => {
114
- return line
115
- .map((col, index) => {
116
- return `${col}${' '.repeat(widths[index] - output.unstyled(col).length)}`;
117
- })
118
- .join(' ')
119
- .trimEnd();
120
- })
121
- .join('\n');
122
- return paddedLines;
106
+ return [title, linesToColumns(lines)];
123
107
  }
124
108
  section(title, body) {
125
109
  const formattedTitle = `${title.toUpperCase()}${' '.repeat(35 - title.length)}`;
@@ -1 +1 @@
1
- {"version":3,"file":"info.js","sourceRoot":"","sources":["../../../src/cli/services/info.ts"],"names":[],"mappings":"AAIA,OAAO,EAAC,MAAM,EAAE,MAAM,EAAE,EAAE,EAAC,MAAM,kBAAkB,CAAA;AAMnD,MAAM,UAAU,IAAI,CAAC,GAAgB,EAAE,EAAC,eAAe,EAAc;IACnE,MAAM,OAAO,GAAG,IAA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OAAO,EAAE,CAAA;QACd,CAAC,CAAC;aACD,IAAI,CAAC,IAAI,CAAC,CAAA;QACb,OAAO,WAAW,CAAA;IACpB,CAAC;IAED,OAAO,CAAC,KAAa,EAAE,IAAY;QACjC,MAAM,cAAc,GAAG,GAAG,KAAK,CAAC,WAAW,EAAE,GAAG,GAAG,CAAC,MAAM,CAAC,EAAE,GAAG,KAAK,CAAC,MAAM,CAAC,EAAE,CAAA;QAC/E,OAAO,MAAM,CAAC,OAAO,CAAA,GAAG,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,cAAc,CAAC,KAAK,IAAI,EAAE,CAAC,KAAK,CAAA;IAC/E,CAAC;CACF;AAED,MAAM,eAAgB,SAAQ,OAAO;CAAG","sourcesContent":["import {HydrogenApp} from '../models/hydrogen.js'\n// eslint-disable-next-line @typescript-eslint/ban-ts-comment\n// @ts-ignore\nimport {HydrogenConfig} from '@shopify/hydrogen/config'\nimport {output, string, os} from '@shopify/cli-kit'\n\ninterface InfoOptions {\n showPrivateData: boolean\n}\n\nexport function info(app: HydrogenApp, {showPrivateData}: InfoOptions): output.Message {\n const appInfo = new HydrogenAppInfo(app)\n\n return appInfo.output({showPrivateData})\n}\n\nconst NOT_FOUND_TEXT = output.content`${output.token.italic('Not found')}`.value\nconst NOT_CONFIGURED_TEXT = output.content`${output.token.italic('Not yet configured')}`.value\n\nclass AppInfo {\n private app: HydrogenApp\n constructor(app: HydrogenApp) {\n this.app = app\n }\n\n output({showPrivateData}: InfoOptions): string {\n const sections: [string, string][] = [\n this.projectSettingsSection(),\n this.storefrontSettingsSection({showPrivateData}),\n this.eslintSection(),\n this.systemInfoSection(),\n ]\n return sections.map((sectionContents: [string, string]) => this.section(...sectionContents)).join('\\n\\n')\n }\n\n projectSettingsSection(): [string, string] {\n const title = 'Your Project'\n\n const lines = [\n ['Name', this.app.name],\n ['Project location', this.app.directory],\n ['Language', this.app.language],\n ]\n\n const projectInfo = this.linesToColumns(lines)\n return [title, projectInfo]\n }\n\n storefrontSettingsSection({showPrivateData}: InfoOptions): [string, string] {\n const errors: string[] = []\n const title = 'Storefront'\n\n if (this.app.configuration.shopify && typeof this.app.configuration.shopify === 'function') {\n return [title, 'Storefront settings defined as a function are not supported in this command.']\n }\n\n const privateFields = showPrivateData ? ['storefrontToken'] : []\n\n const fields = [\n 'storeDomain',\n 'storefrontApiVersion',\n ...privateFields,\n ] as unknown as keyof HydrogenConfig['shopify'][]\n\n const storefrontInfo = this.configurationCheck(fields, this.app.configuration.shopify)\n\n let errorContent = `\\n${errors.map(this.formattedError).join('\\n')}`\n\n if (errorContent.trim() === '') errorContent = ''\n\n return [title, `${this.linesToColumns(storefrontInfo)}${errorContent}`]\n }\n\n eslintSection(): [string, string] {\n const errors: string[] = []\n const title = 'ESLint'\n const dependencyResults = this.dependencyCheck(['eslint', 'eslint-plugin-hydrogen'])\n\n if (this.app.nodeDependencies.eslint && !this.app.nodeDependencies['eslint-plugin-hydrogen']) {\n errors.push('Run `yarn shopify add eslint` to install and configure eslint for hydrogen')\n }\n\n let errorContent = `\\n${errors.map(this.formattedError).join('\\n')}`\n\n if (errorContent.trim() === '') errorContent = ''\n\n return [title, `${this.linesToColumns(dependencyResults)}${errorContent}`]\n }\n\n configurationCheck(\n key: keyof HydrogenConfig | keyof HydrogenConfig[],\n configObject: HydrogenConfig | HydrogenConfig['shopify'] = this.app.configuration,\n ): string[][] {\n const keys = Array.isArray(key) ? key : [key]\n\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n const result = keys.reduce((acc, key) => {\n const found = configObject[key as keyof HydrogenConfig & keyof HydrogenConfig['shopify']]\n\n if (typeof found === 'string') {\n const result = [string.capitalize(key.toString()), found]\n return [...acc, result]\n }\n\n const result = [key, NOT_CONFIGURED_TEXT]\n return [...acc, result]\n }, [])\n\n return result\n }\n\n dependencyCheck(dependency: string | string[]): string[][] {\n const dependencies = Array.isArray(dependency) ? dependency : [dependency]\n\n const result = dependencies.reduce<string[][]>((acc, dependency) => {\n const found = this.app.nodeDependencies[dependency]\n if (found) {\n const result = [dependency, found]\n return [...acc, result]\n }\n\n const result = [dependency, NOT_FOUND_TEXT]\n return [...acc, result]\n }, [])\n\n return result\n }\n\n formattedError(str: string): string {\n const [errorFirstLine, ...errorRemainingLines] = str.split('\\n')\n const errorLines = [`! ${errorFirstLine}`, ...errorRemainingLines.map((line) => ` ${line}`)]\n return output.content`${output.token.errorText(errorLines.join('\\n'))}`.value\n }\n\n systemInfoSection(): [string, string] {\n const title = 'Tooling and System'\n const {platform, arch} = os.platformAndArch()\n const lines: string[][] = [\n ...this.dependencyCheck(['@shopify/hydrogen', '@shopify/cli-hydrogen', '@shopify/cli']),\n ['Package manager', this.app.packageManager],\n ['OS', `${platform}-${arch}`],\n ['Shell', process.env.SHELL || 'unknown'],\n ['Node.js version', process.version],\n ]\n\n return [title, this.linesToColumns(lines)]\n }\n\n linesToColumns(lines: string[][]): string {\n const widths: number[] = []\n for (let i = 0; lines[0] && i < lines[0].length; i++) {\n const columnRows = lines.map((line) => line[i]!)\n widths.push(Math.max(...columnRows.map((row) => output.unstyled(row).length)))\n }\n const paddedLines = lines\n .map((line) => {\n return line\n .map((col, index) => {\n return `${col}${' '.repeat(widths[index]! - output.unstyled(col).length)}`\n })\n .join(' ')\n .trimEnd()\n })\n .join('\\n')\n return paddedLines\n }\n\n section(title: string, body: string): string {\n const formattedTitle = `${title.toUpperCase()}${' '.repeat(35 - title.length)}`\n return output.content`${output.token.heading(formattedTitle)}\\n${body}`.value\n }\n}\n\nclass HydrogenAppInfo extends AppInfo {}\n"]}
1
+ {"version":3,"file":"info.js","sourceRoot":"","sources":["../../../src/cli/services/info.ts"],"names":[],"mappings":"AAIA,OAAO,EAAC,MAAM,EAAC,MAAM,kBAAkB,CAAA;AACvC,OAAO,EAAC,eAAe,EAAC,MAAM,0BAA0B,CAAA;AACxD,OAAO,EAAC,UAAU,EAAE,cAAc,EAAC,MAAM,gCAAgC,CAAA;AAMzE,MAAM,UAAU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AAE,cAAc,CAAC,CAAC;YACvF,CAAC,iBAAiB,EAAE,IAAI,CAAC,GAAG,CAAC,cAAc,CAAC;YAC5C,CAAC,IAAI,EAAE,GAAG,QAAQ,IAAI,IAAI,EAAE,CAAC;YAC7B,CAAC,OAAO,EAAE,OAAO,CAAC,GAAG,CAAC,KAAK,IAAI,SAAS,CAAC;YACzC,CAAC,iBAAiB,EAAE,OAAO,CAAC,OAAO,CAAC;SACrC,CAAA;QAED,OAAO,CAAC,KAAK,EAAE,cAAc,CAAC,KAAK,CAAC,CAAC,CAAA;IACvC,CAAC;IAED,OAAO,CAAC,KAAa,EAAE,IAAY;QACjC,MAAM,cAAc,GAAG,GAAG,KAAK,CAAC,WAAW,EAAE,GAAG,GAAG,CAAC,MAAM,CAAC,EAAE,GAAG,KAAK,CAAC,MAAM,CAAC,EAAE,CAAA;QAC/E,OAAO,MAAM,CAAC,OAAO,CAAA,GAAG,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,cAAc,CAAC,KAAK,IAAI,EAAE,CAAC,KAAK,CAAA;IAC/E,CAAC;CACF;AAED,MAAM,eAAgB,SAAQ,OAAO;CAAG","sourcesContent":["import {HydrogenApp} from '../models/hydrogen.js'\n// eslint-disable-next-line @typescript-eslint/ban-ts-comment\n// @ts-ignore\nimport {HydrogenConfig} from '@shopify/hydrogen/config'\nimport {output} from '@shopify/cli-kit'\nimport {platformAndArch} from '@shopify/cli-kit/node/os'\nimport {capitalize, linesToColumns} from '@shopify/cli-kit/common/string'\n\ninterface InfoOptions {\n showPrivateData: boolean\n}\n\nexport function info(app: HydrogenApp, {showPrivateData}: InfoOptions): output.Message {\n const appInfo = new HydrogenAppInfo(app)\n\n return appInfo.output({showPrivateData})\n}\n\nconst NOT_FOUND_TEXT = output.content`${output.token.italic('Not found')}`.value\nconst NOT_CONFIGURED_TEXT = output.content`${output.token.italic('Not yet configured')}`.value\n\nclass AppInfo {\n private app: HydrogenApp\n constructor(app: HydrogenApp) {\n this.app = app\n }\n\n output({showPrivateData}: InfoOptions): string {\n const sections: [string, string][] = [\n this.projectSettingsSection(),\n this.storefrontSettingsSection({showPrivateData}),\n this.eslintSection(),\n this.systemInfoSection(),\n ]\n return sections.map((sectionContents: [string, string]) => this.section(...sectionContents)).join('\\n\\n')\n }\n\n projectSettingsSection(): [string, string] {\n const title = 'Your Project'\n\n const lines = [\n ['Name', this.app.name],\n ['Project location', this.app.directory],\n ['Language', this.app.language],\n ]\n\n const projectInfo = linesToColumns(lines)\n return [title, projectInfo]\n }\n\n storefrontSettingsSection({showPrivateData}: InfoOptions): [string, string] {\n const errors: string[] = []\n const title = 'Storefront'\n\n if (this.app.configuration.shopify && typeof this.app.configuration.shopify === 'function') {\n return [title, 'Storefront settings defined as a function are not supported in this command.']\n }\n\n const privateFields = showPrivateData ? ['storefrontToken'] : []\n\n const fields = [\n 'storeDomain',\n 'storefrontApiVersion',\n ...privateFields,\n ] as unknown as keyof HydrogenConfig['shopify'][]\n\n const storefrontInfo = this.configurationCheck(fields, this.app.configuration.shopify)\n\n let errorContent = `\\n${errors.map(this.formattedError).join('\\n')}`\n\n if (errorContent.trim() === '') errorContent = ''\n\n return [title, `${linesToColumns(storefrontInfo)}${errorContent}`]\n }\n\n eslintSection(): [string, string] {\n const errors: string[] = []\n const title = 'ESLint'\n const dependencyResults = this.dependencyCheck(['eslint', 'eslint-plugin-hydrogen'])\n\n if (this.app.nodeDependencies.eslint && !this.app.nodeDependencies['eslint-plugin-hydrogen']) {\n errors.push('Run `yarn shopify add eslint` to install and configure eslint for hydrogen')\n }\n\n let errorContent = `\\n${errors.map(this.formattedError).join('\\n')}`\n\n if (errorContent.trim() === '') errorContent = ''\n\n return [title, `${linesToColumns(dependencyResults)}${errorContent}`]\n }\n\n configurationCheck(\n key: keyof HydrogenConfig | keyof HydrogenConfig[],\n configObject: HydrogenConfig | HydrogenConfig['shopify'] = this.app.configuration,\n ): string[][] {\n const keys = Array.isArray(key) ? key : [key]\n\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n const result = keys.reduce((acc, key) => {\n const found = configObject[key as keyof HydrogenConfig & keyof HydrogenConfig['shopify']]\n\n if (typeof found === 'string') {\n const result = [capitalize(key.toString()), found]\n return [...acc, result]\n }\n\n const result = [key, NOT_CONFIGURED_TEXT]\n return [...acc, result]\n }, [])\n\n return result\n }\n\n dependencyCheck(dependency: string | string[]): string[][] {\n const dependencies = Array.isArray(dependency) ? dependency : [dependency]\n\n const result = dependencies.reduce<string[][]>((acc, dependency) => {\n const found = this.app.nodeDependencies[dependency]\n if (found) {\n const result = [dependency, found]\n return [...acc, result]\n }\n\n const result = [dependency, NOT_FOUND_TEXT]\n return [...acc, result]\n }, [])\n\n return result\n }\n\n formattedError(str: string): string {\n const [errorFirstLine, ...errorRemainingLines] = str.split('\\n')\n const errorLines = [`! ${errorFirstLine}`, ...errorRemainingLines.map((line) => ` ${line}`)]\n return output.content`${output.token.errorText(errorLines.join('\\n'))}`.value\n }\n\n systemInfoSection(): [string, string] {\n const title = 'Tooling and System'\n const {platform, arch} = platformAndArch()\n const lines: string[][] = [\n ...this.dependencyCheck(['@shopify/hydrogen', '@shopify/cli-hydrogen', '@shopify/cli']),\n ['Package manager', this.app.packageManager],\n ['OS', `${platform}-${arch}`],\n ['Shell', process.env.SHELL || 'unknown'],\n ['Node.js version', process.version],\n ]\n\n return [title, linesToColumns(lines)]\n }\n\n section(title: string, body: string): string {\n const formattedTitle = `${title.toUpperCase()}${' '.repeat(35 - title.length)}`\n return output.content`${output.token.heading(formattedTitle)}\\n${body}`.value\n }\n}\n\nclass HydrogenAppInfo extends AppInfo {}\n"]}
@@ -1,6 +1,7 @@
1
- import { ui, vscode, system, path, file, error } from '@shopify/cli-kit';
1
+ import { ui, system, path, file, error } from '@shopify/cli-kit';
2
2
  import { addNPMDependenciesWithoutVersionIfNeeded } from '@shopify/cli-kit/node/node-package-manager';
3
- import stream from 'node:stream';
3
+ import { addRecommendedExtensions } from '@shopify/cli-kit/node/vscode';
4
+ import stream from 'stream';
4
5
  const tailwindImports = [
5
6
  "@import 'tailwindcss/base';",
6
7
  "@import 'tailwindcss/components';",
@@ -88,7 +89,7 @@ export async function addTailwind({ app, force, install, directory }) {
88
89
  {
89
90
  title: 'Adding editor plugin recommendations',
90
91
  task: async (_, task) => {
91
- await vscode.addRecommendedExtensions(directory, ['csstools.postcss', 'bradlc.vscode-tailwindcss']);
92
+ await addRecommendedExtensions(directory, ['csstools.postcss', 'bradlc.vscode-tailwindcss']);
92
93
  task.title = 'Editor plugin recommendations added';
93
94
  },
94
95
  },
@@ -1 +1 @@
1
- {"version":3,"file":"tailwind.js","sourceRoot":"","sources":["../../../src/cli/services/tailwind.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAC,MAAM,kBAAkB,CAAA;AACtE,OAAO,EAAC,wCAAwC,EAAC,MAAM,4CAA4C,CAAA;AACnG,OAAO,MAAM,MAAM,aAAa,CAAA;AAShC,MAAM,eAAe,GAAG;IACtB,6BAA6B;IAC7B,mCAAmC;IACnC,kCAAkC;CACnC,CAAA;AAED,MAAM,oBAAoB,GAAG,CAAC,QAAgB,EAAE,EAAE,CAChD,eAAe,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,IAAI,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,iBAAiB,EAAE,EAAE,CAAC,iBAAiB,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAA;AAE5G,MAAM,CAAC,KAAK,UAAU,WAAW,CAAC,EAAC,GAAG,EAAE,KAAK,EAAE,OAAO,EAAE,SAAS,EAAqB;IACpF,MAAM,IAAI,GAAG,EAAE,CAAC,QAAQ,CAAC;QACvB;YACE,KAAK,EAAE,oCAAoC;YAC3C,IAAI,EAAE,GAAG,EAAE,CAAC,CAAC,OAAO;YACpB,IAAI,EAAE,KAAK,EAA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AAC,IAAI,CAAC,YAAY,CAAC,CAAA;gBAE9C,IAAI,oBAAoB,CAAC,QAAQ,CAAC,EAAE;oBAClC,IAAI,CAAC,IAAI,CAAC,oCAAoC,CAAC,CAAA;iBAChD;qBAAM;oBACL,MAAM,WAAW,GAAG,eAAe,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,QAAQ,CAAA;oBAEzD,MAAM,IAAI,CAAC,KAAK,CAAC,YAAY,EAAE,WAAW,CAAC,CAAA;iBAC5C;gBAED,IAAI,CAAC,KAAK,GAAG,wBAAwB,CAAA;YACvC,CAAC;SACF;QACD;YACE,KAAK,EAAE,sCAAsC;YAC7C,IAAI,EAAE,KAAK,EAAE,CAAC,EAAE,IAAI,EAAE,EAAE;gBACtB,MAAM,MAAM,CAAC,wBAAwB,CAAC,SAAS,EAAE,CAAC,kBAAkB,EAAE,2BAA2B,CAAC,CAAC,CAAA;gBACnG,IAAI,CAAC,KAAK,GAAG,qCAAqC,CAAA;YACpD,CAAC;SACF;KACF,CAAC,CAAA;IACF,MAAM,IAAI,CAAC,GAAG,EAAE,CAAA;AAClB,CAAC;AAED,KAAK,UAAU,OAAO,CAAC,IAAqB,EAAE,OAAe,EAAE,QAAgB;IAC7E,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAA;IAC1C,MAAM,QAAQ,GAAG,QAAQ,CAAC,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,CAAA;IAChD,MAAM,IAAI,CAAC,KAAK,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAA;AACtC,CAAC","sourcesContent":["import {HydrogenApp} from '../models/hydrogen.js'\nimport {ui, vscode, system, path, file, error} from '@shopify/cli-kit'\nimport {addNPMDependenciesWithoutVersionIfNeeded} from '@shopify/cli-kit/node/node-package-manager'\nimport stream from 'node:stream'\n\ninterface AddTailwindOptions {\n app: HydrogenApp\n force: boolean\n directory: string\n install: boolean\n}\n\nconst tailwindImports = [\n \"@import 'tailwindcss/base';\",\n \"@import 'tailwindcss/components';\",\n \"@import 'tailwindcss/utilities';\",\n]\n\nconst tailwindImportsExist = (indexCSS: string) =>\n tailwindImports.map((el) => new RegExp(el)).every((tailwindDirective) => tailwindDirective.test(indexCSS))\n\nexport async function addTailwind({app, force, install, directory}: AddTailwindOptions) {\n const list = ui.newListr([\n {\n title: 'Installing additional dependencies',\n skip: () => !install,\n task: async (_, task) => {\n const requiredDependencies = ['postcss', 'postcss-loader', 'tailwindcss', 'autoprefixer']\n await addNPMDependenciesWithoutVersionIfNeeded(requiredDependencies, {\n packageManager: app.packageManager,\n type: 'prod',\n directory: app.directory,\n stderr: new stream.Writable({\n write(chunk, encoding, next) {\n task.output = chunk.toString()\n next()\n },\n }),\n stdout: new stream.Writable({\n write(chunk, encoding, next) {\n task.output = chunk.toString()\n next()\n },\n }),\n })\n task.title = 'Dependencies installed'\n },\n },\n\n {\n title: 'Adding PostCSS configuration',\n task: async (_, task) => {\n const postCSSConfiguration = path.join(directory, 'postcss.config.js')\n\n if (await file.exists(postCSSConfiguration)) {\n if (force) {\n await file.remove(postCSSConfiguration)\n } else {\n throw new error.Abort('PostCSS config already exists.\\nUse --force to override existing config.')\n }\n }\n\n const postCSSConfig = await file.format(\n ['module.exports = {', 'plugins: {', 'tailwindcss: {},', 'autoprefixer: {},', '},', ' };'].join('\\n'),\n {path: 'postcss.config.js'},\n )\n\n await file.write(postCSSConfiguration, postCSSConfig)\n\n task.title = 'PostCSS configuration added'\n },\n },\n\n {\n title: 'Initializing Tailwind CSS...',\n task: async (_, task) => {\n const tailwindConfigurationPath = path.join(directory, 'tailwind.config.js')\n\n if (await file.exists(tailwindConfigurationPath)) {\n if (force) {\n await file.remove(tailwindConfigurationPath)\n } else {\n throw new error.Abort('Tailwind config already exists.\\nUse --force to override existing config.')\n }\n }\n\n await system.exec(app.packageManager, ['tailwindcss', 'init', tailwindConfigurationPath], {\n cwd: directory,\n })\n\n await replace(\n 'content: []',\n \"content: ['./index.html', './src/**/*.{js,jsx,ts,tsx}']\",\n tailwindConfigurationPath,\n )\n\n task.title = 'Tailwind configuration added'\n },\n },\n {\n title: 'Importing Tailwind CSS in index.css',\n task: async (_ctx, task) => {\n const indexCSSPath = path.join(directory, 'src', 'index.css')\n const indexCSS = await file.read(indexCSSPath)\n\n if (tailwindImportsExist(indexCSS)) {\n task.skip('Imports already exist in index.css')\n } else {\n const newIndexCSS = tailwindImports.join('\\n') + indexCSS\n\n await file.write(indexCSSPath, newIndexCSS)\n }\n\n task.title = 'Tailwind imports added'\n },\n },\n {\n title: 'Adding editor plugin recommendations',\n task: async (_, task) => {\n await vscode.addRecommendedExtensions(directory, ['csstools.postcss', 'bradlc.vscode-tailwindcss'])\n task.title = 'Editor plugin recommendations added'\n },\n },\n ])\n await list.run()\n}\n\nasync function replace(find: string | RegExp, replace: string, filepath: string) {\n const original = await file.read(filepath)\n const modified = original.replace(find, replace)\n await file.write(filepath, modified)\n}\n"]}
1
+ {"version":3,"file":"tailwind.js","sourceRoot":"","sources":["../../../src/cli/services/tailwind.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAC,MAAM,kBAAkB,CAAA;AAC9D,OAAO,EAAC,wCAAwC,EAAC,MAAM,4CAA4C,CAAA;AACnG,OAAO,EAAC,wBAAwB,EAAC,MAAM,8BAA8B,CAAA;AACrE,OAAO,MAAM,MAAM,QAAQ,CAAA;AAS3B,MAAM,eAAe,GAAG;IACtB,6BAA6B;IAC7B,mCAAmC;IACnC,kCAAkC;CACnC,CAAA;AAED,MAAM,oBAAoB,GAAG,CAAC,QAAgB,EAAE,EAAE,CAChD,eAAe,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,IAAI,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,iBAAiB,EAAE,EAAE,CAAC,iBAAiB,CAAC,IAAI,CAAC,QAAQ,CAAC,C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;AACtC,CAAC","sourcesContent":["import {HydrogenApp} from '../models/hydrogen.js'\nimport {ui, system, path, file, error} from '@shopify/cli-kit'\nimport {addNPMDependenciesWithoutVersionIfNeeded} from '@shopify/cli-kit/node/node-package-manager'\nimport {addRecommendedExtensions} from '@shopify/cli-kit/node/vscode'\nimport stream from 'stream'\n\ninterface AddTailwindOptions {\n app: HydrogenApp\n force: boolean\n directory: string\n install: boolean\n}\n\nconst tailwindImports = [\n \"@import 'tailwindcss/base';\",\n \"@import 'tailwindcss/components';\",\n \"@import 'tailwindcss/utilities';\",\n]\n\nconst tailwindImportsExist = (indexCSS: string) =>\n tailwindImports.map((el) => new RegExp(el)).every((tailwindDirective) => tailwindDirective.test(indexCSS))\n\nexport async function addTailwind({app, force, install, directory}: AddTailwindOptions) {\n const list = ui.newListr([\n {\n title: 'Installing additional dependencies',\n skip: () => !install,\n task: async (_, task) => {\n const requiredDependencies = ['postcss', 'postcss-loader', 'tailwindcss', 'autoprefixer']\n await addNPMDependenciesWithoutVersionIfNeeded(requiredDependencies, {\n packageManager: app.packageManager,\n type: 'prod',\n directory: app.directory,\n stderr: new stream.Writable({\n write(chunk, encoding, next) {\n task.output = chunk.toString()\n next()\n },\n }),\n stdout: new stream.Writable({\n write(chunk, encoding, next) {\n task.output = chunk.toString()\n next()\n },\n }),\n })\n task.title = 'Dependencies installed'\n },\n },\n\n {\n title: 'Adding PostCSS configuration',\n task: async (_, task) => {\n const postCSSConfiguration = path.join(directory, 'postcss.config.js')\n\n if (await file.exists(postCSSConfiguration)) {\n if (force) {\n await file.remove(postCSSConfiguration)\n } else {\n throw new error.Abort('PostCSS config already exists.\\nUse --force to override existing config.')\n }\n }\n\n const postCSSConfig = await file.format(\n ['module.exports = {', 'plugins: {', 'tailwindcss: {},', 'autoprefixer: {},', '},', ' };'].join('\\n'),\n {path: 'postcss.config.js'},\n )\n\n await file.write(postCSSConfiguration, postCSSConfig)\n\n task.title = 'PostCSS configuration added'\n },\n },\n\n {\n title: 'Initializing Tailwind CSS...',\n task: async (_, task) => {\n const tailwindConfigurationPath = path.join(directory, 'tailwind.config.js')\n\n if (await file.exists(tailwindConfigurationPath)) {\n if (force) {\n await file.remove(tailwindConfigurationPath)\n } else {\n throw new error.Abort('Tailwind config already exists.\\nUse --force to override existing config.')\n }\n }\n\n await system.exec(app.packageManager, ['tailwindcss', 'init', tailwindConfigurationPath], {\n cwd: directory,\n })\n\n await replace(\n 'content: []',\n \"content: ['./index.html', './src/**/*.{js,jsx,ts,tsx}']\",\n tailwindConfigurationPath,\n )\n\n task.title = 'Tailwind configuration added'\n },\n },\n {\n title: 'Importing Tailwind CSS in index.css',\n task: async (_ctx, task) => {\n const indexCSSPath = path.join(directory, 'src', 'index.css')\n const indexCSS = await file.read(indexCSSPath)\n\n if (tailwindImportsExist(indexCSS)) {\n task.skip('Imports already exist in index.css')\n } else {\n const newIndexCSS = tailwindImports.join('\\n') + indexCSS\n\n await file.write(indexCSSPath, newIndexCSS)\n }\n\n task.title = 'Tailwind imports added'\n },\n },\n {\n title: 'Adding editor plugin recommendations',\n task: async (_, task) => {\n await addRecommendedExtensions(directory, ['csstools.postcss', 'bradlc.vscode-tailwindcss'])\n task.title = 'Editor plugin recommendations added'\n },\n },\n ])\n await list.run()\n}\n\nasync function replace(find: string | RegExp, replace: string, filepath: string) {\n const original = await file.read(filepath)\n const modified = original.replace(find, replace)\n await file.write(filepath, modified)\n}\n"]}