@shopify/cli-kit 3.16.3 → 3.18.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 (220) hide show
  1. package/CHANGELOG.md +26 -0
  2. package/README.md +1 -1
  3. package/assets/success.html +1 -1
  4. package/dist/analytics.d.ts +5 -5
  5. package/dist/analytics.js +5 -5
  6. package/dist/analytics.js.map +1 -1
  7. package/dist/api/common.d.ts +2 -2
  8. package/dist/api/common.js +2 -2
  9. package/dist/api/common.js.map +1 -1
  10. package/dist/api/graphql/index.d.ts +0 -2
  11. package/dist/api/graphql/index.js +0 -2
  12. package/dist/api/graphql/index.js.map +1 -1
  13. package/dist/api/oxygen.d.ts +5 -0
  14. package/dist/api/oxygen.js +30 -0
  15. package/dist/api/oxygen.js.map +1 -0
  16. package/dist/api/partners.d.ts +7 -7
  17. package/dist/api/partners.js +7 -7
  18. package/dist/api/partners.js.map +1 -1
  19. package/dist/api.d.ts +2 -2
  20. package/dist/api.js +2 -2
  21. package/dist/api.js.map +1 -1
  22. package/dist/common/object.d.ts +3 -3
  23. package/dist/common/object.js +3 -3
  24. package/dist/common/object.js.map +1 -1
  25. package/dist/content-tokens.js.map +1 -1
  26. package/dist/environment/fqdn.d.ts +3 -3
  27. package/dist/environment/fqdn.js +3 -3
  28. package/dist/environment/fqdn.js.map +1 -1
  29. package/dist/environment/local.d.ts +13 -13
  30. package/dist/environment/local.js +16 -16
  31. package/dist/environment/local.js.map +1 -1
  32. package/dist/environment/service.d.ts +1 -0
  33. package/dist/environment/service.js +3 -0
  34. package/dist/environment/service.js.map +1 -1
  35. package/dist/environment/spin.d.ts +12 -12
  36. package/dist/environment/spin.js +12 -12
  37. package/dist/environment/spin.js.map +1 -1
  38. package/dist/environment/utilities.d.ts +0 -2
  39. package/dist/environment/utilities.js +0 -2
  40. package/dist/environment/utilities.js.map +1 -1
  41. package/dist/environment.d.ts +3 -1
  42. package/dist/environment.js +3 -1
  43. package/dist/environment.js.map +1 -1
  44. package/dist/error.d.ts +1 -1
  45. package/dist/error.js +4 -3
  46. package/dist/error.js.map +1 -1
  47. package/dist/file.d.ts +17 -18
  48. package/dist/file.js +17 -18
  49. package/dist/file.js.map +1 -1
  50. package/dist/git.d.ts +1 -1
  51. package/dist/git.js +5 -2
  52. package/dist/git.js.map +1 -1
  53. package/dist/http/fetch.d.ts +2 -2
  54. package/dist/http/fetch.js +2 -2
  55. package/dist/http/fetch.js.map +1 -1
  56. package/dist/http.d.ts +1 -1
  57. package/dist/http.js +1 -1
  58. package/dist/http.js.map +1 -1
  59. package/dist/id.d.ts +1 -1
  60. package/dist/id.js +1 -1
  61. package/dist/id.js.map +1 -1
  62. package/dist/network/service.d.ts +0 -2
  63. package/dist/network/service.js +0 -1
  64. package/dist/network/service.js.map +1 -1
  65. package/dist/node/archiver.d.ts +2 -2
  66. package/dist/node/archiver.js +2 -2
  67. package/dist/node/archiver.js.map +1 -1
  68. package/dist/node/checksum.d.ts +2 -2
  69. package/dist/node/checksum.js +2 -2
  70. package/dist/node/checksum.js.map +1 -1
  71. package/dist/node/cli.d.ts +1 -2
  72. package/dist/node/cli.js +2 -8
  73. package/dist/node/cli.js.map +1 -1
  74. package/dist/node/colors.d.ts +2 -1
  75. package/dist/node/colors.js +2 -7
  76. package/dist/node/colors.js.map +1 -1
  77. package/dist/node/dot-env.d.ts +7 -7
  78. package/dist/node/dot-env.js +7 -7
  79. package/dist/node/dot-env.js.map +1 -1
  80. package/dist/node/framework.d.ts +2 -2
  81. package/dist/node/framework.js +2 -2
  82. package/dist/node/framework.js.map +1 -1
  83. package/dist/node/hooks/prerun.js +6 -6
  84. package/dist/node/hooks/prerun.js.map +1 -1
  85. package/dist/node/node-package-manager.d.ts +32 -28
  86. package/dist/node/node-package-manager.js +29 -29
  87. package/dist/node/node-package-manager.js.map +1 -1
  88. package/dist/node/ruby.d.ts +4 -4
  89. package/dist/node/ruby.js +5 -5
  90. package/dist/node/ruby.js.map +1 -1
  91. package/dist/os.d.ts +1 -1
  92. package/dist/os.js +1 -1
  93. package/dist/os.js.map +1 -1
  94. package/dist/output.d.ts +26 -34
  95. package/dist/output.js +23 -143
  96. package/dist/output.js.map +1 -1
  97. package/dist/path.d.ts +4 -4
  98. package/dist/path.js +4 -4
  99. package/dist/path.js.map +1 -1
  100. package/dist/plugins.d.ts +4 -4
  101. package/dist/plugins.js +4 -4
  102. package/dist/plugins.js.map +1 -1
  103. package/dist/port.d.ts +1 -1
  104. package/dist/port.js +1 -1
  105. package/dist/port.js.map +1 -1
  106. package/dist/private/node/ui/alert.d.ts +2 -0
  107. package/dist/private/node/ui/alert.js +18 -0
  108. package/dist/private/node/ui/alert.js.map +1 -0
  109. package/dist/private/node/ui/components/Alert.d.ts +17 -0
  110. package/dist/private/node/ui/components/Alert.js +21 -0
  111. package/dist/private/node/ui/components/Alert.js.map +1 -0
  112. package/dist/private/node/ui/components/Banner.d.ts +7 -0
  113. package/dist/private/node/ui/components/Banner.js +35 -0
  114. package/dist/private/node/ui/components/Banner.js.map +1 -0
  115. package/dist/private/node/ui/components/Command.d.ts +9 -0
  116. package/dist/private/node/ui/components/Command.js +10 -0
  117. package/dist/private/node/ui/components/Command.js.map +1 -0
  118. package/dist/private/node/ui/components/ConcurrentOutput.d.ts +48 -0
  119. package/dist/private/node/ui/components/ConcurrentOutput.js +98 -0
  120. package/dist/private/node/ui/components/ConcurrentOutput.js.map +1 -0
  121. package/dist/private/node/ui/components/Error.d.ts +8 -0
  122. package/dist/private/node/ui/components/Error.js +13 -0
  123. package/dist/private/node/ui/components/Error.js.map +1 -0
  124. package/dist/private/node/ui/components/FatalError.d.ts +7 -0
  125. package/dist/private/node/ui/components/FatalError.js +42 -0
  126. package/dist/private/node/ui/components/FatalError.js.map +1 -0
  127. package/dist/private/node/ui/components/FullScreen.d.ts +8 -0
  128. package/dist/private/node/ui/components/FullScreen.js +32 -0
  129. package/dist/private/node/ui/components/FullScreen.js.map +1 -0
  130. package/dist/private/node/ui/components/Link.d.ts +10 -0
  131. package/dist/private/node/ui/components/Link.js +14 -0
  132. package/dist/private/node/ui/components/Link.js.map +1 -0
  133. package/dist/private/node/ui/components/List.d.ts +13 -0
  134. package/dist/private/node/ui/components/List.js +19 -0
  135. package/dist/private/node/ui/components/List.js.map +1 -0
  136. package/dist/private/node/ui/components/TextAnimation.d.ts +11 -0
  137. package/dist/private/node/ui/components/TextAnimation.js +46 -0
  138. package/dist/private/node/ui/components/TextAnimation.js.map +1 -0
  139. package/dist/private/node/ui/components/TokenizedText.d.ts +21 -0
  140. package/dist/private/node/ui/components/TokenizedText.js +26 -0
  141. package/dist/private/node/ui/components/TokenizedText.js.map +1 -0
  142. package/dist/private/node/ui/error.d.ts +4 -0
  143. package/dist/private/node/ui/error.js +12 -0
  144. package/dist/private/node/ui/error.js.map +1 -0
  145. package/dist/private/node/ui.d.ts +10 -0
  146. package/dist/private/node/ui.js +47 -0
  147. package/dist/private/node/ui.js.map +1 -0
  148. package/dist/public/common/array.d.ts +4 -4
  149. package/dist/public/common/array.js +4 -4
  150. package/dist/public/common/array.js.map +1 -1
  151. package/dist/public/node/ui.d.ts +155 -0
  152. package/dist/public/node/ui.js +163 -0
  153. package/dist/public/node/ui.js.map +1 -0
  154. package/dist/secure-store.d.ts +4 -4
  155. package/dist/secure-store.js +4 -4
  156. package/dist/secure-store.js.map +1 -1
  157. package/dist/session/device-authorization.d.ts +5 -5
  158. package/dist/session/device-authorization.js +5 -5
  159. package/dist/session/device-authorization.js.map +1 -1
  160. package/dist/session/exchange.d.ts +10 -16
  161. package/dist/session/exchange.js +10 -16
  162. package/dist/session/exchange.js.map +1 -1
  163. package/dist/session/post-auth.js +2 -2
  164. package/dist/session/post-auth.js.map +1 -1
  165. package/dist/session/redirect-listener.js +1 -1
  166. package/dist/session/redirect-listener.js.map +1 -1
  167. package/dist/session/schema.d.ts +3 -2
  168. package/dist/session/schema.js +3 -2
  169. package/dist/session/schema.js.map +1 -1
  170. package/dist/session/scopes.d.ts +3 -3
  171. package/dist/session/scopes.js +3 -3
  172. package/dist/session/scopes.js.map +1 -1
  173. package/dist/session/store.d.ts +2 -2
  174. package/dist/session/store.js +2 -2
  175. package/dist/session/store.js.map +1 -1
  176. package/dist/session/token.d.ts +1 -1
  177. package/dist/session/token.js +1 -1
  178. package/dist/session/token.js.map +1 -1
  179. package/dist/session/validate.d.ts +4 -4
  180. package/dist/session/validate.js +4 -7
  181. package/dist/session/validate.js.map +1 -1
  182. package/dist/session.d.ts +10 -10
  183. package/dist/session.js +12 -12
  184. package/dist/session.js.map +1 -1
  185. package/dist/string.d.ts +2 -2
  186. package/dist/string.js +2 -2
  187. package/dist/string.js.map +1 -1
  188. package/dist/system.d.ts +6 -9
  189. package/dist/system.js +23 -23
  190. package/dist/system.js.map +1 -1
  191. package/dist/template.d.ts +3 -3
  192. package/dist/template.js +3 -3
  193. package/dist/template.js.map +1 -1
  194. package/dist/testing/fixtures/render-concurrent.d.ts +1 -0
  195. package/dist/testing/fixtures/render-concurrent.js +28 -0
  196. package/dist/testing/fixtures/render-concurrent.js.map +1 -0
  197. package/dist/testing/output.d.ts +1 -0
  198. package/dist/testing/output.js +1 -0
  199. package/dist/testing/output.js.map +1 -1
  200. package/dist/testing/store.d.ts +2 -2
  201. package/dist/testing/store.js +2 -2
  202. package/dist/testing/store.js.map +1 -1
  203. package/dist/testing/ui.d.ts +8 -0
  204. package/dist/testing/ui.js +17 -0
  205. package/dist/testing/ui.js.map +1 -0
  206. package/dist/tsconfig.tsbuildinfo +1 -1
  207. package/dist/ui/inquirer/input.d.ts +1 -1
  208. package/dist/ui.d.ts +1 -1
  209. package/dist/ui.js +17 -8
  210. package/dist/ui.js.map +1 -1
  211. package/dist/version.d.ts +3 -3
  212. package/dist/version.js +3 -3
  213. package/dist/version.js.map +1 -1
  214. package/package.json +9 -2
  215. package/dist/api/graphql/functions/compile_module.d.ts +0 -15
  216. package/dist/api/graphql/functions/compile_module.js +0 -13
  217. package/dist/api/graphql/functions/compile_module.js.map +0 -1
  218. package/dist/api/graphql/functions/module_compilation_status.d.ts +0 -15
  219. package/dist/api/graphql/functions/module_compilation_status.js +0 -13
  220. package/dist/api/graphql/functions/module_compilation_status.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"cli.js","sourceRoot":"","sources":["../../src/node/cli.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAQH,SAAS,yBAAyB,CAAC,OAA2C;IAC5E;;;;OAIG;IACH,IAAI,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,WAAW,CAAC,EAAE;QACtC,OAAO,CAAC,GAAG,CAAC,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,KAAK,IAAI,GAAG,CAAA;KAC7C;IACD,IAAI,OAAO,CAAC,WAAW,EAAE;QACvB,OAAO,CAAC,GAAG,CAAC,eAAe,GAAG,OAAO,CAAC,GAAG,CAAC,eAAe,IAAI,aAAa,CAAA;KAC3E;AACH,CAAC;AAED;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,MAAM,CAAC,OAAsB;IACjD,yBAAyB,CAAC,OAAO,CAAC,CAAA;IAClC;;;;OAIG;IACH,MAAM,EAAC,YAAY,EAAC,GAAG,MAAM,MAAM,CAAC,oBAAoB,CAAC,CAAA;IACzD,MAAM,EAAC,aAAa,EAAC,GAAG,MAAM,MAAM,CAAC,yBAAyB,CAAC,CAAA;IAC/D,MAAM,EAAC,GAAG,EAAE,QAAQ,EAAE,KAAK,EAAC,GAAG,MAAM,MAAM,CAAC,aAAa,CAAC,CAAA;IAE1D,IAAI,aAAa,EAAE,EAAE;QACnB,QAAQ,CAAC,KAAK,GAAG,IAAI,CAAA;KACtB;IAED,GAAG,CAAC,SAAS,EAAE,OAAO,CAAC,SAAS,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,YAAY,CAAC,CAAA;AACnE,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,YAAY,CAAC,OAAsB;IACvD,yBAAyB,CA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,IAAI,aAAa,GAAG,EAAE,CAAA;IACtB,IAAI,eAAe,GAAgB,EAAE,CAAA;IACrC,IAAI;QACF,aAAa,GAAG,MAAM,aAAa,CAAC,KAAK,EAAE,CAAC,MAAM,EAAE,cAAc,EAAE,QAAQ,EAAE,IAAI,CAAC,CAAC,CAAA;QACpF,eAAe,GAAG,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC,CAAA;QAC3C,qDAAqD;KACtD;IAAC,OAAO,GAAG,EAAE;QACZ,OAAM;KACP;IACD,MAAM,gBAAgB,GAAG;QACvB,GAAG,eAAe,CAAC,gBAAgB;QACnC,GAAG,eAAe,CAAC,eAAe;QAClC,GAAG,eAAe,CAAC,YAAY;KAChC,CAAA;IACD,OAAO,gBAAgB,CAAC,cAAc,CAAC,CAAA;AACzC,CAAC;AAED,eAAe,MAAM,CAAA","sourcesContent":["/**\n * IMPORTANT NOTE: Imports in this module are dynamic to ensure that \"setupEnvironmentVariables\" can dynamically\n * set the DEBUG environment variable before the 'debug' package sets up its configuration when modules\n * are loaded statically.\n */\n\ninterface RunCLIOptions {\n /** The value of import.meta.url of the CLI executable module */\n moduleURL: string\n development: boolean\n}\n\nfunction setupEnvironmentVariables(options: Pick<RunCLIOptions, 'development'>) {\n /**\n * By setting DEBUG=* when --verbose is passed we are increasing the\n * verbosity of oclif. Oclif uses debug (https://www.npmjs.com/package/debug)\n * for logging, and it's configured through the DEBUG= environment variable.\n */\n if (process.argv.includes('--verbose')) {\n process.env.DEBUG = process.env.DEBUG ?? '*'\n }\n if (options.development) {\n process.env.SHOPIFY_CLI_ENV = process.env.SHOPIFY_CLI_ENV ?? 'development'\n }\n}\n\n/**\n * A function that abstracts away setting up the environment and running\n * a CLI\n * @param options {RunCLIOptions} Options.\n */\nexport async function runCLI(options: RunCLIOptions) {\n setupEnvironmentVariables(options)\n /**\n * These imports need to be dynamic because if they are static\n * they are loaded before se set the DEBUG=* environment variable\n * and therefore it has no effect.\n */\n const {errorHandler} = await import('./error-handler.js')\n const {isDevelopment} = await import('../environment/local.js')\n const {run, settings, flush} = await import('@oclif/core')\n\n if (isDevelopment()) {\n settings.debug = true\n }\n\n run(undefined, options.moduleURL).then(flush).catch(errorHandler)\n}\n\n/**\n * A function for create-x CLIs that automatically runs the \"init\" command.\n * @param options\n */\nexport async function runCreateCLI(options: RunCLIOptions) {\n setupEnvironmentVariables(options)\n\n const {findUpAndReadPackageJson} = await import('./node-package-manager.js')\n const {moduleDirectory} = await import('../path.js')\n\n const packageJson = await findUpAndReadPackageJson(moduleDirectory(options.moduleURL))\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const packageName = (packageJson.content as any).name as string\n const name = packageName.replace('@shopify/create-', '')\n const initIndex = process.argv.findIndex((arg) => arg.includes('init'))\n if (initIndex === -1) {\n const initIndex =\n process.argv.findIndex((arg) => arg.match(new RegExp(`bin(\\\\/|\\\\\\\\)+(create-${name}|dev|run)`))) + 1\n process.argv.splice(initIndex, 0, 'init')\n }\n await runCLI(options)\n}\n\nexport async function useLocalCLIIfDetected(filepath: string): Promise<boolean> {\n const {isTruthy} = await import('../environment/utilities.js')\n const constants = await import('../constants.js')\n const {join} = await import('../path.js')\n const {exec} = await import('../system.js')\n\n // Temporary flag while we test out this feature and ensure it won't break anything!\n if (!isTruthy(process.env[constants.default.environmentVariables.enableCliRedirect])) return false\n\n // Setting an env variable in the child process prevents accidental recursion.\n if (isTruthy(process.env[constants.default.environmentVariables.skipCliRedirect])) return false\n\n // If already running via package manager, we can assume it's running correctly already.\n if (process.env.npm_config_user_agent) return false\n\n const cliPackage = await localCliPackage()\n if (!cliPackage) return false\n\n const correctExecutablePath = join(cliPackage.path, cliPackage.bin.shopify)\n if (correctExecutablePath === filepath) return false\n try {\n await exec(correctExecutablePath, process.argv.slice(2, process.argv.length), {\n stdio: 'inherit',\n env: {[constants.default.environmentVariables.skipCliRedirect]: '1'},\n })\n // eslint-disable-next-line no-catch-all/no-catch-all, @typescript-eslint/no-explicit-any\n } catch (processError: any) {\n process.exit(processError.exitCode)\n }\n return true\n}\n\ninterface CliPackageInfo {\n path: string\n bin: {shopify: string}\n}\n\ninterface PackageJSON {\n dependencies?: {[packageName: string]: CliPackageInfo}\n devDependencies?: {[packageName: string]: CliPackageInfo}\n peerDependencies?: {[packageName: string]: CliPackageInfo}\n}\n\nexport async function localCliPackage(): Promise<CliPackageInfo | undefined> {\n const {captureOutput} = await import('../system.js')\n\n let npmListOutput = ''\n let localShopifyCLI: PackageJSON = {}\n try {\n npmListOutput = await captureOutput('npm', ['list', '@shopify/cli', '--json', '-l'])\n localShopifyCLI = JSON.parse(npmListOutput)\n // eslint-disable-next-line no-catch-all/no-catch-all\n } catch (err) {\n return\n }\n const dependenciesList = {\n ...localShopifyCLI.peerDependencies,\n ...localShopifyCLI.devDependencies,\n ...localShopifyCLI.dependencies,\n }\n return dependenciesList['@shopify/cli']\n}\n\nexport default runCLI\n"]}
