@tinacms/cli 1.5.16 → 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 +313 -24
- 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");
|
|
@@ -922,7 +922,7 @@ var createMediaRouter = (config3) => {
|
|
|
922
922
|
const bb = (0, import_busboy.default)({ headers: req.headers });
|
|
923
923
|
bb.on("file", async (_name, file, _info) => {
|
|
924
924
|
var _a;
|
|
925
|
-
const fullPath = (_a = req.url) == null ? void 0 : _a.slice("/media/upload/".length);
|
|
925
|
+
const fullPath = decodeURI((_a = req.url) == null ? void 0 : _a.slice("/media/upload/".length));
|
|
926
926
|
const saveTo = import_path4.default.join(mediaFolder, ...fullPath.split("/"));
|
|
927
927
|
await import_fs_extra2.default.ensureDir(import_path4.default.dirname(saveTo));
|
|
928
928
|
file.pipe(import_fs_extra2.default.createWriteStream(saveTo));
|
|
@@ -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)(
|
|
@@ -1775,7 +1829,10 @@ var BaseCommand = class extends import_clipanion.Command {
|
|
|
1775
1829
|
process.on("SIGINT", exitHandler);
|
|
1776
1830
|
process.on("SIGUSR1", exitHandler);
|
|
1777
1831
|
process.on("SIGUSR2", exitHandler);
|
|
1778
|
-
process.on("uncaughtException",
|
|
1832
|
+
process.on("uncaughtException", (error) => {
|
|
1833
|
+
logger.error(`Uncaught exception ${error.name}`);
|
|
1834
|
+
console.error(error);
|
|
1835
|
+
});
|
|
1779
1836
|
}
|
|
1780
1837
|
logDeprecationWarnings() {
|
|
1781
1838
|
if (this.isomorphicGitBridge) {
|
|
@@ -1820,6 +1877,8 @@ var BaseCommand = class extends import_clipanion.Command {
|
|
|
1820
1877
|
};
|
|
1821
1878
|
|
|
1822
1879
|
// src/next/commands/dev-command/index.ts
|
|
1880
|
+
var import_memory_level2 = require("memory-level");
|
|
1881
|
+
var import_search = require("@tinacms/search");
|
|
1823
1882
|
var DevCommand = class extends BaseCommand {
|
|
1824
1883
|
constructor() {
|
|
1825
1884
|
super(...arguments);
|
|
@@ -1844,6 +1903,7 @@ var DevCommand = class extends BaseCommand {
|
|
|
1844
1903
|
}
|
|
1845
1904
|
}
|
|
1846
1905
|
async execute() {
|
|
1906
|
+
var _a, _b, _c, _d;
|
|
1847
1907
|
const configManager = new ConfigManager({
|
|
1848
1908
|
rootPath: this.rootPath,
|
|
1849
1909
|
legacyNoSDK: this.noSDK
|
|
@@ -1875,15 +1935,15 @@ var DevCommand = class extends BaseCommand {
|
|
|
1875
1935
|
} else {
|
|
1876
1936
|
database.clearCache();
|
|
1877
1937
|
}
|
|
1878
|
-
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);
|
|
1879
1939
|
const codegen2 = new Codegen({
|
|
1880
1940
|
isLocal: true,
|
|
1881
1941
|
configManager,
|
|
1882
1942
|
port: Number(this.port),
|
|
1883
1943
|
queryDoc,
|
|
1884
1944
|
fragDoc,
|
|
1885
|
-
graphqlSchemaDoc:
|
|
1886
|
-
tinaSchema,
|
|
1945
|
+
graphqlSchemaDoc: graphQLSchema2,
|
|
1946
|
+
tinaSchema: tinaSchema2,
|
|
1887
1947
|
lookup
|
|
1888
1948
|
});
|
|
1889
1949
|
const apiURL2 = await codegen2.execute();
|
|
@@ -1908,26 +1968,67 @@ var DevCommand = class extends BaseCommand {
|
|
|
1908
1968
|
}
|
|
1909
1969
|
await this.indexContentWithSpinner({
|
|
1910
1970
|
database,
|
|
1911
|
-
graphQLSchema,
|
|
1912
|
-
tinaSchema
|
|
1971
|
+
graphQLSchema: graphQLSchema2,
|
|
1972
|
+
tinaSchema: tinaSchema2
|
|
1913
1973
|
});
|
|
1914
|
-
return { apiURL: apiURL2, database };
|
|
1974
|
+
return { apiURL: apiURL2, database, graphQLSchema: graphQLSchema2, tinaSchema: tinaSchema2 };
|
|
1915
1975
|
};
|
|
1916
|
-
const { apiURL } = await setup({
|
|
1976
|
+
const { apiURL, graphQLSchema, tinaSchema } = await setup({
|
|
1977
|
+
firstTime: true
|
|
1978
|
+
});
|
|
1917
1979
|
await import_fs_extra4.default.outputFile(configManager.outputHTMLFilePath, devHTML(this.port));
|
|
1918
1980
|
await import_fs_extra4.default.outputFile(
|
|
1919
1981
|
configManager.outputGitignorePath,
|
|
1920
1982
|
"index.html\nassets/"
|
|
1921
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);
|
|
1922
1991
|
const server = await createDevServer(
|
|
1923
1992
|
configManager,
|
|
1924
1993
|
database,
|
|
1994
|
+
searchIndex,
|
|
1925
1995
|
apiURL,
|
|
1926
1996
|
this.noWatch
|
|
1927
1997
|
);
|
|
1928
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
|
+
}
|
|
1929
2026
|
if (!this.noWatch) {
|
|
1930
|
-
this.watchContentFiles(
|
|
2027
|
+
this.watchContentFiles(
|
|
2028
|
+
configManager,
|
|
2029
|
+
database,
|
|
2030
|
+
configManager.config.search && searchIndexer
|
|
2031
|
+
);
|
|
1931
2032
|
}
|
|
1932
2033
|
server.watcher.on("change", async (changedPath) => {
|
|
1933
2034
|
if (changedPath.includes("__generated__")) {
|
|
@@ -1998,7 +2099,7 @@ var DevCommand = class extends BaseCommand {
|
|
|
1998
2099
|
});
|
|
1999
2100
|
await this.startSubCommand();
|
|
2000
2101
|
}
|
|
2001
|
-
watchContentFiles(configManager, database) {
|
|
2102
|
+
watchContentFiles(configManager, database, searchIndexer) {
|
|
2002
2103
|
const collectionContentFiles = [];
|
|
2003
2104
|
configManager.config.schema.collections.forEach((collection) => {
|
|
2004
2105
|
const collectionGlob = `${import_path7.default.join(
|
|
@@ -2015,13 +2116,22 @@ var DevCommand = class extends BaseCommand {
|
|
|
2015
2116
|
return;
|
|
2016
2117
|
}
|
|
2017
2118
|
const pathFromRoot = configManager.printContentRelativePath(addedFile);
|
|
2018
|
-
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
|
+
}
|
|
2019
2123
|
}).on("change", async (changedFile) => {
|
|
2020
2124
|
const pathFromRoot = configManager.printContentRelativePath(changedFile);
|
|
2021
|
-
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
|
+
}
|
|
2022
2129
|
}).on("unlink", async (removedFile) => {
|
|
2023
2130
|
const pathFromRoot = configManager.printContentRelativePath(removedFile);
|
|
2024
|
-
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
|
+
}
|
|
2025
2135
|
});
|
|
2026
2136
|
}
|
|
2027
2137
|
watchQueries(configManager, callback) {
|
|
@@ -2189,6 +2299,7 @@ var waitForDB = async (config3, apiUrl, verbose) => {
|
|
|
2189
2299
|
};
|
|
2190
2300
|
|
|
2191
2301
|
// src/next/commands/build-command/index.ts
|
|
2302
|
+
var import_search2 = require("@tinacms/search");
|
|
2192
2303
|
var BuildCommand = class extends BaseCommand {
|
|
2193
2304
|
constructor() {
|
|
2194
2305
|
super(...arguments);
|
|
@@ -2204,12 +2315,16 @@ var BuildCommand = class extends BaseCommand {
|
|
|
2204
2315
|
this.skipCloudChecks = import_clipanion3.Option.Boolean("--skip-cloud-checks", false, {
|
|
2205
2316
|
description: "Skips checking the provided cloud config."
|
|
2206
2317
|
});
|
|
2318
|
+
this.skipSearchIndex = import_clipanion3.Option.Boolean("--skip-search-index", false, {
|
|
2319
|
+
description: "Skip indexing the site for search"
|
|
2320
|
+
});
|
|
2207
2321
|
}
|
|
2208
2322
|
async catch(error) {
|
|
2209
2323
|
console.error(error);
|
|
2210
2324
|
process.exit(1);
|
|
2211
2325
|
}
|
|
2212
2326
|
async execute() {
|
|
2327
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s;
|
|
2213
2328
|
logger.info("Starting Tina build");
|
|
2214
2329
|
this.logDeprecationWarnings();
|
|
2215
2330
|
const configManager = new ConfigManager({
|
|
@@ -2252,7 +2367,13 @@ var BuildCommand = class extends BaseCommand {
|
|
|
2252
2367
|
});
|
|
2253
2368
|
}
|
|
2254
2369
|
if (this.localOption) {
|
|
2255
|
-
server = await createDevServer(
|
|
2370
|
+
server = await createDevServer(
|
|
2371
|
+
configManager,
|
|
2372
|
+
database,
|
|
2373
|
+
null,
|
|
2374
|
+
apiURL,
|
|
2375
|
+
true
|
|
2376
|
+
);
|
|
2256
2377
|
await server.listen(Number(this.port));
|
|
2257
2378
|
console.log("server listening on port", this.port);
|
|
2258
2379
|
}
|
|
@@ -2271,6 +2392,66 @@ var BuildCommand = class extends BaseCommand {
|
|
|
2271
2392
|
configManager.outputGitignorePath,
|
|
2272
2393
|
"index.html\nassets/"
|
|
2273
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
|
+
}
|
|
2274
2455
|
const summaryItems = [];
|
|
2275
2456
|
if (!configManager.shouldSkipSDK()) {
|
|
2276
2457
|
summaryItems.push({
|
|
@@ -4436,8 +4617,115 @@ InitCommand.usage = import_clipanion6.Command.Usage({
|
|
|
4436
4617
|
description: `Add Tina to an existing project`
|
|
4437
4618
|
});
|
|
4438
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
|
+
|
|
4439
4727
|
// src/index.ts
|
|
4440
|
-
var cli = new
|
|
4728
|
+
var cli = new import_clipanion8.Cli({
|
|
4441
4729
|
binaryName: `tinacms`,
|
|
4442
4730
|
binaryLabel: `TinaCMS`,
|
|
4443
4731
|
binaryVersion: version
|
|
@@ -4447,9 +4735,10 @@ cli.register(BuildCommand);
|
|
|
4447
4735
|
cli.register(AuditCommand);
|
|
4448
4736
|
cli.register(InitCommand);
|
|
4449
4737
|
cli.register(CodemodCommand);
|
|
4450
|
-
cli.register(
|
|
4451
|
-
cli.register(
|
|
4452
|
-
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);
|
|
4453
4742
|
var src_default = cli;
|
|
4454
4743
|
// Annotate the CommonJS export names for ESM import in node:
|
|
4455
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",
|