Skip to content

Commit

Permalink
refactor(tunnel): improve changeset and help message
Browse files Browse the repository at this point in the history
  • Loading branch information
charIeszhao committed Sep 2, 2024
1 parent ab1db8d commit 450a97c
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 32 deletions.
12 changes: 8 additions & 4 deletions .changeset/modern-ghosts-sin.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,26 @@ add deploy command and env support
npx @logto/tunnel deploy --auth <your-m2m-app-id>:<your-m2m-app-secret> --endpoint https://<tenant-id>.logto.app --experience-path /path/to/your/custom/ui
```

If you are using custom domain, an additional option `--management-api-resource` (or `--resource`) must be specified.
If you are using custom domain for your Logto endpoint, an additional option `--management-api-resource` (or `--resource`) must be specified.

```bash
npx @logto/tunnel deploy --auth <your-m2m-app-id>:<your-m2m-app-secret> --endpoint https://your.custom.domain --experience-path /path/to/your/custom/ui --management-api-resource https://<tenant-id>.logto.app/api
```

Note:
1. This option can be omitted when using the default Logto domain, since the CLI can infer the value automatically.
2. Using either custom domain or default Logto domain as the endpoint will yield identical results.

#### Add environment variable support

1. Create a `.env` file in the CLI root path, or any parent folder where CLI is located.
2. You can also specify environment variables directly when running CLI command.
1. Create a `.env` file in the CLI root directory, or any parent directory where the CLI is located.
2. Alternatively, specify environment variables directly when running CLI commands:

```bash
ENDPOINT=https://<tenant-id>.logto.app npx @logto/tunnel ...
```

All supported environment variable names are listed as follows:
Supported environment variables:

- LOGTO_AUTH
- LOGTO_ENDPOINT
Expand Down
58 changes: 32 additions & 26 deletions packages/tunnel/src/commands/deploy/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,32 +15,38 @@ const tunnel: CommandModule<unknown, DeployCommandArgs> = {
command: ['deploy'],
describe: 'Deploy your custom UI assets to Logto Cloud',
builder: (yargs) =>
yargs.options({
auth: {
describe: 'Auth credentials of your Logto M2M application. E.g.: <app-id>:<app-secret>',
type: 'string',
},
endpoint: {
describe:
'Logto endpoint URI that points to your Logto Cloud instance. E.g.: https://<tenant-id>.logto.app/',
type: 'string',
},
path: {
alias: ['experience-path'],
describe: 'The local folder path of your custom sign-in experience assets.',
type: 'string',
},
resource: {
alias: ['management-api-resource'],
describe: 'Logto Management API resource indicator. Required if using custom domain.',
type: 'string',
},
verbose: {
describe: 'Show verbose output.',
type: 'boolean',
default: false,
},
}),
yargs
.options({
auth: {
describe: 'Auth credentials of your Logto M2M application. E.g.: <app-id>:<app-secret>',
type: 'string',
},
endpoint: {
describe:
'Logto endpoint URI that points to your Logto Cloud instance. E.g.: https://<tenant-id>.logto.app/',
type: 'string',
},
path: {
alias: ['experience-path'],
describe: 'The local folder path of your custom sign-in experience assets.',
type: 'string',
},
resource: {
alias: ['management-api-resource'],
describe: 'Logto Management API resource indicator. Required if using custom domain.',
type: 'string',
},
verbose: {
describe: 'Show verbose output.',
type: 'boolean',
default: false,
},
})
.epilog(
`Refer to our documentation for more details:\n${chalk.blue(
'https://docs.logto.io/docs/references/tunnel-cli/deploy'
)}`
),
handler: async (options) => {
const {
auth,
Expand Down
3 changes: 1 addition & 2 deletions packages/tunnel/src/commands/tunnel/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@ const tunnel: CommandModule<unknown, TunnelCommandArgs> = {
type: 'string',
},
endpoint: {
describe: `Logto endpoint URI that points to your Logto Cloud instance. E.g.: https://<tenant-id>.logto.app/
Note: Custom domain is not supported.`,
describe: `Logto endpoint URI that points to your Logto Cloud instance. E.g.: https://<tenant-id>.logto.app/`,
type: 'string',
},
port: {
Expand Down
5 changes: 5 additions & 0 deletions packages/tunnel/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,9 @@ void yargs(hideBin(process.argv))
.parserConfiguration({
'dot-notation': false,
})
.epilog(
`Refer to our documentation for more details:\n${chalk.blue(
'https://docs.logto.io/docs/references/tunnel-cli'
)}`
)
.parse();

0 comments on commit 450a97c

Please sign in to comment.