Skip to content

Commit cc0dd98

Browse files
committed
feat: CLI version
1 parent c5589cd commit cc0dd98

3 files changed

Lines changed: 21 additions & 1 deletion

File tree

rslib.config.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
import { defineConfig } from '@rslib/core';
2+
import pkgJson from './package.json' with { type: 'json' };
23

34
export default defineConfig({
45
lib: [{ syntax: 'es2023', dts: true }],
6+
source: {
7+
define: {
8+
RSTACK_VERSION: JSON.stringify(pkgJson.version),
9+
},
10+
},
511
});

src/cli/commands.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import cac from 'cac';
2+
3+
declare global {
4+
const RSTACK_VERSION: string;
5+
}
6+
7+
export function setupCommands(): void {
8+
const cli = cac('rs');
9+
10+
cli.version(RSTACK_VERSION);
11+
12+
cli.parse();
13+
}

src/cli/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { logger } from '@rsbuild/core';
2+
import { setupCommands } from './commands.js';
23

34
const { argv } = process;
45

@@ -18,7 +19,7 @@ export function runCLI(): void {
1819
initNodeEnv(command);
1920

2021
try {
21-
// setupCommands();
22+
setupCommands();
2223
} catch (err) {
2324
logger.error('Failed to start Rstack CLI.');
2425
logger.error(err);

0 commit comments

Comments
 (0)