New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@replit/river-codegen

Package Overview
Dependencies
Maintainers
30
Versions
33
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@replit/river-codegen - npm Package Compare versions

Comparing version 0.0.16 to 0.0.17

2

dist/cli.js

@@ -8,3 +8,3 @@ #!/usr/bin/env node

description: "Generate River server type declarations from gRPC service declarations",
version: "0.0.12",
version: "0.0.17",
args: {

@@ -11,0 +11,0 @@ outputDirectory: option({

@@ -1,2 +0,2 @@

import { mkdir, mkdtemp, readFile, rm, writeFile } from "fs/promises";
import { mkdir, mkdtemp, readFile, rm, unlink, writeFile, } from "fs/promises";
import { tmpdir } from "os";

@@ -226,2 +226,3 @@ import * as nodePath from "path";

// Services.
const serviceNames = {};
for (const [serviceIndex, service] of fileDescriptor.service.entries()) {

@@ -233,2 +234,4 @@ const serviceComment = leadingComments.get([SERVICE_ORDINAL, serviceIndex].toString());

}
serviceNames[toCamelCase(service.name)] =
`${service.name}ServiceConstructor`;
chunks.push(`export const ${service.name}ServiceConstructor = () =>`);

@@ -278,7 +281,10 @@ chunks.push("ServiceBuilder");

}
return Buffer.from(await prettier.format(chunks.join("\n"), {
filepath: outputFilename,
trailingComma: "all",
singleQuote: true,
}), "utf-8");
return {
contents: Buffer.from(await prettier.format(chunks.join("\n"), {
filepath: outputFilename,
trailingComma: "all",
singleQuote: true,
}), "utf-8"),
serviceNames,
};
}

@@ -294,2 +300,3 @@ export async function codegen({ protoFiles, includePaths, outputDirectory, }) {

const descriptorSet = FileDescriptorSet.decode(descriptorSetSource);
const serviceNames = {};
for (const fileDescriptor of descriptorSet.file) {

@@ -300,6 +307,43 @@ if (fileDescriptor.service.length === 0) {

const outputFilename = nodePath.join(outputDirectory, fileDescriptor.name.replace(".proto", ".ts"));
const { contents, serviceNames: currentServiceNames } = await codegenService(fileDescriptor, outputFilename);
await mkdir(nodePath.dirname(outputFilename), { recursive: true });
await writeFile(outputFilename, await codegenService(fileDescriptor, outputFilename));
await writeFile(outputFilename, contents);
console.log(`generated ${outputFilename}`);
serviceNames[fileDescriptor.name.replace(".proto", "")] =
currentServiceNames;
}
// Now generate a single file with all the services imported.
{
const chunks = ["// Code generated by tools/codegen.ts, DO NOT EDIT."];
for (const [filename, serviceTypes] of Object.entries(serviceNames)) {
chunks.push(`import { ${Object.values(serviceTypes).join(", ")} } from './${filename}';`);
}
chunks.push("");
chunks.push("export const serviceDefs = {");
for (const serviceTypes of Object.values(serviceNames)) {
for (const [serviceName, serviceTypeName] of Object.entries(serviceTypes)) {
chunks.push(` ${serviceName}: ${serviceTypeName}(),`);
}
}
chunks.push("};");
await writeFile(nodePath.join(outputDirectory, "index.ts"), chunks.join("\n"));
}
// Finally create an executable file that can dump the json.
{
const contents = `#!/bin/env node
import { serializeService } from '@replit/river';
import { serviceDefs } from './index';
console.log(
JSON.stringify(Object.values(serviceDefs).map(serializeService), null, 2)
);`;
const dumpSchemaPath = nodePath.join(outputDirectory, "dumpSchema.ts");
await writeFile(dumpSchemaPath, contents);
const { stdout } = await promisify(execFile)("npx", [
"tsx",
dumpSchemaPath,
]);
await writeFile(nodePath.join(outputDirectory, "schema.json"), stdout);
await unlink(dumpSchemaPath);
}
}

@@ -306,0 +350,0 @@ finally {

{
"name": "@replit/river-codegen",
"description": "codegenning river from grpc",
"version": "0.0.16",
"version": "0.0.17",
"type": "module",

@@ -16,3 +16,2 @@ "bin": {

"tsc-alias": "^1.8.8",
"tsx": "^4.6.1",
"typescript": "^5.3.2",

@@ -26,3 +25,4 @@ "vitest": "^1.0.1"

"prettier": "^3.1.0",
"ts-proto-descriptors": "^1.15.0"
"ts-proto-descriptors": "^1.15.0",
"tsx": "^4.6.1"
},

@@ -29,0 +29,0 @@ "scripts": {

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc