create-tina-app 2.1.5 → 2.1.6
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 +47 -48
- package/dist/util/posthog.d.ts +1 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -466,7 +466,7 @@ import { Command } from "commander";
|
|
|
466
466
|
|
|
467
467
|
// package.json
|
|
468
468
|
var name = "create-tina-app";
|
|
469
|
-
var version = "2.1.
|
|
469
|
+
var version = "2.1.6";
|
|
470
470
|
|
|
471
471
|
// src/util/packageManagers.ts
|
|
472
472
|
var PKG_MANAGERS = ["npm", "yarn", "pnpm", "bun"];
|
|
@@ -689,6 +689,7 @@ var ERROR_CODES = {
|
|
|
689
689
|
ERR_VAL_INVALID_TEMPLATE: "ERR_VAL_INVALID_TEMPLATE",
|
|
690
690
|
ERR_VAL_INVALID_PKG_MANAGER: "ERR_VAL_INVALID_PKG_MANAGER",
|
|
691
691
|
ERR_VAL_INVALID_PROJECT_NAME: "ERR_VAL_INVALID_PROJECT_NAME",
|
|
692
|
+
ERR_VAL_INVALID_THEME: "ERR_VAL_INVALID_THEME",
|
|
692
693
|
ERR_VAL_UNSUPPORTED_NODE: "ERR_VAL_UNSUPPORTED_NODE",
|
|
693
694
|
ERR_VAL_NO_PKG_MANAGERS: "ERR_VAL_NO_PKG_MANAGERS",
|
|
694
695
|
// File System Errors (FS_*)
|
|
@@ -879,6 +880,7 @@ async function fetchPostHogConfig(endpointUrl) {
|
|
|
879
880
|
|
|
880
881
|
// src/index.ts
|
|
881
882
|
import { osInfo as getOsSystemInfo } from "systeminformation";
|
|
883
|
+
var DISCORD_SUPPORT_URL = "https://discord.com/invite/zumN63Ybpf";
|
|
882
884
|
var posthogClient = null;
|
|
883
885
|
async function initializePostHog(configEndpoint, disableGeoip) {
|
|
884
886
|
let apiKey;
|
|
@@ -963,6 +965,18 @@ ${TextStylesBold.bold("Telemetry Notice")}`);
|
|
|
963
965
|
}
|
|
964
966
|
const spinner = ora();
|
|
965
967
|
preRunChecks(spinner);
|
|
968
|
+
const fatalExit = async (message, error, context) => {
|
|
969
|
+
spinner.fail(
|
|
970
|
+
`${message}
|
|
971
|
+
|
|
972
|
+
Need more help? Reach out to the TinaCMS community at ${TextStyles.link(
|
|
973
|
+
DISCORD_SUPPORT_URL
|
|
974
|
+
)}`
|
|
975
|
+
);
|
|
976
|
+
postHogCaptureError(posthogClient, userId, sessionId, error, context);
|
|
977
|
+
if (posthogClient) await posthogClient.shutdown();
|
|
978
|
+
exit(1);
|
|
979
|
+
};
|
|
966
980
|
postHogCapture(
|
|
967
981
|
posthogClient,
|
|
968
982
|
userId,
|
|
@@ -974,15 +988,10 @@ ${TextStylesBold.bold("Telemetry Notice")}`);
|
|
|
974
988
|
if (opts.template) {
|
|
975
989
|
template = TEMPLATES.find((_template) => _template.value === opts.template);
|
|
976
990
|
if (!template) {
|
|
977
|
-
|
|
991
|
+
await fatalExit(
|
|
978
992
|
`The provided template '${opts.template}' is invalid. Please provide one of the following: ${TEMPLATES.map(
|
|
979
993
|
(x2) => x2.value
|
|
980
|
-
)}
|
|
981
|
-
);
|
|
982
|
-
postHogCaptureError(
|
|
983
|
-
posthogClient,
|
|
984
|
-
userId,
|
|
985
|
-
sessionId,
|
|
994
|
+
)}`,
|
|
986
995
|
new Error(`Invalid template: ${opts.template}`),
|
|
987
996
|
{
|
|
988
997
|
errorCode: ERROR_CODES.ERR_VAL_INVALID_TEMPLATE,
|
|
@@ -992,17 +1001,13 @@ ${TextStylesBold.bold("Telemetry Notice")}`);
|
|
|
992
1001
|
additionalProperties: { ...telemetryData }
|
|
993
1002
|
}
|
|
994
1003
|
);
|
|
995
|
-
if (posthogClient) await posthogClient.shutdown();
|
|
996
|
-
exit(1);
|
|
997
1004
|
}
|
|
998
1005
|
}
|
|
999
1006
|
let pkgManager = opts.pkgManager;
|
|
1000
1007
|
if (pkgManager) {
|
|
1001
1008
|
if (!PKG_MANAGERS.find((_pkgManager) => _pkgManager === pkgManager)) {
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
userId,
|
|
1005
|
-
sessionId,
|
|
1009
|
+
await fatalExit(
|
|
1010
|
+
`The provided package manager '${opts.pkgManager}' is not supported. Please provide one of the following: ${PKG_MANAGERS}`,
|
|
1006
1011
|
new Error(`Invalid package manager: ${opts.pkgManager}`),
|
|
1007
1012
|
{
|
|
1008
1013
|
errorCode: ERROR_CODES.ERR_VAL_INVALID_PKG_MANAGER,
|
|
@@ -1012,22 +1017,12 @@ ${TextStylesBold.bold("Telemetry Notice")}`);
|
|
|
1012
1017
|
additionalProperties: { ...telemetryData }
|
|
1013
1018
|
}
|
|
1014
1019
|
);
|
|
1015
|
-
if (posthogClient) await posthogClient.shutdown();
|
|
1016
|
-
spinner.fail(
|
|
1017
|
-
`The provided package manager '${opts.pkgManager}' is not supported. Please provide one of the following: ${PKG_MANAGERS}`
|
|
1018
|
-
);
|
|
1019
|
-
exit(1);
|
|
1020
1020
|
}
|
|
1021
1021
|
}
|
|
1022
1022
|
if (!pkgManager) {
|
|
1023
1023
|
if (installedPkgManagers.length === 0) {
|
|
1024
|
-
|
|
1025
|
-
`You have no supported package managers installed. Please install one of the following: ${PKG_MANAGERS}
|
|
1026
|
-
);
|
|
1027
|
-
postHogCaptureError(
|
|
1028
|
-
posthogClient,
|
|
1029
|
-
userId,
|
|
1030
|
-
sessionId,
|
|
1024
|
+
await fatalExit(
|
|
1025
|
+
`You have no supported package managers installed. Please install one of the following: ${PKG_MANAGERS}`,
|
|
1031
1026
|
new Error("No supported package managers installed"),
|
|
1032
1027
|
{
|
|
1033
1028
|
errorCode: ERROR_CODES.ERR_VAL_NO_PKG_MANAGERS,
|
|
@@ -1037,8 +1032,6 @@ ${TextStylesBold.bold("Telemetry Notice")}`);
|
|
|
1037
1032
|
additionalProperties: telemetryData
|
|
1038
1033
|
}
|
|
1039
1034
|
);
|
|
1040
|
-
if (posthogClient) await posthogClient.shutdown();
|
|
1041
|
-
exit(1);
|
|
1042
1035
|
}
|
|
1043
1036
|
const res = await prompts({
|
|
1044
1037
|
message: "Which package manager would you like to use?",
|
|
@@ -1134,10 +1127,20 @@ ${TextStylesBold.bold("Telemetry Notice")}`);
|
|
|
1134
1127
|
if (opts.theme) {
|
|
1135
1128
|
const validThemes = THEMES.map((t) => t.value);
|
|
1136
1129
|
if (!validThemes.includes(opts.theme)) {
|
|
1137
|
-
|
|
1138
|
-
`Invalid theme "${opts.theme}". Valid options are: ${validThemes.join(", ")}
|
|
1130
|
+
await fatalExit(
|
|
1131
|
+
`Invalid theme "${opts.theme}". Valid options are: ${validThemes.join(", ")}`,
|
|
1132
|
+
new Error(`Invalid theme: ${opts.theme}`),
|
|
1133
|
+
{
|
|
1134
|
+
errorCode: ERROR_CODES.ERR_VAL_INVALID_THEME,
|
|
1135
|
+
errorCategory: "validation",
|
|
1136
|
+
step: TRACKING_STEPS.THEME_SELECT,
|
|
1137
|
+
fatal: true,
|
|
1138
|
+
additionalProperties: {
|
|
1139
|
+
...telemetryData,
|
|
1140
|
+
template: template.value
|
|
1141
|
+
}
|
|
1142
|
+
}
|
|
1139
1143
|
);
|
|
1140
|
-
exit(1);
|
|
1141
1144
|
}
|
|
1142
1145
|
themeChoice = opts.theme;
|
|
1143
1146
|
} else {
|
|
@@ -1172,13 +1175,8 @@ ${TextStylesBold.bold("Telemetry Notice")}`);
|
|
|
1172
1175
|
}
|
|
1173
1176
|
const rootDir = path3.join(process.cwd(), projectName);
|
|
1174
1177
|
if (!await isWriteable(path3.dirname(rootDir))) {
|
|
1175
|
-
|
|
1176
|
-
"The application path is not writable, please check folder permissions and try again. It is likely you do not have write permissions for this folder."
|
|
1177
|
-
);
|
|
1178
|
-
postHogCaptureError(
|
|
1179
|
-
posthogClient,
|
|
1180
|
-
userId,
|
|
1181
|
-
sessionId,
|
|
1178
|
+
await fatalExit(
|
|
1179
|
+
"The application path is not writable, please check folder permissions and try again. It is likely you do not have write permissions for this folder.",
|
|
1182
1180
|
new Error("Directory not writable"),
|
|
1183
1181
|
{
|
|
1184
1182
|
errorCode: ERROR_CODES.ERR_FS_NOT_WRITABLE,
|
|
@@ -1188,8 +1186,6 @@ ${TextStylesBold.bold("Telemetry Notice")}`);
|
|
|
1188
1186
|
additionalProperties: { ...telemetryData }
|
|
1189
1187
|
}
|
|
1190
1188
|
);
|
|
1191
|
-
if (posthogClient) await posthogClient.shutdown();
|
|
1192
|
-
process.exit(1);
|
|
1193
1189
|
}
|
|
1194
1190
|
let appName;
|
|
1195
1191
|
try {
|
|
@@ -1197,16 +1193,13 @@ ${TextStylesBold.bold("Telemetry Notice")}`);
|
|
|
1197
1193
|
telemetryData["app-name"] = appName;
|
|
1198
1194
|
} catch (err) {
|
|
1199
1195
|
const error = err;
|
|
1200
|
-
|
|
1201
|
-
postHogCaptureError(posthogClient, userId, sessionId, error, {
|
|
1196
|
+
await fatalExit(error.message, error, {
|
|
1202
1197
|
errorCode: ERROR_CODES.ERR_FS_MKDIR_FAILED,
|
|
1203
1198
|
errorCategory: "filesystem",
|
|
1204
1199
|
step: TRACKING_STEPS.DIRECTORY_SETUP,
|
|
1205
1200
|
fatal: true,
|
|
1206
1201
|
additionalProperties: { ...telemetryData }
|
|
1207
1202
|
});
|
|
1208
|
-
if (posthogClient) await posthogClient.shutdown();
|
|
1209
|
-
exit(1);
|
|
1210
1203
|
}
|
|
1211
1204
|
try {
|
|
1212
1205
|
if (themeChoice) {
|
|
@@ -1225,16 +1218,13 @@ ${TextStylesBold.bold("Telemetry Notice")}`);
|
|
|
1225
1218
|
spinner.succeed();
|
|
1226
1219
|
} catch (err) {
|
|
1227
1220
|
const error = err;
|
|
1228
|
-
|
|
1229
|
-
postHogCaptureError(posthogClient, userId, sessionId, error, {
|
|
1221
|
+
await fatalExit(`Failed to download template: ${error.message}`, error, {
|
|
1230
1222
|
errorCode: ERROR_CODES.ERR_TPL_DOWNLOAD_FAILED,
|
|
1231
1223
|
errorCategory: "template",
|
|
1232
1224
|
step: TRACKING_STEPS.DOWNLOADING_TEMPLATE,
|
|
1233
1225
|
fatal: true,
|
|
1234
1226
|
additionalProperties: { ...telemetryData }
|
|
1235
1227
|
});
|
|
1236
|
-
if (posthogClient) await posthogClient.shutdown();
|
|
1237
|
-
exit(1);
|
|
1238
1228
|
}
|
|
1239
1229
|
spinner.start("Installing packages.");
|
|
1240
1230
|
try {
|
|
@@ -1317,12 +1307,21 @@ ${TextStylesBold.bold("Telemetry Notice")}`);
|
|
|
1317
1307
|
"https://tina.io/docs/r/what-is-tinacloud"
|
|
1318
1308
|
)}`
|
|
1319
1309
|
);
|
|
1310
|
+
console.log(
|
|
1311
|
+
` \u2022 \u{1F4AC} Reach out for support: ${TextStyles.link(DISCORD_SUPPORT_URL)}`
|
|
1312
|
+
);
|
|
1320
1313
|
}
|
|
1321
1314
|
run().catch(async (error) => {
|
|
1322
1315
|
if (process.stdout.columns >= 60) {
|
|
1323
1316
|
console.log(TextStyles.tinaOrange(`${errorArt}`));
|
|
1324
1317
|
}
|
|
1325
1318
|
console.error("Error running create-tina-app:", error);
|
|
1319
|
+
console.error(
|
|
1320
|
+
`
|
|
1321
|
+
\u{1F4AC} Need more help? Reach out to the TinaCMS community at ${TextStyles.link(
|
|
1322
|
+
DISCORD_SUPPORT_URL
|
|
1323
|
+
)}`
|
|
1324
|
+
);
|
|
1326
1325
|
const sessionId = generateSessionId();
|
|
1327
1326
|
const userId = await getAnonymousUserId();
|
|
1328
1327
|
postHogCaptureError(posthogClient, userId, sessionId, error, {
|
package/dist/util/posthog.d.ts
CHANGED
|
@@ -35,6 +35,7 @@ export declare const ERROR_CODES: {
|
|
|
35
35
|
readonly ERR_VAL_INVALID_TEMPLATE: "ERR_VAL_INVALID_TEMPLATE";
|
|
36
36
|
readonly ERR_VAL_INVALID_PKG_MANAGER: "ERR_VAL_INVALID_PKG_MANAGER";
|
|
37
37
|
readonly ERR_VAL_INVALID_PROJECT_NAME: "ERR_VAL_INVALID_PROJECT_NAME";
|
|
38
|
+
readonly ERR_VAL_INVALID_THEME: "ERR_VAL_INVALID_THEME";
|
|
38
39
|
readonly ERR_VAL_UNSUPPORTED_NODE: "ERR_VAL_UNSUPPORTED_NODE";
|
|
39
40
|
readonly ERR_VAL_NO_PKG_MANAGERS: "ERR_VAL_NO_PKG_MANAGERS";
|
|
40
41
|
readonly ERR_FS_NOT_WRITABLE: "ERR_FS_NOT_WRITABLE";
|