fix version set for cli and slash commands (#892)
This commit is contained in:
parent
3f5ac384cc
commit
5bab5a7378
|
@ -5,6 +5,9 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import esbuild from 'esbuild';
|
import esbuild from 'esbuild';
|
||||||
|
import { readFileSync } from 'fs';
|
||||||
|
|
||||||
|
const pkg = JSON.parse(readFileSync('./package.json', 'utf-8'));
|
||||||
|
|
||||||
esbuild
|
esbuild
|
||||||
.build({
|
.build({
|
||||||
|
@ -13,6 +16,9 @@ esbuild
|
||||||
outfile: 'bundle/gemini.js',
|
outfile: 'bundle/gemini.js',
|
||||||
platform: 'node',
|
platform: 'node',
|
||||||
format: 'esm',
|
format: 'esm',
|
||||||
|
define: {
|
||||||
|
'process.env.CLI_VERSION': JSON.stringify(pkg.version),
|
||||||
|
},
|
||||||
banner: {
|
banner: {
|
||||||
js: `import { createRequire } from 'module'; const require = createRequire(import.meta.url); globalThis.__filename = require('url').fileURLToPath(import.meta.url); globalThis.__dirname = require('path').dirname(globalThis.__filename);`,
|
js: `import { createRequire } from 'module'; const require = createRequire(import.meta.url); globalThis.__filename = require('url').fileURLToPath(import.meta.url); globalThis.__dirname = require('path').dirname(globalThis.__filename);`,
|
||||||
},
|
},
|
||||||
|
|
|
@ -91,7 +91,7 @@ async function parseArguments(): Promise<CliArgs> {
|
||||||
type: 'boolean',
|
type: 'boolean',
|
||||||
description: 'Enable telemetry?',
|
description: 'Enable telemetry?',
|
||||||
})
|
})
|
||||||
.version() // This will enable the --version flag based on package.json
|
.version(process.env.CLI_VERSION || '0.0.0') // This will enable the --version flag based on package.json
|
||||||
.help()
|
.help()
|
||||||
.alias('h', 'help')
|
.alias('h', 'help')
|
||||||
.strict().argv;
|
.strict().argv;
|
||||||
|
|
|
@ -5,5 +5,5 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
export function getCliVersion(): string {
|
export function getCliVersion(): string {
|
||||||
return process.env.CLI_VERSION || process.version;
|
return process.env.CLI_VERSION || 'unknown';
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,8 +19,10 @@
|
||||||
|
|
||||||
import { spawn, execSync } from 'child_process';
|
import { spawn, execSync } from 'child_process';
|
||||||
import { join } from 'path';
|
import { join } from 'path';
|
||||||
|
import { readFileSync } from 'fs';
|
||||||
|
|
||||||
const root = join(import.meta.dirname, '..');
|
const root = join(import.meta.dirname, '..');
|
||||||
|
const pkg = JSON.parse(readFileSync(join(root, 'package.json'), 'utf-8'));
|
||||||
|
|
||||||
// check build status, write warnings to file for app to display if needed
|
// check build status, write warnings to file for app to display if needed
|
||||||
execSync('node ./scripts/check-build-status.js', {
|
execSync('node ./scripts/check-build-status.js', {
|
||||||
|
@ -56,7 +58,7 @@ nodeArgs.push(...process.argv.slice(2));
|
||||||
|
|
||||||
const env = {
|
const env = {
|
||||||
...process.env,
|
...process.env,
|
||||||
CLI_VERSION: 'development',
|
CLI_VERSION: pkg.version,
|
||||||
DEV: 'true',
|
DEV: 'true',
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue