@incajs/cli 0.0.1 → 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/README.md +49 -91
- package/dist/build.d.mts +3 -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.js +205 -183
- 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/index.d.mts +1 -0
- package/package.json +20 -14
- package/dist/metadata.d.mts +0 -30
package/README.md
CHANGED
|
@@ -5,104 +5,62 @@ SPDX-License-Identifier: MIT OR Apache-2.0
|
|
|
5
5
|
|
|
6
6
|
# @incajs/cli
|
|
7
7
|
|
|
8
|
-
The `inca` command
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
on, and never starts a host. `inca package` builds the same way, then
|
|
17
|
-
pairs the bundle with a prebuilt `inca-host` into a distributable
|
|
18
|
-
application. `adapter/vite` is the bundler wired in by default for all
|
|
19
|
-
three — swapping it for another `Bundler` (the contract `adapter/types.mts`
|
|
20
|
-
defines) is a dependency change in `defaultBundler.mts`, not an edit
|
|
21
|
-
anywhere else.
|
|
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
|
+
```
|
|
22
16
|
|
|
23
17
|
## App entry
|
|
24
18
|
|
|
25
|
-
No entry point is required. Drop a `src/App.vue` and that's a whole
|
|
26
|
-
|
|
27
|
-
itself. Commit a `src/main.mts` instead for full control over
|
|
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
|
|
28
21
|
bootstrapping; it wins outright when both exist.
|
|
29
22
|
|
|
30
|
-
##
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
`
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
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
|
+
});
|
|
53
49
|
```
|
|
54
50
|
|
|
55
51
|
An `identifier` should be world-unique, so `inca package` prints a note
|
|
56
52
|
when it falls back to the generated one rather than using it silently.
|
|
57
53
|
|
|
58
|
-
##
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
integration the caller registered for it.
|
|
72
|
-
|
|
73
|
-
A line the host writes that doesn't parse as a JSON-RPC message is treated
|
|
74
|
-
as stray output from a dependency, not a protocol violation: it's logged
|
|
75
|
-
and the channel keeps reading.
|
|
76
|
-
|
|
77
|
-
`resolveHostBin` tries, in order:
|
|
78
|
-
|
|
79
|
-
1. `INCA_HOST_BIN`, if set — names the binary to spawn outright. This is
|
|
80
|
-
the escape hatch for a platform with no published binary yet, or a
|
|
81
|
-
custom-built one.
|
|
82
|
-
2. The `optionalDependency` matching this OS/arch
|
|
83
|
-
(`@incajs/host-darwin-arm64`, `-darwin-x64`, `-linux-arm64`,
|
|
84
|
-
`-linux-x64` — Windows isn't supported yet), which almost every install
|
|
85
|
-
resolves through without either side ever needing Cargo or Rust.
|
|
86
|
-
|
|
87
|
-
@throws if neither resolves.
|
|
88
|
-
|
|
89
|
-
## `adapter/vite`
|
|
90
|
-
|
|
91
|
-
Bundles an app's entry point into one self-contained bundle that
|
|
92
|
-
`inca-host` can evaluate: no unresolved imports, no dependency on
|
|
93
|
-
QuickJS having Node.js globals.
|
|
94
|
-
|
|
95
|
-
`watch(options)` builds `options.entry` into a bundle under
|
|
96
|
-
`options.outDir` — the returned `Watcher`'s `bundlePath` names the exact
|
|
97
|
-
file — rebuilding it on every change and reporting each result through
|
|
98
|
-
`options.onBuild`/`options.onError`. `build(options)` runs the same
|
|
99
|
-
pipeline once, minified and with `outDir` cleared first, resolving with
|
|
100
|
-
the bundle's path or rejecting on failure rather than reporting it
|
|
101
|
-
through a callback.
|
|
102
|
-
|
|
103
|
-
The template compiler is retargeted at `@vue/runtime-core` — the only Vue
|
|
104
|
-
runtime package `incajs/vue` itself depends on — instead of the default
|
|
105
|
-
`vue` import. `@vitejs/plugin-vue` itself still imports `vue` directly for
|
|
106
|
-
its own internals, which is why it's a peer dependency of this package:
|
|
107
|
-
that build-time need for `vue` never reaches an app's dependency tree or
|
|
108
|
-
the bundle it produces.
|
|
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/dist/build.d.mts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Bundler, BuildOutput } from './adapter/types.mts';
|
|
2
|
+
import { ResolvedBuildConfig } from './config/loader.mts';
|
|
2
3
|
export interface BuildAppOptions {
|
|
3
4
|
/** The app's root directory. Defaults to `process.cwd()`. */
|
|
4
5
|
cwd?: string;
|
|
@@ -9,6 +10,8 @@ export interface BuildAppOptions {
|
|
|
9
10
|
entry?: string;
|
|
10
11
|
/** Overrides the bundler — see {@link defaultBundler} for what's wired in by default. */
|
|
11
12
|
bundler?: Bundler;
|
|
13
|
+
/** An already-resolved config — lets `packageApp` avoid loading it twice. */
|
|
14
|
+
config?: ResolvedBuildConfig;
|
|
12
15
|
}
|
|
13
16
|
/**
|
|
14
17
|
* Builds the app once through the same bundler `dev` uses, and returns what
|
|
@@ -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 };
|