@kenkaiiii/gg-pixel 4.3.83 → 4.3.85

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.cjs CHANGED
@@ -491,8 +491,8 @@ async function install(opts = {}) {
491
491
  const existingKey = readEnvKey(envFilePath, "GG_PIXEL_KEY");
492
492
  let created;
493
493
  let reused = false;
494
- if (existing && existingKey) {
495
- created = { id: existing.id, key: existingKey };
494
+ if (existing && existing.secret && existingKey) {
495
+ created = { id: existing.id, key: existingKey, secret: existing.secret };
496
496
  reused = true;
497
497
  } else {
498
498
  created = await createProject(fetchFn, ingestUrl, projectName);
@@ -509,10 +509,11 @@ async function install(opts = {}) {
509
509
  if (kind !== "browser" && kind !== "tauri") {
510
510
  writeEnvKey(envFilePath, "GG_PIXEL_KEY", created.key);
511
511
  }
512
- writeProjectsMapping(projectsJsonPath, created.id, projectName, nodeRoot);
512
+ writeProjectsMapping(projectsJsonPath, created.id, projectName, nodeRoot, created.secret);
513
513
  return {
514
514
  projectId: created.id,
515
515
  projectKey: created.key,
516
+ projectSecret: created.secret,
516
517
  projectName,
517
518
  projectKind: kind,
518
519
  initFilePath: wired.primaryInitPath,
@@ -569,8 +570,10 @@ async function createProject(fetchFn, ingestUrl, name) {
569
570
  throw new Error(`POST /api/projects failed: ${res.status} ${await safeText(res)}`);
570
571
  }
571
572
  const body = await res.json();
572
- if (!body.id || !body.key) throw new Error("response missing id/key");
573
- return { id: body.id, key: body.key };
573
+ if (!body.id || !body.key || !body.secret) {
574
+ throw new Error("response missing id/key/secret");
575
+ }
576
+ return { id: body.id, key: body.key, secret: body.secret };
574
577
  }
575
578
  async function safeText(r) {
576
579
  try {
@@ -916,7 +919,10 @@ function injectNextClientComponent(layoutPath, clientInitPath) {
916
919
  const childrenIdx = updated.lastIndexOf("{children}");
917
920
  if (childrenIdx === -1) {
918
921
  (0, import_node_fs3.writeFileSync)(layoutPath, updated, "utf8");
919
- return { kind: "skipped", reason: "added import but couldn't find {children} to render <GGPixelClient />" };
922
+ return {
923
+ kind: "skipped",
924
+ reason: "added import but couldn't find {children} to render <GGPixelClient />"
925
+ };
920
926
  }
921
927
  const before = updated.slice(0, childrenIdx);
922
928
  const after = updated.slice(childrenIdx);
@@ -1473,8 +1479,8 @@ async function installGo(ctx) {
1473
1479
  const existingKey = readEnvKey(envFilePath, "GG_PIXEL_KEY");
1474
1480
  let created;
1475
1481
  let reused = false;
1476
- if (existing && existingKey) {
1477
- created = { id: existing.id, key: existingKey };
1482
+ if (existing && existing.secret && existingKey) {
1483
+ created = { id: existing.id, key: existingKey, secret: existing.secret };
1478
1484
  reused = true;
1479
1485
  } else {
1480
1486
  created = await createProject(fetchFn, ingestUrl, projectName);
@@ -1502,10 +1508,11 @@ func init() {
1502
1508
  "utf8"
1503
1509
  );
1504
1510
  writeEnvKey(envFilePath, "GG_PIXEL_KEY", created.key);
1505
- writeProjectsMapping(projectsJsonPath, created.id, projectName, projectRoot);
1511
+ writeProjectsMapping(projectsJsonPath, created.id, projectName, projectRoot, created.secret);
1506
1512
  return {
1507
1513
  projectId: created.id,
1508
1514
  projectKey: created.key,
1515
+ projectSecret: created.secret,
1509
1516
  projectName,
1510
1517
  projectKind: "go",
1511
1518
  initFilePath,
@@ -1546,8 +1553,8 @@ async function installRuby(ctx) {
1546
1553
  const existingKey = readEnvKey(envFilePath, "GG_PIXEL_KEY");
1547
1554
  let created;
1548
1555
  let reused = false;
1549
- if (existing && existingKey) {
1550
- created = { id: existing.id, key: existingKey };
1556
+ if (existing && existing.secret && existingKey) {
1557
+ created = { id: existing.id, key: existingKey, secret: existing.secret };
1551
1558
  reused = true;
1552
1559
  } else {
1553
1560
  created = await createProject(fetchFn, ingestUrl, projectName);
@@ -1566,10 +1573,11 @@ GGPixel.init(
1566
1573
  "utf8"
1567
1574
  );
1568
1575
  writeEnvKey(envFilePath, "GG_PIXEL_KEY", created.key);
1569
- writeProjectsMapping(projectsJsonPath, created.id, projectName, projectRoot);
1576
+ writeProjectsMapping(projectsJsonPath, created.id, projectName, projectRoot, created.secret);
1570
1577
  return {
1571
1578
  projectId: created.id,
1572
1579
  projectKey: created.key,
1580
+ projectSecret: created.secret,
1573
1581
  projectName,
1574
1582
  projectKind: "ruby",
1575
1583
  initFilePath,
@@ -1622,8 +1630,8 @@ async function installPython(ctx) {
1622
1630
  const existingKey = readEnvKey(envFilePath, "GG_PIXEL_KEY");
1623
1631
  let created;
1624
1632
  let reused = false;
1625
- if (existing && existingKey) {
1626
- created = { id: existing.id, key: existingKey };
1633
+ if (existing && existing.secret && existingKey) {
1634
+ created = { id: existing.id, key: existingKey, secret: existing.secret };
1627
1635
  reused = true;
1628
1636
  } else {
1629
1637
  created = await createProject(fetchFn, ingestUrl, projectName);
@@ -1633,11 +1641,12 @@ async function installPython(ctx) {
1633
1641
  const initFilePath = (0, import_node_path2.join)(projectRoot, "gg_pixel_init.py");
1634
1642
  (0, import_node_fs3.writeFileSync)(initFilePath, renderPythonInitFile(ingestUrl, created.key), "utf8");
1635
1643
  writeEnvKey(envFilePath, "GG_PIXEL_KEY", created.key);
1636
- writeProjectsMapping(projectsJsonPath, created.id, projectName, projectRoot);
1644
+ writeProjectsMapping(projectsJsonPath, created.id, projectName, projectRoot, created.secret);
1637
1645
  const entryWiring = wirePythonEntry(projectRoot, initFilePath);
1638
1646
  return {
1639
1647
  projectId: created.id,
1640
1648
  projectKey: created.key,
1649
+ projectSecret: created.secret,
1641
1650
  projectName,
1642
1651
  projectKind: "python",
1643
1652
  initFilePath,
@@ -1755,7 +1764,7 @@ function findPythonEntryFile(projectRoot) {
1755
1764
  }
1756
1765
  return null;
1757
1766
  }
1758
- function writeProjectsMapping(projectsJsonPath, projectId, name, path) {
1767
+ function writeProjectsMapping(projectsJsonPath, projectId, name, path, secret) {
1759
1768
  (0, import_node_fs3.mkdirSync)((0, import_node_path2.dirname)(projectsJsonPath), { recursive: true });
1760
1769
  let map = {};
1761
1770
  if ((0, import_node_fs3.existsSync)(projectsJsonPath)) {
@@ -1764,7 +1773,9 @@ function writeProjectsMapping(projectsJsonPath, projectId, name, path) {
1764
1773
  } catch {
1765
1774
  }
1766
1775
  }
1767
- map[projectId] = { name, path };
1776
+ const entry = { name, path };
1777
+ if (secret) entry.secret = secret;
1778
+ map[projectId] = entry;
1768
1779
  (0, import_node_fs3.writeFileSync)(projectsJsonPath, `${JSON.stringify(map, null, 2)}
1769
1780
  `, "utf8");
1770
1781
  }