Skip to content

Pre release test instructions

Greg Swindle edited this page Aug 25, 2019 · 11 revisions

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-rules.git
    cd archetypes-rules/
  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-rules/archetypes-rules-1.1.0.tgz

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

    npm notice 
    npm notice 📦  [email protected]
    npm notice === Tarball Contents === 
    npm notice 10.4kB package.json            
    npm notice 5.6kB  CHANGELOG.md            
    npm notice 1.1kB  LICENSE                 
    npm notice 28.5kB README.md               
    npm notice 21.7kB dist/archetypes-rules.js
    npm notice === Tarball Details === 
    npm notice name:          archetypes-rules                        
    npm notice version:       1.1.0                                   
    npm notice filename:      archetypes-rules-1.1.0.tgz              
    npm notice package size:  15.9 kB                                 
    npm notice unpacked size: 67.4 kB                                 
    npm notice shasum:        3bfa34ba536ae0da9ad269be437b816666c8db33
    npm notice integrity:     sha512-uBVSNTpQopypQ[...]AEgNGpHoZIBUQ==
    npm notice total files:   5                                       
    npm notice 
    archetypes-rules-1.1.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-rules/archetypes-rules-1.1.0.tgz
  8. Start a Node.js REPL

    node
  9. Import/require the archetypes-rules module

    # version <= 1.2.0
    const archetypesRules = require('archetypes-rules')
    
    # version >= 2.x
    const rules = require('@archetypes/rules')
  10. Try stuff out!