Skip to content

Commit

Permalink
Removed unused files
Browse files Browse the repository at this point in the history
  • Loading branch information
aayushRedHat committed Jan 9, 2024
1 parent 4c5e29d commit 4d7f3ea
Show file tree
Hide file tree
Showing 16 changed files with 46,341 additions and 32 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@ test/test-project/node_modules/*
test/test-project/node_modules/@asyncapi/*
!test/test-project/node_modules/@asyncapi/html-template/
test/test-project/package-lock.json
test/test-project/verdaccio/storage/.verdaccio-db.json
test/test-project/verdaccio/storage/
9 changes: 8 additions & 1 deletion lib/generator.js
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,13 @@ class Generator {
if (!document) {
const err = new Error('Input is not a correct AsyncAPI document so it cannot be processed.');
err.diagnostics = diagnostics;
for (const diag of diagnostics) {
console.error(
`Diagnostic err: ${diag['message']} in path ${JSON.stringify(diag['path'])} starting `+
`L${diag['range']['start']['line'] + 1} C${diag['range']['start']['character']}, ending `+
`L${diag['range']['end']['line'] + 1} C${diag['range']['end']['character']}`
);
}
throw err;
} else {
this.asyncapi = document;
Expand Down Expand Up @@ -1055,4 +1062,4 @@ class Generator {
Generator.DEFAULT_TEMPLATES_DIR = DEFAULT_TEMPLATES_DIR;
Generator.TRANSPILED_TEMPLATE_LOCATION = TRANSPILED_TEMPLATE_LOCATION;

module.exports = Generator;
module.exports = Generator;
8 changes: 0 additions & 8 deletions lib/index.js

This file was deleted.

117 changes: 117 additions & 0 deletions test/test-project/storage/@asyncapi/html-template/filters/all.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
const filter = module.exports;

function isExpandable(obj) {
const fun = (obj) => typeof obj === 'function';
if (
(fun(obj.type) && obj.type() === 'object') ||
(fun(obj.type) && obj.type() === 'array') ||
(fun(obj.oneOf) && obj.oneOf() && obj.oneOf().length) ||
(fun(obj.anyOf) && obj.anyOf() && obj.anyOf().length) ||
(fun(obj.allOf) && obj.allOf() && obj.allOf().length) ||
(fun(obj.items) && obj.items()) ||
(fun(obj.additionalItems) && obj.additionalItems()) ||
(fun(obj.properties) && obj.properties() && Object.keys(obj.properties()).length) ||
(fun(obj.additionalProperties) && obj.additionalProperties()) ||
(fun(obj.extensions) && obj.extensions() &&
Object.keys(obj.extensions()).filter(e => !e.startsWith('x-parser-')).length) ||
(fun(obj.patternProperties) && Object.keys(obj.patternProperties()).length)
) return true;

return false;
}
filter.isExpandable = isExpandable;

function nonParserExtensions(schema) {
if (!schema || !schema.extensions || typeof schema.extensions !== 'function') return new Map();
const extensions = Object.entries(schema.extensions());
return new Map(extensions.filter(e => !e[0].startsWith('x-parser-')).filter(Boolean));
}
filter.nonParserExtensions = nonParserExtensions;

/**
* Check if there is a channel which does not have one of the tags specified.
*/
function containTags(object, tagsToCheck) {
if (!object) {
throw new Error('object for containsTag was not provided?');
}

if (!tagsToCheck) {
throw new Error('tagsToCheck for containsTag was not provided?');
}

//Ensure if only 1 tag are provided it is converted to array.
if (tagsToCheck && !Array.isArray(tagsToCheck)) {
tagsToCheck = [tagsToCheck];
}
//Check if pubsub contain one of the tags to check.
const check = (tag) => {
let found = false;
for (const tagToCheckIndex in tagsToCheck) {
const tagToCheck = tagsToCheck[tagToCheckIndex]._json;
const tagName = tag.name;
if ((tagToCheck && tagToCheck.name === tagName) ||
tagsToCheck[tagToCheckIndex] === tagName) {
found = true;
}
}
return found;
};

//Ensure tags are checked for the group tags
return object._json.tags ? object._json.tags.find(check) != null : false;
}
filter.containTags = containTags;

