Skip to content

Commit 5fc95f7

Browse files
authored
feat(app-tools): enable Rsbuild CLI shortcuts (#6610)
1 parent 809c64e commit 5fc95f7

File tree

4 files changed

+21
-2
lines changed

4 files changed

+21
-2
lines changed

.changeset/afraid-socks-jam.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
'@modern-js/app-tools': patch
3+
'@modern-js/uni-builder': patch
4+
'@modern-js/utils': patch
5+
---
6+
7+
feat(app-tools): enable Rsbuild CLI shortcuts

packages/cli/uni-builder/src/shared/parseCommonConfig.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -316,14 +316,14 @@ export async function parseCommonConfig(
316316
};
317317
}
318318

319-
const { dev: RsbuildDev, server } = transformToRsbuildServerOptions(
319+
const { dev: rsbuildDev, server } = transformToRsbuildServerOptions(
320320
dev || {},
321321
devServer || {},
322322
);
323323

324324
rsbuildConfig.server = removeUndefinedKey(server);
325325

326-
rsbuildConfig.dev = removeUndefinedKey(RsbuildDev);
326+
rsbuildConfig.dev = removeUndefinedKey(rsbuildDev);
327327
rsbuildConfig.html = html;
328328
rsbuildConfig.output = output;
329329

packages/solutions/app-tools/src/config/default.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,12 @@ export function createDefaultConfig(
1111
// `dev.port` should not have a default value
1212
// because we will use `server.port` by default
1313
port: undefined,
14+
cliShortcuts: {
15+
help: false,
16+
// does not support restart server and print urls yet
17+
custom: (shortcuts = []) =>
18+
shortcuts.filter(({ key }) => key !== 'r' && key !== 'u'),
19+
},
1420
};
1521

1622
const output: AppUserConfig['output'] = {

packages/toolkit/utils/src/cli/prettyInstructions.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,5 +142,11 @@ export const prettyInstructions = (appContext: any, config: any) => {
142142
);
143143
}
144144

145+
if (config.dev?.cliShortcuts) {
146+
message += ` ${chalk.dim('> press')} ${chalk.bold(
147+
'h + enter',
148+
)} ${chalk.dim('to show shortcuts')}\n`;
149+
}
150+
145151
return message;
146152
};

0 commit comments

Comments
 (0)