Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into fix/merge-right
Browse files Browse the repository at this point in the history
  • Loading branch information
meskill committed Sep 30, 2024
2 parents 744268a + 2b518fd commit 31d4b9f
Show file tree
Hide file tree
Showing 76 changed files with 466 additions and 393 deletions.
213 changes: 118 additions & 95 deletions Cargo.lock

Large diffs are not rendered by default.

5 changes: 4 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ anyhow = "1.0.82"
async-graphql = { version = "7.0.9" }
futures-util = { version = "0.3.30" }
indexmap = "2.2.6"
headers = "0.3.9" # previous version until hyper is updated to 1+
http = "0.2.12" # previous version until hyper is updated to 1+
insta = { version = "1.38.0", features = ["json"] }
tokio = { version = "1.37.0", features = ["rt", "time"] }
reqwest = { version = "0.11", features = [
Expand Down Expand Up @@ -138,7 +140,8 @@ opentelemetry-prometheus = "0.16.0"
phonenumber = "0.3.4"
chrono = "0.4.38"
async-graphql-extension-apollo-tracing = { version = "3.2.15" }
headers = "0.3.9" # previous version until hyper is updated to 1+
headers = { workspace = true }
http = { workspace = true }
mime = "0.3.17"
htpasswd-verify = { version = "0.3.0", git = "https://github.com/twistedfall/htpasswd-verify", rev = "ff14703083cbd639f7d05622b398926f3e718d61" } # fork version that is wasm compatible
jsonwebtoken = "9.3.0"
Expand Down
2 changes: 1 addition & 1 deletion benches/from_json_bench.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use criterion::Criterion;
use hyper::Method;
use http::Method;
use serde_json::Value;
use tailcall::cli::runtime::NativeHttp;
use tailcall::core::generator::{Generator, Input};
Expand Down
2 changes: 1 addition & 1 deletion benches/handle_request_bench.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std::sync::Arc;

use criterion::Criterion;
use hyper::Request;
use http::Request;
use tailcall::cli::server::server_config::ServerConfig;
use tailcall::core::async_graphql_hyper::GraphQLRequest;
use tailcall::core::blueprint::Blueprint;
Expand Down
2 changes: 1 addition & 1 deletion benches/http_execute_bench.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use criterion::Criterion;
use hyper::Method;
use http::Method;
use tailcall::cli::runtime::NativeHttp;
use tailcall::core::blueprint::Blueprint;
use tailcall::core::HttpIO;
Expand Down
6 changes: 3 additions & 3 deletions benches/impl_path_string_for_evaluation_context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,9 @@ use std::time::Duration;
use async_graphql::{Name, Value};
use async_trait::async_trait;
use criterion::{BenchmarkId, Criterion};
use http::header::{HeaderMap, HeaderValue};
use http_cache_reqwest::{Cache, CacheMode, HttpCache, HttpCacheOptions};
use hyper::body::Bytes;
use hyper::header::HeaderValue;
use hyper::HeaderMap;
use indexmap::IndexMap;
use once_cell::sync::Lazy;
use reqwest::{Client, Request};
Expand Down Expand Up @@ -39,7 +38,8 @@ impl Http {
.http2_keep_alive_while_idle(upstream.keep_alive_while_idle)
.pool_idle_timeout(Some(Duration::from_secs(upstream.pool_idle_timeout)))
.pool_max_idle_per_host(upstream.pool_max_idle_per_host)
.user_agent(upstream.user_agent.clone());
.user_agent(upstream.user_agent.clone())
.danger_accept_invalid_certs(!upstream.verify_ssl);

// Add Http2 Prior Knowledge
if upstream.http2_only {
Expand Down
2 changes: 1 addition & 1 deletion benches/request_template_bench.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use std::borrow::Cow;

use criterion::{black_box, Criterion};
use derive_setters::Setters;
use hyper::HeaderMap;
use http::header::HeaderMap;
use serde_json::json;
use tailcall::core::endpoint::Endpoint;
use tailcall::core::has_headers::HasHeaders;
Expand Down
7 changes: 7 additions & 0 deletions generated/.tailcallrc.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -431,6 +431,13 @@ directive @upstream(
The User-Agent header value to be used in HTTP requests. @default `Tailcall/1.0`
"""
userAgent: String
"""
A boolean value that determines whether to verify certificates. Setting this as `false`
will make tailcall accept self-signed certificates. NOTE: use this *only* during
development or testing. It is highly recommended to keep this enabled (`true`) in
production.
"""
verifySSL: Boolean
) on SCHEMA

"""
Expand Down
7 changes: 7 additions & 0 deletions generated/.tailcallrc.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -1661,6 +1661,13 @@
"string",
"null"
]
},
"verifySSL": {
"description": "A boolean value that determines whether to verify certificates. Setting this as `false` will make tailcall accept self-signed certificates. NOTE: use this *only* during development or testing. It is highly recommended to keep this enabled (`true`) in production.",
"type": [
"boolean",
"null"
]
}
},
"additionalProperties": false
Expand Down
38 changes: 19 additions & 19 deletions npm/gen-root.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import * as fs from "fs/promises"
import {resolve, dirname} from "path"
import * as yml from "yaml"
import {fileURLToPath} from "url"
import {parse} from "ts-command-line-args"
import {PackageJson as IPackageJSON} from "type-fest"
import YML from "yaml"

const __dirname = dirname(fileURLToPath(import.meta.url))

Expand All @@ -17,29 +17,36 @@ const options = parse<ICLI>({
name: {alias: "n", type: String},
})

async function get_build_matrix() {
async function getBuildDefinitions(): Promise<string[]> {
const ciYMLPath = resolve(__dirname, "../.github/workflows/build_matrix.yml")
const ciYML = await fs.readFile(ciYMLPath, "utf8").then(YML.parse)
const ciYML = await fs.readFile(ciYMLPath, "utf8").then(yml.parse)
const steps = ciYML.jobs["setup-matrix"].steps

for (const step of steps) {
const matrix = step?.with?.matrix

if (matrix) {
// Parse yaml again since matrix is defined as string inside setup-matrix
return YML.parse(matrix)
return yml.parse(matrix).build
}
}

throw new Error("Cannot find matrix definition in workflow file")
}

async function genServerPackage() {
async function genServerPackage(buildDefinitions: string[]) {
const packageVersion = options.version || "0.1.0"
const name = options.name || "@tailcallhq/tailcall"

console.log(`Generating package.json with version ${packageVersion}`)

// Construct the optionalDependencies object with the provided version
const optionalDependencies: Record<string, string> = {}

for (const buildDef of buildDefinitions) {
optionalDependencies[`@tailcallhq/core-${buildDef}`] = packageVersion
}

const packageJson = await fs.readFile(resolve(__dirname, "./package.json"), "utf8")
const basePackage = JSON.parse(packageJson) as IPackageJSON
const {description, license, repository, homepage, keywords} = basePackage
Expand All @@ -53,49 +60,42 @@ async function genServerPackage() {
name: name,
type: "module",
version: packageVersion,
optionalDependencies,
scarfSettings: {
defaultOptIn: true,
allowTopLevel: true,
},
dependencies: {
"detect-libc": "^2.0.2",
"@scarf/scarf": "^1.3.0",
yaml: "^2.3.3",
axios: "^1.7.4",
},
scripts: {
postinstall: "node ./scripts/post-install.js",
preinstall: "node ./scripts/pre-install.js",
},
bin: {
tailcall: "bin/tailcall", // will replace with respective platform binary later.
},
}

// Define the directory path where the package.json should be created
const directoryPath = resolve(__dirname, "@tailcallhq/tailcall")
const scriptsPath = resolve(directoryPath, "./scripts")
const binPath = resolve(directoryPath, "./bin")

await fs.mkdir(scriptsPath, {recursive: true})
await fs.mkdir(binPath, {recursive: true})
await fs.mkdir(directoryPath, {recursive: true})

const postInstallScript = await fs.readFile(resolve(__dirname, "./post-install.js"), "utf8")
const preInstallScript = await fs.readFile(resolve(__dirname, "./pre-install.js"), "utf8")
const utilsScript = await fs.readFile(resolve(__dirname, "./utils.js"), "utf8")
const stringified_yaml = YML.stringify(await get_build_matrix())

const postInstallScriptContent = `const version = "${packageVersion}";\n${postInstallScript}`
const preInstallScriptContent = `const optionalDependencies = ${JSON.stringify(
optionalDependencies,
)};\n${preInstallScript}`

await fs.writeFile(resolve(scriptsPath, "post-install.js"), postInstallScriptContent, "utf8")
await fs.writeFile(resolve(scriptsPath, "pre-install.js"), preInstallScript, "utf8")
await fs.writeFile(resolve(scriptsPath, "utils.js"), utilsScript, "utf8")
await fs.writeFile(resolve(directoryPath, "./build-matrix.yaml"), stringified_yaml, "utf8")

await fs.writeFile(resolve(scriptsPath, "pre-install.js"), preInstallScriptContent, "utf8")
await fs.writeFile(resolve(directoryPath, "./package.json"), JSON.stringify(tailcallPackage, null, 2), "utf8")

await fs.copyFile(resolve(__dirname, "../README.md"), resolve(directoryPath, "./README.md"))
}

await genServerPackage()
const buildDefinitions = await getBuildDefinitions()
await genServerPackage(buildDefinitions)
94 changes: 93 additions & 1 deletion npm/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion npm/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@
"dependencies": {
"ts-command-line-args": "^2.5.1",
"type-fest": "^4.7.1",
"yaml": "^2.3.3"
"yaml": "^2.3.3",
"yml": "^1.0.0"
},
"devDependencies": {
"tsx": "^4.1.0"
Expand Down
Loading

0 comments on commit 31d4b9f

Please sign in to comment.