@tahminator/pipeline 1.0.78-beta.1e2228eb → 1.0.78-beta.1fe28066
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 +15 -1
- package/dist/protobuf/backend/artifact-keeper.d.ts +0 -1
- package/dist/protobuf/backend/artifact-keeper.js +26 -18
- package/dist/protobuf/backend/rust-library.d.ts +2 -0
- package/dist/protobuf/backend/rust-library.js +35 -0
- package/dist/protobuf/client.js +5 -4
- package/dist/protobuf/strategy/go.d.ts +3 -1
- package/dist/protobuf/strategy/go.js +4 -1
- package/dist/protobuf/strategy/java.d.ts +3 -1
- package/dist/protobuf/strategy/java.js +8 -3
- package/dist/protobuf/strategy/rust.d.ts +8 -1
- package/dist/protobuf/strategy/rust.js +18 -1
- package/dist/protobuf/strategy/types.d.ts +5 -1
- package/dist/protobuf/types.d.ts +1 -0
- package/dist/protobuf/versions.d.ts +4 -0
- package/dist/protobuf/versions.js +4 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -185,7 +185,7 @@ await client.promoteDockerImage({
|
|
|
185
185
|
|
|
186
186
|
### `ProtobufCompilerClient`
|
|
187
187
|
|
|
188
|
-
Generate protobuf
|
|
188
|
+
Generate protobuf messages and gRPC client/server stubs with the [Buf CLI](https://buf.build/docs/installation/) and its remote plugins. Java, Rust, and Go targets can be published to Artifact Keeper with Maven/Gradle, Cargo, or Go module uploads. The client installs Buf globally with npm when necessary.
|
|
189
189
|
|
|
190
190
|
```ts
|
|
191
191
|
const protobuf = new ProtobufCompilerClient();
|
|
@@ -220,6 +220,20 @@ option java_multiple_files = true;
|
|
|
220
220
|
|
|
221
221
|
`go_package` is required for Go generation with this client. Java package options are recommended; `java_outer_classname` is optional. Rust generation needs no language-specific file options. CI target options such as Java `groupId`/`artifactId` and Rust `crateName` are publishing metadata, not generated-code package names. Go's former unused `modulePath` option has been removed.
|
|
222
222
|
|
|
223
|
+
Every target enables both message and service generation by default:
|
|
224
|
+
|
|
225
|
+
| Target | Generated service API | Published runtime dependencies |
|
|
226
|
+
| ----------------------- | -------------------------------------------------------------------- | --------------------------------------------------- |
|
|
227
|
+
| Java (Maven and Gradle) | `<Service>Grpc.<Service>ImplBase` and client stubs | `protobuf-java`, `grpc-protobuf`, `grpc-stub` |
|
|
228
|
+
| Go | `<Service>Server`, `Unimplemented<Service>Server`, `<Service>Client` | Resolved by `go mod tidy` into the generated module |
|
|
229
|
+
| Rust | Tonic `<service>_server` traits and `<service>_client` clients | `prost`, `prost-types`, `tonic`, `tonic-prost` |
|
|
230
|
+
|
|
231
|
+
Applications implement the generated service interfaces and supply server startup, endpoints, authentication, and transport configuration. Java applications must add a transport implementation such as `io.grpc:grpc-netty-shaded:1.75.0`; the generated SDK does not choose one. Gradle publishes public runtime types as `api` dependencies so they are visible on consumers' compile classpaths.
|
|
232
|
+
|
|
233
|
+
Imported schemas are generated alongside the selected input, except standard well-known types, which use the runtime libraries. This produces self-contained schema output rather than relying on separately published schema packages. Go publishing still requires those package paths to share a valid module root.
|
|
234
|
+
|
|
235
|
+
Rust's Prost and Tonic plugins are pinned to `v0.5.0`, paired with the `0.14` runtime series. `prostVersion` overrides must remain within `0.14`. The published crate preserves proto package hierarchy (for example, `example.v1` becomes `example::v1`) and includes Tonic stubs in the same module as their messages. This replaces the previous flattened Rust module names.
|
|
236
|
+
|
|
223
237
|
For Go publishing, only the release version is needed:
|
|
224
238
|
|
|
225
239
|
```ts
|
|
@@ -14,7 +14,6 @@ export declare class ArtifactKeeperProtobufCompilerBackend implements IProtobufC
|
|
|
14
14
|
private createMavenSettings;
|
|
15
15
|
private createGradleBuild;
|
|
16
16
|
private createCargoToml;
|
|
17
|
-
private createRustLibrary;
|
|
18
17
|
private escapeXml;
|
|
19
18
|
private get artifactKeeperUrl();
|
|
20
19
|
private get mavenRepositoryUrl();
|
|
@@ -3,9 +3,9 @@ import { mkdir, mkdtemp, readdir, rename, rm, writeFile, } from "node:fs/promise
|
|
|
3
3
|
import { tmpdir } from "node:os";
|
|
4
4
|
import path from "node:path";
|
|
5
5
|
import { ProtobufTargetLanguage, } from "../types";
|
|
6
|
-
import { DEFAULT_PROTOBUF_JAVA_VERSION } from "../versions";
|
|
6
|
+
import { DEFAULT_PROTOBUF_JAVA_VERSION, DEFAULT_PROST_VERSION, GRPC_JAVA_VERSION, TONIC_VERSION, } from "../versions";
|
|
7
7
|
import { ArtifactKeeperGoPublisher } from "./go";
|
|
8
|
-
|
|
8
|
+
import { createRustLibrary } from "./rust-library";
|
|
9
9
|
export class ArtifactKeeperProtobufCompilerBackend {
|
|
10
10
|
config;
|
|
11
11
|
constructor(config) {
|
|
@@ -65,7 +65,7 @@ export class ArtifactKeeperProtobufCompilerBackend {
|
|
|
65
65
|
await mkdir(path.join(generatedDirectory, "src"), { recursive: true });
|
|
66
66
|
await Promise.all([
|
|
67
67
|
writeFile(path.join(generatedDirectory, "Cargo.toml"), this.createCargoToml(options)),
|
|
68
|
-
writeFile(path.join(generatedDirectory, "src", "lib.rs"),
|
|
68
|
+
writeFile(path.join(generatedDirectory, "src", "lib.rs"), createRustLibrary(generatedFiles)),
|
|
69
69
|
]);
|
|
70
70
|
await $.env({
|
|
71
71
|
...process.env,
|
|
@@ -124,6 +124,22 @@ export class ArtifactKeeperProtobufCompilerBackend {
|
|
|
124
124
|
<artifactId>protobuf-java</artifactId>
|
|
125
125
|
<version>${this.escapeXml(protobufVersion)}</version>
|
|
126
126
|
</dependency>
|
|
127
|
+
<dependency>
|
|
128
|
+
<groupId>io.grpc</groupId>
|
|
129
|
+
<artifactId>grpc-protobuf</artifactId>
|
|
130
|
+
<version>${GRPC_JAVA_VERSION}</version>
|
|
131
|
+
</dependency>
|
|
132
|
+
<dependency>
|
|
133
|
+
<groupId>io.grpc</groupId>
|
|
134
|
+
<artifactId>grpc-stub</artifactId>
|
|
135
|
+
<version>${GRPC_JAVA_VERSION}</version>
|
|
136
|
+
</dependency>
|
|
137
|
+
<dependency>
|
|
138
|
+
<groupId>javax.annotation</groupId>
|
|
139
|
+
<artifactId>javax.annotation-api</artifactId>
|
|
140
|
+
<version>1.3.2</version>
|
|
141
|
+
<scope>provided</scope>
|
|
142
|
+
</dependency>
|
|
127
143
|
</dependencies>
|
|
128
144
|
<distributionManagement>
|
|
129
145
|
<repository>
|
|
@@ -149,7 +165,7 @@ export class ArtifactKeeperProtobufCompilerBackend {
|
|
|
149
165
|
createGradleBuild(options) {
|
|
150
166
|
const protobufVersion = options.protobufJavaVersion ?? DEFAULT_PROTOBUF_JAVA_VERSION;
|
|
151
167
|
return `plugins {
|
|
152
|
-
id "java"
|
|
168
|
+
id "java-library"
|
|
153
169
|
id "maven-publish"
|
|
154
170
|
}
|
|
155
171
|
|
|
@@ -161,7 +177,10 @@ repositories {
|
|
|
161
177
|
}
|
|
162
178
|
|
|
163
179
|
dependencies {
|
|
164
|
-
|
|
180
|
+
api "com.google.protobuf:protobuf-java:${protobufVersion}"
|
|
181
|
+
api "io.grpc:grpc-protobuf:${GRPC_JAVA_VERSION}"
|
|
182
|
+
api "io.grpc:grpc-stub:${GRPC_JAVA_VERSION}"
|
|
183
|
+
compileOnly "javax.annotation:javax.annotation-api:1.3.2"
|
|
165
184
|
}
|
|
166
185
|
|
|
167
186
|
java {
|
|
@@ -199,21 +218,10 @@ edition = "2021"
|
|
|
199
218
|
[dependencies]
|
|
200
219
|
prost = "${prostVersion}"
|
|
201
220
|
prost-types = "${prostVersion}"
|
|
221
|
+
tonic = "${TONIC_VERSION}"
|
|
222
|
+
tonic-prost = "${TONIC_VERSION}"
|
|
202
223
|
`;
|
|
203
224
|
}
|
|
204
|
-
createRustLibrary(generatedFiles) {
|
|
205
|
-
return generatedFiles
|
|
206
|
-
.map((relativePath) => {
|
|
207
|
-
const moduleName = relativePath
|
|
208
|
-
.replace(/\.rs$/, "")
|
|
209
|
-
.replace(/[^a-zA-Z0-9_]/g, "_");
|
|
210
|
-
return `pub mod ${moduleName} {
|
|
211
|
-
include!(concat!(env!("CARGO_MANIFEST_DIR"), "/${relativePath}"));
|
|
212
|
-
}
|
|
213
|
-
`;
|
|
214
|
-
})
|
|
215
|
-
.join("\n");
|
|
216
|
-
}
|
|
217
225
|
escapeXml(value) {
|
|
218
226
|
return value.replace(/[<>&'"]/g, (character) => {
|
|
219
227
|
switch (character) {
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
/** Prost filenames encode proto packages; Tonic belongs in the same module. */
|
|
3
|
+
export function createRustLibrary(generatedFiles) {
|
|
4
|
+
const root = { files: [], children: new Map() };
|
|
5
|
+
for (const file of [...generatedFiles].sort()) {
|
|
6
|
+
const packageName = path.posix
|
|
7
|
+
.basename(file)
|
|
8
|
+
.replace(/(?:\.tonic)?\.rs$/, "");
|
|
9
|
+
let node = root;
|
|
10
|
+
for (const segment of packageName === "_" ? [] : packageName.split(".")) {
|
|
11
|
+
if (!/^(?:r#)?[a-zA-Z_][a-zA-Z0-9_]*$/.test(segment) ||
|
|
12
|
+
["self", "Self", "super", "crate"].includes(segment)) {
|
|
13
|
+
throw new Error(`Cannot represent Rust package module ${segment} from ${file}.`);
|
|
14
|
+
}
|
|
15
|
+
const name = segment.startsWith("r#") ? segment : `r#${segment}`;
|
|
16
|
+
let child = node.children.get(name);
|
|
17
|
+
if (!child) {
|
|
18
|
+
child = { files: [], children: new Map() };
|
|
19
|
+
node.children.set(name, child);
|
|
20
|
+
}
|
|
21
|
+
node = child;
|
|
22
|
+
}
|
|
23
|
+
node.files.push(file);
|
|
24
|
+
}
|
|
25
|
+
function render(node, indent = "") {
|
|
26
|
+
const includes = node.files
|
|
27
|
+
.map((file) => `${indent}include!(concat!(env!("CARGO_MANIFEST_DIR"), ${JSON.stringify(`/${file}`)}));\n`)
|
|
28
|
+
.join("");
|
|
29
|
+
const children = [...node.children]
|
|
30
|
+
.map(([name, child]) => `${indent}pub mod ${name} {\n${render(child, `${indent} `)}${indent}}\n`)
|
|
31
|
+
.join("");
|
|
32
|
+
return includes + children;
|
|
33
|
+
}
|
|
34
|
+
return render(root);
|
|
35
|
+
}
|
package/dist/protobuf/client.js
CHANGED
|
@@ -10,7 +10,7 @@ import { ProtobufTargetLanguage, } from "./types";
|
|
|
10
10
|
const TARGET_LANGUAGE_STRATEGY_FACTORIES = {
|
|
11
11
|
[ProtobufTargetLanguage.JAVA]: (targets) => new JavaProtobufTargetLanguageStrategy(targets[ProtobufTargetLanguage.JAVA]?.protobufJavaVersion),
|
|
12
12
|
[ProtobufTargetLanguage.GO]: () => new GoProtobufTargetLanguageStrategy(),
|
|
13
|
-
[ProtobufTargetLanguage.RUST]: () => new RustProtobufTargetLanguageStrategy(),
|
|
13
|
+
[ProtobufTargetLanguage.RUST]: (targets) => new RustProtobufTargetLanguageStrategy(targets[ProtobufTargetLanguage.RUST]?.prostVersion),
|
|
14
14
|
};
|
|
15
15
|
export class ProtobufCompilerClient {
|
|
16
16
|
async compile({ backend, bufToken, targetLanguages, protoFilesLocation, outputDirectory, }) {
|
|
@@ -58,10 +58,11 @@ export class ProtobufCompilerClient {
|
|
|
58
58
|
const pathFlag = pathFilter ? ["--path", pathFilter] : [];
|
|
59
59
|
await writeFile(templatePath, yaml.stringify({
|
|
60
60
|
version: "v2",
|
|
61
|
-
plugins: targetStrategies.
|
|
61
|
+
plugins: targetStrategies.flatMap((strategy) => strategy.plugins.map((plugin) => ({
|
|
62
|
+
...plugin,
|
|
62
63
|
out: strategy.outputDirectoryName,
|
|
63
|
-
|
|
64
|
-
})),
|
|
64
|
+
include_imports: true,
|
|
65
|
+
}))),
|
|
65
66
|
}));
|
|
66
67
|
try {
|
|
67
68
|
const command = bufToken ?
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import type { IProtobufTargetLanguageStrategy } from "./types";
|
|
2
2
|
export declare class GoProtobufTargetLanguageStrategy implements IProtobufTargetLanguageStrategy {
|
|
3
3
|
readonly outputDirectoryName = "go";
|
|
4
|
-
readonly
|
|
4
|
+
readonly plugins: {
|
|
5
|
+
remote: string;
|
|
6
|
+
}[];
|
|
5
7
|
}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import type { IProtobufTargetLanguageStrategy } from "./types";
|
|
2
2
|
export declare class JavaProtobufTargetLanguageStrategy implements IProtobufTargetLanguageStrategy {
|
|
3
3
|
readonly outputDirectoryName = "java";
|
|
4
|
-
readonly
|
|
4
|
+
readonly plugins: {
|
|
5
|
+
remote: string;
|
|
6
|
+
}[];
|
|
5
7
|
constructor(runtimeVersion?: string);
|
|
6
8
|
}
|
|
@@ -1,8 +1,13 @@
|
|
|
1
|
-
import { DEFAULT_PROTOBUF_JAVA_VERSION, javaGeneratorVersion, } from "../versions";
|
|
1
|
+
import { DEFAULT_PROTOBUF_JAVA_VERSION, GRPC_JAVA_VERSION, javaGeneratorVersion, } from "../versions";
|
|
2
2
|
export class JavaProtobufTargetLanguageStrategy {
|
|
3
3
|
outputDirectoryName = "java";
|
|
4
|
-
|
|
4
|
+
plugins;
|
|
5
5
|
constructor(runtimeVersion = DEFAULT_PROTOBUF_JAVA_VERSION) {
|
|
6
|
-
this.
|
|
6
|
+
this.plugins = [
|
|
7
|
+
{
|
|
8
|
+
remote: `buf.build/protocolbuffers/java:v${javaGeneratorVersion(runtimeVersion)}`,
|
|
9
|
+
},
|
|
10
|
+
{ remote: `buf.build/grpc/java:v${GRPC_JAVA_VERSION}` },
|
|
11
|
+
];
|
|
7
12
|
}
|
|
8
13
|
}
|
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
import type { IProtobufTargetLanguageStrategy } from "./types";
|
|
2
2
|
export declare class RustProtobufTargetLanguageStrategy implements IProtobufTargetLanguageStrategy {
|
|
3
3
|
readonly outputDirectoryName = "rust";
|
|
4
|
-
readonly
|
|
4
|
+
readonly plugins: ({
|
|
5
|
+
remote: string;
|
|
6
|
+
opt?: undefined;
|
|
7
|
+
} | {
|
|
8
|
+
remote: string;
|
|
9
|
+
opt: string[];
|
|
10
|
+
})[];
|
|
11
|
+
constructor(prostVersion?: string);
|
|
5
12
|
}
|
|
@@ -1,4 +1,21 @@
|
|
|
1
|
+
import semver from "semver";
|
|
2
|
+
import { DEFAULT_PROST_VERSION, PROST_PLUGIN_VERSION } from "../versions";
|
|
1
3
|
export class RustProtobufTargetLanguageStrategy {
|
|
2
4
|
outputDirectoryName = "rust";
|
|
3
|
-
|
|
5
|
+
plugins = [
|
|
6
|
+
{
|
|
7
|
+
remote: `buf.build/community/neoeinstein-prost:v${PROST_PLUGIN_VERSION}`,
|
|
8
|
+
},
|
|
9
|
+
{
|
|
10
|
+
remote: `buf.build/community/neoeinstein-tonic:v${PROST_PLUGIN_VERSION}`,
|
|
11
|
+
// lib.rs includes messages and service stubs into the same package module.
|
|
12
|
+
opt: ["no_include=true"],
|
|
13
|
+
},
|
|
14
|
+
];
|
|
15
|
+
constructor(prostVersion = DEFAULT_PROST_VERSION) {
|
|
16
|
+
if (!semver.validRange(prostVersion) ||
|
|
17
|
+
!semver.subset(prostVersion, ">=0.14.0 <0.15.0")) {
|
|
18
|
+
throw new Error("The pinned Rust gRPC generators require prostVersion in the 0.14 release series.");
|
|
19
|
+
}
|
|
20
|
+
}
|
|
4
21
|
}
|
|
@@ -1,4 +1,8 @@
|
|
|
1
|
+
export interface ProtobufGeneratorPlugin {
|
|
2
|
+
readonly remote: string;
|
|
3
|
+
readonly opt?: string[];
|
|
4
|
+
}
|
|
1
5
|
export interface IProtobufTargetLanguageStrategy {
|
|
2
6
|
readonly outputDirectoryName: string;
|
|
3
|
-
readonly
|
|
7
|
+
readonly plugins: ProtobufGeneratorPlugin[];
|
|
4
8
|
}
|
package/dist/protobuf/types.d.ts
CHANGED
|
@@ -28,6 +28,7 @@ export interface ProtobufJavaTargetLanguageOptions {
|
|
|
28
28
|
export interface ProtobufRustTargetLanguageOptions {
|
|
29
29
|
crateName: string;
|
|
30
30
|
version: string;
|
|
31
|
+
/** Prost runtime constraint within 0.14; matched to the pinned Prost/Tonic generators. */
|
|
31
32
|
prostVersion?: string;
|
|
32
33
|
}
|
|
33
34
|
/** Go import paths are configured with go_package in .proto files. */
|
|
@@ -1,3 +1,7 @@
|
|
|
1
1
|
export declare const DEFAULT_PROTOBUF_JAVA_VERSION = "4.32.1";
|
|
2
|
+
export declare const GRPC_JAVA_VERSION = "1.75.0";
|
|
3
|
+
export declare const PROST_PLUGIN_VERSION = "0.5.0";
|
|
4
|
+
export declare const DEFAULT_PROST_VERSION = "0.14.1";
|
|
5
|
+
export declare const TONIC_VERSION = "0.14.1";
|
|
2
6
|
/** Java runtime releases include a language major absent from modern protoc tags. */
|
|
3
7
|
export declare function javaGeneratorVersion(runtimeVersion: string): string;
|
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
export const DEFAULT_PROTOBUF_JAVA_VERSION = "4.32.1";
|
|
2
|
+
export const GRPC_JAVA_VERSION = "1.75.0";
|
|
3
|
+
export const PROST_PLUGIN_VERSION = "0.5.0";
|
|
4
|
+
export const DEFAULT_PROST_VERSION = "0.14.1";
|
|
5
|
+
export const TONIC_VERSION = "0.14.1";
|
|
2
6
|
/** Java runtime releases include a language major absent from modern protoc tags. */
|
|
3
7
|
export function javaGeneratorVersion(runtimeVersion) {
|
|
4
8
|
const match = /^(3|4)\.(\d+)\.(\d+)$/.exec(runtimeVersion);
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"type": "module",
|
|
4
4
|
"author": "Tahmid Ahmed",
|
|
5
5
|
"description": "A collection of Bun shell scripts that can be re-used in various CICD pipelines.",
|
|
6
|
-
"version": "1.0.78-beta.
|
|
6
|
+
"version": "1.0.78-beta.1fe28066",
|
|
7
7
|
"repository": {
|
|
8
8
|
"url": "git+https://github.com/tahminator/pipeline.git"
|
|
9
9
|
},
|