@tinacms/cli 0.58.1 → 0.59.0

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,53 @@
1
1
  # tinacms-cli
2
2
 
3
+ ## 0.59.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 70da62fe8: deprecated the use of `getStaticPropsForTina`
8
+
9
+ ### Patch Changes
10
+
11
+ - 80732bd97: Create a @tinacms/datalayer package which houses the logic for data management for the GraphQL API. This simplifies the @tinacms/graphql package and allows for a clearer separation.
12
+ - Updated dependencies [34cd3a44a]
13
+ - Updated dependencies [b006a5ab9]
14
+ - Updated dependencies [a324b9c37]
15
+ - Updated dependencies [80732bd97]
16
+ - Updated dependencies [0bec208e2]
17
+ - Updated dependencies [5c070a83f]
18
+ - @tinacms/graphql@0.59.3
19
+ - @tinacms/datalayer@0.0.1
20
+
21
+ ## 0.58.5
22
+
23
+ ### Patch Changes
24
+
25
+ - Updated dependencies [212685fc3]
26
+ - @tinacms/graphql@0.59.2
27
+
28
+ ## 0.58.4
29
+
30
+ ### Patch Changes
31
+
32
+ - 118524507: Fixed typo in admin link
33
+ - Updated dependencies [f46c6f987]
34
+ - @tinacms/graphql@0.59.1
35
+
36
+ ## 0.58.3
37
+
38
+ ### Patch Changes
39
+
40
+ - Updated dependencies [bd4e1f802]
41
+ - Updated dependencies [62bea7019]
42
+ - @tinacms/graphql@0.59.0
43
+
44
+ ## 0.58.2
45
+
46
+ ### Patch Changes
47
+
48
+ - Updated dependencies [fffce3af8]
49
+ - @tinacms/graphql@0.58.2
50
+
3
51
  ## 0.58.1
4
52
 
5
53
  ### Patch Changes
@@ -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 [` /\n admin`](/admin) route. Then click the pencil icon in the bottom lefthand corner to start editing \uD83E\uDD99. \n\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## 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";
15
15
  export declare const nextPostPage: () => string;
16
16
  export declare const AppJsContent: (extraImports?: string) => string;
package/dist/index.js CHANGED
@@ -30,7 +30,7 @@ var server_exports = {};
30
30
  __export(server_exports, {
31
31
  default: () => server_default
32
32
  });
