@shopify/cli-kit 3.43.0 → 3.44.1-pre.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (140) hide show
  1. package/README.md +15 -7
  2. package/assets/cli-ruby/Gemfile +6 -3
  3. package/assets/cli-ruby/lib/project_types/extension/commands/serve.rb +10 -0
  4. package/assets/cli-ruby/lib/project_types/extension/models/specification_handlers/theme_app_extension.rb +1 -1
  5. package/assets/cli-ruby/lib/project_types/theme/cli.rb +1 -0
  6. package/assets/cli-ruby/lib/project_types/theme/commands/common/root_helper.rb +3 -2
  7. package/assets/cli-ruby/lib/project_types/theme/commands/console.rb +15 -0
  8. package/assets/cli-ruby/lib/project_types/theme/commands/push.rb +1 -0
  9. package/assets/cli-ruby/lib/project_types/theme/messages/messages.rb +4 -2
  10. package/assets/cli-ruby/lib/shopify_cli/constants.rb +1 -0
  11. package/assets/cli-ruby/lib/shopify_cli/environment.rb +4 -0
  12. package/assets/cli-ruby/lib/shopify_cli/theme/dev_server/hot_reload/script_injector.rb +1 -1
  13. package/assets/cli-ruby/lib/shopify_cli/theme/dev_server/hot_reload.rb +9 -2
  14. package/assets/cli-ruby/lib/shopify_cli/theme/dev_server/proxy.rb +13 -12
  15. package/assets/cli-ruby/lib/shopify_cli/theme/dev_server.rb +2 -2
  16. package/assets/cli-ruby/lib/shopify_cli/theme/extension/dev_server.rb +7 -4
  17. package/assets/cli-ruby/lib/shopify_cli/theme/extension/host_theme.rb +19 -14
  18. package/assets/cli-ruby/lib/shopify_cli/theme/repl/api.rb +107 -0
  19. package/assets/cli-ruby/lib/shopify_cli/theme/repl/auth_dev_server.rb +80 -0
  20. package/assets/cli-ruby/lib/shopify_cli/theme/repl/auth_middleware.rb +73 -0
  21. package/assets/cli-ruby/lib/shopify_cli/theme/repl/resources/success.html +79 -0
  22. package/assets/cli-ruby/lib/shopify_cli/theme/repl/resources/template.liquid +15 -0
  23. package/assets/cli-ruby/lib/shopify_cli/theme/repl.rb +145 -0
  24. package/assets/cli-ruby/lib/shopify_cli/theme/syncer/standard_reporter.rb +2 -2
  25. package/assets/cli-ruby/lib/shopify_cli/theme/syncer.rb +1 -1
  26. package/assets/cli-ruby/lib/shopify_cli/theme/theme.rb +6 -6
  27. package/dist/private/node/analytics.d.ts +2 -2
  28. package/dist/private/node/analytics.js.map +1 -1
  29. package/dist/private/node/api/graphql.js +9 -16
  30. package/dist/private/node/api/graphql.js.map +1 -1
  31. package/dist/private/node/api/headers.js +8 -5
  32. package/dist/private/node/api/headers.js.map +1 -1
  33. package/dist/private/node/api.d.ts +9 -0
  34. package/dist/private/node/api.js +19 -0
  35. package/dist/private/node/api.js.map +1 -1
  36. package/dist/private/node/colors.js.map +1 -0
  37. package/dist/private/node/conf-store.d.ts +24 -5
  38. package/dist/private/node/conf-store.js +21 -3
  39. package/dist/private/node/conf-store.js.map +1 -1
  40. package/dist/private/node/constants.d.ts +2 -0
  41. package/dist/private/node/constants.js +2 -0
  42. package/dist/private/node/constants.js.map +1 -1
  43. package/dist/private/node/content-tokens.js +1 -1
  44. package/dist/private/node/content-tokens.js.map +1 -1
  45. package/dist/private/node/semver.js.map +1 -0
  46. package/dist/private/node/session/identity-token-validation.d.ts +1 -1
  47. package/dist/private/node/session/identity-token-validation.js +45 -20
  48. package/dist/private/node/session/identity-token-validation.js.map +1 -1
  49. package/dist/private/node/session/store.js +3 -46
  50. package/dist/private/node/session/store.js.map +1 -1
  51. package/dist/private/node/session.js +13 -10
  52. package/dist/private/node/session.js.map +1 -1
  53. package/dist/private/node/themes/generate-theme-name.js.map +1 -0
  54. package/dist/private/node/themes/replace-invalid-characters.js.map +1 -0
  55. package/dist/private/node/themes/themes-api/headers.js.map +1 -0
  56. package/dist/private/node/themes/themes-api/retry.js.map +1 -0
  57. package/dist/private/node/themes/themes-api/throttler.js.map +1 -0
  58. package/dist/private/node/ui/components/ConcurrentOutput.d.ts +0 -1
  59. package/dist/private/node/ui/components/ConcurrentOutput.js +0 -1
  60. package/dist/private/node/ui/components/ConcurrentOutput.js.map +1 -1
  61. package/dist/public/common/string.d.ts +16 -4
  62. package/dist/public/common/string.js +25 -4
  63. package/dist/public/common/string.js.map +1 -1
  64. package/dist/public/common/ts/deep-required.d.ts +0 -1
  65. package/dist/public/common/ts/deep-required.js.map +1 -1
  66. package/dist/public/common/ts/pick-by-prefix.d.ts +0 -1
  67. package/dist/public/common/ts/pick-by-prefix.js.map +1 -1
  68. package/dist/public/common/version.d.ts +1 -1
  69. package/dist/public/common/version.js +1 -1
  70. package/dist/public/common/version.js.map +1 -1
  71. package/dist/public/node/base-command.d.ts +8 -5
  72. package/dist/public/node/base-command.js +1 -1
  73. package/dist/public/node/base-command.js.map +1 -1
  74. package/dist/public/node/cli.d.ts +1 -1
  75. package/dist/public/node/cli.js +0 -1
  76. package/dist/public/node/cli.js.map +1 -1
  77. package/dist/public/node/context/spin.d.ts +14 -0
  78. package/dist/public/node/context/spin.js +19 -0
  79. package/dist/public/node/context/spin.js.map +1 -1
  80. package/dist/public/node/environment.d.ts +12 -0
  81. package/dist/public/node/environment.js +14 -0
  82. package/dist/public/node/environment.js.map +1 -0
  83. package/dist/public/node/fs.d.ts +8 -12
  84. package/dist/public/node/fs.js +11 -35
  85. package/dist/public/node/fs.js.map +1 -1
  86. package/dist/public/node/http.js +5 -10
  87. package/dist/public/node/http.js.map +1 -1
  88. package/dist/public/node/local-storage.d.ts +37 -0
  89. package/dist/public/node/local-storage.js +44 -0
  90. package/dist/public/node/local-storage.js.map +1 -0
  91. package/dist/public/node/node-package-manager.js +1 -1
  92. package/dist/public/node/node-package-manager.js.map +1 -1
  93. package/dist/public/node/output.d.ts +0 -1
  94. package/dist/public/node/output.js +1 -2
  95. package/dist/public/node/output.js.map +1 -1
  96. package/dist/public/node/path.d.ts +58 -2
  97. package/dist/public/node/path.js +75 -3
  98. package/dist/public/node/path.js.map +1 -1
  99. package/dist/public/node/ruby.d.ts +2 -1
  100. package/dist/public/node/ruby.js +85 -31
  101. package/dist/public/node/ruby.js.map +1 -1
  102. package/dist/public/node/themes/conf.d.ts +12 -0
  103. package/dist/public/node/themes/conf.js +24 -0
  104. package/dist/public/node/themes/conf.js.map +1 -0
  105. package/dist/public/node/themes/theme-manager.js +1 -1
  106. package/dist/public/node/themes/theme-manager.js.map +1 -1
  107. package/dist/public/node/themes/themes-api.js +3 -3
  108. package/dist/public/node/themes/themes-api.js.map +1 -1
  109. package/dist/tsconfig.tsbuildinfo +1 -1
  110. package/package.json +9 -8
  111. package/dist/private/node/secure-store.d.ts +0 -19
  112. package/dist/private/node/secure-store.js +0 -63
  113. package/dist/private/node/secure-store.js.map +0 -1
  114. package/dist/public/node/colors.js.map +0 -1
  115. package/dist/public/node/conf.d.ts +0 -2
  116. package/dist/public/node/conf.js +0 -3
  117. package/dist/public/node/conf.js.map +0 -1
  118. package/dist/public/node/semver.js.map +0 -1
  119. package/dist/public/node/themes/generate-theme-name.js.map +0 -1
  120. package/dist/public/node/themes/replace-invalid-characters.js.map +0 -1
  121. package/dist/public/node/themes/themes-api/headers.js.map +0 -1
  122. package/dist/public/node/themes/themes-api/retry.js.map +0 -1
  123. package/dist/public/node/themes/themes-api/throttler.js.map +0 -1
  124. package/dist/store/schema.d.ts +0 -3
  125. package/dist/store/schema.js +0 -27
  126. package/dist/store/schema.js.map +0 -1
  127. /package/dist/{public → private}/node/colors.d.ts +0 -0
  128. /package/dist/{public → private}/node/colors.js +0 -0
  129. /package/dist/{public → private}/node/semver.d.ts +0 -0
  130. /package/dist/{public → private}/node/semver.js +0 -0
  131. /package/dist/{public → private}/node/themes/generate-theme-name.d.ts +0 -0
  132. /package/dist/{public → private}/node/themes/generate-theme-name.js +0 -0
  133. /package/dist/{public → private}/node/themes/replace-invalid-characters.d.ts +0 -0
  134. /package/dist/{public → private}/node/themes/replace-invalid-characters.js +0 -0
  135. /package/dist/{public → private}/node/themes/themes-api/headers.d.ts +0 -0
  136. /package/dist/{public → private}/node/themes/themes-api/headers.js +0 -0
  137. /package/dist/{public → private}/node/themes/themes-api/retry.d.ts +0 -0
  138. /package/dist/{public → private}/node/themes/themes-api/retry.js +0 -0
  139. /package/dist/{public → private}/node/themes/themes-api/throttler.d.ts +0 -0
  140. /package/dist/{public → private}/node/themes/themes-api/throttler.js +0 -0
