How to use the moleculer/package.json.version function in moleculer

To help you get started, we’ve selected a few moleculer examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github moleculerjs / site / api-docs-generator.js View on Github external
if (param.default) {
				return param.name + " = " + param.default;
			}
			return param.name + "?";
		}
		return param.name;
	}
	if (param.type && param.type.name)
		return param.name + ": " + param.type.name.replace(/\n/g, "");

	return param.name;
}

// Read package.json to get API version number
const pkg = require("moleculer/package.json");
const apiVersion = semver.major(pkg.version) + "." + semver.minor(pkg.version);
console.log("API version:", apiVersion);

// Source files for API docs
const sourceFiles = [
	{ path: "service-broker.js", name: "ServiceBroker" },
	{ path: "service.js", name: "Service" },
	{ path: "context.js", name: "Context" }
]

// Target folder
const targetFolder = path.join(".", "source", "docs", apiVersion, "api");
console.log("Target folder:", targetFolder);
mkdir(targetFolder);

// Template
const templateFolder = path.join(__dirname, "api-template", "md");
github moleculerjs / site / __api-docs-generator-html.js View on Github external
}
		return param.name;
	}
	if (param.type && param.type.name)
		return param.name + ": " + param.type.name.replace(/\n/g, "");
	
	return param.name;
}

function codeHighlight(code) {
	return "<pre class="hljs">" + hljs.highlightAuto(code, "js") + "</pre>";
}

const pkg = require("moleculer/package.json");

const apiVersion = semver.major(pkg.version) + "." + semver.minor(pkg.version);

console.log("API version:", apiVersion);

const sourceFiles = [
	{ path: "service-broker.js", name: "ServiceBroker" },
	{ path: "service.js", name: "Service" },
	{ path: "context.js", name: "Context" }
]

const targetFolder = path.join(".", "source", "api-" + apiVersion);
console.log("Target folder:", targetFolder);

mkdir(targetFolder);

Promise.each(sourceFiles, sourceFile =&gt; {