@tinacms/cli 1.5.17 → 1.5.18
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 +308 -22
- package/dist/next/commands/build-command/index.d.ts +1 -0
- package/dist/next/commands/dev-command/index.d.ts +2 -1
- package/dist/next/commands/dev-command/server/index.d.ts +1 -1
- package/dist/next/commands/dev-command/server/searchIndex.d.ts +12 -0
- package/dist/next/commands/searchindex-command/index.d.ts +9 -0
- package/dist/next/vite/plugins.d.ts +2 -1
- package/package.json +6 -5
package/dist/index.js
CHANGED
|
@@ -28,10 +28,10 @@ __export(src_exports, {
|
|
|
28
28
|
default: () => src_default
|
|
29
29
|
});
|
|
30
30
|
module.exports = __toCommonJS(src_exports);
|
|
31
|
-
var
|
|
31
|
+
var import_clipanion8 = require("clipanion");
|
|
32
32
|
|
|
33
33
|
// package.json
|
|
34
|
-
var version = "1.5.
|
|
34
|
+
var version = "1.5.18";
|
|
35
35
|
|
|
36
36
|
// src/next/commands/dev-command/index.ts
|
|
37
37
|
var import_clipanion2 = require("clipanion");
|
|
@@ -1047,6 +1047,45 @@ var MediaModel = class {
|
|
|
1047
1047
|
}
|
|
1048
1048
|
};
|
|
1049
1049
|
|
|
1050
|
+
// src/next/commands/dev-command/server/searchIndex.ts
|
|
1051
|
+
var createSearchIndexRouter = ({
|
|
1052
|
+
config: config3,
|
|
1053
|
+
searchIndex
|
|
1054
|
+
}) => {
|
|
1055
|
+
const put = async (req, res) => {
|
|
1056
|
+
const { docs } = req.body;
|
|
1057
|
+
const result = await searchIndex.PUT(docs);
|
|
1058
|
+
res.end(JSON.stringify({ result }));
|
|
1059
|
+
};
|
|
1060
|
+
const get = async (req, res) => {
|
|
1061
|
+
const requestURL = new URL(req.url, config3.apiURL);
|
|
1062
|
+
const query = requestURL.searchParams.get("q");
|
|
1063
|
+
const optionsParam = requestURL.searchParams.get("options");
|
|
1064
|
+
let options = {
|
|
1065
|
+
DOCUMENTS: false
|
|
1066
|
+
};
|
|
1067
|
+
if (optionsParam) {
|
|
1068
|
+
options = {
|
|
1069
|
+
...options,
|
|
1070
|
+
...JSON.parse(optionsParam)
|
|
1071
|
+
};
|
|
1072
|
+
}
|
|
1073
|
+
if (query) {
|
|
1074
|
+
const result = await searchIndex.QUERY(JSON.parse(query), options);
|
|
1075
|
+
res.end(JSON.stringify(result));
|
|
1076
|
+
} else {
|
|
1077
|
+
res.end(JSON.stringify({ RESULT: [] }));
|
|
1078
|
+
}
|
|
1079
|
+
};
|
|
1080
|
+
const del = async (req, res) => {
|
|
1081
|
+
const requestURL = new URL(req.url, config3.apiURL);
|
|
1082
|
+
const docId = requestURL.pathname.split("/").filter(Boolean).slice(1).join("/");
|
|
1083
|
+
const result = await searchIndex.DELETE(docId);
|
|
1084
|
+
res.end(JSON.stringify({ result }));
|
|
1085
|
+
};
|
|
1086
|
+
return { del, get, put };
|
|
1087
|
+
};
|
|
1088
|
+
|
|
1050
1089
|
// src/next/vite/plugins.ts
|
|
1051
1090
|
var transformTsxPlugin = ({
|
|
1052
1091
|
configManager: _configManager
|
|
@@ -1068,7 +1107,8 @@ var transformTsxPlugin = ({
|
|
|
1068
1107
|
var devServerEndPointsPlugin = ({
|
|
1069
1108
|
configManager,
|
|
1070
1109
|
apiURL,
|
|
1071
|
-
database
|
|
1110
|
+
database,
|
|
1111
|
+
searchIndex
|
|
1072
1112
|
}) => {
|
|
1073
1113
|
const plug = {
|
|
1074
1114
|
name: "graphql-endpoints",
|
|
@@ -1084,6 +1124,10 @@ var devServerEndPointsPlugin = ({
|
|
|
1084
1124
|
publicFolder: parseMediaFolder((mediaPaths == null ? void 0 : mediaPaths.publicFolder) || ""),
|
|
1085
1125
|
mediaRoot: parseMediaFolder((mediaPaths == null ? void 0 : mediaPaths.mediaRoot) || "")
|
|
1086
1126
|
});
|
|
1127
|
+
const searchIndexRouter = createSearchIndexRouter({
|
|
1128
|
+
config: { apiURL, searchPath: "searchIndex" },
|
|
1129
|
+
searchIndex
|
|
1130
|
+
});
|
|
1087
1131
|
if (req.url.startsWith("/media/upload")) {
|
|
1088
1132
|
await mediaRouter.handlePost(req, res);
|
|
1089
1133
|
return;
|
|
@@ -1120,6 +1164,16 @@ var devServerEndPointsPlugin = ({
|
|
|
1120
1164
|
res.end(JSON.stringify(result));
|
|
1121
1165
|
return;
|
|
1122
1166
|
}
|
|
1167
|
+
if (req.url.startsWith("/searchIndex")) {
|
|
1168
|
+
if (req.method === "POST") {
|
|
1169
|
+
await searchIndexRouter.put(req, res);
|
|
1170
|
+
} else if (req.method === "GET") {
|
|
1171
|
+
await searchIndexRouter.get(req, res);
|
|
1172
|
+
} else if (req.method === "DELETE") {
|
|
1173
|
+
await searchIndexRouter.del(req, res);
|
|
1174
|
+
}
|
|
1175
|
+
return;
|
|
1176
|
+
}
|
|
1123
1177
|
next();
|
|
1124
1178
|
});
|
|
1125
1179
|
}
|
|
@@ -1163,10 +1217,10 @@ function viteTransformExtension({
|
|
|
1163
1217
|
}
|
|
1164
1218
|
|
|
1165
1219
|
// src/next/commands/dev-command/server/index.ts
|
|
1166
|
-
var createDevServer = async (configManager, database, apiURL, noWatch) => {
|
|
1220
|
+
var createDevServer = async (configManager, database, searchIndex, apiURL, noWatch) => {
|
|
1167
1221
|
const plugins = [
|
|
1168
1222
|
transformTsxPlugin({ configManager }),
|
|
1169
|
-
devServerEndPointsPlugin({ apiURL, configManager, database }),
|
|
1223
|
+
devServerEndPointsPlugin({ apiURL, configManager, database, searchIndex }),
|
|
1170
1224
|
viteTransformExtension()
|
|
1171
1225
|
];
|
|
1172
1226
|
return (0, import_vite3.createServer)(
|
|
@@ -1823,6 +1877,8 @@ var BaseCommand = class extends import_clipanion.Command {
|
|
|
1823
1877
|
};
|
|
1824
1878
|
|
|
1825
1879
|
// src/next/commands/dev-command/index.ts
|
|
1880
|
+
var import_memory_level2 = require("memory-level");
|
|
1881
|
+
var import_search = require("@tinacms/search");
|
|
1826
1882
|
var DevCommand = class extends BaseCommand {
|
|
1827
1883
|
constructor() {
|
|
1828
1884
|
super(...arguments);
|
|
@@ -1847,6 +1903,7 @@ var DevCommand = class extends BaseCommand {
|
|
|
1847
1903
|
}
|
|
1848
1904
|
}
|
|
1849
1905
|
async execute() {
|
|
1906
|
+
var _a, _b, _c, _d;
|
|
1850
1907
|
const configManager = new ConfigManager({
|
|
1851
1908
|
rootPath: this.rootPath,
|
|
1852
1909
|
legacyNoSDK: this.noSDK
|
|
@@ -1878,15 +1935,15 @@ var DevCommand = class extends BaseCommand {
|
|
|
1878
1935
|
} else {
|
|
1879
1936
|
database.clearCache();
|
|
1880
1937
|
}
|
|
1881
|
-
const { tinaSchema, graphQLSchema, lookup, queryDoc, fragDoc } = await (0, import_graphql8.buildSchema)(configManager.config);
|
|
1938
|
+
const { tinaSchema: tinaSchema2, graphQLSchema: graphQLSchema2, lookup, queryDoc, fragDoc } = await (0, import_graphql8.buildSchema)(configManager.config);
|
|
1882
1939
|
const codegen2 = new Codegen({
|
|
1883
1940
|
isLocal: true,
|
|
1884
1941
|
configManager,
|
|
1885
1942
|
port: Number(this.port),
|
|
1886
1943
|
queryDoc,
|
|
1887
1944
|
fragDoc,
|
|
1888
|
-
graphqlSchemaDoc:
|
|
1889
|
-
tinaSchema,
|
|
1945
|
+
graphqlSchemaDoc: graphQLSchema2,
|
|
1946
|
+
tinaSchema: tinaSchema2,
|
|
1890
1947
|
lookup
|
|
1891
1948
|
});
|
|
1892
1949
|
const apiURL2 = await codegen2.execute();
|
|
@@ -1911,26 +1968,67 @@ var DevCommand = class extends BaseCommand {
|
|
|
1911
1968
|
}
|
|
1912
1969
|
await this.indexContentWithSpinner({
|
|
1913
1970
|
database,
|
|
1914
|
-
graphQLSchema,
|
|
1915
|
-
tinaSchema
|
|
1971
|
+
graphQLSchema: graphQLSchema2,
|
|
1972
|
+
tinaSchema: tinaSchema2
|
|
1916
1973
|
});
|
|
1917
|
-
return { apiURL: apiURL2, database };
|
|
1974
|
+
return { apiURL: apiURL2, database, graphQLSchema: graphQLSchema2, tinaSchema: tinaSchema2 };
|
|
1918
1975
|
};
|
|
1919
|
-
const { apiURL } = await setup({
|
|
1976
|
+
const { apiURL, graphQLSchema, tinaSchema } = await setup({
|
|
1977
|
+
firstTime: true
|
|
1978
|
+
});
|
|
1920
1979
|
await import_fs_extra4.default.outputFile(configManager.outputHTMLFilePath, devHTML(this.port));
|
|
1921
1980
|
await import_fs_extra4.default.outputFile(
|
|
1922
1981
|
configManager.outputGitignorePath,
|
|
1923
1982
|
"index.html\nassets/"
|
|
1924
1983
|
);
|
|
1984
|
+
const searchIndex = await (0, import_search.si)({
|
|
1985
|
+
db: new import_memory_level2.MemoryLevel(),
|
|
1986
|
+
stopwords: (0, import_search.lookupStopwords)(
|
|
1987
|
+
(_b = (_a = configManager.config.search) == null ? void 0 : _a.tina) == null ? void 0 : _b.stopwordLanguages
|
|
1988
|
+
)
|
|
1989
|
+
});
|
|
1990
|
+
const searchIndexClient = new import_search.LocalSearchIndexClient(searchIndex);
|
|
1925
1991
|
const server = await createDevServer(
|
|
1926
1992
|
configManager,
|
|
1927
1993
|
database,
|
|
1994
|
+
searchIndex,
|
|
1928
1995
|
apiURL,
|
|
1929
1996
|
this.noWatch
|
|
1930
1997
|
);
|
|
1931
1998
|
await server.listen(Number(this.port));
|
|
1999
|
+
const searchIndexer = new import_search.SearchIndexer({
|
|
2000
|
+
batchSize: ((_c = configManager.config.search) == null ? void 0 : _c.indexBatchSize) || 100,
|
|
2001
|
+
bridge: new import_graphql8.FilesystemBridge(
|
|
2002
|
+
configManager.rootPath,
|
|
2003
|
+
configManager.contentRootPath
|
|
2004
|
+
),
|
|
2005
|
+
schema: tinaSchema,
|
|
2006
|
+
client: searchIndexClient,
|
|
2007
|
+
textIndexLength: ((_d = configManager.config.search) == null ? void 0 : _d.maxSearchIndexFieldLength) || 100
|
|
2008
|
+
});
|
|
2009
|
+
await spin({
|
|
2010
|
+
waitFor: async () => {
|
|
2011
|
+
const res = await database.indexContent({
|
|
2012
|
+
graphQLSchema,
|
|
2013
|
+
tinaSchema
|
|
2014
|
+
});
|
|
2015
|
+
},
|
|
2016
|
+
text: "Indexing local files"
|
|
2017
|
+
});
|
|
2018
|
+
if (configManager.config.search) {
|
|
2019
|
+
await spin({
|
|
2020
|
+
waitFor: async () => {
|
|
2021
|
+
await searchIndexer.indexAllContent();
|
|
2022
|
+
},
|
|
2023
|
+
text: "Building search index"
|
|
2024
|
+
});
|
|
2025
|
+
}
|
|
1932
2026
|
if (!this.noWatch) {
|
|
1933
|
-
this.watchContentFiles(
|
|
2027
|
+
this.watchContentFiles(
|
|
2028
|
+
configManager,
|
|
2029
|
+
database,
|
|
2030
|
+
configManager.config.search && searchIndexer
|
|
2031
|
+
);
|
|
1934
2032
|
}
|
|
1935
2033
|
server.watcher.on("change", async (changedPath) => {
|
|
1936
2034
|
if (changedPath.includes("__generated__")) {
|
|
@@ -2001,7 +2099,7 @@ var DevCommand = class extends BaseCommand {
|
|
|
2001
2099
|
});
|
|
2002
2100
|
await this.startSubCommand();
|
|
2003
2101
|
}
|
|
2004
|
-
watchContentFiles(configManager, database) {
|
|
2102
|
+
watchContentFiles(configManager, database, searchIndexer) {
|
|
2005
2103
|
const collectionContentFiles = [];
|
|
2006
2104
|
configManager.config.schema.collections.forEach((collection) => {
|
|
2007
2105
|
const collectionGlob = `${import_path7.default.join(
|
|
@@ -2018,13 +2116,22 @@ var DevCommand = class extends BaseCommand {
|
|
|
2018
2116
|
return;
|
|
2019
2117
|
}
|
|
2020
2118
|
const pathFromRoot = configManager.printContentRelativePath(addedFile);
|
|
2021
|
-
database.indexContentByPaths([pathFromRoot]).catch(console.error);
|
|
2119
|
+
await database.indexContentByPaths([pathFromRoot]).catch(console.error);
|
|
2120
|
+
if (searchIndexer) {
|
|
2121
|
+
await searchIndexer.indexContentByPaths([pathFromRoot]).catch(console.error);
|
|
2122
|
+
}
|
|
2022
2123
|
}).on("change", async (changedFile) => {
|
|
2023
2124
|
const pathFromRoot = configManager.printContentRelativePath(changedFile);
|
|
2024
|
-
database.indexContentByPaths([pathFromRoot]).catch(console.error);
|
|
2125
|
+
await database.indexContentByPaths([pathFromRoot]).catch(console.error);
|
|
2126
|
+
if (searchIndexer) {
|
|
2127
|
+
await searchIndexer.indexContentByPaths([pathFromRoot]).catch(console.error);
|
|
2128
|
+
}
|
|
2025
2129
|
}).on("unlink", async (removedFile) => {
|
|
2026
2130
|
const pathFromRoot = configManager.printContentRelativePath(removedFile);
|
|
2027
|
-
database.deleteContentByPaths([pathFromRoot]).catch(console.error);
|
|
2131
|
+
await database.deleteContentByPaths([pathFromRoot]).catch(console.error);
|
|
2132
|
+
if (searchIndexer) {
|
|
2133
|
+
await searchIndexer.deleteIndexContent([pathFromRoot]).catch(console.error);
|
|
2134
|
+
}
|
|
2028
2135
|
});
|
|
2029
2136
|
}
|
|
2030
2137
|
watchQueries(configManager, callback) {
|
|
@@ -2192,6 +2299,7 @@ var waitForDB = async (config3, apiUrl, verbose) => {
|
|
|
2192
2299
|
};
|
|
2193
2300
|
|
|
2194
2301
|
// src/next/commands/build-command/index.ts
|
|
2302
|
+
var import_search2 = require("@tinacms/search");
|
|
2195
2303
|
var BuildCommand = class extends BaseCommand {
|
|
2196
2304
|
constructor() {
|
|
2197
2305
|
super(...arguments);
|
|
@@ -2207,12 +2315,16 @@ var BuildCommand = class extends BaseCommand {
|
|
|
2207
2315
|
this.skipCloudChecks = import_clipanion3.Option.Boolean("--skip-cloud-checks", false, {
|
|
2208
2316
|
description: "Skips checking the provided cloud config."
|
|
2209
2317
|
});
|
|
2318
|
+
this.skipSearchIndex = import_clipanion3.Option.Boolean("--skip-search-index", false, {
|
|
2319
|
+
description: "Skip indexing the site for search"
|
|
2320
|
+
});
|
|
2210
2321
|
}
|
|
2211
2322
|
async catch(error) {
|
|
2212
2323
|
console.error(error);
|
|
2213
2324
|
process.exit(1);
|
|
2214
2325
|
}
|
|
2215
2326
|
async execute() {
|
|
2327
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s;
|
|
2216
2328
|
logger.info("Starting Tina build");
|
|
2217
2329
|
this.logDeprecationWarnings();
|
|
2218
2330
|
const configManager = new ConfigManager({
|
|
@@ -2255,7 +2367,13 @@ var BuildCommand = class extends BaseCommand {
|
|
|
2255
2367
|
});
|
|
2256
2368
|
}
|
|
2257
2369
|
if (this.localOption) {
|
|
2258
|
-
server = await createDevServer(
|
|
2370
|
+
server = await createDevServer(
|
|
2371
|
+
configManager,
|
|
2372
|
+
database,
|
|
2373
|
+
null,
|
|
2374
|
+
apiURL,
|
|
2375
|
+
true
|
|
2376
|
+
);
|
|
2259
2377
|
await server.listen(Number(this.port));
|
|
2260
2378
|
console.log("server listening on port", this.port);
|
|
2261
2379
|
}
|
|
@@ -2274,6 +2392,66 @@ var BuildCommand = class extends BaseCommand {
|
|
|
2274
2392
|
configManager.outputGitignorePath,
|
|
2275
2393
|
"index.html\nassets/"
|
|
2276
2394
|
);
|
|
2395
|
+
if (configManager.config.search && !this.skipSearchIndex && !this.localOption) {
|
|
2396
|
+
let client;
|
|
2397
|
+
const hasTinaSearch = Boolean((_b = (_a = configManager.config) == null ? void 0 : _a.search) == null ? void 0 : _b.tina);
|
|
2398
|
+
if (hasTinaSearch) {
|
|
2399
|
+
if (!((_c = configManager.config) == null ? void 0 : _c.branch)) {
|
|
2400
|
+
logger.error(
|
|
2401
|
+
`${dangerText(
|
|
2402
|
+
`ERROR: Branch not configured in tina search configuration.`
|
|
2403
|
+
)}`
|
|
2404
|
+
);
|
|
2405
|
+
throw new Error("Branch not configured in tina search configuration.");
|
|
2406
|
+
}
|
|
2407
|
+
if (!((_d = configManager.config) == null ? void 0 : _d.clientId)) {
|
|
2408
|
+
logger.error(`${dangerText(`ERROR: clientId not configured.`)}`);
|
|
2409
|
+
throw new Error("clientId not configured.");
|
|
2410
|
+
}
|
|
2411
|
+
if (!((_g = (_f = (_e = configManager.config) == null ? void 0 : _e.search) == null ? void 0 : _f.tina) == null ? void 0 : _g.indexerToken)) {
|
|
2412
|
+
logger.error(
|
|
2413
|
+
`${dangerText(
|
|
2414
|
+
`ERROR: indexerToken not configured in tina search configuration.`
|
|
2415
|
+
)}`
|
|
2416
|
+
);
|
|
2417
|
+
throw new Error(
|
|
2418
|
+
"indexerToken not configured in tina search configuration."
|
|
2419
|
+
);
|
|
2420
|
+
}
|
|
2421
|
+
client = new import_search2.TinaCMSSearchIndexClient({
|
|
2422
|
+
apiUrl: `${((_h = configManager.config.tinaioConfig) == null ? void 0 : _h.contentApiUrlOverride) || "https://content.tinajs.io"}/searchIndex/${(_i = configManager.config) == null ? void 0 : _i.clientId}`,
|
|
2423
|
+
branch: (_j = configManager.config) == null ? void 0 : _j.branch,
|
|
2424
|
+
indexerToken: (_m = (_l = (_k = configManager.config) == null ? void 0 : _k.search) == null ? void 0 : _l.tina) == null ? void 0 : _m.indexerToken,
|
|
2425
|
+
stopwordLanguages: (_p = (_o = (_n = configManager.config) == null ? void 0 : _n.search) == null ? void 0 : _o.tina) == null ? void 0 : _p.stopwordLanguages
|
|
2426
|
+
});
|
|
2427
|
+
} else {
|
|
2428
|
+
client = (_r = (_q = configManager.config) == null ? void 0 : _q.search) == null ? void 0 : _r.searchClient;
|
|
2429
|
+
}
|
|
2430
|
+
const searchIndexer = new import_search2.SearchIndexer({
|
|
2431
|
+
batchSize: ((_s = configManager.config.search) == null ? void 0 : _s.indexBatchSize) || 100,
|
|
2432
|
+
bridge: new import_graphql9.FilesystemBridge(
|
|
2433
|
+
configManager.rootPath,
|
|
2434
|
+
configManager.contentRootPath
|
|
2435
|
+
),
|
|
2436
|
+
schema: tinaSchema,
|
|
2437
|
+
client
|
|
2438
|
+
});
|
|
2439
|
+
let err;
|
|
2440
|
+
await spin({
|
|
2441
|
+
waitFor: async () => {
|
|
2442
|
+
try {
|
|
2443
|
+
await searchIndexer.indexAllContent();
|
|
2444
|
+
} catch (e) {
|
|
2445
|
+
err = e;
|
|
2446
|
+
}
|
|
2447
|
+
},
|
|
2448
|
+
text: "Building search index"
|
|
2449
|
+
});
|
|
2450
|
+
if (err) {
|
|
2451
|
+
logger.error(`${dangerText(`ERROR: ${err.message}`)}`);
|
|
2452
|
+
process.exit(1);
|
|
2453
|
+
}
|
|
2454
|
+
}
|
|
2277
2455
|
const summaryItems = [];
|
|
2278
2456
|
if (!configManager.shouldSkipSDK()) {
|
|
2279
2457
|
summaryItems.push({
|
|
@@ -4439,8 +4617,115 @@ InitCommand.usage = import_clipanion6.Command.Usage({
|
|
|
4439
4617
|
description: `Add Tina to an existing project`
|
|
4440
4618
|
});
|
|
4441
4619
|
|
|
4620
|
+
// src/next/commands/searchindex-command/index.ts
|
|
4621
|
+
var import_clipanion7 = require("clipanion");
|
|
4622
|
+
var import_graphql15 = require("@tinacms/graphql");
|
|
4623
|
+
var import_search3 = require("@tinacms/search");
|
|
4624
|
+
var SearchIndexCommand = class extends import_clipanion7.Command {
|
|
4625
|
+
constructor() {
|
|
4626
|
+
super(...arguments);
|
|
4627
|
+
this.rootPath = import_clipanion7.Option.String("--rootPath", {
|
|
4628
|
+
description: "Specify the root directory to run the CLI from (defaults to current working directory)"
|
|
4629
|
+
});
|
|
4630
|
+
this.verbose = import_clipanion7.Option.Boolean("-v,--verbose", false, {
|
|
4631
|
+
description: "increase verbosity of logged output"
|
|
4632
|
+
});
|
|
4633
|
+
}
|
|
4634
|
+
async catch(error) {
|
|
4635
|
+
logger.error("Error occured during tinacms search-index");
|
|
4636
|
+
console.error(error);
|
|
4637
|
+
process.exit(1);
|
|
4638
|
+
}
|
|
4639
|
+
async execute() {
|
|
4640
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u;
|
|
4641
|
+
const rootPath = this.rootPath || process.cwd();
|
|
4642
|
+
const configManager = new ConfigManager({ rootPath });
|
|
4643
|
+
try {
|
|
4644
|
+
await configManager.processConfig();
|
|
4645
|
+
} catch (e) {
|
|
4646
|
+
logger.error(e.message);
|
|
4647
|
+
if (this.verbose) {
|
|
4648
|
+
console.error(e);
|
|
4649
|
+
}
|
|
4650
|
+
}
|
|
4651
|
+
if (!((_a = configManager.config) == null ? void 0 : _a.search)) {
|
|
4652
|
+
logger.error("No search config found");
|
|
4653
|
+
process.exit(1);
|
|
4654
|
+
}
|
|
4655
|
+
const { schema } = configManager.config;
|
|
4656
|
+
const tinaSchema = await (0, import_graphql15.createSchema)({
|
|
4657
|
+
schema: { ...schema, config: configManager.config }
|
|
4658
|
+
});
|
|
4659
|
+
let client;
|
|
4660
|
+
const hasTinaSearch = Boolean((_c = (_b = configManager.config) == null ? void 0 : _b.search) == null ? void 0 : _c.tina);
|
|
4661
|
+
if (hasTinaSearch) {
|
|
4662
|
+
if (!((_d = configManager.config) == null ? void 0 : _d.branch)) {
|
|
4663
|
+
logger.error(
|
|
4664
|
+
`${dangerText(
|
|
4665
|
+
`ERROR: Branch not configured in tina search configuration.`
|
|
4666
|
+
)}`
|
|
4667
|
+
);
|
|
4668
|
+
throw new Error("Branch not configured in tina search configuration.");
|
|
4669
|
+
}
|
|
4670
|
+
if (!((_e = configManager.config) == null ? void 0 : _e.clientId)) {
|
|
4671
|
+
logger.error(`${dangerText(`ERROR: clientId not configured.`)}`);
|
|
4672
|
+
throw new Error("clientId not configured.");
|
|
4673
|
+
}
|
|
4674
|
+
if (!((_h = (_g = (_f = configManager.config) == null ? void 0 : _f.search) == null ? void 0 : _g.tina) == null ? void 0 : _h.indexerToken)) {
|
|
4675
|
+
logger.error(
|
|
4676
|
+
`${dangerText(
|
|
4677
|
+
`ERROR: indexerToken not configured in tina search configuration.`
|
|
4678
|
+
)}`
|
|
4679
|
+
);
|
|
4680
|
+
throw new Error(
|
|
4681
|
+
"indexerToken not configured in tina search configuration."
|
|
4682
|
+
);
|
|
4683
|
+
}
|
|
4684
|
+
client = new import_search3.TinaCMSSearchIndexClient({
|
|
4685
|
+
apiUrl: `${((_i = configManager.config.tinaioConfig) == null ? void 0 : _i.contentApiUrlOverride) || "https://content.tinajs.io"}/searchIndex/${(_j = configManager.config) == null ? void 0 : _j.clientId}`,
|
|
4686
|
+
branch: (_k = configManager.config) == null ? void 0 : _k.branch,
|
|
4687
|
+
indexerToken: (_n = (_m = (_l = configManager.config) == null ? void 0 : _l.search) == null ? void 0 : _m.tina) == null ? void 0 : _n.indexerToken,
|
|
4688
|
+
stopwordLanguages: (_q = (_p = (_o = configManager.config) == null ? void 0 : _o.search) == null ? void 0 : _p.tina) == null ? void 0 : _q.stopwordLanguages
|
|
4689
|
+
});
|
|
4690
|
+
} else {
|
|
4691
|
+
client = (_s = (_r = configManager.config) == null ? void 0 : _r.search) == null ? void 0 : _s.searchClient;
|
|
4692
|
+
}
|
|
4693
|
+
const searchIndexer = new import_search3.SearchIndexer({
|
|
4694
|
+
batchSize: ((_t = configManager.config.search) == null ? void 0 : _t.indexBatchSize) || 100,
|
|
4695
|
+
bridge: new import_graphql15.FilesystemBridge(
|
|
4696
|
+
configManager.rootPath,
|
|
4697
|
+
configManager.contentRootPath
|
|
4698
|
+
),
|
|
4699
|
+
schema: tinaSchema,
|
|
4700
|
+
textIndexLength: ((_u = configManager.config.search) == null ? void 0 : _u.maxSearchIndexFieldLength) || 100,
|
|
4701
|
+
client
|
|
4702
|
+
});
|
|
4703
|
+
let err;
|
|
4704
|
+
await spin({
|
|
4705
|
+
waitFor: async () => {
|
|
4706
|
+
try {
|
|
4707
|
+
await searchIndexer.indexAllContent();
|
|
4708
|
+
} catch (e) {
|
|
4709
|
+
err = e;
|
|
4710
|
+
}
|
|
4711
|
+
},
|
|
4712
|
+
text: "Building search index"
|
|
4713
|
+
});
|
|
4714
|
+
if (err) {
|
|
4715
|
+
logger.error(`${dangerText(`ERROR: ${err.message}`)}`);
|
|
4716
|
+
process.exit(1);
|
|
4717
|
+
}
|
|
4718
|
+
process.exit(0);
|
|
4719
|
+
}
|
|
4720
|
+
};
|
|
4721
|
+
SearchIndexCommand.paths = [["search-index"]];
|
|
4722
|
+
SearchIndexCommand.usage = import_clipanion7.Command.Usage({
|
|
4723
|
+
category: `Commands`,
|
|
4724
|
+
description: `Index the site for search`
|
|
4725
|
+
});
|
|
4726
|
+
|
|
4442
4727
|
// src/index.ts
|
|
4443
|
-
var cli = new
|
|
4728
|
+
var cli = new import_clipanion8.Cli({
|
|
4444
4729
|
binaryName: `tinacms`,
|
|
4445
4730
|
binaryLabel: `TinaCMS`,
|
|
4446
4731
|
binaryVersion: version
|
|
@@ -4450,9 +4735,10 @@ cli.register(BuildCommand);
|
|
|
4450
4735
|
cli.register(AuditCommand);
|
|
4451
4736
|
cli.register(InitCommand);
|
|
4452
4737
|
cli.register(CodemodCommand);
|
|
4453
|
-
cli.register(
|
|
4454
|
-
cli.register(
|
|
4455
|
-
cli.register(
|
|
4738
|
+
cli.register(SearchIndexCommand);
|
|
4739
|
+
cli.register(import_clipanion8.Builtins.DefinitionsCommand);
|
|
4740
|
+
cli.register(import_clipanion8.Builtins.HelpCommand);
|
|
4741
|
+
cli.register(import_clipanion8.Builtins.VersionCommand);
|
|
4456
4742
|
var src_default = cli;
|
|
4457
4743
|
// Annotate the CommonJS export names for ESM import in node:
|
|
4458
4744
|
0 && (module.exports = {});
|
|
@@ -10,6 +10,7 @@ export declare class BuildCommand extends BaseCommand {
|
|
|
10
10
|
* This option allows the user to skip the tina cloud checks if they want to. This could be useful for mismatched GraphQL versions or if they want to build only using the local client and never connect to Tina Cloud
|
|
11
11
|
*/
|
|
12
12
|
skipCloudChecks: boolean;
|
|
13
|
+
skipSearchIndex: boolean;
|
|
13
14
|
static usage: import("clipanion").Usage;
|
|
14
15
|
catch(error: any): Promise<void>;
|
|
15
16
|
execute(): Promise<number | void>;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Database } from '@tinacms/graphql';
|
|
2
2
|
import { ConfigManager } from '../../config-manager';
|
|
3
3
|
import { BaseCommand } from '../baseCommands';
|
|
4
|
+
import { SearchIndexer } from '@tinacms/search';
|
|
4
5
|
export declare class DevCommand extends BaseCommand {
|
|
5
6
|
static paths: string[][];
|
|
6
7
|
watchFolders: string;
|
|
@@ -9,6 +10,6 @@ export declare class DevCommand extends BaseCommand {
|
|
|
9
10
|
catch(error: any): Promise<void>;
|
|
10
11
|
logDeprecationWarnings(): void;
|
|
11
12
|
execute(): Promise<number | void>;
|
|
12
|
-
watchContentFiles(configManager: ConfigManager, database: Database): void;
|
|
13
|
+
watchContentFiles(configManager: ConfigManager, database: Database, searchIndexer?: SearchIndexer): void;
|
|
13
14
|
watchQueries(configManager: ConfigManager, callback: () => Promise<string>): void;
|
|
14
15
|
}
|
|
@@ -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, apiURL: string, noWatch: boolean) => Promise<import("vite").ViteDevServer>;
|
|
3
|
+
export declare const createDevServer: (configManager: ConfigManager, database: Database, searchIndex: any, apiURL: string, noWatch: boolean) => Promise<import("vite").ViteDevServer>;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export interface PathConfig {
|
|
2
|
+
apiURL: string;
|
|
3
|
+
searchPath: string;
|
|
4
|
+
}
|
|
5
|
+
export declare const createSearchIndexRouter: ({ config, searchIndex, }: {
|
|
6
|
+
config: PathConfig;
|
|
7
|
+
searchIndex: any;
|
|
8
|
+
}) => {
|
|
9
|
+
del: (req: any, res: any) => Promise<void>;
|
|
10
|
+
get: (req: any, res: any) => Promise<void>;
|
|
11
|
+
put: (req: any, res: any) => Promise<void>;
|
|
12
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Command } from 'clipanion';
|
|
2
|
+
export declare class SearchIndexCommand extends Command {
|
|
3
|
+
static paths: string[][];
|
|
4
|
+
rootPath: string;
|
|
5
|
+
verbose: boolean;
|
|
6
|
+
static usage: import("clipanion").Usage;
|
|
7
|
+
catch(error: any): Promise<void>;
|
|
8
|
+
execute(): Promise<number | void>;
|
|
9
|
+
}
|
|
@@ -7,10 +7,11 @@ 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, }: {
|
|
10
|
+
export declare const devServerEndPointsPlugin: ({ configManager, apiURL, database, searchIndex, }: {
|
|
11
11
|
apiURL: string;
|
|
12
12
|
database: Database;
|
|
13
13
|
configManager: ConfigManager;
|
|
14
|
+
searchIndex: any;
|
|
14
15
|
}) => Plugin;
|
|
15
16
|
export interface ViteSvgrOptions {
|
|
16
17
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tinacms/cli",
|
|
3
|
-
"version": "1.5.
|
|
3
|
+
"version": "1.5.18",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"typings": "dist/index.d.ts",
|
|
6
6
|
"files": [
|
|
@@ -58,11 +58,12 @@
|
|
|
58
58
|
"@tailwindcss/aspect-ratio": "^0.4.0",
|
|
59
59
|
"@tailwindcss/line-clamp": "^0.3.1",
|
|
60
60
|
"@tailwindcss/typography": "^0.5.9",
|
|
61
|
-
"@tinacms/app": "1.2.
|
|
62
|
-
"@tinacms/datalayer": "1.2.
|
|
63
|
-
"@tinacms/graphql": "1.4.
|
|
61
|
+
"@tinacms/app": "1.2.16",
|
|
62
|
+
"@tinacms/datalayer": "1.2.16",
|
|
63
|
+
"@tinacms/graphql": "1.4.16",
|
|
64
64
|
"@tinacms/metrics": "1.0.2",
|
|
65
|
-
"@tinacms/schema-tools": "1.4.
|
|
65
|
+
"@tinacms/schema-tools": "1.4.5",
|
|
66
|
+
"@tinacms/search": "1.0.1",
|
|
66
67
|
"@vitejs/plugin-react": "3.1.0",
|
|
67
68
|
"ajv": "^6.12.3",
|
|
68
69
|
"altair-express-middleware": "4.0.6",
|