@tinacms/cli 2.4.1 → 2.4.3

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,6 +1,6 @@
1
1
  import type { Collection, TinaField, ContentFrontmatterFormat } from '@tinacms/schema-tools';
2
- export declare const stringifyLabel: (label: string) => string;
3
- export declare const stringifyLabelWithField: (label: string) => string;
2
+ import { stringifyLabel, stringifyLabelWithField } from './util/naming';
3
+ export { stringifyLabel, stringifyLabelWithField };
4
4
  export declare const generateAllTemplates: ({ pathToForestryConfig, }: {
5
5
  pathToForestryConfig: string;
6
6
  }) => Promise<Map<string, {
@@ -3,9 +3,9 @@ import { TinaField } from '@tinacms/schema-tools';
3
3
  * This function is used to replace the internal code with the actual code
4
4
  *
5
5
  * EX:
6
- * __TINA_INTERNAL__:::...fields::: => ...fields
6
+ * <marker>...fields()<marker> => ...fields()
7
7
  *
8
- * or __TINA_INTERNAL__:::fields::: => fields
8
+ * or <marker>fields()<marker> => fields()
9
9
  */
10
10
  export declare const addVariablesToCode: (codeWithTinaPrefix: string) => {
11
11
  code: string;
@@ -11,8 +11,8 @@ export declare const stringifyTemplateName: (name: string, template: string) =>
11
11
  declare const forestryFieldWithoutField: z.ZodObject<{
12
12
  type: z.ZodUnion<[z.ZodLiteral<"text">, z.ZodLiteral<"datetime">, z.ZodLiteral<"list">, z.ZodLiteral<"file">, z.ZodLiteral<"image_gallery">, z.ZodLiteral<"textarea">, z.ZodLiteral<"tag_list">, z.ZodLiteral<"number">, z.ZodLiteral<"boolean">, z.ZodLiteral<"field_group">, z.ZodLiteral<"field_group_list">, z.ZodLiteral<"select">, z.ZodLiteral<"include">, z.ZodLiteral<"blocks">, z.ZodLiteral<"color">]>;
13
13
  template_types: z.ZodNullable<z.ZodOptional<z.ZodArray<z.ZodString, "many">>>;
14
- name: z.ZodString;
15
- label: z.ZodString;
14
+ name: z.ZodEffects<z.ZodString, string, string>;
15
+ label: z.ZodEffects<z.ZodString, string, string>;
16
16
  default: z.ZodOptional<z.ZodAny>;
17
17
  template: z.ZodOptional<z.ZodString>;
18
18
  config: z.ZodOptional<z.ZodObject<{
@@ -104,7 +104,7 @@ interface ForestryFieldType extends ForestryFieldWithoutFieldType {
104
104
  fields?: ForestryFieldType[];
105
105
  }
106
106
  declare const FrontmatterTemplateSchema: z.ZodObject<{
107
- label: z.ZodString;
107
+ label: z.ZodEffects<z.ZodString, string, string>;
108
108
  hide_body: z.ZodOptional<z.ZodBoolean>;
109
109
  fields: z.ZodOptional<z.ZodArray<z.ZodType<ForestryFieldType, z.ZodTypeDef, ForestryFieldType>, "many">>;
110
110
  }, "strip", z.ZodTypeAny, {
@@ -0,0 +1,3 @@
1
+ export declare const stringifyLabel: (label: string) => string;
2
+ export declare const stringifyLabelWithField: (label: string) => string;
3
+ export declare const isForestrySafeString: (value: string) => boolean;
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.4.1";
5
+ var version = "2.4.3";
6
6
 
7
7
  // src/next/commands/dev-command/index.ts
8
8
  import path10 from "path";
@@ -1387,6 +1387,7 @@ var createDBServer = (port) => {
1387
1387
  }
1388
1388
  });
1389
1389
  dbServer.listen(port, "localhost");
1390
+ return dbServer;
1390
1391
  };
1391
1392
  async function createAndInitializeDatabase(configManager, datalayerPort, bridgeOverride) {
1392
1393
  let database;
@@ -5105,14 +5106,26 @@ var ErrorSingleton = class _ErrorSingleton {
5105
5106
  }
5106
5107
  };
5107
5108
 
5109
+ // src/cmds/forestry-migrate/util/naming.ts
5110
+ var stringifyLabel = (label) => {
5111
+ return label.replace(/[^a-zA-Z0-9]/g, "_").toLowerCase();
5112
+ };
5113
+ var stringifyLabelWithField = (label) => {
5114
+ const labelString = stringifyLabel(label);
5115
+ return `${labelString}Fields`;
5116
+ };
5117
+ var isForestrySafeString = (value) => !/[\x00\r\n]/.test(value);
5118
+
5108
5119
  // src/cmds/forestry-migrate/util/codeTransformer.ts
5120
+ import crypto3 from "crypto";
5109
5121
  import { format } from "prettier";
5110
5122
  import TsParser from "prettier/parser-typescript.js";
5123
+ var INTERNAL_NONCE = crypto3.randomBytes(16).toString("hex");
5124
+ var MARKER_OPEN = `__TINA_INTERNAL_${INTERNAL_NONCE}__:::`;
5125
+ var MARKER_CLOSE = `:::__TINA_INTERNAL_${INTERNAL_NONCE}__`;
5126
+ var MARKER_REGEX = new RegExp(`"${MARKER_OPEN}(.*?)${MARKER_CLOSE}"`, "g");
5111
5127
  var addVariablesToCode = (codeWithTinaPrefix) => {
5112
- const code = codeWithTinaPrefix.replace(
5113
- /"__TINA_INTERNAL__:::(.*?):::"/g,
5114
- "$1"
5115
- );
5128
+ const code = codeWithTinaPrefix.replace(MARKER_REGEX, "$1");
5116
5129
  return { code };
5117
5130
  };
5118
5131
  var makeFieldsWithInternalCode = ({
@@ -5122,10 +5135,10 @@ var makeFieldsWithInternalCode = ({
5122
5135
  spread
5123
5136
  }) => {
5124
5137
  if (hasBody) {
5125
- return [bodyField, `__TINA_INTERNAL__:::...${field}():::`];
5138
+ return [bodyField, `${MARKER_OPEN}...${field}()${MARKER_CLOSE}`];
5126
5139
  } else {
5127
- if (spread) return `__TINA_INTERNAL__:::...${field}():::`;
5128
- return `__TINA_INTERNAL__:::${field}():::`;
5140
+ if (spread) return `${MARKER_OPEN}...${field}()${MARKER_CLOSE}`;
5141
+ return `${MARKER_OPEN}${field}()${MARKER_CLOSE}`;
5129
5142
  }
5130
5143
  };
5131
5144
  var makeTemplateFile = async ({
@@ -5186,6 +5199,9 @@ var stringifyTemplateName = (name2, template) => {
5186
5199
  return newName;
5187
5200
  }
5188
5201
  };
5202
+ var forestrySafeString = z2.string().refine(isForestrySafeString, {
5203
+ message: "Forestry name/label contains an unexpected control character"
5204
+ });
5189
5205
  var forestryConfigSchema = z2.object({
5190
5206
  sections: z2.array(
5191
5207
  z2.object({
@@ -5227,8 +5243,8 @@ var forestryFieldWithoutField = z2.object({
5227
5243
  z2.literal("color")
5228
5244
  ]),
5229
5245
  template_types: z2.array(z2.string()).optional().nullable(),
5230
- name: z2.string(),
5231
- label: z2.string(),
5246
+ name: forestrySafeString,
5247
+ label: forestrySafeString,
5232
5248
  default: z2.any().optional(),
5233
5249
  template: z2.string().optional(),
5234
5250
  config: z2.object({
@@ -5259,7 +5275,7 @@ var forestryField = z2.lazy(
5259
5275
  })
5260
5276
  );
5261
5277
  var FrontmatterTemplateSchema = z2.object({
5262
- label: z2.string(),
5278
+ label: forestrySafeString,
5263
5279
  hide_body: z2.boolean().optional(),
5264
5280
  fields: z2.array(forestryField).optional()
5265
5281
  });
@@ -5530,13 +5546,6 @@ var BODY_FIELD = {
5530
5546
  description: "This is the markdown body",
5531
5547
  isBody: true
5532
5548
  };
5533
- var stringifyLabel = (label) => {
5534
- return label.replace(/[^a-zA-Z0-9]/g, "_").toLowerCase();
5535
- };
5536
- var stringifyLabelWithField = (label) => {
5537
- const labelString = stringifyLabel(label);
5538
- return `${labelString}Fields`;
5539
- };
5540
5549
  var transformForestryMatchToTinaMatch = (match) => {
5541
5550
  const newMatch = match.replace(" ", "").replace(/\.?(mdx|md|json|yaml|yml|toml)/g, "")?.replace(/\..*$/g, "")?.replace("{}", "");
5542
5551
  if (match !== newMatch) {
@@ -0,0 +1 @@
1
+ export {};
@@ -1,4 +1,5 @@
1
+ import { type Server } from 'net';
1
2
  import { Bridge, Database } from '@tinacms/graphql';
2
3
  import { ConfigManager } from './config-manager';
3
- export declare const createDBServer: (port: number) => void;
4
+ export declare const createDBServer: (port: number) => Server;
4
5
  export declare function createAndInitializeDatabase(configManager: ConfigManager, datalayerPort: number, bridgeOverride?: Bridge): Promise<Database>;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tinacms/cli",
3
3
  "type": "module",
4
- "version": "2.4.1",
4
+ "version": "2.4.3",
5
5
  "main": "dist/index.js",
6
6
  "typings": "dist/index.d.ts",
7
7
  "files": [
@@ -41,6 +41,8 @@
41
41
  "@types/progress": "^2.0.7",
42
42
  "@types/prompts": "^2.4.9",
43
43
  "jest": "^29.7.0",
44
+ "mongodb-level": "^0.0.4",
45
+ "sqlite-level": "^2.1.0",
44
46
  "ts-jest": "^29.2.5",
45
47
  "@tinacms/scripts": "1.6.1"
46
48
  },
@@ -90,12 +92,12 @@
90
92
  "vite": "^4.5.9",
91
93
  "yup": "^1.6.1",
92
94
  "zod": "^3.24.2",
93
- "@tinacms/app": "2.5.1",
94
- "@tinacms/graphql": "2.4.2",
95
+ "@tinacms/app": "2.5.3",
96
+ "@tinacms/graphql": "2.4.3",
95
97
  "@tinacms/metrics": "2.1.0",
96
- "@tinacms/search": "1.2.16",
97
- "tinacms": "3.8.3",
98
- "@tinacms/schema-tools": "2.8.0"
98
+ "@tinacms/schema-tools": "2.8.1",
99
+ "@tinacms/search": "1.2.17",
100
+ "tinacms": "3.9.0"
99
101
  },
100
102
  "publishConfig": {
101
103
  "registry": "https://registry.npmjs.org"
@@ -107,6 +109,7 @@
107
109
  "scripts": {
108
110
  "build": "tinacms-scripts build",
109
111
  "test": "jest --passWithNoTests",
112
+ "test:adapters": "NODE_OPTIONS='--experimental-vm-modules' jest --config jest.adapter-matrix.config.js --runTestsByPath src/next/adapter-matrix.adapter-test.ts",
110
113
  "types": "pnpm tsc",
111
114
  "test-watch": "jest --passWithNoTests --watch",
112
115
  "tinacms": "MONOREPO_DEV=true node ./bin/tinacms",