@@ -1,7 +1,63 @@
1
1
  /// <reference types="node" resolution-mode="require"/>
2
- import { relative, dirname, join, normalize, resolve, basename, extname, isAbsolute } from 'pathe';
3
2
  import type { URL } from 'url';
4
- export { join as joinPath, relative as relativePath, normalize as normalizePath, resolve as resolvePath, isAbsolute as isAbsolutePath, dirname, basename, extname, };
3
+ /**
4
+ * Joins a list of paths together.
5
+ *
6
+ * @param paths - Paths to join.
7
+ * @returns Joined path.
8
+ */
9
+ export declare function joinPath(...paths: string[]): string;
10
+ /**
11
+ * Normalizes a path.
12
+ *
13
+ * @param path - Path to normalize.
14
+ * @returns Normalized path.
15
+ */
16
+ export declare function normalizePath(path: string): string;
17
+ /**
18
+ * Resolves a list of paths together.
19
+ *
20
+ * @param paths - Paths to resolve.
21
+ * @returns Resolved path.
22
+ */
23
+ export declare function resolvePath(...paths: string[]): string;
24
+ /**
25
+ * Returns the relative path from one path to another.
26
+ *
27
+ * @param from - Path to resolve from.
28
+ * @param to - Path to resolve to.
29
+ * @returns Relative path.
30
+ */
31
+ export declare function relativePath(from: string, to: string): string;
32
+ /**
33
+ * Returns whether the path is absolute.
34
+ *
35
+ * @param path - Path to check.
36
+ * @returns Whether the path is absolute.
37
+ */
38
+ export declare function isAbsolutePath(path: string): boolean;
39
+ /**
40
+ * Returns the directory name of a path.
41
+ *
42
+ * @param path - Path to get the directory name of.
43
+ * @returns Directory name.
44
+ */
45
+ export declare function dirname(path: string): string;
46
+ /**
47
+ * Returns the base name of a path.
48
+ *
49
+ * @param path - Path to get the base name of.
50
+ * @param ext - Optional extension to remove from the result.
51
+ * @returns Base name.
52
+ */
53
+ export declare function basename(path: string, ext?: string): string;
54
+ /**
55
+ * Returns the extension of the path.
56
+ *
57
+ * @param path - Path to get the extension of.
58
+ * @returns Extension.
59
+ */
60
+ export declare function extname(path: string): string;
5
61
  /**
6
62
  * Given an absolute filesystem path, it makes it relative to
7
63
  * the current working directory. This is useful when logging paths
@@ -1,8 +1,80 @@
1
1
  import commondir from 'commondir';
2
- import { relative, dirname, join, normalize, resolve, basename, extname, isAbsolute } from 'pathe';
2
+ import { relative, dirname as patheDirname, join, normalize, resolve, basename as basenamePathe, extname as extnamePathe, isAbsolute, } from 'pathe';
3
3
  import { fileURLToPath } from 'url';
4
- // Reexport methods from pathe
5
- export { join as joinPath, relative as relativePath, normalize as normalizePath, resolve as resolvePath, isAbsolute as isAbsolutePath, dirname, basename, extname, };
4
+ /**
5
+ * Joins a list of paths together.
6
+ *
7
+ * @param paths - Paths to join.
8
+ * @returns Joined path.
9
+ */
10
+ export function joinPath(...paths) {
11
+ return join(...paths);
12
+ }
13
+ /**
14
+ * Normalizes a path.
15
+ *
16
+ * @param path - Path to normalize.
17
+ * @returns Normalized path.
18
+ */
19
+ export function normalizePath(path) {
20
+ return normalize(path);
21
+ }
22
+ /**
23
+ * Resolves a list of paths together.
24
+ *
25
+ * @param paths - Paths to resolve.
26
+ * @returns Resolved path.
27
+ */
28
+ export function resolvePath(...paths) {
29
+ return resolve(...paths);
30
+ }
31
+ /**
32
+ * Returns the relative path from one path to another.
33
+ *
34
+ * @param from - Path to resolve from.
35
+ * @param to - Path to resolve to.
36
+ * @returns Relative path.
37
+ */
38
+ export function relativePath(from, to) {
39
+ return relative(from, to);
40
+ }
41
+ /**
42
+ * Returns whether the path is absolute.
43
+ *
44
+ * @param path - Path to check.
45
+ * @returns Whether the path is absolute.
46
+ */
47
+ export function isAbsolutePath(path) {
48
+ return isAbsolute(path);
49
+ }
50
+ /**
51
+ * Returns the directory name of a path.
52
+ *
53
+ * @param path - Path to get the directory name of.
54
+ * @returns Directory name.
55
+ */
56
+ export function dirname(path) {
57
+ return patheDirname(path);
58
+ }
59
+ /**
60
+ * Returns the base name of a path.
61
+ *
62
+ * @param path - Path to get the base name of.
63
+ * @param ext - Optional extension to remove from the result.
64
+ * @returns Base name.
65
+ */
66
+ export function basename(path, ext) {
67
+ return basenamePathe(path, ext);
68
+ }
69
+ /**
70
+ * Returns the extension of the path.
71
+ *
72
+ * @param path - Path to get the extension of.
73
+ * @returns Extension.
74
+ */
75
+ export function extname(path) {
76
+ return extnamePathe(path);
77
+ }
6
78
  /**
7
79
  * Given an absolute filesystem path, it makes it relative to
8
80
  * the current working directory. This is useful when logging paths
@@ -1 +1 @@
1
- {"version":3,"file":"path.js","sourceRoot":"","sources":["../../../src/public/node/path.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,WAAW,CAAA;AACjC,OAAO,EAAC,QAAQ,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,UAAU,EAAC,MAAM,OAAO,CAAA;AAChG,OAAO,EAAC,aAAa,EAAC,MAAM,KAAK,CAAA;AAIjC,8BAA8B;AAC9B,OAAO,EACL,IAAI,IAAI,QAAQ,EAChB,QAAQ,IAAI,YAAY,EACxB,SAAS,IAAI,aAAa,EAC1B,OAAO,IAAI,WAAW,EACtB,UAAU,IAAI,cAAc,EAC5B,OAAO,EACP,QAAQ,EACR,OAAO,GACR,CAAA;AAED;;;;;;;;;GASG;AACH,MAAM,UAAU,cAAc,CAAC,IAAY,EAAE,MAAc,GAAG,EAAE;IAC9D,MAAM,MAAM,GAAG,SAAS,CAAC,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC,CAAA;IACrC,MAAM,YAAY,GAAG,QAAQ,CAAC,GAAG,EAAE,IAAI,CAAC,CAAA;IACxC,6DAA6D;IAC7D,aAAa;IACb,MAAM,kBAAkB,GAAG,YAAY,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,SAAS,KAAK,IAAI,CAAC,CAAC,MAAM,CAAA;IACnG,IAAI,MAAM,KAAK,GAAG,IAAI,YAAY,KAAK,EAAE,IAAI,kBAAkB,GAAG,CAAC,EAAE;QACnE,OAAO,IAAI,CAAA;KACZ;SAAM;QACL,OAAO,YAAY,CAAA;KACpB;AACH,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,eAAe,CAAC,SAAuB;IACrD,OAAO,OAAO,CAAC,aAAa,CAAC,SAAS,CAAC,CAAC,CAAA;AAC1C,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,GAAG;IACjB,mDAAmD;IACnD,OAAO,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC,SAAS,CAAC,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,EAAE,CAAA;AAC/E,CAAC","sourcesContent":["import commondir from 'commondir'\nimport {relative, dirname, join, normalize, resolve, basename, extname, isAbsolute} from 'pathe'\nimport {fileURLToPath} from 'url'\n// eslint-disable-next-line node/prefer-global/url\nimport type {URL} from 'url'\n\n// Reexport methods from pathe\nexport {\n join as joinPath,\n relative as relativePath,\n normalize as normalizePath,\n resolve as resolvePath,\n isAbsolute as isAbsolutePath,\n dirname,\n basename,\n extname,\n}\n\n/**\n * Given an absolute filesystem path, it makes it relative to\n * the current working directory. This is useful when logging paths\n * to allow the users to click on the file and let the OS open it\n * in the editor of choice.\n *\n * @param path - Path to relativize.\n * @param dir - Current working directory.\n * @returns Relativized path.\n */\nexport function relativizePath(path: string, dir: string = cwd()): string {\n const result = commondir([path, dir])\n const relativePath = relative(dir, path)\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n const relativeComponents = relativePath.split('/').filter((component) => component === '..').length\n if (result === '/' || relativePath === '' || relativeComponents > 2) {\n return path\n } else {\n return relativePath\n }\n}\n\n/**\n * Given a module's import.meta.url it returns the directory containing the module.\n *\n * @param moduleURL - The value of import.meta.url in the context of the caller module.\n * @returns The path to the directory containing the caller module.\n */\nexport function moduleDirectory(moduleURL: string | URL): string {\n return dirname(fileURLToPath(moduleURL))\n}\n\n/**\n * When running a script using `npm run`, something interesting happens. If the current\n * folder does not have a `package.json` or a `node_modules` folder, npm will traverse\n * the directory tree upwards until it finds one. Then it will run the script and set\n * `process.cwd()` to that folder, while the actual path is stored in the INIT_CWD\n * environment variable (see here: https://docs.npmjs.com/cli/v9/commands/npm-run-script#description).\n *\n * @returns The path to the current working directory.\n */\nexport function cwd(): string {\n // eslint-disable-next-line rulesdir/no-process-cwd\n return process.env.INIT_CWD ? normalize(process.env.INIT_CWD) : process.cwd()\n}\n"]}
1
+ {"version":3,"file":"path.js","sourceRoot":"","sources":["../../../src/public/node/path.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,WAAW,CAAA;AACjC,OAAO,EACL,QAAQ,EACR,OAAO,IAAI,YAAY,EACvB,IAAI,EACJ,SAAS,EACT,OAAO,EACP,QAAQ,IAAI,aAAa,EACzB,OAAO,IAAI,YAAY,EACvB,UAAU,GACX,MAAM,OAAO,CAAA;AACd,OAAO,EAAC,aAAa,EAAC,MAAM,KAAK,CAAA;AAIjC;;;;;GAKG;AACH,MAAM,UAAU,QAAQ,CAAC,GAAG,KAAe;IACzC,OAAO,IAAI,CAAC,GAAG,KAAK,CAAC,CAAA;AACvB,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,aAAa,CAAC,IAAY;IACxC,OAAO,SAAS,CAAC,IAAI,CAAC,CAAA;AACxB,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,WAAW,CAAC,GAAG,KAAe;IAC5C,OAAO,OAAO,CAAC,GAAG,KAAK,CAAC,CAAA;AAC1B,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,YAAY,CAAC,IAAY,EAAE,EAAU;IACnD,OAAO,QAAQ,CAAC,IAAI,EAAE,EAAE,CAAC,CAAA;AAC3B,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,cAAc,CAAC,IAA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,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,EAAE,CAAA;AAC/E,CAAC","sourcesContent":["import commondir from 'commondir'\nimport {\n relative,\n dirname as patheDirname,\n join,\n normalize,\n resolve,\n basename as basenamePathe,\n extname as extnamePathe,\n isAbsolute,\n} from 'pathe'\nimport {fileURLToPath} from 'url'\n// eslint-disable-next-line node/prefer-global/url\nimport type {URL} from 'url'\n\n/**\n * Joins a list of paths together.\n *\n * @param paths - Paths to join.\n * @returns Joined path.\n */\nexport function joinPath(...paths: string[]): string {\n return join(...paths)\n}\n\n/**\n * Normalizes a path.\n *\n * @param path - Path to normalize.\n * @returns Normalized path.\n */\nexport function normalizePath(path: string): string {\n return normalize(path)\n}\n\n/**\n * Resolves a list of paths together.\n *\n * @param paths - Paths to resolve.\n * @returns Resolved path.\n */\nexport function resolvePath(...paths: string[]): string {\n return resolve(...paths)\n}\n\n/**\n * Returns the relative path from one path to another.\n *\n * @param from - Path to resolve from.\n * @param to - Path to resolve to.\n * @returns Relative path.\n */\nexport function relativePath(from: string, to: string): string {\n return relative(from, to)\n}\n\n/**\n * Returns whether the path is absolute.\n *\n * @param path - Path to check.\n * @returns Whether the path is absolute.\n */\nexport function isAbsolutePath(path: string): boolean {\n return isAbsolute(path)\n}\n\n/**\n * Returns the directory name of a path.\n *\n * @param path - Path to get the directory name of.\n * @returns Directory name.\n */\nexport function dirname(path: string): string {\n return patheDirname(path)\n}\n\n/**\n * Returns the base name of a path.\n *\n * @param path - Path to get the base name of.\n * @param ext - Optional extension to remove from the result.\n * @returns Base name.\n */\nexport function basename(path: string, ext?: string): string {\n return basenamePathe(path, ext)\n}\n\n/**\n * Returns the extension of the path.\n *\n * @param path - Path to get the extension of.\n * @returns Extension.\n */\nexport function extname(path: string): string {\n return extnamePathe(path)\n}\n\n/**\n * Given an absolute filesystem path, it makes it relative to\n * the current working directory. This is useful when logging paths\n * to allow the users to click on the file and let the OS open it\n * in the editor of choice.\n *\n * @param path - Path to relativize.\n * @param dir - Current working directory.\n * @returns Relativized path.\n */\nexport function relativizePath(path: string, dir: string = cwd()): string {\n const result = commondir([path, dir])\n const relativePath = relative(dir, path)\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n const relativeComponents = relativePath.split('/').filter((component) => component === '..').length\n if (result === '/' || relativePath === '' || relativeComponents > 2) {\n return path\n } else {\n return relativePath\n }\n}\n\n/**\n * Given a module's import.meta.url it returns the directory containing the module.\n *\n * @param moduleURL - The value of import.meta.url in the context of the caller module.\n * @returns The path to the directory containing the caller module.\n */\nexport function moduleDirectory(moduleURL: string | URL): string {\n return dirname(fileURLToPath(moduleURL))\n}\n\n/**\n * When running a script using `npm run`, something interesting happens. If the current\n * folder does not have a `package.json` or a `node_modules` folder, npm will traverse\n * the directory tree upwards until it finds one. Then it will run the script and set\n * `process.cwd()` to that folder, while the actual path is stored in the INIT_CWD\n * environment variable (see here: https://docs.npmjs.com/cli/v9/commands/npm-run-script#description).\n *\n * @returns The path to the current working directory.\n */\nexport function cwd(): string {\n // eslint-disable-next-line rulesdir/no-process-cwd\n return process.env.INIT_CWD ? normalize(process.env.INIT_CWD) : process.cwd()\n}\n"]}
@@ -2,7 +2,8 @@
2
2
  import { AbortSignal } from './abort.js';
3
3
  import { AdminSession } from '../../public/node/session.js';
4
4
  import { Writable } from 'stream';
5
- export declare const RubyCLIVersion = "2.34.0";
5
+ export declare const RubyCLIVersion = "2.35.0";
6
+ export declare const MinWdmWindowsVersion = "0.1.0";
6
7
  interface ExecCLI2Options {
7
8
  adminSession?: AdminSession;
8
9
  storefrontToken?: string;
@@ -1,19 +1,21 @@
1
- import { coerceSemverVersion } from './semver.js';
2
1
  import { platformAndArch } from './os.js';
3
2
  import { captureOutput, exec } from './system.js';
4
3
  import * as file from './fs.js';
5
4
  import { joinPath, dirname, cwd } from './path.js';
6
5
  import { AbortError, AbortSilentError } from './error.js';
7
- import { isShopify } from './context/local.js';
6
+ import { getEnvironmentVariables } from './environment.js';
7
+ import { isSpinEnvironment, spinFqdn } from './context/spin.js';
8
8
  import { pathConstants } from '../../private/node/constants.js';
9
9
  import { outputContent, outputToken } from '../../public/node/output.js';
10
10
  import { isTruthy } from '../../private/node/context/utilities.js';
11
+ import { coerceSemverVersion } from '../../private/node/semver.js';
11
12
  import { Writable } from 'stream';
12
13
  import { fileURLToPath } from 'url';
13
- export const RubyCLIVersion = '2.34.0';
14
+ export const RubyCLIVersion = '2.35.0';
14
15
  const ThemeCheckVersion = '1.14.0';
15
- const MinBundlerVersion = '2.3.8';
16
+ const MinBundlerVersion = '2.3.11';
16
17
  const MinRubyVersion = '2.7.5';
18
+ export const MinWdmWindowsVersion = '0.1.0';
17
19
  /**
18
20
  * Execute CLI 2.0 commands.
19
21
  * Installs a version of RubyCLI as a vendor dependency in a hidden folder in the system.
@@ -23,10 +25,11 @@ const MinRubyVersion = '2.7.5';
23
25
  * @param options - Options to customize the execution of cli2.
24
26
  */
25
27
  export async function execCLI2(args, options = {}) {
26
- const embedded = (await isShopify()) || isTruthy(process.env.SHOPIFY_CLI_EMBEDDED_THEME_CLI);
28
+ const currentEnv = getEnvironmentVariables();
29
+ const embedded = !isTruthy(currentEnv.SHOPIFY_CLI_BUNDLED_THEME_CLI) && !currentEnv.SHOPIFY_CLI_2_0_DIRECTORY;
27
30
  await installCLIDependencies(options.stdout ?? process.stdout, embedded);
28
31
  const env = {
29
- ...process.env,
32
+ ...currentEnv,
30
33
  SHOPIFY_CLI_STOREFRONT_RENDERER_AUTH_TOKEN: options.storefrontToken,
31
34
  SHOPIFY_CLI_ADMIN_AUTH_TOKEN: options.adminSession?.token,
32
35
  SHOPIFY_SHOP: options.adminSession?.storeFqdn,
@@ -36,12 +39,11 @@ export async function execCLI2(args, options = {}) {
36
39
  // environment. We use this to specify our own Gemfile for CLI2, which exists
37
40
  // outside the user's project directory.
38
41
  BUNDLE_GEMFILE: joinPath(await shopifyCLIDirectory(embedded), 'Gemfile'),
42
+ ...(await getSpinEnvironmentVariables()),
39
43
  };
40
44
  try {
41
- const executable = bundleExecutable();
42
- const shopifyExecutable = embedded ? await embeddedCLIExecutable() : 'shopify';
43
- const finalArgs = ['exec', shopifyExecutable, ...args];
44
- await exec(executable, finalArgs, {
45
+ const shopifyExecutable = embedded ? [rubyExecutable(), await embeddedCLIExecutable()] : ['shopify'];
46
+ await exec(bundleExecutable(), ['exec', ...shopifyExecutable, ...args], {
45
47
  stdio: 'inherit',
46
48
  cwd: options.directory ?? cwd(),
47
49
  env,
@@ -122,7 +124,7 @@ async function installCLIDependencies(stdout, embedded = false) {
122
124
  const exists = await file.fileExists(localCLI);
123
125
  if (!exists)
124
126
  stdout.write('Installing theme dependencies...');
125
- const usingLocalCLI2 = embedded || isTruthy(process.env.SHOPIFY_CLI_2_0_DIRECTORY);
127
+ const usingLocalCLI2 = embedded || isTruthy(getEnvironmentVariables().SHOPIFY_CLI_2_0_DIRECTORY);
126
128
  await validateRubyEnv();
127
129
  if (usingLocalCLI2) {
128
130
  await bundleInstallLocalShopifyCLI(localCLI);
@@ -194,14 +196,9 @@ async function createThemeCheckCLIWorkingDirectory() {
194
196
  * It creates the Gemfile to install The Ruby CLI and the dependencies.
195
197
  */
196
198
  async function createShopifyCLIGemfile() {
197
- const gemPath = joinPath(await shopifyCLIDirectory(), 'Gemfile');
198
- const gemFileContent = ["source 'https://rubygems.org'", `gem 'shopify-cli', '${RubyCLIVersion}'`];
199
- const { platform } = platformAndArch();
200
- if (platform === 'windows') {
201
- // 'wdm' is required by 'listen', see https://github.com/Shopify/cli/issues/780
202
- gemFileContent.push("gem 'wdm', '>= 0.1.0'");
203
- }
204
- await file.writeFile(gemPath, gemFileContent.join('\n'));
199
+ const directory = await shopifyCLIDirectory();
200
+ const gemfileContent = getBaseGemfileContent().concat(getWindowsDependencies());
201
+ await addContentToGemfile(directory, gemfileContent);
205
202
  }
206
203
  /**
207
204
  * It creates the Gemfile to install theme-check and its dependencies.
@@ -216,26 +213,57 @@ async function createThemeCheckGemfile() {
216
213
  * @param directory - Directory where CLI2 Gemfile is located.
217
214
  */
218
215
  async function bundleInstallLocalShopifyCLI(directory) {
219
- await exec(bundleExecutable(), ['install'], { cwd: directory });
216
+ await addContentToGemfile(directory, getWindowsDependencies());
217
+ await localBundleInstall(directory);
218
+ }
219
+ /**
220
+ * Build the list of lines with the base content of the Gemfile.
221
+ *
222
+ * @returns List of lines with base content.
223
+ */
224
+ function getBaseGemfileContent() {
225
+ return ["source 'https://rubygems.org'", `gem 'shopify-cli', '${RubyCLIVersion}'`];
226
+ }
227
+ /**
228
+ * Build the list of Windows dependencies.
229
+ *
230
+ * @returns List of Windows dependencies.
231
+ */
232
+ function getWindowsDependencies() {
233
+ if (platformAndArch().platform === 'windows') {
234
+ // 'wdm' is required by 'listen', see https://github.com/Shopify/cli/issues/780
235
+ // Because it's a Windows-only dependency, it's not included in the `.gemspec` or `Gemfile`.
236
+ // Otherwise it would be installed in non-Windows environments too, where it is not needed.
237
+ return [`gem 'wdm', '>= ${MinWdmWindowsVersion}'`];
238
+ }
239
+ return [];
240
+ }
241
+ /**
242
+ * Append contente to a Gemfile located in the given directory.
243
+ *
244
+ * @param gemfileDirectory - Directory where Gemfile is located.
245
+ * @param content - Content to append to the Gemfile.
246
+ */
247
+ async function addContentToGemfile(gemfileDirectory, content) {
248
+ const gemfilePath = joinPath(gemfileDirectory, 'Gemfile');
249
+ if (!(await file.fileExists(gemfilePath)))
250
+ await file.touchFile(gemfilePath);
251
+ const gemContent = await file.readFile(gemfilePath, { encoding: 'utf8' });
252
+ const contentNoExisting = content.filter((line) => !gemContent.includes(line)).join('\n');
253
+ if (contentNoExisting)
254
+ await file.appendFile(gemfilePath, contentNoExisting.concat('\n'));
220
255
  }
221
256
  /**
222
257
  * It runs bundle install for the CLI-managed copy of the Ruby CLI.
223
258
  */
224
259
  async function bundleInstallShopifyCLI() {
225
- const cliDirectory = await shopifyCLIDirectory();
226
- await exec(bundleExecutable(), ['config', 'set', '--local', 'path', cliDirectory], {
227
- cwd: cliDirectory,
228
- });
229
- await exec(bundleExecutable(), ['install'], { cwd: cliDirectory });
260
+ await localBundleInstall(await shopifyCLIDirectory());
230
261
  }
231
262
  /**
232
263
  * It runs bundle install for the CLI-managed copy of theme-check.
233
264
  */
234
265
  async function bundleInstallThemeCheck() {
235
- await exec(bundleExecutable(), ['config', 'set', '--local', 'path', themeCheckDirectory()], {
236
- cwd: themeCheckDirectory(),
237
- });
238
- await exec(bundleExecutable(), ['install'], { cwd: themeCheckDirectory() });
266
+ await localBundleInstall(themeCheckDirectory());
239
267
  }
240
268
  /**
241
269
  * It returns the directory where the Ruby CLI is located.
@@ -249,7 +277,7 @@ async function shopifyCLIDirectory(embedded = false) {
249
277
  cwd: dirname(fileURLToPath(import.meta.url)),
250
278
  }));
251
279
  const bundledDirectory = joinPath(pathConstants.directories.cache.vendor.path(), 'ruby-cli', RubyCLIVersion);
252
- return embedded ? embeddedDirectory : process.env.SHOPIFY_CLI_2_0_DIRECTORY ?? bundledDirectory;
280
+ return embedded ? embeddedDirectory : getEnvironmentVariables().SHOPIFY_CLI_2_0_DIRECTORY ?? bundledDirectory;
253
281
  }
254
282
  /**
255
283
  * It returns the path to the directory containing the theme-check CLI.
@@ -276,7 +304,7 @@ export async function version() {
276
304
  * @returns The value of the environment variable.
277
305
  */
278
306
  function getRubyBinDir() {
279
- return process.env.SHOPIFY_RUBY_BINDIR;
307
+ return getEnvironmentVariables().SHOPIFY_RUBY_BINDIR;
280
308
  }
281
309
  /**
282
310
  * It returns the path to the "ruby" executable.
@@ -314,4 +342,30 @@ async function embeddedCLIExecutable() {
314
342
  const cliDirectory = await shopifyCLIDirectory(true);
315
343
  return joinPath(cliDirectory, 'bin', 'shopify');
316
344
  }
345
+ /**
346
+ * Get environment variables required by the CLI2 in case the CLI3 is running in a Spin environment.
347
+ *
348
+ * @returns The environment variables to set.
349
+ */
350
+ async function getSpinEnvironmentVariables() {
351
+ if (!isSpinEnvironment())
352
+ return {};
353
+ return {
354
+ SPIN_FQDN: await spinFqdn(),
355
+ SPIN: '1',
356
+ };
357
+ }
358
+ /**
359
+ * It sets bundler's path to the given directory and runs bundle install.
360
+ * This is desirable because the gems will be isolated from the system gems.
361
+ *
362
+ * @param directory - Directory where the Gemfile is located.
363
+ */
364
+ async function localBundleInstall(directory) {
365
+ const bundle = bundleExecutable();
366
+ await exec(bundle, ['config', 'set', '--local', 'path', directory], {
367
+ cwd: directory,
368
+ });
369
+ await exec(bundle, ['install', '--without', 'development', 'test'], { cwd: directory });
370
+ }
317
371
  //# sourceMappingURL=ruby.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ruby.js","sourceRoot":"","sources":["../../../src/public/node/ruby.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,mBAAmB,EAAC,MAAM,aAAa,CAAA;AAE/C,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,CAAA;AACvD,OAAO,EAAC,SAAS,EAAC,MAAM,oBAAoB,CAAA;AAC5C,OAAO,EAAC,aAAa,EAAC,MAAM,iCAAiC,CAAA;AAE7D,OAAO,EAAC,aAAa,EAAE,WAAW,EAAC,MAAM,6BAA6B,CAAA;AACtE,OAAO,EAAC,QAAQ,EAAC,MAAM,yCAAyC,CAAA;AAChE,OAAO,EAAC,QAAQ,EAAC,MAAM,QAAQ,CAAA;AAC/B,OAAO,EAAC,aAAa,EAAC,MAAM,KAAK,CAAA;AAEjC,MAAM,CAAC,MAAM,cAAc,GAAG,QAAQ,CAAA;AACtC,MAAM,iBAAiB,GAAG,QAAQ,CAAA;AAClC,MAAM,iBAAiB,GAAG,OAAO,CA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MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAA;AAC3D,CAAC;AAED;;;;GAIG;AACH,SAAS,gBAAgB;IACvB,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","sourcesContent":["import {coerceSemverVersion} from './semver.js'\nimport {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 {isShopify} from './context/local.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 {Writable} from 'stream'\nimport {fileURLToPath} from 'url'\n\nexport const RubyCLIVersion = '2.34.0'\nconst ThemeCheckVersion = '1.14.0'\nconst MinBundlerVersion = '2.3.8'\nconst MinRubyVersion = '2.7.5'\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}\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 embedded = (await isShopify()) || isTruthy(process.env.SHOPIFY_CLI_EMBEDDED_THEME_CLI)\n\n await installCLIDependencies(options.stdout ?? process.stdout, embedded)\n const env: NodeJS.ProcessEnv = {\n ...process.env,\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 }\n\n try {\n const executable = bundleExecutable()\n const shopifyExecutable = embedded ? await embeddedCLIExecutable() : 'shopify'\n const finalArgs = ['exec', shopifyExecutable, ...args]\n\n await exec(executable, finalArgs, {\n stdio: 'inherit',\n cwd: options.directory ?? cwd(),\n env,\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(process.env.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 gemPath = joinPath(await shopifyCLIDirectory(), 'Gemfile')\n const gemFileContent = [\"source 'https://rubygems.org'\", `gem 'shopify-cli', '${RubyCLIVersion}'`]\n const {platform} = platformAndArch()\n if (platform === 'windows') {\n // 'wdm' is required by 'listen', see https://github.com/Shopify/cli/issues/780\n gemFileContent.push(\"gem 'wdm', '>= 0.1.0'\")\n }\n await file.writeFile(gemPath, gemFileContent.join('\\n'))\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 exec(bundleExecutable(), ['install'], {cwd: directory})\n}\n\n/**\n * It runs bundle install for the CLI-managed copy of the Ruby CLI.\n */\nasync function bundleInstallShopifyCLI() {\n const cliDirectory = await shopifyCLIDirectory()\n await exec(bundleExecutable(), ['config', 'set', '--local', 'path', cliDirectory], {\n cwd: cliDirectory,\n })\n await exec(bundleExecutable(), ['install'], {cwd: cliDirectory})\n}\n\n/**\n * It runs bundle install for the CLI-managed copy of theme-check.\n */\nasync function bundleInstallThemeCheck() {\n await exec(bundleExecutable(), ['config', 'set', '--local', 'path', themeCheckDirectory()], {\n cwd: themeCheckDirectory(),\n })\n await exec(bundleExecutable(), ['install'], {cwd: 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 : process.env.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 process.env.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"]}
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,CAAA;AACvD,OAAO,EAAC,uBAAuB,EAAC,MAAM,kBAAkB,CAAA;AACxD,OAAO,EAAC,iBAAiB,EAAE,QAAQ,EAAC,MAAM,mBAAmB,CAAA;AAC7D,OAAO,EAAC,aAAa,EAAC,MAAM,iCAAiC,CAAA;AAE7D,OAAO,EAAC,aAAa,EAAE,WAAW,EAAC,MAAM,6BAA6B,CAAA;AACtE,OAAO,EAAC,QAAQ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,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}\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 stdio: 'inherit',\n cwd: options.directory ?? cwd(),\n env,\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"]}
@@ -0,0 +1,12 @@
1
+ import { LocalStorage } from '@shopify/cli-kit/node/local-storage';
2
+ import { AdminSession } from '@shopify/cli-kit/node/session';
3
+ type HostThemeId = string;
4
+ type StoreFqdn = AdminSession['storeFqdn'];
5
+ interface HostThemeLocalStorageSchema {
6
+ [themeStore: StoreFqdn]: HostThemeId;
7
+ }
8
+ export declare function hostThemeLocalStorage(): LocalStorage<HostThemeLocalStorageSchema>;
9
+ export declare function getHostTheme(storeFqdn: StoreFqdn): string | undefined;
10
+ export declare function setHostTheme(storeFqdn: StoreFqdn, themeId: HostThemeId): void;
11
+ export declare function removeHostTheme(storeFqdn: StoreFqdn): void;
12
+ export {};
@@ -0,0 +1,24 @@
1
+ import { LocalStorage } from '@shopify/cli-kit/node/local-storage';
2
+ import { outputDebug, outputContent } from '@shopify/cli-kit/node/output';
3
+ let _hostThemeLocalStorageInstance;
4
+ export function hostThemeLocalStorage() {
5
+ if (!_hostThemeLocalStorageInstance) {
6
+ _hostThemeLocalStorageInstance = new LocalStorage({
7
+ projectName: 'shopify-cli-host-theme-conf',
8
+ });
9
+ }
10
+ return _hostThemeLocalStorageInstance;
11
+ }
12
+ export function getHostTheme(storeFqdn) {
13
+ outputDebug(outputContent `Getting host theme...`);
14
+ return hostThemeLocalStorage().get(storeFqdn);
15
+ }
16
+ export function setHostTheme(storeFqdn, themeId) {
17
+ outputDebug(outputContent `Setting host theme...`);
18
+ hostThemeLocalStorage().set(storeFqdn, themeId);
19
+ }
20
+ export function removeHostTheme(storeFqdn) {
21
+ outputDebug(outputContent `Removing host theme...`);
22
+ hostThemeLocalStorage().delete(storeFqdn);
23
+ }
24
+ //# sourceMappingURL=conf.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"conf.js","sourceRoot":"","sources":["../../../../src/public/node/themes/conf.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,YAAY,EAAC,MAAM,qCAAqC,CAAA;AAEhE,OAAO,EAAC,WAAW,EAAE,aAAa,EAAC,MAAM,8BAA8B,CAAA;AASvE,IAAI,8BAAqF,CAAA;AAEzF,MAAM,UAAU,qBAAqB;IACnC,IAAI,CAAC,8BAA8B,EAAE;QACnC,8BAA8B,GAAG,IAAI,YAAY,CAA8B;YAC7E,WAAW,EAAE,6BAA6B;SAC3C,CAAC,CAAA;KACH;IACD,OAAO,8BAA8B,CAAA;AACvC,CAAC;AAED,MAAM,UAAU,YAAY,CAAC,SAAoB;IAC/C,WAAW,CAAC,aAAa,CAAA,uBAAuB,CAAC,CAAA;IACjD,OAAO,qBAAqB,EAAE,CAAC,GAAG,CAAC,SAAS,CAAC,CAAA;AAC/C,CAAC;AAED,MAAM,UAAU,YAAY,CAAC,SAAoB,EAAE,OAAoB;IACrE,WAAW,CAAC,aAAa,CAAA,uBAAuB,CAAC,CAAA;IACjD,qBAAqB,EAAE,CAAC,GAAG,CAAC,SAAS,EAAE,OAAO,CAAC,CAAA;AACjD,CAAC;AAED,MAAM,UAAU,eAAe,CAAC,SAAoB;IAClD,WAAW,CAAC,aAAa,CAAA,wBAAwB,CAAC,CAAA;IAClD,qBAAqB,EAAE,CAAC,MAAM,CAAC,SAAS,CAAC,CAAA;AAC3C,CAAC","sourcesContent":["import {LocalStorage} from '@shopify/cli-kit/node/local-storage'\nimport {AdminSession} from '@shopify/cli-kit/node/session'\nimport {outputDebug, outputContent} from '@shopify/cli-kit/node/output'\n\ntype HostThemeId = string\ntype StoreFqdn = AdminSession['storeFqdn']\n\ninterface HostThemeLocalStorageSchema {\n [themeStore: StoreFqdn]: HostThemeId\n}\n\nlet _hostThemeLocalStorageInstance: LocalStorage<HostThemeLocalStorageSchema> | undefined\n\nexport function hostThemeLocalStorage(): LocalStorage<HostThemeLocalStorageSchema> {\n if (!_hostThemeLocalStorageInstance) {\n _hostThemeLocalStorageInstance = new LocalStorage<HostThemeLocalStorageSchema>({\n projectName: 'shopify-cli-host-theme-conf',\n })\n }\n return _hostThemeLocalStorageInstance\n}\n\nexport function getHostTheme(storeFqdn: StoreFqdn): string | undefined {\n outputDebug(outputContent`Getting host theme...`)\n return hostThemeLocalStorage().get(storeFqdn)\n}\n\nexport function setHostTheme(storeFqdn: StoreFqdn, themeId: HostThemeId): void {\n outputDebug(outputContent`Setting host theme...`)\n hostThemeLocalStorage().set(storeFqdn, themeId)\n}\n\nexport function removeHostTheme(storeFqdn: StoreFqdn): void {\n outputDebug(outputContent`Removing host theme...`)\n hostThemeLocalStorage().delete(storeFqdn)\n}\n"]}
@@ -1,6 +1,6 @@
1
1
  import { fetchTheme, createTheme } from './themes-api.js';
2
2
  import { DEVELOPMENT_THEME_ROLE } from './models/theme.js';
3
- import { generateThemeName } from './generate-theme-name.js';
3
+ import { generateThemeName } from '../../../private/node/themes/generate-theme-name.js';
4
4
  import { BugError } from '@shopify/cli-kit/node/error';
5
5
  export class ThemeManager {
6
6
  constructor(adminSession) {
@@ -1 +1 @@
1
- {"version":3,"file":"theme-manager.js","sourceRoot":"","sources":["../../../../src/public/node/themes/theme-manager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAE,WAAW,EAAC,MAAM,iBAAiB,CAAA;AACvD,OAAO,EAAC,sBAAsB,EAAQ,MAAM,mBAAmB,CAAA;AAC/D,OAAO,EAAC,iBAAiB,EAAC,MAAM,0BAA0B,CAAA;AAE1D,OAAO,EAAC,QAAQ,EAAC,MAAM,6BAA6B,CAAA;AAEpD,MAAM,OAAgB,YAAY;IAMhC,YAAsB,YAA0B;QAA1B,iBAAY,GAAZ,YAAY,CAAc;IAAG,CAAC;IAEpD,KAAK,CAAC,YAAY;QAChB,IAAI,KAAK,GAAG,MAAM,IAAI,CAAC,KAAK,EAAE,CAAA;QAC9B,IAAI,CAAC,KAAK,EAAE;YACV,KAAK,GAAG,MAAM,IAAI,CAAC,MAAM,EAAE,CAAA;SAC5B;QACD,OAAO,KAAK,CAAA;IACd,CAAC;IAES,KAAK,CAAC,KAAK;QACnB,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE;YACjB,OAAM;SACP;QACD,MAAM,KAAK,GAAG,MAAM,UAAU,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,EAAE,EAAE,CAAC,EAAE,IAAI,CAAC,YAAY,CAAC,CAAA;QAC7E,IAAI,CAAC,KAAK,EAAE;YACV,IAAI,CAAC,WAAW,EAAE,CAAA;SACnB;QACD,OAAO,KAAK,CAAA;IACd,CAAC;IAEO,KAAK,CAAC,MAAM;QAClB,MAAM,IAAI,GAAG,iBAAiB,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;QAC5C,MAAM,IAAI,GAAG,sBAAsB,CAAA;QACnC,MAAM,KAAK,GAAG,MAAM,WAAW,CAC7B;YACE,IAAI;YACJ,IAAI;SACL,EACD,IAAI,CAAC,YAAY,CAClB,CAAA;QACD,IAAI,CAAC,KAAK,EAAE;YACV,MAAM,IAAI,QAAQ,CAAC,qCAAqC,IAAI,eAAe,IAAI,GAAG,CAAC,CAAA;SACpF;QACD,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC,QAAQ,EAAE,CAAC,CAAA;QAClC,OAAO,KAAK,CAAA;IACd,CAAC;CACF","sourcesContent":["import {fetchTheme, createTheme} from './themes-api.js'\nimport {DEVELOPMENT_THEME_ROLE, Theme} from './models/theme.js'\nimport {generateThemeName} from './generate-theme-name.js'\nimport {AdminSession} from '@shopify/cli-kit/node/session'\nimport {BugError} from '@shopify/cli-kit/node/error'\n\nexport abstract class ThemeManager {\n protected themeId: string | undefined\n protected abstract setTheme(themeId: string): void\n protected abstract removeTheme(): void\n protected abstract context: string\n\n constructor(protected adminSession: AdminSession) {}\n\n async findOrCreate(): Promise<Theme> {\n let theme = await this.fetch()\n if (!theme) {\n theme = await this.create()\n }\n return theme\n }\n\n protected async fetch() {\n if (!this.themeId) {\n return\n }\n const theme = await fetchTheme(parseInt(this.themeId, 10), this.adminSession)\n if (!theme) {\n this.removeTheme()\n }\n return theme\n }\n\n private async create() {\n const name = generateThemeName(this.context)\n const role = DEVELOPMENT_THEME_ROLE\n const theme = await createTheme(\n {\n name,\n role,\n },\n this.adminSession,\n )\n if (!theme) {\n throw new BugError(`Could not create theme with name \"${name}\" and role \"${role}\"`)\n }\n this.setTheme(theme.id.toString())\n return theme\n }\n}\n"]}
1
+ {"version":3,"file":"theme-manager.js","sourceRoot":"","sources":["../../../../src/public/node/themes/theme-manager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAE,WAAW,EAAC,MAAM,iBAAiB,CAAA;AACvD,OAAO,EAAC,sBAAsB,EAAQ,MAAM,mBAAmB,CAAA;AAC/D,OAAO,EAAC,iBAAiB,EAAC,MAAM,qDAAqD,CAAA;AAErF,OAAO,EAAC,QAAQ,EAAC,MAAM,6BAA6B,CAAA;AAEpD,MAAM,OAAgB,YAAY;IAMhC,YAAsB,YAA0B;QAA1B,iBAAY,GAAZ,YAAY,CAAc;IAAG,CAAC;IAEpD,KAAK,CAAC,YAAY;QAChB,IAAI,KAAK,GAAG,MAAM,IAAI,CAAC,KAAK,EAAE,CAAA;QAC9B,IAAI,CAAC,KAAK,EAAE;YACV,KAAK,GAAG,MAAM,IAAI,CAAC,MAAM,EAAE,CAAA;SAC5B;QACD,OAAO,KAAK,CAAA;IACd,CAAC;IAES,KAAK,CAAC,KAAK;QACnB,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE;YACjB,OAAM;SACP;QACD,MAAM,KAAK,GAAG,MAAM,UAAU,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,EAAE,EAAE,CAAC,EAAE,IAAI,CAAC,YAAY,CAAC,CAAA;QAC7E,IAAI,CAAC,KAAK,EAAE;YACV,IAAI,CAAC,WAAW,EAAE,CAAA;SACnB;QACD,OAAO,KAAK,CAAA;IACd,CAAC;IAEO,KAAK,CAAC,MAAM;QAClB,MAAM,IAAI,GAAG,iBAAiB,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;QAC5C,MAAM,IAAI,GAAG,sBAAsB,CAAA;QACnC,MAAM,KAAK,GAAG,MAAM,WAAW,CAC7B;YACE,IAAI;YACJ,IAAI;SACL,EACD,IAAI,CAAC,YAAY,CAClB,CAAA;QACD,IAAI,CAAC,KAAK,EAAE;YACV,MAAM,IAAI,QAAQ,CAAC,qCAAqC,IAAI,eAAe,IAAI,GAAG,CAAC,CAAA;SACpF;QACD,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC,QAAQ,EAAE,CAAC,CAAA;QAClC,OAAO,KAAK,CAAA;IACd,CAAC;CACF","sourcesContent":["import {fetchTheme, createTheme} from './themes-api.js'\nimport {DEVELOPMENT_THEME_ROLE, Theme} from './models/theme.js'\nimport {generateThemeName} from '../../../private/node/themes/generate-theme-name.js'\nimport {AdminSession} from '@shopify/cli-kit/node/session'\nimport {BugError} from '@shopify/cli-kit/node/error'\n\nexport abstract class ThemeManager {\n protected themeId: string | undefined\n protected abstract setTheme(themeId: string): void\n protected abstract removeTheme(): void\n protected abstract context: string\n\n constructor(protected adminSession: AdminSession) {}\n\n async findOrCreate(): Promise<Theme> {\n let theme = await this.fetch()\n if (!theme) {\n theme = await this.create()\n }\n return theme\n }\n\n protected async fetch() {\n if (!this.themeId) {\n return\n }\n const theme = await fetchTheme(parseInt(this.themeId, 10), this.adminSession)\n if (!theme) {\n this.removeTheme()\n }\n return theme\n }\n\n private async create() {\n const name = generateThemeName(this.context)\n const role = DEVELOPMENT_THEME_ROLE\n const theme = await createTheme(\n {\n name,\n role,\n },\n this.adminSession,\n )\n if (!theme) {\n throw new BugError(`Could not create theme with name \"${name}\" and role \"${role}\"`)\n }\n this.setTheme(theme.id.toString())\n return theme\n }\n}\n"]}
@@ -1,8 +1,8 @@
1
- import * as throttler from './themes-api/throttler.js';
2
- import { apiCallLimit, retryAfter } from './themes-api/headers.js';
3
- import { retry } from './themes-api/retry.js';
4
1
  import { storeAdminUrl } from './theme-urls.js';
5
2
  import { Theme } from './models/theme.js';
3
+ import * as throttler from '../../../private/node/themes/themes-api/throttler.js';
4
+ import { apiCallLimit, retryAfter } from '../../../private/node/themes/themes-api/headers.js';
5
+ import { retry } from '../../../private/node/themes/themes-api/retry.js';
6
6
  import { restRequest } from '@shopify/cli-kit/node/api/admin';
7
7
  import { AbortError } from '@shopify/cli-kit/node/error';
8
8
  export async function fetchTheme(id, session) {