33
- var import_cors, import_http, import_express, import_altair_express_middleware, import_body_parser, GITHUB_ACCESS_TOKEN, gqlServer, server_default;
33
+ var import_cors, import_http, import_express, import_altair_express_middleware, import_body_parser, gqlServer, server_default;
34
34
  var init_server = __esm({
35
35
  "pnp:/Users/jeffsee/code/tinacms/packages/@tinacms/cli/src/cmds/start-server/server.ts"() {
36
36
  import_cors = __toModule(require("cors"));
@@ -38,7 +38,6 @@ var init_server = __esm({
38
38
  import_express = __toModule(require("express"));
39
39
  import_altair_express_middleware = __toModule(require("altair-express-middleware"));
40
40
  import_body_parser = __toModule(require("body-parser"));
41
- GITHUB_ACCESS_TOKEN = process.env.GITHUB_PERSONAL_ACCESS_TOKEN;
42
41
  gqlServer = async (database) => {
43
42
  const gqlPackage = require("@tinacms/graphql");
44
43
  const app = (0, import_express.default)();
@@ -71,36 +70,6 @@ var init_server = __esm({
71
70
  });
72
71
  return res.json(result);
73
72
  });
74
- app.get("/list-branches", async (req, res) => {
75
- try {
76
- const { query } = req;
77
- const { owner, repo } = query;
78
- const result = await gqlPackage.listBranches({
79
- auth: GITHUB_ACCESS_TOKEN,
80
- owner,
81
- repo
82
- });
83
- return res.json(result.data);
84
- } catch (error) {
85
- console.error("There was a problem fetching the branches.", error);
86
- }
87
- });
88
- app.post("/create-branch", async (req, res) => {
89
- try {
90
- const { owner, repo, name: name2, baseBranch } = req.body;
91
- const result = await gqlPackage.createBranch({
92
- auth: GITHUB_ACCESS_TOKEN,
93
- owner,
94
- repo,
95
- baseBranch,
96
- name: name2
97
- });
98
- return res.json(result);
99
- } catch (error) {
100
- res.end();
101
- console.error("There was a problem creating a new branch.", error);
102
- }
103
- });
104
73
  return server;
105
74
  };
106
75
  server_default = gqlServer;
@@ -116,7 +85,7 @@ var commander = __toModule(require("commander"));
116
85
 
117
86
  // pnp:/Users/jeffsee/code/tinacms/packages/@tinacms/cli/package.json
118
87
  var name = "@tinacms/cli";
119
- var version = "0.58.0";
88
+ var version = "0.59.0";
120
89
 
121
90
  // pnp:/Users/jeffsee/code/tinacms/packages/@tinacms/cli/src/utils/theme.ts
122
91
  var import_chalk = __toModule(require("chalk"));
@@ -150,6 +119,7 @@ var chain = async (cmds, options) => {
150
119
 
151
120
  // pnp:/Users/jeffsee/code/tinacms/packages/@tinacms/cli/src/cmds/query-gen/attachSchema.ts
152
121
  var import_graphql = __toModule(require("@tinacms/graphql"));
122
+ var import_datalayer = __toModule(require("@tinacms/datalayer"));
153
123
 
154
124
  // pnp:/Users/jeffsee/code/tinacms/packages/@tinacms/cli/src/logger/index.ts
155
125
  var import_log4js = __toModule(require("log4js"));
@@ -166,8 +136,8 @@ logger.level = "info";
166
136
  async function attachSchema(ctx, next, options) {
167
137
  logger.info(logText("Building schema..."));
168
138
  const rootPath = process.cwd();
169
- const bridge = new import_graphql.FilesystemBridge(rootPath);
170
- const store = new import_graphql.FilesystemStore({ rootPath });
139
+ const bridge = new import_datalayer.FilesystemBridge(rootPath);
140
+ const store = new import_datalayer.FilesystemStore({ rootPath });
171
141
  const database = await (0, import_graphql.createDatabase)({ store, bridge });
172
142
  const schema = await (0, import_graphql.buildSchema)(rootPath, database);
173
143
  ctx.schema = schema;
@@ -184,16 +154,26 @@ var import_typescript_operations = __toModule(require("@graphql-codegen/typescri
184
154
  var AddGeneratedClientFunc = (_schema, _documents, _config, _info) => {
185
155
  return `
186
156
  // TinaSDK generated code
187
- import { getStaticPropsForTina } from 'tinacms'
157
+ import { staticRequest } from 'tinacms'
188
158
  const requester: (doc: any, vars?: any, options?: any) => Promise<any> = async (
189
159
  doc,
190
160
  vars,
191
161
  _options
192
162
  ) => {
193
- // const data = await tinaClient.request(doc, { variables: vars });
194
- const res = await await getStaticPropsForTina({query: doc, variables: vars})
195
- return res
196
- };
163
+ let data = {}
164
+ try {
165
+ data = await staticRequest({
166
+ query: doc,
167
+ variables: vars,
168
+ })
169
+ } catch (e) {
170
+ // swallow errors related to document creation
171
+ console.warn('Warning: There was an error when fetching data')
172
+ console.warn(e)
173
+ }
174
+
175
+ return { data, query: doc, variables: vars || {} }
176
+ }
197
177
 
198
178
  /**
199
179
  * @experimental this class can be used but may change in the future
@@ -384,6 +364,7 @@ schema {
384
364
  var import_child_process = __toModule(require("child_process"));
385
365
  var import_path3 = __toModule(require("path"));
386
366
  var import_graphql7 = __toModule(require("@tinacms/graphql"));
367
+ var import_datalayer2 = __toModule(require("@tinacms/datalayer"));
387
368
 
388
369
  // pnp:/Users/jeffsee/code/tinacms/packages/@tinacms/cli/src/cmds/compile/index.ts
389
370
  var import_fast_glob = __toModule(require("fast-glob"));
@@ -490,8 +471,8 @@ async function startServer(_ctx, _next, { port = 4001, command, noWatch, experim
490
471
  if (!process.env.CI && !noWatch) {
491
472
  await resetGeneratedFolder();
492
473
  }
493
- const bridge = new import_graphql7.FilesystemBridge(rootPath);
494
- const store = experimentalData ? new import_graphql7.LevelStore(rootPath) : new import_graphql7.FilesystemStore({ rootPath });
474
+ const bridge = new import_datalayer2.FilesystemBridge(rootPath);
475
+ const store = experimentalData ? new import_datalayer2.LevelStore(rootPath) : new import_datalayer2.FilesystemStore({ rootPath });
495
476
  const shouldBuild = bridge.supportsBuilding();
496
477
  const database = await (0, import_graphql7.createDatabase)({ store, bridge });
497
478
  const startSubprocess = () => {
@@ -623,9 +604,7 @@ title: Vote For Pedro
623
604
  ---
624
605
  # Welcome to the blog.
625
606
 
626
- > To edit this site head over to the [\` /
627
- admin\`](/admin) route. Then click the pencil icon in the bottom lefthand corner to start editing \u{1F999}.
628
-
607
+ > 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}.
629
608
 
630
609
  # Dixi gaude Arethusa
631
610
 
@@ -653,7 +632,7 @@ mille rigidi sub taurum.
653
632
  var nextPostPage = () => `// THIS FILE HAS BEEN GENERATED WITH THE TINA CLI.
654
633
  // This is a demo file once you have tina setup feel free to delete this file
655
634
 
656
- import { staticRequest, gql, getStaticPropsForTina } from "tinacms";
635
+ import { staticRequest, gql } from "tinacms";
657
636
  import Head from "next/head";
658
637
  import { createGlobalStyle } from "styled-components";
659
638
 
@@ -744,24 +723,35 @@ var nextPostPage = () => `// THIS FILE HAS BEEN GENERATED WITH THE TINA CLI.
744
723
  };
745
724
 
746
725
  export const getStaticProps = async ({ params }) => {
747
- const tinaProps = await getStaticPropsForTina({
748
- query: gql\`
749
- query BlogPostQuery($relativePath: String!) {
750
- getPostsDocument(relativePath: $relativePath) {
751
- data {
752
- title
753
- body
754
- }
726
+ const query = gql\`
727
+ query BlogPostQuery($relativePath: String!) {
728
+ getPostsDocument(relativePath: $relativePath) {
729
+ data {
730
+ title
731
+ body
755
732
  }
756
733
  }
757
- \`,
758
- variables: { relativePath: \`\${params.filename}.md\` },
759
- });
734
+ }
735
+ \`
736
+ const variables = { relativePath: \`\${params.filename}.md\` }
737
+ let data = {}
738
+ try {
739
+ data = await staticRequest({
740
+ query,
741
+ variables,
742
+ })
743
+ } catch {
744
+ // swallow errors related to document creation
745
+ }
746
+
760
747
  return {
761
748
  props: {
762
- ...tinaProps,
749
+ query,
750
+ variables,
751
+ data,
752
+ //myOtherProp: 'some-other-data',
763
753
  },
764
- };
754
+ }
765
755
  };
766
756
 
767
757
  export const getStaticPaths = async () => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tinacms/cli",
3
- "version": "0.58.1",
3
+ "version": "0.59.0",
4
4
  "main": "dist/index.js",
5
5
  "typings": "dist/index.d.ts",
6
6
  "files": [
@@ -56,7 +56,8 @@
56
56
  "@graphql-codegen/visitor-plugin-common": "^2.4.0",
57
57
  "@graphql-tools/graphql-file-loader": "^7.2.0",
58
58
  "@graphql-tools/load": "^7.3.2",
59
- "@tinacms/graphql": "0.58.1",
59
+ "@tinacms/datalayer": "0.0.1",
60
+ "@tinacms/graphql": "0.59.3",
60
61
  "ajv": "^6.12.3",
61
62
  "altair-express-middleware": "4.0.6",
62
63
  "auto-bind": "^4.0.0",