@incajs/cli 0.0.9 → 0.0.11

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 CHANGED
@@ -17,7 +17,7 @@ npm i -D @incajs/cli
17
17
  ## App entry
18
18
 
19
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
20
+ app. Commit a `src/main.mts`, `src/main.ts` or `src/main.js` instead for full control over
21
21
  bootstrapping; it wins outright when both exist.
22
22
 
23
23
  ## Commands
@@ -32,11 +32,15 @@ export interface BundlerOptions extends BuildOptions {
32
32
  /** Called after each successful (re)build, with what it wrote. */
33
33
  onBuild: (output: BuildOutput) => void;
34
34
  /** Called instead of `onBuild` when a (re)build fails. */
35
- onError: (error: {
36
- message: string;
37
- stack: string | null;
38
- code?: string | null;
39
- }) => void;
35
+ onError: (error: BuildFailure) => void;
36
+ }
37
+ /** A failed build or HMR update, in the one shape every bundler adapter reports. */
38
+ export interface BuildFailure {
39
+ message: string;
40
+ /** The stack, plus any further detail worth printing under it. */
41
+ stack: string | null;
42
+ /** An `ERR_INCA_*` identifier, when the failure has one to look up. */
43
+ code?: string | null;
40
44
  }
41
45
  /** What a build wrote — the result of {@link Bundler.build}, and every {@link BundlerOptions.onBuild} call. */
42
46
  export interface BuildOutput {
@@ -52,21 +56,6 @@ export interface BuildOutput {
52
56
  at: number;
53
57
  };
54
58
  }
55
- /**
56
- * A failed HMR update's detail — the same fields a Rollup/Vite plugin
57
- * error carries beyond `message`/`stack`, when it has them.
58
- */
59
- export interface UpdateError {
60
- message: string;
61
- stack?: string | null;
62
- plugin?: string | null;
63
- id?: string | null;
64
- frame?: string | null;
65
- loc?: {
66
- line: number;
67
- column: number;
68
- } | null;
69
- }
70
59
  /** Options for {@link Bundler.hmr}. */
