keyman-cli 0.0.0-stage → 0.1.1

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 moonmangit
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,26 @@
1
- # Temporary Holding Version
1
+ # keyman-cli
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Install the Rust-based Keyman CLI with npm:
4
+
5
+ ```sh
6
+ npm install -g keyman-cli
7
+ ```
8
+
9
+ Create a private `.yml` file with one mapping per project:
10
+
11
+ ```yaml
12
+ my-app:
13
+ API_KEY: "secret-value"
14
+ DEBUG: "true"
15
+ ```
16
+
17
+ Then run:
18
+
19
+ ```sh
20
+ keyman load /path/to/master.yml
21
+ keyman inject my-app /path/to/existing/project
22
+ ```
23
+
24
+ `load` remembers the master file path. `inject` replaces the project's `.env` file. Keep the master file private and ignore `.env` in Git.
25
+
26
+ Prebuilt binaries are included for Windows x64, macOS Intel and Apple Silicon, and Linux x64 and ARM64. No Rust installation is needed. On Windows systems that block the native executable, the command can use WSL if it is installed. The executable is available as both `keyman` and `keyman-cli`. [Source and full documentation](https://github.com/moonmangit/keyman-cli).
package/bin/keyman.cjs ADDED
@@ -0,0 +1,80 @@
1
+ #!/usr/bin/env node
2
+
3
+ const fs = require('node:fs');
4
+ const os = require('node:os');
5
+ const path = require('node:path');
6
+ const { spawnSync } = require('node:child_process');
7
+
8
+ const targets = {
9
+ 'darwin-arm64': 'aarch64-apple-darwin',
10
+ 'darwin-x64': 'x86_64-apple-darwin',
11
+ 'linux-arm64': 'aarch64-unknown-linux-gnu',
12
+ 'linux-x64': 'x86_64-unknown-linux-gnu',
13
+ 'win32-x64': 'x86_64-pc-windows-msvc',
14
+ };
15
+
16
+ const platform = `${process.platform}-${process.arch}`;
17
+ const target = targets[platform];
18
+ if (!target) {
19
+ console.error(`keyman: unsupported platform ${platform}`);
20
+ process.exit(1);
21
+ }
22
+
23
+ const binary = path.join(__dirname, 'native', target, `keyman${process.platform === 'win32' ? '.exe' : ''}`);
24
+ if (!fs.existsSync(binary)) {
25
+ console.error(`keyman: binary for ${platform} is missing from this package`);
26
+ process.exit(1);
27
+ }
28
+
29
+ const args = process.argv.slice(2);
30
+ let result = spawnSync(binary, args, { stdio: 'inherit' });
31
+ if (process.platform === 'win32' && result.error && ['UNKNOWN', 'EPERM', 'EACCES'].includes(result.error.code)) {
32
+ try {
33
+ result = runWithWsl(args);
34
+ } catch (error) {
35
+ console.error(`keyman: Windows blocked the native executable and WSL fallback failed: ${error.message}`);
36
+ process.exit(1);
37
+ }
38
+ }
39
+ if (result.error) {
40
+ console.error(`keyman: ${result.error.message}`);
41
+ process.exit(1);
42
+ }
43
+ if (result.signal) {
44
+ process.kill(process.pid, result.signal);
45
+ } else {
46
+ process.exitCode = result.status ?? 1;
47
+ }
48
+
49
+ function runWithWsl(args) {
50
+ const linuxBinary = path.join(__dirname, 'native', 'x86_64-unknown-linux-gnu', 'keyman');
51
+ if (!fs.existsSync(linuxBinary)) {
52
+ throw new Error('the Linux x64 binary is missing from this package');
53
+ }
54
+
55
+ const linuxArgs = [...args];
56
+ if (linuxArgs[0] === 'load' && linuxArgs.length === 2) {
57
+ linuxArgs[1] = toWslPath(linuxArgs[1]);
58
+ } else if (linuxArgs[0] === 'inject' && linuxArgs.length === 3) {
59
+ linuxArgs[2] = toWslPath(linuxArgs[2]);
60
+ }
61
+
62
+ const linuxHome = toWslPath(process.env.USERPROFILE || os.homedir());
63
+ return spawnSync('wsl.exe', [
64
+ '--exec', 'env', `HOME=${linuxHome}`, toWslPath(linuxBinary), ...linuxArgs,
65
+ ], { stdio: 'inherit' });
66
+ }
67
+
68
+ function toWslPath(input) {
69
+ const gitBashPath = /^\/([a-zA-Z])\//.exec(input);
70
+ const windowsPath = gitBashPath
71
+ ? `${gitBashPath[1].toUpperCase()}:${input.slice(2)}`
72
+ : path.win32.resolve(input);
73
+ const converted = spawnSync('wsl.exe', ['--exec', 'wslpath', '-u', windowsPath], {
74
+ encoding: 'utf8',
75
+ });
76
+ if (converted.error || converted.status !== 0) {
77
+ throw new Error(converted.error?.message || converted.stderr?.trim() || 'wslpath could not convert the path');
78
+ }
79
+ return converted.stdout.replace(/\r?\n$/, '');
80
+ }
package/package.json CHANGED
@@ -1,6 +1,27 @@
1
1
  {
2
2
  "name": "keyman-cli",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.1.1",
4
+ "description": "Manage project .env files from one private YAML file",
5
+ "license": "MIT",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "git+https://github.com/moonmangit/keyman-cli.git"
9
+ },
10
+ "homepage": "https://github.com/moonmangit/keyman-cli#readme",
11
+ "bugs": "https://github.com/moonmangit/keyman-cli/issues",
12
+ "bin": {
13
+ "keyman": "bin/keyman.cjs",
14
+ "keyman-cli": "bin/keyman.cjs"
15
+ },
16
+ "files": [
17
+ "bin/",
18
+ "README.md",
19
+ "LICENSE"
20
+ ],
21
+ "engines": {
22
+ "node": ">=18"
23
+ },
24
+ "publishConfig": {
25
+ "access": "public"
26
+ }
27
+ }