https://github.com/jalal246/corename
Automatically extracts packages root name for monorepos
https://github.com/jalal246/corename
corename extract-data extract-information extract-text extracts get-info monorepo package-development package-json package-management production read-json utility
Last synced: about 1 year ago
JSON representation
Automatically extracts packages root name for monorepos
- Host: GitHub
- URL: https://github.com/jalal246/corename
- Owner: jalal246
- License: gpl-3.0
- Created: 2020-02-21T17:01:10.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2022-08-28T14:28:41.000Z (over 3 years ago)
- Last Synced: 2025-03-02T17:18:43.306Z (about 1 year ago)
- Topics: corename, extract-data, extract-information, extract-text, extracts, get-info, monorepo, package-development, package-json, package-management, production, read-json, utility
- Language: JavaScript
- Homepage: https://jalal246.github.io/corename/
- Size: 111 KB
- Stars: 2
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# corename
> Extracts the name of monorepo project
```bash
npm install corename
```
## API
### getCoreName
```ts
getCoreName(pkgJson: Array|Object)
```
### Usage
```js
import getCoreName from "corename";
const pkg0 = {
name: "pkg-first",
dependencies: {},
};
const pkg1 = {
name: "@pkg-second",
dependencies: {
"@pkg/first": "^0.1.5",
},
};
const pkg2 = {
name: "@pkg/third",
dependencies: {},
};
const name = getCoreName([pkg0, pkg1, pkg2]);
// name = "@pkg";
```
Or just pass a single package
```js
const name = getCoreName(pkg2);
// name = "@pkg";
```
In case there's no matching pattern, it returns null:
```js
const name = getCoreName(pkg1);
// name = null;
```
Or tell it to return the exact name found in package.json
```js
const returnNameIfMonoNotFound = true;
const name = getCoreName(pkg1, returnNameIfMonoNotFound);
// name = "@pkg-second";
```
### Tests
```sh
npm test
```
### License
This project is licensed under the [GPL-3.0 License](https://github.com/jalal246/corename/blob/master/LICENSE)
### Related projects
- [builderz](https://github.com/jalal246/builderz) - JavaScript Bundler with zero configuration.
- [packageSorter](https://github.com/jalal246/packageSorter) - Sorting packages
for monorepos production.
- [get-info](https://github.com/jalal246/get-info) - Utility functions for projects production
- [move-position](https://github.com/jalal246/move-position) - Moves element
index in an array.
- [textics](https://github.com/jalal246/textics) & [textics-stream](https://github.com/jalal246/textics-stream) - Counts lines, words, chars and spaces for a given string.
- [folo](https://github.com/jalal246/folo) - Form & Layout Components Built with
React.