@shopify/cli-hydrogen 3.37.0 → 3.39.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.
@@ -1,16 +1,16 @@
1
1
  import { hydrogenFlags } from '../../flags.js';
2
2
  import { deployToOxygen } from '../../services/deploy.js';
3
- import { output } from '@shopify/cli-kit';
4
3
  import Command from '@shopify/cli-kit/node/base-command';
5
4
  import { Flags } from '@oclif/core';
6
5
  import { isShopify } from '@shopify/cli-kit/node/environment/local';
7
6
  import { globalFlags } from '@shopify/cli-kit/node/cli';
8
7
  import { resolvePath, cwd } from '@shopify/cli-kit/node/path';
8
+ import { outputWarn } from '@shopify/cli-kit/node/output';
9
9
  export default class Deploy extends Command {
10
10
  async run() {
11
11
  const isShopifolk = await isShopify();
12
12
  if (!isShopifolk) {
13
- output.warn('Command coming soon...');
13
+ outputWarn('Command coming soon...');
14
14
  return;
15
15
  }
16
16
  const { flags } = await this.parse(Deploy);
@@ -1 +1 @@
1
- {"version":3,"file":"deploy.js","sourceRoot":"","sources":["../../../../src/cli/commands/hydrogen/deploy.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,aAAa,EAAC,MAAM,gBAAgB,CAAA;AAC5C,OAAO,EAAC,cAAc,EAAC,MAAM,0BAA0B,CAAA;AACvD,OAAO,EAAC,MAAM,EAAC,MAAM,kBAAkB,CAAA;AACvC,OAAO,OAAO,MAAM,oCAAoC,CAAA;AACxD,OAAO,EAAC,KAAK,EAAC,MAAM,aAAa,CAAA;AACjC,OAAO,EAAC,SAAS,EAAC,MAAM,yCAAyC,CAAA;AACjE,OAAO,EAAC,WAAW,EAAC,MAAM,2BAA2B,CAAA;AACrD,OAAO,EAAC,WAAW,EAAE,GAAG,EAAC,MAAM,4BAA4B,CAAA;AAE3D,MAAM,CAAC,OAAO,OAAO,MAAO,SAAQ,OAAO;IA2ClC,KAAK,CAAC,GAAG;QACd,MAAM,WAAW,GAAG,MAAM,SAAS,EAAE,CAAA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C,OAAO,EAAE,KAAK;QACd,WAAW,EAAE,4FAA4F;KAC1G,CAAC;IACF,aAAa,EAAE,KAAK,CAAC,MAAM,CAAC;QAC1B,MAAM,EAAE,IAAI;QACZ,GAAG,EAAE,sCAAsC;QAC3C,OAAO,EAAE,6BAA6B;KACvC,CAAC;CACH,CAAA","sourcesContent":["import {hydrogenFlags} from '../../flags.js'\nimport {deployToOxygen} from '../../services/deploy.js'\nimport {output} from '@shopify/cli-kit'\nimport Command from '@shopify/cli-kit/node/base-command'\nimport {Flags} from '@oclif/core'\nimport {isShopify} from '@shopify/cli-kit/node/environment/local'\nimport {globalFlags} from '@shopify/cli-kit/node/cli'\nimport {resolvePath, cwd} from '@shopify/cli-kit/node/path'\n\nexport default class Deploy extends Command {\n static description = 'Deploy your Hydrogen app to Oxygen hosting'\n static hidden = true\n\n static flags = {\n ...globalFlags,\n ...hydrogenFlags,\n deploymentToken: Flags.string({\n required: true,\n env: 'SHOPIFY_HYDROGEN_FLAG_DEPLOYMENT_TOKEN',\n description: 'Specify your Oxygen deployment token.',\n }),\n commitMessage: Flags.string({\n env: 'SHOPIFY_HYDROGEN_FLAG_COMMIT_MESSAGE',\n description: 'Override the default Git commit message.',\n }),\n commitAuthor: Flags.string({\n env: 'SHOPIFY_HYDROGEN_FLAG_COMMIT_AUTHOR',\n description: 'Override the default Git commit author.',\n }),\n pathToBuild: Flags.string({\n hidden: true,\n env: 'SHOPIFY_HYDROGEN_FLAG_PATH_TO_BUILD',\n description: 'Skip build process and use provided value as build',\n }),\n healthCheck: Flags.boolean({\n env: 'SHOPIFY_HYDROGEN_FLAG_HEALTH_CHECK',\n default: true,\n description: 'Require a health check before the deployment succeeds.',\n }),\n assumeYes: Flags.boolean({\n char: 'y',\n env: 'SHOPIFY_HYDROGEN_FLAG_ASSUME_YES',\n default: false,\n description: 'Automatic yes to prompts. Assume \"yes\" as answer to all prompts and run non-interactively.',\n }),\n oxygenAddress: Flags.string({\n hidden: true,\n env: 'SHOPIFY_HYDROGEN_FLAG_OXYGEN_ADDRESS',\n default: 'oxygen-dms.shopifycloud.com',\n }),\n }\n\n public async run(): Promise<void> {\n const isShopifolk = await isShopify()\n if (!isShopifolk) {\n output.warn('Command coming soon...')\n return\n }\n\n const {flags} = await this.parse(Deploy)\n const dir = flags.path ? resolvePath(flags.path) : cwd()\n\n await deployToOxygen({...flags, path: dir})\n }\n}\n"]}
1
+ {"version":3,"file":"deploy.js","sourceRoot":"","sources":["../../../../src/cli/commands/hydrogen/deploy.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,aAAa,EAAC,MAAM,gBAAgB,CAAA;AAC5C,OAAO,EAAC,cAAc,EAAC,MAAM,0BAA0B,CAAA;AACvD,OAAO,OAAO,MAAM,oCAAoC,CAAA;AACxD,OAAO,EAAC,KAAK,EAAC,MAAM,aAAa,CAAA;AACjC,OAAO,EAAC,SAAS,EAAC,MAAM,yCAAyC,CAAA;AACjE,OAAO,EAAC,WAAW,EAAC,MAAM,2BAA2B,CAAA;AACrD,OAAO,EAAC,WAAW,EAAE,GAAG,EAAC,MAAM,4BAA4B,CAAA;AAC3D,OAAO,EAAC,UAAU,EAAC,MAAM,8BAA8B,CAAA;AAEvD,MAAM,CAAC,OAAO,OAAO,MAAO,SAAQ,OAAO;IA2ClC,KAAK,CAAC,GAAG;QACd,MAAM,WAAW,GAAG,MAAM,SAAS,EAAE,CAAA;QACrC,IAAI,CAAC,WAAW,EAAE;YAChB,UAAU,CAAC,wBAAwB,CAAC,CAAA;YACpC,OAAM;SACP;QAED,MAAM,EAAC,KAAK,EAAC,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAA;QACxC,MAAM,GAAG,GAAG,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,WAAW,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,GAAG,EAAE,CAAA;QAExD,MAAM,cAAc,CAAC,EAAC,GAAG,KAAK,EAAE,IAAI,EAAE,GAAG,EAAC,CAAC,CAAA;IAC7C,CAAC;;AArDM,kBAAW,GAAG,4CAA4C,CAAA;AAC1D,aAAM,GAAG,IAAI,CAAA;AAEb,YAAK,GAAG;IACb,GAAG,WAAW;IACd,GAAG,aAAa;IAChB,eAAe,EAAE,KAAK,CAAC,MAAM,CAAC;QAC5B,QAAQ,EAAE,IAAI;QACd,GAAG,EAAE,wCAAwC;QAC7C,WAAW,EAAE,uCAAuC;KACrD,CAAC;IACF,aAAa,EAAE,KAAK,CAAC,MAAM,CAAC;QAC1B,GAAG,EAAE,sCAAsC;QAC3C,WAAW,EAAE,0CAA0C;KACxD,CAAC;IACF,YAAY,EAAE,KAAK,CAAC,MAAM,CAAC;QACzB,GAAG,EAAE,qCAAqC;QAC1C,WAAW,EAAE,yCAAyC;KACvD,CAAC;IACF,WAAW,EAAE,KAAK,CAAC,MAAM,CAAC;QACxB,MAAM,EAAE,IAAI;QACZ,GAAG,EAAE,qCAAqC;QAC1C,WAAW,EAAE,oDAAoD;KAClE,CAAC;IACF,WAAW,EAAE,KAAK,CAAC,OAAO,CAAC;QACzB,GAAG,EAAE,oCAAoC;QACzC,OAAO,EAAE,IAAI;QACb,WAAW,EAAE,wDAAwD;KACtE,CAAC;IACF,SAAS,EAAE,KAAK,CAAC,OAAO,CAAC;QACvB,IAAI,EAAE,GAAG;QACT,GAAG,EAAE,kCAAkC;QACvC,OAAO,EAAE,KAAK;QACd,WAAW,EAAE,4FAA4F;KAC1G,CAAC;IACF,aAAa,EAAE,KAAK,CAAC,MAAM,CAAC;QAC1B,MAAM,EAAE,IAAI;QACZ,GAAG,EAAE,sCAAsC;QAC3C,OAAO,EAAE,6BAA6B;KACvC,CAAC;CACH,CAAA","sourcesContent":["import {hydrogenFlags} from '../../flags.js'\nimport {deployToOxygen} from '../../services/deploy.js'\nimport Command from '@shopify/cli-kit/node/base-command'\nimport {Flags} from '@oclif/core'\nimport {isShopify} from '@shopify/cli-kit/node/environment/local'\nimport {globalFlags} from '@shopify/cli-kit/node/cli'\nimport {resolvePath, cwd} from '@shopify/cli-kit/node/path'\nimport {outputWarn} from '@shopify/cli-kit/node/output'\n\nexport default class Deploy extends Command {\n static description = 'Deploy your Hydrogen app to Oxygen hosting'\n static hidden = true\n\n static flags = {\n ...globalFlags,\n ...hydrogenFlags,\n deploymentToken: Flags.string({\n required: true,\n env: 'SHOPIFY_HYDROGEN_FLAG_DEPLOYMENT_TOKEN',\n description: 'Specify your Oxygen deployment token.',\n }),\n commitMessage: Flags.string({\n env: 'SHOPIFY_HYDROGEN_FLAG_COMMIT_MESSAGE',\n description: 'Override the default Git commit message.',\n }),\n commitAuthor: Flags.string({\n env: 'SHOPIFY_HYDROGEN_FLAG_COMMIT_AUTHOR',\n description: 'Override the default Git commit author.',\n }),\n pathToBuild: Flags.string({\n hidden: true,\n env: 'SHOPIFY_HYDROGEN_FLAG_PATH_TO_BUILD',\n description: 'Skip build process and use provided value as build',\n }),\n healthCheck: Flags.boolean({\n env: 'SHOPIFY_HYDROGEN_FLAG_HEALTH_CHECK',\n default: true,\n description: 'Require a health check before the deployment succeeds.',\n }),\n assumeYes: Flags.boolean({\n char: 'y',\n env: 'SHOPIFY_HYDROGEN_FLAG_ASSUME_YES',\n default: false,\n description: 'Automatic yes to prompts. Assume \"yes\" as answer to all prompts and run non-interactively.',\n }),\n oxygenAddress: Flags.string({\n hidden: true,\n env: 'SHOPIFY_HYDROGEN_FLAG_OXYGEN_ADDRESS',\n default: 'oxygen-dms.shopifycloud.com',\n }),\n }\n\n public async run(): Promise<void> {\n const isShopifolk = await isShopify()\n if (!isShopifolk) {\n outputWarn('Command coming soon...')\n return\n }\n\n const {flags} = await this.parse(Deploy)\n const dir = flags.path ? resolvePath(flags.path) : cwd()\n\n await deployToOxygen({...flags, path: dir})\n }\n}\n"]}
@@ -3,15 +3,15 @@ import { load as loadApp } from '../../models/hydrogen.js';
3
3
  import { hydrogenFlags } from '../../flags.js';
4
4
  import { Flags } from '@oclif/core';
5
5
  import { globalFlags } from '@shopify/cli-kit/node/cli';
6
- import { output } from '@shopify/cli-kit';
7
6
  import Command from '@shopify/cli-kit/node/base-command';
8
7
  import { resolvePath, cwd } from '@shopify/cli-kit/node/path';
8
+ import { outputInfo } from '@shopify/cli-kit/node/output';
9
9
  export default class Info extends Command {
10
10
  async run() {
11
11
  const { flags } = await this.parse(Info);
12
12
  const directory = flags.path ? resolvePath(flags.path) : cwd();
13
13
  const app = await loadApp(directory);
14
- output.info(info(app, { showPrivateData: flags.showToken }));
14
+ outputInfo(info(app, { showPrivateData: flags.showToken }));
15
15
  if (app.errors)
16
16
  process.exit(2);
17
17
  }
@@ -1 +1 @@
1
- {"version":3,"file":"info.js","sourceRoot":"","sources":["../../../../src/cli/commands/hydrogen/info.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,IAAI,EAAC,MAAM,wBAAwB,CAAA;AAC3C,OAAO,EAAC,IAAI,IAAI,OAAO,EAAc,MAAM,0BAA0B,CAAA;AACrE,OAAO,EAAC,aAAa,EAAC,MAAM,gBAAgB,CAAA;AAC5C,OAAO,EAAC,KAAK,EAAC,MAAM,aAAa,CAAA;AACjC,OAAO,EAAC,WAAW,EAAC,MAAM,2BAA2B,CAAA;AACrD,OAAO,EAAC,MAAM,EAAC,MAAM,kBAAkB,CAAA;AACvC,OAAO,OAAO,MAAM,oCAAoC,CAAA;AACxD,OAAO,EAAC,WAAW,EAAE,GAAG,EAAC,MAAM,4BAA4B,CAAA;AAE3D,MAAM,CAAC,OAAO,OAAO,IAAK,SAAQ,OAAO;IAchC,KAAK,CAAC,GAAG;QACd,MAAM,EAAC,KAAK,EAAC,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAA;QACtC,MAAM,SAAS,GAAG,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,WAAW,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,GAAG,EAAE,CAAA;QAC9D,MAAM,GAAG,GAAgB,MAAM,OAAO,CAAC,SAAS,CAAC,CAAA;QAEjD,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,EAAC,eAAe,EAAE,KAAK,CAAC,SAAS,EAAC,CAAC,CAAC,CAAA;QAC1D,IAAI,GAAG,CAAC,MAAM;YAAE,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;IACjC,CAAC;;AApBM,gBAAW,GAAG,kDAAkD,CAAA;AAEhE,UAAK,GAAG;IACb,GAAG,WAAW;IACd,GAAG,aAAa;IAChB,SAAS,EAAE,KAAK,CAAC,OAAO,CAAC;QACvB,MAAM,EAAE,KAAK;QACb,WAAW,EAAE,2BAA2B;QACxC,OAAO,EAAE,KAAK;QACd,GAAG,EAAE,kCAAkC;KACxC,CAAC;CACH,CAAA","sourcesContent":["import {info} from '../../services/info.js'\nimport {load as loadApp, HydrogenApp} from '../../models/hydrogen.js'\nimport {hydrogenFlags} from '../../flags.js'\nimport {Flags} from '@oclif/core'\nimport {globalFlags} from '@shopify/cli-kit/node/cli'\nimport {output} from '@shopify/cli-kit'\nimport Command from '@shopify/cli-kit/node/base-command'\nimport {resolvePath, cwd} from '@shopify/cli-kit/node/path'\n\nexport default class Info extends Command {\n static description = 'Print basic information about your hydrogen app.'\n\n static flags = {\n ...globalFlags,\n ...hydrogenFlags,\n showToken: Flags.boolean({\n hidden: false,\n description: 'Show storefront API token',\n default: false,\n env: 'SHOPIFY_HYDROGEN_FLAG_SHOW_TOKEN',\n }),\n }\n\n public async run(): Promise<void> {\n const {flags} = await this.parse(Info)\n const directory = flags.path ? resolvePath(flags.path) : cwd()\n const app: HydrogenApp = await loadApp(directory)\n\n output.info(info(app, {showPrivateData: flags.showToken}))\n if (app.errors) process.exit(2)\n }\n}\n"]}
1
+ {"version":3,"file":"info.js","sourceRoot":"","sources":["../../../../src/cli/commands/hydrogen/info.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,IAAI,EAAC,MAAM,wBAAwB,CAAA;AAC3C,OAAO,EAAC,IAAI,IAAI,OAAO,EAAc,MAAM,0BAA0B,CAAA;AACrE,OAAO,EAAC,aAAa,EAAC,MAAM,gBAAgB,CAAA;AAC5C,OAAO,EAAC,KAAK,EAAC,MAAM,aAAa,CAAA;AACjC,OAAO,EAAC,WAAW,EAAC,MAAM,2BAA2B,CAAA;AACrD,OAAO,OAAO,MAAM,oCAAoC,CAAA;AACxD,OAAO,EAAC,WAAW,EAAE,GAAG,EAAC,MAAM,4BAA4B,CAAA;AAC3D,OAAO,EAAC,UAAU,EAAC,MAAM,8BAA8B,CAAA;AAEvD,MAAM,CAAC,OAAO,OAAO,IAAK,SAAQ,OAAO;IAchC,KAAK,CAAC,GAAG;QACd,MAAM,EAAC,KAAK,EAAC,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAA;QACtC,MAAM,SAAS,GAAG,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,WAAW,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,GAAG,EAAE,CAAA;QAC9D,MAAM,GAAG,GAAgB,MAAM,OAAO,CAAC,SAAS,CAAC,CAAA;QAEjD,UAAU,CAAC,IAAI,CAAC,GAAG,EAAE,EAAC,eAAe,EAAE,KAAK,CAAC,SAAS,EAAC,CAAC,CAAC,CAAA;QACzD,IAAI,GAAG,CAAC,MAAM;YAAE,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;IACjC,CAAC;;AApBM,gBAAW,GAAG,kDAAkD,CAAA;AAEhE,UAAK,GAAG;IACb,GAAG,WAAW;IACd,GAAG,aAAa;IAChB,SAAS,EAAE,KAAK,CAAC,OAAO,CAAC;QACvB,MAAM,EAAE,KAAK;QACb,WAAW,EAAE,2BAA2B;QACxC,OAAO,EAAE,KAAK;QACd,GAAG,EAAE,kCAAkC;KACxC,CAAC;CACH,CAAA","sourcesContent":["import {info} from '../../services/info.js'\nimport {load as loadApp, HydrogenApp} from '../../models/hydrogen.js'\nimport {hydrogenFlags} from '../../flags.js'\nimport {Flags} from '@oclif/core'\nimport {globalFlags} from '@shopify/cli-kit/node/cli'\nimport Command from '@shopify/cli-kit/node/base-command'\nimport {resolvePath, cwd} from '@shopify/cli-kit/node/path'\nimport {outputInfo} from '@shopify/cli-kit/node/output'\n\nexport default class Info extends Command {\n static description = 'Print basic information about your hydrogen app.'\n\n static flags = {\n ...globalFlags,\n ...hydrogenFlags,\n showToken: Flags.boolean({\n hidden: false,\n description: 'Show storefront API token',\n default: false,\n env: 'SHOPIFY_HYDROGEN_FLAG_SHOW_TOKEN',\n }),\n }\n\n public async run(): Promise<void> {\n const {flags} = await this.parse(Info)\n const directory = flags.path ? resolvePath(flags.path) : cwd()\n const app: HydrogenApp = await loadApp(directory)\n\n outputInfo(info(app, {showPrivateData: flags.showToken}))\n if (app.errors) process.exit(2)\n }\n}\n"]}
@@ -1,3 +1,3 @@
1
- declare type LockFileStatus = 'missing' | 'multiple' | 'ignored' | 'ok';
1
+ type LockFileStatus = 'missing' | 'multiple' | 'ignored' | 'ok';
2
2
  export declare function checkLockfileStatus(directory: string): Promise<LockFileStatus>;
3
3
  export {};
@@ -1,7 +1,7 @@
1
1
  import { renderWarning } from '@shopify/cli-kit/node/ui';
2
2
  import { lockfiles } from '@shopify/cli-kit/node/node-package-manager';
3
3
  import { fileExists } from '@shopify/cli-kit/node/fs';
4
- import { gitFactory } from '@shopify/cli-kit/node/git';
4
+ import { checkIfIgnoredInGitRepository } from '@shopify/cli-kit/node/git';
5
5
  import { resolvePath } from '@shopify/cli-kit/node/path';
6
6
  function missingLockfileWarning() {
7
7
  renderWarning({
@@ -70,9 +70,8 @@ export async function checkLockfileStatus(directory) {
70
70
  multipleLockfilesWarning(availableLockfiles);
71
71
  return 'multiple';
72
72
  }
73
- const repo = gitFactory(directory);
74
73
  const lockfile = availableLockfiles[0];
75
- const ignoredLockfile = await repo.checkIgnore([lockfile]);
74
+ const ignoredLockfile = await checkIfIgnoredInGitRepository(directory, [lockfile]);
76
75
  if (ignoredLockfile.length) {
77
76
  lockfileIgnoredWarning(lockfile);
78
77
  return 'ignored';
@@ -1 +1 @@
1
- {"version":3,"file":"check-lockfile.js","sourceRoot":"","sources":["../../../../src/cli/services/build/check-lockfile.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,aAAa,EAAC,MAAM,0BAA0B,CAAA;AACtD,OAAO,EAAC,SAAS,EAAC,MAAM,4CAA4C,CAAA;AACpE,OAAO,EAAC,UAAU,EAAC,MAAM,0BAA0B,CAAA;AACnD,OAAO,EAAC,UAAU,EAAC,MAAM,2BAA2B,CAAA;AACpD,OAAO,EAAC,WAAW,EAAC,MAAM,4BAA4B,CAAA;AAGtD,SAAS,sBAAsB;IAC7B,aAAa,CAAC;QACZ,QAAQ,EAAE,mBAAmB;QAC7B,IAAI,EACF,wEAAwE;YACxE,0EAA0E;YAC1E,gDAAgD;QAClD,SAAS,EAAE;YACT;gBACE,0BAA0B;gBAC1B;oBACE,OAAO,EAAE,uBAAuB;iBACjC;aACF;YACD,wCAAwC;SACzC;KACF,CAAC,CAAA;AACJ,CAAC;AAED,SAAS,wBAAwB,CAAC,SAAqB;IACrD,MAAM,eAAe,GAAG;QACtB,WAAW,EAAE,MAAM;QACnB,mBAAmB,EAAE,KAAK;QAC1B,gBAAgB,EAAE,MAAM;KACzB,CAAA;IAED,MAAM,YAAY,GAAG,SAAS,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE;QAC9C,OAAO,GAAG,QAAQ,gBAAgB,eAAe,CAAC,QAAQ,CAAC,GAAG,CAAA;IAChE,CAAC,CAAC,CAAA;IAEF,aAAa,CAAC;QACZ,QAAQ,EAAE,0BAA0B;QACpC,IAAI,EAAE;YACJ,uEAAuE;gBACrE,kEAAkE;gBAClE,4BAA4B;YAC9B,EAAC,IAAI,EAAE,EAAC,KAAK,EAAE,YAAY,EAAC,EAAC;SAC9B;QACD,SAAS,EAAE,CAAC,+BAA+B,EAAE,sCAAsC,CAAC;KACrF,CAAC,CAAA;AACJ,CAAC;AAED,SA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["import {renderWarning} from '@shopify/cli-kit/node/ui'\nimport {lockfiles} from '@shopify/cli-kit/node/node-package-manager'\nimport {fileExists} from '@shopify/cli-kit/node/fs'\nimport {gitFactory} from '@shopify/cli-kit/node/git'\nimport {resolvePath} from '@shopify/cli-kit/node/path'\nimport type {Lockfile} from '@shopify/cli-kit/node/node-package-manager'\n\nfunction missingLockfileWarning() {\n renderWarning({\n headline: 'No lockfile found',\n body:\n `If you don’t commit a lockfile, then your app might install the wrong ` +\n `package versions when deploying. To avoid versioning issues, generate a ` +\n `new lockfile and commit it to your repository.`,\n nextSteps: [\n [\n 'Generate a lockfile. Run',\n {\n command: 'npm|yarn|pnpm install',\n },\n ],\n 'Commit the new file to your repository',\n ],\n })\n}\n\nfunction multipleLockfilesWarning(lockfiles: Lockfile[]) {\n const packageManagers = {\n 'yarn.lock': 'yarn',\n 'package-lock.json': 'npm',\n 'pnpm-lock.yaml': 'pnpm',\n }\n\n const lockfileList = lockfiles.map((lockfile) => {\n return `${lockfile} (created by ${packageManagers[lockfile]})`\n })\n\n renderWarning({\n headline: 'Multiple lockfiles found',\n body: [\n `Your project contains more than one lockfile. This can cause version ` +\n `conflicts when installing and deploying your app. The following ` +\n `lockfiles were detected:\\n`,\n {list: {items: lockfileList}},\n ],\n nextSteps: ['Delete any unneeded lockfiles', 'Commit the change to your repository'],\n })\n}\n\nfunction lockfileIgnoredWarning(lockfile: string) {\n renderWarning({\n headline: 'Lockfile ignored by Git',\n body:\n `Your project’s lockfile isn’t being tracked by Git. If you don’t commit ` +\n `a lockfile, then your app might install the wrong package versions when ` +\n `deploying.`,\n nextSteps: [\n `In your project’s .gitignore file, delete any references to ${lockfile}`,\n 'Commit the change to your repository',\n ],\n })\n}\n\ntype LockFileStatus = 'missing' | 'multiple' | 'ignored' | 'ok'\n\nexport async function checkLockfileStatus(directory: string): Promise<LockFileStatus> {\n const availableLockfiles = await lockfiles.reduce(async (acc, lockFileName) => {\n const lockfilePath = resolvePath(directory, lockFileName)\n if (await fileExists(lockfilePath)) {\n return (await acc).concat(lockFileName)\n } else {\n return acc\n }\n }, Promise.resolve([] as Lockfile[]))\n\n if (!availableLockfiles.length) {\n missingLockfileWarning()\n return 'missing'\n }\n\n if (availableLockfiles.length > 1) {\n multipleLockfilesWarning(availableLockfiles)\n return 'multiple'\n }\n\n const repo = gitFactory(directory)\n const lockfile = availableLockfiles[0]!\n const ignoredLockfile = await repo.checkIgnore([lockfile])\n\n if (ignoredLockfile.length) {\n lockfileIgnoredWarning(lockfile)\n return 'ignored'\n }\n\n return 'ok'\n}\n"]}
1
+ {"version":3,"file":"check-lockfile.js","sourceRoot":"","sources":["../../../../src/cli/services/build/check-lockfile.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,aAAa,EAAC,MAAM,0BAA0B,CAAA;AACtD,OAAO,EAAC,SAAS,EAAC,MAAM,4CAA4C,CAAA;AACpE,OAAO,EAAC,UAAU,EAAC,MAAM,0BAA0B,CAAA;AACnD,OAAO,EAAC,6BAA6B,EAAC,MAAM,2BAA2B,CAAA;AACvE,OAAO,EAAC,WAAW,EAAC,MAAM,4BAA4B,CAAA;AAGtD,SAAS,sBAAsB;IAC7B,aAAa,CAAC;QACZ,QAAQ,EAAE,mBAAmB;QAC7B,IAAI,EACF,wEAAwE;YACxE,0EAA0E;YAC1E,gDAAgD;QAClD,SAAS,EAAE;YACT;gBACE,0BAA0B;gBAC1B;oBACE,OAAO,EAAE,uBAAuB;iBACjC;aACF;YACD,wCAAwC;SACzC;KACF,CAAC,CAAA;AACJ,CAAC;AAED,SAAS,wBAAwB,CAAC,SAAqB;IACrD,MAAM,eAAe,GAAG;QACtB,WAAW,EAAE,MAAM;QACnB,mBAAmB,EAAE,KAAK;QAC1B,gBAAgB,EAAE,MAAM;KACzB,CAAA;IAED,MAAM,YAAY,GAAG,SAAS,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE;QAC9C,OAAO,GAAG,QAAQ,gBAAgB,eAAe,CAAC,QAAQ,CAAC,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,CAAE,CAAA;IACvC,MAAM,eAAe,GAAG,MAAM,6BAA6B,CAAC,SAAS,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAA;IAElF,IAAI,eAAe,CAAC,MAAM,EAAE;QAC1B,sBAAsB,CAAC,QAAQ,CAAC,CAAA;QAChC,OAAO,SAAS,CAAA;KACjB;IAED,OAAO,IAAI,CAAA;AACb,CAAC","sourcesContent":["import {renderWarning} from '@shopify/cli-kit/node/ui'\nimport {lockfiles} from '@shopify/cli-kit/node/node-package-manager'\nimport {fileExists} from '@shopify/cli-kit/node/fs'\nimport {checkIfIgnoredInGitRepository} from '@shopify/cli-kit/node/git'\nimport {resolvePath} from '@shopify/cli-kit/node/path'\nimport type {Lockfile} from '@shopify/cli-kit/node/node-package-manager'\n\nfunction missingLockfileWarning() {\n renderWarning({\n headline: 'No lockfile found',\n body:\n `If you don’t commit a lockfile, then your app might install the wrong ` +\n `package versions when deploying. To avoid versioning issues, generate a ` +\n `new lockfile and commit it to your repository.`,\n nextSteps: [\n [\n 'Generate a lockfile. Run',\n {\n command: 'npm|yarn|pnpm install',\n },\n ],\n 'Commit the new file to your repository',\n ],\n })\n}\n\nfunction multipleLockfilesWarning(lockfiles: Lockfile[]) {\n const packageManagers = {\n 'yarn.lock': 'yarn',\n 'package-lock.json': 'npm',\n 'pnpm-lock.yaml': 'pnpm',\n }\n\n const lockfileList = lockfiles.map((lockfile) => {\n return `${lockfile} (created by ${packageManagers[lockfile]})`\n })\n\n renderWarning({\n headline: 'Multiple lockfiles found',\n body: [\n `Your project contains more than one lockfile. This can cause version ` +\n `conflicts when installing and deploying your app. The following ` +\n `lockfiles were detected:\\n`,\n {list: {items: lockfileList}},\n ],\n nextSteps: ['Delete any unneeded lockfiles', 'Commit the change to your repository'],\n })\n}\n\nfunction lockfileIgnoredWarning(lockfile: string) {\n renderWarning({\n headline: 'Lockfile ignored by Git',\n body:\n `Your project’s lockfile isn’t being tracked by Git. If you don’t commit ` +\n `a lockfile, then your app might install the wrong package versions when ` +\n `deploying.`,\n nextSteps: [\n `In your project’s .gitignore file, delete any references to ${lockfile}`,\n 'Commit the change to your repository',\n ],\n })\n}\n\ntype LockFileStatus = 'missing' | 'multiple' | 'ignored' | 'ok'\n\nexport async function checkLockfileStatus(directory: string): Promise<LockFileStatus> {\n const availableLockfiles = await lockfiles.reduce(async (acc, lockFileName) => {\n const lockfilePath = resolvePath(directory, lockFileName)\n if (await fileExists(lockfilePath)) {\n return (await acc).concat(lockFileName)\n } else {\n return acc\n }\n }, Promise.resolve([] as Lockfile[]))\n\n if (!availableLockfiles.length) {\n missingLockfileWarning()\n return 'missing'\n }\n\n if (availableLockfiles.length > 1) {\n multipleLockfilesWarning(availableLockfiles)\n return 'multiple'\n }\n\n const lockfile = availableLockfiles[0]!\n const ignoredLockfile = await checkIfIgnoredInGitRepository(directory, [lockfile])\n\n if (ignoredLockfile.length) {\n lockfileIgnoredWarning(lockfile)\n return 'ignored'\n }\n\n return 'ok'\n}\n"]}
@@ -1,5 +1,4 @@
1
- import { ui } from '@shopify/cli-kit';
2
- declare type Target = 'node' | 'client' | 'worker';
1
+ type Target = 'node' | 'client' | 'worker';
3
2
  interface DevOptions {
4
3
  directory: string;
5
4
  targets: {
@@ -9,6 +8,9 @@ interface DevOptions {
9
8
  assetBaseURL?: string;
10
9
  verbose?: boolean;
11
10
  }
12
- export declare function buildTaskList({ directory, targets, base, assetBaseURL, verbose }: DevOptions): ui.ListrTask[];
11
+ export declare function buildTaskList({ directory, targets, base, assetBaseURL, verbose }: DevOptions): {
12
+ title: string;
13
+ task: () => Promise<void>;
14
+ }[];
13
15
  export declare function build(options: DevOptions): Promise<void>;
14
16
  export {};
@@ -1,15 +1,14 @@
1
1
  import { checkLockfileStatus } from './build/check-lockfile.js';
2
2
  import { build as viteBuild } from 'vite';
3
- import { ui } from '@shopify/cli-kit';
4
- import { isUnitTest } from '@shopify/cli-kit/node/environment/local';
5
3
  import { AbortError } from '@shopify/cli-kit/node/error';
4
+ import { renderTasks } from '@shopify/cli-kit/node/ui';
6
5
  export function buildTaskList({ directory, targets, base, assetBaseURL, verbose }) {
7
6
  const commonConfig = { base, root: directory };
8
7
  return Object.entries(targets)
9
8
  .filter(([_, value]) => value)
10
9
  .map(([key, value]) => ({
11
10
  title: `Building ${key} code`,
12
- task: async (_, task) => {
11
+ task: async () => {
13
12
  if (key === 'worker') {
14
13
  process.env.WORKER = 'true';
15
14
  }
@@ -33,14 +32,12 @@ export function buildTaskList({ directory, targets, base, assetBaseURL, verbose
33
32
  abortError.stack = error.stack;
34
33
  throw abortError;
35
34
  }
36
- task.title = `Built ${key} code`;
37
35
  },
38
36
  }));
39
37
  }
40
38
  export async function build(options) {
41
39
  await checkLockfileStatus(options.directory);
42
40
  const tasks = await buildTaskList(options);
43
- const list = ui.newListr(tasks, { rendererSilent: isUnitTest() });
44
- await list.run();
41
+ await renderTasks(tasks);
45
42
  }
46
43
  //# sourceMappingURL=build.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"build.js","sourceRoot":"","sources":["../../../src/cli/services/build.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,mBAAmB,EAAC,MAAM,2BAA2B,CAAA;AAC7D,OAAO,EAAC,KAAK,IAAI,SAAS,EAAC,MAAM,MAAM,CAAA;AACvC,OAAO,EAAC,EAAE,EAAC,MAAM,kBAAkB,CAAA;AACnC,OAAO,EAAC,UAAU,EAAC,MAAM,yCAAyC,CAAA;AAClE,OAAO,EAAC,UAAU,EAAC,MAAM,6BAA6B,CAAA;AAYtD,MAAM,UAAU,aAAa,CAAC,EAAC,SAAS,EAAE,OAAO,EAAE,IAAI,EAAE,YAAY,EAAE,OAAO,EAAa;IACzF,MAAM,YAAY,GAAG,EAAC,IAAI,EAAE,IAAI,EAAE,SAAS,EAAC,CAAA;IAE5C,OAAO,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC;SAC3B,MAAM,CAAC,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC,KAAK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AAC,KAAK,EAAE,EAAC,cAAc,EAAE,UAAU,EAAE,EAAC,CAAC,CAAA;IAE/D,MAAM,IAAI,CAAC,GAAG,EAAE,CAAA;AAClB,CAAC","sourcesContent":["import {checkLockfileStatus} from './build/check-lockfile.js'\nimport {build as viteBuild} from 'vite'\nimport {ui} from '@shopify/cli-kit'\nimport {isUnitTest} from '@shopify/cli-kit/node/environment/local'\nimport {AbortError} from '@shopify/cli-kit/node/error'\n\ntype Target = 'node' | 'client' | 'worker'\n\ninterface DevOptions {\n directory: string\n targets: {[key in Target]: boolean | string}\n base?: string\n assetBaseURL?: string\n verbose?: boolean\n}\n\nexport function buildTaskList({directory, targets, base, assetBaseURL, verbose}: DevOptions): ui.ListrTask[] {\n const commonConfig = {base, root: directory}\n\n return Object.entries(targets)\n .filter(([_, value]) => value)\n .map(([key, value]) => ({\n title: `Building ${key} code`,\n task: async (_, task) => {\n if (key === 'worker') {\n process.env.WORKER = 'true'\n }\n if (assetBaseURL) {\n process.env.HYDROGEN_ASSET_BASE_URL = assetBaseURL\n }\n\n try {\n await viteBuild({\n ...commonConfig,\n build: {\n outDir: `dist/${key}`,\n ssr: typeof value === 'string' ? value : undefined,\n manifest: key === 'client',\n },\n logLevel: verbose ? 'info' : 'silent',\n })\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n } catch (error: any) {\n const abortError = new AbortError(error.message)\n abortError.stack = error.stack\n throw abortError\n }\n\n task.title = `Built ${key} code`\n },\n }))\n}\n\nexport async function build(options: DevOptions) {\n await checkLockfileStatus(options.directory)\n\n const tasks = await buildTaskList(options)\n\n const list = ui.newListr(tasks, {rendererSilent: isUnitTest()})\n\n await list.run()\n}\n"]}
1
+ {"version":3,"file":"build.js","sourceRoot":"","sources":["../../../src/cli/services/build.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,mBAAmB,EAAC,MAAM,2BAA2B,CAAA;AAC7D,OAAO,EAAC,KAAK,IAAI,SAAS,EAAC,MAAM,MAAM,CAAA;AACvC,O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AK,CAAC,KAAK,CAAA;gBAC9B,MAAM,UAAU,CAAA;aACjB;QACH,CAAC;KACF,CAAC,CAAC,CAAA;AACP,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,KAAK,CAAC,OAAmB;IAC7C,MAAM,mBAAmB,CAAC,OAAO,CAAC,SAAS,CAAC,CAAA;IAE5C,MAAM,KAAK,GAAG,MAAM,aAAa,CAAC,OAAO,CAAC,CAAA;IAE1C,MAAM,WAAW,CAAC,KAAK,CAAC,CAAA;AAC1B,CAAC","sourcesContent":["import {checkLockfileStatus} from './build/check-lockfile.js'\nimport {build as viteBuild} from 'vite'\nimport {AbortError} from '@shopify/cli-kit/node/error'\nimport {renderTasks} from '@shopify/cli-kit/node/ui'\n\ntype Target = 'node' | 'client' | 'worker'\n\ninterface DevOptions {\n directory: string\n targets: {[key in Target]: boolean | string}\n base?: string\n assetBaseURL?: string\n verbose?: boolean\n}\n\nexport function buildTaskList({directory, targets, base, assetBaseURL, verbose}: DevOptions) {\n const commonConfig = {base, root: directory}\n\n return Object.entries(targets)\n .filter(([_, value]) => value)\n .map(([key, value]) => ({\n title: `Building ${key} code`,\n task: async () => {\n if (key === 'worker') {\n process.env.WORKER = 'true'\n }\n if (assetBaseURL) {\n process.env.HYDROGEN_ASSET_BASE_URL = assetBaseURL\n }\n\n try {\n await viteBuild({\n ...commonConfig,\n build: {\n outDir: `dist/${key}`,\n ssr: typeof value === 'string' ? value : undefined,\n manifest: key === 'client',\n },\n logLevel: verbose ? 'info' : 'silent',\n })\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n } catch (error: any) {\n const abortError = new AbortError(error.message)\n abortError.stack = error.stack\n throw abortError\n }\n },\n }))\n}\n\nexport async function build(options: DevOptions) {\n await checkLockfileStatus(options.directory)\n\n const tasks = await buildTaskList(options)\n\n await renderTasks(tasks)\n}\n"]}
@@ -11,7 +11,7 @@ export interface DeployConfig {
11
11
  commitRef?: string;
12
12
  timestamp?: string;
13
13
  }
14
- export declare type ReqDeployConfig = Required<DeployConfig>;
14
+ export type ReqDeployConfig = Required<DeployConfig>;
15
15
  export interface OxygenError {
16
16
  code: string;
17
17
  unrecoverable: boolean;
@@ -40,7 +40,10 @@ export const uploadDeployment = async (config, deploymentID) => {
40
40
  await inTemporaryDirectory(async (tmpDir) => {
41
41
  const distPath = config.pathToBuild ? config.pathToBuild : `${config.path}/dist`;
42
42
  const distZipPath = `${tmpDir}/dist.zip`;
43
- await zip(distPath, distZipPath);
43
+ await zip({
44
+ inputDirectory: distPath,
45
+ outputZipPath: distZipPath,
46
+ });
44
47
  const form = formData();
45
48
  form.append('operations', buildOperationsString(deploymentID));
46
49
  form.append('map', JSON.stringify({ '0': ['variables.file'] }));
@@ -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,qBAAqB,EAAC,MAAM,gCAAgC,CAAA;AACpE,OAAO,EAAC,GAAG,EAAC,MAAM,gCAAgC,CAAA;AAClD,OAAO,EAAC,WAAW,EAAC,MAAM,iBAAiB,CAAA;AAC3C,OAAO,EAAC,0BAA0B,EAAE,aAAa,EAAC,MAAM,kCAAkC,CAAA;AAC1F,OAAO,EAAC,oBAAoB,EAAE,oBAAoB,EAAC,MAAM,0BAA0B,CAAA;AACnF,OAAO,EAAC,KAAK,EAAE,QAAQ,EAAC,MAAM,4BAA4B,CAAA;AAC1D,OAAO,EAAC,UAAU,EAAC,MAAM,6BAA6B,CAAA;AAEtD,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,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eAAe,CAAC,SAAS,EAAE,CAAC,CAAA;KAClF;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,KAAK,CAAC,GAAG,EAAE,EAAC,MAAM,EAAE,KAAK,EAAC,CAAC,CAAA;IAChD,IAAI,MAAM,CAAC,MAAM,KAAK,GAAG;QAAE,MAAM,IAAI,UAAU,CAAC,yBAAyB,CAAC,CAAA;AAC5E,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 {UploadDeploymentQuery} from './graphql/upload_deployment.js'\nimport {zip} from '@shopify/cli-kit/node/archiver'\nimport {ClientError} from 'graphql-request'\nimport {uploadOxygenDeploymentFile, oxygenRequest} from '@shopify/cli-kit/node/api/oxygen'\nimport {inTemporaryDirectory, createFileReadStream} from '@shopify/cli-kit/node/fs'\nimport {fetch, formData} from '@shopify/cli-kit/node/http'\nimport {AbortError} from '@shopify/cli-kit/node/error'\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 new AbortError(`Unrecoverable: ${response.createDeployment.error.debugInfo}`)\n }\n\n throw new AbortError(`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 new AbortError(\"You've made too many requests. Please try again later\")\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 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 form = formData()\n form.append('operations', buildOperationsString(deploymentID))\n form.append('map', JSON.stringify({'0': ['variables.file']}))\n form.append('0', createFileReadStream(distZipPath), {filename: distZipPath})\n\n const response = await uploadOxygenDeploymentFile(config.oxygenAddress, config.deploymentToken, form)\n if (!response.ok) {\n if (response.status === 429) {\n throw new AbortError(\"You've made too many requests. Please try again later\")\n }\n if (response.status !== 200 && response.status !== 202) {\n throw new AbortError(`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 AbortError('Failed to upload deployment.')\n }\n const deploymentError = deploymentData.data?.uploadDeployment?.error\n if (deploymentError) {\n if (deploymentError.unrecoverable) {\n throw new AbortError(`Unrecoverable: ${deploymentError.debugInfo}`)\n }\n\n throw new AbortError(`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 fetch(url, {method: 'GET'})\n if (result.status !== 200) throw new AbortError('Web page not available.')\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,qBAAqB,EAAC,MAAM,gCAAgC,CAAA;AACpE,OAAO,EAAC,GAAG,EAAC,MAAM,gCAAgC,CAAA;AAClD,OAAO,EAAC,WAAW,EAAC,MAAM,iBAAiB,CAAA;AAC3C,OAAO,EAAC,0BAA0B,EAAE,aAAa,EAAC,MAAM,kCAAkC,CAAA;AAC1F,OAAO,EAAC,oBAAoB,EAAE,oBAAoB,EAAC,MAAM,0BAA0B,CAAA;AACnF,OAAO,EAAC,KAAK,EAAE,QAAQ,EAAC,MAAM,4BAA4B,CAAA;AAC1D,OAAO,EAAC,UAAU,EAAC,MAAM,6BAA6B,CAAA;AAEtD,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,aAAa,CAC/D,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;g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K,CAAC,GAAG,EAAE,EAAC,MAAM,EAAE,KAAK,EAAC,CAAC,CAAA;IAChD,IAAI,MAAM,CAAC,MAAM,KAAK,GAAG;QAAE,MAAM,IAAI,UAAU,CAAC,yBAAyB,CAAC,CAAA;AAC5E,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 {UploadDeploymentQuery} from './graphql/upload_deployment.js'\nimport {zip} from '@shopify/cli-kit/node/archiver'\nimport {ClientError} from 'graphql-request'\nimport {uploadOxygenDeploymentFile, oxygenRequest} from '@shopify/cli-kit/node/api/oxygen'\nimport {inTemporaryDirectory, createFileReadStream} from '@shopify/cli-kit/node/fs'\nimport {fetch, formData} from '@shopify/cli-kit/node/http'\nimport {AbortError} from '@shopify/cli-kit/node/error'\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 new AbortError(`Unrecoverable: ${response.createDeployment.error.debugInfo}`)\n }\n\n throw new AbortError(`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 new AbortError(\"You've made too many requests. Please try again later\")\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 inTemporaryDirectory(async (tmpDir) => {\n const distPath = config.pathToBuild ? config.pathToBuild : `${config.path}/dist`\n const distZipPath = `${tmpDir}/dist.zip`\n await zip({\n inputDirectory: distPath,\n outputZipPath: distZipPath,\n })\n\n const form = formData()\n form.append('operations', buildOperationsString(deploymentID))\n form.append('map', JSON.stringify({'0': ['variables.file']}))\n form.append('0', createFileReadStream(distZipPath), {filename: distZipPath})\n\n const response = await uploadOxygenDeploymentFile(config.oxygenAddress, config.deploymentToken, form)\n if (!response.ok) {\n if (response.status === 429) {\n throw new AbortError(\"You've made too many requests. Please try again later\")\n }\n if (response.status !== 200 && response.status !== 202) {\n throw new AbortError(`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 AbortError('Failed to upload deployment.')\n }\n const deploymentError = deploymentData.data?.uploadDeployment?.error\n if (deploymentError) {\n if (deploymentError.unrecoverable) {\n throw new AbortError(`Unrecoverable: ${deploymentError.debugInfo}`)\n }\n\n throw new AbortError(`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 fetch(url, {method: 'GET'})\n if (result.status !== 200) throw new AbortError('Web page not available.')\n}\n\nconst buildOperationsString = (deploymentID: string): string => {\n return JSON.stringify({\n query: UploadDeploymentQuery,\n variables: {deploymentID, file: null},\n })\n}\n"]}
@@ -1,2 +1,2 @@
1
1
  import { DeployConfig } from './deploy/types.js';
2
- export declare function deployToOxygen(_config: DeployConfig): Promise<any>;
2
+ export declare function deployToOxygen(_config: DeployConfig): Promise<void>;
@@ -1,35 +1,33 @@
1
1
  import { createDeployment, healthCheck, uploadDeployment } from './deploy/upload.js';
2
2
  import { buildTaskList } from './build.js';
3
3
  import { validateProject, fillDeployConfig } from './deploy/config.js';
4
- import { ui } from '@shopify/cli-kit';
5
4
  import { sleep } from '@shopify/cli-kit/node/system';
6
5
  import { isUnitTest } from '@shopify/cli-kit/node/environment/local';
6
+ import { renderTasks, renderWarning } from '@shopify/cli-kit/node/ui';
7
7
  const backoffPolicy = [5, 10, 15, 30, 60];
8
8
  export async function deployToOxygen(_config) {
9
9
  await validateProject(_config);
10
10
  /* eslint-disable require-atomic-updates */
11
11
  const tasks = [
12
12
  {
13
- title: '📝 Getting deployment config',
14
- task: async (ctx, task) => {
13
+ title: 'Getting deployment config',
14
+ task: async (ctx) => {
15
15
  ctx.config = await fillDeployConfig(_config);
16
- task.title = '📝 Deployment config parsed';
17
16
  },
18
17
  },
19
18
  {
20
- title: '💡 Initializing deployment',
19
+ title: 'Initializing deployment',
21
20
  task: async (ctx, task) => {
22
21
  await shouldRetryOxygenCall(task, 'Could not create deployment on Oxygen.');
23
22
  const { deploymentID, assetBaseURL } = await createDeployment(ctx.config);
24
23
  ctx.assetBaseURL = assetBaseURL;
25
24
  ctx.deploymentID = deploymentID;
26
- task.title = '✨ Deployment initialized';
27
25
  },
28
26
  retry: backoffPolicy.length,
29
27
  },
30
28
  {
31
- title: '🛠 Building project',
32
- task: async (ctx, task) => {
29
+ title: 'Building project',
30
+ task: async (ctx) => {
33
31
  const subTasks = buildTaskList({
34
32
  directory: ctx.config.path,
35
33
  targets: {
@@ -39,60 +37,57 @@ export async function deployToOxygen(_config) {
39
37
  },
40
38
  assetBaseURL: ctx.assetBaseURL,
41
39
  });
42
- return task.newListr(subTasks);
40
+ return subTasks;
43
41
  },
44
- skip: (ctx) => ctx.config.pathToBuild,
42
+ skip: (ctx) => Boolean(ctx.config.pathToBuild),
45
43
  },
46
44
  {
47
- title: '🚀 Uploading deployment files',
45
+ title: 'Uploading deployment files',
48
46
  task: async (ctx, task) => {
49
47
  await shouldRetryOxygenCall(task, 'Uploading files to Oxygen failed.');
50
48
  ctx.previewURL = await uploadDeployment(ctx.config, ctx.deploymentID);
51
- task.output = `Preview URL: ${ctx.previewURL}`;
52
- task.title = '🚀 Files uploaded';
53
- },
54
- options: {
55
- bottomBar: Infinity,
56
- persistentOutput: true,
57
49
  },
58
50
  retry: backoffPolicy.length,
59
51
  },
60
52
  {
61
- title: '📡 Checking deployment health',
53
+ title: 'Checking deployment health',
62
54
  task: async (ctx, task) => {
63
- const retryCount = task.isRetrying()?.count;
55
+ const retryCount = task.retryCount;
64
56
  if (retryCount === backoffPolicy.length) {
65
- task.title =
66
- "The deployment uploaded but hasn't become reachable within 2 minutes. Check the preview URL to see if deployment succeeded. If it didn't, then try again later.";
67
- return;
57
+ throw new Error(`Deployment health check failed.`);
68
58
  }
69
59
  if (retryCount && !isUnitTest())
70
60
  await sleep(backoffPolicy[retryCount - 1]);
71
61
  await healthCheck(ctx.previewURL);
72
- task.title = '✅ Deployed successfully';
73
62
  },
74
63
  retry: backoffPolicy.length,
75
64
  skip: (ctx) => !ctx.config.healthCheck,
76
65
  },
77
66
  ];
78
67
  /* eslint-enable require-atomic-updates */
79
- const list = ui.newListr(tasks, {
80
- concurrent: false,
81
- rendererOptions: { collapse: false },
82
- rendererSilent: isUnitTest(),
83
- });
84
- return list.run();
68
+ try {
69
+ await renderTasks(tasks);
70
+ }
71
+ catch (error) {
72
+ if (error instanceof Error && error.message === 'Deployment health check failed.') {
73
+ renderWarning({
74
+ headline: "The deployment uploaded but hasn't become reachable within 2 minutes. Check the preview URL to see if deployment succeeded. If it didn't, then try again later.",
75
+ });
76
+ }
77
+ else {
78
+ throw error;
79
+ }
80
+ }
85
81
  }
86
- async function shouldRetryOxygenCall(
87
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
88
- task, errorMessage) {
89
- const retryCount = task.isRetrying()?.count;
82
+ async function shouldRetryOxygenCall(task, errorMessage) {
83
+ const retryCount = task.retryCount;
84
+ const taskErrors = task.errors ?? [];
90
85
  if (retryCount === backoffPolicy.length) {
91
- throw new Error(`${errorMessage} ${task.errors[task.errors.length - 1]?.message}`);
86
+ throw new Error(`${errorMessage} ${taskErrors[taskErrors.length - 1]?.message}`);
92
87
  }
93
88
  if (retryCount) {
94
- if (task.errors.length > 0) {
95
- const unrecoverableError = task.errors.find((error) => error.message.includes('Unrecoverable'));
89
+ if (taskErrors.length > 0) {
90
+ const unrecoverableError = taskErrors.find((error) => error.message.includes('Unrecoverable'));
96
91
  if (unrecoverableError) {
97
92
  throw new Error(unrecoverableError.message);
98
93
  }
@@ -1 +1 @@
1
- {"version":3,"file":"deploy.js","sourceRoot":"","sources":["../../../src/cli/services/deploy.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,gBAAgB,EAAE,WAAW,EAAE,gBAAgB,EAAC,MAAM,oBAAoB,CAAA;AAClF,OAAO,EAAC,aAAa,EAAC,MAAM,YAAY,CAAA;AACxC,OAAO,EAAC,eAAe,EAAE,gBAAgB,EAAC,MAAM,oBAAoB,CAAA;AACpE,OAAO,EAAC,EAAE,EAAC,MAAM,kBAAkB,CAAA;AACnC,OAAO,EAAC,KAAK,EAAC,MAAM,8BAA8B,CAAA;AAClD,OAAO,EAAC,UAAU,EAAC,MAAM,yCAAyC,CAAA;AASlE,MAAM,aAAa,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,CAAA;AAEzC,MAAM,CAAC,KAAK,UAAU,cAAc,CAAC,OAAqB;IACxD,MAAM,eAAe,CAAC,OAAO,CAAC,CAAA;IAE9B,2CAA2C;IAC3C,MAAM,KAAK,GAAgC;QACzC;YACE,KAAK,EAAE,8BAA8B;YACrC,IAAI,EAAE,KAAK,EAAE,GAAG,EAAE,IAAI,EAAE,EAAE;gBACxB,GAAG,CAAC,MAAM,GAAG,MAAM,gBAAgB,CAAC,OAAO,CAAC,CAAA;g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B;IAEpB,MAAM,UAAU,GAAG,IAAI,CAAC,UAAU,EAAE,EAAE,KAAK,CAAA;IAC3C,IAAI,UAAU,KAAK,aAAa,CAAC,MAAM,EAAE;QACvC,MAAM,IAAI,KAAK,CAAC,GAAG,YAAY,IAAI,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,CAAA;KACnF;IACD,IAAI,UAAU,EAAE;QACd,IAAI,IAAI,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE;YAC1B,MAAM,kBAAkB,GAAG,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAC,CAAC,CAAA;YAC/F,IAAI,kBAAkB,EAAE;gBACtB,MAAM,IAAI,KAAK,CAAC,kBAAkB,CAAC,OAAO,CAAC,CAAA;aAC5C;SACF;KACF;IACD,IAAI,UAAU,IAAI,CAAC,UAAU,EAAE;QAAE,MAAM,KAAK,CAAC,aAAa,CAAC,UAAU,GAAG,CAAC,CAAE,CAAC,CAAA;AAC9E,CAAC","sourcesContent":["import {DeployConfig, ReqDeployConfig} from './deploy/types.js'\nimport {createDeployment, healthCheck, uploadDeployment} from './deploy/upload.js'\nimport {buildTaskList} from './build.js'\nimport {validateProject, fillDeployConfig} from './deploy/config.js'\nimport {ui} from '@shopify/cli-kit'\nimport {sleep} from '@shopify/cli-kit/node/system'\nimport {isUnitTest} from '@shopify/cli-kit/node/environment/local'\n\ninterface TaskContext {\n config: ReqDeployConfig\n deploymentID: string\n assetBaseURL: string\n previewURL: string\n}\n\nconst backoffPolicy = [5, 10, 15, 30, 60]\n\nexport async function deployToOxygen(_config: DeployConfig) {\n await validateProject(_config)\n\n /* eslint-disable require-atomic-updates */\n const tasks: ui.ListrTask<TaskContext>[] = [\n {\n title: '📝 Getting deployment config',\n task: async (ctx, task) => {\n ctx.config = await fillDeployConfig(_config)\n task.title = '📝 Deployment config parsed'\n },\n },\n {\n title: '💡 Initializing deployment',\n task: async (ctx, task) => {\n await shouldRetryOxygenCall(task, 'Could not create deployment on Oxygen.')\n\n const {deploymentID, assetBaseURL} = await createDeployment(ctx.config)\n ctx.assetBaseURL = assetBaseURL\n ctx.deploymentID = deploymentID\n task.title = '✨ Deployment initialized'\n },\n retry: backoffPolicy.length,\n },\n {\n title: '🛠 Building project',\n task: async (ctx, task) => {\n const subTasks = buildTaskList({\n directory: ctx.config.path,\n targets: {\n client: true,\n worker: '@shopify/hydrogen/platforms/worker',\n node: false,\n },\n assetBaseURL: ctx.assetBaseURL,\n })\n\n return task.newListr(subTasks)\n },\n skip: (ctx) => ctx.config.pathToBuild,\n },\n {\n title: '🚀 Uploading deployment files',\n task: async (ctx, task) => {\n await shouldRetryOxygenCall(task, 'Uploading files to Oxygen failed.')\n\n ctx.previewURL = await uploadDeployment(ctx.config, ctx.deploymentID)\n task.output = `Preview URL: ${ctx.previewURL}`\n task.title = '🚀 Files uploaded'\n },\n options: {\n bottomBar: Infinity,\n persistentOutput: true,\n },\n retry: backoffPolicy.length,\n },\n {\n title: '📡 Checking deployment health',\n task: async (ctx, task) => {\n const retryCount = task.isRetrying()?.count\n\n if (retryCount === backoffPolicy.length) {\n task.title =\n \"The deployment uploaded but hasn't become reachable within 2 minutes. Check the preview URL to see if deployment succeeded. If it didn't, then try again later.\"\n return\n }\n if (retryCount && !isUnitTest()) await sleep(backoffPolicy[retryCount - 1]!)\n\n await healthCheck(ctx.previewURL)\n task.title = '✅ Deployed successfully'\n },\n retry: backoffPolicy.length,\n skip: (ctx) => !ctx.config.healthCheck,\n },\n ]\n /* eslint-enable require-atomic-updates */\n\n const list = ui.newListr(tasks, {\n concurrent: false,\n rendererOptions: {collapse: false},\n rendererSilent: isUnitTest(),\n })\n\n return list.run()\n}\n\nasync function shouldRetryOxygenCall(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n task: ui.ListrTaskWrapper<TaskContext, any>,\n errorMessage: string,\n) {\n const retryCount = task.isRetrying()?.count\n if (retryCount === backoffPolicy.length) {\n throw new Error(`${errorMessage} ${task.errors[task.errors.length - 1]?.message}`)\n }\n if (retryCount) {\n if (task.errors.length > 0) {\n const unrecoverableError = task.errors.find((error) => error.message.includes('Unrecoverable'))\n if (unrecoverableError) {\n throw new Error(unrecoverableError.message)\n }\n }\n }\n if (retryCount && !isUnitTest()) await sleep(backoffPolicy[retryCount - 1]!)\n}\n"]}
1
+ {"version":3,"file":"deploy.js","sourceRoot":"","sources":["../../../src/cli/services/deploy.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,gBAAgB,EAAE,WAAW,EAAE,gBAAgB,EAAC,MAAM,oBAAoB,CAAA;AAClF,OAAO,EAAC,aAAa,EAAC,MAAM,YAAY,CAAA;AACxC,OAAO,EAAC,eAAe,EAAE,gBAAgB,EAAC,MAAM,oBAAoB,CAAA;AACpE,OAAO,EAAC,KAAK,EAAC,MAAM,8BAA8B,CAAA;AAClD,OAAO,EAAC,UAAU,EAAC,MAAM,yCAAyC,CAAA;AAClE,OAAO,EAAO,WAAW,EAAE,aAAa,EAAC,MAAM,0BAA0B,CAAA;AASzE,MAAM,aAAa,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,CAAA;AAEzC,MAAM,CAAC,KAAK,UAAU,cAAc,CAAC,OAAqB;IACxD,MAAM,eAAe,CAAC,OAAO,CAAC,CAAA;IAE9B,2CAA2C;IAC3C,MAAM,KAAK,GAAwB;QACjC;YACE,KAAK,EAAE,2BAA2B;YAClC,IAAI,EAAE,KAAK,EAAE,GAAG,EAAE,EAAE;gBAClB,GAAG,CAAC,MAAM,GAAG,MAAM,gBAAgB,CAAC,OAAO,CAAC,CAAA;YAC9C,CAAC;SACF;QACD;YACE,KAAK,EAAE,yBAAyB;YAChC,IAAI,EAAE,KAAK,EAAE,GAAG,EAAE,IAAI,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O,CAAC,QAAQ,CAAC,eAAe,CAAC,CAAC,CAAA;YAC9F,IAAI,kBAAkB,EAAE;gBACtB,MAAM,IAAI,KAAK,CAAC,kBAAkB,CAAC,OAAO,CAAC,CAAA;aAC5C;SACF;KACF;IACD,IAAI,UAAU,IAAI,CAAC,UAAU,EAAE;QAAE,MAAM,KAAK,CAAC,aAAa,CAAC,UAAU,GAAG,CAAC,CAAE,CAAC,CAAA;AAC9E,CAAC","sourcesContent":["import {DeployConfig, ReqDeployConfig} from './deploy/types.js'\nimport {createDeployment, healthCheck, uploadDeployment} from './deploy/upload.js'\nimport {buildTaskList} from './build.js'\nimport {validateProject, fillDeployConfig} from './deploy/config.js'\nimport {sleep} from '@shopify/cli-kit/node/system'\nimport {isUnitTest} from '@shopify/cli-kit/node/environment/local'\nimport {Task, renderTasks, renderWarning} from '@shopify/cli-kit/node/ui'\n\ninterface TaskContext {\n config: ReqDeployConfig\n deploymentID: string\n assetBaseURL: string\n previewURL: string\n}\n\nconst backoffPolicy = [5, 10, 15, 30, 60]\n\nexport async function deployToOxygen(_config: DeployConfig) {\n await validateProject(_config)\n\n /* eslint-disable require-atomic-updates */\n const tasks: Task<TaskContext>[] = [\n {\n title: 'Getting deployment config',\n task: async (ctx) => {\n ctx.config = await fillDeployConfig(_config)\n },\n },\n {\n title: 'Initializing deployment',\n task: async (ctx, task) => {\n await shouldRetryOxygenCall(task, 'Could not create deployment on Oxygen.')\n\n const {deploymentID, assetBaseURL} = await createDeployment(ctx.config)\n ctx.assetBaseURL = assetBaseURL\n ctx.deploymentID = deploymentID\n },\n retry: backoffPolicy.length,\n },\n {\n title: 'Building project',\n task: async (ctx) => {\n const subTasks = buildTaskList({\n directory: ctx.config.path,\n targets: {\n client: true,\n worker: '@shopify/hydrogen/platforms/worker',\n node: false,\n },\n assetBaseURL: ctx.assetBaseURL,\n })\n\n return subTasks\n },\n skip: (ctx) => Boolean(ctx.config.pathToBuild),\n },\n {\n title: 'Uploading deployment files',\n task: async (ctx, task) => {\n await shouldRetryOxygenCall(task, 'Uploading files to Oxygen failed.')\n\n ctx.previewURL = await uploadDeployment(ctx.config, ctx.deploymentID)\n },\n retry: backoffPolicy.length,\n },\n {\n title: 'Checking deployment health',\n task: async (ctx, task) => {\n const retryCount = task.retryCount\n\n if (retryCount === backoffPolicy.length) {\n throw new Error(`Deployment health check failed.`)\n }\n\n if (retryCount && !isUnitTest()) await sleep(backoffPolicy[retryCount - 1]!)\n\n await healthCheck(ctx.previewURL)\n },\n retry: backoffPolicy.length,\n skip: (ctx) => !ctx.config.healthCheck,\n },\n ]\n /* eslint-enable require-atomic-updates */\n\n try {\n await renderTasks(tasks)\n } catch (error: unknown) {\n if (error instanceof Error && error.message === 'Deployment health check failed.') {\n renderWarning({\n headline:\n \"The deployment uploaded but hasn't become reachable within 2 minutes. Check the preview URL to see if deployment succeeded. If it didn't, then try again later.\",\n })\n } else {\n throw error\n }\n }\n}\n\nasync function shouldRetryOxygenCall(task: Task<TaskContext>, errorMessage: string) {\n const retryCount = task.retryCount\n const taskErrors = task.errors ?? []\n if (retryCount === backoffPolicy.length) {\n throw new Error(`${errorMessage} ${taskErrors[taskErrors.length - 1]?.message}`)\n }\n if (retryCount) {\n if (taskErrors.length > 0) {\n const unrecoverableError = taskErrors.find((error) => error.message.includes('Unrecoverable'))\n if (unrecoverableError) {\n throw new Error(unrecoverableError.message)\n }\n }\n }\n if (retryCount && !isUnitTest()) await sleep(backoffPolicy[retryCount - 1]!)\n}\n"]}
@@ -1,42 +1,28 @@
1
1
  import { genericConfigurationFileNames } from '../constants.js';
2
- import { ui } from '@shopify/cli-kit';
3
2
  import { addNPMDependenciesWithoutVersionIfNeeded, findUpAndReadPackageJson, writePackageJSON, } from '@shopify/cli-kit/node/node-package-manager';
4
3
  import { addRecommendedExtensions, isVSCode } from '@shopify/cli-kit/node/vscode';
5
- import { isUnitTest } from '@shopify/cli-kit/node/environment/local';
6
4
  import { writeFile, fileExists, removeFile, fileContentPrettyFormat } from '@shopify/cli-kit/node/fs';
7
5
  import { joinPath } from '@shopify/cli-kit/node/path';
8
6
  import { AbortError } from '@shopify/cli-kit/node/error';
9
- import stream from 'stream';
7
+ import { renderTasks } from '@shopify/cli-kit/node/ui';
10
8
  export async function addESLint({ app, force, install }) {
11
- const list = ui.newListr([
9
+ const vscode = await isVSCode(app.directory);
10
+ const tasks = [
12
11
  {
13
- title: 'Installing additional dependencies',
12
+ title: 'Installing dependencies',
14
13
  skip: () => !install,
15
- task: async (_, task) => {
14
+ task: async () => {
16
15
  const requiredDependencies = ['eslint', 'eslint-plugin-hydrogen', 'prettier', '@shopify/prettier-config'];
17
16
  await addNPMDependenciesWithoutVersionIfNeeded(requiredDependencies, {
18
17
  packageManager: app.packageManager,
19
18
  type: 'prod',
20
19
  directory: app.directory,
21
- stderr: new stream.Writable({
22
- write(chunk, encoding, next) {
23
- task.output = chunk.toString();
24
- next();
25
- },
26
- }),
27
- stdout: new stream.Writable({
28
- write(chunk, encoding, next) {
29
- task.output = chunk.toString();
30
- next();
31
- },
32
- }),
33
20
  });
34
- task.title = 'Dependencies installed';
35
21
  },
36
22
  },
37
23
  {
38
24
  title: 'Adding ESLint configuration',
39
- task: async (_, task) => {
25
+ task: async () => {
40
26
  const eslintConfigPath = joinPath(app.directory, genericConfigurationFileNames.eslint);
41
27
  if (await fileExists(eslintConfigPath)) {
42
28
  if (force) {
@@ -52,29 +38,26 @@ export async function addESLint({ app, force, install }) {
52
38
  }
53
39
  const eslintConfig = await fileContentPrettyFormat(['module.exports = {', 'extends: [', `${extended.join(',')}`, ' ],', ' };'].join('\n'), { path: genericConfigurationFileNames.eslint });
54
40
  await writeFile(eslintConfigPath, eslintConfig);
55
- task.title = 'ESLint configuration added';
56
41
  },
57
42
  },
58
43
  {
59
44
  title: 'Updating package.json',
60
- task: async (_, task) => {
45
+ task: async () => {
61
46
  const packageJSON = (await findUpAndReadPackageJson(app.directory)).content;
62
47
  packageJSON.scripts = packageJSON.scripts || {};
63
48
  packageJSON.scripts.lint = `eslint --ext .js,.ts,.jsx,.tsx src/`;
64
49
  packageJSON.prettier = '@shopify/prettier-config';
65
50
  await writePackageJSON(app.directory, packageJSON);
66
- task.title = 'Package.json updated';
67
51
  },
68
52
  },
69
53
  {
70
54
  title: 'Adding editor plugin recommendations',
71
- skip: async () => !(await isVSCode(app.directory)),
72
- task: async (_, task) => {
55
+ skip: () => !vscode,
56
+ task: async () => {
73
57
  await addRecommendedExtensions(app.directory, ['dbaeumer.vscode-eslint']);
74
- task.title = 'Editor plugin recommendations added';
75
58
  },
76
59
  },
77
- ], { rendererSilent: isUnitTest() });
78
- await list.run();
60
+ ];
61
+ await renderTasks(tasks);
79
62
  }
80
63
  //# sourceMappingURL=eslint.js.map
@@ -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,EAAC,MAAM,kBAAkB,CAAA;AACnC,OAAO,EACL,wCAAwC,EACxC,wBAAwB,EACxB,gBAAgB,GACjB,MAAM,4CAA4C,CAAA;AACnD,OAAO,EAAC,wBAAwB,EAAE,QAAQ,EAAC,MAAM,8BAA8B,CAAA;AAC/E,OAAO,EAAC,UAAU,EAAC,MAAM,yCAAyC,CAAA;AAClE,OAAO,EAAC,SAAS,EAAE,UAAU,EAAE,UAAU,EAAE,uBAAuB,EAAC,MAAM,0BAA0B,CAAA;AACnG,OAAO,EAAC,QAAQ,EAAC,MAAM,4BAA4B,CAAA;AACnD,OAAO,EAAC,UAAU,EAAC,MAAM,6BAA6B,CAAA;AACtD,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,oCA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AAC,EAAE,IAAI,EAAE,EAAE;gBACtB,MAAM,wBAAwB,CAAC,GAAG,CAAC,SAAS,EAAE,CAAC,wBAAwB,CAAC,CAAC,CAAA;gBACzE,IAAI,CAAC,KAAK,GAAG,qCAAqC,CAAA;YACpD,CAAC;SACF;KACF,EACD,EAAC,cAAc,EAAE,UAAU,EAAE,EAAC,CAC/B,CAAA;IACD,MAAM,IAAI,CAAC,GAAG,EAAE,CAAA;AAClB,CAAC","sourcesContent":["import {HydrogenApp} from '../models/hydrogen.js'\nimport {genericConfigurationFileNames} from '../constants.js'\nimport {ui} from '@shopify/cli-kit'\nimport {\n addNPMDependenciesWithoutVersionIfNeeded,\n findUpAndReadPackageJson,\n writePackageJSON,\n} from '@shopify/cli-kit/node/node-package-manager'\nimport {addRecommendedExtensions, isVSCode} from '@shopify/cli-kit/node/vscode'\nimport {isUnitTest} from '@shopify/cli-kit/node/environment/local'\nimport {writeFile, fileExists, removeFile, fileContentPrettyFormat} from '@shopify/cli-kit/node/fs'\nimport {joinPath} from '@shopify/cli-kit/node/path'\nimport {AbortError} from '@shopify/cli-kit/node/error'\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 = joinPath(app.directory, genericConfigurationFileNames.eslint)\n\n if (await fileExists(eslintConfigPath)) {\n if (force) {\n await removeFile(eslintConfigPath)\n } else {\n throw new AbortError('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 fileContentPrettyFormat(\n ['module.exports = {', 'extends: [', `${extended.join(',')}`, ' ],', ' };'].join('\\n'),\n {path: genericConfigurationFileNames.eslint},\n )\n\n await writeFile(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 findUpAndReadPackageJson(app.directory)).content\n packageJSON.scripts = packageJSON.scripts || {}\n packageJSON.scripts.lint = `eslint --ext .js,.ts,.jsx,.tsx src/`\n\n packageJSON.prettier = '@shopify/prettier-config'\n\n await 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: 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,EACL,wCAAwC,EACxC,wBAAwB,EACxB,gBAAgB,GACjB,MAAM,4CAA4C,CAAA;AACnD,OAAO,EAAC,wBAAwB,EAAE,QAAQ,EAAC,MAAM,8BAA8B,CAAA;AAC/E,OAAO,EAAC,SAAS,EAAE,UAAU,EAAE,UAAU,EAAE,uBAAuB,EAAC,MAAM,0BAA0B,CAAA;AACnG,OAAO,EAAC,QAAQ,EAAC,MAAM,4BAA4B,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,YAAY,GAAG,MAAM,uBAAuB,CAChD,CAAC,oBAAoB,EAAE,YAAY,EAAE,GAAG,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,EACtF,EAAC,IAAI,EAAE,6BAA6B,CAAC,MAAM,EAAC,CAC7C,CAAA;gBAED,MAAM,SAAS,CAAC,gBAAgB,EAAE,YAAY,CAAC,CAAA;YACjD,CAAC;SACF;QACD;YACE,KAAK,EAAE,uBAAuB;YAC9B,IAAI,EAAE,KAAK,IAAI,EAAE;gBACf,MAAM,WAAW,GAAG,CAAC,MAAM,wBAAwB,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC,OAAO,CAAA;gBAC3E,WAAW,CAAC,OAAO,GAAG,WAAW,CAAC,OAAO,IAAI,EAAE,CAAA;gBAC/C,WAAW,CAAC,OAAO,CAAC,IAAI,GAAG,qCAAqC,CAAA;gBAEhE,WAAW,CAAC,QAAQ,GAAG,0BAA0B,CAAA;gBAEjD,MAAM,gBAAgB,CAAC,GAAG,CAAC,SAAS,EAAE,WAAW,CAAC,CAAA;YACpD,CAAC;SACF;QACD;YACE,KAAK,EAAE,sCAAsC;YAC7C,IAAI,EAAE,GAAG,EAAE,CAAC,CAAC,MAAM;YACnB,IAAI,EAAE,KAAK,IAAI,EAAE;gBACf,MAAM,wBAAwB,CAAC,GAAG,CAAC,SAAS,EAAE,CAAC,wBAAwB,CAAC,CAAC,CAAA;YAC3E,CAAC;SACF;KACF,CAAA;IACD,MAAM,WAAW,CAAC,KAAK,CAAC,CAAA;AAC1B,CAAC","sourcesContent":["import {HydrogenApp} from '../models/hydrogen.js'\nimport {genericConfigurationFileNames} from '../constants.js'\nimport {\n addNPMDependenciesWithoutVersionIfNeeded,\n findUpAndReadPackageJson,\n writePackageJSON,\n} from '@shopify/cli-kit/node/node-package-manager'\nimport {addRecommendedExtensions, isVSCode} from '@shopify/cli-kit/node/vscode'\nimport {writeFile, fileExists, removeFile, fileContentPrettyFormat} from '@shopify/cli-kit/node/fs'\nimport {joinPath} from '@shopify/cli-kit/node/path'\nimport {AbortError} from '@shopify/cli-kit/node/error'\nimport {renderTasks, Task} from '@shopify/cli-kit/node/ui'\n\ninterface AddESlintOptions {\n app: HydrogenApp\n force: boolean\n install: boolean\n}\n\nexport async function addESLint({app, force, install}: AddESlintOptions) {\n const vscode = await isVSCode(app.directory)\n\n const tasks: Task[] = [\n {\n title: 'Installing dependencies',\n skip: () => !install,\n task: async () => {\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 })\n },\n },\n\n {\n title: 'Adding ESLint configuration',\n task: async () => {\n const eslintConfigPath = joinPath(app.directory, genericConfigurationFileNames.eslint)\n\n if (await fileExists(eslintConfigPath)) {\n if (force) {\n await removeFile(eslintConfigPath)\n } else {\n throw new AbortError('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 fileContentPrettyFormat(\n ['module.exports = {', 'extends: [', `${extended.join(',')}`, ' ],', ' };'].join('\\n'),\n {path: genericConfigurationFileNames.eslint},\n )\n\n await writeFile(eslintConfigPath, eslintConfig)\n },\n },\n {\n title: 'Updating package.json',\n task: async () => {\n const packageJSON = (await findUpAndReadPackageJson(app.directory)).content\n packageJSON.scripts = packageJSON.scripts || {}\n packageJSON.scripts.lint = `eslint --ext .js,.ts,.jsx,.tsx src/`\n\n packageJSON.prettier = '@shopify/prettier-config'\n\n await writePackageJSON(app.directory, packageJSON)\n },\n },\n {\n title: 'Adding editor plugin recommendations',\n skip: () => !vscode,\n task: async () => {\n await addRecommendedExtensions(app.directory, ['dbaeumer.vscode-eslint'])\n },\n },\n ]\n await renderTasks(tasks)\n}\n"]}
@@ -1,7 +1,7 @@
1
1
  import { HydrogenApp } from '../models/hydrogen.js';
2
- import { output } from '@shopify/cli-kit';
2
+ import { OutputMessage } from '@shopify/cli-kit/node/output';
3
3
  interface InfoOptions {
4
4
  showPrivateData: boolean;
5
5
  }
6
- export declare function info(app: HydrogenApp, { showPrivateData }: InfoOptions): output.Message;
6
+ export declare function info(app: HydrogenApp, { showPrivateData }: InfoOptions): OutputMessage;
7
7
  export {};
@@ -1,12 +1,12 @@
1
- import { output } from '@shopify/cli-kit';
2
1
  import { platformAndArch } from '@shopify/cli-kit/node/os';
3
2
  import { capitalize, linesToColumns } from '@shopify/cli-kit/common/string';
3
+ import { outputContent, outputToken } from '@shopify/cli-kit/node/output';
4
4
  export function info(app, { showPrivateData }) {
5
5
  const appInfo = new HydrogenAppInfo(app);
6
6
  return appInfo.output({ showPrivateData });
7
7
  }
8
- const NOT_FOUND_TEXT = output.content `${output.token.italic('Not found')}`.value;
9
- const NOT_CONFIGURED_TEXT = output.content `${output.token.italic('Not yet configured')}`.value;
8
+ const NOT_FOUND_TEXT = outputContent `${outputToken.italic('Not found')}`.value;
9
+ const NOT_CONFIGURED_TEXT = outputContent `${outputToken.italic('Not yet configured')}`.value;
10
10
  class AppInfo {
11
11
  constructor(app) {
12
12
  this.app = app;
@@ -91,7 +91,7 @@ class AppInfo {
91
91
  formattedError(str) {
92
92
  const [errorFirstLine, ...errorRemainingLines] = str.split('\n');
93
93
  const errorLines = [`! ${errorFirstLine}`, ...errorRemainingLines.map((line) => ` ${line}`)];
94
- return output.content `${output.token.errorText(errorLines.join('\n'))}`.value;
94
+ return outputContent `${outputToken.errorText(errorLines.join('\n'))}`.value;
95
95
  }
96
96
  systemInfoSection() {
97
97
  const title = 'Tooling and System';
@@ -107,7 +107,7 @@ class AppInfo {
107
107
  }
108
108
  section(title, body) {
109
109
  const formattedTitle = `${title.toUpperCase()}${' '.repeat(35 - title.length)}`;
110
- return output.content `${output.token.heading(formattedTitle)}\n${body}`.value;
110
+ return outputContent `${outputToken.heading(formattedTitle)}\n${body}`.value;
111
111
  }
112
112
  }
113
113
  class HydrogenAppInfo extends AppInfo {