@kristijorgji/cli-kit 0.1.0
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 +21 -0
- package/README.md +24 -0
- package/dist/cli-logger.d.ts +8 -0
- package/dist/cli-logger.d.ts.map +1 -0
- package/dist/cli-logger.js +28 -0
- package/dist/cli-logger.js.map +1 -0
- package/dist/cli-table.d.ts +3 -0
- package/dist/cli-table.d.ts.map +1 -0
- package/dist/cli-table.js +5 -0
- package/dist/cli-table.js.map +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -0
- package/dist/run-command.d.ts +5 -0
- package/dist/run-command.d.ts.map +1 -0
- package/dist/run-command.js +12 -0
- package/dist/run-command.js.map +1 -0
- package/package.json +47 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 kristijorgji
|
|
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
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# @kristijorgji/cli-kit
|
|
2
|
+
|
|
3
|
+
Shared CLI primitives for `@kristijorgji` tooling: a pino-pretty logger, a table printer, and a `spawnSync` wrapper.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
pnpm add -D @kristijorgji/cli-kit
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
```ts
|
|
14
|
+
import { cliLogger, cliTable, logFatalAndExit, runCommand } from '@kristijorgji/cli-kit';
|
|
15
|
+
|
|
16
|
+
cliLogger.info('starting');
|
|
17
|
+
cliTable([{ Name: 'framework', SizeKB: 58 }]);
|
|
18
|
+
runCommand('pnpm', ['exec', 'size-limit'], { cwd: process.cwd() });
|
|
19
|
+
logFatalAndExit('unrecoverable');
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## License
|
|
23
|
+
|
|
24
|
+
MIT
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Logger } from 'pino';
|
|
2
|
+
import 'pino-pretty';
|
|
3
|
+
export declare function createCliLogger(level?: string): Logger;
|
|
4
|
+
/** Default logger for scripts that do not load a custom log level from env. */
|
|
5
|
+
export declare const cliLogger: Logger;
|
|
6
|
+
export declare function logFatalAndExit(msg: string): never;
|
|
7
|
+
export declare function logFatalAndExitFromError(err: unknown): never;
|
|
8
|
+
//# sourceMappingURL=cli-logger.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli-logger.d.ts","sourceRoot":"","sources":["../src/cli-logger.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAEnC,OAAO,aAAa,CAAC;AAUrB,wBAAgB,eAAe,CAAC,KAAK,SAAS,GAAG,MAAM,CAQtD;AAED,+EAA+E;AAC/E,eAAO,MAAM,SAAS,QAAoB,CAAC;AAE3C,wBAAgB,eAAe,CAAC,GAAG,EAAE,MAAM,GAAG,KAAK,CAGlD;AAED,wBAAgB,wBAAwB,CAAC,GAAG,EAAE,OAAO,GAAG,KAAK,CAE5D"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import pino from 'pino';
|
|
2
|
+
import 'pino-pretty';
|
|
3
|
+
const CLI_PRETTY_OPTIONS = {
|
|
4
|
+
colorize: true,
|
|
5
|
+
levelFirst: true,
|
|
6
|
+
translateTime: 'SYS:HH:MM:ss.l',
|
|
7
|
+
ignore: 'pid,hostname',
|
|
8
|
+
hideObject: true,
|
|
9
|
+
};
|
|
10
|
+
export function createCliLogger(level = 'info') {
|
|
11
|
+
return pino({
|
|
12
|
+
level,
|
|
13
|
+
transport: {
|
|
14
|
+
target: 'pino-pretty',
|
|
15
|
+
options: CLI_PRETTY_OPTIONS,
|
|
16
|
+
},
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
/** Default logger for scripts that do not load a custom log level from env. */
|
|
20
|
+
export const cliLogger = createCliLogger();
|
|
21
|
+
export function logFatalAndExit(msg) {
|
|
22
|
+
cliLogger.error(msg);
|
|
23
|
+
process.exit(1);
|
|
24
|
+
}
|
|
25
|
+
export function logFatalAndExitFromError(err) {
|
|
26
|
+
logFatalAndExit(err instanceof Error ? err.message : String(err));
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=cli-logger.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli-logger.js","sourceRoot":"","sources":["../src/cli-logger.ts"],"names":[],"mappings":"AACA,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,aAAa,CAAC;AAErB,MAAM,kBAAkB,GAAG;IACvB,QAAQ,EAAE,IAAI;IACd,UAAU,EAAE,IAAI;IAChB,aAAa,EAAE,gBAAgB;IAC/B,MAAM,EAAE,cAAc;IACtB,UAAU,EAAE,IAAI;CACV,CAAC;AAEX,MAAM,UAAU,eAAe,CAAC,KAAK,GAAG,MAAM;IAC1C,OAAO,IAAI,CAAC;QACR,KAAK;QACL,SAAS,EAAE;YACP,MAAM,EAAE,aAAa;YACrB,OAAO,EAAE,kBAAkB;SAC9B;KACJ,CAAC,CAAC;AACP,CAAC;AAED,+EAA+E;AAC/E,MAAM,CAAC,MAAM,SAAS,GAAG,eAAe,EAAE,CAAC;AAE3C,MAAM,UAAU,eAAe,CAAC,GAAW;IACvC,SAAS,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IACrB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AACpB,CAAC;AAED,MAAM,UAAU,wBAAwB,CAAC,GAAY;IACjD,eAAe,CAAC,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC;AACtE,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli-table.d.ts","sourceRoot":"","sources":["../src/cli-table.ts"],"names":[],"mappings":"AAAA,kFAAkF;AAClF,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,GAAG,IAAI,CAE9D"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli-table.js","sourceRoot":"","sources":["../src/cli-table.ts"],"names":[],"mappings":"AAAA,kFAAkF;AAClF,MAAM,UAAU,QAAQ,CAAC,IAA+B;IACpD,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;AACxB,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,eAAe,EAAE,wBAAwB,EAAE,MAAM,iBAAiB,CAAC;AACxG,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,eAAe,EAAE,wBAAwB,EAAE,MAAM,iBAAiB,CAAC;AACxG,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"run-command.d.ts","sourceRoot":"","sources":["../src/run-command.ts"],"names":[],"mappings":"AAEA,wBAAgB,UAAU,CACtB,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,MAAM,EAAE,EACd,OAAO,GAAE;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAA;CAA2B,GAC5F,IAAI,CASN"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { spawnSync } from 'node:child_process';
|
|
2
|
+
export function runCommand(command, args, options = { cwd: process.cwd() }) {
|
|
3
|
+
const result = spawnSync(command, args, {
|
|
4
|
+
cwd: options.cwd,
|
|
5
|
+
stdio: 'inherit',
|
|
6
|
+
env: { ...process.env, ...options.env },
|
|
7
|
+
});
|
|
8
|
+
if (result.status !== 0) {
|
|
9
|
+
process.exit(result.status ?? 1);
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=run-command.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"run-command.js","sourceRoot":"","sources":["../src/run-command.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAE/C,MAAM,UAAU,UAAU,CACtB,OAAe,EACf,IAAc,EACd,UAAqE,EAAE,GAAG,EAAE,OAAO,CAAC,GAAG,EAAE,EAAE;IAE3F,MAAM,MAAM,GAAG,SAAS,CAAC,OAAO,EAAE,IAAI,EAAE;QACpC,GAAG,EAAE,OAAO,CAAC,GAAG;QAChB,KAAK,EAAE,SAAS;QAChB,GAAG,EAAE,EAAE,GAAG,OAAO,CAAC,GAAG,EAAE,GAAG,OAAO,CAAC,GAAG,EAAE;KAC1C,CAAC,CAAC;IACH,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACtB,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,IAAI,CAAC,CAAC,CAAC;IACrC,CAAC;AACL,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@kristijorgji/cli-kit",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Shared CLI primitives: pino-pretty logger, table printer, spawn wrapper",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"author": "kristijorgji",
|
|
8
|
+
"engines": {
|
|
9
|
+
"node": ">=22.16.0"
|
|
10
|
+
},
|
|
11
|
+
"publishConfig": {
|
|
12
|
+
"access": "public",
|
|
13
|
+
"provenance": true
|
|
14
|
+
},
|
|
15
|
+
"repository": {
|
|
16
|
+
"type": "git",
|
|
17
|
+
"url": "git+https://github.com/kristijorgji/js-devkit.git",
|
|
18
|
+
"directory": "packages/cli-kit"
|
|
19
|
+
},
|
|
20
|
+
"files": [
|
|
21
|
+
"dist",
|
|
22
|
+
"README.md",
|
|
23
|
+
"LICENSE"
|
|
24
|
+
],
|
|
25
|
+
"exports": {
|
|
26
|
+
".": {
|
|
27
|
+
"types": "./dist/index.d.ts",
|
|
28
|
+
"import": "./dist/index.js"
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
"types": "./dist/index.d.ts",
|
|
32
|
+
"scripts": {
|
|
33
|
+
"build": "tsc -p tsconfig.json",
|
|
34
|
+
"typecheck": "tsc -p tsconfig.json --noEmit",
|
|
35
|
+
"test": "vitest run",
|
|
36
|
+
"test:watch": "vitest"
|
|
37
|
+
},
|
|
38
|
+
"dependencies": {
|
|
39
|
+
"pino": "^9",
|
|
40
|
+
"pino-pretty": "^13"
|
|
41
|
+
},
|
|
42
|
+
"devDependencies": {
|
|
43
|
+
"@types/node": "^26",
|
|
44
|
+
"typescript": "^5",
|
|
45
|
+
"vitest": "^4"
|
|
46
|
+
}
|
|
47
|
+
}
|