Skip to content

Commit d9a7d2d

Browse files
committed
chore: wip
1 parent df99193 commit d9a7d2d

File tree

2 files changed

+68
-12
lines changed

2 files changed

+68
-12
lines changed

packages/launchpad/bin/cli.ts

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -751,6 +751,73 @@ cli
751751
}
752752
})
753753

754+
// Activate command - user-friendly alias for dev:on
755+
cli
756+
.command('activate [dir]', 'Activate development environment for current or specified directory')
757+
.alias('on')
758+
.alias('enable')
759+
.option('--silent', 'Suppress output messages')
760+
.option('--shell-safe', 'Output shell-safe message without ANSI escape sequences')
761+
.example('launchpad activate')
762+
.example('launchpad on /path/to/project')
763+
.example('launchpad enable')
764+
.action(async (dir?: string, options?: { silent?: boolean, shellSafe?: boolean }) => {
765+
try {
766+
const targetDir = dir ? path.resolve(dir) : process.cwd()
767+
768+
// Show activation message if not explicitly silenced
769+
if (!options?.silent) {
770+
// Show activation message if configured
771+
if (config.showShellMessages && config.shellActivationMessage) {
772+
let message = config.shellActivationMessage.replace('{path}', path.basename(targetDir))
773+
774+
// If called with shell-safe option, strip ANSI escape sequences to prevent shell parsing issues
775+
if (options?.shellSafe) {
776+
// eslint-disable-next-line no-control-regex
777+
message = message.replace(/\u001B\[[0-9;]*m/g, '')
778+
}
779+
780+
console.log(message)
781+
}
782+
}
783+
}
784+
catch (error) {
785+
if (!options?.silent) {
786+
console.error('Failed to activate dev environment:', error instanceof Error ? error.message : String(error))
787+
}
788+
process.exit(1)
789+
}
790+
})
791+
792+
// Deactivate command - user-friendly alias for dev:off
793+
cli
794+
.command('deactivate', 'Deactivate current development environment and use system/homebrew dependencies')
795+
.alias('off')
796+
.alias('disable')
797+
.option('--silent', 'Suppress output messages')
798+
.example('launchpad deactivate')
799+
.example('launchpad off')
800+
.example('launchpad disable')
801+
.action(async (options?: { silent?: boolean }) => {
802+
try {
803+
// The actual deactivation is handled by shell functions
804+
// This command exists for consistency and user-friendly access
805+
806+
if (!options?.silent) {
807+
// Show deactivation message if configured
808+
if (config.showShellMessages && config.shellDeactivationMessage) {
809+
console.log(config.shellDeactivationMessage)
810+
}
811+
}
812+
}
813+
catch (error) {
814+
if (!options?.silent) {
815+
console.error('Failed to deactivate dev environment:', error instanceof Error ? error.message : String(error))
816+
}
817+
process.exit(1)
818+
}
819+
})
820+
754821
// Environment management commands
755822

756823
// List environments command

packages/launchpad/src/commands/index.ts

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -48,21 +48,10 @@ const registry: Record<string, () => Promise<Command>> = {
4848
'build-env': async () => (await import('./build-env')).default,
4949
}
5050

51-
// Aliases map to canonical command names
52-
const aliases: Record<string, string> = {
53-
'remove': 'uninstall',
54-
'packages': 'tags',
55-
'cache:info': 'cache:stats',
56-
'up': 'update',
57-
'self-update': 'upgrade',
58-
'service': 'services',
59-
}
60-
6151
export async function resolveCommand(name?: string): Promise<Command | undefined> {
6252
if (!name)
6353
return undefined
64-
const key = aliases[name] || name
65-
const loader = registry[key]
54+
const loader = registry[name]
6655
if (!loader)
6756
return undefined
6857
return loader()

0 commit comments

Comments
 (0)