tinacms 2.2.4 → 2.2.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/README.md CHANGED
@@ -1,4 +1,79 @@
1
- # TinaCMS
2
- > The Fastest Way to Edit Next.js Content
1
+ [![GitHub license](https://img.shields.io/github/license/tinacms/tinacms?color=blue)](https://github.com/tinacms/tinacms/blob/main/LICENSE)
2
+ [![npm version](https://img.shields.io/npm/v/tinacms.svg?style=flat)](https://www.npmjs.com/package/tinacms)
3
+ [![Build, Test, Lint for Main](https://github.com/tinacms/tinacms/actions/workflows/main.yml/badge.svg?branch=main&event=push)](https://github.com/tinacms/tinacms/actions/workflows/main.yml)
3
4
 
4
- [Checkout the docs](https://tina.io/docs/setup-overview/) for information on how to get started
5
+ # [![TINA CMS](https://res.cloudinary.com/forestry-demo/image/upload/c_scale,w_400/v1694189357/tina-brand-assets/logos/png/Logo_Full_-_Default.png 'Visit tinacms.org')](https://tina.io)
6
+
7
+ [![Tina Demo](https://res.cloudinary.com/forestry-demo/video/upload/du_16,w_700,e_loop/tina-io/new-homepage/homepage-demo-2.gif)](https://tina.io/)
8
+
9
+ Tina is a headless content management system with support for **Markdown**, MDX, JSON, YAML, and more.
10
+
11
+ It comes with a GraphQL API:
12
+
13
+ - Query your Markdown content like this 👉 `post.author.firstName`
14
+ - Supports statically generated and server side rendered pages
15
+ - Supports references between documents
16
+
17
+ Tina offers a live preview (optional and opt-in) that makes editing Markdown files very intuitive for less-technical people.
18
+
19
+ ## Getting Started
20
+
21
+ Test a TinaCMS starter site locally
22
+
23
+ ```
24
+ npx create-tina-app@latest
25
+ ```
26
+
27
+ Or try a [demo site](https://app.tina.io/quickstart) on Tina Cloud.
28
+
29
+ ## Documentation
30
+
31
+ Visit [Tina's documentation](https://tina.io/docs/) to learn more.
32
+
33
+ ## Questions?
34
+
35
+ [![Tweet](https://img.shields.io/twitter/url/http/shields.io.svg?style=social)](https://twitter.com/intent/tweet?url=https%3A%2F%2Ftinacms.org&text=I%20just%20checked%20out%20@tinacms%20on%20GitHub%20and%20it%20is%20sweet%21&hashtags=TinaCMS%2Cjamstack%2Cheadlesscms)
36
+ [![Forum](https://shields.io/github/discussions/tinacms/tinacms)](https://github.com/tinacms/tinacms/discussions)
37
+
38
+ Visit the [GitHub Discussions](https://github.com/tinacms/tinacms/discussions) or our [Community Discord](https://discord.com/invite/zumN63Ybpf) to ask questions, or look us up on on Twitter at [@tinacms](https://twitter.com/tinacms).
39
+
40
+ <!-- ## Changelog
41
+
42
+ Check the [CHANGELOG](./CHANGELOG.md) for the latest updates to TinaCMS. -->
43
+
44
+ ## Vision
45
+
46
+ To be the world-leading CMS with Git support that developers love.
47
+
48
+ ## Tech Stack
49
+
50
+ See
51
+ https://tina.io/docs/introduction/faq/#what-is-tinas-tech-stack
52
+
53
+ ## Roadmap
54
+
55
+ Our development priorities can be read on our [Public Roadmap](https://tina.io/roadmap/).
56
+
57
+ ## Contributing
58
+
59
+ Please see our [./CONTRIBUTING.md](https://github.com/tinacms/tinacms/blob/main/CONTRIBUTING.md)
60
+
61
+ ### Maintainers
62
+
63
+ - Kelly Davis ([@kldavis](https://github.com/kldavis4))
64
+ - Jeff See ([@jeffsee55](https://github.com/jeffsee55))
65
+ - Matt Wicks ([@wicksipedia](https://github.com/wicksipedia))
66
+ - Jack Pettit ([@JackDevAU](https://github.com/JackDevAU))
67
+ - Jord Gui ([@Jord-Gui](https://github.com/Jord-Gui))
68
+ - Nick Curran ([@ncn-ssw](https://github.com/ncn-ssw))
69
+ - Brook Jeynes ([@brookjeynes-ssw](https://github.com/brookjeynes-ssw))
70
+ - Ben Neoh ([@Ben0189](https://github.com/Ben0189))
71
+ - Warwick Leahy ([@leahy268](https://github.com/leahy268))
72
+ - Seth Daily ([@sethdaily ](https://github.com/sethdaily))
73
+ - Josh Berman ([@joshbermanssw](https://github.com/joshbermanssw))
74
+ - Scott Gallant ([@scottgallant](https://github.com/scottgallant))
75
+ - Adam Cogan ([@adamcogan](https://github.com/adamcogan))
76
+
77
+ View our awesome SSW devs at [ssw.com.au/people](https://www.ssw.com.au/people/?skill=%F0%9F%A6%99-TinaCMS).
78
+
79
+ ![](https://res.cloudinary.com/forestry-demo/image/upload/h_85/v1573167387/Favicon.png)
@@ -1,9 +1,10 @@
1
1
  import React from 'react';
2
+ import { Collection } from '@tinacms/schema-tools';
2
3
  import type { TinaCMS } from '@tinacms/toolkit';
3
4
  declare const CollectionCreatePage: () => React.JSX.Element;
4
5
  export declare const RenderForm: ({ cms, collection, folder, templateName, mutationInfo, customDefaults, }: {
5
6
  cms: TinaCMS;
6
- collection: any;
7
+ collection: Collection;
7
8
  folder: any;
8
9
  templateName: any;
9
10
  mutationInfo: any;
@@ -1,6 +1,6 @@
1
1
  import React from 'react';
2
- import { NavigateFunction } from 'react-router-dom';
3
- import { TinaCMS } from '@tinacms/toolkit';
2
+ import { type NavigateFunction } from 'react-router-dom';
3
+ import { type TinaCMS } from '@tinacms/toolkit';
4
4
  import type { CollectionResponse, DocumentSys } from '../types';
5
5
  import type { Collection } from '@tinacms/schema-tools';
6
6
  export declare const handleNavigate: (navigate: NavigateFunction, cms: TinaCMS, collection: CollectionResponse, collectionDefinition: Collection<true>, document: DocumentSys) => Promise<any>;
@@ -1,2 +1,2 @@
1
1
  import type { Cache } from './index';
2
- export declare const NodeCache: (dir: string, fs: any) => Cache;
2
+ export declare const NodeCache: (dir: string) => Promise<Cache>;
package/dist/client.js CHANGED
@@ -14,17 +14,30 @@
14
14
  errorPolicy,
15
15
  cacheDir
16
16
  }) {
17
+ this.initialized = false;
17
18
  this.apiUrl = url;
18
19
  this.readonlyToken = token == null ? void 0 : token.trim();
19
20
  this.queries = queries(this);
20
21
  this.errorPolicy = errorPolicy || "throw";
21
- if (cacheDir && typeof require !== "undefined") {
22
- const { NodeCache } = require("tinacms/dist/cache");
23
- this.cache = NodeCache(cacheDir, require("fs"));
22
+ this.cacheDir = cacheDir || "";
23
+ }
24
+ async init() {
25
+ if (this.initialized) {
26
+ return;
27
+ }
28
+ try {
29
+ if (this.cacheDir && typeof require !== "undefined") {
30
+ const { NodeCache: NodeCache2 } = await Promise.resolve().then(() => nodeCache);
31
+ this.cache = await NodeCache2(this.cacheDir);
32
+ }
33
+ } catch (e) {
34
+ console.error(e);
24
35
  }
36
+ this.initialized = true;
25
37
  }
26
38
  async request({ errorPolicy, ...args }, options) {
27
39
  var _a;
40
+ await this.init();
28
41
  const errorPolicyDefined = errorPolicy || this.errorPolicy;
29
42
  const headers = new HeadersDefined();
30
43
  if (this.readonlyToken) {
@@ -92,6 +105,50 @@
92
105
  const client = new TinaClient(args);
93
106
  return client;
94
107
  }
108
+ const makeCacheDir = async (dir, fs) => {
109
+ const path = await import("path");
110
+ const os = await import("os");
111
+ const parts = dir.split(path.sep).filter(Boolean);
112
+ let cacheDir = dir;
113
+ if (!fs.existsSync(path.join(path.sep, parts[0]))) {
114
+ cacheDir = path.join(os.tmpdir(), parts[parts.length - 1]);
115
+ }
116
+ fs.mkdirSync(cacheDir, { recursive: true });
117
+ return cacheDir;
118
+ };
119
+ const NodeCache = async (dir) => {
120
+ const fs = await import("fs");
121
+ const { createHash } = await import("crypto");
122
+ const cacheDir = await makeCacheDir(dir, fs);
123
+ return {
124
+ makeKey: (key) => {
125
+ const input = key && key instanceof Object ? JSON.stringify(key) : key || "";
126
+ return createHash("sha256").update(input).digest("hex");
127
+ },
128
+ get: async (key) => {
129
+ try {
130
+ const data = await fs.promises.readFile(`${cacheDir}/${key}`, "utf-8");
131
+ return JSON.parse(data);
132
+ } catch (e) {
133
+ if (e.code === "ENOENT") {
134
+ return void 0;
135
+ }
136
+ throw e;
137
+ }
138
+ },
139
+ set: async (key, value) => {
140
+ await fs.promises.writeFile(
141
+ `${cacheDir}/${key}`,
142
+ JSON.stringify(value),
143
+ "utf-8"
144
+ );
145
+ }
146
+ };
147
+ };
148
+ const nodeCache = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
149
+ __proto__: null,
150
+ NodeCache
151
+ }, Symbol.toStringTag, { value: "Module" }));
95
152
  exports2.TINA_HOST = TINA_HOST;
96
153
  exports2.TinaClient = TinaClient;
97
154
  exports2.createClient = createClient;
package/dist/client.mjs CHANGED
@@ -11,17 +11,30 @@ class TinaClient {
11
11
  errorPolicy,
12
12
  cacheDir
13
13
  }) {
14
+ this.initialized = false;
14
15
  this.apiUrl = url;
15
16
  this.readonlyToken = token == null ? void 0 : token.trim();
16
17
  this.queries = queries(this);
17
18
  this.errorPolicy = errorPolicy || "throw";
18
- if (cacheDir && typeof require !== "undefined") {
19
- const { NodeCache } = require("tinacms/dist/cache");
20
- this.cache = NodeCache(cacheDir, require("fs"));
19
+ this.cacheDir = cacheDir || "";
20
+ }
21
+ async init() {
22
+ if (this.initialized) {
23
+ return;
24
+ }
25
+ try {
26
+ if (this.cacheDir && typeof require !== "undefined") {
27
+ const { NodeCache } = await import("./node-cache-2267a9e4.mjs");
28
+ this.cache = await NodeCache(this.cacheDir);
29
+ }
30
+ } catch (e) {
31
+ console.error(e);
21
32
  }
33
+ this.initialized = true;
22
34
  }
23
35
  async request({ errorPolicy, ...args }, options) {
24
36
  var _a;
37
+ await this.init();
25
38
  const errorPolicyDefined = errorPolicy || this.errorPolicy;
26
39
  const headers = new HeadersDefined();
27
40
  if (this.readonlyToken) {