Class JScriptProjectLayout

java.lang.Object
org.machanism.machai.project.layout.ProjectLayout
org.machanism.machai.project.layout.JScriptProjectLayout

public class JScriptProjectLayout extends ProjectLayout
A project layout utility for JavaScript/TypeScript-based projects.

Scans for workspace modules defined in package.json, and determines project sources, documents, and test directories.

Since:
0.0.2
Author:
Viktor Tovstyi
  • Field Details

    • PROJECT_MODEL_FILE_NAME

      public static final String PROJECT_MODEL_FILE_NAME
      Name of the JS/TS project model file used to detect this layout.
      See Also:
  • Constructor Details

    • JScriptProjectLayout

      public JScriptProjectLayout()
  • Method Details

    • isPackageJsonPresent

      public static boolean isPackageJsonPresent(File projectDir)
      Checks if the specified directory contains a package.json file, indicating a JS/TS project.
      Parameters:
      projectDir - directory to check
      Returns:
      true if package.json is present; otherwise false
    • getModules

      public List<String> getModules()
      Returns workspace modules listed in package.json under the workspaces key.

      When workspaces is an array of glob patterns, this method searches directories under the configured project root and returns those that match a workspace pattern and contain a package.json.

      Overrides:
      getModules in class ProjectLayout
      Returns:
      list of relative module paths, or empty list when the project does not define workspaces
      Throws:
      IllegalArgumentException - if package.json cannot be read or parsed
    • getSources

      public List<String> getSources()
      Returns a list of conventional source directories for JS/TS projects.
      Specified by:
      getSources in class ProjectLayout
      Returns:
      empty list; not currently implemented
    • getDocuments

      public List<String> getDocuments()
      Returns a list of conventional documentation directories for JS/TS projects.
      Specified by:
      getDocuments in class ProjectLayout
      Returns:
      empty list; not currently implemented
    • getTests

      public List<String> getTests()
      Returns a list of conventional test directories for JS/TS projects.
      Specified by:
      getTests in class ProjectLayout
      Returns:
      empty list; not currently implemented
    • projectDir

      public JScriptProjectLayout projectDir(File projectDir)
      Sets the project directory and narrows the return type for fluent usage.
      Overrides:
      projectDir in class ProjectLayout
      Parameters:
      projectDir - project root directory
      Returns:
      this layout instance
    • getProjectId

      public String getProjectId()
      Returns the package name from package.json.
      Overrides:
      getProjectId in class ProjectLayout
      Returns:
      package name