fix(core): update

This commit is contained in:
Philipp Kunz 2020-02-09 17:36:29 +00:00
parent 3153021190
commit 8da43a79d3
14 changed files with 636 additions and 481 deletions

View File

@ -3,14 +3,14 @@ image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
cache:
paths:
- .npmci_cache/
key: "$CI_BUILD_STAGE"
- .npmci_cache/
key: '$CI_BUILD_STAGE'
stages:
- security
- test
- release
- metadata
- security
- test
- release
- metadata
# ====================
# security stage
@ -18,60 +18,65 @@ stages:
mirror:
stage: security
script:
- npmci git mirror
- npmci git mirror
tags:
- docker
- notpriv
- lossless
- docker
- notpriv
snyk:
image: registry.gitlab.com/hosttoday/ht-docker-node:snyk
stage: security
script:
- npmci npm prepare
- npmci command npm install -g snyk
- npmci command npm install --ignore-scripts
- npmci command snyk test
tags:
- docker
- notpriv
- lossless
- docker
- notpriv
# ====================
# test stage
# ====================
testLTS:
testStable:
stage: test
script:
- npmci npm prepare
- npmci node install lts
- npmci npm install
- npmci npm test
- npmci npm prepare
- npmci node install stable
- npmci npm install
- npmci npm test
coverage: /\d+.?\d+?\%\s*coverage/
tags:
- docker
- notpriv
- lossless
- docker
- priv
testBuild:
stage: test
script:
- npmci npm prepare
- npmci node install lts
- npmci npm install
- npmci command npm run build
- npmci npm prepare
- npmci node install stable
- npmci npm install
- npmci command npm run build
coverage: /\d+.?\d+?\%\s*coverage/
tags:
- docker
- notpriv
- lossless
- docker
- notpriv
release:
stage: release
script:
- npmci node install lts
- npmci npm publish
- npmci node install stable
- npmci npm publish
only:
- tags
- tags
tags:
- docker
- notpriv
- lossless
- docker
- notpriv
# ====================
# metadata stage
@ -81,31 +86,35 @@ codequality:
allow_failure: true
script:
- npmci command npm install -g tslint typescript
- npmci npm prepare
- npmci npm install
- npmci command "tslint -c tslint.json ./ts/**/*.ts"
tags:
- docker
- priv
- lossless
- docker
- priv
trigger:
stage: metadata
script:
- npmci trigger
- npmci trigger
only:
- tags
- tags
tags:
- docker
- notpriv
- lossless
- docker
- notpriv
pages:
image: hosttoday/ht-docker-node:npmci
stage: metadata
script:
- npmci node install lts
- npmci command npm install -g @gitzone/tsdoc
- npmci npm prepare
- npmci npm install
- npmci command tsdoc
tags:
- lossless
- docker
- notpriv
only:
@ -113,5 +122,5 @@ pages:
artifacts:
expire_in: 1 week
paths:
- public
- public
allow_failure: true

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

@ -0,0 +1,29 @@
{
"version": "0.2.0",
"configurations": [
{
"name": "current file",
"type": "node",
"request": "launch",
"args": [
"${relativeFile}"
],
"runtimeArgs": ["-r", "@gitzone/tsrun"],
"cwd": "${workspaceRoot}",
"protocol": "inspector",
"internalConsoleOptions": "openOnSessionStart"
},
{
"name": "test.ts",
"type": "node",
"request": "launch",
"args": [
"test/test.ts"
],
"runtimeArgs": ["-r", "@gitzone/tsrun"],
"cwd": "${workspaceRoot}",
"protocol": "inspector",
"internalConsoleOptions": "openOnSessionStart"
}
]
}

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"]
}
}
}
}
}
}
]
}

View File

