Skip to content

Instantly share code, notes, and snippets.

@indexzero
Forked from totherik/npmjs.ini
Created March 5, 2014 21:27

Revisions

  1. @totherik totherik revised this gist Feb 25, 2014. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion npmjs_install.sh
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,6 @@
    #!/bin/bash

    RELEASE=v2.0.2
    RELEASE=v2.0.3
    BASEDIR=`basename $0`
    SCRIPTPATH=`cd $(dirname $0) ; pwd -P`

  2. @totherik totherik revised this gist Feb 25, 2014. 1 changed file with 5 additions and 1 deletion.
    6 changes: 5 additions & 1 deletion npmjs_install.sh
    Original file line number Diff line number Diff line change
    @@ -102,12 +102,16 @@ npm run load
    assert "$LINENO: Unable to load views."

    # Ensure _design/app exists
    res=`curl -s -w "%{http_code}" -X PUT -d '{}' $registry/_design/app -o /dev/null`
    res=`curl -s -w "%{http_code}" -X PUT -H 'Content-Type: application/json' -d '{}' $registry/_design/app -o /dev/null`
    assert "$LINENO: Unable to connect to $host."
    if [ "$res" != "$CREATED" ] && [ "$res" != "$CONFLICT" ]; then fail "$LINENO: Unable to create _design/app document. Server responded with status code $res"; fi

    # Install app
    npm run copy
    assert "$LINENO: Unable to install couch app."

    res=`curl -s -w "%{http_code}" -X PUT -H 'Content-Type: application/json' $registry/error%3A%20forbidden -d '{ "_id": "error: forbidden", "forbidden":"must supply latest _rev to update existing package" }' -o /dev/null`
    assert "$LINENO: Unable to connect to $host"
    if [ "$res" != "$CREATED" ] && [ "$res" != "$CONFLICT" ]; then fail "$LINENO: Unable to create error document. Server responded with status code $res"; fi

    clean
  3. @totherik totherik revised this gist Feb 23, 2014. 1 changed file with 17 additions and 2 deletions.
    19 changes: 17 additions & 2 deletions npmjs_install.sh
    Original file line number Diff line number Diff line change
    @@ -1,8 +1,13 @@
    #!/bin/bash

    RELEASE=v2.0.2
    BASEDIR=`basename $0`
    SCRIPTPATH=`cd $(dirname $0) ; pwd -P`

    CREATED=201
    CONFLICT=409
    PRECONDITION_FAILED=412

    function assert
    {
    if [ "$?" != "0" ]; then
    @@ -64,6 +69,11 @@ git clone [email protected]:npm/npmjs.org.git
    assert "$LINENO: Unable to clone npmjs.org."

    cd npmjs.org

    # Get the latest release (don't use master)
    git checkout tags/$RELEASE
    assert "$LINENO: Unable to get release $RELEASE."

    npm install
    assert "$LINENO: npm install failed."

    @@ -75,8 +85,13 @@ npm set _npmjs.org:couch=$registry
    # Create the database
    res=`curl -s -w "%{http_code}" -X PUT $registry -o /dev/null`
    assert "$LINENO: Unable to connect to $host."
    if [ "$res" != "201" ]; then fail "$LINENO: Unable to create database \"$database\". Server responded with status code $res"; fi
    if [ "$res" != "$CREATED" ] && [ "$res" != "$PRECONDITION_FAILED" ]; then fail "$LINENO: Unable to create database \"$database\". Server responded with status code $res"; fi


    # XXX
    # Patch env per https://github.com/npm/npmjs.org/commit/2f9dbb9d2f75c96183f9b0cbdbafaa790d380d29
    export DEPLOY_VERSION=`git describe --tags`
    # XXX

    # Sync the ddoc
    npm start
    @@ -89,7 +104,7 @@ assert "$LINENO: Unable to load views."
    # Ensure _design/app exists
    res=`curl -s -w "%{http_code}" -X PUT -d '{}' $registry/_design/app -o /dev/null`
    assert "$LINENO: Unable to connect to $host."
    if [ "$res" != "201" ]; then fail "$LINENO: Unable to create _design/app document. Server responded with status code $res"; fi
    if [ "$res" != "$CREATED" ] && [ "$res" != "$CONFLICT" ]; then fail "$LINENO: Unable to create _design/app document. Server responded with status code $res"; fi

    # Install app
    npm run copy
  4. @totherik totherik revised this gist Feb 22, 2014. 1 changed file with 12 additions and 12 deletions.
    24 changes: 12 additions & 12 deletions npmjs_install.sh
    Original file line number Diff line number Diff line change
    @@ -5,26 +5,26 @@ SCRIPTPATH=`cd $(dirname $0) ; pwd -P`

    function assert
    {
    if [ "$?" != "0" ]; then
    fail "${1:-"An unknown error occurred."}";
    fi
    if [ "$?" != "0" ]; then
    fail "${1:-"An unknown error occurred."}";
    fi
    }

    function fail
    {
    clean
    echo "$BASEDIR: $1" 1>&2
    exit 1
    clean
    echo "$BASEDIR: $1" 1>&2
    exit 1
    }

    function clean
    {
    npm set _npmjs.org:couch=
    # Only try to clean up files if we made it past cloning
    if [ "$SCRIPTPATH" != `pwd` ]; then
    cd ../;
    rm -rf npmjs.org;
    fi
    npm set _npmjs.org:couch=
    # Only try to clean up files if we made it past cloning
    if [ "$SCRIPTPATH" != `pwd` ]; then
    cd ../;
    rm -rf npmjs.org;
    fi
    }


  5. @totherik totherik revised this gist Feb 22, 2014. 1 changed file with 48 additions and 7 deletions.
    55 changes: 48 additions & 7 deletions npmjs_install.sh
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,34 @@
    #!/bin/bash

    BASEDIR=`basename $0`
    SCRIPTPATH=`cd $(dirname $0) ; pwd -P`

    function assert
    {
    if [ "$?" != "0" ]; then
    fail "${1:-"An unknown error occurred."}";
    fi
    }

    function fail
    {
    clean
    echo "$BASEDIR: $1" 1>&2
    exit 1
    }

    function clean
    {
    npm set _npmjs.org:couch=
    # Only try to clean up files if we made it past cloning
    if [ "$SCRIPTPATH" != `pwd` ]; then
    cd ../;
    rm -rf npmjs.org;
    fi
    }



    # Read hostname
    echo -n "Hostname [localhost:5984]: "
    read hostname
    @@ -30,28 +59,40 @@ echo

    # Per: https://github.com/npm/npmjs.org

    # Get the npm app from github
    git clone [email protected]:npm/npmjs.org.git
    assert "$LINENO: Unable to clone npmjs.org."

    cd npmjs.org
    npm install
    assert "$LINENO: npm install failed."

    # Create the database

    # Set the registry for use by the upcoming scripts
    registry=http://$username:$password@$hostname/$database
    curl -X PUT $registry
    npm set _npmjs.org:couch=$registry

    # Create the database
    res=`curl -s -w "%{http_code}" -X PUT $registry -o /dev/null`
    assert "$LINENO: Unable to connect to $host."
    if [ "$res" != "201" ]; then fail "$LINENO: Unable to create database \"$database\". Server responded with status code $res"; fi


    # Sync the ddoc
    npm start
    assert "$LINENO: npm start failed."

    # Load views
    npm run load
    assert "$LINENO: Unable to load views."

    # Ensure _design/app exists
    curl -s -H 'Accept: application/json' -X PUT -d '{}' $registry/_design/app > /dev/null
    res=`curl -s -w "%{http_code}" -X PUT -d '{}' $registry/_design/app -o /dev/null`
    assert "$LINENO: Unable to connect to $host."
    if [ "$res" != "201" ]; then fail "$LINENO: Unable to create _design/app document. Server responded with status code $res"; fi

    # Install app
    npm run copy
    assert "$LINENO: Unable to install couch app."

    # Clean up
    npm set _npmjs.org:couch=
    cd ../
    rm -rf npmjs.org
    clean
  6. @totherik totherik revised this gist Feb 22, 2014. 1 changed file with 11 additions and 1 deletion.
    12 changes: 11 additions & 1 deletion npmjs_install.sh
    Original file line number Diff line number Diff line change
    @@ -1,31 +1,41 @@
    #!/bin/bash

    # Read hostname
    echo -n "Hostname [localhost:5984]: "
    read hostname

    if [ -z $hostname ]; then hostname="localhost:5984"; fi


    # Read DB name
    echo -n "Database Name [registry]: "
    read database

    if [ -z $database ]; then database="registry"; fi


    # Read Username
    echo -n "CouchDB Username [admin]: "
    read username

    if [ -z $username ]; then username="admin"; fi


    # Read Password
    echo -n "CouchDB Password: "
    read -s password
    echo
    echo


    # Per: https://github.com/npm/npmjs.org

    git clone [email protected]:npm/npmjs.org.git
    cd npmjs.org
    npm install

    # Create the database
    registry=http://$username:$password@localhost:5984/$database
    registry=http://$username:$password@$hostname/$database
    curl -X PUT $registry
    npm set _npmjs.org:couch=$registry

  7. @totherik totherik revised this gist Feb 22, 2014. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion npmjs.ini
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,5 @@
    ; CouchDB Config
    ; Drop in PREFIX/local.d/npm.ini
    ; Drop in PREFIX/local.d/npmjs.ini

    [couch_httpd_auth]
    public_fields = appdotnet, avatar, avatarMedium, avatarLarge, date, email, fields, freenode, fullname, github, homepage, name, roles, twitter, type, _id, _rev
  8. @totherik totherik revised this gist Feb 22, 2014. 1 changed file with 2 additions and 1 deletion.
    3 changes: 2 additions & 1 deletion npmjs.ini
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,5 @@
    ; Drop in COUCHDB_PREFIX/local.d/npm.ini
    ; CouchDB Config
    ; Drop in PREFIX/local.d/npm.ini

    [couch_httpd_auth]
    public_fields = appdotnet, avatar, avatarMedium, avatarLarge, date, email, fields, freenode, fullname, github, homepage, name, roles, twitter, type, _id, _rev
  9. @totherik totherik revised this gist Feb 22, 2014. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion npmjs.ini
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,4 @@
    ; Drop in $COUCHDB_PREFIX/local.d/npm.ini
    ; Drop in COUCHDB_PREFIX/local.d/npm.ini

    [couch_httpd_auth]
    public_fields = appdotnet, avatar, avatarMedium, avatarLarge, date, email, fields, freenode, fullname, github, homepage, name, roles, twitter, type, _id, _rev
  10. @totherik totherik revised this gist Feb 22, 2014. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion npmjs.ini
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,4 @@
    ; Drop in $PREFIX/local.d/npm.ini
    ; Drop in $COUCHDB_PREFIX/local.d/npm.ini

    [couch_httpd_auth]
    public_fields = appdotnet, avatar, avatarMedium, avatarLarge, date, email, fields, freenode, fullname, github, homepage, name, roles, twitter, type, _id, _rev
  11. @totherik totherik revised this gist Feb 22, 2014. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion npmjs.ini
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,4 @@
    ; $PREFIX/local.d/npm.ini
    ; Drop in $PREFIX/local.d/npm.ini

    [couch_httpd_auth]
    public_fields = appdotnet, avatar, avatarMedium, avatarLarge, date, email, fields, freenode, fullname, github, homepage, name, roles, twitter, type, _id, _rev
  12. @totherik totherik renamed this gist Feb 22, 2014. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  13. @totherik totherik renamed this gist Feb 22, 2014. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion registry.ini → npm.ini
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,4 @@
    ; $PREFIX/local.d/registry.ini
    ; $PREFIX/local.d/npm.ini

    [couch_httpd_auth]
    public_fields = appdotnet, avatar, avatarMedium, avatarLarge, date, email, fields, freenode, fullname, github, homepage, name, roles, twitter, type, _id, _rev
  14. @totherik totherik revised this gist Feb 22, 2014. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions registry.ini
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,5 @@
    ; $PREFIX/local.d/registry.ini

    [couch_httpd_auth]
    public_fields = appdotnet, avatar, avatarMedium, avatarLarge, date, email, fields, freenode, fullname, github, homepage, name, roles, twitter, type, _id, _rev
    users_db_public = true
  15. @totherik totherik revised this gist Feb 22, 2014. 1 changed file with 9 additions and 0 deletions.
    9 changes: 9 additions & 0 deletions registry.ini
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,9 @@
    [couch_httpd_auth]
    public_fields = appdotnet, avatar, avatarMedium, avatarLarge, date, email, fields, freenode, fullname, github, homepage, name, roles, twitter, type, _id, _rev
    users_db_public = true

    [httpd]
    secure_rewrites = false

    [couchdb]
    delayed_commits = false
  16. @totherik totherik created this gist Feb 22, 2014.
    47 changes: 47 additions & 0 deletions npmjs_install.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,47 @@
    #!/bin/bash

    # Read DB name
    echo -n "Database Name [registry]: "
    read database

    if [ -z $database ]; then database="registry"; fi

    # Read Username
    echo -n "CouchDB Username [admin]: "
    read username

    if [ -z $username ]; then username="admin"; fi

    # Read Password
    echo -n "CouchDB Password: "
    read -s password
    echo
    echo

    # Per: https://github.com/npm/npmjs.org

    git clone [email protected]:npm/npmjs.org.git
    cd npmjs.org
    npm install

    # Create the database
    registry=http://$username:$password@localhost:5984/$database
    curl -X PUT $registry
    npm set _npmjs.org:couch=$registry

    # Sync the ddoc
    npm start

    # Load views
    npm run load

    # Ensure _design/app exists
    curl -s -H 'Accept: application/json' -X PUT -d '{}' $registry/_design/app > /dev/null

    # Install app
    npm run copy

    # Clean up
    npm set _npmjs.org:couch=
    cd ../
    rm -rf npmjs.org