@oml/cli 0.7.0
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/README.md +75 -0
- package/bin/cli.js +6 -0
- package/out/auth.d.ts +25 -0
- package/out/auth.js +253 -0
- package/out/auth.js.map +1 -0
- package/out/backend/backend-types.d.ts +19 -0
- package/out/backend/backend-types.js +3 -0
- package/out/backend/backend-types.js.map +1 -0
- package/out/backend/create-backend.d.ts +2 -0
- package/out/backend/create-backend.js +6 -0
- package/out/backend/create-backend.js.map +1 -0
- package/out/backend/direct-backend.d.ts +17 -0
- package/out/backend/direct-backend.js +97 -0
- package/out/backend/direct-backend.js.map +1 -0
- package/out/backend/reasoned-output.d.ts +38 -0
- package/out/backend/reasoned-output.js +568 -0
- package/out/backend/reasoned-output.js.map +1 -0
- package/out/cli.d.ts +1 -0
- package/out/cli.js +132 -0
- package/out/cli.js.map +1 -0
- package/out/commands/closure.d.ts +33 -0
- package/out/commands/closure.js +537 -0
- package/out/commands/closure.js.map +1 -0
- package/out/commands/compile.d.ts +11 -0
- package/out/commands/compile.js +63 -0
- package/out/commands/compile.js.map +1 -0
- package/out/commands/lint.d.ts +5 -0
- package/out/commands/lint.js +31 -0
- package/out/commands/lint.js.map +1 -0
- package/out/commands/reason.d.ts +13 -0
- package/out/commands/reason.js +62 -0
- package/out/commands/reason.js.map +1 -0
- package/out/commands/render.d.ts +15 -0
- package/out/commands/render.js +753 -0
- package/out/commands/render.js.map +1 -0
- package/out/commands/validate.d.ts +5 -0
- package/out/commands/validate.js +186 -0
- package/out/commands/validate.js.map +1 -0
- package/out/main.d.ts +1 -0
- package/out/main.js +4 -0
- package/out/main.js.map +1 -0
- package/out/update.d.ts +1 -0
- package/out/update.js +79 -0
- package/out/update.js.map +1 -0
- package/out/util.d.ts +10 -0
- package/out/util.js +63 -0
- package/out/util.js.map +1 -0
- package/package.json +36 -0
- package/src/auth.ts +315 -0
- package/src/backend/backend-types.ts +25 -0
- package/src/backend/create-backend.ts +8 -0
- package/src/backend/direct-backend.ts +114 -0
- package/src/backend/reasoned-output.ts +697 -0
- package/src/cli.ts +147 -0
- package/src/commands/closure.ts +624 -0
- package/src/commands/compile.ts +88 -0
- package/src/commands/lint.ts +35 -0
- package/src/commands/reason.ts +79 -0
- package/src/commands/render.ts +1021 -0
- package/src/commands/validate.ts +226 -0
- package/src/main.ts +5 -0
- package/src/update.ts +103 -0
- package/src/util.ts +83 -0
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
// Copyright (c) 2026 Modelware. All rights reserved.
|
|
2
|
+
import chalk from 'chalk';
|
|
3
|
+
import { createBackend } from '../backend/create-backend.js';
|
|
4
|
+
import { formatDuration } from '../util.js';
|
|
5
|
+
export const lintAction = async (fileName, opts) => {
|
|
6
|
+
const startedAt = Date.now();
|
|
7
|
+
const workspaceRoot = opts.workspace ?? opts.workspaceRoot ?? '.';
|
|
8
|
+
const backend = createBackend();
|
|
9
|
+
try {
|
|
10
|
+
const result = await backend.validate(fileName, workspaceRoot);
|
|
11
|
+
if (result.filesChecked === 0) {
|
|
12
|
+
console.log(chalk.yellow(`No .oml files found under ${workspaceRoot}.`));
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
if (fileName && result.warnings === 0) {
|
|
16
|
+
console.log(chalk.green('lint: no syntax or validation errors found.'));
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
if (result.warnings > 0) {
|
|
20
|
+
console.log(chalk.yellow(`lint: ${result.filesChecked} OML file(s) checked with ${result.warnings} warning(s). [${formatDuration(Date.now() - startedAt)}]`));
|
|
21
|
+
process.exit(1);
|
|
22
|
+
}
|
|
23
|
+
else {
|
|
24
|
+
console.log(chalk.green(`lint: ${result.filesChecked} OML file(s) checked. [${formatDuration(Date.now() - startedAt)}]`));
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
finally {
|
|
28
|
+
await backend.dispose();
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
//#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C9J,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QACpB,CAAC;aAAM,CAAC;YACJ,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,SAAS,MAAM,CAAC,YAAY,0BAA0B,cAAc,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC;QAC9H,CAAC;IACL,CAAC;YAAS,CAAC;QACP,MAAM,OAAO,CAAC,OAAO,EAAE,CAAC;IAC5B,CAAC;AACL,CAAC,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export type ReasonOptions = {
|
|
2
|
+
workspace?: string;
|
|
3
|
+
owl?: string;
|
|
4
|
+
format?: string;
|
|
5
|
+
clean?: boolean;
|
|
6
|
+
pretty?: boolean;
|
|
7
|
+
only?: boolean;
|
|
8
|
+
checkOnly?: boolean;
|
|
9
|
+
uniqueNamesAssumption?: boolean;
|
|
10
|
+
explanations?: boolean;
|
|
11
|
+
profile?: boolean;
|
|
12
|
+
};
|
|
13
|
+
export declare const reasonAction: (opts: ReasonOptions) => Promise<void>;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
// Copyright (c) 2026 Modelware. All rights reserved.
|
|
2
|
+
import { createOmlServices } from '@oml/language';
|
|
3
|
+
import chalk from 'chalk';
|
|
4
|
+
import { NodeFileSystem } from 'langium/node';
|
|
5
|
+
import { URI } from 'langium';
|
|
6
|
+
import * as fs from 'node:fs/promises';
|
|
7
|
+
import * as path from 'node:path';
|
|
8
|
+
import { buildWorkspaceDocuments, collectWorkspaceOntologyEntries, normalizeFormatExtension, OntologyInconsistencyError, reasonWorkspaceOntologies } from '../backend/reasoned-output.js';
|
|
9
|
+
import { formatDuration } from '../util.js';
|
|
10
|
+
import { compileAction, resolveCompileOutputRoot, resolveCompileWorkspaceRoot } from './compile.js';
|
|
11
|
+
export const reasonAction = async (opts) => {
|
|
12
|
+
const workspaceRoot = resolveCompileWorkspaceRoot(opts.workspace);
|
|
13
|
+
const outputRoot = resolveCompileOutputRoot(workspaceRoot, opts.owl);
|
|
14
|
+
const format = normalizeFormatExtension(opts.format);
|
|
15
|
+
if (opts.only && opts.clean) {
|
|
16
|
+
console.error(chalk.red('Cannot combine --only with --clean for reason.'));
|
|
17
|
+
process.exit(1);
|
|
18
|
+
}
|
|
19
|
+
if (!opts.only) {
|
|
20
|
+
await compileAction({
|
|
21
|
+
workspace: workspaceRoot,
|
|
22
|
+
owl: outputRoot,
|
|
23
|
+
format,
|
|
24
|
+
clean: opts.clean,
|
|
25
|
+
pretty: opts.pretty
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
const outputStat = await fs.stat(outputRoot).catch(() => undefined);
|
|
29
|
+
if (!outputStat || !outputStat.isDirectory()) {
|
|
30
|
+
console.error(chalk.red(`OWL output folder does not exist: ${outputRoot}`));
|
|
31
|
+
process.exit(1);
|
|
32
|
+
}
|
|
33
|
+
const startedAt = Date.now();
|
|
34
|
+
const servicesBundle = createOmlServices(NodeFileSystem);
|
|
35
|
+
await servicesBundle.Oml.shared.workspace.WorkspaceManager.initializeWorkspace([
|
|
36
|
+
{ uri: URI.file(workspaceRoot).toString(), name: path.basename(workspaceRoot) }
|
|
37
|
+
]);
|
|
38
|
+
const documents = await buildWorkspaceDocuments(servicesBundle.Oml, workspaceRoot, true);
|
|
39
|
+
const entries = collectWorkspaceOntologyEntries(documents, outputRoot, format);
|
|
40
|
+
let result;
|
|
41
|
+
try {
|
|
42
|
+
result = await reasonWorkspaceOntologies(entries, {
|
|
43
|
+
outputRoot,
|
|
44
|
+
format,
|
|
45
|
+
pretty: opts.pretty ?? false,
|
|
46
|
+
explanations: opts.explanations ?? true,
|
|
47
|
+
uniqueNamesAssumption: opts.uniqueNamesAssumption ?? true,
|
|
48
|
+
checkOnly: opts.checkOnly ?? false,
|
|
49
|
+
profile: opts.profile ?? false,
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
catch (error) {
|
|
53
|
+
if (error instanceof OntologyInconsistencyError) {
|
|
54
|
+
console.error(chalk.red(error.message));
|
|
55
|
+
process.exit(1);
|
|
56
|
+
}
|
|
57
|
+
throw error;
|
|
58
|
+
}
|
|
59
|
+
const action = opts.checkOnly ? 'checked in' : 'generated in';
|
|
60
|
+
console.log(chalk.green(`reason: ${result.ontologiesReasoned} ontology file(s) ${action} ${path.relative(process.cwd(), outputRoot) || outputRoot} [${formatDuration(Date.now() - startedAt)}]`));
|
|
61
|
+
};
|
|
62
|
+
//# sourceMappingURL=reason.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reason.js","sourceRoot":"","sources":["../../src/commands/reason.ts"],"names":[],"mappings":"AAAA,qDAAqD;AAErD,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAClD,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,EAAE,GAAG,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACvC,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,uBAAuB,EAAE,+BAA+B,EAAE,wBAAwB,EAAE,0BAA0B,EAAE,yBAAyB,EAAE,MAAM,+BAA+B,CAAC;AAC1L,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,wBAAwB,EAAE,2BAA2B,EAAE,MAAM,cAAc,CAAC;AAepG,MAAM,CAAC,MAAM,YAAY,GAAG,KAAK,EAAE,IAAmB,EAAiB,EAAE;IACrE,MAAM,aAAa,GAAG,2BAA2B,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;IAClE,MAAM,UAAU,GAAG,wBAAwB,CAAC,aAAa,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC;IACrE,MAAM,MAAM,GAAG,wBAAwB,CAAC,IAAI,CAA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
|
|
4
|
+
web: string;
|
|
5
|
+
owl?: string;
|
|
6
|
+
format?: string;
|
|
7
|
+
context?: string;
|
|
8
|
+
clean?: boolean;
|
|
9
|
+
only?: boolean;
|
|
10
|
+
pretty?: boolean;
|
|
11
|
+
uniqueNamesAssumption?: boolean;
|
|
12
|
+
explanations?: boolean;
|
|
13
|
+
profile?: boolean;
|
|
14
|
+
};
|
|
15
|
+
export declare const renderAction: (opts: RenderOptions) => Promise<void>;
|