buner 1.0.2 → 1.0.3
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.
- package/bin/buner.js +17 -14
- package/cli/helpers/format-files.ts +17 -13
- package/package.json +1 -1
package/bin/buner.js
CHANGED
|
@@ -13,7 +13,7 @@ import { globby } from "globby";
|
|
|
13
13
|
import { exec } from "node:child_process";
|
|
14
14
|
import validateProjectName from "validate-npm-package-name";
|
|
15
15
|
const name = "buner";
|
|
16
|
-
const version = "1.0.
|
|
16
|
+
const version = "1.0.3";
|
|
17
17
|
const description = "Frontend build toolkit for Vite + React SSR projects — SCSS pipeline, prerender, SSR dev server, and backend integration.";
|
|
18
18
|
const type = "module";
|
|
19
19
|
const license = "MIT";
|
|
@@ -194,11 +194,15 @@ const install = async () => {
|
|
|
194
194
|
});
|
|
195
195
|
});
|
|
196
196
|
};
|
|
197
|
+
const writeFile = async (filePath, data) => {
|
|
198
|
+
await fs$1.mkdir(path.dirname(filePath), { recursive: true });
|
|
199
|
+
await fs$1.writeFile(filePath, data);
|
|
200
|
+
};
|
|
197
201
|
const formatFiles = async (root) => {
|
|
198
202
|
let filePath, data;
|
|
199
203
|
filePath = path.join(root, "src/mocks/handlers.ts");
|
|
200
204
|
data = "import { handlers } from './consts';\n\nexport { handlers };";
|
|
201
|
-
await
|
|
205
|
+
await writeFile(filePath, data + os.EOL);
|
|
202
206
|
filePath = path.join(root, "src/mocks/example/index.ts");
|
|
203
207
|
data = `
|
|
204
208
|
import { handlers } from '@mocks/handlers';
|
|
@@ -210,9 +214,8 @@ const formatFiles = async (root) => {
|
|
|
210
214
|
})
|
|
211
215
|
);
|
|
212
216
|
`;
|
|
213
|
-
await
|
|
217
|
+
await writeFile(filePath, data + os.EOL);
|
|
214
218
|
filePath = path.join(root, "src/react-loader.tsx");
|
|
215
|
-
await fs$1.mkdir(path.dirname(filePath), { recursive: true });
|
|
216
219
|
data = [
|
|
217
220
|
"import { lazy } from 'react';",
|
|
218
221
|
"",
|
|
@@ -221,23 +224,23 @@ const formatFiles = async (root) => {
|
|
|
221
224
|
"};",
|
|
222
225
|
""
|
|
223
226
|
].join("\n");
|
|
224
|
-
await
|
|
227
|
+
await writeFile(filePath, data);
|
|
225
228
|
filePath = path.join(root, "src/_types/atoms.d.ts");
|
|
226
|
-
await
|
|
229
|
+
await writeFile(
|
|
227
230
|
filePath,
|
|
228
231
|
`
|
|
229
232
|
import { BasedAtomicModel } from "./_general";
|
|
230
233
|
`
|
|
231
234
|
);
|
|
232
235
|
filePath = path.join(root, "src/_types/molecules.d.ts");
|
|
233
|
-
await
|
|
236
|
+
await writeFile(
|
|
234
237
|
filePath,
|
|
235
238
|
`
|
|
236
239
|
import { BasedAtomicModel } from "./_general";
|
|
237
240
|
`
|
|
238
241
|
);
|
|
239
242
|
filePath = path.join(root, "src/_types/organisms.d.ts");
|
|
240
|
-
await
|
|
243
|
+
await writeFile(
|
|
241
244
|
filePath,
|
|
242
245
|
`
|
|
243
246
|
import { BasedAtomicModel } from "./_general";
|
|
@@ -248,7 +251,7 @@ const formatFiles = async (root) => {
|
|
|
248
251
|
`
|
|
249
252
|
);
|
|
250
253
|
filePath = path.join(root, "src/pages/Home.tsx");
|
|
251
|
-
await
|
|
254
|
+
await writeFile(
|
|
252
255
|
filePath,
|
|
253
256
|
`
|
|
254
257
|
import Template from '@templates/home/Home';
|
|
@@ -261,7 +264,7 @@ const formatFiles = async (root) => {
|
|
|
261
264
|
`
|
|
262
265
|
);
|
|
263
266
|
filePath = path.join(root, "src/templates/home/Home.tsx");
|
|
264
|
-
await
|
|
267
|
+
await writeFile(
|
|
265
268
|
filePath,
|
|
266
269
|
`
|
|
267
270
|
import { FooterModel, HeaderModel } from '@_types/organisms';
|
|
@@ -293,7 +296,7 @@ const formatFiles = async (root) => {
|
|
|
293
296
|
`
|
|
294
297
|
);
|
|
295
298
|
filePath = path.join(root, "src/organisms/header/Header.tsx");
|
|
296
|
-
await
|
|
299
|
+
await writeFile(
|
|
297
300
|
filePath,
|
|
298
301
|
`
|
|
299
302
|
import { getModifiers } from '@helpers/functions';
|
|
@@ -315,9 +318,9 @@ const formatFiles = async (root) => {
|
|
|
315
318
|
`
|
|
316
319
|
);
|
|
317
320
|
filePath = path.join(root, "src/organisms/header/Header.scss");
|
|
318
|
-
await
|
|
321
|
+
await writeFile(filePath, "");
|
|
319
322
|
filePath = path.join(root, "src/organisms/footer/Footer.tsx");
|
|
320
|
-
await
|
|
323
|
+
await writeFile(
|
|
321
324
|
filePath,
|
|
322
325
|
`
|
|
323
326
|
import { getModifiers } from '@helpers/functions';
|
|
@@ -339,7 +342,7 @@ const formatFiles = async (root) => {
|
|
|
339
342
|
`
|
|
340
343
|
);
|
|
341
344
|
filePath = path.join(root, "src/organisms/footer/Footer.scss");
|
|
342
|
-
await
|
|
345
|
+
await writeFile(filePath, "");
|
|
343
346
|
return ["xxx"];
|
|
344
347
|
};
|
|
345
348
|
const filename = fileURLToPath(import.meta.url);
|
|
@@ -2,6 +2,11 @@ import path from 'path';
|
|
|
2
2
|
import os from 'os';
|
|
3
3
|
import fs from 'fs/promises';
|
|
4
4
|
|
|
5
|
+
const writeFile = async (filePath: string, data: string) => {
|
|
6
|
+
await fs.mkdir(path.dirname(filePath), { recursive: true });
|
|
7
|
+
await fs.writeFile(filePath, data);
|
|
8
|
+
};
|
|
9
|
+
|
|
5
10
|
const formatFiles = async (root: string) => {
|
|
6
11
|
let filePath, data;
|
|
7
12
|
|
|
@@ -9,7 +14,7 @@ const formatFiles = async (root: string) => {
|
|
|
9
14
|
filePath = path.join(root, 'src/mocks/handlers.ts');
|
|
10
15
|
data = "import { handlers } from './consts';\n\nexport { handlers };";
|
|
11
16
|
|
|
12
|
-
await
|
|
17
|
+
await writeFile(filePath, data + os.EOL);
|
|
13
18
|
|
|
14
19
|
// example mock file
|
|
15
20
|
filePath = path.join(root, 'src/mocks/example/index.ts');
|
|
@@ -24,11 +29,10 @@ const formatFiles = async (root: string) => {
|
|
|
24
29
|
);
|
|
25
30
|
`;
|
|
26
31
|
|
|
27
|
-
await
|
|
32
|
+
await writeFile(filePath, data + os.EOL);
|
|
28
33
|
|
|
29
34
|
// react loader
|
|
30
35
|
filePath = path.join(root, 'src/react-loader.tsx');
|
|
31
|
-
await fs.mkdir(path.dirname(filePath), { recursive: true });
|
|
32
36
|
data = [
|
|
33
37
|
"import { lazy } from 'react';",
|
|
34
38
|
'',
|
|
@@ -38,12 +42,12 @@ const formatFiles = async (root: string) => {
|
|
|
38
42
|
'',
|
|
39
43
|
].join('\n');
|
|
40
44
|
|
|
41
|
-
await
|
|
45
|
+
await writeFile(filePath, data);
|
|
42
46
|
|
|
43
47
|
// src/_types/atoms.d.ts
|
|
44
48
|
filePath = path.join(root, 'src/_types/atoms.d.ts');
|
|
45
49
|
|
|
46
|
-
await
|
|
50
|
+
await writeFile(
|
|
47
51
|
filePath,
|
|
48
52
|
`
|
|
49
53
|
import { BasedAtomicModel } from "./_general";
|
|
@@ -53,7 +57,7 @@ const formatFiles = async (root: string) => {
|
|
|
53
57
|
// src/_types/molecules.d.d.ts
|
|
54
58
|
filePath = path.join(root, 'src/_types/molecules.d.ts');
|
|
55
59
|
|
|
56
|
-
await
|
|
60
|
+
await writeFile(
|
|
57
61
|
filePath,
|
|
58
62
|
`
|
|
59
63
|
import { BasedAtomicModel } from "./_general";
|
|
@@ -63,7 +67,7 @@ const formatFiles = async (root: string) => {
|
|
|
63
67
|
// src/_types/organisms.d.ts
|
|
64
68
|
filePath = path.join(root, 'src/_types/organisms.d.ts');
|
|
65
69
|
|
|
66
|
-
await
|
|
70
|
+
await writeFile(
|
|
67
71
|
filePath,
|
|
68
72
|
`
|
|
69
73
|
import { BasedAtomicModel } from "./_general";
|
|
@@ -77,7 +81,7 @@ const formatFiles = async (root: string) => {
|
|
|
77
81
|
// pages/Home.tsx
|
|
78
82
|
filePath = path.join(root, 'src/pages/Home.tsx');
|
|
79
83
|
|
|
80
|
-
await
|
|
84
|
+
await writeFile(
|
|
81
85
|
filePath,
|
|
82
86
|
`
|
|
83
87
|
import Template from '@templates/home/Home';
|
|
@@ -93,7 +97,7 @@ const formatFiles = async (root: string) => {
|
|
|
93
97
|
// templates/home/Home.tsx
|
|
94
98
|
filePath = path.join(root, 'src/templates/home/Home.tsx');
|
|
95
99
|
|
|
96
|
-
await
|
|
100
|
+
await writeFile(
|
|
97
101
|
filePath,
|
|
98
102
|
`
|
|
99
103
|
import { FooterModel, HeaderModel } from '@_types/organisms';
|
|
@@ -128,7 +132,7 @@ const formatFiles = async (root: string) => {
|
|
|
128
132
|
// src/organisms/header/Header.tsx
|
|
129
133
|
filePath = path.join(root, 'src/organisms/header/Header.tsx');
|
|
130
134
|
|
|
131
|
-
await
|
|
135
|
+
await writeFile(
|
|
132
136
|
filePath,
|
|
133
137
|
`
|
|
134
138
|
import { getModifiers } from '@helpers/functions';
|
|
@@ -153,12 +157,12 @@ const formatFiles = async (root: string) => {
|
|
|
153
157
|
// src/organisms/header/Header.scss
|
|
154
158
|
filePath = path.join(root, 'src/organisms/header/Header.scss');
|
|
155
159
|
|
|
156
|
-
await
|
|
160
|
+
await writeFile(filePath, '');
|
|
157
161
|
|
|
158
162
|
// src/organisms/footer/Footer.tsx
|
|
159
163
|
filePath = path.join(root, 'src/organisms/footer/Footer.tsx');
|
|
160
164
|
|
|
161
|
-
await
|
|
165
|
+
await writeFile(
|
|
162
166
|
filePath,
|
|
163
167
|
`
|
|
164
168
|
import { getModifiers } from '@helpers/functions';
|
|
@@ -183,7 +187,7 @@ const formatFiles = async (root: string) => {
|
|
|
183
187
|
// src/organisms/footer/Footer.scss
|
|
184
188
|
filePath = path.join(root, 'src/organisms/footer/Footer.scss');
|
|
185
189
|
|
|
186
|
-
await
|
|
190
|
+
await writeFile(filePath, '');
|
|
187
191
|
|
|
188
192
|
return ['xxx'];
|
|
189
193
|
};
|
package/package.json
CHANGED