rollerwheel 0.0.5 → 0.0.7

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/README.md CHANGED
File without changes
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "rollerwheel",
3
- "version": "0.0.4",
3
+ "version": "0.0.6",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "rollerwheel",
9
- "version": "0.0.4",
9
+ "version": "0.0.6",
10
10
  "license": "MIT",
11
11
  "dependencies": {
12
12
  "@babel/core": "^7.26.7",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rollerwheel",
3
- "version": "0.0.5",
3
+ "version": "0.0.7",
4
4
  "description": "CLI tool for bundling client.js with Rollup",
5
5
  "main": "roller.js",
6
6
  "bin": {
package/roller.js CHANGED
@@ -8,16 +8,34 @@ const { nodeResolve } = require('@rollup/plugin-node-resolve')
8
8
  const nodePolyfills = require('rollup-plugin-polyfill-node')
9
9
  const ignore = require('rollup-plugin-ignore')
10
10
  const babel = require('@rollup/plugin-babel').babel
11
- const { existsSync } = require('fs')
12
- const { join, basename } = require('path')
13
- const json = require('@rollup/plugin-json')
11
+ const { existsSync, mkdirSync } = require('fs')
12
+ const { join, basename, resolve, dirname } = require('path')
13
+ const json = require('@rollup/plugin-json')
14
14
 
15
15
  // Parse command line args
16
16
  const args = process.argv.slice(2)
17
17
  const watchMode = args.includes('--watch') || args.includes('-w')
18
18
 
19
- // Get file parameter (first arg that doesn't start with -)
20
- const fileArg = args.find(arg => !arg.startsWith('-'))
19
+ // Get output path from -o or --output
20
+ let outputArg = null
21
+ for (let i = 0; i < args.length; i++) {
22
+ if ((args[i] === '-o' || args[i] === '--output') && args[i + 1]) {
23
+ outputArg = args[i + 1]
24
+ break
25
+ }
26
+ const match = args[i].match(/^(?:-o|--output)=(.+)/)
27
+ if (match) {
28
+ outputArg = match[1]
29
+ break
30
+ }
31
+ }
32
+
33
+ // Get file parameter (first non-flag arg, skipping -o's value)
34
+ const fileArg = args.find((arg, i) => {
35
+ if (arg.startsWith('-')) return false
36
+ if (i > 0 && (args[i - 1] === '-o' || args[i - 1] === '--output')) return false
37
+ return true
38
+ })
21
39
  const inputFileName = fileArg || 'client.js'
22
40
 
23
41
  const main = async () => {
@@ -32,15 +50,25 @@ const main = async () => {
32
50
  }
33
51
 
34
52
  // Determine output filename based on input
35
- // e.g., client.js -> client.bundle.js, admin-client.js -> admin-client.bundle.js
36
53
  const baseName = basename(inputFileName, '.js')
37
54
  const outputFileName = `${baseName}.bundle.js`
38
-
55
+
39
56
  // Determine output path
40
- const staticDir = join(cwd, 'static')
41
- const outputFile = existsSync(staticDir)
42
- ? join(staticDir, outputFileName)
43
- : join(cwd, outputFileName)
57
+ let outputFile
58
+ if (outputArg) {
59
+ const resolved = resolve(cwd, outputArg)
60
+ if (outputArg.endsWith('/') || outputArg.endsWith('\\') || (existsSync(resolved) && require('fs').statSync(resolved).isDirectory())) {
61
+ outputFile = join(resolved, outputFileName)
62
+ } else {
63
+ outputFile = resolved
64
+ }
65
+ mkdirSync(dirname(outputFile), { recursive: true })
66
+ } else {
67
+ const staticDir = join(cwd, 'static')
68
+ outputFile = existsSync(staticDir)
69
+ ? join(staticDir, outputFileName)
70
+ : join(cwd, outputFileName)
71
+ }
44
72
 
45
73
  const config = {
46
74
  input: inputFile,