@incajs/cli 0.0.0 → 0.0.2
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/LICENSE +5 -0
- package/README.md +66 -2
- package/bin/inca.mjs +7 -0
- package/dist/adapter/types.d.mts +47 -0
- package/dist/adapter/vite/build.d.mts +8 -0
- package/dist/adapter/vite/captureOutput.d.mts +15 -0
- package/dist/adapter/vite/config.d.mts +26 -0
- package/dist/adapter/vite/index.d.mts +2 -0
- package/dist/adapter/vite/watch.d.mts +8 -0
- package/dist/build.d.mts +21 -0
- package/dist/chunks/__vite-optional-peer-dep_dotenv_c12-CxKvRg9-.js +3 -0
- package/dist/chunks/__vite-optional-peer-dep_giget_c12-BYcrHYBM.js +5 -0
- package/dist/chunks/__vite-optional-peer-dep_jiti_c12-DZVJNj6v.js +5 -0
- package/dist/chunks/_format-BKs7bsc4.js +98 -0
- package/dist/chunks/defaults-EWjAFeZ3.js +1184 -0
- package/dist/chunks/dist-BVKUE9C4.js +114 -0
- package/dist/chunks/json5-feUuPtTt.js +756 -0
- package/dist/chunks/jsonc-BdzClvC8.js +46 -0
- package/dist/chunks/ohash-CHaRSTtv.js +231 -0
- package/dist/chunks/toml-BERh2MAo.js +417 -0
- package/dist/chunks/yaml-N2dF3WHm.js +2123 -0
- package/dist/cli.d.mts +2 -0
- package/dist/cli.js +503 -0
- package/dist/config/defaults.d.mts +44 -0
- package/dist/config/index.d.mts +18 -0
- package/dist/config/loader.d.mts +37 -0
- package/dist/config/types.d.mts +35 -0
- package/dist/config.js +5 -0
- package/dist/defaultBundler.d.mts +7 -0
- package/dist/dev-client/hostBin.d.mts +9 -0
- package/dist/dev-client/hostClient.d.mts +50 -0
- package/dist/dev-client/hostError.d.mts +6 -0
- package/dist/dev-client/index.d.mts +4 -0
- package/dist/dev-client/protocol.d.mts +38 -0
- package/dist/dev.d.mts +25 -0
- package/dist/entry.d.mts +8 -0
- package/dist/fault.d.mts +6 -0
- package/dist/index.d.mts +2 -0
- package/dist/index.js +0 -0
- package/dist/package.d.mts +45 -0
- package/dist/plist.d.mts +4 -0
- package/package.json +64 -3
package/LICENSE
ADDED
package/README.md
CHANGED
|
@@ -1,2 +1,66 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
<!--
|
|
2
|
+
Copyright (c) 2026 tom96da
|
|
3
|
+
SPDX-License-Identifier: MIT OR Apache-2.0
|
|
4
|
+
-->
|
|
5
|
+
|
|
6
|
+
# @incajs/cli
|
|
7
|
+
|
|
8
|
+
The `inca` command for building and running [Incarnative.js](https://github.com/tom96da/incajs)
|
|
9
|
+
apps: `inca dev`, `inca build`, and `inca package`.
|
|
10
|
+
|
|
11
|
+
## Install
|
|
12
|
+
|
|
13
|
+
```sh
|
|
14
|
+
npm i -D @incajs/cli
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## App entry
|
|
18
|
+
|
|
19
|
+
No entry point is required. Drop a `src/App.vue` and that's a whole
|
|
20
|
+
app. Commit a `src/main.mts` instead for full control over
|
|
21
|
+
bootstrapping; it wins outright when both exist.
|
|
22
|
+
|
|
23
|
+
## Commands
|
|
24
|
+
|
|
25
|
+
- **`inca dev`** — watches your app and opens a live-reloading window,
|
|
26
|
+
reloading on every change.
|
|
27
|
+
- **`inca build`** — bundles your app for production, once, with no
|
|
28
|
+
window opened.
|
|
29
|
+
- **`inca package`** — builds your app, then packages it with a
|
|
30
|
+
prebuilt `inca-host` into a distributable application: a `.app` on
|
|
31
|
+
macOS, a plain directory on Linux (other platforms aren't supported
|
|
32
|
+
yet).
|
|
33
|
+
|
|
34
|
+
When running `inca`, it will automatically try to resolve a config file
|
|
35
|
+
named `inca.config.ts` inside your app's root (other JS/JSON extensions
|
|
36
|
+
are also supported), for app metadata and build settings:
|
|
37
|
+
|
|
38
|
+
```ts [inca.config.ts]
|
|
39
|
+
import { defineConfig } from "@incajs/cli/config";
|
|
40
|
+
|
|
41
|
+
export default defineConfig({
|
|
42
|
+
// the app's display name
|
|
43
|
+
productName: "Click Counter",
|
|
44
|
+
// macOS's CFBundleIdentifier or equivalent
|
|
45
|
+
identifier: "com.example.click-counter",
|
|
46
|
+
// the packaged app's icon file
|
|
47
|
+
icon: "assets/icon.icns",
|
|
48
|
+
});
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
An `identifier` should be world-unique, so `inca package` prints a note
|
|
52
|
+
when it falls back to the generated one rather than using it silently.
|
|
53
|
+
|
|
54
|
+
## Requirements
|
|
55
|
+
|
|
56
|
+
`inca`'s host binary is pulled in automatically as a platform-specific
|
|
57
|
+
optional dependency (Linux and macOS on x64/arm64; Windows isn't
|
|
58
|
+
supported yet) — neither Cargo nor Rust are needed. Set `INCA_HOST_BIN`
|
|
59
|
+
to use a specific binary instead, e.g. on a platform with no published
|
|
60
|
+
one yet, or a custom build.
|
|
61
|
+
|
|
62
|
+
## How it works
|
|
63
|
+
|
|
64
|
+
`inca dev`/`build`/`package` bundle your app with Vite, then (for `dev`
|
|
65
|
+
and `package`) launch and supervise `inca-host`, the native runtime
|
|
66
|
+
that renders it, as a child process.
|
package/bin/inca.mjs
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/** A running build watch — the value {@link Bundler.watch} resolves to. */
|
|
2
|
+
export interface Watcher {
|
|
3
|
+
/** Stops watching and releases the underlying build process. */
|
|
4
|
+
close(): Promise<void>;
|
|
5
|
+
}
|
|
6
|
+
/** Options for {@link Bundler.watch}. */
|
|
7
|
+
export interface BundlerOptions {
|
|
8
|
+
/** The app's own entry point — may import `.vue` files. */
|
|
9
|
+
entry: string;
|
|
10
|
+
/** Where the build's output is written. */
|
|
11
|
+
outDir: string;
|
|
12
|
+
/** `"development"` keeps a framework's own warnings; `"production"` strips them. */
|
|
13
|
+
mode: "development" | "production";
|
|
14
|
+
/** Called after each successful (re)build, with what it wrote. */
|
|
15
|
+
onBuild: (output: BuildOutput) => void;
|
|
16
|
+
/** Called instead of `onBuild` when a (re)build fails. */
|
|
17
|
+
onError: (error: {
|
|
18
|
+
message: string;
|
|
19
|
+
stack: string | null;
|
|
20
|
+
}) => void;
|
|
21
|
+
}
|
|
22
|
+
/** Options for {@link Bundler.build}. */
|
|
23
|
+
export interface BuildOptions {
|
|
24
|
+
/** The app's own entry point — may import `.vue` files. */
|
|
25
|
+
entry: string;
|
|
26
|
+
/** Where the build's output is written. */
|
|
27
|
+
outDir: string;
|
|
28
|
+
}
|
|
29
|
+
/** What a build wrote — the result of {@link Bundler.build}, and every {@link BundlerOptions.onBuild} call. */
|
|
30
|
+
export interface BuildOutput {
|
|
31
|
+
/** Directory holding every file this build emitted. */
|
|
32
|
+
outDir: string;
|
|
33
|
+
/** Absolute path to the entry module `inca-host` evaluates. */
|
|
34
|
+
entryFile: string;
|
|
35
|
+
/** Every file this build emitted, relative to `outDir` — may include chunks and assets besides the entry itself. */
|
|
36
|
+
files: readonly string[];
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* The contract a bundler adapter satisfies. Supporting another bundler
|
|
40
|
+
* means adding a sibling adapter module and injecting its `Bundler` here —
|
|
41
|
+
* never editing this package's own types.
|
|
42
|
+
*/
|
|
43
|
+
export interface Bundler {
|
|
44
|
+
watch(options: BundlerOptions): Promise<Watcher>;
|
|
45
|
+
/** One-shot production build, used by `inca build` — rejects on failure. */
|
|
46
|
+
build(options: BuildOptions): Promise<BuildOutput>;
|
|
47
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { BuildOptions, BuildOutput } from '../types.mts';
|
|
2
|
+
export type { BuildOptions, BuildOutput } from '../types.mts';
|
|
3
|
+
/**
|
|
4
|
+
* Builds `entry` into a minified, production build under `outDir` once, and
|
|
5
|
+
* rejects on failure rather than reporting it through a callback. Never
|
|
6
|
+
* starts or talks to `inca-host` — that's `dev.mts`'s job.
|
|
7
|
+
*/
|
|
8
|
+
export declare function build({ entry, outDir }: BuildOptions): Promise<BuildOutput>;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Plugin } from 'vite';
|
|
2
|
+
/** What one (re)build actually wrote, relative to its own `outDir`. */
|
|
3
|
+
export interface CapturedOutput {
|
|
4
|
+
/** The emitted chunk marked as this build's entry. */
|
|
5
|
+
entryFile: string;
|
|
6
|
+
/** Every emitted file, as the bundler reported it. */
|
|
7
|
+
files: readonly string[];
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* A Vite plugin reporting `sink` the files a build wrote once they land on
|
|
11
|
+
* disk, via `writeBundle` — the one hook that fires uniformly for a
|
|
12
|
+
* one-shot build and every watch rebuild, so both read the bundler's real
|
|
13
|
+
* output instead of assuming a file name or layout.
|
|
14
|
+
*/
|
|
15
|
+
export declare function captureOutput(sink: (output: CapturedOutput) => void): Plugin;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { InlineConfig } from 'vite';
|
|
2
|
+
import { CapturedOutput } from './captureOutput.mts';
|
|
3
|
+
export declare const BUNDLE_FILE_NAME = "bundle.js";
|
|
4
|
+
export interface ResolveConfigOptions {
|
|
5
|
+
/** The app's own entry point — may import `.vue` files. */
|
|
6
|
+
entry: string;
|
|
7
|
+
/** Where the build's output is written. */
|
|
8
|
+
outDir: string;
|
|
9
|
+
/** `"development"` keeps `@vue/runtime-core`'s own warnings; `"production"` strips them. */
|
|
10
|
+
mode: "development" | "production";
|
|
11
|
+
/** Whether Vite should keep rebuilding on file changes. */
|
|
12
|
+
watch: boolean;
|
|
13
|
+
/** Called with what each successful (re)build wrote. */
|
|
14
|
+
onOutput: (output: CapturedOutput) => void;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Builds the Vite config shared by `watch` and `build`, compiling `.vue`
|
|
18
|
+
* files via `@vitejs/plugin-vue` targeted at `@vue/runtime-core` rather than
|
|
19
|
+
* the `vue` meta-package it requires to run.
|
|
20
|
+
*
|
|
21
|
+
* An import the entry doesn't inline — a dynamic `import()`, or a `.vue`
|
|
22
|
+
* file's own `<style>` block — lands as its own chunk or asset alongside
|
|
23
|
+
* the entry, named by `chunkFileNames`/`assetFileNames` below, rather than
|
|
24
|
+
* failing the build.
|
|
25
|
+
*/
|
|
26
|
+
export declare function resolveViteConfig({ entry, outDir, mode, watch, onOutput, }: ResolveConfigOptions): InlineConfig;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { BundlerOptions, Watcher } from '../types.mts';
|
|
2
|
+
export type { Watcher } from '../types.mts';
|
|
3
|
+
/**
|
|
4
|
+
* Builds `entry` into a build under `outDir` and rebuilds it on every
|
|
5
|
+
* change, calling `onBuild` with what each rebuild wrote. Never starts,
|
|
6
|
+
* reloads, or talks to `inca-host` — that's `dev.mts`'s job.
|
|
7
|
+
*/
|
|
8
|
+
export declare function watch({ onBuild, onError, ...buildOptions }: BundlerOptions): Promise<Watcher>;
|
package/dist/build.d.mts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { Bundler, BuildOutput } from './adapter/types.mts';
|
|
2
|
+
import { ResolvedBuildConfig } from './config/loader.mts';
|
|
3
|
+
export interface BuildAppOptions {
|
|
4
|
+
/** The app's root directory. Defaults to `process.cwd()`. */
|
|
5
|
+
cwd?: string;
|
|
6
|
+
/**
|
|
7
|
+
* The app's entry point. Defaults to resolving it automatically: a
|
|
8
|
+
* committed `src/main.mts`, or `src/App.vue` wrapped in a synthesized one.
|
|
9
|
+
*/
|
|
10
|
+
entry?: string;
|
|
11
|
+
/** Overrides the bundler — see {@link defaultBundler} for what's wired in by default. */
|
|
12
|
+
bundler?: Bundler;
|
|
13
|
+
/** An already-resolved config — lets `packageApp` avoid loading it twice. */
|
|
14
|
+
config?: ResolvedBuildConfig;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Builds the app once through the same bundler `dev` uses, and returns what
|
|
18
|
+
* it wrote. Rejects on failure — deciding what that means for the process
|
|
19
|
+
* is `cli.mts`'s job.
|
|
20
|
+
*/
|
|
21
|
+
export declare function build(options?: BuildAppOptions): Promise<BuildOutput>;
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
//#region ../../node_modules/.pnpm/confbox@0.3.1/node_modules/confbox/dist/_chunks/libs/detect-indent.mjs
|
|
2
|
+
var e = /^(?:( )+|\t+)/, t = "space";
|
|
3
|
+
function n(e, n, r) {
|
|
4
|
+
return e && n === t && r === 1;
|
|
5
|
+
}
|
|
6
|
+
function r(r, a) {
|
|
7
|
+
let o = /* @__PURE__ */ new Map(), s = 0, c, l;
|
|
8
|
+
for (let u of r.split(/\n/g)) {
|
|
9
|
+
if (!u) continue;
|
|
10
|
+
let r = u.match(e);
|
|
11
|
+
if (r === null) s = 0, c = "";
|
|
12
|
+
else {
|
|
13
|
+
let e = r[0].length, u = r[1] ? t : "tab";
|
|
14
|
+
if (n(a, u, e)) continue;
|
|
15
|
+
u !== c && (s = 0), c = u;
|
|
16
|
+
let d = 1, f = 0, p = e - s;
|
|
17
|
+
if (s = e, p === 0) d = 0, f = 1;
|
|
18
|
+
else {
|
|
19
|
+
let e = Math.abs(p);
|
|
20
|
+
if (n(a, u, e)) continue;
|
|
21
|
+
l = i(u, e);
|
|
22
|
+
}
|
|
23
|
+
let m = o.get(l);
|
|
24
|
+
o.set(l, m === void 0 ? [1, 0] : [m[0] + d, m[1] + f]);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
return o;
|
|
28
|
+
}
|
|
29
|
+
function i(e, n) {
|
|
30
|
+
return (e === t ? "s" : "t") + String(n);
|
|
31
|
+
}
|
|
32
|
+
function a(e) {
|
|
33
|
+
return {
|
|
34
|
+
type: e[0] === "s" ? t : "tab",
|
|
35
|
+
amount: Number(e.slice(1))
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
function o(e) {
|
|
39
|
+
let t, n = 0, r = 0;
|
|
40
|
+
for (let [i, [a, o]] of e) (a > n || a === n && o > r) && (n = a, r = o, t = i);
|
|
41
|
+
return t;
|
|
42
|
+
}
|
|
43
|
+
function s(e, n) {
|
|
44
|
+
return (e === t ? " " : " ").repeat(n);
|
|
45
|
+
}
|
|
46
|
+
function c(e) {
|
|
47
|
+
if (typeof e != "string") throw TypeError("Expected a string");
|
|
48
|
+
let t = r(e, !0);
|
|
49
|
+
t.size === 0 && (t = r(e, !1));
|
|
50
|
+
let n = o(t), i, c = 0, l = "";
|
|
51
|
+
return n !== void 0 && ({type: i, amount: c} = a(n), l = s(i, c)), {
|
|
52
|
+
amount: c,
|
|
53
|
+
type: i,
|
|
54
|
+
indent: l
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
//#endregion
|
|
58
|
+
//#region ../../node_modules/.pnpm/confbox@0.3.1/node_modules/confbox/dist/_chunks/_format.mjs
|
|
59
|
+
var l = Symbol.for("__confbox_fmt__"), u = /^(\s+)/, d = /(\s+)$/;
|
|
60
|
+
function f(e) {
|
|
61
|
+
return e.charCodeAt(0) === 65279 ? e.slice(1) : e;
|
|
62
|
+
}
|
|
63
|
+
function p(e, t = {}) {
|
|
64
|
+
return {
|
|
65
|
+
sample: t.indent === void 0 && t.preserveIndentation !== !1 && f(e).slice(0, t?.sampleSize || 1024),
|
|
66
|
+
whiteSpace: t.preserveWhitespace === !1 ? void 0 : {
|
|
67
|
+
start: u.exec(e)?.[0] || "",
|
|
68
|
+
end: d.exec(e)?.[0] || ""
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
function m(e, t, n) {
|
|
73
|
+
!t || typeof t != "object" || Object.defineProperty(t, l, {
|
|
74
|
+
enumerable: !1,
|
|
75
|
+
configurable: !0,
|
|
76
|
+
writable: !0,
|
|
77
|
+
value: p(e, n)
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
function h(e, t) {
|
|
81
|
+
if (!e || typeof e != "object" || !(l in e)) return {
|
|
82
|
+
indent: t?.indent ?? 2,
|
|
83
|
+
whitespace: {
|
|
84
|
+
start: "",
|
|
85
|
+
end: ""
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
let n = e[l];
|
|
89
|
+
return {
|
|
90
|
+
indent: t?.indent || c(n.sample || "").indent,
|
|
91
|
+
whitespace: n.whiteSpace || {
|
|
92
|
+
start: "",
|
|
93
|
+
end: ""
|
|
94
|
+
}
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
//#endregion
|
|
98
|
+
export { m as n, h as r, f as t };
|