@shopify/cli-kit 3.34.0 → 3.36.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 (241) hide show
  1. package/dist/content-tokens.js +1 -1
  2. package/dist/content-tokens.js.map +1 -1
  3. package/dist/error.js +2 -2
  4. package/dist/error.js.map +1 -1
  5. package/dist/git.js +2 -2
  6. package/dist/git.js.map +1 -1
  7. package/dist/index.d.ts +0 -6
  8. package/dist/index.js +0 -6
  9. package/dist/index.js.map +1 -1
  10. package/dist/metadata.d.ts +1 -1
  11. package/dist/metadata.js.map +1 -1
  12. package/dist/monorail.d.ts +1 -1
  13. package/dist/monorail.js +1 -1
  14. package/dist/monorail.js.map +1 -1
  15. package/dist/output.js +3 -7
  16. package/dist/output.js.map +1 -1
  17. package/dist/plugins.d.ts +1 -1
  18. package/dist/plugins.js.map +1 -1
  19. package/dist/{typing → private/common/ts}/deep-required.d.ts +3 -3
  20. package/dist/{typing → private/common/ts}/deep-required.js +0 -0
  21. package/dist/private/common/ts/deep-required.js.map +1 -0
  22. package/dist/{typing → private/common/ts}/overloaded-parameters.d.ts +0 -0
  23. package/dist/{typing → private/common/ts}/overloaded-parameters.js +0 -0
  24. package/dist/private/common/ts/overloaded-parameters.js.map +1 -0
  25. package/dist/private/node/api/graphql.js +2 -3
  26. package/dist/private/node/api/graphql.js.map +1 -1
  27. package/dist/private/node/api/headers.d.ts +11 -2
  28. package/dist/private/node/api/headers.js +29 -3
  29. package/dist/private/node/api/headers.js.map +1 -1
  30. package/dist/private/node/api/rest.d.ts +5 -3
  31. package/dist/private/node/api/rest.js +8 -7
  32. package/dist/private/node/api/rest.js.map +1 -1
  33. package/dist/private/node/constants.d.ts +42 -0
  34. package/dist/private/node/constants.js +58 -0
  35. package/dist/private/node/constants.js.map +1 -0
  36. package/dist/private/node/environment/service.js +2 -2
  37. package/dist/private/node/environment/service.js.map +1 -1
  38. package/dist/private/node/session/device-authorization.js +1 -1
  39. package/dist/private/node/session/device-authorization.js.map +1 -1
  40. package/dist/private/node/session/exchange.js +1 -1
  41. package/dist/private/node/session/exchange.js.map +1 -1
  42. package/dist/private/node/session/identity-token-validation.js +1 -1
  43. package/dist/private/node/session/identity-token-validation.js.map +1 -1
  44. package/dist/private/node/session/post-auth.js +10 -10
  45. package/dist/private/node/session/post-auth.js.map +1 -1
  46. package/dist/private/node/session/store.js +6 -6
  47. package/dist/private/node/session/store.js.map +1 -1
  48. package/dist/private/node/session/validate.js +2 -2
  49. package/dist/private/node/session/validate.js.map +1 -1
  50. package/dist/private/node/session.js +2 -2
  51. package/dist/private/node/session.js.map +1 -1
  52. package/dist/{typing → private/node}/simple-definitions.d.ts +0 -0
  53. package/dist/{typing → private/node}/simple-definitions.js +0 -0
  54. package/dist/private/node/simple-definitions.js.map +1 -0
  55. package/dist/private/node/ui/alert.d.ts +1 -1
  56. package/dist/private/node/ui/alert.js +2 -2
  57. package/dist/private/node/ui/alert.js.map +1 -1
  58. package/dist/private/node/ui/components/Alert.d.ts +5 -0
  59. package/dist/private/node/ui/components/Alert.js +9 -6
  60. package/dist/private/node/ui/components/Alert.js.map +1 -1
  61. package/dist/private/node/ui/components/Alert.test.js +30 -4
  62. package/dist/private/node/ui/components/Alert.test.js.map +1 -1
  63. package/dist/private/node/ui/components/AutocompletePrompt.d.ts +12 -0
  64. package/dist/private/node/ui/components/AutocompletePrompt.js +111 -0
  65. package/dist/private/node/ui/components/AutocompletePrompt.js.map +1 -0
  66. package/dist/private/node/ui/components/AutocompletePrompt.test.d.ts +1 -0
  67. package/dist/private/node/ui/components/AutocompletePrompt.test.js +473 -0
  68. package/dist/private/node/ui/components/AutocompletePrompt.test.js.map +1 -0
  69. package/dist/private/node/ui/components/Banner.d.ts +0 -1
  70. package/dist/private/node/ui/components/Banner.js +4 -4
  71. package/dist/private/node/ui/components/Banner.js.map +1 -1
  72. package/dist/private/node/ui/components/Banner.test.js +10 -5
  73. package/dist/private/node/ui/components/Banner.test.js.map +1 -1
  74. package/dist/private/node/ui/components/FatalError.js +1 -1
  75. package/dist/private/node/ui/components/FatalError.js.map +1 -1
  76. package/dist/private/node/ui/components/FatalError.test.js +4 -8
  77. package/dist/private/node/ui/components/FatalError.test.js.map +1 -1
  78. package/dist/private/node/ui/components/{Table.d.ts → Prompts/InfoTable.d.ts} +2 -2
  79. package/dist/private/node/ui/components/{Table.js → Prompts/InfoTable.js} +6 -6
  80. package/dist/private/node/ui/components/Prompts/InfoTable.js.map +1 -0
  81. package/dist/private/node/ui/components/SelectInput.d.ts +9 -2
  82. package/dist/private/node/ui/components/SelectInput.js +96 -52
  83. package/dist/private/node/ui/components/SelectInput.js.map +1 -1
  84. package/dist/private/node/ui/components/SelectInput.test.js +140 -54
  85. package/dist/private/node/ui/components/SelectInput.test.js.map +1 -1
  86. package/dist/private/node/ui/components/SelectPrompt.d.ts +6 -4
  87. package/dist/private/node/ui/components/SelectPrompt.js +18 -11
  88. package/dist/private/node/ui/components/SelectPrompt.js.map +1 -1
  89. package/dist/private/node/ui/components/SelectPrompt.test.js +113 -23
  90. package/dist/private/node/ui/components/SelectPrompt.test.js.map +1 -1
  91. package/dist/private/node/ui/components/Table/Column.d.ts +5 -0
  92. package/dist/private/node/ui/components/Table/Column.js +2 -0
  93. package/dist/private/node/ui/components/Table/Column.js.map +1 -0
  94. package/dist/private/node/ui/components/Table/Row.d.ts +12 -0
  95. package/dist/private/node/ui/components/Table/Row.js +24 -0
  96. package/dist/private/node/ui/components/Table/Row.js.map +1 -0
  97. package/dist/private/node/ui/components/Table/ScalarDict.d.ts +5 -0
  98. package/dist/private/node/ui/components/Table/ScalarDict.js +2 -0
  99. package/dist/private/node/ui/components/Table/ScalarDict.js.map +1 -0
  100. package/dist/private/node/ui/components/Table/Table.d.ts +12 -0
  101. package/dist/private/node/ui/components/Table/Table.js +30 -0
  102. package/dist/private/node/ui/components/Table/Table.js.map +1 -0
  103. package/dist/private/node/ui/components/Table/Table.test.d.ts +1 -0
  104. package/dist/private/node/ui/components/Table/Table.test.js +41 -0
  105. package/dist/private/node/ui/components/Table/Table.test.js.map +1 -0
  106. package/dist/private/node/ui/components/Tasks.d.ts +6 -5
  107. package/dist/private/node/ui/components/Tasks.js +32 -11
  108. package/dist/private/node/ui/components/Tasks.js.map +1 -1
  109. package/dist/private/node/ui/components/Tasks.test.js +55 -9
  110. package/dist/private/node/ui/components/Tasks.test.js.map +1 -1
  111. package/dist/private/node/ui/components/TextInput.d.ts +4 -1
  112. package/dist/private/node/ui/components/TextInput.js +22 -13
  113. package/dist/private/node/ui/components/TextInput.js.map +1 -1
  114. package/dist/private/node/ui/components/TextInput.test.js +47 -40
  115. package/dist/private/node/ui/components/TextInput.test.js.map +1 -1
  116. package/dist/private/node/ui/components/TextPrompt.d.ts +3 -1
  117. package/dist/private/node/ui/components/TextPrompt.js +28 -15
  118. package/dist/private/node/ui/components/TextPrompt.js.map +1 -1
  119. package/dist/private/node/ui/components/TextPrompt.test.js +71 -15
  120. package/dist/private/node/ui/components/TextPrompt.test.js.map +1 -1
  121. package/dist/private/node/ui/components/TokenizedText.d.ts +3 -0
  122. package/dist/private/node/ui/components/TokenizedText.js +33 -1
  123. package/dist/private/node/ui/components/TokenizedText.js.map +1 -1
  124. package/dist/private/node/ui/utilities.d.ts +2 -0
  125. package/dist/private/node/ui/utilities.js +6 -0
  126. package/dist/private/node/ui/utilities.js.map +1 -0
  127. package/dist/public/common/string.d.ts +11 -0
  128. package/dist/public/common/string.js +21 -0
  129. package/dist/public/common/string.js.map +1 -1
  130. package/dist/{typing → public/common/ts}/pick-by-prefix.d.ts +4 -3
  131. package/dist/{typing → public/common/ts}/pick-by-prefix.js +0 -0
  132. package/dist/public/common/ts/pick-by-prefix.js.map +1 -0
  133. package/dist/public/common/version.d.ts +1 -0
  134. package/dist/public/common/version.js +2 -0
  135. package/dist/public/common/version.js.map +1 -0
  136. package/dist/public/node/analytics.js +2 -2
  137. package/dist/public/node/analytics.js.map +1 -1
  138. package/dist/public/node/api/admin.d.ts +4 -1
  139. package/dist/public/node/api/admin.js +5 -4
  140. package/dist/public/node/api/admin.js.map +1 -1
  141. package/dist/public/node/api/http.d.ts +0 -0
  142. package/dist/public/node/api/http.js +2 -0
  143. package/dist/public/node/api/http.js.map +1 -0
  144. package/dist/public/node/api/oxygen.js +1 -1
  145. package/dist/public/node/api/oxygen.js.map +1 -1
  146. package/dist/public/node/archiver.js +2 -1
  147. package/dist/public/node/archiver.js.map +1 -1
  148. package/dist/public/node/cli.js +6 -6
  149. package/dist/public/node/cli.js.map +1 -1
  150. package/dist/public/node/dot-env.js +2 -2
  151. package/dist/public/node/dot-env.js.map +1 -1
  152. package/dist/public/node/environment/local.js +17 -17
  153. package/dist/public/node/environment/local.js.map +1 -1
  154. package/dist/public/node/environment/spin.js +6 -6
  155. package/dist/public/node/environment/spin.js.map +1 -1
  156. package/dist/public/node/error-handler.js +13 -10
  157. package/dist/public/node/error-handler.js.map +1 -1
  158. package/dist/public/node/framework.js +2 -2
  159. package/dist/public/node/framework.js.map +1 -1
  160. package/dist/public/node/fs.d.ts +241 -4
  161. package/dist/public/node/fs.js +366 -2
  162. package/dist/public/node/fs.js.map +1 -1
  163. package/dist/public/node/git.d.ts +90 -0
  164. package/dist/public/node/git.js +174 -0
  165. package/dist/public/node/git.js.map +1 -0
  166. package/dist/public/node/github.js +1 -1
  167. package/dist/public/node/github.js.map +1 -1
  168. package/dist/{http/fetch.d.ts → public/node/http.d.ts} +18 -7
  169. package/dist/{http/fetch.js → public/node/http.js} +21 -8
  170. package/dist/public/node/http.js.map +1 -0
  171. package/dist/public/node/liquid.js +9 -9
  172. package/dist/public/node/liquid.js.map +1 -1
  173. package/dist/public/node/node-package-manager.d.ts +20 -9
  174. package/dist/public/node/node-package-manager.js +19 -25
  175. package/dist/public/node/node-package-manager.js.map +1 -1
  176. package/dist/public/node/path.d.ts +22 -0
  177. package/dist/{path.js → public/node/path.js} +8 -20
  178. package/dist/public/node/path.js.map +1 -0
  179. package/dist/public/node/presets.js +5 -5
  180. package/dist/public/node/presets.js.map +1 -1
  181. package/dist/public/node/ruby.js +29 -33
  182. package/dist/public/node/ruby.js.map +1 -1
  183. package/dist/public/node/session.js +2 -2
  184. package/dist/public/node/session.js.map +1 -1
  185. package/dist/public/node/ui.d.ts +63 -9
  186. package/dist/public/node/ui.js +83 -8
  187. package/dist/public/node/ui.js.map +1 -1
  188. package/dist/public/node/vscode.js +8 -8
  189. package/dist/public/node/vscode.js.map +1 -1
  190. package/dist/secure-store.js +4 -4
  191. package/dist/secure-store.js.map +1 -1
  192. package/dist/store.d.ts +10 -10
  193. package/dist/store.js +21 -22
  194. package/dist/store.js.map +1 -1
  195. package/dist/testing/store.js +3 -3
  196. package/dist/testing/store.js.map +1 -1
  197. package/dist/testing/ui.d.ts +4 -1
  198. package/dist/testing/ui.js +24 -1
  199. package/dist/testing/ui.js.map +1 -1
  200. package/dist/tsconfig.tsbuildinfo +1 -1
  201. package/dist/ui/executor.d.ts +2 -14
  202. package/dist/ui/executor.js +38 -72
  203. package/dist/ui/executor.js.map +1 -1
  204. package/dist/ui.js +9 -26
  205. package/dist/ui.js.map +1 -1
  206. package/package.json +4 -6
  207. package/dist/constants.d.ts +0 -48
  208. package/dist/constants.js +0 -67
  209. package/dist/constants.js.map +0 -1
  210. package/dist/file.d.ts +0 -98
  211. package/dist/file.js +0 -216
  212. package/dist/file.js.map +0 -1
  213. package/dist/http/fetch.js.map +0 -1
  214. package/dist/http/formdata.d.ts +0 -3
  215. package/dist/http/formdata.js +0 -6
  216. package/dist/http/formdata.js.map +0 -1
  217. package/dist/http.d.ts +0 -26
  218. package/dist/http.js +0 -31
  219. package/dist/http.js.map +0 -1
  220. package/dist/npm.d.ts +0 -27
  221. package/dist/npm.js +0 -20
  222. package/dist/npm.js.map +0 -1
  223. package/dist/path.d.ts +0 -25
  224. package/dist/path.js.map +0 -1
  225. package/dist/private/node/ui/components/Table.js.map +0 -1
  226. package/dist/typing/deep-required.js.map +0 -1
  227. package/dist/typing/overloaded-parameters.js.map +0 -1
  228. package/dist/typing/pick-by-prefix.js.map +0 -1
  229. package/dist/typing/simple-definitions.js.map +0 -1
  230. package/dist/ui/inquirer/autocomplete.d.ts +0 -11
  231. package/dist/ui/inquirer/autocomplete.js +0 -110
  232. package/dist/ui/inquirer/autocomplete.js.map +0 -1
  233. package/dist/ui/inquirer/input.d.ts +0 -16
  234. package/dist/ui/inquirer/input.js +0 -45
  235. package/dist/ui/inquirer/input.js.map +0 -1
  236. package/dist/ui/inquirer/password.d.ts +0 -7
  237. package/dist/ui/inquirer/password.js +0 -8
  238. package/dist/ui/inquirer/password.js.map +0 -1
  239. package/dist/ui/inquirer/select.d.ts +0 -14
  240. package/dist/ui/inquirer/select.js +0 -26
  241. package/dist/ui/inquirer/select.js.map +0 -1
