@tinacms/cli 0.60.7 → 0.60.10

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/CHANGELOG.md CHANGED
@@ -1,5 +1,63 @@
1
1
  # tinacms-cli
2
2
 
3
+ ## 0.60.10
4
+
5
+ ### Patch Changes
6
+
7
+ - 6154d12b8: Check for appropriate versions of react and react-dom before initializing with tinacms init
8
+ - 8c23d69a2: Adds an MDX example when you run @tinacms/cli init
9
+ - abf25c673: The schema can now to used on the frontend (optional for now but will be the main path moving forward).
10
+
11
+ ### How to migrate.
12
+
13
+ If you gone though the `tinacms init` process there should be a file called `.tina/components/TinaProvider`. In that file you can import the schema from `schema.ts` and add it to the TinaCMS wrapper component.
14
+
15
+ ```tsx
16
+ import TinaCMS from 'tinacms'
17
+ import schema, { tinaConfig } from '../schema.ts'
18
+
19
+ // Importing the TinaProvider directly into your page will cause Tina to be added to the production bundle.
20
+ // Instead, import the tina/provider/index default export to have it dynamially imported in edit-moode
21
+ /**
22
+ *
23
+ * @private Do not import this directly, please import the dynamic provider instead
24
+ */
25
+ const TinaProvider = ({ children }) => {
26
+ return (
27
+ <TinaCMS {...tinaConfig} schema={schema}>
28
+ {children}
29
+ </TinaCMS>
30
+ )
31
+ }
32
+
33
+ export default TinaProvider
34
+ ```
35
+
36
+ - Updated dependencies [8b3be903f]
37
+ - Updated dependencies [82174ff50]
38
+ - Updated dependencies [a87e1e6fa]
39
+ - Updated dependencies [abf25c673]
40
+ - Updated dependencies [591640db0]
41
+ - Updated dependencies [e8b0de1f7]
42
+ - Updated dependencies [b01f2e382]
43
+ - @tinacms/datalayer@0.1.0
44
+ - @tinacms/graphql@0.59.9
45
+
46
+ ## 0.60.9
47
+
48
+ ### Patch Changes
49
+
50
+ - 048538625: fix: return cms on cmsCallback codegen (to fix broken typing)
51
+ - Updated dependencies [e7b27ba3b]
52
+ - Updated dependencies [11d55f441]
53
+ - @tinacms/graphql@0.59.8
54
+
55
+ ## 0.60.8
56
+
57
+ ### Patch Changes
58
+
59
+ - 919f5cb6c: use standard next script names
60
+
3
61
  ## 0.60.7
4
62
 
5
63
  ### Patch Changes
@@ -10,4 +10,4 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10
10
  See the License for the specific language governing permissions and
11
11
  limitations under the License.
12
12
  */
