buner 1.0.1 → 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 +25 -18
- package/cli/helpers/format-files.ts +25 -17
- 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,30 +214,33 @@ 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
|
-
data =
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
"export const blocks: { [name: string]: any } = {
|
|
219
|
-
|
|
220
|
-
|
|
219
|
+
data = [
|
|
220
|
+
"import { lazy } from 'react';",
|
|
221
|
+
"",
|
|
222
|
+
"export const blocks: { [name: string]: any } = {",
|
|
223
|
+
" root: lazy(() => import('./organisms/root/Root')),",
|
|
224
|
+
"};",
|
|
225
|
+
""
|
|
226
|
+
].join("\n");
|
|
227
|
+
await writeFile(filePath, data);
|
|
221
228
|
filePath = path.join(root, "src/_types/atoms.d.ts");
|
|
222
|
-
await
|
|
229
|
+
await writeFile(
|
|
223
230
|
filePath,
|
|
224
231
|
`
|
|
225
232
|
import { BasedAtomicModel } from "./_general";
|
|
226
233
|
`
|
|
227
234
|
);
|
|
228
235
|
filePath = path.join(root, "src/_types/molecules.d.ts");
|
|
229
|
-
await
|
|
236
|
+
await writeFile(
|
|
230
237
|
filePath,
|
|
231
238
|
`
|
|
232
239
|
import { BasedAtomicModel } from "./_general";
|
|
233
240
|
`
|
|
234
241
|
);
|
|
235
242
|
filePath = path.join(root, "src/_types/organisms.d.ts");
|
|
236
|
-
await
|
|
243
|
+
await writeFile(
|
|
237
244
|
filePath,
|
|
238
245
|
`
|
|
239
246
|
import { BasedAtomicModel } from "./_general";
|
|
@@ -244,7 +251,7 @@ const formatFiles = async (root) => {
|
|
|
244
251
|
`
|
|
245
252
|
);
|
|
246
253
|
filePath = path.join(root, "src/pages/Home.tsx");
|
|
247
|
-
await
|
|
254
|
+
await writeFile(
|
|
248
255
|
filePath,
|
|
249
256
|
`
|
|
250
257
|
import Template from '@templates/home/Home';
|
|
@@ -257,7 +264,7 @@ const formatFiles = async (root) => {
|
|
|
257
264
|
`
|
|
258
265
|
);
|
|
259
266
|
filePath = path.join(root, "src/templates/home/Home.tsx");
|
|
260
|
-
await
|
|
267
|
+
await writeFile(
|
|
261
268
|
filePath,
|
|
262
269
|
`
|
|
263
270
|
import { FooterModel, HeaderModel } from '@_types/organisms';
|
|
@@ -289,7 +296,7 @@ const formatFiles = async (root) => {
|
|
|
289
296
|
`
|
|
290
297
|
);
|
|
291
298
|
filePath = path.join(root, "src/organisms/header/Header.tsx");
|
|
292
|
-
await
|
|
299
|
+
await writeFile(
|
|
293
300
|
filePath,
|
|
294
301
|
`
|
|
295
302
|
import { getModifiers } from '@helpers/functions';
|
|
@@ -311,9 +318,9 @@ const formatFiles = async (root) => {
|
|
|
311
318
|
`
|
|
312
319
|
);
|
|
313
320
|
filePath = path.join(root, "src/organisms/header/Header.scss");
|
|
314
|
-
await
|
|
321
|
+
await writeFile(filePath, "");
|
|
315
322
|
filePath = path.join(root, "src/organisms/footer/Footer.tsx");
|
|
316
|
-
await
|
|
323
|
+
await writeFile(
|
|
317
324
|
filePath,
|
|
318
325
|
`
|
|
319
326
|
import { getModifiers } from '@helpers/functions';
|
|
@@ -335,7 +342,7 @@ const formatFiles = async (root) => {
|
|
|
335
342
|
`
|
|
336
343
|
);
|
|
337
344
|
filePath = path.join(root, "src/organisms/footer/Footer.scss");
|
|
338
|
-
await
|
|
345
|
+
await writeFile(filePath, "");
|
|
339
346
|
return ["xxx"];
|
|
340
347
|
};
|
|
341
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,22 +29,25 @@ 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
|
-
data =
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
+
data = [
|
|
37
|
+
"import { lazy } from 'react';",
|
|
38
|
+
'',
|
|
39
|
+
'export const blocks: { [name: string]: any } = {',
|
|
40
|
+
"\troot: lazy(() => import('./organisms/root/Root')),",
|
|
41
|
+
'};',
|
|
42
|
+
'',
|
|
43
|
+
].join('\n');
|
|
36
44
|
|
|
37
|
-
await
|
|
45
|
+
await writeFile(filePath, data);
|
|
38
46
|
|
|
39
47
|
// src/_types/atoms.d.ts
|
|
40
48
|
filePath = path.join(root, 'src/_types/atoms.d.ts');
|
|
41
49
|
|
|
42
|
-
await
|
|
50
|
+
await writeFile(
|
|
43
51
|
filePath,
|
|
44
52
|
`
|
|
45
53
|
import { BasedAtomicModel } from "./_general";
|
|
@@ -49,7 +57,7 @@ const formatFiles = async (root: string) => {
|
|
|
49
57
|
// src/_types/molecules.d.d.ts
|
|
50
58
|
filePath = path.join(root, 'src/_types/molecules.d.ts');
|
|
51
59
|
|
|
52
|
-
await
|
|
60
|
+
await writeFile(
|
|
53
61
|
filePath,
|
|
54
62
|
`
|
|
55
63
|
import { BasedAtomicModel } from "./_general";
|
|
@@ -59,7 +67,7 @@ const formatFiles = async (root: string) => {
|
|
|
59
67
|
// src/_types/organisms.d.ts
|
|
60
68
|
filePath = path.join(root, 'src/_types/organisms.d.ts');
|
|
61
69
|
|
|
62
|
-
await
|
|
70
|
+
await writeFile(
|
|
63
71
|
filePath,
|
|
64
72
|
`
|
|
65
73
|
import { BasedAtomicModel } from "./_general";
|
|
@@ -73,7 +81,7 @@ const formatFiles = async (root: string) => {
|
|
|
73
81
|
// pages/Home.tsx
|
|
74
82
|
filePath = path.join(root, 'src/pages/Home.tsx');
|
|
75
83
|
|
|
76
|
-
await
|
|
84
|
+
await writeFile(
|
|
77
85
|
filePath,
|
|
78
86
|
`
|
|
79
87
|
import Template from '@templates/home/Home';
|
|
@@ -89,7 +97,7 @@ const formatFiles = async (root: string) => {
|
|
|
89
97
|
// templates/home/Home.tsx
|
|
90
98
|
filePath = path.join(root, 'src/templates/home/Home.tsx');
|
|
91
99
|
|
|
92
|
-
await
|
|
100
|
+
await writeFile(
|
|
93
101
|
filePath,
|
|
94
102
|
`
|
|
95
103
|
import { FooterModel, HeaderModel } from '@_types/organisms';
|
|
@@ -124,7 +132,7 @@ const formatFiles = async (root: string) => {
|
|
|
124
132
|
// src/organisms/header/Header.tsx
|
|
125
133
|
filePath = path.join(root, 'src/organisms/header/Header.tsx');
|
|
126
134
|
|
|
127
|
-
await
|
|
135
|
+
await writeFile(
|
|
128
136
|
filePath,
|
|
129
137
|
`
|
|
130
138
|
import { getModifiers } from '@helpers/functions';
|
|
@@ -149,12 +157,12 @@ const formatFiles = async (root: string) => {
|
|
|
149
157
|
// src/organisms/header/Header.scss
|
|
150
158
|
filePath = path.join(root, 'src/organisms/header/Header.scss');
|
|
151
159
|
|
|
152
|
-
await
|
|
160
|
+
await writeFile(filePath, '');
|
|
153
161
|
|
|
154
162
|
// src/organisms/footer/Footer.tsx
|
|
155
163
|
filePath = path.join(root, 'src/organisms/footer/Footer.tsx');
|
|
156
164
|
|
|
157
|
-
await
|
|
165
|
+
await writeFile(
|
|
158
166
|
filePath,
|
|
159
167
|
`
|
|
160
168
|
import { getModifiers } from '@helpers/functions';
|
|
@@ -179,7 +187,7 @@ const formatFiles = async (root: string) => {
|
|
|
179
187
|
// src/organisms/footer/Footer.scss
|
|
180
188
|
filePath = path.join(root, 'src/organisms/footer/Footer.scss');
|
|
181
189
|
|
|
182
|
-
await
|
|
190
|
+
await writeFile(filePath, '');
|
|
183
191
|
|
|
184
192
|
return ['xxx'];
|
|
185
193
|
};
|
package/package.json
CHANGED