Skip to content

Commit

Permalink
feat: Use npmcli config in asyncapi generator
Browse files Browse the repository at this point in the history
  • Loading branch information
pierrick-boule committed Nov 17, 2023
1 parent ae286f4 commit 7a78759
Show file tree
Hide file tree
Showing 5 changed files with 535 additions and 3 deletions.
18 changes: 15 additions & 3 deletions lib/generator.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ const filenamify = require('filenamify');
const git = require('simple-git');
const log = require('loglevel');
const Arborist = require('@npmcli/arborist');
const Config = require('@npmcli/config');

const { isAsyncAPIDocument } = require('@asyncapi/parser/cjs/document');

const { configureReact, renderReact, saveRenderedReactContent } = require('./renderer/react');
Expand All @@ -32,6 +34,7 @@ const {
const { parse, usesNewAPI, getProperApiDocument } = require('./parser');
const { registerFilters } = require('./filtersRegistry');
const { registerHooks } = require('./hooksRegistry');
const { definitions, flatten, shorthands } = require('@npmcli/config/lib/definitions')

const FILTERS_DIRNAME = 'filters';
const HOOKS_DIRNAME = 'hooks';
Expand Down Expand Up @@ -527,9 +530,18 @@ class Generator {

if (isFileSystemPath(this.templateName)) log.debug(logMessage.NPM_INSTALL_TRIGGER);

const arb = new Arborist({
path: ROOT_DIR
});
const npmPath = process.execPath.replace('/bin/node','/lib/node_modules/npm/');

const config = new Config({
definitions,
flatten,
shorthands,
npmPath
})

await config.load()

const arb = new Arborist(config.flat);

try {
const installResult = await arb.reify({
Expand Down
Loading

0 comments on commit 7a78759

Please sign in to comment.