@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.
@@ -0,0 +1,44 @@
1
+ import { IncaConfig } from './types.mts';
2
+ /**
3
+ * The `IncaConfig` fields whose default is a fixed value rather than one
4
+ * derived from `package.json` or the filesystem — importable alongside
5
+ * `defineConfig` for an app that wants to inherit or reference them.
6
+ *
7
+ * @example
8
+ * ```ts
9
+ * import { defaultConfig, defineConfig } from "@incajs/cli/config";
10
+ *
11
+ * export default defineConfig({
12
+ * ...defaultConfig,
13
+ * outDir: "build",
14
+ * });
15
+ * ```
16
+ */
17
+ export declare const defaultConfig: Required<Pick<IncaConfig, "outDir" | "version">>;
18
+ /**
19
+ * Strips an npm scope off a package name.
20
+ *
21
+ * @param name - a `package.json` `"name"`, e.g. `@incajs/cli` or `incajs`
22
+ * @returns the name with its scope removed, e.g. `cli`; an unscoped name
23
+ * passes through unchanged
24
+ */
25
+ export declare function unscopedName(name: string): string;
26
+ /**
27
+ * Turns a display name into a filesystem/URL-safe slug.
28
+ *
29
+ * @param name - e.g. a `productName`
30
+ * @returns `name` lowercased, with runs of non-`[a-z0-9]` collapsed to a
31
+ * single `-` and trimmed from both ends
32
+ */
33
+ export declare function slugify(name: string): string;
34
+ /**
35
+ * @param pkgName - `package.json`'s own `"name"`, if it has one
36
+ * @returns the `productName` a plain `package.json` implies — its name with
37
+ * any scope stripped — or `undefined` if it has none
38
+ */
39
+ export declare function defaultProductName(pkgName: string | undefined): string | undefined;
40
+ /**
41
+ * @param productName - the app's resolved display name
42
+ * @returns a generated `identifier`, e.g. `org.inca.click-counter`
43
+ */
44
+ export declare function defaultIdentifier(productName: string): string;
@@ -0,0 +1,18 @@
1
+ import { IncaConfig } from './types.mts';
2
+ export { defaultConfig } from './defaults.mts';
3
+ export type { IncaConfig } from './types.mts';
4
+ /**
5
+ * Type-completion helper for `inca.config.ts` — an identity function at
6
+ * runtime, the same way `defineConfig` from `vite` or `vitest/config` works.
7
+ *
8
+ * @example
9
+ * ```ts
10
+ * import { defineConfig } from "@incajs/cli/config";
11
+ *
12
+ * export default defineConfig({
13
+ * productName: "Click Counter",
14
+ * identifier: "com.example.click-counter",
15
+ * });
16
+ * ```
17
+ */
18
+ export declare const defineConfig: import('c12').DefineConfig<IncaConfig, import('c12').ConfigLayerMeta>;
@@ -0,0 +1,37 @@
1
+ /** `entry`/`outDir` only — what `build()`/`dev()` need, with no `package.json` requirement. */
2
+ export interface ResolvedBuildConfig {
3
+ /** Absolute path, if `inca.config.ts` set one. */
4
+ entry?: string;
5
+ /** Absolute path. */
6
+ outDir: string;
7
+ }
8
+ /** An app's full config, as `inca package` needs it. */
9
+ export interface ResolvedAppConfig extends ResolvedBuildConfig {
10
+ productName: string;
11
+ identifier: string;
12
+ /** True when `identifier` was generated rather than set explicitly. */
13
+ identifierIsDefault: boolean;
14
+ version: string;
15
+ /** Absolute path, if the app declared one. */
16
+ icon?: string;
17
+ /** package.json's `"inca"` key is deprecated; callers warn when this is true. */
18
+ usedPackageJsonKey: boolean;
19
+ }
20
+ /**
21
+ * Loads just `entry`/`outDir` from `inca.config.ts`, with derived defaults.
22
+ * Never touches `package.json`.
23
+ *
24
+ * @param cwd - the app's root directory
25
+ * @returns `entry`/`outDir`, resolved to absolute paths
26
+ */
27
+ export declare function resolveBuildConfig(cwd: string): Promise<ResolvedBuildConfig>;
28
+ /**
29
+ * Loads an app's full config for `inca package`: `inca.config.ts` over
30
+ * `package.json`'s `"inca"` key over derived defaults.
31
+ *
32
+ * @param cwd - the app's root directory
33
+ * @returns the resolved config
34
+ * @throws if `package.json` is missing, has neither a `name` nor a
35
+ * `productName`, or an `icon` doesn't resolve to a real file
36
+ */
37
+ export declare function resolveAppConfig(cwd: string): Promise<ResolvedAppConfig>;
@@ -0,0 +1,35 @@
1
+ /**
2
+ * An app's own `inca.config.ts` (or `.js`/`.json`), loaded by `@incajs/cli`.
3
+ * `package.json`'s `"inca"` key still works as a fallback, but is
4
+ * deprecated — this file wins where both are present.
5
+ */
6
+ export interface IncaConfig {
7
+ /** Path to an icon file, resolved relative to this config file's own directory. */
8
+ icon?: string;
9
+ /**
10
+ * A reverse-DNS-style unique id — e.g. macOS's `CFBundleIdentifier`.
11
+ * @default a generated `org.inca.<slug>`
12
+ */
13
+ identifier?: string;
14
+ /**
15
+ * The app's display name.
16
+ * @default package.json's "name", with any npm scope stripped
17
+ */
18
+ productName?: string;
19
+ /**
20
+ * The packaged app's version.
21
+ * @default package.json's own "version"
22
+ */
23
+ version?: string;
24
+ /**
25
+ * The app's entry point.
26
+ * @default resolved automatically — a committed `src/main.mts`, or
27
+ * `src/App.vue` wrapped in a synthesized one
28
+ */
29
+ entry?: string;
30
+ /**
31
+ * Where a build's output is written.
32
+ * @default "dist"
33
+ */
34
+ outDir?: string;
35
+ }
package/dist/config.js ADDED
@@ -0,0 +1,5 @@
1
+ import { a as e, t } from "./chunks/defaults-D_1rymg4.js";
2
+ //#region src/config/index.mts
3
+ var n = e();
4
+ //#endregion
5
+ export { t as defaultConfig, n as defineConfig };
@@ -17,6 +17,11 @@ export interface HostClientOptions {
17
17
  onReady?: () => void;
18
18
  /** An app's own event listener threw; the host caught it and kept rendering. */
19
19
  onAppError?: (error: AppErrorParams) => void;
20
+ /**
21
+ * The host exited on its own — its window was closed, or it crashed.
22
+ * Not called for the exit `stop()` asks for.
23
+ */
24
+ onExit?: (code: number | null, signal: NodeJS.Signals | null) => void;
20
25
  /**
21
26
  * Handlers for notification `method`s this package doesn't implement
22
27
  * itself (e.g. a future Vite integration), keyed by method name —
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Claims `cwd` for this process. Two `inca dev`s on one app watch the same
3
+ * files and interleave their output on one terminal, and an orphan left by
4
+ * an earlier run stays invisible until this says so. A lock whose pid is
5
+ * gone is taken over.
6
+ *
7
+ * @returns a function releasing the lock.
8
+ * @throws if another live `inca dev` holds `cwd`.
9
+ */
10
+ export declare function acquireDevLock(cwd: string): Promise<() => Promise<void>>;
package/dist/dev.d.mts CHANGED
@@ -20,6 +20,9 @@ export interface DevOptions {
20
20
  }
21
21
  /**
22
22
  * Builds the app, starts `inca-host` once the first build lands, and
23
- * reloads it on every rebuild — until `options.signal` aborts.
23
+ * reloads it on every rebuild — until `options.signal` aborts or the host
24
+ * exits on its own.
25
+ *
26
+ * @throws if another `inca dev` is already running for this app.
24
27
  */
25
28
  export declare function dev(options: DevOptions): Promise<void>;
@@ -0,0 +1,11 @@
1
+ /**
2
+ * A failure the CLI raises itself, identified by an `ERR_INCA_*` code the
3
+ * way Node's own errors carry one. The code is what a user searches for
4
+ * and what `printFault` names alongside the message, so every distinct
5
+ * cause gets its own.
6
+ */
7
+ export declare class IncaError extends Error {
8
+ readonly code: string;
9
+ readonly name = "IncaError";
10
+ constructor(code: string, message: string);
11
+ }
package/dist/index.d.mts CHANGED
@@ -1 +1,2 @@
1
1
  export type { BuildOptions, BuildOutput, Bundler, BundlerOptions, Watcher, } from './adapter/types.mts';
2
+ export type { ResolvedAppConfig } from './config/loader.mts';
package/dist/log.d.mts ADDED
@@ -0,0 +1,28 @@
1
+ /** Shared by {@link log} and {@link printFault}. */
2
+ export interface LogOptions {
3
+ /** Prefixes the line with `HH:MM:SS`, the way Vite's dev server stamps its own. */
4
+ timestamp?: boolean;
5
+ }
6
+ /** Writes one `[inca] <message>` line to `stream`. */
7
+ export declare function log(stream: NodeJS.WritableStream, message: string, options?: LogOptions): void;
8
+ /** A failure reduced to the message and stack worth printing. */
9
+ export interface Fault {
10
+ message: string;
11
+ stack: string | null;
12
+ /** An `ERR_INCA_*` identifier, when the failure has one to look up. */
13
+ code?: string | null;
14
+ }
15
+ /**
16
+ * Reduces an error a bundler re-wrapped: its text is kept whole — the
17
+ * excerpt a compiler points at is the useful part — while the error class
18
+ * and any `ERR_INCA_*` marker are lifted off the first line, the latter
19
+ * into the fault's code.
20
+ */
21
+ export declare function bundlerFault(message: string): Fault;
22
+ /** Reduces a thrown value to a {@link Fault}. A `HostError` carries the host process's stack. */
23
+ export declare function toFault(error: unknown): Fault;
24
+ /**
25
+ * Writes `[inca] <label> (<code>): <message>` to `stream` — the code only
26
+ * when the failure carries one — followed by the stack when there is one.
27
+ */
28
+ export declare function printFault(stream: NodeJS.WritableStream, label: string, fault: Fault, options?: LogOptions): void;
@@ -24,8 +24,10 @@ export interface PackageAppOptions {
24
24
  * process is running on.
25
25
  */
26
26
  target?: PackageTarget;
27
- /** Where progress notes go. Defaults to `process.stdout`. */
27
+ /** Where progress notes and the bundler's own output go. Defaults to `process.stdout`. */
28
28
  stdout?: NodeJS.WritableStream;
29
+ /** Where the bundler's warnings and errors go. Defaults to `process.stderr`. */
30
+ stderr?: NodeJS.WritableStream;
29
31
  }
30
32
  /** The result of a successful {@link packageApp} call. */
31
33
  export interface PackageResult {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@incajs/cli",
3
- "version": "0.0.1",
3
+ "version": "0.0.3",
4
4
  "description": "The inca CLI: watches an app's entry point through a bundler adapter, starts inca-host once the first bundle lands, and reloads it on every rebuild.",
5
5
  "keywords": [
6
6
  "bundler",
@@ -15,6 +15,7 @@
15
15
  "quickjs",
16
16
  "vite"
17
17
  ],
18
+ "homepage": "https://tom96da.github.io/incajs/",
18
19
  "license": "(MIT OR Apache-2.0)",
19
20
  "repository": {
20
21
  "type": "git",
@@ -36,25 +37,30 @@
36
37
  ".": {
37
38
  "types": "./dist/index.d.mts",
38
39
  "import": "./dist/index.js"
40
+ },
41
+ "./config": {
42
+ "types": "./dist/config/index.d.mts",
43
+ "import": "./dist/config.js"
39
44
  }
40
45
  },
41
46
  "publishConfig": {
42
47
  "access": "public"
43
48
  },
44
49
  "dependencies": {
45
- "@vitejs/plugin-vue": "^6.0.8",
46
- "vite": "^8.2.2"
50
+ "@vitejs/plugin-vue": "^6.0.9",
51
+ "vite": "^8.3.0"
47
52
  },
48
53
  "devDependencies": {
49
- "@types/node": "^26.4.1",
50
- "@vue/runtime-core": "^3.5.42",
51
- "oxfmt": "^0.66.0",
52
- "oxlint": "^1.81.0",
53
- "rolldown": "~1.2.4",
54
- "vue": "^3.5.42"
54
+ "@types/node": "^26.6.2",
55
+ "@vue/runtime-core": "^3.5.43",
56
+ "c12": "4.0.0-rc.1",
57
+ "oxfmt": "^0.68.0",
58
+ "oxlint": "^1.83.0",
59
+ "rolldown": "~1.2.9",
60
+ "vue": "^3.5.43"
55
61
  },
56
62
  "peerDependencies": {
57
- "vue": "^3.5.42"
63
+ "vue": "^3.5.43"
58
64
  },
59
65
  "peerDependenciesMeta": {
60
66
  "vue": {
@@ -62,12 +68,12 @@
62
68
  }
63
69
  },
64
70
  "optionalDependencies": {
65
- "@incajs/host-darwin-arm64": "0.0.1",
66
- "@incajs/host-linux-arm64": "0.0.1",
67
- "@incajs/host-linux-x64": "0.0.1"
71
+ "@incajs/host-darwin-arm64": "0.0.3",
72
+ "@incajs/host-linux-arm64": "0.0.3",
73
+ "@incajs/host-linux-x64": "0.0.3"
68
74
  },
69
75
  "engines": {
70
- "node": ">=22"
76
+ "node": ">=22.18"
71
77
  },
72
78
  "scripts": {
73
79
  "build": "vite build",
package/dist/fault.d.mts DELETED
@@ -1,6 +0,0 @@
1
- export interface Fault {
2
- message: string;
3
- stack: string | null;
4
- }
5
- export declare function toFault(error: unknown): Fault;
6
- export declare function printFault(stream: NodeJS.WritableStream, label: string, fault: Fault): void;
@@ -1,30 +0,0 @@
1
- /** An app's identity and version, for `inca package` to stamp onto the application it emits. */
2
- export interface AppMetadata {
3
- /** Shown to the user — the app's display name. */
4
- productName: string;
5
- /** A reverse-DNS-style unique id — e.g. macOS's `CFBundleIdentifier`. */
6
- identifier: string;
7
- /** True when `identifier` was derived rather than set by the app. */
8
- identifierIsDefault: boolean;
9
- /** The packaged app's version. */
10
- version: string;
11
- /** Absolute path to an icon file, if the app declared one. */
12
- icon?: string;
13
- }
14
- /**
15
- * Turns a display name into a filesystem/URL-safe slug — lowercased, with
16
- * anything outside `[a-z0-9]` collapsed into a single `-`. Used for the
17
- * default `identifier` and for the Linux packaged-app directory name.
18
- */
19
- export declare function slugify(name: string): string;
20
- /**
21
- * Reads an app's package metadata for `inca package`: `productName`,
22
- * `identifier`, `version`, and an optional `icon`. Everything is derived
23
- * from the app's own `package.json` — its `name`/`version` fields, and an
24
- * optional `"inca"` key overriding any of them:
25
- * `{ "inca": { "productName", "identifier", "icon" } }`.
26
- *
27
- * @throws if `package.json` is missing, has neither a `name` nor a
28
- * `"inca".productName`, or `"inca".icon` doesn't resolve to a real file.
29
- */
30
- export declare function readAppMetadata(cwd: string): Promise<AppMetadata>;