@gojinko/cli 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/SKILL.md +108 -0
- package/dist/bin/jinko.d.ts +3 -0
- package/dist/bin/jinko.d.ts.map +1 -0
- package/dist/bin/jinko.js +8 -0
- package/dist/bin/jinko.js.map +1 -0
- package/dist/commands/auth/index.d.ts +3 -0
- package/dist/commands/auth/index.d.ts.map +1 -0
- package/dist/commands/auth/index.js +74 -0
- package/dist/commands/auth/index.js.map +1 -0
- package/dist/commands/config/index.d.ts +3 -0
- package/dist/commands/config/index.d.ts.map +1 -0
- package/dist/commands/config/index.js +32 -0
- package/dist/commands/config/index.js.map +1 -0
- package/dist/commands/flights/calendar.d.ts +3 -0
- package/dist/commands/flights/calendar.d.ts.map +1 -0
- package/dist/commands/flights/calendar.js +45 -0
- package/dist/commands/flights/calendar.js.map +1 -0
- package/dist/commands/flights/destinations.d.ts +3 -0
- package/dist/commands/flights/destinations.d.ts.map +1 -0
- package/dist/commands/flights/destinations.js +39 -0
- package/dist/commands/flights/destinations.js.map +1 -0
- package/dist/commands/flights/index.d.ts +3 -0
- package/dist/commands/flights/index.d.ts.map +1 -0
- package/dist/commands/flights/index.js +12 -0
- package/dist/commands/flights/index.js.map +1 -0
- package/dist/commands/flights/search.d.ts +3 -0
- package/dist/commands/flights/search.d.ts.map +1 -0
- package/dist/commands/flights/search.js +61 -0
- package/dist/commands/flights/search.js.map +1 -0
- package/dist/commands/schema.d.ts +3 -0
- package/dist/commands/schema.d.ts.map +1 -0
- package/dist/commands/schema.js +113 -0
- package/dist/commands/schema.js.map +1 -0
- package/dist/commands/shared.d.ts +16 -0
- package/dist/commands/shared.d.ts.map +1 -0
- package/dist/commands/shared.js +45 -0
- package/dist/commands/shared.js.map +1 -0
- package/dist/commands/travelers/index.d.ts +3 -0
- package/dist/commands/travelers/index.d.ts.map +1 -0
- package/dist/commands/travelers/index.js +118 -0
- package/dist/commands/travelers/index.js.map +1 -0
- package/dist/commands/trip/add-flight.d.ts +3 -0
- package/dist/commands/trip/add-flight.d.ts.map +1 -0
- package/dist/commands/trip/add-flight.js +22 -0
- package/dist/commands/trip/add-flight.js.map +1 -0
- package/dist/commands/trip/checkout.d.ts +3 -0
- package/dist/commands/trip/checkout.d.ts.map +1 -0
- package/dist/commands/trip/checkout.js +59 -0
- package/dist/commands/trip/checkout.js.map +1 -0
- package/dist/commands/trip/create.d.ts +3 -0
- package/dist/commands/trip/create.d.ts.map +1 -0
- package/dist/commands/trip/create.js +14 -0
- package/dist/commands/trip/create.js.map +1 -0
- package/dist/commands/trip/index.d.ts +3 -0
- package/dist/commands/trip/index.d.ts.map +1 -0
- package/dist/commands/trip/index.js +16 -0
- package/dist/commands/trip/index.js.map +1 -0
- package/dist/commands/trip/remove.d.ts +3 -0
- package/dist/commands/trip/remove.d.ts.map +1 -0
- package/dist/commands/trip/remove.js +19 -0
- package/dist/commands/trip/remove.js.map +1 -0
- package/dist/commands/trip/show.d.ts +3 -0
- package/dist/commands/trip/show.d.ts.map +1 -0
- package/dist/commands/trip/show.js +17 -0
- package/dist/commands/trip/show.js.map +1 -0
- package/dist/commands/trip/travelers.d.ts +3 -0
- package/dist/commands/trip/travelers.d.ts.map +1 -0
- package/dist/commands/trip/travelers.js +37 -0
- package/dist/commands/trip/travelers.js.map +1 -0
- package/dist/config/config.d.ts +12 -0
- package/dist/config/config.d.ts.map +1 -0
- package/dist/config/config.js +12 -0
- package/dist/config/config.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +23 -0
- package/dist/index.js.map +1 -0
- package/dist/output/formatter.d.ts +19 -0
- package/dist/output/formatter.d.ts.map +1 -0
- package/dist/output/formatter.js +77 -0
- package/dist/output/formatter.js.map +1 -0
- package/package.json +40 -0
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import chalk from 'chalk';
|
|
2
|
+
/**
|
|
3
|
+
* Print data in the requested format. JSON is the default (agent-friendly).
|
|
4
|
+
* Table format is for human consumption.
|
|
5
|
+
*/
|
|
6
|
+
export function output(data, options) {
|
|
7
|
+
if (options.format === 'table') {
|
|
8
|
+
outputTable(data);
|
|
9
|
+
}
|
|
10
|
+
else {
|
|
11
|
+
outputJson(data);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
function outputJson(data) {
|
|
15
|
+
console.log(JSON.stringify(data, null, 2));
|
|
16
|
+
}
|
|
17
|
+
function outputTable(data) {
|
|
18
|
+
if (Array.isArray(data)) {
|
|
19
|
+
if (data.length === 0) {
|
|
20
|
+
console.log(chalk.dim('No results.'));
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
// Extract columns from first row keys.
|
|
24
|
+
const columns = Object.keys(data[0]);
|
|
25
|
+
const rows = data.map((row) => {
|
|
26
|
+
const record = row;
|
|
27
|
+
return columns.map((col) => formatCell(record[col]));
|
|
28
|
+
});
|
|
29
|
+
printTable(columns, rows);
|
|
30
|
+
}
|
|
31
|
+
else if (data !== null && typeof data === 'object') {
|
|
32
|
+
// Single object — print key/value pairs.
|
|
33
|
+
const record = data;
|
|
34
|
+
const maxKeyLen = Math.max(...Object.keys(record).map((k) => k.length));
|
|
35
|
+
for (const [key, value] of Object.entries(record)) {
|
|
36
|
+
console.log(`${chalk.bold(key.padEnd(maxKeyLen))} ${formatCell(value)}`);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
console.log(String(data));
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
function formatCell(value) {
|
|
44
|
+
if (value === null || value === undefined)
|
|
45
|
+
return chalk.dim('—');
|
|
46
|
+
if (typeof value === 'object')
|
|
47
|
+
return JSON.stringify(value);
|
|
48
|
+
return String(value);
|
|
49
|
+
}
|
|
50
|
+
function printTable(columns, rows) {
|
|
51
|
+
const widths = columns.map((col, i) => Math.max(col.length, ...rows.map((row) => (row[i] ?? '').length)));
|
|
52
|
+
// Header
|
|
53
|
+
const header = columns.map((col, i) => chalk.bold(col.padEnd(widths[i]))).join(' ');
|
|
54
|
+
console.log(header);
|
|
55
|
+
console.log(widths.map((w) => '─'.repeat(w)).join('──'));
|
|
56
|
+
// Rows
|
|
57
|
+
for (const row of rows) {
|
|
58
|
+
const line = row.map((cell, i) => cell.padEnd(widths[i])).join(' ');
|
|
59
|
+
console.log(line);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Print an error in a structured way. JSON format outputs error object,
|
|
64
|
+
* table format prints a human-readable message.
|
|
65
|
+
*/
|
|
66
|
+
export function outputError(error, options) {
|
|
67
|
+
if (options.format === 'json') {
|
|
68
|
+
console.error(JSON.stringify({ error }, null, 2));
|
|
69
|
+
}
|
|
70
|
+
else {
|
|
71
|
+
console.error(chalk.red(`Error: ${error.message}`));
|
|
72
|
+
if (error.doc_url) {
|
|
73
|
+
console.error(chalk.dim(` Docs: ${error.doc_url}`));
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
//# sourceMappingURL=formatter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"formatter.js","sourceRoot":"","sources":["../../src/output/formatter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAQ1B;;;GAGG;AACH,MAAM,UAAU,MAAM,CAAC,IAAa,EAAE,OAAsB;IAC1D,IAAI,OAAO,CAAC,MAAM,KAAK,OAAO,EAAE,CAAC;QAC/B,WAAW,CAAC,IAAI,CAAC,CAAC;IACpB,CAAC;SAAM,CAAC;QACN,UAAU,CAAC,IAAI,CAAC,CAAC;IACnB,CAAC;AACH,CAAC;AAED,SAAS,UAAU,CAAC,IAAa;IAC/B,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;AAC7C,CAAC;AAED,SAAS,WAAW,CAAC,IAAa;IAChC,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C,CAAC,IAAI,EAAE,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAE,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACtE,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IACpB,CAAC;AACH,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,WAAW,CAAC,KAA2D,EAAE,OAAsB;IAC7G,IAAI,OAAO,CAAC,MAAM,KAAK,MAAM,EAAE,CAAC;QAC9B,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;IACpD,CAAC;SAAM,CAAC;QACN,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,UAAU,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC;QACpD,IAAI,KAAK,CAAC,OAAO,EAAE,CAAC;YAClB,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,WAAW,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC;QACvD,CAAC;IACH,CAAC;AACH,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@gojinko/cli",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"bin": {
|
|
6
|
+
"jinko": "./dist/bin/jinko.js"
|
|
7
|
+
},
|
|
8
|
+
"main": "dist/index.js",
|
|
9
|
+
"types": "dist/index.d.ts",
|
|
10
|
+
"dependencies": {
|
|
11
|
+
"commander": "^12.1.0",
|
|
12
|
+
"chalk": "^5.4.1",
|
|
13
|
+
"zod": "^3.23.8",
|
|
14
|
+
"yaml": "^2.7.0",
|
|
15
|
+
"@gojinko/api-client": "0.1.0"
|
|
16
|
+
},
|
|
17
|
+
"publishConfig": {
|
|
18
|
+
"access": "public"
|
|
19
|
+
},
|
|
20
|
+
"files": [
|
|
21
|
+
"dist",
|
|
22
|
+
"bin",
|
|
23
|
+
"SKILL.md",
|
|
24
|
+
"README.md"
|
|
25
|
+
],
|
|
26
|
+
"devDependencies": {
|
|
27
|
+
"typescript": "^5.6.3",
|
|
28
|
+
"tsx": "^4.19.1",
|
|
29
|
+
"vitest": "^2.1.0",
|
|
30
|
+
"@types/node": "^22.0.0"
|
|
31
|
+
},
|
|
32
|
+
"scripts": {
|
|
33
|
+
"build": "tsc",
|
|
34
|
+
"dev": "tsx --watch src/bin/jinko.ts",
|
|
35
|
+
"start": "tsx src/bin/jinko.ts",
|
|
36
|
+
"test": "vitest run",
|
|
37
|
+
"test:watch": "vitest",
|
|
38
|
+
"lint": "tsc --noEmit"
|
|
39
|
+
}
|
|
40
|
+
}
|