13
- export declare const defaultSchema = "\nimport { defineSchema, defineConfig } from \"tinacms\";\n\nexport default defineSchema({\n collections: [\n {\n label: \"Blog Posts\",\n name: \"posts\",\n path: \"content/posts\",\n fields: [\n {\n type: \"string\",\n label: \"Title\",\n name: \"title\",\n },\n {\n type: \"string\",\n label: \"Blog Post Body\",\n name: \"body\",\n isBody: true,\n ui: {\n component: \"textarea\"\n },\n },\n ],\n },\n ],\n});\n\n\n\n\n// Your tina config\n// ==============\nconst branch = 'main'\n// When working locally, hit our local filesystem.\n// On a Vercel deployment, hit the Tina Cloud API\nconst apiURL =\n process.env.NODE_ENV == 'development'\n ? 'http://localhost:4001/graphql'\n : `https://content.tinajs.io/content/${process.env.NEXT_PUBLIC_TINA_CLIENT_ID}/github/${branch}`\n\nexport const tinaConfig = defineConfig({\n apiURL,\n cmsCallback: (cms) => {\n // add your CMS callback code here (if you want)\n\n // The Route Mapper\n /**\n * 1. Import `tinacms` and `RouteMappingPlugin`\n **/\n import(\"tinacms\").then(({ RouteMappingPlugin }) => {\n /**\n * 2. Define the `RouteMappingPlugin` see https://tina.io/docs/tinacms-context/#the-routemappingplugin for more details\n **/\n const RouteMapping = new RouteMappingPlugin((collection, document) => {\n return undefined;\n });\n /**\n * 3. Add the `RouteMappingPlugin` to the `cms`.\n **/\n cms.plugins.add(RouteMapping);\n });\n },\n});\n";
13
+ export declare const defaultSchema = "\nimport { defineSchema, defineConfig } from \"tinacms\";\n\nexport default defineSchema({\n collections: [\n {\n label: \"Blog Posts\",\n name: \"posts\",\n path: \"content/posts\",\n fields: [\n {\n type: \"string\",\n label: \"Title\",\n name: \"title\",\n },\n {\n type: \"rich-text\",\n label: \"Blog Post Body\",\n name: \"body\",\n isBody: true,\n templates: [\n {\n name: \"PageSection\",\n label: \"Page Section\",\n fields: [\n {\n type: \"string\",\n name: \"heading\",\n label: \"Heading\",\n },\n {\n type: \"string\",\n name: \"content\",\n label: \"Content\",\n ui: {\n component: \"textarea\"\n }\n }\n ],\n },\n ]\n },\n ],\n },\n ],\n});\n\n\n\n\n// Your tina config\n// ==============\nconst branch = 'main'\n// When working locally, hit our local filesystem.\n// On a Vercel deployment, hit the Tina Cloud API\nconst apiURL =\n process.env.NODE_ENV == 'development'\n ? 'http://localhost:4001/graphql'\n : `https://content.tinajs.io/content/${process.env.NEXT_PUBLIC_TINA_CLIENT_ID}/github/${branch}`\n\nexport const tinaConfig = defineConfig({\n apiURL,\n cmsCallback: (cms) => {\n // add your CMS callback code here (if you want)\n\n // The Route Mapper\n /**\n * 1. Import `tinacms` and `RouteMappingPlugin`\n **/\n import(\"tinacms\").then(({ RouteMappingPlugin }) => {\n /**\n * 2. Define the `RouteMappingPlugin` see https://tina.io/docs/tinacms-context/#the-routemappingplugin for more details\n **/\n const RouteMapping = new RouteMappingPlugin((collection, document) => {\n return undefined;\n });\n /**\n * 3. Add the `RouteMappingPlugin` to the `cms`.\n **/\n cms.plugins.add(RouteMapping);\n });\n\n return cms;\n },\n});\n";
@@ -1,4 +1,7 @@
1
1
  export declare function initTina(ctx: any, next: () => void, options: any): Promise<void>;
2
+ export declare const MIN_REACT_VERSION = ">=16.14.0";
3
+ export declare function checkDeps(ctx: any, next: () => void, options: any): Promise<void>;
4
+ export declare const checkPackage: (packageJSON: any, packageName: any) => boolean;
2
5
  export declare function installDeps(ctx: any, next: () => void, options: any): Promise<void>;
3
6
  export declare function tinaSetup(_ctx: any, next: () => void, _options: any): Promise<void>;
4
7
  export declare function successMessage(ctx: any, next: () => void, options: any): Promise<void>;
@@ -11,6 +11,6 @@ See the License for the specific language governing permissions and
11
11
  limitations under the License.
12
12
  */
13
13
  export declare const adminPage = "import { TinaAdmin } from 'tinacms';\nexport default TinaAdmin;\n";
