@incajs/cli 0.0.1 → 0.0.3
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/adapter/types.d.mts +26 -0
- package/dist/adapter/vite/build.d.mts +1 -1
- package/dist/adapter/vite/config.d.mts +7 -1
- package/dist/adapter/vite/logger.d.mts +7 -0
- package/dist/adapter/vite/unsupported.d.mts +23 -0
- package/dist/adapter/vite/watch.d.mts +1 -1
- package/dist/build.d.mts +7 -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-D_1rymg4.js +1184 -0
- package/dist/chunks/dist-DZ5asakr.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 +427 -249
- 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/dev-client/hostClient.d.mts +5 -0
- package/dist/dev-lock.d.mts +10 -0
- package/dist/dev.d.mts +4 -1
- package/dist/error.d.mts +11 -0
- package/dist/index.d.mts +1 -0
- package/dist/log.d.mts +28 -0
- package/dist/package.d.mts +3 -1
- package/package.json +20 -14
- package/dist/fault.d.mts +0 -6
- 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/adapter/types.d.mts
CHANGED
|
@@ -17,7 +17,18 @@ export interface BundlerOptions {
|
|
|
17
17
|
onError: (error: {
|
|
18
18
|
message: string;
|
|
19
19
|
stack: string | null;
|
|
20
|
+
code?: string | null;
|
|
20
21
|
}) => void;
|
|
22
|
+
/** Where the bundler's own output goes. Defaults to `process.stdout`. */
|
|
23
|
+
stdout?: NodeJS.WritableStream;
|
|
24
|
+
/** Where the bundler's warnings and errors go. Defaults to `process.stderr`. */
|
|
25
|
+
stderr?: NodeJS.WritableStream;
|
|
26
|
+
/**
|
|
27
|
+
* Drops the bundler's progress output and size report, leaving the
|
|
28
|
+
* per-build summary. Set it when the build has to stay silent: part of
|
|
29
|
+
* that output goes to the process's own stdout, not to `stdout` above.
|
|
30
|
+
*/
|
|
31
|
+
quiet?: boolean;
|
|
21
32
|
}
|
|
22
33
|
/** Options for {@link Bundler.build}. */
|
|
23
34
|
export interface BuildOptions {
|
|
@@ -25,6 +36,16 @@ export interface BuildOptions {
|
|
|
25
36
|
entry: string;
|
|
26
37
|
/** Where the build's output is written. */
|
|
27
38
|
outDir: string;
|
|
39
|
+
/** Where the bundler's own output goes. Defaults to `process.stdout`. */
|
|
40
|
+
stdout?: NodeJS.WritableStream;
|
|
41
|
+
/** Where the bundler's warnings and errors go. Defaults to `process.stderr`. */
|
|
42
|
+
stderr?: NodeJS.WritableStream;
|
|
43
|
+
/**
|
|
44
|
+
* Drops the bundler's progress output and size report, leaving the
|
|
45
|
+
* per-build summary. Set it when the build has to stay silent: part of
|
|
46
|
+
* that output goes to the process's own stdout, not to `stdout` above.
|
|
47
|
+
*/
|
|
48
|
+
quiet?: boolean;
|
|
28
49
|
}
|
|
29
50
|
/** What a build wrote — the result of {@link Bundler.build}, and every {@link BundlerOptions.onBuild} call. */
|
|
30
51
|
export interface BuildOutput {
|
|
@@ -34,6 +55,11 @@ export interface BuildOutput {
|
|
|
34
55
|
entryFile: string;
|
|
35
56
|
/** Every file this build emitted, relative to `outDir` — may include chunks and assets besides the entry itself. */
|
|
36
57
|
files: readonly string[];
|
|
58
|
+
/** The change that triggered this rebuild. Absent from a one-shot build and a watch's first build. */
|
|
59
|
+
changed?: {
|
|
60
|
+
file: string;
|
|
61
|
+
at: number;
|
|
62
|
+
};
|
|
37
63
|
}
|
|
38
64
|
/**
|
|
39
65
|
* The contract a bundler adapter satisfies. Supporting another bundler
|
|
@@ -5,4 +5,4 @@ export type { BuildOptions, BuildOutput } from '../types.mts';
|
|
|
5
5
|
* rejects on failure rather than reporting it through a callback. Never
|
|
6
6
|
* starts or talks to `inca-host` — that's `dev.mts`'s job.
|
|
7
7
|
*/
|
|
8
|
-
export declare function build({ entry, outDir }: BuildOptions): Promise<BuildOutput>;
|
|
8
|
+
export declare function build({ entry, outDir, stdout, stderr, quiet, }: BuildOptions): Promise<BuildOutput>;
|
|
@@ -12,6 +12,12 @@ export interface ResolveConfigOptions {
|
|
|
12
12
|
watch: boolean;
|
|
13
13
|
/** Called with what each successful (re)build wrote. */
|
|
14
14
|
onOutput: (output: CapturedOutput) => void;
|
|
15
|
+
/** Where Vite's own build output goes. */
|
|
16
|
+
stdout: NodeJS.WritableStream;
|
|
17
|
+
/** Where Vite's warnings and errors go. */
|
|
18
|
+
stderr: NodeJS.WritableStream;
|
|
19
|
+
/** Silences the bundler's progress output — see the `quiet` option in `../types.mts`. */
|
|
20
|
+
quiet: boolean;
|
|
15
21
|
}
|
|
16
22
|
/**
|
|
17
23
|
* Builds the Vite config shared by `watch` and `build`, compiling `.vue`
|
|
@@ -23,4 +29,4 @@ export interface ResolveConfigOptions {
|
|
|
23
29
|
* the entry, named by `chunkFileNames`/`assetFileNames` below, rather than
|
|
24
30
|
* failing the build.
|
|
25
31
|
*/
|
|
26
|
-
export declare function resolveViteConfig({ entry, outDir, mode, watch, onOutput, }: ResolveConfigOptions): InlineConfig;
|
|
32
|
+
export declare function resolveViteConfig({ entry, outDir, mode, watch, onOutput, stdout, stderr, quiet, }: ResolveConfigOptions): InlineConfig;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { Logger } from 'vite';
|
|
2
|
+
/**
|
|
3
|
+
* A Vite {@link Logger} writing to the given streams: `info` to `stdout`,
|
|
4
|
+
* `warn` and `error` to `stderr`. Messages arrive fully formatted and are
|
|
5
|
+
* written as they are; Vite's own `LogOptions` are ignored.
|
|
6
|
+
*/
|
|
7
|
+
export declare function streamLogger(stdout: NodeJS.WritableStream, stderr: NodeJS.WritableStream): Logger;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { Plugin } from 'vite';
|
|
2
|
+
/** Something an app can write that the engine can't run yet. */
|
|
3
|
+
export interface UnsupportedFeature {
|
|
4
|
+
/** The `ERR_INCA_*` identifier this failure is looked up by. */
|
|
5
|
+
code: string;
|
|
6
|
+
/** The feature, named as the app's author would recognise it. */
|
|
7
|
+
name: string;
|
|
8
|
+
/** Whether a module id is a use of the feature. */
|
|
9
|
+
matches: (id: string) => boolean;
|
|
10
|
+
/** What happens instead, and what to reach for — appended to the error. */
|
|
11
|
+
hint: string;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Every feature a build refuses. Add an entry when the engine is found to
|
|
15
|
+
* ignore something standard, so an app hits a build error instead of a
|
|
16
|
+
* silent no-op at runtime; drop it again once the engine handles it.
|
|
17
|
+
*/
|
|
18
|
+
export declare const UNSUPPORTED: readonly UnsupportedFeature[];
|
|
19
|
+
/**
|
|
20
|
+
* Fails the build on the first module that uses an unsupported feature,
|
|
21
|
+
* naming the file that used it.
|
|
22
|
+
*/
|
|
23
|
+
export declare function rejectUnsupported(features?: readonly UnsupportedFeature[]): Plugin;
|
|
@@ -5,4 +5,4 @@ export type { Watcher } from '../types.mts';
|
|
|
5
5
|
* change, calling `onBuild` with what each rebuild wrote. Never starts,
|
|
6
6
|
* reloads, or talks to `inca-host` — that's `dev.mts`'s job.
|
|
7
7
|
*/
|
|
8
|
-
export declare function watch({ onBuild, onError, ...buildOptions }: BundlerOptions): Promise<Watcher>;
|
|
8
|
+
export declare function watch({ onBuild, onError, stdout, stderr, quiet, ...buildOptions }: BundlerOptions): Promise<Watcher>;
|
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,12 @@ 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;
|
|
15
|
+
/** Where the bundler's own output goes. Defaults to `process.stdout`. */
|
|
16
|
+
stdout?: NodeJS.WritableStream;
|
|
17
|
+
/** Where the bundler's warnings and errors go. Defaults to `process.stderr`. */
|
|
18
|
+
stderr?: NodeJS.WritableStream;
|
|
12
19
|
}
|
|
13
20
|
/**
|
|
14
21
|
* 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 };
|