@tahminator/pipeline 1.0.78-beta.1fe28066 → 1.0.78-beta.3ef6aac5

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 CHANGED
@@ -185,7 +185,7 @@ await client.promoteDockerImage({
185
185
 
186
186
  ### `ProtobufCompilerClient`
187
187
 
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.
188
+ Generate protobuf clients 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,20 +220,6 @@ 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
-
237
223
  For Go publishing, only the release version is needed:
238
224
 
239
225
  ```ts
@@ -14,6 +14,7 @@ export declare class ArtifactKeeperProtobufCompilerBackend implements IProtobufC
14
14
  private createMavenSettings;
15
15
  private createGradleBuild;
16
16
  private createCargoToml;
17
+ private createRustLibrary;
17
18
  private escapeXml;
18
19
  private get artifactKeeperUrl();
19
20
  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, DEFAULT_PROST_VERSION, GRPC_JAVA_VERSION, TONIC_VERSION, } from "../versions";
6
+ import { DEFAULT_PROTOBUF_JAVA_VERSION } from "../versions";
7
7
  import { ArtifactKeeperGoPublisher } from "./go";
8
- import { createRustLibrary } from "./rust-library";
8
+ const DEFAULT_PROST_VERSION = "0.14";
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"), createRustLibrary(generatedFiles)),
68
+ writeFile(path.join(generatedDirectory, "src", "lib.rs"), this.createRustLibrary(generatedFiles)),
69
69
  ]);
70
70
  await $.env({
71
71
  ...process.env,
@@ -124,22 +124,6 @@ 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>
143
127
  </dependencies>
144
128
  <distributionManagement>
145
129
  <repository>
@@ -165,7 +149,7 @@ export class ArtifactKeeperProtobufCompilerBackend {
165
149
  createGradleBuild(options) {
166
150
  const protobufVersion = options.protobufJavaVersion ?? DEFAULT_PROTOBUF_JAVA_VERSION;
167
151
  return `plugins {
168
- id "java-library"
152
+ id "java"
169
153
  id "maven-publish"
170
154
  }
171
155
 
@@ -177,10 +161,7 @@ repositories {
177
161
  }
178
162
 
179
163
  dependencies {
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"
164
+ implementation "com.google.protobuf:protobuf-java:${protobufVersion}"
184
165
  }
185
166
 
186
167
  java {
@@ -217,11 +198,21 @@ edition = "2021"
217
198
 
218
199
  [dependencies]
219
200
  prost = "${prostVersion}"
220
- prost-types = "${prostVersion}"
221
- tonic = "${TONIC_VERSION}"
222
- tonic-prost = "${TONIC_VERSION}"
223
201
  `;
224
202
  }
203
+ createRustLibrary(generatedFiles) {
204
+ return generatedFiles
205
+ .map((relativePath) => {
206
+ const moduleName = relativePath
207
+ .replace(/\.rs$/, "")
208
+ .replace(/[^a-zA-Z0-9_]/g, "_");
209
+ return `pub mod ${moduleName} {
210
+ include!(concat!(env!("CARGO_MANIFEST_DIR"), "/${relativePath}"));
211
+ }
212
+ `;
213
+ })
214
+ .join("\n");
215
+ }
225
216
  escapeXml(value) {
226
217
  return value.replace(/[<>&'"]/g, (character) => {
227
218
  switch (character) {
@@ -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]: (targets) => new RustProtobufTargetLanguageStrategy(targets[ProtobufTargetLanguage.RUST]?.prostVersion),
13
+ [ProtobufTargetLanguage.RUST]: () => new RustProtobufTargetLanguageStrategy(),
14
14
  };
15
15
  export class ProtobufCompilerClient {
16
16
  async compile({ backend, bufToken, targetLanguages, protoFilesLocation, outputDirectory, }) {
@@ -58,11 +58,10 @@ export class ProtobufCompilerClient {
58
58
  const pathFlag = pathFilter ? ["--path", pathFilter] : [];
59
59
  await writeFile(templatePath, yaml.stringify({
60
60
  version: "v2",
61
- plugins: targetStrategies.flatMap((strategy) => strategy.plugins.map((plugin) => ({
62
- ...plugin,
61
+ plugins: targetStrategies.map((strategy) => ({
63
62
  out: strategy.outputDirectoryName,
64
- include_imports: true,
65
- }))),
63
+ remote: strategy.remotePlugin,
64
+ })),
66
65
  }));
67
66
  try {
68
67
  const command = bufToken ?
@@ -1,7 +1,5 @@
1
1
  import type { IProtobufTargetLanguageStrategy } from "./types";
2
2
  export declare class GoProtobufTargetLanguageStrategy implements IProtobufTargetLanguageStrategy {
3
3
  readonly outputDirectoryName = "go";
4
- readonly plugins: {
5
- remote: string;
6
- }[];
4
+ readonly remotePlugin = "buf.build/protocolbuffers/go";
7
5
  }
@@ -1,7 +1,4 @@
1
1
  export class GoProtobufTargetLanguageStrategy {
2
2
  outputDirectoryName = "go";
3
- plugins = [
4
- { remote: "buf.build/protocolbuffers/go:v1.36.11" },
5
- { remote: "buf.build/grpc/go:v1.5.1" },
6
- ];
3
+ remotePlugin = "buf.build/protocolbuffers/go";
7
4
  }
@@ -1,8 +1,6 @@
1
1
  import type { IProtobufTargetLanguageStrategy } from "./types";
2
2
  export declare class JavaProtobufTargetLanguageStrategy implements IProtobufTargetLanguageStrategy {
3
3
  readonly outputDirectoryName = "java";
4
- readonly plugins: {
5
- remote: string;
6
- }[];
4
+ readonly remotePlugin: string;
7
5
  constructor(runtimeVersion?: string);
8
6
  }
@@ -1,13 +1,8 @@
1
- import { DEFAULT_PROTOBUF_JAVA_VERSION, GRPC_JAVA_VERSION, javaGeneratorVersion, } from "../versions";
1
+ import { DEFAULT_PROTOBUF_JAVA_VERSION, javaGeneratorVersion, } from "../versions";
2
2
  export class JavaProtobufTargetLanguageStrategy {
3
3
  outputDirectoryName = "java";
4
- plugins;
4
+ remotePlugin;
5
5
  constructor(runtimeVersion = DEFAULT_PROTOBUF_JAVA_VERSION) {
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
- ];
6
+ this.remotePlugin = `buf.build/protocolbuffers/java:v${javaGeneratorVersion(runtimeVersion)}`;
12
7
  }
13
8
  }
@@ -1,12 +1,5 @@
1
1
  import type { IProtobufTargetLanguageStrategy } from "./types";
2
2
  export declare class RustProtobufTargetLanguageStrategy implements IProtobufTargetLanguageStrategy {
3
3
  readonly outputDirectoryName = "rust";
4
- readonly plugins: ({
5
- remote: string;
6
- opt?: undefined;
7
- } | {
8
- remote: string;
9
- opt: string[];
10
- })[];
11
- constructor(prostVersion?: string);
4
+ readonly remotePlugin = "buf.build/community/neoeinstein-prost";
12
5
  }
@@ -1,21 +1,4 @@
1
- import semver from "semver";
2
- import { DEFAULT_PROST_VERSION, PROST_PLUGIN_VERSION } from "../versions";
3
1
  export class RustProtobufTargetLanguageStrategy {
4
2
  outputDirectoryName = "rust";
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
- }
3
+ remotePlugin = "buf.build/community/neoeinstein-prost";
21
4
  }
@@ -1,8 +1,4 @@
1
- export interface ProtobufGeneratorPlugin {
2
- readonly remote: string;
3
- readonly opt?: string[];
4
- }
5
1
  export interface IProtobufTargetLanguageStrategy {
6
2
  readonly outputDirectoryName: string;
7
- readonly plugins: ProtobufGeneratorPlugin[];
3
+ readonly remotePlugin: string;
8
4
  }
@@ -28,7 +28,6 @@ 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. */
32
31
  prostVersion?: string;
33
32
  }
34
33
  /** Go import paths are configured with go_package in .proto files. */
@@ -1,7 +1,3 @@
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";
6
2
  /** Java runtime releases include a language major absent from modern protoc tags. */
7
3
  export declare function javaGeneratorVersion(runtimeVersion: string): string;
@@ -1,8 +1,4 @@
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";
6
2
  /** Java runtime releases include a language major absent from modern protoc tags. */
7
3
  export function javaGeneratorVersion(runtimeVersion) {
8
4
  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.1fe28066",
6
+ "version": "1.0.78-beta.3ef6aac5",
7
7
  "repository": {
8
8
  "url": "git+https://github.com/tahminator/pipeline.git"
9
9
  },
@@ -1,2 +0,0 @@
1
- /** Prost filenames encode proto packages; Tonic belongs in the same module. */
2
- export declare function createRustLibrary(generatedFiles: string[]): string;
@@ -1,35 +0,0 @@
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
- }