buner 1.0.3 → 1.0.4

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 CHANGED
@@ -1,19 +1,19 @@
1
1
  #!/usr/bin/env node
2
2
  import path from "path";
3
3
  import { execSync, spawn } from "child_process";
4
+ import { fileURLToPath } from "url";
4
5
  import { Command } from "commander";
5
6
  import chalk from "chalk";
6
7
  import fetch from "node-fetch";
7
8
  import prompts from "prompts";
8
9
  import fs from "fs";
9
10
  import fs$1 from "fs/promises";
10
- import { fileURLToPath } from "url";
11
11
  import os from "os";
12
12
  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.3";
16
+ const version = "1.0.4";
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";
@@ -139,23 +139,26 @@ const tryGitInit = (root) => {
139
139
  };
140
140
  const excludeFiles = [
141
141
  ".git",
142
+ ".github",
143
+ ".npmrc",
142
144
  "bin",
145
+ "cli",
146
+ "xpack",
143
147
  ".vscode",
144
148
  ".build",
149
+ "node_modules",
150
+ "server.ts",
151
+ "prerender.ts",
152
+ "integration.ts",
153
+ "styles.ts",
154
+ "scripts.ts",
155
+ "states.ts",
156
+ "migrate-scss.ts",
157
+ "vite.config.ts",
158
+ "vite.cli.config.ts",
159
+ "src",
145
160
  "public/samples",
146
- "public/assets/vendors",
147
- "src/_api/!(_base.ts)",
148
- "src/_data",
149
- "src/assets/scripts/!(color-mode|main|mock-api|pl-states|root|theme-critical).entry.ts",
150
- "src/atoms",
151
- "src/mocks/avatar",
152
- "src/mocks/user",
153
- "src/molecules",
154
- "src/organisms/!(root|header|footer)/*",
155
- "src/pages/!(Root|Home).tsx",
156
- "src/templates/!(root|home)/*",
157
- "!cli",
158
- "!vite.cli.config.ts"
161
+ "public/assets/vendors"
159
162
  ];
