feat: converted the app schemas to typescript, removed typings file and related schema scripts. (#1869)

* feat: remove app json schemas and clean up

* updated recently added schema refrences
This commit is contained in:
Jeff Smith 2019-06-18 12:55:21 -07:00 коммит произвёл GitHub
Родитель 450a507738
Коммит f7c29da97d
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
44 изменённых файлов: 208 добавлений и 299 удалений

Просмотреть файл

@ -1,6 +1,6 @@
/**
* Utility for copying schemas to their dist folders.
* Usage: node build/copy-schemas.js
* Usage: node build/convert-schemas.js
*/
const path = require("path");
const fs = require("fs");

Просмотреть файл

@ -1,30 +0,0 @@
/**
* Utility for copying schemas to their dist folders.
* Usage: node build/copy-schemas.js
*/
const path = require("path");
const fs = require("fs");
const glob = require("glob");
const rootDir = path.resolve(process.cwd());
const srcSchemaPaths = "src/**/*.schema.json";
const destDir = "dist";
/**
* Function to copy schema files to their dist folder
*/
function copySchemaFiles() {
const resolvedSrcSchemaPaths = path.resolve(rootDir, srcSchemaPaths);
glob(resolvedSrcSchemaPaths, void(0), function(error, files) {
files.forEach((filePath) => {
const destSchemaPath = filePath.replace(/(\bsrc\b)(?!.*\1)/, destDir);
fs.copyFileSync(filePath, destSchemaPath);
});
});
}
/**
* Copy all files
*/
copySchemaFiles();

Просмотреть файл

@ -1,26 +0,0 @@
{
"$schema": "http://json-schema.org/schema#",
"title": "HTML Element",
"description": "An arbitrary HTML element component's schema definition.",
"id": "react-html-element",
"type": "object",
"properties": {
"slot": {
"title": "Slot",
"type": "string"
},
"tag": {
"title": "HTML Tag",
"type": "string"
}
},
"reactProperties": {
"children": {
"title": "Children",
"type": "children",
"defaults": [
"text"
]
}
}
}

Просмотреть файл

@ -23,7 +23,6 @@
"clean:dist": "node ../../build/clean.js dist",
"convert:readme": "node ../../build/convert-readme.js .tmp",
"copy:all": "npm run convert:json-schema && npm run copy:readme",
"copy:json-schema": "node ../../build/copy-schemas.js",
"convert:json-schema": "node ../../build/convert-schemas.js",
"copy:readme": "node ../../build/copy-readme.js",
"prepare": "npm run clean:dist && npm run build",

Просмотреть файл

@ -3,8 +3,5 @@
"compilerOptions": {
"baseUrl": ".",
"outDir": "./dist"
},
"files": [
"typings.d.ts"
]
}
}

Просмотреть файл

@ -1,4 +0,0 @@
declare module "*.json" {
const value: any;
export default value;
}

Просмотреть файл