@@ -1,17 +1,254 @@
1
- import type { RandomNameFamily } from '../common/string.js';
1
+ /// <reference types="node" />
2
+ /// <reference types="node" />
3
+ import { RandomNameFamily } from '../common/string.js';
4
+ import { OverloadParameters } from '../../private/common/ts/overloaded-parameters.js';
5
+ import { findUp as internalFindUp } from 'find-up';
6
+ import { ReadStream } from 'fs';
7
+ import type { Pattern, Options as GlobOptions } from 'fast-glob';
8
+ /**
9
+ * Strip the first `strip` parts of the path.
10
+ *
11
+ * @param path - Path to strip.
12
+ * @param strip - Number of parts to strip.
13
+ * @returns The stripped path.
14
+ */
15
+ export declare function stripUpPath(path: string, strip: number): string;
16
+ /**
17
+ * Creates a temporary directory and ties its lifecycle to the lifecycle of the callback.
18
+ *
19
+ * @param callback - The callback that receives the temporary directory.
20
+ */
21
+ export declare function inTemporaryDirectory<T>(callback: (tmpDir: string) => T | Promise<T>): Promise<T>;
22
+ /**
23
+ * It reads a file and returns its content as a string using the
24
+ * utf-8 encoding.
25
+ *
26
+ * @param path - Path to the file to read.
27
+ * @returns A promise that resolves with the content of the file.
28
+ */
29
+ export declare type ReadOptions = undefined | {
30
+ flag?: string | undefined;
31
+ } | {
32
+ encoding: BufferEncoding | string;
33
+ flag?: string | undefined;
34
+ };
35
+ export declare function readFile(path: string, options?: ReadOptions): Promise<string>;
36
+ export declare function readFile(path: string, options?: ReadOptions): Promise<Buffer>;
37
+ /**
38
+ * Synchronously reads a file and returns its content as a buffer.
39
+ *
40
+ * @param path - Path to the file to read.
41
+ * @returns The content of the file.
42
+ */
43
+ export declare function readFileSync(path: string): Buffer;
44
+ /**
45
+ * Given a path, it determines the actual path. This is useful when working
46
+ * with paths that represent symlinks.
47
+ *
48
+ * @param path - Path whose real path will be returned.
49
+ */
50
+ export declare function fileRealPath(path: string): Promise<string>;
51
+ /**
52
+ * Copies a file.
53
+ *
54
+ * @param from - Path to the directory or file to be copied.
55
+ * @param to - Destination path.
56
+ */
57
+ export declare function copyFile(from: string, to: string): Promise<void>;
58
+ /**
59
+ * Creates a file at the given path.
60
+ *
61
+ * @param path - Path to the file to be created.
62
+ */
63
+ export declare function touchFile(path: string): Promise<void>;
64
+ /**
65
+ * Synchronously creates a file at the given path.
66
+ *
67
+ * @param path - Path to the file to be created.
68
+ */
69
+ export declare function touchFileSync(path: string): void;
70
+ /**
71
+ * Appnds content to file at path.
72
+ *
73
+ * @param path - Path to the file to be appended.
74
+ * @param content - Content to be appended.
75
+ */
76
+ export declare function appendFile(path: string, content: string): Promise<void>;
77
+ /**
78
+ * Synchronously appends content to file at path.
79
+ *
80
+ * @param path - Path to the file to be appended.
81
+ * @param data - Content to be appended.
82
+ */
83
+ export declare function appendFileSync(path: string, data: string): void;
84
+ /**
85
+ * Writes content to file at path.
86
+ *
87
+ * @param path - Path to the file to be written.
88
+ * @param data - Content to be written.
89
+ */
90
+ export declare function writeFile(path: string, data: string): Promise<void>;
91
+ /**
92
+ * Synchronously writes content to file at path.
93
+ *
94
+ * @param path - Path to the file to be written.
95
+ * @param data - Content to be written.
96
+ */
97
+ export declare function writeFileSync(path: string, data: string): void;
98
+ /**
99
+ * Creates a directory at the given path.
100
+ *
101
+ * @param path - Path to the directory to be created.
102
+ */
103
+ export declare function mkdir(path: string): Promise<void>;
104
+ /**
105
+ * Synchronously creates a directory at the given path.
106
+ *
107
+ * @param path - Path to the directory to be created.
108
+ */
109
+ export declare function mkdirSync(path: string): void;
110
+ /**
111
+ * Removes a file at the given path.
112
+ *
113
+ * @param path - Path to the file to be removed.
114
+ */
115
+ export declare function removeFile(path: string): Promise<void>;
116
+ /**
117
+ * Synchronously removes a file at the given path.
118
+ *
119
+ * @param path - Path to the file to be removed.
120
+ */
121
+ export declare function removeFileSync(path: string): void;
122
+ interface RmDirOptions {
123
+ force?: boolean;
124
+ }
125
+ /**
126
+ * Removes a directory at the given path.
127
+ *
128
+ * @param path - Path to the directory to be removed.
129
+ * @param options - Options to remove the directory with.
130
+ */
131
+ export declare function rmdir(path: string, options?: RmDirOptions): Promise<void>;
132
+ /**
133
+ * Create a temporary directory.
134
+ *
135
+ * @returns Path to the temporary directory.
136
+ */
137
+ export declare function mkTmpDir(): Promise<string>;
138
+ /**
139
+ * Check whether a path is a directory.
140
+ *
141
+ * @param path - Path to check.
142
+ * @returns True if the path is a directory, false otherwise.
143
+ */
144
+ export declare function isDirectory(path: string): Promise<boolean>;
145
+ /**
146
+ * Get the size of a file.
147
+ *
148
+ * @param path - Path to the file.
149
+ * @returns The size of the file in bytes.
150
+ */
151
+ export declare function fileSize(path: string): Promise<number>;
152
+ /**
153
+ * Synchronously get the size of a file.
154
+ *
155
+ * @param path - Path to the file.
156
+ * @returns The size of the file in bytes.
157
+ */
158
+ export declare function fileSizeSync(path: string): number;
159
+ /**
160
+ * Create a read stream for a file.
161
+ *
162
+ * @param path - Path to the file.
163
+ * @returns A read stream for the file.
164
+ */
165
+ export declare function createFileReadStream(path: string): ReadStream;
166
+ /**
167
+ * Returns the Date object for the last modification of a file.
168
+ *
169
+ * @param path - Path to the directory or file.
170
+ * @returns A unix timestamp.
171
+ */
172
+ export declare function fileLastUpdated(path: string): Promise<Date>;
173
+ /**
174
+ * Returns the unix timestamp of the last modification of a file.
175
+ *
176
+ * @param path - Path to the directory or file.
177
+ * @returns A unix timestamp.
178
+ */
179
+ export declare function fileLastUpdatedTimestamp(path: string): Promise<number | undefined>;
180
+ interface MoveFileOptions {
181
+ overwrite?: boolean;
182
+ }
183
+ /**
184
+ * Moves a file.
185
+ *
186
+ * @param src - File to be moved.
187
+ * @param dest - Path to be moved to.
188
+ * @param options - Moving options.
189
+ */
190
+ export declare function moveFile(src: string, dest: string, options?: MoveFileOptions): Promise<void>;
191
+ /**
192
+ * Changes the permissions of a directory or file.
193
+ *
194
+ * @param path - Path to the file or directory whose permissions will be modified.
195
+ * @param mode - Permissions to set to the file or directory.
196
+ */
197
+ export declare function chmod(path: string, mode: number | string): Promise<void>;
198
+ /**
199
+ * Checks if a file has executable permissions.
200
+ *
201
+ * @param path - Path to the file whose permissions will be checked.
202
+ */
203
+ export declare function fileHasExecutablePermissions(path: string): Promise<boolean>;
204
+ /**
205
+ * Returns true if a file or directory exists.
206
+ *
207
+ * @param path - Path to the directory or file.
208
+ * @returns True if it exists.
209
+ */
210
+ export declare function fileExists(path: string): Promise<boolean>;
211
+ interface FileOptions {
212
+ path: string;
213
+ }
214
+ /**
215
+ * Format a string using prettier. Return the formatted content.
216
+ *
217
+ * @param content - Content to be formatted.
218
+ * @param options - Options to format the content with.
219
+ * @returns The formatted content.
220
+ */
221
+ export declare function fileContentPrettyFormat(content: string, options: FileOptions): Promise<string>;
2
222
  interface GenerateRandomDirectoryOptions {
3
- /** Suffix to include in the randomly generated directory name */
223
+ /** Suffix to include in the randomly generated directory name. */
4
224
  suffix: string;
5
225
  /** Absolute path to the directory where the random directory will be created. */
6
226
  directory: string;
7
- /** Type of word to use for random name */
227
+ /** Type of word to use for random name. */
8
228
  family?: RandomNameFamily;
9
229
  }
10
230
  /**
11
231
  * It generates a random directory directory name for a sub-directory.
12
232
  * It ensures that the returned directory name doesn't exist.
13
233
  *
234
+ * @param options - Options to generate the random directory name.
14
235
  * @returns It returns the name of the directory.
15
236
  */
16
237
  export declare function generateRandomNameForSubdirectory(options: GenerateRandomDirectoryOptions): Promise<string>;
17
- export {};
238
+ /**
239
+ * Traverse the file system and return pathnames that match the given pattern.
240
+ *
241
+ * @param pattern - A glob pattern or an array of glob patterns.
242
+ * @param options - Options for the glob.
243
+ * @returns A promise that resolves to an array of pathnames that match the given pattern.
244
+ */
245
+ export declare function glob(pattern: Pattern | Pattern[], options?: GlobOptions): Promise<string[]>;
246
+ export { pathToFileURL } from 'url';
247
+ /**
248
+ * Find a file by walking parent directories.
249
+ *
250
+ * @param matcher - A pattern or an array of patterns to match a file name.
251
+ * @param options - Options for the search.
252
+ * @returns The first path found that matches or `undefined` if none could be found.
253
+ */
254
+ export declare function findPathUp(matcher: OverloadParameters<typeof internalFindUp>[0], options: OverloadParameters<typeof internalFindUp>[1]): ReturnType<typeof internalFindUp>;
@@ -1,10 +1,345 @@
1
- import { exists as fileExists } from '../../file.js';
2
- import { join as joinPath } from '../../path.js';
1
+ import { joinPath, normalizePath } from './path.js';
2
+ import { content as outputContent, token, debug } from '../../output.js';
3
3
  import { getRandomName } from '../common/string.js';
