-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #65 from snyk/develop
Merge dev into master for release
- Loading branch information
Showing
21 changed files
with
636 additions
and
111 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,6 +13,5 @@ package-lock.json | |
*.bak | ||
*.vsix | ||
.eslintcache | ||
.circleci | ||
.ops | ||
ops/deploy/dist |
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,15 @@ | ||
module.exports = { | ||
"roots": [ | ||
"<rootDir>/snykTask/src/" | ||
], | ||
"transform": { | ||
"^.+\\.tsx?$": "ts-jest" | ||
}, | ||
"testPathIgnorePatterns": [ | ||
"/node_modules/", | ||
"snykTask/src/__tests__/_test-mock-config-*" | ||
], | ||
testMatch: [ | ||
'<rootDir>/snykTask/src/__tests__/test-task.ts' | ||
], | ||
} |
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,31 @@ | ||
import { getExtensionInfo, getLatestVersion } from "./lib/azure-devops"; | ||
|
||
async function main() { | ||
const publisherName = process.env.DEV_AZ_PUBLISHER || ""; | ||
// warning: the Marketplace stuff calls this extensionId - the rest of the extension stuff calls it name | ||
const extensionName = process.env.DEV_AZ_EXTENSION_ID || ""; | ||
const azToken = process.env.DEV_AZURE_DEVOPS_EXT_PAT || ""; | ||
|
||
const extensionDetails = await getExtensionInfo( | ||
azToken, | ||
publisherName, | ||
extensionName | ||
); | ||
|
||
if (extensionDetails) { | ||
const latestVersion = getLatestVersion(extensionDetails); | ||
if (latestVersion) { | ||
console.log(latestVersion); | ||
} else { | ||
console.error("could not get extension version info"); | ||
process.exit(1); | ||
} | ||
} else { | ||
console.error("could not get extension info"); | ||
process.exit(1); | ||
} | ||
} | ||
|
||
if (require.main === module) { | ||
main(); | ||
} |
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,36 @@ | ||
import { getExtensionInfo, getLatestVersion } from "./lib/azure-devops"; | ||
|
||
async function main() { | ||
const publisherName = process.env.DEV_AZ_PUBLISHER || ""; | ||
// warning: the Marketplace stuff calls this extensionId - the rest of the extension stuff calls it name | ||
const extensionName = process.env.DEV_AZ_EXTENSION_ID || ""; | ||
const azToken = process.env.DEV_AZURE_DEVOPS_EXT_PAT || ""; | ||
|
||
const extensionDetails = await getExtensionInfo( | ||
azToken, | ||
publisherName, | ||
extensionName | ||
); | ||
|
||
if (extensionDetails) { | ||
const latestVersion = getLatestVersion(extensionDetails); | ||
if (latestVersion) { | ||
const splitz = latestVersion.split("."); | ||
const major = parseInt(splitz[0]); | ||
const minor = parseInt(splitz[1]); | ||
const patch = parseInt(splitz[2]) + 1; | ||
const newVersion = `${major}.${minor}.${patch}`; | ||
console.log(newVersion); | ||
} else { | ||
console.error("could not get extension version info"); | ||
process.exit(1); | ||
} | ||
} else { | ||
console.error("could not get extension info"); | ||
process.exit(1); | ||
} | ||
} | ||
|
||
if (require.main === module) { | ||
main(); | ||
} |
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,54 @@ | ||
import { WebApi } from "azure-devops-node-api"; | ||
|
||
import { getAzUrl, getWebApi } from "./lib/azure-devops"; | ||
import { | ||
installExtension, | ||
getInstalledExtensionInfo | ||
} from "./lib/azure-devops/extensions"; | ||
|
||
async function main() { | ||
const publisherName = process.env.DEV_AZ_PUBLISHER || ""; | ||
// warning: the Marketplace stuff calls this extensionId - the rest of the extension stuff calls it name | ||
const extensionName = process.env.DEV_AZ_EXTENSION_ID || ""; | ||
const azToken = process.env.DEV_AZURE_DEVOPS_EXT_PAT || ""; | ||
const azOrg = process.env.DEV_AZ_ORG || ""; | ||
|
||
const azUrl = getAzUrl(azOrg); | ||
const webApi: WebApi = await getWebApi(azUrl, azToken); | ||
|
||
try { | ||
const alreadyInstalledExtensionInfo = await getInstalledExtensionInfo( | ||
webApi, | ||
publisherName, | ||
extensionName | ||
); | ||
const alreadyInstalledVersion = alreadyInstalledExtensionInfo.version; | ||
console.log( | ||
`Extension version currently installed: ${alreadyInstalledVersion}` | ||
); | ||
|
||
console.log( | ||
"Attempting to install latest version of extension into org..." | ||
); | ||
// installExtension will throw an error if it is already installed | ||
const installRes = await installExtension( | ||
webApi, | ||
publisherName, | ||
extensionName | ||
); | ||
|
||
const afterInstallExtensionInfo = await getInstalledExtensionInfo( | ||
webApi, | ||
publisherName, | ||
extensionName | ||
); | ||
const afterInstallExtensionVersion = afterInstallExtensionInfo.version; | ||
console.log(`Extension version installed: ${afterInstallExtensionVersion}`); | ||
} catch (err) { | ||
console.log(`${err.statusCode} - ${err.message}`); | ||
} | ||
} | ||
|
||
if (require.main === module) { | ||
main(); | ||
} |
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,74 @@ | ||
import * as nodeApi from "azure-devops-node-api"; | ||
import * as BuildInterfaces from "azure-devops-node-api/interfaces/BuildInterfaces"; | ||
|
||
export async function getBuildDefinitions( | ||
webApi: nodeApi.WebApi, | ||
projectName: string | ||
) { | ||
const buildApi = await webApi.getBuildApi(); | ||
const buildDefinitions = await buildApi.getDefinitions(projectName); | ||
return buildDefinitions; | ||
} | ||
|
||
export async function getBuildDefinition( | ||
webApi: nodeApi.WebApi, | ||
projectName: string, | ||
buildDefinitionId: number | ||
) { | ||
const buildApi = await webApi.getBuildApi(); | ||
const buildDefinition = await buildApi.getDefinition( | ||
projectName, | ||
buildDefinitionId | ||
); | ||
return buildDefinition; | ||
} | ||
|
||
export async function getBuilds( | ||
webApi: nodeApi.WebApi, | ||
projectName: string, | ||
buildDefinitionId | ||
) { | ||
const buildApi = await webApi.getBuildApi(); | ||
const buildDefinition = await buildApi.getBuilds(projectName, [ | ||
buildDefinitionId | ||
]); | ||
return buildDefinition; | ||
} | ||
|
||
export async function getBuild( | ||
webApi: nodeApi.WebApi, | ||
projectName: string, | ||
buildId: number | ||
) { | ||
const buildApi = await webApi.getBuildApi(); | ||
const buildDefinition = await buildApi.getBuild(projectName, buildId); | ||
return buildDefinition; | ||
} | ||
|
||
export async function queueBuild( | ||
webApi: nodeApi.WebApi, | ||
projectName: string, | ||
build: BuildInterfaces.Build | ||
) { | ||
const buildApi = await webApi.getBuildApi(); | ||
const queueBuildResult: BuildInterfaces.Build = await buildApi.queueBuild( | ||
build, | ||
projectName | ||
); | ||
return queueBuildResult; | ||
} | ||
|
||
export async function launchBuildPipeline( | ||
webApi: nodeApi.WebApi, | ||
azOrg: string, | ||
projectName: string, | ||
buildDefinitionId: number | ||
) { | ||
const apiUrl = `https://dev.azure.com/${azOrg}/${projectName}/_apis/build/builds?api-version=5.1`; | ||
const res = await webApi.rest.create(apiUrl, { | ||
definition: { | ||
id: buildDefinitionId | ||
} | ||
}); | ||
return res as any; | ||
} |
Oops, something went wrong.