71
60
  export interface HmrOptions {
72
61
  /** The app's own entry point — may import `.vue` files. */
@@ -91,7 +80,7 @@ export interface HmrOptions {
91
80
  /** Called in place of forwarding a whole-app reload payload to the app. */
92
81
  reload: () => void;
93
82
  /** Called when an update the app fetched failed to compile. */
94
- onError: (error: UpdateError) => void;
83
+ onError: (error: BuildFailure) => void;
95
84
  /** Called after a successful update, with the file that changed and how long it took. */
96
85
  onUpdate?: (info: {
97
86
  file: string;
@@ -1,7 +1,8 @@
1
+ import { AdapterCore } from '../../adapterCore.mts';
1
2
  import { BuildOptions, BuildOutput } from '../types.mts';
2
3
  /**
3
4
  * Builds `entry` into a minified, production build under `outDir` once, and
4
5
  * rejects on failure rather than reporting it through a callback. Never
5
6
  * starts or talks to `inca-host` — that's `dev.mts`'s job.
6
7
  */
7
- export declare function build({ entry, outDir, runtimeConfig, stdout, stderr, quiet, }: BuildOptions): Promise<BuildOutput>;
8
+ export declare function build(core: AdapterCore, runtimeModuleName: string, { entry, outDir, runtimeConfig, stdout, stderr, quiet, }: BuildOptions): Promise<BuildOutput>;
@@ -1,4 +1,5 @@
1
1
  import { Plugin } from 'vite';
2
+ import { AdapterCore } from '../../adapterCore.mts';
2
3
  import { BuildOutput } from '../types.mts';
3
4
  /** What one (re)build actually wrote, relative to its own `outDir`. */
4
5
  export interface CapturedOutput {
@@ -15,4 +16,4 @@ export declare function toBuildOutput(outDir: string, captured: CapturedOutput,
15
16
  * one-shot build and every watch rebuild, so both read the bundler's real
16
17
  * output instead of assuming a file name or layout.
17
18
  */
18
- export declare function captureOutput(sink: (output: CapturedOutput) => void): Plugin;
19
+ export declare function captureOutput(core: AdapterCore, sink: (output: CapturedOutput) => void): Plugin;
@@ -1,7 +1,11 @@
1
1
  import { InlineConfig } from 'vite';
2
+ import { AdapterCore } from '../../adapterCore.mts';
2
3
  import { CapturedOutput } from './captureOutput.mts';
3
4
  export declare const BUNDLE_FILE_NAME = "bundle.js";
4
5
  export interface ResolveConfigOptions {
6
+ core: AdapterCore;
7
+ /** The module compiled `.vue` templates import their helpers from. */
8
+ runtimeModuleName: string;
5
9
  /** The app's own entry point — may import `.vue` files. */
6
10
  entry: string;
7
11
  /** Where the build's output is written. */
@@ -23,12 +27,12 @@ export interface ResolveConfigOptions {
23
27
  }
24
28
  /**
25
29
  * Builds the Vite config shared by `watch` and `build`, compiling `.vue`
26
- * files via `@vitejs/plugin-vue` targeted at `@vue/runtime-core` rather than
27
- * the `vue` meta-package it requires to run.
30
+ * files via `@vitejs/plugin-vue`. Compiled templates import their helpers
31
+ * from `runtimeModuleName`.
28
32
  *
29
33
  * An import the entry doesn't inline — a dynamic `import()`, or a `.vue`
30
34
  * file's own `<style>` block — lands as its own chunk or asset alongside
31
35
  * the entry, named by `chunkFileNames`/`assetFileNames` below, rather than
32
36
  * failing the build.
33
37
  */
34
- export declare function resolveViteConfig({ entry, outDir, mode, watch, onOutput, stdout, stderr, quiet, runtimeConfig, }: ResolveConfigOptions): InlineConfig;
38
+ export declare function resolveViteConfig({ core, runtimeModuleName, entry, outDir, mode, watch, onOutput, stdout, stderr, quiet, runtimeConfig, }: ResolveConfigOptions): InlineConfig;
@@ -0,0 +1,8 @@
1
+ import { AdapterCore } from '../../adapterCore.mts';
2
+ import { Bundler } from '../types.mts';
3
+ /**
4
+ * The Vite adapter.
5
+ * @param core - the CLI logic the adapter uses
6
+ * @param runtimeModuleName - the module compiled `.vue` templates import their helpers from
7
+ */
8
+ export declare function createViteBundler(core: AdapterCore, runtimeModuleName: string): Bundler;
@@ -1,7 +1,30 @@
1
- import { HmrChannel, HmrOptions } from '../types.mts';
1
+ import { AdapterCore } from '../../adapterCore.mts';
2
+ import { BuildFailure, HmrChannel, HmrOptions } from '../types.mts';
3
+ /**
4
+ * A failed update's detail — the same fields a Rollup/Vite plugin
5
+ * error carries beyond `message`/`stack`, when it has them.
6
+ */
7
+ interface UpdateError {
8
+ message: string;
9
+ stack?: string | null;
10
+ plugin?: string | null;
11
+ id?: string | null;
12
+ frame?: string | null;
13
+ loc?: {
14
+ line: number;
15
+ column: number;
16
+ } | null;
17
+ }
18
+ /**
19
+ * Reduces a failed update to a {@link BuildFailure}, with the message and
20
+ * `code` a failed rebuild reports. Plugin, file and frame detail from Vite's
21
+ * `buildErrorMessage` follows the stack.
22
+ */
23
+ export declare function faultOfUpdate(core: AdapterCore, error: UpdateError): BuildFailure;
2
24
  /**
3
25
  * Starts a Vite dev server driving the app over its dev channel instead of
4
26
  * a browser: a `"client"` environment with a custom {@link HotChannel}
5
27
  * standing in for the WebSocket server `server.ws: false` disables.
6
28
  */
7
- export declare function hmr({ entry, cwd, runtimeConfig, runtimePath, stdout, stderr, quiet, notify, reload, onError, onUpdate, }: HmrOptions): Promise<HmrChannel>;
29
+ export declare function hmr(core: AdapterCore, runtimeModuleName: string, { entry, cwd, runtimeConfig, runtimePath, stdout, stderr, quiet, notify, reload, onError, onUpdate, }: HmrOptions): Promise<HmrChannel>;
30
+ export {};
@@ -1,3 +1 @@
1
- export { build } from './build.mts';
2
- export { hmr } from './hmr.mts';
3
- export { watch } from './watch.mts';
1
+ export { createViteBundler } from './createBundler.mts';
@@ -1,4 +1,5 @@
1
1
  import { Plugin } from 'vite';
2
+ import { AdapterCore } from '../../adapterCore.mts';
2
3
  /** Something an app can write that the engine can't run yet. */
3
4
  export interface UnsupportedFeature {
4
5
  /** The `ERR_INCA_*` identifier this failure is looked up by. */
@@ -20,4 +21,4 @@ export declare const UNSUPPORTED: readonly UnsupportedFeature[];
20
21
  * Fails the build on the first module that uses an unsupported feature,
21
22
  * naming the file that used it.
22
23
  */
23
- export declare function rejectUnsupported(features?: readonly UnsupportedFeature[]): Plugin;
24
+ export declare function rejectUnsupported(core: AdapterCore, features?: readonly UnsupportedFeature[]): Plugin;
@@ -1,7 +1,8 @@
1
+ import { AdapterCore } from '../../adapterCore.mts';
1
2
  import { BundlerOptions, Watcher } from '../types.mts';
2
3
  /**
3
4
  * Builds `entry` into a build under `outDir` and rebuilds it on every
4
5
  * change, calling `onBuild` with what each rebuild wrote. Never starts,
5
6
  * reloads, or talks to `inca-host` — that's `dev.mts`'s job.
6
7
  */
7
- export declare function watch({ onBuild, onError, stdout, stderr, quiet, ...buildOptions }: BundlerOptions): Promise<Watcher>;
8
+ export declare function watch(core: AdapterCore, runtimeModuleName: string, { onBuild, onError, stdout, stderr, quiet, ...buildOptions }: BundlerOptions): Promise<Watcher>;
@@ -0,0 +1,10 @@
1
+ export { IncaError } from './error.mts';
2
+ export { bundlerFault } from './log.mts';
3
+ /**
4
+ * The CLI logic the CLI injects into a bundler adapter: the `IncaError`
5
+ * class and `bundlerFault`, which reduces a bundler's error to a printable
6
+ * fault.
7
+ *
8
+ * Also the seam an adapter's own tests pass the real module through.
9
+ */
10
+ export type AdapterCore = typeof import('./adapterCore.mts');
package/dist/build.d.mts CHANGED
@@ -5,7 +5,7 @@ export interface BuildAppOptions {
5
5
  cwd?: string;
6
6
  /**
7
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.
8
+ * committed `src/main.mts`, `src/main.ts` or `src/main.js`, or `src/App.vue` wrapped in a synthesized one.
9
9
  */
10
10
  entry?: string;
11
11
  /** Overrides the bundler — see {@link defaultBundler} for what's wired in by default. */
@@ -0,0 +1,22 @@
1
+ //#region src/config/defaults.mts
2
+ var e = {
3
+ outDir: "dist",
4
+ version: "0.0.0"
5
+ };
6
+ function t(e) {
7
+ let t = e.indexOf("/");
8
+ return e.startsWith("@") && t !== -1 ? e.slice(t + 1) : e;
9
+ }
10
+ var n = "app";
11
+ function r(e) {
12
+ let t = e.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "");
13
+ return t === "" ? n : t;
14
+ }
15
+ function i(e) {
16
+ return e ? t(e) : void 0;
17
+ }
18
+ function a(e) {
19
+ return `org.inca.${r(e)}`;
20
+ }
21
+ //#endregion
22
+ export { r as i, a as n, i as r, e as t };