Skip to content

Commit

Permalink
fix(rules): rename some to prepare for nested rule
Browse files Browse the repository at this point in the history
  • Loading branch information
bodinsamuel committed Jun 29, 2023
1 parent 3d202da commit 86360e3
Show file tree
Hide file tree
Showing 12 changed files with 68 additions and 51 deletions.
6 changes: 3 additions & 3 deletions src/common/techs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export const list: TechItem[] = [
{ key: 'auth0', name: 'Auth0', type: 'sass' },
{ key: 'aws', name: 'AWS', type: 'hosting' },
{ key: 'azure', name: 'Azure', type: 'hosting' },
{ key: 'azureci', name: 'AzureCi', type: 'ci' },
{ key: 'azure.ci', name: 'AzureCi', type: 'ci' },
{ key: 'bash', name: 'Bash', type: 'language' },
{ key: 'bootstrap', name: 'Bootstrap', type: 'tool' },
{ key: 'browserstack', name: 'Browserstack', type: 'ci' },
Expand Down Expand Up @@ -47,8 +47,8 @@ export const list: TechItem[] = [
{ key: 'gcp.gce', name: 'Compute Engine', type: 'hosting' },
{ key: 'gitlabci', name: 'Gitlab CI', type: 'ci' },
{ key: 'github', name: 'Github', type: 'tool' },
{ key: 'githubactions', name: 'Github Actions', type: 'ci' },
{ key: 'githubpages', name: 'Github Pages', type: 'hosting' },
{ key: 'github.actions', name: 'Github Actions', type: 'ci' },
{ key: 'github.pages', name: 'Github Pages', type: 'hosting' },
{ key: 'golang', name: 'Go', type: 'language' },
{ key: 'helm', name: 'Helm', type: 'tool' },
{ key: 'heroku', name: 'Heroku', type: 'hosting' },
Expand Down
13 changes: 8 additions & 5 deletions src/rules/ci.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { describe, expect, it } from 'vitest';

import { analyser } from '../analyser/index.js';
import { listIndexed } from '../common/techs.js';
import type { AllowedKeys } from '../index.js';
import { FakeProvider } from '../provider/fake.js';
import { rawList } from '../rules.js';
import './index.js';
Expand Down Expand Up @@ -29,16 +30,16 @@ describe('ci', () => {
files: {},
}),
});
expect(res.toJson('').techs).toStrictEqual([
const match: AllowedKeys[] = [
'appveyor',
'azureci',
'azure.ci',
'browserstack',
'circleci',
'cirrusci',
'codesandboxci',
'cypressci',
'dependabot',
'githubactions',
'github.actions',
'gitlabci',
'javascript',
'jenkins',
Expand All @@ -47,7 +48,8 @@ describe('ci', () => {
'styleci',
'teamcity',
'travisci',
]);
];
expect(res.toJson('').techs).toStrictEqual(match);
});

it('enforce that we match .github', async () => {
Expand All @@ -63,6 +65,7 @@ describe('ci', () => {
},
}),
});
expect(res.toJson('').techs).toStrictEqual(['github', 'githubactions']);
const match: AllowedKeys[] = ['github', 'github.actions'];
expect(res.toJson('').techs).toStrictEqual(match);
});
});
2 changes: 1 addition & 1 deletion src/rules/ci/azureci.ts → src/rules/ci/azure.ci.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { register } from '../../rules.js';

register({
tech: 'azureci',
tech: 'azure.ci',
files: ['azure-pipelines.yml'],
});
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { register } from '../../rules.js';

register({
tech: 'githubactions',
tech: 'github.actions',
matchFullPath: true,
files: /.github\/workflows\/.+\.yml/,
example: '.github/workflows/ci.yml',
Expand Down
4 changes: 2 additions & 2 deletions src/rules/ci/index.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import './appveyor.js';
import './azureci.js';
import './azure.ci.js';
import './browserstack.js';
import './circleci.js';
import './cirrusci.js';
import './codesandboxci.js';
import './cypressci.js';
import './dependabot.js';
import './githubactions.js';
import './github.actions.js';
import './gitlabci.js';
import './jenkins.js';
import './relativeci.js';
Expand Down
8 changes: 5 additions & 3 deletions src/rules/hosting.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { describe, expect, it } from 'vitest';

import { analyser } from '../analyser/index.js';
import { listIndexed } from '../common/techs.js';
import type { AllowedKeys } from '../index.js';
import { FakeProvider } from '../provider/fake.js';
import { rawList } from '../rules.js';
import './index.js';
Expand Down Expand Up @@ -29,15 +30,16 @@ describe('hosting', () => {
files: {},
}),
});
expect(res.toJson('').techs).toStrictEqual([
const match: AllowedKeys[] = [
'expodev',
'flyio',
'githubpages',
'github.pages',
'heroku',
'netlify',
'platformsh',
'render',
'vercel',
]);
];
expect(res.toJson('').techs).toStrictEqual(match);
});
});
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { register } from '../../rules.js';

