From a4574c9c0eba3b1337fdafcda003d7386f6451ec Mon Sep 17 00:00:00 2001 From: Samuel Bodin <1637651+bodinsamuel@users.noreply.github.com> Date: Wed, 13 Sep 2023 14:45:29 +0200 Subject: [PATCH] fix(rules): add Cloudflare Workers --- src/rules/__snapshots__/hosting.test.ts.snap | 1 + src/rules/__snapshots__/index.test.ts.snap | 1 + src/rules/hosting/cloudflare.workers.ts | 19 +++++++++++++++++++ src/rules/hosting/index.ts | 1 + .../__snapshots__/component.test.ts.snap | 7 +++++++ .../__snapshots__/component.test.ts.snap | 16 ++++++++++++++++ .../__snapshots__/resource.test.ts.snap | 2 ++ src/types/techs.ts | 1 + 8 files changed, 48 insertions(+) create mode 100644 src/rules/hosting/cloudflare.workers.ts diff --git a/src/rules/__snapshots__/hosting.test.ts.snap b/src/rules/__snapshots__/hosting.test.ts.snap index 8be806a1..fb70b022 100644 --- a/src/rules/__snapshots__/hosting.test.ts.snap +++ b/src/rules/__snapshots__/hosting.test.ts.snap @@ -2,6 +2,7 @@ exports[`hosting > should match everything with files 1`] = ` [ + "cloudflare.workers", "expodev", "firebase", "flyio", diff --git a/src/rules/__snapshots__/index.test.ts.snap b/src/rules/__snapshots__/index.test.ts.snap index a571100c..fdf91325 100644 --- a/src/rules/__snapshots__/index.test.ts.snap +++ b/src/rules/__snapshots__/index.test.ts.snap @@ -47,6 +47,7 @@ exports[`all > should match everything 1`] = ` "cirrusci", "clickhouse", "cloudflare", + "cloudflare.workers", "cockroachdb", "codecov", "codesandboxci", diff --git a/src/rules/hosting/cloudflare.workers.ts b/src/rules/hosting/cloudflare.workers.ts new file mode 100644 index 00000000..ed24a527 --- /dev/null +++ b/src/rules/hosting/cloudflare.workers.ts @@ -0,0 +1,19 @@ +import { register } from '../../register.js'; + +register({ + tech: 'cloudflare.workers', + name: 'Cloudflare Workers', + type: 'hosting', + files: ['wrangler.toml'], + dependencies: [ + { type: 'npm', name: 'wrangler' }, + { type: 'npm', name: '@miniflare/cache' }, + { type: 'npm', name: 'miniflare' }, + { + type: 'terraform.resource', + name: /^cloudflare_workers_/, + example: 'cloudflare_workers_kv_namespace', + }, + { type: 'githubAction', name: 'cloudflare/wrangler-action' }, + ], +}); diff --git a/src/rules/hosting/index.ts b/src/rules/hosting/index.ts index 5e507eee..10db7e09 100644 --- a/src/rules/hosting/index.ts +++ b/src/rules/hosting/index.ts @@ -7,6 +7,7 @@ import './aws.js'; import './aws.lambda.js'; import './azure.js'; import './cloudflare.js'; +import './cloudflare.workers.js'; import './digitalocean.js'; import './elasticstack.js'; import './equinix.js'; diff --git a/src/rules/spec/githubActions/__snapshots__/component.test.ts.snap b/src/rules/spec/githubActions/__snapshots__/component.test.ts.snap index 06999398..8aa8a20d 100644 --- a/src/rules/spec/githubActions/__snapshots__/component.test.ts.snap +++ b/src/rules/spec/githubActions/__snapshots__/component.test.ts.snap @@ -10,6 +10,8 @@ exports[`docker > should match all dependencies 1`] = ` "aws.lambda", "aws.s3", "azure", + "cloudflare", + "cloudflare.workers", "databricks", "datadog", "digitalocean", @@ -218,6 +220,11 @@ exports[`docker > should match all dependencies 2`] = ` "bitovi/github-actions-deploy-docker-to-ec2", "1", ], + [ + "githubAction", + "cloudflare/wrangler-action", + "1", + ], [ "githubAction", "codecov/codecov-action", diff --git a/src/rules/spec/nodejs/__snapshots__/component.test.ts.snap b/src/rules/spec/nodejs/__snapshots__/component.test.ts.snap index 70e8b566..e9fbd5fd 100644 --- a/src/rules/spec/nodejs/__snapshots__/component.test.ts.snap +++ b/src/rules/spec/nodejs/__snapshots__/component.test.ts.snap @@ -25,6 +25,7 @@ exports[`npm > should match everything 1`] = ` "browserstack", "clickhouse", "cloudflare", + "cloudflare.workers", "contenful", "couchbase", "coveralls", @@ -485,6 +486,11 @@ exports[`npm > should match everything 2`] = ` "@mikro-orm/mongodb", "0.0.0", ], + [ + "npm", + "@miniflare/cache", + "0.0.0", + ], [ "npm", "@netlify/plugin-emails", @@ -925,6 +931,11 @@ exports[`npm > should match everything 2`] = ` "meteor-node-stubs", "0.0.0", ], + [ + "npm", + "miniflare", + "0.0.0", + ], [ "npm", "mithril", @@ -1175,5 +1186,10 @@ exports[`npm > should match everything 2`] = ` "webpack", "0.0.0", ], + [ + "npm", + "wrangler", + "0.0.0", + ], ] `; diff --git a/src/rules/spec/terraform/__snapshots__/resource.test.ts.snap b/src/rules/spec/terraform/__snapshots__/resource.test.ts.snap index b48f596e..d664937e 100644 --- a/src/rules/spec/terraform/__snapshots__/resource.test.ts.snap +++ b/src/rules/spec/terraform/__snapshots__/resource.test.ts.snap @@ -14,6 +14,8 @@ exports[`terraform (resource) > should match everything 1`] = ` "aws.s3", "aws.sns", "aws.sqs", + "cloudflare", + "cloudflare.workers", "datadog", "firebase", "firebase.firestore", diff --git a/src/types/techs.ts b/src/types/techs.ts index 77c72bf1..82669e88 100644 --- a/src/types/techs.ts +++ b/src/types/techs.ts @@ -60,6 +60,7 @@ export type AllowedKeys = | 'circleci' | 'cirrusci' | 'clickhouse' + | 'cloudflare.workers' | 'cloudflare' | 'cockroachdb' | 'codecov'