@ -1,50 +0,0 @@
# @mojoio/cloudflare
easy cloudflare management
## Availabililty and Links
* [npmjs.org (npm package)](https://www.npmjs.com/package/@mojoio/cloudflare)
* [gitlab.com (source)](https://gitlab.com/mojoio/cloudflare)
* [github.com (source mirror)](https://github.com/mojoio/cloudflare)
* [docs (typedoc)](https://mojoio.gitlab.io/cloudflare/)
## Status for master
[![build status](https://gitlab.com/mojoio/cloudflare/badges/master/build.svg)](https://gitlab.com/mojoio/cloudflare/commits/master)
[![coverage report](https://gitlab.com/mojoio/cloudflare/badges/master/coverage.svg)](https://gitlab.com/mojoio/cloudflare/commits/master)
[![npm downloads per month](https://img.shields.io/npm/dm/@mojoio/cloudflare.svg)](https://www.npmjs.com/package/@mojoio/cloudflare)
[![Known Vulnerabilities](https://snyk.io/test/npm/@mojoio/cloudflare/badge.svg)](https://snyk.io/test/npm/@mojoio/cloudflare)
[![TypeScript](https://img.shields.io/badge/TypeScript->=%203.x-blue.svg)](https://nodejs.org/dist/latest-v10.x/docs/api/)
[![node](https://img.shields.io/badge/node->=%2010.x.x-blue.svg)](https://nodejs.org/dist/latest-v10.x/docs/api/)
[![JavaScript Style Guide](https://img.shields.io/badge/code%20style-prettier-ff69b4.svg)](https://prettier.io/)
## Usage
Use TypeScript for best in class instellisense.
```javascript
import * as cflare from 'cflare'
let myCflareAccount = new cflare.CflareAccount()
testCflareAccount.auth({
email: 'someuser@example.com',
key: 'someLongApiKey'
})
let myAsyncCflareManagement = async () => {
// get things
let myZones = await myCflareAccount.listZones() // zones are fully typed
let myIdForADomain = await myCflareAccount.getZoneId('example.com') // type number
let myRecordsForADomain = await myCflareAccount.listRecords('example.com') // records are fully typed
// set things
myCflareAccount.updateRecord(...)
myCflareAccount.createRecord(...)
myCflareAccount.deleteRecord(...)
}
```
For further information read the linked docs at the top of this readme.
> MIT licensed | **©** [Lossless GmbH](https://lossless.gmbh)
| By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy.html)
[![repo-footer](https://mojoio.gitlab.io/assets/repo-footer.svg)](https://maintainedby.lossless.com)

View File

@ -4,6 +4,7 @@
"npmAccessLevel": "public"
},
"gitzone": {
"projectType": "npm",
"module": {
"githost": "gitlab.com",
"gitscope": "mojoio",

832
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -24,32 +24,32 @@
},
"homepage": "https://gitlab.com/pushrocks/cflare#readme",
"dependencies": {
"@pushrocks/smartdelay": "^2.0.3",
"@pushrocks/smartlog": "^2.0.19",
"@pushrocks/smartpromise": "^3.0.2",
"@pushrocks/smartrequest": "^1.1.16",
"@pushrocks/smartstring": "^3.0.10",
"@tsclass/tsclass": "^2.0.1"
"@pushrocks/smartdelay": "^2.0.6",
"@pushrocks/smartlog": "^2.0.21",
"@pushrocks/smartpromise": "^3.0.6",
"@pushrocks/smartrequest": "^1.1.47",
"@pushrocks/smartstring": "^3.0.18",
"@tsclass/tsclass": "^3.0.4"
},
"devDependencies": {
"@gitzone/tsbuild": "^2.1.11",
"@gitzone/tsbuild": "^2.1.17",
"@gitzone/tsrun": "^1.2.8",
"@gitzone/tstest": "^1.0.24",
"@pushrocks/qenv": "^4.0.0",
"@pushrocks/tapbundle": "^3.0.11",
"@types/node": "^12.6.6",
"tslint": "^5.18.0",
"@gitzone/tstest": "^1.0.28",
"@pushrocks/qenv": "^4.0.6",
"@pushrocks/tapbundle": "^3.2.0",
"@types/node": "^13.7.0",
"tslint": "^6.0.0",
"tslint-config-prettier": "^1.18.0"
},
"files": [
"ts/*",
"ts_web/*",
"dist/*",
"dist_web/*",
"dist_ts_web/*",
"assets/*",
"ts/**/*",
"ts_web/**/*",
"dist/**/*",
"dist_web/**/*",
"dist_ts_web/**/*",
"assets/**/*",
"cli.js",
"npmextra.json",
"readme.md"
]
}
}

View File

@ -17,9 +17,7 @@ tap.test('should create a valid instance of CloudflareAccount', async () => {
});
});
tap.skip.test('.listZones() -> should display an entire account', async tools => {
tap.test('.listZones() -> should display an entire account', async tools => {
tools.timeout(600000);
const result = await testCloudflareAccount.listZones();
console.log(result);
@ -50,9 +48,11 @@ tap.test('should create a valid record for a subdomain', async tools => {
tap.test('should get a record from Cloudflare', async tools => {
tools.timeout(600000);
await testCloudflareAccount.getRecord(`${randomPrefix}subdomain.bleu.de`, 'A').then(responseArg => {
console.log(responseArg);
});
await testCloudflareAccount
.getRecord(`${randomPrefix}subdomain.bleu.de`, 'A')
.then(responseArg => {
console.log(responseArg);
});
});
tap.test('should remove a subdomain record from Cloudflare', async tools => {
@ -70,7 +70,10 @@ tap.test('.purge(some.domain) -> should purge everything', async () => {
// WORKERS
tap.test('should create a worker', async () => {
const worker = await testCloudflareAccount.workerManager.createWorker('myawesomescript', `addEventListener('fetch', event => { event.respondWith(fetch(event.request)) })`);
const worker = await testCloudflareAccount.workerManager.createWorker(
'myawesomescript',
`addEventListener('fetch', event => { event.respondWith(fetch(event.request)) })`
);
await worker.setRoutes([
{
zoneName: 'bleu.de',

View File

@ -2,7 +2,6 @@ import plugins = require('./cloudflare.plugins');
import * as interfaces from './interfaces';
// interfaces
import { TDnsRecord } from '@tsclass/tsclass';
import { WorkerManager } from './cloudflare.classes.workermanager';
import { ZoneManager } from './cloudflare.classes.zonemanager';
@ -61,7 +60,7 @@ export class CloudflareAccount {
*/
public async getRecord(
domainNameArg: string,
typeArg: TDnsRecord
typeArg: plugins.tsclass.network.TDnsRecord
): Promise<interfaces.ICflareRecord> {
const domain = new plugins.smartstring.Domain(domainNameArg);
const recordArrayArg = await this.listRecords(domain.zoneName);
@ -73,7 +72,7 @@ export class CloudflareAccount {
public async createRecord(
domainNameArg: string,
typeArg: TDnsRecord,
typeArg: plugins.tsclass.network.TDnsRecord,
contentArg: string
): Promise<any> {
const domain = new plugins.smartstring.Domain(domainNameArg);
@ -96,7 +95,10 @@ export class CloudflareAccount {
* @param domainNameArg
* @param typeArg
*/
public async removeRecord(domainNameArg: string, typeArg: TDnsRecord): Promise<any> {
public async removeRecord(
domainNameArg: string,
typeArg: plugins.tsclass.network.TDnsRecord
): Promise<any> {
const domain = new plugins.smartstring.Domain(domainNameArg);
const cflareRecord = await this.getRecord(domain.fullName, typeArg);
if (cflareRecord) {
@ -221,4 +223,6 @@ export class CloudflareAccount {
private authCheck() {
return this.authEmail && this.authKey; // check if auth is available
}
// acme convenience functions
}

View File

@ -8,7 +8,10 @@ export interface IWorkerRoute extends interfaces.ICflareWorkerRoute {
export class CloudflareWorker {
// STATIC
public static async fromApiObject(workerManager: WorkerManager, apiObject): Promise<CloudflareWorker> {
public static async fromApiObject(
workerManager: WorkerManager,
apiObject
): Promise<CloudflareWorker> {
const newWorker = new CloudflareWorker(workerManager);
Object.assign(newWorker, apiObject.result);
await newWorker.getRoutes();
@ -17,7 +20,7 @@ export class CloudflareWorker {
// INSTANCE
private workerManager: WorkerManager;
public script: string;
public id: string;
public etag: string;
@ -38,19 +41,21 @@ export class CloudflareWorker {
const zones = await this.workerManager.cfAccount.listZones();
for (const zone of zones) {
const requestRoute = `/zones/${zone.id}/workers/routes`;
const response: {result: interfaces.ICflareWorkerRoute[]} = await this.workerManager.cfAccount.request('GET', requestRoute);
const response: {
result: interfaces.ICflareWorkerRoute[];
} = await this.workerManager.cfAccount.request('GET', requestRoute);
for (const route of response.result) {
console.log('hey');
console.log(route);
console.log(this.id);
if (route.script === this.id) {
this.routes.push({...route, zoneName: zone.name});
this.routes.push({ ...route, zoneName: zone.name });
}
}
}
}
public async setRoutes(routeArray: Array<{zoneName: string, pattern: string}>) {
public async setRoutes(routeArray: Array<{ zoneName: string; pattern: string }>) {
for (const newRoute of routeArray) {
// lets determine wether a route is new, needs an update or already up to date.
let routeStatus: 'new' | 'needsUpdate' | 'alreadyUpToDate' = 'new';

View File

@ -26,6 +26,11 @@ export class WorkerManager {
const accountIdentifier = await this.cfAccount.getAccountIdentifier();
const route = `/accounts/${accountIdentifier}/workers/scripts`;
const response = await this.cfAccount.request('GET', route);
console.log(response);
const results = response.result;
const workers: CloudflareWorker[] = [];
for (const apiObject of results) {
workers.push(await CloudflareWorker.fromApiObject(this, apiObject));
}
return workers;
}
}

View File

@ -3,4 +3,4 @@ import * as interfaces from './interfaces';
export class CloudflareZone {
// TODO
}
}

View File

@ -12,4 +12,4 @@ export interface ICflareRecord {
created_on: string;
modified_on: string;
data: any;
}
}

View File

@ -3,7 +3,6 @@
"rules": {
"semicolon": [true, "always"],
"no-console": false,
"no-return-await": false,
"ordered-imports": false,
"object-literal-sort-keys": false,
"member-ordering": {