1
+ {"version":3,"file":"cli.js","sourceRoot":"","sources":["../../src/node/cli.ts"],"names":[],"mappings":"AAWA,SAAS,yBAAyB,CAAC,OAA2C;IAC5E;;;;OAIG;IACH,IAAI,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,WAAW,CAAC,EAAE;QACtC,OAAO,CAAC,GAAG,CAAC,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,KAAK,IAAI,GAAG,CAAA;KAC7C;IACD,IAAI,OAAO,CAAC,WAAW,EAAE;QACvB,OAAO,CAAC,GAAG,CAAC,eAAe,GAAG,OAAO,CAAC,GAAG,CAAC,eAAe,IAAI,aAAa,CAAA;KAC3E;AACH,CAAC;AAED;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,MAAM,CAAC,OAAsB;IACjD,yBAAyB,CAAC,OAAO,CAAC,CAAA;IAClC;;;;OAIG;IACH,MAAM,EAAC,YAAY,EAAC,GAAG,MAAM,MAAM,CAAC,oBAAoB,CAAC,CAAA;IACzD,MAAM,EAAC,aAAa,EAAC,GAAG,MAAM,MAAM,CAAC,yB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;YAC5E,KAAK,EAAE,SAAS;YAChB,GAAG,EAAE,EAAC,CAAC,SAAS,CAAC,OAAO,CAAC,oBAAoB,CAAC,eAAe,CAAC,EAAE,GAAG,EAAC;SACrE,CAAC,CAAA;QACF,yFAAyF;KAC1F;IAAC,OAAO,YAAiB,EAAE;QAC1B,OAAO,CAAC,IAAI,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAA;KACpC;IACD,OAAO,IAAI,CAAA;AACb,CAAC;AAaD,MAAM,CAAC,KAAK,UAAU,eAAe;IACnC,MAAM,EAAC,aAAa,EAAC,GAAG,MAAM,MAAM,CAAC,cAAc,CAAC,CAAA;IAEpD,IAAI,aAAa,GAAG,EAAE,CAAA;IACtB,IAAI,eAAe,GAAgB,EAAE,CAAA;IACrC,IAAI;QACF,aAAa,GAAG,MAAM,aAAa,CAAC,KAAK,EAAE,CAAC,MAAM,EAAE,cAAc,EAAE,QAAQ,EAAE,IAAI,CAAC,CAAC,CAAA;QACpF,eAAe,GAAG,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC,CAAA;QAC3C,qDAAqD;KACtD;IAAC,OAAO,GAAG,EAAE;QACZ,OAAM;KACP;IACD,MAAM,gBAAgB,GAAG;QACvB,GAAG,eAAe,CAAC,gBAAgB;QACnC,GAAG,eAAe,CAAC,eAAe;QAClC,GAAG,eAAe,CAAC,YAAY;KAChC,CAAA;IACD,OAAO,gBAAgB,CAAC,cAAc,CAAC,CAAA;AACzC,CAAC;AAED,eAAe,MAAM,CAAA","sourcesContent":["/**\n * IMPORTANT NOTE: Imports in this module are dynamic to ensure that \"setupEnvironmentVariables\" can dynamically\n * set the DEBUG environment variable before the 'debug' package sets up its configuration when modules\n * are loaded statically.\n */\ninterface RunCLIOptions {\n /** The value of import.meta.url of the CLI executable module */\n moduleURL: string\n development: boolean\n}\n\nfunction setupEnvironmentVariables(options: Pick<RunCLIOptions, 'development'>) {\n /**\n * By setting DEBUG=* when --verbose is passed we are increasing the\n * verbosity of oclif. Oclif uses debug (https://www.npmjs.com/package/debug)\n * for logging, and it's configured through the DEBUG= environment variable.\n */\n if (process.argv.includes('--verbose')) {\n process.env.DEBUG = process.env.DEBUG ?? '*'\n }\n if (options.development) {\n process.env.SHOPIFY_CLI_ENV = process.env.SHOPIFY_CLI_ENV ?? 'development'\n }\n}\n\n/**\n * A function that abstracts away setting up the environment and running\n * a CLI\n * @param options - Options.\n */\nexport async function runCLI(options: RunCLIOptions) {\n setupEnvironmentVariables(options)\n /**\n * These imports need to be dynamic because if they are static\n * they are loaded before we set the DEBUG=* environment variable\n * and therefore it has no effect.\n */\n const {errorHandler} = await import('./error-handler.js')\n const {isDevelopment} = await import('../environment/local.js')\n const {run, settings, flush} = await import('@oclif/core')\n\n if (isDevelopment()) {\n settings.debug = true\n }\n\n run(undefined, options.moduleURL).then(flush).catch(errorHandler)\n}\n\n/**\n * A function for create-x CLIs that automatically runs the \"init\" command.\n */\nexport async function runCreateCLI(options: RunCLIOptions) {\n setupEnvironmentVariables(options)\n\n const {findUpAndReadPackageJson} = await import('./node-package-manager.js')\n const {moduleDirectory} = await import('../path.js')\n\n const packageJson = await findUpAndReadPackageJson(moduleDirectory(options.moduleURL))\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const packageName = (packageJson.content as any).name as string\n const name = packageName.replace('@shopify/create-', '')\n const initIndex = process.argv.findIndex((arg) => arg.includes('init'))\n if (initIndex === -1) {\n const initIndex =\n process.argv.findIndex((arg) => arg.match(new RegExp(`bin(\\\\/|\\\\\\\\)+(create-${name}|dev|run)`))) + 1\n process.argv.splice(initIndex, 0, 'init')\n }\n await runCLI(options)\n}\n\nexport async function useLocalCLIIfDetected(filepath: string): Promise<boolean> {\n const {isTruthy} = await import('../environment/utilities.js')\n const constants = await import('../constants.js')\n const {join} = await import('../path.js')\n const {exec} = await import('../system.js')\n\n // Temporary flag while we test out this feature and ensure it won't break anything!\n if (!isTruthy(process.env[constants.default.environmentVariables.enableCliRedirect])) return false\n\n // Setting an env variable in the child process prevents accidental recursion.\n if (isTruthy(process.env[constants.default.environmentVariables.skipCliRedirect])) return false\n\n // If already running via package manager, we can assume it's running correctly already.\n if (process.env.npm_config_user_agent) return false\n\n const cliPackage = await localCliPackage()\n if (!cliPackage) return false\n\n const correctExecutablePath = join(cliPackage.path, cliPackage.bin.shopify)\n if (correctExecutablePath === filepath) return false\n try {\n await exec(correctExecutablePath, process.argv.slice(2, process.argv.length), {\n stdio: 'inherit',\n env: {[constants.default.environmentVariables.skipCliRedirect]: '1'},\n })\n // eslint-disable-next-line no-catch-all/no-catch-all, @typescript-eslint/no-explicit-any\n } catch (processError: any) {\n process.exit(processError.exitCode)\n }\n return true\n}\n\ninterface CliPackageInfo {\n path: string\n bin: {shopify: string}\n}\n\ninterface PackageJSON {\n dependencies?: {[packageName: string]: CliPackageInfo}\n devDependencies?: {[packageName: string]: CliPackageInfo}\n peerDependencies?: {[packageName: string]: CliPackageInfo}\n}\n\nexport async function localCliPackage(): Promise<CliPackageInfo | undefined> {\n const {captureOutput} = await import('../system.js')\n\n let npmListOutput = ''\n let localShopifyCLI: PackageJSON = {}\n try {\n npmListOutput = await captureOutput('npm', ['list', '@shopify/cli', '--json', '-l'])\n localShopifyCLI = JSON.parse(npmListOutput)\n // eslint-disable-next-line no-catch-all/no-catch-all\n } catch (err) {\n return\n }\n const dependenciesList = {\n ...localShopifyCLI.peerDependencies,\n ...localShopifyCLI.devDependencies,\n ...localShopifyCLI.dependencies,\n }\n return dependenciesList['@shopify/cli']\n}\n\nexport default runCLI\n"]}
@@ -1 +1,2 @@
1
- export declare const colors: any;
1
+ import chalk from 'chalk';
2
+ export { chalk as colors };
@@ -1,8 +1,3 @@
1
- import { createRequire } from 'module';
2
- /**
3
- * ansi-colors is a commonjs dependency that can be imported as a module.
4
- * This file is a wrapper to require and export ansi-colors.
5
- */
6
- const require = createRequire(import.meta.url);
7
- export const colors = require('ansi-colors');
1
+ import chalk from 'chalk';
2
+ export { chalk as colors };
8
3
  //# sourceMappingURL=colors.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"colors.js","sourceRoot":"","sources":["../../src/node/colors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,aAAa,EAAC,MAAM,QAAQ,CAAA;AAEpC;;;GAGG;AACH,MAAM,OAAO,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;AAC9C,MAAM,CAAC,MAAM,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC,CAAA","sourcesContent":["import {createRequire} from 'module'\n\n/**\n * ansi-colors is a commonjs dependency that can be imported as a module.\n * This file is a wrapper to require and export ansi-colors.\n */\nconst require = createRequire(import.meta.url)\nexport const colors = require('ansi-colors')\n"]}
