@perceo/perceo 0.3.2 → 0.3.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js
CHANGED
|
@@ -2,10 +2,11 @@
|
|
|
2
2
|
import {
|
|
3
3
|
clearStoredAuth,
|
|
4
4
|
getEffectiveAuth,
|
|
5
|
+
getGlobalConfigDir,
|
|
5
6
|
getStoredAuth,
|
|
6
7
|
isLoggedIn,
|
|
7
8
|
loginCommand
|
|
8
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-WLYZQC65.js";
|
|
9
10
|
|
|
10
11
|
// src/index.ts
|
|
11
12
|
import { Command as Command6 } from "commander";
|
|
@@ -1270,7 +1271,7 @@ async function requireReauth(projectDir) {
|
|
|
1270
1271
|
}
|
|
1271
1272
|
console.log(chalk5.cyan("\nPlease log in again:"));
|
|
1272
1273
|
try {
|
|
1273
|
-
const { loginCommand: loginCommand2 } = await import("./login-
|
|
1274
|
+
const { loginCommand: loginCommand2 } = await import("./login-4TG7LXUP.js");
|
|
1274
1275
|
await loginCommand2.parseAsync(["login", "--scope", "global"], { from: "user" });
|
|
1275
1276
|
return true;
|
|
1276
1277
|
} catch (error) {
|
|
@@ -1786,6 +1787,94 @@ function formatDate(dateStr) {
|
|
|
1786
1787
|
});
|
|
1787
1788
|
}
|
|
1788
1789
|
|
|
1790
|
+
// src/publicEnv.ts
|
|
1791
|
+
import { readFileSync } from "fs";
|
|
1792
|
+
import fs4 from "fs/promises";
|
|
1793
|
+
import path7 from "path";
|
|
1794
|
+
import { fileURLToPath } from "url";
|
|
1795
|
+
var PUBLIC_ENV_FILE = "public-env.json";
|
|
1796
|
+
var PERCEO_CLOUD_SUPABASE_URL = "https://lygslnolucoidnhaitdn.supabase.co";
|
|
1797
|
+
function getPublicEnvPath() {
|
|
1798
|
+
return path7.join(getGlobalConfigDir(), PUBLIC_ENV_FILE);
|
|
1799
|
+
}
|
|
1800
|
+
function getCliVersion() {
|
|
1801
|
+
try {
|
|
1802
|
+
const dir = path7.dirname(fileURLToPath(import.meta.url));
|
|
1803
|
+
const pkgPath = path7.join(dir, "..", "package.json");
|
|
1804
|
+
const raw = readFileSync(pkgPath, "utf8");
|
|
1805
|
+
const pkg = JSON.parse(raw);
|
|
1806
|
+
return typeof pkg.version === "string" ? pkg.version : "0.0.0";
|
|
1807
|
+
} catch {
|
|
1808
|
+
return "0.0.0";
|
|
1809
|
+
}
|
|
1810
|
+
}
|
|
1811
|
+
async function fileExists4(p) {
|
|
1812
|
+
try {
|
|
1813
|
+
await fs4.access(p);
|
|
1814
|
+
return true;
|
|
1815
|
+
} catch {
|
|
1816
|
+
return false;
|
|
1817
|
+
}
|
|
1818
|
+
}
|
|
1819
|
+
async function readCache(cachePath) {
|
|
1820
|
+
if (!await fileExists4(cachePath)) return null;
|
|
1821
|
+
try {
|
|
1822
|
+
const raw = await fs4.readFile(cachePath, "utf8");
|
|
1823
|
+
const data = JSON.parse(raw);
|
|
1824
|
+
if (!data || typeof data._meta !== "object" || typeof data._meta?.cliVersion !== "string") return null;
|
|
1825
|
+
return data;
|
|
1826
|
+
} catch {
|
|
1827
|
+
return null;
|
|
1828
|
+
}
|
|
1829
|
+
}
|
|
1830
|
+
function applyToProcessEnv(env) {
|
|
1831
|
+
for (const [key, value] of Object.entries(env)) {
|
|
1832
|
+
if (key === "_meta" || typeof value !== "string") continue;
|
|
1833
|
+
if (process.env[key] === void 0) {
|
|
1834
|
+
process.env[key] = value;
|
|
1835
|
+
}
|
|
1836
|
+
}
|
|
1837
|
+
}
|
|
1838
|
+
async function fetchPublicEnv(supabaseUrl) {
|
|
1839
|
+
const url = `${supabaseUrl.replace(/\/$/, "")}/functions/v1/get-public-env`;
|
|
1840
|
+
const res = await fetch(url);
|
|
1841
|
+
if (!res.ok) {
|
|
1842
|
+
throw new Error(`get-public-env failed: ${res.status} ${res.statusText}`);
|
|
1843
|
+
}
|
|
1844
|
+
const data = await res.json();
|
|
1845
|
+
if (data == null || typeof data !== "object") {
|
|
1846
|
+
throw new Error("get-public-env returned invalid JSON");
|
|
1847
|
+
}
|
|
1848
|
+
return data;
|
|
1849
|
+
}
|
|
1850
|
+
async function ensurePublicEnvLoaded() {
|
|
1851
|
+
if (process.env.PERCEO_SUPABASE_URL) {
|
|
1852
|
+
return;
|
|
1853
|
+
}
|
|
1854
|
+
const supabaseUrl = PERCEO_CLOUD_SUPABASE_URL;
|
|
1855
|
+
const cachePath = getPublicEnvPath();
|
|
1856
|
+
const currentVersion = getCliVersion();
|
|
1857
|
+
const cached = await readCache(cachePath);
|
|
1858
|
+
if (cached && cached._meta.cliVersion === currentVersion) {
|
|
1859
|
+
applyToProcessEnv(cached);
|
|
1860
|
+
return;
|
|
1861
|
+
}
|
|
1862
|
+
try {
|
|
1863
|
+
const env = await fetchPublicEnv(supabaseUrl);
|
|
1864
|
+
const toWrite = {
|
|
1865
|
+
_meta: { fetchedAt: (/* @__PURE__ */ new Date()).toISOString(), cliVersion: currentVersion },
|
|
1866
|
+
...env
|
|
1867
|
+
};
|
|
1868
|
+
await fs4.mkdir(path7.dirname(cachePath), { recursive: true });
|
|
1869
|
+
await fs4.writeFile(cachePath, JSON.stringify(toWrite, null, 2) + "\n", "utf8");
|
|
1870
|
+
applyToProcessEnv(env);
|
|
1871
|
+
} catch {
|
|
1872
|
+
if (cached) {
|
|
1873
|
+
applyToProcessEnv(cached);
|
|
1874
|
+
}
|
|
1875
|
+
}
|
|
1876
|
+
}
|
|
1877
|
+
|
|
1789
1878
|
// src/index.ts
|
|
1790
1879
|
var originalEmit = process.emit.bind(process);
|
|
1791
1880
|
process.emit = function(event, ...args) {
|
|
@@ -1796,11 +1885,18 @@ process.emit = function(event, ...args) {
|
|
|
1796
1885
|
return originalEmit.apply(process, [event, ...args]);
|
|
1797
1886
|
};
|
|
1798
1887
|
var program = new Command6();
|
|
1799
|
-
program.name("perceo").description("Intelligent regression testing through multi-agent simulation").version(
|
|
1888
|
+
program.name("perceo").description("Intelligent regression testing through multi-agent simulation").version(getCliVersion());
|
|
1800
1889
|
program.addCommand(loginCommand);
|
|
1801
1890
|
program.addCommand(logoutCommand);
|
|
1802
1891
|
program.addCommand(initCommand);
|
|
1803
1892
|
program.addCommand(delCommand);
|
|
1804
1893
|
program.addCommand(analyzeCommand);
|
|
1805
1894
|
program.addCommand(keysCommand);
|
|
1806
|
-
|
|
1895
|
+
async function main() {
|
|
1896
|
+
await ensurePublicEnvLoaded();
|
|
1897
|
+
await program.parseAsync();
|
|
1898
|
+
}
|
|
1899
|
+
main().catch((err) => {
|
|
1900
|
+
console.error(err instanceof Error ? err.message : err);
|
|
1901
|
+
process.exit(1);
|
|
1902
|
+
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@perceo/perceo",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.3",
|
|
4
4
|
"description": "Intelligent regression testing through multi-agent simulation",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"testing",
|
|
@@ -37,8 +37,8 @@
|
|
|
37
37
|
"commander": "^12.0.0",
|
|
38
38
|
"ora": "^8.0.1",
|
|
39
39
|
"tweetnacl": "^1.0.3",
|
|
40
|
-
"@perceo/observer-engine": "2.0.
|
|
41
|
-
"@perceo/supabase": "0.2.
|
|
40
|
+
"@perceo/observer-engine": "2.0.3",
|
|
41
|
+
"@perceo/supabase": "0.2.2"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
44
|
"@changesets/cli": "^2.29.8",
|