@tinacms/cli 0.60.13 → 0.60.16

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,26 @@
1
1
  # tinacms-cli
2
2
 
3
+ ## 0.60.16
4
+
5
+ ### Patch Changes
6
+
7
+ - 7372f90ca: Adds a new client that can be used on the backend and frontend.
8
+ - Updated dependencies [3b11ff6ad]
9
+ - @tinacms/graphql@0.60.1
10
+
11
+ ## 0.60.15
12
+
13
+ ### Patch Changes
14
+
15
+ - ceb826916: Fix issue where \_app override from tina init was improperly formatted
16
+
17
+ ## 0.60.14
18
+
19
+ ### Patch Changes
20
+
21
+ - Updated dependencies [6a6f137ae]
22
+ - @tinacms/graphql@0.60.0
23
+
3
24
  ## 0.60.13
4
25
 
5
26
  ### Patch Changes
package/bin/tinacms CHANGED
@@ -1,4 +1,4 @@
1
1
  #!/usr/bin/env node
2
2
 
3
- require = require("esm")(module);
4
- require("../dist").init(process.argv);
3
+ require = require('esm')(module)
4
+ require('../dist').init(process.argv)
@@ -1,4 +1,5 @@
1
1
  export declare const adminPage = "import { TinaAdmin } from 'tinacms';\nexport default TinaAdmin;\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";
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";
3
3
  export declare const nextPostPage: () => string;
4
4
  export declare const AppJsContent: (usingSrc: boolean, extraImports?: string) => string;
