This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env -S npx tsx | |
// See here how to run this plugin: https://github.com/bufbuild/protobuf-es/tree/main/packages/protoplugin-example | |
import { createEcmaScriptPlugin, runNodeJs } from "@bufbuild/protoplugin"; | |
import type { Schema } from "@bufbuild/protoplugin/ecmascript"; | |
import type { | |
DescEnum, | |
DescExtension, | |
DescFile, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import {npmHighImpact} from 'npm-high-impact' | |
import {readFileSync, existsSync, writeFileSync} from "node:fs"; | |
void main(); | |
async function main() { | |
const pkgs = await getPackages(); | |
const exports = pkgs.filter(pkg => | |
hasExports(pkg, (obj => { | |
return true; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** @type {import('jest').Config} */ | |
module.exports = { | |
transform: { | |
"^.+\\.(ts|tsx)$": ["ts-jest", {}], | |
}, | |
testEnvironment: "jsdom", | |
globals: { | |
TextEncoder: TextEncoder, | |
TextDecoder: TextDecoder, | |
Uint8Array: Uint8Array, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import type {Analysis, FS, Host} from "@arethetypeswrong/core"; | |
import {checkPackage, getProblems, summarizeProblems} from "@arethetypeswrong/core"; | |
import {readdirSync, readFileSync} from "node:fs"; | |
import path from "node:path"; | |
import {z} from "zod"; | |
export async function typeswrong(projectPath: string) { | |
const pkgPath = path.join(projectPath, "package.json"); | |
const pkg = readJsonFile(pkgPath, PackageJson); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Copyright 2021-2023 Buf Technologies, Inc. | |
// | |
// Licensed under the Apache License, Version 2.0 (the "License"); | |
// you may not use this file except in compliance with the License. | |
// You may obtain a copy of the License at | |
// | |
// http://www.apache.org/licenses/LICENSE-2.0 | |
// | |
// Unless required by applicable law or agreed to in writing, software | |
// distributed under the License is distributed on an "AS IS" BASIS, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
default: | |
buf generate buf.build/bufbuild/eliza |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// place this file in pages/api/[[...connect]].ts | |
// Copyright 2021-2023 Buf Technologies, Inc. | |
// | |
// Licensed under the Apache License, Version 2.0 (the "License"); | |
// you may not use this file except in compliance with the License. | |
// You may obtain a copy of the License at | |
// | |
// http://www.apache.org/licenses/LICENSE-2.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
version: v1 | |
plugins: | |
- name: oneofhelper | |
path: ./src/protoc-gen-oneofhelper.ts | |
opt: target=ts | |
out: src/gen |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
default: | |
buf generate buf.build/bufbuild/eliza | |
deno lint . | |
deno run --import-map import_map.json --allow-net client.ts |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import {localName, GeneratedFile, ImportSymbol, Schema} from "@bufbuild/protoplugin/ecmascript"; | |
import type {DescMessage} from "@bufbuild/protobuf"; | |
export function generateTs(schema: Schema) { | |
const map = new Map<DescMessage, ImportSymbol>(); | |
function getFunctionName(f: GeneratedFile, message: DescMessage): ImportSymbol { | |
let s = map.get(message); | |
if (!s) { | |
s = f.export(`validate${localName(message)}`); | |
map.set(message, s); |
NewerOlder