/**
* Check if there is a channel which does not have one of the tags specified.
*/
function containNoTag(channels, tagsToCheck) {
if (!channels) {
throw new Error('Channels for containNoTag was not provided?');
}
for (const channelIndex in channels) {
const channel = channels[channelIndex]._json;
//Check if the channel contains publish or subscribe which does not contain tags
if (channel.publish && (!channel.publish.tags || channel.publish.tags.length == 0) ||
channel.subscribe && (!channel.subscribe.tags || channel.subscribe.tags.length == 0)
) {
//one does not contain tags
return true;
}

//Check if channel publish or subscribe does not contain one of the tags to check.
const check = (tag) => {
let found = false;
for (const tagToCheckIndex in tagsToCheck) {
const tagToCheck = tagsToCheck[tagToCheckIndex]._json;
const tagName = tag.name;
if ((typeof tagToCheck !== 'undefined' && tagToCheck.name === tagName) ||
tagsToCheck[tagToCheckIndex] === tagName) {
found = true;
}
}
return found;
};

//Ensure pubsub tags are checked for the group tags
const publishContainsNoTag = channel.publish && channel.publish.tags ? channel.publish.tags.find(check) == null : false;
if (publishContainsNoTag === true) return true;
const subscribeContainsNoTag = channel.subscribe && channel.subscribe.tags ? channel.subscribe.tags.find(check) == null : false;
if (subscribeContainsNoTag === true) return true;
}
return false;
}
filter.containNoTag = containNoTag;

function operationsTags(object) {
const tags = new Set();
const extractName = (tags, acc) => tags.forEach((tag) => acc.add(tag.name()));
object.channelNames().forEach(channelName => {
const channel = object.channel(channelName);
if (channel.hasPublish() && channel.publish().hasTags()) extractName(channel.publish().tags(), tags);
if (channel.hasSubscribe() && channel.subscribe().hasTags()) extractName(channel.subscribe().tags(), tags);
});
return Array.from(tags);
}
filter.operationsTags = operationsTags;
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
const path = require('path');
const rimraf = require('rimraf');