5
+ export declare const AppJsContentPrintout: (usingSrc: boolean, extraImports?: string) => string;
package/dist/index.js CHANGED
@@ -79,7 +79,7 @@ var init_server = __esm({
79
79
  # We've got a simple query set up for you to get started
80
80
  # but there's plenty more for you to explore on your own!
81
81
  query MyQuery {
82
- getCollections {
82
+ collections {
83
83
  documents {
84
84
  id
85
85
  sys {
@@ -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.13";
117
+ var version = "0.60.16";
118
118
 
119
119
  // pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/cli/src/cmds/query-gen/attachSchema.ts
120
120
  var import_graphql = __toModule(require("@tinacms/graphql"));
@@ -165,7 +165,9 @@ var import_graphql5 = __toModule(require("graphql"));
165
165
  var AddGeneratedClientFunc = (_schema, _documents, _config, _info) => {
166
166
  return `
167
167
  // TinaSDK generated code
168
- import { staticRequest } from 'tinacms'
168
+ import { createClient } from 'tinacms/dist/client'
169
+ const client = createClient({url: 'http://localhost:4001/graphql'})
170
+
169
171
  const requester: (doc: any, vars?: any, options?: any) => Promise<any> = async (
170
172
  doc,
171
173
  vars,
@@ -173,7 +175,7 @@ const requester: (doc: any, vars?: any, options?: any) => Promise<any> = async (
173
175
  ) => {
174
176
  let data = {}
175
177
  try {
176
- data = await staticRequest({
178
+ data = await client.request({
177
179
  query: doc,
178
180
  variables: vars,
179
181
  })
@@ -183,7 +185,7 @@ const requester: (doc: any, vars?: any, options?: any) => Promise<any> = async (
183
185
  console.warn(e)
184
186
  }
185
187
 
186
- return { data, query: doc, variables: vars || {} }
188
+ return { data: data?.data, query: doc, variables: vars || {} }
187
189
  }
188
190
 
189
191
  /**
@@ -275,7 +277,6 @@ var plugin = (schema, documents, config) => {
275
277
  const visitor = new GenericSdkVisitor(schema, allFragments, config);
276
278
  const visitorResult = (0, import_graphql3.visit)(allAst, { leave: visitor });
277
279
  return {
278
- prepend: visitor.getImports(),
279
280
  content: [
280
281
  visitor.fragments,
281
282
  ...visitorResult.definitions.filter((t) => typeof t === "string"),
@@ -328,10 +329,7 @@ var generateTypes = async (schema, queryPathGlob = process.cwd(), fragDocPath =
328
329
  { typescript: {} },
329
330
  { typescriptOperations: {} },
330
331
  {
331
- typescriptSdk: {
332
- gqlImport: "tinacms#gql",
333
- documentNodeImport: "tinacms#DocumentNode"
334
- }
332
+ typescriptSdk: {}
335
333
  },
336
334
  { AddGeneratedClient: {} }
337
335
  ],
@@ -362,6 +360,13 @@ async function genTypes({ schema }, next, options) {
362
360
  const typescriptTypes = await generateTypes(schema, queryPathGlob, fragPath, options);
363
361
  await import_fs_extra.default.outputFile(typesPath, `//@ts-nocheck
364
362
  // DO NOT MODIFY THIS FILE. This file is automatically generated by Tina
363
+ export function gql(strings: TemplateStringsArray, ...args: string[]): string {
364
+ let str = ''
365
+ strings.forEach((string, i) => {
366
+ str += string + (args[i] || '')
367
+ })
368
+ return str
369
+ }
365
370
  ${typescriptTypes}
366
371
  `);
367
372
  logger.info(` Typescript types => ${logText(typesPath)}`);
@@ -393,13 +398,13 @@ var auditCollection = async (args) => {
393
398
  const { collection, database, rootPath: rootPath2 } = args;
394
399
  logger.info(`Checking collection ${collection.name}`);
395
400
  const query = `query {
396
- getCollection(collection: "${collection.name}") {
401
+ collection(collection: "${collection.name}") {
397
402
  format
398
403
  documents {
399
404
  edges {
400
405
  node {
401
406
  ...on Document {
402
- sys {
407
+ _sys {
403
408
  extension
404
409
  path
405
410
  }
@@ -415,15 +420,15 @@ var auditCollection = async (args) => {
415
420
  query,
416
421
  variables: {}
417
422
  });
418
- const format = result.data.getCollection.format;
419
- const docs = result.data.getCollection.documents.edges;
423
+ const format = result.data.collection.format;
424
+ const docs = result.data.collection.documents.edges;
420
425
  docs.forEach((x) => {
421
426
  const node = x.node;
422
- if (node.sys.extension.replace(".", "") !== format) {
427
+ if (node._sys.extension.replace(".", "") !== format) {
423
428
  warning = true;
424
- logger.warn(import_chalk2.default.yellowBright(`WARNING: there is a file with extension \`${node.sys.extension}\` but in your schema it is defined to be \`.${format}\`
429
+ logger.warn(import_chalk2.default.yellowBright(`WARNING: there is a file with extension \`${node._sys.extension}\` but in your schema it is defined to be \`.${format}\`
425
430
 
426
- location: ${import_path2.default.join(rootPath2, node.sys.path)}`));
431
+ location: ${import_path2.default.join(rootPath2, node._sys.path)}`));
427
432
  }
428
433
  });
429
434
  return warning;
@@ -431,14 +436,14 @@ location: ${import_path2.default.join(rootPath2, node.sys.path)}`));
431
436
  var auditDocuments = async (args) => {
432
437
  const { collection, database, rootPath: rootPath2, useDefaultValues } = args;
433
438
  const query = `query {
434
- getCollection(collection: "${collection.name}") {
439
+ collection(collection: "${collection.name}") {
435
440
  format
436
441
  slug
437
442
  documents {
438
443
  edges {
439
444
  node {
440
445
  ...on Document {
441
- sys {
446
+ _sys {
442
447
  extension
443
448
  path
444
449
  relativePath
@@ -456,16 +461,16 @@ var auditDocuments = async (args) => {
456
461
  variables: {}
457
462
  });
458
463
  let error = false;
459
- const documents = result.data.getCollection.documents.edges;
464
+ const documents = result.data.collection.documents.edges;
460
465
  for (let i = 0; i < documents.length; i++) {
461
466
  const node = documents[i].node;
462
- const fullPath = import_path2.default.join(rootPath2, node.sys.path);
467
+ const fullPath = import_path2.default.join(rootPath2, node._sys.path);
463
468
  logger.info(`Checking document: ${fullPath}`);
464
469
  const documentQuery = `query {
465
- getDocument(collection: "${collection.name}", relativePath: "${node.sys.relativePath}") {
470
+ document(collection: "${collection.name}", relativePath: "${node._sys.relativePath}") {
466
471
  __typename
467
472
  ...on Document {
468
- values
473
+ _values
469
474
  }
470
475
  }
471
476
  }`;
@@ -483,7 +488,7 @@ var auditDocuments = async (args) => {
483
488
  }
484
489
  });
485
490
  }
486
- const params = transformDocumentIntoMutationRequestPayload(docResult.data.getDocument.values, {
491
+ const params = transformDocumentIntoMutationRequestPayload(docResult.data.document._values, {
487
492
  includeCollection: true,
488
493
  includeTemplate: typeof collection.templates !== "undefined"
489
494
  }, topLevelDefaults);
@@ -500,7 +505,7 @@ var auditDocuments = async (args) => {
500
505
  variables: {
501
506
  params,
502
507
  collection: collection.name,
503
- relativePath: node.sys.relativePath
508
+ relativePath: node._sys.relativePath
504
509
  },
505
510
  silenceErrors: true
506
511
  });
@@ -637,7 +642,7 @@ title: Vote For Pedro
637
642
  ---
638
643
  # Welcome to the blog.
639
644
 
640
- > To edit this site head over to the [\`/admin\`](/admin) route. Then click the pencil icon in the bottom lefthand corner to start editing \u{1F999}.
645
+ > To edit this site head over to the [\`/admin\`](/admin) route. Then click the pencil icon in the bottom lefthand corner to start editing \u{1F999}.
641
646
 
642
647
  # Dixi gaude Arethusa
643
648
 
@@ -662,7 +667,7 @@ mille rigidi sub taurum.
662
667
  `;
663
668
  var nextPostPage = () => `// THIS FILE HAS BEEN GENERATED WITH THE TINA CLI.
664
669
  // This is a demo file once you have tina setup feel free to delete this file
665
-
670
+
666
671
  import { staticRequest, gql } from "tinacms";
667
672
  import Head from "next/head";
668
673
  import { createGlobalStyle } from "styled-components";
@@ -671,11 +676,9 @@ var nextPostPage = () => `// THIS FILE HAS BEEN GENERATED WITH THE TINA CLI.
671
676
 
672
677
  const query = gql\`
673
678
  query BlogPostQuery($relativePath: String!) {
674
- getPostsDocument(relativePath: $relativePath) {
675
- data {
679
+ posts(relativePath: $relativePath) {
676
680
  title
677
- body
678
- }
681
+ body
679
682
  }
680
683
  }
681
684
  \`
@@ -713,7 +716,7 @@ var nextPostPage = () => `// THIS FILE HAS BEEN GENERATED WITH THE TINA CLI.
713
716
  text-decoration: underline;
714
717
  }
715
718
  \`;
716
-
719
+
717
720
  const BlogPage = (props) => {
718
721
  const { data } = useTina({
719
722
  query,
@@ -740,10 +743,10 @@ var nextPostPage = () => `// THIS FILE HAS BEEN GENERATED WITH THE TINA CLI.
740
743
  }}
741
744
  >
742
745
  <h1 className="text-3xl m-8 text-center leading-8 font-extrabold tracking-tight text-gray-900 sm:text-4xl">
743
- {data.getPostsDocument.data.title}
746
+ {data.posts.title}
744
747
  </h1>
745
748
  <ContentSection
746
- content={data.getPostsDocument.data.body}
749
+ content={data.posts.body}
747
750
  ></ContentSection>
748
751
  </div>
749
752
  <div className="bg-green-100 text-center">
@@ -761,7 +764,7 @@ var nextPostPage = () => `// THIS FILE HAS BEEN GENERATED WITH THE TINA CLI.
761
764
  </>
762
765
  );
763
766
  };
764
-
767
+
765
768
  export const getStaticProps = async ({ params }) => {
766
769
  const variables = { relativePath: \`\${params.filename}.md\` }
767
770
  let data = {}
@@ -782,16 +785,18 @@ var nextPostPage = () => `// THIS FILE HAS BEEN GENERATED WITH THE TINA CLI.
782
785
  },
783
786
  }
784
787
  };
785
-
788
+
786
789
  export const getStaticPaths = async () => {
787
790
  const postsListData = (await staticRequest({
788
791
  query: gql\`
789
792
  query GetPostsList {
790
- getPostsList {
793
+ postsConnection {
791
794
  edges {
792
795
  node {
793
- sys {
794
- filename
796
+ ...on Document {
797
+ _sys {
798
+ filename
799
+ }
795
800
  }
796
801
  }
797
802
  }
@@ -799,15 +804,15 @@ var nextPostPage = () => `// THIS FILE HAS BEEN GENERATED WITH THE TINA CLI.
799
804
  }
800
805
  \`,
801
806
  }));
802
-
807
+
803
808
  return {
804
- paths: postsListData.getPostsList.edges.map((post) => ({
805
- params: { filename: post.node.sys.filename },
809
+ paths: postsListData.postsConnection.edges.map((post) => ({
810
+ params: { filename: post.node._sys.filename },
806
811
  })),
807
812
  fallback: false,
808
813
  };
809
814
  };
810
-
815
+
811
816
  export default BlogPage;
812
817
 
813
818
  const PageSection = props => {
@@ -822,7 +827,7 @@ var nextPostPage = () => `// THIS FILE HAS BEEN GENERATED WITH THE TINA CLI.
822
827
  const components = {
823
828
  PageSection: PageSection,
824
829
  }
825
-
830
+
826
831
  const ContentSection = ({ content }) => {
827
832
  return (
828
833
  <div className="relative py-16 bg-white overflow-hidden">
@@ -938,9 +943,25 @@ var nextPostPage = () => `// THIS FILE HAS BEEN GENERATED WITH THE TINA CLI.
938
943
  </div>
939
944
  );
940
945
  };
941
-
946
+
942
947
  `;
943
948
  var AppJsContent = (usingSrc, extraImports) => {
949
+ const importLine = `import Tina from '${usingSrc ? "../" : ""}../.tina/components/TinaDynamicProvider.js'`;
950
+ return `${importLine}
951
+ ${extraImports || ""}
952
+
953
+ const App = ({ Component, pageProps }) => {
954
+ return (
955
+ <Tina>
956
+ <Component {...pageProps} />
957
+ </Tina>
958
+ )
959
+ }
960
+
961
+ export default App
962
+ `;
963
+ };
964
+ var AppJsContentPrintout = (usingSrc, extraImports) => {
944
965
  const importLine = import_chalk4.default.green(`+ import Tina from '${usingSrc ? "../" : ""}../.tina/components/TinaDynamicProvider.js'`);
945
966
  return `${importLine}
946
967
  ${extraImports || ""}
@@ -952,7 +973,7 @@ var AppJsContent = (usingSrc, extraImports) => {
952
973
  ${import_chalk4.default.green("+ </Tina>")}
953
974
  )
954
975
  }
955
-
976
+
956
977
  export default App
957
978
  `;
958
979
  };
@@ -1177,7 +1198,7 @@ async function successMessage(ctx, next, options) {
1177
1198
  logger.info(`${import_chalk5.default.bold("Add the Tina wrapper")}`);
1178
1199
  logger.info(`\u26A0\uFE0F Before using Tina, you will NEED to add the Tina wrapper to your _app.jsx
1179
1200
  `);
1180
- logger.info(`${AppJsContent(usingSrc)}`);
1201
+ logger.info(`${AppJsContentPrintout(usingSrc)}`);
1181
1202
  }
1182
1203
  logger.info(`${import_chalk5.default.bold("Run your site with Tina")}`);
1183
1204
  logger.info(` yarn dev
@@ -1255,7 +1276,7 @@ var import_esbuild = __toModule(require("esbuild"));
1255
1276
  var defaultSchema = (sep) => `
1256
1277
  import { defineSchema, defineConfig } from "tinacms";
1257
1278
 
1258
- export default defineSchema({
1279
+ const schema = defineSchema({
1259
1280
  collections: [
1260
1281
  {
1261
1282
  label: "Blog Posts",
@@ -1299,8 +1320,7 @@ export default defineSchema({
1299
1320
  ],
1300
1321
  });
1301
1322
 
1302
-
1303
-
1323
+ export default schema
1304
1324
 
1305
1325
  // Your tina config
1306
1326
  // ==============
@@ -1314,6 +1334,7 @@ const apiURL =
1314
1334
 
1315
1335
  export const tinaConfig = defineConfig({
1316
1336
  apiURL,
1337
+ schema,
1317
1338
  cmsCallback: (cms) => {
1318
1339
  // add your CMS callback code here (if you want)
1319
1340
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tinacms/cli",
3
- "version": "0.60.13",
3
+ "version": "0.60.16",
4
4
  "main": "dist/index.js",
5
5
  "typings": "dist/index.d.ts",
6
6
  "files": [
@@ -58,7 +58,7 @@
58
58
  "@graphql-tools/graphql-file-loader": "^7.2.0",
59
59
  "@graphql-tools/load": "^7.3.2",
60
60
  "@tinacms/datalayer": "0.1.1",
61
- "@tinacms/graphql": "0.59.11",
61
+ "@tinacms/graphql": "0.60.1",
62
62
  "@tinacms/metrics": "0.0.3",
63
63
  "@tinacms/schema-tools": "0.0.3",
64
64
  "@yarnpkg/esbuild-plugin-pnp": "^2.0.1-rc.3",