@tinacms/cli 2.1.5 → 2.1.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -2,7 +2,7 @@
2
2
  import { Cli, Builtins } from "clipanion";
3
3
 
4
4
  // package.json
5
- var version = "2.1.5";
5
+ var version = "2.1.6";
6
6
 
7
7
  // src/next/commands/dev-command/index.ts
8
8
  import path8 from "path";
@@ -417,6 +417,38 @@ var loadGraphQLDocuments = async (globPath) => {
417
417
  import { transform } from "esbuild";
418
418
  import { mapUserFields } from "@tinacms/graphql";
419
419
  import normalizePath from "normalize-path";
420
+
421
+ // src/next/codegen/stripSearchTokenFromConfig.ts
422
+ function stripSearchTokenFromConfig(config2) {
423
+ const cfg = config2;
424
+ if (!cfg?.search) {
425
+ return config2;
426
+ }
427
+ const search = cfg.search;
428
+ const tina = search?.tina;
429
+ if (tina) {
430
+ const { indexerToken, ...safeSearchConfig } = tina;
431
+ const newConfig = {};
432
+ for (const key of Object.keys(cfg)) {
433
+ if (key === "search") {
434
+ newConfig.search = { tina: safeSearchConfig };
435
+ } else {
436
+ newConfig[key] = cfg[key];
437
+ }
438
+ }
439
+ return newConfig;
440
+ } else {
441
+ const newConfig = {};
442
+ for (const key of Object.keys(cfg)) {
443
+ if (key !== "search") {
444
+ newConfig[key] = cfg[key];
445
+ }
446
+ }
447
+ return newConfig;
448
+ }
449
+ }
450
+
451
+ // src/next/codegen/index.ts
420
452
  var TINA_HOST = "content.tinajs.io";
421
453
  var Codegen = class {
422
454
  configManager;
@@ -487,27 +519,9 @@ var Codegen = class {
487
519
  "_graphql.json",
488
520
  JSON.stringify(this.graphqlSchemaDoc)
489
521
  );
490
- const config2 = this.tinaSchema.schema.config;
491
- if (config2?.search?.tina) {
492
- const { indexerToken, ...safeSearchConfig } = config2.search.tina;
493
- const newConfig = {};
494
- for (const key of Object.keys(config2)) {
495
- if (key === "search") {
496
- newConfig.search = { tina: safeSearchConfig };
497
- } else {
498
- newConfig[key] = config2[key];
499
- }
500
- }
501
- this.tinaSchema.schema.config = newConfig;
502
- } else if (config2?.search) {
503
- const newConfig = {};
504
- for (const key of Object.keys(config2)) {
505
- if (key !== "search") {
506
- newConfig[key] = config2[key];
507
- }
508
- }
509
- this.tinaSchema.schema.config = newConfig;
510
- }
522
+ this.tinaSchema.schema.config = stripSearchTokenFromConfig(
523
+ this.tinaSchema.schema.config
524
+ );
511
525
  await this.writeConfigFile(
512
526
  "_schema.json",
513
527
  JSON.stringify(this.tinaSchema.schema)
@@ -1017,13 +1031,15 @@ var ConfigManager = class {
1017
1031
  this.contentRootPath = this.rootPath;
1018
1032
  }
1019
1033
  this.generatedFolderPathContentRepo = path3.join(
1020
- await this.getTinaFolderPath(this.contentRootPath),
1034
+ await this.getTinaFolderPath(this.contentRootPath, {
1035
+ isContentRoot: this.hasSeparateContentRoot()
1036
+ }),
1021
1037
  GENERATED_FOLDER
1022
1038
  );
1023
1039
  this.spaMainPath = require2.resolve("@tinacms/app");
1024
1040
  this.spaRootPath = path3.join(this.spaMainPath, "..", "..");
1025
1041
  }
1026
- async getTinaFolderPath(rootPath) {
1042
+ async getTinaFolderPath(rootPath, { isContentRoot } = {}) {
1027
1043
  const tinaFolderPath = path3.join(rootPath, TINA_FOLDER);
1028
1044
  const tinaFolderExists = await fs2.pathExists(tinaFolderPath);
1029
1045
  if (tinaFolderExists) {
@@ -1036,6 +1052,11 @@ var ConfigManager = class {
1036
1052
  this.isUsingLegacyFolder = true;
1037
1053
  return legacyFolderPath;
1038
1054
  }
1055
+ if (isContentRoot) {
1056
+ throw new Error(
1057
+ `Unable to find a ${chalk3.cyan("tina/")} folder in your content root at ${chalk3.cyan(rootPath)}. When using localContentPath, the content directory must contain a ${chalk3.cyan("tina/")} folder for generated files. Create one with: mkdir ${path3.join(rootPath, TINA_FOLDER)}`
1058
+ );
1059
+ }
1039
1060
  throw new Error(
1040
1061
  `Unable to find Tina folder, if you're working in folder outside of the Tina config be sure to specify --rootPath`
1041
1062
  );
@@ -1557,6 +1578,29 @@ import {
1557
1578
  splitVendorChunkPlugin
1558
1579
  } from "vite";
1559
1580
 
1581
+ // src/next/vite/filterPublicEnv.ts
1582
+ function filterPublicEnv(env = process.env) {
1583
+ const publicEnv = {};
1584
+ Object.keys(env).forEach((key) => {
1585
+ if (key.startsWith("TINA_PUBLIC_") || key.startsWith("NEXT_PUBLIC_") || key === "NODE_ENV" || key === "HEAD") {
1586
+ try {
1587
+ const value = env[key];
1588
+ if (typeof value === "string") {
1589
+ publicEnv[key] = value;
1590
+ } else {
1591
+ publicEnv[key] = JSON.stringify(value);
1592
+ }
1593
+ } catch (error) {
1594
+ console.warn(
1595
+ `Could not stringify public env process.env.${key} env variable`
1596
+ );
1597
+ console.warn(error);
1598
+ }
1599
+ }
1600
+ });
1601
+ return publicEnv;
1602
+ }
1603
+
1560
1604
  // src/next/vite/tailwind.ts
1561
1605
  import path4 from "node:path";
1562
1606
  import aspectRatio from "@tailwindcss/aspect-ratio";
@@ -1889,23 +1933,7 @@ var createConfig = async ({
1889
1933
  noWatch,
1890
1934
  rollupOptions
1891
1935
  }) => {
1892
- const publicEnv = {};
1893
- Object.keys(process.env).forEach((key) => {
1894
- if (key.startsWith("TINA_PUBLIC_") || key.startsWith("NEXT_PUBLIC_") || key === "NODE_ENV" || key === "HEAD") {
1895
- try {
1896
- if (typeof process.env[key] === "string") {
1897
- publicEnv[key] = process.env[key];
1898
- } else {
1899
- publicEnv[key] = JSON.stringify(process.env[key]);
1900
- }
1901
- } catch (error) {
1902
- console.warn(
1903
- `Could not stringify public env process.env.${key} env variable`
1904
- );
1905
- console.warn(error);
1906
- }
1907
- }
1908
- });
1936
+ const publicEnv = filterPublicEnv();
1909
1937
  const staticMediaPath = path5.join(
1910
1938
  configManager.generatedFolderPath,
1911
1939
  "static-media.json"
@@ -2555,7 +2583,8 @@ var DevCommand = class extends BaseCommand {
2555
2583
  );
2556
2584
  if (configManager.hasSeparateContentRoot()) {
2557
2585
  const rootPath = await configManager.getTinaFolderPath(
2558
- configManager.contentRootPath
2586
+ configManager.contentRootPath,
2587
+ { isContentRoot: true }
2559
2588
  );
2560
2589
  const filePath = path8.join(rootPath, tinaLockFilename);
2561
2590
  await fs7.ensureFile(filePath);
@@ -2731,6 +2760,13 @@ ${dangerText(e.message)}
2731
2760
  // },
2732
2761
  ]
2733
2762
  });
2763
+ if (configManager?.config?.telemetry === "anonymous") {
2764
+ logger.info(
2765
+ `
2766
+ \u{1F4CA} Note: TinaCMS now collects anonymous telemetry regarding usage. More information on TinaCMS Telemetry: https://tina.io/telemetry
2767
+ `
2768
+ );
2769
+ }
2734
2770
  await this.startSubCommand();
2735
2771
  }
2736
2772
  watchContentFiles(configManager, database, databaseLock, searchIndexer) {
@@ -2831,23 +2867,6 @@ async function sleepAndCallFunc({
2831
2867
  // src/next/commands/build-command/server.ts
2832
2868
  import { build as build2 } from "vite";
2833
2869
  var buildProductionSpa = async (configManager, database, apiURL) => {
2834
- const publicEnv = {};
2835
- Object.keys(process.env).forEach((key) => {
2836
- if (key.startsWith("TINA_PUBLIC_") || key.startsWith("NEXT_PUBLIC_") || key === "NODE_ENV" || key === "HEAD") {
2837
- try {
2838
- if (typeof process.env[key] === "string") {
2839
- publicEnv[key] = process.env[key];
2840
- } else {
2841
- publicEnv[key] = JSON.stringify(process.env[key]);
2842
- }
2843
- } catch (error) {
2844
- console.warn(
2845
- `Could not stringify public env process.env.${key} env variable`
2846
- );
2847
- console.warn(error);
2848
- }
2849
- }
2850
- });
2851
2870
  const config2 = await createConfig({
2852
2871
  plugins: [transformTsxPlugin({ configManager }), viteTransformExtension()],
2853
2872
  configManager,
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Strips `indexerToken` from `search.tina` before serialization to
3
+ * _schema.json / tina-lock.json.
4
+ *
5
+ * @see https://github.com/tinacms/tinacms/security/advisories/GHSA-4qrm-9h4r-v2fx
6
+ */
7
+ export declare function stripSearchTokenFromConfig<T extends object>(config: T): T;
@@ -54,7 +54,9 @@ export declare class ConfigManager {
54
54
  hasSeparateContentRoot(): boolean;
55
55
  shouldSkipSDK(): boolean;
56
56
  processConfig(): Promise<void>;
57
- getTinaFolderPath(rootPath: any): Promise<string>;
57
+ getTinaFolderPath(rootPath: string, { isContentRoot }?: {
58
+ isContentRoot?: boolean;
59
+ }): Promise<string>;
58
60
  getTinaGraphQLVersion(): {
59
61
  fullVersion: string;
60
62
  major: string;
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Filters env vars to only those safe for client-side bundles.
3
+ *
4
+ * Allows: TINA_PUBLIC_*, NEXT_PUBLIC_*, NODE_ENV, HEAD.
5
+ * Everything else is excluded to prevent leaking secrets.
6
+ *
7
+ * @see https://github.com/tinacms/tinacms/security/advisories/GHSA-pc2q-jcxq-rjrr
8
+ */
9
+ export declare function filterPublicEnv(env?: Record<string, string | undefined>): Record<string, string>;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tinacms/cli",
3
3
  "type": "module",
4
- "version": "2.1.5",
4
+ "version": "2.1.6",
5
5
  "main": "dist/index.js",
6
6
  "typings": "dist/index.d.ts",
7
7
  "files": [
@@ -41,7 +41,7 @@
41
41
  "@types/progress": "^2.0.7",
42
42
  "@types/prompts": "^2.4.9",
43
43
  "jest": "^29.7.0",
44
- "@tinacms/scripts": "1.4.2"
44
+ "@tinacms/scripts": "1.5.0"
45
45
  },
46
46
  "dependencies": {
47
47
  "@graphql-codegen/core": "^2.6.8",
@@ -88,12 +88,12 @@
88
88
  "vite": "^4.5.9",
89
89
  "yup": "^1.6.1",
90
90
  "zod": "^3.24.2",
91
- "@tinacms/app": "2.3.24",
92
- "@tinacms/graphql": "2.1.1",
91
+ "@tinacms/app": "2.3.25",
92
+ "@tinacms/schema-tools": "2.6.0",
93
+ "@tinacms/graphql": "2.1.2",
93
94
  "@tinacms/metrics": "2.0.1",
94
- "@tinacms/schema-tools": "2.5.0",
95
- "@tinacms/search": "1.2.2",
96
- "tinacms": "3.4.1"
95
+ "@tinacms/search": "1.2.3",
96
+ "tinacms": "3.5.0"
97
97
  },
98
98
  "publishConfig": {
99
99
  "registry": "https://registry.npmjs.org"