Skip to content

Commit

Permalink
feat(shrinkwrap): support private/scoped packages
Browse files Browse the repository at this point in the history
fixes #50
  • Loading branch information
Scott Sidwell authored and JamieMason committed Jul 1, 2016
1 parent 9c1eef7 commit 2707067
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 5 deletions.
3 changes: 1 addition & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,4 @@ services:
environment:
NPM_VERSION: 3.8.7
links:
- npm_registry

- npm_registry:secure_registry
2 changes: 1 addition & 1 deletion src/addToCache.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ function addToCache (deps) {

function cachePackage (dep) {
console.info(chalk.yellow('↓ %s from %s'), dep.id, dep.shrinkwrap.resolved);
return shell('npm cache add ' + dep.shrinkwrap.resolved)
return shell('npm cache --scope=' + dep.scope + ' add ' + dep.shrinkwrap.resolved)
.catch(fail);

function fail (err) {
Expand Down
6 changes: 6 additions & 0 deletions src/init/readGraph/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ function readGraph (graph, pathToBundle, npmCachePath) {
bundle: getShrinkwrapEntry(name, meta),
id: name + '@' + meta.version,
name: name,
scope: getPackageScope(name),
shrinkwrap: meta,
tarball: {
shrinkpack: getShrinkpackPath(name, meta),
Expand All @@ -45,4 +46,9 @@ function readGraph (graph, pathToBundle, npmCachePath) {
function getTarballName (name, version) {
return name.replace(/\//g, '-') + '-' + version + '.tgz';
}

function getPackageScope (name) {
var scope = name.substring(0, name.indexOf('/'));
return (scope !== name) ? scope : '';
}
}
3 changes: 2 additions & 1 deletion test/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
"express": "git+https://[email protected]/visionmedia/express.git",
"finch": "1.3.11",
"os-locale": "sindresorhus/os-locale",
"wowsuch": "github:swirlycheetah/wowsuch"
"wowsuch": "github:swirlycheetah/wowsuch",
"@telerik/eslint-config": "1.1.0"
},
"private": true
}
15 changes: 15 additions & 0 deletions test/runtests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ function header() {
npm config set loglevel error --global
npm config set registry http://npm_registry:4873

npm login --scope=@telerik --registry=http://secure_registry:4873 <<!
shrinkpack
shrinkpack
[email protected]
!

header "install npm@$NPM_VERSION"
npm install -g npm@$NPM_VERSION
INSTALLED_NPM_VERSION="$(npm --version)"
Expand All @@ -37,11 +43,20 @@ npm install

header "shrinkpacked project: shrinkwrap"
npm shrinkwrap --dev
CONTROL_SHRINKWRAP="$(cat npm-shrinkwrap.json)"

header "shrinkpacked project: shrinkpack"
node /usr/src/shrinkpack/cli.js
ON_SHRINKPACK_SHRINKWRAP="$(cat npm-shrinkwrap.json)"
ON_SHRINKPACK_RUN="$(find ./node_modules | sort)"

if [ "$ON_SHRINKPACK_SHRINKWRAP" == "$CONTROL_SHRINKWRAP" ]; then
header "failed: running shrinkpack doesn't change shrinkwrap file"
exit 1
else
header "√ running shrinkpack updates the shrinkwrap file"
fi

if [ "$ON_SHRINKPACK_RUN" != "$CONTROL_INSTALLATION" ]; then
header "failed: running shrinkpack changes installation"
exit 1
Expand Down
2 changes: 1 addition & 1 deletion test/sinopia/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ uplinks:
packages:
'@*/*':
# scoped packages
access: $all
access: $authenticated
publish: $authenticated
proxy: npmjs

Expand Down

0 comments on commit 2707067

Please sign in to comment.