Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 09384af

Browse files
committed
fix: require token for restartNuxt
1 parent 69316c4 commit 09384af

File tree

5 files changed

+18
-8
lines changed

5 files changed

+18
-8
lines changed

packages/devtools-kit/src/_types/rpc.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,12 +65,14 @@ export interface ServerFunctions {
6565
customTabAction(name: string, action: number): Promise<boolean>
6666
runWizard<T extends WizardActions>(token: string, name: T, ...args: GetWizardArgs<T>): Promise<void>
6767
openInEditor(filepath: string): Promise<boolean>
68-
requestForAuth(info?: string, origin?: string): Promise<void>
69-
verifyAuthToken(token: string): Promise<boolean>
70-
restartNuxt(hard?: boolean): Promise<void>
68+
restartNuxt(token: string, hard?: boolean): Promise<void>
7169
installNuxtModule(token: string, name: string, dry?: boolean): Promise<InstallModuleReturn>
7270
uninstallNuxtModule(token: string, name: string, dry?: boolean): Promise<InstallModuleReturn>
7371
enableTimeline(dry: boolean): Promise<[string, string]>
72+
73+
// Dev Token
74+
requestForAuth(info?: string, origin?: string): Promise<void>
75+
verifyAuthToken(token: string): Promise<boolean>
7476
}
7577

7678
export interface ClientFunctions {

packages/devtools/client/components/AssetDetails.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ const codeSnippets = computed(() => {
8787
})
8888
8989
const copy = useCopy()
90+
const openInEditor = useOpenInEditor()
9091
const timeAgo = useTimeAgo(() => asset.value.mtime)
9192
const fileSize = computed(() => {
9293
const size = asset.value.size

packages/devtools/client/components/RestartDialogs.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ nuxt.hook('devtools:terminal:exit', ({ id, code }) => {
1313
state.value = state.value.filter(dialog => dialog.id !== id)
1414
PromiseConfirm
1515
.start(dialog.message)
16-
.then((result) => {
16+
.then(async (result) => {
1717
if (result) {
18-
rpc.restartNuxt()
18+
rpc.restartNuxt(await ensureDevAuthToken())
1919
setTimeout(() => {
2020
client.value?.app.reload()
2121
}, 500)

packages/devtools/client/composables/npm.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ function getPackageUpdate(name: string, options?: NpmCommandOptions) {
6161
async function restart() {
6262
if (state.value !== 'updated')
6363
return
64-
await rpc.restartNuxt()
64+
await rpc.restartNuxt(await ensureDevAuthToken())
6565
}
6666

6767
return {

packages/devtools/src/server-rpc/general.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,13 @@ import type { AutoImportsWithMetadata, HookInfo, NuxtDevtoolsServerContext, Serv
1313
import { setupHooksDebug } from '../runtime/shared/hooks'
1414
import { getDevAuthToken } from '../dev-auth'
1515

16-
export function setupGeneralRPC({ nuxt, options, refresh, openInEditorHooks }: NuxtDevtoolsServerContext) {
16+
export function setupGeneralRPC({
17+
nuxt,
18+
options,
19+
refresh,
20+
ensureDevAuthToken,
21+
openInEditorHooks,
22+
}: NuxtDevtoolsServerContext) {
1723
const components: Component[] = []
1824
const imports: Import[] = []
1925
const importPresets: Import[] = []
@@ -183,7 +189,8 @@ export function setupGeneralRPC({ nuxt, options, refresh, openInEditorHooks }: N
183189
return false
184190
}
185191
},
186-
restartNuxt(hard = true) {
192+
async restartNuxt(token: string, hard = true) {
193+
await ensureDevAuthToken(token)
187194
logger.info('Restarting Nuxt...')
188195
return nuxt.callHook('restart', { hard })
189196
},

0 commit comments

Comments
 (0)