@tinacms/cli 2.1.7 → 2.1.8
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 +78 -12
- package/dist/next/database.d.ts +1 -1
- package/dist/next/vite/cors.d.ts +13 -0
- package/dist/next/vite/plugins.d.ts +2 -2
- package/package.json +6 -6
package/dist/index.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { Cli, Builtins } from "clipanion";
|
|
3
3
|
|
|
4
4
|
// package.json
|
|
5
|
-
var version = "2.1.
|
|
5
|
+
var version = "2.1.8";
|
|
6
6
|
|
|
7
7
|
// src/next/commands/dev-command/index.ts
|
|
8
8
|
import path8 from "path";
|
|
@@ -1255,15 +1255,15 @@ var loaders = {
|
|
|
1255
1255
|
};
|
|
1256
1256
|
|
|
1257
1257
|
// src/next/database.ts
|
|
1258
|
+
import { createServer } from "net";
|
|
1258
1259
|
import {
|
|
1259
|
-
createDatabaseInternal,
|
|
1260
1260
|
FilesystemBridge,
|
|
1261
|
-
TinaLevelClient
|
|
1261
|
+
TinaLevelClient,
|
|
1262
|
+
createDatabaseInternal
|
|
1262
1263
|
} from "@tinacms/graphql";
|
|
1263
|
-
import { pipeline } from "readable-stream";
|
|
1264
|
-
import { createServer } from "net";
|
|
1265
1264
|
import { ManyLevelHost } from "many-level";
|
|
1266
1265
|
import { MemoryLevel } from "memory-level";
|
|
1266
|
+
import { pipeline } from "readable-stream";
|
|
1267
1267
|
var createDBServer = (port) => {
|
|
1268
1268
|
const levelHost = new ManyLevelHost(
|
|
1269
1269
|
// @ts-ignore
|
|
@@ -1282,7 +1282,7 @@ var createDBServer = (port) => {
|
|
|
1282
1282
|
);
|
|
1283
1283
|
}
|
|
1284
1284
|
});
|
|
1285
|
-
dbServer.listen(port);
|
|
1285
|
+
dbServer.listen(port, "localhost");
|
|
1286
1286
|
};
|
|
1287
1287
|
async function createAndInitializeDatabase(configManager, datalayerPort, bridgeOverride) {
|
|
1288
1288
|
let database;
|
|
@@ -1586,6 +1586,43 @@ import {
|
|
|
1586
1586
|
splitVendorChunkPlugin
|
|
1587
1587
|
} from "vite";
|
|
1588
1588
|
|
|
1589
|
+
// src/next/vite/cors.ts
|
|
1590
|
+
var LOCALHOST_RE = /^https?:\/\/(?:localhost|127\.0\.0\.1|\[::1\])(:\d+)?$/;
|
|
1591
|
+
var PRIVATE_NETWORK_RE = /^https?:\/\/(?:10\.\d{1,3}\.\d{1,3}\.\d{1,3}|172\.(?:1[6-9]|2\d|3[01])\.\d{1,3}\.\d{1,3}|192\.168\.\d{1,3}\.\d{1,3})(:\d+)?$/;
|
|
1592
|
+
function expandOrigins(raw) {
|
|
1593
|
+
const hasPrivate = raw.some((o) => o === "private");
|
|
1594
|
+
const filtered = raw.filter((o) => o !== "private");
|
|
1595
|
+
return hasPrivate ? [...filtered, PRIVATE_NETWORK_RE] : filtered;
|
|
1596
|
+
}
|
|
1597
|
+
function buildCorsOriginCheck(allowedOrigins = []) {
|
|
1598
|
+
const extra = expandOrigins(allowedOrigins);
|
|
1599
|
+
return (origin, callback) => {
|
|
1600
|
+
if (!origin) {
|
|
1601
|
+
callback(null, true);
|
|
1602
|
+
return;
|
|
1603
|
+
}
|
|
1604
|
+
if (LOCALHOST_RE.test(origin)) {
|
|
1605
|
+
callback(null, true);
|
|
1606
|
+
return;
|
|
1607
|
+
}
|
|
1608
|
+
for (const allowed of extra) {
|
|
1609
|
+
if (typeof allowed === "string") {
|
|
1610
|
+
if (allowed === origin) {
|
|
1611
|
+
callback(null, true);
|
|
1612
|
+
return;
|
|
1613
|
+
}
|
|
1614
|
+
} else {
|
|
1615
|
+
allowed.lastIndex = 0;
|
|
1616
|
+
if (allowed.test(origin)) {
|
|
1617
|
+
callback(null, true);
|
|
1618
|
+
return;
|
|
1619
|
+
}
|
|
1620
|
+
}
|
|
1621
|
+
}
|
|
1622
|
+
callback(null, false);
|
|
1623
|
+
};
|
|
1624
|
+
}
|
|
1625
|
+
|
|
1589
1626
|
// src/next/vite/filterPublicEnv.ts
|
|
1590
1627
|
function filterPublicEnv(env = process.env) {
|
|
1591
1628
|
const publicEnv = {};
|
|
@@ -2022,6 +2059,13 @@ var createConfig = async ({
|
|
|
2022
2059
|
},
|
|
2023
2060
|
server: {
|
|
2024
2061
|
host: configManager.config?.build?.host ?? false,
|
|
2062
|
+
// Restrict Vite's built-in CORS to the same origins our custom
|
|
2063
|
+
// middleware allows (localhost + user-configured allowedOrigins).
|
|
2064
|
+
cors: {
|
|
2065
|
+
origin: buildCorsOriginCheck(
|
|
2066
|
+
configManager.config?.server?.allowedOrigins
|
|
2067
|
+
)
|
|
2068
|
+
},
|
|
2025
2069
|
watch: noWatch ? {
|
|
2026
2070
|
ignored: ["**/*"]
|
|
2027
2071
|
} : {
|
|
@@ -2031,7 +2075,15 @@ var createConfig = async ({
|
|
|
2031
2075
|
]
|
|
2032
2076
|
},
|
|
2033
2077
|
fs: {
|
|
2034
|
-
strict:
|
|
2078
|
+
strict: true,
|
|
2079
|
+
// Allow serving files from the project root and the SPA package.
|
|
2080
|
+
// Without this, Vite would block access to tina config/generated
|
|
2081
|
+
// files since the Vite root is the @tinacms/app package directory.
|
|
2082
|
+
allow: [
|
|
2083
|
+
configManager.spaRootPath,
|
|
2084
|
+
configManager.rootPath,
|
|
2085
|
+
...configManager.contentRootPath && configManager.contentRootPath !== configManager.rootPath ? [configManager.contentRootPath] : []
|
|
2086
|
+
]
|
|
2035
2087
|
}
|
|
2036
2088
|
},
|
|
2037
2089
|
build: {
|
|
@@ -2061,14 +2113,14 @@ var createConfig = async ({
|
|
|
2061
2113
|
};
|
|
2062
2114
|
|
|
2063
2115
|
// src/next/vite/plugins.ts
|
|
2064
|
-
import { createFilter } from "@rollup/pluginutils";
|
|
2065
2116
|
import fs6 from "fs";
|
|
2066
|
-
import { transformWithEsbuild } from "vite";
|
|
2067
|
-
import { transform as esbuildTransform } from "esbuild";
|
|
2068
2117
|
import path7 from "path";
|
|
2118
|
+
import { createFilter } from "@rollup/pluginutils";
|
|
2119
|
+
import { resolve as gqlResolve } from "@tinacms/graphql";
|
|
2069
2120
|
import bodyParser from "body-parser";
|
|
2070
2121
|
import cors from "cors";
|
|
2071
|
-
import {
|
|
2122
|
+
import { transform as esbuildTransform } from "esbuild";
|
|
2123
|
+
import { transformWithEsbuild } from "vite";
|
|
2072
2124
|
|
|
2073
2125
|
// src/next/commands/dev-command/server/media.ts
|
|
2074
2126
|
import path6, { join } from "path";
|
|
@@ -2402,10 +2454,18 @@ var devServerEndPointsPlugin = ({
|
|
|
2402
2454
|
searchIndex,
|
|
2403
2455
|
databaseLock
|
|
2404
2456
|
}) => {
|
|
2457
|
+
const corsOriginCheck = buildCorsOriginCheck(
|
|
2458
|
+
configManager.config?.server?.allowedOrigins
|
|
2459
|
+
);
|
|
2405
2460
|
const plug = {
|
|
2406
2461
|
name: "graphql-endpoints",
|
|
2407
2462
|
configureServer(server) {
|
|
2408
|
-
server.middlewares.use(
|
|
2463
|
+
server.middlewares.use(
|
|
2464
|
+
cors({
|
|
2465
|
+
origin: corsOriginCheck,
|
|
2466
|
+
methods: ["GET", "HEAD", "PUT", "PATCH", "POST", "DELETE"]
|
|
2467
|
+
})
|
|
2468
|
+
);
|
|
2409
2469
|
server.middlewares.use(bodyParser.json({ limit: "5mb" }));
|
|
2410
2470
|
server.middlewares.use(async (req, res, next) => {
|
|
2411
2471
|
const mediaPaths = configManager.config.media?.tina;
|
|
@@ -5872,6 +5932,12 @@ import { LocalAuthProvider } from "tinacms";`;
|
|
|
5872
5932
|
outputFolder: "admin",
|
|
5873
5933
|
publicFolder: "${args.publicFolder}",
|
|
5874
5934
|
},
|
|
5935
|
+
// Uncomment to allow cross-origin requests from non-localhost origins
|
|
5936
|
+
// during local development (e.g. GitHub Codespaces, Gitpod, Docker).
|
|
5937
|
+
// Use 'private' to allow all private-network IPs (WSL2, Docker, etc.)
|
|
5938
|
+
// server: {
|
|
5939
|
+
// allowedOrigins: ['https://your-codespace.github.dev'],
|
|
5940
|
+
// },
|
|
5875
5941
|
media: {
|
|
5876
5942
|
tina: {
|
|
5877
5943
|
mediaRoot: "",
|
package/dist/next/database.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Bridge, Database } from '@tinacms/graphql';
|
|
2
2
|
import { ConfigManager } from './config-manager';
|
|
3
3
|
export declare const createDBServer: (port: number) => void;
|
|
4
4
|
export declare function createAndInitializeDatabase(configManager: ConfigManager, datalayerPort: number, bridgeOverride?: Bridge): Promise<Database>;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared CORS origin-checking logic for the TinaCMS dev server.
|
|
3
|
+
*
|
|
4
|
+
* By default only localhost / 127.0.0.1 / [::1] (any port) are allowed.
|
|
5
|
+
* Users can extend this via `server.allowedOrigins` in their tina config.
|
|
6
|
+
* The special keyword `'private'` expands to all RFC 1918 private-network
|
|
7
|
+
* IP ranges (10.x, 172.16-31.x, 192.168.x) — useful for WSL2, Docker
|
|
8
|
+
* bridge networks, etc.
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
11
|
+
* Build a CORS `origin` callback compatible with the `cors` npm package.
|
|
12
|
+
*/
|
|
13
|
+
export declare function buildCorsOriginCheck(allowedOrigins?: (string | RegExp)[]): (origin: string | undefined, callback: (err: Error | null, allow?: boolean) => void) => void;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type { Plugin } from 'vite';
|
|
2
1
|
import { FilterPattern } from '@rollup/pluginutils';
|
|
3
2
|
import type { Config } from '@svgr/core';
|
|
4
|
-
import { transformWithEsbuild } from 'vite';
|
|
5
3
|
import type { Database } from '@tinacms/graphql';
|
|
4
|
+
import type { Plugin } from 'vite';
|
|
5
|
+
import { transformWithEsbuild } from 'vite';
|
|
6
6
|
import type { ConfigManager } from '../config-manager';
|
|
7
7
|
export declare const transformTsxPlugin: ({ configManager: _configManager, }: {
|
|
8
8
|
configManager: ConfigManager;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tinacms/cli",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "2.1.
|
|
4
|
+
"version": "2.1.8",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"typings": "dist/index.d.ts",
|
|
7
7
|
"files": [
|
|
@@ -88,12 +88,12 @@
|
|
|
88
88
|
"vite": "^4.5.9",
|
|
89
89
|
"yup": "^1.6.1",
|
|
90
90
|
"zod": "^3.24.2",
|
|
91
|
-
"@tinacms/app": "2.3.
|
|
92
|
-
"@tinacms/graphql": "2.1.
|
|
91
|
+
"@tinacms/app": "2.3.27",
|
|
92
|
+
"@tinacms/graphql": "2.1.4",
|
|
93
93
|
"@tinacms/metrics": "2.0.1",
|
|
94
|
-
"@tinacms/schema-tools": "2.
|
|
95
|
-
"@tinacms/search": "1.2.
|
|
96
|
-
"tinacms": "3.
|
|
94
|
+
"@tinacms/schema-tools": "2.7.0",
|
|
95
|
+
"@tinacms/search": "1.2.5",
|
|
96
|
+
"tinacms": "3.6.0"
|
|
97
97
|
},
|
|
98
98
|
"publishConfig": {
|
|
99
99
|
"registry": "https://registry.npmjs.org"
|