ecopages 0.1.88 → 0.1.89

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 (4) hide show
  1. package/README.md +49 -11
  2. package/bin/cli.js +72 -22
  3. package/index.js +1 -1
  4. package/package.json +107 -107
package/README.md CHANGED
@@ -1,6 +1,5 @@
1
1
  # ecopages
2
2
 
3
- > [!CAUTION]
4
3
  > **DRAFT / EXPERIMENTAL**
5
4
  > This package is currently in a draft state and is subject to significant changes. Use with caution in production environments.
6
5
 
@@ -15,8 +14,8 @@ Instead of managing multiple `@ecopages` dependencies, you can simply use the `e
15
14
  You can import from specific Ecopages modules directly through the meta-package:
16
15
 
17
16
  ```typescript
18
- import { EcoPage } from 'ecopages/core';
19
- import { KitaJSIntegration } from 'ecopages/kitajs';
17
+ import { eco } from 'ecopages/core';
18
+ import { kitajsPlugin } from 'ecopages/kitajs';
20
19
  ```
21
20
 
22
21
  ## CLI Utilities
@@ -25,14 +24,37 @@ The `ecopages` package includes a CLI to simplify common Bun commands. It automa
25
24
 
26
25
  ### Commands
27
26
 
28
- | Command | Description | Bun Equivalent |
29
- | :------------------- | :--------------------------- | :----------------------------- |
30
- | `ecopages dev` | Start the development server | `bun run app.ts --dev` |
31
- | `ecopages dev:watch` | Start with watch mode | `bun --watch run app.ts --dev` |
32
- | `ecopages dev:hot` | Start with hot reload | `bun --hot run app.ts --dev` |
33
- | `ecopages build` | Build for production | `bun run app.ts --build` |
34
- | `ecopages start` | Start production server | `bun run app.ts` |
35
- | `ecopages preview` | Preview production build | `bun run app.ts --preview` |
27
+ | Command | Description | Bun Equivalent |
28
+ | :--------------------------- | :----------------------------------------------- | :------------------------------ |
29
+ | `ecopages dev [entry]` | Start the development server | `bun run [entry] --dev` |
30
+ | `ecopages dev:watch [entry]` | Start with watch mode (restarts on file changes) | `bun --watch run [entry] --dev` |
31
+ | `ecopages dev:hot [entry]` | Start with hot reload (HMR without restart) | `bun --hot run [entry] --dev` |
32
+ | `ecopages build [entry]` | Build for production | `bun run [entry] --build` |
33
+ | `ecopages start [entry]` | Start production server | `bun run [entry]` |
34
+ | `ecopages preview [entry]` | Preview production build | `bun run [entry] --preview` |
35
+
36
+ > **Note:** `[entry]` defaults to `app.ts` if not provided.
37
+
38
+ ### Environment Overrides
39
+
40
+ All server commands (`dev`, `dev:watch`, `dev:hot`, `start`, `preview`) support the following options:
41
+
42
+ | Option | Environment Variable | Description |
43
+ | :---------------------- | :---------------------- | :------------------------- |
44
+ | `-p, --port <port>` | `ECOPAGES_PORT` | Server port (default 3000) |
45
+ | `-n, --hostname <host>` | `ECOPAGES_HOSTNAME` | Server hostname |
46
+ | `-b, --base-url <url>` | `ECOPAGES_BASE_URL` | Base URL for the app |
47
+ | `-d, --debug` | `ECOPAGES_LOGGER_DEBUG` | Enable debug logging |
48
+
49
+ **Example:**
50
+
51
+ ```bash
52
+ # Start dev server on port 8080 with debug logging
53
+ ecopages dev --port 8080 --debug
54
+
55
+ # Start production server with custom hostname
56
+ ecopages start --hostname 0.0.0.0 --port 3001
57
+ ```
36
58
 
37
59
  ## JSR Packages
38
60
 
@@ -62,6 +84,22 @@ Explore all packages at [jsr.io/@ecopages](https://jsr.io/@ecopages).
62
84
  bun add ecopages
63
85
  ```
64
86
 
