instaserve 1.1.16 → 1.1.18

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.
Files changed (2) hide show
  1. package/instaserve +22 -0
  2. package/package.json +1 -1
package/instaserve CHANGED
@@ -6,6 +6,13 @@ import path from 'node:path'
6
6
  import { pathToFileURL, fileURLToPath } from 'node:url'
7
7
  import { execSync } from 'node:child_process'
8
8
 
9
+ if (process.argv.includes('-v') || process.argv.includes('--version')) {
10
+ const __dirname = path.dirname(fileURLToPath(import.meta.url))
11
+ const packageJson = JSON.parse(fs.readFileSync(path.join(__dirname, 'package.json'), 'utf-8'))
12
+ console.log(packageJson.version)
13
+ process.exit(0)
14
+ }
15
+
9
16
  console.log(chalk.cyan('\nInstaserve - Instant Web Stack\n'))
10
17
  console.log(chalk.yellow('Usage:'))
11
18
  console.log(chalk.green(' npx instaserve [options]'))
@@ -19,12 +26,15 @@ console.log(chalk.green(' -ip <address>') + ' IP address to bind to (defaul
19
26
  console.log(chalk.green(' -public <path>') + ' Public directory path (default: ./public)')
20
27
  console.log(chalk.green(' -api <file>') + ' Path to routes file (default: ./routes.js)')
21
28
  console.log(chalk.green(' -secure') + ' Enable HTTPS (requires cert.pem and key.pem: run "npx instaserve generate-certs")')
29
+ console.log(chalk.green(' -v') + ' Show version number')
22
30
  console.log(chalk.green(' -help') + ' Show this help message\n')
23
31
 
24
32
  if (process.argv.includes('-help')) {
25
33
  process.exit(0)
26
34
  }
27
35
 
36
+
37
+
28
38
  const args = process.argv.slice(2)
29
39
 
30
40
  // Handle generate-routes command
@@ -101,6 +111,18 @@ if (args[0] === 'generate-routes') {
101
111
  }
102
112
  }
103
113
 
114
+ const sourcePublic = path.join(__dirname, 'public')
115
+
116
+ if (fs.existsSync(sourcePublic)) {
117
+ const destPublic = path.join(process.cwd(), 'public')
118
+ try {
119
+ fs.cpSync(sourcePublic, destPublic, { recursive: true })
120
+ console.log(chalk.green(`✓ Created/Updated public/`))
121
+ } catch (e) {
122
+ console.error(chalk.red(`! Failed to copy public/: ${e.message}`))
123
+ }
124
+ }
125
+
104
126
  process.exit(0)
105
127
  }
106
128
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "instaserve",
3
- "version": "1.1.16",
3
+ "version": "1.1.18",
4
4
  "description": "Instant web stack",
5
5
  "main": "module.mjs",
6
6
  "bin": "./instaserve",