@appling/cli 0.2.0 → 0.2.2
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 +13 -2
- package/out/main.js +31 -5
- package/package.json +11 -5
package/README.md
CHANGED
|
@@ -27,6 +27,7 @@ appling generate [--plan | --migrate] [files or folders...]
|
|
|
27
27
|
appling simulate reach <machine> <state> [files or folders...]
|
|
28
28
|
appling simulate actors <action> [files or folders...]
|
|
29
29
|
appling simulate risks <action> [files or folders...]
|
|
30
|
+
appling refs <qualified name | --check> [files or folders...]
|
|
30
31
|
```
|
|
31
32
|
|
|
32
33
|
Folders are searched recursively for `.appling` files. Hidden folders and `node_modules` are skipped. Without a path, the current folder is used.
|
|
@@ -90,13 +91,23 @@ paid is reachable from draft:
|
|
|
90
91
|
PaymentReceived -> paid
|
|
91
92
|
```
|
|
92
93
|
|
|
94
|
+
### refs
|
|
95
|
+
|
|
96
|
+
Prints the code references of the workspace in the current folder (`.appling/references.json`): where an element and its members are implemented, by file and line range. With `--check`, it lists every reference whose anchor line moved (`shifted`), whose file or anchor is gone (`broken`) or whose element the model no longer has (`orphaned`), and exits with 1 when there is one.
|
|
97
|
+
|
|
98
|
+
```
|
|
99
|
+
$ appling refs --check
|
|
100
|
+
../shop/sales/models.py:16-33 sales.Order: shifted from 14-31
|
|
101
|
+
1 reference(s), 1 shifted, 0 broken, 0 orphaned
|
|
102
|
+
```
|
|
103
|
+
|
|
93
104
|
## Exit codes
|
|
94
105
|
|
|
95
106
|
| Code | Meaning |
|
|
96
107
|
|---|---|
|
|
97
108
|
| 0 | No errors |
|
|
98
|
-
| 1 | `check`, `graph`, `release` or `
|
|
99
|
-
| 2 | Unknown command,
|
|
109
|
+
| 1 | `check`, `graph`, `release`, `generate` or `refs` found errors, `refs --check` found a reference that is not current, `release` found an invalid or existing version, `generate` failed, or `fmt` skipped a file with syntax errors |
|
|
110
|
+
| 2 | Unknown command, `release` without a version, or `refs` without a qualified name or `--check` |
|
|
100
111
|
|
|
101
112
|
## License
|
|
102
113
|
|
package/out/main.js
CHANGED
|
@@ -6,16 +6,17 @@ import { URI } from 'langium';
|
|
|
6
6
|
import { NodeFileSystem } from 'langium/node';
|
|
7
7
|
import { createApplingServices, print } from '@appling/lang';
|
|
8
8
|
import { BASELINE, checkPrerequisites, describe, loadExtension, mergeGeneration, pendingChanges, plan, planMigrations, readApplied, readConfig, readRegistry, runMigrations, runPlan } from '@appling/codegen';
|
|
9
|
-
import { buildGraph, dependencies, findApplingFiles, Simulator, writeRelease } from '@appling/model';
|
|
9
|
+
import { buildGraph, dependencies, findApplingFiles, resolveReferences, Simulator, writeRelease } from '@appling/model';
|
|
10
10
|
const USAGE = [
|
|
11
11
|
'Usage: appling <check|fmt|graph> [files or folders...]',
|
|
12
12
|
' appling release <version> [files or folders...]',
|
|
13
13
|
' appling generate [--plan | --migrate | --sync] [files or folders...]',
|
|
14
|
-
' appling simulate <reach <machine> <state> | actors <action> | risks <action>> [files or folders...]'
|
|
14
|
+
' appling simulate <reach <machine> <state> | actors <action> | risks <action>> [files or folders...]',
|
|
15
|
+
' appling refs <qualified name | --check> [files or folders...]'
|
|
15
16
|
].join('\n');
|
|
16
17
|
async function main([command, ...args]) {
|
|
17
|
-
const question = command === 'simulate' ? args.slice(0, args[0] === 'reach' ? 3 : 2) : [];
|
|
18
|
-
if (!['check', 'fmt', 'graph', 'release', 'generate', 'simulate'].includes(command) || (command === 'release' && !args[0])
|
|
18
|
+
const question = command === 'simulate' ? args.slice(0, args[0] === 'reach' ? 3 : 2) : command === 'refs' ? args.slice(0, 1) : [];
|
|
19
|
+
if (!['check', 'fmt', 'graph', 'release', 'generate', 'simulate', 'refs'].includes(command) || ((command === 'release' || command === 'refs') && !args[0])
|
|
19
20
|
|| (command === 'simulate' && (!['reach', 'actors', 'risks'].includes(question[0]) || question.some(a => !a)))) {
|
|
20
21
|
console.error(USAGE);
|
|
21
22
|
return 2;
|
|
@@ -36,6 +37,8 @@ async function main([command, ...args]) {
|
|
|
36
37
|
return generate(documents, Appling, mode);
|
|
37
38
|
if (command === 'simulate')
|
|
38
39
|
return simulate(documents, Appling, question);
|
|
40
|
+
if (command === 'refs')
|
|
41
|
+
return refs(documents, Appling, question[0]);
|
|
39
42
|
const errors = report(documents, console.log);
|
|
40
43
|
console.log(`${documents.length} file(s), ${errors} error(s)`);
|
|
41
44
|
return errors ? 1 : 0;
|
|
@@ -66,6 +69,29 @@ function simulate(documents, services, [question, target, state]) {
|
|
|
66
69
|
return 1;
|
|
67
70
|
}
|
|
68
71
|
}
|
|
72
|
+
/** Prints where an element and its members are implemented, or with --check every reference that is not current. */
|
|
73
|
+
function refs(documents, services, target) {
|
|
74
|
+
if (report(documents, console.error))
|
|
75
|
+
return 1;
|
|
76
|
+
const all = resolveReferences('.', buildGraph(documents.map(doc => doc.parseResult.value), services));
|
|
77
|
+
const line = (r) => `${r.file}:${r.start}-${r.end} ${r.qn}`;
|
|
78
|
+
if (target !== '--check') {
|
|
79
|
+
const found = all.filter(r => r.qn === target || r.qn.startsWith(`${target}.`));
|
|
80
|
+
for (const r of found)
|
|
81
|
+
console.log(`${line(r)}${r.status === 'current' ? '' : ` (${r.status})`}`);
|
|
82
|
+
if (!found.length)
|
|
83
|
+
console.log(`no code references for ${target}`);
|
|
84
|
+
return 0;
|
|
85
|
+
}
|
|
86
|
+
const stale = all.filter(r => r.status !== 'current');
|
|
87
|
+
for (const r of stale) {
|
|
88
|
+
console.log(`${line(r)}: ${r.status === 'shifted' ? `shifted from ${r.recorded.start}-${r.recorded.end}`
|
|
89
|
+
: r.status === 'broken' ? `broken, "${r.anchor}" not found` : 'orphaned, no such element in the model'}`);
|
|
90
|
+
}
|
|
91
|
+
const count = (status) => stale.filter(r => r.status === status).length;
|
|
92
|
+
console.log(`${all.length} reference(s), ${count('shifted')} shifted, ${count('broken')} broken, ${count('orphaned')} orphaned`);
|
|
93
|
+
return stale.length ? 1 : 0;
|
|
94
|
+
}
|
|
69
95
|
async function generate(documents, services, mode) {
|
|
70
96
|
if (report(documents, console.error))
|
|
71
97
|
return 1;
|
|
@@ -228,4 +254,4 @@ function format(documents) {
|
|
|
228
254
|
}
|
|
229
255
|
return failed ? 1 : 0;
|
|
230
256
|
}
|
|
231
|
-
main(process.argv.slice(2)).then(code => process.
|
|
257
|
+
main(process.argv.slice(2)).then(code => { process.exitCode = code; });
|
package/package.json
CHANGED
|
@@ -1,7 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@appling/cli",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.2",
|
|
4
4
|
"description": "Command line tool to check, format, inspect, release and generate Appling models",
|
|
5
|
+
"homepage": "https://www.appling.tools/docs/",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/alex20465/appling.git",
|
|
9
|
+
"directory": "packages/cli"
|
|
10
|
+
},
|
|
5
11
|
"type": "module",
|
|
6
12
|
"bin": {
|
|
7
13
|
"appling": "./out/main.js"
|
|
@@ -10,10 +16,10 @@
|
|
|
10
16
|
"out"
|
|
11
17
|
],
|
|
12
18
|
"dependencies": {
|
|
13
|
-
"
|
|
14
|
-
"@appling/
|
|
15
|
-
"@appling/
|
|
16
|
-
"
|
|
19
|
+
"@appling/codegen": "0.1.2",
|
|
20
|
+
"@appling/lang": "0.2.2",
|
|
21
|
+
"@appling/model": "0.1.2",
|
|
22
|
+
"langium": "4.4.0"
|
|
17
23
|
},
|
|
18
24
|
"devDependencies": {
|
|
19
25
|
"@types/node": "^24.19.2",
|