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

refactor: add pacote to resolve template name instead of arborist workaround #1115

Closed
wants to merge 11 commits into from
12 changes: 7 additions & 5 deletions lib/generator.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ const filenamify = require('filenamify');
const git = require('simple-git');
const log = require('loglevel');
const Arborist = require('@npmcli/arborist');
const pacote = require('pacote');
const { isAsyncAPIDocument } = require('@asyncapi/parser/cjs/document');

const { configureReact, renderReact, saveRenderedReactContent } = require('./renderer/react');
Expand Down Expand Up @@ -595,12 +596,13 @@ class Generator {
save: false
});

const addResult = arb[Symbol.for('resolvedAdd')];
if (!addResult) throw new Error('Unable to resolve the name of the added package. It was most probably not added to node_modules successfully');
const packageName = addResult[0].name;
const manifest = await pacote.manifest(this.templateName);
derberg marked this conversation as resolved.
Show resolved Hide resolved
if (!manifest) throw new Error('Unable to resolve the name of the added package. It was most probably not added to node_modules successfully');

const packageName = manifest.name;
const packageVersion = installResult.children.get(packageName).version;
const packagePath = installResult.children.get(packageName).path;

const packagePath = installResult.children.get(packageName).path;

if (!isFileSystemPath(this.templateName)) log.debug(logMessage.templateSuccessfullyInstalled(packageName, packagePath));
if (packageVersion) log.debug(logMessage.templateVersion(packageVersion));
Expand Down
Loading
Loading