@shopify/cli-kit 3.0.24 → 3.0.27

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 (287) hide show
  1. package/CHANGELOG.md +32 -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 +11 -0
  12. package/dist/analytics.js +96 -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/functions/app_function_set.d.ts +43 -0
  54. package/dist/api/graphql/functions/app_function_set.js +52 -0
  55. package/dist/api/graphql/functions/app_function_set.js.map +1 -0
  56. package/dist/api/graphql/functions/compile_module.d.ts +15 -0
  57. package/dist/api/graphql/functions/compile_module.js +13 -0
  58. package/dist/api/graphql/functions/compile_module.js.map +1 -0
  59. package/dist/api/graphql/functions/function_service_proxy.d.ts +4 -0
  60. package/dist/api/graphql/functions/function_service_proxy.js +7 -0
  61. package/dist/api/graphql/functions/function_service_proxy.js.map +1 -0
  62. package/dist/api/graphql/functions/get_app_functions.d.ts +1 -0
  63. package/dist/api/graphql/functions/get_app_functions.js +10 -0
  64. package/dist/api/graphql/functions/get_app_functions.js.map +1 -0
  65. package/dist/api/graphql/functions/module_compilation_status.d.ts +15 -0
  66. package/dist/api/graphql/functions/module_compilation_status.js +13 -0
  67. package/dist/api/graphql/functions/module_compilation_status.js.map +1 -0
  68. package/dist/api/graphql/functions/module_upload_url_generate.d.ts +18 -0
  69. package/dist/api/graphql/functions/module_upload_url_generate.js +17 -0
  70. package/dist/api/graphql/functions/module_upload_url_generate.js.map +1 -0
  71. package/dist/api/graphql/generate_signed_upload_url.d.ts +15 -0
  72. package/dist/api/graphql/generate_signed_upload_url.js +15 -0
  73. package/dist/api/graphql/generate_signed_upload_url.js.map +1 -0
  74. package/dist/api/graphql/get_variant_id.d.ts +17 -0
  75. package/dist/api/graphql/get_variant_id.js +20 -0
  76. package/dist/api/graphql/get_variant_id.js.map +1 -0
  77. package/dist/api/graphql/index.d.ts +21 -0
  78. package/dist/api/graphql/index.js +22 -0
  79. package/dist/api/graphql/index.js.map +1 -0
  80. package/dist/api/graphql/update_draft.d.ts +33 -0
  81. package/dist/api/graphql/update_draft.js +24 -0
  82. package/dist/api/graphql/update_draft.js.map +1 -0
  83. package/dist/api/graphql/update_urls.d.ts +14 -0
  84. package/dist/api/graphql/update_urls.js +12 -0
  85. package/dist/api/graphql/update_urls.js.map +1 -0
  86. package/dist/api/identity.d.ts +1 -0
  87. package/dist/api/identity.js +32 -0
  88. package/dist/api/identity.js.map +1 -0
  89. package/dist/api/partners.d.ts +25 -0
  90. package/dist/api/partners.js +100 -0
  91. package/dist/api/partners.js.map +1 -0
  92. package/dist/api.d.ts +5 -0
  93. package/dist/api.js +6 -0
  94. package/dist/api.js.map +1 -0
  95. package/dist/cli.d.ts +7 -0
  96. package/dist/cli.js +13 -0
  97. package/dist/cli.js.map +1 -0
  98. package/dist/colors.d.ts +1 -0
  99. package/dist/colors.js +8 -0
  100. package/dist/colors.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/dependency.d.ts +128 -0
  105. package/dist/dependency.js +302 -0
  106. package/dist/dependency.js.map +1 -0
  107. package/dist/environment/fqdn.d.ts +23 -0
  108. package/dist/environment/fqdn.js +61 -0
  109. package/dist/environment/fqdn.js.map +1 -0
  110. package/dist/environment/local.d.ts +48 -0
  111. package/dist/environment/local.js +82 -0
  112. package/dist/environment/local.js.map +1 -0
  113. package/dist/environment/service.d.ts +17 -0
  114. package/dist/environment/service.js +41 -0
  115. package/dist/environment/service.js.map +1 -0
  116. package/dist/environment/spin.d.ts +47 -0
  117. package/dist/environment/spin.js +83 -0
  118. package/dist/environment/spin.js.map +1 -0
  119. package/dist/environment/utilities.d.ts +6 -0
  120. package/dist/environment/utilities.js +12 -0
  121. package/dist/environment/utilities.js.map +1 -0
  122. package/dist/environment.d.ts +5 -0
  123. package/dist/environment.js +6 -0
  124. package/dist/environment.js.map +1 -0
  125. package/dist/error.d.ts +44 -0
  126. package/dist/error.js +91 -0
  127. package/dist/error.js.map +1 -0
  128. package/dist/file.d.ts +67 -0
  129. package/dist/file.js +165 -0
  130. package/dist/file.js.map +1 -0
  131. package/dist/git.d.ts +15 -0
  132. package/dist/git.js +48 -0
  133. package/dist/git.js.map +1 -0
  134. package/dist/github.d.ts +33 -0
  135. package/dist/github.js +56 -0
  136. package/dist/github.js.map +1 -0
  137. package/dist/haiku.d.ts +1 -0
  138. package/dist/haiku.js +8 -0
  139. package/dist/haiku.js.map +1 -0
  140. package/dist/http/fetch.d.ts +16 -0
  141. package/dist/http/fetch.js +18 -0
  142. package/dist/http/fetch.js.map +1 -0
  143. package/dist/http/formdata.d.ts +3 -0
  144. package/dist/http/formdata.js +6 -0
  145. package/dist/http/formdata.js.map +1 -0
  146. package/dist/http.d.ts +2 -0
  147. package/dist/http.js +3 -0
  148. package/dist/http.js.map +1 -0
  149. package/dist/id.d.ts +6 -0
  150. package/dist/id.js +18 -0
  151. package/dist/id.js.map +1 -0
  152. package/dist/index.d.ts +34 -2115
  153. package/dist/index.js +35 -46
  154. package/dist/index.js.map +1 -1
  155. package/dist/network/api.d.ts +2 -0
  156. package/dist/network/api.js +2 -0
  157. package/dist/network/api.js.map +1 -0
  158. package/dist/network/service.d.ts +16 -0
  159. package/dist/network/service.js +12 -0
  160. package/dist/network/service.js.map +1 -0
  161. package/dist/node/archiver.d.ts +6 -0
  162. package/dist/node/archiver.js +24 -0
  163. package/dist/node/archiver.js.map +1 -0
  164. package/dist/node/checksum.d.ts +20 -0
  165. package/dist/node/checksum.js +32 -0
  166. package/dist/node/checksum.js.map +1 -0
  167. package/dist/node/cli.d.ts +18 -0
  168. package/dist/node/cli.js +91 -0
  169. package/dist/node/cli.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/ruby.d.ts +30 -0
  174. package/dist/node/ruby.js +197 -0
  175. package/dist/node/ruby.js.map +1 -0
  176. package/dist/npm.d.ts +27 -0
  177. package/dist/npm.js +20 -0
  178. package/dist/npm.js.map +1 -0
  179. package/dist/os.d.ts +10 -0
  180. package/dist/os.js +70 -0
  181. package/dist/os.js.map +1 -0
  182. package/dist/output.d.ts +142 -0
  183. package/dist/output.js +505 -0
  184. package/dist/output.js.map +1 -0
  185. package/dist/path.d.ts +22 -0
  186. package/dist/path.js +43 -0
  187. package/dist/path.js.map +1 -0
  188. package/dist/plugins.d.ts +9 -0
  189. package/dist/plugins.js +12 -0
  190. package/dist/plugins.js.map +1 -0
  191. package/dist/port.d.ts +5 -0
  192. package/dist/port.js +13 -0
  193. package/dist/port.js.map +1 -0
  194. package/dist/schema.d.ts +1 -0
  195. package/dist/schema.js +2 -0
  196. package/dist/schema.js.map +1 -0
  197. package/dist/secure-store.d.ts +19 -0
  198. package/dist/secure-store.js +63 -0
  199. package/dist/secure-store.js.map +1 -0
  200. package/dist/semver.d.ts +3 -0
  201. package/dist/semver.js +6 -0
  202. package/dist/semver.js.map +1 -0
  203. package/dist/session/authorize.d.ts +7 -0
  204. package/dist/session/authorize.js +40 -0
  205. package/dist/session/authorize.js.map +1 -0
  206. package/dist/session/exchange.d.ts +42 -0
  207. package/dist/session/exchange.js +144 -0
  208. package/dist/session/exchange.js.map +1 -0
  209. package/dist/session/identity.d.ts +3 -0
  210. package/dist/session/identity.js +58 -0
  211. package/dist/session/identity.js.map +1 -0
  212. package/dist/session/post-auth.d.ts +13 -0
  213. package/dist/session/post-auth.js +56 -0
  214. package/dist/session/post-auth.js.map +1 -0
  215. package/dist/session/redirect-listener.d.ts +34 -0
  216. package/dist/session/redirect-listener.js +97 -0
  217. package/dist/session/redirect-listener.js.map +1 -0
  218. package/dist/session/schema.d.ts +174 -0
  219. package/dist/session/schema.js +59 -0
  220. package/dist/session/schema.js.map +1 -0
  221. package/dist/session/scopes.d.ts +16 -0
  222. package/dist/session/scopes.js +53 -0
  223. package/dist/session/scopes.js.map +1 -0
  224. package/dist/session/store.d.ts +24 -0
  225. package/dist/session/store.js +88 -0
  226. package/dist/session/store.js.map +1 -0
  227. package/dist/session/token.d.ts +40 -0
  228. package/dist/session/token.js +22 -0
  229. package/dist/session/token.js.map +1 -0
  230. package/dist/session/validate.d.ts +17 -0
  231. package/dist/session/validate.js +75 -0
  232. package/dist/session/validate.js.map +1 -0
  233. package/dist/session.d.ts +88 -0
  234. package/dist/session.js +251 -0
  235. package/dist/session.js.map +1 -0
  236. package/dist/store/schema.d.ts +3 -0
  237. package/dist/store/schema.js +27 -0
  238. package/dist/store/schema.js.map +1 -0
  239. package/dist/store.d.ts +32 -0
  240. package/dist/store.js +102 -0
  241. package/dist/store.js.map +1 -0
  242. package/dist/string.d.ts +22 -0
  243. package/dist/string.js +38 -0
  244. package/dist/string.js.map +1 -0
  245. package/dist/system.d.ts +53 -0
  246. package/dist/system.js +109 -0
  247. package/dist/system.js.map +1 -0
  248. package/dist/template.d.ts +11 -0
  249. package/dist/template.js +50 -0
  250. package/dist/template.js.map +1 -0
  251. package/dist/testing/output.d.ts +9 -0
  252. package/dist/testing/output.js +15 -0
  253. package/dist/testing/output.js.map +1 -0
  254. package/dist/testing/store.d.ts +7 -0
  255. package/dist/testing/store.js +26 -0
  256. package/dist/testing/store.js.map +1 -0
  257. package/dist/toml.d.ts +3 -0
  258. package/dist/toml.js +8 -0
  259. package/dist/toml.js.map +1 -0
  260. package/dist/tsconfig.tsbuildinfo +1 -0
  261. package/dist/ui/autocomplete.d.ts +7 -0
  262. package/dist/ui/autocomplete.js +43 -0
  263. package/dist/ui/autocomplete.js.map +1 -0
  264. package/dist/ui/input.d.ts +7 -0
  265. package/dist/ui/input.js +48 -0
  266. package/dist/ui/input.js.map +1 -0
  267. package/dist/ui/select.d.ts +6 -0
  268. package/dist/ui/select.js +30 -0
  269. package/dist/ui/select.js.map +1 -0
  270. package/dist/ui.d.ts +36 -0
  271. package/dist/ui.js +124 -0
  272. package/dist/ui.js.map +1 -0
  273. package/dist/version.d.ts +19 -0
  274. package/dist/version.js +34 -0
  275. package/dist/version.js.map +1 -0
  276. package/dist/vscode.d.ts +8 -0
  277. package/dist/vscode.js +36 -0
  278. package/dist/vscode.js.map +1 -0
  279. package/dist/yaml.d.ts +2 -0
  280. package/dist/yaml.js +8 -0
  281. package/dist/yaml.js.map +1 -0
  282. package/package.json +32 -21
  283. package/dist/index-eb280c22.js +0 -175294
  284. package/dist/index-eb280c22.js.map +0 -1
  285. package/dist/index.d.ts.map +0 -1
  286. package/dist/multipart-parser-84c10b92.js +0 -477
  287. package/dist/multipart-parser-84c10b92.js.map +0 -1
