Files
payload/test/generateGraphQLSchema.ts
Alessio Gravili 696a215dd0 feat: move some stuff over to the new adapter pattern (#2880)
* chore: add jsdocs for limit

* moar jsdocs

* Replace find in deleteByID

* (check this:) add missing locale

* move findByID

* Make findByID return only one document

* _id => id

* _id => id

* Improve version types

* Improve sortOrder types

* move version stuff over

* version stuff

* fix: sort types

* fix params

* fix: findVersionByID generic

* fix: type error for versions

* remove unused value

* fix: Document import

* add todo

* feat: updateOne to mongoose

* remove unnecessary Model

* more update stuff

* remove unnecessary imports

* remove unnecessary function arguments

* fix: auth db update calls

* fix: bad updateByID which made tests fail

* fix: update returned docs to fix tests

* fix: update from version using mongoose directly even though the Model does not exist

* feat: implement deleteOne

* fix: assign verificationToken only when it exists - fixes test

* migrate saveVersion partly

* feat: make dev:generate-graphql-schema work even without specifying extra argument

* fix: this.db can be null

* chore: use destructured locale where possible

* chore: improve variable name

* fix: SanitizedConfig type

* feat: findGlobal database adapter

* fix: flaky e2e test

* chore: improve incorrect comment

* chore: undo diffs

* fix: id types

* fix: id typing
2023-06-26 17:45:52 +02:00

35 lines
916 B
TypeScript

import path from 'path';
import fs from 'fs';
import { generateGraphQLSchema } from '../src/bin/generateGraphQLSchema';
const [testConfigDir] = process.argv.slice(2);
let testDir;
if (testConfigDir) {
testDir = path.resolve(__dirname, testConfigDir);
setPaths(testDir);
generateGraphQLSchema();
} else {
// Generate graphql schema for entire directory
testDir = __dirname;
fs.readdirSync(__dirname, { withFileTypes: true })
.filter((f) => f.isDirectory())
.forEach((dir) => {
const suiteDir = path.resolve(testDir, dir.name);
const configFound = setPaths(suiteDir);
if (configFound) generateGraphQLSchema();
});
}
// Set config path and TS output path using test dir
function setPaths(dir) {
const configPath = path.resolve(dir, 'config.ts');
if (fs.existsSync(configPath)) {
process.env.PAYLOAD_CONFIG_PATH = configPath;
return true;
}
return false;
}