@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,61 @@
1
+ import { partners as partnersEnvironment, shopify as shopifyEnvironment, identity as identityEnvironment, } from './service.js';
2
+ import { fqdn as spinFqdn } from './spin.js';
3
+ import { Abort } from '../error.js';
4
+ export const CouldntObtainPartnersSpinFQDNError = new Abort("Couldn't obtain the Spin FQDN for Partners when the CLI is not running from a Spin environment.");
5
+ export const CouldntObtainIdentitySpinFQDNError = new Abort("Couldn't obtain the Spin FQDN for Identity when the CLI is not running from a Spin environment.");
6
+ export const CouldntObtainShopifySpinFQDNError = new Abort("Couldn't obtain the Spin FQDN for Shopify when the CLI is not running from a Spin environment.");
7
+ export const NotProvidedStoreFQDNError = new Abort("Couldn't obtain the Shopify FQDN because the store FQDN was not provided.");
8
+ /**
9
+ * It returns the Partners' API service we should interact with.
10
+ * @returns {string} Fully-qualified domain of the partners service we should interact with.
11
+ */
12
+ export async function partners() {
13
+ const environment = partnersEnvironment();
14
+ const productionFqdn = 'partners.shopify.com';
15
+ switch (environment) {
16
+ case 'local':
17
+ return 'partners.myshopify.io';
18
+ case 'spin':
19
+ return `partners.${await spinFqdn()}`;
20
+ default:
21
+ return productionFqdn;
22
+ }
23
+ }
24
+ /**
25
+ * It returns the Identity service we should interact with.
26
+ * @returns {string} Fully-qualified domain of the Identity service we should interact with.
27
+ */
28
+ export async function identity() {
29
+ const environment = identityEnvironment();
30
+ const productionFqdn = 'accounts.shopify.com';
31
+ switch (environment) {
32
+ case 'local':
33
+ return 'identity.myshopify.io';
34
+ case 'spin':
35
+ return `identity.${await spinFqdn()}`;
36
+ default:
37
+ return productionFqdn;
38
+ }
39
+ }
40
+ /**
41
+ * It returns the Shopify service we should interact with.
42
+ * Note the same fqdn is sued for the Admin and the Storefront Renderer APIs.
43
+ * @returns {string} Fully-qualified domain of the Shopify service we should interact with.
44
+ */
45
+ export async function shopify(options = {}) {
46
+ const environment = shopifyEnvironment();
47
+ switch (environment) {
48
+ case 'local':
49
+ return 'shopify.myshopify.io';
50
+ case 'spin':
51
+ return `identity.${await spinFqdn()}`;
52
+ default:
53
+ if (options.storeFqdn) {
54
+ return options.storeFqdn;
55
+ }
56
+ else {
57
+ throw NotProvidedStoreFQDNError;
58
+ }
59
+ }
60
+ }
61
+ //# sourceMappingURL=fqdn.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fqdn.js","sourceRoot":"","sources":["../../src/environment/fqdn.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,IAAI,mBAAmB,EAC/B,OAAO,IAAI,kBAAkB,EAC7B,QAAQ,IAAI,mBAAmB,GAChC,MAAM,cAAc,CAAA;AACrB,OAAO,EAAC,IAAI,IAAI,QAAQ,EAAC,MAAM,WAAW,CAA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,CAAA;QACvC;YACE,IAAI,OAAO,CAAC,SAAS,EAAE;gBACrB,OAAO,OAAO,CAAC,SAAS,CAAA;aACzB;iBAAM;gBACL,MAAM,yBAAyB,CAAA;aAChC;KACJ;AACH,CAAC","sourcesContent":["import {\n partners as partnersEnvironment,\n shopify as shopifyEnvironment,\n identity as identityEnvironment,\n} from './service.js'\nimport {fqdn as spinFqdn} from './spin.js'\nimport {Abort} from '../error.js'\n\nexport const CouldntObtainPartnersSpinFQDNError = new Abort(\n \"Couldn't obtain the Spin FQDN for Partners when the CLI is not running from a Spin environment.\",\n)\nexport const CouldntObtainIdentitySpinFQDNError = new Abort(\n \"Couldn't obtain the Spin FQDN for Identity when the CLI is not running from a Spin environment.\",\n)\nexport const CouldntObtainShopifySpinFQDNError = new Abort(\n \"Couldn't obtain the Spin FQDN for Shopify when the CLI is not running from a Spin environment.\",\n)\nexport const NotProvidedStoreFQDNError = new Abort(\n \"Couldn't obtain the Shopify FQDN because the store FQDN was not provided.\",\n)\n\n/**\n * It returns the Partners' API service we should interact with.\n * @returns {string} Fully-qualified domain of the partners service we should interact with.\n */\nexport async function partners(): Promise<string> {\n const environment = partnersEnvironment()\n const productionFqdn = 'partners.shopify.com'\n switch (environment) {\n case 'local':\n return 'partners.myshopify.io'\n case 'spin':\n return `partners.${await spinFqdn()}`\n default:\n return productionFqdn\n }\n}\n\n/**\n * It returns the Identity service we should interact with.\n * @returns {string} Fully-qualified domain of the Identity service we should interact with.\n */\nexport async function identity(): Promise<string> {\n const environment = identityEnvironment()\n const productionFqdn = 'accounts.shopify.com'\n switch (environment) {\n case 'local':\n return 'identity.myshopify.io'\n case 'spin':\n return `identity.${await spinFqdn()}`\n default:\n return productionFqdn\n }\n}\n\n/**\n * It returns the Shopify service we should interact with.\n * Note the same fqdn is sued for the Admin and the Storefront Renderer APIs.\n * @returns {string} Fully-qualified domain of the Shopify service we should interact with.\n */\nexport async function shopify(options: {storeFqdn?: string} = {}): Promise<string> {\n const environment = shopifyEnvironment()\n switch (environment) {\n case 'local':\n return 'shopify.myshopify.io'\n case 'spin':\n return `identity.${await spinFqdn()}`\n default:\n if (options.storeFqdn) {\n return options.storeFqdn\n } else {\n throw NotProvidedStoreFQDNError\n }\n }\n}\n"]}
@@ -0,0 +1,48 @@
1
+ /// <reference types="node" />
2
+ /**
3
+ * It returns true if the terminal is interactive.
4
+ * @returns {boolean} True if the terminal is interactive.
5
+ */
6
+ export declare function isTerminalInteractive(): boolean;
7
+ /**
8
+ * Returns the path to the user's home directory.
9
+ * @returns {string} The path to the user's home directory.
10
+ */
11
+ export declare function homeDirectory(): string;
12
+ /**
13
+ * Returns true if the CLI is running in debug mode.
14
+ * @param env The environment variables from the environment of the current process.
15
+ * @returns true if SHOPIFY_CONFIG is debug
16
+ */
17
+ export declare function isDebug(env?: NodeJS.ProcessEnv): boolean;
18
+ /**
19
+ * Returns true if the CLI is running in verbose mode.
20
+ * @param env The environment variables from the environment of the current process.
21
+ * @returns true if SHOPIFY_FLAG_VERBOSE is truthy or the flag --verbose has been passed
22
+ */
23
+ export declare function isVerbose(env?: NodeJS.ProcessEnv): boolean;
24
+ /**
25
+ * Returns true if the environment in which the CLI is running is either
26
+ * a local environment (where dev is present) or a cloud environment (spin).
27
+ * @returns {boolean} True if the CLI is used in a Shopify environment.
28
+ */
29
+ export declare function isShopify(env?: NodeJS.ProcessEnv): Promise<boolean>;
30
+ /**
31
+ * This variable is used when running unit tests to indicate that the CLI's business logic
32
+ * is run as a subject of a unit test. We can use this variable to disable output through
33
+ * the standard streams.
34
+ * @param env The environment variables from the environment of the current process.
35
+ * @returns True if the SHOPIFY_UNIT_TEST environment variable is truthy.
36
+ */
37
+ export declare function isUnitTest(env?: NodeJS.ProcessEnv): boolean;
38
+ /**
39
+ * Returns true if reporting analytics is enabled.
40
+ * @param env The environment variables from the environment of the current process.
41
+ * @returns true unless SHOPIFY_CLI_NO_ANALYTICS is truthy or debug mode is enabled.
42
+ */
43
+ export declare function analyticsDisabled(env?: NodeJS.ProcessEnv): boolean;
44
+ /**
45
+ * Returns whether the environment has Git available.
46
+ * @returns {Promise<boolean>} A promise that resolves with the value.
47
+ */
48
+ export declare function hasGit(): Promise<boolean>;
@@ -0,0 +1,82 @@
1
+ import { isTruthy } from './utilities.js';
2
+ import { isSpin } from './spin.js';
3
+ import constants from '../constants.js';
4
+ import { exists as fileExists } from '../file.js';
5
+ import { exec } from '../system.js';
6
+ import isInteractive from 'is-interactive';
7
+ import { homedir } from 'node:os';
8
+ /**
9
+ * It returns true if the terminal is interactive.
10
+ * @returns {boolean} True if the terminal is interactive.
11
+ */
12
+ export function isTerminalInteractive() {
13
+ return isInteractive();
14
+ }
15
+ /**
16
+ * Returns the path to the user's home directory.
17
+ * @returns {string} The path to the user's home directory.
18
+ */
19
+ export function homeDirectory() {
20
+ return homedir();
21
+ }
22
+ /**
23
+ * Returns true if the CLI is running in debug mode.
24
+ * @param env The environment variables from the environment of the current process.
25
+ * @returns true if SHOPIFY_CONFIG is debug
26
+ */
27
+ export function isDebug(env = process.env) {
28
+ return env[constants.environmentVariables.shopifyConfig] === 'debug';
29
+ }
30
+ /**
31
+ * Returns true if the CLI is running in verbose mode.
32
+ * @param env The environment variables from the environment of the current process.
33
+ * @returns true if SHOPIFY_FLAG_VERBOSE is truthy or the flag --verbose has been passed
34
+ */
35
+ export function isVerbose(env = process.env) {
36
+ return isTruthy(env[constants.environmentVariables.verbose]) || process.argv.includes('--verbose');
37
+ }
38
+ /**
39
+ * Returns true if the environment in which the CLI is running is either
40
+ * a local environment (where dev is present) or a cloud environment (spin).
41
+ * @returns {boolean} True if the CLI is used in a Shopify environment.
42
+ */
43
+ export async function isShopify(env = process.env) {
44
+ if (Object.prototype.hasOwnProperty.call(env, constants.environmentVariables.runAsUser)) {
45
+ return !isTruthy(env[constants.environmentVariables.runAsUser]);
46
+ }
47
+ const devInstalled = await fileExists(constants.paths.executables.dev);
48
+ return devInstalled || isSpin();
49
+ }
50
+ /**
51
+ * This variable is used when running unit tests to indicate that the CLI's business logic
52
+ * is run as a subject of a unit test. We can use this variable to disable output through
53
+ * the standard streams.
54
+ * @param env The environment variables from the environment of the current process.
55
+ * @returns True if the SHOPIFY_UNIT_TEST environment variable is truthy.
56
+ */
57
+ export function isUnitTest(env = process.env) {
58
+ return isTruthy(env[constants.environmentVariables.unitTest]);
59
+ }
60
+ /**
61
+ * Returns true if reporting analytics is enabled.
62
+ * @param env The environment variables from the environment of the current process.
63
+ * @returns true unless SHOPIFY_CLI_NO_ANALYTICS is truthy or debug mode is enabled.
64
+ */
65
+ export function analyticsDisabled(env = process.env) {
66
+ return isTruthy(env[constants.environmentVariables.noAnalytics]) || isDebug(env);
67
+ }
68
+ /**
69
+ * Returns whether the environment has Git available.
70
+ * @returns {Promise<boolean>} A promise that resolves with the value.
71
+ */
72
+ export async function hasGit() {
73
+ try {
74
+ await exec('git', ['--version']);
75
+ return true;
76
+ // eslint-disable-next-line no-catch-all/no-catch-all
77
+ }
78
+ catch {
79
+ return false;
80
+ }
81
+ }
82
+ //# sourceMappingURL=local.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"local.js","sourceRoot":"","sources":["../../src/environment/local.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,QAAQ,EAAC,MAAM,gBAAgB,CAAA;AACvC,OAAO,EAAC,MAAM,EAAC,MAAM,WAAW,CAAA;AAChC,OAAO,SAAS,MAAM,iBAAiB,CAAA;AACvC,OAAO,EAAC,MAAM,IAAI,UAAU,EAAC,MAAM,YAAY,CAAA;AAC/C,OAAO,EAAC,IAAI,EAAC,MAAM,cAAc,CAAA;AACjC,OAAO,aAAa,MAAM,gBAAgB,CAAA;AAC1C,OAAO,EAAC,OAAO,EAAC,MAAM,SAAS,CAAA;AAE/B;;;GAGG;AACH,MAAM,UAAU,qBAAqB;IACnC,OAAO,aAAa,EAAE,CAAA;AACxB,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,aAAa;IAC3B,OAAO,OAAO,EAAE,CAAA;AAClB,CAA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C;AAED;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,MAAM;IAC1B,IAAI;QACF,MAAM,IAAI,CAAC,KAAK,EAAE,CAAC,WAAW,CAAC,CAAC,CAAA;QAChC,OAAO,IAAI,CAAA;QACX,qDAAqD;KACtD;IAAC,MAAM;QACN,OAAO,KAAK,CAAA;KACb;AACH,CAAC","sourcesContent":["import {isTruthy} from './utilities.js'\nimport {isSpin} from './spin.js'\nimport constants from '../constants.js'\nimport {exists as fileExists} from '../file.js'\nimport {exec} from '../system.js'\nimport isInteractive from 'is-interactive'\nimport {homedir} from 'node:os'\n\n/**\n * It returns true if the terminal is interactive.\n * @returns {boolean} True if the terminal is interactive.\n */\nexport function isTerminalInteractive(): boolean {\n return isInteractive()\n}\n\n/**\n * Returns the path to the user's home directory.\n * @returns {string} The path to the user's home directory.\n */\nexport function homeDirectory(): string {\n return homedir()\n}\n\n/**\n * Returns true if the CLI is running in debug mode.\n * @param env The environment variables from the environment of the current process.\n * @returns true if SHOPIFY_CONFIG is debug\n */\nexport function isDebug(env = process.env): boolean {\n return env[constants.environmentVariables.shopifyConfig] === 'debug'\n}\n\n/**\n * Returns true if the CLI is running in verbose mode.\n * @param env The environment variables from the environment of the current process.\n * @returns true if SHOPIFY_FLAG_VERBOSE is truthy or the flag --verbose has been passed\n */\nexport function isVerbose(env = process.env): boolean {\n return isTruthy(env[constants.environmentVariables.verbose]) || process.argv.includes('--verbose')\n}\n\n/**\n * Returns true if the environment in which the CLI is running is either\n * a local environment (where dev is present) or a cloud environment (spin).\n * @returns {boolean} True if the CLI is used in a Shopify environment.\n */\nexport async function isShopify(env = process.env): Promise<boolean> {\n if (Object.prototype.hasOwnProperty.call(env, constants.environmentVariables.runAsUser)) {\n return !isTruthy(env[constants.environmentVariables.runAsUser])\n }\n const devInstalled = await fileExists(constants.paths.executables.dev)\n return devInstalled || isSpin()\n}\n\n/**\n * This variable is used when running unit tests to indicate that the CLI's business logic\n * is run as a subject of a unit test. We can use this variable to disable output through\n * the standard streams.\n * @param env The environment variables from the environment of the current process.\n * @returns True if the SHOPIFY_UNIT_TEST environment variable is truthy.\n */\nexport function isUnitTest(env = process.env): boolean {\n return isTruthy(env[constants.environmentVariables.unitTest])\n}\n\n/**\n * Returns true if reporting analytics is enabled.\n * @param env The environment variables from the environment of the current process.\n * @returns true unless SHOPIFY_CLI_NO_ANALYTICS is truthy or debug mode is enabled.\n */\nexport function analyticsDisabled(env = process.env): boolean {\n return isTruthy(env[constants.environmentVariables.noAnalytics]) || isDebug(env)\n}\n\n/**\n * Returns whether the environment has Git available.\n * @returns {Promise<boolean>} A promise that resolves with the value.\n */\nexport async function hasGit(): Promise<boolean> {\n try {\n await exec('git', ['--version'])\n return true\n // eslint-disable-next-line no-catch-all/no-catch-all\n } catch {\n return false\n }\n}\n"]}
@@ -0,0 +1,17 @@
1
+ /// <reference types="node" />
2
+ import { Environment } from '../network/service.js';
3
+ /**
4
+ * Returns the environment to be used for the interactions with the partners' CLI API.
5
+ * @param env The environment variables from the environment of the current process.
6
+ */
7
+ export declare function partners(env?: NodeJS.ProcessEnv): Environment;
8
+ /**
9
+ * Returns the environment to be used for the interactions with the admin API.
10
+ * @param env The environment variables from the environment of the current process.
11
+ */
12
+ export declare function shopify(env?: NodeJS.ProcessEnv): Environment;
13
+ /**
14
+ * Returns the environment to be used for the interactions with identity.
15
+ * @param env The environment variables from the environment of the current process.
16
+ */
17
+ export declare function identity(env?: NodeJS.ProcessEnv): Environment;
@@ -0,0 +1,41 @@
1
+ import { Environment } from '../network/service.js';
2
+ import constants from '../constants.js';
3
+ /**
4
+ * Given an environment variable that represents the environment to use for a given serve,
5
+ * it returns the environment as a enum;
6
+ * @param value The environment variable value.
7
+ * @returns {Environment} representing the environment to use.
8
+ */
9
+ function service(value) {
10
+ if (value === 'local') {
11
+ return Environment.Local;
12
+ }
13
+ else if (value === 'spin') {
14
+ return Environment.Spin;
15
+ }
16
+ else {
17
+ return Environment.Production;
18
+ }
19
+ }
20
+ /**
21
+ * Returns the environment to be used for the interactions with the partners' CLI API.
22
+ * @param env The environment variables from the environment of the current process.
23
+ */
24
+ export function partners(env = process.env) {
25
+ return service(env[constants.environmentVariables.partnersEnv]);
26
+ }
27
+ /**
28
+ * Returns the environment to be used for the interactions with the admin API.
29
+ * @param env The environment variables from the environment of the current process.
30
+ */
31
+ export function shopify(env = process.env) {
32
+ return service(env[constants.environmentVariables.shopifyEnv]);
33
+ }
34
+ /**
35
+ * Returns the environment to be used for the interactions with identity.
36
+ * @param env The environment variables from the environment of the current process.
37
+ */
38
+ export function identity(env = process.env) {
39
+ return service(env[constants.environmentVariables.identityEnv]);
40
+ }
41
+ //# sourceMappingURL=service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"service.js","sourceRoot":"","sources":["../../src/environment/service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,WAAW,EAAC,MAAM,uBAAuB,CAAA;AACjD,OAAO,SAAS,MAAM,iBAAiB,CAAA;AAEvC;;;;;GAKG;AACH,SAAS,OAAO,CAAC,KAAyB;IACxC,IAAI,KAAK,KAAK,OAAO,EAAE;QACrB,OAAO,WAAW,CAAC,KAAK,CAAA;KACzB;SAAM,IAAI,KAAK,KAAK,MAAM,EAAE;QAC3B,OAAO,WAAW,CAAC,IAAI,CAAA;KACxB;SAAM;QACL,OAAO,WAAW,CAAC,UAAU,CAAA;KAC9B;AACH,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,QAAQ,CAAC,GAAG,GAAG,OAAO,CAAC,GAAG;IACxC,OAAO,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC,oBAAoB,CAAC,WAAW,CAAC,CAAC,CAAA;AACjE,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,OAAO,CAAC,GAAG,GAAG,OAAO,CAAC,GAAG;IACvC,OAAO,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC,oBAAoB,CAAC,UAAU,CAAC,CAAC,CAAA;AAChE,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,QAAQ,CAAC,GAAG,GAAG,OAAO,CAAC,GAAG;IACxC,OAAO,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC,oBAAoB,CAAC,WAAW,CAAC,CAAC,CAAA;AACjE,CAAC","sourcesContent":["import {Environment} from '../network/service.js'\nimport constants from '../constants.js'\n\n/**\n * Given an environment variable that represents the environment to use for a given serve,\n * it returns the environment as a enum;\n * @param value The environment variable value.\n * @returns {Environment} representing the environment to use.\n */\nfunction service(value: undefined | string): Environment {\n if (value === 'local') {\n return Environment.Local\n } else if (value === 'spin') {\n return Environment.Spin\n } else {\n return Environment.Production\n }\n}\n\n/**\n * Returns the environment to be used for the interactions with the partners' CLI API.\n * @param env The environment variables from the environment of the current process.\n */\nexport function partners(env = process.env): Environment {\n return service(env[constants.environmentVariables.partnersEnv])\n}\n\n/**\n * Returns the environment to be used for the interactions with the admin API.\n * @param env The environment variables from the environment of the current process.\n */\nexport function shopify(env = process.env): Environment {\n return service(env[constants.environmentVariables.shopifyEnv])\n}\n\n/**\n * Returns the environment to be used for the interactions with identity.\n * @param env The environment variables from the environment of the current process.\n */\nexport function identity(env = process.env): Environment {\n return service(env[constants.environmentVariables.identityEnv])\n}\n"]}
@@ -0,0 +1,47 @@
1
+ /// <reference types="node" />
2
+ import { Abort } from '../error.js';
3
+ export declare const SpinInstanceNotFound: (spinInstance: string | undefined, error: string) => Abort;
4
+ /**
5
+ * When ran in a Spin environment, it returns the fqdn of the instance.
6
+ * @returns {string} fqdn of the Spin environment.
7
+ */
8
+ export declare function fqdn(env?: NodeJS.ProcessEnv): Promise<string>;
9
+ /**
10
+ * Runs "spin show" and returns the JSON-parsed output.
11
+ * @param {latest} Whether to pass --latest when running the command.
12
+ * @returns The JSON-parsed output of the Spin CLI.
13
+ * @throws Any error raised from the underlying Spin CLI.
14
+ */
15
+ export declare function show(spinInstance: string | undefined, env?: NodeJS.ProcessEnv): Promise<{
16
+ fqdn: string;
17
+ }>;
18
+ /**
19
+ * Returns true if the CLI is running in a Spin environment.
20
+ * @param env {[key: string]: string} Environment variables
21
+ * @returns {boolean} True if the CLI is running in a Spin environment.
22
+ */
23
+ export declare function isSpin(env?: NodeJS.ProcessEnv): boolean;
24
+ /**
25
+ * Returns the value of the SPIN_INSTANCE environment variable.
26
+ * @param env {[key: string]: string} Environment variables
27
+ * @returns {string | undefined} The value of the SPIN_INSTANCE environment variable.
28
+ */
29
+ export declare function instance(env?: NodeJS.ProcessEnv): string | undefined;
30
+ /**
31
+ * Returns the value of the SPIN_WORKSPACE environment variable.
32
+ * @param env {[key: string]: string} Environment variables
33
+ * @returns {string | undefined} The value of the SPIN_WORKSPACE environment variable.
34
+ */
35
+ export declare function workspace(env?: NodeJS.ProcessEnv): string | undefined;
36
+ /**
37
+ * Returns the value of the SPIN_NAMESPACE environment variable.
38
+ * @param env {[key: string]: string} Environment variables
39
+ * @returns {string | undefined} The value of the SPIN_NAMESPACE environment variable.
40
+ */
41
+ export declare function namespace(env?: NodeJS.ProcessEnv): string | undefined;
42
+ /**
43
+ * Returns the value of the SPIN_HOST environment variable.
44
+ * @param env {[key: string]: string} Environment variables
45
+ * @returns {string | undefined} The value of the SPIN_HOST environment variable.
46
+ */
47
+ export declare function host(env?: NodeJS.ProcessEnv): string | undefined;
@@ -0,0 +1,83 @@
1
+ import { isTruthy } from './utilities.js';
2
+ import constants from '../constants.js';
3
+ import { captureOutput } from '../system.js';
4
+ import { Abort } from '../error.js';
5
+ import { content, token } from '../output.js';
6
+ export const SpinInstanceNotFound = (spinInstance, error) => {
7
+ const errorMessage = content `${token.genericShellCommand(`spin`)} yielded the following error trying to obtain the fully qualified domain name of the Spin instance:
8
+ ${error}
9
+ `;
10
+ let nextSteps;
11
+ if (spinInstance) {
12
+ nextSteps = `Make sure ${spinInstance} is the instance name and not a fully qualified domain name`;
13
+ }
14
+ return new Abort(errorMessage, nextSteps);
15
+ };
16
+ /**
17
+ * When ran in a Spin environment, it returns the fqdn of the instance.
18
+ * @returns {string} fqdn of the Spin environment.
19
+ */
20
+ export async function fqdn(env = process.env) {
21
+ const spinInstance = await instance(env);
22
+ const showResponse = await show(spinInstance, env);
23
+ return showResponse.fqdn;
24
+ }
25
+ /**
26
+ * Runs "spin show" and returns the JSON-parsed output.
27
+ * @param {latest} Whether to pass --latest when running the command.
28
+ * @returns The JSON-parsed output of the Spin CLI.
29
+ * @throws Any error raised from the underlying Spin CLI.
30
+ */
31
+ export async function show(spinInstance, env = process.env) {
32
+ const latest = spinInstance === undefined;
33
+ const args = latest ? ['show', '--latest', '--json'] : ['show', '--json'];
34
+ const output = await captureOutput('spin', args, { env });
35
+ const json = JSON.parse(output);
36
+ if (json.error) {
37
+ throw SpinInstanceNotFound(spinInstance, json.error);
38
+ }
39
+ else {
40
+ return json;
41
+ }
42
+ }
43
+ /**
44
+ * Returns true if the CLI is running in a Spin environment.
45
+ * @param env {[key: string]: string} Environment variables
46
+ * @returns {boolean} True if the CLI is running in a Spin environment.
47
+ */
48
+ export function isSpin(env = process.env) {
49
+ return isTruthy(env[constants.environmentVariables.spin]);
50
+ }
51
+ /**
52
+ * Returns the value of the SPIN_INSTANCE environment variable.
53
+ * @param env {[key: string]: string} Environment variables
54
+ * @returns {string | undefined} The value of the SPIN_INSTANCE environment variable.
55
+ */
56
+ export function instance(env = process.env) {
57
+ return env[constants.environmentVariables.spinInstance];
58
+ }
59
+ /**
60
+ * Returns the value of the SPIN_WORKSPACE environment variable.
61
+ * @param env {[key: string]: string} Environment variables
62
+ * @returns {string | undefined} The value of the SPIN_WORKSPACE environment variable.
63
+ */
64
+ export function workspace(env = process.env) {
65
+ return env[constants.environmentVariables.spinWorkspace];
66
+ }
67
+ /**
68
+ * Returns the value of the SPIN_NAMESPACE environment variable.
69
+ * @param env {[key: string]: string} Environment variables
70
+ * @returns {string | undefined} The value of the SPIN_NAMESPACE environment variable.
71
+ */
72
+ export function namespace(env = process.env) {
73
+ return env[constants.environmentVariables.spinNamespace];
74
+ }
75
+ /**
76
+ * Returns the value of the SPIN_HOST environment variable.
77
+ * @param env {[key: string]: string} Environment variables
78
+ * @returns {string | undefined} The value of the SPIN_HOST environment variable.
79
+ */
80
+ export function host(env = process.env) {
81
+ return env[constants.environmentVariables.spinHost];
82
+ }
83
+ //# sourceMappingURL=spin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"spin.js","sourceRoot":"","sources":["../../src/environment/spin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,QAAQ,EAAC,MAAM,gBAAgB,CAAA;AACvC,OAAO,SAAS,MAAM,iBAAiB,CAAA;AACvC,OAAO,EAAC,aAAa,EAAC,MAAM,cAAc,CAAA;AAC1C,OAAO,EAAC,KAAK,EAAC,MAAM,aAAa,CAAA;AACjC,OAAO,EAAC,OAAO,EAAE,KAAK,EAAC,MAAM,cAAc,CAAA;AAE3C,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,YAAgC,EAAE,KAAa,EAAE,EAAE;IACtF,MAAM,YAAY,GAAG,OAAO,CAAA,GAAG,KAAK,CAAC,mBAAmB,CACtD,MAAM,CACP;EACD,KAAK;GACJ,CAAA;IACD,IAAI,SAA6B,CAAA;IACjC,IAAI,YAAY,EAAE;QAChB,SAAS,GAAG,aAAa,YAAY,6DAA6D,CAAA;KACnG;IACD,OAAO,IAAI,KAAK,CAAC,YAAY,EAAE,SAAS,CAAC,CAAA;AAC3C,CAAC,CAAA;AAED;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,IAAI,CAAC,GAAG,GAAG,OAAO,CAAC,GAAG;IAC1C,MAAM,YAAY,GAAG,MAAM,QAAQ,CAAC,GAAG,CAAC,CAAA;IACxC,MAAM,YAAY,GAAG,MAAM,IAAI,CAAC,YAAY,EAAE,GAAG,CAAC,CAAA;IAClD,OAAO,YAAY,CAAC,IAAI,CAAA;AAC1B,CAAC;AAED;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,IAAI,CAAC,YAAgC,EAAE,GAAG,GAAG,OAAO,CAAC,GAAG;IAC5E,MAA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AG,CAAC,SAAS,CAAC,oBAAoB,CAAC,QAAQ,CAAC,CAAA;AACrD,CAAC","sourcesContent":["import {isTruthy} from './utilities.js'\nimport constants from '../constants.js'\nimport {captureOutput} from '../system.js'\nimport {Abort} from '../error.js'\nimport {content, token} from '../output.js'\n\nexport const SpinInstanceNotFound = (spinInstance: string | undefined, error: string) => {\n const errorMessage = content`${token.genericShellCommand(\n `spin`,\n )} yielded the following error trying to obtain the fully qualified domain name of the Spin instance:\n${error}\n `\n let nextSteps: string | undefined\n if (spinInstance) {\n nextSteps = `Make sure ${spinInstance} is the instance name and not a fully qualified domain name`\n }\n return new Abort(errorMessage, nextSteps)\n}\n\n/**\n * When ran in a Spin environment, it returns the fqdn of the instance.\n * @returns {string} fqdn of the Spin environment.\n */\nexport async function fqdn(env = process.env): Promise<string> {\n const spinInstance = await instance(env)\n const showResponse = await show(spinInstance, env)\n return showResponse.fqdn\n}\n\n/**\n * Runs \"spin show\" and returns the JSON-parsed output.\n * @param {latest} Whether to pass --latest when running the command.\n * @returns The JSON-parsed output of the Spin CLI.\n * @throws Any error raised from the underlying Spin CLI.\n */\nexport async function show(spinInstance: string | undefined, env = process.env): Promise<{fqdn: string}> {\n const latest = spinInstance === undefined\n const args = latest ? ['show', '--latest', '--json'] : ['show', '--json']\n const output = await captureOutput('spin', args, {env})\n const json = JSON.parse(output)\n if (json.error) {\n throw SpinInstanceNotFound(spinInstance, json.error)\n } else {\n return json\n }\n}\n\n/**\n * Returns true if the CLI is running in a Spin environment.\n * @param env {[key: string]: string} Environment variables\n * @returns {boolean} True if the CLI is running in a Spin environment.\n */\nexport function isSpin(env = process.env): boolean {\n return isTruthy(env[constants.environmentVariables.spin])\n}\n\n/**\n * Returns the value of the SPIN_INSTANCE environment variable.\n * @param env {[key: string]: string} Environment variables\n * @returns {string | undefined} The value of the SPIN_INSTANCE environment variable.\n */\nexport function instance(env = process.env): string | undefined {\n return env[constants.environmentVariables.spinInstance]\n}\n\n/**\n * Returns the value of the SPIN_WORKSPACE environment variable.\n * @param env {[key: string]: string} Environment variables\n * @returns {string | undefined} The value of the SPIN_WORKSPACE environment variable.\n */\nexport function workspace(env = process.env): string | undefined {\n return env[constants.environmentVariables.spinWorkspace]\n}\n\n/**\n * Returns the value of the SPIN_NAMESPACE environment variable.\n * @param env {[key: string]: string} Environment variables\n * @returns {string | undefined} The value of the SPIN_NAMESPACE environment variable.\n */\nexport function namespace(env = process.env): string | undefined {\n return env[constants.environmentVariables.spinNamespace]\n}\n\n/**\n * Returns the value of the SPIN_HOST environment variable.\n * @param env {[key: string]: string} Environment variables\n * @returns {string | undefined} The value of the SPIN_HOST environment variable.\n */\nexport function host(env = process.env): string | undefined {\n return env[constants.environmentVariables.spinHost]\n}\n"]}
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Returns whether an environment variable value represents a truthy value.
3
+ * @param variable {string | undefined} Given a environment variable value, it returns true if it represents a truthy value.
4
+ * @returns {boolean}
5
+ */
6
+ export declare function isTruthy(variable: string | undefined): boolean;
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Returns whether an environment variable value represents a truthy value.
3
+ * @param variable {string | undefined} Given a environment variable value, it returns true if it represents a truthy value.
4
+ * @returns {boolean}
5
+ */
6
+ export function isTruthy(variable) {
7
+ if (!variable) {
8
+ return false;
9
+ }
10
+ return ['1', 'true', 'TRUE', 'yes', 'YES'].includes(variable);
11
+ }
12
+ //# sourceMappingURL=utilities.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utilities.js","sourceRoot":"","sources":["../../src/environment/utilities.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,UAAU,QAAQ,CAAC,QAA4B;IACnD,IAAI,CAAC,QAAQ,EAAE;QACb,OAAO,KAAK,CAAA;KACb;IACD,OAAO,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAA;AAC/D,CAAC","sourcesContent":["/**\n * Returns whether an environment variable value represents a truthy value.\n * @param variable {string | undefined} Given a environment variable value, it returns true if it represents a truthy value.\n * @returns {boolean}\n */\nexport function isTruthy(variable: string | undefined): boolean {\n if (!variable) {\n return false\n }\n return ['1', 'true', 'TRUE', 'yes', 'YES'].includes(variable)\n}\n"]}
@@ -0,0 +1,5 @@
1
+ import * as local from './environment/local.js';
2
+ import * as service from './environment/service.js';
3
+ import * as fqdn from './environment/fqdn.js';
4
+ import * as utilities from './environment/utilities.js';
5
+ export { local, service, fqdn, utilities };
@@ -0,0 +1,6 @@
1
+ import * as local from './environment/local.js';
2
+ import * as service from './environment/service.js';
3
+ import * as fqdn from './environment/fqdn.js';
4
+ import * as utilities from './environment/utilities.js';
5
+ export { local, service, fqdn, utilities };
6
+ //# sourceMappingURL=environment.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"environment.js","sourceRoot":"","sources":["../src/environment.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,wBAAwB,CAAA;AAC/C,OAAO,KAAK,OAAO,MAAM,0BAA0B,CAAA;AACnD,OAAO,KAAK,IAAI,MAAM,uBAAuB,CAAA;AAC7C,OAAO,KAAK,SAAS,MAAM,4BAA4B,CAAA;AAEvD,OAAO,EAAC,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAC,CAAA","sourcesContent":["import * as local from './environment/local.js'\nimport * as service from './environment/service.js'\nimport * as fqdn from './environment/fqdn.js'\nimport * as utilities from './environment/utilities.js'\n\nexport {local, service, fqdn, utilities}\n"]}
@@ -0,0 +1,44 @@
1
+ import { Message } from './output.js';
2
+ export { ExtendableError } from 'ts-error';
3
+ export { AbortSignal } from 'abort-controller';
4
+ declare enum FatalErrorType {
5
+ Abort = 0,
6
+ AbortSilent = 1,
7
+ Bug = 2
8
+ }
9
+ export declare class CancelExecution extends Error {
10
+ }
11
+ /**
12
+ * A fatal error represents an error shouldn't be rescued and that causes the execution to terminate.
13
+ * There shouldn't be code that catches fatal errors.
14
+ */
15
+ export declare abstract class Fatal extends Error {
16
+ tryMessage: string | null;
17
+ type: FatalErrorType;
18
+ constructor(message: Message, type: FatalErrorType, tryMessage?: Message | null);
19
+ }
20
+ /**
21
+ * An abort error is a fatal error that shouldn't be reported as a bug.
22
+ * Those usually represent unexpected scenarios that we can't handle and that usually require some action from the developer
23
+ */
24
+ export declare class Abort extends Fatal {
25
+ constructor(message: Message, tryMessage?: Message | null);
26
+ }
27
+ export declare class AbortSilent extends Fatal {
28
+ constructor();
29
+ }
30
+ /**
31
+ * A bug error is an error that represents a bug and therefore should be reported.
32
+ */
33
+ export declare class Bug extends Fatal {
34
+ constructor(message: Message, tryMessage?: string | null);
35
+ }
36
+ /**
37
+ * A function that handles errors that blow up in the CLI.
38
+ * @param error Error to be handled.
39
+ * @returns A promise that resolves with the error passed.
40
+ */
41
+ export declare function handler(error: Error): Promise<Error>;
42
+ export declare function mapper(error: Error): Promise<Error>;
43
+ export declare function isFatal(error: Error): boolean;
44
+ export declare function shouldReport(error: Error): boolean;
package/dist/error.js ADDED
@@ -0,0 +1,91 @@
1
+ import { stringifyMessage, error as outputError } from './output.js';
2
+ import { Errors } from '@oclif/core';
3
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
4
+ // @ts-ignore
5
+ import sourceMapSupport from 'source-map-support';
6
+ export { ExtendableError } from 'ts-error';
7
+ export { AbortSignal } from 'abort-controller';
8
+ sourceMapSupport.install();
9
+ var FatalErrorType;
10
+ (function (FatalErrorType) {
11
+ FatalErrorType[FatalErrorType["Abort"] = 0] = "Abort";
12
+ FatalErrorType[FatalErrorType["AbortSilent"] = 1] = "AbortSilent";
13
+ FatalErrorType[FatalErrorType["Bug"] = 2] = "Bug";
14
+ })(FatalErrorType || (FatalErrorType = {}));
15
+ export class CancelExecution extends Error {
16
+ }
17
+ /**
18
+ * A fatal error represents an error shouldn't be rescued and that causes the execution to terminate.
19
+ * There shouldn't be code that catches fatal errors.
20
+ */
21
+ export class Fatal extends Error {
22
+ constructor(message, type, tryMessage = null) {
23
+ super(stringifyMessage(message));
24
+ this.tryMessage = tryMessage ? stringifyMessage(tryMessage) : null;
25
+ this.type = type;
26
+ }
27
+ }
28
+ /**
29
+ * An abort error is a fatal error that shouldn't be reported as a bug.
30
+ * Those usually represent unexpected scenarios that we can't handle and that usually require some action from the developer
31
+ */
32
+ export class Abort extends Fatal {
33
+ constructor(message, tryMessage = null) {
34
+ super(message, FatalErrorType.Abort, tryMessage);
35
+ }
36
+ }
37
+ export class AbortSilent extends Fatal {
38
+ constructor() {
39
+ super('', FatalErrorType.AbortSilent);
40
+ }
41
+ }
42
+ /**
43
+ * A bug error is an error that represents a bug and therefore should be reported.
44
+ */
45
+ export class Bug extends Fatal {
46
+ constructor(message, tryMessage = null) {
47
+ super(message, FatalErrorType.Bug, tryMessage);
48
+ }
49
+ }
50
+ /**
51
+ * A function that handles errors that blow up in the CLI.
52
+ * @param error Error to be handled.
53
+ * @returns A promise that resolves with the error passed.
54
+ */
55
+ export async function handler(error) {
56
+ let fatal;
57
+ if (isFatal(error)) {
58
+ fatal = error;
59
+ }
60
+ else {
61
+ fatal = new Bug(error.message);
62
+ }
63
+ if (fatal.type === FatalErrorType.Bug) {
64
+ fatal.stack = error.stack;
65
+ }
66
+ await outputError(fatal);
67
+ return Promise.resolve(error);
68
+ }
69
+ export function mapper(error) {
70
+ if (error instanceof Errors.CLIError) {
71
+ const mappedError = new Abort(error.message);
72
+ mappedError.stack = error.stack;
73
+ return Promise.resolve(mappedError);
74
+ }
75
+ else {
76
+ return Promise.resolve(error);
77
+ }
78
+ }
79
+ export function isFatal(error) {
80
+ return Object.prototype.hasOwnProperty.call(error, 'type');
81
+ }
82
+ export function shouldReport(error) {
83
+ if (!isFatal(error)) {
84
+ return true;
85
+ }
86
+ if (error.type === FatalErrorType.Bug) {
87
+ return true;
88
+ }
89
+ return false;
90
+ }
91
+ //# sourceMappingURL=error.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"error.js","sourceRoot":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AC,GAAG,EAAE;QAChD,OAAO,IAAI,CAAA;KACZ;IACD,OAAO,KAAK,CAAA;AACd,CAAC","sourcesContent":["import {Message, stringifyMessage, error as outputError} from './output.js'\nimport {Errors} from '@oclif/core'\n\n// eslint-disable-next-line @typescript-eslint/ban-ts-comment\n// @ts-ignore\nimport sourceMapSupport from 'source-map-support'\n\nexport {ExtendableError} from 'ts-error'\nexport {AbortSignal} from 'abort-controller'\n\nsourceMapSupport.install()\n\nenum FatalErrorType {\n Abort,\n AbortSilent,\n Bug,\n}\n\nexport class CancelExecution extends Error {}\n\n/**\n * A fatal error represents an error shouldn't be rescued and that causes the execution to terminate.\n * There shouldn't be code that catches fatal errors.\n */\nexport abstract class Fatal extends Error {\n tryMessage: string | null\n type: FatalErrorType\n constructor(message: Message, type: FatalErrorType, tryMessage: Message | null = null) {\n super(stringifyMessage(message))\n this.tryMessage = tryMessage ? stringifyMessage(tryMessage) : null\n this.type = type\n }\n}\n\n/**\n * An abort error is a fatal error that shouldn't be reported as a bug.\n * Those usually represent unexpected scenarios that we can't handle and that usually require some action from the developer\n */\nexport class Abort extends Fatal {\n constructor(message: Message, tryMessage: Message | null = null) {\n super(message, FatalErrorType.Abort, tryMessage)\n }\n}\n\nexport class AbortSilent extends Fatal {\n constructor() {\n super('', FatalErrorType.AbortSilent)\n }\n}\n\n/**\n * A bug error is an error that represents a bug and therefore should be reported.\n */\nexport class Bug extends Fatal {\n constructor(message: Message, tryMessage: string | null = null) {\n super(message, FatalErrorType.Bug, tryMessage)\n }\n}\n\n/**\n * A function that handles errors that blow up in the CLI.\n * @param error Error to be handled.\n * @returns A promise that resolves with the error passed.\n */\nexport async function handler(error: Error): Promise<Error> {\n let fatal: Fatal\n if (isFatal(error)) {\n fatal = error as Fatal\n } else {\n fatal = new Bug(error.message)\n }\n\n if (fatal.type === FatalErrorType.Bug) {\n fatal.stack = error.stack\n }\n\n await outputError(fatal)\n return Promise.resolve(error)\n}\n\nexport function mapper(error: Error): Promise<Error> {\n if (error instanceof Errors.CLIError) {\n const mappedError = new Abort(error.message)\n mappedError.stack = error.stack\n return Promise.resolve(mappedError)\n } else {\n return Promise.resolve(error)\n }\n}\n\nexport function isFatal(error: Error): boolean {\n return Object.prototype.hasOwnProperty.call(error, 'type')\n}\n\nexport function shouldReport(error: Error): boolean {\n if (!isFatal(error)) {\n return true\n }\n if ((error as Fatal).type === FatalErrorType.Bug) {\n return true\n }\n return false\n}\n"]}