@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/dist/cli.js CHANGED
@@ -1,15 +1,64 @@
1
- import e from "node:path";
2
- import { build as t } from "vite";
3
- import n from "@vitejs/plugin-vue";
4
- import { existsSync as r } from "node:fs";
5
- import { chmod as i, cp as a, mkdir as o, readFile as s, readdir as c, rm as l, writeFile as u } from "node:fs/promises";
6
- import { createRequire as d } from "node:module";
7
- import { spawn as f } from "node:child_process";
8
- import { once as p } from "node:events";
9
- import m from "node:readline";
10
- import { setTimeout as h } from "node:timers/promises";
1
+ import { i as e, n as t, o as n, r, t as i } from "./chunks/defaults-EWjAFeZ3.js";
2
+ import { existsSync as a } from "node:fs";
3
+ import { chmod as o, cp as s, mkdir as c, readFile as l, readdir as u, rm as d, writeFile as f } from "node:fs/promises";
4
+ import p from "node:path";
5
+ import { build as m } from "vite";
6
+ import h from "@vitejs/plugin-vue";
7
+ import { createRequire as g } from "node:module";
8
+ import { spawn as _ } from "node:child_process";
9
+ import { once as v } from "node:events";
10
+ import y from "node:readline";
11
+ import { setTimeout as b } from "node:timers/promises";
12
+ //#region src/config/loader.mts
13
+ async function x(e) {
14
+ let { config: t } = await n({
15
+ cwd: e,
16
+ name: "inca",
17
+ packageJson: "inca",
18
+ rcFile: !1,
19
+ globalRc: !1,
20
+ giget: !1,
21
+ extend: !1
22
+ });
23
+ return {
24
+ entry: t.entry ? p.resolve(e, t.entry) : void 0,
25
+ outDir: p.resolve(e, t.outDir ?? i.outDir)
26
+ };
27
+ }
28
+ async function S(e) {
29
+ let o = p.join(e, "package.json"), s;
30
+ try {
31
+ s = await l(o, "utf8");
32
+ } catch {
33
+ throw Error(`no package.json found at ${o}`);
34
+ }
35
+ let c = JSON.parse(s), { config: u, layers: d } = await n({
36
+ cwd: e,
37
+ name: "inca",
38
+ packageJson: "inca",
39
+ rcFile: !1,
40
+ globalRc: !1,
41
+ giget: !1,
42
+ extend: !1
43
+ }), f = d?.find((e) => e.configFile === "package.json"), m = Object.keys(f?.config ?? {}).length > 0, h = u.productName ?? r(c.name);
44
+ if (!h) throw Error(`${o} needs a "name", or "productName" in inca.config.ts`);
45
+ let g = u.version ?? c.version ?? i.version, _ = u.identifier ?? t(h), v;
46
+ if (u.icon && (v = p.resolve(e, u.icon), !a(v))) throw Error(`"icon" points to ${v}, which doesn't exist`);
47
+ let y = u.entry ? p.resolve(e, u.entry) : void 0, b = p.resolve(e, u.outDir ?? i.outDir);
48
+ return {
49
+ productName: h,
50
+ identifier: _,
51
+ identifierIsDefault: u.identifier === void 0,
52
+ version: g,
53
+ icon: v,
54
+ entry: y,
55
+ outDir: b,
56
+ usedPackageJsonKey: m
57
+ };
58
+ }
59
+ //#endregion
11
60
  //#region src/adapter/vite/captureOutput.mts
