nowaki 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,46 @@
1
+ # nowaki
2
+
3
+ The **Nowaki** CLI — a Rust-powered bundler, dev server, and static-site generator for the [Nowaki](https://nowaki.dev) web framework.
4
+
5
+ This package ships a small Node wrapper that runs a prebuilt native binary for your platform. No Rust toolchain required.
6
+
7
+ ## Install
8
+
9
+ Per project (recommended):
10
+
11
+ ```bash
12
+ npm install --save-dev nowaki
13
+ # or: pnpm add -D nowaki
14
+ ```
15
+
16
+ Globally:
17
+
18
+ ```bash
19
+ npm install -g nowaki
20
+ nowaki --version
21
+ ```
22
+
23
+ ## Usage
24
+
25
+ ```bash
26
+ nowaki dev [dir] # 開発サーバー (HMR + Islands ハイドレーション)
27
+ nowaki build [dir] # 本番ビルド (client + server)
28
+ nowaki start [dir] # ビルド済みアプリを配信
29
+ nowaki prerender [dir] # 静的サイト生成 (SSG)
30
+ ```
31
+
32
+ Scaffold a new app with `npm create nowaki@latest my-app`.
33
+
34
+ ## How it works
35
+
36
+ The native binary is distributed as platform-specific optional dependencies
37
+ (`@nowaki-dev/cli-darwin-arm64`, `@nowaki-dev/cli-linux-x64-gnu`, …). npm/pnpm
38
+ installs only the one matching your `os`/`cpu`/`libc`, and this wrapper resolves
39
+ and executes it. There is no `postinstall` step, so it works with
40
+ `--ignore-scripts` too.
41
+
42
+ Prefer building from source? `cargo install nowaki` also works.
43
+
44
+ ## License
45
+
46
+ MIT
package/bin/nowaki.js ADDED
@@ -0,0 +1,29 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+
4
+ // プリビルドされた Rust 製 nowaki バイナリへ、引数と標準入出力をそのまま委譲する。
5
+ // postinstall は使わず、実行時にプラットフォーム対応パッケージを解決して exec する。
6
+
7
+ const { spawnSync } = require("node:child_process");
8
+ const { resolveBinary } = require("../lib/resolve.js");
9
+
10
+ let binary;
11
+ try {
12
+ binary = resolveBinary();
13
+ } catch (err) {
14
+ console.error(err.message);
15
+ process.exit(1);
16
+ }
17
+
18
+ const result = spawnSync(binary, process.argv.slice(2), { stdio: "inherit" });
19
+
20
+ if (result.error) {
21
+ console.error(`[nowaki] バイナリの起動に失敗しました: ${result.error.message}`);
22
+ process.exit(1);
23
+ }
24
+
25
+ // シグナルで終了した場合は 128 + シグナル番号、それ以外は終了コードをそのまま返す。
26
+ if (result.signal) {
27
+ process.exit(1);
28
+ }
29
+ process.exit(result.status === null ? 1 : result.status);
package/lib/resolve.js ADDED
@@ -0,0 +1,66 @@
1
+ "use strict";
2
+
3
+ // 実行中のプラットフォームに対応する @nowaki-dev/cli-<key> パッケージへ、
4
+ // バイナリの絶対パスを解決する。プリビルドバイナリは optionalDependencies で
5
+ // 配られ、npm/pnpm が os/cpu/libc に一致する1つだけをインストールする。
6
+
7
+ // key -> npm パッケージ名。scripts/build-npm.mjs の TARGETS と一致させること。
8
+ const PACKAGES = {
9
+ "darwin-arm64": "@nowaki-dev/cli-darwin-arm64",
10
+ "darwin-x64": "@nowaki-dev/cli-darwin-x64",
11
+ "linux-x64-gnu": "@nowaki-dev/cli-linux-x64-gnu",
12
+ "linux-arm64-gnu": "@nowaki-dev/cli-linux-arm64-gnu",
13
+ "win32-x64": "@nowaki-dev/cli-win32-x64",
14
+ };
15
+
16
+ // glibc か musl か(linux のみ)。Node の process.report から判定する。
17
+ function detectLibc() {
18
+ try {
19
+ const report = typeof process.report.getReport === "function" ? process.report.getReport() : null;
20
+ const runtime = report && report.header && report.header.glibcVersionRuntime;
21
+ return runtime ? "gnu" : "musl";
22
+ } catch {
23
+ return "gnu";
24
+ }
25
+ }
26
+
27
+ // process.platform / process.arch (+ linux は libc) から解決キーを作る。
28
+ function platformKey() {
29
+ const platform = process.platform;
30
+ const arch = process.arch;
31
+ if (platform === "linux") {
32
+ return `linux-${arch}-${detectLibc()}`;
33
+ }
34
+ return `${platform}-${arch}`;
35
+ }
36
+
37
+ // 対応バイナリの絶対パスを返す。見つからない場合は分かりやすいエラーを投げる。
38
+ function resolveBinary() {
39
+ const key = platformKey();
40
+ const pkg = PACKAGES[key];
41
+ const binName = process.platform === "win32" ? "nowaki.exe" : "nowaki";
42
+
43
+ if (!pkg) {
44
+ const supported = Object.keys(PACKAGES).join(", ");
45
+ throw new Error(
46
+ `Nowaki: このプラットフォーム (${key}) 向けのプリビルドバイナリはありません。\n` +
47
+ `対応: ${supported}\n` +
48
+ `回避策: \`cargo install nowaki\` でソースからビルドするか、` +
49
+ `https://github.com/nowaki-dev/nowaki/issues で対応をリクエストしてください。`,
50
+ );
51
+ }
52
+
53
+ try {
54
+ // 各プラットフォームパッケージは exports を持たない素のファイル袋なので、
55
+ // bin/<name> をサブパス解決できる(esbuild と同方式)。
56
+ return require.resolve(`${pkg}/bin/${binName}`);
57
+ } catch {
58
+ throw new Error(
59
+ `Nowaki: バイナリパッケージ ${pkg} が見つかりません。\n` +
60
+ `optionalDependencies のインストールに失敗した可能性があります。\n` +
61
+ `\`npm install nowaki --force\`(または pnpm/yarn の再インストール)をお試しください。`,
62
+ );
63
+ }
64
+ }
65
+
66
+ module.exports = { resolveBinary, platformKey, PACKAGES };
package/package.json ADDED
@@ -0,0 +1,43 @@
1
+ {
2
+ "name": "nowaki",
3
+ "version": "0.1.1",
4
+ "description": "The Nowaki CLI — Rust-powered bundler, dev server, and SSG for the Nowaki web framework",
5
+ "license": "MIT",
6
+ "author": "Voredge <dev@voredge.com>",
7
+ "homepage": "https://nowaki.dev",
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "git+https://github.com/nowaki-dev/nowaki.git",
11
+ "directory": "packages/nowaki-cli"
12
+ },
13
+ "bugs": "https://github.com/nowaki-dev/nowaki/issues",
14
+ "keywords": [
15
+ "nowaki",
16
+ "cli",
17
+ "bundler",
18
+ "dev-server",
19
+ "ssg",
20
+ "islands",
21
+ "web-framework"
22
+ ],
23
+ "bin": {
24
+ "nowaki": "bin/nowaki.js"
25
+ },
26
+ "files": [
27
+ "bin/",
28
+ "lib/"
29
+ ],
30
+ "optionalDependencies": {
31
+ "@nowaki-dev/cli-darwin-arm64": "0.1.1",
32
+ "@nowaki-dev/cli-darwin-x64": "0.1.1",
33
+ "@nowaki-dev/cli-linux-x64-gnu": "0.1.1",
34
+ "@nowaki-dev/cli-linux-arm64-gnu": "0.1.1",
35
+ "@nowaki-dev/cli-win32-x64": "0.1.1"
36
+ },
37
+ "engines": {
38
+ "node": ">=22"
39
+ },
40
+ "publishConfig": {
41
+ "access": "public"
42
+ }
43
+ }