@tinacms/cli 1.8.4 → 1.9.1
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.
|
@@ -150,7 +150,7 @@ export declare const parseSections: ({ val }: {
|
|
|
150
150
|
}) => {
|
|
151
151
|
sections?: {
|
|
152
152
|
exclude?: string;
|
|
153
|
-
type?: "
|
|
153
|
+
type?: "document" | "heading" | "directory" | "jekyll-pages" | "jekyll-posts";
|
|
154
154
|
match?: string;
|
|
155
155
|
path?: string;
|
|
156
156
|
templates?: string[];
|
package/dist/index.js
CHANGED
|
@@ -27,17 +27,18 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
27
27
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
28
|
|
|
29
29
|
// src/index.ts
|
|
30
|
-
var
|
|
31
|
-
__export(
|
|
32
|
-
default: () =>
|
|
30
|
+
var index_exports = {};
|
|
31
|
+
__export(index_exports, {
|
|
32
|
+
default: () => index_default
|
|
33
33
|
});
|
|
34
|
-
module.exports = __toCommonJS(
|
|
34
|
+
module.exports = __toCommonJS(index_exports);
|
|
35
35
|
var import_clipanion8 = require("clipanion");
|
|
36
36
|
|
|
37
37
|
// package.json
|
|
38
|
-
var version = "1.
|
|
38
|
+
var version = "1.9.1";
|
|
39
39
|
|
|
40
40
|
// src/next/commands/dev-command/index.ts
|
|
41
|
+
var import_async_lock = __toESM(require("async-lock"));
|
|
41
42
|
var import_clipanion2 = require("clipanion");
|
|
42
43
|
var import_fs_extra6 = __toESM(require("fs-extra"));
|
|
43
44
|
var import_path5 = __toESM(require("path"));
|
|
@@ -1329,7 +1330,8 @@ var devServerEndPointsPlugin = ({
|
|
|
1329
1330
|
configManager,
|
|
1330
1331
|
apiURL,
|
|
1331
1332
|
database,
|
|
1332
|
-
searchIndex
|
|
1333
|
+
searchIndex,
|
|
1334
|
+
databaseLock
|
|
1333
1335
|
}) => {
|
|
1334
1336
|
const plug = {
|
|
1335
1337
|
name: "graphql-endpoints",
|
|
@@ -1373,14 +1375,17 @@ var devServerEndPointsPlugin = ({
|
|
|
1373
1375
|
}
|
|
1374
1376
|
if (req.url === "/graphql") {
|
|
1375
1377
|
const { query, variables } = req.body;
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1378
|
+
let result;
|
|
1379
|
+
await databaseLock(async () => {
|
|
1380
|
+
result = await (0, import_graphql.resolve)({
|
|
1381
|
+
config: {
|
|
1382
|
+
useRelativeMedia: true
|
|
1383
|
+
},
|
|
1384
|
+
database,
|
|
1385
|
+
query,
|
|
1386
|
+
variables,
|
|
1387
|
+
verbose: false
|
|
1388
|
+
});
|
|
1384
1389
|
});
|
|
1385
1390
|
res.end(JSON.stringify(result));
|
|
1386
1391
|
return;
|
|
@@ -1439,10 +1444,16 @@ function viteTransformExtension({
|
|
|
1439
1444
|
}
|
|
1440
1445
|
|
|
1441
1446
|
// src/next/commands/dev-command/server/index.ts
|
|
1442
|
-
var createDevServer = async (configManager, database, searchIndex, apiURL, noWatch) => {
|
|
1447
|
+
var createDevServer = async (configManager, database, searchIndex, apiURL, noWatch, databaseLock) => {
|
|
1443
1448
|
const plugins = [
|
|
1444
1449
|
transformTsxPlugin({ configManager }),
|
|
1445
|
-
devServerEndPointsPlugin({
|
|
1450
|
+
devServerEndPointsPlugin({
|
|
1451
|
+
apiURL,
|
|
1452
|
+
configManager,
|
|
1453
|
+
database,
|
|
1454
|
+
searchIndex,
|
|
1455
|
+
databaseLock
|
|
1456
|
+
}),
|
|
1446
1457
|
viteTransformExtension()
|
|
1447
1458
|
];
|
|
1448
1459
|
return (0, import_vite3.createServer)(
|
|
@@ -2192,7 +2203,9 @@ var BaseCommand = class extends import_clipanion.Command {
|
|
|
2192
2203
|
let subProc;
|
|
2193
2204
|
if (this.subCommand) {
|
|
2194
2205
|
subProc = await startSubprocess2({ command: this.subCommand });
|
|
2195
|
-
logger.info(
|
|
2206
|
+
logger.info(
|
|
2207
|
+
`Running web application with command: ${import_chalk4.default.cyan(this.subCommand)}`
|
|
2208
|
+
);
|
|
2196
2209
|
}
|
|
2197
2210
|
function exitHandler(options, exitCode) {
|
|
2198
2211
|
if (subProc) {
|
|
@@ -2326,6 +2339,7 @@ var DevCommand = class extends BaseCommand {
|
|
|
2326
2339
|
this.outputSearchIndexPath = import_clipanion2.Option.String("--outputSearchIndexPath", {
|
|
2327
2340
|
description: "Path to write the search index to"
|
|
2328
2341
|
});
|
|
2342
|
+
this.indexingLock = new import_async_lock.default();
|
|
2329
2343
|
}
|
|
2330
2344
|
async catch(error) {
|
|
2331
2345
|
logger.error("Error occured during tinacms dev");
|
|
@@ -2346,10 +2360,13 @@ var DevCommand = class extends BaseCommand {
|
|
|
2346
2360
|
rootPath: this.rootPath,
|
|
2347
2361
|
legacyNoSDK: this.noSDK
|
|
2348
2362
|
});
|
|
2349
|
-
logger.info("
|
|
2363
|
+
logger.info("\u{1F999} TinaCMS Dev Server is initializing...");
|
|
2350
2364
|
this.logDeprecationWarnings();
|
|
2351
2365
|
createDBServer(Number(this.datalayerPort));
|
|
2352
2366
|
let database = null;
|
|
2367
|
+
const dbLock = async (fn) => {
|
|
2368
|
+
return this.indexingLock.acquire("Key", fn);
|
|
2369
|
+
};
|
|
2353
2370
|
const setup = async ({ firstTime }) => {
|
|
2354
2371
|
try {
|
|
2355
2372
|
await configManager.processConfig();
|
|
@@ -2410,7 +2427,11 @@ var DevCommand = class extends BaseCommand {
|
|
|
2410
2427
|
logger.error("Re-index complete");
|
|
2411
2428
|
}
|
|
2412
2429
|
if (!this.noWatch) {
|
|
2413
|
-
this.watchQueries(
|
|
2430
|
+
this.watchQueries(
|
|
2431
|
+
configManager,
|
|
2432
|
+
dbLock,
|
|
2433
|
+
async () => await codegen2.execute()
|
|
2434
|
+
);
|
|
2414
2435
|
}
|
|
2415
2436
|
return { apiURL: apiURL2, database, graphQLSchema: graphQLSchema2, tinaSchema: tinaSchema2 };
|
|
2416
2437
|
} catch (e) {
|
|
@@ -2446,14 +2467,6 @@ ${dangerText(e.message)}
|
|
|
2446
2467
|
tokenSplitRegex: (_d = (_c = configManager.config.search) == null ? void 0 : _c.tina) == null ? void 0 : _d.tokenSplitRegex
|
|
2447
2468
|
});
|
|
2448
2469
|
await searchIndexClient.onStartIndexing();
|
|
2449
|
-
const server = await createDevServer(
|
|
2450
|
-
configManager,
|
|
2451
|
-
database,
|
|
2452
|
-
searchIndexClient.searchIndex,
|
|
2453
|
-
apiURL,
|
|
2454
|
-
this.noWatch
|
|
2455
|
-
);
|
|
2456
|
-
await server.listen(Number(this.port));
|
|
2457
2470
|
const searchIndexer = new import_search.SearchIndexer({
|
|
2458
2471
|
batchSize: ((_e = configManager.config.search) == null ? void 0 : _e.indexBatchSize) || 100,
|
|
2459
2472
|
bridge: new import_graphql10.FilesystemBridge(
|
|
@@ -2479,12 +2492,26 @@ ${dangerText(e.message)}
|
|
|
2479
2492
|
this.watchContentFiles(
|
|
2480
2493
|
configManager,
|
|
2481
2494
|
database,
|
|
2495
|
+
dbLock,
|
|
2482
2496
|
configManager.config.search && searchIndexer
|
|
2483
2497
|
);
|
|
2498
|
+
}
|
|
2499
|
+
const server = await createDevServer(
|
|
2500
|
+
configManager,
|
|
2501
|
+
database,
|
|
2502
|
+
searchIndexClient.searchIndex,
|
|
2503
|
+
apiURL,
|
|
2504
|
+
this.noWatch,
|
|
2505
|
+
dbLock
|
|
2506
|
+
);
|
|
2507
|
+
await server.listen(Number(this.port));
|
|
2508
|
+
if (!this.noWatch) {
|
|
2484
2509
|
import_chokidar.default.watch(configManager.watchList).on("change", async () => {
|
|
2485
|
-
|
|
2486
|
-
|
|
2487
|
-
|
|
2510
|
+
await dbLock(async () => {
|
|
2511
|
+
logger.info(`Tina config change detected, rebuilding`);
|
|
2512
|
+
await setup({ firstTime: false });
|
|
2513
|
+
server.ws.send({ type: "full-reload", path: "*" });
|
|
2514
|
+
});
|
|
2488
2515
|
});
|
|
2489
2516
|
}
|
|
2490
2517
|
const subItems = [];
|
|
@@ -2497,7 +2524,7 @@ ${dangerText(e.message)}
|
|
|
2497
2524
|
const summaryItems = [
|
|
2498
2525
|
{
|
|
2499
2526
|
emoji: "\u{1F999}",
|
|
2500
|
-
heading: "
|
|
2527
|
+
heading: "TinaCMS URLs",
|
|
2501
2528
|
subItems: [
|
|
2502
2529
|
{
|
|
2503
2530
|
key: "CMS",
|
|
@@ -2532,7 +2559,7 @@ ${dangerText(e.message)}
|
|
|
2532
2559
|
});
|
|
2533
2560
|
}
|
|
2534
2561
|
summary({
|
|
2535
|
-
heading: "
|
|
2562
|
+
heading: "\u2705 \u{1F999} TinaCMS Dev Server is active:",
|
|
2536
2563
|
items: [
|
|
2537
2564
|
...summaryItems
|
|
2538
2565
|
// {
|
|
@@ -2553,7 +2580,7 @@ ${dangerText(e.message)}
|
|
|
2553
2580
|
});
|
|
2554
2581
|
await this.startSubCommand();
|
|
2555
2582
|
}
|
|
2556
|
-
watchContentFiles(configManager, database, searchIndexer) {
|
|
2583
|
+
watchContentFiles(configManager, database, databaseLock, searchIndexer) {
|
|
2557
2584
|
const collectionContentFiles = [];
|
|
2558
2585
|
configManager.config.schema.collections.forEach((collection) => {
|
|
2559
2586
|
const collectionGlob = `${import_path5.default.join(
|
|
@@ -2569,39 +2596,42 @@ ${dangerText(e.message)}
|
|
|
2569
2596
|
if (!ready) {
|
|
2570
2597
|
return;
|
|
2571
2598
|
}
|
|
2572
|
-
|
|
2573
|
-
|
|
2574
|
-
|
|
2575
|
-
|
|
2576
|
-
|
|
2599
|
+
await databaseLock(async () => {
|
|
2600
|
+
const pathFromRoot = configManager.printContentRelativePath(addedFile);
|
|
2601
|
+
await database.indexContentByPaths([pathFromRoot]).catch(console.error);
|
|
2602
|
+
if (searchIndexer) {
|
|
2603
|
+
await searchIndexer.indexContentByPaths([pathFromRoot]).catch(console.error);
|
|
2604
|
+
}
|
|
2605
|
+
});
|
|
2577
2606
|
}).on("change", async (changedFile) => {
|
|
2578
2607
|
const pathFromRoot = configManager.printContentRelativePath(changedFile);
|
|
2579
|
-
await
|
|
2580
|
-
|
|
2581
|
-
|
|
2582
|
-
|
|
2608
|
+
await databaseLock(async () => {
|
|
2609
|
+
await database.indexContentByPaths([pathFromRoot]).catch(console.error);
|
|
2610
|
+
if (searchIndexer) {
|
|
2611
|
+
await searchIndexer.indexContentByPaths([pathFromRoot]).catch(console.error);
|
|
2612
|
+
}
|
|
2613
|
+
});
|
|
2583
2614
|
}).on("unlink", async (removedFile) => {
|
|
2584
2615
|
const pathFromRoot = configManager.printContentRelativePath(removedFile);
|
|
2585
|
-
await
|
|
2586
|
-
|
|
2587
|
-
|
|
2588
|
-
|
|
2616
|
+
await databaseLock(async () => {
|
|
2617
|
+
await database.deleteContentByPaths([pathFromRoot]).catch(console.error);
|
|
2618
|
+
if (searchIndexer) {
|
|
2619
|
+
await searchIndexer.deleteIndexContent([pathFromRoot]).catch(console.error);
|
|
2620
|
+
}
|
|
2621
|
+
});
|
|
2589
2622
|
});
|
|
2590
2623
|
}
|
|
2591
|
-
watchQueries(configManager, callback) {
|
|
2592
|
-
|
|
2593
|
-
|
|
2594
|
-
|
|
2595
|
-
|
|
2596
|
-
|
|
2597
|
-
|
|
2598
|
-
await callback();
|
|
2599
|
-
}).on("unlink", async (removedFile) => {
|
|
2600
|
-
await callback();
|
|
2601
|
-
});
|
|
2624
|
+
watchQueries(configManager, databaseLock, callback) {
|
|
2625
|
+
const executeCallback = async (_) => {
|
|
2626
|
+
await databaseLock(async () => {
|
|
2627
|
+
await callback();
|
|
2628
|
+
});
|
|
2629
|
+
};
|
|
2630
|
+
import_chokidar.default.watch(configManager.userQueriesAndFragmentsGlob).on("add", executeCallback).on("change", executeCallback).on("unlink", executeCallback);
|
|
2602
2631
|
}
|
|
2603
2632
|
};
|
|
2604
2633
|
DevCommand.paths = [["dev"], ["server:start"]];
|
|
2634
|
+
// Prevent indexes and reads occurring at once
|
|
2605
2635
|
DevCommand.usage = import_clipanion2.Command.Usage({
|
|
2606
2636
|
category: `Commands`,
|
|
2607
2637
|
description: `Builds Tina and starts the dev server`,
|
|
@@ -2899,7 +2929,8 @@ ${dangerText(e.message)}
|
|
|
2899
2929
|
database,
|
|
2900
2930
|
null,
|
|
2901
2931
|
apiURL,
|
|
2902
|
-
true
|
|
2932
|
+
true,
|
|
2933
|
+
(lockedFn) => lockedFn()
|
|
2903
2934
|
);
|
|
2904
2935
|
await server.listen(Number(this.port));
|
|
2905
2936
|
console.log("server listening on port", this.port);
|
|
@@ -6695,4 +6726,4 @@ cli.register(SearchIndexCommand);
|
|
|
6695
6726
|
cli.register(import_clipanion8.Builtins.DefinitionsCommand);
|
|
6696
6727
|
cli.register(import_clipanion8.Builtins.HelpCommand);
|
|
6697
6728
|
cli.register(import_clipanion8.Builtins.VersionCommand);
|
|
6698
|
-
var
|
|
6729
|
+
var index_default = cli;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import AsyncLock from 'async-lock';
|
|
1
2
|
import { Database } from '@tinacms/graphql';
|
|
2
3
|
import { ConfigManager } from '../../config-manager';
|
|
3
4
|
import { BaseCommand } from '../baseCommands';
|
|
@@ -7,10 +8,11 @@ export declare class DevCommand extends BaseCommand {
|
|
|
7
8
|
watchFolders: string;
|
|
8
9
|
noWatch: boolean;
|
|
9
10
|
outputSearchIndexPath: string;
|
|
11
|
+
indexingLock: AsyncLock;
|
|
10
12
|
static usage: import("clipanion").Usage;
|
|
11
13
|
catch(error: any): Promise<void>;
|
|
12
14
|
logDeprecationWarnings(): void;
|
|
13
15
|
execute(): Promise<number | void>;
|
|
14
|
-
watchContentFiles(configManager: ConfigManager, database: Database, searchIndexer?: SearchIndexer): void;
|
|
15
|
-
watchQueries(configManager: ConfigManager, callback: () => Promise<string>): void;
|
|
16
|
+
watchContentFiles(configManager: ConfigManager, database: Database, databaseLock: (fn: () => Promise<void>) => Promise<void>, searchIndexer?: SearchIndexer): void;
|
|
17
|
+
watchQueries(configManager: ConfigManager, databaseLock: (fn: () => Promise<void>) => Promise<void>, callback: () => Promise<string>): void;
|
|
16
18
|
}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { Database } from '@tinacms/graphql';
|
|
2
2
|
import { ConfigManager } from '../../../config-manager';
|
|
3
|
-
export declare const createDevServer: (configManager: ConfigManager, database: Database, searchIndex: any, apiURL: string, noWatch: boolean) => Promise<import("vite").ViteDevServer>;
|
|
3
|
+
export declare const createDevServer: (configManager: ConfigManager, database: Database, searchIndex: any, apiURL: string, noWatch: boolean, databaseLock: (fn: () => Promise<void>) => Promise<void>) => Promise<import("vite").ViteDevServer>;
|
|
@@ -7,11 +7,12 @@ import type { ConfigManager } from '../config-manager';
|
|
|
7
7
|
export declare const transformTsxPlugin: ({ configManager: _configManager, }: {
|
|
8
8
|
configManager: ConfigManager;
|
|
9
9
|
}) => Plugin;
|
|
10
|
-
export declare const devServerEndPointsPlugin: ({ configManager, apiURL, database, searchIndex, }: {
|
|
10
|
+
export declare const devServerEndPointsPlugin: ({ configManager, apiURL, database, searchIndex, databaseLock, }: {
|
|
11
11
|
apiURL: string;
|
|
12
12
|
database: Database;
|
|
13
13
|
configManager: ConfigManager;
|
|
14
14
|
searchIndex: any;
|
|
15
|
+
databaseLock: (fn: () => Promise<void>) => Promise<void>;
|
|
15
16
|
}) => Plugin;
|
|
16
17
|
export interface ViteSvgrOptions {
|
|
17
18
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tinacms/cli",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.9.1",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"typings": "dist/index.d.ts",
|
|
6
6
|
"files": [
|
|
@@ -37,24 +37,25 @@
|
|
|
37
37
|
"@types/prompts": "^2.4.9",
|
|
38
38
|
"@types/yup": "^0.32.0",
|
|
39
39
|
"jest": "^29.7.0",
|
|
40
|
-
"@tinacms/scripts": "1.3.
|
|
40
|
+
"@tinacms/scripts": "1.3.2"
|
|
41
41
|
},
|
|
42
42
|
"dependencies": {
|
|
43
43
|
"@graphql-codegen/core": "^2.6.8",
|
|
44
44
|
"@graphql-codegen/plugin-helpers": "latest",
|
|
45
|
-
"@graphql-codegen/typescript": "^4.1.
|
|
46
|
-
"@graphql-codegen/typescript-operations": "^4.
|
|
45
|
+
"@graphql-codegen/typescript": "^4.1.3",
|
|
46
|
+
"@graphql-codegen/typescript-operations": "^4.4.1",
|
|
47
47
|
"@graphql-codegen/visitor-plugin-common": "^4.1.2",
|
|
48
48
|
"@graphql-inspector/core": "^4.2.2",
|
|
49
49
|
"@graphql-tools/graphql-file-loader": "^7.5.17",
|
|
50
50
|
"@graphql-tools/load": "^7.8.14",
|
|
51
|
-
"@rollup/pluginutils": "^5.1.
|
|
51
|
+
"@rollup/pluginutils": "^5.1.4",
|
|
52
52
|
"@svgr/core": "8.1.0",
|
|
53
53
|
"@tailwindcss/aspect-ratio": "^0.4.2",
|
|
54
54
|
"@tailwindcss/container-queries": "^0.1.1",
|
|
55
|
-
"@tailwindcss/typography": "^0.5.
|
|
55
|
+
"@tailwindcss/typography": "^0.5.16",
|
|
56
56
|
"@vitejs/plugin-react": "3.1.0",
|
|
57
57
|
"altair-express-middleware": "^7.3.6",
|
|
58
|
+
"async-lock": "^1.4.1",
|
|
58
59
|
"auto-bind": "^4.0.0",
|
|
59
60
|
"body-parser": "^1.20.3",
|
|
60
61
|
"busboy": "^1.6.0",
|
|
@@ -64,9 +65,9 @@
|
|
|
64
65
|
"clipanion": "^3.2.1",
|
|
65
66
|
"cors": "^2.8.5",
|
|
66
67
|
"crypto-js": "^4.2.0",
|
|
67
|
-
"dotenv": "^16.4.
|
|
68
|
-
"esbuild": "^0.24.
|
|
69
|
-
"fs-extra": "^11.
|
|
68
|
+
"dotenv": "^16.4.7",
|
|
69
|
+
"esbuild": "^0.24.2",
|
|
70
|
+
"fs-extra": "^11.3.0",
|
|
70
71
|
"graphql": "15.8.0",
|
|
71
72
|
"js-yaml": "^4.1.0",
|
|
72
73
|
"log4js": "^6.9.1",
|
|
@@ -77,19 +78,19 @@
|
|
|
77
78
|
"prettier": "^2.8.8",
|
|
78
79
|
"progress": "^2.0.3",
|
|
79
80
|
"prompts": "^2.4.2",
|
|
80
|
-
"readable-stream": "^4.
|
|
81
|
-
"tailwindcss": "^3.4.
|
|
81
|
+
"readable-stream": "^4.7.0",
|
|
82
|
+
"tailwindcss": "^3.4.17",
|
|
82
83
|
"typanion": "3.13.0",
|
|
83
|
-
"typescript": "^5.
|
|
84
|
-
"vite": "^4.5.
|
|
85
|
-
"yup": "^1.
|
|
86
|
-
"zod": "^3.
|
|
87
|
-
"@tinacms/app": "2.1
|
|
88
|
-
"@tinacms/graphql": "1.5.
|
|
89
|
-
"@tinacms/metrics": "1.0.
|
|
90
|
-
"@tinacms/
|
|
91
|
-
"@tinacms/
|
|
92
|
-
"tinacms": "2.
|
|
84
|
+
"typescript": "^5.7.3",
|
|
85
|
+
"vite": "^4.5.9",
|
|
86
|
+
"yup": "^1.6.1",
|
|
87
|
+
"zod": "^3.24.2",
|
|
88
|
+
"@tinacms/app": "2.2.1",
|
|
89
|
+
"@tinacms/graphql": "1.5.13",
|
|
90
|
+
"@tinacms/metrics": "1.0.9",
|
|
91
|
+
"@tinacms/search": "1.0.40",
|
|
92
|
+
"@tinacms/schema-tools": "1.7.1",
|
|
93
|
+
"tinacms": "2.7.1"
|
|
93
94
|
},
|
|
94
95
|
"publishConfig": {
|
|
95
96
|
"registry": "https://registry.npmjs.org"
|