Skip to content

Commit

Permalink
tests: enforce example when using regex, add dependabot, renovate, te…
Browse files Browse the repository at this point in the history
…sts all npm packages
  • Loading branch information
bodinsamuel committed Apr 28, 2023
1 parent 04b77f4 commit 5c1ba4f
Show file tree
Hide file tree
Showing 54 changed files with 192 additions and 42 deletions.
8 changes: 4 additions & 4 deletions TODO.todo
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ NodeJs:
✔ docsearch @done(23-04-27 14:38)
- Slack
- Github API (octokit)
- Storybook
Storybook @done(23-04-28 18:10)
- Webpack
- Rollup
- Esbuild
Expand Down Expand Up @@ -44,13 +44,13 @@ Global:
✔ Detect Vercel @done(23-04-27 11:02)
- Detect github pages
- Detect Cloudflare
- Detect Netlify
Detect Netlify @done(23-04-28 17:13)
- Detect Zeit
- Detect Fly.io
Detect Fly.io @done(23-04-28 17:13)
- Detect Heroku
- Detect Render
- Detect Dependabot
- Detect Renovate
Detect Renovate @done(23-04-28 17:20)
✔ Circleci @done(23-04-27 11:02)
✔ Travisci @done(23-04-27 11:04)
- Codecov
Expand Down
5 changes: 4 additions & 1 deletion src/common/techs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export const list: TechItem[] = [
{ key: 'cypressci', name: 'CypressCI', type: 'ci' },
{ key: 'dart', name: 'Dart', type: 'language' },
{ key: 'datadog', name: 'Datadog', type: 'sass' },
{ key: 'dependabot', name: 'Dependabot', type: 'ci' },
{ key: 'digitalocean', name: 'Digital Ocean', type: 'hosting' },
{ key: 'docker', name: 'Docker', type: 'tool' },
{ key: 'elasticloud', name: 'Elastic Cloud', type: 'sass' },
Expand Down Expand Up @@ -74,6 +75,7 @@ export const list: TechItem[] = [
{ key: 'rabbitmq', name: 'RabbitMQ', type: 'messaging' },
{ key: 'react', name: 'React', type: 'language' },
{ key: 'redis', name: 'Redis', type: 'db' },
{ key: 'renovate', name: 'Renovate', type: 'ci' },
{ key: 'relativeci', name: 'RelativeCI', type: 'ci' },
{ key: 'ruby', name: 'Ruby', type: 'language' },
{ key: 'rust', name: 'Rust', type: 'language' },
Expand All @@ -84,7 +86,8 @@ export const list: TechItem[] = [
{ key: 'slack', name: 'Slack', type: 'sass' },
{ key: 'socketio', name: 'Socket.io', type: 'tool' },
{ key: 'sqreen', name: 'Sqreen', type: 'sass' },
{ key: 'stylelint', name: 'Styelint', type: 'tool' },
{ key: 'storybook', name: 'Storybook', type: 'tool' },
{ key: 'stylelint', name: 'Stylelint', type: 'tool' },
{ key: 'swift', name: 'Swift', type: 'language' },
{ key: 'tailwind', name: 'Tailwind', type: 'tool' },
{ key: 'terraform', name: 'Terraform', type: 'tool' },
Expand Down
11 changes: 8 additions & 3 deletions src/rules.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { matchFiles, matchFilesRegex } from './common/rules/matchFiles';
import type {
ComponentMatcher,
Rule,
RuleDependency,
SupportedDeps,
TechMatcher,
} from './types/rule';
Expand All @@ -21,6 +22,9 @@ export const dependencies: Record<
docker: [],
};

export const rawList: Array<{ ref: RuleDependency } & { type: 'dependency' }> =
[];

export function register(rule: Rule) {
if (registeredTech.has(rule.tech)) {
throw new Error(`Already registered ${rule.tech}`);
Expand All @@ -35,18 +39,19 @@ export function register(rule: Rule) {
typeof dep.name === 'string' ? new RegExp(`^${dep.name}$`) : dep.name,
tech: rule.tech,
});
rawList.push({ type: 'dependency', ref: dep });
});
}