@ -1,4 +1,4 @@
import CarouselDarkImageContentSchema from "./carousel-dark-image-content.schema.json";
import CarouselDarkImageContentSchema from "./carousel-dark-image-content.schema";
import CarouselDarkImageContent from "./carousel-dark-image-content";
export default {
name: "Dark image slide",

Просмотреть файл

@ -1,27 +0,0 @@
{
"$schema": "http://json-schema.org/schema#",
"title": "Carousel Dark Image Content Test Element",
"description": "A carousel dark image content component's schema definition.",
"id": "carousel-dark-image-content",
"type": "object",
"properties": {
"image": {
"title": "Image",
"type": "object",
"properties": {
"src": {
"title": "HTML src attribute",
"type": "string",
"default": "http://placehold.it/1399x600/2F2F2F/171717"
},
"alt": {
"title": "HTML alt attribute",
"type": "string"
}
},
"required": [
"src"
]
}
}
}

Просмотреть файл

@ -0,0 +1,25 @@
export default {
$schema: "http://json-schema.org/schema#",
title: "Carousel Dark Image Content Test Element",
description: "A carousel dark image content component's schema definition.",
id: "carousel-dark-image-content",
type: "object",
properties: {
image: {
title: "Image",
type: "object",
properties: {
src: {
title: "HTML src attribute",
type: "string",
default: "http://placehold.it/1399x600/2F2F2F/171717",
},
alt: {
title: "HTML alt attribute",
type: "string",
},
},
required: ["src"],
},
},
};

Просмотреть файл

@ -1,4 +1,4 @@
import CarouselHeroContentSchema from "./carousel-hero-content.schema.json";
import CarouselHeroContentSchema from "./carousel-hero-content.schema";
import CarouselHeroContent from "./carousel-hero-content";
export default {
name: "Hero slide",

Просмотреть файл

@ -1,67 +0,0 @@
{
"$schema": "http://json-schema.org/schema#",
"title": "Carousel Hero Content Test Element",
"description": "A carousel hero content component's schema definition.",
"id": "carousel-hero-content",
"type": "object",
"properties": {
"heading": {
"title": "Heading",
"type": "object",
"properties": {
"children": {
"title": "Heading text",
"type": "string"
}
}
},
"paragraph": {
"title": "Paragraph",
"type": "object",
"properties": {
"children": {
"title": "Hero paragraph test text",
"type": "string"
}
}
},
"callToAction": {
"title": "Call to action",
"type": "object",
"properties": {
"children": {
"title": "Call to action",
"type": "string"
},
"href": {
"title": "HTML href attribute",
"type": "string"
},
"appearance": {
"title": "Appearance",
"type": "string",
"default": "primary",
"enum": [
"primary",
"justified",
"lightweight"
]
}
}
},
"image": {
"title": "Image",
"type": "object",
"properties": {
"src": {
"title": "HTML src attribute",
"type": "string"
},
"alt": {
"title": "HTML alt attribute",
"type": "string"
}
}
}
}
}

Просмотреть файл

@ -0,0 +1,63 @@
export default {
$schema: "http://json-schema.org/schema#",
title: "Carousel Hero Content Test Element",
description: "A carousel hero content component's schema definition.",
id: "carousel-hero-content",
type: "object",
properties: {
heading: {
title: "Heading",
type: "object",
properties: {
children: {
title: "Heading text",
type: "string",
},
},
},
paragraph: {
title: "Paragraph",
type: "object",
properties: {
children: {
title: "Hero paragraph test text",
type: "string",
},
},
},
callToAction: {
title: "Call to action",
type: "object",
properties: {
children: {
title: "Call to action",
type: "string",
},
href: {
title: "HTML href attribute",
type: "string",
},
appearance: {
title: "Appearance",
type: "string",
default: "primary",
enum: ["primary", "justified", "lightweight"],
},
},
},
image: {
title: "Image",
type: "object",
properties: {
src: {
title: "HTML src attribute",
type: "string",
},
alt: {
title: "HTML alt attribute",
type: "string",
},
},
},
},
};

Просмотреть файл

@ -1,4 +1,4 @@
import CarouselLightImageContentSchema from "./carousel-light-image-content.schema.json";
import CarouselLightImageContentSchema from "./carousel-light-image-content.schema";
import CarouselLightImageContent from "./carousel-light-image-content";
export default {
name: "Light image slide",

Просмотреть файл

@ -1,23 +0,0 @@
{
"$schema": "http://json-schema.org/schema#",
"title": "Carousel Light Image Content Test Element",
"description": "A carousel light image content component's schema definition.",
"id": "carousel-light-image-content",
"type": "object",
"properties": {
"image": {
"title": "Image",
"type": "object",
"properties": {
"src": {
"title": "HTML src attribute",
"type": "string"
},
"alt": {
"title": "HTML alt attribute",
"type": "string"
}
}
}
}
}

Просмотреть файл

@ -0,0 +1,23 @@
export default {
$schema: "http://json-schema.org/schema#",
title: "Carousel Light Image Content Test Element",
description: "A carousel light image content component's schema definition.",
id: "carousel-light-image-content",
type: "object",
properties: {
image: {
title: "Image",
type: "object",
properties: {
src: {
title: "HTML src attribute",
type: "string",
},
alt: {
title: "HTML alt attribute",
type: "string",
},
},
},
},
};

Просмотреть файл

@ -1,4 +1,4 @@
import PivotItemContentSchema from "./pivot-item-content.schema.json";
import PivotItemContentSchema from "./pivot-item-content.schema";
import PivotItemContent from "./pivot-item-content";
export default {
name: "Pivot item content",

Просмотреть файл

@ -1,17 +0,0 @@
{
"$schema": "http://json-schema.org/schema#",
"title": "Pivot Item Content",
"description": "A pivot item content component's schema definition.",
"id": "pivot-item-content",
"type": "object",
"properties": {},
"reactProperties": {
"children": {
"title": "Children",
"type": "children",
"defaults": [
"text"
]
}
}
}

Просмотреть файл

@ -0,0 +1,15 @@
export default {
$schema: "http://json-schema.org/schema#",
title: "Pivot Item Content",
description: "A pivot item content component's schema definition.",
id: "pivot-item-content",
type: "object",
properties: {},
reactProperties: {
children: {
title: "Children",
type: "children",
defaults: ["text"],
},
},
};

Просмотреть файл

@ -1,4 +1,4 @@
import PivotItemTabSchema from "./pivot-item-tab.schema.json";
import PivotItemTabSchema from "./pivot-item-tab.schema";
import PivotItemTab from "./pivot-item-tab";
export default {
name: "Pivot item tab",

Просмотреть файл

@ -1,17 +0,0 @@
{
"$schema": "http://json-schema.org/schema#",
"title": "Pivot Item Tab",
"description": "A pivot item tab component's schema definition.",
"id": "pivot-item-tab",
"type": "object",
"properties": {},
"reactProperties": {
"children": {
"title": "Children",
"type": "children",
"defaults": [
"text"
]
}
}
}

Просмотреть файл

@ -0,0 +1,15 @@
export default {
$schema: "http://json-schema.org/schema#",
title: "Pivot Item Tab",
description: "A pivot item tab component's schema definition.",
id: "pivot-item-tab",
type: "object",
properties: {},
reactProperties: {
children: {
title: "Children",
type: "children",
defaults: ["text"],
},
},
};

Просмотреть файл

@ -1,4 +1,4 @@
import htmlElementSchema from "./react-html-element.schema.json";
import htmlElementSchema from "./react-html-element.schema";
import ReactHTMLElement from "./react-html-element";
export default {
name: "HTML Element",

Просмотреть файл

@ -1,26 +0,0 @@
{
"$schema": "http://json-schema.org/schema#",
"title": "HTML Element",
"description": "An arbitrary HTML element component's schema definition.",
"id": "react-html-element",
"type": "object",
"properties": {
"slot": {
"title": "Slot",
"type": "string"
},
"tag": {
"title": "HTML Tag",
"type": "string"
}
},
"reactProperties": {
"children": {
"title": "Children",
"type": "children",
"defaults": [
"text"
]
}
}
}

Просмотреть файл

@ -0,0 +1,24 @@
export default {
$schema: "http://json-schema.org/schema#",
title: "HTML Element",
description: "An arbitrary HTML element component's schema definition.",
id: "react-html-element",
type: "object",
properties: {
slot: {
title: "Slot",
type: "string",
},
tag: {
title: "HTML Tag",
type: "string",
},
},
reactProperties: {
children: {
title: "Children",
type: "children",
defaults: ["text"],
},
},
};

Просмотреть файл

@ -1,4 +1,4 @@
import svgSvgElementSchema from "./svg-svg-element.schema.json";
import svgSvgElementSchema from "./svg-svg-element.schema";
import SVGSVGElement from "./svg-svg-element";
export default {
name: "SVG Test Element",

Просмотреть файл

@ -1,22 +0,0 @@
{
"$schema": "http://json-schema.org/schema#",
"title": "SVG Test Element",
"description": "An arbitrary SVG svg element component's schema definition.",
"id": "svg-svg-element",
"type": "object",
"properties": {
"path": {
"title": "Glyph",
"type": "string",
"enum": [
"play",
"pause",
"robot",
"user",
"arrow",
"download"
],
"default": "play"
}
}
}

Просмотреть файл

@ -0,0 +1,15 @@
export default {
$schema: "http://json-schema.org/schema#",
title: "SVG Test Element",
description: "An arbitrary SVG svg element component's schema definition.",
id: "svg-svg-element",
type: "object",
properties: {
path: {
title: "Glyph",
type: "string",
enum: ["play", "pause", "robot", "user", "arrow", "download"],
default: "play",
},
},
};

Просмотреть файл

@ -23,7 +23,6 @@
"clean:dist": "node ../../build/clean.js dist",
"convert:readme": "node ../../build/convert-readme.js .tmp",
"copy:all": "npm run convert:json-schema && npm run copy:readme",
"copy:json-schema": "node ../../build/copy-schemas.js",
"convert:json-schema": "node ../../build/convert-schemas.js",
"copy:readme": "node ../../build/copy-readme.js",
"prepare": "npm run clean:dist && npm run build",

Просмотреть файл

@ -4,7 +4,7 @@ import { AccentButton, AccentButtonProps, accentButtonSchema } from "./index";
import Documentation from "./.tmp/documentation";
import { ComponentFactoryExample } from "@microsoft/fast-development-site-react";
import { SVGGlyph } from "../../app/components/svg-svg-element";
import svgSchema from "../../app/components/svg-svg-element.schema.json";
import svgSchema from "../../app/components/svg-svg-element.schema";
const examples: ComponentFactoryExample<AccentButtonProps> = {
name: "Accent button",

Просмотреть файл

@ -8,7 +8,7 @@ import {
import Documentation from "./.tmp/documentation";
import { ComponentFactoryExample } from "@microsoft/fast-development-site-react";
import { SVGGlyph } from "../../app/components/svg-svg-element";
import svgSchema from "../../app/components/svg-svg-element.schema.json";
import svgSchema from "../../app/components/svg-svg-element.schema";
const examples: ComponentFactoryExample<ActionToggleProps> = {
name: "Action toggle",

Просмотреть файл

@ -7,7 +7,7 @@ import {
} from "./index";
import Documentation from "./.tmp/documentation";
import { ComponentFactoryExample } from "@microsoft/fast-development-site-react";
import svgSchema from "../../app/components/svg-svg-element.schema.json";
import svgSchema from "../../app/components/svg-svg-element.schema";
const testDestination: string = "https://www.microsoft.com/en-us/";

Просмотреть файл

@ -3,7 +3,7 @@ import { Breadcrumb, BreadcrumbHandledProps, breadcrumbSchema } from "./index";
import { ComponentFactoryExample } from "@microsoft/fast-development-site-react";
import { hypertextSchema } from "../index";
import Documentation from "./.tmp/documentation";
import ReactHTMLElementSchema from "../../app/components/react-html-element.schema.json";
import ReactHTMLElementSchema from "../../app/components/react-html-element.schema";
const label: any = {
label: "breadcrumb",

Просмотреть файл

@ -4,10 +4,10 @@ import { Button, ButtonAppearance, ButtonProps, buttonSchema } from "./index";
import { ButtonHandledProps as BaseButtonHandledProps } from "@microsoft/fast-components-react-base";
import Documentation from "./.tmp/documentation";
import { ComponentFactoryExample } from "@microsoft/fast-development-site-react";
import ReactHTMLElementSchema from "../../app/components/react-html-element.schema.json";
import ReactHTMLElementSchema from "../../app/components/react-html-element.schema";
import { ButtonSlot } from "./button";
import { SVGGlyph } from "../../app/components/svg-svg-element";
import svgSchema from "../../app/components/svg-svg-element.schema.json";
import svgSchema from "../../app/components/svg-svg-element.schema";
const beforeSlotExample: any = {
id: ReactHTMLElementSchema.id,

Просмотреть файл

@ -5,9 +5,9 @@ import Documentation from "./.tmp/documentation";
import { CarouselSlide, CarouselSlideTheme } from "./carousel.props";
import { CallToActionAppearance } from "../call-to-action";
import { uniqueId } from "lodash-es";
import carouselHeroContentSchema from "../../app/components/carousel-hero-content.schema.json";
import carouselDarkImageContentSchema from "../../app/components/carousel-dark-image-content.schema.json";
import carouselLightImageContentSchema from "../../app/components/carousel-light-image-content.schema.json";
import carouselHeroContentSchema from "../../app/components/carousel-hero-content.schema";
import carouselDarkImageContentSchema from "../../app/components/carousel-dark-image-content.schema";
import carouselLightImageContentSchema from "../../app/components/carousel-light-image-content.schema";
const heroContentProps: object = {
props: {

Просмотреть файл

@ -4,7 +4,7 @@ import { JustifiedButton, JustifiedButtonProps, justifiedButtonSchema } from "./
import Documentation from "./.tmp/documentation";
import { ComponentFactoryExample } from "@microsoft/fast-development-site-react";
import { SVGGlyph } from "../../app/components/svg-svg-element";
import svgSchema from "../../app/components/svg-svg-element.schema.json";
import svgSchema from "../../app/components/svg-svg-element.schema";
const examples: ComponentFactoryExample<JustifiedButtonProps> = {
name: "Justified button",

Просмотреть файл

@ -8,7 +8,7 @@ import {
import Documentation from "./.tmp/documentation";
import { ComponentFactoryExample } from "@microsoft/fast-development-site-react";
import { SVGGlyph } from "../../app/components/svg-svg-element";
import svgSchema from "../../app/components/svg-svg-element.schema.json";
import svgSchema from "../../app/components/svg-svg-element.schema";
const examples: ComponentFactoryExample<LightweightButtonProps> = {
name: "Lightweight button",

Просмотреть файл

@ -4,7 +4,7 @@ import { NeutralButton, NeutralButtonProps, neutralButtonSchema } from "./index"
import Documentation from "./.tmp/documentation";
import { ComponentFactoryExample } from "@microsoft/fast-development-site-react";
import { SVGGlyph } from "../../app/components/svg-svg-element";
import svgSchema from "../../app/components/svg-svg-element.schema.json";
import svgSchema from "../../app/components/svg-svg-element.schema";
const examples: ComponentFactoryExample<NeutralButtonProps> = {
name: "Neutral button",

Просмотреть файл

@ -4,7 +4,7 @@ import { OutlineButton, OutlineButtonProps, outlineButtonSchema } from "./index"
import Documentation from "./.tmp/documentation";
import { ComponentFactoryExample } from "@microsoft/fast-development-site-react";
import { SVGGlyph } from "../../app/components/svg-svg-element";
import svgSchema from "../../app/components/svg-svg-element.schema.json";
import svgSchema from "../../app/components/svg-svg-element.schema";
const examples: ComponentFactoryExample<OutlineButtonProps> = {
name: "Outline button",

Просмотреть файл

@ -4,8 +4,8 @@ import { Pivot, PivotHandledProps, PivotProps, pivotSchema } from "./index";
import Documentation from "./.tmp/documentation";
import { TabsItem } from "@microsoft/fast-components-react-base";
import { uniqueId } from "lodash-es";
import pivotItemContentSchema from "../../app/components/pivot-item-content.schema.json";
import pivotItemTabSchema from "../../app/components/pivot-item-tab.schema.json";
import pivotItemContentSchema from "../../app/components/pivot-item-content.schema";
import pivotItemTabSchema from "../../app/components/pivot-item-tab.schema";
const pivotItem1: TabsItem = {
tab: {

Просмотреть файл

@ -3,7 +3,7 @@ import { SelectOption, SelectOptionProps, selectOptionSchema } from "./index";
import { ComponentFactoryExample } from "@microsoft/fast-development-site-react";
import Documentation from "./.tmp/documentation";
import { SVGGlyph } from "../../app/components/svg-svg-element";
import svgSchema from "../../app/components/svg-svg-element.schema.json";
import svgSchema from "../../app/components/svg-svg-element.schema";
export default {
name: "Select option",

Просмотреть файл

@ -4,7 +4,7 @@ import { StealthButton, StealthButtonProps, stealthButtonSchema } from "./index"
import Documentation from "./.tmp/documentation";
import { ComponentFactoryExample } from "@microsoft/fast-development-site-react";
import { SVGGlyph } from "../../app/components/svg-svg-element";
import svgSchema from "../../app/components/svg-svg-element.schema.json";
import svgSchema from "../../app/components/svg-svg-element.schema";
const examples: ComponentFactoryExample<StealthButtonProps> = {
name: "Stealth button",

Просмотреть файл

@ -4,7 +4,7 @@ import Documentation from "./.tmp/documentation";
import { ComponentFactoryExample } from "@microsoft/fast-development-site-react";
import { TextActionAppearance, TextActionButtonPosition } from "./text-action.props";
import { SVGGlyph } from "../../app/components/svg-svg-element";
import svgSchema from "../../app/components/svg-svg-element.schema.json";
import svgSchema from "../../app/components/svg-svg-element.schema";
import { buttonSchema } from "../index";
const examples: ComponentFactoryExample<TextActionProps> = {

Просмотреть файл

@ -3,8 +3,5 @@
"compilerOptions": {
"baseUrl": ".",
"outDir": "./dist"
},
"files": [
"typings.d.ts"
]
}
}

Просмотреть файл

@ -1,4 +0,0 @@
declare module "*.json" {
const value: any;
export default value;
}