4
+ import { copy as fsCopy, ensureFile as fsEnsureFile, ensureFileSync as fsEnsureFileSync, remove as fsRemove, removeSync as fsRemoveSync, move as fsMove,
5
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
6
+ // @ts-ignore
7
+ } from 'fs-extra/esm';
8
+ import { temporaryDirectoryTask } from 'tempy';
9
+ import { sep, join, extname } from 'pathe';
10
+ import { findUp as internalFindUp } from 'find-up';
11
+ import { mkdirSync as fsMkdirSync, readFileSync as fsReadFileSync, writeFileSync as fsWriteFileSync, appendFileSync as fsAppendFileSync, statSync as fsStatSync, createReadStream as fsCreateReadStream, constants as fsConstants, } from 'fs';
12
+ import { mkdir as fsMkdir, writeFile as fsWriteFile, readFile as fsReadFile, realpath as fsRealPath, appendFile as fsAppendFile, mkdtemp as fsMkdtemp, stat as fsStat, lstat as fsLstat, chmod as fsChmod, access as fsAccess, } from 'fs/promises';
13
+ const DEFAULT_PRETTIER_CONFIG = {
14
+ arrowParens: 'always',
15
+ singleQuote: true,
16
+ bracketSpacing: false,
17
+ trailingComma: 'all',
18
+ };
19
+ /**
20
+ * Strip the first `strip` parts of the path.
21
+ *
22
+ * @param path - Path to strip.
23
+ * @param strip - Number of parts to strip.
24
+ * @returns The stripped path.
25
+ */
26
+ export function stripUpPath(path, strip) {
27
+ const parts = path.split(sep);
28
+ return join(...parts.slice(strip));
29
+ }
30
+ /**
31
+ * Creates a temporary directory and ties its lifecycle to the lifecycle of the callback.
32
+ *
33
+ * @param callback - The callback that receives the temporary directory.
34
+ */
35
+ export async function inTemporaryDirectory(callback) {
36
+ return temporaryDirectoryTask(callback);
37
+ }
38
+ /**
39
+ * It reads a file and returns its content as a string.
40
+ * Uses utf-8 encoding by default.
41
+ *
42
+ * @param path - Path to the file to read.
43
+ * @param options - Options to read the file with (defaults to utf-8 encoding).
44
+ * @returns A promise that resolves with the content of the file.
45
+ */
46
+ export async function readFile(path, options = { encoding: 'utf8' }) {
47
+ debug(outputContent `Reading the content of file at ${token.path(path)}...`);
48
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
49
+ // @ts-ignore
50
+ return fsReadFile(path, options);
51
+ }
52
+ /**
53
+ * Synchronously reads a file and returns its content as a buffer.
54
+ *
55
+ * @param path - Path to the file to read.
56
+ * @returns The content of the file.
57
+ */
58
+ export function readFileSync(path) {
59
+ debug(outputContent `Sync-reading the content of file at ${token.path(path)}...`);
60
+ return fsReadFileSync(path);
61
+ }
62
+ /**
63
+ * Given a path, it determines the actual path. This is useful when working
64
+ * with paths that represent symlinks.
65
+ *
66
+ * @param path - Path whose real path will be returned.
67
+ */
68
+ export async function fileRealPath(path) {
69
+ return fsRealPath(path);
70
+ }
71
+ /**
72
+ * Copies a file.
73
+ *
74
+ * @param from - Path to the directory or file to be copied.
75
+ * @param to - Destination path.
76
+ */
77
+ export async function copyFile(from, to) {
78
+ debug(outputContent `Copying file from ${token.path(from)} to ${token.path(to)}...`);
79
+ await fsCopy(from, to);
80
+ }
81
+ /**
82
+ * Creates a file at the given path.
83
+ *
84
+ * @param path - Path to the file to be created.
85
+ */
86
+ export async function touchFile(path) {
87
+ debug(outputContent `Creating an empty file at ${token.path(path)}...`);
88
+ await fsEnsureFile(path);
89
+ }
90
+ /**
91
+ * Synchronously creates a file at the given path.
92
+ *
93
+ * @param path - Path to the file to be created.
94
+ */
95
+ export function touchFileSync(path) {
96
+ debug(outputContent `Creating an empty file at ${token.path(path)}...`);
97
+ fsEnsureFileSync(path);
98
+ }
99
+ /**
100
+ * Appnds content to file at path.
101
+ *
102
+ * @param path - Path to the file to be appended.
103
+ * @param content - Content to be appended.
104
+ */
105
+ export async function appendFile(path, content) {
106
+ debug(outputContent `Appending the following content to ${token.path(path)}:
107
+ ${content
108
+ .split('\n')
109
+ .map((line) => ` ${line}`)
110
+ .join('\n')}
111
+ `);
112
+ await fsAppendFile(path, content);
113
+ }
114
+ /**
115
+ * Synchronously appends content to file at path.
116
+ *
117
+ * @param path - Path to the file to be appended.
118
+ * @param data - Content to be appended.
119
+ */
120
+ export function appendFileSync(path, data) {
121
+ fsAppendFileSync(path, data);
122
+ }
123
+ /**
124
+ * Writes content to file at path.
125
+ *
126
+ * @param path - Path to the file to be written.
127
+ * @param data - Content to be written.
128
+ */
129
+ export async function writeFile(path, data) {
130
+ debug(outputContent `Writing some content to file at ${token.path(path)}...`);
131
+ await fsWriteFile(path, data, { encoding: 'utf8' });
132
+ }
133
+ /**
134
+ * Synchronously writes content to file at path.
135
+ *
136
+ * @param path - Path to the file to be written.
137
+ * @param data - Content to be written.
138
+ */
139
+ export function writeFileSync(path, data) {
140
+ debug(outputContent `File-writing some content to file at ${token.path(path)}...`);
141
+ fsWriteFileSync(path, data);
142
+ }
143
+ /**
144
+ * Creates a directory at the given path.
145
+ *
146
+ * @param path - Path to the directory to be created.
147
+ */
148
+ export async function mkdir(path) {
149
+ debug(outputContent `Creating directory at ${token.path(path)}...`);
150
+ await fsMkdir(path, { recursive: true });
151
+ }
152
+ /**
153
+ * Synchronously creates a directory at the given path.
154
+ *
155
+ * @param path - Path to the directory to be created.
156
+ */
157
+ export function mkdirSync(path) {
158
+ debug(outputContent `Sync-creating directory at ${token.path(path)}...`);
159
+ fsMkdirSync(path, { recursive: true });
160
+ }
161
+ /**
162
+ * Removes a file at the given path.
163
+ *
164
+ * @param path - Path to the file to be removed.
165
+ */
166
+ export async function removeFile(path) {
167
+ debug(outputContent `Removing file at ${token.path(path)}...`);
168
+ await fsRemove(path);
169
+ }
170
+ /**
171
+ * Synchronously removes a file at the given path.
172
+ *
173
+ * @param path - Path to the file to be removed.
174
+ */
175
+ export function removeFileSync(path) {
176
+ debug(outputContent `Sync-removing file at ${token.path(path)}...`);
177
+ fsRemoveSync(path);
178
+ }
179
+ /**
180
+ * Removes a directory at the given path.
181
+ *
182
+ * @param path - Path to the directory to be removed.
183
+ * @param options - Options to remove the directory with.
184
+ */
185
+ export async function rmdir(path, options = {}) {
186
+ const { default: del } = await import('del');
187
+ debug(outputContent `Removing directory at ${token.path(path)}...`);
188
+ await del(path, { force: options.force });
189
+ }
190
+ /**
191
+ * Create a temporary directory.
192
+ *
193
+ * @returns Path to the temporary directory.
194
+ */
195
+ export async function mkTmpDir() {
196
+ debug(outputContent `Creating a temporary directory...`);
197
+ const directory = await fsMkdtemp('tmp-');
198
+ return directory;
199
+ }
200
+ /**
201
+ * Check whether a path is a directory.
202
+ *
203
+ * @param path - Path to check.
204
+ * @returns True if the path is a directory, false otherwise.
205
+ */
206
+ export async function isDirectory(path) {
207
+ debug(outputContent `Checking if ${token.path(path)} is a directory...`);
208
+ return (await fsLstat(path)).isDirectory();
209
+ }
210
+ /**
211
+ * Get the size of a file.
212
+ *
213
+ * @param path - Path to the file.
214
+ * @returns The size of the file in bytes.
215
+ */
216
+ export async function fileSize(path) {
217
+ debug(outputContent `Getting the size of file file at ${token.path(path)}...`);
218
+ return (await fsStat(path)).size;
219
+ }
220
+ /**
221
+ * Synchronously get the size of a file.
222
+ *
223
+ * @param path - Path to the file.
224
+ * @returns The size of the file in bytes.
225
+ */
226
+ export function fileSizeSync(path) {
227
+ debug(outputContent `Sync-getting the size of file file at ${token.path(path)}...`);
228
+ return fsStatSync(path).size;
229
+ }
230
+ /**
231
+ * Create a read stream for a file.
232
+ *
233
+ * @param path - Path to the file.
234
+ * @returns A read stream for the file.
235
+ */
236
+ export function createFileReadStream(path) {
237
+ return fsCreateReadStream(path);
238
+ }
239
+ /**
240
+ * Returns the Date object for the last modification of a file.
241
+ *
242
+ * @param path - Path to the directory or file.
243
+ * @returns A unix timestamp.
244
+ */
245
+ export async function fileLastUpdated(path) {
246
+ debug(outputContent `Getting last updated timestamp for file at ${token.path(path)}...`);
247
+ return (await fsStat(path)).ctime;
248
+ }
249
+ /**
250
+ * Returns the unix timestamp of the last modification of a file.
251
+ *
252
+ * @param path - Path to the directory or file.
253
+ * @returns A unix timestamp.
254
+ */
255
+ export async function fileLastUpdatedTimestamp(path) {
256
+ try {
257
+ const lastUpdatedDateTime = await fileLastUpdated(path);
258
+ return lastUpdatedDateTime.getTime();
259
+ // eslint-disable-next-line no-catch-all/no-catch-all
260
+ }
261
+ catch {
262
+ return undefined;
263
+ }
264
+ }
265
+ /**
266
+ * Moves a file.
267
+ *
268
+ * @param src - File to be moved.
269
+ * @param dest - Path to be moved to.
270
+ * @param options - Moving options.
271
+ */
272
+ export async function moveFile(src, dest, options = {}) {
273
+ await fsMove(src, dest, options);
274
+ }
275
+ /**
276
+ * Changes the permissions of a directory or file.
277
+ *
278
+ * @param path - Path to the file or directory whose permissions will be modified.
279
+ * @param mode - Permissions to set to the file or directory.
280
+ */
281
+ export async function chmod(path, mode) {
282
+ await fsChmod(path, mode);
283
+ }
284
+ /**
285
+ * Checks if a file has executable permissions.
286
+ *
287
+ * @param path - Path to the file whose permissions will be checked.
288
+ */
289
+ export async function fileHasExecutablePermissions(path) {
290
+ try {
291
+ await fsAccess(path, fsConstants.X_OK);
292
+ return true;
293
+ // eslint-disable-next-line no-catch-all/no-catch-all
294
+ }
295
+ catch {
296
+ return false;
297
+ }
298
+ }
299
+ /**
300
+ * Returns true if a file or directory exists.
301
+ *
302
+ * @param path - Path to the directory or file.
303
+ * @returns True if it exists.
304
+ */
305
+ export async function fileExists(path) {
306
+ try {
307
+ await fsAccess(path);
308
+ return true;
309
+ // eslint-disable-next-line no-catch-all/no-catch-all
310
+ }
311
+ catch {
312
+ return false;
313
+ }
314
+ }
315
+ /**
316
+ * Format a string using prettier. Return the formatted content.
317
+ *
318
+ * @param content - Content to be formatted.
319
+ * @param options - Options to format the content with.
320
+ * @returns The formatted content.
321
+ */
322
+ export async function fileContentPrettyFormat(content, options) {
323
+ const { default: prettier } = await import('prettier');
324
+ const ext = extname(options.path);
325
+ const prettierConfig = {
326
+ ...DEFAULT_PRETTIER_CONFIG,
327
+ parser: 'babel',
328
+ };
329
+ switch (ext) {
330
+ case '.html':
331
+ case '.css':
332
+ prettierConfig.parser = ext.slice(1);
333
+ break;
334
+ }
335
+ const formattedContent = await prettier.format(content, prettierConfig);
336
+ return formattedContent;
337
+ }
4
338
  /**
5
339
  * It generates a random directory directory name for a sub-directory.
6
340
  * It ensures that the returned directory name doesn't exist.
7
341
  *
342
+ * @param options - Options to generate the random directory name.
8
343
  * @returns It returns the name of the directory.
9
344
  */
