@tinacms/cli 0.60.9 → 0.60.12

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,75 @@
1
1
  # tinacms-cli
2
2
 
3
+ ## 0.60.12
4
+
5
+ ### Patch Changes
6
+
7
+ - ef450a53a: - Update tinacms CLI to support schemaFileType option (default 'ts') to allow user to specify the schema file type
8
+ - Update telemetry module to optionally check NO_TELEMETRY environment variable for disabling telemetry
9
+ - 81b729c24: Update formatting of cli init outputs
10
+ - 558cc4368: Make schema init platform-aware and refactor database put requests
11
+ - Updated dependencies [4da32454b]
12
+ - Updated dependencies [921709a7e]
13
+ - Updated dependencies [ef450a53a]
14
+ - Updated dependencies [a2906d6fe]
15
+ - Updated dependencies [558cc4368]
16
+ - Updated dependencies [06666d39f]
17
+ - Updated dependencies [3e2d9e43a]
18
+ - @tinacms/graphql@0.59.11
19
+ - @tinacms/schema-tools@0.0.3
20
+ - @tinacms/metrics@0.0.3
21
+ - @tinacms/datalayer@0.1.1
22
+
23
+ ## 0.60.11
24
+
25
+ ### Patch Changes
26
+
27
+ - Updated dependencies [cf33bcec1]
28
+ - @tinacms/graphql@0.59.10
29
+
30
+ ## 0.60.10
31
+
32
+ ### Patch Changes
33
+
34
+ - 6154d12b8: Check for appropriate versions of react and react-dom before initializing with tinacms init
35
+ - 8c23d69a2: Adds an MDX example when you run @tinacms/cli init
36
+ - abf25c673: The schema can now to used on the frontend (optional for now but will be the main path moving forward).
37
+
38
+ ### How to migrate.
39
+
40
+ 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.
41
+
42
+ ```tsx
43
+ import TinaCMS from 'tinacms'
44
+ import schema, { tinaConfig } from '../schema.ts'
45
+
46
+ // Importing the TinaProvider directly into your page will cause Tina to be added to the production bundle.
47
+ // Instead, import the tina/provider/index default export to have it dynamially imported in edit-moode
48
+ /**
49
+ *
50
+ * @private Do not import this directly, please import the dynamic provider instead
51
+ */
52
+ const TinaProvider = ({ children }) => {
53
+ return (
54
+ <TinaCMS {...tinaConfig} schema={schema}>
55
+ {children}
56
+ </TinaCMS>
57
+ )
58
+ }
59
+
60
+ export default TinaProvider
61
+ ```
62
+
63
+ - Updated dependencies [8b3be903f]
64
+ - Updated dependencies [82174ff50]
65
+ - Updated dependencies [a87e1e6fa]
66
+ - Updated dependencies [abf25c673]
67
+ - Updated dependencies [591640db0]
68
+ - Updated dependencies [e8b0de1f7]
69
+ - Updated dependencies [b01f2e382]
70
+ - @tinacms/datalayer@0.1.0
71
+ - @tinacms/graphql@0.59.9
72
+
3
73
  ## 0.60.9
4
74
 
5
75
  ### 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 return cms;\n },\n});\n";
13
+ export declare const defaultSchema: (sep: string) => string;
@@ -12,5 +12,7 @@ limitations under the License.
12
12
  */
13
13
  import type { TinaCloudSchema } from '@tinacms/graphql';
14
14
  export declare const resetGeneratedFolder: () => Promise<void>;
15
- export declare const compile: (_ctx: any, _next: any) => Promise<void>;
15
+ export declare const compile: (_ctx: any, _next: any, options?: {
16
+ schemaFileType: string;
17
+ }) => Promise<void>;
16
18
  export declare const defineSchema: (config: TinaCloudSchema) => TinaCloudSchema;
@@ -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>;
@@ -1,16 +1,4 @@
1
- /**
2
- Copyright 2021 Forestry.io Holdings, Inc.
3
- Licensed under the Apache License, Version 2.0 (the "License");
4
- you may not use this file except in compliance with the License.
5
- You may obtain a copy of the License at
6
- http://www.apache.org/licenses/LICENSE-2.0
7
- Unless required by applicable law or agreed to in writing, software
8
- distributed under the License is distributed on an "AS IS" BASIS,
9
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10
- See the License for the specific language governing permissions and
11
- limitations under the License.
12
- */
13
1
  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";
2
+ 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
3
  export declare const nextPostPage: () => string;
16
4
  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.9";
