@jtl-software/create-cloud-app 0.5.3 → 0.5.4
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 +67 -15
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -694,6 +694,29 @@ function detectFrontend(root) {
|
|
|
694
694
|
const frontendDir = path2.join(root, "packages", "frontend");
|
|
695
695
|
return fs2.existsSync(path2.join(frontendDir, "package.json")) ? frontendDir : null;
|
|
696
696
|
}
|
|
697
|
+
function readScaffoldStack(root) {
|
|
698
|
+
try {
|
|
699
|
+
const pkg = JSON.parse(
|
|
700
|
+
fs2.readFileSync(path2.join(root, "package.json"), "utf-8")
|
|
701
|
+
);
|
|
702
|
+
const meta = pkg.jtlCloudApp;
|
|
703
|
+
if (meta && typeof meta === "object") {
|
|
704
|
+
return {
|
|
705
|
+
backend: typeof meta.backend === "string" ? meta.backend : null,
|
|
706
|
+
frontend: typeof meta.frontend === "string" ? meta.frontend : null
|
|
707
|
+
};
|
|
708
|
+
}
|
|
709
|
+
} catch {
|
|
710
|
+
}
|
|
711
|
+
return null;
|
|
712
|
+
}
|
|
713
|
+
function environmentFromApi(api) {
|
|
714
|
+
const h = api.toLowerCase();
|
|
715
|
+
if (h.includes("api.qa.")) return "qa";
|
|
716
|
+
if (h.includes("api.dev.")) return "dev";
|
|
717
|
+
if (h.includes("api.jtl-cloud.com")) return "prod";
|
|
718
|
+
return "other";
|
|
719
|
+
}
|
|
697
720
|
function writeFrontendPublicClient(root, authIssuer, publicClientId) {
|
|
698
721
|
const frontendDir = detectFrontend(root);
|
|
699
722
|
if (!frontendDir) return null;
|
|
@@ -1120,6 +1143,18 @@ async function register(argv = [], runOpts = {}) {
|
|
|
1120
1143
|
}
|
|
1121
1144
|
const manifest = readManifest(path2.join(root, "app.json"));
|
|
1122
1145
|
const summary = summarizeManifest(manifest);
|
|
1146
|
+
const stack = readScaffoldStack(root);
|
|
1147
|
+
const auth = manifest.authentication;
|
|
1148
|
+
const hasFrontend = stack ? !!stack.frontend : !!auth?.publicClient;
|
|
1149
|
+
const hasBackend = stack ? !!stack.backend : !!auth?.serviceAccount;
|
|
1150
|
+
const registerTelemetry = {
|
|
1151
|
+
environment: environmentFromApi(opts.api),
|
|
1152
|
+
has_frontend: hasFrontend,
|
|
1153
|
+
has_backend: hasBackend,
|
|
1154
|
+
backend_tech: stack?.backend ?? (hasBackend ? "unknown" : "none"),
|
|
1155
|
+
frontend_tech: stack?.frontend ?? (hasFrontend ? "unknown" : "none"),
|
|
1156
|
+
composition: hasFrontend && hasBackend ? "both" : hasFrontend ? "frontend_only" : hasBackend ? "backend_only" : "none"
|
|
1157
|
+
};
|
|
1123
1158
|
for (; ; ) {
|
|
1124
1159
|
const identityJwt = jwt;
|
|
1125
1160
|
const apiJwt = apiTokenFor(jwt);
|
|
@@ -1234,7 +1269,7 @@ async function register(argv = [], runOpts = {}) {
|
|
|
1234
1269
|
provisioned,
|
|
1235
1270
|
existing.isInstalled ?? false
|
|
1236
1271
|
);
|
|
1237
|
-
return;
|
|
1272
|
+
return { ...registerTelemetry, is_new_app: false };
|
|
1238
1273
|
}
|
|
1239
1274
|
if (existing.publicClientId) {
|
|
1240
1275
|
const written = writeFrontendPublicClient(
|
|
@@ -1266,7 +1301,7 @@ async function register(argv = [], runOpts = {}) {
|
|
|
1266
1301
|
`Manifest updated. Your backend config is missing ${labels.pair} \u2014 they can't be recovered. Re-create the app to get a fresh secret.`
|
|
1267
1302
|
)
|
|
1268
1303
|
);
|
|
1269
|
-
return;
|
|
1304
|
+
return { ...registerTelemetry, is_new_app: false };
|
|
1270
1305
|
}
|
|
1271
1306
|
p2.outro(
|
|
1272
1307
|
pc2.green(
|
|
@@ -1276,7 +1311,7 @@ async function register(argv = [], runOpts = {}) {
|
|
|
1276
1311
|
} else {
|
|
1277
1312
|
p2.outro(pc2.green("Manifest updated."));
|
|
1278
1313
|
}
|
|
1279
|
-
return;
|
|
1314
|
+
return { ...registerTelemetry, is_new_app: false };
|
|
1280
1315
|
}
|
|
1281
1316
|
spinner4.start("Creating draft app");
|
|
1282
1317
|
let appId;
|
|
@@ -1319,7 +1354,7 @@ async function register(argv = [], runOpts = {}) {
|
|
|
1319
1354
|
{ clientId, clientSecret, publicClientId },
|
|
1320
1355
|
false
|
|
1321
1356
|
);
|
|
1322
|
-
return;
|
|
1357
|
+
return { ...registerTelemetry, is_new_app: true };
|
|
1323
1358
|
}
|
|
1324
1359
|
}
|
|
1325
1360
|
|
|
@@ -1612,6 +1647,12 @@ async function pickFrontendPort() {
|
|
|
1612
1647
|
}
|
|
1613
1648
|
return DEFAULT_FRONTEND_PORT;
|
|
1614
1649
|
}
|
|
1650
|
+
function templateTech(template) {
|
|
1651
|
+
const m = template.packageName.match(
|
|
1652
|
+
/cloud-app-template-(?:backend|frontend)-(.+)$/
|
|
1653
|
+
);
|
|
1654
|
+
return m?.[1] ?? template.packageName;
|
|
1655
|
+
}
|
|
1615
1656
|
function toPascalCase(kebab) {
|
|
1616
1657
|
return kebab.split("-").map((part) => part.charAt(0).toUpperCase() + part.slice(1)).join("");
|
|
1617
1658
|
}
|
|
@@ -1816,6 +1857,12 @@ async function scaffold({
|
|
|
1816
1857
|
packageManager: "npm@10.8.2",
|
|
1817
1858
|
devDependencies: {
|
|
1818
1859
|
turbo: "^2.5.5"
|
|
1860
|
+
},
|
|
1861
|
+
// The stack the developer picked, recorded so `register` can report it in telemetry without
|
|
1862
|
+
// guessing from the generated files.
|
|
1863
|
+
jtlCloudApp: {
|
|
1864
|
+
backend: backend ? templateTech(backend) : null,
|
|
1865
|
+
frontend: frontend ? templateTech(frontend) : null
|
|
1819
1866
|
}
|
|
1820
1867
|
};
|
|
1821
1868
|
fs4.writeFileSync(
|
|
@@ -1862,7 +1909,7 @@ import os2 from "os";
|
|
|
1862
1909
|
import path6 from "path";
|
|
1863
1910
|
import { PostHog } from "posthog-node";
|
|
1864
1911
|
var TOKEN = "phc_SkFAxTIa4RUQxotci1Ftdw7xefZK2Ax0LEIGcl8zuD2";
|
|
1865
|
-
var CLI_VERSION = "0.5.
|
|
1912
|
+
var CLI_VERSION = "0.5.4";
|
|
1866
1913
|
var client = TOKEN ? new PostHog(TOKEN, { host: "https://e.jtl-cloud.com" }) : null;
|
|
1867
1914
|
function telemetryDisabledByEnv() {
|
|
1868
1915
|
const dnt = process.env.DO_NOT_TRACK;
|
|
@@ -1931,6 +1978,18 @@ async function shutdownPostHog() {
|
|
|
1931
1978
|
|
|
1932
1979
|
// src/index.ts
|
|
1933
1980
|
var NONE = "__none__";
|
|
1981
|
+
function scaffoldChoice(backend, frontend, next) {
|
|
1982
|
+
const hasBackend = Boolean(backend);
|
|
1983
|
+
const hasFrontend = Boolean(frontend);
|
|
1984
|
+
return {
|
|
1985
|
+
next,
|
|
1986
|
+
backend_tech: hasBackend ? templateTech(backend) : "none",
|
|
1987
|
+
frontend_tech: hasFrontend ? templateTech(frontend) : "none",
|
|
1988
|
+
has_backend: hasBackend,
|
|
1989
|
+
has_frontend: hasFrontend,
|
|
1990
|
+
composition: hasFrontend && hasBackend ? "both" : hasFrontend ? "frontend_only" : hasBackend ? "backend_only" : "none"
|
|
1991
|
+
};
|
|
1992
|
+
}
|
|
1934
1993
|
function templateSelectOptions(templates) {
|
|
1935
1994
|
return templates.map((t) => ({
|
|
1936
1995
|
value: t.packageName,
|
|
@@ -2007,11 +2066,7 @@ async function runNextScaffold(backends, frontends, shared) {
|
|
|
2007
2066
|
}
|
|
2008
2067
|
printNextSteps(answers.appName);
|
|
2009
2068
|
p4.outro(pc4.green("Done! Happy building."));
|
|
2010
|
-
return
|
|
2011
|
-
next: true,
|
|
2012
|
-
frontend: selectedFrontend ? selectedFrontend.meta.label ?? selectedFrontend.packageName : "none",
|
|
2013
|
-
backend: selectedBackend ? selectedBackend.meta.label ?? selectedBackend.packageName : "none"
|
|
2014
|
-
};
|
|
2069
|
+
return scaffoldChoice(selectedBackend, selectedFrontend, true);
|
|
2015
2070
|
}
|
|
2016
2071
|
async function runScaffold() {
|
|
2017
2072
|
console.log();
|
|
@@ -2076,10 +2131,7 @@ async function runScaffold() {
|
|
|
2076
2131
|
s.stop("Project scaffolded");
|
|
2077
2132
|
printNextSteps(answers.appName);
|
|
2078
2133
|
p4.outro(pc4.green("Done! Happy building."));
|
|
2079
|
-
return
|
|
2080
|
-
backend: selectedBackend.meta.label ?? selectedBackend.packageName,
|
|
2081
|
-
frontend: selectedFrontend.meta.label ?? selectedFrontend.packageName
|
|
2082
|
-
};
|
|
2134
|
+
return scaffoldChoice(selectedBackend, selectedFrontend, false);
|
|
2083
2135
|
}
|
|
2084
2136
|
function printNextSteps(appName) {
|
|
2085
2137
|
p4.note(
|
|
@@ -2099,7 +2151,7 @@ async function main() {
|
|
|
2099
2151
|
try {
|
|
2100
2152
|
let detail = {};
|
|
2101
2153
|
if (command === "register") {
|
|
2102
|
-
await register(process.argv.slice(3));
|
|
2154
|
+
detail = await register(process.argv.slice(3));
|
|
2103
2155
|
} else if (command === "listing") {
|
|
2104
2156
|
await listing(process.argv.slice(3));
|
|
2105
2157
|
} else {
|