Skip to content

Commit

Permalink
Merge pull request #33 from zMotivat0r/feature/digest-command
Browse files Browse the repository at this point in the history
feat(scripts): added digest command
  • Loading branch information
michaelyali authored Aug 20, 2021
2 parents 21180cc + 5acb3e6 commit 7836115
Show file tree
Hide file tree
Showing 41 changed files with 1,821 additions and 1,097 deletions.
95 changes: 95 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,101 @@ $ mrepo unlink
$ mrepo unlink packageName
```

### mrepo digest

_Install or create symlinks from mrepos to local target repositories._

_Info:_

```shell
mrepo digest|d [options] [from] [to]

Arguments:
from Mrepo names from the digest config file, comma-separated (optional)
to Target names from the digest config file, comma-separated (optional)

Options:
-c, --config <value> Config file name or path (optional) (default: "mrepo-digest.json")
-m, --mode <value> Digest mode. One of ln, install. (optional)
-p, --packages <value> Mrepo packages to digest, comma-separated (optional)
--installVersion <value> Install packages with version
--quiet Run quietly (default: false)
-h, --help display info
```

_Usage:_

1. Create a config json (default name "mrepo-digest.json") and place it somewhere in your system.

_Example config:_

```json
{
"paths": [
{
"name": "first",
"path": "/some/path/to/first"
},
{
"name": "second",
"path": "/some/path/to/second"
},
{
"name": "third",
"path": "/some/path/to/third"
}
],
"mrepos": [
{
"name": "first",
"defaultPackages": ["one-package", "another-cool-package"],
"targets": [
{
"name": "second",
"packages": ["awesome-package"]
},
{
"name": "third"
}
]
},
{
"name": "second",
"targets": [
{
"name": "third",
"packages": ["from-second-package"],
"noDefaultPackages": true,
"mode": "install"
}
]
}
],
"targets": [
{
"name": "second",
"installExec": "yarn add -W"
},
{
"name": "third",
"installExec": "npm i"
}
],
"mode": "ln"
}
```

In this example `first` and `second` are both `mrepo` generated monorepositories, where `second` depends on `first` (e.g. one has only public packages, another has only private packages under the same npm scope) and the `third` is just another node project wich depends on packages from both those mrepos.

`mrepos.defaultPackages` and `mrepos.targets.packages` are merged (`mrepos.targets.noDefaultPackages` prevents using default packages) . Can be overridden by using `--packages` option.

`mode` and `mrepos.targets.mode` have two values: `ln` - create symbolic links for packages from mrepo, `install` - install packages. Can be overridden by using `--mode` option.

```shell
$ mrepo digest
$ mrepo digest -c another-config.json first third --mode install
```

### mrepo release

_Start release new version: bump package(s) version, generate changelog, git commit and push._
Expand Down
95 changes: 95 additions & 0 deletions lib/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,101 @@ $ mrepo unlink
$ mrepo unlink packageName
```

### mrepo digest

_Install or create symlinks from mrepos to local target repositories._

_Info:_

```shell
mrepo digest|d [options] [from] [to]

Arguments:
from Mrepo names from the digest config file, comma-separated (optional)
to Target names from the digest config file, comma-separated (optional)

Options:
-c, --config <value> Config file name or path (optional) (default: "mrepo-digest.json")
-m, --mode <value> Digest mode. One of ln, install. (optional)
-p, --packages <value> Mrepo packages to digest, comma-separated (optional)
--installVersion <value> Install packages with version
--quiet Run quietly (default: false)
-h, --help display info
```

_Usage:_

1. Create a config json (default name "mrepo-digest.json") and place it somewhere in your system.

_Example config:_

```json
{
"paths": [
{
"name": "first",
"path": "/some/path/to/first"
},
{
"name": "second",
"path": "/some/path/to/second"
},
{
"name": "third",
"path": "/some/path/to/third"
}
],
"mrepos": [
{
"name": "first",
"defaultPackages": ["one-package", "another-cool-package"],
"targets": [
{
"name": "second",
"packages": ["awesome-package"]
},
{
"name": "third"
}
]
},
{
"name": "second",
"targets": [
{
"name": "third",
"packages": ["from-second-package"],
"noDefaultPackages": true,
"mode": "install"
}
]
}
],
"targets": [
{
"name": "second",
"installExec": "yarn add -W"
},
{
"name": "third",
"installExec": "npm i"
}
],
"mode": "ln"
}
```

