@tinacms/cli 0.58.5 → 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,23 @@
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
+
3
21
  ## 0.58.5
4
22
 
5
23
  ### Patch Changes
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.5";
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 = () => {
@@ -651,7 +632,7 @@ mille rigidi sub taurum.
651
632
  var nextPostPage = () => `// THIS FILE HAS BEEN GENERATED WITH THE TINA CLI.
652
633
  // This is a demo file once you have tina setup feel free to delete this file
653
634
 
654
- import { staticRequest, gql, getStaticPropsForTina } from "tinacms";
635
+ import { staticRequest, gql } from "tinacms";
655
636
  import Head from "next/head";
656
637
  import { createGlobalStyle } from "styled-components";
657
638
 
@@ -742,24 +723,35 @@ var nextPostPage = () => `// THIS FILE HAS BEEN GENERATED WITH THE TINA CLI.
742
723
  };
743
724
 
744
725
  export const getStaticProps = async ({ params }) => {
745
- const tinaProps = await getStaticPropsForTina({
746
- query: gql\`
747
- query BlogPostQuery($relativePath: String!) {
748
- getPostsDocument(relativePath: $relativePath) {
749
- data {
750
- title
751
- body
752
- }
726
+ const query = gql\`
727
+ query BlogPostQuery($relativePath: String!) {
728
+ getPostsDocument(relativePath: $relativePath) {
729
+ data {
730
+ title
731
+ body
753
732
  }
754
733
  }
755
- \`,
756
- variables: { relativePath: \`\${params.filename}.md\` },
757
- });
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
+
758
747
  return {
759
748
  props: {
760
- ...tinaProps,
749
+ query,
750
+ variables,
751
+ data,
752
+ //myOtherProp: 'some-other-data',
761
753
  },
762
- };
754
+ }
763
755
  };
764
756
 
765
757
  export const getStaticPaths = async () => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tinacms/cli",
3
- "version": "0.58.5",
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.59.2",
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",