0.1.0-next.3 • Published 4 years ago

@thrashplay/project-utils v0.1.0-next.3

Weekly downloads
-
License
MIT
Repository
github
Last release
4 years ago

@thrashplay/project-utils

Overview

Helpers for exploring packages in a standalone or monorepo project in an abstract way. This package provides methods for discovering the project's structure, as well as metadata for each package -- including the package name, directory path, and full package.json contents.

Currently supported project structures include:

Functions

getProject

Creates a Project instance for the specified initial path, if the path is part of a known project structure. Returns a promise that resolves to the new Project instance, and rejects if the initial path is not part of a recognized project.

getPackages

Retrieves an array of PackageConfig instances for the specified initial path, if the path is part of a known project structure. Returns a promise that resolves to the result array, and rejects if the initial path is not part of a recognized project.

getPackageDirectories

Retrieves a Dictionary that maps package names to absolute directory paths containing the packages for all packages that are part of a known project structure. Returns a promise that resolves to the result object, and rejects if the initial path is not part of a recognized project.

getPackageJsons

Retrieves an array of PackageJson instances for the specified initial path, if the path is part of a known project structure. Returns a promise that resolves to the result array, and rejects if the initial path is not part of a recognized project.

Model

Project

Metadata for the project as a whole.

Fields:

  • isMonorepo: Boolean indicating if the project is a monorepo or not
  • projectRootDir: The root directory for the monorepo, or the single package directory if standalone
  • packages: Array of PackageConfig objects, one for each package in the project

Methods:

Currently, PackageConfig instances provide the functionality from IoHelper: pathExists, readFile, readJsonFile, writeFile, and writeJsonFile. All of these methods use paths relative to the package's directory. It is very likely that these APIs are going to change in the near future, to better separate concerns in the code.

PackageConfig

Metadata for a single package inside the project.

Fields:

  • name: The name of the package
  • directory: The directory containing the package.json file
  • packageJson: PackageJson object containing the package configuration

Methods:

  • getPackageFromDir: TBD
  • isProjectRoot: TBD

Additionally, Project instances provide the functionality from IoHelper: pathExists, readFile, readJsonFile, writeFile, and writeJsonFile. All of these methods use paths relative to the project's root directory. It is very likely that these APIs are going to change in the near future, to better separate concerns in the code.

PackageJson

Simple type declaration for the contents of a package.json file.

0.1.0-next.33

4 years ago

0.1.0-next.32

4 years ago

0.1.0-next.31

4 years ago

0.1.0-next.28

4 years ago

0.1.0-next.29

4 years ago

0.1.0-next.30

4 years ago

0.1.0-next.27

4 years ago

0.1.0-next.26

4 years ago

0.1.0-next.24

4 years ago

0.1.0-next.23

4 years ago

0.1.0-next.25

4 years ago

0.1.0-next.22

4 years ago

0.1.0-next.21

4 years ago

0.1.0-next.20

4 years ago

0.1.0-next.18

4 years ago

0.1.0-next.17

4 years ago

0.1.0-next.16

4 years ago

0.1.0-next.15

4 years ago

0.1.0-next.14

4 years ago

0.1.0-next.7

4 years ago

0.1.0-next.6

4 years ago

0.1.0-next.5

4 years ago

0.1.0-next.4

4 years ago

0.1.0-next.3

4 years ago