@shopify/cli-kit 3.0.25 → 3.1.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 (289) hide show
  1. package/CHANGELOG.md +34 -0
  2. package/assets/auth-error.html +2 -4
  3. package/assets/empty-url.html +2 -4
  4. package/assets/missing-code.html +2 -4
  5. package/assets/missing-state.html +2 -4
  6. package/assets/style.css +5 -8
  7. package/assets/success.html +1 -1
  8. package/dist/abort.d.ts +1 -0
  9. package/dist/abort.js +2 -0
  10. package/dist/abort.js.map +1 -0
  11. package/dist/analytics.d.ts +13 -0
  12. package/dist/analytics.js +111 -0
  13. package/dist/analytics.js.map +1 -0
  14. package/dist/api/admin.d.ts +3 -0
  15. package/dist/api/admin.js +80 -0
  16. package/dist/api/admin.js.map +1 -0
  17. package/dist/api/common.d.ts +11 -0
  18. package/dist/api/common.js +40 -0
  19. package/dist/api/common.js.map +1 -0
  20. package/dist/api/graphql/all_app_extension_registrations.d.ts +14 -0
  21. package/dist/api/graphql/all_app_extension_registrations.js +14 -0
  22. package/dist/api/graphql/all_app_extension_registrations.js.map +1 -0
  23. package/dist/api/graphql/all_orgs.d.ts +12 -0
  24. package/dist/api/graphql/all_orgs.js +14 -0
  25. package/dist/api/graphql/all_orgs.js.map +1 -0
  26. package/dist/api/graphql/all_stores_by_org.d.ts +18 -0
  27. package/dist/api/graphql/all_stores_by_org.js +21 -0
  28. package/dist/api/graphql/all_stores_by_org.js.map +1 -0
  29. package/dist/api/graphql/convert_dev_to_test_store.d.ts +16 -0
  30. package/dist/api/graphql/convert_dev_to_test_store.js +13 -0
  31. package/dist/api/graphql/convert_dev_to_test_store.js.map +1 -0
  32. package/dist/api/graphql/create_app.d.ts +28 -0
  33. package/dist/api/graphql/create_app.js +32 -0
  34. package/dist/api/graphql/create_app.js.map +1 -0
  35. package/dist/api/graphql/create_deployment.d.ts +33 -0
  36. package/dist/api/graphql/create_deployment.js +25 -0
  37. package/dist/api/graphql/create_deployment.js.map +1 -0
  38. package/dist/api/graphql/extension_create.d.ts +30 -0
  39. package/dist/api/graphql/extension_create.js +26 -0
  40. package/dist/api/graphql/extension_create.js.map +1 -0
  41. package/dist/api/graphql/extension_specifications.d.ts +18 -0
  42. package/dist/api/graphql/extension_specifications.js +18 -0
  43. package/dist/api/graphql/extension_specifications.js.map +1 -0
  44. package/dist/api/graphql/find_app.d.ts +13 -0
  45. package/dist/api/graphql/find_app.js +16 -0
  46. package/dist/api/graphql/find_app.js.map +1 -0
  47. package/dist/api/graphql/find_org.d.ts +23 -0
  48. package/dist/api/graphql/find_org.js +26 -0
  49. package/dist/api/graphql/find_org.js.map +1 -0
  50. package/dist/api/graphql/find_org_basic.d.ts +11 -0
  51. package/dist/api/graphql/find_org_basic.js +14 -0
  52. package/dist/api/graphql/find_org_basic.js.map +1 -0
  53. package/dist/api/graphql/find_store_by_domain.d.ts +21 -0
  54. package/dist/api/graphql/find_store_by_domain.js +24 -0
  55. package/dist/api/graphql/find_store_by_domain.js.map +1 -0
  56. package/dist/api/graphql/functions/app_function_set.d.ts +43 -0
  57. package/dist/api/graphql/functions/app_function_set.js +52 -0
  58. package/dist/api/graphql/functions/app_function_set.js.map +1 -0
  59. package/dist/api/graphql/functions/compile_module.d.ts +15 -0
  60. package/dist/api/graphql/functions/compile_module.js +13 -0
  61. package/dist/api/graphql/functions/compile_module.js.map +1 -0
  62. package/dist/api/graphql/functions/function_service_proxy.d.ts +4 -0
  63. package/dist/api/graphql/functions/function_service_proxy.js +7 -0
  64. package/dist/api/graphql/functions/function_service_proxy.js.map +1 -0
  65. package/dist/api/graphql/functions/get_app_functions.d.ts +1 -0
  66. package/dist/api/graphql/functions/get_app_functions.js +10 -0
  67. package/dist/api/graphql/functions/get_app_functions.js.map +1 -0
  68. package/dist/api/graphql/functions/module_compilation_status.d.ts +15 -0
  69. package/dist/api/graphql/functions/module_compilation_status.js +13 -0
  70. package/dist/api/graphql/functions/module_compilation_status.js.map +1 -0
  71. package/dist/api/graphql/functions/module_upload_url_generate.d.ts +18 -0
  72. package/dist/api/graphql/functions/module_upload_url_generate.js +17 -0
  73. package/dist/api/graphql/functions/module_upload_url_generate.js.map +1 -0
  74. package/dist/api/graphql/generate_signed_upload_url.d.ts +15 -0
  75. package/dist/api/graphql/generate_signed_upload_url.js +15 -0
  76. package/dist/api/graphql/generate_signed_upload_url.js.map +1 -0
  77. package/dist/api/graphql/get_variant_id.d.ts +17 -0
  78. package/dist/api/graphql/get_variant_id.js +20 -0
  79. package/dist/api/graphql/get_variant_id.js.map +1 -0
  80. package/dist/api/graphql/index.d.ts +22 -0
  81. package/dist/api/graphql/index.js +23 -0
  82. package/dist/api/graphql/index.js.map +1 -0
  83. package/dist/api/graphql/update_draft.d.ts +33 -0
  84. package/dist/api/graphql/update_draft.js +24 -0
  85. package/dist/api/graphql/update_draft.js.map +1 -0
  86. package/dist/api/graphql/update_urls.d.ts +14 -0
  87. package/dist/api/graphql/update_urls.js +12 -0
  88. package/dist/api/graphql/update_urls.js.map +1 -0
  89. package/dist/api/identity.d.ts +1 -0
  90. package/dist/api/identity.js +32 -0
  91. package/dist/api/identity.js.map +1 -0
  92. package/dist/api/partners.d.ts +25 -0
  93. package/dist/api/partners.js +100 -0
  94. package/dist/api/partners.js.map +1 -0
  95. package/dist/api.d.ts +5 -0
  96. package/dist/api.js +6 -0
  97. package/dist/api.js.map +1 -0
  98. package/dist/cli.d.ts +7 -0
  99. package/dist/cli.js +13 -0
  100. package/dist/cli.js.map +1 -0
  101. package/dist/constants.d.ts +43 -0
  102. package/dist/constants.js +63 -0
  103. package/dist/constants.js.map +1 -0
  104. package/dist/environment/fqdn.d.ts +23 -0
  105. package/dist/environment/fqdn.js +61 -0
  106. package/dist/environment/fqdn.js.map +1 -0
  107. package/dist/environment/local.d.ts +48 -0
  108. package/dist/environment/local.js +82 -0
  109. package/dist/environment/local.js.map +1 -0
  110. package/dist/environment/service.d.ts +17 -0
  111. package/dist/environment/service.js +41 -0
  112. package/dist/environment/service.js.map +1 -0
  113. package/dist/environment/spin.d.ts +47 -0
  114. package/dist/environment/spin.js +83 -0
  115. package/dist/environment/spin.js.map +1 -0
  116. package/dist/environment/utilities.d.ts +6 -0
  117. package/dist/environment/utilities.js +12 -0
  118. package/dist/environment/utilities.js.map +1 -0
  119. package/dist/environment.d.ts +5 -0
  120. package/dist/environment.js +6 -0
  121. package/dist/environment.js.map +1 -0
  122. package/dist/error.d.ts +44 -0
  123. package/dist/error.js +91 -0
  124. package/dist/error.js.map +1 -0
  125. package/dist/file.d.ts +67 -0
  126. package/dist/file.js +165 -0
  127. package/dist/file.js.map +1 -0
  128. package/dist/git.d.ts +15 -0
  129. package/dist/git.js +48 -0
  130. package/dist/git.js.map +1 -0
  131. package/dist/github.d.ts +33 -0
  132. package/dist/github.js +56 -0
  133. package/dist/github.js.map +1 -0
  134. package/dist/haiku.d.ts +1 -0
  135. package/dist/haiku.js +8 -0
  136. package/dist/haiku.js.map +1 -0
  137. package/dist/http/fetch.d.ts +16 -0
  138. package/dist/http/fetch.js +18 -0
  139. package/dist/http/fetch.js.map +1 -0
  140. package/dist/http/formdata.d.ts +3 -0
  141. package/dist/http/formdata.js +6 -0
  142. package/dist/http/formdata.js.map +1 -0
  143. package/dist/http.d.ts +2 -0
  144. package/dist/http.js +3 -0
  145. package/dist/http.js.map +1 -0
  146. package/dist/id.d.ts +6 -0
  147. package/dist/id.js +18 -0
  148. package/dist/id.js.map +1 -0
  149. package/dist/index.d.ts +33 -2179
  150. package/dist/index.js +34 -3264
  151. package/dist/index.js.map +1 -1
  152. package/dist/network/api.d.ts +2 -0
  153. package/dist/network/api.js +2 -0
  154. package/dist/network/api.js.map +1 -0
  155. package/dist/network/service.d.ts +16 -0
  156. package/dist/network/service.js +12 -0
  157. package/dist/network/service.js.map +1 -0
  158. package/dist/{archiver.d.ts → node/archiver.d.ts} +1 -4
  159. package/dist/node/archiver.js +22 -42
  160. package/dist/node/archiver.js.map +1 -1
  161. package/dist/node/checksum.d.ts +20 -0
  162. package/dist/node/checksum.js +32 -0
  163. package/dist/node/checksum.js.map +1 -0
  164. package/dist/node/cli.d.ts +18 -0
  165. package/dist/node/cli.js +96 -0
  166. package/dist/node/cli.js.map +1 -0
  167. package/dist/node/colors.d.ts +1 -0
  168. package/dist/node/colors.js +8 -0
  169. package/dist/node/colors.js.map +1 -0
  170. package/dist/node/dot-env.d.ts +33 -0
  171. package/dist/node/dot-env.js +36 -0
  172. package/dist/node/dot-env.js.map +1 -0
  173. package/dist/node/node-package-manager.d.ts +197 -0
  174. package/dist/node/node-package-manager.js +309 -0
  175. package/dist/node/node-package-manager.js.map +1 -0
  176. package/dist/node/ruby.d.ts +30 -0
  177. package/dist/node/ruby.js +197 -0
  178. package/dist/node/ruby.js.map +1 -0
  179. package/dist/npm.d.ts +27 -0
  180. package/dist/npm.js +20 -0
  181. package/dist/npm.js.map +1 -0
  182. package/dist/os.d.ts +10 -0
  183. package/dist/os.js +70 -0
  184. package/dist/os.js.map +1 -0
  185. package/dist/output.d.ts +149 -0
  186. package/dist/output.js +515 -0
  187. package/dist/output.js.map +1 -0
  188. package/dist/path.d.ts +22 -0
  189. package/dist/path.js +43 -0
  190. package/dist/path.js.map +1 -0
  191. package/dist/plugins.d.ts +9 -0
  192. package/dist/plugins.js +12 -0
  193. package/dist/plugins.js.map +1 -0
  194. package/dist/port.d.ts +5 -0
  195. package/dist/port.js +35 -0
  196. package/dist/port.js.map +1 -0
  197. package/dist/schema.d.ts +1 -0
  198. package/dist/schema.js +2 -0
  199. package/dist/schema.js.map +1 -0
  200. package/dist/secure-store.d.ts +19 -0
  201. package/dist/secure-store.js +63 -0
  202. package/dist/secure-store.js.map +1 -0
  203. package/dist/semver.d.ts +3 -0
  204. package/dist/semver.js +6 -0
  205. package/dist/semver.js.map +1 -0
  206. package/dist/session/authorize.d.ts +7 -0
  207. package/dist/session/authorize.js +40 -0
  208. package/dist/session/authorize.js.map +1 -0
  209. package/dist/session/exchange.d.ts +42 -0
  210. package/dist/session/exchange.js +144 -0
  211. package/dist/session/exchange.js.map +1 -0
  212. package/dist/session/identity.d.ts +3 -0
  213. package/dist/session/identity.js +58 -0
  214. package/dist/session/identity.js.map +1 -0
  215. package/dist/session/post-auth.d.ts +13 -0
  216. package/dist/session/post-auth.js +56 -0
  217. package/dist/session/post-auth.js.map +1 -0
  218. package/dist/session/redirect-listener.d.ts +34 -0
  219. package/dist/session/redirect-listener.js +97 -0
  220. package/dist/session/redirect-listener.js.map +1 -0
  221. package/dist/session/schema.d.ts +174 -0
  222. package/dist/session/schema.js +59 -0
  223. package/dist/session/schema.js.map +1 -0
  224. package/dist/session/scopes.d.ts +16 -0
  225. package/dist/session/scopes.js +53 -0
  226. package/dist/session/scopes.js.map +1 -0
  227. package/dist/session/store.d.ts +24 -0
  228. package/dist/session/store.js +88 -0
  229. package/dist/session/store.js.map +1 -0
  230. package/dist/session/token.d.ts +40 -0
  231. package/dist/session/token.js +22 -0
  232. package/dist/session/token.js.map +1 -0
  233. package/dist/session/validate.d.ts +17 -0
  234. package/dist/session/validate.js +75 -0
  235. package/dist/session/validate.js.map +1 -0
  236. package/dist/session.d.ts +88 -0
  237. package/dist/session.js +251 -0
  238. package/dist/session.js.map +1 -0
  239. package/dist/store/schema.d.ts +3 -0
  240. package/dist/store/schema.js +27 -0
  241. package/dist/store/schema.js.map +1 -0
  242. package/dist/store.d.ts +32 -0
  243. package/dist/store.js +102 -0
  244. package/dist/store.js.map +1 -0
  245. package/dist/string.d.ts +22 -0
  246. package/dist/string.js +38 -0
  247. package/dist/string.js.map +1 -0
  248. package/dist/system.d.ts +53 -0
  249. package/dist/system.js +109 -0
  250. package/dist/system.js.map +1 -0
  251. package/dist/template.d.ts +11 -0
  252. package/dist/template.js +50 -0
  253. package/dist/template.js.map +1 -0
  254. package/dist/testing/output.d.ts +9 -0
  255. package/dist/testing/output.js +15 -0
  256. package/dist/testing/output.js.map +1 -0
  257. package/dist/testing/store.d.ts +7 -0
  258. package/dist/testing/store.js +26 -0
  259. package/dist/testing/store.js.map +1 -0
  260. package/dist/toml.d.ts +3 -0
  261. package/dist/toml.js +8 -0
  262. package/dist/toml.js.map +1 -0
  263. package/dist/tsconfig.tsbuildinfo +1 -0
  264. package/dist/ui/autocomplete.d.ts +7 -0
  265. package/dist/ui/autocomplete.js +43 -0
  266. package/dist/ui/autocomplete.js.map +1 -0
  267. package/dist/ui/input.d.ts +7 -0
  268. package/dist/ui/input.js +48 -0
  269. package/dist/ui/input.js.map +1 -0
  270. package/dist/ui/select.d.ts +6 -0
  271. package/dist/ui/select.js +30 -0
  272. package/dist/ui/select.js.map +1 -0
  273. package/dist/ui.d.ts +36 -0
  274. package/dist/ui.js +124 -0
  275. package/dist/ui.js.map +1 -0
  276. package/dist/version.d.ts +19 -0
  277. package/dist/version.js +34 -0
  278. package/dist/version.js.map +1 -0
  279. package/dist/vscode.d.ts +8 -0
  280. package/dist/vscode.js +36 -0
  281. package/dist/vscode.js.map +1 -0
  282. package/dist/yaml.d.ts +2 -0
  283. package/dist/yaml.js +8 -0
  284. package/dist/yaml.js.map +1 -0
  285. package/package.json +19 -8
  286. package/dist/archiver.d.ts.map +0 -1
  287. package/dist/index.d.ts.map +0 -1
  288. package/dist/local-d0094ffe.js +0 -1344
  289. package/dist/local-d0094ffe.js.map +0 -1
@@ -0,0 +1,2 @@
1
+ export declare type API = 'admin' | 'storefront-renderer' | 'partners';
2
+ export declare const allAPIs: API[];
@@ -0,0 +1,2 @@
1
+ export const allAPIs = ['admin', 'storefront-renderer', 'partners'];
2
+ //# sourceMappingURL=api.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"api.js","sourceRoot":"","sources":["../../src/network/api.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,OAAO,GAAU,CAAC,OAAO,EAAE,qBAAqB,EAAE,UAAU,CAAC,CAAA","sourcesContent":["export type API = 'admin' | 'storefront-renderer' | 'partners'\n\nexport const allAPIs: API[] = ['admin', 'storefront-renderer', 'partners']\n"]}
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Enum for the differnet APIs the CLI can interact with.
3
+ * @readonly
4
+ * @enum {number}
5
+ */
6
+ export declare type Service = 'shopify' | 'admin' | 'identity';
7
+ /**
8
+ * Enum that represents the environment to use for a given service.
9
+ * @readonly
10
+ * @enum {number}
11
+ */
12
+ export declare enum Environment {
13
+ Local = "local",
14
+ Production = "production",
15
+ Spin = "spin"
16
+ }
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Enum that represents the environment to use for a given service.
3
+ * @readonly
4
+ * @enum {number}
5
+ */
6
+ export var Environment;
7
+ (function (Environment) {
8
+ Environment["Local"] = "local";
9
+ Environment["Production"] = "production";
10
+ Environment["Spin"] = "spin";
11
+ })(Environment || (Environment = {}));
12
+ //# sourceMappingURL=service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"service.js","sourceRoot":"","sources":["../../src/network/service.ts"],"names":[],"mappings":"AAOA;;;;GAIG;AACH,MAAM,CAAN,IAAY,WAIX;AAJD,WAAY,WAAW;IACrB,8BAAe,CAAA;IACf,wCAAyB,CAAA;IACzB,4BAAa,CAAA;AACf,CAAC,EAJW,WAAW,KAAX,WAAW,QAItB","sourcesContent":["/**\n * Enum for the differnet APIs the CLI can interact with.\n * @readonly\n * @enum {number}\n */\nexport type Service = 'shopify' | 'admin' | 'identity'\n\n/**\n * Enum that represents the environment to use for a given service.\n * @readonly\n * @enum {number}\n */\nexport enum Environment {\n Local = 'local',\n Production = 'production',\n Spin = 'spin',\n}\n"]}
@@ -3,7 +3,4 @@
3
3
  * @param inputDirectory {string} The absolute path to the directory to be zipped.
