npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

organic-stack-upgrade

v2.1.0

Published

lib for upgrading organic stem skeletons

Downloads

3

Readme

organic-stack-upgrade

lib for upgrading organic stem skeletons

StackUpgrade class

constructor({destDir, name, version})

Constructs class instance with destDir, name and version properties

let stack = new StackUpgrade({
  destDir: process.cwd(),
  name: 'myStack',
  version: '1.0.0'
})

constructor({destDir, packagejson})

Constructs class instance with destDir property. Fills name and version properties by reading packagejson as .json file

let stack = new StackUpgrade({
  destDir: process.cwd(),
  packagejson: __dirname + '/package.json'
})

async configure({sourceDir, answers}): result_answers

Configures stack upgrade. This method does the following:

  1. globs in sourceDir for any placeholders such as {{{variable-name}}} within file contents or file/directory paths
  2. uses answers hash to provide values for found placeholders
  3. prompts the user via inquirer to provide any missing answers to placeholders found from step 1
  4. returns all placeholders with their respective answer values as result_answers hash
let stack = new StackUpgrade(...)
let answers = await stack.configure({
  sourceDir: path.join(__dirname, 'seedTemplateFolder')
})

// `answers` will be a hash with provided answers to 
// any placeholders been found within `seedTemplateFolder`

async merge({sourceDir, answers})

Merges stack upgrade into destDir. This method does the following:

  1. globs in sourceDir for all files and folders and replaces any placeholders such as {{{variable-name}}} in all file/directory path or file contents
  2. writes resulted files and directories do the destDir by using the following merge strategies:
  • for .json files it does deep object merge and overrides existing keys
  • for .gitignore files it reconstructs the file by appending to the using existing file the content provided from sourceDir. It eliminates duplicated lines
  • for gitignore files it outputs .gitignore following the same rules as previous point
  • for all other files it just overrides
let stack = new StackUpgrade({
  destDir: ...,
  ...
})
await stack.merge({
  sourceDir: path.join(__dirname, 'seedTemplateFolder'),
  answers: {...}
})

// will merge `seedTemplateFolder` into `destDir`
// replacing any placeholders been found with provided `answers` hash

async updateJSON()

Updates <destDir>/package.json by adding stack upgrade name and version within stackUpgrades key. This is useful way to record that given stack upgrade by name/version has been applied to the destDir

let stack = new StackUpgrade({
  destDir: process.cwd(),
  name: "my-upgrade",
  version: "1.0.1"
})
stack.updateJSON()

// will create or append the following to destDir/package.json
/*
{
  "stackUpgrades": {
    "my-upgrade": "1.0.1"
  }
}
*/

async checkUpgrade(name, version): Boolean

Checks <destDir>/package.json for specific stackUpgrades key matching name having respective version compared via compare-versions

Returns true when respective version is equal or greater than destination's

let stack = new StackUpgrade({
  destDir: process.cwd()
})

stack.checkUpgrade('my-upgrade', '^1.0.0') 

// returns 'true' when destDir has package.json like
/*
{
  "stackUpgrades": {
    "my-upgrade": "1.0.0"
  }
}
*/

async exec(cmd)

Helper method to execute cmd on destDir and to pipe the output to console. Note that destDir is created if not exists.

let stack = new StackUpgrade({
  destDir: process.cwd()
})

stack.exec('echo TEST')
// will execute `echo TEST` command witin `destDir` 
// inheriting any process env variables

async ensureDestDir()

Helper method to create destination directory if not found

async ask(question, defaultValue)

Helper method to use inquirer prompt and return the resulted answer