10
345
  export async function generateRandomNameForSubdirectory(options) {
@@ -18,4 +353,33 @@ export async function generateRandomNameForSubdirectory(options) {
18
353
  return generated;
19
354
  }
20
355
  }
356
+ /**
357
+ * Traverse the file system and return pathnames that match the given pattern.
358
+ *
359
+ * @param pattern - A glob pattern or an array of glob patterns.
360
+ * @param options - Options for the glob.
361
+ * @returns A promise that resolves to an array of pathnames that match the given pattern.
362
+ */
363
+ export async function glob(pattern, options) {
364
+ const { default: fastGlob } = await import('fast-glob');
365
+ let overridenOptions = options;
366
+ if (options?.dot == null) {
367
+ overridenOptions = { ...options, dot: true };
368
+ }
369
+ return fastGlob(pattern, overridenOptions);
370
+ }
371
+ export { pathToFileURL } from 'url';
372
+ /**
373
+ * Find a file by walking parent directories.
374
+ *
375
+ * @param matcher - A pattern or an array of patterns to match a file name.
376
+ * @param options - Options for the search.
377
+ * @returns The first path found that matches or `undefined` if none could be found.
378
+ */
379
+ export async function findPathUp(matcher, options) {
380
+ // findUp has odd typing
381
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
382
+ const got = await internalFindUp(matcher, options);
383
+ return got ? normalizePath(got) : undefined;
384
+ }
21
385
  //# sourceMappingURL=fs.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"fs.js","sourceRoot":"","sources":["../../../src/public/node/fs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,MAAM,IAAI,UAAU,EAAC,MAAM,eAAe,CAAA;AAClD,OAAO,EAAC,IAAI,IAAI,QAAQ,EAAC,MAAM,eAAe,CAAA;AAC9C,OAAO,EAAC,aAAa,EAAC,MAAM,qBAAqB,CAAA;AAcjD;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,iCAAiC,CAAC,OAAuC;IAC7F,MAAM,SAAS,GAAG,GAAG,aAAa,CAAC,OAAO,CAAC,MAAM,IAAI,UAAU,CAAC,IAAI,OAAO,CAAC,MAAM,EAAE,CAAA;IACpF,MAAM,mBAAmB,GAAG,QAAQ,CAAC,OAAO,CAAC,SAAS,EAAE,SAAS,CAAC,CAAA;IAClE,MAAM,mBAAmB,GAAG,MAAM,UAAU,CAAC,mBAAmB,CAAC,CAAA;IAEjE,IAAI,mBAAmB,EAAE;QACvB,OAAO,iCAAiC,CAAC,OAAO,CAAC,CAAA;KAClD;SAAM;QACL,OAAO,SAAS,CAAA;KACjB;AACH,CAAC","sourcesContent":["import {exists as fileExists} from '../../file.js'\nimport {join as joinPath} from '../../path.js'\nimport {getRandomName} from '../common/string.js'\nimport type {RandomNameFamily} from '../common/string.js'\n\ninterface GenerateRandomDirectoryOptions {\n /** Suffix to include in the randomly generated directory name */\n suffix: string\n\n /** Absolute path to the directory where the random directory will be created. */\n directory: string\n\n /** Type of word to use for random name */\n family?: RandomNameFamily\n}\n\n/**\n * It generates a random directory directory name for a sub-directory.\n * It ensures that the returned directory name doesn't exist.\n *\n * @returns It returns the name of the directory.\n */\nexport async function generateRandomNameForSubdirectory(options: GenerateRandomDirectoryOptions): Promise<string> {\n const generated = `${getRandomName(options.family ?? 'business')}-${options.suffix}`\n const randomDirectoryPath = joinPath(options.directory, generated)\n const isAppDirectoryTaken = await fileExists(randomDirectoryPath)\n\n if (isAppDirectoryTaken) {\n return generateRandomNameForSubdirectory(options)\n } else {\n return generated\n }\n}\n"]}