14
- export declare const blogPost = "---\ntitle: Vote For Pedro\n---\n# Welcome to the blog.\n\n> To edit this site head over to the [`/admin`](/admin) route. Then click the pencil icon in the bottom lefthand corner to start editing \uD83E\uDD99. \n\n# Dixi gaude Arethusa\n\n## Oscula mihi\n\nLorem markdownum numerabilis armentorum platanus, cultros coniunx sibi per\nsilvas, nostris clausit sequemur diverso scopulosque. Fecit tum alta sed non\nfalcato murmura, geminas donata Amyntore, quoque Nox. Invitam inquit, modo\nnocte; ut ignis faciemque manes in imagine sinistra ut mucrone non ramos\nsepulcro supplex. Crescentesque populos motura, fit cumque. Verumque est; retro\nsibi tristia bracchia Aetola telae caruerunt et.\n\n\n## Mutato fefellimus sit demisit aut alterius sollicito\n\nPhaethonteos vestes quem involvite iuvenca; furiali anne: sati totumque,\n**corpora** cum rapacibus nunc! Nervis repetatne, miserabile doleas, deprensum\nhunc, fluctus Threicio, ad urbes, magicaeque, quid. Per credensque series adicis\npoteram [quidem](#)! Iam uni mensas victrix\nvittas ut flumina Satyri adulter; bellum iacet domitae repercusso truncis urnis\nmille rigidi sub taurum.\n\n\n";
14
+ export declare const blogPost = "---\ntitle: Vote For Pedro\n---\n# Welcome to the blog.\n\n> To edit this site head over to the [`/admin`](/admin) route. Then click the pencil icon in the bottom lefthand corner to start editing \uD83E\uDD99. \n\n# Dixi gaude Arethusa\n\n<PageSection heading=\"Oscula mihi\" content=\"Lorem markdownum numerabilis armentorum platanus, cultros coniunx sibi per\nsilvas, nostris clausit sequemur diverso scopulosque. Fecit tum alta sed non\nfalcato murmura, geminas donata Amyntore, quoque Nox. Invitam inquit, modo\nnocte; ut ignis faciemque manes in imagine sinistra ut mucrone non ramos\nsepulcro supplex. Crescentesque populos motura, fit cumque. Verumque est; retro\nsibi tristia bracchia Aetola telae caruerunt et.\"/>\n\n\n## Mutato fefellimus sit demisit aut alterius sollicito\n\nPhaethonteos vestes quem involvite iuvenca; furiali anne: sati totumque,\n**corpora** cum rapacibus nunc! Nervis repetatne, miserabile doleas, deprensum\nhunc, fluctus Threicio, ad urbes, magicaeque, quid. Per credensque series adicis\npoteram [quidem](#)! Iam uni mensas victrix\nvittas ut flumina Satyri adulter; bellum iacet domitae repercusso truncis urnis\nmille rigidi sub taurum.\n\n\n";
15
15
  export declare const nextPostPage: () => string;
16
16
  export declare const AppJsContent: (usingSrc: boolean, extraImports?: string) => string;
package/dist/index.js CHANGED
@@ -114,7 +114,7 @@ var commander = __toModule(require("commander"));
114
114
 
115
115
  // pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/cli/package.json
116
116
  var name = "@tinacms/cli";
117
- var version = "0.60.7";
117
+ var version = "0.60.10";
118
118
 
119
119
  // pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/cli/src/utils/theme.ts
120
120
  var import_chalk = __toModule(require("chalk"));
@@ -417,13 +417,31 @@ export default defineSchema({
417
417
  name: "title",
418
418
  },
419
419
  {
420
- type: "string",
420
+ type: "rich-text",
421
421
  label: "Blog Post Body",
422
422
  name: "body",
423
423
  isBody: true,
424
- ui: {
425
- component: "textarea"
426
- },
424
+ templates: [
425
+ {
426
+ name: "PageSection",
427
+ label: "Page Section",
428
+ fields: [
429
+ {
430
+ type: "string",
431
+ name: "heading",
432
+ label: "Heading",
433
+ },
434
+ {
435
+ type: "string",
436
+ name: "content",
437
+ label: "Content",
438
+ ui: {
439
+ component: "textarea"
440
+ }
441
+ }
442
+ ],
443
+ },
444
+ ]
427
445
  },
428
446
  ],
429
447
  },
@@ -464,6 +482,8 @@ export const tinaConfig = defineConfig({
464
482
  **/
465
483
  cms.plugins.add(RouteMapping);
466
484
  });
485
+
486
+ return cms;
467
487
  },
468
488
  });
