@incajs/cli 0.0.23 → 0.0.24
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 +16 -16
- package/package.json +5 -5
package/dist/cli.js
CHANGED
|
@@ -1,33 +1,33 @@
|
|
|
1
|
-
import{t as e}from"./chunks/rolldown-runtime-DT7IzrpZ.js";import{c as t,i as n,n as r,o as i,r as a,s as o,t as s}from"./chunks/dist-B-B_PlmU.js";import{i as c,n as l,r as u,t as d}from"./chunks/defaults-DfHXv1fN.js";import{createRequire as f}from"node:module";import p,{existsSync as m,lstatSync as h,readFileSync as g,realpathSync as _,statSync as v,watch as y}from"node:fs";import b,{resolve as x}from"node:path";import*as S from"node:util";import{parseArgs as C,styleText as w}from"node:util";import{chmod as ee,cp as T,link as E,mkdir as D,readFile as O,readdir as k,rm as A,writeFile as j}from"node:fs/promises";import{fileURLToPath as te,pathToFileURL as M}from"node:url";import{homedir as ne}from"node:os";import{spawn as re,spawnSync as ie}from"node:child_process";import{once as
|
|
2
|
-
`)}function
|
|
3
|
-
`)}catch(e){console.error(e)}}const
|
|
4
|
-
`)}function
|
|
5
|
-
`),process.exit(1)}}async function Ve(e){let t=await F(e.args||{}),n=/* @__PURE__ */ new Set,r=/* @__PURE__ */ new Set;for(let[e,i]of Object.entries(t)){n.add(e);for(let e of P(i.alias))r.add(e)}return{help:He(`help`,`h`,n,r),version:He(`version`,`v`,n,r)}}function He(e,t,n,r){return n.has(e)||r.has(e)?[]:n.has(t)||r.has(t)?[`--${e}`]:[`--${e}`,`-${t}`]}var Ue=`0.0.23`,We=`Commands to develop, bundle, and package Incarnative.js apps.`;function H(e,t,n){let r=typeof e==`object`&&e?e:{},i=b.relative(n,t).split(b.sep).join(`/`);return{...r,root:i===``?`.`:i}}function Ge(e){return e&&e.constructor&&typeof e.constructor.isBuffer==`function`&&e.constructor.isBuffer(e)}function Ke(e){return e}function qe(e,t){t||={};let n=t.delimiter||`.`,r=t.maxDepth,i=t.transformKey||Ke,a={};function o(e,s,c){c||=1,Object.keys(e).forEach(function(l){let u=e[l],d=t.safe&&Array.isArray(u),f=Object.prototype.toString.call(u),p=Ge(u),m=f===`[object Object]`||f===`[object Array]`,h=s?s+n+i(l):i(l);if(!d&&!p&&m&&Object.keys(u).length&&(!t.maxDepth||c<r))return o(u,h,c+1);a[h]=u})}return o(e),a}function Je(e,t){t||={};let n=t.delimiter||`.`,r=t.overwrite||!1,i=t.transformKey||Ke,a={};if(Ge(e)||Object.prototype.toString.call(e)!==`[object Object]`)return e;function o(e){let n=Number(e);return isNaN(n)||e.indexOf(`.`)!==-1||t.object?e:n}function s(e,t,r){return Object.keys(r).reduce(function(t,i){return t[e+n+i]=r[i],t},t)}function c(e){let t=Object.prototype.toString.call(e),n=t===`[object Array]`,r=t===`[object Object]`;if(!e)return!0;if(n)return!e.length;if(r)return!Object.keys(e).length}return e=Object.keys(e).reduce(function(n,r){let i=Object.prototype.toString.call(e[r]);return i!==`[object Object]`&&i!==`[object Array]`||c(e[r])?(n[r]=e[r],n):s(r,n,qe(e[r],t))},{}),Object.keys(e).forEach(function(s){let c=s.split(n).map(i),l=o(c.shift()),u=o(c[0]),d=a;for(;u!==void 0;){if(l===`__proto__`)return;let e=Object.prototype.toString.call(d[l]),n=e===`[object Object]`||e===`[object Array]`;if(!r&&!n&&d[l]!==void 0)return;(r&&!n||!r&&d[l]==null)&&(d[l]=typeof u==`number`&&!t.object?[]:{}),d=d[l],c.length>0&&(l=o(c.shift()),u=o(c[0]))}d[l]=Je(e[s],t)}),a}const Ye=/"(?:_|\\u0{2}5[Ff]){2}(?:p|\\u0{2}70)(?:r|\\u0{2}72)(?:o|\\u0{2}6[Ff])(?:t|\\u0{2}74)(?:o|\\u0{2}6[Ff])(?:_|\\u0{2}5[Ff]){2}"\s*:/,Xe=/"(?:c|\\u0063)(?:o|\\u006[Ff])(?:n|\\u006[Ee])(?:s|\\u0073)(?:t|\\u0074)(?:r|\\u0072)(?:u|\\u0075)(?:c|\\u0063)(?:t|\\u0074)(?:o|\\u006[Ff])(?:r|\\u0072)"\s*:/,Ze=/^\s*["[{]|^\s*-?\d{1,16}(\.\d{1,17})?([Ee][+-]?\d+)?\s*$/;function Qe(e,t){if(e===`__proto__`||e===`constructor`&&t&&typeof t==`object`&&`prototype`in t)$e(e);else return t}function $e(e){console.warn(`[destr] Dropping "${e}" key to prevent prototype pollution.`)}function et(e,t={}){if(typeof e!=`string`)return e;if(e[0]===`"`&&e[e.length-1]===`"`&&e.indexOf(`\\`)===-1)return e.slice(1,-1);let n=e.trim();if(n.length<=9)switch(n.toLowerCase()){case`true`:return!0;case`false`:return!1;case`undefined`:return;case`null`:return null;case`nan`:return NaN;case`infinity`:return 1/0;case`-infinity`:return-1/0}if(!Ze.test(e)){if(t.strict)throw SyntaxError(`[destr] Invalid JSON`);return e}try{if(Ye.test(e)||Xe.test(e)){if(t.strict)throw Error(`[destr] Possible prototype pollution`);return JSON.parse(e,Qe)}return JSON.parse(e)}catch(n){if(t.strict)throw n;return e}}function tt(e){if(typeof e!=`object`||!e)return!1;let t=Object.getPrototypeOf(e);return t!==null&&t!==Object.prototype&&Object.getPrototypeOf(t)!==null||Symbol.iterator in e?!1:Symbol.toStringTag in e?Object.prototype.toString.call(e)===`[object Module]`:!0}function nt(e,t,n=`.`,r){if(!tt(t))return nt(e,{},n,r);let i={...t};for(let t of Object.keys(e)){if(t===`__proto__`||t===`constructor`)continue;let a=e[t];a!=null&&(r&&r(i,t,a,n)||(i[t]=Array.isArray(a)&&Array.isArray(i[t])?[...a,...i[t]]:tt(a)&&tt(i[t])?nt(a,i[t],(n?`${n}.`:``)+t.toString(),r):a))}return i}function rt(e){return(...t)=>t.reduce((t,n)=>nt(t,n,``,e),{})}const U=rt(),it=/^\s*([^\s=]+)\s*=\s*(.*)?\s*$/,at=/\n|\r|\r\n/,ot={name:`.conf`,dir:process.cwd(),flat:!1};function st(e){return typeof e==`string`&&(e={name:e}),{...ot,...e}}function ct(e,t={}){let n={},r=e.split(at);for(let e of r){let t=e.match(it);if(!t)continue;let r=t[1];if(!r||r===`__proto__`||r===`constructor`)continue;let i=et((t[2]||``).trim());if(r.endsWith(`[]`)){let e=r.slice(0,Math.max(0,r.length-2));n[e]=(n[e]||[]).concat(i)}else n[r]=i}return t.flat?n:Je(n,{overwrite:!0})}function lt(e,t){return m(e)?ct(g(e,`utf8`),t):{}}function W(e){return e=st(e),lt(x(e.dir,e.name),e)}function ut(){return process.env.XDG_CONFIG_HOME||x(ne(),`.config`)}function dt(e){return e=st(e),e.dir=ut(),W(e)}async function ft(e){let t=e.env??process.env,n=await pt({cwd:e.cwd,fileName:e.fileName??`.env`,env:t,interpolate:e.interpolate??!0,expandFileReferences:e.expandFileReferences??!1,parse:e.parse}),r=xt(t);for(let e in n)e.startsWith(`_`)||(t[e]===void 0||r.has(e))&&(t[e]=n[e]);return n}async function pt(e){let n=Object.create(null),r=t(e.cwd||`.`),i=e.fileName||`.env`,a=typeof i==`string`?[i]:i,o=xt(e.env||{});Object.assign(n,e.env);for(let i of a){let a=t(r,i);if(!v(a,{throwIfNoEntry:!1})?.isFile())continue;let s=await ht(a,e.parse);for(let e in s)e in n&&!o.has(e)||(n[e]=s[e],o.add(e))}if(e.expandFileReferences){for(let e in n)if(e.endsWith(`_FILE`)){let t=e.slice(0,-5);if(n[t]===void 0){let r=n[e];r&&v(r,{throwIfNoEntry:!1})?.isFile()&&(n[t]=g(r,`utf8`).trim(),o.add(t))}}}return e.interpolate&>(n),n}let mt=S.parseEnv;async function ht(e,t){let n=g(e,`utf8`);if(t)return t(n);if(!mt)try{let e=await import(`dotenv`);mt=t=>e.parse(t)}catch{throw Error("Failed to parse .env file: `node:util.parseEnv` is not available and `dotenv` package is not installed. Please upgrade your runtime, install `dotenv` as a dependency or provide a custom `parse` option.")}return mt(n)}function gt(e,t={},n=e=>e){function r(n){return t[n]===void 0?e[n]:t[n]}function i(e,t=[]){if(typeof e!=`string`)return e;let a=``,o=0;for(;o<e.length;){let n=e[o];if(n===`\\`&&e[o+1]===`$`){a+=`$`,o+=2;continue}let s=n===`$`?yt(e,o):void 0;if(!s){a+=n,o++;continue}if(t.includes(s.key)){if(s.defaultValue!==void 0){a+=i(s.defaultValue,t),o=s.end;continue}return console.warn(`Please avoid recursive environment variables ( loop: ${t.join(` > `)} > ${s.key} )`),``}let c=i(r(s.key),[...t,s.key]);s.defaultValue!==void 0&&(c===void 0||s.operator===`:-`&&c===``)&&(c=i(s.defaultValue,t)),a+=c===void 0?e.slice(o,s.end):c,o=s.end}return n(a)}for(let t in e)e[t]=i(r(t))}const _t=/\w+/y,vt=/[\w:]+/y;function yt(e,t){let n=t+1,r=e[n]===`{`;r&&n++;let i=r?vt:_t;i.lastIndex=n;let a=i.exec(e);if(!a)return;let o=a[0];if(n=i.lastIndex,!r)return{key:o,end:n};if(e[n]===`}`)return{key:o,end:n+1};if(e[n]===`-`){let t=`-`;o.endsWith(`:`)&&(o=o.slice(0,-1),t=`:-`);let r=o?bt(e,n+1):void 0;return r?{key:o,operator:t,defaultValue:r.value,end:r.end}:void 0}return{key:o,end:n}}function bt(e,t){let n=``,r=1;for(let i=t;i<e.length;i++){let t=e[i];if(t===`\\`&&i+1<e.length){let r=e[i+1];n+=r===`{`||r===`}`?r:t+r,i++}else if(t===`$`&&e[i+1]===`{`)r++,n+="${",i++;else{if(t===`{`&&r++,t===`}`&&(r--,r===0))return{value:n,end:i+1};n+=t}}}function xt(e){let t=globalThis.__c12_dotenv_vars__||=/* @__PURE__ */ new Map;return t.has(e)||t.set(e,/* @__PURE__ */ new Set),t.get(e)}const St=e=>e?.replace(/\\/g,`/`);let Ct=0;const wt={".json":()=>JSON.parse,".yaml":()=>import(`./chunks/yaml-DtBxpt6z.js`).then(e=>e.parseYAML),".yml":()=>import(`./chunks/yaml-DtBxpt6z.js`).then(e=>e.parseYAML),".jsonc":()=>import(`./chunks/jsonc-DJWoCi14.js`).then(e=>e.n).then(e=>t=>e.parseJSONC(t,{allowTrailingComma:!0})),".json5":()=>import(`./chunks/json5-BcF68iGq.js`).then(e=>e.parseJSON5),".toml":()=>import(`./chunks/toml-n3nLqi2g.js`).then(e=>e.parseTOML)},Tt=Object.freeze([`.js`,`.ts`,`.mjs`,`.cjs`,`.mts`,`.cts`,`.json`,`.jsonc`,`.json5`,`.yaml`,`.yml`,`.toml`]);async function Et(e){e.cwd=t(process.cwd(),e.cwd||`.`),e.name=e.name||`config`,e.envName=e.envName??process.env.NODE_ENV,e.configFile=e.configFile??(e.name===`config`?`config`:`${e.name}.config`),e.rcFile=e.rcFile??`.${e.name}rc`,e.extend!==!1&&(e.extend={extendKey:`extends`,...e.extend});let n=e.merger||U,r={config:{},cwd:e.cwd,configFile:t(e.cwd,e.configFile),layers:[],_configFile:void 0},i={overrides:e.overrides,main:void 0,rc:void 0,packageJson:void 0,defaultConfig:e.defaultConfig};e.dotenv&&await ft({cwd:e.cwd,...e.dotenv===!0?{}:e.dotenv});let a=await At(`.`,e);if(a.configFile&&(i.main=a.config,r.configFile=a.configFile,r._configFile=a._configFile),a.meta&&(r.meta=a.meta),e.rcFile){let t=[];if(t.push(W({name:e.rcFile,dir:e.cwd})),e.globalRc){let{findWorkspaceDir:n}=await import(`./chunks/dist-BTWvruNB.js`),r=await n(e.cwd).catch(()=>{});r&&t.push(W({name:e.rcFile,dir:r})),t.push(dt({name:e.rcFile})),t.push(W({name:e.rcFile,dir:ne()}))}i.rc=n({},...t)}if(e.packageJson){let t=(Array.isArray(e.packageJson)?e.packageJson:[typeof e.packageJson==`string`?e.packageJson:e.name]).filter(e=>e&&typeof e==`string`),{readPackageJSON:r}=await import(`./chunks/dist-BTWvruNB.js`),a=await r(e.cwd).catch(()=>{});i.packageJson=n({},...t.map(e=>a?.[e]))}let o={};for(let e in i){let t=i[e];o[e]=await(typeof t==`function`?t({configs:o,rawConfigs:i}):t)}if(Array.isArray(o.main)?r.config=o.main:(r.config=n(o.overrides,o.main,o.rc,o.packageJson,o.defaultConfig),e.extend&&(await Dt(r.config,e),r.layers=r.config._layers,delete r.config._layers,r.config=n(r.config,...r.layers.map(e=>e.config)))),r.layers=[...[o.overrides&&{config:o.overrides,configFile:void 0,cwd:void 0},{config:o.main,configFile:e.configFile,cwd:e.cwd},o.rc&&{config:o.rc,configFile:e.rcFile},o.packageJson&&{config:o.packageJson,configFile:`package.json`}].filter(e=>e&&e.config),...r.layers],e.defaults&&(r.config=n(r.config,e.defaults)),e.omit$Keys)for(let e in r.config)e.startsWith(`$`)&&delete r.config[e];if(e.configFileRequired&&!r._configFile)throw Error(`Required config (${r.configFile}) cannot be resolved.`);return e.schema!=null&&(r.config=await jt(r.config,e.schema)),r}async function Dt(e,t){if(e._layers=e._layers||[],!t.extend)return;let n=t.extend.extendKey;typeof n==`string`&&(n=[n]);let r=[];for(let t of n)r.push(...(Array.isArray(e[t])?e[t]:[e[t]]).filter(Boolean)),delete e[t];for(let n of r){let r=n,i={};if(n.source&&(i=n.options||{},n=n.source),Array.isArray(n)&&(i=n[1]||{},n=n[0]),typeof n!=`string`){console.warn(`Cannot extend config from \`${JSON.stringify(r)}\` in ${t.cwd}`);continue}let a=await At(n,t,i);a.config?(await Dt(a.config,{...t,cwd:a.cwd}),e._layers.push(a),a.config._layers&&(e._layers.push(...a.config._layers),delete a.config._layers)):console.warn(`Cannot extend config from \`${n}\` in ${t.cwd}`)}}const Ot=[`gh:`,`github:`,`gitlab:`,`bitbucket:`,`https://`,`http://`],kt=/^(@[\da-z~-][\d._a-z~-]*\/)?[\da-z~-][\d._a-z~-]*($|\/.*)/;async function At(e,o,s={}){if(o.resolve){let t=await o.resolve(e,o);if(t)return t}let c=o.merger||U,l=Object.keys(s.giget?.providers||{}).map(e=>`${e}:`),u=l.length>0?[.../* @__PURE__ */ new Set([...l,...Ot])]:Ot;if(o.giget!==!1&&u.some(t=>e.startsWith(t))){let{downloadTemplate:n}=await import(`giget`).catch(t=>{throw Error(`Extending config from \`${e}\` requires \`giget\` peer dependency to be installed.\n\nInstall it with: \`npx nypm i giget\``,{cause:t})}),{digest:c}=await import(`./chunks/ohash-DUMW2FP0.js`).then(e=>e.dist_exports),l=e.replace(/\W+/g,`_`).split(`_`).splice(0,3).join(`_`)+`_`+c(e).slice(0,10).replace(/[-_]/g,``),u,d=t(o.cwd,`node_modules`),f=a(o.cwd);u=r(f)===`.c12`?i(f,l):m(d)?i(d,`.c12`,l):process.env.XDG_CACHE_HOME?t(process.env.XDG_CACHE_HOME,`c12`,l):t(ne(),`.cache/c12`,l);let p=s.install?U(s.install===!0?{}:s.install,{ignoreWorkspace:!0}):!1;m(u)&&!p&&await A(u,{recursive:!0}),e=(await n(e,{dir:u,install:p,force:!!p,auth:s.auth,...o.giget,...s.giget})).dir}kt.test(e)&&(e=G(e,o)||e);let d=n(e),f=Mt(t(o.cwd,e))??(!d||d===r(e)),p=t(o.cwd,f?e:a(e));f&&(e=o.configFile);let h={config:void 0,configFile:void 0,cwd:p,source:e,sourceOptions:s};if(h.configFile=G(t(p,e),o)||G(t(p,`.config`,e.replace(/\.config$/,``)),o)||G(t(p,`.config`,e),o)||e,!m(h.configFile))return h;h._configFile=h.configFile;let g=n(h.configFile)||``;if(g in wt)h.config=(await wt[g]())(await O(h.configFile,`utf8`));else{let e=o.resolveModule||(e=>e.default||e);if(o.import)h.config=e(await o.import(h.configFile));else{let t=M(h.configFile);t.search=`_${++Ct}`,h.config=await import(t.href).then(e,async t=>{let{createJiti:n}=await import(`jiti`).catch(()=>{throw Error(`Failed to load config file \`${h.configFile}\`: ${t?.message}. Hint install \`jiti\` for compatibility.`,{cause:t})}),r=n(i(o.cwd||`.`,o.configFile||`/`),{interopDefault:!0,moduleCache:!1,extensions:[...Tt],...o.jitiOptions});return o.import=e=>r.import(e),e(await o.import(h.configFile))})}}typeof h.config==`function`&&(h.config=await h.config(o.context)),h.config&&typeof h.config==`object`&&!Array.isArray(h.config)&&!Object.isExtensible(h.config)&&(h.config={...h.config});let _=(Array.isArray(o.envName)?o.envName:[o.envName]).filter(Boolean).reverse().flatMap(e=>[h.config.$env?.[e],h.config[`$`+e]]).filter(e=>e&&Object.keys(e).length>0);return _.length>0&&(h.config=(o.envMerger||c)({},..._,h.config)),h.meta=U(h.sourceOptions.meta,h.config.$meta),delete h.config.$meta,h.sourceOptions.overrides&&(h.config=c(h.sourceOptions.overrides,h.config)),h.configFile=St(h.configFile),h.source=St(h.source),h}async function jt(e,t){if(typeof t?.[`~standard`]?.validate!=`function`)throw TypeError("Invalid `schema` option: expected a Standard Schema (https://standardschema.dev).");let n=await t[`~standard`].validate(e);if(n.issues){let e=n.issues.map(e=>{let t=e.path?.map(e=>String(typeof e==`object`?e.key:e)).join(`.`);return` - ${t?`${t}: `:``}${e.message}`});throw Error(`Config validation failed (${t[`~standard`].vendor}):\n${e.join(`
|
|
6
|
-
`)}`,{cause:n.issues})}return n.value}function
|
|
7
|
-
`)?e:`${e}\n`)};var
|
|
1
|
+
import{t as e}from"./chunks/rolldown-runtime-DT7IzrpZ.js";import{c as t,i as n,n as r,o as i,r as a,s as o,t as s}from"./chunks/dist-B-B_PlmU.js";import{i as c,n as l,r as u,t as d}from"./chunks/defaults-DfHXv1fN.js";import{createRequire as f}from"node:module";import p,{existsSync as m,lstatSync as h,readFileSync as g,realpathSync as _,statSync as v,watch as y}from"node:fs";import b,{resolve as x}from"node:path";import*as S from"node:util";import{parseArgs as C,styleText as w}from"node:util";import{chmod as ee,cp as T,link as E,mkdir as D,readFile as O,readdir as k,rm as A,writeFile as j}from"node:fs/promises";import{fileURLToPath as te,pathToFileURL as M}from"node:url";import{homedir as ne}from"node:os";import{spawn as re,spawnSync as ie}from"node:child_process";import{once as N}from"node:events";import ae from"node:readline";import{setTimeout as P}from"node:timers/promises";import{DevEnvironment as oe,build as se,buildErrorMessage as ce,createServer as le}from"vite";import ue from"@vitejs/plugin-vue";import{randomUUID as de}from"node:crypto";const fe=/\d/,pe=[`-`,`_`,`/`,`.`];function me(e=``){if(!fe.test(e))return e!==e.toLowerCase()}function he(e,t){let n=t??pe,r=[];if(!e||typeof e!=`string`)return r;let i=``,a,o;for(let t of e){let e=n.includes(t);if(e===!0){r.push(i),i=``,a=void 0;continue}let s=me(t);if(o===!1){if(a===!1&&s===!0){r.push(i),i=t,a=s;continue}if(a===!0&&s===!1&&i.length>1){let e=i.at(-1);r.push(i.slice(0,Math.max(0,i.length-1))),i=e+t,a=s;continue}}i+=t,a=s,o=e}return r.push(i),r}function ge(e){return e?e[0].toUpperCase()+e.slice(1):``}function _e(e){return e?e[0].toLowerCase()+e.slice(1):``}function ve(e,t){return e?(Array.isArray(e)?e:he(e)).map(e=>ge(t?.normalize?e.toLowerCase():e)).join(``):``}function F(e,t){return _e(ve(e||``,t))}function ye(e,t){return e?(Array.isArray(e)?e:he(e)).map(e=>e.toLowerCase()).join(t??`-`):``}function be(e){return ye(e||``,`_`)}function I(e){return Array.isArray(e)?e:e===void 0?[]:[e]}function xe(e,t=``){let n=[];for(let t of e)for(let[e,r]of t.entries())n[e]=Math.max(n[e]||0,r.length);return e.map(e=>e.map((e,r)=>t+e[r===0?`padStart`:`padEnd`](n[r])).join(` `)).join(`
|
|
2
|
+
`)}function L(e){return typeof e==`function`?e():e}var R=class extends Error{code;constructor(e,t){super(e),this.name=`CLIError`,this.code=t}};function Se(e=[],t={}){let n=new Set(t.boolean||[]),r=new Set(t.string||[]),i=t.alias||{},a=t.default||{},o=/* @__PURE__ */ new Map,s=/* @__PURE__ */ new Map;for(let[e,t]of Object.entries(i)){let n=t;for(let t of n)o.set(e,t),s.has(t)||s.set(t,[]),s.get(t).push(e),o.set(t,e),s.has(e)||s.set(e,[]),s.get(e).push(t)}let c={};function l(e){if(n.has(e))return`boolean`;let t=s.get(e)||[];for(let e of t)if(n.has(e))return`boolean`;return`string`}function u(e){if(r.has(e))return!0;let t=s.get(e)||[];for(let e of t)if(r.has(e))return!0;return!1}let d=/* @__PURE__ */ new Set([...n,...r,...Object.keys(i),...Object.values(i).flat(),...Object.keys(a)]);for(let e of d)c[e]||(c[e]={type:l(e),default:a[e]});for(let[e,t]of o.entries())e.length===1&&c[t]&&!c[t].short&&(c[t].short=e);let f=[],p={};for(let t=0;t<e.length;t++){let n=e[t];if(n===`--`){f.push(...e.slice(t));break}if(n.startsWith(`--no-`)){let e=n.slice(5);p[e]=!0}else f.push(n)}let m;try{m=C({args:f,options:Object.keys(c).length>0?c:void 0,allowPositionals:!0,strict:!1})}catch{m={values:{},positionals:f}}let h={_:[]};h._=m.positionals;for(let[e,t]of Object.entries(m.values)){let n=t;l(e)===`boolean`&&typeof t==`string`?n=t!==`false`:u(e)&&typeof t==`boolean`&&(n=``),h[e]=n}for(let[e]of Object.entries(p)){h[e]=!1;let t=o.get(e);t&&(h[t]=!1);let n=s.get(e);if(n)for(let e of n)h[e]=!1}for(let[e,t]of o.entries())h[e]!==void 0&&h[t]===void 0&&(h[t]=h[e]),h[t]!==void 0&&h[e]===void 0&&(h[e]=h[t]),h[e]!==h[t]&&a[t]===h[t]&&(h[t]=h[e]);return h}const Ce=/* @__PURE__ */ (()=>{let e=globalThis.process?.env??{};return e.NO_COLOR===`1`||e.TERM===`dumb`||e.TEST||e.CI})(),we=(e,t=39)=>n=>Ce?n:`\u001B[${e}m${n}\u001B[${t}m`,Te=/* @__PURE__ */ we(1,22),z=/* @__PURE__ */ we(36),B=/* @__PURE__ */ we(90),V=/* @__PURE__ */ we(4,24);function Ee(e,t){let n={boolean:[],string:[],alias:{},default:{}},r=De(t);for(let e of r){if(e.type===`positional`)continue;e.type===`string`||e.type===`enum`?n.string.push(e.name):e.type===`boolean`&&n.boolean.push(e.name),e.default!==void 0&&(n.default[e.name]=e.default),e.alias&&(n.alias[e.name]=e.alias);let t=F(e.name),r=ye(e.name);if(t!==e.name||r!==e.name){let i=I(n.alias[e.name]||[]);t!==e.name&&!i.includes(t)&&i.push(t),r!==e.name&&!i.includes(r)&&i.push(r),i.length>0&&(n.alias[e.name]=i)}}let i=Se(e,n),[...a]=i._,o=new Proxy(i,{get(e,t){return e[t]??e[F(t)]??e[ye(t)]}});for(let[,e]of r.entries())if(e.type===`positional`){let t=a.shift();if(t!==void 0)o[e.name]=t;else if(e.default===void 0&&e.required!==!1)throw new R(`Missing required positional argument: ${e.name.toUpperCase()}`,`EARG`);else o[e.name]=e.default}else if(e.type===`enum`){let t=o[e.name],n=e.options||[];if(t!==void 0&&n.length>0&&!n.includes(t))throw new R(`Invalid value for argument: ${z(`--${e.name}`)} (${z(t)}). Expected one of: ${n.map(e=>z(e)).join(`, `)}.`,`EARG`)}else if(e.required&&o[e.name]===void 0)throw new R(`Missing required argument: --${e.name}`,`EARG`);return o}function De(e){let t=[];for(let[n,r]of Object.entries(e||{}))t.push({...r,name:n,alias:I(r.alias)});return t}async function Oe(e){return Promise.all(e.map(e=>L(e)))}function H(e){return e}async function ke(e,t){let n=await L(e.args||{}),r=Ee(t.rawArgs,n),i={rawArgs:t.rawArgs,args:r,data:t.data,cmd:e},a=await Oe(e.plugins??[]),o,s;try{for(let e of a)await e.setup?.(i);typeof e.setup==`function`&&await e.setup(i);let r=await L(e.subCommands);if(r&&Object.keys(r).length>0){let i=Me(t.rawArgs,n),a=t.rawArgs[i];if(a){let e=await je(r,a);if(!e)throw new R(`Unknown command ${z(a)}`,`E_UNKNOWN_COMMAND`);await ke(e,{rawArgs:t.rawArgs.slice(i+1)})}else{let n=await L(e.default);if(n){if(e.run)throw new R(`Cannot specify both 'run' and 'default' on the same command.`,`E_DEFAULT_CONFLICT`);let i=await je(r,n);if(!i)throw new R(`Default sub command ${z(n)} not found in subCommands.`,`E_UNKNOWN_COMMAND`);await ke(i,{rawArgs:t.rawArgs})}else if(!e.run)throw new R(`No command specified.`,`E_NO_COMMAND`)}}typeof e.run==`function`&&(o=await e.run(i))}catch(e){s=e}let c=[];if(typeof e.cleanup==`function`)try{await e.cleanup(i)}catch(e){c.push(e)}for(let e of[...a].reverse())try{await e.cleanup?.(i)}catch(e){c.push(e)}if(s)throw s;if(c.length===1)throw c[0];if(c.length>1)throw Error(`Multiple cleanup errors`,{cause:c});return{result:o}}async function Ae(e,t,n){let r=await L(e.subCommands);if(r&&Object.keys(r).length>0){let n=Me(t,await L(e.args||{})),i=t[n],a=await je(r,i);if(a)return Ae(a,t.slice(n+1),e)}return[e,n]}async function je(e,t){if(t in e)return L(e[t]);for(let n of Object.values(e)){let e=await L(n),r=await L(e?.meta);if(r?.alias&&I(r.alias).includes(t))return e}}function Me(e,t){for(let n=0;n<e.length;n++){let r=e[n];if(r===`--`)return-1;if(r.startsWith(`-`))!r.includes(`=`)&&Ne(r,t)&&n++;else return n}return-1}function Ne(e,t){let n=e.replace(/^-{1,2}/,``),r=F(n);for(let[e,i]of Object.entries(t))if((i.type===`string`||i.type===`enum`)&&(r===F(e)||(Array.isArray(i.alias)?i.alias:i.alias?[i.alias]:[]).includes(n)))return!0;return!1}async function Pe(e,t){try{console.log(await Ie(e,t)+`
|
|
3
|
+
`)}catch(e){console.error(e)}}const Fe=/^no[-A-Z]/;async function Ie(e,t){let n=await L(e.meta||{}),r=De(await L(e.args||{})),i=await L(t?.meta||{}),a=`${i.name?`${i.name} `:``}`+(n.name||process.argv[1]),o=[],s=[],c=[],l=[];for(let e of r)if(e.type===`positional`){let t=e.name.toUpperCase(),n=e.required!==!1&&e.default===void 0;s.push([z(t+Le(e)),Re(e,n)]),l.push(n?`<${t}>`:`[${t}]`)}else{let t=e.required===!0&&e.default===void 0,n=[...(e.alias||[]).map(e=>`-${e}`),`--${e.name}`].join(`, `)+Le(e);if(o.push([z(n),Re(e,t)]),e.type===`boolean`&&(e.default===!0||e.negativeDescription)&&!Fe.test(e.name)){let n=[...(e.alias||[]).map(e=>`--no-${e}`),`--no-${e.name}`].join(`, `);o.push([z(n),[e.negativeDescription,t?B(`(Required)`):``].filter(Boolean).join(` `)])}t&&l.push(`--${e.name}`+Le(e))}if(e.subCommands){let t=[],n=await L(e.subCommands);for(let[e,r]of Object.entries(n)){let n=await L((await L(r))?.meta);if(n?.hidden)continue;let i=I(n?.alias),a=[e,...i].join(`, `);c.push([z(a),n?.description||``]),t.push(e,...i)}l.push(t.join(`|`))}let u=[],d=n.version||i.version;u.push(B(`${n.description} (${a+(d?` v${d}`:``)})`),``);let f=o.length>0||s.length>0;return u.push(`${V(Te(`USAGE`))} ${z(`${a}${f?` [OPTIONS]`:``} ${l.join(` `)}`)}`,``),s.length>0&&(u.push(V(Te(`ARGUMENTS`)),``),u.push(xe(s,` `)),u.push(``)),o.length>0&&(u.push(V(Te(`OPTIONS`)),``),u.push(xe(o,` `)),u.push(``)),c.length>0&&(u.push(V(Te(`COMMANDS`)),``),u.push(xe(c,` `)),u.push(``,`Use ${z(`${a} <command> --help`)} for more information about a command.`)),u.filter(e=>typeof e==`string`).join(`
|
|
4
|
+
`)}function Le(e){let t=e.valueHint?`=<${e.valueHint}>`:``,n=t||`=<${be(e.name)}>`;return!e.type||e.type===`positional`||e.type===`boolean`?t:e.type===`enum`&&e.options?.length?`=<${e.options.join(`|`)}>`:n}function Re(e,t){let n=t?B(`(Required)`):``,r=e.default===void 0?``:B(`(Default: ${e.default})`);return[e.description,n,r].filter(Boolean).join(` `)}async function ze(e,t={}){let n=t.rawArgs||process.argv.slice(2),r=t.showUsage||Pe;try{let t=await Be(e);if(t.help.length>0&&n.some(e=>t.help.includes(e)))await r(...await Ae(e,n)),process.exit(0);else if(n.length===1&&t.version.includes(n[0])){let t=typeof e.meta==`function`?await e.meta():await e.meta;if(!t?.version)throw new R(`No version specified`,`E_NO_VERSION`);console.log(t.version)}else await ke(e,{rawArgs:n})}catch(t){t instanceof R?(await r(...await Ae(e,n)),console.error(t.message)):console.error(t,`
|
|
5
|
+
`),process.exit(1)}}async function Be(e){let t=await L(e.args||{}),n=/* @__PURE__ */ new Set,r=/* @__PURE__ */ new Set;for(let[e,i]of Object.entries(t)){n.add(e);for(let e of I(i.alias))r.add(e)}return{help:Ve(`help`,`h`,n,r),version:Ve(`version`,`v`,n,r)}}function Ve(e,t,n,r){return n.has(e)||r.has(e)?[]:n.has(t)||r.has(t)?[`--${e}`]:[`--${e}`,`-${t}`]}var He=`0.0.24`,Ue=`Commands to develop, bundle, and package Incarnative.js apps.`;function U(e,t,n){let r=typeof e==`object`&&e?e:{},i=b.relative(n,t).split(b.sep).join(`/`);return{...r,root:i===``?`.`:i}}function We(e){return e&&e.constructor&&typeof e.constructor.isBuffer==`function`&&e.constructor.isBuffer(e)}function Ge(e){return e}function Ke(e,t){t||={};let n=t.delimiter||`.`,r=t.maxDepth,i=t.transformKey||Ge,a={};function o(e,s,c){c||=1,Object.keys(e).forEach(function(l){let u=e[l],d=t.safe&&Array.isArray(u),f=Object.prototype.toString.call(u),p=We(u),m=f===`[object Object]`||f===`[object Array]`,h=s?s+n+i(l):i(l);if(!d&&!p&&m&&Object.keys(u).length&&(!t.maxDepth||c<r))return o(u,h,c+1);a[h]=u})}return o(e),a}function qe(e,t){t||={};let n=t.delimiter||`.`,r=t.overwrite||!1,i=t.transformKey||Ge,a={};if(We(e)||Object.prototype.toString.call(e)!==`[object Object]`)return e;function o(e){let n=Number(e);return isNaN(n)||e.indexOf(`.`)!==-1||t.object?e:n}function s(e,t,r){return Object.keys(r).reduce(function(t,i){return t[e+n+i]=r[i],t},t)}function c(e){let t=Object.prototype.toString.call(e),n=t===`[object Array]`,r=t===`[object Object]`;if(!e)return!0;if(n)return!e.length;if(r)return!Object.keys(e).length}return e=Object.keys(e).reduce(function(n,r){let i=Object.prototype.toString.call(e[r]);return i!==`[object Object]`&&i!==`[object Array]`||c(e[r])?(n[r]=e[r],n):s(r,n,Ke(e[r],t))},{}),Object.keys(e).forEach(function(s){let c=s.split(n).map(i),l=o(c.shift()),u=o(c[0]),d=a;for(;u!==void 0;){if(l===`__proto__`)return;let e=Object.prototype.toString.call(d[l]),n=e===`[object Object]`||e===`[object Array]`;if(!r&&!n&&d[l]!==void 0)return;(r&&!n||!r&&d[l]==null)&&(d[l]=typeof u==`number`&&!t.object?[]:{}),d=d[l],c.length>0&&(l=o(c.shift()),u=o(c[0]))}d[l]=qe(e[s],t)}),a}const Je=/"(?:_|\\u0{2}5[Ff]){2}(?:p|\\u0{2}70)(?:r|\\u0{2}72)(?:o|\\u0{2}6[Ff])(?:t|\\u0{2}74)(?:o|\\u0{2}6[Ff])(?:_|\\u0{2}5[Ff]){2}"\s*:/,Ye=/"(?:c|\\u0063)(?:o|\\u006[Ff])(?:n|\\u006[Ee])(?:s|\\u0073)(?:t|\\u0074)(?:r|\\u0072)(?:u|\\u0075)(?:c|\\u0063)(?:t|\\u0074)(?:o|\\u006[Ff])(?:r|\\u0072)"\s*:/,Xe=/^\s*["[{]|^\s*-?\d{1,16}(\.\d{1,17})?([Ee][+-]?\d+)?\s*$/;function Ze(e,t){if(e===`__proto__`||e===`constructor`&&t&&typeof t==`object`&&`prototype`in t)Qe(e);else return t}function Qe(e){console.warn(`[destr] Dropping "${e}" key to prevent prototype pollution.`)}function $e(e,t={}){if(typeof e!=`string`)return e;if(e[0]===`"`&&e[e.length-1]===`"`&&e.indexOf(`\\`)===-1)return e.slice(1,-1);let n=e.trim();if(n.length<=9)switch(n.toLowerCase()){case`true`:return!0;case`false`:return!1;case`undefined`:return;case`null`:return null;case`nan`:return NaN;case`infinity`:return 1/0;case`-infinity`:return-1/0}if(!Xe.test(e)){if(t.strict)throw SyntaxError(`[destr] Invalid JSON`);return e}try{if(Je.test(e)||Ye.test(e)){if(t.strict)throw Error(`[destr] Possible prototype pollution`);return JSON.parse(e,Ze)}return JSON.parse(e)}catch(n){if(t.strict)throw n;return e}}function et(e){if(typeof e!=`object`||!e)return!1;let t=Object.getPrototypeOf(e);return t!==null&&t!==Object.prototype&&Object.getPrototypeOf(t)!==null||Symbol.iterator in e?!1:Symbol.toStringTag in e?Object.prototype.toString.call(e)===`[object Module]`:!0}function tt(e,t,n=`.`,r){if(!et(t))return tt(e,{},n,r);let i={...t};for(let t of Object.keys(e)){if(t===`__proto__`||t===`constructor`)continue;let a=e[t];a!=null&&(r&&r(i,t,a,n)||(i[t]=Array.isArray(a)&&Array.isArray(i[t])?[...a,...i[t]]:et(a)&&et(i[t])?tt(a,i[t],(n?`${n}.`:``)+t.toString(),r):a))}return i}function nt(e){return(...t)=>t.reduce((t,n)=>tt(t,n,``,e),{})}const W=nt(),rt=/^\s*([^\s=]+)\s*=\s*(.*)?\s*$/,it=/\n|\r|\r\n/,at={name:`.conf`,dir:process.cwd(),flat:!1};function ot(e){return typeof e==`string`&&(e={name:e}),{...at,...e}}function st(e,t={}){let n={},r=e.split(it);for(let e of r){let t=e.match(rt);if(!t)continue;let r=t[1];if(!r||r===`__proto__`||r===`constructor`)continue;let i=$e((t[2]||``).trim());if(r.endsWith(`[]`)){let e=r.slice(0,Math.max(0,r.length-2));n[e]=(n[e]||[]).concat(i)}else n[r]=i}return t.flat?n:qe(n,{overwrite:!0})}function ct(e,t){return m(e)?st(g(e,`utf8`),t):{}}function G(e){return e=ot(e),ct(x(e.dir,e.name),e)}function lt(){return process.env.XDG_CONFIG_HOME||x(ne(),`.config`)}function ut(e){return e=ot(e),e.dir=lt(),G(e)}async function dt(e){let t=e.env??process.env,n=await ft({cwd:e.cwd,fileName:e.fileName??`.env`,env:t,interpolate:e.interpolate??!0,expandFileReferences:e.expandFileReferences??!1,parse:e.parse}),r=bt(t);for(let e in n)e.startsWith(`_`)||(t[e]===void 0||r.has(e))&&(t[e]=n[e]);return n}async function ft(e){let n=Object.create(null),r=t(e.cwd||`.`),i=e.fileName||`.env`,a=typeof i==`string`?[i]:i,o=bt(e.env||{});Object.assign(n,e.env);for(let i of a){let a=t(r,i);if(!v(a,{throwIfNoEntry:!1})?.isFile())continue;let s=await mt(a,e.parse);for(let e in s)e in n&&!o.has(e)||(n[e]=s[e],o.add(e))}if(e.expandFileReferences){for(let e in n)if(e.endsWith(`_FILE`)){let t=e.slice(0,-5);if(n[t]===void 0){let r=n[e];r&&v(r,{throwIfNoEntry:!1})?.isFile()&&(n[t]=g(r,`utf8`).trim(),o.add(t))}}}return e.interpolate&&ht(n),n}let pt=S.parseEnv;async function mt(e,t){let n=g(e,`utf8`);if(t)return t(n);if(!pt)try{let e=await import(`dotenv`);pt=t=>e.parse(t)}catch{throw Error("Failed to parse .env file: `node:util.parseEnv` is not available and `dotenv` package is not installed. Please upgrade your runtime, install `dotenv` as a dependency or provide a custom `parse` option.")}return pt(n)}function ht(e,t={},n=e=>e){function r(n){return t[n]===void 0?e[n]:t[n]}function i(e,t=[]){if(typeof e!=`string`)return e;let a=``,o=0;for(;o<e.length;){let n=e[o];if(n===`\\`&&e[o+1]===`$`){a+=`$`,o+=2;continue}let s=n===`$`?vt(e,o):void 0;if(!s){a+=n,o++;continue}if(t.includes(s.key)){if(s.defaultValue!==void 0){a+=i(s.defaultValue,t),o=s.end;continue}return console.warn(`Please avoid recursive environment variables ( loop: ${t.join(` > `)} > ${s.key} )`),``}let c=i(r(s.key),[...t,s.key]);s.defaultValue!==void 0&&(c===void 0||s.operator===`:-`&&c===``)&&(c=i(s.defaultValue,t)),a+=c===void 0?e.slice(o,s.end):c,o=s.end}return n(a)}for(let t in e)e[t]=i(r(t))}const gt=/\w+/y,_t=/[\w:]+/y;function vt(e,t){let n=t+1,r=e[n]===`{`;r&&n++;let i=r?_t:gt;i.lastIndex=n;let a=i.exec(e);if(!a)return;let o=a[0];if(n=i.lastIndex,!r)return{key:o,end:n};if(e[n]===`}`)return{key:o,end:n+1};if(e[n]===`-`){let t=`-`;o.endsWith(`:`)&&(o=o.slice(0,-1),t=`:-`);let r=o?yt(e,n+1):void 0;return r?{key:o,operator:t,defaultValue:r.value,end:r.end}:void 0}return{key:o,end:n}}function yt(e,t){let n=``,r=1;for(let i=t;i<e.length;i++){let t=e[i];if(t===`\\`&&i+1<e.length){let r=e[i+1];n+=r===`{`||r===`}`?r:t+r,i++}else if(t===`$`&&e[i+1]===`{`)r++,n+="${",i++;else{if(t===`{`&&r++,t===`}`&&(r--,r===0))return{value:n,end:i+1};n+=t}}}function bt(e){let t=globalThis.__c12_dotenv_vars__||=/* @__PURE__ */ new Map;return t.has(e)||t.set(e,/* @__PURE__ */ new Set),t.get(e)}const xt=e=>e?.replace(/\\/g,`/`);let St=0;const Ct={".json":()=>JSON.parse,".yaml":()=>import(`./chunks/yaml-DtBxpt6z.js`).then(e=>e.parseYAML),".yml":()=>import(`./chunks/yaml-DtBxpt6z.js`).then(e=>e.parseYAML),".jsonc":()=>import(`./chunks/jsonc-DJWoCi14.js`).then(e=>e.n).then(e=>t=>e.parseJSONC(t,{allowTrailingComma:!0})),".json5":()=>import(`./chunks/json5-BcF68iGq.js`).then(e=>e.parseJSON5),".toml":()=>import(`./chunks/toml-n3nLqi2g.js`).then(e=>e.parseTOML)},wt=Object.freeze([`.js`,`.ts`,`.mjs`,`.cjs`,`.mts`,`.cts`,`.json`,`.jsonc`,`.json5`,`.yaml`,`.yml`,`.toml`]);async function Tt(e){e.cwd=t(process.cwd(),e.cwd||`.`),e.name=e.name||`config`,e.envName=e.envName??process.env.NODE_ENV,e.configFile=e.configFile??(e.name===`config`?`config`:`${e.name}.config`),e.rcFile=e.rcFile??`.${e.name}rc`,e.extend!==!1&&(e.extend={extendKey:`extends`,...e.extend});let n=e.merger||W,r={config:{},cwd:e.cwd,configFile:t(e.cwd,e.configFile),layers:[],_configFile:void 0},i={overrides:e.overrides,main:void 0,rc:void 0,packageJson:void 0,defaultConfig:e.defaultConfig};e.dotenv&&await dt({cwd:e.cwd,...e.dotenv===!0?{}:e.dotenv});let a=await kt(`.`,e);if(a.configFile&&(i.main=a.config,r.configFile=a.configFile,r._configFile=a._configFile),a.meta&&(r.meta=a.meta),e.rcFile){let t=[];if(t.push(G({name:e.rcFile,dir:e.cwd})),e.globalRc){let{findWorkspaceDir:n}=await import(`./chunks/dist-BTWvruNB.js`),r=await n(e.cwd).catch(()=>{});r&&t.push(G({name:e.rcFile,dir:r})),t.push(ut({name:e.rcFile})),t.push(G({name:e.rcFile,dir:ne()}))}i.rc=n({},...t)}if(e.packageJson){let t=(Array.isArray(e.packageJson)?e.packageJson:[typeof e.packageJson==`string`?e.packageJson:e.name]).filter(e=>e&&typeof e==`string`),{readPackageJSON:r}=await import(`./chunks/dist-BTWvruNB.js`),a=await r(e.cwd).catch(()=>{});i.packageJson=n({},...t.map(e=>a?.[e]))}let o={};for(let e in i){let t=i[e];o[e]=await(typeof t==`function`?t({configs:o,rawConfigs:i}):t)}if(Array.isArray(o.main)?r.config=o.main:(r.config=n(o.overrides,o.main,o.rc,o.packageJson,o.defaultConfig),e.extend&&(await Et(r.config,e),r.layers=r.config._layers,delete r.config._layers,r.config=n(r.config,...r.layers.map(e=>e.config)))),r.layers=[...[o.overrides&&{config:o.overrides,configFile:void 0,cwd:void 0},{config:o.main,configFile:e.configFile,cwd:e.cwd},o.rc&&{config:o.rc,configFile:e.rcFile},o.packageJson&&{config:o.packageJson,configFile:`package.json`}].filter(e=>e&&e.config),...r.layers],e.defaults&&(r.config=n(r.config,e.defaults)),e.omit$Keys)for(let e in r.config)e.startsWith(`$`)&&delete r.config[e];if(e.configFileRequired&&!r._configFile)throw Error(`Required config (${r.configFile}) cannot be resolved.`);return e.schema!=null&&(r.config=await At(r.config,e.schema)),r}async function Et(e,t){if(e._layers=e._layers||[],!t.extend)return;let n=t.extend.extendKey;typeof n==`string`&&(n=[n]);let r=[];for(let t of n)r.push(...(Array.isArray(e[t])?e[t]:[e[t]]).filter(Boolean)),delete e[t];for(let n of r){let r=n,i={};if(n.source&&(i=n.options||{},n=n.source),Array.isArray(n)&&(i=n[1]||{},n=n[0]),typeof n!=`string`){console.warn(`Cannot extend config from \`${JSON.stringify(r)}\` in ${t.cwd}`);continue}let a=await kt(n,t,i);a.config?(await Et(a.config,{...t,cwd:a.cwd}),e._layers.push(a),a.config._layers&&(e._layers.push(...a.config._layers),delete a.config._layers)):console.warn(`Cannot extend config from \`${n}\` in ${t.cwd}`)}}const Dt=[`gh:`,`github:`,`gitlab:`,`bitbucket:`,`https://`,`http://`],Ot=/^(@[\da-z~-][\d._a-z~-]*\/)?[\da-z~-][\d._a-z~-]*($|\/.*)/;async function kt(e,o,s={}){if(o.resolve){let t=await o.resolve(e,o);if(t)return t}let c=o.merger||W,l=Object.keys(s.giget?.providers||{}).map(e=>`${e}:`),u=l.length>0?[.../* @__PURE__ */ new Set([...l,...Dt])]:Dt;if(o.giget!==!1&&u.some(t=>e.startsWith(t))){let{downloadTemplate:n}=await import(`giget`).catch(t=>{throw Error(`Extending config from \`${e}\` requires \`giget\` peer dependency to be installed.\n\nInstall it with: \`npx nypm i giget\``,{cause:t})}),{digest:c}=await import(`./chunks/ohash-DUMW2FP0.js`).then(e=>e.dist_exports),l=e.replace(/\W+/g,`_`).split(`_`).splice(0,3).join(`_`)+`_`+c(e).slice(0,10).replace(/[-_]/g,``),u,d=t(o.cwd,`node_modules`),f=a(o.cwd);u=r(f)===`.c12`?i(f,l):m(d)?i(d,`.c12`,l):process.env.XDG_CACHE_HOME?t(process.env.XDG_CACHE_HOME,`c12`,l):t(ne(),`.cache/c12`,l);let p=s.install?W(s.install===!0?{}:s.install,{ignoreWorkspace:!0}):!1;m(u)&&!p&&await A(u,{recursive:!0}),e=(await n(e,{dir:u,install:p,force:!!p,auth:s.auth,...o.giget,...s.giget})).dir}Ot.test(e)&&(e=jt(e,o)||e);let d=n(e),f=Mt(t(o.cwd,e))??(!d||d===r(e)),p=t(o.cwd,f?e:a(e));f&&(e=o.configFile);let h={config:void 0,configFile:void 0,cwd:p,source:e,sourceOptions:s};if(h.configFile=jt(t(p,e),o)||jt(t(p,`.config`,e.replace(/\.config$/,``)),o)||jt(t(p,`.config`,e),o)||e,!m(h.configFile))return h;h._configFile=h.configFile;let g=n(h.configFile)||``;if(g in Ct)h.config=(await Ct[g]())(await O(h.configFile,`utf8`));else{let e=o.resolveModule||(e=>e.default||e);if(o.import)h.config=e(await o.import(h.configFile));else{let t=M(h.configFile);t.search=`_${++St}`,h.config=await import(t.href).then(e,async t=>{let{createJiti:n}=await import(`jiti`).catch(()=>{throw Error(`Failed to load config file \`${h.configFile}\`: ${t?.message}. Hint install \`jiti\` for compatibility.`,{cause:t})}),r=n(i(o.cwd||`.`,o.configFile||`/`),{interopDefault:!0,moduleCache:!1,extensions:[...wt],...o.jitiOptions});return o.import=e=>r.import(e),e(await o.import(h.configFile))})}}typeof h.config==`function`&&(h.config=await h.config(o.context)),h.config&&typeof h.config==`object`&&!Array.isArray(h.config)&&!Object.isExtensible(h.config)&&(h.config={...h.config});let _=(Array.isArray(o.envName)?o.envName:[o.envName]).filter(Boolean).reverse().flatMap(e=>[h.config.$env?.[e],h.config[`$`+e]]).filter(e=>e&&Object.keys(e).length>0);return _.length>0&&(h.config=(o.envMerger||c)({},..._,h.config)),h.meta=W(h.sourceOptions.meta,h.config.$meta),delete h.config.$meta,h.sourceOptions.overrides&&(h.config=c(h.sourceOptions.overrides,h.config)),h.configFile=xt(h.configFile),h.source=xt(h.source),h}async function At(e,t){if(typeof t?.[`~standard`]?.validate!=`function`)throw TypeError("Invalid `schema` option: expected a Standard Schema (https://standardschema.dev).");let n=await t[`~standard`].validate(e);if(n.issues){let e=n.issues.map(e=>{let t=e.path?.map(e=>String(typeof e==`object`?e.key:e)).join(`.`);return` - ${t?`${t}: `:``}${e.message}`});throw Error(`Config validation failed (${t[`~standard`].vendor}):\n${e.join(`
|
|
6
|
+
`)}`,{cause:n.issues})}return n.value}function jt(e,t){let n=s(e,{try:!0,from:M(i(t.cwd||`.`,t.configFile||`/`)),suffixes:[``,`/index`],extensions:wt,cache:!1});return n?o(n):void 0}function Mt(e){try{return v(e).isDirectory()}catch{return null}}var K=class extends Error{code;path;name=`IncaError`;constructor(e,t,n){super(t),this.code=e,this.path=n}};const Nt={name:`inca`,packageJson:`inca`,rcFile:!1,globalRc:!1,giget:!1,extend:!1},Pt=[`.js`,`.ts`,`.mjs`,`.cjs`,`.mts`,`.cts`],Ft=/[/\\:*?"<>|\0]/;function It(e){return e===e.trim()&&e!==``&&e!==`.`&&e!==`..`&&!Ft.test(e)}function Lt(e){if(!(typeof e==`string`&&It(e)))throw new K(`ERR_INCA_PRODUCT_NAME_INVALID`,`${JSON.stringify(e)} can't name a directory. set a "productName" in inca.config.ts with no leading or trailing space, and none of \`/\\:*?"<>|\``)}const Rt=process.platform===`darwin`||process.platform===`win32`;function zt(e,t){let n=e=>Rt?e.toLowerCase():e,r=b.relative(n(e),n(t));return r===``||r!==`..`&&!r.startsWith(`..${b.sep}`)&&!b.isAbsolute(r)}function Bt(e){let t=b.resolve(e),n=t;for(let e;!h(n,{throwIfNoEntry:!1})&&(e=b.dirname(n))!==n;)n=e;return b.join(_.native(n),b.relative(n,t))}function Vt(e,t,n){let r=b.resolve(e,t),i;try{let t=Bt(r);i=[e,b.join(e,`src`),b.join(e,`node_modules`),...n?[n]:[]].some(e=>zt(t,Bt(e)))}catch{i=!0}if(i)throw new K(`ERR_INCA_OUT_DIR_INVALID`,`"outDir" resolves to ${r}, which holds the app's own files. Set it to a directory the build can own, such as "dist"`)}function Ht(e,t,n){let r=b.resolve(e,t??d.outDir);return Vt(e,r,n),r}function Ut(e,t){try{return JSON.parse(e)}catch(e){throw new K(`ERR_INCA_PACKAGE_JSON_INVALID`,`${t} holds malformed JSON: ${e.message}`,t)}}async function Wt(e){let t=f(import.meta.url).cache;for(let n of Pt)delete t[b.join(e,`inca.config`+n)];let{config:n,layers:r}=await Tt({cwd:e,...Nt}),i=r?.find(e=>e.configFile===`package.json`);return{config:n,usedPackageJsonKey:Object.keys(i?.config??{}).length>0}}async function Gt(e){let{config:t}=await Wt(e),n=t.entry?b.resolve(e,t.entry):void 0;return{entry:n,outDir:Ht(e,t.outDir,n),sourcemap:t.sourcemap??d.sourcemap}}function Kt(e){return e.dev?.stackPaths??d.dev.stackPaths}async function qt(e){let t=b.join(e,`package.json`),n;try{n=await O(t,`utf8`)}catch{throw new K(`ERR_INCA_PACKAGE_JSON_NOT_FOUND`,`no package.json found at ${t}`)}let r=Ut(n,t),{config:i,usedPackageJsonKey:a}=await Wt(e),o=i.productName??u(r.name);if(!o)throw new K(`ERR_INCA_PRODUCT_NAME_MISSING`,`${t} needs a "name", or "productName" in inca.config.ts`);Lt(o);let s=i.version??r.version??d.version,c=i.identifier??l(o),f;if(i.icon&&(f=b.resolve(e,i.icon),!m(f)))throw new K(`ERR_INCA_ICON_NOT_FOUND`,`"icon" points to ${f}, which doesn't exist`,f);let p=i.entry?b.resolve(e,i.entry):void 0,h=Ht(e,i.outDir,p);return{productName:o,identifier:c,identifierIsDefault:i.identifier===void 0,version:s,icon:f,window:i.window,dev:{stackPaths:Kt(i)},entry:p,outDir:h,sourcemap:i.sourcemap??d.sourcemap,usedPackageJsonKey:a}}function Jt(e,{dev:t=!1}={}){return{name:e.productName,identifier:e.identifier,window:e.window,...t&&{dev:{stackPaths:e.dev.stackPaths}}}}async function Yt(e,{dev:t=!1}={}){let{config:n}=await Wt(e),r=b.join(e,`package.json`),i=await O(r,`utf8`).catch(()=>void 0),a=i===void 0?{}:Ut(i,r),o=n.productName??u(a.name);return o&&Lt(o),{name:o,identifier:n.identifier??(o?l(o):void 0),window:n.window,...t&&{dev:{stackPaths:Kt(n)}}}}const Xt=`INCA_HOST_BIN`;function Zt(){let e=process.platform===`darwin`||process.platform===`linux`?process.platform:void 0,t=process.arch===`arm64`||process.arch===`x64`?process.arch:void 0;return e&&t?`@incajs/host-${e}-${t}`:void 0}function Qt(){let e=Zt();if(e)try{return f(import.meta.url).resolve(`${e}/bin/inca-host`)}catch{return}}function q(){let e=process.env[Xt];if(e)return e;let t=Qt();if(t)return t;let n=Zt();throw new K(`ERR_INCA_HOST_BIN_UNRESOLVED`,`no host binary found. ${n?`no ${n} package is installed for it`:`this platform (${process.platform}/${process.arch}) has no published package`}, and ${Xt} isn't set to one`)}function J(e){if(!v(e,{throwIfNoEntry:!1})?.isFile())throw new K(`ERR_INCA_HOST_BIN_NOT_FOUND`,`no host binary at ${e}. check that it was built`)}var $t=class extends Error{code;hostStack;constructor(e,t,n=null){super(e),this.code=t,this.hostStack=n,this.name=`HostError`}};function en(e){return typeof e==`object`&&!!e&&e.jsonrpc===`2.0`}const tn=e=>{process.stderr.write(e.endsWith(`
|
|
7
|
+
`)?e:`${e}\n`)};var nn=class{#e;#t;#n=1;#r=/* @__PURE__ */ new Map;#i=!1;constructor(e){this.#e=e}async start(){let e=this.#e.hostBin??q();J(e);let t=re(e,[`--dev`,this.#e.entryFile],{stdio:[`pipe`,`pipe`,`pipe`],env:this.#e.env});this.#t=t;let n=this.#e.onStderr??tn;t.stderr.setEncoding(`utf8`),t.stderr.on(`data`,e=>n(e)),t.stdin.on(`error`,e=>{e.code!==`EPIPE`&&n(`host stdin: ${e.message}\n`)}),ae.createInterface({input:t.stdout}).on(`line`,e=>{this.#a(e,n)}),t.on(`exit`,(e,t)=>{let n=/* @__PURE__ */ Error(`the host exited (code=${String(e)}, signal=${String(t)}) before answering`);for(let{reject:e}of this.#r.values())e(n);this.#r.clear(),this.#i||this.#e.onExit?.(e,t)});let r=!1;t.on(`error`,e=>{r&&n(`host: ${e.message}\n`)}),await N(t,`spawn`),r=!0}#a(e,t){let n;try{n=JSON.parse(e)}catch{t(`[stray stdout] ${e}`);return}if(!en(n)){t(`[stray stdout] ${e}`);return}if(`method`in n){this.#o(n.method,n.params,t);return}if(n.id===null){if(!(`error`in n))return;let{code:e,message:r,data:i}=n.error;e===-32e3?this.#e.onAppError?.({message:r,stack:i?.stack??null}):t(`[host error ${String(e)}] ${r}\n`);return}let r=this.#r.get(n.id);r&&(this.#r.delete(n.id),`error`in n?r.reject(new $t(n.error.message,n.error.code,n.error.data?.stack??null)):r.resolve(n.result))}#o(e,t,n){switch(e){case`ready`:{let{protocol:e}=t;if(e!==0){n(`the host speaks protocol ${String(e)}, this package was built for 0. stopping it`),this.#t&&this.#s(this.#t);return}this.#e.onReady?.();return}case`appError`:this.#e.onAppError?.(t);return;default:{let r=this.#e.integrations?.[e];r?r(t):n(`[unhandled notification] ${e}`)}}}async#s(e){let t=N(e,`exit`);e.kill(),await t}async call(e,t,n){let r=this.#t;if(!r)throw Error(`HostClient.start() has not been called`);let i=this.#n++,a=JSON.stringify({jsonrpc:`2.0`,id:i,method:e,params:t});return new Promise((t,o)=>{let s=n===void 0?void 0:setTimeout(()=>{this.#r.delete(i),o(/* @__PURE__ */ Error(`${e} timed out after ${String(n)}ms`))},n);this.#r.set(i,{resolve:e=>{clearTimeout(s),t(e)},reject:e=>{clearTimeout(s),o(e)}}),r.stdin.write(`${a}\n`,e=>{e&&(clearTimeout(s),this.#r.delete(i),o(e))})})}notify(e,t){let n=this.#t;if(!n)throw Error(`HostClient.start() has not been called`);n.stdin.write(`${JSON.stringify({jsonrpc:`2.0`,method:e,params:t})}\n`)}async stop(e=2e3){let t=this.#t;if(!t||t.exitCode!==null||t.signalCode!==null)return;this.#i=!0;let n=N(t,`exit`);this.call(`shutdown`).catch(()=>{}),await Promise.race([n.then(()=>`exited`),P(e,void 0,{ref:!1}).then(()=>`timeout`)])===`timeout`&&(t.kill(),await n)}};const rn=new Intl.DateTimeFormat(void 0,{hour:`numeric`,minute:`numeric`,second:`numeric`}),Y={timestamp:!0};function an(e,t,n){let r=w([`bold`,n],`[inca]`,{stream:e});return t.timestamp?`${w(`dim`,rn.format(/* @__PURE__ */ new Date),{stream:e})} ${r}`:r}function X(e,t,n={}){e.write(`${an(e,n,`cyan`)} ${t}\n`)}function on(e,t,n={}){e.write(`${an(e,n,`yellow`)} ${t}\n`)}function sn(e){let t=e.code;return typeof t==`string`?t:null}function cn(e){return/\bERR_INCA_[A-Z0-9_]+/.exec(e)?.[0]??null}function ln(e){let t=e.stack;if(!t)return null;for(let n of[`${e.name}: ${e.message}`,e.message])if(t.startsWith(n))return t.slice(n.length).replace(/^\r?\n/,``)||null;return t}function un(e){let t=/^(?:\w*Error: )?(ERR_INCA_[A-Z0-9_]+): /.exec(e);return t?{message:e.slice(t[0].length),stack:null,code:t[1]}:{message:e.replace(/^\w*Error: /,``),stack:null,code:null}}function Z(e){return e instanceof $t?{message:e.message,stack:e.hostStack,code:sn(e)}:e instanceof Error?{message:e.message,stack:ln(e),code:sn(e)??cn(e.message)}:{message:String(e),stack:null,code:null}}function dn(e,t){return e.split(`
|
|
8
8
|
`).map(e=>/^\s*at\b/.test(e)?w(`dim`,e,{stream:t}):e).join(`
|
|
9
|
-
`)}function
|
|
9
|
+
`)}function Q(e,t,n,r={}){n.stack&&e.write(`${dn(n.stack,e)}\n`);let i=n.code?` (${w(`bold`,n.code,{stream:e})})`:``;e.write(`${an(e,r,`red`)} ${t}${i}: ${n.message}\n`)}var fn=/* @__PURE__ */ e({IncaError:()=>K,bundlerFault:()=>un,withAppRoot:()=>U});function pn(e,t,n){return{outDir:e,entryFile:b.join(e,t.entryFile),files:t.files,changed:n}}function mn(e,t){return{name:`inca:capture-output`,writeBundle(n,r){let i=Object.keys(r),a=Object.values(r).find(e=>e.type===`chunk`&&e.isEntry);if(!a){let t=`ERR_INCA_BUILD_NO_ENTRY_CHUNK`;throw new e.IncaError(t,`${t}: build produced no entry chunk`)}t({entryFile:a.fileName,files:i})}}}const hn=`inca.json`;function gn(e){let t=JSON.stringify(e,void 0,2);return{name:`inca:emit-config`,generateBundle(){t!==void 0&&this.emitFile({type:`asset`,fileName:hn,source:`${t}\n`})}}}function _n(e,t,n=!1){let r=/* @__PURE__ */ new WeakSet,i=/* @__PURE__ */ new Set,a={hasWarned:!1,info(t){n||e.write(`${t}\n`)},warn(e){a.hasWarned=!0,t.write(`${e}\n`)},warnOnce(e){i.has(e)||(i.add(e),a.warn(e))},error(e,n){a.hasWarned=!0,n?.error&&r.add(n.error),e.includes(`Build failed with `)||e.includes(`Pre-transform error`)||t.write(`${e.replace(/\n\s+at .*/g,``)}\n`)},clearScreen(){},hasErrorLogged(e){return r.has(e)}};return a}function vn(e,t){let n=`ERR_INCA_PEER_NOT_FOUND`;return new e.IncaError(n,`${n}: ${t} can't be resolved. add it to the app's dependencies`)}async function yn(e,t){let n=f(M(`${e}/`)).resolve.paths(t)??[];for(let e of n)try{return await O(b.join(e,t,`package.json`),`utf8`)}catch(e){let{code:t}=e;if(t!==`ENOENT`&&t!==`ENOTDIR`)throw e}}async function bn(e,t,[n,r]){let i=await yn(t,n);if(i===void 0)throw vn(e,n);return JSON.parse(i).incajs?.frontends?.[r]?.peers??[]}function xn(e,t){let n=process.cwd(),r;return{name:`inca:require-peers`,enforce:`pre`,configResolved(e){n=e.root},async resolveId(i,a,o){if(r??=await bn(e,n,t),!r.includes(i))return null;let s=await this.resolve(i,a,{...o,skipSelf:!0});if(s&&!s.id.startsWith(`__vite-optional-peer-dep:`))return null;throw vn(e,i)}}}const Sn=/\.(?:css|pcss|postcss|sass|scss|less|styl|stylus)(?:\?|$)/,Cn=[{code:`ERR_INCA_UNSUPPORTED_STYLE`,name:`a <style> block`,matches:e=>e.includes(`vue&type=style`),hint:`the renderer applies no stylesheet. use a :style binding instead`},{code:`ERR_INCA_UNSUPPORTED_STYLESHEET`,name:`a stylesheet import`,matches:e=>Sn.test(e),hint:`the renderer applies no stylesheet. use a :style binding instead`}];function wn(e,t=Cn){return{name:`inca:reject-unsupported`,enforce:`pre`,transform(n,r){let i=t.find(e=>e.matches(r));if(!i)return null;let a=b.relative(process.cwd(),r.split(`?`)[0]??r);throw new e.IncaError(i.code,`${i.code}: ${a} uses ${i.name}, unsupported for now: ${i.hint}`)}}}function Tn({core:e,frontend:t,frontendOptions:n,entry:r,root:i=b.dirname(r),envDir:a,publicDir:o,outDir:s,mode:c,sourcemap:l=!1,watch:u,onOutput:d,stdout:f,stderr:p,quiet:m,runtimeConfig:h}){let g=c===`development`||l;return{configFile:!1,root:i,envDir:a,publicDir:o,mode:c,clearScreen:!1,logLevel:m?`silent`:`info`,customLogger:_n(f,p),define:{"process.env.NODE_ENV":JSON.stringify(c)},plugins:[ue({template:{compilerOptions:{...n,hoistStatic:!1}}}),xn(e,t),wn(e),gn(h),mn(e,d)],build:{lib:{entry:r,formats:[`es`],fileName:()=>`bundle.js`},outDir:s,emptyOutDir:c===`production`,minify:c===`production`,sourcemap:g,watch:u?{buildDelay:30}:void 0,rolldownOptions:{output:{chunkFileNames:`chunks/[name]-[hash].js`,assetFileNames:`assets/[name]-[hash][extname]`,sourcemapExcludeSources:g}}}}}async function En(e,t,n,{entry:r,root:i,envDir:a,publicDir:o,outDir:s,sourcemap:c,runtimeConfig:l,stdout:u=process.stdout,stderr:d=process.stderr,quiet:f=!1}){let p;if(await se(Tn({core:e,frontend:t,frontendOptions:n,entry:r,root:i,envDir:a,publicDir:o,outDir:s,runtimeConfig:l,mode:`production`,sourcemap:c,watch:!1,stdout:u,stderr:d,quiet:f,onOutput:e=>{p=pn(s,e)}})),!p)throw new e.IncaError(`ERR_INCA_BUILD_NO_OUTPUT`,`build produced no output`);return p}function Dn(e){var t=[...arguments].slice(1),n=Array.from(typeof e==`string`?[e]:e);n[n.length-1]=n[n.length-1].replace(/\r?\n([\t ]*)$/,``);var r=n.reduce(function(e,t){var n=t.match(/\n([\t ]+|(?!\s).)/g);return n?e.concat(n.map(function(e){return e.match(/[\t ]/g)?.length??0})):e},[]);if(r.length){var i=RegExp(`
|
|
10
10
|
[ ]{${Math.min.apply(Math,r)}}`,`g`);n=n.map(function(e){return e.replace(i,`
|
|
11
11
|
`)})}n[0]=n[0].replace(/^\r?\n/,``);var a=n[0];return t.forEach(function(e,t){var r=a.match(/(?:^|\n)( *)$/),i=r?r[1]:``,o=e;typeof e==`string`&&e.includes(`
|
|
12
12
|
`)&&(o=String(e).split(`
|
|
13
13
|
`).map(function(e,t){return t===0?e:`${i}${e}`}).join(`
|
|
14
|
-
`)),a+=o+n[t+1]}),a}function
|
|
15
|
-
`);return{...e.bundlerFault(t.message),stack:r||null}}function
|
|
14
|
+
`)),a+=o+n[t+1]}),a}function On(e,t){let n=ce(t,[],!1),r=[t.stack,n].filter(e=>e).join(`
|
|
15
|
+
`);return{...e.bundlerFault(t.message),stack:r||null}}function $(e){return b.join(e,`node_modules/.inca/hmr`)}function kn(){let e=b.dirname(te(import.meta.url));for(;!m(b.join(e,`package.json`));){let t=b.dirname(e);if(t===e)throw Error(`could not locate @incajs/cli's own package.json`);e=t}return b.join(e,`dist/vite-runtime.js`)}function An(e,t){let n=b.relative(e,t).split(b.sep).join(`/`);return n.startsWith(`.`)?n:`./${n}`}const jn=/^[A-Za-z_$][\w$]*$/;function Mn(e){let t={};for(let[n,r]of Object.entries(e??{}))if(jn.test(n))try{t[n]=JSON.parse(typeof r==`string`?r:JSON.stringify(r))}catch{}return t}async function Nn(e,t,n,r){let i=$(e),a=b.join(i,`entry.js`),o=An(i,r??kn()),s=t.split(b.sep).join(`/`);return await j(a,Dn`
|
|
16
16
|
import { start } from ${JSON.stringify(o)};
|
|
17
17
|
await start(${JSON.stringify(s)}, ${JSON.stringify(n)});
|
|
18
|
-
`),a}function
|
|
18
|
+
`),a}function Pn(e){if(e.type===`error`)return e.err;if(e.type===`custom`&&e.event===`vite:invoke`)return e.data?.data?.error}function Fn(e){if(e.type!==`custom`||e.event!==`vite:invoke`)return!1;let t=e.data;return t.name===`fetchModule`&&!t.data?.error}function In(e,t,n,r,i){let a=/* @__PURE__ */ new Map,o={send:s};function s(a){if(a.type===`full-reload`){let e=i.current;i.current=void 0,t(e);return}let o=Pn(a);o?(n(o),i.current=void 0):Fn(a)&&i.current&&(r({file:i.current.file,took:Date.now()-i.current.at}),i.current=void 0),e(a)}return{channel:{send:s,on(e,t){let n=a.get(e);n||a.set(e,n=/* @__PURE__ */ new Set),n.add(t)},off(e,t){a.get(e)?.delete(t)}},dispatch(e){let t=e;if(t?.type===`custom`&&typeof t.event==`string`)for(let e of a.get(t.event)??[])e(t.data,o)}}}function Ln(){let e=`\0inca:vite-client-shim`;return{name:`inca:shim-vite-client`,enforce:`pre`,resolveId(t){return t===`/@vite/client`||t.endsWith(`/dist/client/client.mjs`)?e:null},load(t){return t===e?`export function createHotContext() { return undefined; }`:null}}}function Rn(e){return{name:`inca:file-changed`,hotUpdate(t){e.current={file:t.file,at:Date.now()},this.environment.hot.send({type:`custom`,event:`file-changed`,data:{file:t.file}})}}}async function zn(e,t,n,{entry:r,root:i=b.dirname(r),envDir:a,publicDir:o,cwd:s,runtimeConfig:c,runtimePath:l,stdout:u=process.stdout,stderr:d=process.stderr,quiet:f=!1,notify:p,reload:m,onError:h,onUpdate:g=()=>{}}){await D($(s),{recursive:!0});let _=e.withAppRoot(c,s,$(s));await j(b.join($(s),hn),`${JSON.stringify(_,void 0,2)}\n`);let v={current:void 0},{channel:y,dispatch:x}=In(p,m,t=>h(On(e,t)),g,v),S=await le({configFile:!1,root:i,envDir:a,publicDir:o,mode:`development`,clearScreen:!1,logLevel:f?`silent`:`info`,customLogger:_n(u,d,f),define:{"process.env.NODE_ENV":JSON.stringify(`development`)},server:{middlewareMode:!0,ws:!1,watch:{awaitWriteFinish:{stabilityThreshold:20,pollInterval:10}}},optimizeDeps:{noDiscovery:!0},environments:{client:{consumer:`client`,dev:{moduleRunnerTransform:!0,createEnvironment:(e,t)=>new oe(e,t,{hot:!0,transport:y})}}},plugins:[ue({template:{compilerOptions:{...n,hoistStatic:!1}}}),xn(e,t),wn(e),Ln(),Rn(v)]}),C;try{C=await Nn(s,r,Mn(S.environments.client.config.define),l)}catch(e){throw await S.close(),e}return{entryFile:C,dispatch:x,close:()=>S.close()}}async function Bn(e,t,n,{onBuild:r,onError:i,stdout:a=process.stdout,stderr:o=process.stderr,quiet:s=!1,...c}){let{outDir:l}=c,u,d=await se(Tn({core:e,frontend:t,frontendOptions:n,...c,watch:!0,stdout:a,stderr:o,quiet:s,onOutput:e=>{r(pn(l,e,u)),u=void 0}}));return d.on(`change`,e=>{u??={file:e,at:Date.now()}}),d.on(`event`,t=>{if(t.code!==`ERROR`)return;u=void 0;let{errors:n}=t.error;i(e.bundlerFault(n?.[0]?.message??t.error.message))}),{close:()=>d.close()}}function Vn(e,t,n){return{watch:r=>Bn(e,t,n,r),build:r=>En(e,t,n,r),hmr:r=>zn(e,t,n,r)}}const Hn=Vn(fn,[`incajs`,`vue`],{runtimeModuleName:`incajs/vue/runtime`}),Un=[`main.mts`,`main.ts`,`main.js`];function Wn(e){return b.join(e,`node_modules/.inca/entry.mts`)}function Gn(e,t){return t===Wn(e)?b.join(e,`src`):b.dirname(t)}function Kn(e){return Un.map(t=>b.join(e,`src`,t)).find(e=>m(e))||(m(b.join(e,`src/App.vue`))?Wn(e):void 0)}async function qn(e){let t=b.join(e,`src/App.vue`),n=Kn(e);if(n===Wn(e))return Jn(t,e);if(n)return n;throw new K(`ERR_INCA_ENTRY_NOT_FOUND`,`no app entry found. check that ${b.join(e,`src/main.ts`)} or ${t} exists`)}async function Jn(e,t){let n=Wn(t);await D(b.dirname(n),{recursive:!0});let r=JSON.stringify(e.split(b.sep).join(`/`));return await j(n,Dn`
|
|
19
19
|
import { createIncaApp } from "incajs/vue";
|
|
20
20
|
import App from ${r};
|
|
21
21
|
createIncaApp(App).mount();
|
|
22
|
-
`),n}async function
|
|
22
|
+
`),n}async function Yn(e={}){let t=e.cwd??process.cwd(),n=e.config??await Gt(t),r=b.resolve(t,n.outDir),i=e.bundler??Hn,a=e.entry??n.entry??await qn(t);Vt(t,r,a);let o=e.runtimeConfig??await Yt(t);return i.build({entry:a,root:Gn(t,a),envDir:t,publicDir:b.join(t,`public`),outDir:r,sourcemap:e.sourcemap??n.sourcemap,runtimeConfig:U(o,t,r),stdout:e.stdout,stderr:e.stderr})}function Xn(e){return b.join(e,`node_modules/.inca/dev.pid`)}function Zn(e){try{return process.kill(e,0),!0}catch(e){return e.code===`EPERM`}}const Qn=de();function $n(e){return new K(`ERR_INCA_DEV_RUNNING`,`inca dev is already running for this app (pid ${String(e)})`)}async function er(e){let t=Xn(e),n=`${String(process.pid)}:${Qn}`,r=`${t}.${de()}`;await D(b.dirname(t),{recursive:!0}),await j(r,n);let i=process.pid;try{for(let e=0;e<5;e++){try{return await E(r,t),tr(t,n)}catch(e){if(e.code!==`EEXIST`)throw e}let e=await O(t,`utf8`).catch(()=>``),a=Number.parseInt(e,10);if(a===process.pid){if(e===n)throw $n(a)}else if(Number.isSafeInteger(a)&&a>0&&Zn(a))throw $n(a);i=Number.isSafeInteger(a)&&a>0?a:i,await A(t,{force:!0})}throw $n(i)}finally{await A(r,{force:!0})}}function tr(e,t){let n=!1;return async()=>{n||(n=!0,await O(e,`utf8`).catch(()=>``)===t&&await A(e,{force:!0}))}}function nr(e){return e.replaceAll(`&`,`&`).replaceAll(`<`,`<`).replaceAll(`>`,`>`)}function rr(e){return typeof e==`boolean`?e?`<true/>`:`<false/>`:`<string>${nr(e)}</string>`}function ir(e){return Dn`
|
|
23
23
|
<?xml version="1.0" encoding="UTF-8"?>
|
|
24
24
|
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
25
25
|
<plist version="1.0">
|
|
26
26
|
<dict>
|
|
27
|
-
${Object.entries(e).map(([e,t])=>`\t<key>${
|
|
27
|
+
${Object.entries(e).map(([e,t])=>`\t<key>${nr(e)}</key>\n\t${rr(t)}`).join(`
|
|
28
28
|
`)}
|
|
29
29
|
</dict>
|
|
30
30
|
</plist>
|
|
31
|
-
`}async function
|
|
32
|
-
`)[0]??``;if(!i.startsWith(r))return;let a=i.slice(r.length),o=a.indexOf(`]: `),s;try{s=JSON.parse(a.slice(0,o+1))}catch{return}if(!Array.isArray(s))return;let[c,...l]=s,u=[c===`name`?`productName`:c,...l].join(`.`),d=
|
|
33
|
-
`)[0]??``}"`)}function sr(e,t){let n;try{n=J(),Y(n)}catch(e){if(e instanceof K&&(e.code===`ERR_INCA_HOST_BIN_UNRESOLVED`||e.code===`ERR_INCA_HOST_BIN_NOT_FOUND`)){an(t,`no host binary found, so the config was not checked`);return}throw e}or(n,e)}async function cr(e={}){let t=e.cwd??process.cwd(),n=e.hostBin??J();Y(n);let r=await Jt(t,{dev:!0}),i=b.join(t,`node_modules/.inca/config`),a=b.join(i,`bundle.js`),o=b.join(i,`inca.json`);await D(i,{recursive:!0}),await j(a,``),await j(o,JSON.stringify(H(r,t,i),void 0,2));let s=ar(n,a,o,r);return(e.stdout??process.stdout).write(s.stdout),(e.stderr??process.stderr).write(s.stderr),s.status??1}const lr=/^(?:inca\.config\.[a-z0-9]+|package\.json)$/,ur=[...zn,`App.vue`];function dr(e,t={}){let n=t.debounceMs??100,r=/* @__PURE__ */ new Set,i,a=!1,o=()=>{},s=new Promise(e=>{o=e}),c=()=>{a||(clearTimeout(i),i=setTimeout(o,n),i.unref())},l=(e,t)=>{let n=e;for(let e;!m(n)&&(e=b.dirname(n))!==n;)n=e;let i=n===e?void 0:b.relative(n,e).split(b.sep)[0],a=y(n);a.on(`change`,(e,n)=>{let r=n===null?null:String(n);(r===null||(i===void 0?t(r):r===i))&&c()}),a.on(`error`,()=>{a.close(),r.delete(a),c()}),r.add(a)},u=()=>{a=!0,clearTimeout(i);for(let e of r)e.close();r.clear()};try{l(e,e=>e===`src`||lr.test(e)),l(b.join(e,`src`),e=>ur.includes(e))}catch(e){throw u(),e}return{edited:s,add(e){if(a)return;let t=b.resolve(e);l(b.dirname(t),e=>e===b.basename(t))},close:u}}function fr(e,t){return new Promise(n=>{let r=()=>n(!1);t.addEventListener(`abort`,r,{once:!0}),e.then(()=>{t.removeEventListener(`abort`,r),n(!0)})})}async function pr(e){let{cwd:t,signal:n,stdout:r,stderr:i,debounceMs:a}=e,o=!1;for(;;){let s=dr(t,{debounceMs:a});try{return await e.attempt(s)}catch(e){let t=e instanceof K?e.path:void 0;if(t)try{s.add(t)}catch(t){throw $(i,`build failed`,Q(e),X),t}if(!n.aborted&&!o&&t&&m(t)){o=!0;continue}if(o=!1,$(i,`build failed`,Q(e),X),n.aborted||(Z(r,`waiting for a change to retry`,X),!await fr(s.edited,n)))return;Z(r,`retrying`,X)}finally{s.close()}}}const mr=[`ERR_INCA_PACKAGE_JSON_NOT_FOUND`,`ERR_INCA_PRODUCT_NAME_MISSING`];async function hr(e,t){try{return await Kt(e)}catch(e){if(!(e instanceof K)||!mr.includes(e.code))throw e;Z(t,`running unnamed. ${e.message}`,X);return}}async function gr(e,t,n,r){if(process.platform===`darwin`&&t)try{return(await tr({appPath:b.join(e,`node_modules/.inca`,`${t.productName}.app`),metadata:t,hostBin:n,link:!0})).executablePath}catch(e){Z(r,`running unbundled. ${Q(e).message}`,X);return}}async function _r(e,t){let n=new Set(t),r;try{r=await k(e,{recursive:!0,withFileTypes:!0})}catch{return}await Promise.all(r.filter(e=>e.isFile()).map(t=>b.relative(e,b.join(t.parentPath,t.name))).filter(e=>!n.has(e)).map(t=>A(b.join(e,t),{force:!0})))}function vr(e){let{NO_COLOR:t,FORCE_COLOR:n}=process.env;if(!(!e.isTTY||t||n))return{...process.env,FORCE_COLOR:`1`}}async function yr(e){let t=e.cwd??process.cwd(),n=await Xn(t),r=()=>{},i=!1,a=new Promise(e=>{r=()=>{i=!0,e()}}),o,s;try{let n=e.hostBin??J();Y(n);let c=e.bundler??Rn,l=e.stdout??process.stdout,u=e.stderr??process.stderr,d=e.experimentalHmr?c.hmr?.bind(c):void 0;if(e.experimentalHmr&&!d)throw new K(`ERR_INCA_HMR_UNSUPPORTED`,`--experimental-hmr was set, but the configured bundler has no HMR support`);let f=await pr({cwd:t,signal:e.signal,stdout:l,stderr:u,async attempt(){let n=await Wt(t),r=b.resolve(t,n.outDir),i=e.entry===void 0&&n.entry===void 0,a=e.entry??n.entry??await Un(t);q(t,r,a);let o=await hr(t,l);return{outDir:r,entry:a,automaticEntry:i,metadata:o,runtimeConfig:o?qt(o,{dev:!0}):await Jt(t,{dev:!0})}}});if(!f)return;let{outDir:p,entry:m,automaticEntry:h,metadata:g,runtimeConfig:_}=f,v=await gr(t,g,n,l)??n,y,x,S=!1,C=!1,ee=!1,T,E=Promise.resolve(),D,O=0,k=!1,A;async function j(){try{return await y?.call(`reload`,void 0,1e4),!0}catch(e){return $(u,`reload failed`,Q(e),X),!1}}function te(e){if(!e)return;let n=w(`dim`,b.relative(t,e.file),{stream:l}),r=Date.now()-e.at;Z(l,`${w(`green`,`reload`)} ${n} (${r}ms)`,X)}async function M(e,t){try{or(v,e)}catch(e){e instanceof K&&e.code===`ERR_INCA_CONFIG_INVALID`?(x=e,r()):$(u,`failed to start the host`,Q(e),X);return}let n=new tn({entryFile:e,hostBin:v,env:vr(u),onStderr:e=>u.write(e),onReady:()=>{S=!0,Z(l,`ready`,X),C&&(C=!1,j())},onAppError:e=>$(u,`app error`,e,X),onExit:(e,t)=>{ee=!S,T={code:e,signal:t},Z(l,`host exited. stopping`,X),r()},integrations:t});try{await n.start()}catch(e){$(u,`failed to start the host`,Q(e),X);return}y=n}async function ne(e){await _r(e.outDir,e.files),y?S?await j()&&te(e.changed):C=!0:await M(e.entryFile)}async function re(e){q(t,p,e);let n=++O,a=()=>n===O&&!i,o=e=>(...t)=>{a()&&e(...t)},s;if(d){let n=await d({entry:e,root:Vn(t,e),envDir:t,publicDir:b.join(t,`public`),cwd:t,runtimeConfig:_,stdout:l,stderr:u,notify:o(e=>y?.notify(`vite`,e)),reload:o(e=>{S?j().then(t=>{t&&te(e)}):C=!0}),onError:o(e=>$(u,`build failed`,e,X)),onUpdate:o(({file:e,took:n})=>{if(!S)return;let r=w(`dim`,b.relative(t,e),{stream:l});Z(l,`${w(`green`,`update`)} ${r} (${n}ms)`,X)})});A=e=>n.dispatch(e),s={close:()=>(A=void 0,n.close())},y?S?await j():C=!0:(await M(n.entryFile,{vite:e=>A?.(e)}),y||r())}else s=await c.watch({entry:e,root:Vn(t,e),envDir:t,publicDir:b.join(t,`public`),outDir:p,runtimeConfig:H(_,t,p),mode:`development`,stdout:l,stderr:u,onBuild:e=>{E=E.then(()=>a()?ne(e):void 0)},onError:o(e=>{$(u,`build failed`,e,X)})});return{entry:e,async close(){O++,await s.close()}}}async function ie(){let e=D;D=void 0,await e?.close()}async function ae(){if(i)return;let e=Hn(t);if(e===void 0||e!==D?.entry)try{e===void 0&&await ie();let n=await Un(t);if(k=!1,await ie(),i)return;D=await re(n)}catch(t){k||$(u,`build failed`,Q(t),X),k=e===void 0}}async function oe(e){let n=e;for(;await Promise.race([a.then(()=>!1),n.edited.then(()=>!0)]);)n.close(),n=o=dr(t),E=E.then(ae),await E}let N=m;if(h){o=dr(t);try{N=await Un(t)}catch(e){N=void 0,k=!0,$(u,`build failed`,Q(e),X)}}N!==void 0&&(D=await re(N)),o&&(s=oe(o).then(()=>void 0,e=>(r(),{error:e}))),e.signal.aborted?r():e.signal.addEventListener(`abort`,()=>r(),{once:!0}),await a;let se=await s;if(await D?.close(),await E,await y?.stop(),se)throw se.error;if(x)throw x;if(ee)throw new K(`ERR_INCA_HOST_EXITED_EARLY`,`the host exited before it was ready`);if(T&&T.code!==0&&T.signal!==`SIGINT`&&T.signal!==`SIGTERM`){let{code:e,signal:t}=T;throw new K(`ERR_INCA_HOST_CRASHED`,`the host exited with ${t?`signal ${t}`:`code ${e}`}`)}}finally{r(),await s,o?.close(),await n()}}function br(){if(process.platform===`darwin`)return`macos`;if(process.platform===`linux`)return`linux`;throw new K(`ERR_INCA_PLATFORM_UNSUPPORTED`,`inca package doesn't support ${process.platform} yet`)}async function xr(e,t){await Promise.all(e.files.map(async n=>{let r=b.join(t,n);await D(b.dirname(r),{recursive:!0}),await T(b.join(e.outDir,n),r)}))}function Sr(e,t){let n=e.files.map(e=>e.split(`/`)[0]??e).find(e=>e.toLowerCase()===t.toLowerCase());if(n!==void 0)throw new K(`ERR_INCA_PRODUCT_NAME_INVALID`,`the packaged app's directory "${t}" collides with "${n}" in the build output. Set a different "productName" in inca.config.ts`)}async function Cr({metadata:e,output:t,hostBin:n}){let{appPath:r,resourcesDir:i}=await tr({appPath:b.join(t.outDir,`${e.productName}.app`),metadata:e,hostBin:n});return await xr(t,i),r}async function wr({metadata:e,output:t,hostBin:n}){let r=c(e.productName);Sr(t,r);let i=b.join(t.outDir,r);await A(i,{recursive:!0,force:!0}),await D(i,{recursive:!0});let a=b.join(i,r);return await T(n,a),await ee(a,493),await xr(t,i),i}async function Tr(e={}){let t=e.cwd??process.cwd(),n=e.stdout??process.stdout,r=e.target??br(),i=await Kt(t);i.usedPackageJsonKey&&Z(n,`the "inca" key in package.json is deprecated. move these settings to inca.config.ts`),i.identifierIsDefault&&Z(n,`no "identifier" set in inca.config.ts. using generated identifier ${i.identifier}`);let a=await Gn({cwd:t,entry:e.entry,config:i,sourcemap:e.sourcemap,runtimeConfig:qt(i),bundler:e.bundler,stdout:n,stderr:e.stderr}),o=e.hostBin??J();Y(o),or(o,a.entryFile);let s={metadata:i,output:a,hostBin:o};return{appPath:r===`macos`?await Cr(s):await wr(s)}}function Er(e){return b.relative(process.cwd(),e)}const Dr={type:`boolean`,description:`Write a source map`,negativeDescription:`Skip the source map`};function Or(){for(let e of[0,1,2])try{p.closeSync(e)}catch{}}const kr=V({meta:{name:`build`,description:`Bundle the app into dist`},args:{sourcemap:Dr},async run({args:e}){try{let t=await Gn({sourcemap:e.sourcemap});sr(t.entryFile,process.stderr),Z(process.stdout,`built ${Er(t.entryFile)}`)}catch(e){$(process.stderr,`build failed`,Q(e)),process.exitCode=1}}}),Ar=V({meta:{name:`package`,description:`Package the app as an application bundle`},args:{sourcemap:Dr},async run({args:e}){try{let{appPath:t}=await Tr({sourcemap:e.sourcemap});Z(process.stdout,`packaged ${Er(t)}`)}catch(e){$(process.stderr,`package failed`,Q(e)),process.exitCode=1}}}),jr=V({meta:{name:`config`,description:`Print the settings the host applies to the app`},async run(){try{process.exitCode=await cr()}catch(e){$(process.stderr,`config failed`,Q(e)),process.exitCode=1}}}),Mr=V({meta:{name:`dev`,description:`Run the app in a development window`},args:{"experimental-hmr":{type:`boolean`,description:`Apply edits without a reload (or set INCA_EXPERIMENTAL_HMR)`}},async run({args:e}){`sourcemap`in e&&an(process.stderr,`dev ignores --sourcemap and --no-sourcemap`,{timestamp:!0});let t=new AbortController,n=()=>{t.signal.aborted||(Z(process.stderr,`shutting down`,{timestamp:!0}),t.abort())};process.on(`SIGINT`,n),process.on(`SIGTERM`,n);let r=e[`experimental-hmr`]===!0||![``,`0`,`false`].includes(process.env.INCA_EXPERIMENTAL_HMR??``);r&&Z(process.stdout,`experimental HMR active`,{timestamp:!0});try{await yr({signal:t.signal,experimentalHmr:r}),t.signal.aborted&&Or()}catch(e){$(process.stderr,`dev failed`,Q(e),{timestamp:!0}),process.exitCode=1}}}),Nr=V({meta:{name:`inca`,version:Ue,description:We},subCommands:{dev:Mr,build:kr,package:Ar,config:jr}});async function Pr(e=process.argv){await Be(Nr,{rawArgs:e.slice(2)})}export{Pr as run};
|
|
31
|
+
`}async function ar(e){let{appPath:t,metadata:n,hostBin:r}=e;await A(t,{recursive:!0,force:!0});let i=b.join(t,`Contents`),a=b.join(i,`MacOS`),o=b.join(i,`Resources`);await D(a,{recursive:!0}),await D(o,{recursive:!0});let s=b.join(a,n.productName);e.link?await E(r,s).catch(()=>T(r,s)):await T(r,s),await ee(s,493);let c={CFBundleName:n.productName,CFBundleDisplayName:n.productName,CFBundleExecutable:n.productName,CFBundleIdentifier:n.identifier,CFBundleVersion:n.version,CFBundleShortVersionString:n.version,CFBundlePackageType:`APPL`,CFBundleInfoDictionaryVersion:`6.0`,NSHighResolutionCapable:!0};if(n.icon){let e=b.basename(n.icon);await T(n.icon,b.join(o,e)),c.CFBundleIconFile=e}return await j(b.join(i,`Info.plist`),ir(c)),await j(b.join(i,`PkgInfo`),`APPL????`),{appPath:t,executablePath:s,resourcesDir:o}}const or={productName:`a string`,identifier:`a string`,window:`an object`,dev:`an object`,"window.width":`a number`,"window.height":`a number`,"window.title":`a string`,"window.resizable":`true or false`,"window.minWidth":`a number`,"window.minHeight":`a number`,"dev.stackPaths":`a string`};function sr(e){return typeof e==`number`?`a number`:typeof e==`string`?`a string`:typeof e==`boolean`?`true or false`:`an object`}function cr(e,t,n){let r=`failed to read ${t}: `,i=e.split(`
|
|
32
|
+
`)[0]??``;if(!i.startsWith(r))return;let a=i.slice(r.length),o=a.indexOf(`]: `),s;try{s=JSON.parse(a.slice(0,o+1))}catch{return}if(!Array.isArray(s))return;let[c,...l]=s,u=[c===`name`?`productName`:c,...l].join(`.`),d=or[u];if(!d)return;let f=s.reduce((e,t)=>e?.[t],n),p=sr(f)===d?`the host can't use it`:`it must be ${d}`;return new K(`ERR_INCA_CONFIG_INVALID`,`${u} in inca.config.ts is ${JSON.stringify(f)}. ${p}`)}function lr(e,t,n,r){let i=ie(e,[`--print-config`,t],{encoding:`utf8`});if(i.error)throw i.error;if(i.status!==0){let e=cr(i.stderr,n,r);if(e)throw e}return i}function ur(e,t){let n=b.join(b.dirname(t),`inca.json`),r={};try{r=JSON.parse(g(n,`utf8`))}catch{}let i=lr(e,t,n,r);if(i.status===null)throw new K(`ERR_INCA_HOST_EXITED_EARLY`,`the host exited with signal ${String(i.signal)} before it read the config`);if(i.status!==0)throw new K(`ERR_INCA_CONFIG_INVALID`,`the host can't read ${n}. it reported "${i.stderr.split(`
|
|
33
|
+
`)[0]??``}"`)}function dr(e,t){let n;try{n=q(),J(n)}catch(e){if(e instanceof K&&(e.code===`ERR_INCA_HOST_BIN_UNRESOLVED`||e.code===`ERR_INCA_HOST_BIN_NOT_FOUND`)){on(t,`no host binary found, so the config was not checked`);return}throw e}ur(n,e)}async function fr(e={}){let t=e.cwd??process.cwd(),n=e.hostBin??q();J(n);let r=await Yt(t,{dev:!0}),i=b.join(t,`node_modules/.inca/config`),a=b.join(i,`bundle.js`),o=b.join(i,`inca.json`);await D(i,{recursive:!0}),await j(a,``),await j(o,JSON.stringify(U(r,t,i),void 0,2));let s=lr(n,a,o,r);return(e.stdout??process.stdout).write(s.stdout),(e.stderr??process.stderr).write(s.stderr),s.status??1}const pr=/^(?:inca\.config\.[a-z0-9]+|package\.json)$/,mr=[...Un,`App.vue`];function hr(e,t={}){let n=t.debounceMs??100,r=/* @__PURE__ */ new Set,i,a=!1,o=()=>{},s=new Promise(e=>{o=e}),c=()=>{a||(clearTimeout(i),i=setTimeout(o,n),i.unref())},l=(e,t)=>{let n=e;for(let e;!m(n)&&(e=b.dirname(n))!==n;)n=e;let i=n===e?void 0:b.relative(n,e).split(b.sep)[0],a=y(n);a.on(`change`,(e,n)=>{let r=n===null?null:String(n);(r===null||(i===void 0?t(r):r===i))&&c()}),a.on(`error`,()=>{a.close(),r.delete(a),c()}),r.add(a)},u=()=>{a=!0,clearTimeout(i);for(let e of r)e.close();r.clear()};try{l(e,e=>e===`src`||pr.test(e)),l(b.join(e,`src`),e=>mr.includes(e))}catch(e){throw u(),e}return{edited:s,add(e){if(a)return;let t=b.resolve(e);l(b.dirname(t),e=>e===b.basename(t))},close:u}}function gr(e,t){return new Promise(n=>{let r=()=>n(!1);t.addEventListener(`abort`,r,{once:!0}),e.then(()=>{t.removeEventListener(`abort`,r),n(!0)})})}async function _r(e){let{cwd:t,signal:n,stdout:r,stderr:i,debounceMs:a}=e,o=!1;for(;;){let s=hr(t,{debounceMs:a});try{return await e.attempt(s)}catch(e){let t=e instanceof K?e.path:void 0;if(t)try{s.add(t)}catch(t){throw Q(i,`build failed`,Z(e),Y),t}if(!n.aborted&&!o&&t&&m(t)){o=!0;continue}if(o=!1,Q(i,`build failed`,Z(e),Y),n.aborted||(X(r,`waiting for a change to retry`,Y),!await gr(s.edited,n)))return;X(r,`retrying`,Y)}finally{s.close()}}}const vr=[`ERR_INCA_PACKAGE_JSON_NOT_FOUND`,`ERR_INCA_PRODUCT_NAME_MISSING`];async function yr(e,t){try{return await qt(e)}catch(e){if(!(e instanceof K)||!vr.includes(e.code))throw e;X(t,`running unnamed. ${e.message}`,Y);return}}async function br(e,t,n,r){if(process.platform===`darwin`&&t)try{return(await ar({appPath:b.join(e,`node_modules/.inca`,`${t.productName}.app`),metadata:t,hostBin:n,link:!0})).executablePath}catch(e){X(r,`running unbundled. ${Z(e).message}`,Y);return}}async function xr(e,t){let n=new Set(t),r;try{r=await k(e,{recursive:!0,withFileTypes:!0})}catch{return}await Promise.all(r.filter(e=>e.isFile()).map(t=>b.relative(e,b.join(t.parentPath,t.name))).filter(e=>!n.has(e)).map(t=>A(b.join(e,t),{force:!0})))}function Sr(e){let{NO_COLOR:t,FORCE_COLOR:n}=process.env;if(!(!e.isTTY||t||n))return{...process.env,FORCE_COLOR:`1`}}async function Cr(e){let t=e.cwd??process.cwd(),n=await er(t),r=()=>{},i=!1,a=new Promise(e=>{r=()=>{i=!0,e()}}),o,s;try{let n=e.hostBin??q();J(n);let c=e.bundler??Hn,l=e.stdout??process.stdout,u=e.stderr??process.stderr,d=e.experimentalHmr?c.hmr?.bind(c):void 0;if(e.experimentalHmr&&!d)throw new K(`ERR_INCA_HMR_UNSUPPORTED`,`--experimental-hmr was set, but the configured bundler has no HMR support`);let f=await _r({cwd:t,signal:e.signal,stdout:l,stderr:u,async attempt(){let n=await Gt(t),r=b.resolve(t,n.outDir),i=e.entry===void 0&&n.entry===void 0,a=e.entry??n.entry??await qn(t);Vt(t,r,a);let o=await yr(t,l);return{outDir:r,entry:a,automaticEntry:i,metadata:o,runtimeConfig:o?Jt(o,{dev:!0}):await Yt(t,{dev:!0})}}});if(!f)return;let{outDir:p,entry:m,automaticEntry:h,metadata:g,runtimeConfig:_}=f,v=await br(t,g,n,l)??n,y,x,S=!1,C=!1,ee=!1,T,E=Promise.resolve(),D,O=0,k=!1,A;async function j(){try{return await y?.call(`reload`,void 0,1e4),!0}catch(e){return Q(u,`reload failed`,Z(e),Y),!1}}function te(e){if(!e)return;let n=w(`dim`,b.relative(t,e.file),{stream:l}),r=Date.now()-e.at;X(l,`${w(`green`,`reload`)} ${n} (${r}ms)`,Y)}async function M(e,t){try{ur(v,e)}catch(e){e instanceof K&&e.code===`ERR_INCA_CONFIG_INVALID`?(x=e,r()):Q(u,`failed to start the host`,Z(e),Y);return}let n=new nn({entryFile:e,hostBin:v,env:Sr(u),onStderr:e=>u.write(e),onReady:()=>{S=!0,X(l,`ready`,Y),C&&(C=!1,j())},onAppError:e=>Q(u,`app error`,e,Y),onExit:(e,t)=>{ee=!S,T={code:e,signal:t},X(l,`host exited. stopping`,Y),r()},integrations:t});try{await n.start()}catch(e){Q(u,`failed to start the host`,Z(e),Y);return}y=n}async function ne(e){await xr(e.outDir,e.files),y?S?await j()&&te(e.changed):C=!0:await M(e.entryFile)}async function re(e){Vt(t,p,e);let n=++O,a=()=>n===O&&!i,o=e=>(...t)=>{a()&&e(...t)},s;if(d){let n=await d({entry:e,root:Gn(t,e),envDir:t,publicDir:b.join(t,`public`),cwd:t,runtimeConfig:_,stdout:l,stderr:u,notify:o(e=>y?.notify(`vite`,e)),reload:o(e=>{S?j().then(t=>{t&&te(e)}):C=!0}),onError:o(e=>Q(u,`build failed`,e,Y)),onUpdate:o(({file:e,took:n})=>{if(!S)return;let r=w(`dim`,b.relative(t,e),{stream:l});X(l,`${w(`green`,`update`)} ${r} (${n}ms)`,Y)})});A=e=>n.dispatch(e),s={close:()=>(A=void 0,n.close())},y?S?await j():C=!0:(await M(n.entryFile,{vite:e=>A?.(e)}),y||r())}else s=await c.watch({entry:e,root:Gn(t,e),envDir:t,publicDir:b.join(t,`public`),outDir:p,runtimeConfig:U(_,t,p),mode:`development`,stdout:l,stderr:u,onBuild:e=>{E=E.then(()=>a()?ne(e):void 0)},onError:o(e=>{Q(u,`build failed`,e,Y)})});return{entry:e,async close(){O++,await s.close()}}}async function ie(){let e=D;D=void 0,await e?.close()}async function N(){if(i)return;let e=Kn(t);if(e===void 0||e!==D?.entry)try{e===void 0&&await ie();let n=await qn(t);if(k=!1,await ie(),i)return;D=await re(n)}catch(t){k||Q(u,`build failed`,Z(t),Y),k=e===void 0}}async function ae(e){let n=e;for(;await Promise.race([a.then(()=>!1),n.edited.then(()=>!0)]);)n.close(),n=o=hr(t),E=E.then(N),await E}let P=m;if(h){o=hr(t);try{P=await qn(t)}catch(e){P=void 0,k=!0,Q(u,`build failed`,Z(e),Y)}}P!==void 0&&(D=await re(P)),o&&(s=ae(o).then(()=>void 0,e=>(r(),{error:e}))),e.signal.aborted?r():e.signal.addEventListener(`abort`,()=>r(),{once:!0}),await a;let oe=await s;if(await D?.close(),await E,await y?.stop(),oe)throw oe.error;if(x)throw x;if(ee)throw new K(`ERR_INCA_HOST_EXITED_EARLY`,`the host exited before it was ready`);if(T&&T.code!==0&&T.signal!==`SIGINT`&&T.signal!==`SIGTERM`){let{code:e,signal:t}=T;throw new K(`ERR_INCA_HOST_CRASHED`,`the host exited with ${t?`signal ${t}`:`code ${e}`}`)}}finally{r(),await s,o?.close(),await n()}}function wr(){if(process.platform===`darwin`)return`macos`;if(process.platform===`linux`)return`linux`;throw new K(`ERR_INCA_PLATFORM_UNSUPPORTED`,`inca package doesn't support ${process.platform} yet`)}async function Tr(e,t){await Promise.all(e.files.map(async n=>{let r=b.join(t,n);await D(b.dirname(r),{recursive:!0}),await T(b.join(e.outDir,n),r)}))}function Er(e,t){let n=e.files.map(e=>e.split(`/`)[0]??e).find(e=>e.toLowerCase()===t.toLowerCase());if(n!==void 0)throw new K(`ERR_INCA_PRODUCT_NAME_INVALID`,`the packaged app's directory "${t}" collides with "${n}" in the build output. Set a different "productName" in inca.config.ts`)}async function Dr({metadata:e,output:t,hostBin:n}){let{appPath:r,resourcesDir:i}=await ar({appPath:b.join(t.outDir,`${e.productName}.app`),metadata:e,hostBin:n});return await Tr(t,i),r}async function Or({metadata:e,output:t,hostBin:n}){let r=c(e.productName);Er(t,r);let i=b.join(t.outDir,r);await A(i,{recursive:!0,force:!0}),await D(i,{recursive:!0});let a=b.join(i,r);return await T(n,a),await ee(a,493),await Tr(t,i),i}async function kr(e={}){let t=e.cwd??process.cwd(),n=e.stdout??process.stdout,r=e.target??wr(),i=await qt(t);i.usedPackageJsonKey&&X(n,`the "inca" key in package.json is deprecated. move these settings to inca.config.ts`),i.identifierIsDefault&&X(n,`no "identifier" set in inca.config.ts. using generated identifier ${i.identifier}`);let a=await Yn({cwd:t,entry:e.entry,config:i,sourcemap:e.sourcemap,runtimeConfig:Jt(i),bundler:e.bundler,stdout:n,stderr:e.stderr}),o=e.hostBin??q();J(o),ur(o,a.entryFile);let s={metadata:i,output:a,hostBin:o};return{appPath:r===`macos`?await Dr(s):await Or(s)}}function Ar(e){return b.relative(process.cwd(),e)}const jr={type:`boolean`,description:`Write a source map`,negativeDescription:`Skip the source map`};function Mr(){for(let e of[0,1,2])try{p.closeSync(e)}catch{}}const Nr=H({meta:{name:`build`,description:`Bundle the app into dist`},args:{sourcemap:jr},async run({args:e}){try{let t=await Yn({sourcemap:e.sourcemap});dr(t.entryFile,process.stderr),X(process.stdout,`built ${Ar(t.entryFile)}`)}catch(e){Q(process.stderr,`build failed`,Z(e)),process.exitCode=1}}}),Pr=H({meta:{name:`package`,description:`Package the app as an application bundle`},args:{sourcemap:jr},async run({args:e}){try{let{appPath:t}=await kr({sourcemap:e.sourcemap});X(process.stdout,`packaged ${Ar(t)}`)}catch(e){Q(process.stderr,`package failed`,Z(e)),process.exitCode=1}}}),Fr=H({meta:{name:`config`,description:`Print the settings the host applies to the app`},async run(){try{process.exitCode=await fr()}catch(e){Q(process.stderr,`config failed`,Z(e)),process.exitCode=1}}}),Ir=H({meta:{name:`dev`,description:`Run the app in a development window`},args:{"experimental-hmr":{type:`boolean`,description:`Apply edits without a reload (or set INCA_EXPERIMENTAL_HMR)`}},async run({args:e}){`sourcemap`in e&&on(process.stderr,`dev ignores --sourcemap and --no-sourcemap`,{timestamp:!0});let t=new AbortController,n=()=>{t.signal.aborted||(X(process.stderr,`shutting down`,{timestamp:!0}),t.abort())};process.on(`SIGINT`,n),process.on(`SIGTERM`,n);let r=e[`experimental-hmr`]===!0||![``,`0`,`false`].includes(process.env.INCA_EXPERIMENTAL_HMR??``);r&&X(process.stdout,`experimental HMR active`,{timestamp:!0});try{await Cr({signal:t.signal,experimentalHmr:r}),t.signal.aborted&&Mr()}catch(e){Q(process.stderr,`dev failed`,Z(e),{timestamp:!0}),process.exitCode=1}}}),Lr=H({meta:{name:`inca`,version:He,description:Ue},subCommands:{dev:Ir,build:Nr,package:Pr,config:Fr}});async function Rr(e=process.argv){await ze(Lr,{rawArgs:e.slice(2)})}export{Rr as run};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@incajs/cli",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.24",
|
|
4
4
|
"description": "Commands to develop, bundle, and package Incarnative.js apps.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"bundler",
|
|
@@ -61,10 +61,10 @@
|
|
|
61
61
|
}
|
|
62
62
|
},
|
|
63
63
|
"optionalDependencies": {
|
|
64
|
-
"@incajs/host-darwin-arm64": "0.0.
|
|
65
|
-
"@incajs/host-darwin-x64": "0.0.
|
|
66
|
-
"@incajs/host-linux-arm64": "0.0.
|
|
67
|
-
"@incajs/host-linux-x64": "0.0.
|
|
64
|
+
"@incajs/host-darwin-arm64": "0.0.24",
|
|
65
|
+
"@incajs/host-darwin-x64": "0.0.24",
|
|
66
|
+
"@incajs/host-linux-arm64": "0.0.24",
|
|
67
|
+
"@incajs/host-linux-x64": "0.0.24"
|
|
68
68
|
},
|
|
69
69
|
"engines": {
|
|
70
70
|
"node": ">=22.18"
|