@shopify/cli-kit 3.45.0-pre.1 → 3.45.0-pre.3

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.
@@ -32,6 +32,7 @@ module ShopifyCLI
32
32
  STACKTRACE = "SHOPIFY_CLI_STACKTRACE"
33
33
  TTY = "SHOPIFY_CLI_TTY"
34
34
  RUN_AS_SUBPROCESS = "SHOPIFY_CLI_RUN_AS_SUBPROCESS"
35
+ RUBY_BIN = "SHOPIFY_CLI_RUBY_BIN"
35
36
 
36
37
  # When true the CLI points to a local instance of
37
38
  # the partners dashboard and identity.
@@ -67,7 +68,7 @@ module ShopifyCLI
67
68
  module SupportedVersions
68
69
  module Ruby
69
70
  FROM = "2.7.5"
70
- TO = "3.2.0"
71
+ TO = "3.2.10"
71
72
  end
72
73
 
73
74
  module Node
@@ -13,8 +13,9 @@ module ShopifyCLI
13
13
  # https://github.com/Shopify/themekit-access/blob/4c3c917d78443160dcf24376a8b5ac6b9bef0bcd/app/models/password_token.rb#L8
14
14
  THEME_ACCESS_PASSWORD_PREFIX = "shptka_"
15
15
 
16
- def self.ruby_version(context: Context.new)
17
- output, status = context.capture2e("ruby", "--version")
16
+ def self.ruby_version(context: Context.new, env_variables: ENV)
17
+ ruby_bin = env_variables[Constants::EnvironmentVariables::RUBY_BIN] || "ruby"
18
+ output, status = context.capture2e(ruby_bin, "--version")
18
19
  raise ShopifyCLI::Abort, context.message("core.errors.missing_ruby") unless status.success?
19
20
  version = output.match(/ruby (\d+\.\d+\.\d+)/)[1]
20
21
  ::Semantic::Version.new(version)
@@ -47,7 +47,7 @@ module ShopifyCLI
47
47
  end
48
48
 
49
49
  def leads_to_injectable_body?(path)
50
- path !~ /web-pixels-manager.+sandbox/
50
+ path !~ /.+\/sandbox/
51
51
  end
52
52
 
53
53
  def inject_hot_reload_javascript(body)
@@ -6,15 +6,23 @@ export const allAPIs = ['admin', 'storefront-renderer', 'partners'];
6
6
  const interestingResponseHeaders = new Set(['cache-control', 'content-type', 'etag', 'x-request-id']);
