create-tina-app 1.6.2 → 2.1.0
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/bin/create-tina-app +1 -1
- package/dist/index.js +775 -147
- package/dist/templates.d.ts +6 -0
- package/dist/util/asciiArt.d.ts +1 -0
- package/dist/util/fetchPosthogConfig.d.ts +5 -0
- package/dist/util/isNpm.d.ts +16 -0
- package/dist/util/posthog.d.ts +147 -0
- package/dist/util/textstyles.d.ts +17 -8
- package/package.json +7 -6
package/dist/templates.d.ts
CHANGED
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
import { Ora } from 'ora';
|
|
2
|
+
type Feature = {
|
|
3
|
+
name: string;
|
|
4
|
+
description: string;
|
|
5
|
+
};
|
|
2
6
|
export type BaseExample = {
|
|
3
7
|
title: string;
|
|
4
8
|
description?: string;
|
|
9
|
+
features?: Feature[];
|
|
5
10
|
value: string;
|
|
6
11
|
devUrl: string;
|
|
7
12
|
};
|
|
@@ -15,3 +20,4 @@ export type ExternalTemplate = BaseExample & {
|
|
|
15
20
|
export type Template = InternalTemplate | ExternalTemplate;
|
|
16
21
|
export declare const TEMPLATES: Template[];
|
|
17
22
|
export declare function downloadTemplate(template: Template, root: string, spinner: Ora): Promise<void>;
|
|
23
|
+
export {};
|
package/dist/util/asciiArt.d.ts
CHANGED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @typedef {Object} ValidationResult
|
|
3
|
+
* @property {string | null} message
|
|
4
|
+
* @property {boolean} isError
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Validates whether the provided name is valid on NPM.
|
|
8
|
+
*
|
|
9
|
+
* @param {string} name
|
|
10
|
+
* @returns {ValidationResult}
|
|
11
|
+
*/
|
|
12
|
+
export default function validate(name: string): ValidationResult;
|
|
13
|
+
export type ValidationResult = {
|
|
14
|
+
message: string | null;
|
|
15
|
+
isError: boolean;
|
|
16
|
+
};
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
import { PostHog } from 'posthog-node';
|
|
2
|
+
export declare const CreateTinaAppStartedEvent: string;
|
|
3
|
+
export declare const CreateTinaAppFinishedEvent: string;
|
|
4
|
+
/**
|
|
5
|
+
* Step names for tracking progress through the create-tina-app process
|
|
6
|
+
*/
|
|
7
|
+
export declare const TRACKING_STEPS: {
|
|
8
|
+
readonly INIT: "initializing";
|
|
9
|
+
readonly PRE_RUN_CHECKS: "pre_run_checks";
|
|
10
|
+
readonly TELEMETRY_SETUP: "telemetry_setup";
|
|
11
|
+
readonly PKG_MANAGER_SELECT: "package_manager_selection";
|
|
12
|
+
readonly PROJECT_NAME_INPUT: "project_name_input";
|
|
13
|
+
readonly TEMPLATE_SELECT: "template_selection";
|
|
14
|
+
readonly THEME_SELECT: "theme_selection";
|
|
15
|
+
readonly DIRECTORY_SETUP: "directory_setup";
|
|
16
|
+
readonly DOWNLOADING_TEMPLATE: "downloading_template";
|
|
17
|
+
readonly UPDATING_METADATA: "updating_metadata";
|
|
18
|
+
readonly INSTALLING_PACKAGES: "installing_packages";
|
|
19
|
+
readonly GIT_INIT: "git_initialization";
|
|
20
|
+
readonly COMPLETE: "complete";
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* Generate a unique session ID for this run
|
|
24
|
+
*/
|
|
25
|
+
export declare function generateSessionId(): string;
|
|
26
|
+
/**
|
|
27
|
+
* Get a hashed user ID based on system UUID
|
|
28
|
+
* Returns a consistent anonymous identifier for the machine
|
|
29
|
+
*/
|
|
30
|
+
export declare function getAnonymousUserId(): Promise<string>;
|
|
31
|
+
/**
|
|
32
|
+
* Structured error codes for categorizing failures
|
|
33
|
+
*/
|
|
34
|
+
export declare const ERROR_CODES: {
|
|
35
|
+
readonly ERR_VAL_INVALID_TEMPLATE: "ERR_VAL_INVALID_TEMPLATE";
|
|
36
|
+
readonly ERR_VAL_INVALID_PKG_MANAGER: "ERR_VAL_INVALID_PKG_MANAGER";
|
|
37
|
+
readonly ERR_VAL_INVALID_PROJECT_NAME: "ERR_VAL_INVALID_PROJECT_NAME";
|
|
38
|
+
readonly ERR_VAL_UNSUPPORTED_NODE: "ERR_VAL_UNSUPPORTED_NODE";
|
|
39
|
+
readonly ERR_VAL_NO_PKG_MANAGERS: "ERR_VAL_NO_PKG_MANAGERS";
|
|
40
|
+
readonly ERR_FS_NOT_WRITABLE: "ERR_FS_NOT_WRITABLE";
|
|
41
|
+
readonly ERR_FS_HAS_CONFLICTS: "ERR_FS_HAS_CONFLICTS";
|
|
42
|
+
readonly ERR_FS_MKDIR_FAILED: "ERR_FS_MKDIR_FAILED";
|
|
43
|
+
readonly ERR_FS_CHDIR_FAILED: "ERR_FS_CHDIR_FAILED";
|
|
44
|
+
readonly ERR_FS_READ_PACKAGE_JSON: "ERR_FS_READ_PACKAGE_JSON";
|
|
45
|
+
readonly ERR_FS_WRITE_PACKAGE_JSON: "ERR_FS_WRITE_PACKAGE_JSON";
|
|
46
|
+
readonly ERR_FS_UPDATE_THEME_FAILED: "ERR_FS_UPDATE_THEME_FAILED";
|
|
47
|
+
readonly ERR_FS_COPY_TEMPLATE_FAILED: "ERR_FS_COPY_TEMPLATE_FAILED";
|
|
48
|
+
readonly ERR_NET_POSTHOG_CONFIG_FETCH: "ERR_NET_POSTHOG_CONFIG_FETCH";
|
|
49
|
+
readonly ERR_NET_TARBALL_DOWNLOAD: "ERR_NET_TARBALL_DOWNLOAD";
|
|
50
|
+
readonly ERR_NET_GITHUB_API_FAILED: "ERR_NET_GITHUB_API_FAILED";
|
|
51
|
+
readonly ERR_NET_REPO_INFO_NOT_FOUND: "ERR_NET_REPO_INFO_NOT_FOUND";
|
|
52
|
+
readonly ERR_NET_REPO_INVALID_URL: "ERR_NET_REPO_INVALID_URL";
|
|
53
|
+
readonly ERR_NET_TARBALL_EXTRACT: "ERR_NET_TARBALL_EXTRACT";
|
|
54
|
+
readonly ERR_INSTALL_PKG_MANAGER_FAILED: "ERR_INSTALL_PKG_MANAGER_FAILED";
|
|
55
|
+
readonly ERR_INSTALL_PKG_MANAGER_NOT_FOUND: "ERR_INSTALL_PKG_MANAGER_NOT_FOUND";
|
|
56
|
+
readonly ERR_INSTALL_SPAWN_ERROR: "ERR_INSTALL_SPAWN_ERROR";
|
|
57
|
+
readonly ERR_INSTALL_TIMEOUT: "ERR_INSTALL_TIMEOUT";
|
|
58
|
+
readonly ERR_GIT_NOT_INSTALLED: "ERR_GIT_NOT_INSTALLED";
|
|
59
|
+
readonly ERR_GIT_INIT_FAILED: "ERR_GIT_INIT_FAILED";
|
|
60
|
+
readonly ERR_GIT_ADD_FAILED: "ERR_GIT_ADD_FAILED";
|
|
61
|
+
readonly ERR_GIT_COMMIT_FAILED: "ERR_GIT_COMMIT_FAILED";
|
|
62
|
+
readonly ERR_GIT_CHECKOUT_FAILED: "ERR_GIT_CHECKOUT_FAILED";
|
|
63
|
+
readonly ERR_GIT_ALREADY_INITIALIZED: "ERR_GIT_ALREADY_INITIALIZED";
|
|
64
|
+
readonly ERR_CANCEL_PKG_MANAGER_PROMPT: "ERR_CANCEL_PKG_MANAGER_PROMPT";
|
|
65
|
+
readonly ERR_CANCEL_PROJECT_NAME_PROMPT: "ERR_CANCEL_PROJECT_NAME_PROMPT";
|
|
66
|
+
readonly ERR_CANCEL_TEMPLATE_PROMPT: "ERR_CANCEL_TEMPLATE_PROMPT";
|
|
67
|
+
readonly ERR_CANCEL_THEME_PROMPT: "ERR_CANCEL_THEME_PROMPT";
|
|
68
|
+
readonly ERR_CANCEL_SIGINT: "ERR_CANCEL_SIGINT";
|
|
69
|
+
readonly ERR_CFG_POSTHOG_INIT_FAILED: "ERR_CFG_POSTHOG_INIT_FAILED";
|
|
70
|
+
readonly ERR_CFG_OSINFO_FETCH_FAILED: "ERR_CFG_OSINFO_FETCH_FAILED";
|
|
71
|
+
readonly ERR_CFG_TELEMETRY_SETUP_FAILED: "ERR_CFG_TELEMETRY_SETUP_FAILED";
|
|
72
|
+
readonly ERR_TPL_DOWNLOAD_FAILED: "ERR_TPL_DOWNLOAD_FAILED";
|
|
73
|
+
readonly ERR_TPL_EXTRACT_FAILED: "ERR_TPL_EXTRACT_FAILED";
|
|
74
|
+
readonly ERR_TPL_METADATA_UPDATE_FAILED: "ERR_TPL_METADATA_UPDATE_FAILED";
|
|
75
|
+
readonly ERR_TPL_INTERNAL_COPY_FAILED: "ERR_TPL_INTERNAL_COPY_FAILED";
|
|
76
|
+
readonly ERR_TPL_THEME_UPDATE_FAILED: "ERR_TPL_THEME_UPDATE_FAILED";
|
|
77
|
+
readonly ERR_UNCAUGHT: "ERR_UNCAUGHT";
|
|
78
|
+
};
|
|
79
|
+
/**
|
|
80
|
+
* Sends an event to PostHog for analytics tracking.
|
|
81
|
+
*
|
|
82
|
+
* @param client - The PostHog client instance used to send the event
|
|
83
|
+
* @param distinctId - A unique identifier for the user (hashed system UUID)
|
|
84
|
+
* @param sessionId - A unique identifier for this run/session
|
|
85
|
+
* @param event - The name of the event to track (e.g., 'create-tina-app-started')
|
|
86
|
+
* @param properties - Additional properties to include with the event
|
|
87
|
+
*
|
|
88
|
+
* @remarks
|
|
89
|
+
* - Returns early if the PostHog client is not provided
|
|
90
|
+
* - Skips sending data when `TINA_DEV` environment variable is set to 'true'
|
|
91
|
+
* - Automatically adds a 'system' property with value 'tinacms/create-tina-app'
|
|
92
|
+
* - Includes sessionId in properties to track individual runs
|
|
93
|
+
* - Uses hashed system UUID as distinctId to track unique users anonymously
|
|
94
|
+
* - Logs errors to console if event capture fails
|
|
95
|
+
*
|
|
96
|
+
* @example
|
|
97
|
+
* ```typescript
|
|
98
|
+
* const client = new PostHog('api-key');
|
|
99
|
+
* const userId = await getAnonymousUserId();
|
|
100
|
+
* const sessionId = generateSessionId();
|
|
101
|
+
* postHogCapture(client, userId, sessionId, 'create-tina-app-started', {
|
|
102
|
+
* template: 'basic',
|
|
103
|
+
* typescript: true
|
|
104
|
+
* });
|
|
105
|
+
* ```
|
|
106
|
+
*/
|
|
107
|
+
export declare function postHogCapture(client: PostHog, distinctId: string, sessionId: string, event: string, properties: Record<string, any>): void;
|
|
108
|
+
/**
|
|
109
|
+
* Capture an error event in PostHog with categorized tracking and sanitized stack traces
|
|
110
|
+
*
|
|
111
|
+
* @param client - The PostHog client instance
|
|
112
|
+
* @param distinctId - A unique identifier for the user (hashed system UUID)
|
|
113
|
+
* @param sessionId - A unique identifier for this run/session
|
|
114
|
+
* @param error - The error object that was thrown
|
|
115
|
+
* @param context - Context about the error including code, category, step, and additional properties
|
|
116
|
+
*
|
|
117
|
+
* @remarks
|
|
118
|
+
* - Sanitizes stack traces to remove local file paths
|
|
119
|
+
* - Maps error categories to three event types:
|
|
120
|
+
* - 'create-tina-app-error' for technical failures (filesystem, network, installation, git, etc.)
|
|
121
|
+
* - 'create-tina-app-validation-error' for user input validation issues
|
|
122
|
+
* - 'create-tina-app-user-cancelled' for user cancellations (Ctrl+C)
|
|
123
|
+
* - Includes error code, sanitized stack, step name, and telemetry data in properties
|
|
124
|
+
* - Non-fatal errors are tracked but allow the process to continue
|
|
125
|
+
*
|
|
126
|
+
* @example
|
|
127
|
+
* ```typescript
|
|
128
|
+
* try {
|
|
129
|
+
* await downloadTemplate();
|
|
130
|
+
* } catch (err) {
|
|
131
|
+
* postHogCaptureError(client, userId, sessionId, err as Error, {
|
|
132
|
+
* errorCode: ERROR_CODES.ERR_TPL_DOWNLOAD_FAILED,
|
|
133
|
+
* errorCategory: 'template',
|
|
134
|
+
* step: TRACKING_STEPS.DOWNLOADING_TEMPLATE,
|
|
135
|
+
* fatal: true,
|
|
136
|
+
* additionalProperties: { template: 'basic' }
|
|
137
|
+
* });
|
|
138
|
+
* }
|
|
139
|
+
* ```
|
|
140
|
+
*/
|
|
141
|
+
export declare function postHogCaptureError(client: PostHog | null, distinctId: string, sessionId: string, error: Error, context: {
|
|
142
|
+
errorCode: string;
|
|
143
|
+
errorCategory: string;
|
|
144
|
+
step: string;
|
|
145
|
+
fatal?: boolean;
|
|
146
|
+
additionalProperties?: Record<string, any>;
|
|
147
|
+
}): void;
|
|
@@ -1,11 +1,20 @@
|
|
|
1
|
-
import chalk from 'chalk';
|
|
2
1
|
export declare const TextStyles: {
|
|
3
|
-
tinaOrange: chalk.
|
|
2
|
+
tinaOrange: import("chalk").ChalkInstance;
|
|
4
3
|
link: (url: string) => string;
|
|
5
|
-
cmd: chalk.
|
|
6
|
-
info: chalk.
|
|
7
|
-
success: chalk.
|
|
8
|
-
warn: chalk.
|
|
9
|
-
err: chalk.
|
|
10
|
-
bold: chalk.
|
|
4
|
+
cmd: import("chalk").ChalkInstance;
|
|
5
|
+
info: import("chalk").ChalkInstance;
|
|
6
|
+
success: import("chalk").ChalkInstance;
|
|
7
|
+
warn: import("chalk").ChalkInstance;
|
|
8
|
+
err: import("chalk").ChalkInstance;
|
|
9
|
+
bold: import("chalk").ChalkInstance;
|
|
10
|
+
};
|
|
11
|
+
export declare const TextStylesBold: {
|
|
12
|
+
tinaOrange: import("chalk").ChalkInstance;
|
|
13
|
+
link: (url: string) => string;
|
|
14
|
+
cmd: import("chalk").ChalkInstance;
|
|
15
|
+
info: import("chalk").ChalkInstance;
|
|
16
|
+
success: import("chalk").ChalkInstance;
|
|
17
|
+
warn: import("chalk").ChalkInstance;
|
|
18
|
+
err: import("chalk").ChalkInstance;
|
|
19
|
+
bold: import("chalk").ChalkInstance;
|
|
11
20
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-tina-app",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "2.1.0",
|
|
4
|
+
"type": "module",
|
|
4
5
|
"main": "dist/index.js",
|
|
5
6
|
"files": [
|
|
6
7
|
"dist",
|
|
@@ -35,18 +36,18 @@
|
|
|
35
36
|
"@types/prompts": "^2.4.9",
|
|
36
37
|
"@types/tar": "6.1.13",
|
|
37
38
|
"typescript": "^5.7.3",
|
|
38
|
-
"@tinacms/scripts": "1.4.
|
|
39
|
+
"@tinacms/scripts": "1.4.2"
|
|
39
40
|
},
|
|
40
41
|
"dependencies": {
|
|
41
|
-
"chalk": "4.1
|
|
42
|
+
"chalk": "^5.4.1",
|
|
42
43
|
"commander": "^12.1.0",
|
|
43
44
|
"cross-spawn": "^7.0.6",
|
|
44
45
|
"fs-extra": "^11.3.0",
|
|
45
46
|
"ora": "^8.2.0",
|
|
47
|
+
"posthog-node": "^5.17.2",
|
|
46
48
|
"prompts": "^2.4.2",
|
|
47
|
-
"
|
|
48
|
-
"
|
|
49
|
-
"@tinacms/metrics": "2.0.0"
|
|
49
|
+
"systeminformation": "^5.27.13",
|
|
50
|
+
"tar": "7.4.0"
|
|
50
51
|
},
|
|
51
52
|
"scripts": {
|
|
52
53
|
"types": "pnpm tsc",
|