init command
LDO's cli's init command initializes LDO in an existing Typescript project.
The command is intended to be run using NPX in the same folder as a project's package.json. For example:
If @ldo/cli is installed globally, the ldo command can be used. For example:
This command will create a .shapes and .ldo folder that will store the schemas and generated code for LDO respectively.
Parameters
-d [directory], --directory [directory] (Optional)
The init command takes in one parameter: -d or --directory. If present, the init command will create the .shapes and .ldo folders in the given directory.
Further details
The command does the following:
- Installs
@ldo/ldoas a dependency - Installs
@ldo/cli,@types/shexj, and@types/jsonldas dev dependencies - Selects a
PARENT_DIRECTORY- If the
--directoryparameter is set, thePARENT_DIRECTORYis the given directory. - If
src,lib, orbinare present in the project, thePARENT_DIRECTORYissrc,lib, orbinselected in that order. - Else the
PARENT_DIRECTORYis the project's root directory.
- If the
- Creates a file at
PARENT_DIRECTORY/.shapes/foafProfile.shexto serve as an example ShEx file. (This can be deleted at any time) - Adds a build script,
build:ldo, topackage.json. For example, if thePARENT_DIRECTORYwasfoothe following would be added: - Runs the build script, generating the
.ldofolder