87
+ ## Configuration
88
+
89
+ To use Ecopages packages, which are published on JSR, you need to configure your package manager to resolve the `@jsr` scope.
90
+
91
+ ### npm / pnpm / Yarn
92
+
93
+ Create a `.npmrc` file in the root of your project with the following content:
94
+
95
+ ```ini
96
+ @jsr:registry=https://npm.jsr.io
97
+ ```
98
+
99
+ ### Bun
100
+
101
+ Bun supports JSR natively, but if you are using the `npm:` aliasing strategy (as recommended for compatibility), having the `.npmrc` file ensures consistent behavior.
102
+
65
103
  ## License
66
104
 
67
105
  MIT
package/bin/cli.js CHANGED
@@ -2,18 +2,38 @@
2
2
  import { Command } from 'commander';
3
3
  import { existsSync, readFileSync } from 'node:fs';
4
4
  import { spawn } from 'node:child_process';
5
+ import { Logger } from '@ecopages/logger';
6
+
7
+ const logger = new Logger('[ecopages:cli]');
5
8
 
6
9
  const program = new Command();
7
10
  const pkg = JSON.parse(readFileSync(new URL('../package.json', import.meta.url), 'utf-8'));
8
11
 
9
12
  program.name('ecopages').description('Ecopages CLI utilities').version(pkg.version);
10
13
 