In this example `first` and `second` are both `mrepo` generated monorepositories, where `second` depends on `first` (e.g. one has only public packages, another has only private packages under the same npm scope) and the `third` is just another node project wich depends on packages from both those mrepos.

`mrepos.defaultPackages` and `mrepos.targets.packages` are merged (`mrepos.targets.noDefaultPackages` prevents using default packages) . Can be overridden by using `--packages` option.

`mode` and `mrepos.targets.mode` have two values: `ln` - create symbolic links for packages from mrepo, `install` - install packages. Can be overridden by using `--mode` option.

```shell
$ mrepo digest
$ mrepo digest -c another-config.json first third --mode install
```

### mrepo release

_Start release new version: bump package(s) version, generate changelog, git commit and push._
Expand Down
6 changes: 4 additions & 2 deletions lib/bin/mrepo.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/bin/mrepo.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 28 additions & 0 deletions lib/commands/digest.command.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { CommanderStatic } from 'commander';
import { DIGEST_MODE } from '../constants';
import { IMrepoConfigFile, IMrepoDigestConfigFile, IMrepoDigestConfigFilePath, IMrepoDigestConfigFileMrepo, IMrepoDigestConfigFileMrepoTarget, IMrepoDigestConfigFileTarget } from '../interfaces';
interface DigestCommandOptions {
config: string;
mode: DIGEST_MODE;
packages?: string;
installVersion?: string;
quiet?: boolean;
}
export declare class DigestCommand {
static load(program: CommanderStatic['program']): void;
static runDigest(from: string, to: string, options: DigestCommandOptions): Promise<void>;
static removeFromNodeModules(mrepoConfig: IMrepoConfigFile, targetPath: IMrepoDigestConfigFilePath, digestPackages: string[]): void;
static runInstall(mrepoConfig: IMrepoConfigFile, targetPath: IMrepoDigestConfigFilePath, target: IMrepoDigestConfigFileTarget, digestPackages: string[], options: DigestCommandOptions): void;
static runSymlink(mrepoConfig: IMrepoConfigFile, mrepoPath: IMrepoDigestConfigFilePath, targetPath: IMrepoDigestConfigFilePath, digestPackages: string[]): Promise<void>;
static getMode(config: IMrepoDigestConfigFile, mrepoTarget: IMrepoDigestConfigFileMrepoTarget, options: DigestCommandOptions): DIGEST_MODE;
static getPathFromConfig(name: string, config: IMrepoDigestConfigFile, options: DigestCommandOptions): IMrepoDigestConfigFilePath;
static getMreposFromConfig(from: string, config: IMrepoDigestConfigFile, options: DigestCommandOptions): IMrepoDigestConfigFileMrepo[];
static getMrepoFromConfig(name: string, config: IMrepoDigestConfigFile, options: DigestCommandOptions): IMrepoDigestConfigFileMrepo;
static getMrepoTargetFromConfig(mrepo: IMrepoDigestConfigFileMrepo, to: string): IMrepoDigestConfigFileMrepoTarget[];
static getTargetFromConfig(name: string, config: IMrepoDigestConfigFile, options: DigestCommandOptions): IMrepoDigestConfigFileTarget;
static loadMrepoConfigFile(name: string, path: string): IMrepoConfigFile;
static getTargetDigestPackages(mrepo: IMrepoDigestConfigFileMrepo, mrepoTarget: IMrepoDigestConfigFileMrepoTarget, mrepoConfig: IMrepoConfigFile, options: DigestCommandOptions): string[];
static exit(msg: string): void;
static uniqArr(arr: any[]): any[];
}
export {};
Loading

0 comments on commit 7836115

Please sign in to comment.