diff --git a/.circleci/config.yml b/.circleci/config.yml index 0372834b02..7c2e4e6226 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -66,6 +66,9 @@ references: - test_node_15: requires: - setup + - check_metadata: + requires: + - setup jobs: setup: @@ -223,6 +226,13 @@ jobs: - *install_react - run: npm run test-node -- -w 1 -u + check_metadata: + <<: *container_config + steps: + - checkout + - *attach_workspace + - run: node ./scripts/check-demo.js + workflows: version: 2 build_test: diff --git a/package.json b/package.json index bb9476b691..94985bfc2c 100644 --- a/package.json +++ b/package.json @@ -136,6 +136,7 @@ "eslint-plugin-react": "^7.14.2", "eslint-tinker": "^0.5.0", "fetch-jsonp": "^1.1.3", + "fs-extra": "^8.1.0", "full-icu": "^1.3.0", "glob": "^7.1.4", "husky": "^3.0.2", @@ -186,7 +187,8 @@ "stylelint-order": "^3.0.0", "typescript": "~3.5.1", "xhr-mock": "^2.4.1", - "xhr2": "^0.2.0" + "xhr2": "^0.2.0", + "yaml-front-matter": "^4.0.0" }, "scripts": { "test": "jest --config .jest.js --no-cache", diff --git a/scripts/check-demo.js b/scripts/check-demo.js new file mode 100644 index 0000000000..9443d23487 --- /dev/null +++ b/scripts/check-demo.js @@ -0,0 +1,14 @@ +const path = require('path'); +const yfm = require('yaml-front-matter'); +const glob = require('glob'); +const fs = require('fs-extra'); + +const demoFiles = glob.sync(path.join(process.cwd(), 'components/**/demo/*.md')); +// eslint-disable-next-line no-restricted-syntax +for (const url of demoFiles) { + const demoContent = fs.readFileSync(url); + const meta = yfm.loadFront(demoContent); + if (meta.only) { + throw Error(`there is a 'only': ${url}`); + } +}