package/dist/file.js ADDED
@@ -0,0 +1,165 @@
1
+ import { content as outputContent, token, debug } from './output.js';
2
+ import fs from 'fs-extra';
3
+ import del from 'del';
4
+ import { temporaryDirectoryTask } from 'tempy';
5
+ import { sep, join, extname } from 'pathe';
6
+ import prettier from 'prettier';
7
+ const DEFAULT_PRETTIER_CONFIG = {
8
+ arrowParens: 'always',
9
+ singleQuote: true,
10
+ bracketSpacing: false,
11
+ trailingComma: 'all',
12
+ };
13
+ export function stripUp(path, strip) {
14
+ const parts = path.split(sep);
15
+ return join(...parts.slice(strip));
16
+ }
17
+ /**
18
+ * Creates a temporary directory and ties its lifecycle ot the lifecycle of the callback.
19
+ * @param callback - The callback that receives the temporary directory.
20
+ */
21
+ export async function inTemporaryDirectory(callback) {
22
+ return temporaryDirectoryTask(callback);
23
+ }
24
+ /**
25
+ * It reads a file and returns its content as a string using the
26
+ * utf-8 encoding
27
+ * @param path {string} Path to the file to read.
28
+ * @returns {Promise<string>} A promise that resolves with the content of the file.
29
+ */
30
+ export async function read(path, options = { encoding: 'utf-8' }) {
31
+ debug(outputContent `Reading the content of file at ${token.path(path)}...`);
32
+ const content = await fs.readFile(path, options);
33
+ return content;
34
+ }
35
+ export function readSync(path, options = { encoding: 'utf-8' }) {
36
+ debug(outputContent `Sync-reading the content of file at ${token.path(path)}...`);
37
+ const content = fs.readFileSync(path, options);
38
+ return content.toString();
39
+ }
40
+ /**
41
+ * Copies a file
42
+ * @param from {string} Path to the directory or file to be copied.
43
+ * @param to {string} Destination path.
44
+ */
45
+ export async function copy(from, to) {
46
+ debug(outputContent `Copying file from ${token.path(from)} to ${token.path(to)}...`);
47
+ await fs.copy(from, to);
48
+ }
49
+ export async function touch(path) {
50
+ debug(outputContent `Creating an empty file at ${token.path(path)}...`);
51
+ await fs.ensureFile(path);
52
+ }
53
+ export async function touchSync(path) {
54
+ debug(outputContent `Creating an empty file at ${token.path(path)}...`);
55
+ await fs.ensureFileSync(path);
56
+ }
57
+ export async function write(path, data) {
58
+ debug(outputContent `Writing some content to file at ${token.path(path)}...`);
59
+ await fs.writeFile(path, data);
60
+ }
61
+ export function writeSync(path, data) {
62
+ debug(outputContent `File-writing some content to file at ${token.path(path)}...`);
63
+ fs.writeFileSync(path, data);
64
+ }
65
+ export async function append(path, data) {
66
+ await fs.appendFile(path, data);
67
+ }
68
+ export async function mkdir(path) {
69
+ debug(outputContent `Creating directory at ${token.path(path)}...`);
70
+ await fs.mkdirp(path);
71
+ }
72
+ export function mkdirSync(path) {
73
+ debug(outputContent `Sync-reating directory at ${token.path(path)}...`);
74
+ fs.mkdirpSync(path);
75
+ }
76
+ export async function remove(path) {
77
+ debug(outputContent `Removing file at ${token.path(path)}...`);
78
+ await fs.remove(path);
79
+ }
80
+ export async function rmdir(path, { force } = {}) {
81
+ debug(outputContent `Removing directory at ${token.path(path)}...`);
82
+ await del(path, { force });
83
+ }
84
+ export async function mkTmpDir() {
85
+ debug(outputContent `Creating a temporary directory...`);
86
+ const directory = await fs.mkdtemp('tmp-');
87
+ return directory;
88
+ }
89
+ export async function isDirectory(path) {
90
+ debug(outputContent `Checking if ${token.path(path)} is a directory...`);
91
+ return (await fs.promises.lstat(path)).isDirectory();
92
+ }
93
+ export async function size(path) {
94
+ debug(outputContent `Getting the size of file file at ${token.path(path)}...`);
95
+ return (await fs.stat(path)).size;
96
+ }
97
+ export function sizeSync(path) {
98
+ debug(outputContent `Sync-getting the size of file file at ${token.path(path)}...`);
99
+ return fs.statSync(path).size;
100
+ }
101
+ /**
102
+ * Moves a file.
103
+ * @param src {string} File to be moved.
104
+ * @param dest {string} Path to be moved to.
105
+ * @param options {object} Moving options.
106
+ */
107
+ export async function move(src, dest, options = {}) {
108
+ await fs.move(src, dest, options);
109
+ }
110
+ /**
111
+ * Changes the permissions of a directory or file.
112
+ * @param path {string} Path to the file or directory whose permissions will be modified.
113
+ * @param mode {string | numbers} Permissions to set to the file or directory.
114
+ */
115
+ export async function chmod(path, mode) {
116
+ await fs.promises.chmod(path, mode);
117
+ }
118
+ /**
119
+ * Checks if a file has executable permissions.
120
+ * @param path {string} Path to the file whose permissions will be checked.
121
+ */
122
+ export async function hasExecutablePermissions(path) {
123
+ try {
124
+ await fs.promises.access(path, fs.constants.X_OK);
125
+ return true;
126
+ // eslint-disable-next-line no-catch-all/no-catch-all
127
+ }
128
+ catch {
129
+ return false;
130
+ }
131
+ }
132
+ /**
133
+ * Returns true if a file or directory exists
134
+ * @param path {string} Path to the directory or file.
135
+ * @returns {boolean} True if it exists.
136
+ */
137
+ export async function exists(path) {
138
+ try {
139
+ await fs.promises.access(path);
140
+ return true;
141
+ // eslint-disable-next-line no-catch-all/no-catch-all
142
+ }
143
+ catch {
144
+ return false;
145
+ }
146
+ }
147
+ /**
148
+ * Format a string using prettier. Return the formatted content.
149
+ */
150
+ export async function format(content, options) {
151
+ const ext = extname(options.path);
152
+ const prettierConfig = {
153
+ ...DEFAULT_PRETTIER_CONFIG,
154
+ parser: 'babel',
155
+ };
156
+ switch (ext) {
157
+ case '.html':
158
+ case '.css':
159
+ prettierConfig.parser = ext.slice(1);
160
+ break;
161
+ }
162
+ const formattedContent = await prettier.format(content, prettierConfig);
163
+ return formattedContent;
164
+ }
165
+ //# sourceMappingURL=file.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"file.js","sourceRoot":"","sources":["../src/file.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,OAAO,IAAI,aAAa,EAAE,KAAK,EAAE,KAAK,EAAC,MAAM,aAAa,CAAA;AAClE,OAAO,EAAE,MAAM,UAAU,CAAA;AACzB,OAAO,GAAG,MAAM,KAAK,CAAA;AACrB,OAAO,EAAC,sBAAsB,EAAC,MAAM,OAAO,CAAA;AAC5C,OAAO,EAAC,GAAG,EAAE,IAAI,EAAE,OAAO,EAAC,MAAM,OAAO,CAAA;AACxC,OAAO,QAAQ,MAAM,UAAU,CAAA;AAG/B,MAAM,uBAAuB,GAAY;IACvC,WAAW,EAAE,QAAQ;IACrB,WAAW,EAAE,IAAI;IACjB,cAAc,EAAE,KAAK;IACrB,aAAa,EAAE,KAAK;CACrB,CAAA;AAED,MAAM,UAAU,OAAO,CAAC,IAAY,EAAE,KAAa;IACjD,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;IAC7B,OAAO,IAAI,CAAC,GAAG,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAA;AACpC,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,oBAAoB,CAAI,QAA4C;IACxF,OAAO,sBAAsB,CAAC,QAAQ,CAAC,CAAA;AACzC,CAAC;AAED;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,IAAI,CAAC,IAAY,EAAE,UAAkB,EAAC,QAAQ,EAAE,OAAO,EAAC;IAC5E,KAAK,CAAC,aAAa,CAAA,kCAAkC,KAAK,CA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AAED;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,KAAK,CAAC,IAAY,EAAE,IAAqB;IAC7D,MAAM,EAAE,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,EAAE,IAAI,CAAC,CAAA;AACrC,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,wBAAwB,CAAC,IAAY;IACzD,IAAI;QACF,MAAM,EAAE,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,EAAE,EAAE,CAAC,SAAS,CAAC,IAAI,CAAC,CAAA;QACjD,OAAO,IAAI,CAAA;QACX,qDAAqD;KACtD;IAAC,MAAM;QACN,OAAO,KAAK,CAAA;KACb;AACH,CAAC;AAED;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,MAAM,CAAC,IAAY;IACvC,IAAI;QACF,MAAM,EAAE,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,CAAA;QAC9B,OAAO,IAAI,CAAA;QACX,qDAAqD;KACtD;IAAC,MAAM;QACN,OAAO,KAAK,CAAA;KACb;AACH,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,MAAM,CAAC,OAAe,EAAE,OAAuB;IACnE,MAAM,GAAG,GAAG,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CAAA;IACjC,MAAM,cAAc,GAAY;QAC9B,GAAG,uBAAuB;QAC1B,MAAM,EAAE,OAAO;KAChB,CAAA;IAED,QAAQ,GAAG,EAAE;QACX,KAAK,OAAO,CAAC;QACb,KAAK,MAAM;YACT,cAAc,CAAC,MAAM,GAAG,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAA;YACpC,MAAK;KACR;IAED,MAAM,gBAAgB,GAAG,MAAM,QAAQ,CAAC,MAAM,CAAC,OAAO,EAAE,cAAc,CAAC,CAAA;IAEvE,OAAO,gBAAgB,CAAA;AACzB,CAAC","sourcesContent":["import {content as outputContent, token, debug} from './output.js'\nimport fs from 'fs-extra'\nimport del from 'del'\nimport {temporaryDirectoryTask} from 'tempy'\nimport {sep, join, extname} from 'pathe'\nimport prettier from 'prettier'\nimport type {Options} from 'prettier'\n\nconst DEFAULT_PRETTIER_CONFIG: Options = {\n arrowParens: 'always',\n singleQuote: true,\n bracketSpacing: false,\n trailingComma: 'all',\n}\n\nexport function stripUp(path: string, strip: number) {\n const parts = path.split(sep)\n return join(...parts.slice(strip))\n}\n\n/**\n * Creates a temporary directory and ties its lifecycle ot the lifecycle of the callback.\n * @param callback - The callback that receives the temporary directory.\n */\nexport async function inTemporaryDirectory<T>(callback: (tmpDir: string) => T | Promise<T>): Promise<T> {\n return temporaryDirectoryTask(callback)\n}\n\n/**\n * It reads a file and returns its content as a string using the\n * utf-8 encoding\n * @param path {string} Path to the file to read.\n * @returns {Promise<string>} A promise that resolves with the content of the file.\n */\nexport async function read(path: string, options: object = {encoding: 'utf-8'}): Promise<string> {\n debug(outputContent`Reading the content of file at ${token.path(path)}...`)\n const content = await fs.readFile(path, options)\n return content\n}\n\nexport function readSync(path: string, options: object = {encoding: 'utf-8'}): string {\n debug(outputContent`Sync-reading the content of file at ${token.path(path)}...`)\n const content = fs.readFileSync(path, options)\n return content.toString()\n}\n\n/**\n * Copies a file\n * @param from {string} Path to the directory or file to be copied.\n * @param to {string} Destination path.\n */\nexport async function copy(from: string, to: string): Promise<void> {\n debug(outputContent`Copying file from ${token.path(from)} to ${token.path(to)}...`)\n await fs.copy(from, to)\n}\n\nexport async function touch(path: string): Promise<void> {\n debug(outputContent`Creating an empty file at ${token.path(path)}...`)\n await fs.ensureFile(path)\n}\n\nexport async function touchSync(path: string): Promise<void> {\n debug(outputContent`Creating an empty file at ${token.path(path)}...`)\n await fs.ensureFileSync(path)\n}\n\nexport async function write(path: string, data: string): Promise<void> {\n debug(outputContent`Writing some content to file at ${token.path(path)}...`)\n await fs.writeFile(path, data)\n}\n\nexport function writeSync(path: string, data: string): void {\n debug(outputContent`File-writing some content to file at ${token.path(path)}...`)\n fs.writeFileSync(path, data)\n}\n\nexport async function append(path: string, data: string): Promise<void> {\n await fs.appendFile(path, data)\n}\n\nexport async function mkdir(path: string): Promise<void> {\n debug(outputContent`Creating directory at ${token.path(path)}...`)\n await fs.mkdirp(path)\n}\n\nexport function mkdirSync(path: string): void {\n debug(outputContent`Sync-reating directory at ${token.path(path)}...`)\n fs.mkdirpSync(path)\n}\n\nexport async function remove(path: string): Promise<void> {\n debug(outputContent`Removing file at ${token.path(path)}...`)\n await fs.remove(path)\n}\n\nexport async function rmdir(path: string, {force}: {force?: boolean} = {}): Promise<void> {\n debug(outputContent`Removing directory at ${token.path(path)}...`)\n await del(path, {force})\n}\n\nexport async function mkTmpDir(): Promise<string> {\n debug(outputContent`Creating a temporary directory...`)\n const directory = await fs.mkdtemp('tmp-')\n return directory\n}\n\nexport async function isDirectory(path: string): Promise<boolean> {\n debug(outputContent`Checking if ${token.path(path)} is a directory...`)\n return (await fs.promises.lstat(path)).isDirectory()\n}\n\nexport async function size(path: string): Promise<number> {\n debug(outputContent`Getting the size of file file at ${token.path(path)}...`)\n return (await fs.stat(path)).size\n}\n\nexport function sizeSync(path: string): number {\n debug(outputContent`Sync-getting the size of file file at ${token.path(path)}...`)\n return fs.statSync(path).size\n}\n\n/**\n * Moves a file.\n * @param src {string} File to be moved.\n * @param dest {string} Path to be moved to.\n * @param options {object} Moving options.\n */\nexport async function move(src: string, dest: string, options: {overwrite?: boolean} = {}): Promise<void> {\n await fs.move(src, dest, options)\n}\n\n/**\n * Changes the permissions of a directory or file.\n * @param path {string} Path to the file or directory whose permissions will be modified.\n * @param mode {string | numbers} Permissions to set to the file or directory.\n */\nexport async function chmod(path: string, mode: number | string): Promise<void> {\n await fs.promises.chmod(path, mode)\n}\n\n/**\n * Checks if a file has executable permissions.\n * @param path {string} Path to the file whose permissions will be checked.\n */\nexport async function hasExecutablePermissions(path: string): Promise<boolean> {\n try {\n await fs.promises.access(path, fs.constants.X_OK)\n return true\n // eslint-disable-next-line no-catch-all/no-catch-all\n } catch {\n return false\n }\n}\n\n/**\n * Returns true if a file or directory exists\n * @param path {string} Path to the directory or file.\n * @returns {boolean} True if it exists.\n */\nexport async function exists(path: string): Promise<boolean> {\n try {\n await fs.promises.access(path)\n return true\n // eslint-disable-next-line no-catch-all/no-catch-all\n } catch {\n return false\n }\n}\n\n/**\n * Format a string using prettier. Return the formatted content.\n */\nexport async function format(content: string, options: {path: string}) {\n const ext = extname(options.path)\n const prettierConfig: Options = {\n ...DEFAULT_PRETTIER_CONFIG,\n parser: 'babel',\n }\n\n switch (ext) {\n case '.html':\n case '.css':\n prettierConfig.parser = ext.slice(1)\n break\n }\n\n const formattedContent = await prettier.format(content, prettierConfig)\n\n return formattedContent\n}\n"]}
package/dist/git.d.ts ADDED
@@ -0,0 +1,15 @@
1
+ import { Abort } from './error.js';
2
+ export declare const factory: import("simple-git").SimpleGitFactory;
3
+ export declare const GitNotPresentError: () => Abort;
4
+ export declare function initializeRepository(directory: string): Promise<void>;
5
+ export declare function downloadRepository({ repoUrl, destination, progressUpdater, shallow, }: {
6
+ repoUrl: string;
7
+ destination: string;
8
+ progressUpdater?: (statusString: string) => void;
9
+ shallow?: boolean;
10
+ }): Promise<void>;
11
+ /**
12
+ * If "git" is not present in the environment it throws
13
+ * an abort error.
14
+ */
15
+ export declare function ensurePresentOrAbort(): Promise<void>;
package/dist/git.js ADDED
@@ -0,0 +1,48 @@
1
+ import { Abort } from './error.js';
2
+ import { hasGit } from './environment/local.js';
3
+ import { content, token, debug } from './output.js';
4
+ import git from 'simple-git';
5
+ export const factory = git;
6
+ export const GitNotPresentError = () => {
7
+ return new Abort(`Git is necessary in the environment to continue`, content `Install ${token.link('git', 'https://git-scm.com/book/en/v2/Getting-Started-Installing-Git')}`);
8
+ };
9
+ export async function initializeRepository(directory) {
10
+ debug(content `Initializing git repository at ${token.path(directory)}...`);
11
+ await ensurePresentOrAbort();
12
+ await git(directory).init();
13
+ }
14
+ export async function downloadRepository({ repoUrl, destination, progressUpdater, shallow, }) {
15
+ debug(content `Git-cloning repository ${repoUrl} into ${token.path(destination)}...`);
16
+ await ensurePresentOrAbort();
17
+ const [repository, branch] = repoUrl.split('#');
18
+ // eslint-disable-next-line @typescript-eslint/naming-convention
19
+ const options = { '--recurse-submodules': null };
20
+ if (branch) {
21
+ options['--branch'] = branch;
22
+ }
23
+ if (shallow) {
24
+ options['--depth'] = 1;
25
+ }
26
+ const progress = ({ stage, progress, processed, total }) => {
27
+ const updateString = `${stage}, ${processed}/${total} objects (${progress}% complete)`;
28
+ if (progressUpdater)
29
+ progressUpdater(updateString);
30
+ };
31
+ await git({ progress }).clone(repository, destination, options, (err) => {
32
+ if (err) {
33
+ const abortError = new Abort(err.message);
34
+ abortError.stack = err.stack;
35
+ throw abortError;
36
+ }
37
+ });
38
+ }
39
+ /**
40
+ * If "git" is not present in the environment it throws
41
+ * an abort error.
42
+ */
43
+ export async function ensurePresentOrAbort() {
44
+ if (!(await hasGit())) {
45
+ throw GitNotPresentError();
46
+ }
47
+ }
48
+ //# sourceMappingURL=git.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"git.js","sourceRoot":"","sources":["../src/git.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,KAAK,EAAC,MAAM,YAAY,CAAA;AAChC,OAAO,EAAC,MAAM,EAAC,MAAM,wBAAwB,CAAA;AAC7C,OAAO,EAAC,OAAO,EAAE,KAAK,EAAE,KAAK,EAAC,MAAM,aAAa,CAAA;AACjD,OAAO,GAA0C,MAAM,YAAY,CAAA;AAEnE,MAAM,CAAC,MAAM,OAAO,GAAG,GAAG,CAAA;AAE1B,MAAM,CAAC,MAAM,kBAAkB,GAAG,GAAG,EAAE;IACrC,OAAO,IAAI,KAAK,CACd,iDAAiD,EACjD,OAAO,CAAA,WAAW,KAAK,CAAC,IAAI,CAAC,KAAK,EAAE,+DAA+D,CAAC,EAAE,CACvG,CAAA;AACH,CAAC,CAAA;AAED,MAAM,CAAC,KAAK,UAAU,oBAAoB,CAAC,SAAiB;IA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A;YACzC,UAAU,CAAC,KAAK,GAAG,GAAG,CAAC,KAAK,CAAA;YAC5B,MAAM,UAAU,CAAA;SACjB;IACH,CAAC,CAAC,CAAA;AACJ,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,oBAAoB;IACxC,IAAI,CAAC,CAAC,MAAM,MAAM,EAAE,CAAC,EAAE;QACrB,MAAM,kBAAkB,EAAE,CAAA;KAC3B;AACH,CAAC","sourcesContent":["import {Abort} from './error.js'\nimport {hasGit} from './environment/local.js'\nimport {content, token, debug} from './output.js'\nimport git, {TaskOptions, SimpleGitProgressEvent} from 'simple-git'\n\nexport const factory = git\n\nexport const GitNotPresentError = () => {\n return new Abort(\n `Git is necessary in the environment to continue`,\n content`Install ${token.link('git', 'https://git-scm.com/book/en/v2/Getting-Started-Installing-Git')}`,\n )\n}\n\nexport async function initializeRepository(directory: string) {\n debug(content`Initializing git repository at ${token.path(directory)}...`)\n await ensurePresentOrAbort()\n await git(directory).init()\n}\n\nexport async function downloadRepository({\n repoUrl,\n destination,\n progressUpdater,\n shallow,\n}: {\n repoUrl: string\n destination: string\n progressUpdater?: (statusString: string) => void\n shallow?: boolean\n}) {\n debug(content`Git-cloning repository ${repoUrl} into ${token.path(destination)}...`)\n await ensurePresentOrAbort()\n const [repository, branch] = repoUrl.split('#')\n // eslint-disable-next-line @typescript-eslint/naming-convention\n const options: TaskOptions = {'--recurse-submodules': null}\n if (branch) {\n options['--branch'] = branch\n }\n if (shallow) {\n options['--depth'] = 1\n }\n const progress = ({stage, progress, processed, total}: SimpleGitProgressEvent) => {\n const updateString = `${stage}, ${processed}/${total} objects (${progress}% complete)`\n if (progressUpdater) progressUpdater(updateString)\n }\n\n await git({progress}).clone(repository, destination, options, (err) => {\n if (err) {\n const abortError = new Abort(err.message)\n abortError.stack = err.stack\n throw abortError\n }\n })\n}\n\n/**\n * If \"git\" is not present in the environment it throws\n * an abort error.\n */\nexport async function ensurePresentOrAbort() {\n if (!(await hasGit())) {\n throw GitNotPresentError()\n }\n}\n"]}
@@ -0,0 +1,33 @@
1
+ export interface GithubRelease {
2
+ id: number;
3
+ url: string;
4
+ tag_name: string;
5
+ name: string;
6
+ body: string;
7
+ draft: boolean;
8
+ prerelease: boolean;
9
+ created_at: string;
10
+ published_at: string;
11
+ tarball_url: string;
12
+ }
13
+ interface Options {
14
+ filter: (release: GithubRelease) => boolean;
15
+ }
16
+ export declare function getLatestRelease(user: string, repo: string, { filter }?: Options): Promise<GithubRelease>;
17
+ export declare function parseRepoUrl(src: string): {
18
+ full: string;
19
+ site: string;
20
+ user: string;
21
+ name: string;
22
+ ref: string;
23
+ subDirectory: string;
24
+ ssh: string;
25
+ http: string;
26
+ };
27
+ export interface GithubRepoReference {
28
+ repoBaseUrl: string;
29
+ branch?: string;
30
+ filePath?: string;
31
+ }
32
+ export declare function parseGithubRepoReference(src: string): GithubRepoReference;
33
+ export {};
package/dist/github.js ADDED
@@ -0,0 +1,56 @@
1
+ import { fetch } from './http.js';
2
+ import { Abort } from './error.js';
3
+ import { content, debug } from './output.js';
4
+ class GitHubClientError extends Error {
5
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
6
+ constructor(url, statusCode, bodyJson) {
7
+ super(`The request to GitHub API URL ${url} failed with status code ${statusCode} and the following error message: ${bodyJson.message}`);
8
+ }
9
+ }
10
+ export async function getLatestRelease(user, repo, { filter } = { filter: () => true }) {
11
+ debug(content `Getting the latest release of GitHub repository ${user}/${repo}...`);
12
+ const url = `https://api.github.com/repos/${user}/${repo}/releases`;
13
+ const fetchResult = await fetch(url);
14
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
15
+ const jsonBody = await fetchResult.json();
16
+ if (fetchResult.status !== 200) {
17
+ throw new GitHubClientError(url, fetchResult.status, jsonBody);
18
+ }
19
+ return jsonBody.find(filter);
20
+ }
21
+ export function parseRepoUrl(src) {
22
+ const match = /^(?:(?:https:\/\/)?([^:/]+\.[^:/]+)\/|git@([^:/]+)[:/]|([^/]+):)?([^/\s]+)\/([^/\s#]+)(?:((?:\/[^/\s#]+)+))?(?:\/)?(?:#(.+))?/.exec(src);
23
+ if (!match) {
24
+ const exampleFormats = [
25
+ 'github:user/repo',
26
+ 'user/repo/subdirectory',
27
+ 'git@github.com:user/repo',
28
+ 'user/repo#dev',
29
+ 'https://github.com/user/repo',
30
+ ];
31
+ throw new Abort(`Parsing the url ${src} failed. Supported formats are ${exampleFormats.join(', ')}.`);
32
+ }
33
+ const site = match[1] || match[2] || match[3] || 'github.com';
34
+ const normalizedSite = site === 'github' ? 'github.com' : site;
35
+ const user = match[4];
36
+ const name = match[5].replace(/\.git$/, '');
37
+ const subDirectory = match[6]?.slice(1);
38
+ const ref = match[7];
39
+ const branch = ref ? `#${ref}` : '';
40
+ const ssh = `git@${normalizedSite}:${user}/${name}`;
41
+ const http = `https://${normalizedSite}/${user}/${name}`;
42
+ const full = ['https:/', normalizedSite, user, name, subDirectory].join('/').concat(branch);
43
+ return { full, site: normalizedSite, user, name, ref, subDirectory, ssh, http };
44
+ }
45
+ export function parseGithubRepoReference(src) {
46
+ const url = new URL(src);
47
+ const branch = url.hash ? url.hash.slice(1) : undefined;
48
+ const [_, user, repo, ...repoPath] = url.pathname.split('/');
49
+ const filePath = repoPath.length > 0 ? repoPath.join('/') : undefined;
50
+ return {
51
+ repoBaseUrl: `${url.origin}/${user}/${repo}`,
52
+ branch,
53
+ filePath,
54
+ };
55
+ }
56
+ //# sourceMappingURL=github.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"github.js","sourceRoot":"","sources":["../src/github.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,KAAK,EAAC,MAAM,WAAW,CAAA;AAC/B,OAAO,EAAC,KAAK,EAAC,MAAM,YAAY,CAAA;AAChC,OAAO,EAAC,OAAO,EAAE,KAAK,EAAC,MAAM,aAAa,CAAA;AAE1C,MAAM,iBAAkB,SAAQ,KAAK;IACnC,8DAA8D;IAC9D,YAAY,GAAW,EAAE,UAAkB,EAAE,Q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AAG,CAAC,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;IAC5D,MAAM,QAAQ,GAAG,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,CAAA;IAErE,OAAO;QACL,WAAW,EAAE,GAAG,GAAG,CAAC,MAAM,IAAI,IAAI,IAAI,IAAI,EAAE;QAC5C,MAAM;QACN,QAAQ;KACT,CAAA;AACH,CAAC","sourcesContent":["import {fetch} from './http.js'\nimport {Abort} from './error.js'\nimport {content, debug} from './output.js'\n\nclass GitHubClientError extends Error {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n constructor(url: string, statusCode: number, bodyJson: any) {\n super(\n `The request to GitHub API URL ${url} failed with status code ${statusCode} and the following error message: ${bodyJson.message}`,\n )\n }\n}\n\nexport interface GithubRelease {\n id: number\n url: string\n // eslint-disable-next-line @typescript-eslint/naming-convention\n tag_name: string\n name: string\n body: string\n draft: boolean\n prerelease: boolean\n // eslint-disable-next-line @typescript-eslint/naming-convention\n created_at: string\n // eslint-disable-next-line @typescript-eslint/naming-convention\n published_at: string\n // eslint-disable-next-line @typescript-eslint/naming-convention\n tarball_url: string\n}\n\ninterface Options {\n filter: (release: GithubRelease) => boolean\n}\n\nexport async function getLatestRelease(\n user: string,\n repo: string,\n {filter}: Options = {filter: () => true},\n): Promise<GithubRelease> {\n debug(content`Getting the latest release of GitHub repository ${user}/${repo}...`)\n const url = `https://api.github.com/repos/${user}/${repo}/releases`\n const fetchResult = await fetch(url)\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const jsonBody: any = await fetchResult.json()\n\n if (fetchResult.status !== 200) {\n throw new GitHubClientError(url, fetchResult.status, jsonBody)\n }\n\n return jsonBody.find(filter)\n}\n\nexport function parseRepoUrl(src: string) {\n const match =\n /^(?:(?:https:\\/\\/)?([^:/]+\\.[^:/]+)\\/|git@([^:/]+)[:/]|([^/]+):)?([^/\\s]+)\\/([^/\\s#]+)(?:((?:\\/[^/\\s#]+)+))?(?:\\/)?(?:#(.+))?/.exec(\n src,\n )\n\n if (!match) {\n const exampleFormats = [\n 'github:user/repo',\n 'user/repo/subdirectory',\n 'git@github.com:user/repo',\n 'user/repo#dev',\n 'https://github.com/user/repo',\n ]\n\n throw new Abort(`Parsing the url ${src} failed. Supported formats are ${exampleFormats.join(', ')}.`)\n }\n\n const site = match[1] || match[2] || match[3] || 'github.com'\n const normalizedSite = site === 'github' ? 'github.com' : site\n const user = match[4]\n const name = match[5].replace(/\\.git$/, '')\n const subDirectory = match[6]?.slice(1)\n const ref = match[7]\n const branch = ref ? `#${ref}` : ''\n const ssh = `git@${normalizedSite}:${user}/${name}`\n const http = `https://${normalizedSite}/${user}/${name}`\n const full = ['https:/', normalizedSite, user, name, subDirectory].join('/').concat(branch)\n\n return {full, site: normalizedSite, user, name, ref, subDirectory, ssh, http}\n}\n\nexport interface GithubRepoReference {\n repoBaseUrl: string\n branch?: string\n filePath?: string\n}\n\nexport function parseGithubRepoReference(src: string): GithubRepoReference {\n const url = new URL(src)\n const branch = url.hash ? url.hash.slice(1) : undefined\n const [_, user, repo, ...repoPath] = url.pathname.split('/')\n const filePath = repoPath.length > 0 ? repoPath.join('/') : undefined\n\n return {\n repoBaseUrl: `${url.origin}/${user}/${repo}`,\n branch,\n filePath,\n }\n}\n"]}
@@ -0,0 +1 @@
1
+ export declare function generate(suffix: string): string;
package/dist/haiku.js ADDED
@@ -0,0 +1,8 @@
1
+ import Haikunator from 'haikunator';
2
+ const haikunator = new Haikunator();
3
+ export function generate(suffix) {
4
+ const generated = haikunator.haikunate();
5
+ const [adjective, noun, token] = generated.split('-');
6
+ return [adjective, noun, suffix, token].join('-');
7
+ }
8
+ //# sourceMappingURL=haiku.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"haiku.js","sourceRoot":"","sources":["../src/haiku.ts"],"names":[],"mappings":"AAAA,OAAO,UAAU,MAAM,YAAY,CAAA;AAEnC,MAAM,UAAU,GAAG,IAAI,UAAU,EAAE,CAAA;AAEnC,MAAM,UAAU,QAAQ,CAAC,MAAc;IACrC,MAAM,SAAS,GAAG,UAAU,CAAC,SAAS,EAAE,CAAA;IACxC,MAAM,CAAC,SAAS,EAAE,IAAI,EAAE,KAAK,CAAC,GAAG,SAAS,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;IACrD,OAAO,CAAC,SAAS,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;AACnD,CAAC","sourcesContent":["import Haikunator from 'haikunator'\n\nconst haikunator = new Haikunator()\n\nexport function generate(suffix: string): string {\n const generated = haikunator.haikunate()\n const [adjective, noun, token] = generated.split('-')\n return [adjective, noun, suffix, token].join('-')\n}\n"]}
@@ -0,0 +1,16 @@
1
+ import nodeFetch from 'node-fetch';
2
+ import type { RequestInfo, RequestInit } from 'node-fetch';
3
+ declare type Response = ReturnType<typeof nodeFetch>;
4
+ /**
5
+ * An interface that abstracts way node-fetch. When Node has built-in
6
+ * support for "fetch" in the standard library, we can drop the node-fetch
7
+ * dependency from here.
8
+ * Note that we are exposing types from "node-fetch". The reason being is that
9
+ * they are consistent with the Web API so if we drop node-fetch in the future
10
+ * it won't require changes from the callers.
11
+ * @param url {RequestInfo} This defines the resource that you wish to fetch.
12
+ * @param init {RequestInit} An object containing any custom settings that you want to apply to the request
13
+ * @returns A promise that resolves with the response.
14
+ */
15
+ declare function fetch(url: RequestInfo, init?: RequestInit): Response;
16
+ export default fetch;
@@ -0,0 +1,18 @@
1
+ import nodeFetch from 'node-fetch';
2
+ /**
3
+ * An interface that abstracts way node-fetch. When Node has built-in
4
+ * support for "fetch" in the standard library, we can drop the node-fetch
5
+ * dependency from here.
6
+ * Note that we are exposing types from "node-fetch". The reason being is that
7
+ * they are consistent with the Web API so if we drop node-fetch in the future
8
+ * it won't require changes from the callers.
9
+ * @param url {RequestInfo} This defines the resource that you wish to fetch.
10
+ * @param init {RequestInit} An object containing any custom settings that you want to apply to the request
11
+ * @returns A promise that resolves with the response.
12
+ */
13
+ async function fetch(url, init) {
14
+ const response = await nodeFetch(url, init);
15
+ return response;
16
+ }
17
+ export default fetch;
18
+ //# sourceMappingURL=fetch.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fetch.js","sourceRoot":"","sources":["../../src/http/fetch.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,YAAY,CAAA;AAIlC;;;;;;;;;;GAUG;AACH,KAAK,UAAU,KAAK,CAAC,GAAgB,EAAE,IAAkB;IACvD,MAAM,QAAQ,GAAG,MAAM,SAAS,CAAC,GAAG,EAAE,IAAI,CAAC,CAAA;IAC3C,OAAO,QAAQ,CAAA;AACjB,CAAC;AAED,eAAe,KAAK,CAAA","sourcesContent":["import nodeFetch from 'node-fetch'\nimport type {RequestInfo, RequestInit} from 'node-fetch'\n\ntype Response = ReturnType<typeof nodeFetch>\n/**\n * An interface that abstracts way node-fetch. When Node has built-in\n * support for \"fetch\" in the standard library, we can drop the node-fetch\n * dependency from here.\n * Note that we are exposing types from \"node-fetch\". The reason being is that\n * they are consistent with the Web API so if we drop node-fetch in the future\n * it won't require changes from the callers.\n * @param url {RequestInfo} This defines the resource that you wish to fetch.\n * @param init {RequestInit} An object containing any custom settings that you want to apply to the request\n * @returns A promise that resolves with the response.\n */\nasync function fetch(url: RequestInfo, init?: RequestInit): Response {\n const response = await nodeFetch(url, init)\n return response\n}\n\nexport default fetch\n"]}
@@ -0,0 +1,3 @@
1
+ import FormData from 'form-data';
2
+ declare function formData(): FormData;
3
+ export default formData;
@@ -0,0 +1,6 @@
1
+ import FormData from 'form-data';
2
+ function formData() {
3
+ return new FormData();
4
+ }
5
+ export default formData;
6
+ //# sourceMappingURL=formdata.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"formdata.js","sourceRoot":"","sources":["../../src/http/formdata.ts"],"names":[],"mappings":"AAAA,OAAO,QAAQ,MAAM,WAAW,CAAA;AAEhC,SAAS,QAAQ;IACf,OAAO,IAAI,QAAQ,EAAE,CAAA;AACvB,CAAC;AAED,eAAe,QAAQ,CAAA","sourcesContent":["import FormData from 'form-data'\n\nfunction formData() {\n return new FormData()\n}\n\nexport default formData\n"]}
package/dist/http.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ export { default as fetch } from './http/fetch.js';
2
+ export { default as formData } from './http/formdata.js';
package/dist/http.js ADDED
@@ -0,0 +1,3 @@
1
+ export { default as fetch } from './http/fetch.js';
2
+ export { default as formData } from './http/formdata.js';
3
+ //# sourceMappingURL=http.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"http.js","sourceRoot":"","sources":["../src/http.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,OAAO,IAAI,KAAK,EAAC,MAAM,iBAAiB,CAAA;AAChD,OAAO,EAAC,OAAO,IAAI,QAAQ,EAAC,MAAM,oBAAoB,CAAA","sourcesContent":["export {default as fetch} from './http/fetch.js'\nexport {default as formData} from './http/formdata.js'\n"]}
package/dist/id.d.ts ADDED
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Generates and returns a random UUID.
3
+ * @returns {string} The random UUID generated.
4
+ */
5
+ export declare const generateRandomUUID: () => string;
6
+ export declare const generateShortId: () => string;
package/dist/id.js ADDED
@@ -0,0 +1,18 @@
1
+ import { randomUUID } from 'crypto';
2
+ /**
3
+ * Generates and returns a random UUID.
4
+ * @returns {string} The random UUID generated.
5
+ */
6
+ export const generateRandomUUID = () => {
7
+ return randomUUID();
8
+ };
9
+ export const generateShortId = () => {
10
+ let result = '';
11
+ const characters = 'abcdefghijklmnopqrstuvwxyz0123456789';
12
+ const charactersLength = characters.length;
13
+ for (let i = 0; i < 7; i++) {
14
+ result += characters.charAt(Math.floor(Math.random() * charactersLength));
15
+ }
16
+ return result;
17
+ };
18
+ //# sourceMappingURL=id.js.map
package/dist/id.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"id.js","sourceRoot":"","sources":["../src/id.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAC,MAAM,QAAQ,CAAA;AAEjC;;;GAGG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,GAAW,EAAE;IAC7C,OAAO,UAAU,EAAE,CAAA;AACrB,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,eAAe,GAAG,GAAW,EAAE;IAC1C,IAAI,MAAM,GAAG,EAAE,CAAA;IACf,MAAM,UAAU,GAAG,sCAAsC,CAAA;IACzD,MAAM,gBAAgB,GAAG,UAAU,CAAC,MAAM,CAAA;IAC1C,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE;QAC1B,MAAM,IAAI,UAAU,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,gBAAgB,CAAC,CAAC,CAAA;KAC1E;IACD,OAAO,MAAM,CAAA;AACf,CAAC,CAAA","sourcesContent":["import {randomUUID} from 'crypto'\n\n/**\n * Generates and returns a random UUID.\n * @returns {string} The random UUID generated.\n */\nexport const generateRandomUUID = (): string => {\n return randomUUID()\n}\n\nexport const generateShortId = (): string => {\n let result = ''\n const characters = 'abcdefghijklmnopqrstuvwxyz0123456789'\n const charactersLength = characters.length\n for (let i = 0; i < 7; i++) {\n result += characters.charAt(Math.floor(Math.random() * charactersLength))\n }\n return result\n}\n"]}