@tinacms/cli 0.0.0-b67f55a-20250513032422 → 0.0.0-b782a89-20250521051922

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.
@@ -1,4 +1,4 @@
1
- import type { Collection, TinaField } from '@tinacms/schema-tools';
1
+ import type { Collection, TinaField, ContentFrontmatterFormat } from '@tinacms/schema-tools';
2
2
  export declare const stringifyLabel: (label: string) => string;
3
3
  export declare const stringifyLabelWithField: (label: string) => string;
4
4
  export declare const generateAllTemplates: ({ pathToForestryConfig, }: {
@@ -8,7 +8,7 @@ export declare const generateAllTemplates: ({ pathToForestryConfig, }: {
8
8
  templateObj: any;
9
9
  }>>;
10
10
  export declare const generateCollections: ({ pathToForestryConfig, usingTypescript, frontMatterFormat, }: {
11
- frontMatterFormat?: "toml" | "yaml" | "json";
11
+ frontMatterFormat?: ContentFrontmatterFormat;
12
12
  pathToForestryConfig: string;
13
13
  usingTypescript: boolean;
14
14
  }) => Promise<{
@@ -1,4 +1,5 @@
1
1
  import { CLICommand } from '../index';
2
+ import { ContentFrontmatterFormat } from '@tinacms/schema-tools';
2
3
  export interface Framework {
3
4
  name: 'next' | 'hugo' | 'jekyll' | 'other';
4
5
  reactive: boolean;
@@ -20,11 +21,10 @@ export type GeneratedFile = {
20
21
  parentPath: string;
21
22
  };
22
23
  };
23
- export type FrontmatterFormat = 'yaml' | 'toml' | 'json';
24
24
  export type InitEnvironment = {
25
25
  hasTinaDeps: boolean;
26
26
  forestryConfigExists: boolean;
27
- frontMatterFormat: FrontmatterFormat;
27
+ frontMatterFormat: ContentFrontmatterFormat;
28
28
  gitIgnoreExists: boolean;
29
29
  gitIgnoreNodeModulesExists: boolean;
30
30
  gitIgnoreTinaEnvExists: boolean;
@@ -1,5 +1,6 @@
1
1
  import { Framework, InitEnvironment } from '../';
2
2
  import { Config, ImportStatement } from './types';
3
+ import { ContentFrontmatterFormat } from '@tinacms/schema-tools';
3
4
  export * from './askTinaCloudSetup';
4
5
  export * from './types';
5
6
  export * from './gitProvider';
@@ -14,7 +15,7 @@ export declare const askForestryMigrate: ({ framework, env, }: {
14
15
  env: InitEnvironment;
15
16
  }) => Promise<{
16
17
  forestryMigrate: boolean;
17
- frontMatterFormat?: "yaml" | "toml" | "json";
18
+ frontMatterFormat?: ContentFrontmatterFormat;
18
19
  }>;
19
20
  export declare const askTinaSetupPrompts: (params: {
20
21
  frameworkName: string;
@@ -1,3 +1,4 @@
1
+ import { ContentFrontmatterFormat } from '@tinacms/schema-tools';
1
2
  import { Framework, GeneratedFileType } from '../';
2
3
  export type Config = {
3
4
  typescript: boolean;
@@ -5,7 +6,7 @@ export type Config = {
5
6
  framework: Framework;
6
7
  packageManager: 'pnpm' | 'yarn' | 'npm';
7
8
  forestryMigrate: boolean;
8
- frontMatterFormat?: 'yaml' | 'toml' | 'json';
9
+ frontMatterFormat?: ContentFrontmatterFormat;
9
10
  hosting?: 'tina-cloud' | 'self-host';
10
11
  gitProvider?: PromptGitProvider;
11
12
  databaseAdapter?: PromptDatabaseAdapter;
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.6";
38
+ var version = "1.9.7";
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
- var _a, _b, _c, _d;
591
- const branch = (_a = this.configManager.config) == null ? void 0 : _a.branch;
592
- const clientId = (_b = this.configManager.config) == null ? void 0 : _b.clientId;
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 = ((_d = this.configManager.config.tinaioConfig) == null ? void 0 : _d.contentApiUrlOverride) || `https://${TINA_HOST}`;
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 = (_b = (_a = usersFields[0]) == null ? void 0 : _a.collectable) == null ? void 0 : _b.fields.map((f) => {
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
- var _a, _b, _c;
714
- const token = (_a = this.configManager.config) == null ? void 0 : _a.token;
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 ((_a = this.config.client) == null ? void 0 : _a.skip) || false;
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 (generatedSchema == null ? void 0 : generatedSchema.version) !== "undefined")) {
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 ((err == null ? void 0 : err.code) === "EADDRINUSE") {
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: ((_a = collection.match) == null ? void 0 : _a.exclude) || ((_b = collection.match) == null ? void 0 : _b.include) ? tinaSchema.getMatches({ collection }) : void 0
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 == null ? void 0 : res.warnings) {
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 ((_b = (_a = configManager.config.media) == null ? void 0 : _a.tina) == null ? void 0 : _b.static) {
1826
+ if (configManager.config.media?.tina?.static) {
1833
1827
  const staticMedia = await listFilesRecursively({
1834
- directoryPath: ((_c = configManager.config.media.tina) == null ? void 0 : _c.mediaRoot) || "",
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__: `"${((_e = (_d = configManager.config) == null ? void 0 : _d.build) == null ? void 0 : _e.basePath) || ""}"`,
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: (_h = (_g = (_f = configManager.config) == null ? void 0 : _f.build) == null ? void 0 : _g.host) != null ? _h : false,
1901
+ host: configManager.config?.build?.host ?? false,
1908
1902
  watch: noWatch ? {
1909
1903
  ignored: ["**/*"]
1910
1904
  } : {
@@ -1918,7 +1912,7 @@ var createConfig = async ({
1918
1912
  }
1919
1913
  },
1920
1914
  build: {
1921
- sourcemap: true,
1915
+ sourcemap: false,
1922
1916
  outDir: configManager.outputFolderPath,
1923
1917
  emptyOutDir: true,
1924
1918
  rollupOptions
@@ -1983,8 +1977,7 @@ var createMediaRouter = (config2) => {
1983
1977
  const handlePost = async function(req, res) {
1984
1978
  const bb = (0, import_busboy.default)({ headers: req.headers });
1985
1979
  bb.on("file", async (_name, file, _info) => {
1986
- var _a;
1987
- const fullPath = decodeURI((_a = req.url) == null ? void 0 : _a.slice("/media/upload/".length));
1980
+ const fullPath = decodeURI(req.url?.slice("/media/upload/".length));
1988
1981
  const saveTo = import_path3.default.join(mediaFolder, ...fullPath.split("/"));
1989
1982
  await import_fs_extra5.default.ensureDir(import_path3.default.dirname(saveTo));
1990
1983
  file.pipe(import_fs_extra5.default.createWriteStream(saveTo));
@@ -2086,7 +2079,7 @@ var MediaModel = class {
2086
2079
  return {
2087
2080
  files: [],
2088
2081
  directories: [],
2089
- error: error == null ? void 0 : error.toString()
2082
+ error: error?.toString()
2090
2083
  };
2091
2084
  }
2092
2085
  }
@@ -2103,7 +2096,7 @@ var MediaModel = class {
2103
2096
  return { ok: true };
2104
2097
  } catch (error) {
2105
2098
  console.error(error);
2106
- return { ok: false, message: error == null ? void 0 : error.toString() };
2099
+ return { ok: false, message: error?.toString() };
2107
2100
  }
2108
2101
  }
2109
2102
  };
@@ -2181,13 +2174,12 @@ var devServerEndPointsPlugin = ({
2181
2174
  server.middlewares.use((0, import_cors.default)());
2182
2175
  server.middlewares.use(import_body_parser.default.json({ limit: "5mb" }));
2183
2176
  server.middlewares.use(async (req, res, next) => {
2184
- var _a;
2185
- const mediaPaths = (_a = configManager.config.media) == null ? void 0 : _a.tina;
2177
+ const mediaPaths = configManager.config.media?.tina;
2186
2178
  const mediaRouter = createMediaRouter({
2187
2179
  rootPath: configManager.rootPath,
2188
2180
  apiURL,
2189
- publicFolder: parseMediaFolder((mediaPaths == null ? void 0 : mediaPaths.publicFolder) || ""),
2190
- mediaRoot: parseMediaFolder((mediaPaths == null ? void 0 : mediaPaths.mediaRoot) || "")
2181
+ publicFolder: parseMediaFolder(mediaPaths?.publicFolder || ""),
2182
+ mediaRoot: parseMediaFolder(mediaPaths?.mediaRoot || "")
2191
2183
  });
2192
2184
  const searchIndexRouter = createSearchIndexRouter({
2193
2185
  config: { apiURL, searchPath: "searchIndex" },
@@ -2260,7 +2252,7 @@ function viteTransformExtension({
2260
2252
  name: "vite-plugin-svgr",
2261
2253
  async transform(code, id) {
2262
2254
  if (filter(id)) {
2263
- const { transform: transform2 } = await Promise.resolve().then(() => __toESM(require("@svgr/core")));
2255
+ const { transform: transform2 } = await import("@svgr/core");
2264
2256
  const svgCode = await import_fs.default.promises.readFile(
2265
2257
  id.replace(/\?.*$/, ""),
2266
2258
  "utf8"
@@ -2345,6 +2337,20 @@ var DevCommand = class extends BaseCommand {
2345
2337
  });
2346
2338
  this.indexingLock = new import_async_lock.default();
2347
2339
  }
2340
+ static {
2341
+ this.paths = [["dev"], ["server:start"]];
2342
+ }
2343
+ static {
2344
+ // Prevent indexes and reads occurring at once
2345
+ this.usage = import_clipanion2.Command.Usage({
2346
+ category: `Commands`,
2347
+ description: `Builds Tina and starts the dev server`,
2348
+ examples: [
2349
+ [`A basic example`, `$0 dev`],
2350
+ [`A second example`, `$0 dev --rootPath`]
2351
+ ]
2352
+ });
2353
+ }
2348
2354
  async catch(error) {
2349
2355
  logger.error("Error occured during tinacms dev");
2350
2356
  console.error(error);
@@ -2359,7 +2365,6 @@ var DevCommand = class extends BaseCommand {
2359
2365
  }
2360
2366
  }
2361
2367
  async execute() {
2362
- var _a, _b, _c, _d, _e, _f;
2363
2368
  const configManager = new ConfigManager({
2364
2369
  rootPath: this.rootPath,
2365
2370
  legacyNoSDK: this.noSDK
@@ -2467,19 +2472,19 @@ ${dangerText(e.message)}
2467
2472
  "index.html\nassets/"
2468
2473
  );
2469
2474
  const searchIndexClient = new import_search.LocalSearchIndexClient({
2470
- stopwordLanguages: (_b = (_a = configManager.config.search) == null ? void 0 : _a.tina) == null ? void 0 : _b.stopwordLanguages,
2471
- tokenSplitRegex: (_d = (_c = configManager.config.search) == null ? void 0 : _c.tina) == null ? void 0 : _d.tokenSplitRegex
2475
+ stopwordLanguages: configManager.config.search?.tina?.stopwordLanguages,
2476
+ tokenSplitRegex: configManager.config.search?.tina?.tokenSplitRegex
2472
2477
  });
2473
2478
  await searchIndexClient.onStartIndexing();
2474
2479
  const searchIndexer = new import_search.SearchIndexer({
2475
- batchSize: ((_e = configManager.config.search) == null ? void 0 : _e.indexBatchSize) || 100,
2480
+ batchSize: configManager.config.search?.indexBatchSize || 100,
2476
2481
  bridge: new import_graphql10.FilesystemBridge(
2477
2482
  configManager.rootPath,
2478
2483
  configManager.contentRootPath
2479
2484
  ),
2480
2485
  schema: tinaSchema,
2481
2486
  client: searchIndexClient,
2482
- textIndexLength: ((_f = configManager.config.search) == null ? void 0 : _f.maxSearchIndexFieldLength) || 100
2487
+ textIndexLength: configManager.config.search?.maxSearchIndexFieldLength || 100
2483
2488
  });
2484
2489
  if (configManager.config.search) {
2485
2490
  await spin({
@@ -2638,16 +2643,6 @@ ${dangerText(e.message)}
2638
2643
  import_chokidar.default.watch(configManager.userQueriesAndFragmentsGlob).on("add", executeCallback).on("change", executeCallback).on("unlink", executeCallback);
2639
2644
  }
2640
2645
  };
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
2646
 
2652
2647
  // src/next/commands/build-command/index.ts
2653
2648
  var import_crypto = __toESM(require("crypto"));
@@ -2845,12 +2840,20 @@ var BuildCommand = class extends BaseCommand {
2845
2840
  description: "Disables the client build cache"
2846
2841
  });
2847
2842
  }
2843
+ static {
2844
+ this.paths = [["build"]];
2845
+ }
2846
+ static {
2847
+ this.usage = import_clipanion3.Command.Usage({
2848
+ category: `Commands`,
2849
+ description: `Build the CMS and autogenerated modules for usage with TinaCloud`
2850
+ });
2851
+ }
2848
2852
  async catch(error) {
2849
2853
  console.error(error);
2850
2854
  process.exit(1);
2851
2855
  }
2852
2856
  async execute() {
2853
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s;
2854
2857
  logger.info("Starting Tina build");
2855
2858
  this.logDeprecationWarnings();
2856
2859
  const configManager = new ConfigManager({
@@ -2986,9 +2989,9 @@ ${dangerText(e.message)}
2986
2989
  );
2987
2990
  if (configManager.config.search && !this.skipSearchIndex && !this.localOption) {
2988
2991
  let client;
2989
- const hasTinaSearch = Boolean((_b = (_a = configManager.config) == null ? void 0 : _a.search) == null ? void 0 : _b.tina);
2992
+ const hasTinaSearch = Boolean(configManager.config?.search?.tina);
2990
2993
  if (hasTinaSearch) {
2991
- if (!((_c = configManager.config) == null ? void 0 : _c.branch)) {
2994
+ if (!configManager.config?.branch) {
2992
2995
  logger.error(
2993
2996
  `${dangerText(
2994
2997
  `ERROR: Branch not configured in tina search configuration.`
@@ -2998,11 +3001,11 @@ ${dangerText(e.message)}
2998
3001
  "Branch not configured in tina search configuration."
2999
3002
  );
3000
3003
  }
3001
- if (!((_d = configManager.config) == null ? void 0 : _d.clientId)) {
3004
+ if (!configManager.config?.clientId) {
3002
3005
  logger.error(`${dangerText(`ERROR: clientId not configured.`)}`);
3003
3006
  throw new Error("clientId not configured.");
3004
3007
  }
3005
- if (!((_g = (_f = (_e = configManager.config) == null ? void 0 : _e.search) == null ? void 0 : _f.tina) == null ? void 0 : _g.indexerToken)) {
3008
+ if (!configManager.config?.search?.tina?.indexerToken) {
3006
3009
  logger.error(
3007
3010
  `${dangerText(
3008
3011
  `ERROR: indexerToken not configured in tina search configuration.`
@@ -3013,16 +3016,16 @@ ${dangerText(e.message)}
3013
3016
  );
3014
3017
  }
3015
3018
  client = new import_search2.TinaCMSSearchIndexClient({
3016
- apiUrl: `${((_h = configManager.config.tinaioConfig) == null ? void 0 : _h.contentApiUrlOverride) || "https://content.tinajs.io"}/searchIndex/${(_i = configManager.config) == null ? void 0 : _i.clientId}`,
3017
- branch: (_j = configManager.config) == null ? void 0 : _j.branch,
3018
- indexerToken: (_m = (_l = (_k = configManager.config) == null ? void 0 : _k.search) == null ? void 0 : _l.tina) == null ? void 0 : _m.indexerToken,
3019
- stopwordLanguages: (_p = (_o = (_n = configManager.config) == null ? void 0 : _n.search) == null ? void 0 : _o.tina) == null ? void 0 : _p.stopwordLanguages
3019
+ apiUrl: `${configManager.config.tinaioConfig?.contentApiUrlOverride || "https://content.tinajs.io"}/searchIndex/${configManager.config?.clientId}`,
3020
+ branch: configManager.config?.branch,
3021
+ indexerToken: configManager.config?.search?.tina?.indexerToken,
3022
+ stopwordLanguages: configManager.config?.search?.tina?.stopwordLanguages
3020
3023
  });
3021
3024
  } else {
3022
- client = (_r = (_q = configManager.config) == null ? void 0 : _q.search) == null ? void 0 : _r.searchClient;
3025
+ client = configManager.config?.search?.searchClient;
3023
3026
  }
3024
3027
  const searchIndexer = new import_search2.SearchIndexer({
3025
- batchSize: ((_s = configManager.config.search) == null ? void 0 : _s.indexBatchSize) || 100,
3028
+ batchSize: configManager.config.search?.indexBatchSize || 100,
3026
3029
  bridge: new import_graphql11.FilesystemBridge(
3027
3030
  configManager.rootPath,
3028
3031
  configManager.contentRootPath
@@ -3252,7 +3255,7 @@ ${dangerText(e.message)}
3252
3255
  prog: "\u274C"
3253
3256
  });
3254
3257
  let errorMessage = `The remote GraphQL schema does not exist. Check indexing for this branch.`;
3255
- if (config2 == null ? void 0 : config2.branch) {
3258
+ if (config2?.branch) {
3256
3259
  errorMessage += `
3257
3260
 
3258
3261
  Additional info: Branch: ${config2.branch}, Client ID: ${config2.clientId} `;
@@ -3284,7 +3287,7 @@ Check out '${faqLink}' for possible solutions.`}`;
3284
3287
  Additional info:
3285
3288
 
3286
3289
  `;
3287
- if (config2 == null ? void 0 : config2.branch) {
3290
+ if (config2?.branch) {
3288
3291
  errorMessage += ` Branch: ${config2.branch}, Client ID: ${config2.clientId}
3289
3292
  `;
3290
3293
  }
@@ -3333,7 +3336,7 @@ Additional info:
3333
3336
  prog: "\u274C"
3334
3337
  });
3335
3338
  let errorMessage = `The remote Tina schema does not exist. Check indexing for this branch.`;
3336
- if (config2 == null ? void 0 : config2.branch) {
3339
+ if (config2?.branch) {
3337
3340
  errorMessage += `
3338
3341
 
3339
3342
  Additional info: Branch: ${config2.branch}, Client ID: ${config2.clientId} `;
@@ -3364,7 +3367,7 @@ Additional info: Branch: ${config2.branch}, Client ID: ${config2.clientId} `;
3364
3367
  Additional info:
3365
3368
 
3366
3369
  `;
3367
- if (config2 == null ? void 0 : config2.branch) {
3370
+ if (config2?.branch) {
3368
3371
  errorMessage += ` Branch: ${config2.branch}, Client ID: ${config2.clientId}
3369
3372
  `;
3370
3373
  }
@@ -3376,18 +3379,13 @@ Additional info:
3376
3379
  }
3377
3380
  }
3378
3381
  };
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
3382
  async function request(args) {
3385
3383
  const headers = new Headers();
3386
3384
  if (args.token) {
3387
3385
  headers.append("X-API-KEY", args.token);
3388
3386
  }
3389
3387
  headers.append("Content-Type", "application/json");
3390
- const url = args == null ? void 0 : args.url;
3388
+ const url = args?.url;
3391
3389
  const res = await fetch(url, {
3392
3390
  method: args.method || "GET",
3393
3391
  headers,
@@ -3417,9 +3415,9 @@ Message from server: ${json.message}`;
3417
3415
  );
3418
3416
  }
3419
3417
  return {
3420
- status: json == null ? void 0 : json.status,
3421
- timestamp: json == null ? void 0 : json.timestamp,
3422
- hasUpstream: (json == null ? void 0 : json.hasUpstream) || false
3418
+ status: json?.status,
3419
+ timestamp: json?.timestamp,
3420
+ hasUpstream: json?.hasUpstream || false
3423
3421
  };
3424
3422
  }
3425
3423
  var fetchRemoteGraphqlSchema = async ({
@@ -3442,7 +3440,7 @@ var fetchRemoteGraphqlSchema = async ({
3442
3440
  });
3443
3441
  const data = await res.json();
3444
3442
  return {
3445
- remoteSchema: data == null ? void 0 : data.data,
3443
+ remoteSchema: data?.data,
3446
3444
  remoteRuntimeVersion: res.headers.get("tinacms-grapqhl-version"),
3447
3445
  remoteProjectVersion: res.headers.get("tinacms-graphql-project-version")
3448
3446
  };
@@ -3652,6 +3650,15 @@ var AuditCommand = class extends import_clipanion4.Command {
3652
3650
  description: "Specify a port to run the datalayer server on. (default 9000)"
3653
3651
  });
3654
3652
  }
3653
+ static {
3654
+ this.paths = [["audit"]];
3655
+ }
3656
+ static {
3657
+ this.usage = import_clipanion4.Command.Usage({
3658
+ category: `Commands`,
3659
+ description: `Audit config and content files`
3660
+ });
3661
+ }
3655
3662
  async catch(error) {
3656
3663
  logger.error("Error occured during tinacms audit");
3657
3664
  if (this.verbose) {
@@ -3705,11 +3712,6 @@ var AuditCommand = class extends import_clipanion4.Command {
3705
3712
  process.exit();
3706
3713
  }
3707
3714
  };
3708
- AuditCommand.paths = [["audit"]];
3709
- AuditCommand.usage = import_clipanion4.Command.Usage({
3710
- category: `Commands`,
3711
- description: `Audit config and content files`
3712
- });
3713
3715
 
3714
3716
  // src/next/commands/init-command/index.ts
3715
3717
  var import_clipanion6 = require("clipanion");
@@ -3728,13 +3730,13 @@ var makeGeneratedFile = async (name2, generatedFileType, parentPath, opts) => {
3728
3730
  const result = {
3729
3731
  fullPathTS: import_path7.default.join(
3730
3732
  parentPath,
3731
- `${name2}.${(opts == null ? void 0 : opts.typescriptSuffix) || (opts == null ? void 0 : opts.extensionOverride) || "ts"}`
3733
+ `${name2}.${opts?.typescriptSuffix || opts?.extensionOverride || "ts"}`
3732
3734
  ),
3733
3735
  fullPathJS: import_path7.default.join(
3734
3736
  parentPath,
3735
- `${name2}.${(opts == null ? void 0 : opts.extensionOverride) || "js"}`
3737
+ `${name2}.${opts?.extensionOverride || "js"}`
3736
3738
  ),
3737
- fullPathOverride: (opts == null ? void 0 : opts.extensionOverride) ? import_path7.default.join(parentPath, `${name2}.${opts == null ? void 0 : opts.extensionOverride}`) : "",
3739
+ fullPathOverride: opts?.extensionOverride ? import_path7.default.join(parentPath, `${name2}.${opts?.extensionOverride}`) : "",
3738
3740
  generatedFileType,
3739
3741
  name: name2,
3740
3742
  parentPath,
@@ -3762,7 +3764,6 @@ var detectEnvironment = async ({
3762
3764
  rootPath,
3763
3765
  debug = false
3764
3766
  }) => {
3765
- var _a;
3766
3767
  const hasForestryConfig = await import_fs_extra8.default.pathExists(
3767
3768
  import_path7.default.join(pathToForestryConfig, ".forestry", "settings.yml")
3768
3769
  );
@@ -3819,10 +3820,10 @@ var detectEnvironment = async ({
3819
3820
  try {
3820
3821
  const packageJSON = await import_fs_extra8.default.readJSON("package.json");
3821
3822
  const deps = [];
3822
- if (packageJSON == null ? void 0 : packageJSON.dependencies) {
3823
+ if (packageJSON?.dependencies) {
3823
3824
  deps.push(...Object.keys(packageJSON.dependencies));
3824
3825
  }
3825
- if (packageJSON == null ? void 0 : packageJSON.devDependencies) {
3826
+ if (packageJSON?.devDependencies) {
3826
3827
  deps.push(...Object.keys(packageJSON.devDependencies));
3827
3828
  }
3828
3829
  if (deps.includes("@tinacms/cli") && deps.includes("tinacms")) {
@@ -3843,7 +3844,7 @@ var detectEnvironment = async ({
3843
3844
  const hugoConfigPath = import_path7.default.join(rootPath, "config.toml");
3844
3845
  if (await import_fs_extra8.default.pathExists(hugoConfigPath)) {
3845
3846
  const hugoConfig = await import_fs_extra8.default.readFile(hugoConfigPath, "utf8");
3846
- const metaDataFormat = (_a = hugoConfig.match(/metaDataFormat = "(.*)"/)) == null ? void 0 : _a[1];
3847
+ const metaDataFormat = hugoConfig.toString().match(/metaDataFormat = "(.*)"/)?.[1];
3847
3848
  if (metaDataFormat && (metaDataFormat === "yaml" || metaDataFormat === "toml" || metaDataFormat === "json")) {
3848
3849
  frontMatterFormat = metaDataFormat;
3849
3850
  }
@@ -4462,6 +4463,7 @@ var import_path9 = __toESM(require("path"));
4462
4463
  var import_js_yaml2 = __toESM(require("js-yaml"));
4463
4464
  var import_minimatch = __toESM(require("minimatch"));
4464
4465
  var import_graphql16 = require("@tinacms/graphql");
4466
+ var import_schema_tools3 = require("@tinacms/schema-tools");
4465
4467
 
4466
4468
  // src/cmds/forestry-migrate/util/index.ts
4467
4469
  var import_fs_extra9 = __toESM(require("fs-extra"));
@@ -4494,8 +4496,7 @@ var ErrorSingleton = class _ErrorSingleton {
4494
4496
  this.collectionNameErrors.push(error);
4495
4497
  }
4496
4498
  printCollectionNameErrors() {
4497
- var _a;
4498
- if ((_a = this.collectionNameErrors) == null ? void 0 : _a.length) {
4499
+ if (this.collectionNameErrors?.length) {
4499
4500
  logger.error(
4500
4501
  dangerText("ERROR: TinaCMS only supports alphanumeric template names")
4501
4502
  );
@@ -4677,8 +4678,7 @@ var transformForestryFieldsToTinaFields = ({
4677
4678
  skipBlocks = false
4678
4679
  }) => {
4679
4680
  const tinaFields = [];
4680
- fields == null ? void 0 : fields.forEach((forestryField2) => {
4681
- var _a, _b, _c, _d;
4681
+ fields?.forEach((forestryField2) => {
4682
4682
  if (forestryField2.name === "menu") {
4683
4683
  logger.info(
4684
4684
  warnText(
@@ -4754,12 +4754,12 @@ var transformForestryFieldsToTinaFields = ({
4754
4754
  };
4755
4755
  break;
4756
4756
  case "select":
4757
- if ((_a = forestryField2.config) == null ? void 0 : _a.options) {
4757
+ if (forestryField2.config?.options) {
4758
4758
  field = {
4759
4759
  type: "string",
4760
4760
  ...getTinaFieldsFromName(forestryField2.name),
4761
4761
  label: forestryField2.label,
4762
- options: ((_b = forestryField2.config) == null ? void 0 : _b.options) || []
4762
+ options: forestryField2.config?.options || []
4763
4763
  };
4764
4764
  } else {
4765
4765
  logger.info(
@@ -4777,7 +4777,7 @@ var transformForestryFieldsToTinaFields = ({
4777
4777
  label: forestryField2.label,
4778
4778
  list: true
4779
4779
  };
4780
- if ((_c = forestryField2.config) == null ? void 0 : _c.options) {
4780
+ if (forestryField2.config?.options) {
4781
4781
  field.options = forestryField2.config.options;
4782
4782
  }
4783
4783
  break;
@@ -4825,7 +4825,7 @@ var transformForestryFieldsToTinaFields = ({
4825
4825
  break;
4826
4826
  }
4827
4827
  const templates2 = [];
4828
- forestryField2 == null ? void 0 : forestryField2.template_types.forEach((tem) => {
4828
+ forestryField2?.template_types.forEach((tem) => {
4829
4829
  const { template: template2 } = getFieldsFromTemplates({
4830
4830
  tem,
4831
4831
  skipBlocks: true,
@@ -4883,7 +4883,7 @@ var transformForestryFieldsToTinaFields = ({
4883
4883
  );
4884
4884
  }
4885
4885
  if (field) {
4886
- if ((_d = forestryField2.config) == null ? void 0 : _d.required) {
4886
+ if (forestryField2.config?.required) {
4887
4887
  field = { ...field, required: true };
4888
4888
  }
4889
4889
  tinaFields.push(field);
@@ -4945,8 +4945,7 @@ var stringifyLabelWithField = (label) => {
4945
4945
  return `${labelString}Fields`;
4946
4946
  };
4947
4947
  var transformForestryMatchToTinaMatch = (match) => {
4948
- var _a, _b;
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("{}", "");
4948
+ const newMatch = match.replace(" ", "").replace(/\.?(mdx|md|json|yaml|yml|toml)/g, "")?.replace(/\..*$/g, "")?.replace("{}", "");
4950
4949
  if (match !== newMatch) {
4951
4950
  logger.info(
4952
4951
  `Info: Match ${match} was transformed to ${newMatch}. See ${linkText(
@@ -4958,7 +4957,7 @@ var transformForestryMatchToTinaMatch = (match) => {
4958
4957
  };
4959
4958
  function checkExt(ext) {
4960
4959
  const extReal = ext.replace(".", "");
4961
- if (["mdx", "md", "json", "yaml", "yml", "toml"].includes(extReal)) {
4960
+ if (import_schema_tools3.CONTENT_FORMATS.includes(extReal)) {
4962
4961
  return extReal;
4963
4962
  } else {
4964
4963
  return false;
@@ -5011,18 +5010,18 @@ var generateCollectionFromForestrySection = (args) => {
5011
5010
  }
5012
5011
  if (section.match) {
5013
5012
  baseCollection.match = {
5014
- ...(baseCollection == null ? void 0 : baseCollection.match) || {},
5013
+ ...baseCollection?.match || {},
5015
5014
  include: transformForestryMatchToTinaMatch(section.match)
5016
5015
  };
5017
5016
  }
5018
5017
  if (section.exclude) {
5019
5018
  baseCollection.match = {
5020
- ...(baseCollection == null ? void 0 : baseCollection.match) || {},
5019
+ ...baseCollection?.match || {},
5021
5020
  exclude: transformForestryMatchToTinaMatch(section.exclude)
5022
5021
  };
5023
5022
  }
5024
5023
  if (section.type === "directory") {
5025
- if (!(section == null ? void 0 : section.path) || section.path === "/" || section.path === "./" || section.path === ".") {
5024
+ if (!section?.path || section.path === "/" || section.path === "./" || section.path === ".") {
5026
5025
  logger.log(
5027
5026
  warnText(
5028
5027
  `Warning: Section ${section.label} is using a Root Path. Currently, Tina Does not support Root paths see ${linkText(
@@ -5032,11 +5031,11 @@ var generateCollectionFromForestrySection = (args) => {
5032
5031
  );
5033
5032
  return;
5034
5033
  }
5035
- const forestryTemplates = (section == null ? void 0 : section.templates) || [];
5034
+ const forestryTemplates = section?.templates || [];
5036
5035
  if (forestryTemplates.length === 0 && section.create === "all") {
5037
5036
  for (const templateKey of templateMap.keys()) {
5038
5037
  const { templateObj } = templateMap.get(templateKey);
5039
- const pages = templateObj == null ? void 0 : templateObj.pages;
5038
+ const pages = templateObj?.pages;
5040
5039
  if (pages) {
5041
5040
  let glob = section.match;
5042
5041
  const skipPath = section.path === "" || section.path === "/" || !section.path;
@@ -5053,7 +5052,7 @@ var generateCollectionFromForestrySection = (args) => {
5053
5052
  }
5054
5053
  const hasBody = ["md", "mdx", "markdown"].includes(format3);
5055
5054
  let c;
5056
- if (((forestryTemplates == null ? void 0 : forestryTemplates.length) || 0) > 1) {
5055
+ if ((forestryTemplates?.length || 0) > 1) {
5057
5056
  c = {
5058
5057
  ...baseCollection,
5059
5058
  // @ts-expect-error
@@ -5075,7 +5074,7 @@ var generateCollectionFromForestrySection = (args) => {
5075
5074
  })
5076
5075
  };
5077
5076
  }
5078
- if ((forestryTemplates == null ? void 0 : forestryTemplates.length) === 1) {
5077
+ if (forestryTemplates?.length === 1) {
5079
5078
  const tem = forestryTemplates[0];
5080
5079
  const template = templateMap.get(tem);
5081
5080
  const fieldsString = stringifyLabelWithField(template.templateObj.label);
@@ -5090,7 +5089,7 @@ var generateCollectionFromForestrySection = (args) => {
5090
5089
  })
5091
5090
  };
5092
5091
  }
5093
- if ((forestryTemplates == null ? void 0 : forestryTemplates.length) === 0) {
5092
+ if (forestryTemplates?.length === 0) {
5094
5093
  logger.warn(
5095
5094
  warnText(
5096
5095
  `No templates found for section ${section.label}. Please see ${linkText(
@@ -5103,7 +5102,7 @@ var generateCollectionFromForestrySection = (args) => {
5103
5102
  fields: [BODY_FIELD]
5104
5103
  };
5105
5104
  }
5106
- if ((section == null ? void 0 : section.create) === "none") {
5105
+ if (section?.create === "none") {
5107
5106
  c.ui = {
5108
5107
  ...c.ui,
5109
5108
  allowedActions: {
@@ -5125,7 +5124,7 @@ var generateCollectionFromForestrySection = (args) => {
5125
5124
  }
5126
5125
  for (const currentTemplateName of templateMap.keys()) {
5127
5126
  const { templateObj, fields: additionalFields } = templateMap.get(currentTemplateName);
5128
- const pages = (templateObj == null ? void 0 : templateObj.pages) || [];
5127
+ const pages = templateObj?.pages || [];
5129
5128
  if (pages.includes(section.path)) {
5130
5129
  fields.push(...additionalFields);
5131
5130
  break;
@@ -5204,11 +5203,10 @@ var generateCollections = async ({
5204
5203
  };
5205
5204
  };
5206
5205
  var rewriteTemplateKeysInDocs = (args) => {
5207
- var _a;
5208
5206
  const { templateMap, markdownParseConfig } = args;
5209
5207
  for (const templateKey of templateMap.keys()) {
5210
5208
  const { templateObj } = templateMap.get(templateKey);
5211
- (_a = templateObj == null ? void 0 : templateObj.pages) == null ? void 0 : _a.forEach((page) => {
5209
+ templateObj?.pages?.forEach((page) => {
5212
5210
  try {
5213
5211
  const filePath = import_path9.default.join(page);
5214
5212
  if (import_fs_extra10.default.lstatSync(filePath).isDirectory()) {
@@ -5257,6 +5255,15 @@ var CodemodCommand = class extends import_clipanion5.Command {
5257
5255
  description: "increase verbosity of logged output"
5258
5256
  });
5259
5257
  }
5258
+ static {
5259
+ this.paths = [["codemod"], ["codemod", "move-tina-folder"]];
5260
+ }
5261
+ static {
5262
+ this.usage = import_clipanion5.Command.Usage({
5263
+ category: `Commands`,
5264
+ description: `Use codemods for various Tina tasks`
5265
+ });
5266
+ }
5260
5267
  async catch(error) {
5261
5268
  console.log(error);
5262
5269
  }
@@ -5277,11 +5284,6 @@ var CodemodCommand = class extends import_clipanion5.Command {
5277
5284
  await command2();
5278
5285
  }
5279
5286
  };
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
5287
  var moveTinaFolder = async (rootPath = process.cwd()) => {
5286
5288
  const configManager = new ConfigManager({ rootPath });
5287
5289
  try {
@@ -5561,11 +5563,10 @@ var baseFields = `[
5561
5563
  },
5562
5564
  ]`;
5563
5565
  var generateCollectionString = (args) => {
5564
- var _a, _b, _c, _d;
5565
5566
  if (args.collections) {
5566
5567
  return args.collections;
5567
5568
  }
5568
- let extraTinaCollections = (_b = (_a = args.config.authProvider) == null ? void 0 : _a.extraTinaCollections) == null ? void 0 : _b.join(",\n");
5569
+ let extraTinaCollections = args.config.authProvider?.extraTinaCollections?.join(",\n");
5569
5570
  if (extraTinaCollections) {
5570
5571
  extraTinaCollections = extraTinaCollections + ",";
5571
5572
  }
@@ -5591,18 +5592,17 @@ var generateCollectionString = (args) => {
5591
5592
  },
5592
5593
  },
5593
5594
  ]`;
5594
- if (((_d = (_c = args.config) == null ? void 0 : _c.framework) == null ? void 0 : _d.name) === "next") {
5595
+ if (args.config?.framework?.name === "next") {
5595
5596
  return nextExampleCollection;
5596
5597
  }
5597
5598
  return baseCollections;
5598
5599
  };
5599
5600
  var generateConfig = (args) => {
5600
- var _a, _b, _c;
5601
- const isUsingTinaCloud = !args.selfHosted || ((_a = args.config.authProvider) == null ? void 0 : _a.name) === "tina-cloud";
5601
+ const isUsingTinaCloud = !args.selfHosted || args.config.authProvider?.name === "tina-cloud";
5602
5602
  let extraImports = "";
5603
5603
  if (args.selfHosted) {
5604
5604
  if (args.config.authProvider) {
5605
- extraImports = extraImports + makeImportString((_b = args.config.authProvider) == null ? void 0 : _b.configImports);
5605
+ extraImports = extraImports + makeImportString(args.config.authProvider?.configImports);
5606
5606
  }
5607
5607
  if (!isUsingTinaCloud) {
5608
5608
  extraImports = extraImports + `
@@ -5625,7 +5625,7 @@ import { LocalAuthProvider } from "tinacms";`;
5625
5625
  branch,
5626
5626
  ${args.selfHosted && !isUsingTinaCloud ? `authProvider: isLocal
5627
5627
  ? new LocalAuthProvider()
5628
- :${(_c = args.config) == null ? void 0 : _c.authProvider.configAuthProviderClass},` : ""}
5628
+ :${args.config?.authProvider.configAuthProviderClass},` : ""}
5629
5629
  ${isUsingTinaCloud ? `// Get this from tina.io
5630
5630
  clientId: process.env.NEXT_PUBLIC_TINA_CLIENT_ID,` : ""}
5631
5631
  ${isUsingTinaCloud ? `// Get this from tina.io
@@ -5652,11 +5652,10 @@ import { LocalAuthProvider } from "tinacms";`;
5652
5652
 
5653
5653
  // src/cmds/init/templates/database.ts
5654
5654
  var databaseTemplate = ({ config: config2 }) => {
5655
- var _a, _b, _c, _d;
5656
5655
  return `
5657
5656
  import { createDatabase, createLocalDatabase } from '@tinacms/datalayer'
5658
- ${makeImportString((_a = config2.gitProvider) == null ? void 0 : _a.imports)}
5659
- ${makeImportString((_b = config2.databaseAdapter) == null ? void 0 : _b.imports)}
5657
+ ${makeImportString(config2.gitProvider?.imports)}
5658
+ ${makeImportString(config2.databaseAdapter?.imports)}
5660
5659
 
5661
5660
  const branch = (process.env.GITHUB_BRANCH ||
5662
5661
  process.env.VERCEL_GIT_COMMIT_REF ||
@@ -5668,8 +5667,8 @@ const isLocal = process.env.${config2.isLocalEnvVarName} === 'true'
5668
5667
  export default isLocal
5669
5668
  ? createLocalDatabase()
5670
5669
  : createDatabase({
5671
- gitProvider: ${(_c = config2.gitProvider) == null ? void 0 : _c.gitProviderClassText},
5672
- databaseAdapter: ${(_d = config2.databaseAdapter) == null ? void 0 : _d.databaseAdapterClassText},
5670
+ gitProvider: ${config2.gitProvider?.gitProviderClassText},
5671
+ databaseAdapter: ${config2.databaseAdapter?.databaseAdapterClassText},
5673
5672
  namespace: branch,
5674
5673
  })
5675
5674
  `;
@@ -5680,10 +5679,9 @@ var nextApiRouteTemplate = ({
5680
5679
  config: config2,
5681
5680
  env
5682
5681
  }) => {
5683
- var _a, _b;
5684
5682
  const extraPath = env.usingSrc ? "../" : "";
5685
5683
  return `import { TinaNodeBackend, LocalBackendAuthProvider } from '@tinacms/datalayer'
5686
- ${makeImportString((_a = config2.authProvider) == null ? void 0 : _a.backendAuthProviderImports)}
5684
+ ${makeImportString(config2.authProvider?.backendAuthProviderImports)}
5687
5685
 
5688
5686
 
5689
5687
 
@@ -5694,7 +5692,7 @@ var nextApiRouteTemplate = ({
5694
5692
  const handler = TinaNodeBackend({
5695
5693
  authProvider: isLocal
5696
5694
  ? LocalBackendAuthProvider()
5697
- : ${((_b = config2.authProvider) == null ? void 0 : _b.backendAuthProvider) || ""},
5695
+ : ${config2.authProvider?.backendAuthProvider || ""},
5698
5696
  databaseClient,
5699
5697
  })
5700
5698
 
@@ -5722,19 +5720,18 @@ var import_prettier2 = require("prettier");
5722
5720
  // src/utils/script-helpers.ts
5723
5721
  function generateGqlScript(scriptValue, opts) {
5724
5722
  const cmd = `tinacms dev -c "${scriptValue}"`;
5725
- if (opts == null ? void 0 : opts.isLocalEnvVarName) {
5723
+ if (opts?.isLocalEnvVarName) {
5726
5724
  return `${opts.isLocalEnvVarName}=true ${cmd}`;
5727
5725
  }
5728
5726
  return cmd;
5729
5727
  }
5730
5728
  function extendNextScripts(scripts, opts) {
5731
- var _a, _b;
5732
5729
  const result = {
5733
5730
  ...scripts,
5734
- dev: !(scripts == null ? void 0 : scripts.dev) || ((_a = scripts == null ? void 0 : scripts.dev) == null ? void 0 : _a.indexOf("tinacms dev -c")) === -1 ? generateGqlScript((scripts == null ? void 0 : scripts.dev) || "next dev", opts) : scripts == null ? void 0 : scripts.dev,
5735
- build: !(scripts == null ? void 0 : scripts.build) || !((_b = scripts == null ? void 0 : scripts.build) == null ? void 0 : _b.startsWith("tinacms build &&")) ? `tinacms build && ${(scripts == null ? void 0 : scripts.build) || "next build"}` : scripts == null ? void 0 : scripts.build
5731
+ dev: !scripts?.dev || scripts?.dev?.indexOf("tinacms dev -c") === -1 ? generateGqlScript(scripts?.dev || "next dev", opts) : scripts?.dev,
5732
+ build: !scripts?.build || !scripts?.build?.startsWith("tinacms build &&") ? `tinacms build && ${scripts?.build || "next build"}` : scripts?.build
5736
5733
  };
5737
- if ((opts == null ? void 0 : opts.addSetupUsers) && !scripts["setup:users"]) {
5734
+ if (opts?.addSetupUsers && !scripts["setup:users"]) {
5738
5735
  result["setup:users"] = "tinacms-next-auth setup";
5739
5736
  }
5740
5737
  return result;
@@ -5816,7 +5813,6 @@ var makeVariableStatementVisitor = (sourceFile, variableStmtSourceFile, variable
5816
5813
  }
5817
5814
  };
5818
5815
  var makeImportsVisitor = (sourceFile, importMap) => (ctx) => (node) => {
5819
- var _a;
5820
5816
  if (import_typescript3.default.isSourceFile(node)) {
5821
5817
  const newStatements = [...node.statements];
5822
5818
  let changed = false;
@@ -5825,7 +5821,7 @@ var makeImportsVisitor = (sourceFile, importMap) => (ctx) => (node) => {
5825
5821
  for (const statement of newStatements) {
5826
5822
  if (import_typescript3.default.isImportDeclaration(statement) && import_typescript3.default.isStringLiteral(statement.moduleSpecifier) && statement.moduleSpecifier.text === moduleName) {
5827
5823
  foundImportStatement = true;
5828
- const existingImports = ((_a = statement.importClause) == null ? void 0 : _a.namedBindings) && import_typescript3.default.isNamedImports(statement.importClause.namedBindings) ? statement.importClause.namedBindings.elements.map(
5824
+ const existingImports = statement.importClause?.namedBindings && import_typescript3.default.isNamedImports(statement.importClause.namedBindings) ? statement.importClause.namedBindings.elements.map(
5829
5825
  (e) => e.name.text
5830
5826
  ) : [];
5831
5827
  const newImports = [
@@ -6042,7 +6038,6 @@ async function apply({
6042
6038
  params,
6043
6039
  config: config2
6044
6040
  }) {
6045
- var _a;
6046
6041
  if (config2.framework.name === "other" && config2.hosting === "self-host") {
6047
6042
  logger.error(
6048
6043
  logText(
@@ -6168,7 +6163,7 @@ async function apply({
6168
6163
  env.tinaConfigExists && // Are we running tinacms init backend
6169
6164
  params.isBackendInit && // Do the user choose the 'self-host' option
6170
6165
  config2.hosting === "self-host" && // the user did not choose the 'tina-cloud' auth provider
6171
- (((_a = config2.authProvider) == null ? void 0 : _a.name) || "") !== "tina-cloud"
6166
+ (config2.authProvider?.name || "") !== "tina-cloud"
6172
6167
  ) {
6173
6168
  await addSelfHostedTinaAuthToConfig(config2, env.generatedFiles["config"]);
6174
6169
  }
@@ -6236,7 +6231,6 @@ var updateGitIgnore = async ({
6236
6231
  await import_fs_extra13.default.writeFile(import_path11.default.join(baseDir, ".gitignore"), newGitignoreContent);
6237
6232
  };
6238
6233
  var addDependencies = async (config2, env, params) => {
6239
- var _a, _b, _c, _d, _e, _f, _g, _h, _i;
6240
6234
  const { packageManager } = config2;
6241
6235
  const tagVersion = params.tinaVersion ? `@${params.tinaVersion}` : "";
6242
6236
  let deps = [];
@@ -6252,18 +6246,18 @@ var addDependencies = async (config2, env, params) => {
6252
6246
  deps.push("@tinacms/datalayer");
6253
6247
  }
6254
6248
  deps.push(
6255
- ...((_b = (_a = config2.databaseAdapter) == null ? void 0 : _a.imports) == null ? void 0 : _b.map((x) => x.packageName)) || []
6249
+ ...config2.databaseAdapter?.imports?.map((x) => x.packageName) || []
6256
6250
  );
6257
- deps.push(...((_c = config2.authProvider) == null ? void 0 : _c.peerDependencies) || []);
6251
+ deps.push(...config2.authProvider?.peerDependencies || []);
6258
6252
  deps.push(
6259
- ...((_e = (_d = config2.authProvider) == null ? void 0 : _d.backendAuthProviderImports) == null ? void 0 : _e.map(
6253
+ ...config2.authProvider?.backendAuthProviderImports?.map(
6260
6254
  (x) => x.packageName
6261
- )) || []
6255
+ ) || []
6262
6256
  );
6263
6257
  deps.push(
6264
- ...((_g = (_f = config2.authProvider) == null ? void 0 : _f.configImports) == null ? void 0 : _g.map((x) => x.packageName)) || []
6258
+ ...config2.authProvider?.configImports?.map((x) => x.packageName) || []
6265
6259
  );
6266
- deps.push(...((_i = (_h = config2.gitProvider) == null ? void 0 : _h.imports) == null ? void 0 : _i.map((x) => x.packageName)) || []);
6260
+ deps.push(...config2.gitProvider?.imports?.map((x) => x.packageName) || []);
6267
6261
  if (tagVersion) {
6268
6262
  deps = deps.map(
6269
6263
  (dep) => dep.indexOf("tina") >= 0 ? `${dep}${tagVersion}` : dep
@@ -6327,12 +6321,11 @@ var addConfigFile = async ({
6327
6321
  generatedFile,
6328
6322
  config: config2
6329
6323
  }) => {
6330
- var _a;
6331
6324
  const content = (0, import_prettier2.format)(generateConfig(configArgs), {
6332
6325
  parser: "babel"
6333
6326
  });
6334
6327
  await writeGeneratedFile({
6335
- overwrite: (_a = config2.overwriteList) == null ? void 0 : _a.includes("config"),
6328
+ overwrite: config2.overwriteList?.includes("config"),
6336
6329
  generatedFile,
6337
6330
  content,
6338
6331
  typescript: config2.typescript
@@ -6346,10 +6339,9 @@ var addDatabaseFile = async ({
6346
6339
  config: config2,
6347
6340
  generatedFile
6348
6341
  }) => {
6349
- var _a;
6350
6342
  await writeGeneratedFile({
6351
6343
  generatedFile,
6352
- overwrite: (_a = config2.overwriteList) == null ? void 0 : _a.includes("database"),
6344
+ overwrite: config2.overwriteList?.includes("database"),
6353
6345
  content: databaseTemplate({ config: config2 }),
6354
6346
  typescript: config2.typescript
6355
6347
  });
@@ -6359,13 +6351,12 @@ var addNextApiRoute = async ({
6359
6351
  generatedFile,
6360
6352
  env
6361
6353
  }) => {
6362
- var _a;
6363
6354
  const content = (0, import_prettier2.format)(nextApiRouteTemplate({ config: config2, env }), {
6364
6355
  parser: "babel"
6365
6356
  });
6366
6357
  await writeGeneratedFile({
6367
6358
  generatedFile,
6368
- overwrite: (_a = config2.overwriteList) == null ? void 0 : _a.includes("next-api-handler"),
6359
+ overwrite: config2.overwriteList?.includes("next-api-handler"),
6369
6360
  content,
6370
6361
  typescript: config2.typescript
6371
6362
  });
@@ -6375,10 +6366,9 @@ var addTemplateFile = async ({
6375
6366
  generatedFile,
6376
6367
  config: config2
6377
6368
  }) => {
6378
- var _a;
6379
6369
  await writeGeneratedFile({
6380
6370
  generatedFile,
6381
- overwrite: (_a = config2.overwriteList) == null ? void 0 : _a.includes(generatedFile.generatedFileType),
6371
+ overwrite: config2.overwriteList?.includes(generatedFile.generatedFileType),
6382
6372
  content,
6383
6373
  typescript: config2.typescript
6384
6374
  });
@@ -6387,7 +6377,6 @@ var addContentFile = async ({
6387
6377
  config: config2,
6388
6378
  env
6389
6379
  }) => {
6390
- var _a;
6391
6380
  await writeGeneratedFile({
6392
6381
  generatedFile: {
6393
6382
  javascriptExists: false,
@@ -6405,7 +6394,7 @@ var addContentFile = async ({
6405
6394
  });
6406
6395
  }
6407
6396
  },
6408
- overwrite: (_a = config2.overwriteList) == null ? void 0 : _a.includes("sample-content"),
6397
+ overwrite: config2.overwriteList?.includes("sample-content"),
6409
6398
  content: helloWorldPost,
6410
6399
  typescript: false
6411
6400
  });
@@ -6496,12 +6485,11 @@ var addReactiveFile = {
6496
6485
  baseDir,
6497
6486
  dataLayer
6498
6487
  }) => {
6499
- var _a, _b;
6500
6488
  const packageJsonPath = import_path11.default.join(baseDir, "package.json");
6501
6489
  await writeGeneratedFile({
6502
6490
  generatedFile,
6503
6491
  typescript: config2.typescript,
6504
- overwrite: (_a = config2.overwriteList) == null ? void 0 : _a.includes(
6492
+ overwrite: config2.overwriteList?.includes(
6505
6493
  generatedFile.generatedFileType
6506
6494
  ),
6507
6495
  content: templates["demo-post-page"]({
@@ -6517,7 +6505,7 @@ var addReactiveFile = {
6517
6505
  ...packageJson,
6518
6506
  scripts: extendNextScripts(scripts, {
6519
6507
  isLocalEnvVarName: config2.isLocalEnvVarName,
6520
- addSetupUsers: ((_b = config2.authProvider) == null ? void 0 : _b.name) === "next-auth"
6508
+ addSetupUsers: config2.authProvider?.name === "next-auth"
6521
6509
  })
6522
6510
  },
6523
6511
  null,
@@ -6592,6 +6580,15 @@ var InitCommand = class extends import_clipanion6.Command {
6592
6580
  description: "Specify a version for tina dependencies"
6593
6581
  });
6594
6582
  }
6583
+ static {
6584
+ this.paths = [["init"], ["init", "backend"]];
6585
+ }
6586
+ static {
6587
+ this.usage = import_clipanion6.Command.Usage({
6588
+ category: `Commands`,
6589
+ description: `Add Tina to an existing project`
6590
+ });
6591
+ }
6595
6592
  async catch(error) {
6596
6593
  logger.error("Error occured during tinacms init");
6597
6594
  console.error(error);
@@ -6611,11 +6608,6 @@ var InitCommand = class extends import_clipanion6.Command {
6611
6608
  process.exit();
6612
6609
  }
6613
6610
  };
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
6611
 
6620
6612
  // src/next/commands/searchindex-command/index.ts
6621
6613
  var import_clipanion7 = require("clipanion");
@@ -6631,13 +6623,21 @@ var SearchIndexCommand = class extends import_clipanion7.Command {
6631
6623
  description: "increase verbosity of logged output"
6632
6624
  });
6633
6625
  }
6626
+ static {
6627
+ this.paths = [["search-index"]];
6628
+ }
6629
+ static {
6630
+ this.usage = import_clipanion7.Command.Usage({
6631
+ category: `Commands`,
6632
+ description: `Index the site for search`
6633
+ });
6634
+ }
6634
6635
  async catch(error) {
6635
6636
  logger.error("Error occured during tinacms search-index");
6636
6637
  console.error(error);
6637
6638
  process.exit(1);
6638
6639
  }
6639
6640
  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
6641
  const rootPath = this.rootPath || process.cwd();
6642
6642
  const configManager = new ConfigManager({ rootPath });
6643
6643
  try {
@@ -6648,7 +6648,7 @@ var SearchIndexCommand = class extends import_clipanion7.Command {
6648
6648
  console.error(e);
6649
6649
  }
6650
6650
  }
6651
- if (!((_a = configManager.config) == null ? void 0 : _a.search)) {
6651
+ if (!configManager.config?.search) {
6652
6652
  logger.error("No search config found");
6653
6653
  process.exit(1);
6654
6654
  }
@@ -6657,9 +6657,9 @@ var SearchIndexCommand = class extends import_clipanion7.Command {
6657
6657
  schema: { ...schema, config: configManager.config }
6658
6658
  });
6659
6659
  let client;
6660
- const hasTinaSearch = Boolean((_c = (_b = configManager.config) == null ? void 0 : _b.search) == null ? void 0 : _c.tina);
6660
+ const hasTinaSearch = Boolean(configManager.config?.search?.tina);
6661
6661
  if (hasTinaSearch) {
6662
- if (!((_d = configManager.config) == null ? void 0 : _d.branch)) {
6662
+ if (!configManager.config?.branch) {
6663
6663
  logger.error(
6664
6664
  `${dangerText(
6665
6665
  `ERROR: Branch not configured in tina search configuration.`
@@ -6667,11 +6667,11 @@ var SearchIndexCommand = class extends import_clipanion7.Command {
6667
6667
  );
6668
6668
  throw new Error("Branch not configured in tina search configuration.");
6669
6669
  }
6670
- if (!((_e = configManager.config) == null ? void 0 : _e.clientId)) {
6670
+ if (!configManager.config?.clientId) {
6671
6671
  logger.error(`${dangerText(`ERROR: clientId not configured.`)}`);
6672
6672
  throw new Error("clientId not configured.");
6673
6673
  }
6674
- if (!((_h = (_g = (_f = configManager.config) == null ? void 0 : _f.search) == null ? void 0 : _g.tina) == null ? void 0 : _h.indexerToken)) {
6674
+ if (!configManager.config?.search?.tina?.indexerToken) {
6675
6675
  logger.error(
6676
6676
  `${dangerText(
6677
6677
  `ERROR: indexerToken not configured in tina search configuration.`
@@ -6682,22 +6682,22 @@ var SearchIndexCommand = class extends import_clipanion7.Command {
6682
6682
  );
6683
6683
  }
6684
6684
  client = new import_search3.TinaCMSSearchIndexClient({
6685
- apiUrl: `${((_i = configManager.config.tinaioConfig) == null ? void 0 : _i.contentApiUrlOverride) || "https://content.tinajs.io"}/searchIndex/${(_j = configManager.config) == null ? void 0 : _j.clientId}`,
6686
- branch: (_k = configManager.config) == null ? void 0 : _k.branch,
6687
- indexerToken: (_n = (_m = (_l = configManager.config) == null ? void 0 : _l.search) == null ? void 0 : _m.tina) == null ? void 0 : _n.indexerToken,
6688
- stopwordLanguages: (_q = (_p = (_o = configManager.config) == null ? void 0 : _o.search) == null ? void 0 : _p.tina) == null ? void 0 : _q.stopwordLanguages
6685
+ apiUrl: `${configManager.config.tinaioConfig?.contentApiUrlOverride || "https://content.tinajs.io"}/searchIndex/${configManager.config?.clientId}`,
6686
+ branch: configManager.config?.branch,
6687
+ indexerToken: configManager.config?.search?.tina?.indexerToken,
6688
+ stopwordLanguages: configManager.config?.search?.tina?.stopwordLanguages
6689
6689
  });
6690
6690
  } else {
6691
- client = (_s = (_r = configManager.config) == null ? void 0 : _r.search) == null ? void 0 : _s.searchClient;
6691
+ client = configManager.config?.search?.searchClient;
6692
6692
  }
6693
6693
  const searchIndexer = new import_search3.SearchIndexer({
6694
- batchSize: ((_t = configManager.config.search) == null ? void 0 : _t.indexBatchSize) || 100,
6694
+ batchSize: configManager.config.search?.indexBatchSize || 100,
6695
6695
  bridge: new import_graphql17.FilesystemBridge(
6696
6696
  configManager.rootPath,
6697
6697
  configManager.contentRootPath
6698
6698
  ),
6699
6699
  schema: tinaSchema,
6700
- textIndexLength: ((_u = configManager.config.search) == null ? void 0 : _u.maxSearchIndexFieldLength) || 100,
6700
+ textIndexLength: configManager.config.search?.maxSearchIndexFieldLength || 100,
6701
6701
  client
6702
6702
  });
6703
6703
  let err;
@@ -6718,11 +6718,6 @@ var SearchIndexCommand = class extends import_clipanion7.Command {
6718
6718
  process.exit(0);
6719
6719
  }
6720
6720
  };
6721
- SearchIndexCommand.paths = [["search-index"]];
6722
- SearchIndexCommand.usage = import_clipanion7.Command.Usage({
6723
- category: `Commands`,
6724
- description: `Index the site for search`
6725
- });
6726
6721
 
6727
6722
  // src/index.ts
6728
6723
  var cli = new import_clipanion8.Cli({
@@ -2,4 +2,4 @@
2
2
 
3
3
  */
4
4
  import http from 'node:http';
5
- export declare const gqlServer: (database: any, verbose: boolean) => Promise<http.Server<typeof http.IncomingMessage, typeof http.ServerResponse>>;
5
+ export declare const gqlServer: (database: any, verbose: boolean) => Promise<http.Server<typeof import("http").IncomingMessage, typeof import("http").ServerResponse>>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tinacms/cli",
3
- "version": "0.0.0-b67f55a-20250513032422",
3
+ "version": "0.0.0-b782a89-20250521051922",
4
4
  "main": "dist/index.js",
5
5
  "typings": "dist/index.d.ts",
6
6
  "files": [
@@ -41,7 +41,7 @@
41
41
  "@types/prompts": "^2.4.9",
42
42
  "@types/yup": "^0.32.0",
43
43
  "jest": "^29.7.0",
44
- "@tinacms/scripts": "1.3.4"
44
+ "@tinacms/scripts": "0.0.0-b782a89-20250521051922"
45
45
  },
46
46
  "dependencies": {
47
47
  "@graphql-codegen/core": "^2.6.8",
@@ -89,12 +89,12 @@
89
89
  "vite": "^4.5.9",
90
90
  "yup": "^1.6.1",
91
91
  "zod": "^3.24.2",
92
- "@tinacms/app": "0.0.0-b67f55a-20250513032422",
92
+ "@tinacms/app": "0.0.0-b782a89-20250521051922",
93
93
  "@tinacms/metrics": "1.0.9",
94
- "@tinacms/graphql": "1.5.17",
95
- "@tinacms/schema-tools": "1.7.3",
96
- "@tinacms/search": "1.0.44",
97
- "tinacms": "0.0.0-b67f55a-20250513032422"
94
+ "@tinacms/schema-tools": "0.0.0-b782a89-20250521051922",
95
+ "@tinacms/search": "0.0.0-b782a89-20250521051922",
96
+ "tinacms": "0.0.0-b782a89-20250521051922",
97
+ "@tinacms/graphql": "0.0.0-b782a89-20250521051922"
98
98
  },
99
99
  "publishConfig": {
100
100
  "registry": "https://registry.npmjs.org"