From 90f5f6595caee79a933bb1c89457326ab2a77a61 Mon Sep 17 00:00:00 2001 From: Ross Knudsen Date: Mon, 1 Apr 2024 10:00:38 +1300 Subject: [PATCH] initial implementation (#1) --- .gitignore | 2 ++ package-lock.json | 36 +++++++++++++++++++ package.json | 24 +++++++++++++ src/index.ts | 89 +++++++++++++++++++++++++++++++++++++++++++++++ tsconfig.json | 11 ++++++ 5 files changed, 162 insertions(+) create mode 100644 .gitignore create mode 100644 package-lock.json create mode 100644 package.json create mode 100644 src/index.ts create mode 100644 tsconfig.json diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..ed1bf77 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +out/ +node_modules/ diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 0000000..2e77781 --- /dev/null +++ b/package-lock.json @@ -0,0 +1,36 @@ +{ + "name": "vscode-nuget-installer-api", + "version": "0.0.0", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "vscode-nuget-installer-api", + "version": "0.0.0", + "license": "MIT", + "devDependencies": { + "@types/vscode": "^1.75.0", + "typescript": "^5.4.3" + } + }, + "node_modules/@types/vscode": { + "version": "1.87.0", + "resolved": "https://registry.npmjs.org/@types/vscode/-/vscode-1.87.0.tgz", + "integrity": "sha512-y3yYJV2esWr8LNjp3VNbSMWG7Y43jC8pCldG8YwiHGAQbsymkkMMt0aDT1xZIOFM2eFcNiUc+dJMx1+Z0UT8fg==", + "dev": true + }, + "node_modules/typescript": { + "version": "5.4.3", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.4.3.tgz", + "integrity": "sha512-KrPd3PKaCLr78MalgiwJnA25Nm8HAmdwN3mYUYZgG/wizIo9EainNVQI9/yDavtVFRN2h3k8uf3GLHuhDMgEHg==", + "dev": true, + "bin": { + "tsc": "bin/tsc", + "tsserver": "bin/tsserver" + }, + "engines": { + "node": ">=14.17" + } + } + } +} diff --git a/package.json b/package.json new file mode 100644 index 0000000..f878ac2 --- /dev/null +++ b/package.json @@ -0,0 +1,24 @@ +{ + "name": "vscode-nuget-installer-api", + "version": "0.0.0", + "description": "Contracts for VS Code Nuget Installer", + "main": "out/index.js", + "types": "out/index.d.ts", + "scripts": { + "build": "tsc" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/kavod-io/vscode-nuget-installer-api.git" + }, + "author": "Ross Knudsen", + "license": "MIT", + "bugs": { + "url": "https://github.com/kavod-io/vscode-nuget-installer-api/issues" + }, + "homepage": "https://github.com/kavod-io/vscode-nuget-installer-api#readme", + "devDependencies": { + "@types/vscode": "^1.75.0", + "typescript": "^5.4.3" + } +} diff --git a/src/index.ts b/src/index.ts new file mode 100644 index 0000000..0bf9710 --- /dev/null +++ b/src/index.ts @@ -0,0 +1,89 @@ +/** + * This is a definition for a Nuget source. These are defined in the extension settings. + */ +export interface PackageSource { + name: string; + + /** + * Service Index URL e.g. https://api.nuget.org/v3/index.json + */ + url: string; + + credentials: Credentials | null; +} + +export interface Credentials { + username: string; + password: string; +} + +export type Message = + | SetProjectsMessage + | SetSourcesMessage + | AddCompleteMessage + | RemoveCompleteMessage; + +export interface SetProjectsMessage { + command: "setProjects"; + payload: Project[]; + commandId: string; +} + +export interface SetSourcesMessage { + command: "setSources"; + payload: PackageSource[]; + commandId: string; +} + +export interface AddCompleteMessage { + command: "addCompleted"; + commandId: string; +} + +export interface RemoveCompleteMessage { + command: "removeCompleted"; + commandId: string; +} + +export interface Project { + path: string; + projectName: string; + packages: ProjectPackage[]; +} + +export interface ProjectPackage { + id: string; + version: string; +} + +export type Command = + | GetProjectCommand + | GetSourcesCommand + | AddPackagesCommand + | RemovePackagesCommand; + +export interface GetProjectCommand { + command: "getProjects"; + commandId: string; +} + +export interface GetSourcesCommand { + command: "getSources"; + commandId: string; +} + +export interface AddPackagesCommand { + command: "add"; + commandId: string; + source: string; + projects: Project[]; + packageId: string; + version: string; +} + +export interface RemovePackagesCommand { + command: "remove"; + commandId: string; + projects: Project[]; + packageId: string; +} diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 0000000..d1a17a9 --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,11 @@ +{ + "compilerOptions": { + "target": "es2015", + "module": "commonjs", + "outDir": "out", + "declaration": true + }, + "include": [ + "src/index.ts" + ] + } \ No newline at end of file