Skip to content

Commit

Permalink
Idk
Browse files Browse the repository at this point in the history
  • Loading branch information
Ziothh committed Nov 3, 2023
1 parent 5cf6907 commit d86784e
Show file tree
Hide file tree
Showing 8 changed files with 108 additions and 6 deletions.
31 changes: 31 additions & 0 deletions .github/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
changelog:
categories:
- title: 🏕 Features
labels:
- '*'
exclude:
labels:
- dependencies
- title: 👒 Dependencies
labels:
- dependencies

# changelog:
# exclude:
# labels:
# - ignore-for-release
# authors:
# - octocat
# categories:
# - title: Breaking Changes 🛠
# labels:
# - Semver-Major
# - breaking-change
# - title: Exciting New Features 🎉
# labels:
# - Semver-Minor
# - enhancement
# - title: Other Changes
# labels:
# - "*"
#
6 changes: 6 additions & 0 deletions .github/workflows/cd.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
name: "Continuous Deployment"

on:
push:
tags:
- 'v*.*.*'
11 changes: 6 additions & 5 deletions bin/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,12 @@ pub fn main() -> anyhow::Result<()> {
let config = specta::ts::ExportConfiguration::new()
.bigint(specta::ts::BigIntExportBehavior::Number);

#[rustfmt::skip]
let mut file = File::create(
Path::new(&std::env::var("OUT_DIR").unwrap())
.join("../../../../../lib/generated/rustTypes.d.ts"),
)?;
// The directory of the binary crate
let crate_dir = std::env::var("CARGO_MANIFEST_DIR")?;

let out = Path::new(&crate_dir).join("../lib/generated/rustTypes.d.ts");

let mut file = File::create(Path::new(&out))?;

let contents = [
"/* THIS FILE HAS BEEN AUTOMATICALLY GENERATED AND CONTAINS TYPES THAT CORESPOND WITH THE RUST BINARY */\n".to_owned(),
Expand Down
7 changes: 7 additions & 0 deletions lib/.npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
src
node_modules
.gitignore
.npmignore
.npmrc
download
dist/tsconfig.tsbuildinfo
41 changes: 41 additions & 0 deletions lib/bin/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#! /usr/bin/env node

import { spawnSync } from "child_process";

/**
* Returns the executable path which is located inside `node_modules`
* The naming convention is app-${os}-${arch}
* If the platform is `win32` or `cygwin`, executable will include a `.exe` extension.
* @see https://nodejs.org/api/os.html#osarch
* @see https://nodejs.org/api/os.html#osplatform
* @example "x/xx/node_modules/app-darwin-arm64"
*/
function getExePath() {
const arch = process.arch;
let os = process.platform as string;
let extension = "";
if (["win32", "cygwin"].includes(process.platform)) {
os = "windows";
extension = ".exe";
}

try {
// Since the binary will be located inside `node_modules`, we can simply call `require.resolve`
return require.resolve(`@next-typed-routes/bin-${os}-${arch}/bin/app${extension}`);
} catch (e) {
throw new Error(
`Couldn't find application binary inside node_modules for ${os}-${arch}`
);
}
}

/**
* Runs the application with args using nodejs spawn
*/
function run() {
const args = process.argv.slice(2);
const processResult = spawnSync(getExePath(), args, { stdio: "inherit" });
process.exit(processResult.status ?? 0);
}

run();
2 changes: 2 additions & 0 deletions lib/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,7 @@
},
"peerDependencies": {
"next": "^13.4.13"
},
"optionalDependencies": {
}
}
4 changes: 3 additions & 1 deletion lib/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"compilerOptions": {
"outDir": "dist",
"target": "ESNext",
"lib": [
"dom",
Expand Down Expand Up @@ -27,6 +28,7 @@
"../playground/generated/routes.ts"
],
"exclude": [
"node_modules"
"node_modules",
"dist"
]
}
12 changes: 12 additions & 0 deletions rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[toolchain]
channel = "nightly"
# components = [ "rustfmt", "rustc-dev" ]
targets = [
"x86_64-unknown-linux-gnu",
# "aarch64-unknown-linux-gnu",
# "x86_64-pc-windows-msvc"
# "aarch64-pc-windows-msvc"
"x86_64-apple-darwin"
# "aarch64-apple-darwin"
]

0 comments on commit d86784e

Please sign in to comment.