veslx 0.0.24 → 0.0.25

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/lib/build.ts CHANGED
@@ -5,9 +5,27 @@ import fs from 'fs'
5
5
  import importConfig from "./import-config";
6
6
  import veslxPlugin from '../../plugin/src/plugin'
7
7
 
8
+ /**
9
+ * Recursively copy a directory
10
+ */
11
+ function copyDirSync(src: string, dest: string) {
12
+ fs.mkdirSync(dest, { recursive: true })
13
+ const entries = fs.readdirSync(src, { withFileTypes: true })
14
+
15
+ for (const entry of entries) {
16
+ const srcPath = path.join(src, entry.name)
17
+ const destPath = path.join(dest, entry.name)
18
+
19
+ if (entry.isDirectory()) {
20
+ copyDirSync(srcPath, destPath)
21
+ } else {
22
+ fs.copyFileSync(srcPath, destPath)
23
+ }
24
+ }
25
+ }
26
+
8
27
  export default async function buildApp() {
9
- // Normalize paths to resolve symlinks (e.g., /tmp -> /private/tmp on macOS)
10
- const cwd = fs.realpathSync(process.cwd())
28
+ const cwd = process.cwd()
11
29
 
12
30
  console.log(`Building veslx app in ${cwd}`);
13
31
 
@@ -18,9 +36,12 @@ export default async function buildApp() {
18
36
  return
19
37
  }
20
38
 
21
- const veslxRoot = fs.realpathSync(new URL('../..', import.meta.url).pathname);
22
- const configFile = fs.realpathSync(new URL('../../vite.config.ts', import.meta.url).pathname);
23
- const outDir = path.join(cwd, 'dist')
39
+ const veslxRoot = new URL('../..', import.meta.url).pathname;
40
+ const configFile = new URL('../../vite.config.ts', import.meta.url).pathname;
41
+
42
+ // Build inside veslxRoot first (Vite requires outDir to be within or relative to root)
43
+ const tempOutDir = path.join(veslxRoot, '.veslx-build')
44
+ const finalOutDir = path.join(cwd, 'dist')
24
45
 
25
46
  // Resolve content directory relative to user's cwd (where config lives)
26
47
  const contentDir = path.isAbsolute(config.dir)
@@ -31,7 +52,7 @@ export default async function buildApp() {
31
52
  root: veslxRoot,
32
53
  configFile,
33
54
  build: {
34
- outDir,
55
+ outDir: tempOutDir,
35
56
  emptyOutDir: true,
36
57
  },
37
58
  plugins: [
@@ -39,5 +60,14 @@ export default async function buildApp() {
39
60
  ],
40
61
  })
41
62
 
42
- console.log(`\nBuild complete: ${outDir}`)
63
+ // Copy built files to user's dist directory
64
+ if (fs.existsSync(finalOutDir)) {
65
+ fs.rmSync(finalOutDir, { recursive: true })
66
+ }
67
+ copyDirSync(tempOutDir, finalOutDir)
68
+
69
+ // Clean up temp build directory
70
+ fs.rmSync(tempOutDir, { recursive: true })
71
+
72
+ console.log(`\nBuild complete: ${finalOutDir}`)
43
73
  }
package/bin/lib/serve.ts CHANGED
@@ -3,11 +3,9 @@ import { createServer, preview } from 'vite'
3
3
  import importConfig from "./import-config";
4
4
  import veslxPlugin from '../../plugin/src/plugin'
5
5
  import path from 'path'
6
- import fs from 'fs'
7
6
 
8
7
  export default async function start() {
9
- // Normalize paths to resolve symlinks (e.g., /tmp -> /private/tmp on macOS)
10
- const cwd = fs.realpathSync(process.cwd())
8
+ const cwd = process.cwd()
11
9
 
12
10
  console.log(`Starting veslx server in ${cwd}`);
13
11
 
@@ -18,8 +16,8 @@ export default async function start() {
18
16
  return
19
17
  }
20
18
 
21
- const veslxRoot = fs.realpathSync(new URL('../..', import.meta.url).pathname);
22
- const configFile = fs.realpathSync(new URL('../../vite.config.ts', import.meta.url).pathname);
19
+ const veslxRoot = new URL('../..', import.meta.url).pathname;
20
+ const configFile = new URL('../../vite.config.ts', import.meta.url).pathname;
23
21
 
24
22
  // Resolve content directory relative to user's cwd (where config lives)
25
23
  const contentDir = path.isAbsolute(config.dir)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "veslx",
3
- "version": "0.0.24",
3
+ "version": "0.0.25",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "veslx": "bin/veslx.ts"