create-tina-app 2.1.1 → 2.1.3
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 +90 -64
- package/dist/util/fileUtil.d.ts +5 -0
- package/dist/util/options.d.ts +1 -0
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -113,6 +113,33 @@ async function updateThemeSettings(dir, selectedTheme) {
|
|
|
113
113
|
config.selectedTheme = selectedTheme;
|
|
114
114
|
await fs.writeFile(configPath, JSON.stringify(config, null, 2));
|
|
115
115
|
}
|
|
116
|
+
async function updateTelemetryConfig(dir, mode) {
|
|
117
|
+
const configPaths = [
|
|
118
|
+
path.join(dir, "tina", "config.ts"),
|
|
119
|
+
path.join(dir, "tina", "config.tsx"),
|
|
120
|
+
path.join(dir, "tina", "config.js"),
|
|
121
|
+
path.join(dir, "tina", "config.jsx")
|
|
122
|
+
];
|
|
123
|
+
for (const configPath of configPaths) {
|
|
124
|
+
if (await fs.pathExists(configPath)) {
|
|
125
|
+
let content = await fs.readFile(configPath, "utf8");
|
|
126
|
+
if (/telemetry\s*:/.test(content)) {
|
|
127
|
+
content = content.replace(
|
|
128
|
+
/telemetry\s*:\s*['"][^'"]*['"]/,
|
|
129
|
+
`telemetry: '${mode}'`
|
|
130
|
+
);
|
|
131
|
+
} else {
|
|
132
|
+
content = content.replace(
|
|
133
|
+
/defineConfig\(\s*\{/,
|
|
134
|
+
`defineConfig({
|
|
135
|
+
telemetry: '${mode}',`
|
|
136
|
+
);
|
|
137
|
+
}
|
|
138
|
+
await fs.writeFile(configPath, content);
|
|
139
|
+
return;
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
}
|
|
116
143
|
|
|
117
144
|
// src/util/install.ts
|
|
118
145
|
import spawn from "cross-spawn";
|
|
@@ -458,7 +485,7 @@ import { Command } from "commander";
|
|
|
458
485
|
|
|
459
486
|
// package.json
|
|
460
487
|
var name = "create-tina-app";
|
|
461
|
-
var version = "2.1.
|
|
488
|
+
var version = "2.1.3";
|
|
462
489
|
|
|
463
490
|
// src/util/packageManagers.ts
|
|
464
491
|
var PKG_MANAGERS = ["npm", "yarn", "pnpm", "bun"];
|
|
@@ -478,7 +505,10 @@ function extractOptions(args) {
|
|
|
478
505
|
).option(
|
|
479
506
|
"-d, --dir <dir>",
|
|
480
507
|
"Choose which directory to run this script from."
|
|
481
|
-
).option("-v, --verbose", "Enable verbose output.").option("--noTelemetry", "Disable anonymous telemetry that is collected.").
|
|
508
|
+
).option("-v, --verbose", "Enable verbose output.").option("--noTelemetry", "Disable anonymous telemetry that is collected.").option(
|
|
509
|
+
"--theme <theme>",
|
|
510
|
+
"Choose a theme for the tina-docs template (skips interactive prompt)."
|
|
511
|
+
).arguments("[project-directory]").usage(`${TextStyles.success("<project-directory>")} [options]`).action((name2) => {
|
|
482
512
|
projectName = name2;
|
|
483
513
|
});
|
|
484
514
|
program.parse(args);
|
|
@@ -929,9 +959,7 @@ async function run() {
|
|
|
929
959
|
console.log(`
|
|
930
960
|
${TextStylesBold.bold("Telemetry Notice")}`);
|
|
931
961
|
console.log(
|
|
932
|
-
|
|
933
|
-
No personal or project-specific code is ever collected. You can opt out at any time by passing the --noTelemetry flag.
|
|
934
|
-
`
|
|
962
|
+
"To help the TinaCMS team improve the developer experience, create-tina-app collects anonymous usage statistics. This data helps us understand which environments and features are most important to support. Usage analytics may include: Operating system and version, package manager name and version (local only), Node.js version (local only), and the selected TinaCMS starter template.\nNo personal or project-specific code is ever collected. You can opt out at any time by passing the --noTelemetry flag.\n"
|
|
935
963
|
);
|
|
936
964
|
posthogClient = await initializePostHog(
|
|
937
965
|
"https://identity-v2.tinajs.io/v2/posthog-token",
|
|
@@ -945,6 +973,12 @@ No personal or project-specific code is ever collected. You can opt out at any t
|
|
|
945
973
|
for (const pkgManager2 of PKG_MANAGERS) {
|
|
946
974
|
telemetryData[`${pkgManager2}-installed`] = installedPkgManagers.includes(pkgManager2);
|
|
947
975
|
}
|
|
976
|
+
if (opts.template) {
|
|
977
|
+
telemetryData["template"] = opts.template;
|
|
978
|
+
}
|
|
979
|
+
if (opts.pkgManager) {
|
|
980
|
+
telemetryData["package-manager"] = opts.pkgManager;
|
|
981
|
+
}
|
|
948
982
|
}
|
|
949
983
|
const spinner = ora();
|
|
950
984
|
preRunChecks(spinner);
|
|
@@ -974,10 +1008,7 @@ No personal or project-specific code is ever collected. You can opt out at any t
|
|
|
974
1008
|
errorCategory: "validation",
|
|
975
1009
|
step: TRACKING_STEPS.TEMPLATE_SELECT,
|
|
976
1010
|
fatal: true,
|
|
977
|
-
additionalProperties: {
|
|
978
|
-
...telemetryData,
|
|
979
|
-
provided_template: opts.template
|
|
980
|
-
}
|
|
1011
|
+
additionalProperties: { ...telemetryData }
|
|
981
1012
|
}
|
|
982
1013
|
);
|
|
983
1014
|
if (posthogClient) await posthogClient.shutdown();
|
|
@@ -987,9 +1018,6 @@ No personal or project-specific code is ever collected. You can opt out at any t
|
|
|
987
1018
|
let pkgManager = opts.pkgManager;
|
|
988
1019
|
if (pkgManager) {
|
|
989
1020
|
if (!PKG_MANAGERS.find((_pkgManager) => _pkgManager === pkgManager)) {
|
|
990
|
-
spinner.fail(
|
|
991
|
-
`The provided package manager '${opts.pkgManager}' is not supported. Please provide one of the following: ${PKG_MANAGERS}`
|
|
992
|
-
);
|
|
993
1021
|
postHogCaptureError(
|
|
994
1022
|
posthogClient,
|
|
995
1023
|
userId,
|
|
@@ -1000,13 +1028,13 @@ No personal or project-specific code is ever collected. You can opt out at any t
|
|
|
1000
1028
|
errorCategory: "validation",
|
|
1001
1029
|
step: TRACKING_STEPS.PKG_MANAGER_SELECT,
|
|
1002
1030
|
fatal: true,
|
|
1003
|
-
additionalProperties: {
|
|
1004
|
-
...telemetryData,
|
|
1005
|
-
provided_pkg_manager: opts.pkgManager
|
|
1006
|
-
}
|
|
1031
|
+
additionalProperties: { ...telemetryData }
|
|
1007
1032
|
}
|
|
1008
1033
|
);
|
|
1009
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
|
+
);
|
|
1010
1038
|
exit(1);
|
|
1011
1039
|
}
|
|
1012
1040
|
}
|
|
@@ -1057,8 +1085,8 @@ No personal or project-specific code is ever collected. You can opt out at any t
|
|
|
1057
1085
|
exit(1);
|
|
1058
1086
|
}
|
|
1059
1087
|
pkgManager = res.packageManager;
|
|
1060
|
-
telemetryData["package-manager"] = pkgManager;
|
|
1061
1088
|
}
|
|
1089
|
+
telemetryData["package-manager"] = pkgManager;
|
|
1062
1090
|
let projectName = opts.projectName;
|
|
1063
1091
|
if (!projectName) {
|
|
1064
1092
|
const res = await prompts({
|
|
@@ -1122,33 +1150,44 @@ No personal or project-specific code is ever collected. You can opt out at any t
|
|
|
1122
1150
|
telemetryData["template"] = template.value;
|
|
1123
1151
|
let themeChoice;
|
|
1124
1152
|
if (template.value === "tina-docs") {
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1153
|
+
if (opts.theme) {
|
|
1154
|
+
const validThemes = THEMES.map((t) => t.value);
|
|
1155
|
+
if (!validThemes.includes(opts.theme)) {
|
|
1156
|
+
console.error(
|
|
1157
|
+
`Invalid theme "${opts.theme}". Valid options are: ${validThemes.join(", ")}`
|
|
1158
|
+
);
|
|
1159
|
+
exit(1);
|
|
1160
|
+
}
|
|
1161
|
+
themeChoice = opts.theme;
|
|
1162
|
+
} else {
|
|
1163
|
+
const res = await prompts({
|
|
1164
|
+
name: "theme",
|
|
1165
|
+
type: "select",
|
|
1166
|
+
message: "What theme would you like to use?",
|
|
1167
|
+
choices: THEMES
|
|
1168
|
+
});
|
|
1169
|
+
if (!Object.hasOwn(res, "theme")) {
|
|
1170
|
+
postHogCaptureError(
|
|
1171
|
+
posthogClient,
|
|
1172
|
+
userId,
|
|
1173
|
+
sessionId,
|
|
1174
|
+
new Error("User cancelled theme selection"),
|
|
1175
|
+
{
|
|
1176
|
+
errorCode: ERROR_CODES.ERR_CANCEL_THEME_PROMPT,
|
|
1177
|
+
errorCategory: "user-cancellation",
|
|
1178
|
+
step: TRACKING_STEPS.THEME_SELECT,
|
|
1179
|
+
fatal: true,
|
|
1180
|
+
additionalProperties: {
|
|
1181
|
+
...telemetryData,
|
|
1182
|
+
template: template.value
|
|
1183
|
+
}
|
|
1145
1184
|
}
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1185
|
+
);
|
|
1186
|
+
if (posthogClient) await posthogClient.shutdown();
|
|
1187
|
+
exit(1);
|
|
1188
|
+
}
|
|
1189
|
+
themeChoice = res.theme;
|
|
1150
1190
|
}
|
|
1151
|
-
themeChoice = res.theme;
|
|
1152
1191
|
}
|
|
1153
1192
|
const rootDir = path3.join(process.cwd(), projectName);
|
|
1154
1193
|
if (!await isWriteable(path3.dirname(rootDir))) {
|
|
@@ -1165,10 +1204,7 @@ No personal or project-specific code is ever collected. You can opt out at any t
|
|
|
1165
1204
|
errorCategory: "filesystem",
|
|
1166
1205
|
step: TRACKING_STEPS.DIRECTORY_SETUP,
|
|
1167
1206
|
fatal: true,
|
|
1168
|
-
additionalProperties: {
|
|
1169
|
-
...telemetryData,
|
|
1170
|
-
template: template.value
|
|
1171
|
-
}
|
|
1207
|
+
additionalProperties: { ...telemetryData }
|
|
1172
1208
|
}
|
|
1173
1209
|
);
|
|
1174
1210
|
if (posthogClient) await posthogClient.shutdown();
|
|
@@ -1186,16 +1222,14 @@ No personal or project-specific code is ever collected. You can opt out at any t
|
|
|
1186
1222
|
errorCategory: "filesystem",
|
|
1187
1223
|
step: TRACKING_STEPS.DIRECTORY_SETUP,
|
|
1188
1224
|
fatal: true,
|
|
1189
|
-
additionalProperties: {
|
|
1190
|
-
...telemetryData,
|
|
1191
|
-
template: template.value
|
|
1192
|
-
}
|
|
1225
|
+
additionalProperties: { ...telemetryData }
|
|
1193
1226
|
});
|
|
1194
1227
|
if (posthogClient) await posthogClient.shutdown();
|
|
1195
1228
|
exit(1);
|
|
1196
1229
|
}
|
|
1197
1230
|
try {
|
|
1198
1231
|
if (themeChoice) {
|
|
1232
|
+
telemetryData["theme"] = themeChoice;
|
|
1199
1233
|
await updateThemeSettings(rootDir, themeChoice);
|
|
1200
1234
|
}
|
|
1201
1235
|
spinner.start("Downloading template...");
|
|
@@ -1204,6 +1238,9 @@ No personal or project-specific code is ever collected. You can opt out at any t
|
|
|
1204
1238
|
spinner.start("Updating project metadata...");
|
|
1205
1239
|
updateProjectPackageName(rootDir, projectName);
|
|
1206
1240
|
updateProjectPackageVersion(rootDir, "0.0.1");
|
|
1241
|
+
if (opts.noTelemetry) {
|
|
1242
|
+
await updateTelemetryConfig(rootDir, "disabled");
|
|
1243
|
+
}
|
|
1207
1244
|
spinner.succeed();
|
|
1208
1245
|
} catch (err) {
|
|
1209
1246
|
const error = err;
|
|
@@ -1213,11 +1250,7 @@ No personal or project-specific code is ever collected. You can opt out at any t
|
|
|
1213
1250
|
errorCategory: "template",
|
|
1214
1251
|
step: TRACKING_STEPS.DOWNLOADING_TEMPLATE,
|
|
1215
1252
|
fatal: true,
|
|
1216
|
-
additionalProperties: {
|
|
1217
|
-
...telemetryData,
|
|
1218
|
-
template: template.value,
|
|
1219
|
-
theme: themeChoice
|
|
1220
|
-
}
|
|
1253
|
+
additionalProperties: { ...telemetryData }
|
|
1221
1254
|
});
|
|
1222
1255
|
if (posthogClient) await posthogClient.shutdown();
|
|
1223
1256
|
exit(1);
|
|
@@ -1235,11 +1268,7 @@ No personal or project-specific code is ever collected. You can opt out at any t
|
|
|
1235
1268
|
errorCategory: "installation",
|
|
1236
1269
|
step: TRACKING_STEPS.INSTALLING_PACKAGES,
|
|
1237
1270
|
fatal: false,
|
|
1238
|
-
additionalProperties: {
|
|
1239
|
-
...telemetryData,
|
|
1240
|
-
template: template.value,
|
|
1241
|
-
package_manager: pkgManager
|
|
1242
|
-
}
|
|
1271
|
+
additionalProperties: { ...telemetryData }
|
|
1243
1272
|
});
|
|
1244
1273
|
}
|
|
1245
1274
|
spinner.start("Initializing git repository.");
|
|
@@ -1256,10 +1285,7 @@ No personal or project-specific code is ever collected. You can opt out at any t
|
|
|
1256
1285
|
errorCategory: "git",
|
|
1257
1286
|
step: TRACKING_STEPS.GIT_INIT,
|
|
1258
1287
|
fatal: false,
|
|
1259
|
-
additionalProperties: {
|
|
1260
|
-
...telemetryData,
|
|
1261
|
-
template: template.value
|
|
1262
|
-
}
|
|
1288
|
+
additionalProperties: { ...telemetryData }
|
|
1263
1289
|
});
|
|
1264
1290
|
}
|
|
1265
1291
|
postHogCapture(
|
package/dist/util/fileUtil.d.ts
CHANGED
|
@@ -4,3 +4,8 @@ export declare function setupProjectDirectory(dir: string): Promise<string>;
|
|
|
4
4
|
export declare function updateProjectPackageName(dir: string, name: string): void;
|
|
5
5
|
export declare function updateProjectPackageVersion(dir: string, version: string): void;
|
|
6
6
|
export declare function updateThemeSettings(dir: string, selectedTheme: string): Promise<void>;
|
|
7
|
+
/**
|
|
8
|
+
* Updates the tina config file to set the telemetry mode.
|
|
9
|
+
* This modifies the TypeScript/JavaScript config file by inserting the telemetry setting.
|
|
10
|
+
*/
|
|
11
|
+
export declare function updateTelemetryConfig(dir: string, mode: 'anonymous' | 'disabled'): Promise<void>;
|
package/dist/util/options.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-tina-app",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.3",
|
|
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.
|
|
39
|
+
"@tinacms/scripts": "1.6.0"
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
42
|
"chalk": "^5.4.1",
|