@tinacms/cli 0.0.0-bdc07c1-20250506013835 → 0.0.0-bdea884-20250606054015
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 +1 -2
- package/dist/cmds/init/index.d.ts +1 -1
- package/dist/cmds/init/prompts/index.d.ts +1 -1
- package/dist/cmds/init/prompts/types.d.ts +1 -1
- package/dist/index.d.ts +4 -1
- package/dist/index.js +309 -293
- package/dist/next/commands/build-command/index.d.ts +3 -0
- package/dist/utils/sleep.d.ts +1 -0
- package/package.json +16 -22
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.9.
|
|
38
|
+
var version = "1.9.8";
|
|
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);
|
|
@@ -4929,7 +4951,6 @@ var parseSections = ({ val }) => {
|
|
|
4929
4951
|
};
|
|
4930
4952
|
|
|
4931
4953
|
// src/cmds/forestry-migrate/index.ts
|
|
4932
|
-
var import_common = require("@tinacms/common");
|
|
4933
4954
|
var BODY_FIELD = {
|
|
4934
4955
|
// This is the body field
|
|
4935
4956
|
type: "rich-text",
|
|
@@ -4946,8 +4967,7 @@ var stringifyLabelWithField = (label) => {
|
|
|
4946
4967
|
return `${labelString}Fields`;
|
|
4947
4968
|
};
|
|
4948
4969
|
var transformForestryMatchToTinaMatch = (match) => {
|
|
4949
|
-
|
|
4950
|
-
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("{}", "");
|
|
4951
4971
|
if (match !== newMatch) {
|
|
4952
4972
|
logger.info(
|
|
4953
4973
|
`Info: Match ${match} was transformed to ${newMatch}. See ${linkText(
|
|
@@ -4959,7 +4979,7 @@ var transformForestryMatchToTinaMatch = (match) => {
|
|
|
4959
4979
|
};
|
|
4960
4980
|
function checkExt(ext) {
|
|
4961
4981
|
const extReal = ext.replace(".", "");
|
|
4962
|
-
if (
|
|
4982
|
+
if (import_schema_tools3.CONTENT_FORMATS.includes(extReal)) {
|
|
4963
4983
|
return extReal;
|
|
4964
4984
|
} else {
|
|
4965
4985
|
return false;
|
|
@@ -5012,18 +5032,18 @@ var generateCollectionFromForestrySection = (args) => {
|
|
|
5012
5032
|
}
|
|
5013
5033
|
if (section.match) {
|
|
5014
5034
|
baseCollection.match = {
|
|
5015
|
-
...
|
|
5035
|
+
...baseCollection?.match || {},
|
|
5016
5036
|
include: transformForestryMatchToTinaMatch(section.match)
|
|
5017
5037
|
};
|
|
5018
5038
|
}
|
|
5019
5039
|
if (section.exclude) {
|
|
5020
5040
|
baseCollection.match = {
|
|
5021
|
-
...
|
|
5041
|
+
...baseCollection?.match || {},
|
|
5022
5042
|
exclude: transformForestryMatchToTinaMatch(section.exclude)
|
|
5023
5043
|
};
|
|
5024
5044
|
}
|
|
5025
5045
|
if (section.type === "directory") {
|
|
5026
|
-
if (!
|
|
5046
|
+
if (!section?.path || section.path === "/" || section.path === "./" || section.path === ".") {
|
|
5027
5047
|
logger.log(
|
|
5028
5048
|
warnText(
|
|
5029
5049
|
`Warning: Section ${section.label} is using a Root Path. Currently, Tina Does not support Root paths see ${linkText(
|
|
@@ -5033,11 +5053,11 @@ var generateCollectionFromForestrySection = (args) => {
|
|
|
5033
5053
|
);
|
|
5034
5054
|
return;
|
|
5035
5055
|
}
|
|
5036
|
-
const forestryTemplates =
|
|
5056
|
+
const forestryTemplates = section?.templates || [];
|
|
5037
5057
|
if (forestryTemplates.length === 0 && section.create === "all") {
|
|
5038
5058
|
for (const templateKey of templateMap.keys()) {
|
|
5039
5059
|
const { templateObj } = templateMap.get(templateKey);
|
|
5040
|
-
const pages = templateObj
|
|
5060
|
+
const pages = templateObj?.pages;
|
|
5041
5061
|
if (pages) {
|
|
5042
5062
|
let glob = section.match;
|
|
5043
5063
|
const skipPath = section.path === "" || section.path === "/" || !section.path;
|
|
@@ -5054,7 +5074,7 @@ var generateCollectionFromForestrySection = (args) => {
|
|
|
5054
5074
|
}
|
|
5055
5075
|
const hasBody = ["md", "mdx", "markdown"].includes(format3);
|
|
5056
5076
|
let c;
|
|
5057
|
-
if ((
|
|
5077
|
+
if ((forestryTemplates?.length || 0) > 1) {
|
|
5058
5078
|
c = {
|
|
5059
5079
|
...baseCollection,
|
|
5060
5080
|
// @ts-expect-error
|
|
@@ -5076,7 +5096,7 @@ var generateCollectionFromForestrySection = (args) => {
|
|
|
5076
5096
|
})
|
|
5077
5097
|
};
|
|
5078
5098
|
}
|
|
5079
|
-
if (
|
|
5099
|
+
if (forestryTemplates?.length === 1) {
|
|
5080
5100
|
const tem = forestryTemplates[0];
|
|
5081
5101
|
const template = templateMap.get(tem);
|
|
5082
5102
|
const fieldsString = stringifyLabelWithField(template.templateObj.label);
|
|
@@ -5091,7 +5111,7 @@ var generateCollectionFromForestrySection = (args) => {
|
|
|
5091
5111
|
})
|
|
5092
5112
|
};
|
|
5093
5113
|
}
|
|
5094
|
-
if (
|
|
5114
|
+
if (forestryTemplates?.length === 0) {
|
|
5095
5115
|
logger.warn(
|
|
5096
5116
|
warnText(
|
|
5097
5117
|
`No templates found for section ${section.label}. Please see ${linkText(
|
|
@@ -5104,7 +5124,7 @@ var generateCollectionFromForestrySection = (args) => {
|
|
|
5104
5124
|
fields: [BODY_FIELD]
|
|
5105
5125
|
};
|
|
5106
5126
|
}
|
|
5107
|
-
if (
|
|
5127
|
+
if (section?.create === "none") {
|
|
5108
5128
|
c.ui = {
|
|
5109
5129
|
...c.ui,
|
|
5110
5130
|
allowedActions: {
|
|
@@ -5126,7 +5146,7 @@ var generateCollectionFromForestrySection = (args) => {
|
|
|
5126
5146
|
}
|
|
5127
5147
|
for (const currentTemplateName of templateMap.keys()) {
|
|
5128
5148
|
const { templateObj, fields: additionalFields } = templateMap.get(currentTemplateName);
|
|
5129
|
-
const pages =
|
|
5149
|
+
const pages = templateObj?.pages || [];
|
|
5130
5150
|
if (pages.includes(section.path)) {
|
|
5131
5151
|
fields.push(...additionalFields);
|
|
5132
5152
|
break;
|
|
@@ -5205,11 +5225,10 @@ var generateCollections = async ({
|
|
|
5205
5225
|
};
|
|
5206
5226
|
};
|
|
5207
5227
|
var rewriteTemplateKeysInDocs = (args) => {
|
|
5208
|
-
var _a;
|
|
5209
5228
|
const { templateMap, markdownParseConfig } = args;
|
|
5210
5229
|
for (const templateKey of templateMap.keys()) {
|
|
5211
5230
|
const { templateObj } = templateMap.get(templateKey);
|
|
5212
|
-
|
|
5231
|
+
templateObj?.pages?.forEach((page) => {
|
|
5213
5232
|
try {
|
|
5214
5233
|
const filePath = import_path9.default.join(page);
|
|
5215
5234
|
if (import_fs_extra10.default.lstatSync(filePath).isDirectory()) {
|
|
@@ -5258,6 +5277,15 @@ var CodemodCommand = class extends import_clipanion5.Command {
|
|
|
5258
5277
|
description: "increase verbosity of logged output"
|
|
5259
5278
|
});
|
|
5260
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
|
+
}
|
|
5261
5289
|
async catch(error) {
|
|
5262
5290
|
console.log(error);
|
|
5263
5291
|
}
|
|
@@ -5278,11 +5306,6 @@ var CodemodCommand = class extends import_clipanion5.Command {
|
|
|
5278
5306
|
await command2();
|
|
5279
5307
|
}
|
|
5280
5308
|
};
|
|
5281
|
-
CodemodCommand.paths = [["codemod"], ["codemod", "move-tina-folder"]];
|
|
5282
|
-
CodemodCommand.usage = import_clipanion5.Command.Usage({
|
|
5283
|
-
category: `Commands`,
|
|
5284
|
-
description: `Use codemods for various Tina tasks`
|
|
5285
|
-
});
|
|
5286
5309
|
var moveTinaFolder = async (rootPath = process.cwd()) => {
|
|
5287
5310
|
const configManager = new ConfigManager({ rootPath });
|
|
5288
5311
|
try {
|
|
@@ -5562,11 +5585,10 @@ var baseFields = `[
|
|
|
5562
5585
|
},
|
|
5563
5586
|
]`;
|
|
5564
5587
|
var generateCollectionString = (args) => {
|
|
5565
|
-
var _a, _b, _c, _d;
|
|
5566
5588
|
if (args.collections) {
|
|
5567
5589
|
return args.collections;
|
|
5568
5590
|
}
|
|
5569
|
-
let extraTinaCollections =
|
|
5591
|
+
let extraTinaCollections = args.config.authProvider?.extraTinaCollections?.join(",\n");
|
|
5570
5592
|
if (extraTinaCollections) {
|
|
5571
5593
|
extraTinaCollections = extraTinaCollections + ",";
|
|
5572
5594
|
}
|
|
@@ -5592,18 +5614,17 @@ var generateCollectionString = (args) => {
|
|
|
5592
5614
|
},
|
|
5593
5615
|
},
|
|
5594
5616
|
]`;
|
|
5595
|
-
if (
|
|
5617
|
+
if (args.config?.framework?.name === "next") {
|
|
5596
5618
|
return nextExampleCollection;
|
|
5597
5619
|
}
|
|
5598
5620
|
return baseCollections;
|
|
5599
5621
|
};
|
|
5600
5622
|
var generateConfig = (args) => {
|
|
5601
|
-
|
|
5602
|
-
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";
|
|
5603
5624
|
let extraImports = "";
|
|
5604
5625
|
if (args.selfHosted) {
|
|
5605
5626
|
if (args.config.authProvider) {
|
|
5606
|
-
extraImports = extraImports + makeImportString(
|
|
5627
|
+
extraImports = extraImports + makeImportString(args.config.authProvider?.configImports);
|
|
5607
5628
|
}
|
|
5608
5629
|
if (!isUsingTinaCloud) {
|
|
5609
5630
|
extraImports = extraImports + `
|
|
@@ -5626,7 +5647,7 @@ import { LocalAuthProvider } from "tinacms";`;
|
|
|
5626
5647
|
branch,
|
|
5627
5648
|
${args.selfHosted && !isUsingTinaCloud ? `authProvider: isLocal
|
|
5628
5649
|
? new LocalAuthProvider()
|
|
5629
|
-
:${
|
|
5650
|
+
:${args.config?.authProvider.configAuthProviderClass},` : ""}
|
|
5630
5651
|
${isUsingTinaCloud ? `// Get this from tina.io
|
|
5631
5652
|
clientId: process.env.NEXT_PUBLIC_TINA_CLIENT_ID,` : ""}
|
|
5632
5653
|
${isUsingTinaCloud ? `// Get this from tina.io
|
|
@@ -5653,11 +5674,10 @@ import { LocalAuthProvider } from "tinacms";`;
|
|
|
5653
5674
|
|
|
5654
5675
|
// src/cmds/init/templates/database.ts
|
|
5655
5676
|
var databaseTemplate = ({ config: config2 }) => {
|
|
5656
|
-
var _a, _b, _c, _d;
|
|
5657
5677
|
return `
|
|
5658
5678
|
import { createDatabase, createLocalDatabase } from '@tinacms/datalayer'
|
|
5659
|
-
${makeImportString(
|
|
5660
|
-
${makeImportString(
|
|
5679
|
+
${makeImportString(config2.gitProvider?.imports)}
|
|
5680
|
+
${makeImportString(config2.databaseAdapter?.imports)}
|
|
5661
5681
|
|
|
5662
5682
|
const branch = (process.env.GITHUB_BRANCH ||
|
|
5663
5683
|
process.env.VERCEL_GIT_COMMIT_REF ||
|
|
@@ -5669,8 +5689,8 @@ const isLocal = process.env.${config2.isLocalEnvVarName} === 'true'
|
|
|
5669
5689
|
export default isLocal
|
|
5670
5690
|
? createLocalDatabase()
|
|
5671
5691
|
: createDatabase({
|
|
5672
|
-
gitProvider: ${
|
|
5673
|
-
databaseAdapter: ${
|
|
5692
|
+
gitProvider: ${config2.gitProvider?.gitProviderClassText},
|
|
5693
|
+
databaseAdapter: ${config2.databaseAdapter?.databaseAdapterClassText},
|
|
5674
5694
|
namespace: branch,
|
|
5675
5695
|
})
|
|
5676
5696
|
`;
|
|
@@ -5681,10 +5701,9 @@ var nextApiRouteTemplate = ({
|
|
|
5681
5701
|
config: config2,
|
|
5682
5702
|
env
|
|
5683
5703
|
}) => {
|
|
5684
|
-
var _a, _b;
|
|
5685
5704
|
const extraPath = env.usingSrc ? "../" : "";
|
|
5686
5705
|
return `import { TinaNodeBackend, LocalBackendAuthProvider } from '@tinacms/datalayer'
|
|
5687
|
-
${makeImportString(
|
|
5706
|
+
${makeImportString(config2.authProvider?.backendAuthProviderImports)}
|
|
5688
5707
|
|
|
5689
5708
|
|
|
5690
5709
|
|
|
@@ -5695,7 +5714,7 @@ var nextApiRouteTemplate = ({
|
|
|
5695
5714
|
const handler = TinaNodeBackend({
|
|
5696
5715
|
authProvider: isLocal
|
|
5697
5716
|
? LocalBackendAuthProvider()
|
|
5698
|
-
: ${
|
|
5717
|
+
: ${config2.authProvider?.backendAuthProvider || ""},
|
|
5699
5718
|
databaseClient,
|
|
5700
5719
|
})
|
|
5701
5720
|
|
|
@@ -5723,19 +5742,18 @@ var import_prettier2 = require("prettier");
|
|
|
5723
5742
|
// src/utils/script-helpers.ts
|
|
5724
5743
|
function generateGqlScript(scriptValue, opts) {
|
|
5725
5744
|
const cmd = `tinacms dev -c "${scriptValue}"`;
|
|
5726
|
-
if (opts
|
|
5745
|
+
if (opts?.isLocalEnvVarName) {
|
|
5727
5746
|
return `${opts.isLocalEnvVarName}=true ${cmd}`;
|
|
5728
5747
|
}
|
|
5729
5748
|
return cmd;
|
|
5730
5749
|
}
|
|
5731
5750
|
function extendNextScripts(scripts, opts) {
|
|
5732
|
-
var _a, _b;
|
|
5733
5751
|
const result = {
|
|
5734
5752
|
...scripts,
|
|
5735
|
-
dev: !
|
|
5736
|
-
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
|
|
5737
5755
|
};
|
|
5738
|
-
if (
|
|
5756
|
+
if (opts?.addSetupUsers && !scripts["setup:users"]) {
|
|
5739
5757
|
result["setup:users"] = "tinacms-next-auth setup";
|
|
5740
5758
|
}
|
|
5741
5759
|
return result;
|
|
@@ -5817,7 +5835,6 @@ var makeVariableStatementVisitor = (sourceFile, variableStmtSourceFile, variable
|
|
|
5817
5835
|
}
|
|
5818
5836
|
};
|
|
5819
5837
|
var makeImportsVisitor = (sourceFile, importMap) => (ctx) => (node) => {
|
|
5820
|
-
var _a;
|
|
5821
5838
|
if (import_typescript3.default.isSourceFile(node)) {
|
|
5822
5839
|
const newStatements = [...node.statements];
|
|
5823
5840
|
let changed = false;
|
|
@@ -5826,7 +5843,7 @@ var makeImportsVisitor = (sourceFile, importMap) => (ctx) => (node) => {
|
|
|
5826
5843
|
for (const statement of newStatements) {
|
|
5827
5844
|
if (import_typescript3.default.isImportDeclaration(statement) && import_typescript3.default.isStringLiteral(statement.moduleSpecifier) && statement.moduleSpecifier.text === moduleName) {
|
|
5828
5845
|
foundImportStatement = true;
|
|
5829
|
-
const existingImports =
|
|
5846
|
+
const existingImports = statement.importClause?.namedBindings && import_typescript3.default.isNamedImports(statement.importClause.namedBindings) ? statement.importClause.namedBindings.elements.map(
|
|
5830
5847
|
(e) => e.name.text
|
|
5831
5848
|
) : [];
|
|
5832
5849
|
const newImports = [
|
|
@@ -6043,7 +6060,6 @@ async function apply({
|
|
|
6043
6060
|
params,
|
|
6044
6061
|
config: config2
|
|
6045
6062
|
}) {
|
|
6046
|
-
var _a;
|
|
6047
6063
|
if (config2.framework.name === "other" && config2.hosting === "self-host") {
|
|
6048
6064
|
logger.error(
|
|
6049
6065
|
logText(
|
|
@@ -6169,7 +6185,7 @@ async function apply({
|
|
|
6169
6185
|
env.tinaConfigExists && // Are we running tinacms init backend
|
|
6170
6186
|
params.isBackendInit && // Do the user choose the 'self-host' option
|
|
6171
6187
|
config2.hosting === "self-host" && // the user did not choose the 'tina-cloud' auth provider
|
|
6172
|
-
(
|
|
6188
|
+
(config2.authProvider?.name || "") !== "tina-cloud"
|
|
6173
6189
|
) {
|
|
6174
6190
|
await addSelfHostedTinaAuthToConfig(config2, env.generatedFiles["config"]);
|
|
6175
6191
|
}
|
|
@@ -6237,7 +6253,6 @@ var updateGitIgnore = async ({
|
|
|
6237
6253
|
await import_fs_extra13.default.writeFile(import_path11.default.join(baseDir, ".gitignore"), newGitignoreContent);
|
|
6238
6254
|
};
|
|
6239
6255
|
var addDependencies = async (config2, env, params) => {
|
|
6240
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i;
|
|
6241
6256
|
const { packageManager } = config2;
|
|
6242
6257
|
const tagVersion = params.tinaVersion ? `@${params.tinaVersion}` : "";
|
|
6243
6258
|
let deps = [];
|
|
@@ -6253,18 +6268,18 @@ var addDependencies = async (config2, env, params) => {
|
|
|
6253
6268
|
deps.push("@tinacms/datalayer");
|
|
6254
6269
|
}
|
|
6255
6270
|
deps.push(
|
|
6256
|
-
...
|
|
6271
|
+
...config2.databaseAdapter?.imports?.map((x) => x.packageName) || []
|
|
6257
6272
|
);
|
|
6258
|
-
deps.push(...
|
|
6273
|
+
deps.push(...config2.authProvider?.peerDependencies || []);
|
|
6259
6274
|
deps.push(
|
|
6260
|
-
...
|
|
6275
|
+
...config2.authProvider?.backendAuthProviderImports?.map(
|
|
6261
6276
|
(x) => x.packageName
|
|
6262
|
-
)
|
|
6277
|
+
) || []
|
|
6263
6278
|
);
|
|
6264
6279
|
deps.push(
|
|
6265
|
-
...
|
|
6280
|
+
...config2.authProvider?.configImports?.map((x) => x.packageName) || []
|
|
6266
6281
|
);
|
|
6267
|
-
deps.push(...
|
|
6282
|
+
deps.push(...config2.gitProvider?.imports?.map((x) => x.packageName) || []);
|
|
6268
6283
|
if (tagVersion) {
|
|
6269
6284
|
deps = deps.map(
|
|
6270
6285
|
(dep) => dep.indexOf("tina") >= 0 ? `${dep}${tagVersion}` : dep
|
|
@@ -6328,12 +6343,11 @@ var addConfigFile = async ({
|
|
|
6328
6343
|
generatedFile,
|
|
6329
6344
|
config: config2
|
|
6330
6345
|
}) => {
|
|
6331
|
-
var _a;
|
|
6332
6346
|
const content = (0, import_prettier2.format)(generateConfig(configArgs), {
|
|
6333
6347
|
parser: "babel"
|
|
6334
6348
|
});
|
|
6335
6349
|
await writeGeneratedFile({
|
|
6336
|
-
overwrite:
|
|
6350
|
+
overwrite: config2.overwriteList?.includes("config"),
|
|
6337
6351
|
generatedFile,
|
|
6338
6352
|
content,
|
|
6339
6353
|
typescript: config2.typescript
|
|
@@ -6347,10 +6361,9 @@ var addDatabaseFile = async ({
|
|
|
6347
6361
|
config: config2,
|
|
6348
6362
|
generatedFile
|
|
6349
6363
|
}) => {
|
|
6350
|
-
var _a;
|
|
6351
6364
|
await writeGeneratedFile({
|
|
6352
6365
|
generatedFile,
|
|
6353
|
-
overwrite:
|
|
6366
|
+
overwrite: config2.overwriteList?.includes("database"),
|
|
6354
6367
|
content: databaseTemplate({ config: config2 }),
|
|
6355
6368
|
typescript: config2.typescript
|
|
6356
6369
|
});
|
|
@@ -6360,13 +6373,12 @@ var addNextApiRoute = async ({
|
|
|
6360
6373
|
generatedFile,
|
|
6361
6374
|
env
|
|
6362
6375
|
}) => {
|
|
6363
|
-
var _a;
|
|
6364
6376
|
const content = (0, import_prettier2.format)(nextApiRouteTemplate({ config: config2, env }), {
|
|
6365
6377
|
parser: "babel"
|
|
6366
6378
|
});
|
|
6367
6379
|
await writeGeneratedFile({
|
|
6368
6380
|
generatedFile,
|
|
6369
|
-
overwrite:
|
|
6381
|
+
overwrite: config2.overwriteList?.includes("next-api-handler"),
|
|
6370
6382
|
content,
|
|
6371
6383
|
typescript: config2.typescript
|
|
6372
6384
|
});
|
|
@@ -6376,10 +6388,9 @@ var addTemplateFile = async ({
|
|
|
6376
6388
|
generatedFile,
|
|
6377
6389
|
config: config2
|
|
6378
6390
|
}) => {
|
|
6379
|
-
var _a;
|
|
6380
6391
|
await writeGeneratedFile({
|
|
6381
6392
|
generatedFile,
|
|
6382
|
-
overwrite:
|
|
6393
|
+
overwrite: config2.overwriteList?.includes(generatedFile.generatedFileType),
|
|
6383
6394
|
content,
|
|
6384
6395
|
typescript: config2.typescript
|
|
6385
6396
|
});
|
|
@@ -6388,7 +6399,6 @@ var addContentFile = async ({
|
|
|
6388
6399
|
config: config2,
|
|
6389
6400
|
env
|
|
6390
6401
|
}) => {
|
|
6391
|
-
var _a;
|
|
6392
6402
|
await writeGeneratedFile({
|
|
6393
6403
|
generatedFile: {
|
|
6394
6404
|
javascriptExists: false,
|
|
@@ -6406,7 +6416,7 @@ var addContentFile = async ({
|
|
|
6406
6416
|
});
|
|
6407
6417
|
}
|
|
6408
6418
|
},
|
|
6409
|
-
overwrite:
|
|
6419
|
+
overwrite: config2.overwriteList?.includes("sample-content"),
|
|
6410
6420
|
content: helloWorldPost,
|
|
6411
6421
|
typescript: false
|
|
6412
6422
|
});
|
|
@@ -6497,12 +6507,11 @@ var addReactiveFile = {
|
|
|
6497
6507
|
baseDir,
|
|
6498
6508
|
dataLayer
|
|
6499
6509
|
}) => {
|
|
6500
|
-
var _a, _b;
|
|
6501
6510
|
const packageJsonPath = import_path11.default.join(baseDir, "package.json");
|
|
6502
6511
|
await writeGeneratedFile({
|
|
6503
6512
|
generatedFile,
|
|
6504
6513
|
typescript: config2.typescript,
|
|
6505
|
-
overwrite:
|
|
6514
|
+
overwrite: config2.overwriteList?.includes(
|
|
6506
6515
|
generatedFile.generatedFileType
|
|
6507
6516
|
),
|
|
6508
6517
|
content: templates["demo-post-page"]({
|
|
@@ -6518,7 +6527,7 @@ var addReactiveFile = {
|
|
|
6518
6527
|
...packageJson,
|
|
6519
6528
|
scripts: extendNextScripts(scripts, {
|
|
6520
6529
|
isLocalEnvVarName: config2.isLocalEnvVarName,
|
|
6521
|
-
addSetupUsers:
|
|
6530
|
+
addSetupUsers: config2.authProvider?.name === "next-auth"
|
|
6522
6531
|
})
|
|
6523
6532
|
},
|
|
6524
6533
|
null,
|
|
@@ -6593,6 +6602,15 @@ var InitCommand = class extends import_clipanion6.Command {
|
|
|
6593
6602
|
description: "Specify a version for tina dependencies"
|
|
6594
6603
|
});
|
|
6595
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
|
+
}
|
|
6596
6614
|
async catch(error) {
|
|
6597
6615
|
logger.error("Error occured during tinacms init");
|
|
6598
6616
|
console.error(error);
|
|
@@ -6612,11 +6630,6 @@ var InitCommand = class extends import_clipanion6.Command {
|
|
|
6612
6630
|
process.exit();
|
|
6613
6631
|
}
|
|
6614
6632
|
};
|
|
6615
|
-
InitCommand.paths = [["init"], ["init", "backend"]];
|
|
6616
|
-
InitCommand.usage = import_clipanion6.Command.Usage({
|
|
6617
|
-
category: `Commands`,
|
|
6618
|
-
description: `Add Tina to an existing project`
|
|
6619
|
-
});
|
|
6620
6633
|
|
|
6621
6634
|
// src/next/commands/searchindex-command/index.ts
|
|
6622
6635
|
var import_clipanion7 = require("clipanion");
|
|
@@ -6632,13 +6645,21 @@ var SearchIndexCommand = class extends import_clipanion7.Command {
|
|
|
6632
6645
|
description: "increase verbosity of logged output"
|
|
6633
6646
|
});
|
|
6634
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
|
+
}
|
|
6635
6657
|
async catch(error) {
|
|
6636
6658
|
logger.error("Error occured during tinacms search-index");
|
|
6637
6659
|
console.error(error);
|
|
6638
6660
|
process.exit(1);
|
|
6639
6661
|
}
|
|
6640
6662
|
async execute() {
|
|
6641
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u;
|
|
6642
6663
|
const rootPath = this.rootPath || process.cwd();
|
|
6643
6664
|
const configManager = new ConfigManager({ rootPath });
|
|
6644
6665
|
try {
|
|
@@ -6649,7 +6670,7 @@ var SearchIndexCommand = class extends import_clipanion7.Command {
|
|
|
6649
6670
|
console.error(e);
|
|
6650
6671
|
}
|
|
6651
6672
|
}
|
|
6652
|
-
if (!
|
|
6673
|
+
if (!configManager.config?.search) {
|
|
6653
6674
|
logger.error("No search config found");
|
|
6654
6675
|
process.exit(1);
|
|
6655
6676
|
}
|
|
@@ -6658,9 +6679,9 @@ var SearchIndexCommand = class extends import_clipanion7.Command {
|
|
|
6658
6679
|
schema: { ...schema, config: configManager.config }
|
|
6659
6680
|
});
|
|
6660
6681
|
let client;
|
|
6661
|
-
const hasTinaSearch = Boolean(
|
|
6682
|
+
const hasTinaSearch = Boolean(configManager.config?.search?.tina);
|
|
6662
6683
|
if (hasTinaSearch) {
|
|
6663
|
-
if (!
|
|
6684
|
+
if (!configManager.config?.branch) {
|
|
6664
6685
|
logger.error(
|
|
6665
6686
|
`${dangerText(
|
|
6666
6687
|
`ERROR: Branch not configured in tina search configuration.`
|
|
@@ -6668,11 +6689,11 @@ var SearchIndexCommand = class extends import_clipanion7.Command {
|
|
|
6668
6689
|
);
|
|
6669
6690
|
throw new Error("Branch not configured in tina search configuration.");
|
|
6670
6691
|
}
|
|
6671
|
-
if (!
|
|
6692
|
+
if (!configManager.config?.clientId) {
|
|
6672
6693
|
logger.error(`${dangerText(`ERROR: clientId not configured.`)}`);
|
|
6673
6694
|
throw new Error("clientId not configured.");
|
|
6674
6695
|
}
|
|
6675
|
-
if (!
|
|
6696
|
+
if (!configManager.config?.search?.tina?.indexerToken) {
|
|
6676
6697
|
logger.error(
|
|
6677
6698
|
`${dangerText(
|
|
6678
6699
|
`ERROR: indexerToken not configured in tina search configuration.`
|
|
@@ -6683,22 +6704,22 @@ var SearchIndexCommand = class extends import_clipanion7.Command {
|
|
|
6683
6704
|
);
|
|
6684
6705
|
}
|
|
6685
6706
|
client = new import_search3.TinaCMSSearchIndexClient({
|
|
6686
|
-
apiUrl: `${
|
|
6687
|
-
branch:
|
|
6688
|
-
indexerToken:
|
|
6689
|
-
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
|
|
6690
6711
|
});
|
|
6691
6712
|
} else {
|
|
6692
|
-
client =
|
|
6713
|
+
client = configManager.config?.search?.searchClient;
|
|
6693
6714
|
}
|
|
6694
6715
|
const searchIndexer = new import_search3.SearchIndexer({
|
|
6695
|
-
batchSize:
|
|
6716
|
+
batchSize: configManager.config.search?.indexBatchSize || 100,
|
|
6696
6717
|
bridge: new import_graphql17.FilesystemBridge(
|
|
6697
6718
|
configManager.rootPath,
|
|
6698
6719
|
configManager.contentRootPath
|
|
6699
6720
|
),
|
|
6700
6721
|
schema: tinaSchema,
|
|
6701
|
-
textIndexLength:
|
|
6722
|
+
textIndexLength: configManager.config.search?.maxSearchIndexFieldLength || 100,
|
|
6702
6723
|
client
|
|
6703
6724
|
});
|
|
6704
6725
|
let err;
|
|
@@ -6719,11 +6740,6 @@ var SearchIndexCommand = class extends import_clipanion7.Command {
|
|
|
6719
6740
|
process.exit(0);
|
|
6720
6741
|
}
|
|
6721
6742
|
};
|
|
6722
|
-
SearchIndexCommand.paths = [["search-index"]];
|
|
6723
|
-
SearchIndexCommand.usage = import_clipanion7.Command.Usage({
|
|
6724
|
-
category: `Commands`,
|
|
6725
|
-
description: `Index the site for search`
|
|
6726
|
-
});
|
|
6727
6743
|
|
|
6728
6744
|
// src/index.ts
|
|
6729
6745
|
var cli = new import_clipanion8.Cli({
|