Conversation
|
|
||
| const pkgIds = [] | ||
| for (const dep of deps) { | ||
| const ret = await opts.storeController.requestPackage(dep, { |
There was a problem hiding this comment.
I think you can run them all simultaneously because that is how it works during regular installation (there is a network concurrency limit inside package-requester).
const pkgIds = await Promise.all(deps.map(...| const deps = await parseWantedDependencies(fuzzyDeps, { | ||
| allowNew: true, | ||
| currentPrefs: {}, | ||
| defaultTag: '', |
There was a problem hiding this comment.
you could pass in the tag config from pnpm. It is a config that is "latest" by default.
| pkgIds.push(ret.body.id) | ||
| } | ||
|
|
||
| await opts.storeController.updateConnections(opts.prefix, { |
There was a problem hiding this comment.
As far as I remember, this is not the desired behavior because you don't want this prefix to be added to store.json
I think what we can do is, make package requester add the new fields to storeIndex right after downloading the packages to the store.
Then calling updateConnections won't be needed
There was a problem hiding this comment.
As you can see, storeIndex is passed in to package-requester
https://github.com/pnpm/package-store/blob/master/src/storeController/index.ts#L55
so you can just add the field in package-requester like it is done in package-store currently (but just add an empty array)
https://github.com/pnpm/package-store/blob/master/src/storeController/index.ts#L91
There was a problem hiding this comment.
I am not sure what you mean with this
There was a problem hiding this comment.
with the implementation you did, an entry like this well be added to store.json:
"registry.npmjs.com/foo/1.0.0": ["/home/usr"],
but what you need is:
"registry.npmjs.com/foo/1.0.0": [],
| await storeAdd(['express@4.16.3'], opts as any) // tslint:disable-line | ||
|
|
||
| await project.storeHas('express', '4.16.3') | ||
| }) |
There was a problem hiding this comment.
might be good to also test the content of store.json
There was a problem hiding this comment.
storeHas already checks the content of store.json
|
That's the part I understood. The part I didn't understand is if I have to
add an entry everytime I call requestPackage, or only in this specific
case, that is, when used inside the store add command. In both cases, I am
not entirely sure this makes sense.
I would rather add a way for updateConnections to add an empty array. For
example if prefix is null or empty, it adds an empty array.
Il mar 10 lug 2018, 09:22 Zoltan Kochan <notifications@github.com> ha
scritto:
… ***@***.**** commented on this pull request.
------------------------------
In packages/supi/src/api/storeAdd.ts
<#1268 (comment)>:
> + const pkgIds = []
+ for (const dep of deps) {
+ const ret = await opts.storeController.requestPackage(dep, {
+ downloadPriority: 1,
+ loggedPkg: {
+ rawSpec: dep.raw,
+ },
+ preferredVersions: {},
+ prefix: opts.prefix,
+ registry: normalizeRegistryUrl(opts.registry || 'https://registry.npmjs.org/'),
+ verifyStoreIntegrity: opts.verifyStoreIntegrity,
+ })
+ pkgIds.push(ret.body.id)
+ }
+
+ await opts.storeController.updateConnections(opts.prefix, {
with the implementation you did, an entry like this well be added to
store.json:
"registry.npmjs.com/foo/1.0.0": ["/home/usr"],
but what you need is:
"registry.npmjs.com/foo/1.0.0": [],
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#1268 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AAjUNHax4tLIvnLpVp09Rr1fWkc8ahjcks5uFFZNgaJpZM4VIFKI>
.
|
|
I meant that requestPackage would add the empty array in all cases. I think it would make sense because the package is in the store but it does not have any connections yet |
|
Oh, ok
Il mar 10 lug 2018, 09:34 Zoltan Kochan <notifications@github.com> ha
scritto:
… I meant that requestPackage would add the empty array in all cases. I
think it would make sense because the package is in the store but it does
not have any connections yet
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#1268 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AAjUNHvvov-lhfTgP2rLK3b2x1um4t4Nks5uFFjzgaJpZM4VIFKI>
.
|
|
I'll add the test that checks |
| const deps = await parseWantedDependencies(fuzzyDeps, { | ||
| allowNew: true, | ||
| currentPrefs: {}, | ||
| defaultTag: opts.tag || 'default', |
| registry: normalizeRegistryUrl(opts.registry || 'https://registry.npmjs.org/'), | ||
| verifyStoreIntegrity: opts.verifyStoreIntegrity || true, | ||
| }) | ||
| await pkgResponse['fetchingFiles'].catch((err: Error) => {}) // tslint:disable-line |
There was a problem hiding this comment.
I think there should be an info message printed about the added tarballs.
When you run pnpm store add typescript@1 it would be useful to see which version of typescript was added. So maybe just print the pkgId?
$ pnpm store add typescript@1
+ registry.npmjs.org/typescript/1.2.1
pnpm store prune provides a similar output at the moment.
Also, I think it is important to print failures. So don't just ignore if fetchingFiles fails. Maybe the process should exit with a non-zero exit code. Fetching the package is the intention of the operation after all, so if it fails, the operation was not successful.
| await project.storeHas('express', '4.16.3') | ||
|
|
||
| const storeIndex = await loadJsonFile(path.join(opts.store, 'store.json')) | ||
| t.deepEqual(storeIndex['localhost+4873/express/4.16.3'], []) |
There was a problem hiding this comment.
You can make a deepEqual of the whole file because it should be empty
t.deepEqual(storeIndex, {
'localhost+4873/express/4.16.3': [],
})There was a problem hiding this comment.
it also contains another package, I needed to install it to initialize the store in the test
There was a problem hiding this comment.
oh, I see. But that's an issue, isn't it? I think pnpm store add should be able to create a new store
There was a problem hiding this comment.
It only happens in this test, if I run it from the command line it creates the store correctly
There was a problem hiding this comment.
are you sure? When you run it manually, it probably uses your global store that already exists at ~/.pnpm-store but tests use a new store in every test case. So to test it manually, you'd need something like rm -rf store && pnpm store add typescript@1 --store store
There was a problem hiding this comment.
That's exactly how I tested it
| Returns a 0 exit code if packages in the store are not modified, i.e. the content of the package is the | ||
| same as it was at the time of unpacking. | ||
|
|
||
| pnpm store add |
There was a problem hiding this comment.
pnpm store add [pkg...] would be more straightforward
| } | ||
|
|
||
| if (hasFailures) { | ||
| throw new Error('Some packages have not been added correctly') |
There was a problem hiding this comment.
please add an additional test for checking this behavior. You can just add a non-existent package to the store pnpm store add @pnpm/this-does-not-exist
| rawSpec: dep.raw, | ||
| }, | ||
| preferredVersions: {}, | ||
| prefix: '', |
There was a problem hiding this comment.
should it work with local tarballs? If you pass in the prefix, it will work with pnpm store add ../some.tgz
There was a problem hiding this comment.
I have no idea what the prefix is
There was a problem hiding this comment.
it should be passed in by pnpm. prefix is basically the current working directory in most cases
|
🚢 2.12.0-0 |
No description provided.