Skip to content

Add CLI commands #3

@jsdevel

Description

@jsdevel
  • init [directory name]

    Creates a basic alle monorepo structure in the current directory if no directory name is given.
    A basic alle structure looks like this:

    package.json
    packages/
    packages/node_modules -> packages (this is a symlink that points back to packages.  Allows packages to reference each other with require and import).
    
  • install

    Runs npm i in each of the package directories (when dependencies are defined therein) and the repo directory. Creates the symlink packages/node_modules -> packages/ to allow packages to reference each other.

  • publish [...packages]

    Publish each of the packages given. If no packages are given, the packages directory would be scanned for packages and the user would be prompted in the terminal to choose which available packages they'd like to publish. The publishing process for each package would go like this:

    1. If the repo has a .git directory, then it is checked for a clean working directory. If the working directory is not clean, then the program exits with an error message about the directory not being clean.
    2. The package would be scanned for dependencies via requireandimportstatements used by the package. If a dependency is found that is not listed in thedependencies` section of either the package's package.json file or the repository package.json file, then an error is shown to the user and the program exits.
    3. The package's package.json file would inherit from the repo package.json file. Dependencies listed in the package's package.json file would override dependencies listed in the repo's package.json file i.e.
    packages/foo-package/package.json
    {
      "version": "1.0.3",
      "description": "A foo life in your terminal.",
      "dependencies": {
        "lodash": "*",
        "yargs": "6.9.x"
      }
    }
    
    package.json
    {
      "version": "0.0.0",
      "author": "Bob Hope",
      "dependencies": {
        "lodash": "3.4.1"
      }
    }
    

    This scenario would result in the following package.json being temporarily written to packages/foo-package/package.json (assuming patch was chosen as the next version for the package):

    {
      "version": "1.0.4",
      "description": "A foo life in your terminal.",
      "author": "Bob Hope",
      "dependencies": {
        "lodash": "*",
        "yargs": "6.9.x"
      }
    }
    
    1. npm pu would be run in each of the packages given in the command.
    2. Each of the newly published packages would have their versions left but other changes would be reverted.
    3. If a .git directory was found in the repo then the updated package.json files would be committed.
  • run <...command>

    Runs the command in each of the packages.

  • t, test

    Alias for alle run npm t.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions