Skip to content

Commit

Permalink
added pacote
Browse files Browse the repository at this point in the history
  • Loading branch information
ShashwatPS committed Oct 6, 2024
1 parent 52c6796 commit 0712275
Show file tree
Hide file tree
Showing 9 changed files with 949 additions and 35 deletions.
Empty file modified apps/generator/cli.js
100755 → 100644
Empty file.
7 changes: 3 additions & 4 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,8 @@ 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);
const packageName = manifest.name;
const packageVersion = installResult.children.get(packageName).version;
const packagePath = installResult.children.get(packageName).path;

Expand Down
1 change: 1 addition & 0 deletions apps/generator/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@
"minimatch": "^3.0.4",
"node-fetch": "^2.6.0",
"nunjucks": "^3.2.0",
"pacote": "^11.1.9",
"requireg": "^0.2.2",
"resolve-from": "^5.0.0",
"resolve-pkg": "^2.0.0",
Expand Down
2 changes: 0 additions & 2 deletions apps/generator/test/__mocks__/@npmcli/arborist.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
const arb = jest.genMockFromModule('@npmcli/arborist');

arb.prototype[Symbol.for('resolvedAdd')] = [{name: 'test'}];

arb.prototype.reify = jest.fn(async (opt) => {
const childrenMap = new Map();
childrenMap.set('test', {path: './test'});
Expand Down
9 changes: 9 additions & 0 deletions apps/generator/test/__mocks__/pacote/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
const pacote = jest.genMockFromModule('pacote');

pacote.manifest = jest.fn(async (templateName) => {
return {
name: 'test'
};
});

module.exports = pacote;
Empty file modified apps/generator/test/test-project/verdaccio/config.yaml
100755 → 100644
Empty file.
Empty file modified apps/generator/test/test-project/verdaccio/htpasswd
100755 → 100644
Empty file.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 0712275

Please sign in to comment.