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/ldo
as a dependency - Installs
@ldo/cli
,@types/shexj
, and@types/jsonld
as dev dependencies - Selects a
PARENT_DIRECTORY
- If the
--directory
parameter is set, thePARENT_DIRECTORY
is the given directory. - If
src
,lib
, orbin
are present in the project, thePARENT_DIRECTORY
issrc
,lib
, orbin
selected in that order. - Else the
PARENT_DIRECTORY
is the project's root directory.
- If the
- Creates a file at
PARENT_DIRECTORY/.shapes/foafProfile.shex
to 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_DIRECTORY
wasfoo
the following would be added: - Runs the build script, generating the
.ldo
folder