@fgv/ks 5.1.0-25
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 +58 -0
- package/bin/ks.js +18 -0
- package/config/jest.config.json +12 -0
- package/config/rig.json +4 -0
- package/eslint.config.js +24 -0
- package/package.json +55 -0
- package/src/app.ts +595 -0
- package/src/cli.ts +1 -0
- package/src/help.ts +116 -0
- package/src/index.ts +21 -0
- package/src/io.ts +179 -0
- package/src/keystore.ts +196 -0
- package/src/template.ts +61 -0
- package/test/mocks/clipboardy.js +5 -0
- package/test/unit/app.test.ts +112 -0
- package/test/unit/help.test.ts +45 -0
- package/test/unit/io.test.ts +173 -0
- package/test/unit/keystore.test.ts +448 -0
- package/test/unit/template.test.ts +33 -0
- package/tsconfig.json +8 -0
- package/tsconfig.test.json +8 -0
package/README.md
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
# @fgv/ks
|
|
2
|
+
|
|
3
|
+
Command-line tool for creating, managing, and exporting ts-extras keystores.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- Create a keystore at `~/.fgv-ks` by default
|
|
8
|
+
- Change the keystore password
|
|
9
|
+
- Add, list, read, and remove secrets without putting them on the command line
|
|
10
|
+
- Export secrets through a template rendered to a POSIX shell snippet
|
|
11
|
+
- Prompt interactively for missing secrets and optionally persist them
|
|
12
|
+
- Copy rendered output to the clipboard
|
|
13
|
+
|
|
14
|
+
## Usage
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
ks --help
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
### Self-contained help topics
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
ks help
|
|
24
|
+
ks help commands
|
|
25
|
+
ks help password
|
|
26
|
+
ks help template
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
### Initialize a keystore
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
ks init
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
### Put a secret from stdin or a file
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
printf '%s' "$XAI_API_KEY" | ks put xai --stdin
|
|
39
|
+
ks put xai --file ./xai.txt
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
### Export secrets into shell variables
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
eval "$(ks export --template-file ./keystore.template.sh)"
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
### Start a shell session with the keystore password
|
|
49
|
+
|
|
50
|
+
```bash
|
|
51
|
+
eval "$(ks session --var FGV_KS_PASSWORD)"
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
### Copy rendered output to the clipboard
|
|
55
|
+
|
|
56
|
+
```bash
|
|
57
|
+
ks export --template-string 'export XAI_API_KEY={{xai}}' --clipboard
|
|
58
|
+
```
|
package/bin/ks.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
const { KsCli } = require('../lib/index');
|
|
4
|
+
|
|
5
|
+
async function main() {
|
|
6
|
+
try {
|
|
7
|
+
const cli = new KsCli();
|
|
8
|
+
await cli.run(process.argv);
|
|
9
|
+
} catch (error) {
|
|
10
|
+
console.error('Fatal error:', error.message);
|
|
11
|
+
process.exit(1);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
main().catch((error) => {
|
|
16
|
+
console.error('Unhandled error:', error);
|
|
17
|
+
process.exit(1);
|
|
18
|
+
});
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
{
|
|
2
|
+
"testMatch": ["<rootDir>/src/test/**/*.test.ts", "<rootDir>/test/**/*.test.ts"],
|
|
3
|
+
"preset": "ts-jest",
|
|
4
|
+
"testEnvironment": "node",
|
|
5
|
+
"extensionsToTreatAsEsm": [],
|
|
6
|
+
"moduleNameMapper": {
|
|
7
|
+
"^clipboardy$": "<rootDir>/test/mocks/clipboardy.js"
|
|
8
|
+
},
|
|
9
|
+
"transform": {
|
|
10
|
+
"^.+\\.ts$": ["ts-jest", { "tsconfig": "tsconfig.test.json" }]
|
|
11
|
+
}
|
|
12
|
+
}
|
package/config/rig.json
ADDED
package/eslint.config.js
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
// ESLint 9 flat config
|
|
2
|
+
const nodeProfile = require('@rushstack/eslint-config/flat/profile/node');
|
|
3
|
+
const packletsPlugin = require('@rushstack/eslint-config/flat/mixins/packlets');
|
|
4
|
+
const tsdocPlugin = require('@rushstack/eslint-config/flat/mixins/tsdoc');
|
|
5
|
+
|
|
6
|
+
module.exports = [
|
|
7
|
+
...nodeProfile,
|
|
8
|
+
packletsPlugin,
|
|
9
|
+
...tsdocPlugin,
|
|
10
|
+
{
|
|
11
|
+
files: ['test/**/*.ts'],
|
|
12
|
+
languageOptions: {
|
|
13
|
+
parserOptions: {
|
|
14
|
+
project: './tsconfig.test.json',
|
|
15
|
+
tsconfigRootDir: __dirname
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
rules: {
|
|
21
|
+
'@rushstack/packlets/mechanics': 'warn'
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
];
|
package/package.json
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@fgv/ks",
|
|
3
|
+
"version": "5.1.0-25",
|
|
4
|
+
"description": "Command-line utility for managing ts-extras keystore files",
|
|
5
|
+
"main": "lib/index.js",
|
|
6
|
+
"types": "lib/index.d.ts",
|
|
7
|
+
"bin": {
|
|
8
|
+
"ks": "bin/ks.js"
|
|
9
|
+
},
|
|
10
|
+
"scripts": {
|
|
11
|
+
"build": "heft build --clean",
|
|
12
|
+
"test": "heft test --clean",
|
|
13
|
+
"coverage": "heft test --clean --coverage",
|
|
14
|
+
"clean": "heft clean",
|
|
15
|
+
"lint": "eslint src --ext .ts",
|
|
16
|
+
"fixlint": "eslint src --ext .ts --fix"
|
|
17
|
+
},
|
|
18
|
+
"keywords": [
|
|
19
|
+
"keystore",
|
|
20
|
+
"cli",
|
|
21
|
+
"tool",
|
|
22
|
+
"security",
|
|
23
|
+
"secrets"
|
|
24
|
+
],
|
|
25
|
+
"author": "Erik Fortune",
|
|
26
|
+
"license": "MIT",
|
|
27
|
+
"engines": {
|
|
28
|
+
"node": ">=22.22.0 <23.0.0 || >=24.15.0 <25.0.0"
|
|
29
|
+
},
|
|
30
|
+
"dependencies": {
|
|
31
|
+
"@fgv/ts-extras": "workspace:*",
|
|
32
|
+
"@fgv/ts-json-base": "workspace:*",
|
|
33
|
+
"@fgv/ts-utils": "workspace:*",
|
|
34
|
+
"clipboardy": "^3.0.0",
|
|
35
|
+
"commander": "^11.0.0"
|
|
36
|
+
},
|
|
37
|
+
"devDependencies": {
|
|
38
|
+
"@fgv/ts-utils-jest": "workspace:*",
|
|
39
|
+
"@rushstack/eslint-config": "4.6.4",
|
|
40
|
+
"@rushstack/heft": "1.2.7",
|
|
41
|
+
"@rushstack/heft-node-rig": "2.11.27",
|
|
42
|
+
"@rushstack/heft-jest-plugin": "1.2.6",
|
|
43
|
+
"@types/jest": "^29.5.14",
|
|
44
|
+
"@types/node": "^20.14.9",
|
|
45
|
+
"eslint": "^9.39.2",
|
|
46
|
+
"jest": "^29.7.0",
|
|
47
|
+
"typescript": "5.9.3",
|
|
48
|
+
"@types/heft-jest": "1.0.6",
|
|
49
|
+
"ts-jest": "^29.4.6"
|
|
50
|
+
},
|
|
51
|
+
"repository": {
|
|
52
|
+
"type": "git",
|
|
53
|
+
"url": "https://github.com/ErikFortune/fgv.git"
|
|
54
|
+
}
|
|
55
|
+
}
|