mirror of
https://github.com/LukeHagar/vercel.git
synced 2025-12-09 21:07:46 +00:00
We renamed the GitHub repository from `zeit/now` to `vercel/vercel` so this PR updates all references to the repo URL. There were also a few remaining references to Now CLI that have been updated to Vercel CLI.
133 lines
3.1 KiB
TypeScript
Vendored
133 lines
3.1 KiB
TypeScript
Vendored
import Ajv from 'ajv';
|
|
import path from 'path';
|
|
import { existsSync } from 'fs';
|
|
import { Framework } from '../';
|
|
|
|
function isString(arg: any): arg is string {
|
|
return typeof arg === 'string';
|
|
}
|
|
|
|
const SchemaFrameworkDetectionItem = {
|
|
type: 'array',
|
|
items: [
|
|
{
|
|
type: 'object',
|
|
required: ['path'],
|
|
additionalProperties: false,
|
|
properties: {
|
|
path: {
|
|
type: 'string',
|
|
},
|
|
matchContent: {
|
|
type: 'string',
|
|
},
|
|
},
|
|
},
|
|
],
|
|
};
|
|
|
|
const SchemaSettings = {
|
|
oneOf: [
|
|
{
|
|
type: 'object',
|
|
required: ['value'],
|
|
additionalProperties: false,
|
|
properties: {
|
|
value: {
|
|
type: 'string',
|
|
},
|
|
},
|
|
},
|
|
{
|
|
type: 'object',
|
|
required: ['placeholder'],
|
|
additionalProperties: false,
|
|
properties: {
|
|
placeholder: {
|
|
type: 'string',
|
|
},
|
|
},
|
|
},
|
|
],
|
|
};
|
|
|
|
const Schema = {
|
|
type: 'array',
|
|
items: {
|
|
type: 'object',
|
|
required: ['name', 'slug', 'logo', 'description', 'settings'],
|
|
additionalProperties: false,
|
|
properties: {
|
|
name: { type: 'string' },
|
|
slug: { type: ['string', 'null'] },
|
|
logo: { type: 'string' },
|
|
demo: { type: 'string' },
|
|
tagline: { type: 'string' },
|
|
website: { type: 'string' },
|
|
description: { type: 'string' },
|
|
detectors: {
|
|
type: 'object',
|
|
additionalProperties: false,
|
|
properties: {
|
|
every: SchemaFrameworkDetectionItem,
|
|
some: SchemaFrameworkDetectionItem,
|
|
},
|
|
},
|
|
settings: {
|
|
type: 'object',
|
|
required: ['buildCommand', 'devCommand', 'outputDirectory'],
|
|
additionalProperties: false,
|
|
properties: {
|
|
buildCommand: SchemaSettings,
|
|
devCommand: SchemaSettings,
|
|
outputDirectory: SchemaSettings,
|
|
},
|
|
},
|
|
},
|
|
},
|
|
};
|
|
|
|
describe('frameworks', () => {
|
|
it('ensure there is an example for every framework', async () => {
|
|
const root = path.join(__dirname, '..', '..', '..');
|
|
const getExample = (name: string) => path.join(root, 'examples', name);
|
|
|
|
const frameworks = require('../frameworks.json') as Framework[];
|
|
|
|
const result = frameworks
|
|
.map(f => f.slug)
|
|
.filter(isString)
|
|
.filter(f => existsSync(getExample(f)) === false);
|
|
|
|
expect(result).toEqual([]);
|
|
});
|
|
|
|
it('ensure schema', async () => {
|
|
const frameworks = require('../frameworks.json') as Framework[];
|
|
|
|
const ajv = new Ajv();
|
|
const result = ajv.validate(Schema, frameworks);
|
|
|
|
if (ajv.errors) {
|
|
console.error(ajv.errors);
|
|
}
|
|
|
|
expect(result).toBe(true);
|
|
});
|
|
|
|
it('ensure logo', async () => {
|
|
const frameworks = require('../frameworks.json') as Framework[];
|
|
|
|
const missing = frameworks
|
|
.map(f => f.logo)
|
|
.filter(url => {
|
|
const prefix =
|
|
'https://raw.githubusercontent.com/vercel/vercel/master/packages/frameworks/logos/';
|
|
const name = url.replace(prefix, '');
|
|
return existsSync(path.join(__dirname, '..', 'logos', name)) === false;
|
|
});
|
|
|
|
expect(missing).toEqual([]);
|
|
});
|
|
});
|