Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@asyncapi/generator

Package Overview
Dependencies
Maintainers
3
Versions
213
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@asyncapi/generator - npm Package Compare versions

Comparing version 0.35.2 to 0.36.0

42

lib/generator.js

@@ -41,33 +41,16 @@ const path = require('path');

const FILTERS_DIRNAME = '.filters';
const PARTIALS_DIRNAME = '.partials';
const HOOKS_DIRNAME = '.hooks';
const NODE_MODULES_DIRNAME = 'node_modules';
const FILTERS_DIRNAME = 'filters';
const HOOKS_DIRNAME = 'hooks';
const CONFIG_FILENAME = '.tp-config.json';
const PACKAGE_JSON_FILENAME = 'package.json';
const PACKAGE_LOCK_FILENAME = 'package-lock.json';
const ROOT_DIR = path.resolve(__dirname, '..');
const DEFAULT_TEMPLATES_DIR = path.resolve(ROOT_DIR, 'node_modules');
const TEMPLATE_CONTENT_DIRNAME = 'template';
const shouldIgnoreFile = filePath =>
filePath.startsWith(`.git${path.sep}`)
|| filePath.startsWith(`${PARTIALS_DIRNAME}${path.sep}`)
|| filePath.startsWith(`${FILTERS_DIRNAME}${path.sep}`)
|| filePath.startsWith(`${HOOKS_DIRNAME}${path.sep}`)
|| path.basename(filePath) === CONFIG_FILENAME
|| path.basename(filePath) === PACKAGE_JSON_FILENAME
|| path.basename(filePath) === PACKAGE_LOCK_FILENAME
|| filePath.startsWith(`${NODE_MODULES_DIRNAME}${path.sep}`);
filePath.startsWith(`.git${path.sep}`);
const shouldIgnoreDir = dirPath =>
dirPath === '.git'
|| dirPath.startsWith(`.git${path.sep}`)
|| dirPath === PARTIALS_DIRNAME
|| dirPath.startsWith(`${PARTIALS_DIRNAME}${path.sep}`)
|| dirPath === FILTERS_DIRNAME
|| dirPath.startsWith(`${FILTERS_DIRNAME}${path.sep}`)
|| dirPath === HOOKS_DIRNAME
|| dirPath.startsWith(`${HOOKS_DIRNAME}${path.sep}`)
|| dirPath === NODE_MODULES_DIRNAME
|| dirPath.startsWith(`${NODE_MODULES_DIRNAME}${path.sep}`);
|| dirPath.startsWith(`.git${path.sep}`);

@@ -160,2 +143,3 @@ class Generator {

this.templateName = templatePkgName;
this.templateContentDir = path.resolve(this.templateDir, TEMPLATE_CONTENT_DIRNAME);
this.configNunjucks();

@@ -167,3 +151,3 @@ await this.loadTemplateConfig();

if (this.entrypoint) {
const entrypointPath = path.resolve(this.templateDir, this.entrypoint);
const entrypointPath = path.resolve(this.templateContentDir, this.entrypoint);
if (!(await exists(entrypointPath))) throw new Error(`Template entrypoint "${entrypointPath}" couldn't be found.`);

@@ -278,3 +262,3 @@ if (this.output === 'fs') {

* const Generator = require('asyncapi-generator');
* const content = await Generator.getTemplateFile('html', '.partials/content.html');
* const content = await Generator.getTemplateFile('html', 'partials/content.html');
*

@@ -426,3 +410,3 @@ * @static

const walker = xfs.walk(this.templateDir, {
const walker = xfs.walk(this.templateContentDir, {
followLinks: false

@@ -439,3 +423,3 @@ });

await this.generateSeparateFiles(asyncapiDocument, fileNamesForSeparation[prop], prop, stats.name, root);
const templateFilePath = path.relative(this.templateDir, path.resolve(root, stats.name));
const templateFilePath = path.relative(this.templateContentDir, path.resolve(root, stats.name));
fs.unlink(path.resolve(this.targetDir, templateFilePath), next);

@@ -460,3 +444,3 @@ wasSeparated = true;

try {
const relativeDir = path.relative(this.templateDir, path.resolve(root, stats.name));
const relativeDir = path.relative(this.templateContentDir, path.resolve(root, stats.name));
const dirPath = path.resolve(this.targetDir, relativeDir);

@@ -518,3 +502,3 @@ if (!shouldIgnoreDir(relativeDir)) {

try {
const relativeBaseDir = path.relative(this.templateDir, baseDir);
const relativeBaseDir = path.relative(this.templateContentDir, baseDir);
const newFileName = fileName.replace(`\$\$${template}\$\$`, filenamify(name, { replacement: '-', maxLength: 255 }));

@@ -551,3 +535,3 @@ const targetFile = path.resolve(this.targetDir, relativeBaseDir, newFileName);

const sourceFile = path.resolve(baseDir, fileName);
const relativeSourceFile = path.relative(this.templateDir, sourceFile);
const relativeSourceFile = path.relative(this.templateContentDir, sourceFile);
const targetFile = path.resolve(this.targetDir, relativeSourceFile);

@@ -554,0 +538,0 @@ const relativeTargetFile = path.relative(this.targetDir, targetFile);

{
"name": "@asyncapi/generator",
"version": "0.35.2",
"version": "0.36.0",
"description": "The AsyncAPI generator. It can generate documentation, code, anything!",

@@ -5,0 +5,0 @@ "main": "./lib/generator.js",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc