Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,18 @@ export default [
{
rules: {
'@typescript-eslint/restrict-template-expressions': ['error', { allowNumber: true }],
'@typescript-eslint/no-unused-vars': [
'error',
{
args: 'all',
argsIgnorePattern: '^_',
caughtErrors: 'all',
caughtErrorsIgnorePattern: '^_',
destructuredArrayIgnorePattern: '^_',
varsIgnorePattern: '^_',
ignoreRestSiblings: true,
},
],
},
},
];
11 changes: 1 addition & 10 deletions src/templates/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,20 +40,11 @@ export const getBoatsRc = (): string => {
return (
JSON.stringify(
{
nunjucksOptions: {
// this empty object just needs to exist, otherwise boats explodes
tags: {},
},
picomatchOptions: {
bash: true,
},
permissionConfig: {
globalPrefix: true,
},
paths: {
'@shared/': '../shared/',
},
fancyPluralization: true,
paths: {},
},
null,
2,
Expand Down
26 changes: 16 additions & 10 deletions test/boats.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import { default as template } from 'boats/build/src/Template';
import { default as bundlerSwaggerParse } from 'boats/build/src/bundlerSwaggerParse';
import { BoatsRC } from 'boats/build/src/interfaces/BoatsRc';
import { access, readFile } from 'fs/promises';
import { dirname } from 'path';
import pj from '../package.json';
import { getBoatsRc } from '../src/templates/init';

export type ErrorWithLogs = Error & { code: string; logs: unknown[] };

Expand All @@ -12,14 +14,6 @@ type ConsoleMock = {
unmock: () => void;
};

export const defaultBoats: BoatsRC = {
nunjucksOptions: { tags: {} },
picomatchOptions: { bash: true },
permissionConfig: { globalPrefix: true },
paths: {},
fancyPluralization: true,
};

const mockConsoleLog = (): ConsoleMock => {
/* eslint-disable no-console */
const olog = console.log;
Expand Down Expand Up @@ -74,19 +68,31 @@ const overridePackageJsonReader = (): void => {
};
};

const defaultBoatsRc = JSON.parse(getBoatsRc()) as BoatsRC;

export const boats = async (inFile: string, outFile: string, validate = true): Promise<string> => {
const trim = dirname(inFile) + '/paths/';
const customBoatsRcPath = dirname(dirname(inFile)) + '/.boatsrc';
let boatsRc = defaultBoatsRc;
try {
const hasBoatsRc = await access(customBoatsRcPath)
.then(() => true)
.catch(() => false);
if (hasBoatsRc) {
boatsRc = JSON.parse(await readFile(customBoatsRcPath, { encoding: 'utf8' })) as BoatsRC;
}
} catch (_e: unknown) {}

overridePackageJsonReader();
// overwrite console during testing - no debug output needed
const con = mockConsoleLog();

try {
const indexFile = template.directoryParse(inFile, outFile, null as unknown as number, trim, [], [], defaultBoats, false);
const indexFile = template.directoryParse(inFile, outFile, null as unknown as number, trim, [], [], boatsRc, false);
const outApiFile = await bundlerSwaggerParse({
inputFile: indexFile,
outputFile: outFile,
boatsRc: defaultBoats,
boatsRc,
dereference: false,
doNotValidate: !validate,
excludeVersion: false,
Expand Down
12 changes: 2 additions & 10 deletions test/e2e.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,11 @@ describe('e2e.spec.ts', async () => {
content,
trimIndent`\
{
"nunjucksOptions": {
"tags": {}
},
"picomatchOptions": {
"bash": true
},
"permissionConfig": {
"globalPrefix": true
},
"paths": {
"@shared/": "../shared/"
},
"fancyPluralization": true
"fancyPluralization": true,
"paths": {}
}
`,
);
Expand Down
12 changes: 2 additions & 10 deletions test/fixtures/e2e/gen1/.boatsrc
Original file line number Diff line number Diff line change
@@ -1,15 +1,7 @@
{
"nunjucksOptions": {
"tags": {}
},
"picomatchOptions": {
"bash": true
},
"permissionConfig": {
"globalPrefix": true
},
"paths": {
"@shared/": "../shared/"
},
"fancyPluralization": true
"fancyPluralization": true,
"paths": {}
}
12 changes: 2 additions & 10 deletions test/fixtures/e2e/gen2/.boatsrc
Original file line number Diff line number Diff line change
@@ -1,15 +1,7 @@
{
"nunjucksOptions": {
"tags": {}
},
"picomatchOptions": {
"bash": true
},
"permissionConfig": {
"globalPrefix": true
},
"paths": {
"@shared/": "../shared/"
},
"fancyPluralization": true
"fancyPluralization": true,
"paths": {}
}
12 changes: 2 additions & 10 deletions test/model.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,19 +60,11 @@ describe('model.spec.ts', async () => {
await getFile('test/output/model/.boatsrc'),
trimIndent`\
{
"nunjucksOptions": {
"tags": {}
},
"picomatchOptions": {
"bash": true
},
"permissionConfig": {
"globalPrefix": true
},
"paths": {
"@shared/": "../shared/"
},
"fancyPluralization": true
"fancyPluralization": true,
"paths": {}
}
`,
);
Expand Down
12 changes: 2 additions & 10 deletions test/path.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,19 +70,11 @@ describe('path.spec.ts', async () => {
await getFile('test/output/path/.boatsrc'),
trimIndent`\
{
"nunjucksOptions": {
"tags": {}
},
"picomatchOptions": {
"bash": true
},
"permissionConfig": {
"globalPrefix": true
},
"paths": {
"@shared/": "../shared/"
},
"fancyPluralization": true
"fancyPluralization": true,
"paths": {}
}
`,
);
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@
"strictNullChecks": true
},
"include": ["src", "test"],
"exclude": ["node_modules"]
"exclude": ["node_modules", "test/output"]
}