cnvr 2.8.7 → 2.8.8

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 (3) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +341 -6
  3. package/package.json +46 -30
package/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2024 Eugene Nesvetaev
3
+ Copyright (c) 2026 Eugene Nesvetaev
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/README.md CHANGED
@@ -1,13 +1,348 @@
1
- # Project build/dev pipeline
1
+ # cnvr
2
+
3
+ **Build and dev in one config file.**
4
+
5
+ Chain stages, run once to build, or watch and rebuild.
6
+
7
+ ```bash
8
+ node .conveyer.js
9
+ ```
2
10
 
3
11
  ## Installation
4
12
 
5
- ```sh
6
- $ npm install cnvr --save-dev
13
+ ```bash
14
+ npm install cnvr --save-dev
15
+ ```
16
+
17
+ For `.conveyer.ts` you need `tsx` as a peer dependency:
18
+
19
+ ```bash
20
+ npm install tsx --save-dev
21
+ ```
22
+
23
+ ## Quick Start
24
+
25
+ Create `.conveyer.js` in your project root:
26
+
27
+ ```javascript
28
+ import { resolve } from "node:path";
29
+ import { Conveyer, ESBuild } from "cnvr";
30
+
31
+ new Conveyer([
32
+ new ESBuild({
33
+ entryPoints: [ "src/index.ts" ],
34
+ outfile: resolve("dist", "index.js"),
35
+ external: true,
36
+ platform: "neutral",
37
+ format: "esm",
38
+ sourcemap: true,
39
+ target: "es2020"
40
+ })
41
+ ], { initialCleanup: "dist" });
42
+ ```
43
+
44
+ Add to `package.json`:
45
+
46
+ ```json
47
+ {
48
+ "scripts": {
49
+ "build": "node .conveyer.js",
50
+ "dev": "node .conveyer.js --dev"
51
+ }
52
+ }
53
+ ```
54
+
55
+ Run `npm run build` for a one-shot build, or `npm run dev` for watch mode.
56
+
57
+ ## Entry Points
58
+
59
+ cnvr looks for a conveyer file in the current directory or the path you pass:
60
+
61
+ | Pattern | Example |
62
+ |---------|---------|
63
+ | `.conveyer.js` | Root file |
64
+ | `.conveyer.ts` | TypeScript (requires tsx) |
65
+ | `.conveyer.mjs` / `.conveyer.cjs` | ESM / CJS |
66
+ | `.conveyer/index.{js,ts,mjs,cjs}` | Alternative layout |
67
+
68
+ **CLI:**
69
+
70
+ - `cnvr` — runs `.conveyer.js` (or path you pass)
71
+ - `cnvr-ts` — runs `.conveyer.ts` via tsx
72
+
73
+ **Direct run:**
74
+
75
+ ```bash
76
+ node .conveyer.js
77
+ npx cnvr
78
+ ```
79
+
80
+ ## Environment Variables
81
+
82
+ | Variable | Description |
83
+ |----------|-------------|
84
+ | `NODE_ENV` | `development` or `production` |
85
+ | `WATCH` | Enable watch mode |
86
+ | `BUILD` | Production build mode |
87
+ | `DEV` | Dev mode (watch + dev options) |
88
+ | `BUNDLE` | Create zip bundle |
89
+ | `FORCE` | Rebuild all, including dependencies |
90
+ | `VERSION` | From package.json |
91
+ | `GIT_COMMIT_ID` | Current git commit |
92
+ | `SOURCEMAPS` | Enable sourcemaps in production |
93
+
94
+ **CLI flags:** `-p` / `--production`, `-d` / `--development`, `-e` / `--env <name>`, `-f` / `--force`.
95
+
96
+ ## Public API
97
+
98
+ ### Conveyer
99
+
100
+ ```javascript
101
+ new Conveyer(stages, options?)
102
+ ```
103
+
104
+ - `stages` — Array of stages (supports nesting up to 3 levels)
105
+ - `options.initialCleanup` — Path(s) to clean before first run
106
+ - `options.context` — Extra data in shared context
107
+
108
+ ### Stage (base class)
109
+
110
+ All stages extend `Stage`. Base options:
111
+
112
+ ```javascript
113
+ new Stage({ watch, initialCleanup, cwd, symbol, title, id, ... })
114
+ ```
115
+
116
+ | Option | Type | Description |
117
+ |--------|------|-------------|
118
+ | `watch` | `string` \| `string[]` \| `{ paths, events, ... }` | Paths to watch (chokidar) |
119
+ | `initialCleanup` | `string` \| `string[]` | Dir(s) to clean before `run` |
120
+ | `cwd` | `string` | Working directory (default: `process.cwd()`) |
121
+ | `symbol` | `string` | Log icon |
122
+ | `title` | `string` | Stage name in logs |
123
+ | `id` | `string` | Unique ID (default: derived from title) |
124
+
125
+ **Hooks:** `onInit`, `onBefore`, `onAfter` — all optional, async.
126
+
127
+ **Override:** `do(isInitial, ...args)` — main logic.
128
+
129
+ ### ESBuild
130
+
131
+ Bundles with esbuild. Supports JSX, jscc, raw imports.
132
+
133
+ ```javascript
134
+ new ESBuild({
135
+ entryPoints: [ "src/index.ts" ],
136
+ outfile: resolve("dist", "index.js"),
137
+ external: true, // or array of package names, or [ true ] for auto
138
+ local: [ "my-pkg" ], // local packages to bundle
139
+ alias: { "@": "src" },
140
+ define: { "process.env.NODE_ENV": JSON.stringify(NODE_ENV) },
141
+ jsx: "automatic",
142
+ jsccValues: { _DEV: true },
143
+ plugins: [ myPlugin ],
144
+ platform: "neutral",
145
+ format: "esm",
146
+ target: "es2020",
147
+ loader: { ".svg": "file" },
148
+ mainFields: [ "module", "main" ],
149
+ watch: { paths: [ "public" ], events: [ "change" ] }
150
+ })
151
+ ```
152
+
153
+ After build: `context.packages`, `context.dependencies` (from metafile).
154
+
155
+ ### Copier
156
+
157
+ Copies files or directories. Watches and syncs on change.
158
+
159
+ ```javascript
160
+ new Copier({
161
+ targets: [
162
+ [ "public", "dist/public" ],
163
+ [ "assets", "dist/assets" ]
164
+ ]
165
+ })
7
166
  ```
8
167
 
9
- Or
168
+ - `targets` — `[[src, dest], ...]` or `[src, dest]` for a single pair
169
+ - Other stages can push to `context.targets` (Map) before Copier runs
170
+ - Watch: add/change → copy, addDir → mkdir, unlink/unlinkDir → rm
10
171
 
11
- ```sh
12
- $ bun add cnvr --dev
172
+ ### Bundler
173
+
174
+ Creates a zip archive from targets.
175
+
176
+ ```javascript
177
+ new Bundler({
178
+ target: "dist",
179
+ targets: [ [ "dist", ".", false, false ] ],
180
+ destDir: "release",
181
+ name: "my-app-1.0.0",
182
+ getName: (ctx) => `${ctx.packageJSON.name}-${ctx.packageJSON.version}`,
183
+ compressionLevel: "high",
184
+ onDone: (path) => console.log("Bundle:", path)
185
+ })
186
+ ```
187
+
188
+ - `target` / `targets` — `src` or `[src, relativeDest?, shouldCompress?, shouldRemove?]`
189
+ - Uses `context.targets` (array) from other stages
190
+ - `compressionLevel`: `"high"` \| `"medium"` \| `"low"`
191
+
192
+ ### NodeProcess
193
+
194
+ Runs Node.js with dev-friendly flags.
195
+
196
+ ```javascript
197
+ new NodeProcess({
198
+ entry: "dist/index.js",
199
+ inspect: true,
200
+ enableSourceMaps: true,
201
+ traceWarnings: true,
202
+ traceUncaught: true,
203
+ args: [ "--experimental-vm-modules" ],
204
+ watch: { paths: [ "dist" ] }
205
+ })
206
+ ```
207
+
208
+ ### BunProcess
209
+
210
+ Runs Bun.
211
+
212
+ ```javascript
213
+ new BunProcess({
214
+ entry: "src/index.ts",
215
+ inspect: false,
216
+ hot: true,
217
+ smol: false,
218
+ args: [],
219
+ watch: { paths: [ "src" ] }
220
+ })
221
+ ```
222
+
223
+ ### ChildProcess (base)
224
+
225
+ Base for custom process stages.
226
+
227
+ ```javascript
228
+ new ChildProcess({
229
+ command: "my-cli",
230
+ args: [ "--flag" ],
231
+ cwd: process.cwd(),
232
+ env: { CUSTOM: "1" },
233
+ watchdog: true,
234
+ checkIfRunning: false,
235
+ filterStdout: [ "noise" ],
236
+ filterStderr: [ "deprecated" ],
237
+ stopTimeout: 3000,
238
+ killTimeout: 1000,
239
+ isDetached: false
240
+ })
241
+ ```
242
+
243
+ ### MongodProcess
244
+
245
+ Starts MongoDB. Skips if already running.
246
+
247
+ ```javascript
248
+ new MongodProcess({
249
+ config: "/usr/local/etc/mongod.conf",
250
+ args: [],
251
+ watch: { paths: [ "config" ] }
252
+ })
253
+ ```
254
+
255
+ ### NginxProcess
256
+
257
+ Starts nginx. Uses `nginx -s stop` on exit.
258
+
259
+ ```javascript
260
+ new NginxProcess({
261
+ config: "nginx.conf",
262
+ args: [],
263
+ watch: { paths: [ "nginx.conf" ] }
264
+ })
265
+ ```
266
+
267
+ ### PackageJSONMaker
268
+
269
+ Generates a minimal `package.json` with selected dependencies.
270
+
271
+ ```javascript
272
+ new PackageJSONMaker({
273
+ src: ".",
274
+ dest: "dist",
275
+ dependenciesOf: [ "esbuild" ],
276
+ dependencies: [ "chalk", "ora" ],
277
+ symlinkNodeModules: true,
278
+ overrides: { "engines": { "node": ">=18" } }
279
+ })
280
+ ```
281
+
282
+ - `dependenciesOf` — Stage IDs to pull dependencies from (e.g. `["esbuild"]`)
283
+ - `dependencies` — Array of names or `() => string[]`
284
+ - `symlinkNodeModules` — Symlink instead of copy (for dev)
285
+
286
+ ### Reveal
287
+
288
+ Opens a path in the system file manager (Finder, Explorer, nautilus, etc.).
289
+
290
+ ```javascript
291
+ new Reveal({
292
+ target: "dist",
293
+ noTargetPhrase: "Nothing to show"
294
+ })
295
+ ```
296
+
297
+ Uses `target` or `context.target` if set.
298
+
299
+ ## Utils
300
+
301
+ Exported helpers:
302
+
303
+ | Export | Description |
304
+ |--------|-------------|
305
+ | `env(dirName?, envName?)` | Load `.env` with `${VAR}` interpolation, `.env.local`, `.env.{NODE_ENV}` |
306
+ | `log(message, type?, title?, bold?)` | Console output; `log.progress()`, `log.finish()` |
307
+ | `Packages` | Package.json, workspace, external/local resolution |
308
+ | `getCurrentCommitId(short?)` | Current git commit |
309
+ | `reveal(path)` | Open path in file manager |
310
+ | `rawImportPlugin()` | esbuild plugin for `?raw` imports |
311
+ | `copyRecursive`, `pathExists`, `isRunning` | File utilities |
312
+
313
+ ## Workspace & Multi-Entrypoint
314
+
315
+ For monorepos, use `Entrypoints` to orchestrate multiple conveyer files. Dependencies are inferred from `scripts.build` in package.json.
316
+
317
+ ```javascript
318
+ import { __Entrypoints as Entrypoints } from "cnvr";
319
+
320
+ new Entrypoints({ entrypointsWatchQueueDelay: 300 }, true);
321
+ ```
322
+
323
+ ## Custom Stage
324
+
325
+ ```javascript
326
+ import { Stage } from "cnvr";
327
+
328
+ class MyStage extends Stage {
329
+ constructor(options) {
330
+ super({
331
+ symbol: "🔧",
332
+ title: "My Stage",
333
+ watch: "src/**",
334
+ ...options
335
+ });
336
+ }
337
+
338
+ async do(isInitial, eventMap) {
339
+ // Your logic
340
+ }
341
+ }
13
342
  ```
343
+
344
+ ## Transparency
345
+
346
+ - Runs locally — no external services, no data leaves your machine
347
+ - Peer: `tsx` for TypeScript conveyer files
348
+ - cnvr is maintained by one developer
package/package.json CHANGED
@@ -1,26 +1,7 @@
1
1
  {
2
2
  "name": "cnvr",
3
- "version": "2.8.7",
4
- "description": "Project build/dev pipeline",
5
- "type": "module",
6
- "module": "./dist/index.js",
7
- "main": "./dist/index.js",
8
- "bin": {
9
- "cnvr": "./cli/js.js",
10
- "cnvr-ts": "./cli/ts.ts"
11
- },
12
- "imports": {
13
- "#utils": "./src/utils/index.ts"
14
- },
15
- "packageManager": "bun@1.3.5",
16
- "scripts": {
17
- "test": "echo \"Error: no test specified\" && exit 1",
18
- "b": "bun .conveyer.js --production && tsc -p ."
19
- },
20
- "repository": {
21
- "type": "git",
22
- "url": "git+https://github.com/nesvet/cnvr.git"
23
- },
3
+ "version": "2.8.8",
4
+ "description": "Build and dev pipeline in one config file",
24
5
  "keywords": [
25
6
  "build",
26
7
  "dev",
@@ -32,28 +13,63 @@
32
13
  "mongodb",
33
14
  "nginx"
34
15
  ],
35
- "author": "Eugene Nesvetaev <dev@nesvet.dev> (https://nesvet.dev/)",
16
+ "homepage": "https://github.com/nesvet/cnvr#readme",
17
+ "bugs": {
18
+ "url": "https://github.com/nesvet/cnvr/issues"
19
+ },
20
+ "repository": {
21
+ "type": "git",
22
+ "url": "git+https://github.com/nesvet/cnvr.git"
23
+ },
24
+ "funding": {
25
+ "type": "patreon",
26
+ "url": "https://www.patreon.com/nesvet"
27
+ },
36
28
  "license": "MIT",
37
- "peerDependencies": {
38
- "tsx": "^4"
29
+ "author": "Eugene Nesvetaev <dev@nesvet.dev> (https://nesvet.dev/)",
30
+ "type": "module",
31
+ "imports": {
32
+ "#utils": "./src/utils/index.ts"
33
+ },
34
+ "main": "./dist/index.js",
35
+ "module": "./dist/index.js",
36
+ "bin": {
37
+ "cnvr": "./cli/js.js",
38
+ "cnvr-ts": "./cli/ts.ts"
39
+ },
40
+ "files": [
41
+ "dist",
42
+ "cli"
43
+ ],
44
+ "scripts": {
45
+ "b": "bun .conveyer.js --production && tsc -p .",
46
+ "test": "echo \"Error: no test specified\" && exit 1"
39
47
  },
40
48
  "dependencies": {
41
49
  "@nesvet/n": "^1.2.1",
42
50
  "chalk": "^5.6.2",
43
51
  "chokidar": "^5.0.0",
44
- "esbuild": "^0.27.2",
52
+ "esbuild": "^0.27.3",
45
53
  "esbuild-plugin-jscc": "^1.1.2",
46
54
  "micromatch": "^4.0.8",
47
- "ora": "^9.0.0",
55
+ "ora": "^9.3.0",
48
56
  "process-request": "^1.1.7",
49
57
  "resolve-package-path": "^4.0.3",
50
- "semver": "^7.7.3",
58
+ "semver": "^7.7.4",
51
59
  "zip-a-folder": "^4.0.4"
52
60
  },
53
61
  "devDependencies": {
54
- "@nesvet/eslint-config": "^2.2.2",
55
- "@types/node": "^24.10.1",
56
- "type-fest": "^5.3.1",
62
+ "@nesvet/eslint-config": "^2.2.8",
63
+ "@types/node": "^24.10.13",
64
+ "type-fest": "^5.4.4",
57
65
  "typescript": "^5.9.3"
66
+ },
67
+ "peerDependencies": {
68
+ "tsx": "^4.20.6"
69
+ },
70
+ "packageManager": "bun@1.3.9",
71
+ "engines": {
72
+ "bun": ">=1.3",
73
+ "node": ">=20"
58
74
  }
59
75
  }