-
Notifications
You must be signed in to change notification settings - Fork 79
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add optional login to init command * workaround for local profile deletion * unified text formatting
- Loading branch information
Roy Razon
authored
Oct 22, 2023
1 parent
13442fb
commit 4ab73c6
Showing
24 changed files
with
561 additions
and
321 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,8 @@ | ||
export * from './lib/plugins/model' | ||
export * as text from './lib/text' | ||
export { HookName, HookFunc, HooksListeners, Hooks } from './lib/hooks' | ||
export { PluginContext, PluginInitContext } from './lib/plugins/context' | ||
export { composeFlags, envIdFlags, tunnelServerFlags, urlFlags } from './lib/flags' | ||
export { composeFlags, envIdFlags, tunnelServerFlags, urlFlags } from './lib/common-flags' | ||
export { formatFlagsToArgs } from './lib/flags' | ||
export { initHook } from './hooks/init/load-plugins' | ||
export { default as BaseCommand } from './commands/base-command' | ||
export * as utils from './utils' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
import { Flags } from '@oclif/core' | ||
|
||
const projectFlag = { | ||
project: Flags.string({ | ||
char: 'p', | ||
description: 'Project name. Defaults to the Compose project name', | ||
required: false, | ||
helpGroup: 'GLOBAL', | ||
}), | ||
} | ||
export const composeFlags = { | ||
file: Flags.string({ | ||
description: 'Compose configuration file', | ||
multiple: true, | ||
required: false, | ||
char: 'f', | ||
default: [], | ||
helpGroup: 'GLOBAL', | ||
}), | ||
'system-compose-file': Flags.string({ | ||
description: 'Add extra Compose configuration file without overriding the defaults', | ||
multiple: true, | ||
required: false, | ||
default: [], | ||
helpGroup: 'GLOBAL', | ||
}), | ||
...projectFlag, | ||
} as const | ||
|
||
export const envIdFlags = { | ||
id: Flags.string({ | ||
description: 'Environment id - affects created URLs. If not specified, will try to detect automatically', | ||
required: false, | ||
}), | ||
...projectFlag, | ||
} as const | ||
|
||
export const tunnelServerFlags = { | ||
'tunnel-url': Flags.string({ | ||
description: 'Tunnel url, specify ssh://hostname[:port] or ssh+tls://hostname[:port]', | ||
char: 't', | ||
default: 'ssh+tls://livecycle.run' ?? process.env.PREVIEW_TUNNEL_OVERRIDE, | ||
}), | ||
'tls-hostname': Flags.string({ | ||
description: 'Override TLS server name when tunneling via HTTPS', | ||
required: false, | ||
}), | ||
'insecure-skip-verify': Flags.boolean({ | ||
description: 'Skip TLS or SSH certificate verification', | ||
default: false, | ||
}), | ||
} as const | ||
|
||
export const urlFlags = { | ||
'include-access-credentials': Flags.boolean({ | ||
description: 'Include access credentials for basic auth for each service URL', | ||
default: false, | ||
}), | ||
'show-preevy-service-urls': Flags.boolean({ | ||
description: 'Show URLs for internal Preevy services', | ||
default: false, | ||
}), | ||
'access-credentials-type': Flags.custom<'browser' | 'api'>({ | ||
options: ['api', 'browser'], | ||
dependsOn: ['include-access-credentials'], | ||
default: 'browser', | ||
required: true, | ||
})(), | ||
} as const |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,69 +1,25 @@ | ||
import { Flags } from '@oclif/core' | ||
import { Flag } from '@oclif/core/lib/interfaces' | ||
|
||
const projectFlag = { | ||
project: Flags.string({ | ||
char: 'p', | ||
description: 'Project name. Defaults to the Compose project name', | ||
required: false, | ||
helpGroup: 'GLOBAL', | ||
}), | ||
} | ||
export const composeFlags = { | ||
file: Flags.string({ | ||
description: 'Compose configuration file', | ||
multiple: true, | ||
required: false, | ||
char: 'f', | ||
default: [], | ||
helpGroup: 'GLOBAL', | ||
}), | ||
'system-compose-file': Flags.string({ | ||
description: 'Add extra Compose configuration file without overriding the defaults', | ||
multiple: true, | ||
required: false, | ||
default: [], | ||
helpGroup: 'GLOBAL', | ||
}), | ||
...projectFlag, | ||
} as const | ||
|
||
export const envIdFlags = { | ||
id: Flags.string({ | ||
description: 'Environment id - affects created URLs. If not specified, will try to detect automatically', | ||
required: false, | ||
}), | ||
...projectFlag, | ||
} as const | ||
type FlagSpec<T> =Pick<Flag<T>, 'type' | 'default'> | ||
|
||
export const tunnelServerFlags = { | ||
'tunnel-url': Flags.string({ | ||
description: 'Tunnel url, specify ssh://hostname[:port] or ssh+tls://hostname[:port]', | ||
char: 't', | ||
default: 'ssh+tls://livecycle.run' ?? process.env.PREVIEW_TUNNEL_OVERRIDE, | ||
}), | ||
'tls-hostname': Flags.string({ | ||
description: 'Override TLS server name when tunneling via HTTPS', | ||
required: false, | ||
}), | ||
'insecure-skip-verify': Flags.boolean({ | ||
description: 'Skip TLS or SSH certificate verification', | ||
default: false, | ||
}), | ||
} as const | ||
|
||
export const urlFlags = { | ||
'include-access-credentials': Flags.boolean({ | ||
description: 'Include access credentials for basic auth for each service URL', | ||
default: false, | ||
}), | ||
'show-preevy-service-urls': Flags.boolean({ | ||
description: 'Show URLs for internal Preevy services', | ||
default: false, | ||
}), | ||
'access-credentials-type': Flags.custom<'browser' | 'api'>({ | ||
options: ['api', 'browser'], | ||
dependsOn: ['include-access-credentials'], | ||
default: 'browser', | ||
required: true, | ||
})(), | ||
} as const | ||
export function formatFlagsToArgs(flags: Record<string, unknown>, spec: Record<string, FlagSpec<unknown>> = {}, prefix = '') { | ||
return Object.entries(flags).flatMap(function format(this: void, [key, value]):string[] { | ||
if (spec[key]?.default === value) { | ||
return [] | ||
} | ||
if (Array.isArray(value)) { | ||
return value.flatMap(v => format([key, v])) | ||
} | ||
if (typeof value === 'boolean') { | ||
const defaultIsOn = spec[key]?.type === 'boolean' && spec[key].default === true | ||
if (!value && defaultIsOn) { | ||
return [`--no-${key}`] | ||
} | ||
return [`--${key}`] | ||
} | ||
if (typeof value === 'object') { | ||
return Object.entries(value ?? {}).flatMap(([k, v]) => format([`${key}-${k}`, v])) | ||
} | ||
return [`--${prefix}${key}`, `${value}`] | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { Config } from '@oclif/core' | ||
import chalk from 'chalk' | ||
|
||
export const code = (c: string) => chalk.bold(c) | ||
|
||
export const codeList = (c: string[]) => c.map(code).join(', ') | ||
|
||
export const command = ({ bin }: Pick<Config, 'bin'>, ...args: string[]) => code(`${bin} ${args.join(' ')}`) | ||
|
||
export const highlight = (s: string) => chalk.greenBright(s) | ||
|
||
export const success = (s: string) => chalk.greenBright(s) | ||
|
||
export const recommendation = (s: string) => chalk.cyan(s) |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
`preevy login` | ||
============== | ||
|
||
Login to the Livecycle SaaS | ||
|
||
* [`preevy login`](#preevy-login) | ||
|
||
## `preevy login` | ||
|
||
Login to the Livecycle SaaS | ||
|
||
``` | ||
USAGE | ||
$ preevy login [-D] [-f <value>] [--system-compose-file <value>] [-p <value>] [--lc-auth-url <value>] | ||
[--lc-api-url <value>] [--lc-client-id <value>] | ||
FLAGS | ||
--lc-api-url=<value> [default: https://app.livecycle.run] The Livecycle API URL' | ||
--lc-auth-url=<value> [default: https://auth.livecycle.dev] The login URL | ||
--lc-client-id=<value> [default: BHXcVtapfKPEpZtYO3AJ2Livmz6j7xK0] The client ID for the OAuth app | ||
GLOBAL FLAGS | ||
-D, --debug Enable debug logging | ||
-f, --file=<value>... [default: ] Compose configuration file | ||
-p, --project=<value> Project name. Defaults to the Compose project name | ||
--system-compose-file=<value>... [default: ] Add extra Compose configuration file without overriding the defaults | ||
DESCRIPTION | ||
Login to the Livecycle SaaS | ||
``` | ||
|
||
_See code: [dist/commands/login.ts](https://github.com/livecycle/preevy/blob/v0.0.55/packages/cli/src/commands/login.ts)_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.