1
+ {"version":3,"file":"colors.js","sourceRoot":"","sources":["../../src/node/colors.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,OAAO,EAAC,KAAK,IAAI,MAAM,EAAC,CAAA","sourcesContent":["import chalk from 'chalk'\n\nexport {chalk as colors}\n"]}
@@ -1,8 +1,8 @@
1
1
  import { Abort } from '../error.js';
2
2
  /**
3
3
  * Error that's thrown when the .env is not found.
4
- * @param path {string} Path to the .env file.
5
- * @returns {Abort} An abort error.
4
+ * @param path - Path to the .env file.
5
+ * @returns An abort error.
6
6
  */
7
7
  export declare const DotEnvNotFoundError: (path: string) => Abort;
8
8
  /**
@@ -22,20 +22,20 @@ export interface DotEnvFile {
22
22
  }
23
23
  /**
24
24
  * Reads and parses a .env file.
25
- * @param path {string} Path to the .env file
26
- * @returns {Promise<DotEnvFile>} An in-memory representation of the .env file.
25
+ * @param path - Path to the .env file
26
+ * @returns An in-memory representation of the .env file.
27
27
  */
28
28
  export declare function readAndParseDotEnv(path: string): Promise<DotEnvFile>;
29
29
  /**
30
30
  * Writes a .env file to disk.
31
- * @param file {DotEnvFile} .env file to be written.
31
+ * @param file - .env file to be written.
32
32
  */
33
33
  export declare function writeDotEnv(file: DotEnvFile): Promise<void>;
34
34
  /**
35
35
  * Given an .env file content, generates a new one with new values
36
36
  * without removing already existing lines.
37
- * @param envFileContent {string | null} .env file contents.
38
- * @param updatedValues {[key: string]: string}} object containing new env variables values.
37
+ * @param envFileContent - .env file contents.
38
+ * @param updatedValues - object containing new env variables values.
39
39
  */
40
40
  export declare function patchEnvFile(envFileContent: string | null, updatedValues: {
41
41
  [key: string]: string | undefined;
@@ -4,16 +4,16 @@ import { debug, content as outputContent, token } from '../output.js';
4
4
  import { parse, stringify } from 'envfile';
5
5
  /**
6
6
  * Error that's thrown when the .env is not found.
7
- * @param path {string} Path to the .env file.
8
- * @returns {Abort} An abort error.
7
+ * @param path - Path to the .env file.
8
+ * @returns An abort error.
9
9
  */
10
10
  export const DotEnvNotFoundError = (path) => {
11
11
  return new Abort(`The environment file at ${path} does not exist.`);
12
12
  };
13
13
  /**
14
14
  * Reads and parses a .env file.
15
- * @param path {string} Path to the .env file
16
- * @returns {Promise<DotEnvFile>} An in-memory representation of the .env file.
15
+ * @param path - Path to the .env file
16
+ * @returns An in-memory representation of the .env file.
17
17
  */
18
18
  export async function readAndParseDotEnv(path) {
19
19
  debug(outputContent `Reading the .env file at ${token.path(path)}`);
@@ -28,7 +28,7 @@ export async function readAndParseDotEnv(path) {
28
28
  }
29
29
  /**
30
30
  * Writes a .env file to disk.
31
- * @param file {DotEnvFile} .env file to be written.
31
+ * @param file - .env file to be written.
32
32
  */
33
33
  export async function writeDotEnv(file) {
34
34
  await writeFile(file.path, stringify(file.variables));
@@ -36,8 +36,8 @@ export async function writeDotEnv(file) {
36
36
  /**
37
37
  * Given an .env file content, generates a new one with new values
38
38
  * without removing already existing lines.
39
- * @param envFileContent {string | null} .env file contents.
40
- * @param updatedValues {[key: string]: string}} object containing new env variables values.
39
+ * @param envFileContent - .env file contents.
40
+ * @param updatedValues - object containing new env variables values.
41
41
  */
42
42
  export function patchEnvFile(envFileContent, updatedValues) {
43
43
  const outputLines = [];
@@ -1 +1 @@
1
- {"version":3,"file":"dot-env.js","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AAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,cAAc,CAAC,KAAK,CAAC,IAAI,CAAC,CAAA;IAEvE,MAAM,kBAAkB,GAAa,EAAE,CAAA;IAEvC,MAAM,MAAM,GAAG,CAAC,GAAW,EAAE,KAAc,EAAE,EAAE,CAAC,GAAG,GAAG,IAAI,KAAK,EAAE,CAAA;IAEjE,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE;QACxB,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,qBAAqB,CAAC,CAAA;QAC/C,IAAI,WAAW,GAAG,IAAI,CAAA;QAEtB,IAAI,KAAK,EAAE;YACT,MAAM,GAAG,GAAG,KAAK,CAAC,CAAC,CAAE,CAAC,IAAI,EAAE,CAAA;YAC5B,MAAM,QAAQ,GAAG,aAAa,CAAC,GAAG,CAAC,CAAA;YACnC,IAAI,QAAQ,EAAE;gBACZ,kBAAkB,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;gBAC5B,WAAW,GAAG,MAAM,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAA;aACpC;SACF;QAED,WAAW,CAAC,IAAI,CAAC,WAAW,CAAC,CAAA;KAC9B;IAED,KAAK,MAAM,CAAC,QAAQ,EAAE,YAAY,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,aAAa,CAAC,EAAE;QACpE,IAAI,CAAC,kBAAkB,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE;YAC1C,WAAW,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,EAAE,YAAY,CAAC,CAAC,CAAA;SACjD;KACF;IAED,OAAO,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;AAC/B,CAAC","sourcesContent":["import {Abort} from '../error.js'\nimport {exists, read as readFile, write as writeFile} from '../file.js'\nimport {debug, content as outputContent, token} from '../output.js'\nimport {parse, stringify} from 'envfile'\n\n/**\n * Error that's thrown when the .env is not found.\n * @param path {string} Path to the .env file.\n * @returns {Abort} An abort error.\n */\nexport const DotEnvNotFoundError = (path: string) => {\n return new Abort(`The environment file at ${path} does not exist.`)\n}\n\n/**\n * This interface represents a .env file.\n */\nexport interface DotEnvFile {\n /**\n * Path to the .env file.\n */\n path: string\n /**\n * Variables of the .env file.\n */\n variables: {[name: string]: string}\n}\n\n/**\n * Reads and parses a .env file.\n * @param path {string} Path to the .env file\n * @returns {Promise<DotEnvFile>} An in-memory representation of the .env file.\n */\nexport async function readAndParseDotEnv(path: string): Promise<DotEnvFile> {\n debug(outputContent`Reading the .env file at ${token.path(path)}`)\n if (!(await exists(path))) {\n throw DotEnvNotFoundError(path)\n }\n const content = await readFile(path)\n return {\n path,\n variables: parse(content),\n }\n}\n\n/**\n * Writes a .env file to disk.\n * @param file {DotEnvFile} .env file to be written.\n */\nexport async function writeDotEnv(file: DotEnvFile) {\n await writeFile(file.path, stringify(file.variables))\n}\n\n/**\n * Given an .env file content, generates a new one with new values\n * without removing already existing lines.\n * @param envFileContent {string | null} .env file contents.\n * @param updatedValues {[key: string]: string}} object containing new env variables values.\n */\nexport function patchEnvFile(\n envFileContent: string | null,\n updatedValues: {[key: string]: string | undefined},\n): string {\n const outputLines: string[] = []\n const lines = envFileContent === null ? [] : envFileContent.split('\\n')\n\n const alreadyPresentKeys: string[] = []\n\n const toLine = (key: string, value?: string) => `${key}=${value}`\n\n for (const line of lines) {\n const match = line.match(/^([^=:#]+?)[=:](.*)/)\n let lineToWrite = line\n\n if (match) {\n const key = match[1]!.trim()\n const newValue = updatedValues[key]\n if (newValue) {\n alreadyPresentKeys.push(key)\n lineToWrite = toLine(key, newValue)\n }\n }\n\n outputLines.push(lineToWrite)\n }\n\n for (const [patchKey, updatedValue] of Object.entries(updatedValues)) {\n if (!alreadyPresentKeys.includes(patchKey)) {\n outputLines.push(toLine(patchKey, updatedValue))\n }\n }\n\n return outputLines.join('\\n')\n}\n"]}
1
+ {"version":3,"file":"dot-env.js","sourceRoot":"","sources":["../../src/node/dot-env.ts"],"names":[],"mapp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AC,cAAc,CAAC,KAAK,CAAC,IAAI,CAAC,CAAA;IAEvE,MAAM,kBAAkB,GAAa,EAAE,CAAA;IAEvC,MAAM,MAAM,GAAG,CAAC,GAAW,EAAE,KAAc,EAAE,EAAE,CAAC,GAAG,GAAG,IAAI,KAAK,EAAE,CAAA;IAEjE,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE;QACxB,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,qBAAqB,CAAC,CAAA;QAC/C,IAAI,WAAW,GAAG,IAAI,CAAA;QAEtB,IAAI,KAAK,EAAE;YACT,MAAM,GAAG,GAAG,KAAK,CAAC,CAAC,CAAE,CAAC,IAAI,EAAE,CAAA;YAC5B,MAAM,QAAQ,GAAG,aAAa,CAAC,GAAG,CAAC,CAAA;YACnC,IAAI,QAAQ,EAAE;gBACZ,kBAAkB,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;gBAC5B,WAAW,GAAG,MAAM,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAA;aACpC;SACF;QAED,WAAW,CAAC,IAAI,CAAC,WAAW,CAAC,CAAA;KAC9B;IAED,KAAK,MAAM,CAAC,QAAQ,EAAE,YAAY,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,aAAa,CAAC,EAAE;QACpE,IAAI,CAAC,kBAAkB,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE;YAC1C,WAAW,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,EAAE,YAAY,CAAC,CAAC,CAAA;SACjD;KACF;IAED,OAAO,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;AAC/B,CAAC","sourcesContent":["import {Abort} from '../error.js'\nimport {exists, read as readFile, write as writeFile} from '../file.js'\nimport {debug, content as outputContent, token} from '../output.js'\nimport {parse, stringify} from 'envfile'\n\n/**\n * Error that's thrown when the .env is not found.\n * @param path - Path to the .env file.\n * @returns An abort error.\n */\nexport const DotEnvNotFoundError = (path: string) => {\n return new Abort(`The environment file at ${path} does not exist.`)\n}\n\n/**\n * This interface represents a .env file.\n */\nexport interface DotEnvFile {\n /**\n * Path to the .env file.\n */\n path: string\n /**\n * Variables of the .env file.\n */\n variables: {[name: string]: string}\n}\n\n/**\n * Reads and parses a .env file.\n * @param path - Path to the .env file\n * @returns An in-memory representation of the .env file.\n */\nexport async function readAndParseDotEnv(path: string): Promise<DotEnvFile> {\n debug(outputContent`Reading the .env file at ${token.path(path)}`)\n if (!(await exists(path))) {\n throw DotEnvNotFoundError(path)\n }\n const content = await readFile(path)\n return {\n path,\n variables: parse(content),\n }\n}\n\n/**\n * Writes a .env file to disk.\n * @param file - .env file to be written.\n */\nexport async function writeDotEnv(file: DotEnvFile) {\n await writeFile(file.path, stringify(file.variables))\n}\n\n/**\n * Given an .env file content, generates a new one with new values\n * without removing already existing lines.\n * @param envFileContent - .env file contents.\n * @param updatedValues - object containing new env variables values.\n */\nexport function patchEnvFile(\n envFileContent: string | null,\n updatedValues: {[key: string]: string | undefined},\n): string {\n const outputLines: string[] = []\n const lines = envFileContent === null ? [] : envFileContent.split('\\n')\n\n const alreadyPresentKeys: string[] = []\n\n const toLine = (key: string, value?: string) => `${key}=${value}`\n\n for (const line of lines) {\n const match = line.match(/^([^=:#]+?)[=:](.*)/)\n let lineToWrite = line\n\n if (match) {\n const key = match[1]!.trim()\n const newValue = updatedValues[key]\n if (newValue) {\n alreadyPresentKeys.push(key)\n lineToWrite = toLine(key, newValue)\n }\n }\n\n outputLines.push(lineToWrite)\n }\n\n for (const [patchKey, updatedValue] of Object.entries(updatedValues)) {\n if (!alreadyPresentKeys.includes(patchKey)) {\n outputLines.push(toLine(patchKey, updatedValue))\n }\n }\n\n return outputLines.join('\\n')\n}\n"]}
@@ -2,7 +2,7 @@
2
2
  * Tries to identify the using of a framework analyzing the existence and/or content of different files inside a
3
3
  * specific directory.
4
4
  *
5
- * @param {string} rootDirectory - Directory from which the files required for each framework are searched
6
- * @returns {string} The name of the framework used or 'unknown' otherwise
5
+ * @param rootDirectory - Directory from which the files required for each framework are searched
6
+ * @returns The name of the framework used or 'unknown' otherwise
7
7
  */
8
8
  export declare function resolveFramework(rootDirectory: string): Promise<string>;
@@ -102,8 +102,8 @@ const frameworks = [
102
102
  * Tries to identify the using of a framework analyzing the existence and/or content of different files inside a
103
103
  * specific directory.
104
104
  *
105
- * @param {string} rootDirectory - Directory from which the files required for each framework are searched
106
- * @returns {string} The name of the framework used or 'unknown' otherwise
105
+ * @param rootDirectory - Directory from which the files required for each framework are searched
106
+ * @returns The name of the framework used or 'unknown' otherwise
107
107
  */
108
108
  export async function resolveFramework(rootDirectory) {
109
109
  const fwConfigFiles = {};
@@ -1 +1 @@
1
- {"version":3,"file":"framework.js","sourceRoot":"","sources":["../../src/node/framework.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,IAAI,IAAI,QAAQ,EAAC,MAAM,YAAY,CAAA;AAC3C,OAAO,EAAC,UAAU,EAAE,YAAY,EAAC,MAAM,SAAS,CAAA;AAuChD,MAAM,UAAU,GAAgB;IAC9B;QACE,IAAI,EAAE,OAAO;QACb,SAAS,EAAE;YACT,KAAK,EAAE;gBACL;oBACE,IAAI,EAAE,cAAc;oBACpB,YAAY,EAAE,sEAAsE;iBACrF;gBACD;oBACE,IAAI,EAAE,cAAc;oBACpB,YAAY,EAAE,4DAA4D;iBAC3E;aACF;SACF;KACF;IACD;QACE,IAAI,EAAE,QAAQ;QACd,SAAS,EAAE;YACT,KAAK,EAAE;gBACL;oBACE,IAAI,EAAE,cAAc;oBACpB,YAAY,EAAE,2DAA2D;iBAC1E;gBACD;oBACE,IAAI,EAAE,cAAc;oBACpB,YAAY,EAAE,4DAA4D;iBAC3E;aACF;SACF;KACF;IACD;QACE,IAAI,EAAE,SAAS;QACf,SAAS,EAAE;YACT,KAAK,EAAE;gBACL;oBACE,IAAI,EAAE,cAAc;oBACpB,YAAY,EAAE,8DAA8D;iBAC7E;aACF;SACF;KACF;IACD;QACE,IAAI,EAAE,OAAO;QACb,SA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sBAA+B,EAAE,QAAQ,EAAE,EAAE,CAC5C,sBAAsB;gBACpB,CAAC,CAAC,aAAa,CAAC,QAAQ,EAAE,gBAAgB,CAAC,aAAa,EAAE,QAAQ,CAAC,IAAI,EAAE,aAAa,CAAC,CAAC;gBACxF,CAAC,CAAC,KAAK,EACX,IAAI,CACL,CAAC,CACP,CAAA;IAED,OAAO,gBAAgB,CAAC,CAAC,CAAC,gBAAgB,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,CAAA;AAC7D,CAAC;AAED,SAAS,aAAa,CAAC,QAAmC,EAAE,gBAAqD,EAAE;IACjH,IAAI,CAAC,aAAa,CAAC,QAAQ,CAAC,IAAI,CAAC;QAAE,OAAO,KAAK,CAAA;IAE/C,OAAO,CAAC,QAAQ,CAAC,YAAY,IAAI,IAAI,MAAM,CAAC,QAAQ,CAAC,YAAY,CAAC,CAAC,IAAI,CAAC,aAAa,CAAC,QAAQ,CAAC,IAAI,CAAE,CAAC,CAAA;AACxG,CAAC;AAED,SAAS,gBAAgB,CACvB,QAAgB,EAChB,gBAAwB,EACxB,gBAAqD,EAAE;IAEvD,IAAI,aAAa,CAAC,gBAAgB,CAAC,EAAE;QACnC,OAAO,aAAa,CAAA;KACrB;IAED,MAAM,gBAAgB,GAAG,QAAQ,CAAC,QAAQ,EAAE,gBAAgB,CAAC,CAAA;IAC7D,IAAI,CAAC,UAAU,CAAC,gBAAgB,CAAC,EAAE;QACjC,OAAO,aAAa,CAAA;KACrB;IAED,MAAM,UAAU,GAAG,YAAY,CAAC,gBAAgB,EAAE,EAAC,QAAQ,EAAE,MAAM,EAAC,CAAC,CAAA;IAErE,aAAa,CAAC,gBAAgB,CAAC,GAAG,UAAU,CAAA;IAC5C,OAAO,aAAa,CAAA;AACtB,CAAC","sourcesContent":["import {join as pathJoin} from '../path.js'\nimport {existsSync, readFileSync} from 'node:fs'\n\ninterface FrameworkDetectionPattern {\n /**\n * A file path\n * @example \"package.json\"\n */\n path: string\n /**\n * A matcher\n * @example \"\\\"(dev)?(d|D)ependencies\\\":\\\\s*{[^}]*\\\"next\\\":\\\\s*\\\".+?\\\"[^}]*}\"\n */\n matchContent?: string\n}\n\ninterface Framework {\n /**\n * Name of the framework\n * @example \"nextjs\"\n */\n name: string\n\n /**\n * Detectors used to find out the framework\n */\n detectors: {\n /**\n * Collection of detectors that must be matched for the framework\n * to be detected.\n */\n every?: FrameworkDetectionPattern[]\n /**\n * Collection of detectors where one match triggers the framework\n * to be detected.\n */\n some?: FrameworkDetectionPattern[]\n }\n}\n\nconst frameworks: Framework[] = [\n {\n name: 'remix',\n detectors: {\n every: [\n {\n path: 'package.json',\n matchContent: '\"(dev)?(d|D)ependencies\":\\\\s*{[^}]*\"@remix-run\\\\/.*\":\\\\s*\".+?\"[^}]*}',\n },\n {\n path: 'package.json',\n matchContent: '\"(dev)?(d|D)ependencies\":\\\\s*{[^}]*\"react\":\\\\s*\".+?\"[^}]*}',\n },\n ],\n },\n },\n {\n name: 'nextjs',\n detectors: {\n every: [\n {\n path: 'package.json',\n matchContent: '\"(dev)?(d|D)ependencies\":\\\\s*{[^}]*\"next\":\\\\s*\".+?\"[^}]*}',\n },\n {\n path: 'package.json',\n matchContent: '\"(dev)?(d|D)ependencies\":\\\\s*{[^}]*\"react\":\\\\s*\".+?\"[^}]*}',\n },\n ],\n },\n },\n {\n name: 'express',\n detectors: {\n every: [\n {\n path: 'package.json',\n matchContent: '\"(dev)?(d|D)ependencies\":\\\\s*{[^}]*\"express\":\\\\s*\".+?\"[^}]*}',\n },\n ],\n },\n },\n {\n name: 'rails',\n detectors: {\n every: [\n {\n path: 'Gemfile',\n matchContent: 'gem \"rails\"',\n },\n ],\n },\n },\n {\n name: 'flask',\n detectors: {\n every: [\n {\n path: 'Pipfile',\n matchContent: 'flask',\n },\n ],\n },\n },\n {\n name: 'django',\n detectors: {\n every: [\n {\n path: 'Pipfile',\n matchContent: 'django',\n },\n ],\n },\n },\n {\n name: 'laravel',\n detectors: {\n every: [\n {\n path: 'composer.json',\n matchContent: '\"require\":\\\\s*{[^}]*\"laravel/framework\":\\\\s*\".+?\"[^}]*}',\n },\n ],\n },\n },\n {\n name: 'symfony',\n detectors: {\n every: [\n {\n path: 'composer.json',\n matchContent: '\"require\":\\\\s*{[^}]*\"symfony\\\\/.*\":\\\\s*\".+?\"[^}]*}',\n },\n ],\n },\n },\n]\n\n/**\n * Tries to identify the using of a framework analyzing the existence and/or content of different files inside a\n * specific directory.\n *\n * @param {string} rootDirectory - Directory from which the files required for each framework are searched\n * @returns {string} The name of the framework used or 'unknown' otherwise\n */\nexport async function resolveFramework(rootDirectory: string) {\n const fwConfigFiles: {[key: string]: string | undefined} = {}\n\n const matchedFramework = frameworks.find(\n (framework) =>\n (!framework.detectors?.some ||\n framework.detectors?.some?.reduce(\n (_previousDetectorsMatch: boolean, detector) =>\n matchDetector(detector, loadFwConfigFile(rootDirectory, detector.path, fwConfigFiles)),\n false,\n )) &&\n (!framework.detectors?.every ||\n framework.detectors?.every?.reduce(\n (previousDetectorsMatch: boolean, detector) =>\n previousDetectorsMatch\n ? matchDetector(detector, loadFwConfigFile(rootDirectory, detector.path, fwConfigFiles))\n : false,\n true,\n )),\n )\n\n return matchedFramework ? matchedFramework.name : 'unknown'\n}\n\nfunction matchDetector(detector: FrameworkDetectionPattern, fwConfigFiles: {[key: string]: string | undefined} = {}) {\n if (!fwConfigFiles[detector.path]) return false\n\n return !detector.matchContent || new RegExp(detector.matchContent).test(fwConfigFiles[detector.path]!)\n}\n\nfunction loadFwConfigFile(\n rootPath: string,\n fwConfigFileName: string,\n fwConfigFiles: {[key: string]: string | undefined} = {},\n) {\n if (fwConfigFiles[fwConfigFileName]) {\n return fwConfigFiles\n }\n\n const fwConfigFilePath = pathJoin(rootPath, fwConfigFileName)\n if (!existsSync(fwConfigFilePath)) {\n return fwConfigFiles\n }\n\n const rawContent = readFileSync(fwConfigFilePath, {encoding: 'utf8'})\n\n fwConfigFiles[fwConfigFileName] = rawContent\n return fwConfigFiles\n}\n"]}
1
+ {"version":3,"file":"framework.js","sourceRoot":"","sources":["../../src/node/framework.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,IAAI,IAAI,QAAQ,EAAC,MAAM,YAAY,CAAA;AAC3C,OAAO,EAAC,UAAU,EAAE,YAAY,EAAC,MAAM,SAAS,CAAA;AA2ChD,MAAM,UAAU,GAAgB;IAC9B;QACE,IAAI,EAAE,OAAO;QACb,SAAS,EAAE;YACT,KAAK,EAAE;gBACL;oBACE,IAAI,EAAE,cAAc;oBACpB,YAAY,EAAE,sEAAsE;iBACrF;gBACD;oBACE,IAAI,EAAE,cAAc;oBACpB,YAAY,EAAE,4DAA4D;iBAC3E;aACF;SACF;KACF;IACD;QACE,IAAI,EAAE,QAAQ;QACd,SAAS,EAAE;YACT,KAAK,EAAE;gBACL;oBACE,IAAI,EAAE,cAAc;oBACpB,YAAY,EAAE,2DAA2D;iBAC1E;gBACD;oBACE,IAAI,EAAE,cAAc;oBACpB,YAAY,EAAE,4DAA4D;iBAC3E;aACF;SACF;KACF;IACD;QACE,IAAI,EAAE,SAAS;QACf,SAAS,EAAE;YACT,KAAK,EAAE;gBACL;oBACE,IAAI,EAAE,cAAc;oBACpB,YAAY,EAAE,8DAA8D;iBAC7E;aACF;SACF;KACF;IACD;QACE,IAAI,EAAE,OAAO;QACb,SAAS,EAAE;YACT,KAAK,EAAE;gBACL;oBACE,IAAI,EAAE,SAAS;oBACf,YAAY,EAAE,aAAa;iBAC5B;aACF;SACF;KACF;IACD;QACE,IAAI,EAAE,OAAO;QACb,SAAS,EAAE;YACT,KAAK,EAAE;gBACL;oBACE,IAAI,EAAE,SAAS;oBACf,YAAY,EAAE,OAAO;iBACtB;aACF;SACF;KACF;IACD;QACE,IAAI,EAAE,QAAQ;QACd,SAAS,EAAE;YACT,KAAK,EAAE;gBACL;oBACE,IAAI,EAAE,SAAS;oBACf,YAAY,EAAE,QAAQ;iBACvB;aACF;SACF;KACF;IACD;QACE,IAAI,EAAE,SAAS;Q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,CAAC,IAAI,CAAC;QAAE,OAAO,KAAK,CAAA;IAE/C,OAAO,CAAC,QAAQ,CAAC,YAAY,IAAI,IAAI,MAAM,CAAC,QAAQ,CAAC,YAAY,CAAC,CAAC,IAAI,CAAC,aAAa,CAAC,QAAQ,CAAC,IAAI,CAAE,CAAC,CAAA;AACxG,CAAC;AAED,SAAS,gBAAgB,CACvB,QAAgB,EAChB,gBAAwB,EACxB,gBAAqD,EAAE;IAEvD,IAAI,aAAa,CAAC,gBAAgB,CAAC,EAAE;QACnC,OAAO,aAAa,CAAA;KACrB;IAED,MAAM,gBAAgB,GAAG,QAAQ,CAAC,QAAQ,EAAE,gBAAgB,CAAC,CAAA;IAC7D,IAAI,CAAC,UAAU,CAAC,gBAAgB,CAAC,EAAE;QACjC,OAAO,aAAa,CAAA;KACrB;IAED,MAAM,UAAU,GAAG,YAAY,CAAC,gBAAgB,EAAE,EAAC,QAAQ,EAAE,MAAM,EAAC,CAAC,CAAA;IAErE,aAAa,CAAC,gBAAgB,CAAC,GAAG,UAAU,CAAA;IAC5C,OAAO,aAAa,CAAA;AACtB,CAAC","sourcesContent":["import {join as pathJoin} from '../path.js'\nimport {existsSync, readFileSync} from 'node:fs'\n\ninterface FrameworkDetectionPattern {\n /**\n * @example A file path\n * ```\n * \"package.json\"\n * ```\n */\n path: string\n /**\n * @example A matcher\n * ```\n * \"\\\"(dev)?(d|D)ependencies\\\":\\\\s*{[^}]*\\\"next\\\":\\\\s*\\\".+?\\\"[^}]*}\"\n * ```\n */\n matchContent?: string\n}\n\ninterface Framework {\n /**\n * Name of the framework\n * @example \"nextjs\"\n */\n name: string\n\n /**\n * Detectors used to find out the framework\n */\n detectors: {\n /**\n * Collection of detectors that must be matched for the framework\n * to be detected.\n */\n every?: FrameworkDetectionPattern[]\n /**\n * Collection of detectors where one match triggers the framework\n * to be detected.\n */\n some?: FrameworkDetectionPattern[]\n }\n}\n\nconst frameworks: Framework[] = [\n {\n name: 'remix',\n detectors: {\n every: [\n {\n path: 'package.json',\n matchContent: '\"(dev)?(d|D)ependencies\":\\\\s*{[^}]*\"@remix-run\\\\/.*\":\\\\s*\".+?\"[^}]*}',\n },\n {\n path: 'package.json',\n matchContent: '\"(dev)?(d|D)ependencies\":\\\\s*{[^}]*\"react\":\\\\s*\".+?\"[^}]*}',\n },\n ],\n },\n },\n {\n name: 'nextjs',\n detectors: {\n every: [\n {\n path: 'package.json',\n matchContent: '\"(dev)?(d|D)ependencies\":\\\\s*{[^}]*\"next\":\\\\s*\".+?\"[^}]*}',\n },\n {\n path: 'package.json',\n matchContent: '\"(dev)?(d|D)ependencies\":\\\\s*{[^}]*\"react\":\\\\s*\".+?\"[^}]*}',\n },\n ],\n },\n },\n {\n name: 'express',\n detectors: {\n every: [\n {\n path: 'package.json',\n matchContent: '\"(dev)?(d|D)ependencies\":\\\\s*{[^}]*\"express\":\\\\s*\".+?\"[^}]*}',\n },\n ],\n },\n },\n {\n name: 'rails',\n detectors: {\n every: [\n {\n path: 'Gemfile',\n matchContent: 'gem \"rails\"',\n },\n ],\n },\n },\n {\n name: 'flask',\n detectors: {\n every: [\n {\n path: 'Pipfile',\n matchContent: 'flask',\n },\n ],\n },\n },\n {\n name: 'django',\n detectors: {\n every: [\n {\n path: 'Pipfile',\n matchContent: 'django',\n },\n ],\n },\n },\n {\n name: 'laravel',\n detectors: {\n every: [\n {\n path: 'composer.json',\n matchContent: '\"require\":\\\\s*{[^}]*\"laravel/framework\":\\\\s*\".+?\"[^}]*}',\n },\n ],\n },\n },\n {\n name: 'symfony',\n detectors: {\n every: [\n {\n path: 'composer.json',\n matchContent: '\"require\":\\\\s*{[^}]*\"symfony\\\\/.*\":\\\\s*\".+?\"[^}]*}',\n },\n ],\n },\n },\n]\n\n/**\n * Tries to identify the using of a framework analyzing the existence and/or content of different files inside a\n * specific directory.\n *\n * @param rootDirectory - Directory from which the files required for each framework are searched\n * @returns The name of the framework used or 'unknown' otherwise\n */\nexport async function resolveFramework(rootDirectory: string) {\n const fwConfigFiles: {[key: string]: string | undefined} = {}\n\n const matchedFramework = frameworks.find(\n (framework) =>\n (!framework.detectors?.some ||\n framework.detectors?.some?.reduce(\n (_previousDetectorsMatch: boolean, detector) =>\n matchDetector(detector, loadFwConfigFile(rootDirectory, detector.path, fwConfigFiles)),\n false,\n )) &&\n (!framework.detectors?.every ||\n framework.detectors?.every?.reduce(\n (previousDetectorsMatch: boolean, detector) =>\n previousDetectorsMatch\n ? matchDetector(detector, loadFwConfigFile(rootDirectory, detector.path, fwConfigFiles))\n : false,\n true,\n )),\n )\n\n return matchedFramework ? matchedFramework.name : 'unknown'\n}\n\nfunction matchDetector(detector: FrameworkDetectionPattern, fwConfigFiles: {[key: string]: string | undefined} = {}) {\n if (!fwConfigFiles[detector.path]) return false\n\n return !detector.matchContent || new RegExp(detector.matchContent).test(fwConfigFiles[detector.path]!)\n}\n\nfunction loadFwConfigFile(\n rootPath: string,\n fwConfigFileName: string,\n fwConfigFiles: {[key: string]: string | undefined} = {},\n) {\n if (fwConfigFiles[fwConfigFileName]) {\n return fwConfigFiles\n }\n\n const fwConfigFilePath = pathJoin(rootPath, fwConfigFileName)\n if (!existsSync(fwConfigFilePath)) {\n return fwConfigFiles\n }\n\n const rawContent = readFileSync(fwConfigFilePath, {encoding: 'utf8'})\n\n fwConfigFiles[fwConfigFileName] = rawContent\n return fwConfigFiles\n}\n"]}
@@ -29,8 +29,8 @@ function parseNormalCommand(id, aliases) {
29
29
  * Create commands implement Init by default, so the name of the command must be extracted from
30
30
  * the plugin/module name. Neither alias or topic are supported
31
31
  *
32
- * @param {Interfaces.Command.Class} commandClass - Oclif command configuration
33
- * @returns {(CommandContent | undefined)} Command content with the name of the command or undefined otherwise
32
+ * @param commandClass - Oclif command configuration
33
+ * @returns Command content with the name of the command or undefined otherwise
34
34
  */
35
35
  function parseCreateCommand(pluginAlias) {
36
36
  if (!pluginAlias || !pluginAlias.startsWith('@shopify/create-')) {
@@ -42,8 +42,8 @@ function parseCreateCommand(pluginAlias) {
42
42
  * Commands use this pattern topic:subtopic1:...:subtopicN:command. This method extract the topic and subtopic
43
43
  * information replacing the ':' separator with one space
44
44
  *
45
- * @param {string} cmd - Complete command string to extract the topic information
46
- * @returns {(string | undefined)} The topic name or undefined otherwise
45
+ * @param cmd - Complete command string to extract the topic information
46
+ * @returns The topic name or undefined otherwise
47
47
  */
48
48
  function parseTopic(cmd) {
49
49
  if (cmd.lastIndexOf(':') === -1) {
@@ -54,8 +54,8 @@ function parseTopic(cmd) {
54
54
  /**
55
55
  * Identifies if the command was launched using an alias instead of the oficial command name
56
56
  *
57
- * @param {string[]} aliases - List of possible alias a command has
58
- * @returns {(string | undefined)} The alias used or undefined otherwise
57
+ * @param aliases - List of possible alias a command has
58
+ * @returns The alias used or undefined otherwise
59
59
  */
60
60
  function findAlias(aliases) {
61
61
  const existingAlias = aliases.find((alias) => alias.split(':').every((aliasToken) => process.argv.includes(aliasToken)));
@@ -1 +1 @@
1
- {"version":3,"file":"prerun.js","sourceRoot":"","sources":["../../../src/node/hooks/prerun.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,KAAK,EAAC,MAAM,oBAAoB,CAAA;AACxC,OAAO,EAAC,KAAK,EAAC,MAAM,iBAAiB,CAAA;AASrC,sFAAsF;AACtF,MAAM,CAAC,MAAM,IAAI,GAAgB,KAAK,EAAE,OAAO,EAAE,EAAE;IACjD,MAAM,cAAc,GAAG,mBAAmB,CAAC;QACzC,EAAE,EAAE,OAAO,CAAC,OAAO,CAAC,EAAE;QACtB,OAAO,EAAE,OAAO,CAAC,OAAO,CAAC,OAAO;QAChC,WAAW,EAAE,OAAO,CAAC,OAAO,CAAC,MAAM,EAAE,KAAK;KAC3C,CAAC,CAAA;IACF,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAA;IACzB,KAAK,CAAC,mBAAmB,cAAc,CAAC,OAAO,EAAE,CAAC,CAAA;IAClD,MAAM,KAAK,CAAC,EAAC,cAAc,EAAE,IAAI,EAAE,YAAY,EAAE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C,KAAK,EAAE,EAAE,CAC3C,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,UAAU,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC,CAC1E,CAAA;IACD,IAAI,aAAa,EAAE;QACjB,OAAO,aAAa,CAAC,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC,CAAA;KACxC;AACH,CAAC","sourcesContent":["import {start} from '../../analytics.js'\nimport {debug} from '../../output.js'\nimport Command from '../base-command.js'\nimport {Hook} from '@oclif/core'\n\nexport declare interface CommandContent {\n command: string\n topic?: string\n alias?: string\n}\n// This hook is called before each command run. More info: https://oclif.io/docs/hooks\nexport const hook: Hook.Prerun = async (options) => {\n const commandContent = parseCommandContent({\n id: options.Command.id,\n aliases: options.Command.aliases,\n pluginAlias: options.Command.plugin?.alias,\n })\n const args = options.argv\n debug(`Running command ${commandContent.command}`)\n await start({commandContent, args, commandClass: options.Command as unknown as typeof Command})\n}\n\nexport function parseCommandContent(cmdInfo: {id: string; aliases: string[]; pluginAlias?: string}) {\n let commandContent = parseCreateCommand(cmdInfo.pluginAlias)\n if (!commandContent) {\n commandContent = parseNormalCommand(cmdInfo.id, cmdInfo.aliases)\n }\n return commandContent\n}\n\nfunction parseNormalCommand(id: string, aliases: string[]): CommandContent {\n return {\n command: id.replace(/:/g, ' '),\n topic: parseTopic(id),\n alias: findAlias(aliases),\n }\n}\n\n/**\n * Create commands implement Init by default, so the name of the command must be extracted from\n * the plugin/module name. Neither alias or topic are supported\n *\n * @param {Interfaces.Command.Class} commandClass - Oclif command configuration\n * @returns {(CommandContent | undefined)} Command content with the name of the command or undefined otherwise\n */\nfunction parseCreateCommand(pluginAlias?: string): CommandContent | undefined {\n if (!pluginAlias || !pluginAlias.startsWith('@shopify/create-')) {\n return undefined\n }\n\n return {command: pluginAlias.substring(pluginAlias.indexOf('/') + 1)}\n}\n\n/**\n * Commands use this pattern topic:subtopic1:...:subtopicN:command. This method extract the topic and subtopic\n * information replacing the ':' separator with one space\n *\n * @param {string} cmd - Complete command string to extract the topic information\n * @returns {(string | undefined)} The topic name or undefined otherwise\n */\nfunction parseTopic(cmd: string) {\n if (cmd.lastIndexOf(':') === -1) {\n return\n }\n return cmd.slice(0, cmd.lastIndexOf(':')).replace(/:/g, ' ')\n}\n\n/**\n * Identifies if the command was launched using an alias instead of the oficial command name\n *\n * @param {string[]} aliases - List of possible alias a command has\n * @returns {(string | undefined)} The alias used or undefined otherwise\n */\nfunction findAlias(aliases: string[]) {\n const existingAlias = aliases.find((alias) =>\n alias.split(':').every((aliasToken) => process.argv.includes(aliasToken)),\n )\n if (existingAlias) {\n return existingAlias.replace(/:/g, ' ')\n }\n}\n"]}
1
+ {"version":3,"file":"prerun.js","sourceRoot":"","sources":["../../../src/node/hooks/prerun.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,KAAK,EAAC,MAAM,oBAAoB,CAAA;AACxC,OAAO,EAAC,KAAK,EAAC,MAAM,iBAAiB,CAAA;AASrC,sFAAsF;AACtF,MAAM,CAAC,MAAM,IAAI,GAAgB,KAAK,EAAE,OAAO,EAAE,EAAE;IACjD,MAAM,cAAc,GAAG,mBAAmB,CAAC;QACzC,EAAE,EAAE,OAAO,CAAC,OAAO,CAAC,EAAE;QACtB,OAAO,EAAE,OAAO,CAAC,OAAO,CAAC,OAAO;QAChC,WAAW,EAAE,OAAO,CAAC,OAAO,CAAC,MAAM,EAAE,KAAK;KAC3C,CAAC,CAAA;IACF,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAA;IACzB,KAAK,CAAC,mBAAmB,cAAc,CAAC,OAAO,EAAE,CAAC,CAAA;IAClD,MAAM,KAAK,CAAC,EAAC,cAAc,EAAE,IAAI,EAAE,YAAY,EAAE,OAAO,CAAC,OAAoC,EAAC,CAAC,CAAA;AACjG,CAAC,CAAA;AAED,MAAM,UAAU,mBAAmB,CAAC,OAA8D;IAChG,IAAI,c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AC,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC,CAC1E,CAAA;IACD,IAAI,aAAa,EAAE;QACjB,OAAO,aAAa,CAAC,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC,CAAA;KACxC;AACH,CAAC","sourcesContent":["import {start} from '../../analytics.js'\nimport {debug} from '../../output.js'\nimport Command from '../base-command.js'\nimport {Hook} from '@oclif/core'\n\nexport declare interface CommandContent {\n command: string\n topic?: string\n alias?: string\n}\n// This hook is called before each command run. More info: https://oclif.io/docs/hooks\nexport const hook: Hook.Prerun = async (options) => {\n const commandContent = parseCommandContent({\n id: options.Command.id,\n aliases: options.Command.aliases,\n pluginAlias: options.Command.plugin?.alias,\n })\n const args = options.argv\n debug(`Running command ${commandContent.command}`)\n await start({commandContent, args, commandClass: options.Command as unknown as typeof Command})\n}\n\nexport function parseCommandContent(cmdInfo: {id: string; aliases: string[]; pluginAlias?: string}) {\n let commandContent = parseCreateCommand(cmdInfo.pluginAlias)\n if (!commandContent) {\n commandContent = parseNormalCommand(cmdInfo.id, cmdInfo.aliases)\n }\n return commandContent\n}\n\nfunction parseNormalCommand(id: string, aliases: string[]): CommandContent {\n return {\n command: id.replace(/:/g, ' '),\n topic: parseTopic(id),\n alias: findAlias(aliases),\n }\n}\n\n/**\n * Create commands implement Init by default, so the name of the command must be extracted from\n * the plugin/module name. Neither alias or topic are supported\n *\n * @param commandClass - Oclif command configuration\n * @returns Command content with the name of the command or undefined otherwise\n */\nfunction parseCreateCommand(pluginAlias?: string): CommandContent | undefined {\n if (!pluginAlias || !pluginAlias.startsWith('@shopify/create-')) {\n return undefined\n }\n\n return {command: pluginAlias.substring(pluginAlias.indexOf('/') + 1)}\n}\n\n/**\n * Commands use this pattern topic:subtopic1:...:subtopicN:command. This method extract the topic and subtopic\n * information replacing the ':' separator with one space\n *\n * @param cmd - Complete command string to extract the topic information\n * @returns The topic name or undefined otherwise\n */\nfunction parseTopic(cmd: string) {\n if (cmd.lastIndexOf(':') === -1) {\n return\n }\n return cmd.slice(0, cmd.lastIndexOf(':')).replace(/:/g, ' ')\n}\n\n/**\n * Identifies if the command was launched using an alias instead of the oficial command name\n *\n * @param aliases - List of possible alias a command has\n * @returns The alias used or undefined otherwise\n */\nfunction findAlias(aliases: string[]) {\n const existingAlias = aliases.find((alias) =>\n alias.split(':').every((aliasToken) => process.argv.includes(aliasToken)),\n )\n if (existingAlias) {\n return existingAlias.replace(/:/g, ' ')\n }\n}\n"]}
@@ -25,26 +25,26 @@ export declare type PackageManager = typeof packageManager[number];
25
25
  /**
26
26
  * Returns an abort error that's thrown when a directory that's expected to have
27
27
  * a package.json doesn't have it.
28
- * @param directory {string} The path to the directory that should contain a package.json
29
- * @returns {Abort} An abort error.
28
+ * @param directory - The path to the directory that should contain a package.json
29
+ * @returns An abort error.
30
30
  */
31
31
  export declare const PackageJsonNotFoundError: (directory: string) => Abort;
32
32
  /**
33
33
  * Returns a bug error that's thrown when the lookup of the package.json traversing the directory
34
34
  * hierarchy up can't find a package.json
35
- * @param directory {string} The directory from which the traverse has been done
36
- * @returns {Abort} An abort error.
35
+ * @param directory - The directory from which the traverse has been done
36
+ * @returns An abort error.
37
37
  */
38
38
  export declare const FindUpAndReadPackageJsonNotFoundError: (directory: string) => Bug;
39
39
  /**
40
40
  * Returns the dependency manager used to run the create workflow.
41
- * @param env {Object} The environment variables of the process in which the CLI runs.
41
+ * @param env - The environment variables of the process in which the CLI runs.
42
42
  * @returns The dependency manager
43
43
  */
44
44
  export declare function packageManagerUsedForCreating(env?: NodeJS.ProcessEnv): PackageManager | 'unknown';
45
45
  /**
46
46
  * Returns the dependency manager used by an existing project.
47
- * @param directory {string} The root directory of the project.
47
+ * @param directory - The root directory of the project.
48
48
  * @returns The dependency manager
49
49
  */
50
50
  export declare function getPackageManager(directory: string): Promise<PackageManager>;
@@ -66,7 +66,7 @@ interface InstallNPMDependenciesRecursivelyOptions {
66
66
  * This function traverses down a directory tree to find directories containing a package.json
67
67
  * and installs the dependencies if needed. To know if it's needed, it uses the "check" command
68
68
  * provided by dependency managers.
69
- * @param options {InstallNPMDependenciesRecursivelyOptions} Options to install dependencies recursively.
69
+ * @param options - Options to install dependencies recursively.
70
70
  */
71
71
  export declare function installNPMDependenciesRecursively(options: InstallNPMDependenciesRecursivelyOptions): Promise<void>;
72
72
  interface InstallNodeModulesOptions {
@@ -80,13 +80,13 @@ interface InstallNodeModulesOptions {
80
80
  export declare function installNodeModules(options: InstallNodeModulesOptions): Promise<void>;
81
81
  /**
82
82
  * Returns the name of the package configured in its package.json
83
- * @param packageJsonPath {string} Path to the package.json file
83
+ * @param packageJsonPath - Path to the package.json file
84
84
  * @returns A promise that resolves with the name.
85
85
  */
86
86
  export declare function getPackageName(packageJsonPath: string): Promise<string | undefined>;
87
87
  /**
88
88
  * Returns the list of production and dev dependencies of a package.json
89
- * @param packageJsonPath {string} Path to the package.json file
89
+ * @param packageJsonPath - Path to the package.json file
90
90
  * @returns A promise that resolves with the list of dependencies.
91
91
  */
92
92
  export declare function getDependencies(packageJsonPath: string): Promise<{
@@ -94,16 +94,16 @@ export declare function getDependencies(packageJsonPath: string): Promise<{
94
94
  }>;
95
95
  /**
96
96
  * Returns true if the app uses workspaces, false otherwise.
97
- * @param packageJsonPath {string} Path to the package.json file
98
- * @param pnpmWorkspacePath {string} Path to the pnpm-workspace.yaml file
97
+ * @param packageJsonPath - Path to the package.json file
98
+ * @param pnpmWorkspacePath - Path to the pnpm-workspace.yaml file
99
99
  * @returns A promise that resolves with true if the app uses workspaces, false otherwise.
100
100
  */
101
101
  export declare function usesWorkspaces(appDirectory: string): Promise<boolean>;
102
102
  /**
103
103
  * Given an NPM dependency, it checks if there's a more recent version, and if there is, it returns its value.
104
- * @param dependency {string} The dependency name (e.g. react)
105
- * @param currentVersion {string} The current version.
106
- * @returns {Promise<string>} A promise that resolves with a more recent version or undefined if there's no more recent version.
104
+ * @param dependency - The dependency name (e.g. react)
105
+ * @param currentVersion - The current version.
106
+ * @returns A promise that resolves with a more recent version or undefined if there's no more recent version.
107
107
  */
108
108
  export declare function checkForNewVersion(dependency: string, currentVersion: string): Promise<string | undefined>;
109
109
  /**
@@ -155,8 +155,8 @@ export interface PackageJson {
155
155
  }
156
156
  /**
157
157
  * Reads and parses a package.json
158
- * @param packageJsonPath {string} Path to the package.json
159
- * @returns {Promise<PackageJson>} An promise that resolves with an in-memory representation
158
+ * @param packageJsonPath - Path to the package.json
159
+ * @returns An promise that resolves with an in-memory representation
160
160
  * of the package.json or rejects with an error if the file is not found or the content is
161
161
  * not decodable.
162
162
  */
@@ -183,27 +183,31 @@ export interface DependencyVersion {
183
183
  * The name of the NPM dependency as it's reflected in the package.json:
184
184
  *
185
185
  * @example
186
- * In the example below name would be "react"
187
- * {
188
- * "react": "1.2.3"
189
- * }
186
+ * In the example below name would be "react"
187
+ * ```
188
+ * {
189
+ * "react": "1.2.3"
190
+ * }
191
+ * ```
190
192
  */
191
193
  name: string;
192
194
  /**
193
195
  * The version of the NPM dependency as it's reflected in the package.json:
194
196
  *
195
197
  * @example
196
- * In the example below version would be "1.2.3"
197
- * {
198
- * "react": "1.2.3"
199
- * }
198
+ * In the example below version would be "1.2.3"
199
+ * ```
200
+ * {
201
+ * "react": "1.2.3"
202
+ * }
203
+ * ```
200
204
  */
201
205
  version: string | undefined;
202
206
  }
203
207
  /**
204
208
  * Adds dependencies to a Node project (i.e. a project that has a package.json)
205
- * @param dependencies {string[]} List of dependencies to be added.
206
- * @param options {AddNPMDependenciesIfNeededOptions} Options for adding dependencies.
209
+ * @param dependencies - List of dependencies to be added.
210
+ * @param options - Options for adding dependencies.
207
211
  */
208
212
  export declare function addNPMDependenciesIfNeeded(dependencies: DependencyVersion[], options: AddNPMDependenciesIfNeededOptions): Promise<void>;
209
213
  export declare function addNPMDependencies(dependencies: DependencyVersion[], options: AddNPMDependenciesIfNeededOptions): Promise<void>;
@@ -211,8 +215,8 @@ export declare function addNPMDependenciesWithoutVersionIfNeeded(dependencies: s
211
215
  /**
212
216
  * Given a directory it traverses the directory up looking for a package.json and if found, it reads it
213
217
  * decodes the JSON, and returns its content as a Javascript object.
214
- * @param options {string} The directory from which traverse up.
215
- * @returns {Promise<{path: string; content: unknown}>} If found, the promise resolves with the path to the
218
+ * @param options - The directory from which traverse up.
219
+ * @returns If found, the promise resolves with the path to the
216
220
  * package.json and its content. If not found, it throws a FindUpAndReadPackageJsonNotFoundError error.
217
221
  */
218
222
  export declare function findUpAndReadPackageJson(fromDirectory: string): Promise<{
@@ -21,8 +21,8 @@ export const packageManager = ['yarn', 'npm', 'pnpm'];
21
21
  /**
22
22
  * Returns an abort error that's thrown when a directory that's expected to have
23
23
  * a package.json doesn't have it.
24
- * @param directory {string} The path to the directory that should contain a package.json
25
- * @returns {Abort} An abort error.
24
+ * @param directory - The path to the directory that should contain a package.json
25
+ * @returns An abort error.
26
26
  */
27
27
  export const PackageJsonNotFoundError = (directory) => {
28
28
  return new Abort(`The directory ${directory} doesn't have a package.json.`);
@@ -30,15 +30,15 @@ export const PackageJsonNotFoundError = (directory) => {
30
30
  /**
31
31
  * Returns a bug error that's thrown when the lookup of the package.json traversing the directory
32
32
  * hierarchy up can't find a package.json
33
- * @param directory {string} The directory from which the traverse has been done
34
- * @returns {Abort} An abort error.
33
+ * @param directory - The directory from which the traverse has been done
34
+ * @returns An abort error.
35
35
  */
36
36
  export const FindUpAndReadPackageJsonNotFoundError = (directory) => {
37
37
  return new Bug(content `Couldn't find a a package.json traversing directories from ${token.path(directory)}`);
38
38
  };
39
39
  /**
40
40
  * Returns the dependency manager used to run the create workflow.
41
- * @param env {Object} The environment variables of the process in which the CLI runs.
41
+ * @param env - The environment variables of the process in which the CLI runs.
42
42
  * @returns The dependency manager
43
43
  */
44
44
  export function packageManagerUsedForCreating(env = process.env) {
@@ -55,7 +55,7 @@ export function packageManagerUsedForCreating(env = process.env) {
55
55
  }
56
56
  /**
57
57
  * Returns the dependency manager used by an existing project.
58
- * @param directory {string} The root directory of the project.
58
+ * @param directory - The root directory of the project.
59
59
  * @returns The dependency manager
60
60
  */
61
61
  export async function getPackageManager(directory) {
@@ -76,7 +76,7 @@ export async function getPackageManager(directory) {
76
76
  * This function traverses down a directory tree to find directories containing a package.json
77
77
  * and installs the dependencies if needed. To know if it's needed, it uses the "check" command
78
78
  * provided by dependency managers.
79
- * @param options {InstallNPMDependenciesRecursivelyOptions} Options to install dependencies recursively.
79
+ * @param options - Options to install dependencies recursively.
80
80
  */
81
81
  export async function installNPMDependenciesRecursively(options) {
82
82
  const packageJsons = await glob(pathJoin(options.directory, '**/package.json'), {
@@ -120,7 +120,7 @@ export async function installNodeModules(options) {
120
120
  }
121
121
  /**
122
122
  * Returns the name of the package configured in its package.json
123
- * @param packageJsonPath {string} Path to the package.json file
123
+ * @param packageJsonPath - Path to the package.json file
124
124
  * @returns A promise that resolves with the name.
125
125
  */
126
126
  export async function getPackageName(packageJsonPath) {
@@ -129,7 +129,7 @@ export async function getPackageName(packageJsonPath) {
129
129
  }
130
130
  /**
131
131
  * Returns the list of production and dev dependencies of a package.json
132
- * @param packageJsonPath {string} Path to the package.json file
132
+ * @param packageJsonPath - Path to the package.json file
133
133
  * @returns A promise that resolves with the list of dependencies.
134
134
  */
135
135
  export async function getDependencies(packageJsonPath) {
@@ -140,8 +140,8 @@ export async function getDependencies(packageJsonPath) {
140
140
  }
141
141
  /**
142
142
  * Returns true if the app uses workspaces, false otherwise.
143
- * @param packageJsonPath {string} Path to the package.json file
144
- * @param pnpmWorkspacePath {string} Path to the pnpm-workspace.yaml file
143
+ * @param packageJsonPath - Path to the package.json file
144
+ * @param pnpmWorkspacePath - Path to the pnpm-workspace.yaml file
145
145
  * @returns A promise that resolves with true if the app uses workspaces, false otherwise.
146
146
  */
147
147
  export async function usesWorkspaces(appDirectory) {
@@ -152,9 +152,9 @@ export async function usesWorkspaces(appDirectory) {
152
152
  }
153
153
  /**
154
154
  * Given an NPM dependency, it checks if there's a more recent version, and if there is, it returns its value.
155
- * @param dependency {string} The dependency name (e.g. react)
156
- * @param currentVersion {string} The current version.
157
- * @returns {Promise<string>} A promise that resolves with a more recent version or undefined if there's no more recent version.
155
+ * @param dependency - The dependency name (e.g. react)
156
+ * @param currentVersion - The current version.
157
+ * @returns A promise that resolves with a more recent version or undefined if there's no more recent version.
158
158
  */
159
159
  export async function checkForNewVersion(dependency, currentVersion) {
160
160
  debug(content `Checking if there's a version of ${dependency} newer than ${currentVersion}`);
@@ -174,8 +174,8 @@ export async function checkForNewVersion(dependency, currentVersion) {
174
174
  }
175
175
  /**
176
176
  * Reads and parses a package.json
177
- * @param packageJsonPath {string} Path to the package.json
178
- * @returns {Promise<PackageJson>} An promise that resolves with an in-memory representation
177
+ * @param packageJsonPath - Path to the package.json
178
+ * @returns An promise that resolves with an in-memory representation
179
179
  * of the package.json or rejects with an error if the file is not found or the content is
180
180
  * not decodable.
181
181
  */
@@ -187,8 +187,8 @@ export async function readAndParsePackageJson(packageJsonPath) {
187
187
  }
188
188
  /**
189
189
  * Adds dependencies to a Node project (i.e. a project that has a package.json)
190
- * @param dependencies {string[]} List of dependencies to be added.
191
- * @param options {AddNPMDependenciesIfNeededOptions} Options for adding dependencies.
190
+ * @param dependencies - List of dependencies to be added.
191
+ * @param options - Options for adding dependencies.
192
192
  */
193
193
  export async function addNPMDependenciesIfNeeded(dependencies, options) {
194
194
  debug(content `Adding the following dependencies if needed:
@@ -241,9 +241,9 @@ export async function addNPMDependenciesWithoutVersionIfNeeded(dependencies, opt
241
241
  }
242
242
  /**
243
243
  * Returns the arguments to add dependencies using NPM.
244
- * @param dependencies {string[]} The list of dependencies to add
245
- * @param type {DependencyType} The dependency type.
246
- * @returns {string[]} An array with the arguments.
244
+ * @param dependencies - The list of dependencies to add
245
+ * @param type - The dependency type.
246
+ * @returns An array with the arguments.
247
247
  */
248
248
  function argumentsToAddDependenciesWithNPM(dependencies, type) {
249
249
  let command = ['install'];
@@ -263,9 +263,9 @@ function argumentsToAddDependenciesWithNPM(dependencies, type) {
263
263
  }
264
264
  /**
265
265
  * Returns the arguments to add dependencies using Yarn.
266
- * @param dependencies {string[]} The list of dependencies to add
267
- * @param type {DependencyType} The dependency type.
268
- * @returns {string[]} An array with the arguments.
266
+ * @param dependencies - The list of dependencies to add
267
+ * @param type - The dependency type.
268
+ * @returns An array with the arguments.
269
269
  */
270
270
  function argumentsToAddDependenciesWithYarn(dependencies, type) {
271
271
  let command = ['add'];
@@ -285,9 +285,9 @@ function argumentsToAddDependenciesWithYarn(dependencies, type) {
285
285
  }
286
286
  /**
287
287
  * Returns the arguments to add dependencies using PNPM.
288
- * @param dependencies {string[]} The list of dependencies to add
289
- * @param type {DependencyType} The dependency type.
290
- * @returns {string[]} An array with the arguments.
288
+ * @param dependencies - The list of dependencies to add
289
+ * @param type - The dependency type.
290
+ * @returns An array with the arguments.
291
291
  */
292
292
  function argumentsToAddDependenciesWithPNPM(dependencies, type) {
293
293
  let command = ['add'];
@@ -308,8 +308,8 @@ function argumentsToAddDependenciesWithPNPM(dependencies, type) {
308
308
  /**
309
309
  * Given a directory it traverses the directory up looking for a package.json and if found, it reads it
310
310
  * decodes the JSON, and returns its content as a Javascript object.
311
- * @param options {string} The directory from which traverse up.
312
- * @returns {Promise<{path: string; content: unknown}>} If found, the promise resolves with the path to the
311
+ * @param options - The directory from which traverse up.
312
+ * @returns If found, the promise resolves with the path to the
313
313
  * package.json and its content. If not found, it throws a FindUpAndReadPackageJsonNotFoundError error.
314
314
  */
315
315
  export async function findUpAndReadPackageJson(fromDirectory) {