Skip to content
This repository has been archived by the owner on Aug 17, 2019. It is now read-only.

Commit

Permalink
feat(cli): splitting off CLI into a separate tool
Browse files Browse the repository at this point in the history
BREAKING CHANGE: libcipm is its own library now,
  • Loading branch information
zkat committed Jan 7, 2018
1 parent 1205cb3 commit cff65c1
Show file tree
Hide file tree
Showing 14 changed files with 642 additions and 116 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/node_modules
/bin/node_modules
/.nyc_output
/test/cache
2 changes: 2 additions & 0 deletions CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ Examples of behavior that contributes to creating a positive environment include
Examples of unacceptable behavior by participants include:

* The use of sexualized language or imagery and unwelcome sexual attention or advances, including when simulated online. The only exception to sexual topics is channels/spaces specifically for topics of sexual identity.
* Casual mention of slavery or indentured servitude and/or false comparisons of one's occupation or situation to slavery. Please consider using or asking about alternate terminology when referring to such metaphors in technology.
* Making light of/making mocking comments about trigger warnings and content warnings.
* Trolling, insulting/derogatory comments, and personal or political attacks.
* Public or private harassment, deliberate intimidation, or threats.
* Publishing others' private information, such as a physical or electronic address, without explicit permission. This includes any sort of "outing" of any aspect of someone's identity without their consent.
Expand Down
45 changes: 25 additions & 20 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,21 +1,16 @@
# Contributing

Thank you so much for your interest in contributing!. All types of contributions are encouraged and valued. See below for different ways to help, and details about how this project handles them!
## How do I... <a name="toc"></a>

Please make sure to read the relevant section before making your contribution! It will make it a lot easier for us maintainers to make the most of it and smooth out the experience fo all involved. 💚

