Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,8 @@ luacov.stats.out

# Python
tests/__pycache__

# Node
lib/
node_module/
package-lock.json
53 changes: 53 additions & 0 deletions Cargo.lock

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

7 changes: 7 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ lua52 = ["luamodule", "mlua/lua52"]
lua51 = ["luamodule", "mlua/lua51"]
luajit = ["luamodule", "mlua/luajit"]
pythonmodule = ["pyo3"]
nodemodule = ["neon"]

[profile.release]
lto = true
Expand All @@ -58,6 +59,12 @@ unicode_titlecase = "2.3"
optional = true
features = ["module"]

[dependencies.neon]
version = "1.0"
optional = true
default-features = false
# features = ["napi-8"]

[dependencies.pyo3]
version = "0.22"
optional = true
Expand Down
4 changes: 2 additions & 2 deletions Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ docdir = $(datarootdir)/doc/$(TRANSFORMED_PACKAGE_NAME)
licensedir = $(datarootdir)/licenses/$(TRANSFORMED_PACKAGE_NAME)

bin_PROGRAMS = decasify
decasify_SOURCES = src/bin/decasify.rs src/cli.rs src/lib.rs src/lua.rs src/python.rs src/types.rs
decasify_SOURCES = src/bin/decasify.rs src/cli.rs src/lib.rs src/lua.rs src/node.rs src/python.rs src/types.rs
EXTRA_decasify_SOURCES = tests/cli.rs
EXTRA_DIST = pyproject.toml spec/decasify_spec.lua tests/test_all.py
EXTRA_DIST = package.json pyproject.toml spec/decasify_spec.lua tests/test_all.py
dist_doc_DATA = README.md CHANGELOG.md
dist_license_DATA = LICENSE.md
nodist_man_MANS =
Expand Down
3 changes: 3 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ AM_COND_IF([DEVELOPER_MODE], [
QUE_PROGVAR([maturin])
QUE_PROGVAR([pytest])
QUE_PROGVAR([uv])
# Node build and testing dependencies
QUE_PROGVAR([node])
QUE_PROGVAR([tsc])
# Release tooling
QUE_PROGVAR([gitcliff], [git-cliff])
])
Expand Down
42 changes: 42 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{
"name": "decasify",
"version": "0.5.5",
"description": "A CLI utility and library to cast strings to title-case according to locale specific style guides including Turkish support",
"main": "./lib/index.cjs",
"scripts": {
"build": "tsc && cargo build --features nodemodule --release --message-format=json > cargo.log"
},
"author": "Caleb Maclennan <caleb@alerque.com>",
"license": "GPL-3.0-only",
"exports": {
".": {
"import": {
"types": "./lib/index.d.mts",
"default": "./lib/index.mjs"
},
"require": {
"types": "./lib/index.d.cts",
"default": "./lib/index.cjs"
}
}
},
"types": "./lib/index.d.cts",
"files": [
"lib/**/*.?({c,m}){t,j}s"
],
"neon": {
"type": "library",
"org": "@nus",
"platforms": "common",
"load": "./src/load.cts"
},
"devDependencies": {
"neon-cli": "^0.4",
"@tsconfig/node20": "^20.1",
"@types/node": "^20.14",
"typescript": "^5.5"
},
"dependencies": {
"@neon-rs/load": "^0.1"
}
}
19 changes: 19 additions & 0 deletions src/index.cts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// This module is the CJS entry point for the library.

// The Rust addon.
import * as addon from './load.cjs';

// Use this declaration to assign types to the addon's exports,
// which otherwise by default are `any`.
declare module "./load.cjs" {
function hello(): string;
}

export type Greeting = {
message: string
};

export function greeting(): Greeting {
const message = addon.hello();
return { message };
}
3 changes: 3 additions & 0 deletions src/index.mts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// This module is the ESM entry point for the library.

export * from './index.cjs';
3 changes: 3 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ pub use types::{InputLocale, Result, StyleGuide, TargetCase};
#[cfg(feature = "cli")]
pub mod cli;

#[cfg(feature = "nodemodule")]
pub mod node;

#[cfg(feature = "luamodule")]
pub mod lua;

Expand Down
16 changes: 16 additions & 0 deletions src/load.cts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// This module loads the platform-specific build of the addon on
// the current system. The supported platforms are registered in
// the `platforms` object below, whose entries can be managed by
// by the Neon CLI:
//
// https://www.npmjs.com/package/@neon-rs/cli

module.exports = require('@neon-rs/load').proxy({
platforms: {
'win32-x64-msvc': () => require('@nus/win32-x64-msvc'),
'darwin-x64': () => require('@nus/darwin-x64'),
'darwin-arm64': () => require('@nus/darwin-arm64'),
'linux-x64-gnu': () => require('@nus/linux-x64-gnu')
},
debug: () => require('../index.node')
});
12 changes: 12 additions & 0 deletions src/node.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
use crate::*;
use neon::prelude::*;

#[neon::main]
fn main(mut cx: ModuleContext) -> NeonResult<()> {
cx.export_function("titlecase", titlecase)?;
Ok(())
}

fn titlecase(mut cx: FunctionContext) -> JsResult<JsString> {
Ok(cx.string("foo"))
}