generated from oracle/template-repo
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Switch to bundle API for validation (#50)
- Loading branch information
1 parent
d2d2a41
commit 57af404
Showing
5 changed files
with
68 additions
and
54 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 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,44 @@ | ||
/** | ||
* Copyright © 2022-2024, Oracle and/or its affiliates. | ||
* This software is licensed to you under the Universal Permissive License (UPL) 1.0 as shown at https://oss.oracle.com/licenses/upl. | ||
*/ | ||
|
||
import * as vscode from 'vscode'; | ||
|
||
|
||
import * as api from '../api'; | ||
import { log } from '../logger'; | ||
import { get as getProfileManager } from '../profile-manager-provider'; | ||
import { RABError, showErrorMessage, showInfoMessage, withProgress } from '../utils/ui-utils'; | ||
import { createRABBundle } from '../workspace-manager'; | ||
|
||
async function callback(file: vscode.Uri, context: vscode.ExtensionContext): Promise<any> { | ||
|
||
withProgress("Validating RAB bundle...", async () => { | ||
log.info(`Validating RAB bundle...`); | ||
let bundle; | ||
try { | ||
bundle = await createRABBundle(); | ||
} catch (err) { | ||
showErrorMessage(err); return; | ||
} | ||
|
||
let profileName = (await getProfileManager().active())?.name; | ||
log.info(`Using the publisher profile '${profileName}'`); | ||
|
||
try { | ||
let ret; | ||
ret = await api.bundle.validate(bundle.content); | ||
showInfoMessage(`Adapter '${bundle.id}' is ${ret.valid ? 'valid' : 'invalid'}.`); | ||
} catch (err) { | ||
showErrorMessage(new RABError('Cannot validate the bundle.', err)); | ||
} | ||
}); | ||
} | ||
|
||
export function register(context: vscode.ExtensionContext) { | ||
|
||
context.subscriptions.push( | ||
vscode.commands.registerCommand("orab.bundle.validate", callback) | ||
); | ||
} |
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