@fougere/cli 0.3.0-alpha.0 → 0.4.0-alpha.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 +1 -1
- package/app/commands/CallCommand.ts +3 -3
- package/app/commands/ExplainCommand.ts +51 -4
- package/app/commands/FreezeCommand.ts +1 -1
- package/app/commands/KeysCommand.ts +1 -1
- package/app/commands/ServeCommand.ts +7 -16
- package/dist/bin.js +4 -5
- package/dist/bin.js.map +1 -1
- package/dist/bridge.d.ts.map +1 -1
- package/dist/bridge.js +11 -4
- package/dist/bridge.js.map +1 -1
- package/dist/completion.d.ts +4 -1
- package/dist/completion.d.ts.map +1 -1
- package/dist/completion.js +54 -20
- package/dist/completion.js.map +1 -1
- package/dist/loader.d.ts +11 -0
- package/dist/loader.d.ts.map +1 -0
- package/dist/loader.js +23 -0
- package/dist/loader.js.map +1 -0
- package/dist/runner.d.ts.map +1 -1
- package/dist/runner.js +4 -3
- package/dist/runner.js.map +1 -1
- package/fronds/analysis/entities/Explain.ts +2 -1
- package/fronds/analysis/handlers/ExplainHandler.ts +52 -12
- package/fronds/analysis/handlers/FreezeHandler.ts +15 -11
- package/fronds/analysis/handlers/MigrateHandler.ts +2 -2
- package/fronds/scaffold/entities/BuildFrond.ts +1 -1
- package/fronds/scaffold/entities/Call.ts +1 -1
- package/fronds/scaffold/entities/Sync.ts +1 -1
- package/fronds/scaffold/handlers/BuildFrondHandler.ts +5 -5
- package/fronds/scaffold/handlers/SyncHandler.ts +15 -15
- package/package.json +9 -8
- package/src/bin.ts +83 -0
- package/src/bridge.ts +70 -0
- package/src/completion.ts +152 -0
- package/src/index.ts +3 -0
- package/src/loader.ts +28 -0
- package/src/runner.ts +139 -0
- package/src/theme.ts +19 -0
- package/src/ui.ts +131 -0
package/README.md
CHANGED
|
@@ -23,4 +23,4 @@ pnpm add @fougere/cli
|
|
|
23
23
|
|
|
24
24
|
Part of [Fougere](https://github.com/chok/fougere) — one schema, a gradient from
|
|
25
25
|
monolith to distributed, the same user code.
|
|
26
|
-
Reference documentation: [the site](https://
|
|
26
|
+
Reference documentation: [the site](https://fougere.dev/) (en/fr).
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createAppRunner } from '@fougere/core';
|
|
2
|
-
import {
|
|
2
|
+
import { lowerFirst } from '@fougere/core/contract';
|
|
3
3
|
import { bootAppFromConfig } from '@fougere/defaults';
|
|
4
4
|
import type { App } from '@fougere/core';
|
|
5
5
|
import type { ui as createUi } from '../../src/ui.js';
|
|
@@ -36,7 +36,7 @@ export default class CallCommand {
|
|
|
36
36
|
constructor(private app: App, private ui: Ui) {}
|
|
37
37
|
|
|
38
38
|
async run(raw: Record<string, unknown>) {
|
|
39
|
-
const target = raw.
|
|
39
|
+
const target = raw.operation as string | undefined;
|
|
40
40
|
if (!target || !target.includes('.')) {
|
|
41
41
|
this.ui.error('Usage: fougere call <entity>.<op> [--field value …]');
|
|
42
42
|
return;
|
|
@@ -57,7 +57,7 @@ export default class CallCommand {
|
|
|
57
57
|
const app = await bootAppFromConfig(process.cwd(), {});
|
|
58
58
|
try {
|
|
59
59
|
const result = await createAppRunner(app)(
|
|
60
|
-
{ entity:
|
|
60
|
+
{ entity: lowerFirst(entityName), op },
|
|
61
61
|
{ params, query: {}, body, state: {} },
|
|
62
62
|
);
|
|
63
63
|
this.ui.note(JSON.stringify(result, null, 2), target);
|
|
@@ -3,6 +3,7 @@ import { createAppRunner } from '@fougere/core';
|
|
|
3
3
|
import type { ui as createUi } from '../../src/ui.js';
|
|
4
4
|
import type {
|
|
5
5
|
ExplainResult,
|
|
6
|
+
ExplainListing,
|
|
6
7
|
ExplainedBinding,
|
|
7
8
|
} from '../../fronds/analysis/handlers/ExplainHandler.js';
|
|
8
9
|
import pc from 'picocolors';
|
|
@@ -13,10 +14,14 @@ export default class ExplainCommand {
|
|
|
13
14
|
constructor(private app: App, private ui: Ui) {}
|
|
14
15
|
|
|
15
16
|
async run(raw: Record<string, unknown>) {
|
|
16
|
-
const
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
17
|
+
const names = raw.names as 'operations' | 'fronds' | undefined;
|
|
18
|
+
const operation = (raw.operation as string | undefined)?.trim();
|
|
19
|
+
|
|
20
|
+
// No operation named — the question is what this project serves at all. The same
|
|
21
|
+
// model answers both, so the door is the one that was asked, never a guess.
|
|
22
|
+
if (names || !operation) return this.listing(raw, names);
|
|
23
|
+
|
|
24
|
+
const result = await this.ask('execute', raw) as ExplainResult;
|
|
20
25
|
|
|
21
26
|
if (raw.json === true) {
|
|
22
27
|
process.stdout.write(renderExplainJson(result) + '\n');
|
|
@@ -25,6 +30,33 @@ export default class ExplainCommand {
|
|
|
25
30
|
|
|
26
31
|
this.ui.note(renderExplain(result), result.operation);
|
|
27
32
|
}
|
|
33
|
+
|
|
34
|
+
private async listing(raw: Record<string, unknown>, names?: 'operations' | 'fronds') {
|
|
35
|
+
const listing = await this.ask('list', raw) as ExplainListing;
|
|
36
|
+
|
|
37
|
+
// A completion script has no JSON parser: one name per line, nothing else on stdout.
|
|
38
|
+
if (names) {
|
|
39
|
+
const values = names === 'fronds'
|
|
40
|
+
? listing.fronds.map((frond) => frond.name)
|
|
41
|
+
: listing.operations;
|
|
42
|
+
if (values.length > 0) process.stdout.write(values.join('\n') + '\n');
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
if (raw.json === true) {
|
|
47
|
+
process.stdout.write(JSON.stringify(listing, null, 2) + '\n');
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
this.ui.note(renderListing(listing), 'what this project serves');
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
private ask(op: string, raw: Record<string, unknown>) {
|
|
55
|
+
return createAppRunner(this.app)(
|
|
56
|
+
{ entity: 'explain', op },
|
|
57
|
+
{ params: {}, query: {}, body: raw, state: {} },
|
|
58
|
+
);
|
|
59
|
+
}
|
|
28
60
|
}
|
|
29
61
|
|
|
30
62
|
export function renderExplainJson(result: ExplainResult): string {
|
|
@@ -66,6 +98,21 @@ export function renderExplain(result: ExplainResult): string {
|
|
|
66
98
|
return lines.join('\n');
|
|
67
99
|
}
|
|
68
100
|
|
|
101
|
+
export function renderListing(listing: ExplainListing): string {
|
|
102
|
+
const lines = [pc.bold('Fronds')];
|
|
103
|
+
if (listing.fronds.length === 0) lines.push(' —');
|
|
104
|
+
for (const frond of listing.fronds) {
|
|
105
|
+
const where = frond.remote ? `remote ${pc.dim(frond.remote)}` : 'local';
|
|
106
|
+
lines.push(` ${frond.name} ${pc.dim('→')} ${where}, ${frond.operations} operation(s)`);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
lines.push('', pc.bold('Operations'));
|
|
110
|
+
if (listing.operations.length === 0) lines.push(' —');
|
|
111
|
+
for (const operation of listing.operations) lines.push(` ${operation}`);
|
|
112
|
+
|
|
113
|
+
return lines.join('\n');
|
|
114
|
+
}
|
|
115
|
+
|
|
69
116
|
function bindingName(binding: ExplainedBinding | null): string {
|
|
70
117
|
if (!binding) return 'unbound';
|
|
71
118
|
switch (binding.kind) {
|
|
@@ -74,7 +74,7 @@ export default class FreezeCommand {
|
|
|
74
74
|
this.ui.warn(`${entity}.${removed} treated as dropped — say so explicitly if that is right.`);
|
|
75
75
|
return undefined;
|
|
76
76
|
}
|
|
77
|
-
renamed[entity] = { ...
|
|
77
|
+
renamed[entity] = { ...renamed[entity], [removed]: answer };
|
|
78
78
|
}
|
|
79
79
|
}
|
|
80
80
|
return renamed;
|
|
@@ -36,7 +36,7 @@ export default class KeysCommand {
|
|
|
36
36
|
|
|
37
37
|
this.ui.success(`root created — ${ROOT_KEY} (never commit it; added to .gitignore)`);
|
|
38
38
|
this.ui.note(
|
|
39
|
-
`
|
|
39
|
+
`FOUGERE_ROOT_KEY=${packed(publicKey)}`,
|
|
40
40
|
'Every frond that ANSWERS — public, safe in an image or a manifest',
|
|
41
41
|
);
|
|
42
42
|
this.ui.info('Then `fougere grant <frond>` for each frond that CALLS.');
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { createLocalRunner, identityFromEnv } from '@fougere/core';
|
|
2
|
-
import {
|
|
2
|
+
import { watchPathsOf } from '@fougere/core/node';
|
|
3
|
+
import { installLoader } from '../../src/loader.js';
|
|
4
|
+
import type { Conventions } from '@fougere/core/node';
|
|
3
5
|
import { bootAppFromConfig } from '@fougere/defaults';
|
|
4
6
|
import { serve } from '@fougere/transport-http';
|
|
5
7
|
import { watch } from 'node:fs';
|
|
@@ -14,16 +16,6 @@ const DRAIN_MS = 5_000;
|
|
|
14
16
|
/** One save fires several events; the boot must not start once per event. */
|
|
15
17
|
const SETTLE_MS = 60;
|
|
16
18
|
|
|
17
|
-
/**
|
|
18
|
-
* A loader that re-reads. Every loader caches by specifier, so a second boot in this
|
|
19
|
-
* process would be handed the modules the first one read — a reload that changes nothing.
|
|
20
|
-
*/
|
|
21
|
-
async function rereadingLoader(): Promise<void> {
|
|
22
|
-
const { createJiti } = await import('jiti');
|
|
23
|
-
const jiti = createJiti(import.meta.url, { interopDefault: true, moduleCache: false });
|
|
24
|
-
setModuleLoader((filePath) => jiti.import(filePath) as Promise<Record<string, unknown>>);
|
|
25
|
-
}
|
|
26
|
-
|
|
27
19
|
/**
|
|
28
20
|
* The host end of the gradient: one frond, alone in this process, reachable
|
|
29
21
|
* over HTTP. `topology: false` — a served frond IS the host, it never routes
|
|
@@ -40,8 +32,9 @@ export default class ServeCommand {
|
|
|
40
32
|
const root = process.cwd();
|
|
41
33
|
const watching = raw.watch === true;
|
|
42
34
|
|
|
43
|
-
// Cache-free from the FIRST boot, so every boot in this process reads
|
|
44
|
-
|
|
35
|
+
// Cache-free from the FIRST boot when watching, so every boot in this process reads
|
|
36
|
+
// the same way rather than the first one being special.
|
|
37
|
+
const conventions = await installLoader(root, watching);
|
|
45
38
|
|
|
46
39
|
let hosted = await bootAppFromConfig(root, { fronds: [frond], topology: false });
|
|
47
40
|
if (!hosted.fronds.some((f) => f.name === frond)) {
|
|
@@ -59,7 +52,7 @@ export default class ServeCommand {
|
|
|
59
52
|
const { verify, requireIdentity } = await identityFromEnv();
|
|
60
53
|
const { port: bound } = await serve((call, inv) => current(call, inv), { port, verify, requireIdentity });
|
|
61
54
|
this.ui.step(`frond ${frond} servie — POST http://127.0.0.1:${bound}/_fougere/call`);
|
|
62
|
-
this.ui.info(requireIdentity ? 'signed calls only (
|
|
55
|
+
this.ui.info(requireIdentity ? 'signed calls only (FOUGERE_ROOT_KEY is set)' : 'unsigned calls accepted — no FOUGERE_ROOT_KEY');
|
|
63
56
|
|
|
64
57
|
if (!watching) {
|
|
65
58
|
this.ui.info('Ctrl-C pour arrêter.');
|
|
@@ -88,8 +81,6 @@ export default class ServeCommand {
|
|
|
88
81
|
await previous.dispose();
|
|
89
82
|
};
|
|
90
83
|
|
|
91
|
-
const config = await loadConfig(root);
|
|
92
|
-
const conventions = resolveConventions(config.conventions);
|
|
93
84
|
let settling: NodeJS.Timeout | undefined;
|
|
94
85
|
let watched = 0;
|
|
95
86
|
|
package/dist/bin.js
CHANGED
|
@@ -7,15 +7,14 @@
|
|
|
7
7
|
* app/ → loaded at runtime by jiti (presentation)
|
|
8
8
|
*/
|
|
9
9
|
import { createApp, setLogLevel, envLevel } from '@fougere/core';
|
|
10
|
-
import { scanProject,
|
|
10
|
+
import { scanProject, getModuleLoader, frondDirsOf, DEFAULT_CONVENTIONS } from '@fougere/core/node';
|
|
11
11
|
import { readdir, stat } from 'node:fs/promises';
|
|
12
12
|
import { join } from 'node:path';
|
|
13
13
|
import { createContainer } from '@fougere/container';
|
|
14
14
|
import { ui } from './ui.js';
|
|
15
15
|
import { run } from './runner.js';
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
setModuleLoader((filePath) => jiti.import(filePath));
|
|
16
|
+
import { installLoader } from './loader.js';
|
|
17
|
+
await installLoader(process.cwd());
|
|
19
18
|
const cliRoot = new URL('..', import.meta.url).pathname;
|
|
20
19
|
const container = createContainer();
|
|
21
20
|
const terminal = ui();
|
|
@@ -57,7 +56,7 @@ async function scanOf(root) {
|
|
|
57
56
|
const written = join(root, '.fougere/scan.generated.ts');
|
|
58
57
|
const writtenAt = await stat(written).then((s) => s.mtimeMs).catch(() => 0);
|
|
59
58
|
if (writtenAt > 0 && writtenAt >= await newestDeclaration(root)) {
|
|
60
|
-
return (await
|
|
59
|
+
return (await getModuleLoader()(written)).scan;
|
|
61
60
|
}
|
|
62
61
|
// The only slow phase, and it announced nothing: the boot states it at `info`, which the
|
|
63
62
|
// threshold above lowers to `warn`. The terminal says it instead, and a pipe keeps its
|
package/dist/bin.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bin.js","sourceRoot":"","sources":["../src/bin.ts"],"names":[],"mappings":";AACA;;;;;;GAMG;AACH,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,QAAQ,EAAmB,MAAM,eAAe,CAAC;AAClF,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,WAAW,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AACpG,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAE,EAAE,EAAE,MAAM,SAAS,CAAC;AAC7B,OAAO,EAAE,GAAG,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"bin.js","sourceRoot":"","sources":["../src/bin.ts"],"names":[],"mappings":";AACA;;;;;;GAMG;AACH,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,QAAQ,EAAmB,MAAM,eAAe,CAAC;AAClF,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,WAAW,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AACpG,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,k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OAAO,KAAK,EAAE,OAAO,EAAU,MAAM,OAAO,CAAC;AAM7C,6DAA6D;AAC7D,wBAAgB,YAAY,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,
|
|
1
|
+
{"version":3,"file":"bridge.d.ts","sourceRoot":"","sources":["../src/bridge.ts"],"names":[],"mappings":"AACA;;;;;GAKG;AACH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAE9C,OAAO,KAAK,EAAE,OAAO,EAAU,MAAM,OAAO,CAAC;AAM7C,6DAA6D;AAC7D,wBAAgB,YAAY,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAqDpD"}
|
package/dist/bridge.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Lifecycle, Role } from '@fougere/schema';
|
|
2
|
-
import { Anatomy,
|
|
2
|
+
import { Anatomy, Visibility } from '@fougere/schema';
|
|
3
3
|
function toKebab(name) {
|
|
4
4
|
return name.replace(/[A-Z]/g, (c) => '-' + c.toLowerCase());
|
|
5
5
|
}
|
|
@@ -9,7 +9,7 @@ export function entityToArgs(fields) {
|
|
|
9
9
|
let positionalIndex = 0;
|
|
10
10
|
// Axes-derived ingress membership; the CLI additionally skips ALL relations
|
|
11
11
|
// (a ref is not a flag — supplying related rows is not a CLI gesture).
|
|
12
|
-
for (const [key, field] of Object.entries(
|
|
12
|
+
for (const [key, field] of Object.entries(Visibility.of(fields).input)) {
|
|
13
13
|
if (Role.of(field).relation)
|
|
14
14
|
continue;
|
|
15
15
|
// A `default(v)` travels as the create rule `{ value }` — citty shows it.
|
|
@@ -29,8 +29,15 @@ export function entityToArgs(fields) {
|
|
|
29
29
|
case 'number':
|
|
30
30
|
case 'integer':
|
|
31
31
|
case 'string':
|
|
32
|
-
// A
|
|
33
|
-
|
|
32
|
+
// A closed set is citty's `enum`: the shape already names the legal values, so the
|
|
33
|
+
// refusal and the `--help` listing come from the declaration rather than a check
|
|
34
|
+
// written beside it.
|
|
35
|
+
if (shape.type === 'string' && shape.enum?.length) {
|
|
36
|
+
def.type = 'enum';
|
|
37
|
+
def.options = shape.enum.filter((v) => v !== null);
|
|
38
|
+
// A date-time string stays a named string — never a positional arg.
|
|
39
|
+
}
|
|
40
|
+
else if (shape.type === 'string' && shape.format === 'date-time') {
|
|
34
41
|
def.type = 'string';
|
|
35
42
|
}
|
|
36
43
|
else if (positionalIndex === 0 && def.required && key !== 'force') {
|
package/dist/bridge.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bridge.js","sourceRoot":"","sources":["../src/bridge.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AAQlD,OAAO,EAAE,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"bridge.js","sourceRoot":"","sources":["../src/bridge.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AAQlD,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAGtD,SAAS,OAAO,CAAC,IAAY;IAC3B,OAAO,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,GAAG,CAAC,CAAC,WAAW,EAAE,CAAC,CAAC;AAC9D,CAAC;AAED,6DAA6D;AAC7D,MAAM,UAAU,YAAY,CAAC,MAAc;IACzC,MAAM,IAAI,GAAY,EAAE,CAAC;IACzB,IAAI,eAAe,GAAG,CAAC,CAAC;IAExB,4EAA4E;IAC5E,uEAAuE;IACvE,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC,KAAK,CAAC,EAAE,CAAC;QACvE,IAAI,IAAI,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,QAAQ;YAAE,SAAS;QAEtC,0E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,GAAG,CAAC,QAAQ,IAAI,GAAG,KAAK,OAAO,EAAE,CAAC;oBACpE,mDAAmD;oBAClD,GAA+B,CAAC,IAAI,GAAG,YAAY,CAAC;oBACrD,eAAe,EAAE,CAAC;gBACpB,CAAC;qBAAM,CAAC;oBACL,GAA+B,CAAC,IAAI,GAAG,QAAQ,CAAC;gBACnD,CAAC;gBACD,IAAI,YAAY,KAAK,SAAS;oBAAE,GAAG,CAAC,OAAO,GAAG,MAAM,CAAC,YAAY,CAAC,CAAC;gBACnE,MAAM;YACR;gBACG,GAA+B,CAAC,IAAI,GAAG,QAAQ,CAAC;QACrD,CAAC;QAED,IAAI,CAAC,KAAK,KAAK,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,GAAG,CAAC;IAC1C,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC"}
|
package/dist/completion.d.ts
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Shell completion generator — outputs a script for bash/zsh.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
4
|
+
* Commands and flags are the CLI's own entities, read once at generation. The VALUES a
|
|
5
|
+
* positional accepts belong to the project the shell sits in, so they are not written
|
|
6
|
+
* down here: the script asks `fougere explain --names` at the moment of the TAB. A list
|
|
7
|
+
* frozen into a script is stale the first time a handler is added.
|
|
5
8
|
*/
|
|
6
9
|
import type { App } from '@fougere/core';
|
|
7
10
|
export declare function generateZshCompletion(app: App, binName?: string): string;
|
package/dist/completion.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"completion.d.ts","sourceRoot":"","sources":["../src/completion.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"completion.d.ts","sourceRoot":"","sources":["../src/completion.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AAkDzC,wBAAgB,qBAAqB,CAAC,GAAG,EAAE,GAAG,EAAE,OAAO,SAAY,GAAG,MAAM,CAgD3E;AAED,wBAAgB,sBAAsB,CAAC,GAAG,EAAE,GAAG,EAAE,OAAO,SAAY,GAAG,MAAM,CA2C5E"}
|
package/dist/completion.js
CHANGED
|
@@ -1,7 +1,12 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { entityToArgs } from './bridge.js';
|
|
2
2
|
function toKebab(name) {
|
|
3
3
|
return name.replace(/[A-Z]/g, (c) => '-' + c.toLowerCase()).replace(/^-/, '');
|
|
4
4
|
}
|
|
5
|
+
/** What a positional names, said by the field's own name — no table to keep in step. */
|
|
6
|
+
const NAMES = {
|
|
7
|
+
operation: 'operations',
|
|
8
|
+
frond: 'fronds',
|
|
9
|
+
};
|
|
5
10
|
function extractCommandMeta(app) {
|
|
6
11
|
const commands = [];
|
|
7
12
|
for (const frond of app.fronds) {
|
|
@@ -19,25 +24,37 @@ function extractCommandMeta(app) {
|
|
|
19
24
|
}
|
|
20
25
|
if (typeof facade.execute !== 'function')
|
|
21
26
|
continue;
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
27
|
+
// The same function the runner builds citty's args from, so the positional and the
|
|
28
|
+
// flags are the ones the command actually has.
|
|
29
|
+
const args = Object.entries(entityToArgs(entity.entityClass.getFields()));
|
|
30
|
+
const positional = args.find(([, def]) => def.type === 'positional')?.[0];
|
|
31
|
+
commands.push({
|
|
32
|
+
name: toKebab(entity.name),
|
|
33
|
+
flags: args.filter(([, def]) => def.type !== 'positional').map(([key]) => `--${key}`),
|
|
34
|
+
...(positional && NAMES[positional] ? { names: NAMES[positional] } : {}),
|
|
35
|
+
});
|
|
26
36
|
}
|
|
27
37
|
}
|
|
28
38
|
return commands;
|
|
29
39
|
}
|
|
30
40
|
export function generateZshCompletion(app, binName = 'fougere') {
|
|
31
41
|
const commands = extractCommandMeta(app);
|
|
32
|
-
const
|
|
42
|
+
const valueCases = commands
|
|
43
|
+
.filter((cmd) => cmd.names)
|
|
44
|
+
.map((cmd) => ` ${cmd.name}) _${binName}_names ${cmd.names} ;;`)
|
|
45
|
+
.join('\n');
|
|
33
46
|
const flagCases = commands
|
|
34
|
-
.map((cmd) => {
|
|
35
|
-
const flags = cmd.flags.join(' ');
|
|
36
|
-
return ` ${cmd.name}) flags="${flags}" ;;`;
|
|
37
|
-
})
|
|
47
|
+
.map((cmd) => ` ${cmd.name}) flags="${cmd.flags.join(' ')}" ;;`)
|
|
38
48
|
.join('\n');
|
|
39
49
|
return `# Auto-generated by @fougere/cli
|
|
40
50
|
|
|
51
|
+
# The project answers; a stale list in this file would not.
|
|
52
|
+
_${binName}_names() {
|
|
53
|
+
local -a values
|
|
54
|
+
values=(\${(f)"$(${binName} explain --names $1 2>/dev/null)"})
|
|
55
|
+
(( \${#values} )) && compadd -- \${values}
|
|
56
|
+
}
|
|
57
|
+
|
|
41
58
|
_${binName}() {
|
|
42
59
|
local -a commands flags
|
|
43
60
|
commands=(${commands.map((c) => `'${c.name}'`).join(' ')})
|
|
@@ -48,14 +65,19 @@ _${binName}() {
|
|
|
48
65
|
fi
|
|
49
66
|
|
|
50
67
|
local cmd=\${words[2]}
|
|
68
|
+
|
|
69
|
+
if [[ "\${words[CURRENT]}" != --* ]]; then
|
|
70
|
+
case "$cmd" in
|
|
71
|
+
${valueCases}
|
|
72
|
+
esac
|
|
73
|
+
return
|
|
74
|
+
fi
|
|
75
|
+
|
|
51
76
|
case "$cmd" in
|
|
52
77
|
${flagCases}
|
|
53
78
|
*) flags="" ;;
|
|
54
79
|
esac
|
|
55
|
-
|
|
56
|
-
if [[ "\${words[CURRENT]}" == --* ]]; then
|
|
57
|
-
_values 'flags' \${(s: :)flags}
|
|
58
|
-
fi
|
|
80
|
+
_values 'flags' \${(s: :)flags}
|
|
59
81
|
}
|
|
60
82
|
|
|
61
83
|
compdef _${binName} ${binName}
|
|
@@ -64,17 +86,17 @@ compdef _${binName} ${binName}
|
|
|
64
86
|
export function generateBashCompletion(app, binName = 'fougere') {
|
|
65
87
|
const commands = extractCommandMeta(app);
|
|
66
88
|
const cmdNames = commands.map((c) => c.name).join(' ');
|
|
89
|
+
const valueCases = commands
|
|
90
|
+
.filter((cmd) => cmd.names)
|
|
91
|
+
.map((cmd) => ` ${cmd.name}) names="${cmd.names}" ;;`)
|
|
92
|
+
.join('\n');
|
|
67
93
|
const flagCases = commands
|
|
68
|
-
.map((cmd) => {
|
|
69
|
-
const flags = cmd.flags.join(' ');
|
|
70
|
-
return ` ${cmd.name}) COMPREPLY=( $(compgen -W "${flags}" -- "\${cur}") ) ;;`;
|
|
71
|
-
})
|
|
94
|
+
.map((cmd) => ` ${cmd.name}) COMPREPLY=( $(compgen -W "${cmd.flags.join(' ')}" -- "\${cur}") ) ;;`)
|
|
72
95
|
.join('\n');
|
|
73
96
|
return `# Auto-generated by @fougere/cli
|
|
74
97
|
_${binName}_completions() {
|
|
75
|
-
local cur
|
|
98
|
+
local cur cmd names
|
|
76
99
|
cur="\${COMP_WORDS[COMP_CWORD]}"
|
|
77
|
-
prev="\${COMP_WORDS[COMP_CWORD-1]}"
|
|
78
100
|
cmd="\${COMP_WORDS[1]}"
|
|
79
101
|
|
|
80
102
|
if [[ \${COMP_CWORD} -eq 1 ]]; then
|
|
@@ -82,6 +104,18 @@ _${binName}_completions() {
|
|
|
82
104
|
return
|
|
83
105
|
fi
|
|
84
106
|
|
|
107
|
+
if [[ "\${cur}" != --* ]]; then
|
|
108
|
+
names=""
|
|
109
|
+
case "$cmd" in
|
|
110
|
+
${valueCases}
|
|
111
|
+
esac
|
|
112
|
+
if [[ -n "\${names}" ]]; then
|
|
113
|
+
# The project answers; a stale list in this file would not.
|
|
114
|
+
COMPREPLY=( $(compgen -W "$(${binName} explain --names "\${names}" 2>/dev/null | tr '\\n' ' ')" -- "\${cur}") )
|
|
115
|
+
return
|
|
116
|
+
fi
|
|
117
|
+
fi
|
|
118
|
+
|
|
85
119
|
case "$cmd" in
|
|
86
120
|
${flagCases}
|
|
87
121
|
esac
|
package/dist/completion.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"completion.js","sourceRoot":"","sources":["../src/completion.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"completion.js","sourceRoot":"","sources":["../src/completion.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAE3C,SAAS,OAAO,CAAC,IAAY;IAC3B,OAAO,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,GAAG,CAAC,CAAC,WAAW,EAAE,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;AAChF,CAAC;AAED,wFAAwF;AACxF,MAAM,KAAK,GAAwD;IACjE,SAAS,EAAE,YAAY;IACvB,KAAK,EAAE,QAAQ;CAChB,CAAC;AAQF,SAAS,kBAAkB,CAAC,GAAQ;IAClC,MAAM,QAAQ,GAAkB,EAAE,CAAC;IAEnC,KAAK,MAAM,KAAK,IAAI,GAAG,CAAC,MAAM,EAAE,CAAC;QAC/B,MAAM,UAAU,GAAG,IAAI,GAAG,CAAC,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;QAEtE,KAAK,MAAM,MAAM,IAAI,KAAK,CAAC,QAAQ,EAAE,CAAC;YACpC,MAAM,OAAO,GAAG,UAAU,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;YAC5C,IAAI,CAAC,OAAO;gBAAE,SAAS;YAEvB,IAAI,MAAgC,CAAC;YACrC,IAAI,CAAC;gBAAC,MAAM,GAAG,GAAG,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;YAAC,CAAC;YAAC,MAAM,CAAC;gBAAC,SAAS;YAAC,CAAC;Y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IAAI,CAAC,IAAI,CAAC,CAAC;IAEd,OAAO;GACN,OAAO;;;;;;gCAMsB,QAAQ;;;;;;;EAOtC,UAAU;;;;oCAIwB,OAAO;;;;;;EAMzC,SAAS;;;;eAII,OAAO,gBAAgB,OAAO;CAC5C,CAAC;AACF,CAAC"}
|
package/dist/loader.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Conventions } from '@fougere/core/node';
|
|
2
|
+
/**
|
|
3
|
+
* The loader every command needs: `alias` is what makes `@fronds/user/entities/User.js`
|
|
4
|
+
* resolve when one frond names its neighbour, in any command that loads user code.
|
|
5
|
+
*
|
|
6
|
+
* Two jitis, because the config is read BEFORE the aliases — it names the scope they are
|
|
7
|
+
* built from. `reread` drops the module cache: every loader caches by specifier, so a
|
|
8
|
+
* second boot in one process would be handed what the first one read.
|
|
9
|
+
*/
|
|
10
|
+
export declare function installLoader(root: string, reread?: boolean): Promise<Conventions>;
|
|
11
|
+
//# sourceMappingURL=loader.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"loader.d.ts","sourceRoot":"","sources":["../src/loader.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAEtD;;;;;;;GAOG;AACH,wBAAsB,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,UAAQ,GAAG,OAAO,CAAC,WAAW,CAAC,CActF"}
|
package/dist/loader.js
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { setModuleLoader, loadConfig, resolveConventions, frondAliases, } from '@fougere/core/node';
|
|
2
|
+
/**
|
|
3
|
+
* The loader every command needs: `alias` is what makes `@fronds/user/entities/User.js`
|
|
4
|
+
* resolve when one frond names its neighbour, in any command that loads user code.
|
|
5
|
+
*
|
|
6
|
+
* Two jitis, because the config is read BEFORE the aliases — it names the scope they are
|
|
7
|
+
* built from. `reread` drops the module cache: every loader caches by specifier, so a
|
|
8
|
+
* second boot in one process would be handed what the first one read.
|
|
9
|
+
*/
|
|
10
|
+
export async function installLoader(root, reread = false) {
|
|
11
|
+
const { createJiti } = await import('jiti');
|
|
12
|
+
const bare = createJiti(import.meta.url, { interopDefault: true });
|
|
13
|
+
setModuleLoader((filePath) => bare.import(filePath));
|
|
14
|
+
const conventions = resolveConventions((await loadConfig(root)).conventions);
|
|
15
|
+
const jiti = createJiti(import.meta.url, {
|
|
16
|
+
interopDefault: true,
|
|
17
|
+
alias: await frondAliases(root, conventions),
|
|
18
|
+
...(reread ? { moduleCache: false } : {}),
|
|
19
|
+
});
|
|
20
|
+
setModuleLoader((filePath) => jiti.import(filePath));
|
|
21
|
+
return conventions;
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=loader.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"loader.js","sourceRoot":"","sources":["../src/loader.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,EAAE,UAAU,EAAE,kBAAkB,EAAE,YAAY,GAC9D,MAAM,oBAAoB,CAAC;AAG5B;;;;;;;GAOG;AACH,MAAM,CAAC,KAAK,UAAU,aAAa,CAAC,IAAY,EAAE,MAAM,GAAG,KAAK;IAC9D,MAAM,EAAE,UAAU,EAAE,GAAG,MAAM,MAAM,CAAC,MAAM,CAAC,CAAC;IAC5C,MAAM,IAAI,GAAG,UAAU,CAAC,OAAO,IAAI,CAAC,GAAG,EAAE,EAAE,cAAc,EAAE,IAAI,EAAE,CAAC,CAAC;IACnE,eAAe,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAqC,CAAC,CAAC;IAEzF,MAAM,WAAW,GAAG,kBAAkB,CAAC,CAAC,MAAM,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC;IAC7E,MAAM,IAAI,GAAG,UAAU,CAAC,OAAO,IAAI,CAAC,GAAG,EAAE;QACvC,cAAc,EAAE,IAAI;QACpB,KAAK,EAAE,MAAM,YAAY,CAAC,IAAI,EAAE,WAAW,CAAC;QAC5C,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,WAAW,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KAC1C,CAAC,CAAC;IACH,eAAe,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAqC,CAAC,CAAC;IAEzF,OAAO,WAAW,CAAC;AACrB,CAAC"}
|
package/dist/runner.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runner.d.ts","sourceRoot":"","sources":["../src/runner.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AAuCzC,wBAAsB,GAAG,CAAC,GAAG,EAAE,GAAG,GAAG,OAAO,CAAC,IAAI,CAAC,
|
|
1
|
+
{"version":3,"file":"runner.d.ts","sourceRoot":"","sources":["../src/runner.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AAuCzC,wBAAsB,GAAG,CAAC,GAAG,EAAE,GAAG,GAAG,OAAO,CAAC,IAAI,CAAC,CA0FjD"}
|
package/dist/runner.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createAppRunner } from '@fougere/core';
|
|
2
|
-
import {
|
|
2
|
+
import { lowerFirst } from '@fougere/core/contract';
|
|
3
3
|
import { defineCommand, runMain } from 'citty';
|
|
4
4
|
import { ui } from './ui.js';
|
|
5
5
|
import { entityToArgs } from './bridge.js';
|
|
@@ -78,7 +78,8 @@ export async function run(app) {
|
|
|
78
78
|
run: async ({ args: parsed }) => {
|
|
79
79
|
// JSON is a protocol: a branded intro before `{` makes it unparsable. The
|
|
80
80
|
// explain command owns its machine output and therefore gets a clean stdout.
|
|
81
|
-
const machineOutput = cmdName === 'explain'
|
|
81
|
+
const machineOutput = cmdName === 'explain'
|
|
82
|
+
&& (parsed.json === true || typeof parsed.names === 'string');
|
|
82
83
|
if (cmdName !== 'completion' && !machineOutput)
|
|
83
84
|
terminal.intro();
|
|
84
85
|
// citty adds `_` (raw positionals) and `--` (passthrough); strip them
|
|
@@ -93,7 +94,7 @@ export async function run(app) {
|
|
|
93
94
|
}
|
|
94
95
|
else {
|
|
95
96
|
// Ride the call contract — the same envelope every consumer uses.
|
|
96
|
-
await createAppRunner(app)({ entity:
|
|
97
|
+
await createAppRunner(app)({ entity: lowerFirst(entity.name), op: 'execute' }, { params: {}, query: {}, body: input, state: {} });
|
|
97
98
|
}
|
|
98
99
|
}
|
|
99
100
|
catch (err) {
|
package/dist/runner.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runner.js","sourceRoot":"","sources":["../src/runner.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"runner.js","sourceRoot":"","sources":["../src/runner.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACpD,OAAO,EAAE,aAAa,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAC/C,OAAO,EAAE,EAAE,EAAE,MAAM,SAAS,CAAC;AAC7B,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAC3C,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,SAAS,OAAO,CAAC,IAAY;IAC3B,OAAO,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,GAAG,CAAC,CAAC,WAAW,E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|
|
1
|
+
import { bool, entity, oneOf, optional, text } from '@fougere/schema';
|
|
2
2
|
|
|
3
3
|
/** `fougere explain <Operation>` — print the operation contract Fougere will serve. */
|
|
4
4
|
export default class Explain extends entity({
|
|
5
5
|
operation: text({ min: 1, description: 'Operation to inspect (e.g. Post.publish)' }),
|
|
6
6
|
root: optional(text({ description: 'Project to read. Default: the current directory' })),
|
|
7
7
|
json: bool({ default: false, description: 'Print stable machine-readable JSON' }),
|
|
8
|
+
names: optional(oneOf('operations', 'fronds', { description: 'Print one name per line — what shell completion reads' })),
|
|
8
9
|
}) {}
|