if (rule.files) {
if (typeof rule.files !== 'undefined') {
let matcher: TechMatcher;
if (Array.isArray(rule.files)) {
matcher = (files) => {
return matchFiles(
rule.tech,
files,
rule.files as string[],
rule.matchFullPath
'matchFullPath' in rule ? rule.matchFullPath : false
);
};
} else {
Expand All @@ -55,7 +60,7 @@ export function register(rule: Rule) {
rule.tech,
files,
rule.files as RegExp,
rule.matchFullPath
'matchFullPath' in rule ? rule.matchFullPath : false
);
};
}
Expand Down
5 changes: 3 additions & 2 deletions src/rules/app/caddy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { register } from '../../rules';

register({
tech: 'caddy',
files: /\.Caddyfile/,
dependencies: [{ type: 'docker', name: /caddy/ }],
files: /\.Caddyfile$/,
example: 'test.Caddyfile',
dependencies: [{ type: 'docker', name: /caddy/, example: 'caddy:0.0.0' }],
});
2 changes: 1 addition & 1 deletion src/rules/app/httpd.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ import { register } from '../../rules';
register({
tech: 'httpd',
files: ['httpd.conf'],
dependencies: [{ type: 'docker', name: /httpd/ }],
dependencies: [{ type: 'docker', name: /httpd/, example: 'httpd:0.0.0' }],
});
2 changes: 1 addition & 1 deletion src/rules/app/kibana.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ import { register } from '../../rules';

register({
tech: 'kibana',
dependencies: [{ type: 'docker', name: /kibana/ }],
dependencies: [{ type: 'docker', name: /kibana/, example: 'kibana:0.0.0' }],
});
2 changes: 1 addition & 1 deletion src/rules/app/nginx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ import { register } from '../../rules';
register({
tech: 'nginx',
files: ['nginx.conf'],
dependencies: [{ type: 'docker', name: /nginx/ }],
dependencies: [{ type: 'docker', name: /nginx/, example: 'nginx:0.0.0' }],
});
4 changes: 3 additions & 1 deletion src/rules/app/zookeeper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,7 @@ import { register } from '../../rules';

register({
tech: 'zookeeper',
dependencies: [{ type: 'docker', name: /zookeeper/ }],
dependencies: [
{ type: 'docker', name: /zookeeper/, example: 'zookeeper:0.0.0' },
],
});
1 change: 1 addition & 0 deletions src/rules/ci/codesandboxci.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ register({
tech: 'codesandboxci',
matchFullPath: true,
files: /.codesandbox\/ci.json/,
example: '.codesandbox/ci.json',
});
3 changes: 2 additions & 1 deletion src/rules/ci/cypressci.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ import { register } from '../../rules';
register({
tech: 'cypressci',
files: /cypress.config.(js|ts|mjs|cjs)/,
example: 'cypress.config.js',
dependencies: [
{ type: 'npm', name: 'cypress' },
{ type: 'docker', name: /cypress/ },
{ type: 'docker', name: /cypress/, example: 'cypress:0.0.0' },
],
});
8 changes: 8 additions & 0 deletions src/rules/ci/dependabot.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { register } from '../../rules';

register({
tech: 'dependabot',
matchFullPath: true,
files: /.github\/dependabot.yml/,
example: '.github/dependabot.yml',
});
1 change: 1 addition & 0 deletions src/rules/ci/githubactions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ register({
tech: 'githubactions',
matchFullPath: true,
files: /.github\/workflows\/.+\.yml/,
example: '.github/workflows/ci.yml',
});
2 changes: 2 additions & 0 deletions src/rules/ci/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import './browserstack';
import './circleci';
import './cypressci';
import './dependabot';
import './githubactions';
import './renovate';
import './relativeci';
import './travisci';
7 changes: 7 additions & 0 deletions src/rules/ci/renovate.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { register } from '../../rules';

register({
tech: 'renovate',
files: ['.renovaterc.json', '.renovaterc', 'renovate.json', 'renovate.json5'],
dependencies: [{ type: 'npm', name: 'renovate' }],
});
4 changes: 3 additions & 1 deletion src/rules/db/cassandra.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,7 @@ import { register } from '../../rules';

register({
tech: 'cassandra',
dependencies: [{ type: 'docker', name: /cassandra/ }],
dependencies: [
{ type: 'docker', name: /cassandra/, example: 'cassandra:0.0.0' },
],
});
2 changes: 1 addition & 1 deletion src/rules/db/couchbase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ register({
tech: 'couchbase',
dependencies: [
{ type: 'npm', name: 'couchbase' },
{ type: 'docker', name: /couchbase/ },
{ type: 'docker', name: /couchbase/, example: 'couchbase:0.0.0' },
],
});
2 changes: 1 addition & 1 deletion src/rules/db/elasticsearch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ register({
tech: 'elasticsearch',
dependencies: [
{ type: 'npm', name: '@elastic/elasticsearch' },
{ type: 'docker', name: /elasticsearch/ },
{ type: 'docker', name: /elasticsearch/, example: 'elasticsearch:0.0.0' },
],
});
2 changes: 1 addition & 1 deletion src/rules/db/influxdb.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ register({
tech: 'influxdb',
dependencies: [
{ type: 'npm', name: '@influxdata/influxdb-client' },
{ type: 'docker', name: /influxdb/ },
{ type: 'docker', name: /influxdb/, example: 'influxdb:0.0.0' },
],
});
2 changes: 1 addition & 1 deletion src/rules/db/mariadb.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ register({
tech: 'mariadb',
dependencies: [
{ type: 'npm', name: 'mariadb' },
{ type: 'docker', name: /mariadb/ },
{ type: 'docker', name: /mariadb/, example: 'mariadb:0.0.0' },
],
});
2 changes: 1 addition & 1 deletion src/rules/db/memcached.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ register({
tech: 'memcached',
dependencies: [
{ type: 'npm', name: 'memcached' },
{ type: 'docker', name: /memcached/ },
{ type: 'docker', name: /memcached/, example: 'memcached:0.0.0' },
],
});
2 changes: 1 addition & 1 deletion src/rules/db/mongo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ register({
tech: 'mongodb',
dependencies: [
{ type: 'npm', name: 'mongoose' },
{ type: 'docker', name: /mongo/ },
{ type: 'docker', name: /mongo/, example: 'mongo:0.0.0' },
],
});
2 changes: 1 addition & 1 deletion src/rules/db/mysql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ register({
tech: 'mysql',
dependencies: [
{ type: 'npm', name: 'mysql' },
{ type: 'docker', name: /mysql/ },
{ type: 'docker', name: /mysql/, example: 'mysql:0.0.0' },
],
});
2 changes: 1 addition & 1 deletion src/rules/db/neo4j.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ register({
tech: 'neo4j',
dependencies: [
{ type: 'npm', name: 'neo4j-driver' },
{ type: 'docker', name: /neo4j/ },
{ type: 'docker', name: /neo4j/, example: 'neo4j:0.0.0' },
],
});
2 changes: 1 addition & 1 deletion src/rules/db/percona.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ import { register } from '../../rules';

register({
tech: 'percona',
dependencies: [{ type: 'docker', name: /percona/ }],
dependencies: [{ type: 'docker', name: /percona/, example: 'percona:0.0.0' }],
});
2 changes: 1 addition & 1 deletion src/rules/db/postgres.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ register({
tech: 'postgresql',
dependencies: [
{ type: 'npm', name: 'pg' },
{ type: 'docker', name: /postgres/ },
{ type: 'docker', name: /postgres/, example: 'postgres:0.0.0' },
],
});
2 changes: 1 addition & 1 deletion src/rules/db/redis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ register({
tech: 'redis',
dependencies: [
{ type: 'npm', name: 'redis' },
{ type: 'docker', name: /redis/ },
{ type: 'docker', name: /redis/, example: 'redis:0.0.0' },
],
});
2 changes: 1 addition & 1 deletion src/rules/db/vault.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ import { register } from '../../rules';

register({
tech: 'vault',
dependencies: [{ type: 'docker', name: /vault/ }],
dependencies: [{ type: 'docker', name: /vault/, example: 'vault:0.0.0' }],
});
2 changes: 1 addition & 1 deletion src/rules/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import './ci';
import './db';
import './hosting';
import './messaging';
import './npm';
import './js';
import './sass';
import './spec';
import './tool';
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
1 change: 1 addition & 0 deletions src/rules/npm/index.ts → src/rules/js/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import './react';
import './sentry';
import './sequelize';
import './socketio';
import './storybook';
import './stylelint';
import './tailwind';
import './typescript';
Expand Down
1 change: 1 addition & 0 deletions src/rules/npm/jest.ts → src/rules/js/jest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { register } from '../../rules';
register({
tech: 'jest',
files: /jest.config.(js|ts|mjs|cjs|json)/,
example: 'jest.config.ts',
dependencies: [
{ type: 'npm', name: 'jest' },
{ type: 'npm', name: 'babel-jest' },
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
8 changes: 8 additions & 0 deletions src/rules/js/sentry.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { register } from '../../rules';

register({
tech: 'sentry',
dependencies: [
{ type: 'npm', name: /@sentry\//, example: '@sentry/browser' },
],
});
4 changes: 3 additions & 1 deletion src/rules/npm/sequelize.ts → src/rules/js/sequelize.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,7 @@ import { register } from '../../rules';
register({
tech: 'sequelize',
files: ['.sequelizerc'],
dependencies: [{ type: 'npm', name: /sequelize(-cli)?/ }],
dependencies: [
{ type: 'npm', name: /sequelize(-cli)?/, example: 'sequelize' },
],
});
File renamed without changes.
7 changes: 7 additions & 0 deletions src/rules/js/storybook.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { register } from '../../rules';

register({
tech: 'storybook',
files: ['.storybook'],
dependencies: [{ type: 'npm', name: 'storybook' }],
});
File renamed without changes.
File renamed without changes.
1 change: 1 addition & 0 deletions src/rules/npm/typescript.ts → src/rules/js/typescript.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@ import { register } from '../../rules';
register({
tech: 'typescript',
files: /tsconfig(.[a-zA-Z0-9_-]+)?.json/,
example: 'tsconfig.json',
dependencies: [{ type: 'npm', name: 'typescript' }],
});
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion src/rules/messaging/rabbitmq.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ register({
tech: 'rabbitmq',
dependencies: [
{ type: 'npm', name: 'amqplib' },
{ type: 'docker', name: /rabbitmq/ },
{ type: 'docker', name: /rabbitmq/, example: 'rabbitmq:0.0.0' },
],
});
Loading

0 comments on commit 5c1ba4f

Please sign in to comment.