|
|
@ -15,7 +15,6 @@ const DEFAULT_LDO_FOLDER = "./.ldo"; |
|
|
|
const POTENTIAL_PARENT_DIRECTORIES = ["src", "lib", "bin"]; |
|
|
|
const POTENTIAL_PARENT_DIRECTORIES = ["src", "lib", "bin"]; |
|
|
|
|
|
|
|
|
|
|
|
export async function init(directory?: string) { |
|
|
|
export async function init(directory?: string) { |
|
|
|
console.log("directory", directory); |
|
|
|
|
|
|
|
// Find folder to save to
|
|
|
|
// Find folder to save to
|
|
|
|
const projectDirectory = directory ?? "./"; |
|
|
|
const projectDirectory = directory ?? "./"; |
|
|
|
|
|
|
|
|
|
|
@ -35,7 +34,6 @@ export async function init(directory?: string) { |
|
|
|
break; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
console.log("parentDirectory", parentDirectory); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Install dependencies
|
|
|
|
// Install dependencies
|
|
|
|
await exec(`cd ${projectDirectory} && npm install @ldo/ldo --save`); |
|
|
|
await exec(`cd ${projectDirectory} && npm install @ldo/ldo --save`); |
|
|
@ -43,8 +41,6 @@ export async function init(directory?: string) { |
|
|
|
`cd ${projectDirectory} && npm install @ldo/cli @types/shexj @types/jsonld --save-dev`, |
|
|
|
`cd ${projectDirectory} && npm install @ldo/cli @types/shexj @types/jsonld --save-dev`, |
|
|
|
); |
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
console.log("Ran installs"); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Create "shapes" folder
|
|
|
|
// Create "shapes" folder
|
|
|
|
const shapesFolderPath = path.join(parentDirectory, DEFAULT_SHAPES_FOLDER); |
|
|
|
const shapesFolderPath = path.join(parentDirectory, DEFAULT_SHAPES_FOLDER); |
|
|
|
await fs.promises.mkdir(shapesFolderPath); |
|
|
|
await fs.promises.mkdir(shapesFolderPath); |
|
|
@ -64,15 +60,12 @@ export async function init(directory?: string) { |
|
|
|
}), |
|
|
|
}), |
|
|
|
); |
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
console.log("Createed shapes folder and filled with default shex shapes"); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Add build script
|
|
|
|
// Add build script
|
|
|
|
await modifyPackageJson("./", async (packageJson) => { |
|
|
|
await modifyPackageJson("./", async (packageJson) => { |
|
|
|
if (!packageJson.scripts) { |
|
|
|
if (!packageJson.scripts) { |
|
|
|
packageJson.scripts = {}; |
|
|
|
packageJson.scripts = {}; |
|
|
|
} |
|
|
|
} |
|
|
|
const ldoFolder = path.join(parentDirectory, DEFAULT_LDO_FOLDER); |
|
|
|
const ldoFolder = path.join(parentDirectory, DEFAULT_LDO_FOLDER); |
|
|
|
console.log("ldo folder", ldoFolder); |
|
|
|
|
|
|
|
packageJson.scripts["build:ldo"] = `ldo build --input ${path.relative( |
|
|
|
packageJson.scripts["build:ldo"] = `ldo build --input ${path.relative( |
|
|
|
projectDirectory, |
|
|
|
projectDirectory, |
|
|
|
shapesFolderPath, |
|
|
|
shapesFolderPath, |
|
|
|