Compare commits

...

9 Commits

Author SHA1 Message Date
4ea00e5f25 1.0.5 2024-01-24 23:56:30 +01:00
758e3f9a58 fix(core): update 2024-01-24 23:56:29 +01:00
efc666c464 1.0.4 2024-01-24 15:24:53 +01:00
eab8a38234 fix(core): update 2024-01-24 15:24:53 +01:00
ba7ffa45e1 1.0.3 2019-01-05 22:00:21 +01:00
b35e87b2dd 1.0.2 2019-01-05 22:00:03 +01:00
0498c1d793 fix(core): update 2019-01-05 22:00:02 +01:00
c193fe9546 1.0.2 2017-09-17 17:35:51 +02:00
c07457d43e initial 2017-09-17 17:35:01 +02:00
23 changed files with 5990 additions and 81 deletions

View File

@ -0,0 +1,66 @@
name: Default (not tags)
on:
push:
tags-ignore:
- '**'
env:
IMAGE: registry.gitlab.com/hosttoday/ht-docker-node:npmci
NPMCI_COMPUTED_REPOURL: https://${{gitea.repository_owner}}:${{secrets.GITEA_TOKEN}}@gitea.lossless.digital/${{gitea.repository}}.git
NPMCI_TOKEN_NPM: ${{secrets.NPMCI_TOKEN_NPM}}
NPMCI_TOKEN_NPM2: ${{secrets.NPMCI_TOKEN_NPM2}}
NPMCI_GIT_GITHUBTOKEN: ${{secrets.NPMCI_GIT_GITHUBTOKEN}}
NPMCI_URL_CLOUDLY: ${{secrets.NPMCI_URL_CLOUDLY}}
jobs:
security:
runs-on: ubuntu-latest
continue-on-error: true
container:
image: ${{ env.IMAGE }}
steps:
- uses: actions/checkout@v3
- name: Install pnpm and npmci
run: |
pnpm install -g pnpm
pnpm install -g @shipzone/npmci
- name: Run npm prepare
run: npmci npm prepare
- name: Audit production dependencies
run: |
npmci command npm config set registry https://registry.npmjs.org
npmci command pnpm audit --audit-level=high --prod
continue-on-error: true
- name: Audit development dependencies
run: |
npmci command npm config set registry https://registry.npmjs.org
npmci command pnpm audit --audit-level=high --dev
continue-on-error: true
test:
if: ${{ always() }}
needs: security
runs-on: ubuntu-latest
container:
image: ${{ env.IMAGE }}
steps:
- uses: actions/checkout@v3
- name: Test stable
run: |
npmci node install stable
npmci npm install
npmci npm test
- name: Test build
run: |
npmci node install stable
npmci npm install
npmci npm build

View File

@ -0,0 +1,124 @@
name: Default (tags)
on:
push:
tags:
- '*'
env:
IMAGE: registry.gitlab.com/hosttoday/ht-docker-node:npmci
NPMCI_COMPUTED_REPOURL: https://${{gitea.repository_owner}}:${{secrets.GITEA_TOKEN}}@gitea.lossless.digital/${{gitea.repository}}.git
NPMCI_TOKEN_NPM: ${{secrets.NPMCI_TOKEN_NPM}}
NPMCI_TOKEN_NPM2: ${{secrets.NPMCI_TOKEN_NPM2}}
NPMCI_GIT_GITHUBTOKEN: ${{secrets.NPMCI_GIT_GITHUBTOKEN}}
NPMCI_URL_CLOUDLY: ${{secrets.NPMCI_URL_CLOUDLY}}
jobs:
security:
runs-on: ubuntu-latest
continue-on-error: true
container:
image: ${{ env.IMAGE }}
steps:
- uses: actions/checkout@v3
- name: Prepare
run: |
pnpm install -g pnpm
pnpm install -g @shipzone/npmci
npmci npm prepare
- name: Audit production dependencies
run: |
npmci command npm config set registry https://registry.npmjs.org
npmci command pnpm audit --audit-level=high --prod
continue-on-error: true
- name: Audit development dependencies
run: |
npmci command npm config set registry https://registry.npmjs.org
npmci command pnpm audit --audit-level=high --dev
continue-on-error: true
test:
if: ${{ always() }}
needs: security
runs-on: ubuntu-latest
container:
image: ${{ env.IMAGE }}
steps:
- uses: actions/checkout@v3
- name: Prepare
run: |
pnpm install -g pnpm
pnpm install -g @shipzone/npmci
npmci npm prepare
- name: Test stable
run: |
npmci node install stable
npmci npm install
npmci npm test
- name: Test build
run: |
npmci node install stable
npmci npm install
npmci npm build
release:
needs: test
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
container:
image: ${{ env.IMAGE }}
steps:
- uses: actions/checkout@v3
- name: Prepare
run: |
pnpm install -g pnpm
pnpm install -g @shipzone/npmci
npmci npm prepare
- name: Release
run: |
npmci node install stable
npmci npm publish
metadata:
needs: test
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
container:
image: ${{ env.IMAGE }}
continue-on-error: true
steps:
- uses: actions/checkout@v3
- name: Prepare
run: |
pnpm install -g pnpm
pnpm install -g @shipzone/npmci
npmci npm prepare
- name: Code quality
run: |
npmci command npm install -g typescript
npmci npm install
- name: Trigger
run: npmci trigger
- name: Build docs and upload artifacts
run: |
npmci node install stable
npmci npm install
pnpm install -g @git.zone/tsdoc
npmci command tsdoc
continue-on-error: true