11
- function runBunCommand(args, options = {}) {
12
- const hasConfig = existsSync('eco.config.ts');
13
- const hasApp = existsSync('app.ts');
14
+ /**
15
+ * Build environment variables from CLI options
16
+ */
17
+ function buildEnvOverrides(options) {
18
+ const env = {};
19
+ if (options.port) env.ECOPAGES_PORT = String(options.port);
20
+ if (options.hostname) env.ECOPAGES_HOSTNAME = options.hostname;
21
+ if (options.baseUrl) env.ECOPAGES_BASE_URL = options.baseUrl;
22
+ if (options.debug) env.ECOPAGES_LOGGER_DEBUG = 'true';
23
+ return env;
24
+ }
14
25
 
15
- if (!hasApp) {
16
- console.error('❌ Error: app.ts not found in the current directory.');
26
+ /**
27
+ * Execute a bun command with the given arguments and options.
28
+ * Automatically detects eco.config.ts and applies preloads.
29
+ * @param {string[]} args - Arguments to pass to the entry file
30
+ * @param {object} options - CLI options (watch, hot, port, hostname, etc.)
31
+ * @param {string} entryFile - Entry file to run
32
+ */
33
+ function runBunCommand(args, options = {}, entryFile = 'app.ts') {
34
+ const hasConfig = existsSync('eco.config.ts');
35
+ if (!existsSync(entryFile)) {
36
+ logger.error(`Error: Entry file "${entryFile}" not found in the current directory.`);
17
37
  process.exit(1);
18
38
  }
19
39
 
@@ -26,56 +46,86 @@ function runBunCommand(args, options = {}) {
26
46
  if (hasConfig) {
27
47
  bunArgs.push('--preload', 'eco.config.ts');
28
48
  }
29
- bunArgs.push('app.ts', ...args);
49
+ bunArgs.push(entryFile, ...args);
30
50
 
31
- console.log(`🚀 Running: bun ${bunArgs.join(' ')}`);
51
+ /** Merge CLI overrides with current environment */
52
+ const envOverrides = buildEnvOverrides(options);
53
+ const env = { ...process.env, ...envOverrides };
32
54
 
33
- const child = spawn('bun', bunArgs, { stdio: 'inherit' });
55
+ if (Object.keys(envOverrides).length > 0) {
56
+ logger.info(`Environment overrides: ${JSON.stringify(envOverrides)}`);
57
+ }
58
+ logger.info(`Running: bun ${bunArgs.join(' ')}`);
59
+
60
+ const child = spawn('bun', bunArgs, { stdio: 'inherit', env });
34
61
  child.on('exit', (code) => {
35
62
  process.exit(code || 0);
36
63
  });
37
64
  }
38
65
 
66
+ /**
67
+ * Add shared server options to a command.
68
+ * @param {import('commander').Command} cmd - The command to add options to
69
+ * @returns {import('commander').Command} The command with options added
70
+ */
71
+ const serverOptions = (cmd) =>
72
+ cmd
73
+ .option('-p, --port <port>', 'Override ECOPAGES_PORT')
74
+ .option('-n, --hostname <hostname>', 'Override ECOPAGES_HOSTNAME')
75
+ .option('-b, --base-url <url>', 'Override ECOPAGES_BASE_URL')
76
+ .option('-d, --debug', 'Enable debug logging (ECOPAGES_LOGGER_DEBUG=true)');
77
+
39
78
  program
40
79
  .command('dev')
41
80
  .description('Start the development server')
42
- .action(() => {
43
- runBunCommand(['--dev']);
81
+ .argument('[entry]', 'Entry file', 'app.ts')
82
+ .tap(serverOptions)
83
+ .action((entry, opts) => {
84
+ runBunCommand(['--dev'], opts, entry);
44
85
  });
45
86
 
46
87
  program
47
88
  .command('dev:watch')
48
- .description('Start the development server with watch mode')
49
- .action(() => {
50
- runBunCommand(['--dev'], { watch: true });
89
+ .description('Start the development server with watch mode (restarts on file changes)')
90
+ .argument('[entry]', 'Entry file', 'app.ts')
91
+ .tap(serverOptions)
92
+ .action((entry, opts) => {
93
+ runBunCommand(['--dev'], { ...opts, watch: true }, entry);
51
94
  });
52
95
 
53
96
  program
54
97
  .command('dev:hot')
55
- .description('Start the development server with hot reload')
56
- .action(() => {
57
- runBunCommand(['--dev'], { hot: true });
98
+ .description('Start the development server with hot reload (HMR without restart)')
99
+ .argument('[entry]', 'Entry file', 'app.ts')
100
+ .tap(serverOptions)
101
+ .action((entry, opts) => {
102
+ runBunCommand(['--dev'], { ...opts, hot: true }, entry);
58
103
  });
59
104
 
60
105
  program
61
106
  .command('build')
62
107
  .description('Build the project for production')
63
- .action(() => {
64
- runBunCommand(['--build']);
108
+ .argument('[entry]', 'Entry file', 'app.ts')
109
+ .action((entry) => {
110
+ runBunCommand(['--build'], {}, entry);
65
111
  });
66
112
 
67
113
  program
68
114
  .command('start')
69
115
  .description('Start the production server')
70
- .action(() => {
71
- runBunCommand([]);
116
+ .argument('[entry]', 'Entry file', 'app.ts')
117
+ .tap(serverOptions)
118
+ .action((entry, opts) => {
119
+ runBunCommand([], opts, entry);
72
120
  });
73
121
 
74
122
  program
75
123
  .command('preview')
76
124
  .description('Preview the production build')
77
- .action(() => {
78
- runBunCommand(['--preview']);
125
+ .argument('[entry]', 'Entry file', 'app.ts')
126
+ .tap(serverOptions)
127
+ .action((entry, opts) => {
128
+ runBunCommand(['--preview'], opts, entry);
79
129
  });
80
130
 
81
131
  program.parse();
package/index.js CHANGED
@@ -1 +1 @@
1
- export const version = "0.1.88";
1
+ export const version = "0.1.89";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ecopages",
3
- "version": "0.1.88",
3
+ "version": "0.1.89",
4
4
  "description": "Universal entry point for Ecopages",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -8,7 +8,7 @@
8
8
  "repository": {
9
9
  "type": "git",
10
10
  "url": "git+https://github.com/ecopages/ecopages.git",
11
- "directory": "packages/ecopages"
11
+ "directory": "npm/ecopages"
12
12
  },
13
13
  "homepage": "https://github.com/ecopages/ecopages#readme",
14
14
  "bugs": {
@@ -35,37 +35,13 @@
35
35
  "import": "./index.js",
36
36
  "types": "./index.d.ts"
37
37
  },
38
- "./react-router": {
39
- "import": "./react-router/index.js",
40
- "types": "./react-router/index.d.ts"
41
- },
42
- "./react-router/browser": {
43
- "import": "./react-router/browser/index.js",
44
- "types": "./react-router/browser/index.d.ts"
45
- },
46
- "./react-router/styles.css": {
47
- "import": "./react-router/styles.css/index.js",
48
- "types": "./react-router/styles.css/index.d.ts"
49
- },
50
- "./bun-mdx-kitajs-loader": {
51
- "import": "./bun-mdx-kitajs-loader/index.js",
52
- "types": "./bun-mdx-kitajs-loader/index.d.ts"
53
- },
54
38
  "./bun-postcss-loader": {
55
39
  "import": "./bun-postcss-loader/index.js",
56
40
  "types": "./bun-postcss-loader/index.d.ts"
57
41
  },
58
- "./file-system": {
59
- "import": "./file-system/index.js",
60
- "types": "./file-system/index.d.ts"
61
- },
62
- "./file-system/bun": {
63
- "import": "./file-system/bun/index.js",
64
- "types": "./file-system/bun/index.d.ts"
65
- },
66
- "./file-system/node": {
67
- "import": "./file-system/node/index.js",
68
- "types": "./file-system/node/index.d.ts"
42
+ "./bun-mdx-kitajs-loader": {
43
+ "import": "./bun-mdx-kitajs-loader/index.js",
44
+ "types": "./bun-mdx-kitajs-loader/index.d.ts"
69
45
  },
70
46
  "./browser-router": {
71
47
  "import": "./browser-router/index.js",
@@ -79,45 +55,21 @@
79
55
  "import": "./browser-router/src/styles.css/index.js",
80
56
  "types": "./browser-router/src/styles.css/index.d.ts"
81
57
  },
82
- "./image-processor": {
83
- "import": "./image-processor/index.js",
84
- "types": "./image-processor/index.d.ts"
85
- },
86
- "./image-processor/types": {
87
- "import": "./image-processor/types/index.js",
88
- "types": "./image-processor/types/index.d.ts"
89
- },
90
- "./image-processor/component/html": {
91
- "import": "./image-processor/component/html/index.js",
92
- "types": "./image-processor/component/html/index.d.ts"
93
- },
94
- "./image-processor/component/react": {
95
- "import": "./image-processor/component/react/index.js",
96
- "types": "./image-processor/component/react/index.d.ts"
97
- },
98
- "./postcss-processor": {
99
- "import": "./postcss-processor/index.js",
100
- "types": "./postcss-processor/index.d.ts"
101
- },
102
- "./postcss-processor/postcss-processor": {
103
- "import": "./postcss-processor/postcss-processor/index.js",
104
- "types": "./postcss-processor/postcss-processor/index.d.ts"
105
- },
106
- "./postcss-processor/plugin": {
107
- "import": "./postcss-processor/plugin/index.js",
108
- "types": "./postcss-processor/plugin/index.d.ts"
58
+ "./mdx": {
59
+ "import": "./mdx/index.js",
60
+ "types": "./mdx/index.d.ts"
109
61
  },
110
- "./postcss-processor/presets": {
111
- "import": "./postcss-processor/presets/index.js",
112
- "types": "./postcss-processor/presets/index.d.ts"
62
+ "./kitajs": {
63
+ "import": "./kitajs/index.js",
64
+ "types": "./kitajs/index.d.ts"
113
65
  },
114
- "./postcss-processor/presets/tailwind-v3": {
115
- "import": "./postcss-processor/presets/tailwind-v3/index.js",
116
- "types": "./postcss-processor/presets/tailwind-v3/index.d.ts"
66
+ "./lit": {
67
+ "import": "./lit/index.js",
68
+ "types": "./lit/index.d.ts"
117
69
  },
118
- "./postcss-processor/presets/tailwind-v4": {
119
- "import": "./postcss-processor/presets/tailwind-v4/index.js",
120
- "types": "./postcss-processor/presets/tailwind-v4/index.d.ts"
70
+ "./lit/styled-mixin": {
71
+ "import": "./lit/styled-mixin/index.js",
72
+ "types": "./lit/styled-mixin/index.d.ts"
121
73
  },
122
74
  "./react": {
123
75
  "import": "./react/index.js",
@@ -143,26 +95,6 @@
143
95
  "import": "./react/router-adapter/index.js",
144
96
  "types": "./react/router-adapter/index.d.ts"
145
97
  },
146
- "./lit": {
147
- "import": "./lit/index.js",
148
- "types": "./lit/index.d.ts"
149
- },
150
- "./lit/styled-mixin": {
151
- "import": "./lit/styled-mixin/index.js",
152
- "types": "./lit/styled-mixin/index.d.ts"
153
- },
154
- "./kitajs": {
155
- "import": "./kitajs/index.js",
156
- "types": "./kitajs/index.d.ts"
157
- },
158
- "./mdx": {
159
- "import": "./mdx/index.js",
160
- "types": "./mdx/index.d.ts"
161
- },
162
- "./bun-inline-css-plugin": {
163
- "import": "./bun-inline-css-plugin/index.js",
164
- "types": "./bun-inline-css-plugin/index.d.ts"
165
- },
166
98
  "./core": {
167
99
  "import": "./core/index.js",
168
100
  "types": "./core/index.d.ts"
@@ -258,23 +190,91 @@
258
190
  "./core/errors": {
259
191
  "import": "./core/errors/index.js",
260
192
  "types": "./core/errors/index.d.ts"
193
+ },
194
+ "./bun-inline-css-plugin": {
195
+ "import": "./bun-inline-css-plugin/index.js",
196
+ "types": "./bun-inline-css-plugin/index.d.ts"
197
+ },
198
+ "./postcss-processor": {
199
+ "import": "./postcss-processor/index.js",
200
+ "types": "./postcss-processor/index.d.ts"
201
+ },
202
+ "./postcss-processor/postcss-processor": {
203
+ "import": "./postcss-processor/postcss-processor/index.js",
204
+ "types": "./postcss-processor/postcss-processor/index.d.ts"
205
+ },
206
+ "./postcss-processor/plugin": {
207
+ "import": "./postcss-processor/plugin/index.js",
208
+ "types": "./postcss-processor/plugin/index.d.ts"
209
+ },
210
+ "./postcss-processor/presets": {
211
+ "import": "./postcss-processor/presets/index.js",
212
+ "types": "./postcss-processor/presets/index.d.ts"
213
+ },
214
+ "./postcss-processor/presets/tailwind-v3": {
215
+ "import": "./postcss-processor/presets/tailwind-v3/index.js",
216
+ "types": "./postcss-processor/presets/tailwind-v3/index.d.ts"
217
+ },
218
+ "./postcss-processor/presets/tailwind-v4": {
219
+ "import": "./postcss-processor/presets/tailwind-v4/index.js",
220
+ "types": "./postcss-processor/presets/tailwind-v4/index.d.ts"
221
+ },
222
+ "./image-processor": {
223
+ "import": "./image-processor/index.js",
224
+ "types": "./image-processor/index.d.ts"
225
+ },
226
+ "./image-processor/types": {
227
+ "import": "./image-processor/types/index.js",
228
+ "types": "./image-processor/types/index.d.ts"
229
+ },
230
+ "./image-processor/component/html": {
231
+ "import": "./image-processor/component/html/index.js",
232
+ "types": "./image-processor/component/html/index.d.ts"
233
+ },
234
+ "./image-processor/component/react": {
235
+ "import": "./image-processor/component/react/index.js",
236
+ "types": "./image-processor/component/react/index.d.ts"
237
+ },
238
+ "./file-system": {
239
+ "import": "./file-system/index.js",
240
+ "types": "./file-system/index.d.ts"
241
+ },
242
+ "./file-system/bun": {
243
+ "import": "./file-system/bun/index.js",
244
+ "types": "./file-system/bun/index.d.ts"
245
+ },
246
+ "./file-system/node": {
247
+ "import": "./file-system/node/index.js",
248
+ "types": "./file-system/node/index.d.ts"
249
+ },
250
+ "./react-router": {
251
+ "import": "./react-router/index.js",
252
+ "types": "./react-router/index.d.ts"
253
+ },
254
+ "./react-router/browser": {
255
+ "import": "./react-router/browser/index.js",
256
+ "types": "./react-router/browser/index.d.ts"
257
+ },
258
+ "./react-router/styles.css": {
259
+ "import": "./react-router/styles.css/index.js",
260
+ "types": "./react-router/styles.css/index.d.ts"
261
261
  }
262
262
  },
263
263
  "dependencies": {
264
264
  "commander": "^12.1.0",
265
- "@ecopages/react-router": "npm:@jsr/ecopages__react-router@0.1.88",
266
- "@ecopages/bun-mdx-kitajs-loader": "npm:@jsr/ecopages__bun-mdx-kitajs-loader@0.1.88",
267
- "@ecopages/bun-postcss-loader": "npm:@jsr/ecopages__bun-postcss-loader@0.1.88",
268
- "@ecopages/file-system": "npm:@jsr/ecopages__file-system@0.1.88",
269
- "@ecopages/browser-router": "npm:@jsr/ecopages__browser-router@0.1.88",
270
- "@ecopages/image-processor": "npm:@jsr/ecopages__image-processor@0.1.88",
271
- "@ecopages/postcss-processor": "npm:@jsr/ecopages__postcss-processor@0.1.88",
272
- "@ecopages/react": "npm:@jsr/ecopages__react@0.1.88",
273
- "@ecopages/lit": "npm:@jsr/ecopages__lit@0.1.88",
274
- "@ecopages/kitajs": "npm:@jsr/ecopages__kitajs@0.1.88",
275
- "@ecopages/mdx": "npm:@jsr/ecopages__mdx@0.1.88",
276
- "@ecopages/bun-inline-css-plugin": "npm:@jsr/ecopages__bun-inline-css-plugin@0.1.88",
277
- "@ecopages/core": "npm:@jsr/ecopages__core@0.1.88"
265
+ "@ecopages/bun-postcss-loader": "npm:@jsr/ecopages__bun-postcss-loader@0.1.89",
266
+ "@ecopages/bun-mdx-kitajs-loader": "npm:@jsr/ecopages__bun-mdx-kitajs-loader@0.1.89",
267
+ "@ecopages/browser-router": "npm:@jsr/ecopages__browser-router@0.1.89",
268
+ "@ecopages/mdx": "npm:@jsr/ecopages__mdx@0.1.89",
269
+ "@ecopages/kitajs": "npm:@jsr/ecopages__kitajs@0.1.89",
270
+ "@ecopages/lit": "npm:@jsr/ecopages__lit@0.1.89",
271
+ "@ecopages/react": "npm:@jsr/ecopages__react@0.1.89",
272
+ "@ecopages/core": "npm:@jsr/ecopages__core@0.1.89",
273
+ "@ecopages/bun-inline-css-plugin": "npm:@jsr/ecopages__bun-inline-css-plugin@0.1.89",
274
+ "@ecopages/postcss-processor": "npm:@jsr/ecopages__postcss-processor@0.1.89",
275
+ "@ecopages/image-processor": "npm:@jsr/ecopages__image-processor@0.1.89",
276
+ "@ecopages/file-system": "npm:@jsr/ecopages__file-system@0.1.89",
277
+ "@ecopages/react-router": "npm:@jsr/ecopages__react-router@0.1.89"
278
278
  },
279
279
  "peerDependencies": {
280
280
  "bun-types": "latest",
@@ -285,18 +285,18 @@
285
285
  "index.d.ts",
286
286
  "bin/",
287
287
  "README.md",
288
- "react-router/",
289
- "bun-mdx-kitajs-loader/",
290
288
  "bun-postcss-loader/",
291
- "file-system/",
289
+ "bun-mdx-kitajs-loader/",
292
290
  "browser-router/",
293
- "image-processor/",
294
- "postcss-processor/",
295
- "react/",
296
- "lit/",
297
- "kitajs/",
298
291
  "mdx/",
292
+ "kitajs/",
293
+ "lit/",
294
+ "react/",
295
+ "core/",
299
296
  "bun-inline-css-plugin/",
300
- "core/"
297
+ "postcss-processor/",
298
+ "image-processor/",
299
+ "file-system/",
300
+ "react-router/"
301
301
  ]
302
302
  }