Compare commits

...

7 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
25 changed files with 5982 additions and 117 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

17
.gitignore vendored
View File

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

View File

@ -1,86 +0,0 @@
# gitzone standard
image: hosttoday/ht-docker-node:npmci
cache:
paths:
- .yarn/
key: "$CI_BUILD_STAGE"
stages:
- mirror
- test
- release
- trigger
- pages
mirror:
stage: mirror
script:
- npmci git mirror
tags:
- docker
testLEGACY:
stage: test
script:
- npmci node install legacy
- npmci npm install
- npmci npm test
coverage: /\d+.?\d+?\%\s*coverage/
tags:
- docker
allow_failure: true
testLTS:
stage: test
script:
- npmci node install lts
- npmci npm install
- npmci npm test
coverage: /\d+.?\d+?\%\s*coverage/
tags:
- docker
testSTABLE:
stage: test
script:
- npmci node install stable
- npmci npm install
- npmci npm test
coverage: /\d+.?\d+?\%\s*coverage/
tags:
- docker
release:
stage: release
script:
- npmci npm prepare
- npmci npm publish
only:
- tags
tags:
- docker
trigger:
stage: trigger
script:
- npmci trigger
only:
- tags
tags:
- docker
pages:
image: hosttoday/ht-docker-node:npmci
stage: pages
script:
- npmci command yarn global add npmpage
- npmci command npmpage
tags:
- docker
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"]
}
}
}
}
}
}
]
}

View File

@ -1,4 +0,0 @@
module.name: smartmodule
module.description: a smart description
module.author: Lossless GmbH
module.license: MIT

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.

View File

@ -1,7 +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": [
"npmts"
]
"npmGlobalTools": [],
"npmAccessLevel": "public"
}
}
}

View File

@ -1,18 +1,51 @@
{
"name": "docean",
"version": "1.0.2",
"description": "Digital Ocean abstracted API package for mojo.io",
"main": "dist/index.js",
"typings": "dist/index.d.ts",
"name": "@apiclient.xyz/digitalocean",
"version": "1.0.5",
"private": false,
"description": "a digital ocean API wrapper by Lossless GmbH",
"main": "dist_ts/index.js",
"typings": "dist_ts/index.d.ts",
"author": "Lossless GmbH",
"license": "MIT",
"scripts": {
"test": "(npmts)"
"test": "(tstest test/)",
"build": "(tsbuild)",
"format": "(gitzone format)",
"buildDocs": "tsdoc"
},
"devDependencies": {
"tapbundle": "^1.0.13"
"@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": {
"typings-global": "^1.0.16"
}
"@git.zone/tsrun": "^1.2.46",
"@push.rocks/smartrequest": "^2.0.21"
},
"repository": {
"type": "git",
"url": "git+https://gitea.lossless.digital/apiclient.xyz/digitalocean.git"
},
"bugs": {
"url": "https://gitea.lossless.digital/apiclient.xyz/digitalocean/issues"
},
"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

View File

@ -1,8 +1,26 @@
import { expect, tap } from 'tapbundle'
import * as docean from '../ts/index'
import { expect, tap } from '@push.rocks/tapbundle';
import { Qenv } from '@push.rocks/qenv';
tap.test('first test', async () => {
console.log(docean.standardExport)
})
const testQenv = new Qenv('./', './.nogit/');
tap.start()
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 };

View File

@ -1 +0,0 @@
import 'typings-global'

View File

@ -1,3 +1,2 @@
import * as plugins from './docean.plugins'
export let standardExport = 'Hi there! :) This is a exported string'
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"
}