fix: multi-repo local dev (file:../ deps, package exports, missing deps)

This commit is contained in:
Raven Scott
2026-05-21 20:14:54 -04:00
parent 76e3272ced
commit b63275c6cc
802 changed files with 94636 additions and 4 deletions
+13
View File
@@ -0,0 +1,13 @@
cmake_minimum_required(VERSION 4.0)
find_package(cmake-bare REQUIRED PATHS node_modules/cmake-bare)
project(bare_stdio C)
add_bare_module(bare_stdio)
target_sources(
${bare_stdio}
PRIVATE
binding.c
)
+42
View File
@@ -0,0 +1,42 @@
# bare-stdio
Standard input/output streams for Bare.
```
npm i bare-stdio
```
## Usage
```js
const stdio = require('bare-stdio')
// Write to stdout
stdio.out.write('Hello, World!\n')
// Write to stderr
stdio.err.write('An error occurred\n')
// Read from stdin
stdio.in.on('data', (data) => {
console.log('Received:', data.toString())
})
```
## API
#### `stdio.in`
A readable stream for standard input (`fd 0`). Returns a `bare-tty` `ReadStream` if stdin is a terminal, a `bare-pipe` `Pipe` if it's a pipe, otherwise a `bare-fs` `ReadStream`.
#### `stdio.out`
A writable stream for standard output (`fd 1`). Returns a `bare-tty` `WriteStream` if stdout is a terminal, a `bare-pipe` `Pipe` if it's a pipe, otherwise a `bare-fs` `WriteStream`.
#### `stdio.err`
A writable stream for standard error (`fd 2`). Returns a `bare-tty` `WriteStream` if stderr is a terminal, a `bare-pipe` `Pipe` if it's a pipe, otherwise a `bare-fs` `WriteStream`.
## License
Apache-2.0
+62
View File
@@ -0,0 +1,62 @@
#include <assert.h>
#include <bare.h>
#include <js.h>
#include <uv.h>
static js_value_t *
bare_stdio_guess_type(js_env_t *env, js_callback_info_t *info) {
int err;
size_t argc = 1;
js_value_t *argv[1];
err = js_get_callback_info(env, info, &argc, argv, NULL, NULL);
assert(err == 0);
assert(argc == 1);
int64_t fd;
err = js_get_value_int64(env, argv[0], &fd);
assert(err == 0);
uv_handle_type type = uv_guess_handle(fd);
js_value_t *result;
err = js_create_int64(env, type, &result);
assert(err == 0);
return result;
}
static js_value_t *
bare_stdio_exports(js_env_t *env, js_value_t *exports) {
int err;
#define V(name, msg) \
{ \
js_value_t *val; \
err = js_create_int64(env, UV_##name, &val); \
assert(err == 0); \
err = js_set_named_property(env, exports, #name, val); \
assert(err == 0); \
}
UV_HANDLE_TYPE_MAP(V);
#undef V
#define V(name, fn) \
{ \
js_value_t *val; \
err = js_create_function(env, name, -1, fn, NULL, &val); \
assert(err == 0); \
err = js_set_named_property(env, exports, name, val); \
assert(err == 0); \
}
V("guessType", bare_stdio_guess_type)
#undef V
return exports;
}
BARE_MODULE(bare_stdio, bare_stdio_exports)
+1
View File
@@ -0,0 +1 @@
module.exports = require.addon()
+69
View File
@@ -0,0 +1,69 @@
const fs = require('bare-fs')
const tty = require('bare-tty')
const Pipe = require('bare-pipe')
const binding = require('./binding')
const { TTY, NAMED_PIPE } = binding
class IO {
constructor() {
this._in = null
this._out = null
this._err = null
}
get in() {
if (this._in === null) {
switch (binding.guessType(0)) {
case TTY:
this._in = new tty.ReadStream(0)
break
case NAMED_PIPE:
this._in = new Pipe(0, { eagerOpen: false })
break
default:
this._in = fs.createReadStream(null, { fd: 0, eagerOpen: false })
}
}
return this._in
}
get out() {
if (this._out === null) {
switch (binding.guessType(1)) {
case TTY:
this._out = new tty.WriteStream(1)
break
case NAMED_PIPE:
this._out = new Pipe(1, { eagerOpen: false })
this._out.unref()
break
default:
this._out = fs.createWriteStream(null, { fd: 1, eagerOpen: false })
}
}
return this._out
}
get err() {
if (this._err === null) {
switch (binding.guessType(2)) {
case TTY:
this._err = new tty.WriteStream(2)
break
case NAMED_PIPE:
this._err = new Pipe(2, { eagerOpen: false })
this._err.unref()
break
default:
this._err = fs.createWriteStream(null, { fd: 2, eagerOpen: false })
}
}
return this._err
}
}
module.exports = new IO()
+55
View File
@@ -0,0 +1,55 @@
{
"name": "bare-stdio",
"version": "1.0.2",
"description": "Standard input/output streams for Bare",
"exports": {
".": {
"types": "./index.d.ts",
"default": "./index.js"
},
"./package": "./package.json",
"./constants": "./lib/constants.js",
"./errors": "./lib/errors.js"
},
"files": [
"index.js",
"index.d.ts",
"binding.c",
"binding.js",
"CMakeLists.txt",
"lib",
"prebuilds"
],
"addon": true,
"scripts": {
"format": "prettier --write . && lunte --fix",
"lint": "prettier --check . && lunte",
"test": "brittle-bare --coverage test.js"
},
"repository": {
"type": "git",
"url": "git+https://github.com/holepunchto/bare-stdio.git"
},
"author": "Holepunch",
"license": "Apache-2.0",
"bugs": {
"url": "https://github.com/holepunchto/bare-stdio/issues"
},
"homepage": "https://github.com/holepunchto/bare-stdio#readme",
"dependencies": {
"bare-fs": "^4.5.2",
"bare-pipe": "^4.1.5",
"bare-tty": "^5.0.3"
},
"devDependencies": {
"bare-os": "^3.6.2",
"bare-path": "^3.0.0",
"bare-subprocess": "^3.1.4",
"brittle": "^3.19.1",
"cmake-bare": "^1.7.7",
"lunte": "^1.4.0",
"prettier": "^3.8.1",
"prettier-config-holepunch": "^2.0.0",
"tt-native": "^1.1.1"
}
}
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.