@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
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import '@fgv/ts-utils-jest';
|
|
2
|
+
|
|
3
|
+
import { extractTemplateVariables, renderShellTemplate, shellQuote } from '../../src/template';
|
|
4
|
+
|
|
5
|
+
describe('template helpers', () => {
|
|
6
|
+
test('shellQuote wraps values in single quotes and escapes embedded quotes', () => {
|
|
7
|
+
expect(shellQuote("abc'def")).toBe("'abc'\"'\"'def'");
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
test('extractTemplateVariables reads simple template variables', () => {
|
|
11
|
+
expect(extractTemplateVariables('export XAI_API_KEY={{xai}}')).toSucceedWith(['xai']);
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
test('renderShellTemplate renders shell-quoted export values', () => {
|
|
15
|
+
expect(renderShellTemplate('export XAI_API_KEY={{xai}}', { xai: "abc'def" })).toSucceedWith(
|
|
16
|
+
"export XAI_API_KEY='abc'\"'\"'def'"
|
|
17
|
+
);
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
test('extractTemplateVariables reads unescaped ampersand variables', () => {
|
|
21
|
+
expect(extractTemplateVariables('export XAI_API_KEY={{& xai}}')).toSucceedWith(['xai']);
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
test('renderShellTemplate renders unescaped ampersand variables', () => {
|
|
25
|
+
expect(renderShellTemplate('export XAI_API_KEY={{& xai}}', { xai: "abc'def" })).toSucceedWith(
|
|
26
|
+
"export XAI_API_KEY='abc'\"'\"'def'"
|
|
27
|
+
);
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
test('renderShellTemplate fails when the template uses unsupported sections', () => {
|
|
31
|
+
expect(renderShellTemplate('{{#xai}}value{{/xai}}', { xai: 'value' })).toFail();
|
|
32
|
+
});
|
|
33
|
+
});
|
package/tsconfig.json
ADDED