@hkonda/loco-translate 1.0.3 → 1.0.4
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 +62 -0
- package/bin/loco.js +41 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -349,3 +349,65 @@ flowchart TB
|
|
|
349
349
|
| Build Tool | Vite |
|
|
350
350
|
| AI | BlueHive API |
|
|
351
351
|
| Deployment | systemd + deploy.sh |
|
|
352
|
+
|
|
353
|
+
---
|
|
354
|
+
|
|
355
|
+
## Publishing an NPM Update
|
|
356
|
+
|
|
357
|
+
Use this checklist whenever you add new features or fixes and want to release a new version.
|
|
358
|
+
|
|
359
|
+
### 1. Make your changes
|
|
360
|
+
|
|
361
|
+
Work on `main` or a feature branch as normal. Run `npm run dev` to develop locally.
|
|
362
|
+
|
|
363
|
+
### 2. Bump the version
|
|
364
|
+
|
|
365
|
+
Edit `package.json` at the root — increment `"version"` following [semver](https://semver.org/):
|
|
366
|
+
|
|
367
|
+
```
|
|
368
|
+
patch (1.0.3 → 1.0.4) — bug fixes, small tweaks
|
|
369
|
+
minor (1.0.3 → 1.1.0) — new backwards-compatible features
|
|
370
|
+
major (1.0.3 → 2.0.0) — breaking changes
|
|
371
|
+
```
|
|
372
|
+
|
|
373
|
+
### 3. Build the package
|
|
374
|
+
|
|
375
|
+
```bash
|
|
376
|
+
node scripts/build-npm.js
|
|
377
|
+
```
|
|
378
|
+
|
|
379
|
+
This compiles the TypeScript server, builds the Svelte dashboard (with the correct `/dashboard/` base path), builds the CDN client bundles, and assembles everything into `npm-package/`.
|
|
380
|
+
|
|
381
|
+
### 4. Publish
|
|
382
|
+
|
|
383
|
+
```bash
|
|
384
|
+
cd npm-package
|
|
385
|
+
echo '//registry.npmjs.org/:_authToken=<your-npm-token>' > .npmrc
|
|
386
|
+
npm publish --access public
|
|
387
|
+
rm .npmrc
|
|
388
|
+
```
|
|
389
|
+
|
|
390
|
+
Get a token at [npmjs.com → Access Tokens](https://www.npmjs.com/settings/~/tokens) — use a **Classic Automation** token (bypasses 2FA).
|
|
391
|
+
|
|
392
|
+
### 5. Verify
|
|
393
|
+
|
|
394
|
+
```bash
|
|
395
|
+
npm install -g @hkonda/loco-translate@<new-version>
|
|
396
|
+
loco
|
|
397
|
+
```
|
|
398
|
+
|
|
399
|
+
Open `http://localhost:6101/dashboard/` to confirm everything loads.
|
|
400
|
+
|
|
401
|
+
---
|
|
402
|
+
|
|
403
|
+
### What the build script does
|
|
404
|
+
|
|
405
|
+
| Step | Command | Output |
|
|
406
|
+
|---|---|---|
|
|
407
|
+
| Compile server | `tsc -p tsconfig.server.json` | `dist-server/` |
|
|
408
|
+
| Build dashboard | `vite build` (with `LOCO_VITE_BASE=/dashboard/`) | `dist/` |
|
|
409
|
+
| Build CDN (minified) | `vite build` in `client/` | `public/loco.min.js` |
|
|
410
|
+
| Build CDN (unminified) | `cross-env LOCO_UNMINIFIED=1 vite build` in `client/` | `public/loco.js` |
|
|
411
|
+
| Assemble | copies all of the above + `bin/loco.js` + `README.md` | `npm-package/` |
|
|
412
|
+
|
|
413
|
+
The `npm-package/` directory is gitignored — never commit it directly.
|
package/bin/loco.js
CHANGED
|
@@ -1,5 +1,44 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
// Loco Translation Manager — CLI entry point
|
|
3
|
-
// Usage:
|
|
3
|
+
// Usage: loco [options]
|
|
4
|
+
//
|
|
5
|
+
// Options:
|
|
6
|
+
// -p, --port <number> Port to listen on (default: 6101, or PORT env var)
|
|
7
|
+
// -d, --data-dir <path> Directory for loco.db and backups (default: .loco/ in cwd)
|
|
8
|
+
// -h, --help Show this help message
|
|
4
9
|
|
|
5
|
-
|
|
10
|
+
const args = process.argv.slice(2);
|
|
11
|
+
|
|
12
|
+
if (args.includes('-h') || args.includes('--help')) {
|
|
13
|
+
console.log(`
|
|
14
|
+
Usage: loco [options]
|
|
15
|
+
|
|
16
|
+
Options:
|
|
17
|
+
-p, --port <number> Port to listen on (default: 6101)
|
|
18
|
+
-d, --data-dir <path> Directory for loco.db (default: .loco/ in cwd)
|
|
19
|
+
-h, --help Show this help message
|
|
20
|
+
|
|
21
|
+
Environment variables (can also be set in a .env file):
|
|
22
|
+
PORT Same as --port
|
|
23
|
+
LOCO_DATA_DIR Same as --data-dir
|
|
24
|
+
BASE_PATH URL prefix for reverse-proxy deployments
|
|
25
|
+
BLUEHIVE_API_KEY BlueHive key for AI translations
|
|
26
|
+
PUBLIC_URL Override the printed public URL
|
|
27
|
+
`);
|
|
28
|
+
process.exit(0);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// Parse --port / -p
|
|
32
|
+
const portIdx = args.findIndex(a => a === '--port' || a === '-p');
|
|
33
|
+
if (portIdx !== -1 && args[portIdx + 1]) {
|
|
34
|
+
process.env.PORT = args[portIdx + 1];
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
// Parse --data-dir / -d
|
|
38
|
+
const dataDirIdx = args.findIndex(a => a === '--data-dir' || a === '-d');
|
|
39
|
+
if (dataDirIdx !== -1 && args[dataDirIdx + 1]) {
|
|
40
|
+
process.env.LOCO_DATA_DIR = args[dataDirIdx + 1];
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
// Dynamic import so env vars are set before config.ts runs
|
|
44
|
+
await import('../dist-server/index.js');
|