Skip to content

Commit

Permalink
fixed generator.js and added pacote dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
rajRishi22 authored Nov 13, 2024
1 parent 02dd677 commit 6f70657
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions apps/generator/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 Config = require('@npmcli/config');
const requireg = require('requireg');
const npmPath = requireg.resolve('npm').replace('index.js','');
Expand Down Expand Up @@ -605,10 +606,18 @@ 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 manifest = await pacote.manifest(this.templateName);
const packageName = manifest.name;

const packageName = addResult[0].name;
try {
const manifest = await pacote.manifest(this.templateName);
const packageName = manifest.name;
} catch (error) {
console.error('Error fetching package manifest:', error);
throw new Error('Failed to fetch the package manifest. Please check the package name and try again.');
}


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

Expand Down

0 comments on commit 6f70657

Please sign in to comment.