@token-dashboard/codex-usage-uploader 0.1.4 → 0.1.5
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/package.json +1 -1
- package/src/cli.js +10 -1
- package/src/install.js +6 -0
package/package.json
CHANGED
package/src/cli.js
CHANGED
|
@@ -3,7 +3,7 @@ import path from 'node:path';
|
|
|
3
3
|
import { CodexUsageUploader } from './collector.js';
|
|
4
4
|
import { identityIsBound, promptConfirm } from './auth.js';
|
|
5
5
|
import { CLI_NAME, DEFAULT_BACKEND_URL, DEFAULT_CONFIG_FILE, PRODUCT_NAME } from './constants.js';
|
|
6
|
-
import { ensurePathInShellConfigs, findPackageRoot, installCurrentPackage, removePathFromShellConfigs } from './install.js';
|
|
6
|
+
import { ensurePathInShellConfigs, findPackageRoot, getPackageVersion, installCurrentPackage, removePathFromShellConfigs } from './install.js';
|
|
7
7
|
import { LaunchdServiceManager } from './launchd.js';
|
|
8
8
|
import { collectLocalUsage, getLocalTimeZone } from './local-usage.js';
|
|
9
9
|
import { formatStatusOutput, mergeRuntimeConfig, saveRuntimeConfig } from './runtime-config.js';
|
|
@@ -41,6 +41,7 @@ Common options:
|
|
|
41
41
|
--yes Skip interactive prompts
|
|
42
42
|
--package-spec <spec> npm install spec used by init
|
|
43
43
|
--lines <n> Number of log lines for service logs
|
|
44
|
+
-v, --version Show version
|
|
44
45
|
-h, --help Show help
|
|
45
46
|
`;
|
|
46
47
|
|
|
@@ -93,6 +94,10 @@ export function parseCliArgs(argv) {
|
|
|
93
94
|
options.help = true;
|
|
94
95
|
continue;
|
|
95
96
|
}
|
|
97
|
+
if (token === '-v' || token === '--version') {
|
|
98
|
+
options.version = true;
|
|
99
|
+
continue;
|
|
100
|
+
}
|
|
96
101
|
if (token === '--yes') {
|
|
97
102
|
options.yes = true;
|
|
98
103
|
continue;
|
|
@@ -685,6 +690,10 @@ function runLifecycleCommand(action, options) {
|
|
|
685
690
|
export async function main(argv = process.argv.slice(2)) {
|
|
686
691
|
try {
|
|
687
692
|
const { command, subcommand, extraPositionals, options } = parseCliArgs(argv);
|
|
693
|
+
if (options.version) {
|
|
694
|
+
console.log(getPackageVersion());
|
|
695
|
+
return 0;
|
|
696
|
+
}
|
|
688
697
|
if (!command || options.help) {
|
|
689
698
|
printUsage();
|
|
690
699
|
return 0;
|
package/src/install.js
CHANGED
|
@@ -12,6 +12,12 @@ const SHELL_CONFIG_FILES = [
|
|
|
12
12
|
path.join(os.homedir(), '.bash_profile'),
|
|
13
13
|
];
|
|
14
14
|
|
|
15
|
+
export function getPackageVersion(startUrl = import.meta.url) {
|
|
16
|
+
const root = findPackageRoot(startUrl);
|
|
17
|
+
const pkg = JSON.parse(fs.readFileSync(path.join(root, 'package.json'), 'utf8'));
|
|
18
|
+
return pkg.version ?? 'unknown';
|
|
19
|
+
}
|
|
20
|
+
|
|
15
21
|
export function findPackageRoot(startUrl = import.meta.url) {
|
|
16
22
|
let current = path.dirname(fileURLToPath(startUrl));
|
|
17
23
|
while (true) {
|