From 9e338354c6f36c51d4e6687984c3be9c90f3fd77 Mon Sep 17 00:00:00 2001 From: Phil Kunz Date: Fri, 22 Jan 2021 20:46:26 +0000 Subject: [PATCH] fix(core): update --- .gitlab-ci.yml | 26 ++++++++++++++++++-------- .vscode/settings.json | 2 +- package.json | 5 ++++- test/test.ts | 22 +++++++++++----------- ts/cloudflare.classes.account.ts | 14 +++++++------- ts/cloudflare.classes.worker.ts | 4 ++-- ts/cloudflare.classes.workermanager.ts | 2 +- 7 files changed, 44 insertions(+), 31 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 8ebc8b5..9a4467e 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -19,23 +19,35 @@ mirror: stage: security script: - npmci git mirror + only: + - tags tags: - lossless - docker - notpriv -audit: +auditProductionDependencies: + image: registry.gitlab.com/hosttoday/ht-docker-node:npmci + stage: security + script: + - npmci npm prepare + - npmci command npm install --production --ignore-scripts + - npmci command npm config set registry https://registry.npmjs.org + - npmci command npm audit --audit-level=high --only=prod --production + tags: + - docker + +auditDevDependencies: image: registry.gitlab.com/hosttoday/ht-docker-node:npmci stage: security script: - npmci npm prepare - npmci command npm install --ignore-scripts - npmci command npm config set registry https://registry.npmjs.org - - npmci command npm audit --audit-level=high + - npmci command npm audit --audit-level=high --only=dev tags: - - lossless - docker - - notpriv + allow_failure: true # ==================== # test stage @@ -50,9 +62,7 @@ testStable: - npmci npm test coverage: /\d+.?\d+?\%\s*coverage/ tags: - - lossless - docker - - priv testBuild: stage: test @@ -63,9 +73,7 @@ testBuild: - npmci command npm run build coverage: /\d+.?\d+?\%\s*coverage/ tags: - - lossless - docker - - notpriv release: stage: release @@ -85,6 +93,8 @@ release: codequality: stage: metadata allow_failure: true + only: + - tags script: - npmci command npm install -g tslint typescript - npmci npm prepare diff --git a/.vscode/settings.json b/.vscode/settings.json index 01d2b8d..3648eaa 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -15,7 +15,7 @@ "properties": { "projectType": { "type": "string", - "enum": ["website", "element", "service", "npm"] + "enum": ["website", "element", "service", "npm", "wcc"] } } } diff --git a/package.json b/package.json index 148f730..14a774f 100644 --- a/package.json +++ b/package.json @@ -52,5 +52,8 @@ "cli.js", "npmextra.json", "readme.md" + ], + "browserslist": [ + "last 1 chrome versions" ] -} +} \ No newline at end of file diff --git a/test/test.ts b/test/test.ts index dfa4332..761f07d 100644 --- a/test/test.ts +++ b/test/test.ts @@ -14,7 +14,7 @@ tap.test('should create a valid instance of CloudflareAccount', async () => { testCloudflareAccount = new cloudflare.CloudflareAccount(testQenv.getEnvVarOnDemand('CF_KEY')); }); -tap.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.convenience.listZones(); console.log(result); @@ -22,7 +22,7 @@ tap.test('.listZones() -> should display an entire account', async tools => { tap.test( '.getZoneId(domainName) -> should get an Cloudflare Id for a domain string', - async tools => { + async (tools) => { tools.timeout(600000); await testCloudflareAccount.convenience.getZoneId('bleu.de'); } @@ -30,15 +30,15 @@ tap.test( tap.test( '.listRecords(domainName) -> should list all records for a specific Domain Name', - async tools => { + async (tools) => { tools.timeout(600000); - await testCloudflareAccount.convenience.listRecords('bleu.de').then(async responseArg => { + await testCloudflareAccount.convenience.listRecords('bleu.de').then(async (responseArg) => { console.log(responseArg); }); } ); -tap.test('should create a valid record for a subdomain', async tools => { +tap.test('should create a valid record for a subdomain', async (tools) => { tools.timeout(600000); await testCloudflareAccount.convenience.createRecord( `${randomPrefix}subdomain.bleu.de`, @@ -47,20 +47,20 @@ tap.test('should create a valid record for a subdomain', async tools => { ); }); -tap.test('should get a record from Cloudflare', async tools => { +tap.test('should get a record from Cloudflare', async (tools) => { tools.timeout(600000); await testCloudflareAccount.convenience .getRecord(`${randomPrefix}subdomain.bleu.de`, 'A') - .then(responseArg => { + .then((responseArg) => { console.log(responseArg); }); }); -tap.test('should remove a subdomain record from Cloudflare', async tools => { +tap.test('should remove a subdomain record from Cloudflare', async (tools) => { tools.timeout(600000); await testCloudflareAccount.convenience .removeRecord(`${randomPrefix}subdomain.bleu.de`, 'A') - .then(async responseArg => { + .then(async (responseArg) => { console.log(responseArg); }); }); @@ -78,8 +78,8 @@ tap.test('should create a worker', async () => { await worker.setRoutes([ { zoneName: 'bleu.de', - pattern: 'https://*bleu.de/hello' - } + pattern: 'https://*bleu.de/hello', + }, ]); console.log(worker); }); diff --git a/ts/cloudflare.classes.account.ts b/ts/cloudflare.classes.account.ts index c72835f..eb6a40f 100644 --- a/ts/cloudflare.classes.account.ts +++ b/ts/cloudflare.classes.account.ts @@ -41,7 +41,7 @@ export class CloudflareAccount { getZoneId: async (domainName: string) => { const domain = new plugins.smartstring.Domain(domainName); const zoneArray = await this.convenience.listZones(domain.zoneName); - const filteredResponse = zoneArray.filter(zoneArg => { + const filteredResponse = zoneArray.filter((zoneArg) => { return zoneArg.name === domainName; }); if (filteredResponse.length >= 1) { @@ -62,7 +62,7 @@ export class CloudflareAccount { ): Promise => { const domain = new plugins.smartstring.Domain(domainNameArg); const recordArrayArg = await this.convenience.listRecords(domain.zoneName); - const filteredResponse = recordArrayArg.filter(recordArg => { + const filteredResponse = recordArrayArg.filter((recordArg) => { return recordArg.type === typeArg && recordArg.name === domainNameArg; }); return filteredResponse[0]; @@ -82,7 +82,7 @@ export class CloudflareAccount { name: domain.fullName, type: typeArg, content: contentArg, - ttl: ttlArg + ttl: ttlArg, }; const response = await this.request( 'POST', @@ -168,7 +168,7 @@ export class CloudflareAccount { const domainId = await this.convenience.getZoneId(domain.zoneName); const requestUrl = `/zones/${domainId}/purge_cache`; const payload = { - purge_everything: true + purge_everything: true, }; const respone = await this.request('DELETE', requestUrl, payload); }, @@ -179,7 +179,7 @@ export class CloudflareAccount { }, acmeRemoveDnsChallenge: async (dnsChallenge: plugins.tsclass.network.IDnsChallenge) => { await this.convenience.removeRecord(dnsChallenge.hostName, 'TXT'); - } + }, }; public async request( @@ -194,9 +194,9 @@ export class CloudflareAccount { 'Content-Type': 'application/json', Authorization: `Bearer ${this.authToken}`, 'Content-Length': Buffer.byteLength(JSON.stringify(dataArg)), - ...requestHeadersArg + ...requestHeadersArg, }, - requestBody: dataArg + requestBody: dataArg, }; // route analysis diff --git a/ts/cloudflare.classes.worker.ts b/ts/cloudflare.classes.worker.ts index 7896116..e2b8d67 100644 --- a/ts/cloudflare.classes.worker.ts +++ b/ts/cloudflare.classes.worker.ts @@ -78,14 +78,14 @@ export class CloudflareWorker { const requestRoute = `/zones/${zoneId}/workers/routes`; await this.workerManager.cfAccount.request('POST', requestRoute, { pattern: newRoute.pattern, - script: this.id + script: this.id, }); } else if (routeStatus === 'needsUpdate') { const zoneId = await this.workerManager.cfAccount.convenience.getZoneId(newRoute.zoneName); const requestRoute = `/zones/${zoneId}/workers/routes/${routeIdForUpdate}`; await this.workerManager.cfAccount.request('PUT', requestRoute, { pattern: newRoute.pattern, - script: this.id + script: this.id, }); } } diff --git a/ts/cloudflare.classes.workermanager.ts b/ts/cloudflare.classes.workermanager.ts index 3a83573..5831a58 100644 --- a/ts/cloudflare.classes.workermanager.ts +++ b/ts/cloudflare.classes.workermanager.ts @@ -14,7 +14,7 @@ export class WorkerManager { const route = `/accounts/${accountIdentifier}/workers/scripts/${workerName}`; const responseBody = await this.cfAccount.request('PUT', route, workerScript, { 'Content-Type': 'application/javascript', - 'Content-Length': Buffer.byteLength(workerScript) + 'Content-Length': Buffer.byteLength(workerScript), }); return CloudflareWorker.fromApiObject(this, responseBody.result); }