@tinacms/cli 0.0.0-c312c38-20250414065513 → 0.0.0-c466c52-20250801052040
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/cmds/forestry-migrate/index.d.ts +2 -2
- package/dist/cmds/init/index.d.ts +2 -2
- package/dist/cmds/init/prompts/index.d.ts +2 -1
- package/dist/cmds/init/prompts/types.d.ts +2 -1
- package/dist/index.d.ts +4 -1
- package/dist/index.js +309 -292
- package/dist/next/commands/build-command/index.d.ts +3 -0
- package/dist/server/server.d.ts +1 -1
- package/dist/utils/sleep.d.ts +1 -0
- package/package.json +12 -8
package/dist/index.js
CHANGED
|
@@ -35,7 +35,7 @@ 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.10.1";
|
|
39
39
|
|
|
40
40
|
// src/next/commands/dev-command/index.ts
|
|
41
41
|
var import_path5 = __toESM(require("path"));
|
|
@@ -587,13 +587,12 @@ var Codegen = class {
|
|
|
587
587
|
return apiURL;
|
|
588
588
|
}
|
|
589
589
|
_createApiUrl() {
|
|
590
|
-
|
|
591
|
-
const
|
|
592
|
-
const
|
|
593
|
-
const token = (_c = this.configManager.config) == null ? void 0 : _c.token;
|
|
590
|
+
const branch = this.configManager.config?.branch;
|
|
591
|
+
const clientId = this.configManager.config?.clientId;
|
|
592
|
+
const token = this.configManager.config?.token;
|
|
594
593
|
const fullVersion = this.configManager.getTinaGraphQLVersion();
|
|
595
594
|
const version2 = `${fullVersion.major}.${fullVersion.minor}`;
|
|
596
|
-
const baseUrl =
|
|
595
|
+
const baseUrl = this.configManager.config.tinaioConfig?.contentApiUrlOverride || `https://${TINA_HOST}`;
|
|
597
596
|
if ((!branch || !clientId || !token) && !this.port && !this.configManager.config.contentApiUrlOverride) {
|
|
598
597
|
const missing = [];
|
|
599
598
|
if (!branch) missing.push("branch");
|
|
@@ -621,7 +620,6 @@ var Codegen = class {
|
|
|
621
620
|
return this.apiURL;
|
|
622
621
|
}
|
|
623
622
|
async genDatabaseClient() {
|
|
624
|
-
var _a, _b;
|
|
625
623
|
const authCollection = this.tinaSchema.getCollections().find((c) => c.isAuthCollection);
|
|
626
624
|
let authFields = [];
|
|
627
625
|
if (authCollection) {
|
|
@@ -632,7 +630,7 @@ var Codegen = class {
|
|
|
632
630
|
if (usersFields.length > 1) {
|
|
633
631
|
throw new Error("Only one user field is allowed");
|
|
634
632
|
}
|
|
635
|
-
authFields =
|
|
633
|
+
authFields = usersFields[0]?.collectable?.fields.map((f) => {
|
|
636
634
|
if (f.type !== "password" && f.type !== "object") {
|
|
637
635
|
if (f.uid) {
|
|
638
636
|
return `id:${f.name}`;
|
|
@@ -710,9 +708,8 @@ export default databaseClient;
|
|
|
710
708
|
`;
|
|
711
709
|
}
|
|
712
710
|
async genClient() {
|
|
713
|
-
|
|
714
|
-
const
|
|
715
|
-
const errorPolicy = (_c = (_b = this.configManager.config) == null ? void 0 : _b.client) == null ? void 0 : _c.errorPolicy;
|
|
711
|
+
const token = this.configManager.config?.token;
|
|
712
|
+
const errorPolicy = this.configManager.config?.client?.errorPolicy;
|
|
716
713
|
const apiURL = this.getApiURL();
|
|
717
714
|
const clientString = `import { createClient } from "tinacms/dist/client";
|
|
718
715
|
import { queries } from "./types";
|
|
@@ -811,11 +808,10 @@ var ConfigManager = class {
|
|
|
811
808
|
return this.rootPath !== this.contentRootPath;
|
|
812
809
|
}
|
|
813
810
|
shouldSkipSDK() {
|
|
814
|
-
var _a;
|
|
815
811
|
if (this.legacyNoSDK) {
|
|
816
812
|
return this.legacyNoSDK;
|
|
817
813
|
}
|
|
818
|
-
return
|
|
814
|
+
return this.config.client?.skip || false;
|
|
819
815
|
}
|
|
820
816
|
async processConfig() {
|
|
821
817
|
this.tinaFolderPath = await this.getTinaFolderPath(this.rootPath);
|
|
@@ -991,7 +987,7 @@ var ConfigManager = class {
|
|
|
991
987
|
};
|
|
992
988
|
}
|
|
993
989
|
const generatedSchema = import_fs_extra2.default.readJSONSync(this.generatedSchemaJSONPath);
|
|
994
|
-
if (!generatedSchema || !(typeof
|
|
990
|
+
if (!generatedSchema || !(typeof generatedSchema?.version !== "undefined")) {
|
|
995
991
|
throw new Error(
|
|
996
992
|
`Can not find Tina GraphQL version in ${this.generatedSchemaJSONPath}`
|
|
997
993
|
);
|
|
@@ -1168,7 +1164,7 @@ var createDBServer = (port) => {
|
|
|
1168
1164
|
});
|
|
1169
1165
|
});
|
|
1170
1166
|
dbServer.once("error", (err) => {
|
|
1171
|
-
if (
|
|
1167
|
+
if (err?.code === "EADDRINUSE") {
|
|
1172
1168
|
throw new Error(
|
|
1173
1169
|
`Tina Dev server is already in use. Datalayer server is busy on port ${port}`
|
|
1174
1170
|
);
|
|
@@ -1319,7 +1315,6 @@ var BaseCommand = class extends import_clipanion.Command {
|
|
|
1319
1315
|
const warnings = [];
|
|
1320
1316
|
await spin({
|
|
1321
1317
|
waitFor: async () => {
|
|
1322
|
-
var _a, _b;
|
|
1323
1318
|
const rootPath = configManager.rootPath;
|
|
1324
1319
|
let sha;
|
|
1325
1320
|
try {
|
|
@@ -1344,7 +1339,7 @@ var BaseCommand = class extends import_clipanion.Command {
|
|
|
1344
1339
|
}
|
|
1345
1340
|
for (const collection of tinaSchema.getCollections()) {
|
|
1346
1341
|
pathFilter[collection.path] = {
|
|
1347
|
-
matches:
|
|
1342
|
+
matches: collection.match?.exclude || collection.match?.include ? tinaSchema.getMatches({ collection }) : void 0
|
|
1348
1343
|
};
|
|
1349
1344
|
}
|
|
1350
1345
|
const { added, modified, deleted } = await (0, import_graphql8.getChangedFiles)({
|
|
@@ -1379,7 +1374,7 @@ var BaseCommand = class extends import_clipanion.Command {
|
|
|
1379
1374
|
if (sha) {
|
|
1380
1375
|
await database.setMetadata("lastSha", sha);
|
|
1381
1376
|
}
|
|
1382
|
-
if (res
|
|
1377
|
+
if (res?.warnings) {
|
|
1383
1378
|
warnings.push(...res.warnings);
|
|
1384
1379
|
}
|
|
1385
1380
|
},
|
|
@@ -1474,14 +1469,14 @@ var devHTML = (port) => `<!DOCTYPE html>
|
|
|
1474
1469
|
var import_vite3 = require("vite");
|
|
1475
1470
|
|
|
1476
1471
|
// src/next/vite/index.ts
|
|
1477
|
-
var import_node_path2 = __toESM(require("path"));
|
|
1472
|
+
var import_node_path2 = __toESM(require("node:path"));
|
|
1478
1473
|
var import_plugin_react = __toESM(require("@vitejs/plugin-react"));
|
|
1479
1474
|
var import_fs_extra4 = __toESM(require("fs-extra"));
|
|
1480
1475
|
var import_normalize_path3 = __toESM(require("normalize-path"));
|
|
1481
1476
|
var import_vite = require("vite");
|
|
1482
1477
|
|
|
1483
1478
|
// src/next/vite/tailwind.ts
|
|
1484
|
-
var import_node_path = __toESM(require("path"));
|
|
1479
|
+
var import_node_path = __toESM(require("node:path"));
|
|
1485
1480
|
var import_aspect_ratio = __toESM(require("@tailwindcss/aspect-ratio"));
|
|
1486
1481
|
var import_container_queries = __toESM(require("@tailwindcss/container-queries"));
|
|
1487
1482
|
var import_typography = __toESM(require("@tailwindcss/typography"));
|
|
@@ -1807,7 +1802,6 @@ var createConfig = async ({
|
|
|
1807
1802
|
noWatch,
|
|
1808
1803
|
rollupOptions
|
|
1809
1804
|
}) => {
|
|
1810
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
1811
1805
|
const publicEnv = {};
|
|
1812
1806
|
Object.keys(process.env).forEach((key) => {
|
|
1813
1807
|
if (key.startsWith("TINA_PUBLIC_") || key.startsWith("NEXT_PUBLIC_") || key === "NODE_ENV" || key === "HEAD") {
|
|
@@ -1829,9 +1823,9 @@ var createConfig = async ({
|
|
|
1829
1823
|
configManager.generatedFolderPath,
|
|
1830
1824
|
"static-media.json"
|
|
1831
1825
|
);
|
|
1832
|
-
if (
|
|
1826
|
+
if (configManager.config.media?.tina?.static) {
|
|
1833
1827
|
const staticMedia = await listFilesRecursively({
|
|
1834
|
-
directoryPath:
|
|
1828
|
+
directoryPath: configManager.config.media.tina?.mediaRoot || "",
|
|
1835
1829
|
config: configManager.config.media.tina,
|
|
1836
1830
|
roothPath: configManager.rootPath
|
|
1837
1831
|
});
|
|
@@ -1892,7 +1886,7 @@ var createConfig = async ({
|
|
|
1892
1886
|
// Used by picomatch https://github.com/micromatch/picomatch/blob/master/lib/utils.js#L4
|
|
1893
1887
|
"process.platform": `"${process.platform}"`,
|
|
1894
1888
|
__API_URL__: `"${apiURL}"`,
|
|
1895
|
-
__BASE_PATH__: `"${
|
|
1889
|
+
__BASE_PATH__: `"${configManager.config?.build?.basePath || ""}"`,
|
|
1896
1890
|
__TINA_GRAPHQL_VERSION__: version2
|
|
1897
1891
|
},
|
|
1898
1892
|
logLevel: "error",
|
|
@@ -1904,7 +1898,7 @@ var createConfig = async ({
|
|
|
1904
1898
|
include: ["react/jsx-runtime", "react/jsx-dev-runtime"]
|
|
1905
1899
|
},
|
|
1906
1900
|
server: {
|
|
1907
|
-
host:
|
|
1901
|
+
host: configManager.config?.build?.host ?? false,
|
|
1908
1902
|
watch: noWatch ? {
|
|
1909
1903
|
ignored: ["**/*"]
|
|
1910
1904
|
} : {
|
|
@@ -1932,7 +1926,8 @@ var createConfig = async ({
|
|
|
1932
1926
|
babel: {
|
|
1933
1927
|
// Supresses the warning [NOTE] babel The code generator has deoptimised the styling of
|
|
1934
1928
|
compact: true
|
|
1935
|
-
}
|
|
1929
|
+
},
|
|
1930
|
+
fastRefresh: false
|
|
1936
1931
|
}),
|
|
1937
1932
|
(0, import_vite.splitVendorChunkPlugin)(),
|
|
1938
1933
|
tinaTailwind(configManager.spaRootPath, configManager.prebuildFilePath),
|
|
@@ -1983,8 +1978,7 @@ var createMediaRouter = (config2) => {
|
|
|
1983
1978
|
const handlePost = async function(req, res) {
|
|
1984
1979
|
const bb = (0, import_busboy.default)({ headers: req.headers });
|
|
1985
1980
|
bb.on("file", async (_name, file, _info) => {
|
|
1986
|
-
|
|
1987
|
-
const fullPath = decodeURI((_a = req.url) == null ? void 0 : _a.slice("/media/upload/".length));
|
|
1981
|
+
const fullPath = decodeURI(req.url?.slice("/media/upload/".length));
|
|
1988
1982
|
const saveTo = import_path3.default.join(mediaFolder, ...fullPath.split("/"));
|
|
1989
1983
|
await import_fs_extra5.default.ensureDir(import_path3.default.dirname(saveTo));
|
|
1990
1984
|
file.pipe(import_fs_extra5.default.createWriteStream(saveTo));
|
|
@@ -2086,7 +2080,7 @@ var MediaModel = class {
|
|
|
2086
2080
|
return {
|
|
2087
2081
|
files: [],
|
|
2088
2082
|
directories: [],
|
|
2089
|
-
error: error
|
|
2083
|
+
error: error?.toString()
|
|
2090
2084
|
};
|
|
2091
2085
|
}
|
|
2092
2086
|
}
|
|
@@ -2103,7 +2097,7 @@ var MediaModel = class {
|
|
|
2103
2097
|
return { ok: true };
|
|
2104
2098
|
} catch (error) {
|
|
2105
2099
|
console.error(error);
|
|
2106
|
-
return { ok: false, message: error
|
|
2100
|
+
return { ok: false, message: error?.toString() };
|
|
2107
2101
|
}
|
|
2108
2102
|
}
|
|
2109
2103
|
};
|
|
@@ -2181,13 +2175,12 @@ var devServerEndPointsPlugin = ({
|
|
|
2181
2175
|
server.middlewares.use((0, import_cors.default)());
|
|
2182
2176
|
server.middlewares.use(import_body_parser.default.json({ limit: "5mb" }));
|
|
2183
2177
|
server.middlewares.use(async (req, res, next) => {
|
|
2184
|
-
|
|
2185
|
-
const mediaPaths = (_a = configManager.config.media) == null ? void 0 : _a.tina;
|
|
2178
|
+
const mediaPaths = configManager.config.media?.tina;
|
|
2186
2179
|
const mediaRouter = createMediaRouter({
|
|
2187
2180
|
rootPath: configManager.rootPath,
|
|
2188
2181
|
apiURL,
|
|
2189
|
-
publicFolder: parseMediaFolder(
|
|
2190
|
-
mediaRoot: parseMediaFolder(
|
|
2182
|
+
publicFolder: parseMediaFolder(mediaPaths?.publicFolder || ""),
|
|
2183
|
+
mediaRoot: parseMediaFolder(mediaPaths?.mediaRoot || "")
|
|
2191
2184
|
});
|
|
2192
2185
|
const searchIndexRouter = createSearchIndexRouter({
|
|
2193
2186
|
config: { apiURL, searchPath: "searchIndex" },
|
|
@@ -2260,7 +2253,7 @@ function viteTransformExtension({
|
|
|
2260
2253
|
name: "vite-plugin-svgr",
|
|
2261
2254
|
async transform(code, id) {
|
|
2262
2255
|
if (filter(id)) {
|
|
2263
|
-
const { transform: transform2 } = await
|
|
2256
|
+
const { transform: transform2 } = await import("@svgr/core");
|
|
2264
2257
|
const svgCode = await import_fs.default.promises.readFile(
|
|
2265
2258
|
id.replace(/\?.*$/, ""),
|
|
2266
2259
|
"utf8"
|
|
@@ -2345,6 +2338,20 @@ var DevCommand = class extends BaseCommand {
|
|
|
2345
2338
|
});
|
|
2346
2339
|
this.indexingLock = new import_async_lock.default();
|
|
2347
2340
|
}
|
|
2341
|
+
static {
|
|
2342
|
+
this.paths = [["dev"], ["server:start"]];
|
|
2343
|
+
}
|
|
2344
|
+
static {
|
|
2345
|
+
// Prevent indexes and reads occurring at once
|
|
2346
|
+
this.usage = import_clipanion2.Command.Usage({
|
|
2347
|
+
category: `Commands`,
|
|
2348
|
+
description: `Builds Tina and starts the dev server`,
|
|
2349
|
+
examples: [
|
|
2350
|
+
[`A basic example`, `$0 dev`],
|
|
2351
|
+
[`A second example`, `$0 dev --rootPath`]
|
|
2352
|
+
]
|
|
2353
|
+
});
|
|
2354
|
+
}
|
|
2348
2355
|
async catch(error) {
|
|
2349
2356
|
logger.error("Error occured during tinacms dev");
|
|
2350
2357
|
console.error(error);
|
|
@@ -2359,7 +2366,6 @@ var DevCommand = class extends BaseCommand {
|
|
|
2359
2366
|
}
|
|
2360
2367
|
}
|
|
2361
2368
|
async execute() {
|
|
2362
|
-
var _a, _b, _c, _d, _e, _f;
|
|
2363
2369
|
const configManager = new ConfigManager({
|
|
2364
2370
|
rootPath: this.rootPath,
|
|
2365
2371
|
legacyNoSDK: this.noSDK
|
|
@@ -2467,19 +2473,19 @@ ${dangerText(e.message)}
|
|
|
2467
2473
|
"index.html\nassets/"
|
|
2468
2474
|
);
|
|
2469
2475
|
const searchIndexClient = new import_search.LocalSearchIndexClient({
|
|
2470
|
-
stopwordLanguages:
|
|
2471
|
-
tokenSplitRegex:
|
|
2476
|
+
stopwordLanguages: configManager.config.search?.tina?.stopwordLanguages,
|
|
2477
|
+
tokenSplitRegex: configManager.config.search?.tina?.tokenSplitRegex
|
|
2472
2478
|
});
|
|
2473
2479
|
await searchIndexClient.onStartIndexing();
|
|
2474
2480
|
const searchIndexer = new import_search.SearchIndexer({
|
|
2475
|
-
batchSize:
|
|
2481
|
+
batchSize: configManager.config.search?.indexBatchSize || 100,
|
|
2476
2482
|
bridge: new import_graphql10.FilesystemBridge(
|
|
2477
2483
|
configManager.rootPath,
|
|
2478
2484
|
configManager.contentRootPath
|
|
2479
2485
|
),
|
|
2480
2486
|
schema: tinaSchema,
|
|
2481
2487
|
client: searchIndexClient,
|
|
2482
|
-
textIndexLength:
|
|
2488
|
+
textIndexLength: configManager.config.search?.maxSearchIndexFieldLength || 100
|
|
2483
2489
|
});
|
|
2484
2490
|
if (configManager.config.search) {
|
|
2485
2491
|
await spin({
|
|
@@ -2638,16 +2644,6 @@ ${dangerText(e.message)}
|
|
|
2638
2644
|
import_chokidar.default.watch(configManager.userQueriesAndFragmentsGlob).on("add", executeCallback).on("change", executeCallback).on("unlink", executeCallback);
|
|
2639
2645
|
}
|
|
2640
2646
|
};
|
|
2641
|
-
DevCommand.paths = [["dev"], ["server:start"]];
|
|
2642
|
-
// Prevent indexes and reads occurring at once
|
|
2643
|
-
DevCommand.usage = import_clipanion2.Command.Usage({
|
|
2644
|
-
category: `Commands`,
|
|
2645
|
-
description: `Builds Tina and starts the dev server`,
|
|
2646
|
-
examples: [
|
|
2647
|
-
[`A basic example`, `$0 dev`],
|
|
2648
|
-
[`A second example`, `$0 dev --rootPath`]
|
|
2649
|
-
]
|
|
2650
|
-
});
|
|
2651
2647
|
|
|
2652
2648
|
// src/next/commands/build-command/index.ts
|
|
2653
2649
|
var import_crypto = __toESM(require("crypto"));
|
|
@@ -2845,12 +2841,20 @@ var BuildCommand = class extends BaseCommand {
|
|
|
2845
2841
|
description: "Disables the client build cache"
|
|
2846
2842
|
});
|
|
2847
2843
|
}
|
|
2844
|
+
static {
|
|
2845
|
+
this.paths = [["build"]];
|
|
2846
|
+
}
|
|
2847
|
+
static {
|
|
2848
|
+
this.usage = import_clipanion3.Command.Usage({
|
|
2849
|
+
category: `Commands`,
|
|
2850
|
+
description: `Build the CMS and autogenerated modules for usage with TinaCloud`
|
|
2851
|
+
});
|
|
2852
|
+
}
|
|
2848
2853
|
async catch(error) {
|
|
2849
2854
|
console.error(error);
|
|
2850
2855
|
process.exit(1);
|
|
2851
2856
|
}
|
|
2852
2857
|
async execute() {
|
|
2853
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s;
|
|
2854
2858
|
logger.info("Starting Tina build");
|
|
2855
2859
|
this.logDeprecationWarnings();
|
|
2856
2860
|
const configManager = new ConfigManager({
|
|
@@ -2939,45 +2943,63 @@ ${dangerText(e.message)}
|
|
|
2939
2943
|
}
|
|
2940
2944
|
const skipCloudChecks = this.skipCloudChecks || configManager.hasSelfHostedConfig();
|
|
2941
2945
|
if (!skipCloudChecks) {
|
|
2942
|
-
|
|
2943
|
-
|
|
2944
|
-
|
|
2945
|
-
|
|
2946
|
-
|
|
2947
|
-
if (!hasUpstream && this.upstreamBranch) {
|
|
2948
|
-
logger.warn(
|
|
2949
|
-
`${dangerText(
|
|
2950
|
-
`WARN: Upstream branch '${this.upstreamBranch}' specified but no upstream project was found.`
|
|
2951
|
-
)}`
|
|
2946
|
+
try {
|
|
2947
|
+
const clientInfo = await this.checkClientInfo(
|
|
2948
|
+
configManager,
|
|
2949
|
+
codegen2.productionUrl,
|
|
2950
|
+
this.previewBaseBranch
|
|
2952
2951
|
);
|
|
2952
|
+
if (clientInfo.detectedBotBranch) {
|
|
2953
|
+
logger.warn(
|
|
2954
|
+
`${warnText(
|
|
2955
|
+
`WARN: Detected bot branch. Using schema/content from default branch '${clientInfo.defaultBranch}' instead of '${configManager.config.branch}'.`
|
|
2956
|
+
)}`
|
|
2957
|
+
);
|
|
2958
|
+
}
|
|
2959
|
+
if (!clientInfo.hasUpstream && this.upstreamBranch) {
|
|
2960
|
+
logger.warn(
|
|
2961
|
+
`${dangerText(
|
|
2962
|
+
`WARN: Upstream branch '${this.upstreamBranch}' specified but no upstream project was found.`
|
|
2963
|
+
)}`
|
|
2964
|
+
);
|
|
2965
|
+
}
|
|
2966
|
+
if (clientInfo.hasUpstream || this.previewBaseBranch && this.previewName) {
|
|
2967
|
+
await this.syncProject(configManager, codegen2.productionUrl, {
|
|
2968
|
+
upstreamBranch: this.upstreamBranch,
|
|
2969
|
+
previewBaseBranch: this.previewBaseBranch,
|
|
2970
|
+
previewName: this.previewName
|
|
2971
|
+
});
|
|
2972
|
+
}
|
|
2973
|
+
await waitForDB(
|
|
2974
|
+
configManager.config,
|
|
2975
|
+
codegen2.productionUrl,
|
|
2976
|
+
this.previewName,
|
|
2977
|
+
false
|
|
2978
|
+
);
|
|
2979
|
+
await this.checkGraphqlSchema(
|
|
2980
|
+
configManager,
|
|
2981
|
+
database,
|
|
2982
|
+
codegen2.productionUrl,
|
|
2983
|
+
clientInfo.timestamp
|
|
2984
|
+
);
|
|
2985
|
+
await this.checkTinaSchema(
|
|
2986
|
+
configManager,
|
|
2987
|
+
database,
|
|
2988
|
+
codegen2.productionUrl,
|
|
2989
|
+
this.previewName,
|
|
2990
|
+
this.verbose,
|
|
2991
|
+
clientInfo.timestamp
|
|
2992
|
+
);
|
|
2993
|
+
} catch (e) {
|
|
2994
|
+
logger.error(`
|
|
2995
|
+
|
|
2996
|
+
${dangerText(e.message)}
|
|
2997
|
+
`);
|
|
2998
|
+
if (this.verbose) {
|
|
2999
|
+
console.error(e);
|
|
3000
|
+
}
|
|
3001
|
+
process.exit(1);
|
|
2953
3002
|
}
|
|
2954
|
-
if (hasUpstream || this.previewBaseBranch && this.previewName) {
|
|
2955
|
-
await this.syncProject(configManager, codegen2.productionUrl, {
|
|
2956
|
-
upstreamBranch: this.upstreamBranch,
|
|
2957
|
-
previewBaseBranch: this.previewBaseBranch,
|
|
2958
|
-
previewName: this.previewName
|
|
2959
|
-
});
|
|
2960
|
-
}
|
|
2961
|
-
await waitForDB(
|
|
2962
|
-
configManager.config,
|
|
2963
|
-
codegen2.productionUrl,
|
|
2964
|
-
this.previewName,
|
|
2965
|
-
false
|
|
2966
|
-
);
|
|
2967
|
-
await this.checkGraphqlSchema(
|
|
2968
|
-
configManager,
|
|
2969
|
-
database,
|
|
2970
|
-
codegen2.productionUrl,
|
|
2971
|
-
timestamp
|
|
2972
|
-
);
|
|
2973
|
-
await this.checkTinaSchema(
|
|
2974
|
-
configManager,
|
|
2975
|
-
database,
|
|
2976
|
-
codegen2.productionUrl,
|
|
2977
|
-
this.previewName,
|
|
2978
|
-
this.verbose,
|
|
2979
|
-
timestamp
|
|
2980
|
-
);
|
|
2981
3003
|
}
|
|
2982
3004
|
await buildProductionSpa(configManager, database, codegen2.productionUrl);
|
|
2983
3005
|
await import_fs_extra7.default.outputFile(
|
|
@@ -2986,9 +3008,9 @@ ${dangerText(e.message)}
|
|
|
2986
3008
|
);
|
|
2987
3009
|
if (configManager.config.search && !this.skipSearchIndex && !this.localOption) {
|
|
2988
3010
|
let client;
|
|
2989
|
-
const hasTinaSearch = Boolean(
|
|
3011
|
+
const hasTinaSearch = Boolean(configManager.config?.search?.tina);
|
|
2990
3012
|
if (hasTinaSearch) {
|
|
2991
|
-
if (!
|
|
3013
|
+
if (!configManager.config?.branch) {
|
|
2992
3014
|
logger.error(
|
|
2993
3015
|
`${dangerText(
|
|
2994
3016
|
`ERROR: Branch not configured in tina search configuration.`
|
|
@@ -2998,11 +3020,11 @@ ${dangerText(e.message)}
|
|
|
2998
3020
|
"Branch not configured in tina search configuration."
|
|
2999
3021
|
);
|
|
3000
3022
|
}
|
|
3001
|
-
if (!
|
|
3023
|
+
if (!configManager.config?.clientId) {
|
|
3002
3024
|
logger.error(`${dangerText(`ERROR: clientId not configured.`)}`);
|
|
3003
3025
|
throw new Error("clientId not configured.");
|
|
3004
3026
|
}
|
|
3005
|
-
if (!
|
|
3027
|
+
if (!configManager.config?.search?.tina?.indexerToken) {
|
|
3006
3028
|
logger.error(
|
|
3007
3029
|
`${dangerText(
|
|
3008
3030
|
`ERROR: indexerToken not configured in tina search configuration.`
|
|
@@ -3013,16 +3035,16 @@ ${dangerText(e.message)}
|
|
|
3013
3035
|
);
|
|
3014
3036
|
}
|
|
3015
3037
|
client = new import_search2.TinaCMSSearchIndexClient({
|
|
3016
|
-
apiUrl: `${
|
|
3017
|
-
branch:
|
|
3018
|
-
indexerToken:
|
|
3019
|
-
stopwordLanguages:
|
|
3038
|
+
apiUrl: `${configManager.config.tinaioConfig?.contentApiUrlOverride || "https://content.tinajs.io"}/searchIndex/${configManager.config?.clientId}`,
|
|
3039
|
+
branch: configManager.config?.branch,
|
|
3040
|
+
indexerToken: configManager.config?.search?.tina?.indexerToken,
|
|
3041
|
+
stopwordLanguages: configManager.config?.search?.tina?.stopwordLanguages
|
|
3020
3042
|
});
|
|
3021
3043
|
} else {
|
|
3022
|
-
client =
|
|
3044
|
+
client = configManager.config?.search?.searchClient;
|
|
3023
3045
|
}
|
|
3024
3046
|
const searchIndexer = new import_search2.SearchIndexer({
|
|
3025
|
-
batchSize:
|
|
3047
|
+
batchSize: configManager.config.search?.indexBatchSize || 100,
|
|
3026
3048
|
bridge: new import_graphql11.FilesystemBridge(
|
|
3027
3049
|
configManager.rootPath,
|
|
3028
3050
|
configManager.contentRootPath
|
|
@@ -3090,86 +3112,88 @@ ${dangerText(e.message)}
|
|
|
3090
3112
|
}
|
|
3091
3113
|
}
|
|
3092
3114
|
async checkClientInfo(configManager, apiURL, previewBaseBranch) {
|
|
3115
|
+
const MAX_RETRIES = 5;
|
|
3093
3116
|
const { config: config2 } = configManager;
|
|
3094
3117
|
const token = config2.token;
|
|
3095
3118
|
const { clientId, branch, host } = (0, import_schema_tools2.parseURL)(apiURL);
|
|
3096
|
-
const url = `https://${host}/db/${clientId}/status/${previewBaseBranch || branch}`;
|
|
3097
3119
|
const bar2 = new import_progress2.default("Checking clientId and token. :prog", 1);
|
|
3098
|
-
|
|
3099
|
-
|
|
3100
|
-
|
|
3101
|
-
|
|
3102
|
-
|
|
3103
|
-
|
|
3104
|
-
|
|
3105
|
-
|
|
3106
|
-
|
|
3107
|
-
|
|
3108
|
-
|
|
3109
|
-
|
|
3110
|
-
|
|
3111
|
-
|
|
3112
|
-
|
|
3113
|
-
|
|
3114
|
-
|
|
3120
|
+
const getBranchInfo = async () => {
|
|
3121
|
+
const url = `https://${host}/db/${clientId}/status/${previewBaseBranch || branch}`;
|
|
3122
|
+
const branchInfo2 = {
|
|
3123
|
+
status: "unknown",
|
|
3124
|
+
branchKnown: false,
|
|
3125
|
+
hasUpstream: false,
|
|
3126
|
+
timestamp: 0,
|
|
3127
|
+
detectedBotBranch: false,
|
|
3128
|
+
defaultBranch: void 0
|
|
3129
|
+
};
|
|
3130
|
+
try {
|
|
3131
|
+
const res = await request({
|
|
3132
|
+
token,
|
|
3133
|
+
url
|
|
3134
|
+
});
|
|
3135
|
+
branchInfo2.status = res.status;
|
|
3136
|
+
branchInfo2.branchKnown = res.status !== "unknown";
|
|
3137
|
+
branchInfo2.timestamp = res.timestamp || 0;
|
|
3138
|
+
branchInfo2.hasUpstream = res.hasUpstream;
|
|
3139
|
+
branchInfo2.detectedBotBranch = res.json.detectedBotBranch;
|
|
3140
|
+
branchInfo2.defaultBranch = res.json.defaultBranch;
|
|
3141
|
+
} catch (e) {
|
|
3142
|
+
summary({
|
|
3143
|
+
heading: "Error when checking client information",
|
|
3144
|
+
items: [
|
|
3145
|
+
{
|
|
3146
|
+
emoji: "\u274C",
|
|
3147
|
+
heading: "You provided",
|
|
3148
|
+
subItems: [
|
|
3149
|
+
{
|
|
3150
|
+
key: "clientId",
|
|
3151
|
+
value: config2.clientId
|
|
3152
|
+
},
|
|
3153
|
+
{
|
|
3154
|
+
key: "branch",
|
|
3155
|
+
value: config2.branch
|
|
3156
|
+
},
|
|
3157
|
+
{
|
|
3158
|
+
key: "token",
|
|
3159
|
+
value: config2.token
|
|
3160
|
+
}
|
|
3161
|
+
]
|
|
3162
|
+
}
|
|
3163
|
+
]
|
|
3164
|
+
});
|
|
3165
|
+
throw e;
|
|
3115
3166
|
}
|
|
3116
|
-
|
|
3117
|
-
|
|
3118
|
-
|
|
3119
|
-
|
|
3120
|
-
|
|
3121
|
-
|
|
3122
|
-
|
|
3123
|
-
|
|
3124
|
-
|
|
3125
|
-
|
|
3126
|
-
|
|
3127
|
-
},
|
|
3128
|
-
{
|
|
3129
|
-
key: "branch",
|
|
3130
|
-
value: config2.branch
|
|
3131
|
-
},
|
|
3132
|
-
{
|
|
3133
|
-
key: "token",
|
|
3134
|
-
value: config2.token
|
|
3135
|
-
}
|
|
3136
|
-
]
|
|
3137
|
-
}
|
|
3138
|
-
]
|
|
3139
|
-
});
|
|
3140
|
-
throw e;
|
|
3141
|
-
}
|
|
3142
|
-
const branchBar = new import_progress2.default("Checking branch is on TinaCloud. :prog", 1);
|
|
3143
|
-
if (branchKnown) {
|
|
3167
|
+
return branchInfo2;
|
|
3168
|
+
};
|
|
3169
|
+
const branchInfo = await getBranchInfo();
|
|
3170
|
+
bar2.tick({
|
|
3171
|
+
prog: "\u2705"
|
|
3172
|
+
});
|
|
3173
|
+
const branchBar = new import_progress2.default(
|
|
3174
|
+
`Checking branch '${config2.branch}' is on TinaCloud. :prog`,
|
|
3175
|
+
1
|
|
3176
|
+
);
|
|
3177
|
+
if (branchInfo.branchKnown) {
|
|
3144
3178
|
branchBar.tick({
|
|
3145
3179
|
prog: "\u2705"
|
|
3146
3180
|
});
|
|
3147
|
-
return
|
|
3148
|
-
hasUpstream,
|
|
3149
|
-
timestamp
|
|
3150
|
-
};
|
|
3181
|
+
return branchInfo;
|
|
3151
3182
|
}
|
|
3152
|
-
for (let i =
|
|
3153
|
-
await
|
|
3154
|
-
|
|
3155
|
-
|
|
3156
|
-
|
|
3157
|
-
|
|
3158
|
-
|
|
3159
|
-
|
|
3160
|
-
|
|
3161
|
-
|
|
3162
|
-
|
|
3163
|
-
|
|
3164
|
-
|
|
3165
|
-
|
|
3166
|
-
prog: "\u2705"
|
|
3167
|
-
});
|
|
3168
|
-
return;
|
|
3169
|
-
}
|
|
3170
|
-
},
|
|
3171
|
-
ms: 5e3
|
|
3172
|
-
});
|
|
3183
|
+
for (let i = 1; i <= MAX_RETRIES; i++) {
|
|
3184
|
+
await timeout(5e3);
|
|
3185
|
+
const branchInfo2 = await getBranchInfo();
|
|
3186
|
+
if (this.verbose) {
|
|
3187
|
+
logger.info(
|
|
3188
|
+
`Branch status: ${branchInfo2.status}. Attempt: ${i}. Trying again in 5 seconds.`
|
|
3189
|
+
);
|
|
3190
|
+
}
|
|
3191
|
+
if (branchInfo2.branchKnown) {
|
|
3192
|
+
branchBar.tick({
|
|
3193
|
+
prog: "\u2705"
|
|
3194
|
+
});
|
|
3195
|
+
return branchInfo2;
|
|
3196
|
+
}
|
|
3173
3197
|
}
|
|
3174
3198
|
branchBar.tick({
|
|
3175
3199
|
prog: "\u274C"
|
|
@@ -3177,7 +3201,7 @@ ${dangerText(e.message)}
|
|
|
3177
3201
|
logger.error(
|
|
3178
3202
|
`${dangerText(
|
|
3179
3203
|
`ERROR: Branch '${branch}' is not on TinaCloud.`
|
|
3180
|
-
)} Please make sure that branch '${branch}' exists in your repository and that you have pushed your all changes to the remote. View all
|
|
3204
|
+
)} Please make sure that branch '${branch}' exists in your repository and that you have pushed your all changes to the remote. View all branches and their current status here: ${linkText(
|
|
3181
3205
|
`https://app.tina.io/projects/${clientId}/configuration`
|
|
3182
3206
|
)}`
|
|
3183
3207
|
);
|
|
@@ -3252,7 +3276,7 @@ ${dangerText(e.message)}
|
|
|
3252
3276
|
prog: "\u274C"
|
|
3253
3277
|
});
|
|
3254
3278
|
let errorMessage = `The remote GraphQL schema does not exist. Check indexing for this branch.`;
|
|
3255
|
-
if (config2
|
|
3279
|
+
if (config2?.branch) {
|
|
3256
3280
|
errorMessage += `
|
|
3257
3281
|
|
|
3258
3282
|
Additional info: Branch: ${config2.branch}, Client ID: ${config2.clientId} `;
|
|
@@ -3284,7 +3308,7 @@ Check out '${faqLink}' for possible solutions.`}`;
|
|
|
3284
3308
|
Additional info:
|
|
3285
3309
|
|
|
3286
3310
|
`;
|
|
3287
|
-
if (config2
|
|
3311
|
+
if (config2?.branch) {
|
|
3288
3312
|
errorMessage += ` Branch: ${config2.branch}, Client ID: ${config2.clientId}
|
|
3289
3313
|
`;
|
|
3290
3314
|
}
|
|
@@ -3333,7 +3357,7 @@ Additional info:
|
|
|
3333
3357
|
prog: "\u274C"
|
|
3334
3358
|
});
|
|
3335
3359
|
let errorMessage = `The remote Tina schema does not exist. Check indexing for this branch.`;
|
|
3336
|
-
if (config2
|
|
3360
|
+
if (config2?.branch) {
|
|
3337
3361
|
errorMessage += `
|
|
3338
3362
|
|
|
3339
3363
|
Additional info: Branch: ${config2.branch}, Client ID: ${config2.clientId} `;
|
|
@@ -3364,7 +3388,7 @@ Additional info: Branch: ${config2.branch}, Client ID: ${config2.clientId} `;
|
|
|
3364
3388
|
Additional info:
|
|
3365
3389
|
|
|
3366
3390
|
`;
|
|
3367
|
-
if (config2
|
|
3391
|
+
if (config2?.branch) {
|
|
3368
3392
|
errorMessage += ` Branch: ${config2.branch}, Client ID: ${config2.clientId}
|
|
3369
3393
|
`;
|
|
3370
3394
|
}
|
|
@@ -3376,18 +3400,13 @@ Additional info:
|
|
|
3376
3400
|
}
|
|
3377
3401
|
}
|
|
3378
3402
|
};
|
|
3379
|
-
BuildCommand.paths = [["build"]];
|
|
3380
|
-
BuildCommand.usage = import_clipanion3.Command.Usage({
|
|
3381
|
-
category: `Commands`,
|
|
3382
|
-
description: `Build the CMS and autogenerated modules for usage with TinaCloud`
|
|
3383
|
-
});
|
|
3384
3403
|
async function request(args) {
|
|
3385
3404
|
const headers = new Headers();
|
|
3386
3405
|
if (args.token) {
|
|
3387
3406
|
headers.append("X-API-KEY", args.token);
|
|
3388
3407
|
}
|
|
3389
3408
|
headers.append("Content-Type", "application/json");
|
|
3390
|
-
const url = args
|
|
3409
|
+
const url = args?.url;
|
|
3391
3410
|
const res = await fetch(url, {
|
|
3392
3411
|
method: args.method || "GET",
|
|
3393
3412
|
headers,
|
|
@@ -3417,9 +3436,10 @@ Message from server: ${json.message}`;
|
|
|
3417
3436
|
);
|
|
3418
3437
|
}
|
|
3419
3438
|
return {
|
|
3420
|
-
status: json
|
|
3421
|
-
timestamp: json
|
|
3422
|
-
hasUpstream:
|
|
3439
|
+
status: json?.status,
|
|
3440
|
+
timestamp: json?.timestamp,
|
|
3441
|
+
hasUpstream: json?.hasUpstream || false,
|
|
3442
|
+
json
|
|
3423
3443
|
};
|
|
3424
3444
|
}
|
|
3425
3445
|
var fetchRemoteGraphqlSchema = async ({
|
|
@@ -3442,7 +3462,7 @@ var fetchRemoteGraphqlSchema = async ({
|
|
|
3442
3462
|
});
|
|
3443
3463
|
const data = await res.json();
|
|
3444
3464
|
return {
|
|
3445
|
-
remoteSchema: data
|
|
3465
|
+
remoteSchema: data?.data,
|
|
3446
3466
|
remoteRuntimeVersion: res.headers.get("tinacms-grapqhl-version"),
|
|
3447
3467
|
remoteProjectVersion: res.headers.get("tinacms-graphql-project-version")
|
|
3448
3468
|
};
|
|
@@ -3652,6 +3672,15 @@ var AuditCommand = class extends import_clipanion4.Command {
|
|
|
3652
3672
|
description: "Specify a port to run the datalayer server on. (default 9000)"
|
|
3653
3673
|
});
|
|
3654
3674
|
}
|
|
3675
|
+
static {
|
|
3676
|
+
this.paths = [["audit"]];
|
|
3677
|
+
}
|
|
3678
|
+
static {
|
|
3679
|
+
this.usage = import_clipanion4.Command.Usage({
|
|
3680
|
+
category: `Commands`,
|
|
3681
|
+
description: `Audit config and content files`
|
|
3682
|
+
});
|
|
3683
|
+
}
|
|
3655
3684
|
async catch(error) {
|
|
3656
3685
|
logger.error("Error occured during tinacms audit");
|
|
3657
3686
|
if (this.verbose) {
|
|
@@ -3705,11 +3734,6 @@ var AuditCommand = class extends import_clipanion4.Command {
|
|
|
3705
3734
|
process.exit();
|
|
3706
3735
|
}
|
|
3707
3736
|
};
|
|
3708
|
-
AuditCommand.paths = [["audit"]];
|
|
3709
|
-
AuditCommand.usage = import_clipanion4.Command.Usage({
|
|
3710
|
-
category: `Commands`,
|
|
3711
|
-
description: `Audit config and content files`
|
|
3712
|
-
});
|
|
3713
3737
|
|
|
3714
3738
|
// src/next/commands/init-command/index.ts
|
|
3715
3739
|
var import_clipanion6 = require("clipanion");
|
|
@@ -3728,13 +3752,13 @@ var makeGeneratedFile = async (name2, generatedFileType, parentPath, opts) => {
|
|
|
3728
3752
|
const result = {
|
|
3729
3753
|
fullPathTS: import_path7.default.join(
|
|
3730
3754
|
parentPath,
|
|
3731
|
-
`${name2}.${
|
|
3755
|
+
`${name2}.${opts?.typescriptSuffix || opts?.extensionOverride || "ts"}`
|
|
3732
3756
|
),
|
|
3733
3757
|
fullPathJS: import_path7.default.join(
|
|
3734
3758
|
parentPath,
|
|
3735
|
-
`${name2}.${
|
|
3759
|
+
`${name2}.${opts?.extensionOverride || "js"}`
|
|
3736
3760
|
),
|
|
3737
|
-
fullPathOverride:
|
|
3761
|
+
fullPathOverride: opts?.extensionOverride ? import_path7.default.join(parentPath, `${name2}.${opts?.extensionOverride}`) : "",
|
|
3738
3762
|
generatedFileType,
|
|
3739
3763
|
name: name2,
|
|
3740
3764
|
parentPath,
|
|
@@ -3762,7 +3786,6 @@ var detectEnvironment = async ({
|
|
|
3762
3786
|
rootPath,
|
|
3763
3787
|
debug = false
|
|
3764
3788
|
}) => {
|
|
3765
|
-
var _a;
|
|
3766
3789
|
const hasForestryConfig = await import_fs_extra8.default.pathExists(
|
|
3767
3790
|
import_path7.default.join(pathToForestryConfig, ".forestry", "settings.yml")
|
|
3768
3791
|
);
|
|
@@ -3819,10 +3842,10 @@ var detectEnvironment = async ({
|
|
|
3819
3842
|
try {
|
|
3820
3843
|
const packageJSON = await import_fs_extra8.default.readJSON("package.json");
|
|
3821
3844
|
const deps = [];
|
|
3822
|
-
if (packageJSON
|
|
3845
|
+
if (packageJSON?.dependencies) {
|
|
3823
3846
|
deps.push(...Object.keys(packageJSON.dependencies));
|
|
3824
3847
|
}
|
|
3825
|
-
if (packageJSON
|
|
3848
|
+
if (packageJSON?.devDependencies) {
|
|
3826
3849
|
deps.push(...Object.keys(packageJSON.devDependencies));
|
|
3827
3850
|
}
|
|
3828
3851
|
if (deps.includes("@tinacms/cli") && deps.includes("tinacms")) {
|
|
@@ -3843,7 +3866,7 @@ var detectEnvironment = async ({
|
|
|
3843
3866
|
const hugoConfigPath = import_path7.default.join(rootPath, "config.toml");
|
|
3844
3867
|
if (await import_fs_extra8.default.pathExists(hugoConfigPath)) {
|
|
3845
3868
|
const hugoConfig = await import_fs_extra8.default.readFile(hugoConfigPath, "utf8");
|
|
3846
|
-
const metaDataFormat =
|
|
3869
|
+
const metaDataFormat = hugoConfig.toString().match(/metaDataFormat = "(.*)"/)?.[1];
|
|
3847
3870
|
if (metaDataFormat && (metaDataFormat === "yaml" || metaDataFormat === "toml" || metaDataFormat === "json")) {
|
|
3848
3871
|
frontMatterFormat = metaDataFormat;
|
|
3849
3872
|
}
|
|
@@ -4462,6 +4485,7 @@ var import_path9 = __toESM(require("path"));
|
|
|
4462
4485
|
var import_js_yaml2 = __toESM(require("js-yaml"));
|
|
4463
4486
|
var import_minimatch = __toESM(require("minimatch"));
|
|
4464
4487
|
var import_graphql16 = require("@tinacms/graphql");
|
|
4488
|
+
var import_schema_tools3 = require("@tinacms/schema-tools");
|
|
4465
4489
|
|
|
4466
4490
|
// src/cmds/forestry-migrate/util/index.ts
|
|
4467
4491
|
var import_fs_extra9 = __toESM(require("fs-extra"));
|
|
@@ -4494,8 +4518,7 @@ var ErrorSingleton = class _ErrorSingleton {
|
|
|
4494
4518
|
this.collectionNameErrors.push(error);
|
|
4495
4519
|
}
|
|
4496
4520
|
printCollectionNameErrors() {
|
|
4497
|
-
|
|
4498
|
-
if ((_a = this.collectionNameErrors) == null ? void 0 : _a.length) {
|
|
4521
|
+
if (this.collectionNameErrors?.length) {
|
|
4499
4522
|
logger.error(
|
|
4500
4523
|
dangerText("ERROR: TinaCMS only supports alphanumeric template names")
|
|
4501
4524
|
);
|
|
@@ -4677,8 +4700,7 @@ var transformForestryFieldsToTinaFields = ({
|
|
|
4677
4700
|
skipBlocks = false
|
|
4678
4701
|
}) => {
|
|
4679
4702
|
const tinaFields = [];
|
|
4680
|
-
fields
|
|
4681
|
-
var _a, _b, _c, _d;
|
|
4703
|
+
fields?.forEach((forestryField2) => {
|
|
4682
4704
|
if (forestryField2.name === "menu") {
|
|
4683
4705
|
logger.info(
|
|
4684
4706
|
warnText(
|
|
@@ -4754,12 +4776,12 @@ var transformForestryFieldsToTinaFields = ({
|
|
|
4754
4776
|
};
|
|
4755
4777
|
break;
|
|
4756
4778
|
case "select":
|
|
4757
|
-
if (
|
|
4779
|
+
if (forestryField2.config?.options) {
|
|
4758
4780
|
field = {
|
|
4759
4781
|
type: "string",
|
|
4760
4782
|
...getTinaFieldsFromName(forestryField2.name),
|
|
4761
4783
|
label: forestryField2.label,
|
|
4762
|
-
options:
|
|
4784
|
+
options: forestryField2.config?.options || []
|
|
4763
4785
|
};
|
|
4764
4786
|
} else {
|
|
4765
4787
|
logger.info(
|
|
@@ -4777,7 +4799,7 @@ var transformForestryFieldsToTinaFields = ({
|
|
|
4777
4799
|
label: forestryField2.label,
|
|
4778
4800
|
list: true
|
|
4779
4801
|
};
|
|
4780
|
-
if (
|
|
4802
|
+
if (forestryField2.config?.options) {
|
|
4781
4803
|
field.options = forestryField2.config.options;
|
|
4782
4804
|
}
|
|
4783
4805
|
break;
|
|
@@ -4825,7 +4847,7 @@ var transformForestryFieldsToTinaFields = ({
|
|
|
4825
4847
|
break;
|
|
4826
4848
|
}
|
|
4827
4849
|
const templates2 = [];
|
|
4828
|
-
forestryField2
|
|
4850
|
+
forestryField2?.template_types.forEach((tem) => {
|
|
4829
4851
|
const { template: template2 } = getFieldsFromTemplates({
|
|
4830
4852
|
tem,
|
|
4831
4853
|
skipBlocks: true,
|
|
@@ -4883,7 +4905,7 @@ var transformForestryFieldsToTinaFields = ({
|
|
|
4883
4905
|
);
|
|
4884
4906
|
}
|
|
4885
4907
|
if (field) {
|
|
4886
|
-
if (
|
|
4908
|
+
if (forestryField2.config?.required) {
|
|
4887
4909
|
field = { ...field, required: true };
|
|
4888
4910
|
}
|
|
4889
4911
|
tinaFields.push(field);
|
|
@@ -4945,8 +4967,7 @@ var stringifyLabelWithField = (label) => {
|
|
|
4945
4967
|
return `${labelString}Fields`;
|
|
4946
4968
|
};
|
|
4947
4969
|
var transformForestryMatchToTinaMatch = (match) => {
|
|
4948
|
-
|
|
4949
|
-
const newMatch = (_b = (_a = match.replace(" ", "").replace(/\.?(mdx|md|json|yaml|yml|toml)/g, "")) == null ? void 0 : _a.replace(/\..*$/g, "")) == null ? void 0 : _b.replace("{}", "");
|
|
4970
|
+
const newMatch = match.replace(" ", "").replace(/\.?(mdx|md|json|yaml|yml|toml)/g, "")?.replace(/\..*$/g, "")?.replace("{}", "");
|
|
4950
4971
|
if (match !== newMatch) {
|
|
4951
4972
|
logger.info(
|
|
4952
4973
|
`Info: Match ${match} was transformed to ${newMatch}. See ${linkText(
|
|
@@ -4958,7 +4979,7 @@ var transformForestryMatchToTinaMatch = (match) => {
|
|
|
4958
4979
|
};
|
|
4959
4980
|
function checkExt(ext) {
|
|
4960
4981
|
const extReal = ext.replace(".", "");
|
|
4961
|
-
if (
|
|
4982
|
+
if (import_schema_tools3.CONTENT_FORMATS.includes(extReal)) {
|
|
4962
4983
|
return extReal;
|
|
4963
4984
|
} else {
|
|
4964
4985
|
return false;
|
|
@@ -5011,18 +5032,18 @@ var generateCollectionFromForestrySection = (args) => {
|
|
|
5011
5032
|
}
|
|
5012
5033
|
if (section.match) {
|
|
5013
5034
|
baseCollection.match = {
|
|
5014
|
-
...
|
|
5035
|
+
...baseCollection?.match || {},
|
|
5015
5036
|
include: transformForestryMatchToTinaMatch(section.match)
|
|
5016
5037
|
};
|
|
5017
5038
|
}
|
|
5018
5039
|
if (section.exclude) {
|
|
5019
5040
|
baseCollection.match = {
|
|
5020
|
-
...
|
|
5041
|
+
...baseCollection?.match || {},
|
|
5021
5042
|
exclude: transformForestryMatchToTinaMatch(section.exclude)
|
|
5022
5043
|
};
|
|
5023
5044
|
}
|
|
5024
5045
|
if (section.type === "directory") {
|
|
5025
|
-
if (!
|
|
5046
|
+
if (!section?.path || section.path === "/" || section.path === "./" || section.path === ".") {
|
|
5026
5047
|
logger.log(
|
|
5027
5048
|
warnText(
|
|
5028
5049
|
`Warning: Section ${section.label} is using a Root Path. Currently, Tina Does not support Root paths see ${linkText(
|
|
@@ -5032,11 +5053,11 @@ var generateCollectionFromForestrySection = (args) => {
|
|
|
5032
5053
|
);
|
|
5033
5054
|
return;
|
|
5034
5055
|
}
|
|
5035
|
-
const forestryTemplates =
|
|
5056
|
+
const forestryTemplates = section?.templates || [];
|
|
5036
5057
|
if (forestryTemplates.length === 0 && section.create === "all") {
|
|
5037
5058
|
for (const templateKey of templateMap.keys()) {
|
|
5038
5059
|
const { templateObj } = templateMap.get(templateKey);
|
|
5039
|
-
const pages = templateObj
|
|
5060
|
+
const pages = templateObj?.pages;
|
|
5040
5061
|
if (pages) {
|
|
5041
5062
|
let glob = section.match;
|
|
5042
5063
|
const skipPath = section.path === "" || section.path === "/" || !section.path;
|
|
@@ -5053,7 +5074,7 @@ var generateCollectionFromForestrySection = (args) => {
|
|
|
5053
5074
|
}
|
|
5054
5075
|
const hasBody = ["md", "mdx", "markdown"].includes(format3);
|
|
5055
5076
|
let c;
|
|
5056
|
-
if ((
|
|
5077
|
+
if ((forestryTemplates?.length || 0) > 1) {
|
|
5057
5078
|
c = {
|
|
5058
5079
|
...baseCollection,
|
|
5059
5080
|
// @ts-expect-error
|
|
@@ -5075,7 +5096,7 @@ var generateCollectionFromForestrySection = (args) => {
|
|
|
5075
5096
|
})
|
|
5076
5097
|
};
|
|
5077
5098
|
}
|
|
5078
|
-
if (
|
|
5099
|
+
if (forestryTemplates?.length === 1) {
|
|
5079
5100
|
const tem = forestryTemplates[0];
|
|
5080
5101
|
const template = templateMap.get(tem);
|
|
5081
5102
|
const fieldsString = stringifyLabelWithField(template.templateObj.label);
|
|
@@ -5090,7 +5111,7 @@ var generateCollectionFromForestrySection = (args) => {
|
|
|
5090
5111
|
})
|
|
5091
5112
|
};
|
|
5092
5113
|
}
|
|
5093
|
-
if (
|
|
5114
|
+
if (forestryTemplates?.length === 0) {
|
|
5094
5115
|
logger.warn(
|
|
5095
5116
|
warnText(
|
|
5096
5117
|
`No templates found for section ${section.label}. Please see ${linkText(
|
|
@@ -5103,7 +5124,7 @@ var generateCollectionFromForestrySection = (args) => {
|
|
|
5103
5124
|
fields: [BODY_FIELD]
|
|
5104
5125
|
};
|
|
5105
5126
|
}
|
|
5106
|
-
if (
|
|
5127
|
+
if (section?.create === "none") {
|
|
5107
5128
|
c.ui = {
|
|
5108
5129
|
...c.ui,
|
|
5109
5130
|
allowedActions: {
|
|
@@ -5125,7 +5146,7 @@ var generateCollectionFromForestrySection = (args) => {
|
|
|
5125
5146
|
}
|
|
5126
5147
|
for (const currentTemplateName of templateMap.keys()) {
|
|
5127
5148
|
const { templateObj, fields: additionalFields } = templateMap.get(currentTemplateName);
|
|
5128
|
-
const pages =
|
|
5149
|
+
const pages = templateObj?.pages || [];
|
|
5129
5150
|
if (pages.includes(section.path)) {
|
|
5130
5151
|
fields.push(...additionalFields);
|
|
5131
5152
|
break;
|
|
@@ -5204,11 +5225,10 @@ var generateCollections = async ({
|
|
|
5204
5225
|
};
|
|
5205
5226
|
};
|
|
5206
5227
|
var rewriteTemplateKeysInDocs = (args) => {
|
|
5207
|
-
var _a;
|
|
5208
5228
|
const { templateMap, markdownParseConfig } = args;
|
|
5209
5229
|
for (const templateKey of templateMap.keys()) {
|
|
5210
5230
|
const { templateObj } = templateMap.get(templateKey);
|
|
5211
|
-
|
|
5231
|
+
templateObj?.pages?.forEach((page) => {
|
|
5212
5232
|
try {
|
|
5213
5233
|
const filePath = import_path9.default.join(page);
|
|
5214
5234
|
if (import_fs_extra10.default.lstatSync(filePath).isDirectory()) {
|
|
@@ -5257,6 +5277,15 @@ var CodemodCommand = class extends import_clipanion5.Command {
|
|
|
5257
5277
|
description: "increase verbosity of logged output"
|
|
5258
5278
|
});
|
|
5259
5279
|
}
|
|
5280
|
+
static {
|
|
5281
|
+
this.paths = [["codemod"], ["codemod", "move-tina-folder"]];
|
|
5282
|
+
}
|
|
5283
|
+
static {
|
|
5284
|
+
this.usage = import_clipanion5.Command.Usage({
|
|
5285
|
+
category: `Commands`,
|
|
5286
|
+
description: `Use codemods for various Tina tasks`
|
|
5287
|
+
});
|
|
5288
|
+
}
|
|
5260
5289
|
async catch(error) {
|
|
5261
5290
|
console.log(error);
|
|
5262
5291
|
}
|
|
@@ -5277,11 +5306,6 @@ var CodemodCommand = class extends import_clipanion5.Command {
|
|
|
5277
5306
|
await command2();
|
|
5278
5307
|
}
|
|
5279
5308
|
};
|
|
5280
|
-
CodemodCommand.paths = [["codemod"], ["codemod", "move-tina-folder"]];
|
|
5281
|
-
CodemodCommand.usage = import_clipanion5.Command.Usage({
|
|
5282
|
-
category: `Commands`,
|
|
5283
|
-
description: `Use codemods for various Tina tasks`
|
|
5284
|
-
});
|
|
5285
5309
|
var moveTinaFolder = async (rootPath = process.cwd()) => {
|
|
5286
5310
|
const configManager = new ConfigManager({ rootPath });
|
|
5287
5311
|
try {
|
|
@@ -5561,11 +5585,10 @@ var baseFields = `[
|
|
|
5561
5585
|
},
|
|
5562
5586
|
]`;
|
|
5563
5587
|
var generateCollectionString = (args) => {
|
|
5564
|
-
var _a, _b, _c, _d;
|
|
5565
5588
|
if (args.collections) {
|
|
5566
5589
|
return args.collections;
|
|
5567
5590
|
}
|
|
5568
|
-
let extraTinaCollections =
|
|
5591
|
+
let extraTinaCollections = args.config.authProvider?.extraTinaCollections?.join(",\n");
|
|
5569
5592
|
if (extraTinaCollections) {
|
|
5570
5593
|
extraTinaCollections = extraTinaCollections + ",";
|
|
5571
5594
|
}
|
|
@@ -5591,18 +5614,17 @@ var generateCollectionString = (args) => {
|
|
|
5591
5614
|
},
|
|
5592
5615
|
},
|
|
5593
5616
|
]`;
|
|
5594
|
-
if (
|
|
5617
|
+
if (args.config?.framework?.name === "next") {
|
|
5595
5618
|
return nextExampleCollection;
|
|
5596
5619
|
}
|
|
5597
5620
|
return baseCollections;
|
|
5598
5621
|
};
|
|
5599
5622
|
var generateConfig = (args) => {
|
|
5600
|
-
|
|
5601
|
-
const isUsingTinaCloud = !args.selfHosted || ((_a = args.config.authProvider) == null ? void 0 : _a.name) === "tina-cloud";
|
|
5623
|
+
const isUsingTinaCloud = !args.selfHosted || args.config.authProvider?.name === "tina-cloud";
|
|
5602
5624
|
let extraImports = "";
|
|
5603
5625
|
if (args.selfHosted) {
|
|
5604
5626
|
if (args.config.authProvider) {
|
|
5605
|
-
extraImports = extraImports + makeImportString(
|
|
5627
|
+
extraImports = extraImports + makeImportString(args.config.authProvider?.configImports);
|
|
5606
5628
|
}
|
|
5607
5629
|
if (!isUsingTinaCloud) {
|
|
5608
5630
|
extraImports = extraImports + `
|
|
@@ -5625,7 +5647,7 @@ import { LocalAuthProvider } from "tinacms";`;
|
|
|
5625
5647
|
branch,
|
|
5626
5648
|
${args.selfHosted && !isUsingTinaCloud ? `authProvider: isLocal
|
|
5627
5649
|
? new LocalAuthProvider()
|
|
5628
|
-
:${
|
|
5650
|
+
:${args.config?.authProvider.configAuthProviderClass},` : ""}
|
|
5629
5651
|
${isUsingTinaCloud ? `// Get this from tina.io
|
|
5630
5652
|
clientId: process.env.NEXT_PUBLIC_TINA_CLIENT_ID,` : ""}
|
|
5631
5653
|
${isUsingTinaCloud ? `// Get this from tina.io
|
|
@@ -5652,11 +5674,10 @@ import { LocalAuthProvider } from "tinacms";`;
|
|
|
5652
5674
|
|
|
5653
5675
|
// src/cmds/init/templates/database.ts
|
|
5654
5676
|
var databaseTemplate = ({ config: config2 }) => {
|
|
5655
|
-
var _a, _b, _c, _d;
|
|
5656
5677
|
return `
|
|
5657
5678
|
import { createDatabase, createLocalDatabase } from '@tinacms/datalayer'
|
|
5658
|
-
${makeImportString(
|
|
5659
|
-
${makeImportString(
|
|
5679
|
+
${makeImportString(config2.gitProvider?.imports)}
|
|
5680
|
+
${makeImportString(config2.databaseAdapter?.imports)}
|
|
5660
5681
|
|
|
5661
5682
|
const branch = (process.env.GITHUB_BRANCH ||
|
|
5662
5683
|
process.env.VERCEL_GIT_COMMIT_REF ||
|
|
@@ -5668,8 +5689,8 @@ const isLocal = process.env.${config2.isLocalEnvVarName} === 'true'
|
|
|
5668
5689
|
export default isLocal
|
|
5669
5690
|
? createLocalDatabase()
|
|
5670
5691
|
: createDatabase({
|
|
5671
|
-
gitProvider: ${
|
|
5672
|
-
databaseAdapter: ${
|
|
5692
|
+
gitProvider: ${config2.gitProvider?.gitProviderClassText},
|
|
5693
|
+
databaseAdapter: ${config2.databaseAdapter?.databaseAdapterClassText},
|
|
5673
5694
|
namespace: branch,
|
|
5674
5695
|
})
|
|
5675
5696
|
`;
|
|
@@ -5680,10 +5701,9 @@ var nextApiRouteTemplate = ({
|
|
|
5680
5701
|
config: config2,
|
|
5681
5702
|
env
|
|
5682
5703
|
}) => {
|
|
5683
|
-
var _a, _b;
|
|
5684
5704
|
const extraPath = env.usingSrc ? "../" : "";
|
|
5685
5705
|
return `import { TinaNodeBackend, LocalBackendAuthProvider } from '@tinacms/datalayer'
|
|
5686
|
-
${makeImportString(
|
|
5706
|
+
${makeImportString(config2.authProvider?.backendAuthProviderImports)}
|
|
5687
5707
|
|
|
5688
5708
|
|
|
5689
5709
|
|
|
@@ -5694,7 +5714,7 @@ var nextApiRouteTemplate = ({
|
|
|
5694
5714
|
const handler = TinaNodeBackend({
|
|
5695
5715
|
authProvider: isLocal
|
|
5696
5716
|
? LocalBackendAuthProvider()
|
|
5697
|
-
: ${
|
|
5717
|
+
: ${config2.authProvider?.backendAuthProvider || ""},
|
|
5698
5718
|
databaseClient,
|
|
5699
5719
|
})
|
|
5700
5720
|
|
|
@@ -5722,19 +5742,18 @@ var import_prettier2 = require("prettier");
|
|
|
5722
5742
|
// src/utils/script-helpers.ts
|
|
5723
5743
|
function generateGqlScript(scriptValue, opts) {
|
|
5724
5744
|
const cmd = `tinacms dev -c "${scriptValue}"`;
|
|
5725
|
-
if (opts
|
|
5745
|
+
if (opts?.isLocalEnvVarName) {
|
|
5726
5746
|
return `${opts.isLocalEnvVarName}=true ${cmd}`;
|
|
5727
5747
|
}
|
|
5728
5748
|
return cmd;
|
|
5729
5749
|
}
|
|
5730
5750
|
function extendNextScripts(scripts, opts) {
|
|
5731
|
-
var _a, _b;
|
|
5732
5751
|
const result = {
|
|
5733
5752
|
...scripts,
|
|
5734
|
-
dev: !
|
|
5735
|
-
build: !
|
|
5753
|
+
dev: !scripts?.dev || scripts?.dev?.indexOf("tinacms dev -c") === -1 ? generateGqlScript(scripts?.dev || "next dev", opts) : scripts?.dev,
|
|
5754
|
+
build: !scripts?.build || !scripts?.build?.startsWith("tinacms build &&") ? `tinacms build && ${scripts?.build || "next build"}` : scripts?.build
|
|
5736
5755
|
};
|
|
5737
|
-
if (
|
|
5756
|
+
if (opts?.addSetupUsers && !scripts["setup:users"]) {
|
|
5738
5757
|
result["setup:users"] = "tinacms-next-auth setup";
|
|
5739
5758
|
}
|
|
5740
5759
|
return result;
|
|
@@ -5816,7 +5835,6 @@ var makeVariableStatementVisitor = (sourceFile, variableStmtSourceFile, variable
|
|
|
5816
5835
|
}
|
|
5817
5836
|
};
|
|
5818
5837
|
var makeImportsVisitor = (sourceFile, importMap) => (ctx) => (node) => {
|
|
5819
|
-
var _a;
|
|
5820
5838
|
if (import_typescript3.default.isSourceFile(node)) {
|
|
5821
5839
|
const newStatements = [...node.statements];
|
|
5822
5840
|
let changed = false;
|
|
@@ -5825,7 +5843,7 @@ var makeImportsVisitor = (sourceFile, importMap) => (ctx) => (node) => {
|
|
|
5825
5843
|
for (const statement of newStatements) {
|
|
5826
5844
|
if (import_typescript3.default.isImportDeclaration(statement) && import_typescript3.default.isStringLiteral(statement.moduleSpecifier) && statement.moduleSpecifier.text === moduleName) {
|
|
5827
5845
|
foundImportStatement = true;
|
|
5828
|
-
const existingImports =
|
|
5846
|
+
const existingImports = statement.importClause?.namedBindings && import_typescript3.default.isNamedImports(statement.importClause.namedBindings) ? statement.importClause.namedBindings.elements.map(
|
|
5829
5847
|
(e) => e.name.text
|
|
5830
5848
|
) : [];
|
|
5831
5849
|
const newImports = [
|
|
@@ -6042,7 +6060,6 @@ async function apply({
|
|
|
6042
6060
|
params,
|
|
6043
6061
|
config: config2
|
|
6044
6062
|
}) {
|
|
6045
|
-
var _a;
|
|
6046
6063
|
if (config2.framework.name === "other" && config2.hosting === "self-host") {
|
|
6047
6064
|
logger.error(
|
|
6048
6065
|
logText(
|
|
@@ -6168,7 +6185,7 @@ async function apply({
|
|
|
6168
6185
|
env.tinaConfigExists && // Are we running tinacms init backend
|
|
6169
6186
|
params.isBackendInit && // Do the user choose the 'self-host' option
|
|
6170
6187
|
config2.hosting === "self-host" && // the user did not choose the 'tina-cloud' auth provider
|
|
6171
|
-
(
|
|
6188
|
+
(config2.authProvider?.name || "") !== "tina-cloud"
|
|
6172
6189
|
) {
|
|
6173
6190
|
await addSelfHostedTinaAuthToConfig(config2, env.generatedFiles["config"]);
|
|
6174
6191
|
}
|
|
@@ -6236,7 +6253,6 @@ var updateGitIgnore = async ({
|
|
|
6236
6253
|
await import_fs_extra13.default.writeFile(import_path11.default.join(baseDir, ".gitignore"), newGitignoreContent);
|
|
6237
6254
|
};
|
|
6238
6255
|
var addDependencies = async (config2, env, params) => {
|
|
6239
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i;
|
|
6240
6256
|
const { packageManager } = config2;
|
|
6241
6257
|
const tagVersion = params.tinaVersion ? `@${params.tinaVersion}` : "";
|
|
6242
6258
|
let deps = [];
|
|
@@ -6252,18 +6268,18 @@ var addDependencies = async (config2, env, params) => {
|
|
|
6252
6268
|
deps.push("@tinacms/datalayer");
|
|
6253
6269
|
}
|
|
6254
6270
|
deps.push(
|
|
6255
|
-
...
|
|
6271
|
+
...config2.databaseAdapter?.imports?.map((x) => x.packageName) || []
|
|
6256
6272
|
);
|
|
6257
|
-
deps.push(...
|
|
6273
|
+
deps.push(...config2.authProvider?.peerDependencies || []);
|
|
6258
6274
|
deps.push(
|
|
6259
|
-
...
|
|
6275
|
+
...config2.authProvider?.backendAuthProviderImports?.map(
|
|
6260
6276
|
(x) => x.packageName
|
|
6261
|
-
)
|
|
6277
|
+
) || []
|
|
6262
6278
|
);
|
|
6263
6279
|
deps.push(
|
|
6264
|
-
...
|
|
6280
|
+
...config2.authProvider?.configImports?.map((x) => x.packageName) || []
|
|
6265
6281
|
);
|
|
6266
|
-
deps.push(...
|
|
6282
|
+
deps.push(...config2.gitProvider?.imports?.map((x) => x.packageName) || []);
|
|
6267
6283
|
if (tagVersion) {
|
|
6268
6284
|
deps = deps.map(
|
|
6269
6285
|
(dep) => dep.indexOf("tina") >= 0 ? `${dep}${tagVersion}` : dep
|
|
@@ -6327,12 +6343,11 @@ var addConfigFile = async ({
|
|
|
6327
6343
|
generatedFile,
|
|
6328
6344
|
config: config2
|
|
6329
6345
|
}) => {
|
|
6330
|
-
var _a;
|
|
6331
6346
|
const content = (0, import_prettier2.format)(generateConfig(configArgs), {
|
|
6332
6347
|
parser: "babel"
|
|
6333
6348
|
});
|
|
6334
6349
|
await writeGeneratedFile({
|
|
6335
|
-
overwrite:
|
|
6350
|
+
overwrite: config2.overwriteList?.includes("config"),
|
|
6336
6351
|
generatedFile,
|
|
6337
6352
|
content,
|
|
6338
6353
|
typescript: config2.typescript
|
|
@@ -6346,10 +6361,9 @@ var addDatabaseFile = async ({
|
|
|
6346
6361
|
config: config2,
|
|
6347
6362
|
generatedFile
|
|
6348
6363
|
}) => {
|
|
6349
|
-
var _a;
|
|
6350
6364
|
await writeGeneratedFile({
|
|
6351
6365
|
generatedFile,
|
|
6352
|
-
overwrite:
|
|
6366
|
+
overwrite: config2.overwriteList?.includes("database"),
|
|
6353
6367
|
content: databaseTemplate({ config: config2 }),
|
|
6354
6368
|
typescript: config2.typescript
|
|
6355
6369
|
});
|
|
@@ -6359,13 +6373,12 @@ var addNextApiRoute = async ({
|
|
|
6359
6373
|
generatedFile,
|
|
6360
6374
|
env
|
|
6361
6375
|
}) => {
|
|
6362
|
-
var _a;
|
|
6363
6376
|
const content = (0, import_prettier2.format)(nextApiRouteTemplate({ config: config2, env }), {
|
|
6364
6377
|
parser: "babel"
|
|
6365
6378
|
});
|
|
6366
6379
|
await writeGeneratedFile({
|
|
6367
6380
|
generatedFile,
|
|
6368
|
-
overwrite:
|
|
6381
|
+
overwrite: config2.overwriteList?.includes("next-api-handler"),
|
|
6369
6382
|
content,
|
|
6370
6383
|
typescript: config2.typescript
|
|
6371
6384
|
});
|
|
@@ -6375,10 +6388,9 @@ var addTemplateFile = async ({
|
|
|
6375
6388
|
generatedFile,
|
|
6376
6389
|
config: config2
|
|
6377
6390
|
}) => {
|
|
6378
|
-
var _a;
|
|
6379
6391
|
await writeGeneratedFile({
|
|
6380
6392
|
generatedFile,
|
|
6381
|
-
overwrite:
|
|
6393
|
+
overwrite: config2.overwriteList?.includes(generatedFile.generatedFileType),
|
|
6382
6394
|
content,
|
|
6383
6395
|
typescript: config2.typescript
|
|
6384
6396
|
});
|
|
@@ -6387,7 +6399,6 @@ var addContentFile = async ({
|
|
|
6387
6399
|
config: config2,
|
|
6388
6400
|
env
|
|
6389
6401
|
}) => {
|
|
6390
|
-
var _a;
|
|
6391
6402
|
await writeGeneratedFile({
|
|
6392
6403
|
generatedFile: {
|
|
6393
6404
|
javascriptExists: false,
|
|
@@ -6405,7 +6416,7 @@ var addContentFile = async ({
|
|
|
6405
6416
|
});
|
|
6406
6417
|
}
|
|
6407
6418
|
},
|
|
6408
|
-
overwrite:
|
|
6419
|
+
overwrite: config2.overwriteList?.includes("sample-content"),
|
|
6409
6420
|
content: helloWorldPost,
|
|
6410
6421
|
typescript: false
|
|
6411
6422
|
});
|
|
@@ -6496,12 +6507,11 @@ var addReactiveFile = {
|
|
|
6496
6507
|
baseDir,
|
|
6497
6508
|
dataLayer
|
|
6498
6509
|
}) => {
|
|
6499
|
-
var _a, _b;
|
|
6500
6510
|
const packageJsonPath = import_path11.default.join(baseDir, "package.json");
|
|
6501
6511
|
await writeGeneratedFile({
|
|
6502
6512
|
generatedFile,
|
|
6503
6513
|
typescript: config2.typescript,
|
|
6504
|
-
overwrite:
|
|
6514
|
+
overwrite: config2.overwriteList?.includes(
|
|
6505
6515
|
generatedFile.generatedFileType
|
|
6506
6516
|
),
|
|
6507
6517
|
content: templates["demo-post-page"]({
|
|
@@ -6517,7 +6527,7 @@ var addReactiveFile = {
|
|
|
6517
6527
|
...packageJson,
|
|
6518
6528
|
scripts: extendNextScripts(scripts, {
|
|
6519
6529
|
isLocalEnvVarName: config2.isLocalEnvVarName,
|
|
6520
|
-
addSetupUsers:
|
|
6530
|
+
addSetupUsers: config2.authProvider?.name === "next-auth"
|
|
6521
6531
|
})
|
|
6522
6532
|
},
|
|
6523
6533
|
null,
|
|
@@ -6592,6 +6602,15 @@ var InitCommand = class extends import_clipanion6.Command {
|
|
|
6592
6602
|
description: "Specify a version for tina dependencies"
|
|
6593
6603
|
});
|
|
6594
6604
|
}
|
|
6605
|
+
static {
|
|
6606
|
+
this.paths = [["init"], ["init", "backend"]];
|
|
6607
|
+
}
|
|
6608
|
+
static {
|
|
6609
|
+
this.usage = import_clipanion6.Command.Usage({
|
|
6610
|
+
category: `Commands`,
|
|
6611
|
+
description: `Add Tina to an existing project`
|
|
6612
|
+
});
|
|
6613
|
+
}
|
|
6595
6614
|
async catch(error) {
|
|
6596
6615
|
logger.error("Error occured during tinacms init");
|
|
6597
6616
|
console.error(error);
|
|
@@ -6611,11 +6630,6 @@ var InitCommand = class extends import_clipanion6.Command {
|
|
|
6611
6630
|
process.exit();
|
|
6612
6631
|
}
|
|
6613
6632
|
};
|
|
6614
|
-
InitCommand.paths = [["init"], ["init", "backend"]];
|
|
6615
|
-
InitCommand.usage = import_clipanion6.Command.Usage({
|
|
6616
|
-
category: `Commands`,
|
|
6617
|
-
description: `Add Tina to an existing project`
|
|
6618
|
-
});
|
|
6619
6633
|
|
|
6620
6634
|
// src/next/commands/searchindex-command/index.ts
|
|
6621
6635
|
var import_clipanion7 = require("clipanion");
|
|
@@ -6631,13 +6645,21 @@ var SearchIndexCommand = class extends import_clipanion7.Command {
|
|
|
6631
6645
|
description: "increase verbosity of logged output"
|
|
6632
6646
|
});
|
|
6633
6647
|
}
|
|
6648
|
+
static {
|
|
6649
|
+
this.paths = [["search-index"]];
|
|
6650
|
+
}
|
|
6651
|
+
static {
|
|
6652
|
+
this.usage = import_clipanion7.Command.Usage({
|
|
6653
|
+
category: `Commands`,
|
|
6654
|
+
description: `Index the site for search`
|
|
6655
|
+
});
|
|
6656
|
+
}
|
|
6634
6657
|
async catch(error) {
|
|
6635
6658
|
logger.error("Error occured during tinacms search-index");
|
|
6636
6659
|
console.error(error);
|
|
6637
6660
|
process.exit(1);
|
|
6638
6661
|
}
|
|
6639
6662
|
async execute() {
|
|
6640
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u;
|
|
6641
6663
|
const rootPath = this.rootPath || process.cwd();
|
|
6642
6664
|
const configManager = new ConfigManager({ rootPath });
|
|
6643
6665
|
try {
|
|
@@ -6648,7 +6670,7 @@ var SearchIndexCommand = class extends import_clipanion7.Command {
|
|
|
6648
6670
|
console.error(e);
|
|
6649
6671
|
}
|
|
6650
6672
|
}
|
|
6651
|
-
if (!
|
|
6673
|
+
if (!configManager.config?.search) {
|
|
6652
6674
|
logger.error("No search config found");
|
|
6653
6675
|
process.exit(1);
|
|
6654
6676
|
}
|
|
@@ -6657,9 +6679,9 @@ var SearchIndexCommand = class extends import_clipanion7.Command {
|
|
|
6657
6679
|
schema: { ...schema, config: configManager.config }
|
|
6658
6680
|
});
|
|
6659
6681
|
let client;
|
|
6660
|
-
const hasTinaSearch = Boolean(
|
|
6682
|
+
const hasTinaSearch = Boolean(configManager.config?.search?.tina);
|
|
6661
6683
|
if (hasTinaSearch) {
|
|
6662
|
-
if (!
|
|
6684
|
+
if (!configManager.config?.branch) {
|
|
6663
6685
|
logger.error(
|
|
6664
6686
|
`${dangerText(
|
|
6665
6687
|
`ERROR: Branch not configured in tina search configuration.`
|
|
@@ -6667,11 +6689,11 @@ var SearchIndexCommand = class extends import_clipanion7.Command {
|
|
|
6667
6689
|
);
|
|
6668
6690
|
throw new Error("Branch not configured in tina search configuration.");
|
|
6669
6691
|
}
|
|
6670
|
-
if (!
|
|
6692
|
+
if (!configManager.config?.clientId) {
|
|
6671
6693
|
logger.error(`${dangerText(`ERROR: clientId not configured.`)}`);
|
|
6672
6694
|
throw new Error("clientId not configured.");
|
|
6673
6695
|
}
|
|
6674
|
-
if (!
|
|
6696
|
+
if (!configManager.config?.search?.tina?.indexerToken) {
|
|
6675
6697
|
logger.error(
|
|
6676
6698
|
`${dangerText(
|
|
6677
6699
|
`ERROR: indexerToken not configured in tina search configuration.`
|
|
@@ -6682,22 +6704,22 @@ var SearchIndexCommand = class extends import_clipanion7.Command {
|
|
|
6682
6704
|
);
|
|
6683
6705
|
}
|
|
6684
6706
|
client = new import_search3.TinaCMSSearchIndexClient({
|
|
6685
|
-
apiUrl: `${
|
|
6686
|
-
branch:
|
|
6687
|
-
indexerToken:
|
|
6688
|
-
stopwordLanguages:
|
|
6707
|
+
apiUrl: `${configManager.config.tinaioConfig?.contentApiUrlOverride || "https://content.tinajs.io"}/searchIndex/${configManager.config?.clientId}`,
|
|
6708
|
+
branch: configManager.config?.branch,
|
|
6709
|
+
indexerToken: configManager.config?.search?.tina?.indexerToken,
|
|
6710
|
+
stopwordLanguages: configManager.config?.search?.tina?.stopwordLanguages
|
|
6689
6711
|
});
|
|
6690
6712
|
} else {
|
|
6691
|
-
client =
|
|
6713
|
+
client = configManager.config?.search?.searchClient;
|
|
6692
6714
|
}
|
|
6693
6715
|
const searchIndexer = new import_search3.SearchIndexer({
|
|
6694
|
-
batchSize:
|
|
6716
|
+
batchSize: configManager.config.search?.indexBatchSize || 100,
|
|
6695
6717
|
bridge: new import_graphql17.FilesystemBridge(
|
|
6696
6718
|
configManager.rootPath,
|
|
6697
6719
|
configManager.contentRootPath
|
|
6698
6720
|
),
|
|
6699
6721
|
schema: tinaSchema,
|
|
6700
|
-
textIndexLength:
|
|
6722
|
+
textIndexLength: configManager.config.search?.maxSearchIndexFieldLength || 100,
|
|
6701
6723
|
client
|
|
6702
6724
|
});
|
|
6703
6725
|
let err;
|
|
@@ -6718,11 +6740,6 @@ var SearchIndexCommand = class extends import_clipanion7.Command {
|
|
|
6718
6740
|
process.exit(0);
|
|
6719
6741
|
}
|
|
6720
6742
|
};
|
|
6721
|
-
SearchIndexCommand.paths = [["search-index"]];
|
|
6722
|
-
SearchIndexCommand.usage = import_clipanion7.Command.Usage({
|
|
6723
|
-
category: `Commands`,
|
|
6724
|
-
description: `Index the site for search`
|
|
6725
|
-
});
|
|
6726
6743
|
|
|
6727
6744
|
// src/index.ts
|
|
6728
6745
|
var cli = new import_clipanion8.Cli({
|