create-tina-app 2.1.4 → 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 +62 -82
- package/dist/templates.d.ts +1 -0
- package/dist/util/examples.d.ts +0 -4
- package/dist/util/posthog.d.ts +1 -0
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -213,35 +213,6 @@ function initializeGit(spinner) {
|
|
|
213
213
|
import { Readable } from "node:stream";
|
|
214
214
|
import { pipeline } from "node:stream/promises";
|
|
215
215
|
import { x } from "tar";
|
|
216
|
-
async function getRepoInfo(url, examplePath) {
|
|
217
|
-
const [, username, name2, t, _branch, ...file] = url.pathname.split("/");
|
|
218
|
-
const filePath = examplePath ? examplePath.replace(/^\//, "") : file.join("/");
|
|
219
|
-
if (
|
|
220
|
-
// Support repos whose entire purpose is to be a Next.js example, e.g.
|
|
221
|
-
// https://github.com/:username/:my-cool-nextjs-example-repo-name.
|
|
222
|
-
t === void 0 || // Support GitHub URL that ends with a trailing slash, e.g.
|
|
223
|
-
// https://github.com/:username/:my-cool-nextjs-example-repo-name/
|
|
224
|
-
// In this case "t" will be an empty string while the next part "_branch" will be undefined
|
|
225
|
-
t === "" && _branch === void 0
|
|
226
|
-
) {
|
|
227
|
-
try {
|
|
228
|
-
const infoResponse = await fetch(
|
|
229
|
-
`https://api.github.com/repos/${username}/${name2}`
|
|
230
|
-
);
|
|
231
|
-
if (infoResponse.status !== 200) {
|
|
232
|
-
return;
|
|
233
|
-
}
|
|
234
|
-
const info = await infoResponse.json();
|
|
235
|
-
return { username, name: name2, branch: info.default_branch, filePath };
|
|
236
|
-
} catch {
|
|
237
|
-
return;
|
|
238
|
-
}
|
|
239
|
-
}
|
|
240
|
-
const branch = examplePath ? `${_branch}/${file.join("/")}`.replace(new RegExp(`/${filePath}|/$`), "") : _branch;
|
|
241
|
-
if (username && name2 && branch && t === "tree") {
|
|
242
|
-
return { username, name: name2, branch, filePath };
|
|
243
|
-
}
|
|
244
|
-
}
|
|
245
216
|
async function downloadTarStream(url) {
|
|
246
217
|
const res = await fetch(url);
|
|
247
218
|
if (!res.body) {
|
|
@@ -288,6 +259,7 @@ var TEMPLATES = [
|
|
|
288
259
|
}
|
|
289
260
|
],
|
|
290
261
|
gitURL: "https://github.com/tinacms/tina-nextjs-starter",
|
|
262
|
+
branch: "main",
|
|
291
263
|
devUrl: "http://localhost:3000"
|
|
292
264
|
},
|
|
293
265
|
{
|
|
@@ -310,6 +282,7 @@ var TEMPLATES = [
|
|
|
310
282
|
}
|
|
311
283
|
],
|
|
312
284
|
gitURL: "https://github.com/tinacms/tina-docs",
|
|
285
|
+
branch: "main",
|
|
313
286
|
devUrl: "http://localhost:3000"
|
|
314
287
|
},
|
|
315
288
|
{
|
|
@@ -332,6 +305,7 @@ var TEMPLATES = [
|
|
|
332
305
|
}
|
|
333
306
|
],
|
|
334
307
|
gitURL: "https://github.com/tinacms/tina-astro-starter",
|
|
308
|
+
branch: "main",
|
|
335
309
|
devUrl: "http://localhost:4321"
|
|
336
310
|
},
|
|
337
311
|
{
|
|
@@ -354,6 +328,7 @@ var TEMPLATES = [
|
|
|
354
328
|
}
|
|
355
329
|
],
|
|
356
330
|
gitURL: "https://github.com/tinacms/tina-hugo-starter",
|
|
331
|
+
branch: "main",
|
|
357
332
|
devUrl: "http://localhost:1313"
|
|
358
333
|
},
|
|
359
334
|
{
|
|
@@ -376,6 +351,7 @@ var TEMPLATES = [
|
|
|
376
351
|
}
|
|
377
352
|
],
|
|
378
353
|
gitURL: "https://github.com/tinacms/tina-remix-starter",
|
|
354
|
+
branch: "main",
|
|
379
355
|
devUrl: "http://localhost:3000"
|
|
380
356
|
},
|
|
381
357
|
{
|
|
@@ -398,6 +374,7 @@ var TEMPLATES = [
|
|
|
398
374
|
}
|
|
399
375
|
],
|
|
400
376
|
gitURL: "https://github.com/tinacms/tinasaurus",
|
|
377
|
+
branch: "main",
|
|
401
378
|
devUrl: "http://localhost:3000"
|
|
402
379
|
},
|
|
403
380
|
{
|
|
@@ -420,18 +397,22 @@ var TEMPLATES = [
|
|
|
420
397
|
}
|
|
421
398
|
],
|
|
422
399
|
gitURL: "https://github.com/tinacms/tina-barebones-starter",
|
|
400
|
+
branch: "main",
|
|
423
401
|
devUrl: "http://localhost:3000"
|
|
424
402
|
}
|
|
425
403
|
];
|
|
426
404
|
async function downloadTemplate(template, root, spinner) {
|
|
427
405
|
if (template.isInternal === false) {
|
|
428
406
|
const repoURL = new URL(template.gitURL);
|
|
429
|
-
const
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
407
|
+
const [, username, name2] = repoURL.pathname.split("/");
|
|
408
|
+
const repoInfo = {
|
|
409
|
+
username,
|
|
410
|
+
name: name2,
|
|
411
|
+
branch: template.branch,
|
|
412
|
+
filePath: ""
|
|
413
|
+
};
|
|
433
414
|
spinner.text = `Downloading files from repo ${TextStyles.tinaOrange(
|
|
434
|
-
`${repoInfo
|
|
415
|
+
`${repoInfo.username}/${repoInfo.name}`
|
|
435
416
|
)}`;
|
|
436
417
|
await downloadAndExtractRepo(root, repoInfo);
|
|
437
418
|
} else {
|
|
@@ -485,7 +466,7 @@ import { Command } from "commander";
|
|
|
485
466
|
|
|
486
467
|
// package.json
|
|
487
468
|
var name = "create-tina-app";
|
|
488
|
-
var version = "2.1.
|
|
469
|
+
var version = "2.1.6";
|
|
489
470
|
|
|
490
471
|
// src/util/packageManagers.ts
|
|
491
472
|
var PKG_MANAGERS = ["npm", "yarn", "pnpm", "bun"];
|
|
@@ -708,6 +689,7 @@ var ERROR_CODES = {
|
|
|
708
689
|
ERR_VAL_INVALID_TEMPLATE: "ERR_VAL_INVALID_TEMPLATE",
|
|
709
690
|
ERR_VAL_INVALID_PKG_MANAGER: "ERR_VAL_INVALID_PKG_MANAGER",
|
|
710
691
|
ERR_VAL_INVALID_PROJECT_NAME: "ERR_VAL_INVALID_PROJECT_NAME",
|
|
692
|
+
ERR_VAL_INVALID_THEME: "ERR_VAL_INVALID_THEME",
|
|
711
693
|
ERR_VAL_UNSUPPORTED_NODE: "ERR_VAL_UNSUPPORTED_NODE",
|
|
712
694
|
ERR_VAL_NO_PKG_MANAGERS: "ERR_VAL_NO_PKG_MANAGERS",
|
|
713
695
|
// File System Errors (FS_*)
|
|
@@ -898,6 +880,7 @@ async function fetchPostHogConfig(endpointUrl) {
|
|
|
898
880
|
|
|
899
881
|
// src/index.ts
|
|
900
882
|
import { osInfo as getOsSystemInfo } from "systeminformation";
|
|
883
|
+
var DISCORD_SUPPORT_URL = "https://discord.com/invite/zumN63Ybpf";
|
|
901
884
|
var posthogClient = null;
|
|
902
885
|
async function initializePostHog(configEndpoint, disableGeoip) {
|
|
903
886
|
let apiKey;
|
|
@@ -982,6 +965,18 @@ ${TextStylesBold.bold("Telemetry Notice")}`);
|
|
|
982
965
|
}
|
|
983
966
|
const spinner = ora();
|
|
984
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
|
+
};
|
|
985
980
|
postHogCapture(
|
|
986
981
|
posthogClient,
|
|
987
982
|
userId,
|
|
@@ -993,15 +988,10 @@ ${TextStylesBold.bold("Telemetry Notice")}`);
|
|
|
993
988
|
if (opts.template) {
|
|
994
989
|
template = TEMPLATES.find((_template) => _template.value === opts.template);
|
|
995
990
|
if (!template) {
|
|
996
|
-
|
|
991
|
+
await fatalExit(
|
|
997
992
|
`The provided template '${opts.template}' is invalid. Please provide one of the following: ${TEMPLATES.map(
|
|
998
993
|
(x2) => x2.value
|
|
999
|
-
)}
|
|
1000
|
-
);
|
|
1001
|
-
postHogCaptureError(
|
|
1002
|
-
posthogClient,
|
|
1003
|
-
userId,
|
|
1004
|
-
sessionId,
|
|
994
|
+
)}`,
|
|
1005
995
|
new Error(`Invalid template: ${opts.template}`),
|
|
1006
996
|
{
|
|
1007
997
|
errorCode: ERROR_CODES.ERR_VAL_INVALID_TEMPLATE,
|
|
@@ -1011,17 +1001,13 @@ ${TextStylesBold.bold("Telemetry Notice")}`);
|
|
|
1011
1001
|
additionalProperties: { ...telemetryData }
|
|
1012
1002
|
}
|
|
1013
1003
|
);
|
|
1014
|
-
if (posthogClient) await posthogClient.shutdown();
|
|
1015
|
-
exit(1);
|
|
1016
1004
|
}
|
|
1017
1005
|
}
|
|
1018
1006
|
let pkgManager = opts.pkgManager;
|
|
1019
1007
|
if (pkgManager) {
|
|
1020
1008
|
if (!PKG_MANAGERS.find((_pkgManager) => _pkgManager === pkgManager)) {
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
userId,
|
|
1024
|
-
sessionId,
|
|
1009
|
+
await fatalExit(
|
|
1010
|
+
`The provided package manager '${opts.pkgManager}' is not supported. Please provide one of the following: ${PKG_MANAGERS}`,
|
|
1025
1011
|
new Error(`Invalid package manager: ${opts.pkgManager}`),
|
|
1026
1012
|
{
|
|
1027
1013
|
errorCode: ERROR_CODES.ERR_VAL_INVALID_PKG_MANAGER,
|
|
@@ -1031,22 +1017,12 @@ ${TextStylesBold.bold("Telemetry Notice")}`);
|
|
|
1031
1017
|
additionalProperties: { ...telemetryData }
|
|
1032
1018
|
}
|
|
1033
1019
|
);
|
|
1034
|
-
if (posthogClient) await posthogClient.shutdown();
|
|
1035
|
-
spinner.fail(
|
|
1036
|
-
`The provided package manager '${opts.pkgManager}' is not supported. Please provide one of the following: ${PKG_MANAGERS}`
|
|
1037
|
-
);
|
|
1038
|
-
exit(1);
|
|
1039
1020
|
}
|
|
1040
1021
|
}
|
|
1041
1022
|
if (!pkgManager) {
|
|
1042
1023
|
if (installedPkgManagers.length === 0) {
|
|
1043
|
-
|
|
1044
|
-
`You have no supported package managers installed. Please install one of the following: ${PKG_MANAGERS}
|
|
1045
|
-
);
|
|
1046
|
-
postHogCaptureError(
|
|
1047
|
-
posthogClient,
|
|
1048
|
-
userId,
|
|
1049
|
-
sessionId,
|
|
1024
|
+
await fatalExit(
|
|
1025
|
+
`You have no supported package managers installed. Please install one of the following: ${PKG_MANAGERS}`,
|
|
1050
1026
|
new Error("No supported package managers installed"),
|
|
1051
1027
|
{
|
|
1052
1028
|
errorCode: ERROR_CODES.ERR_VAL_NO_PKG_MANAGERS,
|
|
@@ -1056,8 +1032,6 @@ ${TextStylesBold.bold("Telemetry Notice")}`);
|
|
|
1056
1032
|
additionalProperties: telemetryData
|
|
1057
1033
|
}
|
|
1058
1034
|
);
|
|
1059
|
-
if (posthogClient) await posthogClient.shutdown();
|
|
1060
|
-
exit(1);
|
|
1061
1035
|
}
|
|
1062
1036
|
const res = await prompts({
|
|
1063
1037
|
message: "Which package manager would you like to use?",
|
|
@@ -1153,10 +1127,20 @@ ${TextStylesBold.bold("Telemetry Notice")}`);
|
|
|
1153
1127
|
if (opts.theme) {
|
|
1154
1128
|
const validThemes = THEMES.map((t) => t.value);
|
|
1155
1129
|
if (!validThemes.includes(opts.theme)) {
|
|
1156
|
-
|
|
1157
|
-
`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
|
+
}
|
|
1158
1143
|
);
|
|
1159
|
-
exit(1);
|
|
1160
1144
|
}
|
|
1161
1145
|
themeChoice = opts.theme;
|
|
1162
1146
|
} else {
|
|
@@ -1191,13 +1175,8 @@ ${TextStylesBold.bold("Telemetry Notice")}`);
|
|
|
1191
1175
|
}
|
|
1192
1176
|
const rootDir = path3.join(process.cwd(), projectName);
|
|
1193
1177
|
if (!await isWriteable(path3.dirname(rootDir))) {
|
|
1194
|
-
|
|
1195
|
-
"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."
|
|
1196
|
-
);
|
|
1197
|
-
postHogCaptureError(
|
|
1198
|
-
posthogClient,
|
|
1199
|
-
userId,
|
|
1200
|
-
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.",
|
|
1201
1180
|
new Error("Directory not writable"),
|
|
1202
1181
|
{
|
|
1203
1182
|
errorCode: ERROR_CODES.ERR_FS_NOT_WRITABLE,
|
|
@@ -1207,8 +1186,6 @@ ${TextStylesBold.bold("Telemetry Notice")}`);
|
|
|
1207
1186
|
additionalProperties: { ...telemetryData }
|
|
1208
1187
|
}
|
|
1209
1188
|
);
|
|
1210
|
-
if (posthogClient) await posthogClient.shutdown();
|
|
1211
|
-
process.exit(1);
|
|
1212
1189
|
}
|
|
1213
1190
|
let appName;
|
|
1214
1191
|
try {
|
|
@@ -1216,16 +1193,13 @@ ${TextStylesBold.bold("Telemetry Notice")}`);
|
|
|
1216
1193
|
telemetryData["app-name"] = appName;
|
|
1217
1194
|
} catch (err) {
|
|
1218
1195
|
const error = err;
|
|
1219
|
-
|
|
1220
|
-
postHogCaptureError(posthogClient, userId, sessionId, error, {
|
|
1196
|
+
await fatalExit(error.message, error, {
|
|
1221
1197
|
errorCode: ERROR_CODES.ERR_FS_MKDIR_FAILED,
|
|
1222
1198
|
errorCategory: "filesystem",
|
|
1223
1199
|
step: TRACKING_STEPS.DIRECTORY_SETUP,
|
|
1224
1200
|
fatal: true,
|
|
1225
1201
|
additionalProperties: { ...telemetryData }
|
|
1226
1202
|
});
|
|
1227
|
-
if (posthogClient) await posthogClient.shutdown();
|
|
1228
|
-
exit(1);
|
|
1229
1203
|
}
|
|
1230
1204
|
try {
|
|
1231
1205
|
if (themeChoice) {
|
|
@@ -1244,16 +1218,13 @@ ${TextStylesBold.bold("Telemetry Notice")}`);
|
|
|
1244
1218
|
spinner.succeed();
|
|
1245
1219
|
} catch (err) {
|
|
1246
1220
|
const error = err;
|
|
1247
|
-
|
|
1248
|
-
postHogCaptureError(posthogClient, userId, sessionId, error, {
|
|
1221
|
+
await fatalExit(`Failed to download template: ${error.message}`, error, {
|
|
1249
1222
|
errorCode: ERROR_CODES.ERR_TPL_DOWNLOAD_FAILED,
|
|
1250
1223
|
errorCategory: "template",
|
|
1251
1224
|
step: TRACKING_STEPS.DOWNLOADING_TEMPLATE,
|
|
1252
1225
|
fatal: true,
|
|
1253
1226
|
additionalProperties: { ...telemetryData }
|
|
1254
1227
|
});
|
|
1255
|
-
if (posthogClient) await posthogClient.shutdown();
|
|
1256
|
-
exit(1);
|
|
1257
1228
|
}
|
|
1258
1229
|
spinner.start("Installing packages.");
|
|
1259
1230
|
try {
|
|
@@ -1336,12 +1307,21 @@ ${TextStylesBold.bold("Telemetry Notice")}`);
|
|
|
1336
1307
|
"https://tina.io/docs/r/what-is-tinacloud"
|
|
1337
1308
|
)}`
|
|
1338
1309
|
);
|
|
1310
|
+
console.log(
|
|
1311
|
+
` \u2022 \u{1F4AC} Reach out for support: ${TextStyles.link(DISCORD_SUPPORT_URL)}`
|
|
1312
|
+
);
|
|
1339
1313
|
}
|
|
1340
1314
|
run().catch(async (error) => {
|
|
1341
1315
|
if (process.stdout.columns >= 60) {
|
|
1342
1316
|
console.log(TextStyles.tinaOrange(`${errorArt}`));
|
|
1343
1317
|
}
|
|
1344
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
|
+
);
|
|
1345
1325
|
const sessionId = generateSessionId();
|
|
1346
1326
|
const userId = await getAnonymousUserId();
|
|
1347
1327
|
postHogCaptureError(posthogClient, userId, sessionId, error, {
|
package/dist/templates.d.ts
CHANGED
|
@@ -16,6 +16,7 @@ export type InternalTemplate = BaseExample & {
|
|
|
16
16
|
export type ExternalTemplate = BaseExample & {
|
|
17
17
|
isInternal: false;
|
|
18
18
|
gitURL: string;
|
|
19
|
+
branch: string;
|
|
19
20
|
};
|
|
20
21
|
export type Template = InternalTemplate | ExternalTemplate;
|
|
21
22
|
export declare const TEMPLATES: Template[];
|
package/dist/util/examples.d.ts
CHANGED
|
@@ -4,9 +4,5 @@ export type RepoInfo = {
|
|
|
4
4
|
branch: string;
|
|
5
5
|
filePath: string;
|
|
6
6
|
};
|
|
7
|
-
export declare function isUrlOk(url: string): Promise<boolean>;
|
|
8
|
-
export declare function getRepoInfo(url: URL, examplePath?: string): Promise<RepoInfo | undefined>;
|
|
9
|
-
export declare function hasRepo({ username, name, branch, filePath, }: RepoInfo): Promise<boolean>;
|
|
10
|
-
export declare function existsInRepo(nameOrUrl: string): Promise<boolean>;
|
|
11
7
|
export declare function downloadAndExtractRepo(root: string, { username, name, branch, filePath }: RepoInfo): Promise<void>;
|
|
12
8
|
export declare function downloadAndExtractExample(root: string, name: string): Promise<void>;
|
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";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-tina-app",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.6",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"files": [
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"@types/prompts": "^2.4.9",
|
|
37
37
|
"@types/tar": "6.1.13",
|
|
38
38
|
"typescript": "^5.7.3",
|
|
39
|
-
"@tinacms/scripts": "1.6.
|
|
39
|
+
"@tinacms/scripts": "1.6.1"
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
42
|
"chalk": "^5.4.1",
|