Redid relative paths for ldo script in init

main
Jackson Morgan 9 months ago
parent d284b5d56a
commit f0c9b2b19c
  1. 19
      packages/cli/example-create/.shapes/foafProfile.shex
  2. 1601
      packages/cli/example-create/package-lock.json
  3. 21
      packages/cli/example-create/package.json
  4. 9
      packages/cli/src/create.ts
  5. 9
      packages/cli/src/init.ts

@ -0,0 +1,19 @@
# This shape is provided by default as an example
# You can create your own shape to fit your needs using ShEx (https://shex.io)
# Also check out https://shaperepo.com for examples of more shapes.
PREFIX ex: <https://example.com/>
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
ex:FoafProfile EXTRA a {
a [ foaf:Person ]
// rdfs:comment "Defines the node as a Person (from foaf)" ;
foaf:name xsd:string ?
// rdfs:comment "Define a person's name." ;
foaf:img xsd:string ?
// rdfs:comment "Photo link but in string form" ;
foaf:knows @ex:FoafProfile *
// rdfs:comment "A list of WebIds for all the people this user knows." ;
}

File diff suppressed because it is too large Load Diff

@ -0,0 +1,21 @@
{
"name": "example-create",
"version": "1.0.0",
"description": "",
"keywords": [
""
],
"author": "",
"license": "MIT",
"dependencies": {
"@ldo/ldo": "^0.0.1-alpha.28"
},
"devDependencies": {
"@ldo/cli": "^0.0.1-alpha.28",
"@types/jsonld": "^1.5.15",
"@types/shexj": "^2.1.7"
},
"scripts": {
"build:ldo": "ldo build --input example-create/.shapes --output example-create/.ldo"
}
}

@ -4,6 +4,7 @@ import { generateReadme } from "./generateReadme";
import path from "path"; import path from "path";
import prompts from "prompts"; import prompts from "prompts";
import type { PackageJson } from "type-fest"; import type { PackageJson } from "type-fest";
import loading from "loading-cli";
export async function create(directory: string) { export async function create(directory: string) {
// Init the NPM Package // Init the NPM Package
@ -12,7 +13,7 @@ export async function create(directory: string) {
type: "text", type: "text",
name: "name", name: "name",
message: "Package name:", message: "Package name:",
initial: path.basename(process.cwd()), initial: path.basename(directory),
}, },
{ {
type: "text", type: "text",
@ -49,6 +50,8 @@ export async function create(directory: string) {
}, },
]); ]);
const load = loading("Generating package.json");
const packageJson: PackageJson = { const packageJson: PackageJson = {
name: responses.name, name: responses.name,
version: responses.version, version: responses.version,
@ -75,6 +78,7 @@ export async function create(directory: string) {
await savePackageJson(directory, packageJson); await savePackageJson(directory, packageJson);
// Init LDO // Init LDO
load.text = "Initializing LDO";
await init({ directory }); await init({ directory });
// Add prepublish script // Add prepublish script
@ -88,10 +92,13 @@ export async function create(directory: string) {
return packageJson; return packageJson;
}); });
load.text = "Generating README";
// Generate ReadMe // Generate ReadMe
await generateReadme({ await generateReadme({
project: directory, project: directory,
shapes: path.join(directory, ".shapes"), shapes: path.join(directory, ".shapes"),
ldo: path.join(directory, ".ldo"), ldo: path.join(directory, ".ldo"),
}); });
load.stop();
} }

@ -13,7 +13,6 @@ export interface InitOptions {
} }
export async function init(initOptions: InitOptions) { export async function init(initOptions: InitOptions) {
console.log("In init");
// Install dependencies // Install dependencies
await exec(`cd ${initOptions.directory} && npm install @ldo/ldo --save`); await exec(`cd ${initOptions.directory} && npm install @ldo/ldo --save`);
await exec( await exec(
@ -60,16 +59,16 @@ export async function init(initOptions: InitOptions) {
}), }),
); );
console.log("here");
// Add build script // Add build script
await modifyPackageJson(parentDirectory, async (packageJson) => { await modifyPackageJson(parentDirectory, 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);
packageJson.scripts[ packageJson.scripts["build:ldo"] = `ldo build --input ${path.relative(
"build:ldo" parentDirectory,
] = `ldo build --input ${shapesFolderPath} --output ${ldoFolder}`; shapesFolderPath,
)} --output ${path.relative(parentDirectory, ldoFolder)}`;
return packageJson; return packageJson;
}); });

Loading…
Cancel
Save