Skip to content

Commit

Permalink
feat: rename from dev-package to npm-cross-link
Browse files Browse the repository at this point in the history
  • Loading branch information
medikoo committed Nov 9, 2018
1 parent a9f992b commit bf537ed
Show file tree
Hide file tree
Showing 20 changed files with 47 additions and 47 deletions.
18 changes: 9 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# dev-package
# npm-cross-link

## npm package cross linker (an installer for packages developer)

Expand All @@ -10,7 +10,7 @@ You maintain many npm packages which depend on each other. When developing local

Within [configuration](#configuration) you choose a folder (defaults to `~/npm-packages`) where maintained packages are placed, and predefine (at `packagesMeta`) a _package name_ to _repository url_ mappings of packages you maintain.

When running `dev-package install <package-name>` command following steps are pursued:
When running `npm-cross-link install <package-name>` command following steps are pursued:

1. If repository is not setup, it is cloned into corresponding folder. Otherwise changes from remote are pulled (can be opt out via `--no-pull`), and optionally committed changes can be pushed (indicate such intent with `--push`)
2. All maintained project dependencies (also `devDependencies`) are installed according to same flow. Those not maintained (not found in `packagesMeta`) are npm linked to global npm folder, if supported at latest version, otherwise they're installed on spot (but in a form where all its dependencies persist in a dependency folder)
Expand All @@ -30,7 +30,7 @@ To avoid confusion it's better to rely on global installation. Still [nvm](https

### CLI

#### `dev-package install [...options] <package-name>`
#### `npm-cross-link install [...options] <package-name>`

Installs or updates indicated package (with its dependencies) at packages folder.

Expand All @@ -41,24 +41,24 @@ _Note: This command doesn't interfere in any way with eventual project at curren
- `--no-pull` - By default (for all updated packages) mising updates are pulled from remote. This option turns that off
- `--push` - For all updated packages push eventually committed changes to remote

#### `dev-package install [...options]`
#### `npm-cross-link install [...options]`

Installs and links all maintained dependencies of a project (found at current working directory).
Installation rules are same as for package install. Maintained packages are linked to its location, not maintained are linked to global npm folder (unless they do not refer to latest version, as then they're installed on spot)

Supports same options as `dev-package install`
Supports same options as `npm-cross-link install`

#### `dev-package update-all [...options]`
#### `npm-cross-link update-all [...options]`

Updates all already installed packages.

_Note: This command doesn't interfere in any way with eventual project at current working directory._

Supports same options as `dev-package install`
Supports same options as `npm-cross-link install`

### Configuration

User configuraiton is mandatory and is expected to be placed at `~/.dev-package` path.
User configuraiton is mandatory and is expected to be placed at `~/.npm-cross-link` path.

It's expected to be a typical Node.js module, that exposes (asynchronously if needed) a configuration object with following properties:

Expand Down Expand Up @@ -94,7 +94,7 @@ Additional operation that should be done after successful package installation (
Function is run with following arguments:

- `packageContext` - All needed information about package that was just installed or updated
- `userConfiguration` - User configuration as resolved and normalized from `~/.dev-package`
- `userConfiguration` - User configuration as resolved and normalized from `~/.npm-cross-link`
- `inputOptions` - CLI command options

#### `userDependencies`
Expand Down
2 changes: 1 addition & 1 deletion bin/dev-package.js → bin/npm-cross-link.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Error.stackTraceLimit = Infinity;

process.on("unhandledRejection", reason => { throw reason; });

require("log4-nodejs")({ defaultNamespace: "dev-package" });
require("log4-nodejs")({ defaultNamespace: "npm-cross-link" });

const meta = require("../package");

Expand Down
2 changes: 1 addition & 1 deletion lib/get-npm-modules-path.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"use strict";

const { resolve } = require("path")
, log = require("log4").get("dev-package")
, log = require("log4").get("npm-cross-link")
, memoize = require("memoizee")
, runProgram = require("./run-program");

Expand Down
File renamed without changes.
6 changes: 3 additions & 3 deletions lib/private/cli/index.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
"use strict";

const log = require("log4").get("dev-package")
const log = require("log4").get("npm-cross-link")
, clc = require("cli-color")
, format = require("cli-sprintf-format")
, cliFooter = require("cli-progress-footer")()
, DevPackageError = require("../../dev-package-error")
, NpmCrossLinkError = require("../../npm-cross-link-error")
, resolveUserConfiguration = require("../resolve-user-configuration")
, install = require("../../../install")
, installPackage = require("../../../install-package")
Expand Down Expand Up @@ -48,7 +48,7 @@ module.exports = async (command, packageName, inputOptions) => {
await installPromise;
} catch (error) {
cliFooter.updateProgress();
if (error instanceof DevPackageError) {
if (error instanceof NpmCrossLinkError) {
process.stdout.write(`\n${ clc.red(error.message) }\n`);
process.exit(1);
return;
Expand Down
16 changes: 8 additions & 8 deletions lib/private/cli/usage.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,31 +3,31 @@
const meta = require("../../../package");

module.exports = {
"main": `dev-package v${ meta.version }
"main": `npm-cross-link v${ meta.version }
Usage: dev-package [-h | --help] <command> [<args>]
Usage: npm-cross-link [-h | --help] <command> [<args>]
where <command> is one of:
install
dev-package <command> -h quick help on <command>
npm-cross-link <command> -h quick help on <command>
Options:
--help, -h Show this message
`,
"install": `dev-package v${ meta.version }
"install": `npm-cross-link v${ meta.version }
Usage: dev-package install [-h | --help] [--no-pull] [--push] [<package-name>]
Usage: npm-cross-link install [-h | --help] [--no-pull] [--push] [<package-name>]
When <package-name> is provided, it is ensured it's installed and is up to date,
as located in npm packages folder
(there are no updates made to eventual project at current working directory)
When <package-name> is not provided then all dependencies of a project at
current working directory are ensured to be linked or installed
up to dev-package installation rules
up to npm-cross-link installation rules
Options:
Expand All @@ -36,9 +36,9 @@ Options:
--help, -h Show this message
`,
"update-all": `dev-package v${ meta.version }
"update-all": `npm-cross-link v${ meta.version }
Usage: dev-package update-all [-h | --help] [--no-pull] [--push]
Usage: npm-cross-link update-all [-h | --help] [--no-pull] [--push]
Ensures all packages in npm packages folder are properly installed and up to date
Expand Down
2 changes: 1 addition & 1 deletion lib/private/ensure-user-configuration.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const ensureArray = require("es5-ext/array/valid-array")
, ensureString = require("es5-ext/object/validate-stringifiable-value")
, { resolve } = require("path")
, { homedir } = require("os")
, log = require("log4").get("dev-package:configuration").info;
, log = require("log4").get("npm-cross-link:configuration").info;

module.exports = userConfiguration => {
log.debug("user input: %O", userConfiguration);
Expand Down
6 changes: 3 additions & 3 deletions lib/private/install-package/index.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
"use strict";

const { resolve } = require("path")
, log = require("log4").get("dev-package")
, log = require("log4").get("npm-cross-link")
, isDirectory = require("fs2/is-directory")
, npmLink = require("./npm-link")
, DevPackageError = require("../../dev-package-error")
, NpmCrossLinkError = require("../../npm-cross-link-error")
, setupRepository = require("../../setup-repository")
, cleanupNpmInstall = require("../cleanup-npm-install")
, removeNonDirectDependencies = require("../remove-non-direct-dependencies");
Expand All @@ -31,7 +31,7 @@ module.exports = async (packageContext, userConfiguration, inputOptions, progres
const { hooks, packagesPath, packagesMeta } = userConfiguration;
const { ongoingMap } = progressData;
if (!packagesMeta[name]) {
throw new DevPackageError(
throw new NpmCrossLinkError(
`Cannot install package. "${ name }" is not recognized as a dev package`
);
}
Expand Down
2 changes: 1 addition & 1 deletion lib/private/install-package/npm-link.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"use strict";

const { resolve } = require("path")
, log = require("log4").get("dev-package")
, log = require("log4").get("npm-cross-link")
, isSymlink = require("fs2/is-symlink")
, rm = require("fs2/rm")
, cleanupNpmInstall = require("../cleanup-npm-install")
Expand Down
2 changes: 1 addition & 1 deletion lib/private/remove-non-direct-dependencies.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"use strict";

const { resolve } = require("path")
, log = require("log4").get("dev-package")
, log = require("log4").get("npm-cross-link")
, readdir = require("fs2/readdir")
, rm = require("fs2/rm");

Expand Down
6 changes: 3 additions & 3 deletions lib/private/resolve-user-configuration.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@
const { resolve } = require("path")
, { homedir } = require("os")
, isModuleNotFoundError = require("cjs-module/is-module-not-found-error")
, DevPackageError = require("../dev-package-error");
, NpmCrossLinkError = require("../npm-cross-link-error");

const configurationPath = resolve(homedir(), ".dev-package");
const configurationPath = resolve(homedir(), ".npm-cross-link");

const resolveConfigurationModule = () => {
try {
return require(configurationPath);
} catch (error) {
if (isModuleNotFoundError(error, configurationPath)) {
throw new DevPackageError("Configuration not provided at ~/.dev-package");
throw new NpmCrossLinkError("Configuration not provided at ~/.npm-cross-link");
}
throw error;
}
Expand Down
2 changes: 1 addition & 1 deletion lib/private/setup-dependencies/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"use strict";

const log = require("log4").get("dev-package")
const log = require("log4").get("npm-cross-link")
, getPackageJson = require("../get-package-json")
, setupDependency = require("./setup-dependency");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

const memoizee = require("memoizee")
, got = require("got")
, log = require("log4").get("dev-package");
, log = require("log4").get("npm-cross-link");

module.exports = memoizee(
async dependencyName => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

const optionalChaining = require("es5-ext/optional-chaining")
, { resolve } = require("path")
, log = require("log4").get("dev-package")
, log = require("log4").get("npm-cross-link")
, semver = require("semver")
, isSymlink = require("fs2/is-symlink")
, rm = require("fs2/rm")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ const memoizee = require("memoizee")
, got = require("got")
, tar = require("tar")
, tmpdir = require("os").tmpdir()
, log = require("log4").get("dev-package")
, log = require("log4").get("npm-cross-link")
, runProgram = require("../../../../run-program")
, getPackageJson = require("../../../get-package-json")
, muteErrorIfOptional = require("./mute-error-if-optional");

const prepareDependency = memoizee(
async (name, version, metadata) => {
const targetDirname = resolve(tmpdir, "dev-package", name, version);
const targetDirname = resolve(tmpdir, "npm-cross-link", name, version);
log.notice("preparing install of %s", `${ name }@${ version }`);
await rm(targetDirname, { loose: true, recursive: true, force: true });
await mkdir(targetDirname, { intermediate: true });
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"use strict";

const log = require("log4").get("dev-package");
const log = require("log4").get("npm-cross-link");

module.exports = async (dependencyContext, operation) => {
try {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"use strict";

const optionalChaining = require("es5-ext/optional-chaining")
, log = require("log4").get("dev-package")
, log = require("log4").get("npm-cross-link")
, isDirectory = require("fs2/is-directory")
, semver = require("semver")
, getPackageJson = require("../../../get-package-json")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"use strict";

const optionalChaining = require("es5-ext/optional-chaining")
, log = require("log4").get("dev-package")
, log = require("log4").get("npm-cross-link")
, isDirectory = require("fs2/is-directory")
, isSymlink = require("fs2/is-symlink")
, rm = require("fs2/rm")
Expand Down
12 changes: 6 additions & 6 deletions lib/setup-repository.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
"use strict";

const isObject = require("es5-ext/object/is-object")
, log = require("log4").get("dev-package")
, isDirectory = require("fs2/is-directory")
, DevPackageError = require("./dev-package-error")
, runProgram = require("./run-program");
const isObject = require("es5-ext/object/is-object")
, log = require("log4").get("npm-cross-link")
, isDirectory = require("fs2/is-directory")
, NpmCrossLinkError = require("./npm-cross-link-error")
, runProgram = require("./run-program");

module.exports = async (path, repoUrl, options = {}) => {
if (!isObject(options)) options = {};
Expand All @@ -19,7 +19,7 @@ module.exports = async (path, repoUrl, options = {}) => {
cwd: path
});
if (localStatus) {
throw new DevPackageError(
throw new NpmCrossLinkError(
`Cannot proceed with update, repository at ${ path } is not clean:\n${
localStatus.split("\n").map(line => ` ${ line }`).join("\n")
}`
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"name": "dev-package",
"name": "npm-cross-link",
"version": "1.0.0",
"author": "Mariusz Nowak <[email protected]> (http://www.medikoo.com/)",
"bin": {
"dev-package": "./bin/dev-package.js"
"npm-cross-link": "./bin/npm-cross-link.js"
},
"dependencies": {
"child-process-es6-promise": "^1.2",
Expand Down

0 comments on commit bf537ed

Please sign in to comment.