{"id":17256134,"url":"https://github.com/jalal246/get-info","last_synced_at":"2025-04-14T05:42:31.600Z","repository":{"id":38012137,"uuid":"240048097","full_name":"jalal246/get-info","owner":"jalal246","description":"Extracting and parsing data for project production works on a root directory with submodule/monorepo  ","archived":false,"fork":false,"pushed_at":"2022-09-22T02:40:05.000Z","size":158,"stargazers_count":7,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-27T19:40:20.967Z","etag":null,"topics":["build","build-tool","dev-ops","extracts","filesystem-library","filter","fs","get-info","json","json-objects","monorepo","monorepos","production","read-file","recursive","sort-files","textics","tools","utility-library"],"latest_commit_sha":null,"homepage":"https://jalal246.github.io/get-info/","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jalal246.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-02-12T15:35:10.000Z","updated_at":"2023-11-05T11:02:47.000Z","dependencies_parsed_at":"2022-07-10T20:30:25.391Z","dependency_job_id":null,"html_url":"https://github.com/jalal246/get-info","commit_stats":null,"previous_names":[],"tags_count":14,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jalal246%2Fget-info","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jalal246%2Fget-info/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jalal246%2Fget-info/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jalal246%2Fget-info/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jalal246","download_url":"https://codeload.github.com/jalal246/get-info/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248665748,"owners_count":21142123,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["build","build-tool","dev-ops","extracts","filesystem-library","filter","fs","get-info","json","json-objects","monorepo","monorepos","production","read-file","recursive","sort-files","textics","tools","utility-library"],"created_at":"2024-10-15T07:13:41.506Z","updated_at":"2025-04-14T05:42:31.573Z","avatar_url":"https://github.com/jalal246.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# get-info\n\n\u003e Utility functions extract project(s) Json by providing\u003e project root path or package names.\n\n`get-info` Works with monorepos `./packages/**/` as well as for a single package project `./myFiles`.\n\n```bash\nnpm install get-info\n```\n\n## API\n\n### getJsonByName\n\nExtracts package json, and resolved path for each project name. If `names` are\nnot passed, it returns all json objects can be found in\n`./packages/**/package.json` or `./package json`\n\n```js\ngetJsonByName(...packNames?string)\n```\n\nThe result object:\n\n- `json: Array \u003cpackJson\u003e` - Contains objects of all retrieved package.json based on given names\n- `pkgInfo: Array \u003cpackPath\u003e` - Contains objects of package paths based on package name\n\n```js\nconst { json, pkgInfo } = getJsonByName(...names);\n```\n\n#### Example(1)\n\n```js\nimport { getJsonByName } from \"get-info\";\n\n// workspace\n// │\n// ├───foo\n// │   ├───src\n// │   └───package.json\n// ├───bar\n// │   ├───src\n// │   └───package.json\n// ├───foobar\n// │   ├───src\n// │\n\nconst { json, pkgInfo } = getJsonByName(\"foo\", \"bar\");\n\n// json = [\n//   { name: \"foo\", version: \"1.0.0\", main: \"index.js\" },\n//   { name: \"bar\", version: \"2.1.1\", main: \"bundle.js\" },\n// ];\n\n// pkgInfo = {\n//   foo: { path: \"path/to/foo\" },\n//   bar: { path: \"path/to/bar\" },\n// };\n```\n\nWhat if passed invalid name? It returns empty array `[]`\n\n#### Example(2)\n\n```js\n// workspace\n// │\n// ├───foo\n// │   ├───src\n// │   └───package.json\n// ├───bar\n// │   ├───src\n// │   └───package.json\n// ├───foobar\n// │   ├───src\n// │\n\nconst { json, pkgInfo } = getJsonByName(\"baz\");\n\n// json =[]\n\nif (json.length === 0) console.log(\"do something\");\n```\n\n### getJsonByPath\n\nExtracts package json, and its associated resolved path. If `paths` are not\npassed, it returns all json objects can be found in `./packages/**/package.json`\nor `./package.json`\n\n```js\ngetJsonByPath(...paths?string)\n```\n\nThe result object:\n\n- `json: Array \u003cpackJson\u003e` - Contains objects of all retrieved package.json based on given paths\n- `pkgInfo: Array \u003cpackPath\u003e` - Contains objects of package paths based on package path\n- `unfoundJson: Array \u003cstring\u003e` - List of paths don't have valid package.json\n\n```js\nconst { json, pkgInfo, unfoundJson } = getJsonByPath(...paths);\n```\n\n#### Example(3)\n\n```js\nimport { getJsonByPath } from \"get-info\";\n\n// workspace\n// │\n// ├───foo\n// │   ├───src\n// │   └───package.json\n// ├───bar\n// │   ├───src\n// │   └───package.json\n// ├───foobar\n// │   ├───src\n// │\n\nconst { json, pkgInfo, unfoundJson } = getJsonByPath(\n  `${__dirname}/foo`,\n  `${__dirname}/bar`\n);\n\n// json = [\n//   { name: \"foo\", version: \"1.0.0\", main: \"index.js\" },\n//   { name: \"bar\", version: \"2.1.1\", main: \"bundle.js\" },\n// ];\n\n// pkgInfo = {\n//   foo: { path: \"path/to/foo\" },\n//   bar: { path: \"path/to/bar\" },\n// };\n\n// unfoundJson = [\"path/to/foobar\"];\n```\n\nBy default, `getJsonByPath` returns all package in `workspace` tree.\n\n```js\n// workspace\n// │\n// ├───foo\n// │   ├───src\n// │   └───package.json\n// ├───bar\n// │   ├───src\n// │   └───package.json\n// ├───foobar\n// │   └───src\n// │\n// │───package.json\n\nconst { json, pkgInfo, unfoundJson } = getJsonByPath();\n\n// json = [\n//   { name: \"foo\", version: \"1.0.0\", main: \"index.js\" },\n//   { name: \"bar\", version: \"2.1.1\", main: \"bundle.js\" },\n// ];\n\n// pkgInfo = {\n//   foo: { path: \"path/to/foo\" },\n//   bar: { path: \"path/to/bar\" },\n// };\n\n// unfoundJson = [\"path/to/foobar\"];\n```\n\n## Tests\n\n```sh\nnpm test\n```\n\n## License\n\nThis project is licensed under the [GPL-3.0 License](https://github.com/jalal246/get-info/blob/master/LICENSE)\n\n### Related projects\n\n- [validate-access](https://github.com/jalal246/validate-access) - Validate\n  project accessibility files\n\n- [packageSorter](https://github.com/jalal246/packageSorter) - Sorts a group of\n  packages that depends on each other.\n\n- [builderz](https://github.com/jalal246/builderz) - JavaScript Bundler with zero configuration.\n\n- [corename](https://github.com/jalal246/corename) - Extracts package name.\n\n- [move-position](https://github.com/jalal246/move-position) - Moves element\n  index in an array.\n\n- [textics](https://github.com/jalal246/textics) \u0026 [textics-stream](https://github.com/jalal246/textics-stream) - Counts lines, words, chars and spaces for a given string.\n\n- [folo](https://github.com/jalal246/folo) - Form \u0026 Layout Components Built with\n  React.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjalal246%2Fget-info","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjalal246%2Fget-info","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjalal246%2Fget-info/lists"}