Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: expose all AsyncAPI JSON Schema documents #502

Closed
Closed
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,7 @@ public/rss.xml
.env.local
roadmap.json
yarn.lock
meetings.json
meetings.json

#Automatically copied in the build script
public/definitions
32 changes: 16 additions & 16 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
},
"homepage": "https://github.com/asyncapi/website#readme",
"dependencies": {
"@asyncapi/specs": "^3.0.0-next-major.1",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why 3.0.0? Should we just use the latest stable version?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because the introduction of split schemas and bundling them is a breaking change, i.e. version 3.0.0 of the library :)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ouch, yeah, sorry. 😅

"@asyncapi/modelina": "^0.49.0",
"@fec/remark-a11y-emoji": "^1.0.0",
"@fullhuman/postcss-purgecss": "^2.2.0",
Expand Down
40 changes: 40 additions & 0 deletions scripts/copy-schema-files.js
Original file line number Diff line number Diff line change
@@ -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');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would add a console.log somewhere so you can at least have some logs of what is happening

const destinationPath = path.resolve(__dirname, '../public/definitions')

const destinationExists = fs.existsSync(sourcePath);

//Ensure we have a clean slate
if(destinationExists) fs.rmSync(destinationPath, {recursive: true})

copyRecursiveSync(sourcePath, destinationPath);
};
2 changes: 2 additions & 0 deletions scripts/index.js
Original file line number Diff line number Diff line change
@@ -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',
Expand Down