4
4
  * @param outputZipPath {string} The absolute path to the output zip file.
5
5
  */
6
- declare function zip(inputDirectory: string, outputZipPath: string): Promise<void>;
7
-
8
- export { zip };
9
- //# sourceMappingURL=archiver.d.ts.map
6
+ export declare function zip(inputDirectory: string, outputZipPath: string): Promise<void>;
@@ -1,44 +1,24 @@
1
- import { o as debug, b as content, t as token } from '../local-d0094ffe.js';
2
- import { zip as zip$1 } from 'cross-zip';
3
- import 'commondir';
4
- import 'pathe';
5
- import 'url';
6
- import 'find-up';
7
- import 'fast-glob';
8
- import 'node:url';
9
- import 'env-paths';
10
- import '@oclif/core';
11
- import 'source-map-support';
12
- import 'ts-error';
13
- import 'abort-controller';
14
- import 'fs-extra';
15
- import 'del';
16
- import 'tempy';
17
- import 'prettier';
18
- import 'is-interactive';
19
- import 'node:os';
20
- import 'terminal-link';
21
- import 'stacktracey';
22
- import 'color-json';
23
- import 'node:stream';
24
- import 'execa';
25
- import 'node:process';
26
-
27
- async function zip(inputDirectory, outputZipPath) {
28
- debug(content`Zipping ${token.path(inputDirectory)} into ${token.path(outputZipPath)}`);
29
- const cwd = process.cwd();
30
- process.chdir(inputDirectory);
31
- await new Promise((resolve, reject) => {
32
- zip$1("./", outputZipPath, (error) => {
33
- process.chdir(cwd);
34
- if (error) {
35
- reject(error);
36
- } else {
37
- resolve();
38
- }
1
+ import { debug, content, token } from '../output.js';
2
+ import { zip as crossZip } from 'cross-zip';
3
+ /**
4
+ * It zips a directory.
5
+ * @param inputDirectory {string} The absolute path to the directory to be zipped.
6
+ * @param outputZipPath {string} The absolute path to the output zip file.
7
+ */
8
+ export async function zip(inputDirectory, outputZipPath) {
9
+ debug(content `Zipping ${token.path(inputDirectory)} into ${token.path(outputZipPath)}`);
10
+ const cwd = process.cwd();
11
+ process.chdir(inputDirectory);
12
+ await new Promise((resolve, reject) => {
13
+ crossZip('./', outputZipPath, (error) => {
14
+ process.chdir(cwd);
15
+ if (error) {
16
+ reject(error);
17
+ }
18
+ else {
19
+ resolve();
20
+ }
21
+ });
39
22
  });
40
- });
41
23
  }
42
-
43
- export { zip };
44
- //# sourceMappingURL=archiver.js.map
24
+ //# sourceMappingURL=archiver.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"archiver.js","sources":["../../src/node/archiver.ts"],"sourcesContent":["import {debug, content, token} from '../output'\nimport {zip as crossZip} from 'cross-zip'\n\n/**\n * It zips a directory.\n * @param inputDirectory {string} The absolute path to the directory to be zipped.\n * @param outputZipPath {string} The absolute path to the output zip file.\n */\nexport async function zip(inputDirectory: string, outputZipPath: string): Promise<void> {\n debug(content`Zipping ${token.path(inputDirectory)} into ${token.path(outputZipPath)}`)\n const cwd = process.cwd()\n process.chdir(inputDirectory)\n\n await new Promise<void>((resolve, reject) => {\n crossZip('./', outputZipPath, (error) => {\n process.chdir(cwd)\n if (error) {\n reject(error)\n } else {\n resolve()\n }\n })\n })\n}\n"],"names":["crossZip"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAQA,eAAA,GAAA,CAA0B,gBAAwB,aAAsC,EAAA;AACtF,EAAM,KAAA,CAAA,OAAA,CAAA,QAAA,EAAkB,MAAM,IAAK,CAAA,cAAc,UAAU,KAAM,CAAA,IAAA,CAAK,aAAa,CAAG,CAAA,CAAA,CAAA,CAAA;AACtF,EAAM,MAAA,GAAA,GAAM,QAAQ,GAAI,EAAA,CAAA;AACxB,EAAA,OAAA,CAAQ,MAAM,cAAc,CAAA,CAAA;AAE5B,EAAA,MAAM,IAAI,OAAA,CAAc,CAAC,OAAA,EAAS,MAAW,KAAA;AAC3C,IAASA,KAAA,CAAA,IAAA,EAAM,aAAe,EAAA,CAAC,KAAU,KAAA;AACvC,MAAA,OAAA,CAAQ,MAAM,GAAG,CAAA,CAAA;AACjB,MAAA,IAAI,KAAO,EAAA;AACT,QAAA,MAAA,CAAO,KAAK,CAAA,CAAA;AAAA,OACP,MAAA;AACL,QAAQ,OAAA,EAAA,CAAA;AAAA,OACV;AAAA,KACD,CAAA,CAAA;AAAA,GACF,CAAA,CAAA;AACH;;;;"}
1
+ {"version":3,"file":"archiver.js","sourceRoot":"","sources":["../../src/node/archiver.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,KAAK,EAAE,OAAO,EAAE,KAAK,EAAC,MAAM,cAAc,CAAA;AAClD,OAAO,EAAC,GAAG,IAAI,QAAQ,EAAC,MAAM,WAAW,CAAA;AAEzC;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,GAAG,CAAC,cAAsB,EAAE,aAAqB;IACrE,KAAK,CAAC,OAAO,CAAA,WAAW,KAAK,CAAC,IAAI,CAAC,cAAc,CAAC,SAAS,KAAK,CAAC,IAAI,CAAC,aAAa,CAAC,EAAE,CAAC,CAAA;IACvF,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,EAAE,CAAA;IACzB,OAAO,CAAC,KAAK,CAAC,cAAc,CAAC,CAAA;IAE7B,MAAM,IAAI,OAAO,CAAO,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QAC1C,QAAQ,CAAC,IAAI,EAAE,aAAa,EAAE,CAAC,KAAK,EAAE,EAAE;YACtC,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;YAClB,IAAI,KAAK,EAAE;gBACT,MAAM,CAAC,KAAK,CAAC,CAAA;aACd;iBAAM;gBACL,OAAO,EAAE,CAAA;aACV;QACH,CAAC,CAAC,CAAA;IACJ,CAAC,CAAC,CAAA;AACJ,CAAC","sourcesContent":["import {debug, content, token} from '../output.js'\nimport {zip as crossZip} from 'cross-zip'\n\n/**\n * It zips a directory.\n * @param inputDirectory {string} The absolute path to the directory to be zipped.\n * @param outputZipPath {string} The absolute path to the output zip file.\n */\nexport async function zip(inputDirectory: string, outputZipPath: string): Promise<void> {\n debug(content`Zipping ${token.path(inputDirectory)} into ${token.path(outputZipPath)}`)\n const cwd = process.cwd()\n process.chdir(inputDirectory)\n\n await new Promise<void>((resolve, reject) => {\n crossZip('./', outputZipPath, (error) => {\n process.chdir(cwd)\n if (error) {\n reject(error)\n } else {\n resolve()\n }\n })\n })\n}\n"]}
@@ -0,0 +1,20 @@
1
+ import { Abort } from '../error.js';
2
+ /**
3
+ * An error that's thrown when a file's MD5 doesn't match the expected value.
4
+ * @param options An options object that includes the file path, and the expected and actual MD5.
5
+ * @returns An instance of Abort.
6
+ */
7
+ export declare const InvalidChecksumError: ({ file, expected, got }: {
8
+ file: string;
9
+ expected: string;
10
+ got: string;
11
+ }) => Abort;
12
+ /**
13
+ * Given a local file and a URL pointing to a remote file representing the MD5 of a local file,
14
+ * it validates the authenticity of the binary using an MD5 checksum.
15
+ * @param options: The file to validate and the URL that points to the file containing the MD5.
16
+ */
17
+ export declare function validateMD5({ file, md5FileURL }: {
18
+ file: string;
19
+ md5FileURL: string;
20
+ }): Promise<void>;
@@ -0,0 +1,32 @@
1
+ import { fetch } from '../http.js';
2
+ import { Abort } from '../error.js';
3
+ import { debug, token } from '../output.js';
4
+ import md5File from 'md5-file';
5
+ /**
6
+ * An error that's thrown when a file's MD5 doesn't match the expected value.
7
+ * @param options An options object that includes the file path, and the expected and actual MD5.
8
+ * @returns An instance of Abort.
9
+ */
10
+ export const InvalidChecksumError = ({ file, expected, got }) => {
11
+ return new Abort(`The validation of ${file} failed. We expected the checksum ${expected}, but got ${got})`);
12
+ };
13
+ /**
14
+ * Given a local file and a URL pointing to a remote file representing the MD5 of a local file,
15
+ * it validates the authenticity of the binary using an MD5 checksum.
16
+ * @param options: The file to validate and the URL that points to the file containing the MD5.
17
+ */
18
+ export async function validateMD5({ file, md5FileURL }) {
19
+ debug(`Checking MD5 of file ${token.path(file)} against the MD5 in ${token.link('URL', md5FileURL)}`);
20
+ const md5Digest = await md5File(file);
21
+ const md5Response = await fetch(md5FileURL);
22
+ const md5Contents = await md5Response.text();
23
+ const canonicalMD5 = md5Contents.split(' ')[0];
24
+ if (!(canonicalMD5 === md5Digest)) {
25
+ throw InvalidChecksumError({
26
+ file,
27
+ got: md5Digest,
28
+ expected: canonicalMD5,
29
+ });
30
+ }
31
+ }
32
+ //# sourceMappingURL=checksum.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"checksum.js","sourceRoot":"","sources":["../../src/node/checksum.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,KAAK,EAAC,MAAM,YAAY,CAAA;AAChC,OAAO,EAAC,KAAK,EAAC,MAAM,aAAa,CAAA;AACjC,OAAO,EAAC,KAAK,EAAE,KAAK,EAAC,MAAM,cAAc,CAAA;AACzC,OAAO,OAAO,MAAM,UAAU,CAAA;AAE9B;;;;GAIG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,EAAC,IAAI,EAAE,QAAQ,EAAE,GAAG,EAAgD,EAAE,EAAE;IAC3G,OAAO,IAAI,KAAK,CAAC,qBAAqB,IAAI,qCAAqC,QAAQ,aAAa,GAAG,GAAG,CAAC,CAAA;AAC7G,CAAC,CAAA;AACD;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,WAAW,CAAC,EAAC,IAAI,EAAE,UAAU,EAAqC;IACtF,KAAK,CAAC,wBAAwB,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,uBAAuB,KAAK,CAAC,IAAI,CAAC,KAAK,EAAE,UAAU,CAAC,EAAE,CAAC,CAAA;IACrG,MAAM,SAAS,GAAG,MAAM,OAAO,CAAC,IAAI,CAAC,CAAA;IACrC,MAAM,WAAW,GAAG,MAAM,KAAK,CAAC,UAAU,CAAC,CAAA;IAC3C,MAAM,WAAW,GAAG,MAAM,WAAW,CAAC,IAAI,EAAE,CAAA;IAC5C,MAAM,YAAY,GAAG,WAAW,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAA;IAC9C,IAAI,CAAC,CAAC,YAAY,KAAK,SAAS,CAAC,EAAE;QACjC,MAAM,oBAAoB,CAAC;YACzB,IAAI;YACJ,GAAG,EAAE,SAAS;YACd,QAAQ,EAAE,YAAY;SACvB,CAAC,CAAA;KACH;AACH,CAAC","sourcesContent":["import {fetch} from '../http.js'\nimport {Abort} from '../error.js'\nimport {debug, token} from '../output.js'\nimport md5File from 'md5-file'\n\n/**\n * An error that's thrown when a file's MD5 doesn't match the expected value.\n * @param options An options object that includes the file path, and the expected and actual MD5.\n * @returns An instance of Abort.\n */\nexport const InvalidChecksumError = ({file, expected, got}: {file: string; expected: string; got: string}) => {\n return new Abort(`The validation of ${file} failed. We expected the checksum ${expected}, but got ${got})`)\n}\n/**\n * Given a local file and a URL pointing to a remote file representing the MD5 of a local file,\n * it validates the authenticity of the binary using an MD5 checksum.\n * @param options: The file to validate and the URL that points to the file containing the MD5.\n */\nexport async function validateMD5({file, md5FileURL}: {file: string; md5FileURL: string}) {\n debug(`Checking MD5 of file ${token.path(file)} against the MD5 in ${token.link('URL', md5FileURL)}`)\n const md5Digest = await md5File(file)\n const md5Response = await fetch(md5FileURL)\n const md5Contents = await md5Response.text()\n const canonicalMD5 = md5Contents.split(' ')[0]\n if (!(canonicalMD5 === md5Digest)) {\n throw InvalidChecksumError({\n file,\n got: md5Digest,\n expected: canonicalMD5,\n })\n }\n}\n"]}
@@ -0,0 +1,18 @@
1
+ interface RunCLIOptions {
2
+ /** The value of import.meta.url of the CLI executable module */
3
+ moduleURL: string;
4
+ /** The logs file name */
5
+ logFilename: string;
6
+ }
7
+ /**
8
+ * A function that abstracts away setting up the environment and running
9
+ * a CLI
10
+ * @param module {RunCLIOptions} Options.
11
+ */
12
+ export declare function runCLI(options: RunCLIOptions): Promise<void>;
13
+ /**
14
+ * A function for create-x CLIs that automatically runs the "init" command.
15
+ * @param options
16
+ */
17
+ export declare function runCreateCLI(options: RunCLIOptions): Promise<void>;
18
+ export default runCLI;
@@ -0,0 +1,96 @@
1
+ // CLI
2
+ import { findUpAndReadPackageJson } from './node-package-manager.js';
3
+ import { initializeCliKitStore } from '../store.js';
4
+ import { initiateLogging } from '../output.js';
5
+ import { isDebug } from '../environment/local.js';
6
+ import constants, { bugsnagApiKey } from '../constants.js';
7
+ import { reportEvent } from '../analytics.js';
8
+ import { mapper as errorMapper, handler as errorHandler, AbortSilent, shouldReport as shouldReportError, } from '../error.js';
9
+ import { moduleDirectory, normalize } from '../path.js';
10
+ import StackTracey from 'stacktracey';
11
+ import { run, settings, flush } from '@oclif/core';
12
+ import Bugsnag from '@bugsnag/js';
13
+ /**
14
+ * A function that abstracts away setting up the environment and running
15
+ * a CLI
16
+ * @param module {RunCLIOptions} Options.
17
+ */
18
+ export async function runCLI(options) {
19
+ await initializeCliKitStore();
20
+ initiateLogging({ filename: options.logFilename });
21
+ if (isDebug()) {
22
+ settings.debug = true;
23
+ }
24
+ else {
25
+ Bugsnag.start({
26
+ appType: 'node',
27
+ apiKey: bugsnagApiKey,
28
+ logger: null,
29
+ appVersion: await constants.versions.cliKit(),
30
+ autoTrackSessions: false,
31
+ autoDetectErrors: false,
32
+ });
33
+ }
34
+ run(undefined, options.moduleURL)
35
+ .then(flush)
36
+ .catch((error) => {
37
+ if (error instanceof AbortSilent) {
38
+ process.exit(1);
39
+ }
40
+ // eslint-disable-next-line promise/no-nesting
41
+ return errorMapper(error)
42
+ .then((error) => {
43
+ return errorHandler(error);
44
+ })
45
+ .then(reportError)
46
+ .then(() => {
47
+ process.exit(1);
48
+ });
49
+ });
50
+ }
51
+ /**
52
+ * A function for create-x CLIs that automatically runs the "init" command.
53
+ * @param options
54
+ */
55
+ export async function runCreateCLI(options) {
56
+ const packageJson = await findUpAndReadPackageJson(moduleDirectory(options.moduleURL));
57
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
58
+ const packageName = packageJson.content.name;
59
+ const name = packageName.replace('@shopify/create-', '');
60
+ const initIndex = process.argv.findIndex((arg) => arg.includes('init'));
61
+ if (initIndex === -1) {
62
+ const initIndex = process.argv.findIndex((arg) => arg.match(new RegExp(`bin(\\/|\\\\)+(create-${name}|dev|run)`))) + 1;
63
+ process.argv.splice(initIndex, 0, 'init');
64
+ }
65
+ await runCLI(options);
66
+ }
67
+ const reportError = async (errorToReport) => {
68
+ await reportEvent({ errorMessage: errorToReport.message });
69
+ if (settings.debug || !shouldReportError(errorToReport))
70
+ return errorToReport;
71
+ let mappedError;
72
+ // eslint-disable-next-line no-prototype-builtins
73
+ if (Error.prototype.isPrototypeOf(errorToReport)) {
74
+ mappedError = new Error(errorToReport.message);
75
+ const mappedStacktrace = new StackTracey(errorToReport)
76
+ .clean()
77
+ .items.map((item) => {
78
+ const filePath = normalize(item.file).replace('file:/', '/').replace('C:/', '');
79
+ return ` at ${item.callee} (${filePath}:${item.line}:${item.column})`;
80
+ })
81
+ .join('\n');
82
+ mappedError.stack = `Error: ${errorToReport.message}\n${mappedStacktrace}`;
83
+ }
84
+ else if (typeof errorToReport === 'string') {
85
+ mappedError = new Error(errorToReport);
86
+ }
87
+ else {
88
+ mappedError = new Error('Unknown error');
89
+ }
90
+ await new Promise((resolve, reject) => {
91
+ Bugsnag.notify(mappedError, undefined, resolve);
92
+ });
93
+ return mappedError;
94
+ };
95
+ export default runCLI;
96
+ //# sourceMappingURL=cli.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli.js","sourceRoot":"","sources":["../../src/node/cli.ts"],"names":[],"mappings":"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","sourcesContent":["// CLI\nimport {findUpAndReadPackageJson} from './node-package-manager.js'\nimport {initializeCliKitStore} from '../store.js'\nimport {initiateLogging} from '../output.js'\nimport {isDebug} from '../environment/local.js'\nimport constants, {bugsnagApiKey} from '../constants.js'\nimport {reportEvent} from '../analytics.js'\nimport {\n mapper as errorMapper,\n handler as errorHandler,\n AbortSilent,\n shouldReport as shouldReportError,\n} from '../error.js'\nimport {moduleDirectory, normalize} from '../path.js'\nimport StackTracey from 'stacktracey'\nimport {run, settings, flush} from '@oclif/core'\nimport Bugsnag from '@bugsnag/js'\n\ninterface RunCLIOptions {\n /** The value of import.meta.url of the CLI executable module */\n moduleURL: string\n /** The logs file name */\n logFilename: string\n}\n\n/**\n * A function that abstracts away setting up the environment and running\n * a CLI\n * @param module {RunCLIOptions} Options.\n */\nexport async function runCLI(options: RunCLIOptions) {\n await initializeCliKitStore()\n initiateLogging({filename: options.logFilename})\n if (isDebug()) {\n settings.debug = true\n } else {\n Bugsnag.start({\n appType: 'node',\n apiKey: bugsnagApiKey,\n logger: null,\n appVersion: await constants.versions.cliKit(),\n autoTrackSessions: false,\n autoDetectErrors: false,\n })\n }\n\n run(undefined, options.moduleURL)\n .then(flush)\n .catch((error: Error): Promise<void | Error> => {\n if (error instanceof AbortSilent) {\n process.exit(1)\n }\n // eslint-disable-next-line promise/no-nesting\n return errorMapper(error)\n .then((error: Error) => {\n return errorHandler(error)\n })\n .then(reportError)\n .then(() => {\n process.exit(1)\n })\n })\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 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\nconst reportError = async (errorToReport: Error): Promise<Error> => {\n await reportEvent({errorMessage: errorToReport.message})\n if (settings.debug || !shouldReportError(errorToReport)) return errorToReport\n\n let mappedError: Error\n\n // eslint-disable-next-line no-prototype-builtins\n if (Error.prototype.isPrototypeOf(errorToReport)) {\n mappedError = new Error(errorToReport.message)\n const mappedStacktrace = new StackTracey(errorToReport)\n .clean()\n .items.map((item) => {\n const filePath = normalize(item.file).replace('file:/', '/').replace('C:/', '')\n return ` at ${item.callee} (${filePath}:${item.line}:${item.column})`\n })\n .join('\\n')\n mappedError.stack = `Error: ${errorToReport.message}\\n${mappedStacktrace}`\n } else if (typeof errorToReport === 'string') {\n mappedError = new Error(errorToReport)\n } else {\n mappedError = new Error('Unknown error')\n }\n\n await new Promise((resolve, reject) => {\n Bugsnag.notify(mappedError, undefined, resolve)\n })\n return mappedError\n}\n\nexport default runCLI\n"]}
@@ -0,0 +1 @@
1
+ export declare const colors: any;
@@ -0,0 +1,8 @@
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');
8
+ //# sourceMappingURL=colors.js.map
@@ -0,0 +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"]}
@@ -0,0 +1,33 @@
1
+ import { Abort } from '../error.js';
2
+ /**
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.
6
+ */
7
+ export declare const DotEnvNotFoundError: (path: string) => Abort;
8
+ /**
9
+ * This interface represents a .env file.
10
+ */
11
+ export interface DotEnvFile {
12
+ /**
13
+ * Path to the .env file.
14
+ */
15
+ path: string;
16
+ /**
17
+ * Variables of the .env file.
18
+ */
19
+ variables: {
20
+ [name: string]: string;
21
+ };
22
+ }
23
+ /**
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.
27
+ */
28
+ export declare function readAndParseDotEnv(path: string): Promise<DotEnvFile>;
29
+ /**
30
+ * Writes a .env file to disk.
31
+ * @param file {DotEnvFile} .env file to be written.
32
+ */
33
+ export declare function writeDotEnv(file: DotEnvFile): Promise<void>;
@@ -0,0 +1,36 @@
1
+ import { Abort } from '../error.js';
2
+ import { exists, read as readFile, write as writeFile } from '../file.js';
3
+ import { debug, content as outputContent, token } from '../output.js';
4
+ import { parse, stringify } from 'envfile';
5
+ /**
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.
9
+ */
10
+ export const DotEnvNotFoundError = (path) => {
11
+ return new Abort(`The environment file at ${path} does not exist.`);
12
+ };
13
+ /**
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.
17
+ */
18
+ export async function readAndParseDotEnv(path) {
19
+ debug(outputContent `Reading the .env file at ${token.path(path)}`);
20
+ if (!(await exists(path))) {
21
+ throw DotEnvNotFoundError(path);
22
+ }
23
+ const content = await readFile(path);
24
+ return {
25
+ path,
26
+ variables: parse(content),
27
+ };
28
+ }
29
+ /**
30
+ * Writes a .env file to disk.
31
+ * @param file {DotEnvFile} .env file to be written.
32
+ */
33
+ export async function writeDotEnv(file) {
34
+ await writeFile(file.path, stringify(file.variables));
35
+ }
36
+ //# sourceMappingURL=dot-env.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dot-env.js","sourceRoot":"","sources":["../../src/node/dot-env.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,KAAK,EAAC,MAAM,aAAa,CAAA;AACjC,OAAO,EAAC,MAAM,EAAE,IAAI,IAAI,QAAQ,EAAE,KAAK,IAAI,SAAS,EAAC,MAAM,YAAY,CAAA;AACvE,OAAO,EAAC,KAAK,EAAE,OAAO,IAAI,aAAa,EAAE,KAAK,EAAC,MAAM,cAAc,CAAA;AACnE,OAAO,EAAC,KAAK,EAAE,SAAS,EAAC,MAAM,SAAS,CAAA;AAExC;;;;GAIG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,IAAY,EAAE,EAAE;IAClD,OAAO,IAAI,KAAK,CAAC,2BAA2B,IAAI,kBAAkB,CAAC,CAAA;AACrE,CAAC,CAAA;AAgBD;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,kBAAkB,CAAC,IAAY;IACnD,KAAK,CAAC,aAAa,CAAA,4BAA4B,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;IAClE,IAAI,CAAC,CAAC,MAAM,MAAM,CAAC,IAAI,CAAC,CAAC,EAAE;QACzB,MAAM,mBAAmB,CAAC,IAAI,CAAC,CAAA;KAChC;IACD,MAAM,OAAO,GAAG,MAAM,QAAQ,CAAC,IAAI,CAAC,CAAA;IACpC,OAAO;QACL,IAAI;QACJ,SAAS,EAAE,KAAK,CAAC,OAAO,CAAC;KAC1B,CAAA;AACH,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,WAAW,CAAC,IAAgB;IAChD,MAAM,SAAS,CAAC,IAAI,CAAC,IAAI,EAAE,SAAS,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAA;AACvD,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"]}
@@ -0,0 +1,197 @@
1
+ /// <reference types="node" />
2
+ /// <reference types="node" />
3
+ import { Abort, Bug } from '../error.js';
4
+ import { AbortSignal } from 'abort-controller';
5
+ import type { Writable } from 'node:stream';
6
+ /** The name of the Yarn lock file */
7
+ export declare const yarnLockfile = "yarn.lock";
8
+ /** The name of the pnpm lock file */
9
+ export declare const pnpmLockfile = "pnpm-lock.yaml";
10
+ /** An array containing the lockfiles from all the package managers */
11
+ export declare const lockfiles: string[];
12
+ /**
13
+ * A union type that represents the type of dependencies in the package.json
14
+ * - dev: devDependencies
15
+ * - prod: dependencies
16
+ * - peer: peerDependencies
17
+ */
18
+ export declare type DependencyType = 'dev' | 'prod' | 'peer';
19
+ /**
20
+ * A union that represents the package managers available.
21
+ */
22
+ export declare const packageManager: readonly ["yarn", "npm", "pnpm"];
23
+ export declare type PackageManager = typeof packageManager[number];
24
+ /**
25
+ * Returns an abort error that's thrown when a directory that's expected to have
26
+ * a package.json doesn't have it.
27
+ * @param directory {string} The path to the directory that should contain a package.json
28
+ * @returns {Abort} An abort error.
29
+ */
30
+ export declare const PackageJsonNotFoundError: (directory: string) => Abort;
31
+ /**
32
+ * Returns a bug error that's thrown when the lookup of the package.json traversing the directory
33
+ * hierarchy up can't find a package.json
34
+ * @param directory {string} The directory from which the traverse has been done
35
+ * @returns {Abort} An abort error.
36
+ */
37
+ export declare const FindUpAndReadPackageJsonNotFoundError: (directory: string) => Bug;
38
+ /**
39
+ * Returns the dependency manager used to run the create workflow.
40
+ * @param env {Object} The environment variables of the process in which the CLI runs.
41
+ * @returns The dependency manager
42
+ */
43
+ export declare function packageManagerUsedForCreating(env?: NodeJS.ProcessEnv): PackageManager;
44
+ /**
45
+ * Returns the dependency manager used by an existing project.
46
+ * @param directory {string} The root directory of the project.
47
+ * @returns The dependency manager
48
+ */
49
+ export declare function getPackageManager(directory: string): Promise<PackageManager>;
50
+ interface InstallNPMDependenciesRecursivelyOptions {
51
+ /**
52
+ * The dependency manager to use to install the dependencies.
53
+ */
54
+ packageManager: PackageManager;
55
+ /**
56
+ * The directory from where we'll find package.json's recursively
57
+ */
58
+ directory: string;
59
+ /**
60
+ * Specifies the maximum depth of the glob search.
61
+ */
62
+ deep?: number;
63
+ }
64
+ /**
65
+ * This function traverses down a directory tree to find directories containing a package.json
66
+ * and installs the dependencies if needed. To know if it's needed, it uses the "check" command
67
+ * provided by dependency managers.
68
+ * @param options {InstallNPMDependenciesRecursivelyOptions} Options to install dependencies recursively.
69
+ */
70
+ export declare function installNPMDependenciesRecursively(options: InstallNPMDependenciesRecursivelyOptions): Promise<void>;
71
+ /**
72
+ * Installs the dependencies in the given directory.
73
+ * @param directory {string} The directory that contains the package.json
74
+ * @param packageManager {PackageManager} The package manager to use to install the dependencies.
75
+ * @param stdout {Writable} Standard output stream.
76
+ * @param stderr {Writable} Standard error stream.
77
+ * @param signal {AbortSignal} Abort signal.
78
+ * @returns stderr {Writable} Standard error stream.
79
+ */
80
+ export declare function installNodeModules(directory: string, packageManager: PackageManager, stdout?: Writable, stderr?: Writable, signal?: AbortSignal): Promise<void>;
81
+ /**
82
+ * Returns the name of the package configured in its package.json
83
+ * @param packageJsonPath {string} Path to the package.json file
84
+ * @returns A promise that resolves with the name.
85
+ */
86
+ export declare function getPackageName(packageJsonPath: string): Promise<string>;
87
+ /**
88
+ * Returns the list of production and dev dependencies of a package.json
89
+ * @param packageJsonPath {string} Path to the package.json file
90
+ * @returns A promise that resolves with the list of dependencies.
91
+ */
92
+ export declare function getDependencies(packageJsonPath: string): Promise<{
93
+ [key: string]: string;
94
+ }>;
95
+ /**
96
+ * Given an NPM dependency, it checks if there's a more recent version, and if there is, it returns its value.
97
+ * @param dependency {string} The dependency name (e.g. react)
98
+ * @param currentVersion {string} The current version.
99
+ * @returns {Promise<string>} A promise that resolves with a more recent version or undefined if there's no more recent version.
100
+ */
101
+ export declare function checkForNewVersion(dependency: string, currentVersion: string): Promise<string | undefined>;
102
+ /**
103
+ * An interface that represents a package.json
104
+ */
105
+ interface PackageJson {
106
+ /**
107
+ * The absolute path to the package.json
108
+ */
109
+ path: string;
110
+ /**
111
+ * The name attribute of the package.json
112
+ */
113
+ name: string;
114
+ /**
115
+ * The version attribute of the package.json
116
+ */
117
+ version?: string;
118
+ /**
119
+ * The dependencies attribute of the package.json
120
+ */
121
+ dependencies?: {
122
+ [key: string]: string;
123
+ };
124
+ /**
125
+ * The devDependencies attribute of the package.json
126
+ */
127
+ devDependencies?: {
128
+ [key: string]: string;
129
+ };
130
+ }
131
+ /**
132
+ * Reads and parses a package.json
133
+ * @param packageJsonPath {string} Path to the package.json
134
+ * @returns {Promise<PackageJson>} An promise that resolves with an in-memory representation
135
+ * of the package.json or rejects with an error if the file is not found or the content is
136
+ * not decodable.
137
+ */
138
+ export declare function readAndParsePackageJson(packageJsonPath: string): Promise<PackageJson>;
139
+ interface AddNPMDependenciesIfNeededOptions {
140
+ /** How dependencies should be added */
141
+ type: DependencyType;
142
+ /** The dependency manager to use to add dependencies */
143
+ packageManager: PackageManager;
144
+ /** The directory that contains the package.json where dependencies will be added */
145
+ directory: string;
146
+ /** Standard output coming from the underlying installation process */
147
+ stdout?: Writable;
148
+ /** Standard error coming from the underlying installation process */
149
+ stderr?: Writable;
150
+ /** Abort signal to stop the process */
151
+ signal?: AbortSignal;
152
+ }
153
+ /**
154
+ * An interface that represents a dependency name with its version
155
+ */
156
+ export interface DependencyVersion {
157
+ /**
158
+ * The name of the NPM dependency as it's reflected in the package.json:
159
+ *
160
+ * @example
161
+ * In the example below name would be "react"
162
+ * {
163
+ * "react": "1.2.3"
164
+ * }
165
+ */
166
+ name: string;
167
+ /**
168
+ * The version of the NPM dependency as it's reflected in the package.json:
169
+ *
170
+ * @example
171
+ * In the example below version would be "1.2.3"
172
+ * {
173
+ * "react": "1.2.3"
174
+ * }
175
+ */
176
+ version: string | undefined;
177
+ }
178
+ /**
179
+ * Adds dependencies to a Node project (i.e. a project that has a package.json)
180
+ * @param dependencies {string[]} List of dependencies to be added.
181
+ * @param options {AddNPMDependenciesIfNeededOptions} Options for adding dependencies.
182
+ */
183
+ export declare function addNPMDependenciesIfNeeded(dependencies: DependencyVersion[], options: AddNPMDependenciesIfNeededOptions, force?: boolean): Promise<void>;
184
+ export declare function addNPMDependenciesWithoutVersionIfNeeded(dependencies: string[], options: AddNPMDependenciesIfNeededOptions): Promise<void>;
185
+ export declare function addLatestNPMDependencies(dependencies: string[], options: AddNPMDependenciesIfNeededOptions): Promise<void>;
186
+ /**
187
+ * Given a directory it traverses the directory up looking for a package.json and if found, it reads it
188
+ * decodes the JSON, and returns its content as a Javascript object.
189
+ * @param options {string} The directory from which traverse up.
190
+ * @returns {Promise<{path: string; content: unknown}>} If found, the promise resolves with the path to the
191
+ * package.json and its content. If not found, it throws a FindUpAndReadPackageJsonNotFoundError error.
192
+ */
193
+ export declare function findUpAndReadPackageJson(fromDirectory: string): Promise<{
194
+ path: string;
195
+ content: unknown;
196
+ }>;
197
+ export {};