yini-cli 1.0.0-alpha.2
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/.github/workflows/publish.yml +30 -0
- package/.github/workflows/run-all-tests.yml +51 -0
- package/.github/workflows/run-smoke-tests.yml +33 -0
- package/.nvmrc +1 -0
- package/.vscode/settings.json +3 -0
- package/CONTRIBUTING.md +6 -0
- package/README.md +68 -0
- package/dist/commands/info.d.ts +1 -0
- package/dist/commands/parse.d.ts +2 -0
- package/dist/commands/validate.d.ts +7 -0
- package/dist/config/env.d.ts +34 -0
- package/dist/descriptions.d.ts +6 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +162 -0
- package/dist/types.d.ts +8 -0
- package/dist/utils/print.d.ts +14 -0
- package/docs/contributing.md +28 -0
- package/docs/project-setup.md +32 -0
- package/eslint.config.js +40 -0
- package/package.json +93 -0
- package/prettier.config.cjs +33 -0
- package/sample.yini +19 -0
- package/samples/basic.yini +11 -0
- package/samples/nested.yini +26 -0
- package/src/commands/info.ts +19 -0
- package/src/commands/parse.ts +88 -0
- package/src/commands/validate.ts +48 -0
- package/src/config/env.ts +85 -0
- package/src/descriptions.ts +6 -0
- package/src/index.ts +182 -0
- package/src/types.ts +9 -0
- package/src/utils/print.ts +49 -0
- package/tests/fixtures/corrupt-config-1.yini +8 -0
- package/tests/fixtures/invalid-config-1.yini +2 -0
- package/tests/fixtures/nested-config-1.yini +7 -0
- package/tests/fixtures/valid-config-1.yini +5 -0
- package/tests/general.test.ts +86 -0
- package/tests/smoke.test.ts +145 -0
- package/tests/test-helpers.ts +9 -0
- package/tsconfig.json +16 -0
- package/vitest.config.ts +8 -0
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
name: Publish npm package
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
release:
|
|
5
|
+
types: [published]
|
|
6
|
+
|
|
7
|
+
jobs:
|
|
8
|
+
publish:
|
|
9
|
+
runs-on: ubuntu-latest
|
|
10
|
+
|
|
11
|
+
steps:
|
|
12
|
+
- name: Checkout code
|
|
13
|
+
uses: actions/checkout@v4
|
|
14
|
+
|
|
15
|
+
- name: Set up Node.js
|
|
16
|
+
uses: actions/setup-node@v4
|
|
17
|
+
with:
|
|
18
|
+
node-version: '20' # Use your desired Node version
|
|
19
|
+
registry-url: 'https://registry.npmjs.org/'
|
|
20
|
+
|
|
21
|
+
- name: Install dependencies
|
|
22
|
+
run: npm ci
|
|
23
|
+
|
|
24
|
+
- name: Build package
|
|
25
|
+
run: npm run build # Optional, if you have a build step
|
|
26
|
+
|
|
27
|
+
- name: Publish to npm
|
|
28
|
+
run: npm publish --access public # Use --access public for public packages
|
|
29
|
+
env:
|
|
30
|
+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
name: Run All Tests
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
pull_request:
|
|
5
|
+
branches: ['main']
|
|
6
|
+
workflow_dispatch: # allows manual run from GitHub UI
|
|
7
|
+
|
|
8
|
+
jobs:
|
|
9
|
+
run-all-tests:
|
|
10
|
+
# runs-on: ubuntu-latest
|
|
11
|
+
# runs-on: windows-latest
|
|
12
|
+
strategy:
|
|
13
|
+
matrix:
|
|
14
|
+
node: [13, 20, 22]
|
|
15
|
+
# Available GitHub-hosted runner types see:
|
|
16
|
+
# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#choosing-github-hosted-runners
|
|
17
|
+
os: [
|
|
18
|
+
windows-latest,
|
|
19
|
+
windows-2022,
|
|
20
|
+
#windows-11-arm, # Not supported yet on private
|
|
21
|
+
ubuntu-latest,
|
|
22
|
+
ubuntu-24.04,
|
|
23
|
+
#ubuntu-24.04-arm, # Not supported yet on private
|
|
24
|
+
macos-latest,
|
|
25
|
+
macos-13,
|
|
26
|
+
]
|
|
27
|
+
runs-on: ${{ matrix.os }}
|
|
28
|
+
#runs-on: ubuntu-latest
|
|
29
|
+
|
|
30
|
+
steps:
|
|
31
|
+
- name: Checkout code
|
|
32
|
+
uses: actions/checkout@v4
|
|
33
|
+
|
|
34
|
+
- name: Setup Node.js
|
|
35
|
+
uses: actions/setup-node@v4
|
|
36
|
+
with:
|
|
37
|
+
node-version: '20' # adjust as needed
|
|
38
|
+
|
|
39
|
+
- name: Print Node.js version
|
|
40
|
+
run: node --version
|
|
41
|
+
|
|
42
|
+
- name: Install dependencies
|
|
43
|
+
run: npm ci # npm clean-install (installs without changing package-lock.json)
|
|
44
|
+
|
|
45
|
+
- name: Build # So that dist/ gets updated too.
|
|
46
|
+
run: npm run build
|
|
47
|
+
|
|
48
|
+
- name: Run Specific Test
|
|
49
|
+
run: |
|
|
50
|
+
echo "Running test: ${{ github.event.inputs.testName }}"
|
|
51
|
+
npm run ci:test:smoke
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
name: Run Smoke Tests
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: ['main']
|
|
6
|
+
workflow_dispatch: # allows manual run from GitHub UI
|
|
7
|
+
|
|
8
|
+
jobs:
|
|
9
|
+
run-smoke-tests:
|
|
10
|
+
runs-on: ubuntu-latest
|
|
11
|
+
|
|
12
|
+
steps:
|
|
13
|
+
- name: Checkout code
|
|
14
|
+
uses: actions/checkout@v4
|
|
15
|
+
|
|
16
|
+
- name: Setup Node.js
|
|
17
|
+
uses: actions/setup-node@v4
|
|
18
|
+
with:
|
|
19
|
+
node-version: '20' # adjust as needed
|
|
20
|
+
|
|
21
|
+
- name: Print Node.js version
|
|
22
|
+
run: node --version
|
|
23
|
+
|
|
24
|
+
- name: Install dependencies
|
|
25
|
+
run: npm ci # npm clean-install (installs without changing package-lock.json)
|
|
26
|
+
|
|
27
|
+
- name: Build # So that dist/ gets updated too.
|
|
28
|
+
run: npm run build
|
|
29
|
+
|
|
30
|
+
- name: Run Specific Test
|
|
31
|
+
run: |
|
|
32
|
+
echo "Running test: ${{ github.event.inputs.testName }}"
|
|
33
|
+
npm run ci:test:smoke
|
package/.nvmrc
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
20.18.0
|
package/CONTRIBUTING.md
ADDED
package/README.md
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
# YINI-CLI
|
|
2
|
+
Command-line tool for working with YINI configuration files. A human-friendly config format — like INI, but with type-safe values, nested sections, comments, minimal syntax noise, and optional strict mode.
|
|
3
|
+
|
|
4
|
+
[](https://www.npmjs.com/package/yini-parser) [](https://github.com/YINI-lang/yini-cli/actions/workflows/run-all-tests.yml)
|
|
5
|
+
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
## 🙋♀️ Why YINI?
|
|
9
|
+
- **YINI is an alternative** to other great config formats like INI, JSON, YAML, XML, and TOML — designed for clarity, simplicity, and straightforward section nesting.
|
|
10
|
+
- **Started as a personal project and a research challenge:** Aiming for something more readable than JSON, more structured than INI, and less surprising than YAML.
|
|
11
|
+
- **Built for clarity:**
|
|
12
|
+
* Easy to read and write for humans, especially for nested sections.
|
|
13
|
+
* Not too much syntax noise.
|
|
14
|
+
* Just enough structure for real-world configs.
|
|
15
|
+
- **A little bit of fun and joy:**
|
|
16
|
+
* Created to scratch our own itch — if you like it too, that's a bonus!
|
|
17
|
+
|
|
18
|
+
---
|
|
19
|
+
|
|
20
|
+
## 💡 What is YINI?
|
|
21
|
+
- **Simple like INI** — but with strong typing, comments, and nested sections.
|
|
22
|
+
- **Easy to read and write** — minimal syntax noise, maximum clarity.
|
|
23
|
+
- **Clear, minimal section nesting** — no painful indentation or long dot-delimited keys.
|
|
24
|
+
- **Supports strict and lenient modes**, and all major data types.
|
|
25
|
+
- Both **human-friendly** and **machine-friendly**.
|
|
26
|
+
- 👉 See [how YINI compares to JSON, YAML, INI, and TOML](https://github.com/YINI-lang/yini-parser-typescript/tree/main/examples/compare-formats.md).
|
|
27
|
+
- Want the full syntax reference? See the [YINI Specification](https://github.com/YINI-lang/YINI-spec).
|
|
28
|
+
|
|
29
|
+
---
|
|
30
|
+
|
|
31
|
+
## Usage
|
|
32
|
+
|
|
33
|
+
### 📤 Output Modes for `yini parse`
|
|
34
|
+
|
|
35
|
+
The `parse` command supports multiple output styles:
|
|
36
|
+
|
|
37
|
+
| Command Example | Output Style | Description |
|
|
38
|
+
|----------------------------------------------------|----------------------|------------------------------------------------------------------------------|
|
|
39
|
+
| `yini parse config.yini` | JS-style object | Uses Node’s `util.inspect` — human-readable, shows types, nesting, etc. |
|
|
40
|
+
| `yini parse config.yini --pretty` | Pretty JSON | Formatted and indented with `JSON.stringify(obj, null, 4)`. |
|
|
41
|
+
| `yini parse config.yini --log` | Console log | Uses `console.log` — quick output but may truncate deep structures. |
|
|
42
|
+
| `yini parse config.yini --json` | Compact JSON | Compact and machine-friendly `JSON.stringify(obj)`. |
|
|
43
|
+
| `yini parse config.yini --output out.txt` | File (JS-style) | Default style, written to specified file. |
|
|
44
|
+
| `yini parse config.yini --pretty --output out.json`| File (Pretty JSON) | Formatted JSON written to file. |
|
|
45
|
+
|
|
46
|
+
>💡 Tip: You can combine --output with any style flag to control both formatting and destination.
|
|
47
|
+
|
|
48
|
+
---
|
|
49
|
+
|
|
50
|
+
## Links
|
|
51
|
+
- ➡️ [Why YINI? Why another format!?](https://github.com/YINI-lang/YINI-spec/blob/develop/RATIONALE.md) (rationale)
|
|
52
|
+
- ➡️ [Intro to YINI Config Format](https://github.com/YINI-lang/yini-parser-typescript?tab=readme-ov-file#intro-to-yini-config-format) (learn YINI)
|
|
53
|
+
- ➡️ [Read the YINI Specification](https://github.com/YINI-lang/YINI-spec/blob/develop/YINI-Specification.md#table-of-contents) (spec)
|
|
54
|
+
- ➡️ [Official YINI Parser on npm](https://www.npmjs.com/package/yini-parser) (npm)
|
|
55
|
+
- ➡️ [YINI Parser GitHub Repo](https://github.com/YINI-lang/yini-parser-typescript) (GitHub)
|
|
56
|
+
- ➡️ [YINI vs Other Formats](https://github.com/YINI-lang/YINI-spec/blob/develop/Docs/Examples%20of%20YINI%20vs%20Other%20Formats.md)
|
|
57
|
+
- ➡️ [YINI Project](https://github.com/YINI-lang) (home)
|
|
58
|
+
|
|
59
|
+
---
|
|
60
|
+
|
|
61
|
+
## License
|
|
62
|
+
This project is licensed under the Apache-2.0 license - see the [LICENSE](<./LICENSE>) file for details.
|
|
63
|
+
|
|
64
|
+
In this project on GitHub, the `libs` directory contains third party software and each is licensed under its own license which is described in its own license file under the respective directory under `libs`.
|
|
65
|
+
|
|
66
|
+
---
|
|
67
|
+
|
|
68
|
+
~ **YINI ≡** • [https://yini-lang.org](https://yini-lang.org)
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const printInfo: () => void;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* NODE_ENV - Defacto Node.js modes (environments)
|
|
3
|
+
*
|
|
4
|
+
* Used in many JS frameworks and tools, for special purposes.
|
|
5
|
+
* Some even only know 'production' and treat everything else as 'development'.
|
|
6
|
+
* Also Jest sets NODE_ENV automatically to 'test'.
|
|
7
|
+
*/
|
|
8
|
+
type TNodeEnv = 'development' | 'production' | 'test';
|
|
9
|
+
/**
|
|
10
|
+
* APP_ENV - More custom envs (more finer-grained control) for this project.
|
|
11
|
+
* @note Since this is a library (as opposed to a Web/App), we don't use "staging".
|
|
12
|
+
*/
|
|
13
|
+
type TAppEnv = 'local' | 'ci' | 'production';
|
|
14
|
+
declare const localNodeEnv: TNodeEnv;
|
|
15
|
+
declare const localAppEnv: TAppEnv;
|
|
16
|
+
/** Are we running in the environment "development"? Will be based on the (global) environment variable process.env.NODE_ENV. */
|
|
17
|
+
export declare const isDevEnv: () => boolean;
|
|
18
|
+
/** Are we running in the environment "production"? Will be based on the (global) environment variable process.env.NODE_ENV. */
|
|
19
|
+
export declare const isProdEnv: () => boolean;
|
|
20
|
+
/** Are we running in the environment "test"? Will be based on the (global) variable process.env.NODE_ENV. */
|
|
21
|
+
export declare const isTestEnv: () => boolean;
|
|
22
|
+
/** Will be based on the local argument when this process was launched.
|
|
23
|
+
* @returns True if the DEV flag is set.
|
|
24
|
+
* @example npm run start -- isDev=1
|
|
25
|
+
* @example node dist/index.js isDev=1
|
|
26
|
+
*/
|
|
27
|
+
export declare const isDev: () => boolean;
|
|
28
|
+
/** Will be based on the local argument when this process was launched.
|
|
29
|
+
* @returns True if the DEBUG flag is set.
|
|
30
|
+
* @example npm run start -- isDebug=1
|
|
31
|
+
* @example node dist/index.js isDebug=1
|
|
32
|
+
*/
|
|
33
|
+
export declare const isDebug: () => boolean;
|
|
34
|
+
export { localNodeEnv, localAppEnv };
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// (!) NOTE: Leave above shebang as first line!
|
|
3
|
+
// import pkg from '../package.json'
|
|
4
|
+
import { createRequire } from 'module';
|
|
5
|
+
import { Command } from 'commander';
|
|
6
|
+
import { printInfo } from './commands/info.js';
|
|
7
|
+
import { parseFile } from './commands/parse.js';
|
|
8
|
+
import { validateFile } from './commands/validate.js';
|
|
9
|
+
import { isDebug } from './config/env.js';
|
|
10
|
+
import { descriptions as descripts } from './descriptions.js';
|
|
11
|
+
import { debugPrint, toPrettyJSON } from './utils/print.js';
|
|
12
|
+
const require = createRequire(import.meta.url);
|
|
13
|
+
const pkg = require('../package.json');
|
|
14
|
+
const program = new Command();
|
|
15
|
+
/*
|
|
16
|
+
|
|
17
|
+
Idea/suggestion
|
|
18
|
+
yini [parse] [--strict] [--pretty] [--output]
|
|
19
|
+
|
|
20
|
+
Current suggestion:
|
|
21
|
+
* yini parse config.yini
|
|
22
|
+
JS-style object using printObject()
|
|
23
|
+
to stdout
|
|
24
|
+
* yini parse config.yini --pretty
|
|
25
|
+
Pretty JSON using JSON.stringify(obj, null, 4)
|
|
26
|
+
to stdout
|
|
27
|
+
* yini parse config.yini --output out.txt
|
|
28
|
+
JS-style object
|
|
29
|
+
to out.txt
|
|
30
|
+
* yini parse config.yini --pretty --output out.json
|
|
31
|
+
Pretty JSON
|
|
32
|
+
to out.json
|
|
33
|
+
|
|
34
|
+
New suggestion:
|
|
35
|
+
Current suggestion:
|
|
36
|
+
* yini parse config.yini
|
|
37
|
+
JS-style object using printObject(obj) (using using util.inspect)
|
|
38
|
+
to stdout
|
|
39
|
+
* yini parse config.yini --pretty
|
|
40
|
+
Pretty JSON using JSON.stringify(obj, null, 4) (formatted, readable)
|
|
41
|
+
to stdout
|
|
42
|
+
* yini parse config.yini --log
|
|
43
|
+
Intended for quick output using console.log (nested object may get compacted/abbreviate)
|
|
44
|
+
to stdout
|
|
45
|
+
* yini parse config.yini --json
|
|
46
|
+
Stringigies JSON using using JSON.stringify(obj) (compact, machine-parseable)
|
|
47
|
+
to stdout
|
|
48
|
+
* yini parse config.yini --output out.txt
|
|
49
|
+
JS-style object
|
|
50
|
+
to out.txt
|
|
51
|
+
* yini parse config.yini --pretty --output out.json
|
|
52
|
+
Pretty JSON
|
|
53
|
+
to out.json
|
|
54
|
+
|
|
55
|
+
*/
|
|
56
|
+
// Display help for command
|
|
57
|
+
program.name('yini').description(descripts.yini).version(pkg.version);
|
|
58
|
+
program.addHelpText('before', `YINI CLI (Yet another INI)
|
|
59
|
+
|
|
60
|
+
For parsing and validating YINI configuration files.
|
|
61
|
+
A human-friendly config format - like INI, but with type-safe values,
|
|
62
|
+
nested sections, comments, minimal syntax noise, and optional strict mode.
|
|
63
|
+
|
|
64
|
+
Crafted for clarity, consistency, and the simple joy of it. :)`);
|
|
65
|
+
program.addHelpText('after', `
|
|
66
|
+
Examples:
|
|
67
|
+
$ yini parse config.yini
|
|
68
|
+
$ yini validate config.yini --strict
|
|
69
|
+
$ yini parse config.yini --pretty --output out.json
|
|
70
|
+
|
|
71
|
+
More info: https://github.com/YINI-lang/yini-parser
|
|
72
|
+
`);
|
|
73
|
+
//program.command('help [command]').description('Display help for command')
|
|
74
|
+
// Command info
|
|
75
|
+
program
|
|
76
|
+
.command('info')
|
|
77
|
+
// .command('')
|
|
78
|
+
.description(descripts['For-command-info'])
|
|
79
|
+
// .option('info')
|
|
80
|
+
.action((options) => {
|
|
81
|
+
debugPrint('Run command "info"');
|
|
82
|
+
if (isDebug()) {
|
|
83
|
+
console.log('options:');
|
|
84
|
+
console.log(toPrettyJSON(options));
|
|
85
|
+
}
|
|
86
|
+
printInfo();
|
|
87
|
+
});
|
|
88
|
+
/**
|
|
89
|
+
*
|
|
90
|
+
* Maybe later, to as default command: parse <parse>
|
|
91
|
+
*/
|
|
92
|
+
// program
|
|
93
|
+
// .argument('<file>', 'File to parse')
|
|
94
|
+
// .option('--strict', 'Parse YINI in strict-mode')
|
|
95
|
+
// .option('--pretty', 'Pretty-print output as JSON')
|
|
96
|
+
// // .option('--log', 'Use console.log output format (compact, quick view)')
|
|
97
|
+
// .option('--json', 'Compact JSON output using JSON.stringify')
|
|
98
|
+
// .option('--output <file>', 'Write output to a specified file')
|
|
99
|
+
// .action((file, options) => {
|
|
100
|
+
// if (file) {
|
|
101
|
+
// parseFile(file, options)
|
|
102
|
+
// } else {
|
|
103
|
+
// program.help()
|
|
104
|
+
// }
|
|
105
|
+
// })
|
|
106
|
+
// Explicit "parse" command
|
|
107
|
+
program
|
|
108
|
+
.command('parse <file>')
|
|
109
|
+
.description(descripts['For-command-parse'])
|
|
110
|
+
.option('--strict', 'Parse YINI in strict-mode')
|
|
111
|
+
.option('--pretty', 'Pretty-print output as JSON')
|
|
112
|
+
// .option('--log', 'Use console.log output format (compact, quick view)')
|
|
113
|
+
.option('--json', 'Compact JSON output using JSON.stringify')
|
|
114
|
+
.option('--output <file>', 'Write output to a specified file')
|
|
115
|
+
.action((file, options) => {
|
|
116
|
+
debugPrint('Run command "parse"');
|
|
117
|
+
debugPrint(`<file> = ${file}`);
|
|
118
|
+
if (isDebug()) {
|
|
119
|
+
console.log('options:');
|
|
120
|
+
console.log(toPrettyJSON(options));
|
|
121
|
+
}
|
|
122
|
+
if (file) {
|
|
123
|
+
parseFile(file, options);
|
|
124
|
+
}
|
|
125
|
+
else {
|
|
126
|
+
program.help();
|
|
127
|
+
}
|
|
128
|
+
});
|
|
129
|
+
/**
|
|
130
|
+
* To handle command validate, e.g.:
|
|
131
|
+
* yini validate config.yini
|
|
132
|
+
* yini validate config.yini --strict
|
|
133
|
+
* yini validate config.yini --details
|
|
134
|
+
* yini validate config.yini --silent
|
|
135
|
+
*
|
|
136
|
+
* If details:
|
|
137
|
+
* Details:
|
|
138
|
+
* - YINI version: 1.0.0-beta.6
|
|
139
|
+
* - Mode: strict
|
|
140
|
+
* - Keys: 42
|
|
141
|
+
* - Sections: 6
|
|
142
|
+
* - Nesting depth: 3
|
|
143
|
+
* - Has @yini: true
|
|
144
|
+
*/
|
|
145
|
+
program
|
|
146
|
+
.command('validate <file>')
|
|
147
|
+
.description(descripts['For-command-validate'])
|
|
148
|
+
.option('--strict', 'Enable parsing in strict-mode')
|
|
149
|
+
.option('--details', 'Print detailed meta-data info (e.g., key count, nesting, etc.)')
|
|
150
|
+
.option('--silent', 'Suppress output')
|
|
151
|
+
.action((file, options) => {
|
|
152
|
+
//@todo add debugPrint
|
|
153
|
+
if (file) {
|
|
154
|
+
validateFile(file, options);
|
|
155
|
+
}
|
|
156
|
+
else {
|
|
157
|
+
program.help();
|
|
158
|
+
}
|
|
159
|
+
});
|
|
160
|
+
// NOTE: Converting YINI files to other formats than json and js.
|
|
161
|
+
// Other format should go into a new CLI-command called 'yini-convert'.
|
|
162
|
+
program.parseAsync();
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export declare const debugPrint: (str?: any) => void;
|
|
2
|
+
export declare const devPrint: (str?: any) => void;
|
|
3
|
+
export declare const toJSON: (obj: any) => string;
|
|
4
|
+
export declare const toPrettyJSON: (obj: any) => string;
|
|
5
|
+
/** Pretty-prints a JavaScript object as formatted JSON to the console.
|
|
6
|
+
* Strict JSON, all keys are enclosed in ", etc.
|
|
7
|
+
*/
|
|
8
|
+
export declare const printJSON: (obj: any) => void;
|
|
9
|
+
/**
|
|
10
|
+
* Print a full JavaScript object in a human-readable way (not as JSON).
|
|
11
|
+
* Not strict JSON, and shows functions, symbols, getters/setters, and class names.
|
|
12
|
+
* @param isColors If true, the output is styled with ANSI color codes.
|
|
13
|
+
*/
|
|
14
|
+
export declare const printObject: (obj: any, isColors?: boolean) => void;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# Contributing
|
|
2
|
+
|
|
3
|
+
- First things first: welcome!
|
|
4
|
+
- Feedback, bug reports, suggestions, or even a bit of roasting are all welcome.
|
|
5
|
+
- Feel free to open a [discussion](https://github.com/YINI-lang/yini-cli/discussions) or [issue](https://github.com/YINI-lang/yini-cli/issues).
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
Even though `yini-cli` is in beta, your feedback, suggestions, and contributions are **highly valued**.
|
|
10
|
+
|
|
11
|
+
If you find any bugs, errors or other issues in the YINI parser, if something doesn't work as you expect, or you have other ideas—please make a new issue!
|
|
12
|
+
|
|
13
|
+
## Quick Start
|
|
14
|
+
|
|
15
|
+
Head over to the [Project-Setup](./project-setup.md).
|
|
16
|
+
|
|
17
|
+
## Submitting Changes
|
|
18
|
+
|
|
19
|
+
Of course, you are free to fork this repo and mess around with it. 😄
|
|
20
|
+
Did you write a patch that fixes a bug, adds a new feature or implenting test cases in tests? Thank you!
|
|
21
|
+
|
|
22
|
+
- Open a pull request (PR) against the `main` branch (make sure all tests pass by running `npm run test`).
|
|
23
|
+
- Name the branch using one of the following prefixes:
|
|
24
|
+
* `fix/` for bug fixes.
|
|
25
|
+
* `update/` for updates to docs or data.
|
|
26
|
+
* `feature/` for new features.
|
|
27
|
+
|
|
28
|
+
**Before submitting a PR, it's a good idea to create an issue to discuss your changes—so your PR is less likely to be wasted!** 🙂
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# Project Setup
|
|
2
|
+
|
|
3
|
+
Here you'll find some info for install/setup/directory structure.
|
|
4
|
+
|
|
5
|
+
## Project Setup
|
|
6
|
+
- Source in TypeScript.
|
|
7
|
+
- In full ESM (ECMAScript Modules) (as opposed to CommonJS).
|
|
8
|
+
- Commander
|
|
9
|
+
- Vitest (good for ESM and TypeScript)
|
|
10
|
+
- GitHub Actions (CI/CD)
|
|
11
|
+
- ESLint (code style / linting)
|
|
12
|
+
|
|
13
|
+
## Project Dir Structure
|
|
14
|
+
```txt
|
|
15
|
+
yini-cli/
|
|
16
|
+
├── bin/
|
|
17
|
+
│ └── yini.js # CLI entry point
|
|
18
|
+
├── src/
|
|
19
|
+
│ ├── commands/
|
|
20
|
+
│ │ └── parse.ts
|
|
21
|
+
│ │ └── validate.ts
|
|
22
|
+
│ │ └── convert.ts
|
|
23
|
+
│ └── index.ts
|
|
24
|
+
├── tests/
|
|
25
|
+
│ ├── smoke.test.ts
|
|
26
|
+
│ └── fixtures/
|
|
27
|
+
├── package.json
|
|
28
|
+
├── tsconfig.json
|
|
29
|
+
├── vitest.config.ts
|
|
30
|
+
└── README.md
|
|
31
|
+
```
|
|
32
|
+
|
package/eslint.config.js
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import prettier from 'eslint-config-prettier'
|
|
2
|
+
import js from '@eslint/js'
|
|
3
|
+
import tseslint from '@typescript-eslint/eslint-plugin'
|
|
4
|
+
import tsparser from '@typescript-eslint/parser'
|
|
5
|
+
|
|
6
|
+
export default [
|
|
7
|
+
js.configs.recommended,
|
|
8
|
+
{
|
|
9
|
+
files: ['**/*.ts', '**/*.tsx'],
|
|
10
|
+
languageOptions: {
|
|
11
|
+
parser: tsparser,
|
|
12
|
+
parserOptions: {
|
|
13
|
+
project: './tsconfig.json',
|
|
14
|
+
},
|
|
15
|
+
// Add these lines:
|
|
16
|
+
globals: {
|
|
17
|
+
console: 'readonly',
|
|
18
|
+
process: 'readonly',
|
|
19
|
+
module: 'readonly',
|
|
20
|
+
__dirname: 'readonly',
|
|
21
|
+
require: 'readonly',
|
|
22
|
+
Buffer: 'readonly',
|
|
23
|
+
// add more Node.js globals if you use them
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
plugins: {
|
|
27
|
+
'@typescript-eslint': tseslint,
|
|
28
|
+
},
|
|
29
|
+
rules: {
|
|
30
|
+
...tseslint.configs.recommended.rules,
|
|
31
|
+
// Your custom rules here
|
|
32
|
+
'@typescript-eslint/no-explicit-any': 'off',
|
|
33
|
+
'@typescript-eslint/no-unused-vars': 'off',
|
|
34
|
+
'no-undef': 'off',
|
|
35
|
+
'no-unused-expressions': 'off',
|
|
36
|
+
'@typescript-eslint/no-unused-expressions': 'off',
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
prettier,
|
|
40
|
+
]
|
package/package.json
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "yini-cli",
|
|
3
|
+
"version": "1.0.0-alpha.2",
|
|
4
|
+
"description": "CLI for parsing and validating YINI config files: type-safe values, nested sections, comments, minimal syntax noise, and optional strict mode.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"yini",
|
|
7
|
+
"cli",
|
|
8
|
+
"config",
|
|
9
|
+
"configuration",
|
|
10
|
+
"parser",
|
|
11
|
+
"validator",
|
|
12
|
+
"ini",
|
|
13
|
+
"ini alternative",
|
|
14
|
+
"json",
|
|
15
|
+
"type-safe",
|
|
16
|
+
"nested sections",
|
|
17
|
+
"command-line",
|
|
18
|
+
"strict mode",
|
|
19
|
+
"nodejs",
|
|
20
|
+
"typescript"
|
|
21
|
+
],
|
|
22
|
+
"type": "module",
|
|
23
|
+
"main": "dist/index.js",
|
|
24
|
+
"exports": {
|
|
25
|
+
".": {
|
|
26
|
+
"import": "./dist/index.js"
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
"bin": {
|
|
30
|
+
"yini": "./dist/index.js"
|
|
31
|
+
},
|
|
32
|
+
"homepage": "https://github.com/YINI-lang",
|
|
33
|
+
"license": "Apache-2.0",
|
|
34
|
+
"repository": {
|
|
35
|
+
"type": "git",
|
|
36
|
+
"url": "https://github.com/YINI-lang/yini-cli.git"
|
|
37
|
+
},
|
|
38
|
+
"private": false,
|
|
39
|
+
"scripts": {
|
|
40
|
+
"start": "node ./bin/yini.js",
|
|
41
|
+
"start:dev": "cross-env NODE_ENV=development isDev=1 tsx src/index.ts",
|
|
42
|
+
"start:dev:debug": "cross-env isDebug=1 npm run start:dev",
|
|
43
|
+
"run:version": "npm run start -- --version",
|
|
44
|
+
"run:info": "npm run start -- info",
|
|
45
|
+
"run:parse": "npm run start -- parse sample.yini",
|
|
46
|
+
"test:smoke": "vitest tests/smoke",
|
|
47
|
+
"test:general": "vitest tests/general",
|
|
48
|
+
"test": "vitest run",
|
|
49
|
+
"test:debug": "cross-env isDebug=1 vitest run --reporter=verbose",
|
|
50
|
+
"test:general:debug": "cross-env isDebug=1 npm run test:general",
|
|
51
|
+
"test:watch": "vitest --watch",
|
|
52
|
+
"ci:test": "vitest run --reporter=verbose",
|
|
53
|
+
"ci:test:smoke": "vitest run tests/smoke --reporter=verbose",
|
|
54
|
+
"lint": "eslint src --ext .ts",
|
|
55
|
+
"format": "prettier --check .",
|
|
56
|
+
"format:fix": "prettier --write .",
|
|
57
|
+
"build": "tsc",
|
|
58
|
+
"clean": "rm -rf dist",
|
|
59
|
+
"prepare": "npm run build",
|
|
60
|
+
"prepublishOnly": "npm run lint && npm test && npm run build"
|
|
61
|
+
},
|
|
62
|
+
"author": "Marko K. Seppänen",
|
|
63
|
+
"dependencies": {
|
|
64
|
+
"commander": "^11.0.0",
|
|
65
|
+
"yini-parser": "^1.0.1-beta"
|
|
66
|
+
},
|
|
67
|
+
"devDependencies": {
|
|
68
|
+
"@eslint/js": "^9.31.0",
|
|
69
|
+
"@ianvs/prettier-plugin-sort-imports": "^4.4.2",
|
|
70
|
+
"@types/node": "^22.15.3",
|
|
71
|
+
"@typescript-eslint/eslint-plugin": "^8.37.0",
|
|
72
|
+
"@typescript-eslint/parser": "^8.37.0",
|
|
73
|
+
"cross-env": "^7.0.3",
|
|
74
|
+
"eslint": "^9.31.0",
|
|
75
|
+
"eslint-config-prettier": "^10.1.5",
|
|
76
|
+
"eslint-plugin-prettier": "^5.4.0",
|
|
77
|
+
"execa": "^9.6.0",
|
|
78
|
+
"husky": "^9.1.7",
|
|
79
|
+
"lint-staged": "^16.0.0",
|
|
80
|
+
"prettier": "^3.5.3",
|
|
81
|
+
"tsx": "^4.7.0",
|
|
82
|
+
"typescript": "^5.8.3",
|
|
83
|
+
"vitest": "^3.2.4"
|
|
84
|
+
},
|
|
85
|
+
"lint-staged": {
|
|
86
|
+
"src/**/*.{js,jsx,json,ts,tsx,css,scss}": [
|
|
87
|
+
"prettier --config ./.prettierrc --write"
|
|
88
|
+
]
|
|
89
|
+
},
|
|
90
|
+
"engines": {
|
|
91
|
+
"node": ">=13"
|
|
92
|
+
}
|
|
93
|
+
}
|