The [Project Team](#join-the-project-team) looks forward to your contributions.~

## How do I...

* Ask or Say Something 🤔🐛😱
* [Use This Guide](#introduction)?
* Ask or Say Something? 🤔🐛😱
* [Request Support](#request-support)
* [Report an Error or Bug](#report-an-error-or-bug)
* [Request a Feature](#request-a-feature)
* Make Something 🤓👩🏽‍💻📜🍳
* Make Something? 🤓👩🏽‍💻📜🍳
* [Project Setup](#project-setup)
* [Contribute Documentation](#contribute-documentation)
* [Contibute Code](#contribute-code)
* [Contribute Code](#contribute-code)
* Manage Something ✅🙆🏼💃👔
* [Provide Support on Issues](#provide-support-on-issues)
* [Label Issues](#label-issues)
Expand All @@ -24,13 +19,21 @@ The [Project Team](#join-the-project-team) looks forward to your contributions.~
* [Merge Pull Requests](#merge-pull-requests)
* [Tag a Release](#tag-a-release)
* [Join the Project Team](#join-the-project-team)
* [Add a Guide Like This One To My Project](#Attribution) 🤖😻👻
* Add a Guide Like This One [To My Project](#attribution)? 🤖😻👻

## Introduction

Thank you so much for your interest in contributing!. All types of contributions are encouraged and valued. See the [table of contents](#toc) for different ways to help and details about how this project handles them!📝

Please make sure to read the relevant section before making your contribution! It will make it a lot easier for us maintainers to make the most of it and smooth out the experience for all involved. 💚

The [Project Team](#join-the-project-team) looks forward to your contributions. 🙌🏾✨

## Request Support

If you have a question about this project, how to use it, or just need clarification about something:

* Open an Issue at https://github.com/wealljs/weallcontribute/issues
* Open an Issue at https://github.com/zkat/cipm/issues
* Provide as much context as you can about what you're running into.
* Provide project and platform versions (nodejs, npm, etc), depending on what seems relevant. If not, please be ready to provide that information if maintainers ask for it.

Expand All @@ -44,7 +47,7 @@ Once it's filed:

If you run into an error or bug with the project:

* Open an Issue at https://github.com/wealljs/weallcontribute/issues
* Open an Issue at https://github.com/zkat/cipm/issues
* Include *reproduction steps* that someone else can follow to recreate the bug or error on their own.
* Provide project and platform versions (nodejs, npm, etc), depending on what seems relevant. If not, please be ready to provide that information if maintainers ask for it.

Expand All @@ -60,7 +63,7 @@ Once it's filed:

If the project doesn't do something you need or want it to do:

* Open an Issue at https://github.com/wealljs/weallcontribute/issues
* Open an Issue at https://github.com/zkat/cipm/issues
* Provide as much context as you can about what you're running into.
* Please try and be clear about why existing features and alternatives would not work for you.

Expand Down Expand Up @@ -104,7 +107,7 @@ To contribute documentation:
* Re-read what you wrote, and run a spellchecker on it to make sure you didn't miss anything.
* In your commit message(s), begin the first line with `docs: `. For example: `docs: Adding a doc contrib section to CONTRIBUTING.md`.
* Write clear, concise commit message(s) using [conventional-changelog format](https://github.com/conventional-changelog/conventional-changelog-angular/blob/master/convention.md). Documentation commits should use `docs(<component>): <message>`.
* Go to https://github.com/wealljs/weallcontribute/pulls and open a new pull request with your changes.
* Go to https://github.com/zkat/cipm/pulls and open a new pull request with your changes.
* If your PR is connected to an open issue, add a line in your PR's description that says `Fixes: #123`, where `#123` is the number of the issue you're fixing.

Once you've filed the PR:
Expand All @@ -130,7 +133,7 @@ To contribute code:
* Write tests that verify that your contribution works as expected.
* Write clear, concise commit message(s) using [conventional-changelog format](https://github.com/conventional-changelog/conventional-changelog-angular/blob/master/convention.md).
* Dependency updates, additions, or removals must be in individual commits, and the message must use the format: `<prefix>(deps): PKG@VERSION`, where `<prefix>` is any of the usual `conventional-changelog` prefixes, at your discretion.
* Go to https://github.com/wealljs/weallcontribute/pulls and open a new pull request with your changes.
* Go to https://github.com/zkat/cipm/pulls and open a new pull request with your changes.
* If your PR is connected to an open issue, add a line in your PR's description that says `Fixes: #123`, where `#123` is the number of the issue you're fixing.

Once you've filed the PR:
Expand All @@ -151,7 +154,7 @@ Sometimes, the `support` label will be added to things that turn out to actually

In order to help other folks out with their questions:

* Go to the issue tracker and [filter open issues by the `support` label](https://github.com/wealljs/weallcontribute/issues?q=is%3Aopen+is%3Aissue+label%3Asupport).
* Go to the issue tracker and [filter open issues by the `support` label](https://github.com/zkat/cipm/issues?q=is%3Aopen+is%3Aissue+label%3Asupport).
* Read through the list until you find something that you're familiar enough with to give an answer to.
* Respond to the issue with whatever details are needed to clarify the question, or get more details about what's going on.
* Once the discussion wraps up and things are clarified, either close the issue, or ask the original issue filer (or a maintainer) to close it for you.
Expand All @@ -168,7 +171,7 @@ Some notes on picking up support issues:

One of the most important tasks in handling issues is labeling them usefully and accurately. All other tasks involving issues ultimately rely on the issue being classified in such a way that relevant parties looking to do their own tasks can find them quickly and easily.

In order to label issues, [open up the list of unlabeled issues](https://github.com/wealljs/weallcontribute/issues?q=is%3Aopen+is%3Aissue+no%3Alabel) and, **from newest to oldest**, read through each one and apply issue labels according to the table below. If you're unsure about what label to apply, skip the issue and try the next one: don't feel obligated to label each and every issue yourself!
In order to label issues, [open up the list of unlabeled issues](https://github.com/zkat/cipm/issues?q=is%3Aopen+is%3Aissue+no%3Alabel) and, **from newest to oldest**, read through each one and apply issue labels according to the table below. If you're unsure about what label to apply, skip the issue and try the next one: don't feel obligated to label each and every issue yourself!

Label | Apply When | Notes
--- | --- | ---
Expand All @@ -179,6 +182,8 @@ Label | Apply When | Notes
`enhancement` | Added to [feature requests](#request-a-feature), PRs, or documentation issues that are purely additive: the code or docs currently work as expected, but a change is being requested or suggested. |
`help wanted` | Applied by [Committers](#join-the-project-team) to issues and PRs that they would like to get outside help for. Generally, this means it's lower priority for the maintainer team to itself implement, but that the community is encouraged to pick up if they so desire | Never applied on first-pass labeling.
`in-progress` | Applied by [Committers](#join-the-project-team) to PRs that are pending some work before they're ready for review. | The original PR submitter should @mention the team member that applied the label once the PR is complete.
`performance` | This issue or PR is directly related to improving performance. |
`refactor` | Added to issues or PRs that deal with cleaning up or modifying the project for the betterment of it. |
`starter` | Applied by [Committers](#join-the-project-team) to issues that they consider good introductions to the project for people who have not contributed before. These are not necessarily "easy", but rather focused around how much context is necessary in order to understand what needs to be done for this project in particular. | Existing project members are expected to stay away from these unless they increase in priority.
`support` | This issue is either asking a question about how to use the project, clarifying the reason for unexpected behavior, or possibly reporting a `bug` but does not have enough detail yet to determine whether it would count as such. | The label should be switched to `bug` if reliable reproduction steps are provided. Issues primarily with unintended configurations of a user's environment are not considered bugs, even if they cause crashes.
`tests` | This issue or PR either requests or adds primarily tests to the project. | If a PR is pending tests, that will be handled through the [PR review process](#review-pull-requests)
Expand All @@ -201,7 +206,7 @@ To clean up issues and PRs:
* not marked as `starter` or `help wanted` (these might stick around for a while, in general, as they're intended to be available)
* no explicit messages in the comments asking for it to be left open
* does not belong to a milestone
* Leave a message when closing saying "Cleaning up stale issue. Please reopen or ping us if and when you're ready to resume this. See https://github.com/wealljs/weallcontribute/blob/latest/CONTRIBUTING.md#clean-up-issues-and-prs for more details."
* Leave a message when closing saying "Cleaning up stale issue. Please reopen or ping us if and when you're ready to resume this. See https://github.com/zkat/cipm/blob/latest/CONTRIBUTING.md#clean-up-issues-and-prs for more details."

## Review Pull Requests

Expand Down Expand Up @@ -248,4 +253,4 @@ Admin/Owner | Granted to people ultimately responsible for the project, its comm

## Attribution

This guide was generated using the WeAllJS CONTRIBUTING.md generator. [Make your own!](https://npm.im/weallcontribute)
This guide was generated using the WeAllJS `CONTRIBUTING.md` generator. [Make your own](https://npm.im/weallcontribute)!
60 changes: 27 additions & 33 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,43 +1,37 @@
[![npm](https://img.shields.io/npm/v/cipm.svg)](https://npm.im/cipm) [![license](https://img.shields.io/npm/l/cipm.svg)](https://npm.im/cipm) [![Travis](https://img.shields.io/travis/zkat/cipm.svg)](https://travis-ci.org/zkat/cipm) [![AppVeyor](https://ci.appveyor.com/api/projects/status/github/zkat/cipm?svg=true)](https://ci.appveyor.com/project/zkat/cipm) [![Coverage Status](https://coveralls.io/repos/github/zkat/cipm/badge.svg?branch=latest)](https://coveralls.io/github/zkat/cipm?branch=latest)
[![npm](https://img.shields.io/npm/v/libcipm.svg)](https://npm.im/libcipm) [![license](https://img.shields.io/npm/l/libcipm.svg)](https://npm.im/libcipm) [![Travis](https://img.shields.io/travis/zkat/cipm.svg)](https://travis-ci.org/zkat/cipm) [![AppVeyor](https://ci.appveyor.com/api/projects/status/github/zkat/cipm?svg=true)](https://ci.appveyor.com/project/zkat/cipm) [![Coverage Status](https://coveralls.io/repos/github/zkat/cipm/badge.svg?branch=latest)](https://coveralls.io/github/zkat/cipm?branch=latest)

## NOTE: this project is under active development. Please don't use it yet.
[`libcipm`](https://github.com/zkat/cipm) installs npm projects in a way that's
optimized for continuous integration/deployment/etc scenarios. It gives up
the ability to build its own trees or install packages individually, as well
as other user-oriented features, in exchange for speed, and being more strict
about project state.

# cipm(1) -- install npm dependencies from a package lock
For documentation about the associated command-line tool, see
[`cipm`](https://npm.im/cipm).

## SYNOPSIS
## Install

`cipm [--userconfig <path>] [--ignore-scripts] [--offline] [--loglevel <level>]`
`$ npm install libcipm`

## INSTALL
## Table of Contents

`npm install [-g|-D] cipm`
* [Features](#features)
* [Contributing](#contributing)
* [API](#api)

## DESCRIPTION
### Features

When invoked inside an npm project with a `package.json` and `package-lock.json` (or an `npm-shrinkwrap.json`), it will install the specified dependencies and run their install scripts.
* npm-compatible project installation
* lifecycle script support
* blazing fast
* npm-compatible caching
* errors if `package.json` and `package-lock.json` are out of sync, instead of fixing it like npm does. Essentially provides a `--frozen` install.

The main difference between this and `npm install` is that `cipm` is both a small, standalone program, and that it can bypass a lot of the heavier machinery in npm oriented towards interacting with invalid states: `cipm` completely removes `node_modules` before beginning the install, if it exists.
### Contributing

`cipm` also requires that the current project have an existing lockfile, which must first be generated using `npm install` in `npm@5` or later versions (or any other package manager supporting `lockfileVersion@>=1`).

This tool is ideal for using in CI environments that require regular, full installs of an application, but that are usually able to cache package data in a central cache.

## EXAMPLES

## AUTHOR

Written by [Kat Marchan](https://github.com/zkat).

## REPORTING BUGS

Please file any relevant issues [on Github.](https://github.com/zkat/cipm)

## LICENSE

This work is released under the conditions of the MIT license. See LICENSE.md for more details.

## SEE ALSO

* `npm-install(1)`
* `npm-package-locks(5)`
* `package-lock.json(5)`
The libcipm team enthusiastically welcomes contributions and project
participation! There's a bunch of things you can do if you want to contribute!
The [Contributor Guide](CONTRIBUTING.md) has all the information you need for
everything from reporting bugs to contributing entire new features. Please don't
hesitate to jump in if you'd like to, or even ask us questions if something
isn't clear.
3 changes: 3 additions & 0 deletions bin/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/node_modules
/.nyc_output
/test/cache
7 changes: 7 additions & 0 deletions bin/LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Copyright 2017 Kat Marchán and Contributors

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
43 changes: 43 additions & 0 deletions bin/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
[![npm](https://img.shields.io/npm/v/cipm.svg)](https://npm.im/cipm) [![license](https://img.shields.io/npm/l/cipm.svg)](https://npm.im/cipm) [![Travis](https://img.shields.io/travis/zkat/cipm.svg)](https://travis-ci.org/zkat/cipm) [![AppVeyor](https://ci.appveyor.com/api/projects/status/github/zkat/cipm?svg=true)](https://ci.appveyor.com/project/zkat/cipm) [![Coverage Status](https://coveralls.io/repos/github/zkat/cipm/badge.svg?branch=latest)](https://coveralls.io/github/zkat/cipm?branch=latest)

## NOTE: this project is under active development. Please don't use it yet.

# cipm(1) -- install npm dependencies from a package lock

## SYNOPSIS

`cipm [--userconfig <path>] [--ignore-scripts] [--offline] [--loglevel <level>]`

## INSTALL

`npm install [-g|-D] cipm`

## DESCRIPTION

When invoked inside an npm project with a `package.json` and `package-lock.json` (or an `npm-shrinkwrap.json`), it will install the specified dependencies and run their install scripts.

The main difference between this and `npm install` is that `cipm` is both a small, standalone program, and that it can bypass a lot of the heavier machinery in npm oriented towards interacting with invalid states: `cipm` completely removes `node_modules` before beginning the install, if it exists.

`cipm` also requires that the current project have an existing lockfile, which must first be generated using `npm install` in `npm@5` or later versions (or any other package manager supporting `lockfileVersion@>=1`).

This tool is ideal for using in CI environments that require regular, full installs of an application, but that are usually able to cache package data in a central cache.

## EXAMPLES

## AUTHOR

Written by [Kat Marchan](https://github.com/zkat).

## REPORTING BUGS

Please file any relevant issues [on Github.](https://github.com/zkat/cipm)

## LICENSE

This work is released under the conditions of the MIT license. See LICENSE.md for more details.

## SEE ALSO

* `npm-install(1)`
* `npm-package-locks(5)`
* `package-lock.json(5)`
19 changes: 12 additions & 7 deletions bin/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

'use strict'

const config = require('../lib/config/npm-config.js')
const yargs = require('yargs')
const Installer = require('../index.js')
const Installer = require('libcipm')
const fromNpm = require('libcipm/lib/config/npm-config.js').fromNpm

module.exports = cliMain

Expand All @@ -14,11 +14,16 @@ if (require.main === module) {

function cliMain () {
parseArgs()
return config.fromNpm(process.argv)
.then(c => new Installer({
config: c,
log: require('npmlog')
}).run())
const log = require('npmlog')
return fromNpm(process.argv)
.then(c => {
log.level = c.get('loglevel')
return new Installer({
config: c,
log
})
})
.then(cipm => cipm.run())
.then(
details => console.error(`added ${details.pkgCount} packages in ${
details.runTime / 1000
Expand Down
Loading

0 comments on commit cff65c1

Please sign in to comment.