appos 0.3.19-0 → 0.3.20-0
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/exports/cli/index.mjs +83 -77
- package/package.json +1 -1
|
@@ -17,10 +17,11 @@ import { createRequire, register } from "node:module";
|
|
|
17
17
|
import path, { basename, dirname, join, resolve } from "node:path";
|
|
18
18
|
import fs, { existsSync } from "node:fs";
|
|
19
19
|
import { DBOS } from "@dbos-inc/dbos-sdk";
|
|
20
|
-
import fs$1, { access, cp, glob, mkdir, readFile, readdir,
|
|
20
|
+
import fs$1, { access, cp, glob, mkdir, readFile, readdir, rm, writeFile } from "node:fs/promises";
|
|
21
21
|
import { createHash } from "node:crypto";
|
|
22
22
|
import { isIP, isIPv6 } from "node:net";
|
|
23
23
|
import net, { isIP as isIP$1 } from "net";
|
|
24
|
+
import { fileURLToPath } from "node:url";
|
|
24
25
|
import Stream, { PassThrough, Readable, Writable, pipeline } from "stream";
|
|
25
26
|
import { spawn } from "node:child_process";
|
|
26
27
|
import { stripVTControlCharacters } from "node:util";
|
|
@@ -35,7 +36,7 @@ import tty from "tty";
|
|
|
35
36
|
import crypto2, { createHash as createHash$1, createHmac, createPrivateKey, createPublicKey, randomUUID, sign } from "crypto";
|
|
36
37
|
import fs4, { ReadStream, existsSync as existsSync$1, fstatSync, lstatSync, mkdirSync, promises, readFileSync, readdirSync as readdirSync$1, writeFileSync } from "fs";
|
|
37
38
|
import path2, { dirname as dirname$1, join as join$1, resolve as resolve$1, sep } from "path";
|
|
38
|
-
import { fileURLToPath, format, parse } from "url";
|
|
39
|
+
import { fileURLToPath as fileURLToPath$1, format, parse } from "url";
|
|
39
40
|
import { deprecate, promisify as promisify$1, types } from "util";
|
|
40
41
|
import { Buffer as Buffer$1 } from "buffer";
|
|
41
42
|
import http, { Agent, createServer, request } from "http";
|
|
@@ -1475,6 +1476,7 @@ function defineCommand(def) {
|
|
|
1475
1476
|
* Runtime externals - needed in production Docker.
|
|
1476
1477
|
*/
|
|
1477
1478
|
const RUNTIME_EXACT = [
|
|
1479
|
+
"appos",
|
|
1478
1480
|
"canvas",
|
|
1479
1481
|
"pino",
|
|
1480
1482
|
"react",
|
|
@@ -1580,95 +1582,99 @@ async function collectEntryPoints() {
|
|
|
1580
1582
|
return entryPoints;
|
|
1581
1583
|
}
|
|
1582
1584
|
/**
|
|
1585
|
+
* Prefixes of packages to skip when collecting runtime dependencies.
|
|
1586
|
+
*/
|
|
1587
|
+
const SKIP_PREFIXES = [
|
|
1588
|
+
"@babel",
|
|
1589
|
+
"@esbuild",
|
|
1590
|
+
"@rollup",
|
|
1591
|
+
"@tailwindcss",
|
|
1592
|
+
"@types",
|
|
1593
|
+
"biome",
|
|
1594
|
+
"esbuild",
|
|
1595
|
+
"prettier",
|
|
1596
|
+
"rollup",
|
|
1597
|
+
"tailwindcss",
|
|
1598
|
+
"vite"
|
|
1599
|
+
];
|
|
1600
|
+
/**
|
|
1583
1601
|
* Collect runtime dependencies to build/node_modules/.
|
|
1584
1602
|
*
|
|
1585
1603
|
* Algorithm:
|
|
1586
|
-
* 1.
|
|
1604
|
+
* 1. Use import.meta.resolve() to find packages (works with all package managers)
|
|
1587
1605
|
* 2. Copy RUNTIME externals and their transitive dependencies
|
|
1588
1606
|
* 3. Prune platform-specific binaries for current arch
|
|
1589
1607
|
*/
|
|
1590
1608
|
async function collectRuntimeDeps() {
|
|
1591
|
-
let nodeModules = "";
|
|
1592
|
-
let dir = process.cwd();
|
|
1593
|
-
while (dir !== "/") {
|
|
1594
|
-
const candidate = join(dir, "node_modules");
|
|
1595
|
-
if (existsSync(join(candidate, ".bun"))) {
|
|
1596
|
-
nodeModules = candidate;
|
|
1597
|
-
break;
|
|
1598
|
-
}
|
|
1599
|
-
dir = dirname(dir);
|
|
1600
|
-
}
|
|
1601
|
-
if (!nodeModules) throw new Error("Could not find workspace root node_modules");
|
|
1602
1609
|
const targetDir = join(process.cwd(), BUILD_DIR, "node_modules");
|
|
1603
1610
|
const collected = /* @__PURE__ */ new Set();
|
|
1604
1611
|
/**
|
|
1605
|
-
*
|
|
1612
|
+
* Find package.json path for a package using Node.js resolution.
|
|
1606
1613
|
*
|
|
1607
1614
|
* Algorithm:
|
|
1608
|
-
* 1.
|
|
1609
|
-
* 2.
|
|
1610
|
-
*
|
|
1615
|
+
* 1. Try resolving package/package.json directly (works for most packages)
|
|
1616
|
+
* 2. If not found or path doesn't end with package.json (wildcard export issue),
|
|
1617
|
+
* resolve any export and walk up to find package.json
|
|
1618
|
+
* 3. For packages without root export, try common subpaths (api, cli, web)
|
|
1611
1619
|
*/
|
|
1612
|
-
async function
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
"
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
"
|
|
1619
|
-
"
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
if (!pkgDir) {
|
|
1628
|
-
const directPath = join(nodeModules, name);
|
|
1629
|
-
if (existsSync(directPath)) pkgDir = await realpath(directPath);
|
|
1630
|
-
}
|
|
1631
|
-
if (!pkgDir) {
|
|
1632
|
-
const bunDir = join(nodeModules, ".bun");
|
|
1633
|
-
const prefix = name.startsWith("@") ? name.replace("/", "+") : name;
|
|
1634
|
-
for (const entry of await readdir(bunDir)) if (entry.startsWith(`${prefix}@`)) {
|
|
1635
|
-
const candidate = join(bunDir, entry, "node_modules", name);
|
|
1620
|
+
async function findPackageJson(name) {
|
|
1621
|
+
try {
|
|
1622
|
+
const pkgPath = fileURLToPath(import.meta.resolve(`${name}/package.json`));
|
|
1623
|
+
if (pkgPath.endsWith("package.json") && existsSync(pkgPath)) return pkgPath;
|
|
1624
|
+
} catch {}
|
|
1625
|
+
for (const subpath of [
|
|
1626
|
+
"",
|
|
1627
|
+
"/api",
|
|
1628
|
+
"/cli",
|
|
1629
|
+
"/web",
|
|
1630
|
+
"/index"
|
|
1631
|
+
]) try {
|
|
1632
|
+
let dir = dirname(fileURLToPath(import.meta.resolve(`${name}${subpath}`)));
|
|
1633
|
+
while (dir !== "/" && !dir.endsWith("node_modules")) {
|
|
1634
|
+
const candidate = join(dir, "package.json");
|
|
1636
1635
|
if (existsSync(candidate)) {
|
|
1637
|
-
|
|
1638
|
-
break;
|
|
1636
|
+
if (JSON.parse(await readFile(candidate, "utf8")).name === name) return candidate;
|
|
1639
1637
|
}
|
|
1638
|
+
dir = dirname(dir);
|
|
1640
1639
|
}
|
|
1641
|
-
}
|
|
1642
|
-
|
|
1643
|
-
|
|
1640
|
+
} catch {}
|
|
1641
|
+
return null;
|
|
1642
|
+
}
|
|
1643
|
+
/**
|
|
1644
|
+
* Collect a package and its transitive dependencies using Node.js native resolution.
|
|
1645
|
+
*
|
|
1646
|
+
* Algorithm:
|
|
1647
|
+
* 1. Find package.json using Node.js resolution (works with npm/yarn/pnpm/bun)
|
|
1648
|
+
* 2. Copy package directory to target
|
|
1649
|
+
* 3. Recursively collect dependencies and non-optional peerDependencies
|
|
1650
|
+
*/
|
|
1651
|
+
async function collectPackage(name) {
|
|
1652
|
+
if (collected.has(name) || SKIP_PREFIXES.some((p$3) => name.startsWith(p$3))) return;
|
|
1653
|
+
collected.add(name);
|
|
1654
|
+
const pkgPath = await findPackageJson(name);
|
|
1655
|
+
if (!pkgPath) return;
|
|
1656
|
+
const pkgDir = dirname(pkgPath);
|
|
1657
|
+
const pkgJson = JSON.parse(await readFile(pkgPath, "utf8"));
|
|
1644
1658
|
const destDir = join(targetDir, name);
|
|
1645
1659
|
await mkdir(dirname(destDir), { recursive: true });
|
|
1646
1660
|
await cp(pkgDir, destDir, {
|
|
1647
1661
|
recursive: true,
|
|
1648
1662
|
dereference: true
|
|
1649
1663
|
});
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
|
|
1656
|
-
const scope = prefix.slice(0, -1);
|
|
1657
|
-
const scopeDir = join(nodeModules, scope);
|
|
1658
|
-
if (existsSync(scopeDir)) {
|
|
1659
|
-
for (const pkg of await readdir(scopeDir)) await collectPackage(`${scope}/${pkg}`);
|
|
1664
|
+
if (name === "appos") {
|
|
1665
|
+
for (const dep of Object.keys(pkgJson.dependencies || {})) {
|
|
1666
|
+
const isRuntimeExact = RUNTIME_EXACT.includes(dep);
|
|
1667
|
+
const isRuntimePrefix = RUNTIME_PREFIXES.some((p$3) => dep.startsWith(p$3));
|
|
1668
|
+
if (isRuntimeExact || isRuntimePrefix) await collectPackage(dep);
|
|
1669
|
+
}
|
|
1660
1670
|
return;
|
|
1661
1671
|
}
|
|
1662
|
-
const
|
|
1663
|
-
const
|
|
1664
|
-
for (const
|
|
1665
|
-
const match$1 = entry.match(/^(@[^+]+)\+([^@]+)@/);
|
|
1666
|
-
if (match$1) await collectPackage(`${match$1[1]}/${match$1[2]}`);
|
|
1667
|
-
}
|
|
1672
|
+
for (const dep of Object.keys(pkgJson.dependencies || {})) await collectPackage(dep);
|
|
1673
|
+
const peerMeta = pkgJson.peerDependenciesMeta || {};
|
|
1674
|
+
for (const dep of Object.keys(pkgJson.peerDependencies || {})) if (!peerMeta[dep]?.optional) await collectPackage(dep);
|
|
1668
1675
|
}
|
|
1669
1676
|
await mkdir(targetDir, { recursive: true });
|
|
1670
1677
|
for (const pkg of RUNTIME_EXACT) await collectPackage(pkg);
|
|
1671
|
-
for (const prefix of RUNTIME_PREFIXES) await collectScopedPackages(prefix);
|
|
1672
1678
|
const arch$1 = process.arch === "x64" ? "x64" : process.arch;
|
|
1673
1679
|
const platform$1 = process.platform;
|
|
1674
1680
|
const nodeAbi = process.versions.modules;
|
|
@@ -1707,7 +1713,7 @@ var build_default = defineCommand({
|
|
|
1707
1713
|
const entryPoints = await collectEntryPoints();
|
|
1708
1714
|
const outdir = `./${BUILD_DIR}`;
|
|
1709
1715
|
ctx.step(`Found ${entryPoints.length} entry points`);
|
|
1710
|
-
await ctx.spinner("Building production bundle", async () => {
|
|
1716
|
+
await ctx.spinner("Building API production bundle", async () => {
|
|
1711
1717
|
if (!hasWebDir) await rm(outdir, {
|
|
1712
1718
|
recursive: true,
|
|
1713
1719
|
force: true
|
|
@@ -1730,7 +1736,7 @@ var build_default = defineCommand({
|
|
|
1730
1736
|
});
|
|
1731
1737
|
await cp(`./${APPOS_DIR}/${DATABASES_DIR}`, `${outdir}/${APPOS_DIR}/${DATABASES_DIR}`, { recursive: true });
|
|
1732
1738
|
});
|
|
1733
|
-
ctx.success("Built API successfully");
|
|
1739
|
+
ctx.success("Built API production bundle successfully");
|
|
1734
1740
|
const count = await ctx.spinner("Collecting runtime dependencies", collectRuntimeDeps);
|
|
1735
1741
|
ctx.success(`Collected ${count} runtime packages to "${outdir}/node_modules"`);
|
|
1736
1742
|
await ctx.cleanup();
|
|
@@ -26682,7 +26688,7 @@ var require_old = __commonJS({ "../node_modules/.pnpm/fs.realpath@1.0.0/node_mod
|
|
|
26682
26688
|
if (cache6) cache6[original] = p6;
|
|
26683
26689
|
return p6;
|
|
26684
26690
|
};
|
|
26685
|
-
exports2.realpath = function realpath
|
|
26691
|
+
exports2.realpath = function realpath(p6, cache6, cb) {
|
|
26686
26692
|
if (typeof cb !== "function") {
|
|
26687
26693
|
cb = maybeCallback(cache6);
|
|
26688
26694
|
cache6 = null;
|
|
@@ -26756,12 +26762,12 @@ var require_old = __commonJS({ "../node_modules/.pnpm/fs.realpath@1.0.0/node_mod
|
|
|
26756
26762
|
} });
|
|
26757
26763
|
var require_fs = __commonJS({ "../node_modules/.pnpm/fs.realpath@1.0.0/node_modules/fs.realpath/index.js"(exports2, module$1) {
|
|
26758
26764
|
"use strict";
|
|
26759
|
-
module$1.exports = realpath
|
|
26760
|
-
realpath
|
|
26761
|
-
realpath
|
|
26762
|
-
realpath
|
|
26763
|
-
realpath
|
|
26764
|
-
realpath
|
|
26765
|
+
module$1.exports = realpath;
|
|
26766
|
+
realpath.realpath = realpath;
|
|
26767
|
+
realpath.sync = realpathSync;
|
|
26768
|
+
realpath.realpathSync = realpathSync;
|
|
26769
|
+
realpath.monkeypatch = monkeypatch;
|
|
26770
|
+
realpath.unmonkeypatch = unmonkeypatch;
|
|
26765
26771
|
var fs11 = __require("fs");
|
|
26766
26772
|
var origRealpath = fs11.realpath;
|
|
26767
26773
|
var origRealpathSync = fs11.realpathSync;
|
|
@@ -26771,7 +26777,7 @@ var require_fs = __commonJS({ "../node_modules/.pnpm/fs.realpath@1.0.0/node_modu
|
|
|
26771
26777
|
function newError(er$1) {
|
|
26772
26778
|
return er$1 && er$1.syscall === "realpath" && (er$1.code === "ELOOP" || er$1.code === "ENOMEM" || er$1.code === "ENAMETOOLONG");
|
|
26773
26779
|
}
|
|
26774
|
-
function realpath
|
|
26780
|
+
function realpath(p6, cache6, cb) {
|
|
26775
26781
|
if (ok) return origRealpath(p6, cache6, cb);
|
|
26776
26782
|
if (typeof cache6 === "function") {
|
|
26777
26783
|
cb = cache6;
|
|
@@ -26792,7 +26798,7 @@ var require_fs = __commonJS({ "../node_modules/.pnpm/fs.realpath@1.0.0/node_modu
|
|
|
26792
26798
|
}
|
|
26793
26799
|
}
|
|
26794
26800
|
function monkeypatch() {
|
|
26795
|
-
fs11.realpath = realpath
|
|
26801
|
+
fs11.realpath = realpath;
|
|
26796
26802
|
fs11.realpathSync = realpathSync;
|
|
26797
26803
|
}
|
|
26798
26804
|
function unmonkeypatch() {
|
|
@@ -102303,7 +102309,7 @@ var init_open = __esm({ "../node_modules/.pnpm/open@10.2.0/node_modules/open/ind
|
|
|
102303
102309
|
init_default_browser();
|
|
102304
102310
|
init_is_inside_container();
|
|
102305
102311
|
execFile5 = promisify$1(childProcess$1.execFile);
|
|
102306
|
-
__dirname2 = path2.dirname(fileURLToPath(import.meta.url));
|
|
102312
|
+
__dirname2 = path2.dirname(fileURLToPath$1(import.meta.url));
|
|
102307
102313
|
localXdgOpenPath = path2.join(__dirname2, "xdg-open");
|
|
102308
102314
|
({platform: platform2, arch} = process2);
|
|
102309
102315
|
pTryEach = async (array2, mapper) => {
|
|
@@ -147021,7 +147027,7 @@ var preview_default = defineCommand({
|
|
|
147021
147027
|
|
|
147022
147028
|
//#endregion
|
|
147023
147029
|
//#region package.json
|
|
147024
|
-
var version = "0.3.
|
|
147030
|
+
var version = "0.3.20-0";
|
|
147025
147031
|
|
|
147026
147032
|
//#endregion
|
|
147027
147033
|
//#region src/cli/commands/repl.ts
|