1
+ {"version":3,"file":"fs.js","sourceRoot":"","sources":["../../../src/public/node/fs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,QAAQ,EAAE,aAAa,EAAC,MAAM,WAAW,CAAA;AACjD,OAAO,EAAC,OAAO,IAAI,aAAa,EAAE,KAAK,EAAE,KAAK,EAAC,MAAM,iBAAiB,CAAA;AACtE,OAAO,EAAC,aAAa,EAAmB,MAAM,qBAAqB,CAAA;AAEnE,OAAO,EACL,IAAI,IAAI,MAAM,EACd,UAAU,IAAI,YAAY,EAC1B,cAAc,IAAI,gBAAgB,EAClC,MAAM,IAAI,QAAQ,EAClB,UAAU,IAAI,YAAY,EAC1B,IAAI,IAAI,MAAM;AACd,6DAA6D;AAC7D,aAAa;EACd,MAAM,cAAc,CAAA;AAErB,OAAO,EAAC,sBAAsB,EAAC,MAAM,OAAO,CAAA;AAC5C,OAAO,EAAC,GAAG,EAAE,IAAI,EAAE,OAAO,EAAC,MAAM,OAAO,CAAA;AACxC,OAAO,EAAC,MAAM,IAAI,cAAc,EAAC,MAAM,SAAS,CAAA;AAChD,OAAO,EACL,SAAS,IAAI,WAAW,EACxB,YAAY,IAAI,cAAc,EAC9B,aAAa,IAAI,eAAe,EAChC,cAAc,IAAI,gBAAgB,EAClC,QAAQ,IAAI,UAAU,EACtB,gBAAgB,IAAI,kBAAkB,EACtC,SAAS,IAAI,WAAW,GAEzB,MA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,CAAC,SAAS,EAAE,SAAS,CAAC,CAAA;IAClE,MAAM,mBAAmB,GAAG,MAAM,UAAU,CAAC,mBAAmB,CAAC,CAAA;IAEjE,IAAI,mBAAmB,EAAE;QACvB,OAAO,iCAAiC,CAAC,OAAO,CAAC,CAAA;KAClD;SAAM;QACL,OAAO,SAAS,CAAA;KACjB;AACH,CAAC;AAED;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,IAAI,CAAC,OAA4B,EAAE,OAAqB;IAC5E,MAAM,EAAC,OAAO,EAAE,QAAQ,EAAC,GAAG,MAAM,MAAM,CAAC,WAAW,CAAC,CAAA;IACrD,IAAI,gBAAgB,GAAG,OAAO,CAAA;IAC9B,IAAI,OAAO,EAAE,GAAG,IAAI,IAAI,EAAE;QACxB,gBAAgB,GAAG,EAAC,GAAG,OAAO,EAAE,GAAG,EAAE,IAAI,EAAC,CAAA;KAC3C;IACD,OAAO,QAAQ,CAAC,OAAO,EAAE,gBAAgB,CAAC,CAAA;AAC5C,CAAC;AACD,OAAO,EAAC,aAAa,EAAC,MAAM,KAAK,CAAA;AAEjC;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,UAAU,CAC9B,OAAqD,EACrD,OAAqD;IAErD,wBAAwB;IACxB,8DAA8D;IAC9D,MAAM,GAAG,GAAG,MAAM,cAAc,CAAC,OAAc,EAAE,OAAO,CAAC,CAAA;IACzD,OAAO,GAAG,CAAC,CAAC,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,CAAA;AAC7C,CAAC","sourcesContent":["import {joinPath, normalizePath} from './path.js'\nimport {content as outputContent, token, debug} from '../../output.js'\nimport {getRandomName, RandomNameFamily} from '../common/string.js'\nimport {OverloadParameters} from '../../private/common/ts/overloaded-parameters.js'\nimport {\n copy as fsCopy,\n ensureFile as fsEnsureFile,\n ensureFileSync as fsEnsureFileSync,\n remove as fsRemove,\n removeSync as fsRemoveSync,\n move as fsMove,\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n} from 'fs-extra/esm'\n\nimport {temporaryDirectoryTask} from 'tempy'\nimport {sep, join, extname} from 'pathe'\nimport {findUp as internalFindUp} from 'find-up'\nimport {\n mkdirSync as fsMkdirSync,\n readFileSync as fsReadFileSync,\n writeFileSync as fsWriteFileSync,\n appendFileSync as fsAppendFileSync,\n statSync as fsStatSync,\n createReadStream as fsCreateReadStream,\n constants as fsConstants,\n ReadStream,\n} from 'fs'\nimport {\n mkdir as fsMkdir,\n writeFile as fsWriteFile,\n readFile as fsReadFile,\n realpath as fsRealPath,\n appendFile as fsAppendFile,\n mkdtemp as fsMkdtemp,\n stat as fsStat,\n lstat as fsLstat,\n chmod as fsChmod,\n access as fsAccess,\n} from 'fs/promises'\nimport type {Options} from 'prettier'\nimport type {Pattern, Options as GlobOptions} from 'fast-glob'\n\nconst DEFAULT_PRETTIER_CONFIG: Options = {\n arrowParens: 'always',\n singleQuote: true,\n bracketSpacing: false,\n trailingComma: 'all',\n}\n\n/**\n * Strip the first `strip` parts of the path.\n *\n * @param path - Path to strip.\n * @param strip - Number of parts to strip.\n * @returns The stripped path.\n */\nexport function stripUpPath(path: string, strip: number): string {\n const parts = path.split(sep)\n return join(...parts.slice(strip))\n}\n\n/**\n * Creates a temporary directory and ties its lifecycle to the lifecycle of the callback.\n *\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 *\n * @param path - Path to the file to read.\n * @returns A promise that resolves with the content of the file.\n */\n\nexport type ReadOptions =\n | undefined\n | {flag?: string | undefined}\n | {\n encoding: BufferEncoding | string\n flag?: string | undefined\n }\nexport async function readFile(path: string, options?: ReadOptions): Promise<string>\nexport async function readFile(path: string, options?: ReadOptions): Promise<Buffer>\n\n/**\n * It reads a file and returns its content as a string.\n * Uses utf-8 encoding by default.\n *\n * @param path - Path to the file to read.\n * @param options - Options to read the file with (defaults to utf-8 encoding).\n * @returns A promise that resolves with the content of the file.\n */\nexport async function readFile(path: string, options: ReadOptions = {encoding: 'utf8'}): Promise<string | Buffer> {\n debug(outputContent`Reading the content of file at ${token.path(path)}...`)\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n return fsReadFile(path, options)\n}\n\n/**\n * Synchronously reads a file and returns its content as a buffer.\n *\n * @param path - Path to the file to read.\n * @returns The content of the file.\n */\nexport function readFileSync(path: string): Buffer {\n debug(outputContent`Sync-reading the content of file at ${token.path(path)}...`)\n return fsReadFileSync(path)\n}\n\n/**\n * Given a path, it determines the actual path. This is useful when working\n * with paths that represent symlinks.\n *\n * @param path - Path whose real path will be returned.\n */\nexport async function fileRealPath(path: string): Promise<string> {\n return fsRealPath(path)\n}\n\n/**\n * Copies a file.\n *\n * @param from - Path to the directory or file to be copied.\n * @param to - Destination path.\n */\nexport async function copyFile(from: string, to: string): Promise<void> {\n debug(outputContent`Copying file from ${token.path(from)} to ${token.path(to)}...`)\n await fsCopy(from, to)\n}\n\n/**\n * Creates a file at the given path.\n *\n * @param path - Path to the file to be created.\n */\nexport async function touchFile(path: string): Promise<void> {\n debug(outputContent`Creating an empty file at ${token.path(path)}...`)\n await fsEnsureFile(path)\n}\n\n/**\n * Synchronously creates a file at the given path.\n *\n * @param path - Path to the file to be created.\n */\nexport function touchFileSync(path: string): void {\n debug(outputContent`Creating an empty file at ${token.path(path)}...`)\n fsEnsureFileSync(path)\n}\n\n/**\n * Appnds content to file at path.\n *\n * @param path - Path to the file to be appended.\n * @param content - Content to be appended.\n */\nexport async function appendFile(path: string, content: string): Promise<void> {\n debug(outputContent`Appending the following content to ${token.path(path)}:\n ${content\n .split('\\n')\n .map((line) => ` ${line}`)\n .join('\\n')}\n `)\n await fsAppendFile(path, content)\n}\n\n/**\n * Synchronously appends content to file at path.\n *\n * @param path - Path to the file to be appended.\n * @param data - Content to be appended.\n */\nexport function appendFileSync(path: string, data: string): void {\n fsAppendFileSync(path, data)\n}\n\n/**\n * Writes content to file at path.\n *\n * @param path - Path to the file to be written.\n * @param data - Content to be written.\n */\nexport async function writeFile(path: string, data: string): Promise<void> {\n debug(outputContent`Writing some content to file at ${token.path(path)}...`)\n await fsWriteFile(path, data, {encoding: 'utf8'})\n}\n\n/**\n * Synchronously writes content to file at path.\n *\n * @param path - Path to the file to be written.\n * @param data - Content to be written.\n */\nexport function writeFileSync(path: string, data: string): void {\n debug(outputContent`File-writing some content to file at ${token.path(path)}...`)\n fsWriteFileSync(path, data)\n}\n\n/**\n * Creates a directory at the given path.\n *\n * @param path - Path to the directory to be created.\n */\nexport async function mkdir(path: string): Promise<void> {\n debug(outputContent`Creating directory at ${token.path(path)}...`)\n await fsMkdir(path, {recursive: true})\n}\n\n/**\n * Synchronously creates a directory at the given path.\n *\n * @param path - Path to the directory to be created.\n */\nexport function mkdirSync(path: string): void {\n debug(outputContent`Sync-creating directory at ${token.path(path)}...`)\n fsMkdirSync(path, {recursive: true})\n}\n\n/**\n * Removes a file at the given path.\n *\n * @param path - Path to the file to be removed.\n */\nexport async function removeFile(path: string): Promise<void> {\n debug(outputContent`Removing file at ${token.path(path)}...`)\n await fsRemove(path)\n}\n\n/**\n * Synchronously removes a file at the given path.\n *\n * @param path - Path to the file to be removed.\n */\nexport function removeFileSync(path: string): void {\n debug(outputContent`Sync-removing file at ${token.path(path)}...`)\n fsRemoveSync(path)\n}\n\ninterface RmDirOptions {\n force?: boolean\n}\n/**\n * Removes a directory at the given path.\n *\n * @param path - Path to the directory to be removed.\n * @param options - Options to remove the directory with.\n */\nexport async function rmdir(path: string, options: RmDirOptions = {}): Promise<void> {\n const {default: del} = await import('del')\n debug(outputContent`Removing directory at ${token.path(path)}...`)\n await del(path, {force: options.force})\n}\n\n/**\n * Create a temporary directory.\n *\n * @returns Path to the temporary directory.\n */\nexport async function mkTmpDir(): Promise<string> {\n debug(outputContent`Creating a temporary directory...`)\n const directory = await fsMkdtemp('tmp-')\n return directory\n}\n\n/**\n * Check whether a path is a directory.\n *\n * @param path - Path to check.\n * @returns True if the path is a directory, false otherwise.\n */\nexport async function isDirectory(path: string): Promise<boolean> {\n debug(outputContent`Checking if ${token.path(path)} is a directory...`)\n return (await fsLstat(path)).isDirectory()\n}\n\n/**\n * Get the size of a file.\n *\n * @param path - Path to the file.\n * @returns The size of the file in bytes.\n */\nexport async function fileSize(path: string): Promise<number> {\n debug(outputContent`Getting the size of file file at ${token.path(path)}...`)\n return (await fsStat(path)).size\n}\n\n/**\n * Synchronously get the size of a file.\n *\n * @param path - Path to the file.\n * @returns The size of the file in bytes.\n */\nexport function fileSizeSync(path: string): number {\n debug(outputContent`Sync-getting the size of file file at ${token.path(path)}...`)\n return fsStatSync(path).size\n}\n\n/**\n * Create a read stream for a file.\n *\n * @param path - Path to the file.\n * @returns A read stream for the file.\n */\nexport function createFileReadStream(path: string): ReadStream {\n return fsCreateReadStream(path)\n}\n\n/**\n * Returns the Date object for the last modification of a file.\n *\n * @param path - Path to the directory or file.\n * @returns A unix timestamp.\n */\nexport async function fileLastUpdated(path: string): Promise<Date> {\n debug(outputContent`Getting last updated timestamp for file at ${token.path(path)}...`)\n return (await fsStat(path)).ctime\n}\n\n/**\n * Returns the unix timestamp of the last modification of a file.\n *\n * @param path - Path to the directory or file.\n * @returns A unix timestamp.\n */\nexport async function fileLastUpdatedTimestamp(path: string): Promise<number | undefined> {\n try {\n const lastUpdatedDateTime = await fileLastUpdated(path)\n return lastUpdatedDateTime.getTime()\n // eslint-disable-next-line no-catch-all/no-catch-all\n } catch {\n return undefined\n }\n}\n\ninterface MoveFileOptions {\n overwrite?: boolean\n}\n\n/**\n * Moves a file.\n *\n * @param src - File to be moved.\n * @param dest - Path to be moved to.\n * @param options - Moving options.\n */\nexport async function moveFile(src: string, dest: string, options: MoveFileOptions = {}): Promise<void> {\n await fsMove(src, dest, options)\n}\n\n/**\n * Changes the permissions of a directory or file.\n *\n * @param path - Path to the file or directory whose permissions will be modified.\n * @param mode - Permissions to set to the file or directory.\n */\nexport async function chmod(path: string, mode: number | string): Promise<void> {\n await fsChmod(path, mode)\n}\n\n/**\n * Checks if a file has executable permissions.\n *\n * @param path - Path to the file whose permissions will be checked.\n */\nexport async function fileHasExecutablePermissions(path: string): Promise<boolean> {\n try {\n await fsAccess(path, fsConstants.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 *\n * @param path - Path to the directory or file.\n * @returns True if it exists.\n */\nexport async function fileExists(path: string): Promise<boolean> {\n try {\n await fsAccess(path)\n return true\n // eslint-disable-next-line no-catch-all/no-catch-all\n } catch {\n return false\n }\n}\n\ninterface FileOptions {\n path: string\n}\n\n/**\n * Format a string using prettier. Return the formatted content.\n *\n * @param content - Content to be formatted.\n * @param options - Options to format the content with.\n * @returns The formatted content.\n */\nexport async function fileContentPrettyFormat(content: string, options: FileOptions): Promise<string> {\n const {default: prettier} = await import('prettier')\n\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\ninterface GenerateRandomDirectoryOptions {\n /** Suffix to include in the randomly generated directory name. */\n suffix: string\n\n /** Absolute path to the directory where the random directory will be created. */\n directory: string\n\n /** Type of word to use for random name. */\n family?: RandomNameFamily\n}\n\n/**\n * It generates a random directory directory name for a sub-directory.\n * It ensures that the returned directory name doesn't exist.\n *\n * @param options - Options to generate the random directory name.\n * @returns It returns the name of the directory.\n */\nexport async function generateRandomNameForSubdirectory(options: GenerateRandomDirectoryOptions): Promise<string> {\n const generated = `${getRandomName(options.family ?? 'business')}-${options.suffix}`\n const randomDirectoryPath = joinPath(options.directory, generated)\n const isAppDirectoryTaken = await fileExists(randomDirectoryPath)\n\n if (isAppDirectoryTaken) {\n return generateRandomNameForSubdirectory(options)\n } else {\n return generated\n }\n}\n\n/**\n * Traverse the file system and return pathnames that match the given pattern.\n *\n * @param pattern - A glob pattern or an array of glob patterns.\n * @param options - Options for the glob.\n * @returns A promise that resolves to an array of pathnames that match the given pattern.\n */\nexport async function glob(pattern: Pattern | Pattern[], options?: GlobOptions): Promise<string[]> {\n const {default: fastGlob} = await import('fast-glob')\n let overridenOptions = options\n if (options?.dot == null) {\n overridenOptions = {...options, dot: true}\n }\n return fastGlob(pattern, overridenOptions)\n}\nexport {pathToFileURL} from 'url'\n\n/**\n * Find a file by walking parent directories.\n *\n * @param matcher - A pattern or an array of patterns to match a file name.\n * @param options - Options for the search.\n * @returns The first path found that matches or `undefined` if none could be found.\n */\nexport async function findPathUp(\n matcher: OverloadParameters<typeof internalFindUp>[0],\n options: OverloadParameters<typeof internalFindUp>[1],\n): ReturnType<typeof internalFindUp> {\n // findUp has odd typing\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const got = await internalFindUp(matcher as any, options)\n return got ? normalizePath(got) : undefined\n}\n"]}