160
163
  const copy = async (src, dest, { cwd }) => {
161
164
  const sourceFiles = await globby(src, {
@@ -166,9 +169,6 @@ const copy = async (src, dest, { cwd }) => {
166
169
  ignore: excludeFiles
167
170
  });
168
171
  const destRelativeToCwd = path.resolve(dest);
169
- await fs$1.mkdir(path.join(destRelativeToCwd, "src/atoms"), { recursive: true });
170
- await fs$1.mkdir(path.join(destRelativeToCwd, "src/molecules"), { recursive: true });
171
- await fs$1.mkdir(path.join(destRelativeToCwd, "src/mocks/example"), { recursive: true });
172
172
  return Promise.all(
173
173
  sourceFiles.map(async (p) => {
174
174
  const dirname2 = path.dirname(p);
@@ -356,32 +356,35 @@ const installTemplate = async (model) => {
356
356
  cwd: path.join(dirname, "..")
357
357
  });
358
358
  await formatFiles(root);
359
- const packageJson2 = JSON.parse(await fs$1.readFile("package.json", "utf8"));
360
- packageJson2.name = appName;
361
- packageJson2.description = "";
362
- packageJson2.version = "0.1.0";
363
- delete packageJson2.bin;
364
- packageJson2.scripts && Object.keys(packageJson2.scripts).map((scriptName) => {
365
- if (scriptName.startsWith("cli")) {
366
- delete packageJson2.scripts[scriptName];
367
- }
368
- });
369
- packageJson2.dependencies && Object.keys(packageJson2.dependencies).map((dependency) => {
370
- if (!dependency.startsWith("react")) {
371
- delete packageJson2.dependencies[dependency];
359
+ const packageJson$1 = {
360
+ name: appName,
361
+ description: "",
362
+ version: "0.1.0",
363
+ type: "module",
364
+ private: true,
365
+ scripts: {
366
+ start: "buner dev",
367
+ dev: "buner dev",
368
+ serve: "buner serve",
369
+ build: "buner build",
370
+ generate: "buner generate",
371
+ eshn: "buner eshn",
372
+ inte: "buner inte",
373
+ styles: "buner styles",
374
+ prerender: "buner prerender"
375
+ },
376
+ dependencies: {
377
+ buner: `^${packageJson.version}`,
378
+ react: "^19.0.0",
379
+ "react-dom": "^19.0.0",
380
+ "react-router-dom": "^7.0.0"
372
381
  }
373
- });
374
- const devDeps = Object.keys(packageJson2.devDependencies).length;
375
- if (!devDeps) delete packageJson2.devDependencies;
376
- await fs$1.writeFile(path.join(root, "package.json"), JSON.stringify(packageJson2, null, 2) + os.EOL);
382
+ };
383
+ await fs$1.writeFile(path.join(root, "package.json"), JSON.stringify(packageJson$1, null, 2) + os.EOL);
377
384
  console.log("\nInstalling dependencies:");
378
- for (const dependency in packageJson2.dependencies) {
385
+ for (const dependency in packageJson$1.dependencies) {
379
386
  console.log(`- ${cyan$1(dependency)}`);
380
387
  }
381
- if (devDeps) {
382
- console.log("\nInstalling devDependencies:");
383
- for (const dependency in packageJson2.devDependencies) console.log(`- ${cyan$1(dependency)}`);
384
- }
385
388
  await install();
386
389
  };
387
390
  const { green: green$1 } = chalk;
@@ -427,6 +430,8 @@ function validateNpmName(name2) {
427
430
  }
428
431
  const { green, yellow, bold, cyan, red } = chalk;
429
432
  const packageName = "buner";
433
+ const packageDir = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "..");
434
+ const pkg = (file) => path.join(packageDir, file);
430
435
  const run = (cmd, args = [], options = {}) => {
431
436
  return new Promise((resolve, reject) => {
432
437
  const child = spawn(cmd, args, {
@@ -513,52 +518,52 @@ program.command("dev").description("Start development mode with all watchers").a
513
518
  await run("npx", [
514
519
  "concurrently",
515
520
  "--kill-others",
516
- '"bun styles.ts --watch"',
517
- '"bun states.ts --watch"',
518
- '"cross-env scriptOnly=true npx vite build --mode development --watch"',
519
- '"bun server.ts --mode development"'
521
+ `"bun ${pkg("styles.ts")} --watch"`,
522
+ `"bun ${pkg("states.ts")} --watch"`,
523
+ `"cross-env scriptOnly=true npx vite build --config ${pkg("vite.config.ts")} --mode development --watch"`,
524
+ `"bun ${pkg("server.ts")} --mode development"`
520
525
  ]);
521
526
  });
522
527
  program.command("serve").description("Start the SSR dev server").option("--mode <mode>", "server mode", "development").action(async (opts) => {
523
- await run("bun", ["server.ts", "--mode", opts.mode]);
528
+ await run("bun", [pkg("server.ts"), "--mode", opts.mode]);
524
529
  });
525
530
  program.command("build").description("Build the project (static + SSR)").action(async () => {
526
- runSync("npx vite build --outDir dist/static");
527
- runSync("npx vite build --ssr src/entry-server.tsx --outDir dist/server");
531
+ runSync(`npx vite build --config ${pkg("vite.config.ts")} --outDir dist/static`);
532
+ runSync(`npx vite build --config ${pkg("vite.config.ts")} --ssr src/entry-server.tsx --outDir dist/server`);
528
533
  });
529
534
  program.command("generate").description("Full static site generation (states + styles + build + prerender)").option("--mode <mode>", "build mode", "production").action(async (opts) => {
530
- runSync("bun states.ts");
531
- runSync("bun styles.ts");
535
+ runSync(`bun ${pkg("states.ts")}`);
536
+ runSync(`bun ${pkg("styles.ts")}`);
532
537
  if (opts.mode === "production") {
533
- runSync("npx vite build --outDir dist/static");
534
- runSync("npx vite build --ssr src/entry-server.tsx --outDir dist/server");
538
+ runSync(`npx vite build --config ${pkg("vite.config.ts")} --outDir dist/static`);
539
+ runSync(`npx vite build --config ${pkg("vite.config.ts")} --ssr src/entry-server.tsx --outDir dist/server`);
535
540
  } else {
536
- runSync(`npx vite build --outDir dist/static --mode ${opts.mode}`);
537
- runSync(`npx vite build --ssr src/entry-server.tsx --outDir dist/server --mode ${opts.mode}`);
541
+ runSync(`npx vite build --config ${pkg("vite.config.ts")} --outDir dist/static --mode ${opts.mode}`);
542
+ runSync(`npx vite build --config ${pkg("vite.config.ts")} --ssr src/entry-server.tsx --outDir dist/server --mode ${opts.mode}`);
538
543
  }
539
- runSync(`bun prerender.ts --add-hash --mode ${opts.mode}`);
544
+ runSync(`bun ${pkg("prerender.ts")} --add-hash --mode ${opts.mode}`);
540
545
  });
541
546
  program.command("eshn").description("Generate with --mode eshn").action(async () => {
542
- runSync("bun states.ts");
543
- runSync("bun styles.ts");
544
- runSync("npx vite build --outDir dist/static --mode eshn");
545
- runSync("npx vite build --ssr src/entry-server.tsx --outDir dist/server --mode eshn");
546
- runSync("bun prerender.ts --add-hash --mode eshn");
547
+ runSync(`bun ${pkg("states.ts")}`);
548
+ runSync(`bun ${pkg("styles.ts")}`);
549
+ runSync(`npx vite build --config ${pkg("vite.config.ts")} --outDir dist/static --mode eshn`);
550
+ runSync(`npx vite build --config ${pkg("vite.config.ts")} --ssr src/entry-server.tsx --outDir dist/server --mode eshn`);
551
+ runSync(`bun ${pkg("prerender.ts")} --add-hash --mode eshn`);
547
552
  });
548
553
  program.command("inte").description("Build and integrate with backend (styles + build + prerender + integration)").action(async () => {
549
- runSync("bun styles.ts");
550
- runSync("npx vite build --outDir dist/static");
551
- runSync("npx vite build --ssr src/entry-server.tsx --outDir dist/server");
552
- runSync("bun prerender.ts");
553
- runSync("bun integration.ts");
554
+ runSync(`bun ${pkg("styles.ts")}`);
555
+ runSync(`npx vite build --config ${pkg("vite.config.ts")} --outDir dist/static`);
556
+ runSync(`npx vite build --config ${pkg("vite.config.ts")} --ssr src/entry-server.tsx --outDir dist/server`);
557
+ runSync(`bun ${pkg("prerender.ts")}`);
558
+ runSync(`bun ${pkg("integration.ts")}`);
554
559
  });
555
560
  program.command("styles").description("Compile SCSS").option("--watch", "Watch for changes").action(async (opts) => {
556
- const args = ["styles.ts"];
561
+ const args = [pkg("styles.ts")];
557
562
  if (opts.watch) args.push("--watch");
558
563
  await run("bun", args);
559
564
  });
560
565
  program.command("prerender").description("Pre-render HTML files").option("--add-hash", "Add content hashes to asset URLs").option("--mode <mode>", "build mode", "production").action(async (opts) => {
561
- const args = ["prerender.ts"];
566
+ const args = [pkg("prerender.ts")];
562
567
  if (opts.addHash) args.push("--add-hash");
563
568
  args.push("--mode", opts.mode);
564
569
  await run("bun", args);
package/cli/buner.ts CHANGED
@@ -2,6 +2,7 @@
2
2
 
3
3
  import path from 'path';
4
4
  import { execSync, spawn, SpawnOptions } from 'child_process';
5
+ import { fileURLToPath } from 'url';
5
6
 
6
7
  import { Command } from 'commander';
7
8
  import chalk from 'chalk';
@@ -16,6 +17,12 @@ import { validateNpmName } from './helpers/validate-pkg.js';
16
17
  const { green, yellow, bold, cyan, red } = chalk;
17
18
  const packageName = 'buner';
18
19
 
20
+ // Package's own directory (where server.ts, styles.ts, etc. live)
21
+ const packageDir = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..');
22
+
23
+ /** Resolve a file path relative to the buner package directory */
24
+ const pkg = (file: string) => path.join(packageDir, file);
25
+
19
26
  const run = (cmd: string, args: string[] = [], options: SpawnOptions = {}) => {
20
27
  return new Promise<void>((resolve, reject) => {
21
28
  const child = spawn(cmd, args, {
@@ -132,10 +139,10 @@ program
132
139
  await run('npx', [
133
140
  'concurrently',
134
141
  '--kill-others',
135
- '"bun styles.ts --watch"',
136
- '"bun states.ts --watch"',
137
- '"cross-env scriptOnly=true npx vite build --mode development --watch"',
138
- '"bun server.ts --mode development"',
142
+ `"bun ${pkg('styles.ts')} --watch"`,
143
+ `"bun ${pkg('states.ts')} --watch"`,
144
+ `"cross-env scriptOnly=true npx vite build --config ${pkg('vite.config.ts')} --mode development --watch"`,
145
+ `"bun ${pkg('server.ts')} --mode development"`,
139
146
  ]);
140
147
  });
141
148
 
@@ -145,7 +152,7 @@ program
145
152
  .description('Start the SSR dev server')
146
153
  .option('--mode <mode>', 'server mode', 'development')
147
154
  .action(async (opts) => {
148
- await run('bun', ['server.ts', '--mode', opts.mode]);
155
+ await run('bun', [pkg('server.ts'), '--mode', opts.mode]);
149
156
  });
150
157
 
151
158
  // buner build
@@ -153,8 +160,8 @@ program
153
160
  .command('build')
154
161
  .description('Build the project (static + SSR)')
155
162
  .action(async () => {
156
- runSync('npx vite build --outDir dist/static');
157
- runSync('npx vite build --ssr src/entry-server.tsx --outDir dist/server');
163
+ runSync(`npx vite build --config ${pkg('vite.config.ts')} --outDir dist/static`);
164
+ runSync(`npx vite build --config ${pkg('vite.config.ts')} --ssr src/entry-server.tsx --outDir dist/server`);
158
165
  });
159
166
 
160
167
  // buner generate
@@ -163,16 +170,16 @@ program
163
170
  .description('Full static site generation (states + styles + build + prerender)')
164
171
  .option('--mode <mode>', 'build mode', 'production')
165
172
  .action(async (opts) => {
166
- runSync('bun states.ts');
167
- runSync('bun styles.ts');
173
+ runSync(`bun ${pkg('states.ts')}`);
174
+ runSync(`bun ${pkg('styles.ts')}`);
168
175
  if (opts.mode === 'production') {
169
- runSync('npx vite build --outDir dist/static');
170
- runSync('npx vite build --ssr src/entry-server.tsx --outDir dist/server');
176
+ runSync(`npx vite build --config ${pkg('vite.config.ts')} --outDir dist/static`);
177
+ runSync(`npx vite build --config ${pkg('vite.config.ts')} --ssr src/entry-server.tsx --outDir dist/server`);
171
178
  } else {
172
- runSync(`npx vite build --outDir dist/static --mode ${opts.mode}`);
173
- runSync(`npx vite build --ssr src/entry-server.tsx --outDir dist/server --mode ${opts.mode}`);
179
+ runSync(`npx vite build --config ${pkg('vite.config.ts')} --outDir dist/static --mode ${opts.mode}`);
180
+ runSync(`npx vite build --config ${pkg('vite.config.ts')} --ssr src/entry-server.tsx --outDir dist/server --mode ${opts.mode}`);
174
181
  }
175
- runSync(`bun prerender.ts --add-hash --mode ${opts.mode}`);
182
+ runSync(`bun ${pkg('prerender.ts')} --add-hash --mode ${opts.mode}`);
176
183
  });
177
184
 
178
185
  // buner eshn
@@ -180,11 +187,11 @@ program
180
187
  .command('eshn')
181
188
  .description('Generate with --mode eshn')
182
189
  .action(async () => {
183
- runSync('bun states.ts');
184
- runSync('bun styles.ts');
185
- runSync('npx vite build --outDir dist/static --mode eshn');
186
- runSync('npx vite build --ssr src/entry-server.tsx --outDir dist/server --mode eshn');
187
- runSync('bun prerender.ts --add-hash --mode eshn');
190
+ runSync(`bun ${pkg('states.ts')}`);
191
+ runSync(`bun ${pkg('styles.ts')}`);
192
+ runSync(`npx vite build --config ${pkg('vite.config.ts')} --outDir dist/static --mode eshn`);
193
+ runSync(`npx vite build --config ${pkg('vite.config.ts')} --ssr src/entry-server.tsx --outDir dist/server --mode eshn`);
194
+ runSync(`bun ${pkg('prerender.ts')} --add-hash --mode eshn`);
188
195
  });
189
196
 
190
197
  // buner inte
@@ -192,11 +199,11 @@ program
192
199
  .command('inte')
193
200
  .description('Build and integrate with backend (styles + build + prerender + integration)')
194
201
  .action(async () => {
195
- runSync('bun styles.ts');
196
- runSync('npx vite build --outDir dist/static');
197
- runSync('npx vite build --ssr src/entry-server.tsx --outDir dist/server');
198
- runSync('bun prerender.ts');
199
- runSync('bun integration.ts');
202
+ runSync(`bun ${pkg('styles.ts')}`);
203
+ runSync(`npx vite build --config ${pkg('vite.config.ts')} --outDir dist/static`);
204
+ runSync(`npx vite build --config ${pkg('vite.config.ts')} --ssr src/entry-server.tsx --outDir dist/server`);
205
+ runSync(`bun ${pkg('prerender.ts')}`);
206
+ runSync(`bun ${pkg('integration.ts')}`);
200
207
  });
201
208
 
202
209
  // buner styles
@@ -205,7 +212,7 @@ program
205
212
  .description('Compile SCSS')
206
213
  .option('--watch', 'Watch for changes')
207
214
  .action(async (opts) => {
208
- const args = ['styles.ts'];
215
+ const args = [pkg('styles.ts')];
209
216
 
210
217
  if (opts.watch) args.push('--watch');
211
218
  await run('bun', args);
@@ -218,7 +225,7 @@ program
218
225
  .option('--add-hash', 'Add content hashes to asset URLs')
219
226
  .option('--mode <mode>', 'build mode', 'production')
220
227
  .action(async (opts) => {
221
- const args = ['prerender.ts'];
228
+ const args = [pkg('prerender.ts')];
222
229
 
223
230
  if (opts.addHash) args.push('--add-hash');
224
231
  args.push('--mode', opts.mode);
@@ -9,23 +9,26 @@ interface CopyOption {
9
9
 
10
10
  const excludeFiles = [
11
11
  '.git',
12
+ '.github',
13
+ '.npmrc',
12
14
  'bin',
15
+ 'cli',
16
+ 'xpack',
13
17
  '.vscode',
14
18
  '.build',
19
+ 'node_modules',
20
+ 'server.ts',
21
+ 'prerender.ts',
22
+ 'integration.ts',
23
+ 'styles.ts',
24
+ 'scripts.ts',
25
+ 'states.ts',
26
+ 'migrate-scss.ts',
27
+ 'vite.config.ts',
28
+ 'vite.cli.config.ts',
29
+ 'src',
15
30
  'public/samples',
16
31
  'public/assets/vendors',
17
- 'src/_api/!(_base.ts)',
18
- 'src/_data',
19
- 'src/assets/scripts/!(color-mode|main|mock-api|pl-states|root|theme-critical).entry.ts',
20
- 'src/atoms',
21
- 'src/mocks/avatar',
22
- 'src/mocks/user',
23
- 'src/molecules',
24
- 'src/organisms/!(root|header|footer)/*',
25
- 'src/pages/!(Root|Home).tsx',
26
- 'src/templates/!(root|home)/*',
27
- '!cli',
28
- '!vite.cli.config.ts',
29
32
  ];
30
33
 
31
34
  const copy = async (src: string | string[], dest: string, { cwd }: CopyOption) => {
@@ -39,10 +42,6 @@ const copy = async (src: string | string[], dest: string, { cwd }: CopyOption) =
39
42
 
40
43
  const destRelativeToCwd = path.resolve(dest);
41
44
 
42
- await fs.mkdir(path.join(destRelativeToCwd, 'src/atoms'), { recursive: true });
43
- await fs.mkdir(path.join(destRelativeToCwd, 'src/molecules'), { recursive: true });
44
- await fs.mkdir(path.join(destRelativeToCwd, 'src/mocks/example'), { recursive: true });
45
-
46
45
  return Promise.all(
47
46
  sourceFiles.map(async (p) => {
48
47
  const dirname = path.dirname(p);
@@ -9,6 +9,7 @@ import chalk from 'chalk';
9
9
  import { copy } from './helpers/copy.js';
10
10
  import { install } from './helpers/install.js';
11
11
  import { formatFiles } from './helpers/format-files.js';
12
+ import packageJson_ from '../package.json';
12
13
 
13
14
  export const filename = fileURLToPath(import.meta.url);
14
15
  export const dirname = path.dirname(filename);
@@ -32,30 +33,30 @@ const installTemplate = async (model: Props) => {
32
33
 
33
34
  await formatFiles(root);
34
35
 
35
- const packageJson = JSON.parse(await fs.readFile('package.json', 'utf8'));
36
-
37
- packageJson.name = appName;
38
- packageJson.description = '';
39
- packageJson.version = '0.1.0';
40
-
41
- delete packageJson.bin;
42
- packageJson.scripts &&
43
- Object.keys(packageJson.scripts).map((scriptName: string) => {
44
- if (scriptName.startsWith('cli')) {
45
- delete packageJson.scripts[scriptName];
46
- }
47
- });
48
-
49
- packageJson.dependencies &&
50
- Object.keys(packageJson.dependencies).map((dependency) => {
51
- if (!dependency.startsWith('react')) {
52
- delete packageJson.dependencies[dependency];
53
- }
54
- });
55
-
56
- const devDeps = Object.keys(packageJson.devDependencies).length;
57
-
58
- if (!devDeps) delete packageJson.devDependencies;
36
+ const packageJson = {
37
+ name: appName,
38
+ description: '',
39
+ version: '0.1.0',
40
+ type: 'module',
41
+ private: true,
42
+ scripts: {
43
+ start: 'buner dev',
44
+ dev: 'buner dev',
45
+ serve: 'buner serve',
46
+ build: 'buner build',
47
+ generate: 'buner generate',
48
+ eshn: 'buner eshn',
49
+ inte: 'buner inte',
50
+ styles: 'buner styles',
51
+ prerender: 'buner prerender',
52
+ },
53
+ dependencies: {
54
+ buner: `^${packageJson_.version}`,
55
+ react: '^19.0.0',
56
+ 'react-dom': '^19.0.0',
57
+ 'react-router-dom': '^7.0.0',
58
+ },
59
+ };
59
60
 
60
61
  await fs.writeFile(path.join(root, 'package.json'), JSON.stringify(packageJson, null, 2) + os.EOL);
61
62
 
@@ -65,12 +66,6 @@ const installTemplate = async (model: Props) => {
65
66
  console.log(`- ${cyan(dependency)}`);
66
67
  }
67
68
 
68
- if (devDeps) {
69
- console.log('\nInstalling devDependencies:');
70
-
71
- for (const dependency in packageJson.devDependencies) console.log(`- ${cyan(dependency)}`);
72
- }
73
-
74
69
  await install();
75
70
  };
76
71
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "buner",
3
- "version": "1.0.3",
3
+ "version": "1.0.4",
4
4
  "description": "Frontend build toolkit for Vite + React SSR projects — SCSS pipeline, prerender, SSR dev server, and backend integration.",
5
5
  "type": "module",
6
6
  "license": "MIT",