Skip to content

Prerelease test instructions

Greg Swindle edited this page Dec 2, 2019 · 1 revision

Package The last step in a Pull Request is to verify that a new feature or defect fix really works. 😄

How to create a local Node.js distribution (package) and test it

Artifact repositories like NPM and JFrog ("OneArtifactory") store the Node.js distributions as *.tgz "bundles. So whenever you run npm install cold-blooded-module, the Node Package Manager sends a request to an artifact registry, which responds by downloading a bundled file (in this case cold-blooded-module.tgz).

npm-pack

npm pack lets you do the same thing on your local machine. And, instead of requesting a package using HTTPS, you can request a local package with a physical file path, e.g.:

npm i /path/to/your/local/npm/pack/distribution.tgz

Step-by-step: how to verify a local Node.js distribution

Terminal Run the following instructions in a Terminal (command-line interface).

  1. Clone the repo

    git clone https://github.com/commonality/archetypes-quantity.git
    cd archetypes-quantity/
  2. Checkout the topic branch you want to test.

    # Example feature branch
    git checkout 10-feat-extend-object-variable
  3. "Build" the distribution package.

    Run:

    npm run bundle

    Sample output:

    The last line will output the absolute path to the package, e.g.:

    Package location:
    
    /path/to/local/repo/archetypes-quantity/archetypes-quantity-1.1.0.tgz

    Click/tap to view full npm pack output...

    npm notice 
    npm notice 📦  @archetypes/[email protected]
    npm notice === Tarball Contents === 
    npm notice 1.4kB   LICENSE                         
    npm notice 21.7kB  dist/@archetypes/quantity.esm.js
    npm notice 34.9kB  dist/@archetypes/quantity.js    
    npm notice 739.7kB npm-shrinkwrap.json             
    npm notice 8.1kB   package.json                    
    npm notice 18.8kB  README.md                       
    npm notice === Tarball Details === 
    npm notice name:          @archetypes/quantity                    
    npm notice version:       1.0.0                                   
    npm notice filename:      archetypes-quantity-1.0.0.tgz           
    npm notice package size:  184.0 kB                                
    npm notice unpacked size: 824.5 kB                                
    npm notice shasum:        c743d5f8ef2d2e7790283ca4c48f516d4d687fec
    npm notice integrity:     sha512-1LISGVzU1ODki[...]deiUKukOsFSLQ==
    npm notice total files:   6                                       
    npm notice 
    archetypes-quantity-1.0.0.tgz

  4. Copy the full path to the packaged module

    # This works on MacOS (bash); dunno about PowerShell
    echo "$(pwd)/$(ls *.tgz)" | pbcopy
  5. Create another directory somewhere else on your hard-drive:

    mkdir -p /path/to/temp/test/directory/ && cd $_
  6. Initialize with npm (the --yes argument accepts all defaults):

    npm init --yes
  7. Install your local package with npm

    npm i /path/to/local/repo/archetypes-quantity/archetypes-quantity-1.1.0.tgz
  8. Start a Node.js REPL

    node
  9. Import/require the archetypes-quantity module

    const quantity = require('@archetypes/quantity')
    
    # OR
    
    import quantity from '@archetypes/quantity'
  10. Try stuff out!