117
+ var version = "0.60.12";
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"));
@@ -401,7 +401,7 @@ var import_fs_extra3 = __toModule(require("fs-extra"));
401
401
  var import_esbuild = __toModule(require("esbuild"));
402
402
 
403
403
  // pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/cli/src/cmds/compile/defaultSchema.ts
404
- var defaultSchema = `
404
+ var defaultSchema = (sep) => `
405
405
  import { defineSchema, defineConfig } from "tinacms";
406
406
 
407
407
  export default defineSchema({
@@ -409,7 +409,7 @@ export default defineSchema({
409
409
  {
410
410
  label: "Blog Posts",
411
411
  name: "posts",
412
- path: "content/posts",
412
+ path: "content${sep}posts",
413
413
  fields: [
414
414
  {
415
415
  type: "string",
@@ -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
  },
@@ -512,14 +530,18 @@ var ExecuteSchemaError = class extends Error {
512
530
  }
513
531
  };
514
532
  var handleServerErrors = (e) => {
515
- if (e instanceof BuildSchemaError) {
533
+ if (e.name === "BuildSchemaError") {
516
534
  logger.error(`${dangerText("ERROR: your schema was not successfully built: see https://tina.io/docs/errors/esbuild-error/ for more details")}
517
535
  Error Message Below
518
536
  ${e}`);
519
- } else if (e instanceof ExecuteSchemaError) {
537
+ } else if (e.name === "ExecuteSchemaError") {
520
538
  logger.error(`${dangerText("ERROR: your schema was not successfully executed: see https://tina.io/docs/errors/esbuild-error/ for more details")}
521
539
  Error Message Below
522
540
  ${e}`);
541
+ } else if (e.name === "TinaSchemaValidationError") {
542
+ logger.error(`${dangerText("ERROR: your schema was not successfully validated: see https://tina.io/docs/schema/ for instructions on how to setup a schema")}
543
+ Error Message Below
544
+ ${e}`);
523
545
  } else {
524
546
  logger.info(dangerText("Compilation failed with errors. Server has not been restarted.") + ` see error below
525
547
  ${e.message}`);
@@ -546,8 +568,16 @@ var resetGeneratedFolder = async () => {
546
568
  var cleanup = async ({ tinaTempPath: tinaTempPath2 }) => {
547
569
  await import_fs_extra3.default.remove(tinaTempPath2);
548
570
  };
549
- var compile = async (_ctx, _next) => {
571
+ var compile = async (_ctx, _next, options = { schemaFileType: "ts" }) => {
550
572
  logger.info(logText("Compiling..."));
573
+ const { schemaFileType: requestedSchemaFileType = "ts" } = options;
574
+ const schemaFileType2 = (requestedSchemaFileType === "ts" || requestedSchemaFileType === "tsx") && "ts" || (requestedSchemaFileType === "js" || requestedSchemaFileType === "jsx") && "js";
575
+ if (!schemaFileType2) {
576
+ throw new Error(`Requested schema file type '${requestedSchemaFileType}' is not valid. Supported schema file types: 'ts, js, tsx, jsx'`);
577
+ }
578
+ if (_ctx) {
579
+ _ctx.schemaFileType = schemaFileType2;
580
+ }
551
581
  let schemaExists = true;
552
582
  try {
553
583
  getSchemaPath({ projectDir: tinaPath });
@@ -556,12 +586,12 @@ var compile = async (_ctx, _next) => {
556
586
  }
557
587
  if (!schemaExists) {
558
588
  logger.info(dangerText(`
559
- .tina/schema.ts not found, Creating one for you...
589
+ .tina/schema.${schemaFileType2} not found, Creating one for you...
560
590
  See Documentation: https://tina.io/docs/tina-cloud/cli/#getting-started"
561
591
  `));
562
- const file = import_path3.default.join(tinaPath, "schema.ts");
592
+ const file = import_path3.default.join(tinaPath, `schema.${schemaFileType2}`);
563
593
  await import_fs_extra3.default.ensureFile(file);
564
- await import_fs_extra3.default.writeFile(file, defaultSchema);
594
+ await import_fs_extra3.default.writeFile(file, defaultSchema(import_path3.default.sep));
565
595
  }
566
596
  try {
567
597
  await transpile(tinaPath, tinaTempPath);
@@ -581,6 +611,11 @@ var compile = async (_ctx, _next) => {
581
611
  await cleanup({ tinaTempPath });
582
612
  } catch (e) {
583
613
  await cleanup({ tinaTempPath });
614
+ if (e instanceof Error) {
615
+ if (e.name === "TinaSchemaValidationError") {
616
+ throw e;
617
+ }
618
+ }
584
619
  throw new ExecuteSchemaError(e);
585
620
  }
586
621
  };
@@ -820,14 +855,8 @@ stack: ${code.stack || "No stack was provided"}`);
820
855
  }
821
856
  }
822
857
 
823
- // pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/cli/src/cmds/init/index.ts
824
- var import_fs_extra4 = __toModule(require("fs-extra"));
825
- var import_path5 = __toModule(require("path"));
826
- var import_progress = __toModule(require("progress"));
827
- var import_prompts = __toModule(require("prompts"));
828
- var import_metrics2 = __toModule(require("@tinacms/metrics"));
829
-
830
858
  // pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/cli/src/cmds/init/setup-files/index.ts
859
+ var import_chalk2 = __toModule(require("chalk"));
831
860
  var adminPage = `import { TinaAdmin } from 'tinacms';
832
861
  export default TinaAdmin;
833
862
  `;
@@ -840,14 +869,12 @@ title: Vote For Pedro
840
869
 
841
870
  # Dixi gaude Arethusa
842
871
 
843
- ## Oscula mihi
844
-
845
- Lorem markdownum numerabilis armentorum platanus, cultros coniunx sibi per
872
+ <PageSection heading="Oscula mihi" content="Lorem markdownum numerabilis armentorum platanus, cultros coniunx sibi per
846
873
  silvas, nostris clausit sequemur diverso scopulosque. Fecit tum alta sed non
847
874
  falcato murmura, geminas donata Amyntore, quoque Nox. Invitam inquit, modo
848
875
  nocte; ut ignis faciemque manes in imagine sinistra ut mucrone non ramos
849
876
  sepulcro supplex. Crescentesque populos motura, fit cumque. Verumque est; retro
850
- sibi tristia bracchia Aetola telae caruerunt et.
877
+ sibi tristia bracchia Aetola telae caruerunt et."/>
851
878
 
852
879
 
853
880
  ## Mutato fefellimus sit demisit aut alterius sollicito
@@ -868,6 +895,7 @@ var nextPostPage = () => `// THIS FILE HAS BEEN GENERATED WITH THE TINA CLI.
868
895
  import Head from "next/head";
869
896
  import { createGlobalStyle } from "styled-components";
870
897
  import { useTina } from "tinacms/dist/edit-state";
898
+ import { TinaMarkdown } from 'tinacms/dist/rich-text'
871
899
 
872
900
  const query = gql\`
873
901
  query BlogPostQuery($relativePath: String!) {
@@ -913,8 +941,7 @@ var nextPostPage = () => `// THIS FILE HAS BEEN GENERATED WITH THE TINA CLI.
913
941
  text-decoration: underline;
914
942
  }
915
943
  \`;
916
- const defaultMarked = (markdown) => markdown;
917
- // Use the props returned by get static props (this can be deleted when the edit provider and tina-wrapper are moved to _app.js)
944
+
918
945
  const BlogPage = (props) => {
919
946
  const { data } = useTina({
920
947
  query,
@@ -933,12 +960,6 @@ var nextPostPage = () => `// THIS FILE HAS BEEN GENERATED WITH THE TINA CLI.
933
960
  crossOrigin="anonymous"
934
961
  referrerPolicy="no-referrer"
935
962
  />
936
- {/* Marked CDN */}
937
- <script
938
- type="text/javascript"
939
- crossOrigin="anonymous"
940
- src="https://cdnjs.cloudflare.com/ajax/libs/marked/4.0.0/marked.min.js"
941
- />
942
963
  </Head>
943
964
  <div>
944
965
  <div
@@ -949,12 +970,9 @@ var nextPostPage = () => `// THIS FILE HAS BEEN GENERATED WITH THE TINA CLI.
949
970
  <h1 className="text-3xl m-8 text-center leading-8 font-extrabold tracking-tight text-gray-900 sm:text-4xl">
950
971
  {data.getPostsDocument.data.title}
951
972
  </h1>
952
- {/* Convert markdown to html in the browser only */}
953
- {typeof window !== "undefined" && (
954
- <ContentSection
955
- content={window.marked.parse(data.getPostsDocument.data.body)}
956
- ></ContentSection>
957
- )}
973
+ <ContentSection
974
+ content={data.getPostsDocument.data.body}
975
+ ></ContentSection>
958
976
  </div>
959
977
  <div className="bg-green-100 text-center">
960
978
  Lost and looking for a place to start?
@@ -1019,6 +1037,19 @@ var nextPostPage = () => `// THIS FILE HAS BEEN GENERATED WITH THE TINA CLI.
1019
1037
  };
1020
1038
 
1021
1039
  export default BlogPage;
1040
+
1041
+ const PageSection = props => {
1042
+ return (
1043
+ <>
1044
+ <h2>{ props.heading }</h2>
1045
+ <p>{ props.content }</p>
1046
+ </>
1047
+ )
1048
+ }
1049
+
1050
+ const components = {
1051
+ PageSection: PageSection,
1052
+ }
1022
1053
 
1023
1054
  const ContentSection = ({ content }) => {
1024
1055
  return (
@@ -1128,7 +1159,7 @@ var nextPostPage = () => `// THIS FILE HAS BEEN GENERATED WITH THE TINA CLI.
1128
1159
  </div>
1129
1160
  <div className="relative px-4 sm:px-6 lg:px-8">
1130
1161
  <div className="text-lg max-w-prose mx-auto">
1131
- <div dangerouslySetInnerHTML={{ __html: content }}></div>
1162
+ <TinaMarkdown components={components} content={content}/>
1132
1163
  <GlobalStyle />
1133
1164
  </div>
1134
1165
  </div>
@@ -1137,23 +1168,22 @@ var nextPostPage = () => `// THIS FILE HAS BEEN GENERATED WITH THE TINA CLI.
1137
1168
  };
1138
1169
 
1139
1170
  `;
1140
- var AppJsContent = (usingSrc, extraImports) => `import Tina from '${usingSrc ? "../" : ""}../.tina/components/TinaDynamicProvider.js'
1171
+ var AppJsContent = (usingSrc, extraImports) => {
1172
+ const importLine = import_chalk2.default.green(`+ import Tina from '${usingSrc ? "../" : ""}../.tina/components/TinaDynamicProvider.js'`);
1173
+ return `${importLine}
1174
+ ${extraImports || ""}
1141
1175
 
1142
- ${extraImports || ""}
1143
- const App = ({ Component, pageProps }) => {
1176
+ const App = ({ Component, pageProps }) => {
1144
1177
  return (
1145
- <Tina>
1146
- <Component {...pageProps} />
1147
- </Tina>
1178
+ ${import_chalk2.default.green("+ <Tina>")}
1179
+ <Component {...pageProps} />
1180
+ ${import_chalk2.default.green("+ </Tina>")}
1148
1181
  )
1149
1182
  }
1150
-
1183
+
1151
1184
  export default App
1152
-
1153
1185
  `;
1154
-
1155
- // pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/cli/src/cmds/init/index.ts
1156
- var import_chalk2 = __toModule(require("chalk"));
1186
+ };
1157
1187
 
1158
1188
  // pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/cli/src/cmds/init/setup-files/tinaProvider.ts
1159
1189
  var TinaProvider = `import TinaCMS from 'tinacms'
@@ -1201,6 +1231,12 @@ function extendNextScripts(scripts) {
1201
1231
  }
1202
1232
 
1203
1233
  // pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/cli/src/cmds/init/index.ts
1234
+ var import_fs_extra4 = __toModule(require("fs-extra"));
1235
+ var import_progress = __toModule(require("progress"));
1236
+ var import_metrics2 = __toModule(require("@tinacms/metrics"));
1237
+ var import_chalk3 = __toModule(require("chalk"));
1238
+ var import_path5 = __toModule(require("path"));
1239
+ var import_prompts = __toModule(require("prompts"));
1204
1240
  function execShellCommand(cmd) {
1205
1241
  const exec = require("child_process").exec;
1206
1242
  return new Promise((resolve2, _reject) => {
@@ -1214,10 +1250,69 @@ function execShellCommand(cmd) {
1214
1250
  }
1215
1251
  async function initTina(ctx, next, options) {
1216
1252
  const telemetry = new import_metrics2.Telemetry({ disabled: options.noTelemetry });
1217
- await telemetry.submitRecord({ event: { name: "tinacms:cli:init:invoke" } });
1253
+ await telemetry.submitRecord({
1254
+ event: {
1255
+ name: "tinacms:cli:init:invoke",
1256
+ schemaFileType: options.schemaFileType || "ts"
1257
+ }
1258
+ });
1218
1259
  logger.info(successText("Setting up Tina..."));
1219
1260
  next();
1220
1261
  }
1262
+ var MIN_REACT_VERSION = ">=16.14.0";
1263
+ async function checkDeps(ctx, next, options) {
1264
+ const bar = new import_progress.default("Checking dependencies. :prog", 1);
1265
+ const packageJSON = JSON.parse((await import_fs_extra4.default.readFileSync(packageJSONPath)).toString());
1266
+ if (!checkPackage(packageJSON, "react") || !checkPackage(packageJSON, "react-dom")) {
1267
+ const message = `Unable to initialize Tina due to outdated dependencies, try upgrading the following packages:
1268
+ "react@${MIN_REACT_VERSION}"
1269
+ "react-dom@${MIN_REACT_VERSION}"
1270
+
1271
+ Then re-rerun "@tinacms/cli init"`;
1272
+ throw new Error(message);
1273
+ }
1274
+ bar.tick({
1275
+ prog: "\u2705"
1276
+ });
1277
+ logger.level = "fatal";
1278
+ next();
1279
+ }
1280
+ var checkPackage = (packageJSON, packageName) => {
1281
+ let strippedVersion;
1282
+ Object.entries(packageJSON.dependencies).map(([depPackageName, version2]) => {
1283
+ if (depPackageName === packageName) {
1284
+ strippedVersion = version2.replace(/^[^a-zA-Z0-9]*|[^a-zA-Z0-9]*$/g, "");
1285
+ }
1286
+ });
1287
+ return checkVersion(strippedVersion);
1288
+ };
1289
+ var checkVersion = (version2) => {
1290
+ const majorMin = 16;
1291
+ const minorMin = 14;
1292
+ const parts = version2.split(".");
1293
+ const major = Number(parts[0]);
1294
+ const minor = Number(parts[1]);
1295
+ if (parts.length === 1) {
1296
+ if (isNaN(major)) {
1297
+ return true;
1298
+ } else if (major > majorMin) {
1299
+ return true;
1300
+ } else {
1301
+ return false;
1302
+ }
1303
+ }
1304
+ if (major > majorMin) {
1305
+ return true;
1306
+ } else if (major === majorMin) {
1307
+ if (minor >= minorMin) {
1308
+ return true;
1309
+ } else {
1310
+ return false;
1311
+ }
1312
+ } else {
1313
+ return false;
1314
+ }
1315
+ };
1221
1316
  async function installDeps(ctx, next, options) {
1222
1317
  const bar = new import_progress.default("Installing Tina packages. This might take a moment... :prog", 2);
1223
1318
  const deps = ["tinacms", "styled-components", "@tinacms/cli"];
@@ -1233,6 +1328,7 @@ async function installDeps(ctx, next, options) {
1233
1328
  next();
1234
1329
  }
1235
1330
  var baseDir = process.cwd();
1331
+ var packageJSONPath = import_path5.default.join(baseDir, "package.json");
1236
1332
  var blogContentPath = import_path5.default.join(baseDir, "content", "posts");
1237
1333
  var blogPostPath = import_path5.default.join(blogContentPath, "HelloWorld.md");
1238
1334
  var TinaFolder = import_path5.default.join(baseDir, ".tina");
@@ -1240,7 +1336,7 @@ var componentFolder = import_path5.default.join(TinaFolder, "components");
1240
1336
  var TinaProviderPath = import_path5.default.join(componentFolder, "TinaProvider.js");
1241
1337
  var TinaDynamicProvider = import_path5.default.join(componentFolder, "TinaDynamicProvider.js");
1242
1338
  async function tinaSetup(_ctx, next, _options) {
1243
- const useingSrc = import_fs_extra4.default.pathExistsSync(import_path5.default.join(baseDir, "src"));
1339
+ const usingSrc = import_fs_extra4.default.pathExistsSync(import_path5.default.join(baseDir, "src"));
1244
1340
  if (!import_fs_extra4.default.pathExistsSync(blogPostPath)) {
1245
1341
  logger.info(logText("Adding a content folder..."));
1246
1342
  import_fs_extra4.default.mkdirpSync(blogContentPath);
@@ -1248,23 +1344,24 @@ async function tinaSetup(_ctx, next, _options) {
1248
1344
  }
1249
1345
  if (!import_fs_extra4.default.existsSync(TinaProviderPath) && !import_fs_extra4.default.existsSync(TinaDynamicProvider)) {
1250
1346
  import_fs_extra4.default.mkdirpSync(componentFolder);
1251
- import_fs_extra4.default.writeFileSync(TinaProviderPath, TinaProvider);
1347
+ import_fs_extra4.default.writeFileSync(TinaProviderPath, TinaProvider.replace(/'\.\.\/schema\.ts'/, `'../schema.${_ctx.schemaFileType || "ts"}'`));
1252
1348
  import_fs_extra4.default.writeFileSync(TinaDynamicProvider, TinaProviderDynamic);
1253
1349
  }
1254
1350
  logger.level = "info";
1255
- const pagesPath = import_path5.default.join(baseDir, useingSrc ? "src" : "", "pages");
1351
+ const pagesPath = import_path5.default.join(baseDir, usingSrc ? "src" : "", "pages");
1256
1352
  const appPath = import_path5.default.join(pagesPath, "_app.js");
1257
1353
  const appPathTS = import_path5.default.join(pagesPath, "_app.tsx");
1258
1354
  const appExtension = import_fs_extra4.default.existsSync(appPath) ? ".js" : ".tsx";
1259
1355
  if (!import_fs_extra4.default.pathExistsSync(appPath) && !import_fs_extra4.default.pathExistsSync(appPathTS)) {
1260
1356
  logger.info(logText("Adding _app.js ... \u2705"));
1261
- import_fs_extra4.default.writeFileSync(appPath, AppJsContent(useingSrc));
1357
+ import_fs_extra4.default.writeFileSync(appPath, AppJsContent(usingSrc));
1262
1358
  } else {
1263
1359
  const override = await (0, import_prompts.default)({
1264
1360
  name: "res",
1265
1361
  type: "confirm",
1266
- message: `do you want us to ${import_chalk2.default.bold(`override`)} your _app${appExtension}?`
1362
+ message: `do you want us to ${import_chalk3.default.bold(`override`)} your _app${appExtension}?`
1267
1363
  });
1364
+ _ctx.overrideApp = override.res;
1268
1365
  if (override.res) {
1269
1366
  logger.info(logText(`Adding _app${appExtension} ... \u2705`));
1270
1367
  const appPathWithExtension = import_path5.default.join(pagesPath, `_app${appExtension}`);
@@ -1273,10 +1370,7 @@ async function tinaSetup(_ctx, next, _options) {
1273
1370
  ...fileContent.toString().matchAll(/^.*import.*\.css("|').*$/gm)
1274
1371
  ];
1275
1372
  const primaryMatches = matches.map((x) => x[0]);
1276
- import_fs_extra4.default.writeFileSync(appPathWithExtension, AppJsContent(useingSrc, primaryMatches.join("\n")));
1277
- } else {
1278
- logger.info(dangerText(`Heads up, to enable live-editing you'll need to wrap your page or site in Tina:
1279
- `, warnText(AppJsContent(useingSrc))));
1373
+ import_fs_extra4.default.writeFileSync(appPathWithExtension, AppJsContent(usingSrc, primaryMatches.join("\n")));
1280
1374
  }
1281
1375
  }
1282
1376
  const tinaBlogPagePath = import_path5.default.join(pagesPath, "demo", "blog");
@@ -1303,10 +1397,26 @@ async function tinaSetup(_ctx, next, _options) {
1303
1397
  next();
1304
1398
  }
1305
1399
  async function successMessage(ctx, next, options) {
1306
- logger.info(`Tina setup ${import_chalk2.default.underline.green("done")} \u2705
1307
- 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")}
1308
- Enjoy Tina \u{1F999} !
1400
+ const usingSrc = import_fs_extra4.default.pathExistsSync(import_path5.default.join(baseDir, "src"));
1401
+ logger.info(`Tina setup ${import_chalk3.default.underline.green("done")} \u2705
1402
+ `);
1403
+ logger.info("Next Steps: \n");
1404
+ if (!ctx.overrideApp) {
1405
+ logger.info(`${import_chalk3.default.bold("Add the Tina wrapper")}`);
1406
+ logger.info(`\u26A0\uFE0F Before using Tina, you will NEED to add the Tina wrapper to your _app.jsx
1407
+ `);
1408
+ logger.info(`${AppJsContent(usingSrc)}`);
1409
+ }
1410
+ logger.info(`${import_chalk3.default.bold("Run your site with Tina")}`);
1411
+ logger.info(` yarn dev
1412
+ `);
1413
+ logger.info(`${import_chalk3.default.bold("Start Editing")}`);
1414
+ logger.info(` Go to 'http://localhost:3000/admin'
1309
1415
  `);
1416
+ logger.info(`${import_chalk3.default.bold("Read the docs")}`);
1417
+ logger.info(` Check out 'https://tina.io/docs/introduction/tina-init/#adding-tina' for help getting started with Tina
1418
+ `);
1419
+ logger.info(`Enjoy Tina! \u{1F999}`);
1310
1420
  next();
1311
1421
  }
1312
1422
 
@@ -1318,7 +1428,7 @@ var import_datalayer3 = __toModule(require("@tinacms/datalayer"));
1318
1428
  var import_graphql8 = __toModule(require("@tinacms/graphql"));
1319
1429
  var import_path6 = __toModule(require("path"));
1320
1430
  var import_graphql9 = __toModule(require("@tinacms/graphql"));
1321
- var import_chalk3 = __toModule(require("chalk"));
1431
+ var import_chalk4 = __toModule(require("chalk"));
1322
1432
  var auditCollection = async (args) => {
1323
1433
  let warning = false;
1324
1434
  const { collection, database, rootPath: rootPath2 } = args;
@@ -1352,7 +1462,7 @@ var auditCollection = async (args) => {
1352
1462
  const node = x.node;
1353
1463
  if (node.sys.extension.replace(".", "") !== format) {
1354
1464
  warning = true;
1355
- logger.warn(import_chalk3.default.yellowBright(`WARNING: there is a file with extension \`${node.sys.extension}\` but in your schema it is defined to be \`.${format}\`
1465
+ logger.warn(import_chalk4.default.yellowBright(`WARNING: there is a file with extension \`${node.sys.extension}\` but in your schema it is defined to be \`.${format}\`
1356
1466
 
1357
1467
  location: ${import_path6.default.join(rootPath2, node.sys.path)}`));
1358
1468
  }
@@ -1438,7 +1548,7 @@ var auditDocuments = async (args) => {
1438
1548
  if (mutationRes.errors) {
1439
1549
  mutationRes.errors.forEach((err) => {
1440
1550
  error = true;
1441
- logger.error(import_chalk3.default.red(err.message));
1551
+ logger.error(import_chalk4.default.red(err.message));
1442
1552
  });
1443
1553
  }
1444
1554
  }
@@ -1489,7 +1599,7 @@ function filterObject(obj) {
1489
1599
  }
1490
1600
 
1491
1601
  // pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/cli/src/cmds/audit/index.ts
1492
- var import_chalk4 = __toModule(require("chalk"));
1602
+ var import_chalk5 = __toModule(require("chalk"));
1493
1603
  var import_prompts2 = __toModule(require("prompts"));
1494
1604
  var import_metrics3 = __toModule(require("@tinacms/metrics"));
1495
1605
  var rootPath = process.cwd();
@@ -1503,7 +1613,7 @@ var audit = async (ctx, next, options) => {
1503
1613
  }
1504
1614
  });
1505
1615
  if (options.clean) {
1506
- logger.info(`You are using the \`--clean\` option. This will modify your content as if a user is submitting a form. Before running this you should have a ${import_chalk4.default.bold("clean git tree")} so unwanted changes can be undone.
1616
+ logger.info(`You are using the \`--clean\` option. This will modify your content as if a user is submitting a form. Before running this you should have a ${import_chalk5.default.bold("clean git tree")} so unwanted changes can be undone.
1507
1617
 
1508
1618
  `);
1509
1619
  const res = await (0, import_prompts2.default)({
@@ -1512,12 +1622,12 @@ var audit = async (ctx, next, options) => {
1512
1622
  message: `Do you want to continue?`
1513
1623
  });
1514
1624
  if (!res.useClean) {
1515
- logger.warn(import_chalk4.default.yellowBright("\u26A0\uFE0F Audit not complete"));
1625
+ logger.warn(import_chalk5.default.yellowBright("\u26A0\uFE0F Audit not complete"));
1516
1626
  process.exit(0);
1517
1627
  }
1518
1628
  }
1519
1629
  if (options.useDefaultValues && !options.clean) {
1520
- logger.warn(import_chalk4.default.yellowBright("WARNING: using the `--useDefaultValues` without the `--clean` flag has no effect. Please re-run audit and add the `--clean` flag"));
1630
+ logger.warn(import_chalk5.default.yellowBright("WARNING: using the `--useDefaultValues` without the `--clean` flag has no effect. Please re-run audit and add the `--clean` flag"));
1521
1631
  }
1522
1632
  const bridge = options.clean ? new import_datalayer3.FilesystemBridge(rootPath) : new import_datalayer3.AuditFileSystemBridge(rootPath);
1523
1633
  const store = options.clean ? new import_datalayer3.FilesystemStore({ rootPath }) : new import_datalayer3.AuditFilesystemStore({ rootPath });
@@ -1549,17 +1659,17 @@ var audit = async (ctx, next, options) => {
1549
1659
  };
1550
1660
  var printFinalMessage = async (ctx, next, _options) => {
1551
1661
  if (ctx.error) {
1552
- logger.error(import_chalk4.default.redBright(`\u203C\uFE0F Audit ${import_chalk4.default.bold("failed")} with errors`));
1662
+ logger.error(import_chalk5.default.redBright(`\u203C\uFE0F Audit ${import_chalk5.default.bold("failed")} with errors`));
1553
1663
  } else if (ctx.warning) {
1554
- logger.warn(import_chalk4.default.yellowBright("\u26A0\uFE0F Audit passed with warnings"));
1664
+ logger.warn(import_chalk5.default.yellowBright("\u26A0\uFE0F Audit passed with warnings"));
1555
1665
  } else {
1556
- logger.info(import_chalk4.default.greenBright("\u2705 Audit passed"));
1666
+ logger.info(import_chalk5.default.greenBright("\u2705 Audit passed"));
1557
1667
  }
1558
1668
  next();
1559
1669
  };
1560
1670
 
1561
1671
  // pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/cli/src/cmds/baseCmds.ts
1562
- var import_chalk5 = __toModule(require("chalk"));
1672
+ var import_chalk6 = __toModule(require("chalk"));
1563
1673
  var CMD_GEN_TYPES = "schema:types";
1564
1674
  var CMD_START_SERVER = "server:start";
1565
1675
  var CMD_COMPILE_MODELS = "schema:compile";
@@ -1573,6 +1683,10 @@ var experimentalDatalayer = {
1573
1683
  name: "--experimentalData",
1574
1684
  description: "Build the server with additional data querying capabilities"
1575
1685
  };
1686
+ var schemaFileType = {
1687
+ name: "--schemaFileType [fileType]",
1688
+ description: "The file type to use for the Tina schema"
1689
+ };
1576
1690
  var subCommand = {
1577
1691
  name: "-c, --command <command>",
1578
1692
  description: "The sub-command to run"
@@ -1630,13 +1744,14 @@ var baseCmds = [
1630
1744
  },
1631
1745
  {
1632
1746
  command: INIT,
1633
- options: [experimentalDatalayer, noTelemetryOption],
1747
+ options: [experimentalDatalayer, noTelemetryOption, schemaFileType],
1634
1748
  description: "Add Tina Cloud to an existing project",
1635
1749
  action: (options) => chain([
1750
+ checkDeps,
1636
1751
  initTina,
1637
1752
  installDeps,
1638
- async (_ctx, next) => {
1639
- await compile(_ctx, next);
1753
+ async (_ctx, next, options2) => {
1754
+ await compile(_ctx, next, options2);
1640
1755
  next();
1641
1756
  },
1642
1757
  attachSchema,
@@ -1655,14 +1770,14 @@ var baseCmds = [
1655
1770
  next();
1656
1771
  },
1657
1772
  async (_ctx, next) => {
1658
- await compile(_ctx, next);
1773
+ await compile(_ctx, next, options);
1659
1774
  next();
1660
1775
  },
1661
1776
  attachSchema,
1662
1777
  genTypes,
1663
1778
  async (_ctx, next) => {
1664
1779
  logger.level = "info";
1665
- logger.info(import_chalk5.default.hex("#eb6337").bgWhite("Welcome to tina audit \u{1F999}"));
1780
+ logger.info(import_chalk6.default.hex("#eb6337").bgWhite("Welcome to tina audit \u{1F999}"));
1666
1781
  next();
1667
1782
  },
1668
1783
  audit,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tinacms/cli",
3
- "version": "0.60.9",
3
+ "version": "0.60.12",
4
4
  "main": "dist/index.js",
5
5
  "typings": "dist/index.d.ts",
6
6
  "files": [
@@ -57,15 +57,16 @@
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.8",
62
- "@tinacms/metrics": "0.0.2",
60
+ "@tinacms/datalayer": "0.1.1",
61
+ "@tinacms/graphql": "0.59.11",
62
+ "@tinacms/metrics": "0.0.3",
63
+ "@tinacms/schema-tools": "0.0.3",
63
64
  "@yarnpkg/esbuild-plugin-pnp": "^2.0.1-rc.3",
64
65
  "add": "^2.0.6",
65
66
  "ajv": "^6.12.3",
66
67
  "altair-express-middleware": "4.0.6",
67
68
  "auto-bind": "^4.0.0",
68
- "axios": "0.19.0",
69
+ "axios": "0.21.2",
69
70
  "body-parser": "^1.19.0",
70
71
  "chalk": "^2.4.2",
71
72
  "chokidar": "^3.5.1",