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