12
- function g(e) {
61
+ function C(e) {
13
62
  return {
14
63
  name: "inca:capture-output",
15
64
  writeBundle(t, n) {
@@ -24,26 +73,26 @@ function g(e) {
24
73
  }
25
74
  //#endregion
26
75
  //#region src/adapter/vite/config.mts
27
- var _ = "bundle.js";
28
- function v({ entry: t, outDir: r, mode: i, watch: a, onOutput: o }) {
76
+ var w = "bundle.js";
77
+ function T({ entry: e, outDir: t, mode: n, watch: r, onOutput: i }) {
29
78
  return {
30
79
  configFile: !1,
31
- root: e.dirname(t),
32
- mode: i,
80
+ root: p.dirname(e),
81
+ mode: n,
33
82
  clearScreen: !1,
34
83
  logLevel: "silent",
35
- define: { "process.env.NODE_ENV": JSON.stringify(i) },
36
- plugins: [n({ template: { compilerOptions: { runtimeModuleName: "@vue/runtime-core" } } }), g(o)],
84
+ define: { "process.env.NODE_ENV": JSON.stringify(n) },
85
+ plugins: [h({ template: { compilerOptions: { runtimeModuleName: "@vue/runtime-core" } } }), C(i)],
37
86
  build: {
38
87
  lib: {
39
- entry: t,
88
+ entry: e,
40
89
  formats: ["es"],
41
- fileName: () => _
90
+ fileName: () => w
42
91
  },
43
- outDir: r,
44
- emptyOutDir: i === "production",
45
- minify: i === "production",
46
- watch: a ? {} : void 0,
92
+ outDir: t,
93
+ emptyOutDir: n === "production",
94
+ minify: n === "production",
95
+ watch: r ? {} : void 0,
47
96
  rolldownOptions: { output: {
48
97
  chunkFileNames: "chunks/[name]-[hash].js",
49
98
  assetFileNames: "assets/[name]-[hash][extname]"
@@ -53,69 +102,69 @@ function v({ entry: t, outDir: r, mode: i, watch: a, onOutput: o }) {
53
102
  }
54
103
  //#endregion
55
104
  //#region src/adapter/vite/build.mts
56
- async function y({ entry: n, outDir: r }) {
57
- let i;
58
- if (await t(v({
59
- entry: n,
60
- outDir: r,
105
+ async function E({ entry: e, outDir: t }) {
106
+ let n;
107
+ if (await m(T({
108
+ entry: e,
109
+ outDir: t,
61
110
  mode: "production",
62
111
  watch: !1,
63
- onOutput: (t) => {
64
- i = {
65
- outDir: r,
66
- entryFile: e.join(r, t.entryFile),
67
- files: t.files
112
+ onOutput: (e) => {
113
+ n = {
114
+ outDir: t,
115
+ entryFile: p.join(t, e.entryFile),
116
+ files: e.files
68
117
  };
69
118
  }
70
- })), !i) throw Error("inca: build produced no output");
71
- return i;
119
+ })), !n) throw Error("inca: build produced no output");
120
+ return n;
72
121
  }
73
122
  //#endregion
74
123
  //#region src/adapter/vite/watch.mts
75
- async function b({ onBuild: n, onError: r, ...i }) {
76
- let { outDir: a } = i, o = await t(v({
77
- ...i,
124
+ async function D({ onBuild: e, onError: t, ...n }) {
125
+ let { outDir: r } = n, i = await m(T({
126
+ ...n,
78
127
  watch: !0,
79
128
  onOutput: (t) => {
80
- n({
81
- outDir: a,
82
- entryFile: e.join(a, t.entryFile),
129
+ e({
130
+ outDir: r,
131
+ entryFile: p.join(r, t.entryFile),
83
132
  files: t.files
84
133
  });
85
134
  }
86
135
  }));
87
- return o.on("event", (e) => {
88
- e.code === "ERROR" && r({
136
+ return i.on("event", (e) => {
137
+ e.code === "ERROR" && t({
89
138
  message: e.error.message,
90
139
  stack: e.error.stack ?? null
91
140
  });
92
- }), { close: () => o.close() };
141
+ }), { close: () => i.close() };
93
142
  }
94
143
  //#endregion
95
144
  //#region src/defaultBundler.mts
96
- var x = {
97
- watch: b,
98
- build: y
145
+ var O = {
146
+ watch: D,
147
+ build: E
99
148
  };
100
149
  //#endregion
101
150
  //#region src/entry.mts
102
- async function S(t) {
103
- let n = e.join(t, "src/main.mts");
104
- if (r(n)) return n;
105
- let i = e.join(t, "src/App.vue");
106
- if (r(i)) return C(i, t);
107
- throw Error(`no app entry found — expected ${n} or ${i}`);
151
+ async function k(e) {
152
+ let t = p.join(e, "src/main.mts");
153
+ if (a(t)) return t;
154
+ let n = p.join(e, "src/App.vue");
155
+ if (a(n)) return A(n, e);
156
+ throw Error(`no app entry found — expected ${t} or ${n}`);
108
157
  }
109
- async function C(t, n) {
110
- let r = e.join(n, "node_modules/.inca");
111
- await o(r, { recursive: !0 });
112
- let i = e.join(r, "entry.mts"), a = JSON.stringify(t.split(e.sep).join("/"));
113
- return await u(i, `import { createIncaApp } from "incajs/vue";\nimport App from ${a};\ncreateIncaApp(App).mount();\n`), i;
158
+ async function A(e, t) {
159
+ let n = p.join(t, "node_modules/.inca");
160
+ await c(n, { recursive: !0 });
161
+ let r = p.join(n, "entry.mts"), i = JSON.stringify(e.split(p.sep).join("/"));
162
+ return await f(r, `import { createIncaApp } from "incajs/vue";\nimport App from ${i};\ncreateIncaApp(App).mount();\n`), r;
114
163
  }
115
164
  //#endregion
116
165
  //#region src/build.mts
117
- async function w(t = {}) {
118
- let n = t.cwd ?? process.cwd(), r = e.join(n, "dist"), i = t.bundler ?? x, a = t.entry ?? await S(n);
166
+ async function j(e = {}) {
167
+ let t = e.cwd ?? process.cwd(), n = e.config ?? await x(t), r = n.outDir, i = e.bundler ?? O, a = e.entry ?? n.entry ?? await k(t);
119
168
  return i.build({
120
169
  entry: a,
121
170
  outDir: r
@@ -123,44 +172,44 @@ async function w(t = {}) {
123
172
  }
124
173
  //#endregion
125
174
  //#region src/dev-client/hostBin.mts
126
- var T = "INCA_HOST_BIN";
127
- function E() {
175
+ var M = "INCA_HOST_BIN";
176
+ function N() {
128
177
  let e = process.platform === "darwin" || process.platform === "linux" ? process.platform : void 0, t = process.arch === "arm64" || process.arch === "x64" ? process.arch : void 0;
129
178
  return e && t ? `@incajs/host-${e}-${t}` : void 0;
130
179
  }
131
- function D() {
132
- let e = E();
180
+ function P() {
181
+ let e = N();
133
182
  if (e) try {
134
- return d(import.meta.url).resolve(`${e}/bin/inca-host`);
183
+ return g(import.meta.url).resolve(`${e}/bin/inca-host`);
135
184
  } catch {
136
185
  return;
137
186
  }
138
187
  }
139
- function O() {
140
- let e = process.env[T];
188
+ function F() {
189
+ let e = process.env[M];
141
190
  if (e) return e;
142
- let t = D();
191
+ let t = P();
143
192
  if (t) return t;
144
- let n = E(), r = n ? `no ${n} package is installed for it` : `this platform (${process.platform}/${process.arch}) has no published package`;
145
- throw Error(`no inca-host binary found — ${r}, and ${T} isn't set to one`);
193
+ let n = N(), r = n ? `no ${n} package is installed for it` : `this platform (${process.platform}/${process.arch}) has no published package`;
194
+ throw Error(`no inca-host binary found — ${r}, and ${M} isn't set to one`);
146
195
  }
147
196
  //#endregion
148
197
  //#region src/dev-client/hostError.mts
149
- var k = class extends Error {
198
+ var I = class extends Error {
150
199
  code;
151
200
  hostStack;
152
201
  constructor(e, t, n = null) {
153
202
  super(e), this.code = t, this.hostStack = n, this.name = "HostError";
154
203
  }
155
204
  };
156
- function A(e) {
205
+ function L(e) {
157
206
  return typeof e == "object" && !!e && e.jsonrpc === "2.0";
158
207
  }
159
208
  //#endregion
160
209
  //#region src/dev-client/hostClient.mts
161
- var j = (e) => {
210
+ var R = (e) => {
162
211
  process.stderr.write(e.endsWith("\n") ? e : `${e}\n`);
163
- }, M = class {
212
+ }, z = class {
164
213
  #e;
165
214
  #t;
166
215
  #n = 1;
@@ -169,20 +218,20 @@ var j = (e) => {
169
218
  this.#e = e;
170
219
  }
171
220
  async start() {
172
- let e = this.#e.hostBin ?? O(), t = f(e, ["--dev", this.#e.entryFile], { stdio: [
221
+ let e = this.#e.hostBin ?? F(), t = _(e, ["--dev", this.#e.entryFile], { stdio: [
173
222
  "pipe",
174
223
  "pipe",
175
224
  "pipe"
176
225
  ] });
177
226
  this.#t = t;
178
- let n = this.#e.onStderr ?? j;
179
- t.stderr.setEncoding("utf8"), t.stderr.on("data", (e) => n(e)), m.createInterface({ input: t.stdout }).on("line", (e) => {
227
+ let n = this.#e.onStderr ?? R;
228
+ t.stderr.setEncoding("utf8"), t.stderr.on("data", (e) => n(e)), y.createInterface({ input: t.stdout }).on("line", (e) => {
180
229
  this.#i(e, n);
181
230
  }), t.on("exit", (e, t) => {
182
231
  let n = /* @__PURE__ */ Error(`inca-host exited (code=${String(e)}, signal=${String(t)}) before answering`);
183
232
  for (let { reject: e } of this.#r.values()) e(n);
184
233
  this.#r.clear();
185
- }), await p(t, "spawn");
234
+ }), await v(t, "spawn");
186
235
  }
187
236
  #i(e, t) {
188
237
  let n;
@@ -192,7 +241,7 @@ var j = (e) => {
192
241
  t(`[stray stdout] ${e}`);
193
242
  return;
194
243
  }
195
- if (!A(n)) {
244
+ if (!L(n)) {
196
245
  t(`[stray stdout] ${e}`);
197
246
  return;
198
247
  }
@@ -201,7 +250,7 @@ var j = (e) => {
201
250
  return;
202
251
  }
203
252
  let r = this.#r.get(n.id);
204
- r && (this.#r.delete(n.id), "error" in n ? r.reject(new k(n.error.message, n.error.code, n.error.data?.stack ?? null)) : r.resolve(n.result));
253
+ r && (this.#r.delete(n.id), "error" in n ? r.reject(new I(n.error.message, n.error.code, n.error.data?.stack ?? null)) : r.resolve(n.result));
205
254
  }
206
255
  #a(e, t, n) {
207
256
  switch (e) {
@@ -224,7 +273,7 @@ var j = (e) => {
224
273
  }
225
274
  }
226
275
  async #o(e) {
227
- let t = p(e, "exit");
276
+ let t = v(e, "exit");
228
277
  e.kill(), await t;
229
278
  }
230
279
  async call(e, t) {
@@ -246,14 +295,14 @@ var j = (e) => {
246
295
  async stop(e = 2e3) {
247
296
  let t = this.#t;
248
297
  if (!t || t.exitCode !== null || t.signalCode !== null) return;
249
- let n = p(t, "exit");
250
- this.call("shutdown").catch(() => {}), await Promise.race([n.then(() => "exited"), h(e).then(() => "timeout")]) === "timeout" && (t.kill(), await n);
298
+ let n = v(t, "exit");
299
+ this.call("shutdown").catch(() => {}), await Promise.race([n.then(() => "exited"), b(e).then(() => "timeout")]) === "timeout" && (t.kill(), await n);
251
300
  }
252
301
  };
253
302
  //#endregion
254
303
  //#region src/fault.mts
255
- function N(e) {
256
- return e instanceof k ? {
304
+ function B(e) {
305
+ return e instanceof I ? {
257
306
  message: e.message,
258
307
  stack: e.hostStack
259
308
  } : e instanceof Error ? {
@@ -264,47 +313,47 @@ function N(e) {
264
313
  stack: null
265
314
  };
266
315
  }
267
- function P(e, t, n) {
316
+ function V(e, t, n) {
268
317
  e.write(`[inca] ${t}: ${n.message}\n`), n.stack && e.write(`${n.stack}\n`);
269
318
  }
270
319
  //#endregion
271
320
  //#region src/dev.mts
272
- async function F(t, n) {
273
- let r = new Set(n), i;
321
+ async function H(e, t) {
322
+ let n = new Set(t), r;
274
323
  try {
275
- i = await c(t, {
324
+ r = await u(e, {
276
325
  recursive: !0,
277
326
  withFileTypes: !0
278
327
  });
279
328
  } catch {
280
329
  return;
281
330
  }
282
- await Promise.all(i.filter((e) => e.isFile()).map((n) => e.relative(t, e.join(n.parentPath, n.name))).filter((e) => !r.has(e)).map((n) => l(e.join(t, n), { force: !0 })));
331
+ await Promise.all(r.filter((e) => e.isFile()).map((t) => p.relative(e, p.join(t.parentPath, t.name))).filter((e) => !n.has(e)).map((t) => d(p.join(e, t), { force: !0 })));
283
332
  }
284
- async function I(t) {
285
- let n = t.cwd ?? process.cwd(), r = e.join(n, "dist"), i = t.bundler ?? x, a = t.stdout ?? process.stdout, o = t.stderr ?? process.stderr, s = t.entry ?? await S(n), c, l = !1, u = !1, d = Promise.resolve();
333
+ async function U(e) {
334
+ let t = e.cwd ?? process.cwd(), n = await x(t), r = n.outDir, i = e.bundler ?? O, a = e.stdout ?? process.stdout, o = e.stderr ?? process.stderr, s = e.entry ?? n.entry ?? await k(t), c, l = !1, u = !1, d = Promise.resolve();
286
335
  async function f() {
287
336
  try {
288
337
  await c?.call("reload");
289
338
  } catch (e) {
290
- P(o, "reload failed", N(e));
339
+ V(o, "reload failed", B(e));
291
340
  }
292
341
  }
293
- async function p(e) {
294
- if (await F(e.outDir, e.files), !c) {
295
- let n = new M({
296
- entryFile: e.entryFile,
297
- hostBin: t.hostBin,
342
+ async function p(t) {
343
+ if (await H(t.outDir, t.files), !c) {
344
+ let n = new z({
345
+ entryFile: t.entryFile,
346
+ hostBin: e.hostBin,
298
347
  onStderr: (e) => o.write(e),
299
348
  onReady: () => {
300
349
  l = !0, a.write("[inca] ready\n"), u && (u = !1, f());
301
350
  },
302
- onAppError: (e) => P(o, "app error", e)
351
+ onAppError: (e) => V(o, "app error", e)
303
352
  });
304
353
  try {
305
354
  await n.start();
306
355
  } catch (e) {
307
- P(o, "failed to start inca-host", N(e));
356
+ V(o, "failed to start inca-host", B(e));
308
357
  return;
309
358
  }
310
359
  c = n;
@@ -324,158 +373,131 @@ async function I(t) {
324
373
  d = d.then(() => p(e));
325
374
  },
326
375
  onError: (e) => {
327
- P(o, "build failed", e);
376
+ V(o, "build failed", e);
328
377
  }
329
378
  });
330
- await new Promise((e) => {
331
- if (t.signal.aborted) {
332
- e();
379
+ await new Promise((t) => {
380
+ if (e.signal.aborted) {
381
+ t();
333
382
  return;
334
383
  }
335
- t.signal.addEventListener("abort", () => e(), { once: !0 });
384
+ e.signal.addEventListener("abort", () => t(), { once: !0 });
336
385
  }), await d, await c?.stop(), await m.close();
337
386
  }
338
387
  //#endregion
339
- //#region src/metadata.mts
340
- function L(e) {
341
- let t = e.indexOf("/");
342
- return e.startsWith("@") && t !== -1 ? e.slice(t + 1) : e;
343
- }
344
- function R(e) {
345
- return e.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "");
346
- }
347
- async function z(t) {
348
- let n = e.join(t, "package.json"), i;
349
- try {
350
- i = await s(n, "utf8");
351
- } catch {
352
- throw Error(`no package.json found at ${n}`);
353
- }
354
- let a = JSON.parse(i), o = a.inca ?? {}, c = o.productName ?? (a.name ? L(a.name) : void 0);
355
- if (!c) throw Error(`${n} needs a "name", or "inca": { "productName" }`);
356
- let l = a.version ?? "0.0.0", u = o.identifier ?? `org.inca.${R(c)}`, d;
357
- if (o.icon && (d = e.resolve(t, o.icon), !r(d))) throw Error(`"inca.icon" points to ${d}, which doesn't exist`);
358
- return {
359
- productName: c,
360
- identifier: u,
361
- identifierIsDefault: o.identifier === void 0,
362
- version: l,
363
- icon: d
364
- };
365
- }
366
- //#endregion
367
388
  //#region src/plist.mts
368
- function B(e) {
389
+ function W(e) {
369
390
  return e.replaceAll("&", "&amp;").replaceAll("<", "&lt;").replaceAll(">", "&gt;");
370
391
  }
371
- function V(e) {
372
- return typeof e == "boolean" ? e ? "<true/>" : "<false/>" : `<string>${B(e)}</string>`;
392
+ function G(e) {
393
+ return typeof e == "boolean" ? e ? "<true/>" : "<false/>" : `<string>${W(e)}</string>`;
373
394
  }
374
- function H(e) {
395
+ function K(e) {
375
396
  return `<?xml version="1.0" encoding="UTF-8"?>
376
397
  <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
377
398
  <plist version="1.0">
378
399
  <dict>
379
- ${Object.entries(e).map(([e, t]) => `\t<key>${B(e)}</key>\n\t${V(t)}`).join("\n")}\n</dict>
400
+ ${Object.entries(e).map(([e, t]) => `\t<key>${W(e)}</key>\n\t${G(t)}`).join("\n")}\n</dict>
380
401
  </plist>
381
402
  `;
382
403
  }
383
404
  //#endregion
384
405
  //#region src/package.mts
385
- function U() {
406
+ function q() {
386
407
  if (process.platform === "darwin") return "macos";
387
408
  if (process.platform === "linux") return "linux";
388
409
  throw Error(`inca package doesn't support ${process.platform} yet`);
389
410
  }
390
- async function W(t, n) {
391
- await Promise.all(t.files.map(async (r) => {
392
- let i = e.join(n, r);
393
- await o(e.dirname(i), { recursive: !0 }), await a(e.join(t.outDir, r), i);
411
+ async function J(e, t) {
412
+ await Promise.all(e.files.map(async (n) => {
413
+ let r = p.join(t, n);
414
+ await c(p.dirname(r), { recursive: !0 }), await s(p.join(e.outDir, n), r);
394
415
  }));
395
416
  }
396
- async function G({ metadata: t, output: n, hostBin: r }) {
397
- let s = e.join(n.outDir, `${t.productName}.app`);
398
- await l(s, {
417
+ async function Y({ metadata: e, output: t, hostBin: n }) {
418
+ let r = p.join(t.outDir, `${e.productName}.app`);
419
+ await d(r, {
399
420
  recursive: !0,
400
421
  force: !0
401
422
  });
402
- let c = e.join(s, "Contents"), d = e.join(c, "MacOS"), f = e.join(c, "Resources");
403
- await o(d, { recursive: !0 }), await o(f, { recursive: !0 });
404
- let p = e.join(d, t.productName);
405
- await a(r, p), await i(p, 493), await W(n, f);
423
+ let i = p.join(r, "Contents"), a = p.join(i, "MacOS"), l = p.join(i, "Resources");
424
+ await c(a, { recursive: !0 }), await c(l, { recursive: !0 });
425
+ let u = p.join(a, e.productName);
426
+ await s(n, u), await o(u, 493), await J(t, l);
406
427
  let m = {
407
- CFBundleName: t.productName,
408
- CFBundleDisplayName: t.productName,
409
- CFBundleExecutable: t.productName,
410
- CFBundleIdentifier: t.identifier,
411
- CFBundleVersion: t.version,
412
- CFBundleShortVersionString: t.version,
428
+ CFBundleName: e.productName,
429
+ CFBundleDisplayName: e.productName,
430
+ CFBundleExecutable: e.productName,
431
+ CFBundleIdentifier: e.identifier,
432
+ CFBundleVersion: e.version,
433
+ CFBundleShortVersionString: e.version,
413
434
  CFBundlePackageType: "APPL",
414
435
  CFBundleInfoDictionaryVersion: "6.0",
415
436
  NSHighResolutionCapable: !0
416
437
  };
417
- if (t.icon) {
418
- let n = e.basename(t.icon);
419
- await a(t.icon, e.join(f, n)), m.CFBundleIconFile = n;
438
+ if (e.icon) {
439
+ let t = p.basename(e.icon);
440
+ await s(e.icon, p.join(l, t)), m.CFBundleIconFile = t;
420
441
  }
421
- return await u(e.join(c, "Info.plist"), H(m)), await u(e.join(c, "PkgInfo"), "APPL????"), s;
442
+ return await f(p.join(i, "Info.plist"), K(m)), await f(p.join(i, "PkgInfo"), "APPL????"), r;
422
443
  }
423
- async function K({ metadata: t, output: n, hostBin: r }) {
424
- let s = R(t.productName), c = e.join(n.outDir, s);
425
- await l(c, {
444
+ async function X({ metadata: t, output: n, hostBin: r }) {
445
+ let i = e(t.productName), a = p.join(n.outDir, i);
446
+ await d(a, {
426
447
  recursive: !0,
427
448
  force: !0
428
- }), await o(c, { recursive: !0 });
429
- let u = e.join(c, s);
430
- return await a(r, u), await i(u, 493), await W(n, c), c;
449
+ }), await c(a, { recursive: !0 });
450
+ let l = p.join(a, i);
451
+ return await s(r, l), await o(l, 493), await J(n, a), a;
431
452
  }
432
- async function q(e = {}) {
433
- let t = e.cwd ?? process.cwd(), n = e.stdout ?? process.stdout, i = e.target ?? U(), a = await z(t);
434
- a.identifierIsDefault && n.write(`[inca] no "inca.identifier" set in package.json — using generated identifier ${a.identifier}\n`);
435
- let o = await w({
453
+ async function Z(e = {}) {
454
+ let t = e.cwd ?? process.cwd(), n = e.stdout ?? process.stdout, r = e.target ?? q(), i = await S(t);
455
+ i.usedPackageJsonKey && n.write("[inca] the \"inca\" key in package.json is deprecated — move these settings to inca.config.ts\n"), i.identifierIsDefault && n.write(`[inca] no "identifier" set in inca.config.ts — using generated identifier ${i.identifier}\n`);
456
+ let o = await j({
436
457
  cwd: t,
437
458
  entry: e.entry,
459
+ config: i,
438
460
  bundler: e.bundler
439
- }), s = e.hostBin ?? O();
440
- if (!r(s)) throw Error(`no host binary at ${s} — check that it was built and is executable`);
461
+ }), s = e.hostBin ?? F();
462
+ if (!a(s)) throw Error(`no host binary at ${s} — check that it was built and is executable`);
441
463
  let c = {
442
- metadata: a,
464
+ metadata: i,
443
465
  output: o,
444
466
  hostBin: s
445
467
  };
446
- return { appPath: i === "macos" ? await G(c) : await K(c) };
468
+ return { appPath: r === "macos" ? await Y(c) : await X(c) };
447
469
  }
448
470
  //#endregion
449
471
  //#region src/cli.mts
450
- var J = "Usage: inca <dev|build|package>";
451
- async function Y(e = process.argv) {
472
+ var Q = "Usage: inca <dev|build|package>";
473
+ async function $(e = process.argv) {
452
474
  let t = e[2];
453
475
  if (t === "build") {
454
476
  try {
455
- let e = await w();
477
+ let e = await j();
456
478
  process.stdout.write(`[inca] built ${e.entryFile}\n`);
457
479
  } catch (e) {
458
- P(process.stderr, "build failed", N(e)), process.exitCode = 1;
480
+ V(process.stderr, "build failed", B(e)), process.exitCode = 1;
459
481
  }
460
482
  return;
461
483
  }
462
484
  if (t === "package") {
463
485
  try {
464
- let { appPath: e } = await q();
486
+ let { appPath: e } = await Z();
465
487
  process.stdout.write(`[inca] packaged ${e}\n`);
466
488
  } catch (e) {
467
- P(process.stderr, "package failed", N(e)), process.exitCode = 1;
489
+ V(process.stderr, "package failed", B(e)), process.exitCode = 1;
468
490
  }
469
491
  return;
470
492
  }
471
493
  if (t !== "dev") {
472
- process.stderr.write(`${J}\n`), process.exitCode = 1;
494
+ process.stderr.write(`${Q}\n`), process.exitCode = 1;
473
495
  return;
474
496
  }
475
497
  let n = new AbortController(), r = () => {
476
498
  process.stderr.write("[inca] shutting down\n"), n.abort();
477
499
  };
478
- process.on("SIGINT", r), process.on("SIGTERM", r), await I({ signal: n.signal });
500
+ process.on("SIGINT", r), process.on("SIGTERM", r), await U({ signal: n.signal });
479
501
  }
480
502
  //#endregion
481
- export { Y as run };
503
+ export { $ as run };