23
.gitignore vendored
View File

@ -1,5 +1,20 @@
coverage/ .nogit/
node_modules/
pages/
public/
# artifacts
coverage/
public/
pages/
# installs
node_modules/
# caches
.yarn/
.cache/
.rpt2_cache
# builds
dist/
dist_*/
# custom

View File

@ -1,59 +0,0 @@
image: hosttoday/ht-docker-node:npmts
stages:
- test
- release
- trigger
- pages
testLEGACY:
stage: test
script:
- npmci test legacy
tags:
- docker
allow_failure: true
testLTS:
stage: test
script:
- npmci test lts
tags:
- docker
testSTABLE:
stage: test
script:
- npmci test stable
tags:
- docker
release:
stage: release
script:
- npmci publish
only:
- tags
tags:
- docker
trigger:
stage: trigger
script:
- npmci trigger
only:
- tags
tags:
- docker
pages:
image: hosttoday/ht-docker-node:npmpage
stage: pages
script:
- npmci command npmpage --publish gitlab
only:
- tags
artifacts:
expire_in: 1 week
paths:
- public

11
.vscode/launch.json vendored Normal file
View File

@ -0,0 +1,11 @@
{
"version": "0.2.0",
"configurations": [
{
"command": "npm test",
"name": "Run npm test",
"request": "launch",
"type": "node-terminal"
}
]
}

26
.vscode/settings.json vendored Normal file
View File

@ -0,0 +1,26 @@
{
"json.schemas": [
{
"fileMatch": ["/npmextra.json"],
"schema": {
"type": "object",
"properties": {
"npmci": {
"type": "object",
"description": "settings for npmci"
},
"gitzone": {
"type": "object",
"description": "settings for gitzone",
"properties": {
"projectType": {
"type": "string",
"enum": ["website", "element", "service", "npm", "wcc"]
}
}
}
}
}
}
]
}

19
license Normal file
View File

@ -0,0 +1,19 @@
Copyright (c) 2019 Lossless GmbH (hello@lossless.com)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

17
npmextra.json Normal file
View File

@ -0,0 +1,17 @@
{
"gitzone": {
"projectType": "npm",
"module": {
"githost": "gitea.lossless.digital",
"gitscope": "apiclient.xyz",
"gitrepo": "digitalocean",
"description": "an api package for Digital Ocean",
"npmPackagename": "@apiclient.xyz/digitalocean",
"license": "MIT"
}
},
"npmci": {
"npmGlobalTools": [],
"npmAccessLevel": "public"
}
}

View File

@ -1,24 +1,51 @@
{ {
"name": "docean", "name": "@apiclient.xyz/digitalocean",
"version": "1.0.1", "version": "1.0.5",
"description": "digitalocean API wrapper", "private": false,
"main": "dist/index.js", "description": "a digital ocean API wrapper by Lossless GmbH",
"typings": "dist/index.d.ts", "main": "dist_ts/index.js",
"typings": "dist_ts/index.d.ts",
"author": "Lossless GmbH",
"license": "MIT",
"scripts": { "scripts": {
"test": "(npmts)" "test": "(tstest test/)",
"build": "(tsbuild)",
"format": "(gitzone format)",
"buildDocs": "tsdoc"
},
"devDependencies": {
"@git.zone/tsbuild": "^2.0.22",
"@git.zone/tstest": "^1.0.15",
"@push.rocks/qenv": "^6.0.4",
"@push.rocks/tapbundle": "^5.0.15",
"@types/node": "^10.11.7"
},
"dependencies": {
"@git.zone/tsrun": "^1.2.46",
"@push.rocks/smartrequest": "^2.0.21"
}, },
"repository": { "repository": {
"type": "git", "type": "git",
"url": "git+ssh://git@gitlab.com/mojoio/docean.git" "url": "git+https://gitea.lossless.digital/apiclient.xyz/digitalocean.git"
}, },
"keywords": [
"digitalocean",
"API"
],
"author": "Lossless GmbH",
"license": "MIT",
"bugs": { "bugs": {
"url": "https://gitlab.com/mojoio/docean/issues" "url": "https://gitea.lossless.digital/apiclient.xyz/digitalocean/issues"
}, },
"homepage": "https://gitlab.com/mojoio/docean#README" "homepage": "https://gitea.lossless.digital/apiclient.xyz/digitalocean#readme",
"type": "module",
"browserslist": [
"last 1 chrome versions"
],
"files": [
"ts/**/*",
"ts_web/**/*",
"dist/**/*",
"dist_*/**/*",
"dist_ts/**/*",
"dist_ts_web/**/*",
"assets/**/*",
"cli.js",
"npmextra.json",
"readme.md"
]
} }