module.exports = {
'generate:after': generator => {
const params = generator.templateParams;
const singleFile = params.singleFile === 'true';

if (singleFile) {
const jsDir = path.resolve(generator.targetDir, 'js');
const cssDir = path.resolve(generator.targetDir, 'css');

const callback = (error) => {
if (error) {
throw error;
}
};

const opts = {
disableGlob: true,
maxBusyTries: 3
};

rimraf(jsDir, opts, callback);
rimraf(cssDir, opts, callback);
}
}
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
const fs = require('fs');

module.exports = {
'generate:after': generator => {
if (generator.templateParams.outFilename !== 'index.html') {
fs.renameSync(`${generator.targetDir}/index.html`,
`${generator.targetDir}/${generator.templateParams.outFilename}`);
}
}
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
const puppeteer = require('puppeteer');
const path = require('path');

module.exports = {
'generate:after': generatePdf
};

async function generatePdf(generator) {
const targetDir = generator.targetDir;
const parameters = generator.templateParams;

//all actions of this hook depend on parameters passed by the user, if non are provided we should just stop the hook
if (!parameters || parameters.pdf !== 'true') return;

const browser = await puppeteer.launch({args: ['--no-sandbox', '--disable-setuid-sandbox']});
const page = await browser.newPage();

await page.goto(`file://${path.join(targetDir, 'index.html')}`, { waitUntil: 'networkidle0' });

await page.$$eval('div.payload-examples > div.js-prop', links => links.forEach(link => link.click()));
await page.$$eval('div.headers-examples > div.js-prop', links => links.forEach(link => link.click()));
await page.$$eval('div.all-messages div.js-prop', links => links.forEach(link => link.click()));

await page.pdf({ format: 'A4', path: `${targetDir}/index.pdf`, printBackground: true });

browser.close();
}
145 changes: 145 additions & 0 deletions test/test-project/storage/@asyncapi/html-template/tailwind.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
module.exports = {
purge: ['./template/**/*.html', './partials/**/*.html'],
darkMode: false, // or 'media' or 'class'
theme: {
// use default styles of tailwind v1: https://tailwindcss.com/docs/upgrading-to-v2#configure-your-color-palette-explicitly
colors: {
transparent: 'transparent',
current: 'currentColor',

black: '#000',
white: '#fff',
gray: {
100: '#f7fafc',
200: '#edf2f7',
300: '#e2e8f0',
400: '#cbd5e0',
500: '#a0aec0',
600: '#718096',
700: '#4a5568',
800: '#2d3748',
900: '#1a202c',
},
red: {
100: '#fff5f5',
200: '#fed7d7',
300: '#feb2b2',
400: '#fc8181',
500: '#f56565',
600: '#e53e3e',
700: '#c53030',
800: '#9b2c2c',
900: '#742a2a',
},
orange: {
100: '#fffaf0',
200: '#feebc8',
300: '#fbd38d',
400: '#f6ad55',
500: '#ed8936',
600: '#dd6b20',
700: '#c05621',
800: '#9c4221',
900: '#7b341e',
},
yellow: {
100: '#fffff0',
200: '#fefcbf',
300: '#faf089',
400: '#f6e05e',
500: '#ecc94b',
600: '#d69e2e',
700: '#b7791f',
800: '#975a16',
900: '#744210',
},
green: {
100: '#f0fff4',
200: '#c6f6d5',
300: '#9ae6b4',
400: '#68d391',
500: '#48bb78',
600: '#38a169',
700: '#2f855a',
800: '#276749',
900: '#22543d',
},
teal: {
100: '#e6fffa',
200: '#b2f5ea',
300: '#81e6d9',
400: '#4fd1c5',
500: '#38b2ac',
600: '#319795',
700: '#2c7a7b',
800: '#285e61',
900: '#234e52',
},
blue: {
100: '#ebf8ff',
200: '#bee3f8',
300: '#90cdf4',
400: '#63b3ed',
500: '#4299e1',
600: '#3182ce',
700: '#2b6cb0',
800: '#2c5282',
900: '#2a4365',
},
indigo: {
100: '#ebf4ff',
200: '#c3dafe',
300: '#a3bffa',
400: '#7f9cf5',
500: '#667eea',
600: '#5a67d8',
700: '#4c51bf',
800: '#434190',
900: '#3c366b',
},
purple: {
100: '#faf5ff',
200: '#e9d8fd',
300: '#d6bcfa',
400: '#b794f4',
500: '#9f7aea',
600: '#805ad5',
700: '#6b46c1',
800: '#553c9a',
900: '#44337a',
},
pink: {
100: '#fff5f7',
200: '#fed7e2',
300: '#fbb6ce',
400: '#f687b3',
500: '#ed64a6',
600: '#d53f8c',
700: '#b83280',
800: '#97266d',
900: '#702459',
},
},
fontSize: {
xs: '0.75rem',
sm: '0.875rem',
base: '1rem',
lg: '1.125rem',
xl: '1.25rem',
'2xl': '1.5rem',
'3xl': '1.875rem',
'4xl': '2.25rem',
'5xl': '3rem',
'6xl': '4rem',
},
borderColor: (theme) => ({
...theme('colors'),
DEFAULT: theme('colors.gray.400', 'currentColor'),
}),
extend: {},
},
variants: {
extend: {},
},
plugins: [],
};

Large diffs are not rendered by default.

Loading

0 comments on commit 4d7f3ea

Please sign in to comment.