Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add doctl #37

Merged
merged 36 commits into from
Dec 13, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
ec57967
chore(pipeline): upgrade node 14 to 16
marceloavf Nov 23, 2021
321f7e3
chore(packages): upgrade versions
marceloavf Nov 23, 2021
cdefe52
feat: add DigitalOceanDoctlInstaller
marceloavf Nov 23, 2021
a215ea0
chore: upgrade packages
marceloavf Nov 23, 2021
6f4ed47
fix: add lint and webpack azure tool changes
marceloavf Nov 23, 2021
47d0903
fix: use lerna to group packages
marceloavf Nov 24, 2021
548eceb
fix: direct use dependencies that has an expression for webpack
marceloavf Nov 24, 2021
e97ab8a
chore: add lerna clean before run tests
marceloavf Nov 24, 2021
73f3f4b
chore: upgrade packages and default node to v16
marceloavf Nov 24, 2021
ebd68b5
chore: upgrade test packages
marceloavf Nov 24, 2021
2a36f63
chore: upgrade aws & semantic release packages
marceloavf Nov 24, 2021
b362e2b
test: enable sourcemaps to pass tests
marceloavf Nov 25, 2021
65e0481
chore: upgrade aws-sdk packages
marceloavf Nov 25, 2021
858a23b
chore: migrate to husky 7
marceloavf Nov 25, 2021
a93e617
chore: upgrade prettier & webpack
marceloavf Nov 25, 2021
fd5bd2d
chore: fix lint and loglevel
marceloavf Nov 26, 2021
8f52b6e
fix(download): watch for progress on object instead of request
marceloavf Nov 26, 2021
8b909e0
fix(download): remove httpDownloadProgress and use httpHeader & data
marceloavf Nov 26, 2021
7c69b3c
chore: upgrade aws-sdk
marceloavf Nov 29, 2021
35847ad
fix(doctlInstaller): get tool path and download
marceloavf Nov 29, 2021
f0d5672
chore: upgrade jest
marceloavf Nov 29, 2021
55b9a47
feat: add doctl runner
marceloavf Nov 29, 2021
ef263ad
fix: lint import rules and semicolon
marceloavf Nov 30, 2021
9cf9331
fix(webpack): auto import entries, remove replace files
marceloavf Nov 30, 2021
4fe0378
chore: upgrade packages
marceloavf Dec 6, 2021
0fc66f1
test: setup initial tests
marceloavf Dec 6, 2021
f43e4ec
test: add remaining tests for doctl
marceloavf Dec 6, 2021
fc599a0
chore: remove tests from tsconfig
marceloavf Dec 6, 2021
4f056d9
test: mock process cwd
marceloavf Dec 6, 2021
6adc7b2
chore: upgrade packages
marceloavf Dec 13, 2021
ba0f0d3
docs: add @marceloavf as a contributor
marceloavf Dec 13, 2021
a384305
chore: add all-contributors
marceloavf Dec 13, 2021
073c956
docs: add @usrme as a contributor
marceloavf Dec 13, 2021
538a8c0
docs: add @TrueBrain as a contributor
marceloavf Dec 13, 2021
5ce590c
docs: add tasks information
marceloavf Dec 13, 2021
ebbea7e
docs: fix typo
marceloavf Dec 13, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 49 additions & 0 deletions .all-contributorsrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
{
"projectName": "digitalocean-tools-vsts",
"projectOwner": "marceloavf",
"repoType": "github",
"repoHost": "https://github.com",
"files": [
"README.md"
],
"imageSize": 100,
"commit": true,
"commitConvention": "angular",
"contributors": [
{
"login": "marceloavf",
"name": "Marcelo Formentão",
"avatar_url": "https://avatars.githubusercontent.com/u/5435657?v=4",
"profile": "https://www.linkedin.com/in/marceloavf/",
"contributions": [
"question",
"code",
"content",
"design",
"doc",
"ideas",
"infra"
]
},
{
"login": "usrme",
"name": "usrme",
"avatar_url": "https://avatars.githubusercontent.com/u/5902545?v=4",
"profile": "https://usrme.xyz/",
"contributions": [
"doc"
]
},
{
"login": "TrueBrain",
"name": "Patric Stout",
"avatar_url": "https://avatars.githubusercontent.com/u/1663690?v=4",
"profile": "https://github.com/TrueBrain",
"contributions": [
"code",
"doc"
]
}
],
"contributorsPerLine": 7
}
30 changes: 30 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"root": true,
"parser": "@typescript-eslint/parser",
"plugins": [
"@typescript-eslint",
"prettier"
],
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/eslint-recommended",
"plugin:@typescript-eslint/recommended",
"prettier",
"plugin:import/recommended",
"plugin:import/typescript"
],
"rules": {
"@typescript-eslint/no-var-requires": 0,
"@typescript-eslint/ban-ts-comment": 1,
"semi": [2, "never"],
"import/order": ["error"]
},
"settings": {
"import/resolver": {
"typescript": {
"alwaysTryTypes": true,
"project": "tsconfig.json"
}
}
}
}
4 changes: 4 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

npx lint-staged
16 changes: 10 additions & 6 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
{
"editor.formatOnSave": true,
"jest.autoEnable": false,
"editor.defaultFormatter": "esbenp.prettier-vscode",
"[typescript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"editor.formatOnPaste": true,
"editor.formatOnSave": true,
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true
},
"eslint.alwaysShowStatus": true,
"editor.defaultFormatter": "esbenp.prettier-vscode",
"[jsonc]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
}
17 changes: 17 additions & 0 deletions Common/Node/Doctl.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import * as tl from 'azure-pipelines-task-lib/task'

export class Doctl {
public accessToken: string
public arguments: string
public pathToRun: string

constructor() {
try {
this.accessToken = tl.getVariable('doctl.token')
this.arguments = tl.getInput('arguments')
this.pathToRun = tl.getPathInput("pathToRun") || process.cwd()
} catch (error) {
throw new Error(error.message)
}
}
}
2 changes: 1 addition & 1 deletion Common/Node/utils/filterFiles.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as path from 'path'
import AWS from 'aws-sdk'
import { isEmpty } from 'lodash'
import * as path from 'path'
import matcher from 'matcher'

interface FilterFilesOnList {
Expand Down
16 changes: 14 additions & 2 deletions Extension/OVERVIEW.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,11 @@ DigitalOcean Tools provide the ability to upload and delete objects from Digital

## Tasks included

- [**DigitalOcean Spaces Upload:**](https://github.com/marceloavf/digitalocean-tools-vsts/wiki/DigitalOcean-Spaces-Upload) Upload file(s) and folder(s) content to DigitalOcean Spaces Bucket.
- [**DigitalOcean Spaces Delete:**](https://github.com/marceloavf/digitalocean-tools-vsts/wiki/DigitalOcean-Spaces-Delete) Delete file(s) from DigitalOcean Spaces Bucket.
- [**DigitalOcean Spaces Upload:**](https://github.com/marceloavf/digitalocean-tools-vsts/blob/master/Extension/OVERVIEW.md#digitalocean-spaces-upload) Upload file(s) and folder(s) content to DigitalOcean Spaces Bucket.
- [**DigitalOcean Spaces Delete:**](https://github.com/marceloavf/digitalocean-tools-vsts/blob/master/Extension/OVERVIEW.md#digitalocean-spaces-delete) Delete file(s) from DigitalOcean Spaces Bucket.
- [**DigitalOcean Spaces Download:**](https://github.com/marceloavf/digitalocean-tools-vsts/blob/master/Extension/OVERVIEW.md#digitalocean-spaces-download) Download file(s) from DigitalOcean Spaces Bucket.
- [**DigitalOcean Doctl Installer:**](https://github.com/marceloavf/digitalocean-tools-vsts/blob/master/Extension/OVERVIEW.md#digitalocean-doctl-installer) Download and install Doctl.
- [**DigitalOcean Doctl:**](https://github.com/marceloavf/digitalocean-tools-vsts/blob/master/Extension/OVERVIEW.md#digitalocean-doctl) Runs Doctl command(s).

## DigitalOcean Spaces Upload

Expand Down Expand Up @@ -54,6 +57,15 @@ Advanced Options:
- **Concurrency limit:** Specify how many files to download simultaneously.
- **Retry failed limit:** Specify how many times to retry a failed download.

## DigitalOcean Doctl Installer

No inputs needed to be provided in this task, it will install the latest version avaiable of Doctl.

## DigitalOcean Doctl

- **Arguments:** Arguments passed to the doctl script. Either ordinal parameters or named parameters.
- **Working Directory:** The working folder that the cli will be run against. Root is assumed when empty.

## Install the extension to your account

You can find the latest stable version of the Azure DevOps Extension tasks on the [Visual Studio Marketplace](https://marketplace.visualstudio.com/items?itemName=marcelo-formentao.digitalocean-tools).
Expand Down
29 changes: 27 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@ DigitalOcean Tools

<h4 align="center">

[![VS Marketplace Version](https://vsmarketplacebadge.apphb.com/version-short/marcelo-formentao.digitalocean-tools.svg?label=Production&color=0080ff)](https://marketplace.visualstudio.com/items?itemName=marcelo-formentao.digitalocean-tools) ![GitHub release (latest by date including pre-releases)](https://img.shields.io/github/v/release/marceloavf/digitalocean-tools-vsts?include_prerelease&label=Development&color=blueviolet) [![VS Marketplace Installs](https://vsmarketplacebadge.apphb.com/installs/marcelo-formentao.digitalocean-tools.svg)](https://marketplace.visualstudio.com/items?itemName=marcelo-formentao.digitalocean-tools) [![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg?color=success)](https://github.com/semantic-release/semantic-release) [![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)](http://makeapullrequest.com) [![Build Status](https://dev.azure.com/precisaosistemas/VSTSExtensions/_apis/build/status/marceloavf.digitalocean-tools-vsts?branchName=master)](https://dev.azure.com/precisaosistemas/VSTSExtensions/_build/latest?definitionId=264&branchName=master) [![codecov](https://codecov.io/gh/marceloavf/digitalocean-tools-vsts/branch/master/graph/badge.svg)](https://codecov.io/gh/marceloavf/digitalocean-tools-vsts) [![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=marceloavf_digitalocean-tools-vsts&metric=alert_status)](https://sonarcloud.io/dashboard?id=marceloavf_digitalocean-tools-vsts) [![Maintainability Rating](https://sonarcloud.io/api/project_badges/measure?project=marceloavf_digitalocean-tools-vsts&metric=sqale_rating)](https://sonarcloud.io/dashboard?id=marceloavf_digitalocean-tools-vsts)
[![FOSSA Status](https://app.fossa.com/api/projects/git%2Bgithub.com%2Fmarceloavf%2Fdigitalocean-tools-vsts.svg?type=shield)](https://app.fossa.com/projects/git%2Bgithub.com%2Fmarceloavf%2Fdigitalocean-tools-vsts?ref=badge_shield)
[![VS Marketplace Version](https://vsmarketplacebadge.apphb.com/version-short/marcelo-formentao.digitalocean-tools.svg?label=Production&color=0080ff)](https://marketplace.visualstudio.com/items?itemName=marcelo-formentao.digitalocean-tools) ![GitHub release (latest by date including pre-releases)](https://img.shields.io/github/v/release/marceloavf/digitalocean-tools-vsts?include_prerelease&label=Development&color=blueviolet) [![VS Marketplace Installs](https://vsmarketplacebadge.apphb.com/installs/marcelo-formentao.digitalocean-tools.svg)](https://marketplace.visualstudio.com/items?itemName=marcelo-formentao.digitalocean-tools) [![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg?color=success)](https://github.com/semantic-release/semantic-release) [![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)](http://makeapullrequest.com) [![Build Status](https://dev.azure.com/precisaosistemas/VSTSExtensions/_apis/build/status/marceloavf.digitalocean-tools-vsts?branchName=master)](https://dev.azure.com/precisaosistemas/VSTSExtensions/_build/latest?definitionId=264&branchName=master) [![codecov](https://codecov.io/gh/marceloavf/digitalocean-tools-vsts/branch/master/graph/badge.svg)](https://codecov.io/gh/marceloavf/digitalocean-tools-vsts) [![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=marceloavf_digitalocean-tools-vsts&metric=alert_status)](https://sonarcloud.io/dashboard?id=marceloavf_digitalocean-tools-vsts) [![Maintainability Rating](https://sonarcloud.io/api/project_badges/measure?project=marceloavf_digitalocean-tools-vsts&metric=sqale_rating)](https://sonarcloud.io/dashboard?id=marceloavf_digitalocean-tools-vsts)[![FOSSA Status](https://app.fossa.com/api/projects/git%2Bgithub.com%2Fmarceloavf%2Fdigitalocean-tools-vsts.svg?type=shield)](https://app.fossa.com/projects/git%2Bgithub.com%2Fmarceloavf%2Fdigitalocean-tools-vsts?ref=badge_shield)<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->
[![All Contributors](https://img.shields.io/badge/all_contributors-3-orange.svg?style=flat-square)](#contributors-)
<!-- ALL-CONTRIBUTORS-BADGE:END -->

</h4>

Expand All @@ -23,6 +24,8 @@ DigitalOcean Tools
- 🔹 &nbsp; [**DigitalOcean Spaces Upload:**](https://github.com/marceloavf/digitalocean-tools-vsts/blob/master/Extension/OVERVIEW.md#digitalocean-spaces-upload) Upload file(s) and folder(s) content to DigitalOcean Spaces Bucket.
- 🔹 &nbsp; [**DigitalOcean Spaces Delete:**](https://github.com/marceloavf/digitalocean-tools-vsts/blob/master/Extension/OVERVIEW.md#digitalocean-spaces-delete) Delete file(s) from DigitalOcean Spaces Bucket.
- 🔹 &nbsp; [**DigitalOcean Spaces Download:**](https://github.com/marceloavf/digitalocean-tools-vsts/blob/master/Extension/OVERVIEW.md#digitalocean-spaces-download) Download file(s) from DigitalOcean Spaces Bucket.
- 🔹 &nbsp; [**DigitalOcean Doctl Installer:**](https://github.com/marceloavf/digitalocean-tools-vsts/blob/master/Extension/OVERVIEW.md#digitalocean-doctl-installer) Download and install Doctl.
- 🔹 &nbsp; [**DigitalOcean Doctl:**](https://github.com/marceloavf/digitalocean-tools-vsts/blob/master/Extension/OVERVIEW.md#digitalocean-doctl) Runs Doctl command(s).

## 📟 &nbsp; Install the extension to your account

Expand All @@ -43,3 +46,25 @@ Please refer to our [wiki page](https://github.com/marceloavf/digitalocean-tools
## 📑 &nbsp; License

[![FOSSA Status](https://app.fossa.com/api/projects/git%2Bgithub.com%2Fmarceloavf%2Fdigitalocean-tools-vsts.svg?type=large)](https://app.fossa.com/projects/git%2Bgithub.com%2Fmarceloavf%2Fdigitalocean-tools-vsts?ref=badge_large)

## Contributors ✨

Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key)):

<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->
<!-- prettier-ignore-start -->
<!-- markdownlint-disable -->
<table>
<tr>
<td align="center"><a href="https://www.linkedin.com/in/marceloavf/"><img src="https://avatars.githubusercontent.com/u/5435657?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Marcelo Formentão</b></sub></a><br /><a href="#question-marceloavf" title="Answering Questions">💬</a> <a href="https://github.com/marceloavf/digitalocean-tools-vsts/commits?author=marceloavf" title="Code">💻</a> <a href="#content-marceloavf" title="Content">🖋</a> <a href="#design-marceloavf" title="Design">🎨</a> <a href="https://github.com/marceloavf/digitalocean-tools-vsts/commits?author=marceloavf" title="Documentation">📖</a> <a href="#ideas-marceloavf" title="Ideas, Planning, & Feedback">🤔</a> <a href="#infra-marceloavf" title="Infrastructure (Hosting, Build-Tools, etc)">🚇</a></td>
<td align="center"><a href="https://usrme.xyz/"><img src="https://avatars.githubusercontent.com/u/5902545?v=4?s=100" width="100px;" alt=""/><br /><sub><b>usrme</b></sub></a><br /><a href="https://github.com/marceloavf/digitalocean-tools-vsts/commits?author=usrme" title="Documentation">📖</a></td>
<td align="center"><a href="https://github.com/TrueBrain"><img src="https://avatars.githubusercontent.com/u/1663690?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Patric Stout</b></sub></a><br /><a href="https://github.com/marceloavf/digitalocean-tools-vsts/commits?author=TrueBrain" title="Code">💻</a> <a href="https://github.com/marceloavf/digitalocean-tools-vsts/commits?author=TrueBrain" title="Documentation">📖</a></td>
</tr>
</table>

<!-- markdownlint-restore -->
<!-- prettier-ignore-end -->

<!-- ALL-CONTRIBUTORS-LIST:END -->

This project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome!
10 changes: 10 additions & 0 deletions Tasks/DigitalOceanDoctl/digitalOceanDoctl.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import tl from './tl'
import { Runner } from './utils/Doctl'

const digitalOceanDoctl = new Runner()

export default () =>
digitalOceanDoctl
.init()
.then((result) => tl.setResult(tl.TaskResult.Succeeded, ''))
.catch((error) => tl.setResult(tl.TaskResult.Failed, error))
Binary file added Tasks/DigitalOceanDoctl/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions Tasks/DigitalOceanDoctl/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import init from './digitalOceanDoctl'

init()
10 changes: 10 additions & 0 deletions Tasks/DigitalOceanDoctl/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"name": "DigitalOceanDoctl",
"version": "1.0.0",
"main": "index.js",
"license": "MIT",
"dependencies": {
"azure-pipelines-task-lib": "3.1.10",
"azure-pipelines-tool-lib": "0.13.3"
}
}
53 changes: 53 additions & 0 deletions Tasks/DigitalOceanDoctl/task.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
{
"id": "06f78d7e-c262-47fa-9422-3d4f2d50875e",
"name": "DigitalOceanDoctl",
"friendlyName": "DigitalOcean Doctl",
"instanceNameFormat": "DigitalOcean Doctl $(Arguments)",
"description": "Executes Doctl",
"author": "Marcelo Formentão",
"helpMarkDown": "[More Information](https://github.com/marceloavf/digitalocean-tools-vsts) (Version #{Version}#).",
"category": "Utility",
"visibility": [
"Build",
"Release"
],
"version": {
"Major": 0,
"Minor": 0,
"Patch": 0
},
"runsOn": [
"Agent",
"DeploymentGroup"
],
"demands": ["doctl"],
"minimumAgentVersion": "1.91.0",
"inputs": [
{
"name": "arguments",
"type": "string",
"label": "Arguments",
"defaultValue": "",
"required": false,
"helpMarkDown": "Arguments passed to the doctl script. Either ordinal parameters or named parameters."
},
{
"name": "pathToRun",
"type": "filePath",
"label": "Working Directory",
"required": false
}
],
"execution": {
"Node10": {
"target": "index.js",
"argumentFormat": ""
}
},
"messages": {
"NotFound": "Couldn't locate Doctl",
"ExecutionFailed": "Doctl failed with exit code %d",
"DoctlFailed": "Doctl failed with error %s",
"TaskCompleted": "All specified files deleted from Space completed"
}
}
10 changes: 10 additions & 0 deletions Tasks/DigitalOceanDoctl/tl.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import * as path from 'path'
import * as tl from 'azure-pipelines-task-lib/task'

/**
* Set language loc file
*/
const taskManifestPath = path.join(__dirname, './task.json')
tl.setResourcePath(taskManifestPath)

export default tl
35 changes: 35 additions & 0 deletions Tasks/DigitalOceanDoctl/utils/Doctl.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import trm = require('azure-pipelines-task-lib/toolrunner')
import { Doctl } from '@Common/Doctl'
import tl from '../tl'

export class Runner extends Doctl {
public async init(): Promise<void> {
try {
const doctlPath = tl.which('doctl', true)

const doctl = tl.tool(doctlPath)
if (this.accessToken) doctl.arg(`--access-token ${this.accessToken}`)
doctl.line(this.arguments)

const options: trm.IExecOptions = {
cwd: this.pathToRun,
env: process.env,
silent: false,
failOnStdErr: false,
ignoreReturnCode: false,
outStream: undefined,
errStream: undefined,
windowsVerbatimArguments: undefined
}

const result = await doctl.exec(options)
if (result) {
throw new Error(tl.loc('ExecutionFailed', result))
}
} catch (err) {
console.error(tl.loc('DoctlFailed'), err)
throw err
}
}

}
Loading