register({
tech: 'githubpages',
tech: 'github.pages',
files: ['_config.yml'],
});
2 changes: 1 addition & 1 deletion src/rules/hosting/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import './flyio.js';
import './gcp.js';
import './gcp.cloudrun.js';
import './gcp.gce.js';
import './githubpages.js';
import './github.pages.js';
import './heroku.js';
import './kubernetes.js';
import './mongodbatlas.js';
Expand Down
10 changes: 6 additions & 4 deletions src/rules/spec/docker/dependencies.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { describe, expect, it } from 'vitest';

import { analyser } from '../../../analyser/index.js';
import type { AllowedKeys } from '../../../index.js';
import { flatten } from '../../../payload/helpers.js';
import { FakeProvider } from '../../../provider/fake.js';
import { rawList } from '../../../rules.js';
Expand Down Expand Up @@ -36,9 +37,7 @@ describe('docker', () => {
}),
});

expect(
Array.from(flatten(res, { merge: true }).techs).sort()
).toStrictEqual([
const match: AllowedKeys[] = [
'caddy',
'cassandra',
'couchbase',
Expand All @@ -64,6 +63,9 @@ describe('docker', () => {
'strapi',
'vault',
'zookeeper',
]);
];
expect(
Array.from(flatten(res, { merge: true }).techs).sort()
).toStrictEqual(match);
});
});
10 changes: 6 additions & 4 deletions src/rules/spec/nodejs/dependencies.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { describe, expect, it } from 'vitest';

import { analyser } from '../../../analyser/index.js';
import type { AllowedKeys } from '../../../index.js';
import { flatten } from '../../../payload/helpers.js';
import { FakeProvider } from '../../../provider/fake.js';
import { rawList } from '../../../rules.js';
Expand Down Expand Up @@ -30,9 +31,7 @@ describe('npm', () => {
},
}),
});
expect(
Array.from(flatten(res, { merge: true }).techs).sort()
).toStrictEqual([
const match: AllowedKeys[] = [
'algolia',
'angular',
'auth0',
Expand Down Expand Up @@ -89,6 +88,9 @@ describe('npm', () => {
'vite',
'vue',
'webpack',
]);
];
expect(
Array.from(flatten(res, { merge: true }).techs).sort()
).toStrictEqual(match);
});
});
54 changes: 31 additions & 23 deletions src/rules/spec/terraform/dependencies.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { describe, expect, it } from 'vitest';

import { analyser } from '../../../analyser/index.js';
import type { AllowedKeys } from '../../../index.js';
import { flatten } from '../../../payload/helpers.js';
import { FakeProvider } from '../../../provider/fake.js';
import { rawList } from '../../../rules.js';
Expand Down Expand Up @@ -33,28 +34,29 @@ describe('terraform (lockfile)', () => {
}),
});

expect(flatten(res, { merge: true }).techs).toStrictEqual(
new Set([
'alibabacloud',
'auth0',
'aws',
'azure',
'datadog',
'elasticsearch',
'elasticstack',
'flyio',
'gcp',
'github',
'helm',
'kubernetes',
'mongodbatlas',
'newrelic',
'oraclecloud',
'terraform',
'vault',
'vercel',
])
);
const match: AllowedKeys[] = [
'alibabacloud',
'auth0',
'aws',
'azure',
'datadog',
'elasticsearch',
'elasticstack',
'flyio',
'gcp',
'github',
'helm',
'kubernetes',
'mongodbatlas',
'newrelic',
'oraclecloud',
'terraform',
'vault',
'vercel',
];
expect(
Array.from(flatten(res, { merge: true }).techs).sort()
).toStrictEqual(match);
});
});

Expand Down Expand Up @@ -89,8 +91,14 @@ describe('terraform (resource)', () => {
}),
});

const match: AllowedKeys[] = [
'gcp.cloudrun',
'gcp.gce',
'gcp.pubsub',
'terraform',
];
expect(
Array.from(flatten(res, { merge: true }).techs).sort()
).toStrictEqual(['gcp.cloudrun', 'gcp.gce', 'gcp.pubsub', 'terraform']);
).toStrictEqual(match);
});
});
6 changes: 3 additions & 3 deletions src/types/techs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ export type AllowedKeys =
| 'appveyor'
| 'auth0'
| 'aws'
| 'azure.ci'
| 'azure'
| 'azureci'
| 'bash'
| 'bootstrap'
| 'browserstack'
Expand Down Expand Up @@ -54,9 +54,9 @@ export type AllowedKeys =
| 'gcp.gce'
| 'gcp.pubsub'
| 'gcp'
| 'github.actions'
| 'github.pages'
| 'github'
| 'githubactions'
| 'githubpages'
| 'gitlabci'
| 'golang'
| 'helm'
Expand Down

0 comments on commit 86360e3

Please sign in to comment.