create-tina-app 2.1.2 → 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 +71 -27
- 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);
|
|
@@ -1120,33 +1150,44 @@ ${TextStylesBold.bold("Telemetry Notice")}`);
|
|
|
1120
1150
|
telemetryData["template"] = template.value;
|
|
1121
1151
|
let themeChoice;
|
|
1122
1152
|
if (template.value === "tina-docs") {
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
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
|
+
}
|
|
1143
1184
|
}
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1185
|
+
);
|
|
1186
|
+
if (posthogClient) await posthogClient.shutdown();
|
|
1187
|
+
exit(1);
|
|
1188
|
+
}
|
|
1189
|
+
themeChoice = res.theme;
|
|
1148
1190
|
}
|
|
1149
|
-
themeChoice = res.theme;
|
|
1150
1191
|
}
|
|
1151
1192
|
const rootDir = path3.join(process.cwd(), projectName);
|
|
1152
1193
|
if (!await isWriteable(path3.dirname(rootDir))) {
|
|
@@ -1197,6 +1238,9 @@ ${TextStylesBold.bold("Telemetry Notice")}`);
|
|
|
1197
1238
|
spinner.start("Updating project metadata...");
|
|
1198
1239
|
updateProjectPackageName(rootDir, projectName);
|
|
1199
1240
|
updateProjectPackageVersion(rootDir, "0.0.1");
|
|
1241
|
+
if (opts.noTelemetry) {
|
|
1242
|
+
await updateTelemetryConfig(rootDir, "disabled");
|
|
1243
|
+
}
|
|
1200
1244
|
spinner.succeed();
|
|
1201
1245
|
} catch (err) {
|
|
1202
1246
|
const error = err;
|
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",
|