469
489
  `;
@@ -838,14 +858,12 @@ title: Vote For Pedro
838
858
 
839
859
  # Dixi gaude Arethusa
840
860
 
841
- ## Oscula mihi
842
-
843
- Lorem markdownum numerabilis armentorum platanus, cultros coniunx sibi per
861
+ <PageSection heading="Oscula mihi" content="Lorem markdownum numerabilis armentorum platanus, cultros coniunx sibi per
844
862
  silvas, nostris clausit sequemur diverso scopulosque. Fecit tum alta sed non
845
863
  falcato murmura, geminas donata Amyntore, quoque Nox. Invitam inquit, modo
846
864
  nocte; ut ignis faciemque manes in imagine sinistra ut mucrone non ramos
847
865
  sepulcro supplex. Crescentesque populos motura, fit cumque. Verumque est; retro
848
- sibi tristia bracchia Aetola telae caruerunt et.
866
+ sibi tristia bracchia Aetola telae caruerunt et."/>
849
867
 
850
868
 
851
869
  ## Mutato fefellimus sit demisit aut alterius sollicito
@@ -866,6 +884,7 @@ var nextPostPage = () => `// THIS FILE HAS BEEN GENERATED WITH THE TINA CLI.
866
884
  import Head from "next/head";
867
885
  import { createGlobalStyle } from "styled-components";
868
886
  import { useTina } from "tinacms/dist/edit-state";
887
+ import { TinaMarkdown } from 'tinacms/dist/rich-text'
869
888
 
870
889
  const query = gql\`
871
890
  query BlogPostQuery($relativePath: String!) {
@@ -911,8 +930,7 @@ var nextPostPage = () => `// THIS FILE HAS BEEN GENERATED WITH THE TINA CLI.
911
930
  text-decoration: underline;
912
931
  }
913
932
  \`;
914
- const defaultMarked = (markdown) => markdown;
915
- // Use the props returned by get static props (this can be deleted when the edit provider and tina-wrapper are moved to _app.js)
933
+
916
934
  const BlogPage = (props) => {
917
935
  const { data } = useTina({
918
936
  query,
@@ -931,12 +949,6 @@ var nextPostPage = () => `// THIS FILE HAS BEEN GENERATED WITH THE TINA CLI.
931
949
  crossOrigin="anonymous"
932
950
  referrerPolicy="no-referrer"
933
951
  />
934
- {/* Marked CDN */}
935
- <script
936
- type="text/javascript"
937
- crossOrigin="anonymous"
938
- src="https://cdnjs.cloudflare.com/ajax/libs/marked/4.0.0/marked.min.js"
939
- />
940
952
  </Head>
941
953
  <div>
942
954
  <div
@@ -947,12 +959,9 @@ var nextPostPage = () => `// THIS FILE HAS BEEN GENERATED WITH THE TINA CLI.
947
959
  <h1 className="text-3xl m-8 text-center leading-8 font-extrabold tracking-tight text-gray-900 sm:text-4xl">
948
960
  {data.getPostsDocument.data.title}
949
961
  </h1>
950
- {/* Convert markdown to html in the browser only */}
951
- {typeof window !== "undefined" && (
952
- <ContentSection
953
- content={window.marked.parse(data.getPostsDocument.data.body)}
954
- ></ContentSection>
955
- )}
962
+ <ContentSection
963
+ content={data.getPostsDocument.data.body}
964
+ ></ContentSection>
956
965
  </div>
957
966
  <div className="bg-green-100 text-center">
958
967
  Lost and looking for a place to start?
@@ -1017,6 +1026,19 @@ var nextPostPage = () => `// THIS FILE HAS BEEN GENERATED WITH THE TINA CLI.
1017
1026
  };
1018
1027
 
1019
1028
  export default BlogPage;
1029
+
1030
+ const PageSection = props => {
1031
+ return (
1032
+ <>
1033
+ <h2>{ props.heading }</h2>
1034
+ <p>{ props.content }</p>
1035
+ </>
1036
+ )
1037
+ }
1038
+
1039
+ const components = {
1040
+ PageSection: PageSection,
1041
+ }
1020
1042
 