5543
pnpm-lock.yaml generated Normal file

File diff suppressed because it is too large Load Diff

2
qenv.yml Normal file
View File

@ -0,0 +1,2 @@
vars:
- DO_API_TOKEN

26
test/test.ts Normal file
View File

@ -0,0 +1,26 @@
import { expect, tap } from '@push.rocks/tapbundle';
import { Qenv } from '@push.rocks/qenv';
const testQenv = new Qenv('./', './.nogit/');
import * as digitalocean from '../ts/index.js';
let testAccount: digitalocean.DigitalOceanAccount;
let testDroplet: digitalocean.DigitalOceanDroplet;
tap.skip.test('should create a valid account instance', async () => {
testAccount = new digitalocean.DigitalOceanAccount(process.env.DO_API_TOKEN);
expect(testAccount).toBeInstanceOf(digitalocean.DigitalOceanAccount);
});
tap.skip.test('should be able to create a droplet', async () => {
await digitalocean.DigitalOceanDroplet.createDroplet({
account: testAccount,
name: 'mydroplet1',
image: 'ubuntu-18-04-x64',
region: 'fra1',
size: 's-1vcpu-1gb'
});
});
tap.start();

8
ts/00_commitinfo_data.ts Normal file
View File

@ -0,0 +1,8 @@
/**
* autocreated commitinfo by @pushrocks/commitinfo
*/
export const commitinfo = {
name: '@apiclient.xyz/digitalocean',
version: '1.0.5',
description: 'a digital ocean API wrapper by Lossless GmbH'
}

View File

@ -0,0 +1,27 @@
import * as plugins from './do.plugins.js';
export class DigitalOceanAccount {
token: string;
constructor(tokenArg: string) {
this.token = tokenArg;
}
/**
* the main request method used
*/
async request(routeArg: string, methodArg: string, payloadArg?: any) {
const response = await plugins.smartrequest.request(
`https://api.digitalocean.com/v2${routeArg}`,
{
method: methodArg,
headers: {
Authorization: `Bearer ${this.token}`,
'Content-Type': `application/json`
},
requestBody: payloadArg
}
);
return response.body;
}
}

View File

@ -0,0 +1,32 @@
import * as plugins from './do.plugins.js';
import { type TDropletSizes, type TRegions, type TImages } from './interfaces/index.js';
import { DigitalOceanAccount } from './do.classes.doaccount.js';
export class DigitalOceanDroplet {
public static async createDroplet(dropletCreateOptions: {
account: DigitalOceanAccount;
name: string;
size: TDropletSizes;
region: TRegions;
image: string | TImages;
}) {
const response = await dropletCreateOptions.account.request('/droplets', 'POST', {
name: dropletCreateOptions.name,
region: dropletCreateOptions.region,
size: dropletCreateOptions.size,
image: dropletCreateOptions.image,
ssh_keys: null,
backups: false,
ipv6: true,
user_data: null,
private_networking: null,
volumes: null,
tags: ['web']
});
console.log(response);
}
constructor() {}
}

3
ts/do.plugins.ts Normal file
View File

@ -0,0 +1,3 @@
import * as smartrequest from '@push.rocks/smartrequest';
export { smartrequest };

2
ts/index.ts Normal file
View File

@ -0,0 +1,2 @@
export * from './do.classes.doaccount.js';
export * from './do.classes.dodroplet.js';

View File

@ -0,0 +1 @@
export type TDropletSizes = 's-1vcpu-1gb';

1
ts/interfaces/images.ts Normal file
View File

@ -0,0 +1 @@
export type TImages = 'ubuntu-18-04-x64';

3
ts/interfaces/index.ts Normal file
View File

@ -0,0 +1,3 @@
export * from './droplets.js';
export * from './regions.js';
export * from './images.js';

4
ts/interfaces/regions.ts Normal file
View File

@ -0,0 +1,4 @@
/**
* An interface describing the available regions
*/
export type TRegions = 'ams1' | 'ams2' | 'ams3' | 'fra1' | 'nyc1' | 'nyc2' | 'nyc3';

14
tsconfig.json Normal file
View File

@ -0,0 +1,14 @@
{
"compilerOptions": {
"experimentalDecorators": true,
"useDefineForClassFields": false,
"target": "ES2022",
"module": "NodeNext",
"moduleResolution": "NodeNext",
"esModuleInterop": true,
"verbatimModuleSyntax": true
},
"exclude": [
"dist_*/**/*.d.ts"
]
}

View File

@ -1,3 +0,0 @@
{
"extends": "tslint-config-standard"
}