-
Notifications
You must be signed in to change notification settings - Fork 11
feat: enable sandbox with developer command #1083
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
ec8960b
feat: enable sandbox with developer command
elibosley 691c06e
fix: use an enum and defaults for sandbox value
elibosley 30280d2
fix: extra log line
elibosley 6cb1704
fix: tests and validate token clears screen
elibosley 73bef89
feat: enable sandbox in dev mode
elibosley 31b69eb
fix: sandbox defaults in dev mode wrong
elibosley File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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,45 @@ | ||
| import { Injectable } from '@nestjs/common'; | ||
|
|
||
| import { Command, CommandRunner, InquirerService } from 'nest-commander'; | ||
|
|
||
| import { loadConfigFile, updateUserConfig } from '@app/store/modules/config'; | ||
| import { writeConfigSync } from '@app/store/sync/config-disk-sync'; | ||
| import { DeveloperQuestions } from '@app/unraid-api/cli/developer/developer.questions'; | ||
| import { LogService } from '@app/unraid-api/cli/log.service'; | ||
| import { RestartCommand } from '@app/unraid-api/cli/restart.command'; | ||
|
|
||
| interface DeveloperOptions { | ||
| disclaimer: boolean; | ||
| sandbox: boolean; | ||
| } | ||
| @Injectable() | ||
| @Command({ | ||
| name: 'developer', | ||
| description: 'Configure Developer Features for the API', | ||
| }) | ||
| export class DeveloperCommand extends CommandRunner { | ||
| constructor( | ||
| private logger: LogService, | ||
| private readonly inquirerService: InquirerService, | ||
| private readonly restartCommand: RestartCommand | ||
| ) { | ||
| super(); | ||
| } | ||
| async run(_, options?: DeveloperOptions): Promise<void> { | ||
| options = await this.inquirerService.prompt(DeveloperQuestions.name, options); | ||
| if (!options.disclaimer) { | ||
| this.logger.warn('No changes made, disclaimer not accepted.'); | ||
| process.exit(1); | ||
| } | ||
| const { store } = await import('@app/store'); | ||
| await store.dispatch(loadConfigFile()); | ||
| store.dispatch(updateUserConfig({ local: { sandbox: options.sandbox ? 'yes' : 'no' } })); | ||
| writeConfigSync('flash'); | ||
|
|
||
| this.logger.info( | ||
| 'Updated Developer Configuration - restart the API in 5 seconds to apply them...' | ||
| ); | ||
| await new Promise((resolve) => setTimeout(resolve, 5000)); | ||
| await this.restartCommand.run([]); | ||
| } | ||
| } |
This file contains hidden or 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,26 @@ | ||
| import { Question, QuestionSet } from 'nest-commander'; | ||
|
|
||
| @QuestionSet({ name: 'developer' }) | ||
| export class DeveloperQuestions { | ||
| static name = 'developer'; | ||
|
|
||
| @Question({ | ||
| message: `Are you sure you wish to enable developer mode? | ||
| Currently this allows enabling the GraphQL sandbox on SERVER_URL/graphql. | ||
| `, | ||
| type: 'confirm', | ||
| name: 'disclaimer', | ||
| }) | ||
| parseDisclaimer(val: boolean) { | ||
| return val; | ||
| } | ||
|
|
||
| @Question({ | ||
| message: 'Do you wish to enable the sandbox?', | ||
| type: 'confirm', | ||
| name: 'sandbox', | ||
| }) | ||
| parseSandbox(val: boolean) { | ||
| return val; | ||
| } | ||
| } | ||
This file contains hidden or 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 hidden or 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 hidden or 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
3 changes: 0 additions & 3 deletions
3
api/src/unraid-api/unraid-file-modifier/__snapshots__/unraid-file-modifier.spec.ts.snap
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.