@stackable-labs/cli-app-extension 1.95.0 → 1.96.1
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 +91 -28
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -98,14 +98,14 @@ var gradientColor = (row, col, rows, cols) => {
|
|
|
98
98
|
const hi = Math.min(lo + 1, COLORS.length - 1);
|
|
99
99
|
return lerp(COLORS[lo], COLORS[hi], idx - lo);
|
|
100
100
|
};
|
|
101
|
-
var Banner = ({ userId, orgId } = {}) => {
|
|
101
|
+
var Banner = ({ userId, orgId, appName, appId } = {}) => {
|
|
102
102
|
const termWidth = process.stdout.columns ?? 80;
|
|
103
103
|
const maxLen = Math.max(...WORDMARK.map((l) => l.length));
|
|
104
104
|
return /* @__PURE__ */ jsxs(Box, { flexDirection: "column", children: [
|
|
105
105
|
/* @__PURE__ */ jsx(Text, { dimColor: true, children: "\u2500".repeat(termWidth) }),
|
|
106
106
|
/* @__PURE__ */ jsxs(Box, { flexDirection: "column", paddingX: 1, paddingY: 1, children: [
|
|
107
107
|
WORDMARK.map((line, row) => /* @__PURE__ */ jsx(Box, { children: line.split("").map((ch, col) => /* @__PURE__ */ jsx(Text, { bold: true, color: ch === " " ? void 0 : gradientColor(row, col, WORDMARK.length, maxLen), children: ch }, col)) }, row)),
|
|
108
|
-
userId && orgId && /* @__PURE__ */ jsxs(Box, {
|
|
108
|
+
userId && orgId && /* @__PURE__ */ jsxs(Box, { flexDirection: "column", marginTop: 1, children: [
|
|
109
109
|
/* @__PURE__ */ jsxs(Box, { gap: 1, children: [
|
|
110
110
|
/* @__PURE__ */ jsx(Text, { dimColor: true, children: "User:" }),
|
|
111
111
|
/* @__PURE__ */ jsx(Text, { color: "cyan", children: userId })
|
|
@@ -113,6 +113,15 @@ var Banner = ({ userId, orgId } = {}) => {
|
|
|
113
113
|
/* @__PURE__ */ jsxs(Box, { gap: 1, children: [
|
|
114
114
|
/* @__PURE__ */ jsx(Text, { dimColor: true, children: "Org:" }),
|
|
115
115
|
/* @__PURE__ */ jsx(Text, { color: "cyan", children: orgId })
|
|
116
|
+
] }),
|
|
117
|
+
appId && /* @__PURE__ */ jsxs(Box, { gap: 1, children: [
|
|
118
|
+
/* @__PURE__ */ jsx(Text, { dimColor: true, children: "App:" }),
|
|
119
|
+
/* @__PURE__ */ jsx(Text, { color: "cyan", children: appId }),
|
|
120
|
+
appName && /* @__PURE__ */ jsxs(Text, { dimColor: true, children: [
|
|
121
|
+
"(",
|
|
122
|
+
appName,
|
|
123
|
+
")"
|
|
124
|
+
] })
|
|
116
125
|
] })
|
|
117
126
|
] })
|
|
118
127
|
] })
|
|
@@ -605,6 +614,40 @@ var SettingsPrompt = ({ defaultDir, onSubmit, onBack }) => {
|
|
|
605
614
|
);
|
|
606
615
|
};
|
|
607
616
|
|
|
617
|
+
// ../../lib/contracts/src/base.ts
|
|
618
|
+
var asClerkUserId = (value) => value;
|
|
619
|
+
var asClerkOrgId = (value) => value;
|
|
620
|
+
|
|
621
|
+
// ../../lib/contracts/src/permissions.ts
|
|
622
|
+
var SUPER_ROLE = {
|
|
623
|
+
ADMIN: "org:super_admin"
|
|
624
|
+
};
|
|
625
|
+
var ORG_ROLE = {
|
|
626
|
+
ADMIN: "org:admin",
|
|
627
|
+
OWNER: "org:owner"};
|
|
628
|
+
var EDITOR_ROLES = [
|
|
629
|
+
SUPER_ROLE.ADMIN,
|
|
630
|
+
ORG_ROLE.ADMIN,
|
|
631
|
+
ORG_ROLE.OWNER
|
|
632
|
+
];
|
|
633
|
+
[
|
|
634
|
+
...Object.values(SUPER_ROLE),
|
|
635
|
+
...Object.values(EDITOR_ROLES)
|
|
636
|
+
];
|
|
637
|
+
|
|
638
|
+
// ../../lib/contracts/src/fields.ts
|
|
639
|
+
var FIELD_TYPE = {
|
|
640
|
+
TEXTAREA: "textarea",
|
|
641
|
+
TEXT: "text",
|
|
642
|
+
EMAIL: "email"};
|
|
643
|
+
var SECUREABLE_FIELD_TYPE = {
|
|
644
|
+
TEXT: FIELD_TYPE.TEXT,
|
|
645
|
+
TEXTAREA: FIELD_TYPE.TEXTAREA,
|
|
646
|
+
EMAIL: FIELD_TYPE.EMAIL
|
|
647
|
+
};
|
|
648
|
+
var typeAllowsSecret = (fieldType) => Object.values(SECUREABLE_FIELD_TYPE).includes(fieldType);
|
|
649
|
+
var allowsSecret = (field) => typeAllowsSecret(field.type);
|
|
650
|
+
|
|
608
651
|
// src/lib/manifest-diff.ts
|
|
609
652
|
var diffItems = (previous, next, getKey) => {
|
|
610
653
|
const prevMap = new Map(previous.map((item) => [getKey(item), item]));
|
|
@@ -744,15 +787,17 @@ var ManifestReviewPrompt = ({
|
|
|
744
787
|
const globalIndex = schemaSectionStart + index;
|
|
745
788
|
const isCursor = globalIndex === cursor;
|
|
746
789
|
const field = item.after ?? item.before;
|
|
747
|
-
const detail = field ? `${field.type}${field.secret ? ", secret" : ""}` : "";
|
|
790
|
+
const detail = field ? `${field.type}${allowsSecret(field) && field.secret ? ", secret" : ""}` : "";
|
|
748
791
|
let changeDetail;
|
|
749
792
|
if (item.status === "changed" && item.before && item.after) {
|
|
750
793
|
const parts = [];
|
|
751
794
|
if (item.before.type !== item.after.type) {
|
|
752
795
|
parts.push(`type ${item.before.type} \u2192 ${item.after.type}`);
|
|
753
796
|
}
|
|
754
|
-
|
|
755
|
-
|
|
797
|
+
const beforeSecret = allowsSecret(item.before) ? item.before.secret : void 0;
|
|
798
|
+
const afterSecret = allowsSecret(item.after) ? item.after.secret : void 0;
|
|
799
|
+
if (beforeSecret !== afterSecret) {
|
|
800
|
+
parts.push(`secret ${!!beforeSecret} \u2192 ${!!afterSecret}`);
|
|
756
801
|
}
|
|
757
802
|
if (item.before.label !== item.after.label) {
|
|
758
803
|
parts.push(`label "${item.before.label}" \u2192 "${item.after.label}"`);
|
|
@@ -1167,27 +1212,6 @@ var TemplateSelect = ({ onSubmit, onBack }) => {
|
|
|
1167
1212
|
);
|
|
1168
1213
|
};
|
|
1169
1214
|
|
|
1170
|
-
// ../../lib/contracts/src/base.ts
|
|
1171
|
-
var asClerkUserId = (value) => value;
|
|
1172
|
-
var asClerkOrgId = (value) => value;
|
|
1173
|
-
|
|
1174
|
-
// ../../lib/contracts/src/permissions.ts
|
|
1175
|
-
var SUPER_ROLE = {
|
|
1176
|
-
ADMIN: "org:super_admin"
|
|
1177
|
-
};
|
|
1178
|
-
var ORG_ROLE = {
|
|
1179
|
-
ADMIN: "org:admin",
|
|
1180
|
-
OWNER: "org:owner"};
|
|
1181
|
-
var EDITOR_ROLES = [
|
|
1182
|
-
SUPER_ROLE.ADMIN,
|
|
1183
|
-
ORG_ROLE.ADMIN,
|
|
1184
|
-
ORG_ROLE.OWNER
|
|
1185
|
-
];
|
|
1186
|
-
[
|
|
1187
|
-
...Object.values(SUPER_ROLE),
|
|
1188
|
-
...Object.values(EDITOR_ROLES)
|
|
1189
|
-
];
|
|
1190
|
-
|
|
1191
1215
|
// ../../lib/utils-auth/src/constants.ts
|
|
1192
1216
|
var STANDALONE_CLIENT_DATA = {
|
|
1193
1217
|
CLI: { name: "@stackable-labs/cli-app-extension", authFile: "cli-auth.json" },
|
|
@@ -1383,16 +1407,26 @@ var updateExtension = async (token, appId, extensionId, payload) => {
|
|
|
1383
1407
|
throw new Error(`Failed to update extension: ${res.status} ${body}`);
|
|
1384
1408
|
}
|
|
1385
1409
|
};
|
|
1410
|
+
var AUTO_SELECT_DELAY_MS = 600;
|
|
1386
1411
|
var AppSelect = ({ token, userId, orgId, onSubmit }) => {
|
|
1387
1412
|
const [apps, setApps] = useState([]);
|
|
1388
1413
|
const [loading, setLoading] = useState(true);
|
|
1389
1414
|
const [error, setError] = useState();
|
|
1390
1415
|
const [cursor, setCursor] = useState(0);
|
|
1416
|
+
const autoSubmittedRef = useRef(false);
|
|
1391
1417
|
useEffect(() => {
|
|
1392
1418
|
fetchApps(token).then(setApps).catch((err) => setError(err instanceof Error ? err.message : String(err))).finally(() => setLoading(false));
|
|
1393
1419
|
}, [token]);
|
|
1420
|
+
useEffect(() => {
|
|
1421
|
+
if (loading || error || autoSubmittedRef.current || apps.length !== 1) {
|
|
1422
|
+
return;
|
|
1423
|
+
}
|
|
1424
|
+
autoSubmittedRef.current = true;
|
|
1425
|
+
const timer = setTimeout(() => onSubmit(apps[0]), AUTO_SELECT_DELAY_MS);
|
|
1426
|
+
return () => clearTimeout(timer);
|
|
1427
|
+
}, [loading, error, apps, onSubmit]);
|
|
1394
1428
|
useInput((_, key) => {
|
|
1395
|
-
if (loading || error || apps.length
|
|
1429
|
+
if (loading || error || apps.length <= 1) {
|
|
1396
1430
|
return;
|
|
1397
1431
|
}
|
|
1398
1432
|
if (key.upArrow) {
|
|
@@ -1403,6 +1437,7 @@ var AppSelect = ({ token, userId, orgId, onSubmit }) => {
|
|
|
1403
1437
|
onSubmit(apps[cursor]);
|
|
1404
1438
|
}
|
|
1405
1439
|
});
|
|
1440
|
+
const defaultApp = !loading && !error && apps.length === 1 ? apps[0] : void 0;
|
|
1406
1441
|
const renderContent = () => {
|
|
1407
1442
|
if (loading) {
|
|
1408
1443
|
return /* @__PURE__ */ jsxs(Box, { gap: 2, children: [
|
|
@@ -1432,6 +1467,26 @@ var AppSelect = ({ token, userId, orgId, onSubmit }) => {
|
|
|
1432
1467
|
] }, app.id);
|
|
1433
1468
|
}) });
|
|
1434
1469
|
};
|
|
1470
|
+
if (defaultApp) {
|
|
1471
|
+
return /* @__PURE__ */ jsxs(Box, { flexDirection: "column", children: [
|
|
1472
|
+
/* @__PURE__ */ jsx(Banner, { userId, orgId, appName: defaultApp.name, appId: defaultApp.id }),
|
|
1473
|
+
/* @__PURE__ */ jsxs(Box, { flexDirection: "column", paddingX: 2, paddingY: 1, gap: 1, children: [
|
|
1474
|
+
/* @__PURE__ */ jsxs(Box, { gap: 1, children: [
|
|
1475
|
+
/* @__PURE__ */ jsx(Text, { color: "green", children: "\u2713" }),
|
|
1476
|
+
/* @__PURE__ */ jsxs(Text, { children: [
|
|
1477
|
+
"Using ",
|
|
1478
|
+
/* @__PURE__ */ jsx(Text, { bold: true, color: "cyan", children: defaultApp.name })
|
|
1479
|
+
] }),
|
|
1480
|
+
/* @__PURE__ */ jsxs(Text, { dimColor: true, children: [
|
|
1481
|
+
"(",
|
|
1482
|
+
defaultApp.id,
|
|
1483
|
+
")"
|
|
1484
|
+
] })
|
|
1485
|
+
] }),
|
|
1486
|
+
/* @__PURE__ */ jsx(Text, { dimColor: true, children: "Auto-selected \u2014 only one App available." })
|
|
1487
|
+
] })
|
|
1488
|
+
] });
|
|
1489
|
+
}
|
|
1435
1490
|
return /* @__PURE__ */ jsxs(Box, { flexDirection: "column", children: [
|
|
1436
1491
|
/* @__PURE__ */ jsx(Banner, { userId, orgId }),
|
|
1437
1492
|
/* @__PURE__ */ jsx(StepShell, { title: "Select the App you are building an Extension for:", children: renderContent() })
|
|
@@ -2601,7 +2656,15 @@ var App = ({ command, token, userId, orgId, initialName, initialExtensionId, opt
|
|
|
2601
2656
|
case "app": {
|
|
2602
2657
|
if (options?.appId || initialExtensionId && (command === "update" /* UPDATE */ || command === "scaffold" /* SCAFFOLD */)) {
|
|
2603
2658
|
return /* @__PURE__ */ jsxs(Box, { flexDirection: "column", children: [
|
|
2604
|
-
/* @__PURE__ */ jsx(
|
|
2659
|
+
/* @__PURE__ */ jsx(
|
|
2660
|
+
Banner,
|
|
2661
|
+
{
|
|
2662
|
+
userId,
|
|
2663
|
+
orgId,
|
|
2664
|
+
appId: selectedApp?.id,
|
|
2665
|
+
appName: selectedApp?.name
|
|
2666
|
+
}
|
|
2667
|
+
),
|
|
2605
2668
|
/* @__PURE__ */ jsx(StepShell, { title: "Loading App\u2026", children: /* @__PURE__ */ jsxs(Box, { gap: 2, children: [
|
|
2606
2669
|
/* @__PURE__ */ jsx(Spinner5, { type: "dots" }),
|
|
2607
2670
|
/* @__PURE__ */ jsx(Text, { children: options?.appId ? "Fetching app details\u2026" : "Resolving app from extension\u2026" })
|