@tinacms/cli 2.3.0 → 2.4.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/dist/cmds/forestry-migrate/util/index.d.ts +2 -2
- package/dist/cmds/init/index.d.ts +1 -0
- package/dist/index.js +447 -270
- package/dist/next/build-database-esbuild-config.d.ts +38 -0
- package/dist/next/cache-manager.d.ts +51 -0
- package/dist/next/commands/build-command/index.d.ts +3 -0
- package/dist/next/external-resolver.d.ts +23 -0
- package/dist/utils/fetchPostHogConfig.d.ts +5 -0
- package/dist/utils/posthog.d.ts +21 -0
- package/package.json +8 -6
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { BuildOptions, Loader } from 'esbuild';
|
|
2
|
+
/**
|
|
3
|
+
* Construct the esbuild options used by `loadDatabaseFile()` to bundle a
|
|
4
|
+
* user's `tina/database.ts`.
|
|
5
|
+
*
|
|
6
|
+
* Extracted from `config-manager.ts` so the externalize / output-path
|
|
7
|
+
* contract — both critical for the ESM native-module fix (#6675, #6750) —
|
|
8
|
+
* can be locked down by unit tests without spinning up the full
|
|
9
|
+
* ConfigManager (which uses `import.meta.url` at module load and isn't
|
|
10
|
+
* directly importable from Jest's CJS runtime).
|
|
11
|
+
*
|
|
12
|
+
* The contract enforced here is intentionally strict:
|
|
13
|
+
*
|
|
14
|
+
* - `external` is set to the caller-provided list (typically the curated
|
|
15
|
+
* baseline + `build.externalDependencies`). NEVER set `packages: 'external'`
|
|
16
|
+
* — broad-externalize would also externalize CJS UMD packages like
|
|
17
|
+
* `sqlite-level` (v1) and `mongodb-level`, breaking user-side named imports
|
|
18
|
+
* because Node's `cjs-module-lexer` can't reliably detect their exports.
|
|
19
|
+
* See #6785 for the regression test that locks this down.
|
|
20
|
+
*
|
|
21
|
+
* - `outfile` is whatever the caller passes in. The caller is responsible for
|
|
22
|
+
* constructing a path inside the project tree (typically via
|
|
23
|
+
* `prepareCacheLocation()` from `cache-manager.ts`) so Node's runtime
|
|
24
|
+
* resolver can walk up to the project's `node_modules` and find the
|
|
25
|
+
* externalized packages.
|
|
26
|
+
*/
|
|
27
|
+
export declare const buildDatabaseEsbuildConfig: (opts: {
|
|
28
|
+
/** Path to the user's `tina/database.ts`. */
|
|
29
|
+
entryPoint: string;
|
|
30
|
+
/** Where esbuild writes the bundled `.mjs`. Must be inside the project tree. */
|
|
31
|
+
outfile: string;
|
|
32
|
+
/** Externalized package names (must include `better-sqlite3` baseline). */
|
|
33
|
+
external: string[];
|
|
34
|
+
/** Loader map shared with the rest of the CLI (asset extensions, .ts/.tsx, etc.). */
|
|
35
|
+
loader: {
|
|
36
|
+
[ext: string]: Loader;
|
|
37
|
+
};
|
|
38
|
+
}) => BuildOptions;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Per-build cache layout under `tina/__generated__/.cache/`.
|
|
3
|
+
*
|
|
4
|
+
* Each `tinacms dev` / `tinacms build` invocation creates one
|
|
5
|
+
* `<timestamp>/` subdir for esbuild output. The subdir is removed after
|
|
6
|
+
* the dynamic-import resolves; the parent is swept on next startup to
|
|
7
|
+
* mop up anything a crashed run (Ctrl+C mid-build, OOM kill, etc.) left
|
|
8
|
+
* behind.
|
|
9
|
+
*/
|
|
10
|
+
export type CacheLocation = {
|
|
11
|
+
/** `<project>/tina/__generated__/.cache/` — the long-lived parent. */
|
|
12
|
+
parentPath: string;
|
|
13
|
+
/** `<project>/tina/__generated__/.cache/<timestamp>/` — fresh per build. */
|
|
14
|
+
buildPath: string;
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* Build the user-facing error message thrown when the cache parent can't
|
|
18
|
+
* be written to (Docker `:ro` mount, AWS Lambda `/var/task`, sandboxed CI
|
|
19
|
+
* runner, restricted file permissions, …).
|
|
20
|
+
*
|
|
21
|
+
* Exported for testing — kept separate from {@link prepareCacheLocation}
|
|
22
|
+
* so the message contract can be locked down without spinning up a real
|
|
23
|
+
* read-only directory.
|
|
24
|
+
*/
|
|
25
|
+
export declare const buildReadOnlyMountErrorMessage: (cacheParentPath: string, underlyingError: NodeJS.ErrnoException) => string;
|
|
26
|
+
/**
|
|
27
|
+
* Sweep stale cache residue, ensure the parent dir exists and is
|
|
28
|
+
* writable, and return the fresh per-build cache location.
|
|
29
|
+
*
|
|
30
|
+
* Throws an actionable error (built via
|
|
31
|
+
* {@link buildReadOnlyMountErrorMessage}) when the project tree can't
|
|
32
|
+
* be written to.
|
|
33
|
+
*
|
|
34
|
+
* @param generatedFolderPath The project's `tina/__generated__/` dir.
|
|
35
|
+
* @param now Override for the timestamp (tests pass a fixed value;
|
|
36
|
+
* production passes nothing so `Date.now()` is used).
|
|
37
|
+
*/
|
|
38
|
+
export declare const prepareCacheLocation: (generatedFolderPath: string, now?: number) => Promise<CacheLocation>;
|
|
39
|
+
/**
|
|
40
|
+
* Cleanup a per-load build subdir after its dynamic-import resolves.
|
|
41
|
+
*
|
|
42
|
+
* Removes the subdir entirely (not just the .mjs file), then attempts
|
|
43
|
+
* to reap the timestamp parent if it's now empty — the sibling load
|
|
44
|
+
* function may have already finished and removed its own subdir.
|
|
45
|
+
*
|
|
46
|
+
* `ENOTEMPTY` is the expected case for the parent reap (other content
|
|
47
|
+
* still in flight) and is safely deferred to the next startup sweep.
|
|
48
|
+
* Any other error re-throws so genuine permission / filesystem issues
|
|
49
|
+
* surface instead of being silently swallowed.
|
|
50
|
+
*/
|
|
51
|
+
export declare const reapBuildSubdir: (buildSubdirPath: string, buildParentPath: string) => void;
|
|
@@ -18,6 +18,9 @@ export declare class BuildCommand extends BaseCommand {
|
|
|
18
18
|
previewName: string;
|
|
19
19
|
noClientBuildCache: boolean;
|
|
20
20
|
static usage: import("clipanion").Usage;
|
|
21
|
+
private posthogClient;
|
|
22
|
+
private buildStartedAt;
|
|
23
|
+
private buildRunId;
|
|
21
24
|
catch(error: any): Promise<void>;
|
|
22
25
|
execute(): Promise<number | void>;
|
|
23
26
|
checkClientInfo(configManager: ConfigManager, apiURL: string, previewBaseBranch?: string): Promise<{
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { Config } from '@tinacms/schema-tools';
|
|
2
|
+
/**
|
|
3
|
+
* Packages always externalized when bundling `tina/database.ts`.
|
|
4
|
+
*
|
|
5
|
+
* `better-sqlite3` is a native CJS module — it ships a `.node` binary and its
|
|
6
|
+
* `bindings` dependency uses `__filename` to locate it. Both fundamentals are
|
|
7
|
+
* incompatible with ESM bundling, so it must be left as a runtime import.
|
|
8
|
+
*
|
|
9
|
+
* Users can extend this list via `build.externalDependencies` in their
|
|
10
|
+
* `tina/config.ts` when they need to externalize additional packages (e.g.
|
|
11
|
+
* a custom native adapter outside this baseline).
|
|
12
|
+
*/
|
|
13
|
+
export declare const EXTERNAL_BASELINE: string[];
|
|
14
|
+
/**
|
|
15
|
+
* Resolve the full list of packages to externalize when bundling
|
|
16
|
+
* `tina/database.ts`. Combines the always-on baseline (which fixes native
|
|
17
|
+
* modules out of the box) with the user-provided
|
|
18
|
+
* `build.externalDependencies` extension list from their config.
|
|
19
|
+
*
|
|
20
|
+
* Order is significant: baseline first, then user list — so users can't
|
|
21
|
+
* accidentally remove an item from the baseline by listing it themselves.
|
|
22
|
+
*/
|
|
23
|
+
export declare const resolveDatabaseExternals: (config: Config | undefined) => string[];
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { PostHog } from 'posthog-node';
|
|
2
|
+
export declare function generateSessionId(): string;
|
|
3
|
+
export declare const BuildInvokeEvent = "tinacms-cli-build-invoke";
|
|
4
|
+
export type BuildInvokeEventPayload = {
|
|
5
|
+
hasLocalOption: boolean;
|
|
6
|
+
hasContentLocal: boolean;
|
|
7
|
+
skipIndexing: boolean;
|
|
8
|
+
partialReindex: boolean;
|
|
9
|
+
hasPreviewName: boolean;
|
|
10
|
+
specifiesTinaGraphQLVersions?: boolean;
|
|
11
|
+
skipCloudChecks: boolean;
|
|
12
|
+
skipSearchIndex: boolean;
|
|
13
|
+
};
|
|
14
|
+
export declare const BuildFinishedEvent = "tinacms-cli-build-finished";
|
|
15
|
+
export type BuildFinishedEventPayload = {
|
|
16
|
+
success: boolean;
|
|
17
|
+
durationMs: number;
|
|
18
|
+
errorCode?: string;
|
|
19
|
+
};
|
|
20
|
+
export declare function initializePostHog(configEndpoint?: string, disableGeoip?: boolean): Promise<PostHog | null>;
|
|
21
|
+
export declare function postHogCapture(client: PostHog, distinctId: string, event: string, properties: Record<string, any>): void;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tinacms/cli",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "2.
|
|
4
|
+
"version": "2.4.0",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"typings": "dist/index.d.ts",
|
|
7
7
|
"files": [
|
|
@@ -41,6 +41,7 @@
|
|
|
41
41
|
"@types/progress": "^2.0.7",
|
|
42
42
|
"@types/prompts": "^2.4.9",
|
|
43
43
|
"jest": "^29.7.0",
|
|
44
|
+
"ts-jest": "^29.2.5",
|
|
44
45
|
"@tinacms/scripts": "1.6.1"
|
|
45
46
|
},
|
|
46
47
|
"dependencies": {
|
|
@@ -78,6 +79,7 @@
|
|
|
78
79
|
"memory-level": "^1.0.0",
|
|
79
80
|
"minimatch": "^5.1.6",
|
|
80
81
|
"normalize-path": "^3.0.0",
|
|
82
|
+
"posthog-node": "^5.17.2",
|
|
81
83
|
"prettier": "^2.8.8",
|
|
82
84
|
"progress": "^2.0.3",
|
|
83
85
|
"prompts": "^2.4.2",
|
|
@@ -88,12 +90,12 @@
|
|
|
88
90
|
"vite": "^4.5.9",
|
|
89
91
|
"yup": "^1.6.1",
|
|
90
92
|
"zod": "^3.24.2",
|
|
91
|
-
"@tinacms/graphql": "2.4.0",
|
|
92
|
-
"@tinacms/schema-tools": "2.7.4",
|
|
93
93
|
"@tinacms/metrics": "2.1.0",
|
|
94
|
-
"@tinacms/
|
|
95
|
-
"@tinacms/
|
|
96
|
-
"tinacms": "
|
|
94
|
+
"@tinacms/app": "2.5.0",
|
|
95
|
+
"@tinacms/schema-tools": "2.8.0",
|
|
96
|
+
"@tinacms/graphql": "2.4.2",
|
|
97
|
+
"@tinacms/search": "1.2.16",
|
|
98
|
+
"tinacms": "3.8.2"
|
|
97
99
|
},
|
|
98
100
|
"publishConfig": {
|
|
99
101
|
"registry": "https://registry.npmjs.org"
|