@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/cli.js +28 -17
- package/dist/cli.js.map +1 -1
- package/dist/index.cjs +28 -17
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +6 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +28 -17
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -74,6 +74,12 @@ interface InstallOptions {
|
|
|
74
74
|
interface InstallResult {
|
|
75
75
|
projectId: string;
|
|
76
76
|
projectKey: string;
|
|
77
|
+
/**
|
|
78
|
+
* Per-project bearer secret returned by the server on creation. Stored in
|
|
79
|
+
* ~/.gg/projects.json and required for every /api/* call (read/list/patch/
|
|
80
|
+
* delete). Never leaves the user's machine — never inlined into source.
|
|
81
|
+
*/
|
|
82
|
+
projectSecret: string;
|
|
77
83
|
projectName: string;
|
|
78
84
|
projectKind: ProjectKind;
|
|
79
85
|
initFilePath: string;
|
package/dist/index.js
CHANGED
|
@@ -457,8 +457,8 @@ async function install(opts = {}) {
|
|
|
457
457
|
const existingKey = readEnvKey(envFilePath, "GG_PIXEL_KEY");
|
|
458
458
|
let created;
|
|
459
459
|
let reused = false;
|
|
460
|
-
if (existing && existingKey) {
|
|
461
|
-
created = { id: existing.id, key: existingKey };
|
|
460
|
+
if (existing && existing.secret && existingKey) {
|
|
461
|
+
created = { id: existing.id, key: existingKey, secret: existing.secret };
|
|
462
462
|
reused = true;
|
|
463
463
|
} else {
|
|
464
464
|
created = await createProject(fetchFn, ingestUrl, projectName);
|
|
@@ -475,10 +475,11 @@ async function install(opts = {}) {
|
|
|
475
475
|
if (kind !== "browser" && kind !== "tauri") {
|
|
476
476
|
writeEnvKey(envFilePath, "GG_PIXEL_KEY", created.key);
|
|
477
477
|
}
|
|
478
|
-
writeProjectsMapping(projectsJsonPath, created.id, projectName, nodeRoot);
|
|
478
|
+
writeProjectsMapping(projectsJsonPath, created.id, projectName, nodeRoot, created.secret);
|
|
479
479
|
return {
|
|
480
480
|
projectId: created.id,
|
|
481
481
|
projectKey: created.key,
|
|
482
|
+
projectSecret: created.secret,
|
|
482
483
|
projectName,
|
|
483
484
|
projectKind: kind,
|
|
484
485
|
initFilePath: wired.primaryInitPath,
|
|
@@ -535,8 +536,10 @@ async function createProject(fetchFn, ingestUrl, name) {
|
|
|
535
536
|
throw new Error(`POST /api/projects failed: ${res.status} ${await safeText(res)}`);
|
|
536
537
|
}
|
|
537
538
|
const body = await res.json();
|
|
538
|
-
if (!body.id || !body.key
|
|
539
|
-
|
|
539
|
+
if (!body.id || !body.key || !body.secret) {
|
|
540
|
+
throw new Error("response missing id/key/secret");
|
|
541
|
+
}
|
|
542
|
+
return { id: body.id, key: body.key, secret: body.secret };
|
|
540
543
|
}
|
|
541
544
|
async function safeText(r) {
|
|
542
545
|
try {
|
|
@@ -882,7 +885,10 @@ function injectNextClientComponent(layoutPath, clientInitPath) {
|
|
|
882
885
|
const childrenIdx = updated.lastIndexOf("{children}");
|
|
883
886
|
if (childrenIdx === -1) {
|
|
884
887
|
writeFileSync(layoutPath, updated, "utf8");
|
|
885
|
-
return {
|
|
888
|
+
return {
|
|
889
|
+
kind: "skipped",
|
|
890
|
+
reason: "added import but couldn't find {children} to render <GGPixelClient />"
|
|
891
|
+
};
|
|
886
892
|
}
|
|
887
893
|
const before = updated.slice(0, childrenIdx);
|
|
888
894
|
const after = updated.slice(childrenIdx);
|
|
@@ -1439,8 +1445,8 @@ async function installGo(ctx) {
|
|
|
1439
1445
|
const existingKey = readEnvKey(envFilePath, "GG_PIXEL_KEY");
|
|
1440
1446
|
let created;
|
|
1441
1447
|
let reused = false;
|
|
1442
|
-
if (existing && existingKey) {
|
|
1443
|
-
created = { id: existing.id, key: existingKey };
|
|
1448
|
+
if (existing && existing.secret && existingKey) {
|
|
1449
|
+
created = { id: existing.id, key: existingKey, secret: existing.secret };
|
|
1444
1450
|
reused = true;
|
|
1445
1451
|
} else {
|
|
1446
1452
|
created = await createProject(fetchFn, ingestUrl, projectName);
|
|
@@ -1468,10 +1474,11 @@ func init() {
|
|
|
1468
1474
|
"utf8"
|
|
1469
1475
|
);
|
|
1470
1476
|
writeEnvKey(envFilePath, "GG_PIXEL_KEY", created.key);
|
|
1471
|
-
writeProjectsMapping(projectsJsonPath, created.id, projectName, projectRoot);
|
|
1477
|
+
writeProjectsMapping(projectsJsonPath, created.id, projectName, projectRoot, created.secret);
|
|
1472
1478
|
return {
|
|
1473
1479
|
projectId: created.id,
|
|
1474
1480
|
projectKey: created.key,
|
|
1481
|
+
projectSecret: created.secret,
|
|
1475
1482
|
projectName,
|
|
1476
1483
|
projectKind: "go",
|
|
1477
1484
|
initFilePath,
|
|
@@ -1512,8 +1519,8 @@ async function installRuby(ctx) {
|
|
|
1512
1519
|
const existingKey = readEnvKey(envFilePath, "GG_PIXEL_KEY");
|
|
1513
1520
|
let created;
|
|
1514
1521
|
let reused = false;
|
|
1515
|
-
if (existing && existingKey) {
|
|
1516
|
-
created = { id: existing.id, key: existingKey };
|
|
1522
|
+
if (existing && existing.secret && existingKey) {
|
|
1523
|
+
created = { id: existing.id, key: existingKey, secret: existing.secret };
|
|
1517
1524
|
reused = true;
|
|
1518
1525
|
} else {
|
|
1519
1526
|
created = await createProject(fetchFn, ingestUrl, projectName);
|
|
@@ -1532,10 +1539,11 @@ GGPixel.init(
|
|
|
1532
1539
|
"utf8"
|
|
1533
1540
|
);
|
|
1534
1541
|
writeEnvKey(envFilePath, "GG_PIXEL_KEY", created.key);
|
|
1535
|
-
writeProjectsMapping(projectsJsonPath, created.id, projectName, projectRoot);
|
|
1542
|
+
writeProjectsMapping(projectsJsonPath, created.id, projectName, projectRoot, created.secret);
|
|
1536
1543
|
return {
|
|
1537
1544
|
projectId: created.id,
|
|
1538
1545
|
projectKey: created.key,
|
|
1546
|
+
projectSecret: created.secret,
|
|
1539
1547
|
projectName,
|
|
1540
1548
|
projectKind: "ruby",
|
|
1541
1549
|
initFilePath,
|
|
@@ -1588,8 +1596,8 @@ async function installPython(ctx) {
|
|
|
1588
1596
|
const existingKey = readEnvKey(envFilePath, "GG_PIXEL_KEY");
|
|
1589
1597
|
let created;
|
|
1590
1598
|
let reused = false;
|
|
1591
|
-
if (existing && existingKey) {
|
|
1592
|
-
created = { id: existing.id, key: existingKey };
|
|
1599
|
+
if (existing && existing.secret && existingKey) {
|
|
1600
|
+
created = { id: existing.id, key: existingKey, secret: existing.secret };
|
|
1593
1601
|
reused = true;
|
|
1594
1602
|
} else {
|
|
1595
1603
|
created = await createProject(fetchFn, ingestUrl, projectName);
|
|
@@ -1599,11 +1607,12 @@ async function installPython(ctx) {
|
|
|
1599
1607
|
const initFilePath = join2(projectRoot, "gg_pixel_init.py");
|
|
1600
1608
|
writeFileSync(initFilePath, renderPythonInitFile(ingestUrl, created.key), "utf8");
|
|
1601
1609
|
writeEnvKey(envFilePath, "GG_PIXEL_KEY", created.key);
|
|
1602
|
-
writeProjectsMapping(projectsJsonPath, created.id, projectName, projectRoot);
|
|
1610
|
+
writeProjectsMapping(projectsJsonPath, created.id, projectName, projectRoot, created.secret);
|
|
1603
1611
|
const entryWiring = wirePythonEntry(projectRoot, initFilePath);
|
|
1604
1612
|
return {
|
|
1605
1613
|
projectId: created.id,
|
|
1606
1614
|
projectKey: created.key,
|
|
1615
|
+
projectSecret: created.secret,
|
|
1607
1616
|
projectName,
|
|
1608
1617
|
projectKind: "python",
|
|
1609
1618
|
initFilePath,
|
|
@@ -1721,7 +1730,7 @@ function findPythonEntryFile(projectRoot) {
|
|
|
1721
1730
|
}
|
|
1722
1731
|
return null;
|
|
1723
1732
|
}
|
|
1724
|
-
function writeProjectsMapping(projectsJsonPath, projectId, name, path) {
|
|
1733
|
+
function writeProjectsMapping(projectsJsonPath, projectId, name, path, secret) {
|
|
1725
1734
|
mkdirSync2(dirname2(projectsJsonPath), { recursive: true });
|
|
1726
1735
|
let map = {};
|
|
1727
1736
|
if (existsSync2(projectsJsonPath)) {
|
|
@@ -1730,7 +1739,9 @@ function writeProjectsMapping(projectsJsonPath, projectId, name, path) {
|
|
|
1730
1739
|
} catch {
|
|
1731
1740
|
}
|
|
1732
1741
|
}
|
|
1733
|
-
|
|
1742
|
+
const entry = { name, path };
|
|
1743
|
+
if (secret) entry.secret = secret;
|
|
1744
|
+
map[projectId] = entry;
|
|
1734
1745
|
writeFileSync(projectsJsonPath, `${JSON.stringify(map, null, 2)}
|
|
1735
1746
|
`, "utf8");
|
|
1736
1747
|
}
|