7
7
  export async function debugLogResponseInfo({ request, url }, errorHandler) {
8
8
  const t0 = performance.now();
9
- let headers = new Headers();
9
+ const responseHeaders = {};
10
10
  let response = {};
11
11
  try {
12
12
  response = await request;
13
- headers = response.headers;
13
+ response.headers.forEach((value, key) => {
14
+ if (interestingResponseHeaders.has(key))
15
+ responseHeaders[key] = value;
16
+ });
14
17
  }
15
18
  catch (err) {
16
19
  if (err instanceof ClientError) {
17
- headers = err.response?.headers;
20
+ if (err.response?.headers) {
21
+ for (const [key, value] of err.response?.headers) {
22
+ if (interestingResponseHeaders.has(key))
23
+ responseHeaders[key] = value;
24
+ }
25
+ }
18
26
  }
19
27
  if (errorHandler) {
20
28
  throw errorHandler(err);
@@ -25,11 +33,6 @@ export async function debugLogResponseInfo({ request, url }, errorHandler) {
25
33
  }
26
34
  finally {
27
35
  const t1 = performance.now();
28
- const responseHeaders = {};
29
- headers.forEach((value, key) => {
30
- if (interestingResponseHeaders.has(key))
31
- responseHeaders[key] = value;
32
- });
33
36
  outputDebug(`Request to ${url} completed in ${Math.round(t1 - t0)} ms
34
37
  With response headers:
35
38
  ${sanitizedHeadersOutput(responseHeaders)}
@@ -1 +1 @@
1
- {"version":3,"file":"api.js","sourceRoot":"","sources":["../../../src/private/node/api.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,sBAAsB,EAAC,MAAM,kBAAkB,CAAA;AACvD,OAAO,EAAC,WAAW,EAAC,MAAM,8BAA8B,CAAA;AACxD,OAAO,EAAC,WAAW,EAAC,MAAM,iBAAiB,CAAA;AAC3C,OAAO,EAAC,WAAW,EAAC,MAAM,YAAY,CAAA;AAItC,MAAM,CAAC,MAAM,OAAO,GAAU,CAAC,OAAO,EAAE,qBAAqB,EAAE,UAAU,CAAC,CAAA;AAO1E,MAAM,0BAA0B,GAAG,IAAI,GAAG,CAAC,CAAC,eAAe,EAAE,cAAc,EAAE,MAAM,EAAE,cAAc,CAAC,CAAC,CAAA;AAErG,MAAM,CAAC,KAAK,UAAU,oBAAoB,CACxC,EAAC,OAAO,EAAE,GAAG,EAAoB,EACjC,YAAkD;IAElD,MAAM,EAAE,GAAG,WAAW,CAAC,GAAG,EAAE,CAAA;IAC5B,IAAI,OAAO,GAAY,IAAI,OAAO,EAAE,CAAA;IACpC,IAAI,QAAQ,GAAM,EAAO,CAAA;IACzB,IAAI;QACF,QAAQ,GAAG,MAAM,OAAO,CAAA;QACxB,OAAO,GAAG,QAAQ,CAAC,OAAO,CAAA;KAC3B;IAAC,OAAO,GAAG,EAAE;QACZ,IAAI,GAAG,YAAY,WAAW,EAAE;YAC9B,OAAO,GAAG,GAAG,CAAC,QAAQ,EAAE,OAAkB,CAAA;SAC3C;QACD,IAAI,YAAY,EAAE;YAChB,MAAM,YAAY,CAAC,GAAG,CAAC,CAAA;SACxB;aAAM;YACL,MAAM,GAAG,CAAA;SACV;KACF;YAAS;QACR,MAAM,EAAE,GAAG,WAAW,CAAC,GAAG,EAAE,CAAA;QAC5B,MAAM,eAAe,GAA4B,EAAE,CAAA;QACnD,OAAO,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,GAAG,EAAE,EAAE;YAC7B,IAAI,0BAA0B,CAAC,GAAG,CAAC,GAAG,CAAC;gBAAE,eAAe,CAAC,GAAG,CAAC,GAAG,KAAK,CAAA;QACvE,CAAC,CAAC,CAAA;QACF,WAAW,CAAC,cAAc,GAAG,iBAAiB,IAAI,CAAC,KAAK,CAAC,EAAE,GAAG,EAAE,CAAC;;EAEnE,sBAAsB,CAAC,eAAe,CAAC;KACpC,CAAC,CAAA;KACH;IACD,OAAO,QAAQ,CAAA;AACjB,CAAC","sourcesContent":["import {sanitizedHeadersOutput} from './api/headers.js'\nimport {outputDebug} from '@shopify/cli-kit/node/output'\nimport {ClientError} from 'graphql-request'\nimport {performance} from 'perf_hooks'\n\nexport type API = 'admin' | 'storefront-renderer' | 'partners'\n\nexport const allAPIs: API[] = ['admin', 'storefront-renderer', 'partners']\n\ninterface RequestOptions<T> {\n request: Promise<T>\n url: string\n}\n\nconst interestingResponseHeaders = new Set(['cache-control', 'content-type', 'etag', 'x-request-id'])\n\nexport async function debugLogResponseInfo<T extends {headers: Headers; status: number}>(\n {request, url}: RequestOptions<T>,\n errorHandler?: (error: unknown) => Error | unknown,\n): Promise<T> {\n const t0 = performance.now()\n let headers: Headers = new Headers()\n let response: T = {} as T\n try {\n response = await request\n headers = response.headers\n } catch (err) {\n if (err instanceof ClientError) {\n headers = err.response?.headers as Headers\n }\n if (errorHandler) {\n throw errorHandler(err)\n } else {\n throw err\n }\n } finally {\n const t1 = performance.now()\n const responseHeaders: {[key: string]: string} = {}\n headers.forEach((value, key) => {\n if (interestingResponseHeaders.has(key)) responseHeaders[key] = value\n })\n outputDebug(`Request to ${url} completed in ${Math.round(t1 - t0)} ms\nWith response headers:\n${sanitizedHeadersOutput(responseHeaders)}\n `)\n }\n return response\n}\n"]}
1
+ {"version":3,"file":"api.js","sourceRoot":"","sources":["../../../src/private/node/api.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,sBAAsB,EAAC,MAAM,kBAAkB,CAAA;AACvD,OAAO,EAAC,WAAW,EAAC,MAAM,8BAA8B,CAAA;AACxD,OAAO,EAAC,WAAW,EAAC,MAAM,iBAAiB,CAAA;AAC3C,OAAO,EAAC,WAAW,EAAC,MAAM,YAAY,CAAA;AAItC,MAAM,CAAC,MAAM,OAAO,GAAU,CAAC,OAAO,EAAE,qBAAqB,EAAE,UAAU,CAAC,CAAA;AAO1E,MAAM,0BAA0B,GAAG,IAAI,GAAG,CAAC,CAAC,eAAe,EAAE,cAAc,EAAE,MAAM,EAAE,cAAc,CAAC,CAAC,CAAA;AAErG,MAAM,CAAC,KAAK,UAAU,oBAAoB,CACxC,EAAC,OAAO,EAAE,GAAG,EAAoB,EACjC,YAAkD;IAElD,MAAM,EAAE,GAAG,WAAW,CAAC,GAAG,EAAE,CAAA;IAC5B,MAAM,eAAe,GAA4B,EAAE,CAAA;IACnD,IAAI,QAAQ,GAAM,EAAO,CAAA;IACzB,IAAI;QACF,QAAQ,GAAG,MAAM,OAAO,CAAA;QACxB,QAAQ,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,GAAG,EAAE,EAAE;YACtC,IAAI,0BAA0B,CAAC,GAAG,CAAC,GAAG,CAAC;gBAAE,eAAe,CAAC,GAAG,CAAC,GAAG,KAAK,CAAA;QACvE,CAAC,CAAC,CAAA;KACH;IAAC,OAAO,GAAG,EAAE;QACZ,IAAI,GAAG,YAAY,WAAW,EAAE;YAC9B,IAAI,GAAG,CAAC,QAAQ,EAAE,OAAO,EAAE;gBACzB,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,GAAG,CAAC,QAAQ,EAAE,OAAqC,EAAE;oBAC9E,IAAI,0BAA0B,CAAC,GAAG,CAAC,GAAG,CAAC;wBAAE,eAAe,CAAC,GAAG,CAAC,GAAG,KAAK,CAAA;iBACtE;aACF;SACF;QACD,IAAI,YAAY,EAAE;YAChB,MAAM,YAAY,CAAC,GAAG,CAAC,CAAA;SACxB;aAAM;YACL,MAAM,GAAG,CAAA;SACV;KACF;YAAS;QACR,MAAM,EAAE,GAAG,WAAW,CAAC,GAAG,EAAE,CAAA;QAC5B,WAAW,CAAC,cAAc,GAAG,iBAAiB,IAAI,CAAC,KAAK,CAAC,EAAE,GAAG,EAAE,CAAC;;EAEnE,sBAAsB,CAAC,eAAe,CAAC;KACpC,CAAC,CAAA;KACH;IACD,OAAO,QAAQ,CAAA;AACjB,CAAC","sourcesContent":["import {sanitizedHeadersOutput} from './api/headers.js'\nimport {outputDebug} from '@shopify/cli-kit/node/output'\nimport {ClientError} from 'graphql-request'\nimport {performance} from 'perf_hooks'\n\nexport type API = 'admin' | 'storefront-renderer' | 'partners'\n\nexport const allAPIs: API[] = ['admin', 'storefront-renderer', 'partners']\n\ninterface RequestOptions<T> {\n request: Promise<T>\n url: string\n}\n\nconst interestingResponseHeaders = new Set(['cache-control', 'content-type', 'etag', 'x-request-id'])\n\nexport async function debugLogResponseInfo<T extends {headers: Headers; status: number}>(\n {request, url}: RequestOptions<T>,\n errorHandler?: (error: unknown) => Error | unknown,\n): Promise<T> {\n const t0 = performance.now()\n const responseHeaders: {[key: string]: string} = {}\n let response: T = {} as T\n try {\n response = await request\n response.headers.forEach((value, key) => {\n if (interestingResponseHeaders.has(key)) responseHeaders[key] = value\n })\n } catch (err) {\n if (err instanceof ClientError) {\n if (err.response?.headers) {\n for (const [key, value] of err.response?.headers as Iterable<[string, string]>) {\n if (interestingResponseHeaders.has(key)) responseHeaders[key] = value\n }\n }\n }\n if (errorHandler) {\n throw errorHandler(err)\n } else {\n throw err\n }\n } finally {\n const t1 = performance.now()\n outputDebug(`Request to ${url} completed in ${Math.round(t1 - t0)} ms\nWith response headers:\n${sanitizedHeadersOutput(responseHeaders)}\n `)\n }\n return response\n}\n"]}
@@ -1,7 +1,6 @@
1
1
  import { getFavicon, getStylesheet, getEmptyUrlHTML, getAuthErrorHTML, getMissingCodeHTML, getMissingStateHTML, getSuccessHTML, EmptyUrlString, MissingCodeString, MissingStateString, } from './post-auth.js';
2
2
  import { AbortError, BugError } from '../../../public/node/error.js';
3
3
  import { outputContent, outputInfo, outputToken } from '../../../public/node/output.js';
4
- import { createApp } from 'h3';
5
4
  import url from 'url';
6
5
  import { createServer } from 'http';
7
6
  const ResponseTimeoutSeconds = 10;
@@ -15,7 +14,7 @@ const ServerStopDelaySeconds = 0.5;
15
14
  */
16
15
  export class RedirectListener {
17
16
  static createServer(callback) {
18
- const app = createApp().use('*', async (request, response) => {
17
+ const app = async (request, response) => {
19
18
  const requestUrl = request.url;
20
19
  if (requestUrl?.includes('favicon')) {
21
20
  const faviconFile = await getFavicon();
@@ -65,7 +64,7 @@ export class RedirectListener {
65
64
  }
66
65
  const file = await getSuccessHTML();
67
66
  return respond(file, undefined, `${queryObject.code}`, `${queryObject.state}`);
68
- });
67
+ };
69
68
  // eslint-disable-next-line @typescript-eslint/no-misused-promises
70
69
  return createServer(app);
71
70
  }
@@ -1 +1 @@
1
- {"version":3,"file":"redirect-listener.js","sourceRoot":"","sources":["../../../../src/private/node/session/redirect-listener.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EACV,aAAa,EACb,eAAe,EACf,gBAAgB,EAChB,kBAAkB,EAClB,mBAAmB,EACnB,cAAc,EACd,cAAc,EACd,iBAAiB,EACjB,kBAAkB,GACnB,MAAM,gBAAgB,CAAA;AACvB,OAAO,EAAC,UAAU,EAAE,QAAQ,EAAC,MAAM,+BAA+B,CAAA;AAClE,OAAO,EAAC,aAAa,EAAE,UAAU,EAAE,WAAW,EAAC,MAAM,gCAAgC,CAAA;AACrF,OAAO,EAAC,SAAS,EAAkC,MAAM,IAAI,CAAA;AAC7D,OAAO,GAAG,MAAM,KAAK,CAAA;AACrB,OAAO,EAAC,YAAY,EAAS,MAAM,MAAM,CAAA;AAEzC,MAAM,sBAAsB,GAAG,EAAE,CAAA;AACjC,MAAM,sBAAsB,GAAG,GAAG,CAAA;AAgBlC;;;;;;GAMG;AACH,MAAM,OAAO,gBAAgB;IACnB,MAAM,CAAC,YAAY,CAAC,QAA0B;QACpD,MAAM,GAAG,GAAG,SAAS,EAAE,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,EAAE,OAAwB,EAAE,QAAwB,EAAE,EAAE;YAC5F,MAAM,UAAU,GAAG,OAAO,CAAC,GAAG,CAAA;YAC9B,IAAI,UAAU,EAAE,QAAQ,CAAC,SAAS,CAAC,EAAE;gBACnC,MAAM,WAAW,GAAG,MAAM,UAAU,EAAE,CAAA;gBACtC,QAAQ,CAAC,SAAS,CAAC,cAAc,EAAE,eAAe,CAAC,CAAA;gBACnD,QAAQ,CAAC,KAAK,CAAC,WAAW,CAAC,CAAA;gBAC3B,QAAQ,CAAC,GAAG,EAAE,CAAA;gBACd,OAAO,EAAE,CAAA;aACV;iBAAM,IAAI,UAAU,KAAK,YAAY,EAAE;gBACt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,KAAK,EAAE,CAAA;IAC3B,CAAC;CACF;AAED,MAAM,CAAC,KAAK,UAAU,cAAc,CAAC,IAAY,EAAE,IAAY,EAAE,GAAW;IAC1E,MAAM,MAAM,GAAG,MAAM,IAAI,OAAO,CAAgC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QAClF,MAAM,OAAO,GAAG,UAAU,CAAC,GAAG,EAAE;YAC9B,MAAM,OAAO,GAAG,8CAA8C,CAAA;YAC9D,UAAU,CAAC,aAAa,CAAA,GAAG,OAAO,GAAG,WAAW,CAAC,IAAI,CAAC,4BAA4B,EAAE,GAAG,CAAC,IAAI,CAAC,CAAA;QAC/F,CAAC,EAAE,sBAAsB,GAAG,IAAI,CAAC,CAAA;QAEjC,MAAM,QAAQ,GAAqB,CAAC,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE;YACxD,YAAY,CAAC,OAAO,CAAC,CAAA;YACrB,UAAU,CAAC,GAAG,EAAE;gBACd,mEAAmE;gBACnE,gBAAgB,CAAC,IAAI,EAAE,CAAA;gBACvB,IAAI,KAAK;oBAAE,MAAM,CAAC,KAAK,CAAC,CAAA;;oBACnB,OAAO,CAAC,EAAC,IAAI,EAAE,IAAc,EAAE,KAAK,EAAE,KAAe,EAAC,CAAC,CAAA;YAC9D,CAAC,EAAE,sBAAsB,GAAG,IAAI,CAAC,CAAA;QACnC,CAAC,CAAA;QAED,MAAM,gBAAgB,GAAG,IAAI,gBAAgB,CAAC,EAAC,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAC,CAAC,CAAA;QACrE,gBAAgB,CAAC,KAAK,EAAE,CAAA;IAC1B,CAAC,CAAC,CAAA;IACF,OAAO,MAAM,CAAA;AACf,CAAC","sourcesContent":["import {\n getFavicon,\n getStylesheet,\n getEmptyUrlHTML,\n getAuthErrorHTML,\n getMissingCodeHTML,\n getMissingStateHTML,\n getSuccessHTML,\n EmptyUrlString,\n MissingCodeString,\n MissingStateString,\n} from './post-auth.js'\nimport {AbortError, BugError} from '../../../public/node/error.js'\nimport {outputContent, outputInfo, outputToken} from '../../../public/node/output.js'\nimport {createApp, IncomingMessage, ServerResponse} from 'h3'\nimport url from 'url'\nimport {createServer, Server} from 'http'\n\nconst ResponseTimeoutSeconds = 10\nconst ServerStopDelaySeconds = 0.5\n\n/**\n * It represents the result of a redirect.\n */\ntype RedirectCallback = (error: Error | undefined, state: string | undefined, code: string | undefined) => void\n\n/**\n * Defines the interface of the options that\n * are used to instantiate a redirect listener.\n */\ninterface RedirectListenerOptions {\n host: string\n port: number\n callback: RedirectCallback\n}\n/**\n * When the authentication completes, Identity redirects\n * the user to a URL. In the case of the CLI, the redirect\n * is to localhost passing some parameters that are necessary\n * to continue the authentication. Because of that, we need\n * an HTTP server that runs and listens to the request.\n */\nexport class RedirectListener {\n private static createServer(callback: RedirectCallback): Server {\n const app = createApp().use('*', async (request: IncomingMessage, response: ServerResponse) => {\n const requestUrl = request.url\n if (requestUrl?.includes('favicon')) {\n const faviconFile = await getFavicon()\n response.setHeader('Content-Type', 'image/svg+xml')\n response.write(faviconFile)\n response.end()\n return {}\n } else if (requestUrl === '/style.css') {\n const stylesheetFile = await getStylesheet()\n response.setHeader('Content-Type', 'text/css')\n response.write(stylesheetFile)\n response.end()\n return {}\n }\n\n const respond = async (contents: string, error?: Error, state?: string, code?: string) => {\n response.setHeader('Content-Type', 'text/html')\n response.write(contents)\n response.end()\n callback(error, state, code)\n return {}\n }\n\n // If there was an empty/malformed URL sent back.\n if (!requestUrl) {\n const file = await getEmptyUrlHTML()\n const err = new BugError(EmptyUrlString)\n return respond(file, err, undefined, undefined)\n }\n\n // If an error was returned by the Identity server.\n const queryObject = url.parse(requestUrl, true).query\n if (queryObject.error && queryObject.error_description) {\n const file = await getAuthErrorHTML()\n const err = new AbortError(`${queryObject.error_description}`)\n return respond(file, err, undefined, undefined)\n }\n\n // If the code isn't present in the URL.\n if (!queryObject.code) {\n const file = await getMissingCodeHTML()\n const err = new BugError(MissingCodeString)\n return respond(file, err, undefined, undefined)\n }\n\n // If the state isn't present in the URL.\n if (!queryObject.state) {\n const file = await getMissingStateHTML()\n const err = new BugError(MissingStateString)\n return respond(file, err, undefined, undefined)\n }\n\n const file = await getSuccessHTML()\n return respond(file, undefined, `${queryObject.code}`, `${queryObject.state}`)\n })\n\n // eslint-disable-next-line @typescript-eslint/no-misused-promises\n return createServer(app)\n }\n\n port: number\n host: string\n server: ReturnType<typeof RedirectListener.createServer>\n\n constructor(options: RedirectListenerOptions) {\n this.port = options.port\n this.host = options.host\n this.server = RedirectListener.createServer(options.callback)\n }\n\n start(): void {\n this.server.listen({port: this.port, host: this.host}, () => {})\n }\n\n async stop(): Promise<void> {\n await this.server.close()\n }\n}\n\nexport async function listenRedirect(host: string, port: number, url: string): Promise<{code: string; state: string}> {\n const result = await new Promise<{code: string; state: string}>((resolve, reject) => {\n const timeout = setTimeout(() => {\n const message = '\\nAuto-open timed out. Open the login page: '\n outputInfo(outputContent`${message}${outputToken.link('Log in to Shopify Partners', url)}\\n`)\n }, ResponseTimeoutSeconds * 1000)\n\n const callback: RedirectCallback = (error, code, state) => {\n clearTimeout(timeout)\n setTimeout(() => {\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\n redirectListener.stop()\n if (error) reject(error)\n else resolve({code: code as string, state: state as string})\n }, ServerStopDelaySeconds * 1000)\n }\n\n const redirectListener = new RedirectListener({host, port, callback})\n redirectListener.start()\n })\n return result\n}\n"]}
1
+ {"version":3,"file":"redirect-listener.js","sourceRoot":"","sources":["../../../../src/private/node/session/redirect-listener.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EACV,aAAa,EACb,eAAe,EACf,gBAAgB,EAChB,kBAAkB,EAClB,mBAAmB,EACnB,cAAc,EACd,cAAc,EACd,iBAAiB,EACjB,kBAAkB,GACnB,MAAM,gBAAgB,CAAA;AACvB,OAAO,EAAC,UAAU,EAAE,QAAQ,EAAC,MAAM,+BAA+B,CAAA;AAClE,OAAO,EAAC,aAAa,EAAE,U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,EAAE,KAAK,EAAE,EAAE;YACxD,YAAY,CAAC,OAAO,CAAC,CAAA;YACrB,UAAU,CAAC,GAAG,EAAE;gBACd,mEAAmE;gBACnE,gBAAgB,CAAC,IAAI,EAAE,CAAA;gBACvB,IAAI,KAAK;oBAAE,MAAM,CAAC,KAAK,CAAC,CAAA;;oBACnB,OAAO,CAAC,EAAC,IAAI,EAAE,IAAc,EAAE,KAAK,EAAE,KAAe,EAAC,CAAC,CAAA;YAC9D,CAAC,EAAE,sBAAsB,GAAG,IAAI,CAAC,CAAA;QACnC,CAAC,CAAA;QAED,MAAM,gBAAgB,GAAG,IAAI,gBAAgB,CAAC,EAAC,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAC,CAAC,CAAA;QACrE,gBAAgB,CAAC,KAAK,EAAE,CAAA;IAC1B,CAAC,CAAC,CAAA;IACF,OAAO,MAAM,CAAA;AACf,CAAC","sourcesContent":["import {\n getFavicon,\n getStylesheet,\n getEmptyUrlHTML,\n getAuthErrorHTML,\n getMissingCodeHTML,\n getMissingStateHTML,\n getSuccessHTML,\n EmptyUrlString,\n MissingCodeString,\n MissingStateString,\n} from './post-auth.js'\nimport {AbortError, BugError} from '../../../public/node/error.js'\nimport {outputContent, outputInfo, outputToken} from '../../../public/node/output.js'\nimport url from 'url'\nimport {createServer, Server, IncomingMessage, ServerResponse} from 'http'\n\nconst ResponseTimeoutSeconds = 10\nconst ServerStopDelaySeconds = 0.5\n\n/**\n * It represents the result of a redirect.\n */\ntype RedirectCallback = (error: Error | undefined, state: string | undefined, code: string | undefined) => void\n\n/**\n * Defines the interface of the options that\n * are used to instantiate a redirect listener.\n */\ninterface RedirectListenerOptions {\n host: string\n port: number\n callback: RedirectCallback\n}\n/**\n * When the authentication completes, Identity redirects\n * the user to a URL. In the case of the CLI, the redirect\n * is to localhost passing some parameters that are necessary\n * to continue the authentication. Because of that, we need\n * an HTTP server that runs and listens to the request.\n */\nexport class RedirectListener {\n private static createServer(callback: RedirectCallback): Server {\n const app = async (request: IncomingMessage, response: ServerResponse) => {\n const requestUrl = request.url\n if (requestUrl?.includes('favicon')) {\n const faviconFile = await getFavicon()\n response.setHeader('Content-Type', 'image/svg+xml')\n response.write(faviconFile)\n response.end()\n return {}\n } else if (requestUrl === '/style.css') {\n const stylesheetFile = await getStylesheet()\n response.setHeader('Content-Type', 'text/css')\n response.write(stylesheetFile)\n response.end()\n return {}\n }\n\n const respond = async (contents: string, error?: Error, state?: string, code?: string) => {\n response.setHeader('Content-Type', 'text/html')\n response.write(contents)\n response.end()\n callback(error, state, code)\n return {}\n }\n\n // If there was an empty/malformed URL sent back.\n if (!requestUrl) {\n const file = await getEmptyUrlHTML()\n const err = new BugError(EmptyUrlString)\n return respond(file, err, undefined, undefined)\n }\n\n // If an error was returned by the Identity server.\n const queryObject = url.parse(requestUrl, true).query\n if (queryObject.error && queryObject.error_description) {\n const file = await getAuthErrorHTML()\n const err = new AbortError(`${queryObject.error_description}`)\n return respond(file, err, undefined, undefined)\n }\n\n // If the code isn't present in the URL.\n if (!queryObject.code) {\n const file = await getMissingCodeHTML()\n const err = new BugError(MissingCodeString)\n return respond(file, err, undefined, undefined)\n }\n\n // If the state isn't present in the URL.\n if (!queryObject.state) {\n const file = await getMissingStateHTML()\n const err = new BugError(MissingStateString)\n return respond(file, err, undefined, undefined)\n }\n\n const file = await getSuccessHTML()\n return respond(file, undefined, `${queryObject.code}`, `${queryObject.state}`)\n }\n\n // eslint-disable-next-line @typescript-eslint/no-misused-promises\n return createServer(app)\n }\n\n port: number\n host: string\n server: ReturnType<typeof RedirectListener.createServer>\n\n constructor(options: RedirectListenerOptions) {\n this.port = options.port\n this.host = options.host\n this.server = RedirectListener.createServer(options.callback)\n }\n\n start(): void {\n this.server.listen({port: this.port, host: this.host}, () => {})\n }\n\n async stop(): Promise<void> {\n await this.server.close()\n }\n}\n\nexport async function listenRedirect(host: string, port: number, url: string): Promise<{code: string; state: string}> {\n const result = await new Promise<{code: string; state: string}>((resolve, reject) => {\n const timeout = setTimeout(() => {\n const message = '\\nAuto-open timed out. Open the login page: '\n outputInfo(outputContent`${message}${outputToken.link('Log in to Shopify Partners', url)}\\n`)\n }, ResponseTimeoutSeconds * 1000)\n\n const callback: RedirectCallback = (error, code, state) => {\n clearTimeout(timeout)\n setTimeout(() => {\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\n redirectListener.stop()\n if (error) reject(error)\n else resolve({code: code as string, state: state as string})\n }, ServerStopDelaySeconds * 1000)\n }\n\n const redirectListener = new RedirectListener({host, port, callback})\n redirectListener.start()\n })\n return result\n}\n"]}
@@ -1,13 +1,13 @@
1
- import { schema } from '../../../public/node/schema.js';
1
+ import { zod } from '../../../public/node/schema.js';
2
2
  /**
3
3
  * The schema represents an Identity token.
4
4
  */
5
- declare const IdentityTokenSchema: schema.ZodObject<{
6
- accessToken: schema.ZodString;
7
- refreshToken: schema.ZodString;
8
- expiresAt: schema.ZodEffects<schema.ZodDate, Date, Date>;
9
- scopes: schema.ZodArray<schema.ZodString, "many">;
10
- }, "strip", schema.ZodTypeAny, {
5
+ declare const IdentityTokenSchema: zod.ZodObject<{
6
+ accessToken: zod.ZodString;
7
+ refreshToken: zod.ZodString;
8
+ expiresAt: zod.ZodEffects<zod.ZodDate, Date, Date>;
9
+ scopes: zod.ZodArray<zod.ZodString, "many">;
10
+ }, "strip", zod.ZodTypeAny, {
11
11
  accessToken: string;
12
12
  refreshToken: string;
13
13
  expiresAt: Date;
@@ -21,11 +21,11 @@ declare const IdentityTokenSchema: schema.ZodObject<{
21
21
  /**
22
22
  * The schema represents an application token.
23
23
  */
24
- declare const ApplicationTokenSchema: schema.ZodObject<{
25
- accessToken: schema.ZodString;
26
- expiresAt: schema.ZodEffects<schema.ZodDate, Date, Date>;
27
- scopes: schema.ZodArray<schema.ZodString, "many">;
28
- }, "strip", schema.ZodTypeAny, {
24
+ declare const ApplicationTokenSchema: zod.ZodObject<{
25
+ accessToken: zod.ZodString;
26
+ expiresAt: zod.ZodEffects<zod.ZodDate, Date, Date>;
27
+ scopes: zod.ZodArray<zod.ZodString, "many">;
28
+ }, "strip", zod.ZodTypeAny, {
29
29
  accessToken: string;
30
30
  expiresAt: Date;
31
31
  scopes: string[];
@@ -57,18 +57,18 @@ declare const ApplicationTokenSchema: schema.ZodObject<{
57
57
  * }
58
58
  * ```
59
59
  */
60
- export declare const SessionSchema: schema.ZodObject<{}, "strip", schema.ZodObject<{
60
+ export declare const SessionSchema: zod.ZodObject<{}, "strip", zod.ZodObject<{
61
61
  /**
62
62
  * It contains the identity token. Before usint it, we exchange it
63
63
  * to get a token that we can use with different applications. The exchanged
64
64
  * tokens for the applications are stored under applications.
65
65
  */
66
- identity: schema.ZodObject<{
67
- accessToken: schema.ZodString;
68
- refreshToken: schema.ZodString;
69
- expiresAt: schema.ZodEffects<schema.ZodDate, Date, Date>;
70
- scopes: schema.ZodArray<schema.ZodString, "many">;
71
- }, "strip", schema.ZodTypeAny, {
66
+ identity: zod.ZodObject<{
67
+ accessToken: zod.ZodString;
68
+ refreshToken: zod.ZodString;
69
+ expiresAt: zod.ZodEffects<zod.ZodDate, Date, Date>;
70
+ scopes: zod.ZodArray<zod.ZodString, "many">;
71
+ }, "strip", zod.ZodTypeAny, {
72
72
  accessToken: string;
73
73
  refreshToken: string;
74
74
  expiresAt: Date;
@@ -83,11 +83,11 @@ export declare const SessionSchema: schema.ZodObject<{}, "strip", schema.ZodObje
83
83
  * It contains exchanged tokens for the applications the CLI
84
84
  * authenticates with. Tokens are scoped under the fqdn of the applications.
85
85
  */
86
- applications: schema.ZodObject<{}, "strip", schema.ZodObject<{
87
- accessToken: schema.ZodString;
88
- expiresAt: schema.ZodEffects<schema.ZodDate, Date, Date>;
89
- scopes: schema.ZodArray<schema.ZodString, "many">;
90
- }, "strip", schema.ZodTypeAny, {
86
+ applications: zod.ZodObject<{}, "strip", zod.ZodObject<{
87
+ accessToken: zod.ZodString;
88
+ expiresAt: zod.ZodEffects<zod.ZodDate, Date, Date>;
89
+ scopes: zod.ZodArray<zod.ZodString, "many">;
90
+ }, "strip", zod.ZodTypeAny, {
91
91
  accessToken: string;
92
92
  expiresAt: Date;
93
93
  scopes: string[];
@@ -108,7 +108,7 @@ export declare const SessionSchema: schema.ZodObject<{}, "strip", schema.ZodObje
108
108
  scopes: string[];
109
109
  };
110
110
  }>;
111
- }, "strip", schema.ZodTypeAny, {
111
+ }, "strip", zod.ZodTypeAny, {
112
112
  identity: {
113
113
  accessToken: string;
114
114
  refreshToken: string;
@@ -169,7 +169,7 @@ export declare const SessionSchema: schema.ZodObject<{}, "strip", schema.ZodObje
169
169
  };
170
170
  };
171
171
  }>;
172
- export type Session = schema.infer<typeof SessionSchema>;
173
- export type IdentityToken = schema.infer<typeof IdentityTokenSchema>;
174
- export type ApplicationToken = schema.infer<typeof ApplicationTokenSchema>;
172
+ export type Session = zod.infer<typeof SessionSchema>;
173
+ export type IdentityToken = zod.infer<typeof IdentityTokenSchema>;
174
+ export type ApplicationToken = zod.infer<typeof ApplicationTokenSchema>;
175
175
  export {};
@@ -1,25 +1,25 @@
1
- import { schema } from '../../../public/node/schema.js';
2
- const DateSchema = schema.preprocess((arg) => {
1
+ import { zod } from '../../../public/node/schema.js';
2
+ const DateSchema = zod.preprocess((arg) => {
3
3
  if (typeof arg === 'string' || arg instanceof Date)
4
4
  return new Date(arg);
5
5
  return null;
6
- }, schema.date());
6
+ }, zod.date());
7
7
  /**
8
8
  * The schema represents an Identity token.
9
9
  */
10
- const IdentityTokenSchema = schema.object({
11
- accessToken: schema.string(),
12
- refreshToken: schema.string(),
10
+ const IdentityTokenSchema = zod.object({
11
+ accessToken: zod.string(),
12
+ refreshToken: zod.string(),
13
13
  expiresAt: DateSchema,
14
- scopes: schema.array(schema.string()),
14
+ scopes: zod.array(zod.string()),
15
15
  });
16
16
  /**
17
17
  * The schema represents an application token.
18
18
  */
19
- const ApplicationTokenSchema = schema.object({
20
- accessToken: schema.string(),
19
+ const ApplicationTokenSchema = zod.object({
20
+ accessToken: zod.string(),
21
21
  expiresAt: DateSchema,
22
- scopes: schema.array(schema.string()),
22
+ scopes: zod.array(zod.string()),
23
23
  });
24
24
  /**
25
25
  * This schema represents the format of the session
@@ -44,7 +44,7 @@ const ApplicationTokenSchema = schema.object({
44
44
  * }
45
45
  * ```
46
46
  */
47
- export const SessionSchema = schema.object({}).catchall(schema.object({
47
+ export const SessionSchema = zod.object({}).catchall(zod.object({
48
48
  /**
49
49
  * It contains the identity token. Before usint it, we exchange it
50
50
  * to get a token that we can use with different applications. The exchanged
@@ -55,6 +55,6 @@ export const SessionSchema = schema.object({}).catchall(schema.object({
55
55
  * It contains exchanged tokens for the applications the CLI
56
56
  * authenticates with. Tokens are scoped under the fqdn of the applications.
57
57
  */
58
- applications: schema.object({}).catchall(ApplicationTokenSchema),
58
+ applications: zod.object({}).catchall(ApplicationTokenSchema),
59
59
  }));
60
60
  //# sourceMappingURL=schema.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"schema.js","sourceRoot":"","sources":["../../../../src/private/node/session/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,MAAM,EAAC,MAAM,gCAAgC,CAAA;AAErD,MAAM,UAAU,GAAG,MAAM,CAAC,UAAU,CAAC,CAAC,GAAG,EAAE,EAAE;IAC3C,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,GAAG,YAAY,IAAI;QAAE,OAAO,IAAI,IAAI,CAAC,GAAG,CAAC,CAAA;IACxE,OAAO,IAAI,CAAA;AACb,CAAC,EAAE,MAAM,CAAC,IAAI,EAAE,CAAC,CAAA;AAEjB;;GAEG;AACH,MAAM,mBAAmB,GAAG,MAAM,CAAC,MAAM,CAAC;IACxC,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE;IAC5B,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE;IAC7B,SAAS,EAAE,UAAU;IACrB,MAAM,EAAE,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC;CACtC,CAAC,CAAA;AAEF;;GAEG;AACH,MAAM,sBAAsB,GAAG,MAAM,CAAC,MAAM,CAAC;IAC3C,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE;IAC5B,SAAS,EAAE,UAAU;IACrB,MAAM,EAAE,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC;CACtC,CAAC,CAAA;AAEF;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,QAAQ,CACrD,MAAM,CAAC,MAAM,CAAC;IACZ;;;;OAIG;IACH,QAAQ,EAAE,mBAAmB;IAC7B;;;OAGG;IACH,YAAY,EAAE,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,sBAAsB,CAAC;CACjE,CAAC,CACH,CAAA","sourcesContent":["import {schema} from '../../../public/node/schema.js'\n\nconst DateSchema = schema.preprocess((arg) => {\n if (typeof arg === 'string' || arg instanceof Date) return new Date(arg)\n return null\n}, schema.date())\n\n/**\n * The schema represents an Identity token.\n */\nconst IdentityTokenSchema = schema.object({\n accessToken: schema.string(),\n refreshToken: schema.string(),\n expiresAt: DateSchema,\n scopes: schema.array(schema.string()),\n})\n\n/**\n * The schema represents an application token.\n */\nconst ApplicationTokenSchema = schema.object({\n accessToken: schema.string(),\n expiresAt: DateSchema,\n scopes: schema.array(schema.string()),\n})\n\n/**\n * This schema represents the format of the session\n * that we cache in the system to avoid unnecessary\n * token exchanges.\n *\n * @example\n * ```\n * {\n * \"accounts.shopify.com\": {\n * \"identity\": {...} // IdentityTokenSchema\n * \"applications\": {\n * \"${domain}-application-id\": { // Admin APIs includes domain in the key\n * \"accessToken\": \"...\",\n * },\n * \"$application-id\": { // ApplicationTokenSchema\n * \"accessToken\": \"...\",\n * },\n * }\n * },\n * \"identity.spin.com\": {...}\n * }\n * ```\n */\nexport const SessionSchema = schema.object({}).catchall(\n schema.object({\n /**\n * It contains the identity token. Before usint it, we exchange it\n * to get a token that we can use with different applications. The exchanged\n * tokens for the applications are stored under applications.\n */\n identity: IdentityTokenSchema,\n /**\n * It contains exchanged tokens for the applications the CLI\n * authenticates with. Tokens are scoped under the fqdn of the applications.\n */\n applications: schema.object({}).catchall(ApplicationTokenSchema),\n }),\n)\n\nexport type Session = schema.infer<typeof SessionSchema>\nexport type IdentityToken = schema.infer<typeof IdentityTokenSchema>\nexport type ApplicationToken = schema.infer<typeof ApplicationTokenSchema>\n"]}
1
+ {"version":3,"file":"schema.js","sourceRoot":"","sources":["../../../../src/private/node/session/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,GAAG,EAAC,MAAM,gCAAgC,CAAA;AAElD,MAAM,UAAU,GAAG,GAAG,CAAC,UAAU,CAAC,CAAC,GAAG,EAAE,EAAE;IACxC,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,GAAG,YAAY,IAAI;QAAE,OAAO,IAAI,IAAI,CAAC,GAAG,CAAC,CAAA;IACxE,OAAO,IAAI,CAAA;AACb,CAAC,EAAE,GAAG,CAAC,IAAI,EAAE,CAAC,CAAA;AAEd;;GAEG;AACH,MAAM,mBAAmB,GAAG,GAAG,CAAC,MAAM,CAAC;IACrC,WAAW,EAAE,GAAG,CAAC,MAAM,EAAE;IACzB,YAAY,EAAE,GAAG,CAAC,MAAM,EAAE;IAC1B,SAAS,EAAE,UAAU;IACrB,MAAM,EAAE,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,MAAM,EAAE,CAAC;CAChC,CAAC,CAAA;AAEF;;GAEG;AACH,MAAM,sBAAsB,GAAG,GAAG,CAAC,MAAM,CAAC;IACxC,WAAW,EAAE,GAAG,CAAC,MAAM,EAAE;IACzB,SAAS,EAAE,UAAU;IACrB,MAAM,EAAE,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,MAAM,EAAE,CAAC;CAChC,CAAC,CAAA;AAEF;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,QAAQ,CAClD,GAAG,CAAC,MAAM,CAAC;IACT;;;;OAIG;IACH,QAAQ,EAAE,mBAAmB;IAC7B;;;OAGG;IACH,YAAY,EAAE,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,sBAAsB,CAAC;CAC9D,CAAC,CACH,CAAA","sourcesContent":["import {zod} from '../../../public/node/schema.js'\n\nconst DateSchema = zod.preprocess((arg) => {\n if (typeof arg === 'string' || arg instanceof Date) return new Date(arg)\n return null\n}, zod.date())\n\n/**\n * The schema represents an Identity token.\n */\nconst IdentityTokenSchema = zod.object({\n accessToken: zod.string(),\n refreshToken: zod.string(),\n expiresAt: DateSchema,\n scopes: zod.array(zod.string()),\n})\n\n/**\n * The schema represents an application token.\n */\nconst ApplicationTokenSchema = zod.object({\n accessToken: zod.string(),\n expiresAt: DateSchema,\n scopes: zod.array(zod.string()),\n})\n\n/**\n * This schema represents the format of the session\n * that we cache in the system to avoid unnecessary\n * token exchanges.\n *\n * @example\n * ```\n * {\n * \"accounts.shopify.com\": {\n * \"identity\": {...} // IdentityTokenSchema\n * \"applications\": {\n * \"${domain}-application-id\": { // Admin APIs includes domain in the key\n * \"accessToken\": \"...\",\n * },\n * \"$application-id\": { // ApplicationTokenSchema\n * \"accessToken\": \"...\",\n * },\n * }\n * },\n * \"identity.spin.com\": {...}\n * }\n * ```\n */\nexport const SessionSchema = zod.object({}).catchall(\n zod.object({\n /**\n * It contains the identity token. Before usint it, we exchange it\n * to get a token that we can use with different applications. The exchanged\n * tokens for the applications are stored under applications.\n */\n identity: IdentityTokenSchema,\n /**\n * It contains exchanged tokens for the applications the CLI\n * authenticates with. Tokens are scoped under the fqdn of the applications.\n */\n applications: zod.object({}).catchall(ApplicationTokenSchema),\n }),\n)\n\nexport type Session = zod.infer<typeof SessionSchema>\nexport type IdentityToken = zod.infer<typeof IdentityTokenSchema>\nexport type ApplicationToken = zod.infer<typeof ApplicationTokenSchema>\n"]}
@@ -1 +1,2 @@
1
+ export declare const API_NAME_LIMIT = 50;
1
2
  export declare function generateThemeName(context: string): string;
@@ -1,12 +1,12 @@
1
1
  import { replaceInvalidCharacters } from './replace-invalid-characters.js';
2
2
  import { randomBytes } from 'crypto';
3
3
  import { hostname } from 'os';
4
- const API_NAME_LIMIT = 50;
4
+ export const API_NAME_LIMIT = 50;
5
5
  export function generateThemeName(context) {
6
6
  const hostNameWithoutDomain = hostname().split('.')[0];
7
7
  const hash = randomBytes(3).toString('hex');
8
8
  const name = `${context} ()`;
9
- const hostNameCharacterLimit = API_NAME_LIMIT - name.length - hash.length;
9
+ const hostNameCharacterLimit = API_NAME_LIMIT - name.length - hash.length - 1;
10
10
  const identifier = replaceInvalidCharacters(`${hash}-${hostNameWithoutDomain.substring(0, hostNameCharacterLimit)}`);
11
11
  return `${context} (${identifier})`;
12
12
  }
@@ -1 +1 @@
1
- {"version":3,"file":"generate-theme-name.js","sourceRoot":"","sources":["../../../../src/private/node/themes/generate-theme-name.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,wBAAwB,EAAC,MAAM,iCAAiC,CAAA;AACxE,OAAO,EAAC,WAAW,EAAC,MAAM,QAAQ,CAAA;AAClC,OAAO,EAAC,QAAQ,EAAC,MAAM,IAAI,CAAA;AAE3B,MAAM,cAAc,GAAG,EAAE,CAAA;AAEzB,MAAM,UAAU,iBAAiB,CAAC,OAAe;IAC/C,MAAM,qBAAqB,GAAG,QAAQ,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAE,CAAA;IACvD,MAAM,IAAI,GAAG,WAAW,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAA;IAE3C,MAAM,IAAI,GAAG,GAAG,OAAO,KAAK,CAAA;IAC5B,MAAM,sBAAsB,GAAG,cAAc,GAAG,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,CAAA;IACzE,MAAM,UAAU,GAAG,wBAAwB,CAAC,GAAG,IAAI,IAAI,qBAAqB,CAAC,SAAS,CAAC,CAAC,EAAE,sBAAsB,CAAC,EAAE,CAAC,CAAA;IACpH,OAAO,GAAG,OAAO,KAAK,UAAU,GAAG,CAAA;AACrC,CAAC","sourcesContent":["import {replaceInvalidCharacters} from './replace-invalid-characters.js'\nimport {randomBytes} from 'crypto'\nimport {hostname} from 'os'\n\nconst API_NAME_LIMIT = 50\n\nexport function generateThemeName(context: string): string {\n const hostNameWithoutDomain = hostname().split('.')[0]!\n const hash = randomBytes(3).toString('hex')\n\n const name = `${context} ()`\n const hostNameCharacterLimit = API_NAME_LIMIT - name.length - hash.length\n const identifier = replaceInvalidCharacters(`${hash}-${hostNameWithoutDomain.substring(0, hostNameCharacterLimit)}`)\n return `${context} (${identifier})`\n}\n"]}
1
+ {"version":3,"file":"generate-theme-name.js","sourceRoot":"","sources":["../../../../src/private/node/themes/generate-theme-name.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,wBAAwB,EAAC,MAAM,iCAAiC,CAAA;AACxE,OAAO,EAAC,WAAW,EAAC,MAAM,QAAQ,CAAA;AAClC,OAAO,EAAC,QAAQ,EAAC,MAAM,IAAI,CAAA;AAE3B,MAAM,CAAC,MAAM,cAAc,GAAG,EAAE,CAAA;AAEhC,MAAM,UAAU,iBAAiB,CAAC,OAAe;IAC/C,MAAM,qBAAqB,GAAG,QAAQ,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAE,CAAA;IACvD,MAAM,IAAI,GAAG,WAAW,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAA;IAE3C,MAAM,IAAI,GAAG,GAAG,OAAO,KAAK,CAAA;IAC5B,MAAM,sBAAsB,GAAG,cAAc,GAAG,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,GAAG,CAAC,CAAA;IAC7E,MAAM,UAAU,GAAG,wBAAwB,CAAC,GAAG,IAAI,IAAI,qBAAqB,CAAC,SAAS,CAAC,CAAC,EAAE,sBAAsB,CAAC,EAAE,CAAC,CAAA;IACpH,OAAO,GAAG,OAAO,KAAK,UAAU,GAAG,CAAA;AACrC,CAAC","sourcesContent":["import {replaceInvalidCharacters} from './replace-invalid-characters.js'\nimport {randomBytes} from 'crypto'\nimport {hostname} from 'os'\n\nexport const API_NAME_LIMIT = 50\n\nexport function generateThemeName(context: string): string {\n const hostNameWithoutDomain = hostname().split('.')[0]!\n const hash = randomBytes(3).toString('hex')\n\n const name = `${context} ()`\n const hostNameCharacterLimit = API_NAME_LIMIT - name.length - hash.length - 1\n const identifier = replaceInvalidCharacters(`${hash}-${hostNameWithoutDomain.substring(0, hostNameCharacterLimit)}`)\n return `${context} (${identifier})`\n}\n"]}
@@ -1 +1 @@
1
- export declare const CLI_KIT_VERSION = "3.45.0-pre.1";
1
+ export declare const CLI_KIT_VERSION = "3.45.0-pre.3";
@@ -1,2 +1,2 @@
1
- export const CLI_KIT_VERSION = '3.45.0-pre.1';
1
+ export const CLI_KIT_VERSION = '3.45.0-pre.3';
2
2
  //# sourceMappingURL=version.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"version.js","sourceRoot":"","sources":["../../../src/public/common/version.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,eAAe,GAAG,cAAc,CAAA","sourcesContent":["export const CLI_KIT_VERSION = '3.45.0-pre.1'\n"]}
1
+ {"version":3,"file":"version.js","sourceRoot":"","sources":["../../../src/public/common/version.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,eAAe,GAAG,cAAc,CAAA","sourcesContent":["export const CLI_KIT_VERSION = '3.45.0-pre.3'\n"]}
@@ -1,6 +1,5 @@
1
1
  import FormData from 'form-data';
2
2
  import nodeFetch, { RequestInfo, RequestInit } from 'node-fetch';
3
- export { createApp, createRouter, IncomingMessage, ServerResponse, CompatibilityEvent, createError, send, sendError, sendRedirect, H3Error, } from 'h3';
4
3
  export { FetchError } from 'node-fetch';
5
4
  /**
6
5
  * Create a new FormData object.
@@ -5,7 +5,6 @@ import { outputContent, outputDebug } from '../../public/node/output.js';
5
5
  import { debugLogResponseInfo } from '../../private/node/api.js';
6
6
  import FormData from 'form-data';
7
7
  import nodeFetch from 'node-fetch';
8
- export { createApp, createRouter, createError, send, sendError, sendRedirect, H3Error, } from 'h3';
9
8
  export { FetchError } from 'node-fetch';
10
9
  /**
11
10
  * Create a new FormData object.
@@ -1 +1 @@
1
- {"version":3,"file":"http.js","sourceRoot":"","sources":["../../../src/public/node/http.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,OAAO,EAAC,MAAM,WAAW,CAAA;AACjC,OAAO,EAAC,qBAAqB,EAAE,cAAc,EAAE,SAAS,EAAE,cAAc,EAAC,MAAM,SAAS,CAAA;AACxF,OAAO,EAAC,YAAY,EAAE,UAAU,EAAE,sBAAsB,EAAC,MAAM,mCAAmC,CAAA;AAClG,OAAO,EAAC,aAAa,EAAE,WAAW,EAAC,MAAM,6BAA6B,CAAA;AACtE,OAAO,EAAC,oBAAoB,EAAC,MAAM,2BAA2B,CAAA;AAC9D,OAAO,QAAQ,MAAM,WAAW,CAAA;AAChC,OAAO,SAAqC,MAAM,YAAY,CAAA;AAE9D,OAAO,EACL,SAAS,EACT,YAAY,EAIZ,WAAW,EACX,IAAI,EACJ,SAAS,EACT,YAAY,EACZ,OAAO,GACR,MAAM,IAAI,CAAA;AAEX,OAAO,EAAC,UAAU,EAAC,MAAM,YAAY,CAAA;AAErC;;;;GAIG;AACH,MAAM,UAAU,QAAQ;IACtB,OAAO,IAAI,QAAQ,EAAE,CAAA;AACvB,CAAC;AAID;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,KAAK,UAAU,KAAK,CAAC,GAAgB,EAAE,IAAkB;IAC9D,OAAO,oBAAoB,CAAC,EAAC,GAAG,EAAE,GAAG,CAAC,QAAQ,EAAE,EAAE,OAAO,EAAE,SAAS,CAAC,GAAG,EAAE,IAAI,CAAC,EAAC,CA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I,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,GAAG,EAAE,EAAE;YACvB,cAAc,CAAC,EAAE,CAAC,CAAA;YAClB,MAAM,CAAC,GAAG,CAAC,CAAA;QACb,CAAC,CAAC,CAAA;QAEF,SAAS,CAAC,GAAG,EAAE,EAAC,QAAQ,EAAE,QAAQ,EAAC,CAAC;aACjC,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE;YACZ,GAAG,CAAC,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,CAAA;QACtB,CAAC,CAAC;aACD,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE;YACb,cAAc,CAAC,EAAE,CAAC,CAAA;YAClB,MAAM,CAAC,GAAG,CAAC,CAAA;QACb,CAAC,CAAC,CAAA;IACN,CAAC,CAAC,CAAA;AACJ,CAAC","sourcesContent":["import {dirname} from './path.js'\nimport {createFileWriteStream, fileExistsSync, mkdirSync, unlinkFileSync} from './fs.js'\nimport {buildHeaders, httpsAgent, sanitizedHeadersOutput} from '../../private/node/api/headers.js'\nimport {outputContent, outputDebug} from '../../public/node/output.js'\nimport {debugLogResponseInfo} from '../../private/node/api.js'\nimport FormData from 'form-data'\nimport nodeFetch, {RequestInfo, RequestInit} from 'node-fetch'\n\nexport {\n createApp,\n createRouter,\n IncomingMessage,\n ServerResponse,\n CompatibilityEvent,\n createError,\n send,\n sendError,\n sendRedirect,\n H3Error,\n} from 'h3'\n\nexport {FetchError} from 'node-fetch'\n\n/**\n * Create a new FormData object.\n *\n * @returns A FormData object.\n */\nexport function formData(): FormData {\n return new FormData()\n}\n\nexport type Response = ReturnType<typeof nodeFetch>\n\n/**\n * An interface that abstracts way node-fetch. When Node has built-in\n * support for \"fetch\" in the standard library, we can drop the node-fetch\n * dependency from here.\n * Note that we are exposing types from \"node-fetch\". The reason being is that\n * they are consistent with the Web API so if we drop node-fetch in the future\n * it won't require changes from the callers.\n *\n * @param url - This defines the resource that you wish to fetch.\n * @param init - An object containing any custom settings that you want to apply to the request.\n * @returns A promise that resolves with the response.\n */\nexport async function fetch(url: RequestInfo, init?: RequestInit): Response {\n return debugLogResponseInfo({url: url.toString(), request: nodeFetch(url, init)})\n}\n\n/**\n * A fetch function to use with Shopify services. The function ensures the right\n * TLS configuragion is used based on the environment in which the service is running\n * (e.g. Spin).\n *\n * @param url - This defines the resource that you wish to fetch.\n * @param init - An object containing any custom settings that you want to apply to the request.\n * @returns A promise that resolves with the response.\n */\nexport async function shopifyFetch(url: RequestInfo, init?: RequestInit): Response {\n const options: RequestInit = {\n ...(init ?? {}),\n headers: {\n ...(await buildHeaders()),\n ...(init?.headers ?? {}),\n },\n }\n\n outputDebug(outputContent`Sending ${options.method ?? 'GET'} request to URL ${url.toString()}\nWith request headers:\n${sanitizedHeadersOutput((options?.headers ?? {}) as {[header: string]: string})}\n`)\n return debugLogResponseInfo({url: url.toString(), request: nodeFetch(url, {...init, agent: await httpsAgent()})})\n}\n\n/**\n * Download a file from a URL to a local path.\n *\n * @param url - The URL to download from.\n * @param to - The local path to download to.\n * @returns - A promise that resolves with the local path.\n */\nexport function downloadFile(url: string, to: string): Promise<string> {\n outputDebug(`Downloading ${url} to ${to}`)\n\n return new Promise<string>((resolve, reject) => {\n if (!fileExistsSync(dirname(to))) {\n mkdirSync(dirname(to))\n }\n\n const file = createFileWriteStream(to)\n\n file.on('finish', () => {\n file.close()\n resolve(to)\n })\n\n file.on('error', (err) => {\n unlinkFileSync(to)\n reject(err)\n })\n\n nodeFetch(url, {redirect: 'follow'})\n .then((res) => {\n res.body?.pipe(file)\n })\n .catch((err) => {\n unlinkFileSync(to)\n reject(err)\n })\n })\n}\n"]}
1
+ {"version":3,"file":"http.js","sourceRoot":"","sources":["../../../src/public/node/http.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,OAAO,EAAC,MAAM,WAAW,CAAA;AACjC,OAAO,EAAC,qBAAqB,EAAE,cAAc,EAAE,SAAS,EAAE,cAAc,EAAC,MAAM,SAAS,CAAA;AACxF,OAAO,EAA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,KAAK,EAAE,MAAM,UAAU,EAAE,EAAC,CAAC,EAAC,CAAC,CAAA;AACnH,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,YAAY,CAAC,GAAW,EAAE,EAAU;IAClD,WAAW,CAAC,eAAe,GAAG,OAAO,EAAE,EAAE,CAAC,CAAA;IAE1C,OAAO,IAAI,OAAO,CAAS,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QAC7C,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,EAAE;YAChC,SAAS,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,CAAA;SACvB;QAED,MAAM,IAAI,GAAG,qBAAqB,CAAC,EAAE,CAAC,CAAA;QAEtC,IAAI,CAAC,EAAE,CAAC,QAAQ,EAAE,GAAG,EAAE;YACrB,IAAI,CAAC,KAAK,EAAE,CAAA;YACZ,OAAO,CAAC,EAAE,CAAC,CAAA;QACb,CAAC,CAAC,CAAA;QAEF,IAAI,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,GAAG,EAAE,EAAE;YACvB,cAAc,CAAC,EAAE,CAAC,CAAA;YAClB,MAAM,CAAC,GAAG,CAAC,CAAA;QACb,CAAC,CAAC,CAAA;QAEF,SAAS,CAAC,GAAG,EAAE,EAAC,QAAQ,EAAE,QAAQ,EAAC,CAAC;aACjC,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE;YACZ,GAAG,CAAC,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,CAAA;QACtB,CAAC,CAAC;aACD,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE;YACb,cAAc,CAAC,EAAE,CAAC,CAAA;YAClB,MAAM,CAAC,GAAG,CAAC,CAAA;QACb,CAAC,CAAC,CAAA;IACN,CAAC,CAAC,CAAA;AACJ,CAAC","sourcesContent":["import {dirname} from './path.js'\nimport {createFileWriteStream, fileExistsSync, mkdirSync, unlinkFileSync} from './fs.js'\nimport {buildHeaders, httpsAgent, sanitizedHeadersOutput} from '../../private/node/api/headers.js'\nimport {outputContent, outputDebug} from '../../public/node/output.js'\nimport {debugLogResponseInfo} from '../../private/node/api.js'\nimport FormData from 'form-data'\nimport nodeFetch, {RequestInfo, RequestInit} from 'node-fetch'\n\nexport {FetchError} from 'node-fetch'\n\n/**\n * Create a new FormData object.\n *\n * @returns A FormData object.\n */\nexport function formData(): FormData {\n return new FormData()\n}\n\nexport type Response = ReturnType<typeof nodeFetch>\n\n/**\n * An interface that abstracts way node-fetch. When Node has built-in\n * support for \"fetch\" in the standard library, we can drop the node-fetch\n * dependency from here.\n * Note that we are exposing types from \"node-fetch\". The reason being is that\n * they are consistent with the Web API so if we drop node-fetch in the future\n * it won't require changes from the callers.\n *\n * @param url - This defines the resource that you wish to fetch.\n * @param init - An object containing any custom settings that you want to apply to the request.\n * @returns A promise that resolves with the response.\n */\nexport async function fetch(url: RequestInfo, init?: RequestInit): Response {\n return debugLogResponseInfo({url: url.toString(), request: nodeFetch(url, init)})\n}\n\n/**\n * A fetch function to use with Shopify services. The function ensures the right\n * TLS configuragion is used based on the environment in which the service is running\n * (e.g. Spin).\n *\n * @param url - This defines the resource that you wish to fetch.\n * @param init - An object containing any custom settings that you want to apply to the request.\n * @returns A promise that resolves with the response.\n */\nexport async function shopifyFetch(url: RequestInfo, init?: RequestInit): Response {\n const options: RequestInit = {\n ...(init ?? {}),\n headers: {\n ...(await buildHeaders()),\n ...(init?.headers ?? {}),\n },\n }\n\n outputDebug(outputContent`Sending ${options.method ?? 'GET'} request to URL ${url.toString()}\nWith request headers:\n${sanitizedHeadersOutput((options?.headers ?? {}) as {[header: string]: string})}\n`)\n return debugLogResponseInfo({url: url.toString(), request: nodeFetch(url, {...init, agent: await httpsAgent()})})\n}\n\n/**\n * Download a file from a URL to a local path.\n *\n * @param url - The URL to download from.\n * @param to - The local path to download to.\n * @returns - A promise that resolves with the local path.\n */\nexport function downloadFile(url: string, to: string): Promise<string> {\n outputDebug(`Downloading ${url} to ${to}`)\n\n return new Promise<string>((resolve, reject) => {\n if (!fileExistsSync(dirname(to))) {\n mkdirSync(dirname(to))\n }\n\n const file = createFileWriteStream(to)\n\n file.on('finish', () => {\n file.close()\n resolve(to)\n })\n\n file.on('error', (err) => {\n unlinkFileSync(to)\n reject(err)\n })\n\n nodeFetch(url, {redirect: 'follow'})\n .then((res) => {\n res.body?.pipe(file)\n })\n .catch((err) => {\n unlinkFileSync(to)\n reject(err)\n })\n })\n}\n"]}
@@ -35,6 +35,7 @@ export async function execCLI2(args, options = {}) {
35
35
  SHOPIFY_SHOP: options.adminSession?.storeFqdn,
36
36
  SHOPIFY_CLI_AUTH_TOKEN: options.token,
37
37
  SHOPIFY_CLI_RUN_AS_SUBPROCESS: 'true',
38
+ SHOPIFY_CLI_RUBY_BIN: rubyExecutable(),
38
39
  // Bundler uses this Gemfile to understand which gems are available in the
39
40
  // environment. We use this to specify our own Gemfile for CLI2, which exists
40
41
  // outside the user's project directory.
@@ -367,6 +368,9 @@ async function localBundleInstall(directory) {
367
368
  await exec(bundle, ['config', 'set', '--local', 'path', directory], {
368
369
  cwd: directory,
369
370
  });
370
- await exec(bundle, ['install', '--without', 'development', 'test'], { cwd: directory });
371
+ await exec(bundle, ['config', 'set', '--local', 'without', 'development:test'], {
372
+ cwd: directory,
373
+ });
374
+ await exec(bundle, ['install'], { cwd: directory });
371
375
  }
372
376
  //# sourceMappingURL=ruby.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ruby.js","sourceRoot":"","sources":["../../../src/public/node/ruby.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,eAAe,EAAC,MAAM,SAAS,CAAA;AACvC,OAAO,EAAC,aAAa,EAAE,IAAI,EAAC,MAAM,aAAa,CAAA;AAC/C,OAAO,KAAK,IAAI,MAAM,SAAS,CAAA;AAC/B,OAAO,EAAC,QAAQ,EAAE,OAAO,EAAE,GAAG,EAAC,MAAM,WAAW,CAAA;AAChD,OAAO,EAAC,UAAU,EAAE,gBAAgB,EAAC,MAAM,YAAY,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ACvB,MAAM,UAAU,GAAG,aAAa,EAAE,CAAA;IAClC,OAAO,UAAU,CAAC,CAAC,CAAC,QAAQ,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAA;AAC/D,CAAC;AAED;;;;GAIG;AACH,SAAS,aAAa;IACpB,MAAM,UAAU,GAAG,aAAa,EAAE,CAAA;IAClC,OAAO,UAAU,CAAC,CAAC,CAAC,QAAQ,CAAC,UAAU,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAA;AACzD,CAAC;AAED;;;;GAIG;AACH,KAAK,UAAU,qBAAqB;IAClC,MAAM,YAAY,GAAG,MAAM,mBAAmB,CAAC,IAAI,CAAC,CAAA;IACpD,OAAO,QAAQ,CAAC,YAAY,EAAE,KAAK,EAAE,SAAS,CAAC,CAAA;AACjD,CAAC;AAED;;;;GAIG;AACH,KAAK,UAAU,2BAA2B;IACxC,IAAI,CAAC,iBAAiB,EAAE;QAAE,OAAO,EAAE,CAAA;IAEnC,OAAO;QACL,SAAS,EAAE,MAAM,QAAQ,EAAE;QAC3B,IAAI,EAAE,GAAG;KACV,CAAA;AACH,CAAC;AAED;;;;;GAKG;AACH,KAAK,UAAU,kBAAkB,CAAC,SAAiB;IACjD,MAAM,MAAM,GAAG,gBAAgB,EAAE,CAAA;IACjC,MAAM,IAAI,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE;QAClE,GAAG,EAAE,SAAS;KACf,CAAC,CAAA;IACF,MAAM,IAAI,CAAC,MAAM,EAAE,CAAC,SAAS,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,CAAC,EAAE,EAAC,GAAG,EAAE,SAAS,EAAC,CAAC,CAAA;AACvF,CAAC","sourcesContent":["import {AbortSignal} from './abort.js'\nimport {platformAndArch} from './os.js'\nimport {captureOutput, exec} from './system.js'\nimport * as file from './fs.js'\nimport {joinPath, dirname, cwd} from './path.js'\nimport {AbortError, AbortSilentError} from './error.js'\nimport {getEnvironmentVariables} from './environment.js'\nimport {isSpinEnvironment, spinFqdn} from './context/spin.js'\nimport {pathConstants} from '../../private/node/constants.js'\nimport {AdminSession} from '../../public/node/session.js'\nimport {outputContent, outputToken} from '../../public/node/output.js'\nimport {isTruthy} from '../../private/node/context/utilities.js'\nimport {coerceSemverVersion} from '../../private/node/semver.js'\nimport {Writable} from 'stream'\nimport {fileURLToPath} from 'url'\n\nexport const RubyCLIVersion = '2.35.0'\nconst ThemeCheckVersion = '1.14.0'\nconst MinBundlerVersion = '2.3.11'\nconst MinRubyVersion = '2.7.5'\nexport const MinWdmWindowsVersion = '0.1.0'\n\ninterface ExecCLI2Options {\n // Contains token and store to pass to CLI 2.0, which will be set as environment variables\n adminSession?: AdminSession\n // Contains token for storefront access to pass to CLI 2.0 as environment variable\n storefrontToken?: string\n // Contains token for partners access to pass to CLI 2.0 as environment variable\n token?: string\n // Directory in which to execute the command. Otherwise the current directory will be used.\n directory?: string\n // A signal to stop the process execution.\n signal?: AbortSignal\n // Stream to pipe the command's stdout to.\n stdout?: Writable\n // Stream to pipe the command's stdout to.\n stderr?: Writable\n}\n/**\n * Execute CLI 2.0 commands.\n * Installs a version of RubyCLI as a vendor dependency in a hidden folder in the system.\n * User must have a valid ruby+bundler environment to run any command.\n *\n * @param args - List of argumets to execute. (ex: ['theme', 'pull']).\n * @param options - Options to customize the execution of cli2.\n */\nexport async function execCLI2(args: string[], options: ExecCLI2Options = {}): Promise<void> {\n const currentEnv = getEnvironmentVariables()\n const embedded = !isTruthy(currentEnv.SHOPIFY_CLI_BUNDLED_THEME_CLI) && !currentEnv.SHOPIFY_CLI_2_0_DIRECTORY\n\n await installCLIDependencies(options.stdout ?? process.stdout, embedded)\n const env: NodeJS.ProcessEnv = {\n ...currentEnv,\n SHOPIFY_CLI_STOREFRONT_RENDERER_AUTH_TOKEN: options.storefrontToken,\n SHOPIFY_CLI_ADMIN_AUTH_TOKEN: options.adminSession?.token,\n SHOPIFY_SHOP: options.adminSession?.storeFqdn,\n SHOPIFY_CLI_AUTH_TOKEN: options.token,\n SHOPIFY_CLI_RUN_AS_SUBPROCESS: 'true',\n // Bundler uses this Gemfile to understand which gems are available in the\n // environment. We use this to specify our own Gemfile for CLI2, which exists\n // outside the user's project directory.\n BUNDLE_GEMFILE: joinPath(await shopifyCLIDirectory(embedded), 'Gemfile'),\n ...(await getSpinEnvironmentVariables()),\n }\n\n try {\n const shopifyExecutable = embedded ? [rubyExecutable(), await embeddedCLIExecutable()] : ['shopify']\n await exec(bundleExecutable(), ['exec', ...shopifyExecutable, ...args], {\n ...(options.stdout === undefined && {stdio: 'inherit'}),\n cwd: options.directory ?? cwd(),\n env,\n ...(options.stdout !== undefined && {stdout: options.stdout, stderr: options.stderr}),\n signal: options.signal,\n })\n } catch (error) {\n // CLI2 will show it's own errors, we don't need to show an additional CLI3 error\n throw new AbortSilentError()\n }\n}\n\ninterface ExecThemeCheckCLIOptions {\n /** A list of directories in which theme-check should run. */\n directories: string[]\n /** Arguments to pass to the theme-check CLI. */\n args?: string[]\n /** Writable to send standard output content through. */\n stdout: Writable\n /** Writable to send standard error content through. */\n stderr: Writable\n}\n\n/**\n * A function that installs (if needed) and runs the theme-check CLI.\n *\n * @param options - Options to customize the execution of theme-check.\n * @returns A promise that resolves or rejects depending on the result of the underlying theme-check process.\n */\nexport async function execThemeCheckCLI(options: ExecThemeCheckCLIOptions): Promise<void[]> {\n await installThemeCheckCLIDependencies(options.stdout)\n\n const processes = options.directories.map(async (directory): Promise<void> => {\n // Check that there are files aside from the extension TOML config file,\n // otherwise theme-check will return a false failure.\n const files = await file.glob(joinPath(directory, '/**/*'))\n const fileCount = files.filter((file) => !file.match(/\\.toml$/)).length\n if (fileCount === 0) return\n\n const customStderr = new Writable({\n write(chunk, ...args) {\n // For some reason, theme-check reports this initial status line to stderr\n // See https://github.com/Shopify/theme-check/blob/1092737cfb58a73ca397ffb1371665dc55df2976/lib/theme_check/language_server/diagnostics_engine.rb#L31\n // which leads to https://github.com/Shopify/theme-check/blob/1092737cfb58a73ca397ffb1371665dc55df2976/lib/theme_check/language_server/io_messenger.rb#L65\n if (chunk.toString('ascii').match(/^Checking/)) {\n options.stdout.write(chunk, ...args)\n } else {\n options.stderr.write(chunk, ...args)\n }\n },\n })\n await exec(bundleExecutable(), ['exec', 'theme-check'].concat([directory, ...(options.args || [])]), {\n stdout: options.stdout,\n stderr: customStderr,\n cwd: themeCheckDirectory(),\n })\n })\n return Promise.all(processes)\n}\n\n/**\n * Validate Ruby Enviroment\n * Install Theme Check CLI and its dependencies\n * Shows a loading message if it's the first time installing dependencies\n * or if we are installing a new version of Theme Check CLI.\n *\n * @param stdout - The Writable stream on which to write the standard output.\n */\nasync function installThemeCheckCLIDependencies(stdout: Writable) {\n const exists = await file.fileExists(themeCheckDirectory())\n\n if (!exists) stdout.write('Installing theme dependencies...')\n await validateRubyEnv()\n await createThemeCheckCLIWorkingDirectory()\n await createThemeCheckGemfile()\n await bundleInstallThemeCheck()\n if (!exists) stdout.write('Installed theme dependencies!')\n}\n\n/**\n * Validate Ruby Enviroment\n * Install RubyCLI and its dependencies\n * Shows a loading spinner if it's the first time installing dependencies\n * or if we are installing a new version of RubyCLI.\n *\n * @param stdout - The Writable stream on which to write the standard output.\n * @param embedded - True when embebbed codebase of CLI should be used.\n */\nasync function installCLIDependencies(stdout: Writable, embedded = false) {\n const localCLI = await shopifyCLIDirectory(embedded)\n const exists = await file.fileExists(localCLI)\n\n if (!exists) stdout.write('Installing theme dependencies...')\n const usingLocalCLI2 = embedded || isTruthy(getEnvironmentVariables().SHOPIFY_CLI_2_0_DIRECTORY)\n await validateRubyEnv()\n if (usingLocalCLI2) {\n await bundleInstallLocalShopifyCLI(localCLI)\n } else {\n await createShopifyCLIWorkingDirectory()\n await createShopifyCLIGemfile()\n await bundleInstallShopifyCLI()\n }\n\n if (!exists) stdout.write('Installed theme dependencies!')\n}\n\n/**\n * A function that validates if the environment in which the CLI is running is set up with Ruby and Bundler.\n */\nasync function validateRubyEnv() {\n await validateRuby()\n await validateBundler()\n}\n\n/**\n * A function that validates if the environment in which the CLI is running is set up with Ruby.\n */\nasync function validateRuby() {\n let version\n try {\n const stdout = await captureOutput(rubyExecutable(), ['-v'])\n version = coerceSemverVersion(stdout)\n } catch {\n throw new AbortError(\n 'Ruby environment not found',\n `Make sure you have Ruby installed on your system. ${\n outputContent`${outputToken.link('Documentation.', 'https://www.ruby-lang.org/en/documentation/installation/')}`\n .value\n }`,\n )\n }\n\n const isValid = version?.compare(MinRubyVersion)\n if (isValid === -1 || isValid === undefined) {\n throw new AbortError(\n `Ruby version ${outputContent`${outputToken.yellow(version.raw)}`.value} is not supported`,\n `Make sure you have at least Ruby ${\n outputContent`${outputToken.yellow(MinRubyVersion)}`.value\n } installed on your system. ${\n outputContent`${outputToken.link('Documentation.', 'https://www.ruby-lang.org/en/documentation/installation/')}`\n .value\n }`,\n )\n }\n}\n\n/**\n * A function that validates if the environment in which the CLI is running is set up with Bundler.\n */\nasync function validateBundler() {\n let version\n try {\n const stdout = await captureOutput(bundleExecutable(), ['-v'])\n version = coerceSemverVersion(stdout)\n } catch {\n throw new AbortError(\n 'Bundler not found',\n `To install the latest version of Bundler, run ${\n outputContent`${outputToken.genericShellCommand(`${gemExecutable()} install bundler`)}`.value\n }`,\n )\n }\n\n const isValid = version?.compare(MinBundlerVersion)\n if (isValid === -1 || isValid === undefined) {\n throw new AbortError(\n `Bundler version ${outputContent`${outputToken.yellow(version.raw)}`.value} is not supported`,\n `To update to the latest version of Bundler, run ${\n outputContent`${outputToken.genericShellCommand(`${gemExecutable()} install bundler`)}`.value\n }`,\n )\n }\n}\n\n/**\n * It creates the directory where the Ruby CLI will be downloaded along its dependencies.\n */\nasync function createShopifyCLIWorkingDirectory(): Promise<void> {\n return file.mkdir(await shopifyCLIDirectory())\n}\n\n/**\n * It creates the directory where the theme-check CLI will be downloaded along its dependencies.\n */\nasync function createThemeCheckCLIWorkingDirectory(): Promise<void> {\n return file.mkdir(themeCheckDirectory())\n}\n\n/**\n * It creates the Gemfile to install The Ruby CLI and the dependencies.\n */\nasync function createShopifyCLIGemfile(): Promise<void> {\n const directory = await shopifyCLIDirectory()\n const gemfileContent = getBaseGemfileContent().concat(getWindowsDependencies())\n await addContentToGemfile(directory, gemfileContent)\n}\n\n/**\n * It creates the Gemfile to install theme-check and its dependencies.\n */\nasync function createThemeCheckGemfile(): Promise<void> {\n const gemPath = joinPath(themeCheckDirectory(), 'Gemfile')\n await file.writeFile(gemPath, `source 'https://rubygems.org'\\ngem 'theme-check', '${ThemeCheckVersion}'`)\n}\n\n/**\n * It runs bundle install for the dev-managed copy of the Ruby CLI.\n *\n * @param directory - Directory where CLI2 Gemfile is located.\n */\nasync function bundleInstallLocalShopifyCLI(directory: string): Promise<void> {\n await addContentToGemfile(directory, getWindowsDependencies())\n await localBundleInstall(directory)\n}\n\n/**\n * Build the list of lines with the base content of the Gemfile.\n *\n * @returns List of lines with base content.\n */\nfunction getBaseGemfileContent() {\n return [\"source 'https://rubygems.org'\", `gem 'shopify-cli', '${RubyCLIVersion}'`]\n}\n\n/**\n * Build the list of Windows dependencies.\n *\n * @returns List of Windows dependencies.\n */\nfunction getWindowsDependencies() {\n if (platformAndArch().platform === 'windows') {\n // 'wdm' is required by 'listen', see https://github.com/Shopify/cli/issues/780\n // Because it's a Windows-only dependency, it's not included in the `.gemspec` or `Gemfile`.\n // Otherwise it would be installed in non-Windows environments too, where it is not needed.\n return [`gem 'wdm', '>= ${MinWdmWindowsVersion}'`]\n }\n return []\n}\n\n/**\n * Append contente to a Gemfile located in the given directory.\n *\n * @param gemfileDirectory - Directory where Gemfile is located.\n * @param content - Content to append to the Gemfile.\n */\nasync function addContentToGemfile(gemfileDirectory: string, content: string[]) {\n const gemfilePath = joinPath(gemfileDirectory, 'Gemfile')\n if (!(await file.fileExists(gemfilePath))) await file.touchFile(gemfilePath)\n const gemContent = await file.readFile(gemfilePath, {encoding: 'utf8'})\n const contentNoExisting = content.filter((line) => !gemContent.includes(line)).join('\\n')\n if (contentNoExisting) await file.appendFile(gemfilePath, contentNoExisting.concat('\\n'))\n}\n\n/**\n * It runs bundle install for the CLI-managed copy of the Ruby CLI.\n */\nasync function bundleInstallShopifyCLI() {\n await localBundleInstall(await shopifyCLIDirectory())\n}\n\n/**\n * It runs bundle install for the CLI-managed copy of theme-check.\n */\nasync function bundleInstallThemeCheck() {\n await localBundleInstall(themeCheckDirectory())\n}\n\n/**\n * It returns the directory where the Ruby CLI is located.\n *\n * @param embedded - True when embebbed codebase of CLI should be used.\n * @returns The absolute path to the directory.\n */\nasync function shopifyCLIDirectory(embedded = false): Promise<string> {\n const embeddedDirectory = (await file.findPathUp('assets/cli-ruby', {\n type: 'directory',\n cwd: dirname(fileURLToPath(import.meta.url)),\n })) as string\n const bundledDirectory = joinPath(pathConstants.directories.cache.vendor.path(), 'ruby-cli', RubyCLIVersion)\n\n return embedded ? embeddedDirectory : getEnvironmentVariables().SHOPIFY_CLI_2_0_DIRECTORY ?? bundledDirectory\n}\n\n/**\n * It returns the path to the directory containing the theme-check CLI.\n *\n * @returns The absolute path to the theme-check directory.\n */\nfunction themeCheckDirectory(): string {\n return joinPath(pathConstants.directories.cache.vendor.path(), 'theme-check', ThemeCheckVersion)\n}\n\n/**\n * It returns the Ruby version present in the envirronment.\n */\nexport async function version(): Promise<string | undefined> {\n const parseOutput = (version: string) => version.match(/ruby (\\d+\\.\\d+\\.\\d+)/)?.[1]\n return captureOutput(rubyExecutable(), ['-v'])\n .then(parseOutput)\n .catch(() => undefined)\n}\n\n/**\n * It returns the Ruby binary path set through the environment variable SHOPIFY_RUBY_BINDIR.\n * This is useful when the CLI is managed by an installer like a Homebrew where we need to\n * point the CLI to the Ruby installation managed by Homebrew.\n *\n * @returns The value of the environment variable.\n */\nfunction getRubyBinDir(): string | undefined {\n return getEnvironmentVariables().SHOPIFY_RUBY_BINDIR\n}\n\n/**\n * It returns the path to the \"ruby\" executable.\n *\n * @returns The path to the executable.\n */\nfunction rubyExecutable(): string {\n const rubyBinDir = getRubyBinDir()\n return rubyBinDir ? joinPath(rubyBinDir, 'ruby') : 'ruby'\n}\n\n/**\n * It returns the path to the \"bundle\" executable.\n *\n * @returns The path to the executable.\n */\nfunction bundleExecutable(): string {\n const rubyBinDir = getRubyBinDir()\n return rubyBinDir ? joinPath(rubyBinDir, 'bundle') : 'bundle'\n}\n\n/**\n * It returns the path to the \"gem\"\" executable.\n *\n * @returns The path to the executable.\n */\nfunction gemExecutable(): string {\n const rubyBinDir = getRubyBinDir()\n return rubyBinDir ? joinPath(rubyBinDir, 'gem') : 'gem'\n}\n\n/**\n * It returns the path to the \"bundle\" executable.\n *\n * @returns The path to the executable.\n */\nasync function embeddedCLIExecutable(): Promise<string> {\n const cliDirectory = await shopifyCLIDirectory(true)\n return joinPath(cliDirectory, 'bin', 'shopify')\n}\n\n/**\n * Get environment variables required by the CLI2 in case the CLI3 is running in a Spin environment.\n *\n * @returns The environment variables to set.\n */\nasync function getSpinEnvironmentVariables() {\n if (!isSpinEnvironment()) return {}\n\n return {\n SPIN_FQDN: await spinFqdn(),\n SPIN: '1',\n }\n}\n\n/**\n * It sets bundler's path to the given directory and runs bundle install.\n * This is desirable because the gems will be isolated from the system gems.\n *\n * @param directory - Directory where the Gemfile is located.\n */\nasync function localBundleInstall(directory: string): Promise<void> {\n const bundle = bundleExecutable()\n await exec(bundle, ['config', 'set', '--local', 'path', directory], {\n cwd: directory,\n })\n await exec(bundle, ['install', '--without', 'development', 'test'], {cwd: directory})\n}\n"]}
1
+ {"version":3,"file":"ruby.js","sourceRoot":"","sources":["../../../src/public/node/ruby.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,eAAe,EAAC,MAAM,SAAS,CAAA;AACvC,OAAO,EAAC,aAAa,EAAE,IAAI,EAAC,MAAM,aAAa,CAAA;AAC/C,OAAO,KAAK,IAAI,MAAM,SAAS,CAAA;AAC/B,OAAO,EAAC,QAAQ,EAA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AE,SAAS;KACf,CAAC,CAAA;IACF,MAAM,IAAI,CAAC,MAAM,EAAE,CAAC,SAAS,CAAC,EAAE,EAAC,GAAG,EAAE,SAAS,EAAC,CAAC,CAAA;AACnD,CAAC","sourcesContent":["import {AbortSignal} from './abort.js'\nimport {platformAndArch} from './os.js'\nimport {captureOutput, exec} from './system.js'\nimport * as file from './fs.js'\nimport {joinPath, dirname, cwd} from './path.js'\nimport {AbortError, AbortSilentError} from './error.js'\nimport {getEnvironmentVariables} from './environment.js'\nimport {isSpinEnvironment, spinFqdn} from './context/spin.js'\nimport {pathConstants} from '../../private/node/constants.js'\nimport {AdminSession} from '../../public/node/session.js'\nimport {outputContent, outputToken} from '../../public/node/output.js'\nimport {isTruthy} from '../../private/node/context/utilities.js'\nimport {coerceSemverVersion} from '../../private/node/semver.js'\nimport {Writable} from 'stream'\nimport {fileURLToPath} from 'url'\n\nexport const RubyCLIVersion = '2.35.0'\nconst ThemeCheckVersion = '1.14.0'\nconst MinBundlerVersion = '2.3.11'\nconst MinRubyVersion = '2.7.5'\nexport const MinWdmWindowsVersion = '0.1.0'\n\ninterface ExecCLI2Options {\n // Contains token and store to pass to CLI 2.0, which will be set as environment variables\n adminSession?: AdminSession\n // Contains token for storefront access to pass to CLI 2.0 as environment variable\n storefrontToken?: string\n // Contains token for partners access to pass to CLI 2.0 as environment variable\n token?: string\n // Directory in which to execute the command. Otherwise the current directory will be used.\n directory?: string\n // A signal to stop the process execution.\n signal?: AbortSignal\n // Stream to pipe the command's stdout to.\n stdout?: Writable\n // Stream to pipe the command's stdout to.\n stderr?: Writable\n}\n/**\n * Execute CLI 2.0 commands.\n * Installs a version of RubyCLI as a vendor dependency in a hidden folder in the system.\n * User must have a valid ruby+bundler environment to run any command.\n *\n * @param args - List of argumets to execute. (ex: ['theme', 'pull']).\n * @param options - Options to customize the execution of cli2.\n */\nexport async function execCLI2(args: string[], options: ExecCLI2Options = {}): Promise<void> {\n const currentEnv = getEnvironmentVariables()\n const embedded = !isTruthy(currentEnv.SHOPIFY_CLI_BUNDLED_THEME_CLI) && !currentEnv.SHOPIFY_CLI_2_0_DIRECTORY\n\n await installCLIDependencies(options.stdout ?? process.stdout, embedded)\n const env: NodeJS.ProcessEnv = {\n ...currentEnv,\n SHOPIFY_CLI_STOREFRONT_RENDERER_AUTH_TOKEN: options.storefrontToken,\n SHOPIFY_CLI_ADMIN_AUTH_TOKEN: options.adminSession?.token,\n SHOPIFY_SHOP: options.adminSession?.storeFqdn,\n SHOPIFY_CLI_AUTH_TOKEN: options.token,\n SHOPIFY_CLI_RUN_AS_SUBPROCESS: 'true',\n SHOPIFY_CLI_RUBY_BIN: rubyExecutable(),\n // Bundler uses this Gemfile to understand which gems are available in the\n // environment. We use this to specify our own Gemfile for CLI2, which exists\n // outside the user's project directory.\n BUNDLE_GEMFILE: joinPath(await shopifyCLIDirectory(embedded), 'Gemfile'),\n ...(await getSpinEnvironmentVariables()),\n }\n\n try {\n const shopifyExecutable = embedded ? [rubyExecutable(), await embeddedCLIExecutable()] : ['shopify']\n await exec(bundleExecutable(), ['exec', ...shopifyExecutable, ...args], {\n ...(options.stdout === undefined && {stdio: 'inherit'}),\n cwd: options.directory ?? cwd(),\n env,\n ...(options.stdout !== undefined && {stdout: options.stdout, stderr: options.stderr}),\n signal: options.signal,\n })\n } catch (error) {\n // CLI2 will show it's own errors, we don't need to show an additional CLI3 error\n throw new AbortSilentError()\n }\n}\n\ninterface ExecThemeCheckCLIOptions {\n /** A list of directories in which theme-check should run. */\n directories: string[]\n /** Arguments to pass to the theme-check CLI. */\n args?: string[]\n /** Writable to send standard output content through. */\n stdout: Writable\n /** Writable to send standard error content through. */\n stderr: Writable\n}\n\n/**\n * A function that installs (if needed) and runs the theme-check CLI.\n *\n * @param options - Options to customize the execution of theme-check.\n * @returns A promise that resolves or rejects depending on the result of the underlying theme-check process.\n */\nexport async function execThemeCheckCLI(options: ExecThemeCheckCLIOptions): Promise<void[]> {\n await installThemeCheckCLIDependencies(options.stdout)\n\n const processes = options.directories.map(async (directory): Promise<void> => {\n // Check that there are files aside from the extension TOML config file,\n // otherwise theme-check will return a false failure.\n const files = await file.glob(joinPath(directory, '/**/*'))\n const fileCount = files.filter((file) => !file.match(/\\.toml$/)).length\n if (fileCount === 0) return\n\n const customStderr = new Writable({\n write(chunk, ...args) {\n // For some reason, theme-check reports this initial status line to stderr\n // See https://github.com/Shopify/theme-check/blob/1092737cfb58a73ca397ffb1371665dc55df2976/lib/theme_check/language_server/diagnostics_engine.rb#L31\n // which leads to https://github.com/Shopify/theme-check/blob/1092737cfb58a73ca397ffb1371665dc55df2976/lib/theme_check/language_server/io_messenger.rb#L65\n if (chunk.toString('ascii').match(/^Checking/)) {\n options.stdout.write(chunk, ...args)\n } else {\n options.stderr.write(chunk, ...args)\n }\n },\n })\n await exec(bundleExecutable(), ['exec', 'theme-check'].concat([directory, ...(options.args || [])]), {\n stdout: options.stdout,\n stderr: customStderr,\n cwd: themeCheckDirectory(),\n })\n })\n return Promise.all(processes)\n}\n\n/**\n * Validate Ruby Enviroment\n * Install Theme Check CLI and its dependencies\n * Shows a loading message if it's the first time installing dependencies\n * or if we are installing a new version of Theme Check CLI.\n *\n * @param stdout - The Writable stream on which to write the standard output.\n */\nasync function installThemeCheckCLIDependencies(stdout: Writable) {\n const exists = await file.fileExists(themeCheckDirectory())\n\n if (!exists) stdout.write('Installing theme dependencies...')\n await validateRubyEnv()\n await createThemeCheckCLIWorkingDirectory()\n await createThemeCheckGemfile()\n await bundleInstallThemeCheck()\n if (!exists) stdout.write('Installed theme dependencies!')\n}\n\n/**\n * Validate Ruby Enviroment\n * Install RubyCLI and its dependencies\n * Shows a loading spinner if it's the first time installing dependencies\n * or if we are installing a new version of RubyCLI.\n *\n * @param stdout - The Writable stream on which to write the standard output.\n * @param embedded - True when embebbed codebase of CLI should be used.\n */\nasync function installCLIDependencies(stdout: Writable, embedded = false) {\n const localCLI = await shopifyCLIDirectory(embedded)\n const exists = await file.fileExists(localCLI)\n\n if (!exists) stdout.write('Installing theme dependencies...')\n const usingLocalCLI2 = embedded || isTruthy(getEnvironmentVariables().SHOPIFY_CLI_2_0_DIRECTORY)\n await validateRubyEnv()\n if (usingLocalCLI2) {\n await bundleInstallLocalShopifyCLI(localCLI)\n } else {\n await createShopifyCLIWorkingDirectory()\n await createShopifyCLIGemfile()\n await bundleInstallShopifyCLI()\n }\n\n if (!exists) stdout.write('Installed theme dependencies!')\n}\n\n/**\n * A function that validates if the environment in which the CLI is running is set up with Ruby and Bundler.\n */\nasync function validateRubyEnv() {\n await validateRuby()\n await validateBundler()\n}\n\n/**\n * A function that validates if the environment in which the CLI is running is set up with Ruby.\n */\nasync function validateRuby() {\n let version\n try {\n const stdout = await captureOutput(rubyExecutable(), ['-v'])\n version = coerceSemverVersion(stdout)\n } catch {\n throw new AbortError(\n 'Ruby environment not found',\n `Make sure you have Ruby installed on your system. ${\n outputContent`${outputToken.link('Documentation.', 'https://www.ruby-lang.org/en/documentation/installation/')}`\n .value\n }`,\n )\n }\n\n const isValid = version?.compare(MinRubyVersion)\n if (isValid === -1 || isValid === undefined) {\n throw new AbortError(\n `Ruby version ${outputContent`${outputToken.yellow(version.raw)}`.value} is not supported`,\n `Make sure you have at least Ruby ${\n outputContent`${outputToken.yellow(MinRubyVersion)}`.value\n } installed on your system. ${\n outputContent`${outputToken.link('Documentation.', 'https://www.ruby-lang.org/en/documentation/installation/')}`\n .value\n }`,\n )\n }\n}\n\n/**\n * A function that validates if the environment in which the CLI is running is set up with Bundler.\n */\nasync function validateBundler() {\n let version\n try {\n const stdout = await captureOutput(bundleExecutable(), ['-v'])\n version = coerceSemverVersion(stdout)\n } catch {\n throw new AbortError(\n 'Bundler not found',\n `To install the latest version of Bundler, run ${\n outputContent`${outputToken.genericShellCommand(`${gemExecutable()} install bundler`)}`.value\n }`,\n )\n }\n\n const isValid = version?.compare(MinBundlerVersion)\n if (isValid === -1 || isValid === undefined) {\n throw new AbortError(\n `Bundler version ${outputContent`${outputToken.yellow(version.raw)}`.value} is not supported`,\n `To update to the latest version of Bundler, run ${\n outputContent`${outputToken.genericShellCommand(`${gemExecutable()} install bundler`)}`.value\n }`,\n )\n }\n}\n\n/**\n * It creates the directory where the Ruby CLI will be downloaded along its dependencies.\n */\nasync function createShopifyCLIWorkingDirectory(): Promise<void> {\n return file.mkdir(await shopifyCLIDirectory())\n}\n\n/**\n * It creates the directory where the theme-check CLI will be downloaded along its dependencies.\n */\nasync function createThemeCheckCLIWorkingDirectory(): Promise<void> {\n return file.mkdir(themeCheckDirectory())\n}\n\n/**\n * It creates the Gemfile to install The Ruby CLI and the dependencies.\n */\nasync function createShopifyCLIGemfile(): Promise<void> {\n const directory = await shopifyCLIDirectory()\n const gemfileContent = getBaseGemfileContent().concat(getWindowsDependencies())\n await addContentToGemfile(directory, gemfileContent)\n}\n\n/**\n * It creates the Gemfile to install theme-check and its dependencies.\n */\nasync function createThemeCheckGemfile(): Promise<void> {\n const gemPath = joinPath(themeCheckDirectory(), 'Gemfile')\n await file.writeFile(gemPath, `source 'https://rubygems.org'\\ngem 'theme-check', '${ThemeCheckVersion}'`)\n}\n\n/**\n * It runs bundle install for the dev-managed copy of the Ruby CLI.\n *\n * @param directory - Directory where CLI2 Gemfile is located.\n */\nasync function bundleInstallLocalShopifyCLI(directory: string): Promise<void> {\n await addContentToGemfile(directory, getWindowsDependencies())\n await localBundleInstall(directory)\n}\n\n/**\n * Build the list of lines with the base content of the Gemfile.\n *\n * @returns List of lines with base content.\n */\nfunction getBaseGemfileContent() {\n return [\"source 'https://rubygems.org'\", `gem 'shopify-cli', '${RubyCLIVersion}'`]\n}\n\n/**\n * Build the list of Windows dependencies.\n *\n * @returns List of Windows dependencies.\n */\nfunction getWindowsDependencies() {\n if (platformAndArch().platform === 'windows') {\n // 'wdm' is required by 'listen', see https://github.com/Shopify/cli/issues/780\n // Because it's a Windows-only dependency, it's not included in the `.gemspec` or `Gemfile`.\n // Otherwise it would be installed in non-Windows environments too, where it is not needed.\n return [`gem 'wdm', '>= ${MinWdmWindowsVersion}'`]\n }\n return []\n}\n\n/**\n * Append contente to a Gemfile located in the given directory.\n *\n * @param gemfileDirectory - Directory where Gemfile is located.\n * @param content - Content to append to the Gemfile.\n */\nasync function addContentToGemfile(gemfileDirectory: string, content: string[]) {\n const gemfilePath = joinPath(gemfileDirectory, 'Gemfile')\n if (!(await file.fileExists(gemfilePath))) await file.touchFile(gemfilePath)\n const gemContent = await file.readFile(gemfilePath, {encoding: 'utf8'})\n const contentNoExisting = content.filter((line) => !gemContent.includes(line)).join('\\n')\n if (contentNoExisting) await file.appendFile(gemfilePath, contentNoExisting.concat('\\n'))\n}\n\n/**\n * It runs bundle install for the CLI-managed copy of the Ruby CLI.\n */\nasync function bundleInstallShopifyCLI() {\n await localBundleInstall(await shopifyCLIDirectory())\n}\n\n/**\n * It runs bundle install for the CLI-managed copy of theme-check.\n */\nasync function bundleInstallThemeCheck() {\n await localBundleInstall(themeCheckDirectory())\n}\n\n/**\n * It returns the directory where the Ruby CLI is located.\n *\n * @param embedded - True when embebbed codebase of CLI should be used.\n * @returns The absolute path to the directory.\n */\nasync function shopifyCLIDirectory(embedded = false): Promise<string> {\n const embeddedDirectory = (await file.findPathUp('assets/cli-ruby', {\n type: 'directory',\n cwd: dirname(fileURLToPath(import.meta.url)),\n })) as string\n const bundledDirectory = joinPath(pathConstants.directories.cache.vendor.path(), 'ruby-cli', RubyCLIVersion)\n\n return embedded ? embeddedDirectory : getEnvironmentVariables().SHOPIFY_CLI_2_0_DIRECTORY ?? bundledDirectory\n}\n\n/**\n * It returns the path to the directory containing the theme-check CLI.\n *\n * @returns The absolute path to the theme-check directory.\n */\nfunction themeCheckDirectory(): string {\n return joinPath(pathConstants.directories.cache.vendor.path(), 'theme-check', ThemeCheckVersion)\n}\n\n/**\n * It returns the Ruby version present in the envirronment.\n */\nexport async function version(): Promise<string | undefined> {\n const parseOutput = (version: string) => version.match(/ruby (\\d+\\.\\d+\\.\\d+)/)?.[1]\n return captureOutput(rubyExecutable(), ['-v'])\n .then(parseOutput)\n .catch(() => undefined)\n}\n\n/**\n * It returns the Ruby binary path set through the environment variable SHOPIFY_RUBY_BINDIR.\n * This is useful when the CLI is managed by an installer like a Homebrew where we need to\n * point the CLI to the Ruby installation managed by Homebrew.\n *\n * @returns The value of the environment variable.\n */\nfunction getRubyBinDir(): string | undefined {\n return getEnvironmentVariables().SHOPIFY_RUBY_BINDIR\n}\n\n/**\n * It returns the path to the \"ruby\" executable.\n *\n * @returns The path to the executable.\n */\nfunction rubyExecutable(): string {\n const rubyBinDir = getRubyBinDir()\n return rubyBinDir ? joinPath(rubyBinDir, 'ruby') : 'ruby'\n}\n\n/**\n * It returns the path to the \"bundle\" executable.\n *\n * @returns The path to the executable.\n */\nfunction bundleExecutable(): string {\n const rubyBinDir = getRubyBinDir()\n return rubyBinDir ? joinPath(rubyBinDir, 'bundle') : 'bundle'\n}\n\n/**\n * It returns the path to the \"gem\"\" executable.\n *\n * @returns The path to the executable.\n */\nfunction gemExecutable(): string {\n const rubyBinDir = getRubyBinDir()\n return rubyBinDir ? joinPath(rubyBinDir, 'gem') : 'gem'\n}\n\n/**\n * It returns the path to the \"bundle\" executable.\n *\n * @returns The path to the executable.\n */\nasync function embeddedCLIExecutable(): Promise<string> {\n const cliDirectory = await shopifyCLIDirectory(true)\n return joinPath(cliDirectory, 'bin', 'shopify')\n}\n\n/**\n * Get environment variables required by the CLI2 in case the CLI3 is running in a Spin environment.\n *\n * @returns The environment variables to set.\n */\nasync function getSpinEnvironmentVariables() {\n if (!isSpinEnvironment()) return {}\n\n return {\n SPIN_FQDN: await spinFqdn(),\n SPIN: '1',\n }\n}\n\n/**\n * It sets bundler's path to the given directory and runs bundle install.\n * This is desirable because the gems will be isolated from the system gems.\n *\n * @param directory - Directory where the Gemfile is located.\n */\nasync function localBundleInstall(directory: string): Promise<void> {\n const bundle = bundleExecutable()\n await exec(bundle, ['config', 'set', '--local', 'path', directory], {\n cwd: directory,\n })\n await exec(bundle, ['config', 'set', '--local', 'without', 'development:test'], {\n cwd: directory,\n })\n await exec(bundle, ['install'], {cwd: directory})\n}\n"]}
@@ -1 +1 @@
1
- export { z as schema } from 'zod';
1
+ export { z as zod } from 'zod';
@@ -1,2 +1,2 @@
1
- export { z as schema } from 'zod';
1
+ export { z as zod } from 'zod';
2
2
  //# sourceMappingURL=schema.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"schema.js","sourceRoot":"","sources":["../../../src/public/node/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,CAAC,IAAI,MAAM,EAAC,MAAM,KAAK,CAAA","sourcesContent":["export {z as schema} from 'zod'\n"]}
1
+ {"version":3,"file":"schema.js","sourceRoot":"","sources":["../../../src/public/node/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,CAAC,IAAI,GAAG,EAAC,MAAM,KAAK,CAAA","sourcesContent":["export {z as zod} from 'zod'\n"]}