diff --git a/repository-info-extension/context.html b/repository-info-extension/context.html new file mode 100644 index 0000000..a3b2f55 --- /dev/null +++ b/repository-info-extension/context.html @@ -0,0 +1,43 @@ + + + Repository Information + + + + + + +

Repository Information

+

+
+    
+
+    
+

ID

+

+

Name

+

+

URL

+

+
+ + diff --git a/repository-info-extension/images/fabrikam-logo.png b/repository-info-extension/images/fabrikam-logo.png new file mode 100644 index 0000000..f9bece7 Binary files /dev/null and b/repository-info-extension/images/fabrikam-logo.png differ diff --git a/repository-info-extension/images/hub-content.PNG b/repository-info-extension/images/hub-content.PNG new file mode 100644 index 0000000..37cb843 Binary files /dev/null and b/repository-info-extension/images/hub-content.PNG differ diff --git a/repository-info-extension/package-lock.json b/repository-info-extension/package-lock.json new file mode 100644 index 0000000..bf772cc --- /dev/null +++ b/repository-info-extension/package-lock.json @@ -0,0 +1,60 @@ +{ + "name": "repository-info-extension", + "version": "1.0.0", + "lockfileVersion": 1, + "requires": true, + "dependencies": { + "@types/jquery": { + "version": "3.3.10", + "resolved": "https://registry.npmjs.org/@types/jquery/-/jquery-3.3.10.tgz", + "integrity": "sha512-W2bE8pGh9Tsg8mxh+B6BSH8lTG6ZV7K2ZMAlEwSTqKFU1wMI5HShyRKSp3DngnxCmDu35tW3RAC4mxBFYRsTuw==" + }, + "@types/jqueryui": { + "version": "1.12.4", + "resolved": "https://registry.npmjs.org/@types/jqueryui/-/jqueryui-1.12.4.tgz", + "integrity": "sha512-N0h+mY9CgvP6eJc+Uc3yQiqXu8mxR1j2FcxbZz5RGrHR6POaWA4dAFsFbaLEk7CFG+Kv2s5iFx+xy830jongug==", + "requires": { + "@types/jquery": "*" + } + }, + "@types/knockout": { + "version": "3.4.59", + "resolved": "https://registry.npmjs.org/@types/knockout/-/knockout-3.4.59.tgz", + "integrity": "sha512-uLVb9AWPnQajGE8QETNVS2qPpxTVzsWOWP9dLwBrqfIkatR3mCOoU3QP8idI4YDwRRxdTlYgfSeMFbUOjENvyw==" + }, + "@types/mousetrap": { + "version": "1.5.34", + "resolved": "https://registry.npmjs.org/@types/mousetrap/-/mousetrap-1.5.34.tgz", + "integrity": "sha512-a2yhRIADupQfOFM75v7GfcQQLUxU705+i/xcZ3N/3PK3Xdo31SUfuCUByWPGOHB1e38m7MxTx/D8FPVsJXZKJw==" + }, + "@types/q": { + "version": "0.0.32", + "resolved": "http://registry.npmjs.org/@types/q/-/q-0.0.32.tgz", + "integrity": "sha1-vShOV8hPEyXacCur/IKlMoGQwMU=" + }, + "@types/react": { + "version": "15.6.19", + "resolved": "https://registry.npmjs.org/@types/react/-/react-15.6.19.tgz", + "integrity": "sha512-QUgMbR4JWOXOddjzTnieXlqiAWq8mQFbqQd7e5WwllGA3AEwuCE4vMhT05HaYGxHHCItS5vDX9Du0XWD1FQvnw==" + }, + "@types/requirejs": { + "version": "2.1.31", + "resolved": "https://registry.npmjs.org/@types/requirejs/-/requirejs-2.1.31.tgz", + "integrity": "sha512-b2soeyuU76rMbcRJ4e0hEl0tbMhFwZeTC0VZnfuWlfGlk6BwWNsev6kFu/twKABPX29wkX84wU2o+cEJoXsiTw==" + }, + "vss-web-extension-sdk": { + "version": "5.141.0", + "resolved": "https://registry.npmjs.org/vss-web-extension-sdk/-/vss-web-extension-sdk-5.141.0.tgz", + "integrity": "sha512-c/r/HWQh4hljKOSNQMiFoeICckKFfU/1nxDCVFhioDHOE8B0i5aJN9rrihGilgMXugzl8K5hBsZs42eFqd30AQ==", + "requires": { + "@types/jquery": ">=2.0.48", + "@types/jqueryui": ">=1.11.34", + "@types/knockout": "^3.4.49", + "@types/mousetrap": "~1.5.34", + "@types/q": "0.0.32", + "@types/react": "^15.6.12", + "@types/requirejs": ">=2.1.28" + } + } + } +} diff --git a/repository-info-extension/package.json b/repository-info-extension/package.json new file mode 100644 index 0000000..1605d7b --- /dev/null +++ b/repository-info-extension/package.json @@ -0,0 +1,13 @@ +{ + "name": "repository-info-extension", + "version": "1.0.0", + "description": "Provides an example for accessing the currently selected repository from an extension.", + "repository": { + "type": "git", + "url": "https://github.com/Microsoft/vsts-extension-samples/tree/master/repository-info-extension" + }, + "author": "Microsoft", + "dependencies": { + "vss-web-extension-sdk": "^5.140.0" + } +} diff --git a/repository-info-extension/readme.md b/repository-info-extension/readme.md new file mode 100644 index 0000000..a0ee328 --- /dev/null +++ b/repository-info-extension/readme.md @@ -0,0 +1,13 @@ +This extension is an example of how to access information about the user's currently selected repository from an extension. Note: this information will only be accessible on pages that are within the "code" hub, including new pages that may be added by the extension (as in this example). + +## Building + +This extension is built using NodeJS with the [typescript](https://github.com/Microsoft/TypeScript) and [tfs-cli](https://github.com/Microsoft/tfs-cli) packages. Once those are installed, open a command prompt at the extension's root and run: + +1. `npm install` +2. `tsc` +3. `tfx extension create` + +## Screenshot + +![hub](images/hub-content.PNG) diff --git a/repository-info-extension/scripts/app.ts b/repository-info-extension/scripts/app.ts new file mode 100644 index 0000000..6cfabf5 --- /dev/null +++ b/repository-info-extension/scripts/app.ts @@ -0,0 +1,14 @@ +/// + +import TFS_VC_Services = require("TFS/VersionControl/Services"); + +export async function execute() { + const svc = await TFS_VC_Services.VersionControlRepositoryService.getService(); + const repo = await svc.getCurrentGitRepository(); + let idContainer = document.getElementById("repository-id"); + let nameContainer = document.getElementById("repository-name"); + let urlContainer = document.getElementById("repository-url"); + idContainer.innerHTML = repo.id; + nameContainer.innerHTML = repo.name; + urlContainer.innerHTML = repo.url; +} \ No newline at end of file diff --git a/repository-info-extension/tsconfig.json b/repository-info-extension/tsconfig.json new file mode 100644 index 0000000..5361713 --- /dev/null +++ b/repository-info-extension/tsconfig.json @@ -0,0 +1,9 @@ +{ + "compilerOptions": { + "module": "amd", + "sourceMap": false + }, + "exclude": [ + "node_modules" + ] +} \ No newline at end of file diff --git a/repository-info-extension/vss-extension.json b/repository-info-extension/vss-extension.json new file mode 100644 index 0000000..8820363 --- /dev/null +++ b/repository-info-extension/vss-extension.json @@ -0,0 +1,68 @@ +{ + "manifestVersion": 1, + "id": "repository-info-extension", + "version": "1.0.0", + "name": "Repository Information Sample", + "description": "Provides an example for accessing the currently selected repository from an extension.", + "publisher": "ms-samples", + "public": true, + "categories": [ + "Developer samples", + "Code" + ], + "links": { + "learn": { + "uri": "https://github.com/Microsoft/vso-extension-samples" + } + }, + "icons": { + "default": "images/fabrikam-logo.png" + }, + "targets": [ + { + "id": "Microsoft.VisualStudio.Services" + } + ], + "content": { + "details": { + "path": "readme.md" + } + }, + "branding": { + "color": "rgb(190, 39, 3)", + "theme": "dark" + }, + "files": [ + { + "path": "scripts/app.js", + "addressable": true + }, + { + "path": "images", + "addressable": true + }, + { + "path": "context.html", + "addressable": true + }, + { + "path": "node_modules/vss-web-extension-sdk/lib", + "addressable": true + } + ], + "contributions": [ + { + "id": "repository-info-hub", + "type": "ms.vss-web.hub", + "description": "Custom hub in the Code hub group that displays information about the currently active Git repository.", + "targets": [ + "ms.vss-code-web.code-hub-group" + ], + "properties": { + "name": "Repository Information", + "order": 100, + "uri": "context.html" + } + } + ] +}