@aventara/client 0.1.0-pilot.4 → 1.0.0-rc.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/CHANGELOG.md +222 -0
- package/README.md +21 -3
- package/dist/cli/command.parser.d.ts +3 -1
- package/dist/cli/command.parser.js +12 -1
- package/dist/cli/generate.command.d.ts +6 -1
- package/dist/cli/generate.command.js +12 -1
- package/dist/cli/step.reporter.d.ts +31 -0
- package/dist/cli/step.reporter.js +87 -0
- package/dist/cli.js +2 -0
- package/dist/contract/contract.acceptance.d.ts +1 -1
- package/dist/contract/contract.acceptance.js +1 -1
- package/dist/emit/client-surface.emitter.js +17 -6
- package/dist/emit/contract-carrier.emitter.d.ts +1 -1
- package/dist/emit/contract-carrier.emitter.js +1 -1
- package/dist/emit/descriptor.emitter.d.ts +1 -1
- package/dist/emit/descriptor.emitter.js +1 -1
- package/dist/emit/json-shape.emitter.d.ts +16 -0
- package/dist/emit/json-shape.emitter.js +88 -0
- package/dist/emit/name.deriver.d.ts +1 -1
- package/dist/emit/name.deriver.js +1 -1
- package/dist/emit/runtime.emitter.d.ts +1 -1
- package/dist/emit/runtime.emitter.js +3 -3
- package/dist/emit/scalar.codec.js +56 -13
- package/dist/emit/transaction.emitter.js +109 -73
- package/dist/generate.d.ts +9 -1
- package/dist/generate.js +38 -24
- package/dist/init/client-init.orchestrator.js +31 -16
- package/dist/init/command.runner.d.ts +2 -0
- package/dist/init/command.runner.js +4 -1
- package/package.json +6 -5
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { mkdirSync, readFileSync, rmSync, writeFileSync } from "node:fs";
|
|
2
2
|
import path from "node:path";
|
|
3
|
-
import { runGenerate } from "../cli/generate.command.js";
|
|
3
|
+
import { GENERATION_STEPS, runGenerate, } from "../cli/generate.command.js";
|
|
4
|
+
import { createStepReporter } from "../cli/step.reporter.js";
|
|
4
5
|
import { CLIENT_CONFIG_FILE } from "../config/config.loader.js";
|
|
5
6
|
import { resolveModuleStyle } from "../config/module-style.resolver.js";
|
|
6
7
|
import { ContractTransportError } from "../contract/contract.fetcher.js";
|
|
@@ -47,34 +48,48 @@ export async function runClientInit(command, io) {
|
|
|
47
48
|
}
|
|
48
49
|
}
|
|
49
50
|
const writes = plan.conflicts.length === 0 ? plan.keeping : plan.replacing;
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
51
|
+
const progress = createStepReporter({
|
|
52
|
+
write: io.stderr,
|
|
53
|
+
mode: io.progress ?? "off",
|
|
54
|
+
total: command.skipInstall
|
|
55
|
+
? 1
|
|
56
|
+
: 2 + (command.skipGenerate ? 0 : GENERATION_STEPS),
|
|
57
|
+
verbose: command.verbose === true,
|
|
58
|
+
});
|
|
59
|
+
await progress.step("Writing the client setup", () => {
|
|
60
|
+
for (const write of writes) {
|
|
61
|
+
const target = path.join(io.cwd, write.path);
|
|
62
|
+
if (write.content === undefined) {
|
|
63
|
+
rmSync(target, { force: true });
|
|
64
|
+
continue;
|
|
65
|
+
}
|
|
66
|
+
mkdirSync(path.dirname(target), { recursive: true });
|
|
67
|
+
writeFileSync(target, write.content);
|
|
55
68
|
}
|
|
56
|
-
|
|
57
|
-
writeFileSync(target, write.content);
|
|
58
|
-
}
|
|
69
|
+
});
|
|
59
70
|
io.stdout(`avclient: initialized ${io.cwd}: ${writes.map((write) => (write.content === undefined ? `removed ${write.path}` : write.path)).join(", ") || "nothing to change"}.\n`);
|
|
60
71
|
const install = `${answers.packageManager} install`;
|
|
61
72
|
if (command.skipInstall) {
|
|
73
|
+
progress.finish("avclient", "done");
|
|
62
74
|
io.stdout(`Next:\n 1. Install @aventara/client ${clientVersion}: ${install}\n 2. With the server running: ${answers.packageManager} run ${GENERATE_SCRIPT}\n`);
|
|
63
75
|
return 0;
|
|
64
76
|
}
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
77
|
+
await progress.step(`Installing dependencies (${install})`, async () => {
|
|
78
|
+
const installed = await (io.run ?? runCommand)(answers.packageManager, ["install"], {
|
|
79
|
+
cwd: io.cwd,
|
|
80
|
+
onOutput: progress.output,
|
|
81
|
+
});
|
|
82
|
+
if (installed.code !== 0) {
|
|
83
|
+
throw new ClientInitStepError(`\`${install}\` exited with code ${installed.code} after ${project.configFile ?? CLIENT_CONFIG_FILE} was written; fix what it reports and run \`${install}\` again:\n${installed.stderr.trimEnd()}`);
|
|
84
|
+
}
|
|
68
85
|
});
|
|
69
|
-
if (installed.code !== 0) {
|
|
70
|
-
throw new ClientInitStepError(`\`${install}\` exited with code ${installed.code} after ${project.configFile ?? CLIENT_CONFIG_FILE} was written; fix what it reports and run \`${install}\` again:\n${installed.stderr.trimEnd()}`);
|
|
71
|
-
}
|
|
72
86
|
if (command.skipGenerate) {
|
|
87
|
+
progress.finish("avclient", "done");
|
|
73
88
|
io.stdout(`Next: with the server running, ${answers.packageManager} run ${GENERATE_SCRIPT}\n`);
|
|
74
89
|
return 0;
|
|
75
90
|
}
|
|
76
91
|
try {
|
|
77
|
-
return await runGenerate(io, command.yes);
|
|
92
|
+
return await runGenerate(io, command.yes, progress);
|
|
78
93
|
}
|
|
79
94
|
catch (error) {
|
|
80
95
|
if (error instanceof ContractTransportError) {
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
/** One child process, stdout and stderr piped and collected: `init`'s install. */
|
|
2
2
|
export type CommandRunner = (command: string, args: readonly string[], options: {
|
|
3
3
|
readonly cwd: string;
|
|
4
|
+
/** Each chunk of the child's stdout and stderr as it arrives (`--verbose`). */
|
|
5
|
+
readonly onOutput?: (chunk: string) => void;
|
|
4
6
|
}) => Promise<{
|
|
5
7
|
readonly code: number;
|
|
6
8
|
readonly stderr: string;
|
|
@@ -6,9 +6,12 @@ export const runCommand = (command, args, options) => new Promise((resolve, reje
|
|
|
6
6
|
env: process.env,
|
|
7
7
|
});
|
|
8
8
|
let stderr = "";
|
|
9
|
-
child.stdout.
|
|
9
|
+
child.stdout.setEncoding("utf8").on("data", (chunk) => {
|
|
10
|
+
options.onOutput?.(chunk);
|
|
11
|
+
});
|
|
10
12
|
child.stderr.setEncoding("utf8").on("data", (chunk) => {
|
|
11
13
|
stderr += chunk;
|
|
14
|
+
options.onOutput?.(chunk);
|
|
12
15
|
});
|
|
13
16
|
child.once("error", reject);
|
|
14
17
|
child.once("close", (code) => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aventara/client",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "1.0.0-rc.0",
|
|
4
4
|
"license": "SEE LICENSE IN LICENSE",
|
|
5
5
|
"description": "Development-time generator for Aventara typed remote clients.",
|
|
6
6
|
"type": "module",
|
|
@@ -20,10 +20,11 @@
|
|
|
20
20
|
},
|
|
21
21
|
"files": [
|
|
22
22
|
"dist",
|
|
23
|
-
"LICENSE-ADDITIONAL-PERMISSION.md"
|
|
23
|
+
"LICENSE-ADDITIONAL-PERMISSION.md",
|
|
24
|
+
"CHANGELOG.md"
|
|
24
25
|
],
|
|
25
26
|
"dependencies": {
|
|
26
|
-
"@aventara/core": "
|
|
27
|
+
"@aventara/core": "1.0.0-rc.0",
|
|
27
28
|
"c12": "3.3.4",
|
|
28
29
|
"get-tsconfig": "4.10.0"
|
|
29
30
|
},
|
|
@@ -39,12 +40,12 @@
|
|
|
39
40
|
"access": "public"
|
|
40
41
|
},
|
|
41
42
|
"devDependencies": {
|
|
42
|
-
"@aventara/testing": "
|
|
43
|
+
"@aventara/testing": "1.0.0-rc.0",
|
|
43
44
|
"@types/node": "24.10.1",
|
|
44
45
|
"typescript": "^5.9.2"
|
|
45
46
|
},
|
|
46
47
|
"scripts": {
|
|
47
|
-
"build": "tsc -p tsconfig.json --removeComments --declaration false && tsc -p tsconfig.json --emitDeclarationOnly && node ../../scripts/build/declaration-comments.sanitizer.ts dist",
|
|
48
|
+
"build": "node ../../scripts/build/build-output.cleaner.ts dist && tsc -p tsconfig.json --removeComments --declaration false && tsc -p tsconfig.json --emitDeclarationOnly && node ../../scripts/build/declaration-comments.sanitizer.ts dist",
|
|
48
49
|
"typecheck": "tsc -p tsconfig.typecheck.json --noEmit",
|
|
49
50
|
"test": "vitest run --typecheck --config ../../vitest.config.mts --root .",
|
|
50
51
|
"lint": "biome lint src"
|