@jinshuju/cli 0.1.1 → 0.1.3
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 +2 -0
- package/dist/cli.d.ts +6 -1
- package/dist/cli.js +15 -1
- package/dist/commands.js +20 -2
- package/package.json +1 -1
package/README.md
CHANGED
package/dist/cli.d.ts
CHANGED
|
@@ -11,6 +11,11 @@ export type CliRuntime = {
|
|
|
11
11
|
/** How wide a table may be. Defaults to the terminal, or 120 through a pipe. */
|
|
12
12
|
width?: number;
|
|
13
13
|
};
|
|
14
|
-
|
|
14
|
+
/**
|
|
15
|
+
* Read from package.json, not restated here. A release bumps that file and
|
|
16
|
+
* nothing else, so a constant reports the previous version from the moment it
|
|
17
|
+
* is published — 0.1.1 shipped saying 0.1.0.
|
|
18
|
+
*/
|
|
19
|
+
export declare const VERSION: string;
|
|
15
20
|
export declare function terminalWidth(stream?: NodeJS.WriteStream): number;
|
|
16
21
|
export declare function runCli(args?: string[], runtime?: CliRuntime): Promise<CliResult>;
|
package/dist/cli.js
CHANGED
|
@@ -186,7 +186,21 @@ function localOptions(flags, stdin) {
|
|
|
186
186
|
showSecret: Boolean(bound.show_secret)
|
|
187
187
|
};
|
|
188
188
|
}
|
|
189
|
-
|
|
189
|
+
/**
|
|
190
|
+
* Read from package.json, not restated here. A release bumps that file and
|
|
191
|
+
* nothing else, so a constant reports the previous version from the moment it
|
|
192
|
+
* is published — 0.1.1 shipped saying 0.1.0.
|
|
193
|
+
*/
|
|
194
|
+
export const VERSION = readVersion();
|
|
195
|
+
function readVersion() {
|
|
196
|
+
try {
|
|
197
|
+
const pkg = JSON.parse(readFileSync(new URL('../package.json', import.meta.url), 'utf8'));
|
|
198
|
+
return pkg.version ?? 'unknown';
|
|
199
|
+
}
|
|
200
|
+
catch {
|
|
201
|
+
return 'unknown';
|
|
202
|
+
}
|
|
203
|
+
}
|
|
190
204
|
function ok(stdout) {
|
|
191
205
|
return { exitCode: 0, stdout: stdout.endsWith('\n') ? stdout : `${stdout}\n`, stderr: '' };
|
|
192
206
|
}
|
package/dist/commands.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { CONTAINER_LIST_OPTIONS, CONTAINER_OPTIONS, FILTER_OPTION, FILTERS_OPTION, JSON_OPTION, LIMIT_OPTION, LOCAL_OPTIONS, MINE_OPTION, PAGINATION_OPTIONS, SORT_OPTION, TIME_BUCKETS, UsageError, parseDimension, parseFilter, parseMetric, parseSort, resolveContainer, resolveContainers } from './options.js';
|
|
2
2
|
import { CONFIG_KEYS } from './config.js';
|
|
3
3
|
import { readFileSync } from 'node:fs';
|
|
4
|
-
import { basename } from 'node:path';
|
|
4
|
+
import { basename, extname } from 'node:path';
|
|
5
5
|
import { validateCreateFormPayload } from './payload.js';
|
|
6
6
|
import { progress } from './progress.js';
|
|
7
7
|
/** Resource order in the root help, and the one-liner each gets. */
|
|
@@ -892,6 +892,23 @@ const VIEW = [
|
|
|
892
892
|
}
|
|
893
893
|
];
|
|
894
894
|
// --- uploads ----------------------------------------------------------------
|
|
895
|
+
/**
|
|
896
|
+
* The media type of an upload, by extension. The server stores the type the
|
|
897
|
+
* multipart part declares and decides from it what the file may be used for, so
|
|
898
|
+
* an untyped part is an .xlsx it refuses as not a spreadsheet.
|
|
899
|
+
*/
|
|
900
|
+
const UPLOAD_TYPES = {
|
|
901
|
+
'.xlsx': 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
|
|
902
|
+
'.xlsm': 'application/vnd.ms-excel.sheet.macroEnabled.12',
|
|
903
|
+
'.xls': 'application/vnd.ms-excel',
|
|
904
|
+
'.csv': 'text/csv',
|
|
905
|
+
'.png': 'image/png',
|
|
906
|
+
'.jpg': 'image/jpeg',
|
|
907
|
+
'.jpeg': 'image/jpeg',
|
|
908
|
+
'.gif': 'image/gif',
|
|
909
|
+
'.webp': 'image/webp',
|
|
910
|
+
'.pdf': 'application/pdf'
|
|
911
|
+
};
|
|
895
912
|
/**
|
|
896
913
|
* A file on disk, as multipart. The three endpoints that take one authenticate
|
|
897
914
|
* like every other request, so there is no ticket to fetch first: the file goes
|
|
@@ -906,7 +923,8 @@ function upload(path, file, extra = {}) {
|
|
|
906
923
|
catch (error) {
|
|
907
924
|
throw new UsageError(`could not read ${file}: ${error.message}`);
|
|
908
925
|
}
|
|
909
|
-
|
|
926
|
+
const type = UPLOAD_TYPES[extname(file).toLowerCase()];
|
|
927
|
+
form.append('file', new Blob([new Uint8Array(bytes)], type ? { type } : undefined), basename(file));
|
|
910
928
|
for (const [name, value] of Object.entries(extra))
|
|
911
929
|
form.append(name, value);
|
|
912
930
|
return { method: 'POST', path, form };
|