diff --git a/.github/workflows/extension.yml b/.github/workflows/extension.yml index c52029ab..8dab185e 100644 --- a/.github/workflows/extension.yml +++ b/.github/workflows/extension.yml @@ -60,13 +60,13 @@ jobs: working-directory: '${{ github.workspace }}/extension' - name: Build - run: npm run build:prod + run: npm run build working-directory: '${{ github.workspace }}/extension' - name: Install tfx-cli run: npm install -g tfx-cli@0.12.0 - - name: Replace tokens + - name: Update version numbers in vss-extension.json overrides files uses: cschleiden/replace-tokens@v1 with: files: '["${{ github.workspace }}/extension/overrides*.json"]' @@ -74,11 +74,11 @@ jobs: MAJOR_MINOR_PATCH: ${{ steps.gitversion.outputs.majorMinorPatch }} BUILD_NUMBER: ${{ github.run_number }} - - name: Update values in extension/task/task.json + - name: Update version numbers in task.json run: | - echo "`jq '.version.Major=${{ steps.gitversion.outputs.major }}' extension/task/task.json`" > extension/task/task.json - echo "`jq '.version.Minor=${{ steps.gitversion.outputs.minor }}' extension/task/task.json`" > extension/task/task.json - echo "`jq '.version.Patch=${{ github.run_number }}' extension/task/task.json`" > extension/task/task.json + echo "`jq '.version.Major=${{ steps.gitversion.outputs.major }}' extension/tasks/dependabot/dependabotV1/task.json`" > extension/tasks/dependabot/dependabotV1/task.json + echo "`jq '.version.Minor=${{ steps.gitversion.outputs.minor }}' extension/tasks/dependabot/dependabotV1/task.json`" > extension/tasks/dependabot/dependabotV1/task.json + echo "`jq '.version.Patch=${{ github.run_number }}' extension/tasks/dependabot/dependabotV1/task.json`" > extension/tasks/dependabot/dependabotV1/task.json - name: Create Extension (dev) run: > diff --git a/docs/extension.md b/docs/extension.md index 50af697e..408f0755 100644 --- a/docs/extension.md +++ b/docs/extension.md @@ -28,22 +28,28 @@ npm install ```bash cd extension -npm run build:prod +npm run build ``` To generate the Azure DevOps `.vsix` extension package for testing, you'll first need to [create a publisher account](https://learn.microsoft.com/en-us/azure/devops/extend/publish/overview?view=azure-devops#create-a-publisher) on the [Visual Studio Marketplace Publishing Portal](https://marketplace.visualstudio.com/manage/createpublisher?managePageRedirect=true). After this, override your publisher ID below and generate the extension with: ```bash -npx tfx-cli extension create --overrides-file overrides.local.json --override "{\"publisher\": \"your-publisher-id-here\"}" --json5 +npm run package -- --overrides-file overrides.local.json --rev-version --publisher your-publisher-id-here ``` ## Installing the extension To test the extension in Azure DevOps, you'll first need to build the extension `.vsix` file (see above). After this, [publish your extension](https://learn.microsoft.com/en-us/azure/devops/extend/publish/overview?view=azure-devops#publish-your-extension), then [install your extension](https://learn.microsoft.com/en-us/azure/devops/extend/publish/overview?view=azure-devops#install-your-extension). +## Running the task locally + +```bash +npm start +``` + ## Running the unit tests ```bash cd extension -npm run test +npm test ``` diff --git a/extension/.gitignore b/extension/.gitignore index 57c2ca3a..e949d8ed 100644 --- a/extension/.gitignore +++ b/extension/.gitignore @@ -1,4 +1,4 @@ node_modules .taskkey -task/**/*.js +**/*.js *.vsix \ No newline at end of file diff --git a/extension/jest.config.ts b/extension/jest.config.ts index e095ec23..e82e036a 100644 --- a/extension/jest.config.ts +++ b/extension/jest.config.ts @@ -7,8 +7,7 @@ const config: Config.InitialOptions = { // "^.+\\.test.tsx?$": "ts-jest", // }, testEnvironment: 'node', - preset: 'ts-jest', - rootDir: './tests', + preset: 'ts-jest' }; export default config; diff --git a/extension/overrides.local.json b/extension/overrides.local.json index caa39dcf..8063d93a 100644 --- a/extension/overrides.local.json +++ b/extension/overrides.local.json @@ -1,5 +1,5 @@ { "id": "dependabot-local", - "version": "0.1.0.6", + "version": "1.0.0.0", "name": "Dependabot (Local)" } diff --git a/extension/package.json b/extension/package.json index b4bff593..2ce3de93 100644 --- a/extension/package.json +++ b/extension/package.json @@ -4,8 +4,10 @@ "description": "Dependabot Azure DevOps task", "main": "''", "scripts": { + "postdependencies": "cp -r node_modules tasks/dependabot/dependabotV1/node_modules", "build": "tsc -p .", - "build:prod": "npm run build && cp -r node_modules task/node_modules", + "package": "npx tfx-cli extension create --json5", + "start": "node tasks/dependabot/dependabotV1/index.js", "test": "jest" }, "repository": { diff --git a/extension/task/icon.png b/extension/tasks/dependabot/dependabotV1/icon.png similarity index 100% rename from extension/task/icon.png rename to extension/tasks/dependabot/dependabotV1/icon.png diff --git a/extension/task/index.ts b/extension/tasks/dependabot/dependabotV1/index.ts similarity index 99% rename from extension/task/index.ts rename to extension/tasks/dependabot/dependabotV1/index.ts index b2d5ddfc..774f1db9 100644 --- a/extension/task/index.ts +++ b/extension/tasks/dependabot/dependabotV1/index.ts @@ -1,6 +1,6 @@ import * as tl from 'azure-pipelines-task-lib/task'; import { ToolRunner } from 'azure-pipelines-task-lib/toolrunner'; -import { IDependabotRegistry, IDependabotUpdate } from './IDependabotConfig'; +import { IDependabotRegistry, IDependabotUpdate } from './utils/IDependabotConfig'; import getSharedVariables from './utils/getSharedVariables'; import { parseConfigFile } from './utils/parseConfigFile'; import { resolveAzureDevOpsIdentities } from './utils/resolveAzureDevOpsIdentities'; diff --git a/extension/task/task.json b/extension/tasks/dependabot/dependabotV1/task.json similarity index 99% rename from extension/task/task.json rename to extension/tasks/dependabot/dependabotV1/task.json index bdb71f26..b7368afa 100644 --- a/extension/task/task.json +++ b/extension/tasks/dependabot/dependabotV1/task.json @@ -14,7 +14,7 @@ "demands": [], "version": { "Major": 1, - "Minor": 6, + "Minor": 0, "Patch": 0 }, "instanceNameFormat": "Dependabot", diff --git a/extension/task/IDependabotConfig.ts b/extension/tasks/dependabot/dependabotV1/utils/IDependabotConfig.ts similarity index 100% rename from extension/task/IDependabotConfig.ts rename to extension/tasks/dependabot/dependabotV1/utils/IDependabotConfig.ts diff --git a/extension/tests/utils/convertPlaceholder.test.ts b/extension/tasks/dependabot/dependabotV1/utils/convertPlaceholder.test.ts similarity index 93% rename from extension/tests/utils/convertPlaceholder.test.ts rename to extension/tasks/dependabot/dependabotV1/utils/convertPlaceholder.test.ts index eed88400..d16418a6 100644 --- a/extension/tests/utils/convertPlaceholder.test.ts +++ b/extension/tasks/dependabot/dependabotV1/utils/convertPlaceholder.test.ts @@ -1,4 +1,4 @@ -import { extractPlaceholder } from '../../task/utils/convertPlaceholder'; +import { extractPlaceholder } from './convertPlaceholder'; describe('Parse property placeholder', () => { it('Should return key with underscores', () => { diff --git a/extension/task/utils/convertPlaceholder.ts b/extension/tasks/dependabot/dependabotV1/utils/convertPlaceholder.ts similarity index 100% rename from extension/task/utils/convertPlaceholder.ts rename to extension/tasks/dependabot/dependabotV1/utils/convertPlaceholder.ts diff --git a/extension/tests/utils/extractHostname.test.ts b/extension/tasks/dependabot/dependabotV1/utils/extractHostname.test.ts similarity index 91% rename from extension/tests/utils/extractHostname.test.ts rename to extension/tasks/dependabot/dependabotV1/utils/extractHostname.test.ts index ca8d01f7..78044219 100644 --- a/extension/tests/utils/extractHostname.test.ts +++ b/extension/tasks/dependabot/dependabotV1/utils/extractHostname.test.ts @@ -1,4 +1,4 @@ -import extractHostname from '../../task/utils/extractHostname'; +import extractHostname from './extractHostname'; describe('Extract hostname', () => { it('Should convert old *.visualstudio.com hostname to dev.azure.com', () => { diff --git a/extension/task/utils/extractHostname.ts b/extension/tasks/dependabot/dependabotV1/utils/extractHostname.ts similarity index 100% rename from extension/task/utils/extractHostname.ts rename to extension/tasks/dependabot/dependabotV1/utils/extractHostname.ts diff --git a/extension/tests/utils/extractOrganization.test.ts b/extension/tasks/dependabot/dependabotV1/utils/extractOrganization.test.ts similarity index 90% rename from extension/tests/utils/extractOrganization.test.ts rename to extension/tasks/dependabot/dependabotV1/utils/extractOrganization.test.ts index a827bae0..ebdb8209 100644 --- a/extension/tests/utils/extractOrganization.test.ts +++ b/extension/tasks/dependabot/dependabotV1/utils/extractOrganization.test.ts @@ -1,4 +1,4 @@ -import extractOrganization from '../../task/utils/extractOrganization'; +import extractOrganization from './extractOrganization'; describe('Extract organization name', () => { it('Should extract organization for on-premise domain', () => { diff --git a/extension/task/utils/extractOrganization.ts b/extension/tasks/dependabot/dependabotV1/utils/extractOrganization.ts similarity index 100% rename from extension/task/utils/extractOrganization.ts rename to extension/tasks/dependabot/dependabotV1/utils/extractOrganization.ts diff --git a/extension/tests/utils/extractVirtualDirectory.test.ts b/extension/tasks/dependabot/dependabotV1/utils/extractVirtualDirectory.test.ts similarity index 86% rename from extension/tests/utils/extractVirtualDirectory.test.ts rename to extension/tasks/dependabot/dependabotV1/utils/extractVirtualDirectory.test.ts index 35a734b8..71ce773d 100644 --- a/extension/tests/utils/extractVirtualDirectory.test.ts +++ b/extension/tasks/dependabot/dependabotV1/utils/extractVirtualDirectory.test.ts @@ -1,4 +1,4 @@ -import extractVirtualDirectory from '../../task/utils/extractVirtualDirectory'; +import extractVirtualDirectory from './extractVirtualDirectory'; describe('Extract virtual directory', () => { it('Should extract virtual directory', () => { diff --git a/extension/task/utils/extractVirtualDirectory.ts b/extension/tasks/dependabot/dependabotV1/utils/extractVirtualDirectory.ts similarity index 100% rename from extension/task/utils/extractVirtualDirectory.ts rename to extension/tasks/dependabot/dependabotV1/utils/extractVirtualDirectory.ts diff --git a/extension/task/utils/getAzureDevOpsAccessToken.ts b/extension/tasks/dependabot/dependabotV1/utils/getAzureDevOpsAccessToken.ts similarity index 100% rename from extension/task/utils/getAzureDevOpsAccessToken.ts rename to extension/tasks/dependabot/dependabotV1/utils/getAzureDevOpsAccessToken.ts diff --git a/extension/task/utils/getDockerImageTag.ts b/extension/tasks/dependabot/dependabotV1/utils/getDockerImageTag.ts similarity index 100% rename from extension/task/utils/getDockerImageTag.ts rename to extension/tasks/dependabot/dependabotV1/utils/getDockerImageTag.ts diff --git a/extension/task/utils/getGithubAccessToken.ts b/extension/tasks/dependabot/dependabotV1/utils/getGithubAccessToken.ts similarity index 100% rename from extension/task/utils/getGithubAccessToken.ts rename to extension/tasks/dependabot/dependabotV1/utils/getGithubAccessToken.ts diff --git a/extension/task/utils/getSharedVariables.ts b/extension/tasks/dependabot/dependabotV1/utils/getSharedVariables.ts similarity index 100% rename from extension/task/utils/getSharedVariables.ts rename to extension/tasks/dependabot/dependabotV1/utils/getSharedVariables.ts diff --git a/extension/tests/utils/parseConfigFile.test.ts b/extension/tasks/dependabot/dependabotV1/utils/parseConfigFile.test.ts similarity index 97% rename from extension/tests/utils/parseConfigFile.test.ts rename to extension/tasks/dependabot/dependabotV1/utils/parseConfigFile.test.ts index 864218a2..2e908379 100644 --- a/extension/tests/utils/parseConfigFile.test.ts +++ b/extension/tasks/dependabot/dependabotV1/utils/parseConfigFile.test.ts @@ -1,11 +1,11 @@ import * as fs from 'fs'; import { load } from 'js-yaml'; -import { IDependabotRegistry, IDependabotUpdate } from '../../task/IDependabotConfig'; -import { parseRegistries, parseUpdates, validateConfiguration } from '../../task/utils/parseConfigFile'; +import { IDependabotRegistry, IDependabotUpdate } from './IDependabotConfig'; +import { parseRegistries, parseUpdates, validateConfiguration } from './parseConfigFile'; describe('Parse configuration file', () => { it('Parsing works as expected', () => { - let config: any = load(fs.readFileSync('tests/utils/dependabot.yml', 'utf-8')); + let config: any = load(fs.readFileSync('tests/config/dependabot.yml', 'utf-8')); let updates = parseUpdates(config); expect(updates.length).toBe(3); @@ -36,7 +36,7 @@ describe('Parse configuration file', () => { describe('Parse registries', () => { it('Parsing works as expected', () => { - let config: any = load(fs.readFileSync('tests/utils/sample-registries.yml', 'utf-8')); + let config: any = load(fs.readFileSync('tests/config/sample-registries.yml', 'utf-8')); let registries = parseRegistries(config); expect(Object.keys(registries).length).toBe(11); diff --git a/extension/task/utils/parseConfigFile.ts b/extension/tasks/dependabot/dependabotV1/utils/parseConfigFile.ts similarity index 99% rename from extension/task/utils/parseConfigFile.ts rename to extension/tasks/dependabot/dependabotV1/utils/parseConfigFile.ts index e158f679..356aa7f5 100644 --- a/extension/task/utils/parseConfigFile.ts +++ b/extension/tasks/dependabot/dependabotV1/utils/parseConfigFile.ts @@ -5,7 +5,7 @@ import * as fs from 'fs'; import { load } from 'js-yaml'; import * as path from 'path'; import { URL } from 'url'; -import { IDependabotConfig, IDependabotRegistry, IDependabotUpdate } from '../IDependabotConfig'; +import { IDependabotConfig, IDependabotRegistry, IDependabotUpdate } from './IDependabotConfig'; import { convertPlaceholder } from './convertPlaceholder'; import { ISharedVariables } from './getSharedVariables'; diff --git a/extension/tests/utils/resolveAzureDevOpsIdentities.test.ts b/extension/tasks/dependabot/dependabotV1/utils/resolveAzureDevOpsIdentities.test.ts similarity index 98% rename from extension/tests/utils/resolveAzureDevOpsIdentities.test.ts rename to extension/tasks/dependabot/dependabotV1/utils/resolveAzureDevOpsIdentities.test.ts index d3e54d4c..1e0d91cf 100644 --- a/extension/tests/utils/resolveAzureDevOpsIdentities.test.ts +++ b/extension/tasks/dependabot/dependabotV1/utils/resolveAzureDevOpsIdentities.test.ts @@ -1,6 +1,6 @@ import axios from 'axios'; import { describe } from 'node:test'; -import { isHostedAzureDevOps, resolveAzureDevOpsIdentities } from '../../task/utils/resolveAzureDevOpsIdentities'; +import { isHostedAzureDevOps, resolveAzureDevOpsIdentities } from './resolveAzureDevOpsIdentities'; describe('isHostedAzureDevOps', () => { it('Old visualstudio url is hosted.', () => { diff --git a/extension/task/utils/resolveAzureDevOpsIdentities.ts b/extension/tasks/dependabot/dependabotV1/utils/resolveAzureDevOpsIdentities.ts similarity index 100% rename from extension/task/utils/resolveAzureDevOpsIdentities.ts rename to extension/tasks/dependabot/dependabotV1/utils/resolveAzureDevOpsIdentities.ts diff --git a/extension/tests/utils/dependabot.yml b/extension/tests/config/dependabot.yml similarity index 100% rename from extension/tests/utils/dependabot.yml rename to extension/tests/config/dependabot.yml diff --git a/extension/tests/utils/sample-registries.yml b/extension/tests/config/sample-registries.yml similarity index 100% rename from extension/tests/utils/sample-registries.yml rename to extension/tests/config/sample-registries.yml diff --git a/extension/vss-extension.json b/extension/vss-extension.json index 7be9b6ec..7fbf213f 100644 --- a/extension/vss-extension.json +++ b/extension/vss-extension.json @@ -2,7 +2,7 @@ "manifestVersion": 1, "id": "dependabot", "name": "Dependabot", - "version": "0.1.0", + "version": "1.0.0", "publisher": "tingle-software", "public": false, "targets": [ @@ -31,7 +31,7 @@ }, "files": [ { - "path": "task" + "path": "tasks" }, { "path": "images", @@ -44,7 +44,7 @@ "type": "ms.vss-distributed-task.task", "targets": ["ms.vss-distributed-task.tasks"], "properties": { - "name": "task" + "name": "tasks/dependabot" } } ]