1021
1043
  const ContentSection = ({ content }) => {
1022
1044
  return (
@@ -1126,7 +1148,7 @@ var nextPostPage = () => `// THIS FILE HAS BEEN GENERATED WITH THE TINA CLI.
1126
1148
  </div>
1127
1149
  <div className="relative px-4 sm:px-6 lg:px-8">
1128
1150
  <div className="text-lg max-w-prose mx-auto">
1129
- <div dangerouslySetInnerHTML={{ __html: content }}></div>
1151
+ <TinaMarkdown components={components} content={content}/>
1130
1152
  <GlobalStyle />
1131
1153
  </div>
1132
1154
  </div>
@@ -1186,6 +1208,18 @@ const DynamicTina = ({ children }) => {
1186
1208
  export default DynamicTina
1187
1209
  `;
1188
1210
 
1211
+ // pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/cli/src/utils/script-helpers.ts
1212
+ function generateGqlScript(scriptValue) {
1213
+ return `tinacms server:start -c "${scriptValue}"`;
1214
+ }
1215
+ function extendNextScripts(scripts) {
1216
+ return __spreadProps(__spreadValues({}, scripts), {
1217
+ dev: generateGqlScript(scripts.dev || "next dev"),
1218
+ build: generateGqlScript(scripts.build || "next build"),
1219
+ start: generateGqlScript(scripts.start || "next start")
1220
+ });
1221
+ }
1222
+
1189
1223
  // pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/cli/src/cmds/init/index.ts
1190
1224
  function execShellCommand(cmd) {
1191
1225
  const exec = require("child_process").exec;
@@ -1204,6 +1238,60 @@ async function initTina(ctx, next, options) {
1204
1238
  logger.info(successText("Setting up Tina..."));
1205
1239
  next();
1206
1240
  }
1241
+ var MIN_REACT_VERSION = ">=16.14.0";
1242
+ async function checkDeps(ctx, next, options) {
1243
+ const bar = new import_progress.default("Checking dependencies. :prog", 1);
1244
+ const packageJSON = JSON.parse((await import_fs_extra4.default.readFileSync(packageJSONPath)).toString());
1245
+ if (!checkPackage(packageJSON, "react") || !checkPackage(packageJSON, "react-dom")) {
1246
+ const message = `Unable to initialize Tina due to outdated dependencies, try upgrading the following packages:
1247
+ "react@${MIN_REACT_VERSION}"
1248
+ "react-dom@${MIN_REACT_VERSION}"
1249
+
1250
+ Then re-rerun "@tinacms/cli init"`;
1251
+ throw new Error(message);
1252
+ }
1253
+ bar.tick({
1254
+ prog: "\u2705"
1255
+ });
1256
+ logger.level = "fatal";
1257
+ next();
1258
+ }
1259
+ var checkPackage = (packageJSON, packageName) => {
1260
+ let strippedVersion;
1261
+ Object.entries(packageJSON.dependencies).map(([depPackageName, version2]) => {
1262
+ if (depPackageName === packageName) {
1263
+ strippedVersion = version2.replace(/^[^a-zA-Z0-9]*|[^a-zA-Z0-9]*$/g, "");
1264
+ }
1265
+ });
1266
+ return checkVersion(strippedVersion);
1267
+ };
1268
+ var checkVersion = (version2) => {
1269
+ const majorMin = 16;
1270
+ const minorMin = 14;
1271
+ const parts = version2.split(".");
1272
+ const major = Number(parts[0]);
1273
+ const minor = Number(parts[1]);
1274
+ if (parts.length === 1) {
1275
+ if (isNaN(major)) {
1276
+ return true;
1277
+ } else if (major > majorMin) {
1278
+ return true;
1279
+ } else {
1280
+ return false;
1281
+ }
1282
+ }
1283
+ if (major > majorMin) {
1284
+ return true;
1285
+ } else if (major === majorMin) {
1286
+ if (minor >= minorMin) {
1287
+ return true;
1288
+ } else {
1289
+ return false;
1290
+ }
1291
+ } else {
1292
+ return false;
1293
+ }
1294
+ };
1207
1295
  async function installDeps(ctx, next, options) {
1208
1296
  const bar = new import_progress.default("Installing Tina packages. This might take a moment... :prog", 2);
1209
1297
  const deps = ["tinacms", "styled-components", "@tinacms/cli"];
@@ -1219,6 +1307,7 @@ async function installDeps(ctx, next, options) {
1219
1307
  next();
1220
1308
  }
1221
1309
  var baseDir = process.cwd();
1310
+ var packageJSONPath = import_path5.default.join(baseDir, "package.json");
1222
1311
  var blogContentPath = import_path5.default.join(baseDir, "content", "posts");
1223
1312
  var blogPostPath = import_path5.default.join(blogContentPath, "HelloWorld.md");
1224
1313
  var TinaFolder = import_path5.default.join(baseDir, ".tina");
@@ -1276,11 +1365,7 @@ async function tinaSetup(_ctx, next, _options) {
1276
1365
  const pack = JSON.parse((0, import_fs_extra4.readFileSync)(packagePath).toString());
1277
1366
  const oldScripts = pack.scripts || {};
1278
1367
  const newPack = JSON.stringify(__spreadProps(__spreadValues({}, pack), {
1279
- scripts: __spreadProps(__spreadValues({}, oldScripts), {
1280
- "tina-dev": 'yarn tinacms server:start -c "next dev"',
1281
- "tina-build": 'yarn tinacms server:start -c "next build"',
1282
- "tina-start": 'yarn tinacms server:start -c "next start"'
1283
- })
1368
+ scripts: extendNextScripts(oldScripts)
1284
1369
  }), null, 2);
1285
1370
  (0, import_fs_extra4.writeFileSync)(packagePath, newPack);
1286
1371
  const adminPath = import_path5.default.join(pagesPath, "admin.js");
@@ -1294,7 +1379,7 @@ async function tinaSetup(_ctx, next, _options) {
1294
1379
  }
1295
1380
  async function successMessage(ctx, next, options) {
1296
1381
  logger.info(`Tina setup ${import_chalk2.default.underline.green("done")} \u2705
1297
- Start your dev server with ${successText(`yarn tina-dev`)} and go to http://localhost:3000/demo/blog/HelloWorld to ${successText("check it out the page that was created for you")}
1382
+ Start your dev server with ${successText(`yarn dev`)} and go to http://localhost:3000/demo/blog/HelloWorld to ${successText("check it out the page that was created for you")}
1298
1383
  Enjoy Tina \u{1F999} !
1299
1384
  `);
1300
1385
  next();
@@ -1623,6 +1708,7 @@ var baseCmds = [
1623
1708
  options: [experimentalDatalayer, noTelemetryOption],
1624
1709
  description: "Add Tina Cloud to an existing project",
1625
1710
  action: (options) => chain([
1711
+ checkDeps,
1626
1712
  initTina,
1627
1713
  installDeps,
1628
1714
  async (_ctx, next) => {
@@ -0,0 +1,19 @@
1
+ /**
2
+
3
+ Copyright 2021 Forestry.io Holdings, Inc.
4
+
5
+ Licensed under the Apache License, Version 2.0 (the "License");
6
+ you may not use this file except in compliance with the License.
7
+ You may obtain a copy of the License at
8
+
9
+ http://www.apache.org/licenses/LICENSE-2.0
10
+
11
+ Unless required by applicable law or agreed to in writing, software
12
+ distributed under the License is distributed on an "AS IS" BASIS,
13
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ See the License for the specific language governing permissions and
15
+ limitations under the License.
16
+
17
+ */
18
+ export declare function generateGqlScript(scriptValue: any): string;
19
+ export declare function extendNextScripts(scripts: any): any;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tinacms/cli",
3
- "version": "0.60.7",
3
+ "version": "0.60.10",
4
4
  "main": "dist/index.js",
5
5
  "typings": "dist/index.d.ts",
6
6
  "files": [
@@ -57,8 +57,8 @@
57
57
  "@graphql-codegen/visitor-plugin-common": "^2.4.0",
58
58
  "@graphql-tools/graphql-file-loader": "^7.2.0",
59
59
  "@graphql-tools/load": "^7.3.2",
60
- "@tinacms/datalayer": "0.0.2",
61
- "@tinacms/graphql": "0.59.7",
60
+ "@tinacms/datalayer": "0.1.0",
61
+ "@tinacms/graphql": "0.59.9",
62
62
  "@tinacms/metrics": "0.0.2",
63
63
  "@yarnpkg/esbuild-plugin-pnp": "^2.0.1-rc.3",
64
64
  "add": "^2.0.6",