@ldo/cli 1.0.0-alpha.2 → 1.0.0-alpha.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/build.d.ts +1 -0
- package/dist/build.d.ts.map +1 -0
- package/dist/build.js +27 -25
- package/dist/build.js.map +1 -1
- package/dist/create.d.ts +1 -0
- package/dist/create.d.ts.map +1 -0
- package/dist/create.js +28 -25
- package/dist/create.js.map +1 -1
- package/dist/generateReadme.d.ts +4 -0
- package/dist/generateReadme.d.ts.map +1 -0
- package/dist/generateReadme.js +29 -26
- package/dist/generateReadme.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +15 -17
- package/dist/index.js.map +1 -1
- package/dist/init.d.ts +1 -0
- package/dist/init.d.ts.map +1 -0
- package/dist/init.js +38 -35
- package/dist/init.js.map +1 -1
- package/dist/util/forAllShapes.d.ts +1 -0
- package/dist/util/forAllShapes.d.ts.map +1 -0
- package/dist/util/forAllShapes.js +8 -13
- package/dist/util/forAllShapes.js.map +1 -1
- package/dist/util/modifyPackageJson.d.ts +1 -0
- package/dist/util/modifyPackageJson.d.ts.map +1 -0
- package/dist/util/modifyPackageJson.js +8 -17
- package/dist/util/modifyPackageJson.js.map +1 -1
- package/package.json +10 -10
- package/src/build.ts +8 -2
- package/src/create.ts +12 -4
- package/src/generateReadme.ts +8 -2
- package/src/index.ts +4 -4
- package/src/init.ts +29 -24
package/dist/build.d.ts
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"build.d.ts","sourceRoot":"","sources":["../src/build.ts"],"names":[],"mappings":"AAgBA,UAAU,YAAY;IACpB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,wBAAsB,KAAK,CAAC,OAAO,EAAE,YAAY,iBAkDhD"}
|
package/dist/build.js
CHANGED
|
@@ -1,29 +1,30 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
const
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
const load = (0, loading_cli_1.default)("Peparing Environment");
|
|
1
|
+
import fs from "fs-extra";
|
|
2
|
+
import path from "path";
|
|
3
|
+
import parser from "@shexjs/parser";
|
|
4
|
+
import schemaConverterShex from "@ldo/schema-converter-shex";
|
|
5
|
+
import { renderFile } from "ejs";
|
|
6
|
+
import prettier from "prettier";
|
|
7
|
+
import loading from "loading-cli";
|
|
8
|
+
import { dirname } from "node:path";
|
|
9
|
+
import { fileURLToPath } from "node:url";
|
|
10
|
+
import { forAllShapes } from "./util/forAllShapes.js";
|
|
11
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
12
|
+
// @ts-ignore
|
|
13
|
+
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
14
|
+
export async function build(options) {
|
|
15
|
+
const load = loading("Preparing Environment");
|
|
17
16
|
load.start();
|
|
18
|
-
|
|
19
|
-
|
|
17
|
+
// Prepare new folder by clearing/and/or creating it
|
|
18
|
+
if (fs.existsSync(options.output)) {
|
|
19
|
+
await fs.promises.rm(options.output, { recursive: true });
|
|
20
20
|
}
|
|
21
|
-
await
|
|
21
|
+
await fs.promises.mkdir(options.output);
|
|
22
22
|
load.text = "Generating LDO Documents";
|
|
23
|
-
await
|
|
23
|
+
await forAllShapes(options.input, async (fileName, shexC) => {
|
|
24
|
+
// Convert to ShexJ
|
|
24
25
|
let schema;
|
|
25
26
|
try {
|
|
26
|
-
schema =
|
|
27
|
+
schema = parser.construct("https://ldo.js.org/").parse(shexC);
|
|
27
28
|
}
|
|
28
29
|
catch (err) {
|
|
29
30
|
const errMessage = err instanceof Error
|
|
@@ -34,18 +35,19 @@ async function build(options) {
|
|
|
34
35
|
console.error(`Error processing ${fileName}: ${errMessage}`);
|
|
35
36
|
return;
|
|
36
37
|
}
|
|
37
|
-
|
|
38
|
+
// Convert the content to types
|
|
39
|
+
const [typings, context] = await schemaConverterShex(schema);
|
|
38
40
|
await Promise.all(["context", "schema", "shapeTypes", "typings"].map(async (templateName) => {
|
|
39
|
-
const finalContent = await
|
|
41
|
+
const finalContent = await renderFile(path.join(__dirname, "./templates", `${templateName}.ejs`), {
|
|
40
42
|
typings: typings.typings,
|
|
41
43
|
fileName,
|
|
42
44
|
schema: JSON.stringify(schema, null, 2),
|
|
43
45
|
context: JSON.stringify(context, null, 2),
|
|
44
46
|
});
|
|
45
|
-
|
|
47
|
+
// Save conversion to document
|
|
48
|
+
await fs.promises.writeFile(path.join(options.output, `${fileName}.${templateName}.ts`), await prettier.format(finalContent, { parser: "typescript" }));
|
|
46
49
|
}));
|
|
47
50
|
});
|
|
48
51
|
load.stop();
|
|
49
52
|
}
|
|
50
|
-
exports.build = build;
|
|
51
53
|
//# sourceMappingURL=build.js.map
|
package/dist/build.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build.js","sourceRoot":"","sources":["../src/build.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"build.js","sourceRoot":"","sources":["../src/build.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,UAAU,CAAC;AAC1B,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,MAAM,MAAM,gBAAgB,CAAC;AACpC,OAAO,mBAAmB,MAAM,4BAA4B,CAAC;AAC7D,OAAO,EAAE,UAAU,EAAE,MAAM,KAAK,CAAC;AACjC,OAAO,QAAQ,MAAM,UAAU,CAAC;AAChC,OAAO,OAAO,MAAM,aAAa,CAAC;AAClC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAEtD,6D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CAAC,MAAM,CAAC,CAAC;QAC7D,MAAM,OAAO,CAAC,GAAG,CACf,CAAC,SAAS,EAAE,QAAQ,EAAE,YAAY,EAAE,SAAS,CAAC,CAAC,GAAG,CAChD,KAAK,EAAE,YAAY,EAAE,EAAE;YACrB,MAAM,YAAY,GAAG,MAAM,UAAU,CACnC,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,aAAa,EAAE,GAAG,YAAY,MAAM,CAAC,EAC1D;gBACE,OAAO,EAAE,OAAO,CAAC,OAAO;gBACxB,QAAQ;gBACR,MAAM,EAAE,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC;gBACvC,OAAO,EAAE,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC;aAC1C,CACF,CAAC;YACF,8BAA8B;YAC9B,MAAM,EAAE,CAAC,QAAQ,CAAC,SAAS,CACzB,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,GAAG,QAAQ,IAAI,YAAY,KAAK,CAAC,EAC3D,MAAM,QAAQ,CAAC,MAAM,CAAC,YAAY,EAAE,EAAE,MAAM,EAAE,YAAY,EAAE,CAAC,CAC9D,CAAC;QACJ,CAAC,CACF,CACF,CAAC;IACJ,CAAC,CAAC,CAAC;IAEH,IAAI,CAAC,IAAI,EAAE,CAAC;AACd,CAAC"}
|
package/dist/create.d.ts
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create.d.ts","sourceRoot":"","sources":["../src/create.ts"],"names":[],"mappings":"AAkBA,wBAAsB,MAAM,CAAC,SAAS,EAAE,MAAM,iBAoG7C"}
|
package/dist/create.js
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
const responses = await (
|
|
1
|
+
import { init } from "./init.js";
|
|
2
|
+
import { modifyPackageJson, savePackageJson, } from "./util/modifyPackageJson.js";
|
|
3
|
+
import { generateReadme } from "./generateReadme.js";
|
|
4
|
+
import path from "path";
|
|
5
|
+
import prompts from "prompts";
|
|
6
|
+
import loading from "loading-cli";
|
|
7
|
+
import { promises as fs } from "fs";
|
|
8
|
+
import { dirname } from "node:path";
|
|
9
|
+
import { fileURLToPath } from "node:url";
|
|
10
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
11
|
+
// @ts-ignore
|
|
12
|
+
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
13
|
+
export async function create(directory) {
|
|
14
|
+
// Init the NPM Package
|
|
15
|
+
const responses = await prompts([
|
|
16
16
|
{
|
|
17
17
|
type: "text",
|
|
18
18
|
name: "name",
|
|
19
19
|
message: "Package name:",
|
|
20
|
-
initial:
|
|
20
|
+
initial: path.basename(directory),
|
|
21
21
|
},
|
|
22
22
|
{
|
|
23
23
|
type: "text",
|
|
@@ -53,7 +53,7 @@ async function create(directory) {
|
|
|
53
53
|
message: "Git repository (optional):",
|
|
54
54
|
},
|
|
55
55
|
]);
|
|
56
|
-
const load = (
|
|
56
|
+
const load = loading("Generating package.json");
|
|
57
57
|
const packageJson = {
|
|
58
58
|
name: responses.name,
|
|
59
59
|
version: responses.version,
|
|
@@ -73,10 +73,12 @@ async function create(directory) {
|
|
|
73
73
|
};
|
|
74
74
|
packageJson.homepage = `${responses.repository.replace(/\.git$/, "")}#readme`;
|
|
75
75
|
}
|
|
76
|
-
await
|
|
76
|
+
await savePackageJson(directory, packageJson);
|
|
77
|
+
// Init LDO
|
|
77
78
|
load.text = "Initializing LDO";
|
|
78
|
-
await
|
|
79
|
-
|
|
79
|
+
await init(directory);
|
|
80
|
+
// Add prepublish script
|
|
81
|
+
await modifyPackageJson(directory, async (packageJson) => {
|
|
80
82
|
if (!packageJson.scripts)
|
|
81
83
|
packageJson.scripts = {};
|
|
82
84
|
packageJson.scripts.prepublish =
|
|
@@ -84,15 +86,16 @@ async function create(directory) {
|
|
|
84
86
|
packageJson.scripts["generate-readme"] = `ldo generate-readme --project ./ --shapes ./.shapes --ldo ./.ldo`;
|
|
85
87
|
return packageJson;
|
|
86
88
|
});
|
|
89
|
+
// Generate ReadMe
|
|
87
90
|
load.text = "Generating README";
|
|
88
|
-
await
|
|
91
|
+
await generateReadme({
|
|
89
92
|
project: directory,
|
|
90
|
-
shapes:
|
|
91
|
-
ldo:
|
|
93
|
+
shapes: path.join(directory, ".shapes"),
|
|
94
|
+
ldo: path.join(directory, ".ldo"),
|
|
92
95
|
});
|
|
96
|
+
// Create .gitignore
|
|
93
97
|
load.text = "Create .gitignore";
|
|
94
|
-
await
|
|
98
|
+
await fs.writeFile(path.join(directory, ".gitignore"), "node_modules");
|
|
95
99
|
load.stop();
|
|
96
100
|
}
|
|
97
|
-
exports.create = create;
|
|
98
101
|
//# sourceMappingURL=create.js.map
|
package/dist/create.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create.js","sourceRoot":"","sources":["../src/create.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"create.js","sourceRoot":"","sources":["../src/create.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EACL,iBAAiB,EACjB,eAAe,GAChB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,OAAO,MAAM,SAAS,CAAC;AAE9B,OAAO,OAAO,MAAM,aAAa,CAAC;AAClC,OAAO,EAAE,QAAQ,IAAI,EAAE,EAAE,MAAM,IAAI,CAAC;AACpC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,aAAa,EAAE,MAA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ACpB,IAAI,CAAC,IAAI,GAAG,mBAAmB,CAAC;IAChC,MAAM,EAAE,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,YAAY,CAAC,EAAE,cAAc,CAAC,CAAC;IAEvE,IAAI,CAAC,IAAI,EAAE,CAAC;AACd,CAAC"}
|
package/dist/generateReadme.d.ts
CHANGED
|
@@ -4,8 +4,12 @@ interface GenerateReadmeOptions {
|
|
|
4
4
|
ldo: string;
|
|
5
5
|
}
|
|
6
6
|
export declare function generateReadme(options: GenerateReadmeOptions): Promise<void>;
|
|
7
|
+
/**
|
|
8
|
+
* Generate Index
|
|
9
|
+
*/
|
|
7
10
|
interface GenerateIndexOptions {
|
|
8
11
|
project: string;
|
|
9
12
|
}
|
|
10
13
|
export declare function generateIndex(options: GenerateIndexOptions): Promise<void>;
|
|
11
14
|
export {};
|
|
15
|
+
//# sourceMappingURL=generateReadme.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generateReadme.d.ts","sourceRoot":"","sources":["../src/generateReadme.ts"],"names":[],"mappings":"AAaA,UAAU,qBAAqB;IAC7B,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,GAAG,EAAE,MAAM,CAAC;CACb;AAgBD,wBAAsB,cAAc,CAAC,OAAO,EAAE,qBAAqB,iBA2ClE;AAcD;;GAEG;AACH,UAAU,oBAAoB;IAC5B,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,wBAAsB,aAAa,CAAC,OAAO,EAAE,oBAAoB,iBAShE"}
|
package/dist/generateReadme.js
CHANGED
|
@@ -1,23 +1,22 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
const packageJson = await (0, modifyPackageJson_1.getPackageJson)(options.project);
|
|
1
|
+
import { getPackageJson } from "./util/modifyPackageJson.js";
|
|
2
|
+
import { forAllShapes } from "./util/forAllShapes.js";
|
|
3
|
+
import { promises as fs } from "fs";
|
|
4
|
+
import path from "path";
|
|
5
|
+
import { Project } from "ts-morph";
|
|
6
|
+
import { renderFile } from "ejs";
|
|
7
|
+
import { dirname } from "node:path";
|
|
8
|
+
import { fileURLToPath } from "node:url";
|
|
9
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
10
|
+
// @ts-ignore
|
|
11
|
+
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
12
|
+
export async function generateReadme(options) {
|
|
13
|
+
const packageJson = await getPackageJson(options.project);
|
|
15
14
|
const projectName = packageJson.name;
|
|
16
15
|
const projectDescription = packageJson.description;
|
|
17
16
|
const shapes = [];
|
|
18
|
-
await
|
|
19
|
-
const typeFilePath =
|
|
20
|
-
const typesRaw = await
|
|
17
|
+
await forAllShapes(options.shapes, async (fileName, shexC) => {
|
|
18
|
+
const typeFilePath = path.join(options.ldo, `${fileName}.typings.ts`);
|
|
19
|
+
const typesRaw = await fs.readFile(typeFilePath, "utf8");
|
|
21
20
|
const shape = {
|
|
22
21
|
name: fileName,
|
|
23
22
|
shex: shexC,
|
|
@@ -37,23 +36,27 @@ async function generateReadme(options) {
|
|
|
37
36
|
projectDescription,
|
|
38
37
|
shapes,
|
|
39
38
|
};
|
|
40
|
-
|
|
41
|
-
await
|
|
39
|
+
// Save Readme
|
|
40
|
+
const finalContent = await renderFile(path.join(__dirname, "./templates/readme/", "main.ejs"), readmeEjsOptions);
|
|
41
|
+
// Save readme to document
|
|
42
|
+
await fs.writeFile(path.join(options.project, "README.md"), finalContent);
|
|
42
43
|
await generateIndex({ project: options.project });
|
|
43
44
|
}
|
|
44
|
-
|
|
45
|
+
/**
|
|
46
|
+
* Helper Function that lists all the interfaces in a typescript file
|
|
47
|
+
*/
|
|
45
48
|
function listInterfaces(filePath) {
|
|
46
|
-
const project = new
|
|
49
|
+
const project = new Project();
|
|
47
50
|
const sourceFile = project.addSourceFileAtPath(filePath);
|
|
51
|
+
// Get all interfaces in the file
|
|
48
52
|
const interfaces = sourceFile.getInterfaces().map((iface) => iface.getName());
|
|
49
53
|
return interfaces;
|
|
50
54
|
}
|
|
51
|
-
async function generateIndex(options) {
|
|
52
|
-
const ldoDir = await
|
|
55
|
+
export async function generateIndex(options) {
|
|
56
|
+
const ldoDir = await fs.readdir(path.join(options.project, "./.ldo"), {
|
|
53
57
|
withFileTypes: true,
|
|
54
58
|
});
|
|
55
|
-
const indexText = await
|
|
56
|
-
await
|
|
59
|
+
const indexText = await renderFile(path.join(__dirname, "./templates/readme/projectIndex.ejs"), { fileNames: ldoDir.map((file) => file.name) });
|
|
60
|
+
await fs.writeFile(path.join(options.project, "index.js"), indexText);
|
|
57
61
|
}
|
|
58
|
-
exports.generateIndex = generateIndex;
|
|
59
62
|
//# sourceMappingURL=generateReadme.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generateReadme.js","sourceRoot":"","sources":["../src/generateReadme.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"generateReadme.js","sourceRoot":"","sources":["../src/generateReadme.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAC7D,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AACtD,OAAO,EAAE,QAAQ,IAAI,EAAE,EAAE,MAAM,IAAI,CAAC;AACpC,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AACnC,OAAO,EAAE,UAAU,EAAE,MAAM,KAAK,CAAC;AACjC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzC,6DAA6D;AAC7D,aAAa;AACb,MAAM,SAAS,GAAG,OAAO,CAAC,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ceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":""}
|
package/dist/index.js
CHANGED
|
@@ -1,37 +1,35 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
const generateReadme_1 = require("./generateReadme");
|
|
9
|
-
commander_1.program
|
|
2
|
+
import { program } from "commander";
|
|
3
|
+
import { build } from "./build.js";
|
|
4
|
+
import { init } from "./init.js";
|
|
5
|
+
import { create } from "./create.js";
|
|
6
|
+
import { generateReadme } from "./generateReadme.js";
|
|
7
|
+
program
|
|
10
8
|
.name("LDO-CLI")
|
|
11
9
|
.description("CLI to some JavaScript string utilities")
|
|
12
10
|
.version("3.0.1");
|
|
13
|
-
|
|
11
|
+
program
|
|
14
12
|
.command("build")
|
|
15
13
|
.description("Build contents of a shex folder into Shape Types")
|
|
16
14
|
.option("-i, --input <inputPath>", "Provide the input path", "./.shapes")
|
|
17
15
|
.option("-o, --output <outputPath>", "Provide the output path", "./.ldo")
|
|
18
|
-
.action(
|
|
19
|
-
|
|
16
|
+
.action(build);
|
|
17
|
+
program
|
|
20
18
|
.command("init")
|
|
21
19
|
.argument("[directory]", "A parent directory for ldo files")
|
|
22
20
|
.description("Initializes a project for LDO.")
|
|
23
|
-
.action(
|
|
24
|
-
|
|
21
|
+
.action(init);
|
|
22
|
+
program
|
|
25
23
|
.command("create")
|
|
26
24
|
.argument("<directory>", "The package's directory")
|
|
27
25
|
.description("Creates a standalone package for shapes to publish to NPM.")
|
|
28
|
-
.action(
|
|
29
|
-
|
|
26
|
+
.action(create);
|
|
27
|
+
program
|
|
30
28
|
.command("generate-readme")
|
|
31
29
|
.description("Create a ReadMe from the shapes and generated code.")
|
|
32
30
|
.requiredOption("-p, --project <projectPath>", "Provide the path to the root project", "./")
|
|
33
31
|
.requiredOption("-s, --shapes <shapesPath>", "Provide the path to the shapes folder", "./.shapes")
|
|
34
32
|
.requiredOption("-s, --ldo <ldoPath>", "Provide the path to the ldo folder", "./.ldo")
|
|
35
|
-
.action(
|
|
36
|
-
|
|
33
|
+
.action(generateReadme);
|
|
34
|
+
program.parse();
|
|
37
35
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACnC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAErD,OAAO;KACJ,IAAI,CAAC,SAAS,CAAC;KACf,WAAW,CAAC,yCAAyC,CAAC;KACtD,OAAO,CAAC,OAAO,CAAC,CAAC;AAEpB,OAAO;KACJ,OAAO,CAAC,OAAO,CAAC;KAChB,WAAW,CAAC,kDAAkD,CAAC;KAC/D,MAAM,CAAC,yBAAyB,EAAE,wBAAwB,EAAE,WAAW,CAAC;KACxE,MAAM,CAAC,2BAA2B,EAAE,yBAAyB,EAAE,QAAQ,CAAC;KACxE,MAAM,CAAC,KAAK,CAAC,CAAC;AAEjB,OAAO;KACJ,OAAO,CAAC,MAAM,CAAC;KACf,QAAQ,CAAC,aAAa,EAAE,kCAAkC,CAAC;KAC3D,WAAW,CAAC,gCAAgC,CAAC;KAC7C,MAAM,CAAC,IAAI,CAAC,CAAC;AAEhB,OAAO;KACJ,OAAO,CAAC,QAAQ,CAAC;KACjB,QAAQ,CAAC,aAAa,EAAE,yBAAyB,CAAC;KAClD,WAAW,CAAC,4DAA4D,CAAC;KACzE,MAAM,CAAC,MAAM,CAAC,CAAC;AAElB,OAAO;KACJ,OAAO,CAAC,iBAAiB,CAAC;KAC1B,WAAW,CAAC,qDAAqD,CAAC;KAClE,cAAc,CACb,6BAA6B,EAC7B,sCAAsC,EACtC,IAAI,CACL;KACA,cAAc,CACb,2BAA2B,EAC3B,uCAAuC,EACvC,WAAW,CACZ;KACA,cAAc,CACb,qBAAqB,EACrB,oCAAoC,EACpC,QAAQ,CACT;KACA,MAAM,CAAC,cAAc,CAAC,CAAC;AAE1B,OAAO,CAAC,KAAK,EAAE,CAAC"}
|
package/dist/init.d.ts
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../src/init.ts"],"names":[],"mappings":"AAgBA,wBAAsB,IAAI,CAAC,SAAS,CAAC,EAAE,MAAM,iBA6D5C"}
|
package/dist/init.js
CHANGED
|
@@ -1,49 +1,52 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
};
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
const
|
|
11
|
-
const modifyPackageJson_1 = require("./util/modifyPackageJson");
|
|
1
|
+
import { exec } from "child-process-promise";
|
|
2
|
+
import fs from "fs-extra";
|
|
3
|
+
import path from "path";
|
|
4
|
+
import { renderFile } from "ejs";
|
|
5
|
+
import { modifyPackageJson } from "./util/modifyPackageJson.js";
|
|
6
|
+
import { dirname } from "node:path";
|
|
7
|
+
import { fileURLToPath } from "node:url";
|
|
8
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
9
|
+
// @ts-ignore
|
|
10
|
+
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
12
11
|
const DEFAULT_SHAPES_FOLDER = "./.shapes";
|
|
13
12
|
const DEFAULT_LDO_FOLDER = "./.ldo";
|
|
14
13
|
const POTENTIAL_PARENT_DIRECTORIES = ["src", "lib", "bin"];
|
|
15
|
-
async function init(directory) {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
14
|
+
export async function init(directory) {
|
|
15
|
+
// Find folder to save to
|
|
16
|
+
const projectDirectory = directory ?? "./";
|
|
17
|
+
// Get the parent directory for the ldo files
|
|
18
|
+
let parentDirectory = projectDirectory;
|
|
19
|
+
parentDirectory = "./";
|
|
20
|
+
const allDirectories = (await fs.promises.readdir("./", {
|
|
21
|
+
withFileTypes: true,
|
|
22
|
+
})).filter((file) => file.isDirectory());
|
|
23
|
+
for (let i = 0; i < POTENTIAL_PARENT_DIRECTORIES.length; i++) {
|
|
24
|
+
if (allDirectories.some((dir) => dir.name === POTENTIAL_PARENT_DIRECTORIES[i])) {
|
|
25
|
+
parentDirectory = POTENTIAL_PARENT_DIRECTORIES[i];
|
|
26
|
+
break;
|
|
27
27
|
}
|
|
28
28
|
}
|
|
29
|
-
|
|
30
|
-
await
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
const
|
|
29
|
+
// Install dependencies
|
|
30
|
+
await exec(`cd ${projectDirectory} && npm install @ldo/ldo --save`);
|
|
31
|
+
await exec(`cd ${projectDirectory} && npm install @ldo/cli @types/shexj @types/jsonld --save-dev`);
|
|
32
|
+
// Create "shapes" folder
|
|
33
|
+
const shapesFolderPath = path.join(parentDirectory, DEFAULT_SHAPES_FOLDER);
|
|
34
|
+
await fs.promises.mkdir(shapesFolderPath);
|
|
35
|
+
const defaultShapePaths = await fs.promises.readdir(path.join(__dirname, "./templates/defaultShapes"));
|
|
34
36
|
await Promise.all(defaultShapePaths.map(async (shapePath) => {
|
|
35
|
-
const shapeContent = await
|
|
36
|
-
await
|
|
37
|
+
const shapeContent = await renderFile(path.join(__dirname, "./templates/defaultShapes", shapePath), {});
|
|
38
|
+
await fs.promises.writeFile(path.join(shapesFolderPath, `${path.parse(shapePath).name}.shex`), shapeContent);
|
|
37
39
|
}));
|
|
38
|
-
|
|
40
|
+
// Add build script
|
|
41
|
+
await modifyPackageJson("./", async (packageJson) => {
|
|
39
42
|
if (!packageJson.scripts) {
|
|
40
43
|
packageJson.scripts = {};
|
|
41
44
|
}
|
|
42
|
-
const ldoFolder =
|
|
43
|
-
packageJson.scripts["build:ldo"] = `ldo build --input ${
|
|
45
|
+
const ldoFolder = path.join(parentDirectory, DEFAULT_LDO_FOLDER);
|
|
46
|
+
packageJson.scripts["build:ldo"] = `ldo build --input ${path.relative(projectDirectory, shapesFolderPath)} --output ${path.relative(projectDirectory, ldoFolder)}`;
|
|
44
47
|
return packageJson;
|
|
45
48
|
});
|
|
46
|
-
|
|
49
|
+
// Build LDO
|
|
50
|
+
await exec(`cd ${projectDirectory} && npm run build:ldo`);
|
|
47
51
|
}
|
|
48
|
-
exports.init = init;
|
|
49
52
|
//# sourceMappingURL=init.js.map
|
package/dist/init.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"init.js","sourceRoot":"","sources":["../src/init.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"init.js","sourceRoot":"","sources":["../src/init.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,uBAAuB,CAAC;AAC7C,OAAO,EAAE,MAAM,UAAU,CAAC;AAC1B,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,UAAU,EAAE,MAAM,KAAK,CAAC;AACjC,OAAO,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzC,6DAA6D;AAC7D,aAAa;AACb,MAAM,SAAS,GAAG,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;AAE1D,MAAM,qBAAqB,GAAG,WAAW,CAAC;AAC1C,MAAM,kBA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AAE,MAAM,EAAE,KAAK,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,GAC3D,OAAO,CAAC,IAAI,CAAC,CAmBf"}
|
|
@@ -1,21 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.forAllShapes = void 0;
|
|
7
|
-
const fs_1 = __importDefault(require("fs"));
|
|
8
|
-
const path_1 = __importDefault(require("path"));
|
|
9
|
-
async function forAllShapes(shapePath, callback) {
|
|
10
|
-
const shapeDir = await fs_1.default.promises.readdir(shapePath, {
|
|
1
|
+
import fs from "fs";
|
|
2
|
+
import path from "path";
|
|
3
|
+
export async function forAllShapes(shapePath, callback) {
|
|
4
|
+
const shapeDir = await fs.promises.readdir(shapePath, {
|
|
11
5
|
withFileTypes: true,
|
|
12
6
|
});
|
|
7
|
+
// Filter out non-shex documents
|
|
13
8
|
const shexFiles = shapeDir.filter((file) => file.isFile() && file.name.endsWith(".shex"));
|
|
14
9
|
await Promise.all(shexFiles.map(async (file) => {
|
|
15
|
-
const fileName =
|
|
16
|
-
|
|
10
|
+
const fileName = path.parse(file.name).name;
|
|
11
|
+
// Get the content of each document
|
|
12
|
+
const shexC = await fs.promises.readFile(path.join(shapePath, file.name), "utf8");
|
|
17
13
|
await callback(fileName, shexC);
|
|
18
14
|
}));
|
|
19
15
|
}
|
|
20
|
-
exports.forAllShapes = forAllShapes;
|
|
21
16
|
//# sourceMappingURL=forAllShapes.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"forAllShapes.js","sourceRoot":"","sources":["../../src/util/forAllShapes.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"forAllShapes.js","sourceRoot":"","sources":["../../src/util/forAllShapes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,MAAM,CAAC,KAAK,UAAU,YAAY,CAChC,SAAiB,EACjB,QAA4D;IAE5D,MAAM,QAAQ,GAAG,MAAM,EAAE,CAAC,QAAQ,CAAC,OAAO,CAAC,SAAS,EAAE;QACpD,aAAa,EAAE,IAAI;KACpB,CAAC,CAAC;IACH,gCAAgC;IAChC,MAAM,SAAS,GAAG,QAAQ,CAAC,MAAM,CAC/B,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,CACvD,CAAC;IACF,MAAM,OAAO,CAAC,GAAG,CACf,SAAS,CAAC,GAAG,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE;QAC3B,MAAM,QAAQ,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC;QAC5C,mCAAmC;QACnC,MAAM,KAAK,GAAG,MAAM,EAAE,CAAC,QAAQ,CAAC,QAAQ,CACtC,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,IAAI,CAAC,EAC/B,MAAM,CACP,CAAC;QACF,MAAM,QAAQ,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC;IAClC,CAAC,CAAC,CACH,CAAC;AACJ,CAAC"}
|
|
@@ -2,3 +2,4 @@ import type { PackageJson } from "type-fest";
|
|
|
2
2
|
export declare function getPackageJson(projectFolder: string): Promise<PackageJson>;
|
|
3
3
|
export declare function savePackageJson(projectFolder: string, packageJson: PackageJson): Promise<void>;
|
|
4
4
|
export declare function modifyPackageJson(projectFolder: string, modifyCallback: (packageJson: PackageJson) => Promise<PackageJson>): Promise<void>;
|
|
5
|
+
//# sourceMappingURL=modifyPackageJson.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"modifyPackageJson.d.ts","sourceRoot":"","sources":["../../src/util/modifyPackageJson.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAI7C,wBAAsB,cAAc,CAClC,aAAa,EAAE,MAAM,GACpB,OAAO,CAAC,WAAW,CAAC,CAMtB;AAED,wBAAsB,eAAe,CACnC,aAAa,EAAE,MAAM,EACrB,WAAW,EAAE,WAAW,GACvB,OAAO,CAAC,IAAI,CAAC,CAMf;AAED,wBAAsB,iBAAiB,CACrC,aAAa,EAAE,MAAM,EACrB,cAAc,EAAE,CAAC,WAAW,EAAE,WAAW,KAAK,OAAO,CAAC,WAAW,CAAC,GACjE,OAAO,CAAC,IAAI,CAAC,CAIf"}
|
|
@@ -1,24 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.modifyPackageJson = exports.savePackageJson = exports.getPackageJson = void 0;
|
|
7
|
-
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
8
|
-
const path_1 = __importDefault(require("path"));
|
|
9
|
-
async function getPackageJson(projectFolder) {
|
|
10
|
-
return JSON.parse((await fs_extra_1.default.promises.readFile(path_1.default.join(projectFolder, "./package.json"))).toString());
|
|
1
|
+
import fs from "fs-extra";
|
|
2
|
+
import path from "path";
|
|
3
|
+
export async function getPackageJson(projectFolder) {
|
|
4
|
+
return JSON.parse((await fs.promises.readFile(path.join(projectFolder, "./package.json"))).toString());
|
|
11
5
|
}
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
await
|
|
15
|
-
await fs_extra_1.default.promises.writeFile(path_1.default.join(projectFolder, "./package.json"), JSON.stringify(packageJson, null, 2));
|
|
6
|
+
export async function savePackageJson(projectFolder, packageJson) {
|
|
7
|
+
await fs.promises.mkdir(projectFolder, { recursive: true });
|
|
8
|
+
await fs.promises.writeFile(path.join(projectFolder, "./package.json"), JSON.stringify(packageJson, null, 2));
|
|
16
9
|
}
|
|
17
|
-
|
|
18
|
-
async function modifyPackageJson(projectFolder, modifyCallback) {
|
|
10
|
+
export async function modifyPackageJson(projectFolder, modifyCallback) {
|
|
19
11
|
const packageJson = await getPackageJson(projectFolder);
|
|
20
12
|
const newPackageJson = await modifyCallback(packageJson);
|
|
21
13
|
await savePackageJson(projectFolder, newPackageJson);
|
|
22
14
|
}
|
|
23
|
-
exports.modifyPackageJson = modifyPackageJson;
|
|
24
15
|
//# sourceMappingURL=modifyPackageJson.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"modifyPackageJson.js","sourceRoot":"","sources":["../../src/util/modifyPackageJson.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"modifyPackageJson.js","sourceRoot":"","sources":["../../src/util/modifyPackageJson.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,UAAU,CAAC;AAC1B,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,MAAM,CAAC,KAAK,UAAU,cAAc,CAClC,aAAqB;IAErB,OAAO,IAAI,CAAC,KAAK,CACf,CACE,MAAM,EAAE,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,aAAa,EAAE,gBAAgB,CAAC,CAAC,CACvE,CAAC,QAAQ,EAAE,CACb,CAAC;AACJ,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,eAAe,CACnC,aAAqB,EACrB,WAAwB;IAExB,MAAM,EAAE,CAAC,QAAQ,CAAC,KAAK,CAAC,aAAa,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IAC5D,MAAM,EAAE,CAAC,QAAQ,CAAC,SAAS,CACzB,IAAI,CAAC,IAAI,CAAC,aAAa,EAAE,gBAAgB,CAAC,EAC1C,IAAI,CAAC,SAAS,CAAC,WAAW,EAAE,IAAI,EAAE,CAAC,CAAC,CACrC,CAAC;AACJ,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,iBAAiB,CACrC,aAAqB,EACrB,cAAkE;IAElE,MAAM,WAAW,GAAgB,MAAM,cAAc,CAAC,aAAa,CAAC,CAAC;IACrE,MAAM,cAAc,GAAG,MAAM,cAAc,CAAC,WAAW,CAAC,CAAC;IACzD,MAAM,eAAe,CAAC,aAAa,EAAE,cAAc,CAAC,CAAC;AACvD,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,35 +1,35 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ldo/cli",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.21",
|
|
4
4
|
"description": "A Command Line Interface for Linked Data Objects",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
|
+
"type": "module",
|
|
6
7
|
"bin": {
|
|
7
8
|
"ldo": "./dist/index.js"
|
|
8
9
|
},
|
|
9
10
|
"scripts": {
|
|
10
11
|
"build": "npm run clean && npm run build:ts && npm run copy-files && npm run update-permission",
|
|
11
|
-
"build:ts": "tsc --project tsconfig.
|
|
12
|
+
"build:ts": "tsc --project tsconfig.cjs.json",
|
|
12
13
|
"clean": "rimraf dist/",
|
|
13
14
|
"copy-files": "copyfiles -u 1 \"./src/**/*.ejs\" dist/",
|
|
14
15
|
"update-permission": "chmod +x ./dist/index.js",
|
|
15
16
|
"test": "jest --coverage",
|
|
16
|
-
"prepublishOnly": "
|
|
17
|
+
"prepublishOnly": " npm run build",
|
|
17
18
|
"lint": "eslint src/** --fix --no-error-on-unmatched-pattern",
|
|
18
19
|
"test:init": "rm -rf ./example-init && cp -R ./example-init-placeholder ./example-init && cd ./example-init && ../dist/index.js init",
|
|
19
20
|
"test:create": "rm -rf ./example-create && ./dist/index.js create ./example-create"
|
|
20
21
|
},
|
|
21
22
|
"repository": {
|
|
22
23
|
"type": "git",
|
|
23
|
-
"url": "git+https://github.com/o-development/
|
|
24
|
+
"url": "git+https://github.com/o-development/ldo.git"
|
|
24
25
|
},
|
|
25
26
|
"author": "Jackson Morgan",
|
|
26
27
|
"license": "MIT",
|
|
27
28
|
"bugs": {
|
|
28
|
-
"url": "https://github.com/o-development/
|
|
29
|
+
"url": "https://github.com/o-development/ldo/issues"
|
|
29
30
|
},
|
|
30
|
-
"homepage": "https://github.com/o-development/
|
|
31
|
+
"homepage": "https://github.com/o-development/ldo/tree/main/packages/cli#readme",
|
|
31
32
|
"devDependencies": {
|
|
32
|
-
"@ldo/cli": "^0.0.1-alpha.28",
|
|
33
33
|
"@types/child-process-promise": "^2.2.2",
|
|
34
34
|
"@types/ejs": "^3.1.1",
|
|
35
35
|
"@types/fs-extra": "^9.0.13",
|
|
@@ -40,8 +40,8 @@
|
|
|
40
40
|
"rimraf": "^3.0.2"
|
|
41
41
|
},
|
|
42
42
|
"dependencies": {
|
|
43
|
-
"@ldo/ldo": "^1.0.0-alpha.
|
|
44
|
-
"@ldo/schema-converter-shex": "^1.0.0-alpha.
|
|
43
|
+
"@ldo/ldo": "^1.0.0-alpha.21",
|
|
44
|
+
"@ldo/schema-converter-shex": "^1.0.0-alpha.21",
|
|
45
45
|
"@shexjs/parser": "^1.0.0-alpha.24",
|
|
46
46
|
"child-process-promise": "^2.2.1",
|
|
47
47
|
"commander": "^9.3.0",
|
|
@@ -60,5 +60,5 @@
|
|
|
60
60
|
"publishConfig": {
|
|
61
61
|
"access": "public"
|
|
62
62
|
},
|
|
63
|
-
"gitHead": "
|
|
63
|
+
"gitHead": "1a85b65e4e84bb1f1322a6de4fdc6d5bf649ddfd"
|
|
64
64
|
}
|
package/src/build.ts
CHANGED
|
@@ -6,7 +6,13 @@ import schemaConverterShex from "@ldo/schema-converter-shex";
|
|
|
6
6
|
import { renderFile } from "ejs";
|
|
7
7
|
import prettier from "prettier";
|
|
8
8
|
import loading from "loading-cli";
|
|
9
|
-
import {
|
|
9
|
+
import { dirname } from "node:path";
|
|
10
|
+
import { fileURLToPath } from "node:url";
|
|
11
|
+
import { forAllShapes } from "./util/forAllShapes.js";
|
|
12
|
+
|
|
13
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
14
|
+
// @ts-ignore
|
|
15
|
+
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
10
16
|
|
|
11
17
|
interface BuildOptions {
|
|
12
18
|
input: string;
|
|
@@ -14,7 +20,7 @@ interface BuildOptions {
|
|
|
14
20
|
}
|
|
15
21
|
|
|
16
22
|
export async function build(options: BuildOptions) {
|
|
17
|
-
const load = loading("
|
|
23
|
+
const load = loading("Preparing Environment");
|
|
18
24
|
load.start();
|
|
19
25
|
// Prepare new folder by clearing/and/or creating it
|
|
20
26
|
if (fs.existsSync(options.output)) {
|
package/src/create.ts
CHANGED
|
@@ -1,12 +1,20 @@
|
|
|
1
|
-
import { init } from "./init";
|
|
2
|
-
import {
|
|
3
|
-
|
|
1
|
+
import { init } from "./init.js";
|
|
2
|
+
import {
|
|
3
|
+
modifyPackageJson,
|
|
4
|
+
savePackageJson,
|
|
5
|
+
} from "./util/modifyPackageJson.js";
|
|
6
|
+
import { generateReadme } from "./generateReadme.js";
|
|
4
7
|
import path from "path";
|
|
5
8
|
import prompts from "prompts";
|
|
6
9
|
import type { PackageJson } from "type-fest";
|
|
7
10
|
import loading from "loading-cli";
|
|
8
11
|
import { promises as fs } from "fs";
|
|
9
|
-
import {
|
|
12
|
+
import { dirname } from "node:path";
|
|
13
|
+
import { fileURLToPath } from "node:url";
|
|
14
|
+
|
|
15
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
16
|
+
// @ts-ignore
|
|
17
|
+
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
10
18
|
|
|
11
19
|
export async function create(directory: string) {
|
|
12
20
|
// Init the NPM Package
|
package/src/generateReadme.ts
CHANGED
|
@@ -1,9 +1,15 @@
|
|
|
1
|
-
import { getPackageJson } from "./util/modifyPackageJson";
|
|
2
|
-
import { forAllShapes } from "./util/forAllShapes";
|
|
1
|
+
import { getPackageJson } from "./util/modifyPackageJson.js";
|
|
2
|
+
import { forAllShapes } from "./util/forAllShapes.js";
|
|
3
3
|
import { promises as fs } from "fs";
|
|
4
4
|
import path from "path";
|
|
5
5
|
import { Project } from "ts-morph";
|
|
6
6
|
import { renderFile } from "ejs";
|
|
7
|
+
import { dirname } from "node:path";
|
|
8
|
+
import { fileURLToPath } from "node:url";
|
|
9
|
+
|
|
10
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
11
|
+
// @ts-ignore
|
|
12
|
+
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
7
13
|
|
|
8
14
|
interface GenerateReadmeOptions {
|
|
9
15
|
project: string;
|
package/src/index.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
3
|
import { program } from "commander";
|
|
4
|
-
import { build } from "./build";
|
|
5
|
-
import { init } from "./init";
|
|
6
|
-
import { create } from "./create";
|
|
7
|
-
import { generateReadme } from "./generateReadme";
|
|
4
|
+
import { build } from "./build.js";
|
|
5
|
+
import { init } from "./init.js";
|
|
6
|
+
import { create } from "./create.js";
|
|
7
|
+
import { generateReadme } from "./generateReadme.js";
|
|
8
8
|
|
|
9
9
|
program
|
|
10
10
|
.name("LDO-CLI")
|
package/src/init.ts
CHANGED
|
@@ -2,7 +2,13 @@ import { exec } from "child-process-promise";
|
|
|
2
2
|
import fs from "fs-extra";
|
|
3
3
|
import path from "path";
|
|
4
4
|
import { renderFile } from "ejs";
|
|
5
|
-
import { modifyPackageJson } from "./util/modifyPackageJson";
|
|
5
|
+
import { modifyPackageJson } from "./util/modifyPackageJson.js";
|
|
6
|
+
import { dirname } from "node:path";
|
|
7
|
+
import { fileURLToPath } from "node:url";
|
|
8
|
+
|
|
9
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
10
|
+
// @ts-ignore
|
|
11
|
+
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
6
12
|
|
|
7
13
|
const DEFAULT_SHAPES_FOLDER = "./.shapes";
|
|
8
14
|
const DEFAULT_LDO_FOLDER = "./.ldo";
|
|
@@ -10,30 +16,29 @@ const POTENTIAL_PARENT_DIRECTORIES = ["src", "lib", "bin"];
|
|
|
10
16
|
|
|
11
17
|
export async function init(directory?: string) {
|
|
12
18
|
// Find folder to save to
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
}
|
|
19
|
+
const projectDirectory = directory ?? "./";
|
|
20
|
+
|
|
21
|
+
// Get the parent directory for the ldo files
|
|
22
|
+
let parentDirectory = projectDirectory;
|
|
23
|
+
parentDirectory = "./";
|
|
24
|
+
const allDirectories = (
|
|
25
|
+
await fs.promises.readdir("./", {
|
|
26
|
+
withFileTypes: true,
|
|
27
|
+
})
|
|
28
|
+
).filter((file) => file.isDirectory());
|
|
29
|
+
for (let i = 0; i < POTENTIAL_PARENT_DIRECTORIES.length; i++) {
|
|
30
|
+
if (
|
|
31
|
+
allDirectories.some((dir) => dir.name === POTENTIAL_PARENT_DIRECTORIES[i])
|
|
32
|
+
) {
|
|
33
|
+
parentDirectory = POTENTIAL_PARENT_DIRECTORIES[i];
|
|
34
|
+
break;
|
|
30
35
|
}
|
|
31
36
|
}
|
|
32
37
|
|
|
33
38
|
// Install dependencies
|
|
34
|
-
await exec(`cd ${
|
|
39
|
+
await exec(`cd ${projectDirectory} && npm install @ldo/ldo --save`);
|
|
35
40
|
await exec(
|
|
36
|
-
`cd ${
|
|
41
|
+
`cd ${projectDirectory} && npm install @ldo/cli @types/shexj @types/jsonld --save-dev`,
|
|
37
42
|
);
|
|
38
43
|
|
|
39
44
|
// Create "shapes" folder
|
|
@@ -56,18 +61,18 @@ export async function init(directory?: string) {
|
|
|
56
61
|
);
|
|
57
62
|
|
|
58
63
|
// Add build script
|
|
59
|
-
await modifyPackageJson(
|
|
64
|
+
await modifyPackageJson("./", async (packageJson) => {
|
|
60
65
|
if (!packageJson.scripts) {
|
|
61
66
|
packageJson.scripts = {};
|
|
62
67
|
}
|
|
63
68
|
const ldoFolder = path.join(parentDirectory, DEFAULT_LDO_FOLDER);
|
|
64
69
|
packageJson.scripts["build:ldo"] = `ldo build --input ${path.relative(
|
|
65
|
-
|
|
70
|
+
projectDirectory,
|
|
66
71
|
shapesFolderPath,
|
|
67
|
-
)} --output ${path.relative(
|
|
72
|
+
)} --output ${path.relative(projectDirectory, ldoFolder)}`;
|
|
68
73
|
return packageJson;
|
|
69
74
|
});
|
|
70
75
|
|
|
71
76
|
// Build LDO
|
|
72
|
-
await exec(`cd ${
|
|
77
|
+
await exec(`cd ${projectDirectory} && npm run build:ldo`);
|
|
73
78
|
}
|