|
1 |
| -import { randomInt } from "node:crypto"; |
2 |
| -import fs from "node:fs"; |
3 |
| -import { parseArgs, styleText } from "node:util"; |
| 1 | +import { randomInt } from 'node:crypto'; |
| 2 | +import fs from 'node:fs'; |
| 3 | +import { parseArgs, styleText } from 'node:util'; |
4 | 4 |
|
5 | 5 | interface User {
|
6 |
| - id: string; |
7 |
| - email: string; |
| 6 | + id: string; |
| 7 | + email: string; |
8 | 8 | }
|
9 | 9 |
|
10 | 10 | const args = parseArgs({
|
11 |
| - options: { |
12 |
| - url: { |
13 |
| - type: "string", |
14 |
| - }, |
15 |
| - dry: { |
16 |
| - type: "boolean", |
17 |
| - default: true, |
18 |
| - }, |
19 |
| - }, |
| 11 | + options: { |
| 12 | + url: { |
| 13 | + type: 'string', |
| 14 | + }, |
| 15 | + dry: { |
| 16 | + type: 'boolean', |
| 17 | + default: true, |
| 18 | + }, |
| 19 | + }, |
20 | 20 | });
|
21 | 21 |
|
22 | 22 | const user = (await fetch(`https://dummyjson.com/users/${randomInt(100)}`).then(
|
23 |
| - (data) => data.json(), |
| 23 | + (data) => data.json(), |
24 | 24 | )) as User;
|
25 | 25 |
|
26 | 26 | const data = {
|
27 |
| - user: { |
28 |
| - id: user.id, |
29 |
| - email: user.email, |
30 |
| - }, |
31 |
| - args: { ...args.values }, |
32 |
| - env: { token: process.env.API_TOKEN }, |
| 27 | + user: { |
| 28 | + id: user.id, |
| 29 | + email: user.email, |
| 30 | + }, |
| 31 | + args: { ...args.values }, |
| 32 | + env: { token: process.env.API_TOKEN }, |
33 | 33 | };
|
34 | 34 |
|
35 |
| -fs.writeFileSync("input.json", JSON.stringify(data, null, 2)); |
| 35 | +fs.writeFileSync('input.json', JSON.stringify(data, null, 2)); |
36 | 36 |
|
37 | 37 | console.log(
|
38 |
| - styleText("green", "Execution completed."), |
39 |
| - "\n", |
40 |
| - JSON.stringify({ data }, null, 2), |
| 38 | + styleText('green', 'Execution completed.'), |
| 39 | + '\n', |
| 40 | + JSON.stringify({ data }, null, 2), |
41 | 41 | );
|
0 commit comments