diff --git a/.gitignore b/.gitignore index e2d04b6a01ee..7e7f1bb278fe 100644 --- a/.gitignore +++ b/.gitignore @@ -9,4 +9,7 @@ public/rss.xml .env.local roadmap.json yarn.lock -meetings.json \ No newline at end of file +meetings.json + +#Automatically copied in the build script +public/definitions \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 6c24e73d94bc..b7d306605ad5 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,7 +1,7 @@ { "name": "@asyncapi/website", "version": "0.1.0", - "lockfileVersion": 2, + "lockfileVersion": 1, "requires": true, "packages": { "": { @@ -15761,21 +15761,6 @@ } } }, - "string_decoder": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.3.0.tgz", - "integrity": "sha512-hkRX8U1WjJFd8LsDJ2yQ/wWWxaopEsABU1XfkM8A+j0+85JAGppt16cr1Whg6KIbb4okU6Mql6BOj+uup/wKeA==", - "requires": { - "safe-buffer": "~5.2.0" - }, - "dependencies": { - "safe-buffer": { - "version": "5.2.1", - "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", - "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==" - } - } - }, "string-hash": { "version": "1.1.3", "resolved": "https://registry.npmjs.org/string-hash/-/string-hash-1.1.3.tgz", @@ -15826,6 +15811,21 @@ "define-properties": "^1.1.3" } }, + "string_decoder": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.3.0.tgz", + "integrity": "sha512-hkRX8U1WjJFd8LsDJ2yQ/wWWxaopEsABU1XfkM8A+j0+85JAGppt16cr1Whg6KIbb4okU6Mql6BOj+uup/wKeA==", + "requires": { + "safe-buffer": "~5.2.0" + }, + "dependencies": { + "safe-buffer": { + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", + "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==" + } + } + }, "strip-ansi": { "version": "6.0.1", "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", diff --git a/package.json b/package.json index 970ec5db7110..137226064a0f 100644 --- a/package.json +++ b/package.json @@ -31,6 +31,7 @@ }, "homepage": "https://github.com/asyncapi/website#readme", "dependencies": { + "@asyncapi/specs": "^3.0.0-next-major.1", "@asyncapi/modelina": "^0.49.0", "@fec/remark-a11y-emoji": "^1.0.0", "@fullhuman/postcss-purgecss": "^2.2.0", diff --git a/scripts/copy-schema-files.js b/scripts/copy-schema-files.js new file mode 100644 index 000000000000..cc8f09960e5a --- /dev/null +++ b/scripts/copy-schema-files.js @@ -0,0 +1,40 @@ +const fs = require('fs'); +const path = require('path'); + +/** + * Look ma, it's cp -R. + * + * Pun intended https://stackoverflow.com/a/22185855/6803886 + * + * @param {string} src The path to the thing to copy. + * @param {string} dest The path to the new copy. + */ + var copyRecursiveSync = function(src, dest) { + var exists = fs.existsSync(src); + var stats = exists && fs.statSync(src); + var isDirectory = exists && stats.isDirectory(); + if (isDirectory) { + fs.mkdirSync(dest); + fs.readdirSync(src).forEach(function(childItemName) { + copyRecursiveSync(path.join(src, childItemName), + path.join(dest, childItemName)); + }); + } else { + fs.copyFileSync(src, dest); + } +}; + +/** + * Copy all the internal schema files to expose them as static files. + */ +module.exports = function copySchemaFiles() { + const sourcePath = path.resolve(__dirname, '../node_modules/@asyncapi/specs/definitions'); + const destinationPath = path.resolve(__dirname, '../public/definitions') + + const destinationExists = fs.existsSync(destinationPath); + + //Ensure we have a clean slate + if(destinationExists) fs.rmSync(destinationPath, {recursive: true}) + + copyRecursiveSync(sourcePath, destinationPath); +}; diff --git a/scripts/index.js b/scripts/index.js index d24daff1653d..dd429877af4a 100644 --- a/scripts/index.js +++ b/scripts/index.js @@ -1,12 +1,14 @@ const rssFeed = require('./build-rss'); const buildRoadMap = require('./build-roadmap'); const buildPostList = require('./build-post-list'); +const copySchemaFiles = require('./copy-schema-files'); const buildMeetings = require('./build-meetings'); async function start() { buildMeetings(); buildRoadMap(); await buildPostList(); + copySchemaFiles(); rssFeed( 'blog', 'AsyncAPI Initiative Blog RSS Feed',