-
Notifications
You must be signed in to change notification settings - Fork 160
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* enh: add cli command and supporting endpoint to verify token
- Loading branch information
1 parent
c73f5eb
commit cea8434
Showing
10 changed files
with
202 additions
and
3 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"recommendations": [ | ||
"dbaeumer.vscode-eslint", | ||
"redhat.java", | ||
"vscjava.vscode-java-debug", | ||
"vscjava.vscode-java-test", | ||
"richardwillis.vscode-gradle" | ||
] | ||
} |
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
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,52 @@ | ||
/******************************************************************************** | ||
* Copyright (c) 2022 Anibal Solon and others | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Eclipse Public License v. 2.0 which is available at | ||
* http://www.eclipse.org/legal/epl-2.0. | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
********************************************************************************/ | ||
|
||
import { Registry, RegistryOptions } from './registry'; | ||
import { readManifest, addEnvOptions } from './util'; | ||
|
||
/** | ||
* Validates that a Personal Access Token can publish to a namespace. | ||
*/ | ||
export async function verifyPat(options: VerifyPatOptions): Promise<void> { | ||
addEnvOptions(options); | ||
if (!options.pat) { | ||
throw new Error("A personal access token must be given with the option '--pat'."); | ||
} | ||
|
||
if (!options.namespace) { | ||
let error; | ||
try { | ||
options.namespace = (await readManifest()).publisher; | ||
} catch (e) { | ||
error = e; | ||
} | ||
|
||
if (!options.namespace) { | ||
throw new Error( | ||
`Unable to read the namespace's name. Please supply it as an argument or run ovsx from the extension folder.` + | ||
(error ? `\n\n${error}` : '') | ||
); | ||
} | ||
} | ||
|
||
const registry = new Registry(options); | ||
const result = await registry.verifyPat(options.namespace, options.pat); | ||
if (result.error) { | ||
throw new Error(result.error); | ||
} | ||
console.log(`\ud83d\ude80 PAT valid to publish at ${options.namespace}`); | ||
} | ||
|
||
export interface VerifyPatOptions extends RegistryOptions { | ||
/** | ||
* Name of the namespace. | ||
*/ | ||
namespace?: string | ||
} |
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
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