@tinacms/cli 0.56.2 → 0.57.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,43 @@
1
1
  # tinacms-cli
2
2
 
3
+ ## 0.57.0
4
+
5
+ ### Minor Changes
6
+
7
+ - d1ed404ba: Add support for auto-generated SDK for type-safe data fetching
8
+
9
+ ### Patch Changes
10
+
11
+ - 138ceb8c4: Clean up dependencies
12
+ - Updated dependencies [138ceb8c4]
13
+ - Updated dependencies [577d6a5ad]
14
+ - Updated dependencies [ed277e3bd]
15
+ - Updated dependencies [d1ed404ba]
16
+ - @tinacms/graphql@0.57.0
17
+
18
+ ## 0.56.5
19
+
20
+ ### Patch Changes
21
+
22
+ - 33ebe7a41: updated cli generated files
23
+ - Updated dependencies [4b7795612]
24
+ - @tinacms/graphql@0.56.1
25
+
26
+ ## 0.56.4
27
+
28
+ ### Patch Changes
29
+
30
+ - b99baebf1: Add rich-text editor based on mdx, bump React dependency requirement to 16.14
31
+ - Updated dependencies [891623c7c]
32
+ - Updated dependencies [b99baebf1]
33
+ - @tinacms/graphql@0.56.0
34
+
35
+ ## 0.56.3
36
+
37
+ ### Patch Changes
38
+
39
+ - 7c389cb0f: Remove Forestry reference in CLI hint
40
+
3
41
  ## 0.56.2
4
42
 
5
43
  ### Patch Changes
@@ -11,4 +11,4 @@ See the License for the specific language governing permissions and
11
11
  limitations under the License.
12
12
  */
13
13
  import { GraphQLSchema } from 'graphql';
14
- export declare const generateTypes: (schema: GraphQLSchema) => Promise<string>;
14
+ export declare const generateTypes: (schema: GraphQLSchema, queryPathGlob?: string, fragDocPath?: string) => Promise<string>;
@@ -0,0 +1,17 @@
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
+ import type { PluginFunction } from '@graphql-codegen/plugin-helpers';
14
+ export declare const AddGeneratedClientFunc: PluginFunction;
15
+ export declare const AddGeneratedClient: {
16
+ plugin: PluginFunction<any, import("@graphql-codegen/plugin-helpers").Types.PluginOutput>;
17
+ };
@@ -0,0 +1,24 @@
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
+ import { RawClientSideBasePluginConfig } from '@graphql-codegen/visitor-plugin-common';
14
+ /**
15
+ * This plugin generate a generic SDK (without any Requester implemented), allow you to easily customize the way you fetch your data, without loosing the strongly-typed integration.
16
+ */
17
+ export interface RawGenericSdkPluginConfig extends RawClientSideBasePluginConfig {
18
+ /**
19
+ * usingObservableFrom: "import Observable from 'zen-observable';"
20
+ * OR
21
+ * usingObservableFrom: "import { Observable } from 'rxjs';"
22
+ */
23
+ usingObservableFrom?: string;
24
+ }
@@ -0,0 +1,27 @@
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
+ /**
14
+ * PLEASE READ THIS:
15
+ *
16
+ * This plugin is directly copied from https://github.com/dotansimha/graphql-code-generator/tree/master/packages/plugins/typescript/generic-sdk
17
+ *
18
+ * The reason this was needed is because we had to modified the return type of the SDK client. We need to return {data, variables, query}. While the other one just returned the data.
19
+ *
20
+ * This is the same as the above link and may need to be updated time to time. (for example if we want to support GQL v16). There is only one line that differs from the original. (This is shown)
21
+ */
22
+ import { PluginFunction, PluginValidateFn } from '@graphql-codegen/plugin-helpers';
23
+ import { RawGenericSdkPluginConfig } from './config';
24
+ import { GenericSdkVisitor } from './visitor';
25
+ export declare const plugin: PluginFunction<RawGenericSdkPluginConfig>;
26
+ export declare const validate: PluginValidateFn<any>;
27
+ export { GenericSdkVisitor };
@@ -0,0 +1,24 @@
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
+ import { ClientSideBasePluginConfig, ClientSideBaseVisitor, LoadedFragment } from '@graphql-codegen/visitor-plugin-common';
14
+ import { GraphQLSchema, OperationDefinitionNode } from 'graphql';
15
+ import { RawGenericSdkPluginConfig } from './config';
16
+ export interface GenericSdkPluginConfig extends ClientSideBasePluginConfig {
17
+ usingObservableFrom: string;
18
+ }
19
+ export declare class GenericSdkVisitor extends ClientSideBaseVisitor<RawGenericSdkPluginConfig, GenericSdkPluginConfig> {
20
+ private _operationsToInclude;
21
+ constructor(schema: GraphQLSchema, fragments: LoadedFragment[], rawConfig: RawGenericSdkPluginConfig);
22
+ protected buildOperation(node: OperationDefinitionNode, documentVariableName: string, operationType: string, operationResultType: string, operationVariablesTypes: string): string;
23
+ get sdkContent(): string;
24
+ }
package/dist/index.js CHANGED
@@ -30,10 +30,10 @@ var server_exports = {};
30
30
  __export(server_exports, {
31
31
  default: () => server_default
32
32
  });
33
- var import_path2, import_cors, import_http, import_express, import_altair_express_middleware, import_body_parser, GITHUB_ACCESS_TOKEN, gqlServer, server_default;
33
+ var import_path3, import_cors, import_http, import_express, import_altair_express_middleware, import_body_parser, GITHUB_ACCESS_TOKEN, gqlServer, server_default;
34
34
  var init_server = __esm({
35
35
  "pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/cli/src/cmds/start-server/server.ts"() {
36
- import_path2 = __toModule(require("path"));
36
+ import_path3 = __toModule(require("path"));
37
37
  import_cors = __toModule(require("cors"));
38
38
  import_http = __toModule(require("http"));
39
39
  import_express = __toModule(require("express"));
@@ -63,7 +63,7 @@ var init_server = __esm({
63
63
  }
64
64
  }`
65
65
  }));
66
- const rootPath = import_path2.default.join(process.cwd());
66
+ const rootPath = import_path3.default.join(process.cwd());
67
67
  app.post("/graphql", async (req, res) => {
68
68
  const { query, variables } = req.body;
69
69
  const result = await gqlPackage.gql({
@@ -118,7 +118,7 @@ var commander = __toModule(require("commander"));
118
118
 
119
119
  // pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/cli/package.json
120
120
  var name = "@tinacms/cli";
121
- var version = "0.56.2";
121
+ var version = "0.57.0";
122
122
 
123
123
  // pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/cli/src/utils/theme.ts
124
124
  var import_chalk = __toModule(require("chalk"));
@@ -174,26 +174,173 @@ async function attachSchema(ctx, next, options) {
174
174
  }
175
175
 
176
176
  // pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/cli/src/codegen/index.ts
177
- var import_graphql2 = __toModule(require("graphql"));
177
+ var import_graphql5 = __toModule(require("graphql"));
178
178
  var import_core = __toModule(require("@graphql-codegen/core"));
179
179
  var import_typescript = __toModule(require("@graphql-codegen/typescript"));
180
180
  var import_typescript_operations = __toModule(require("@graphql-codegen/typescript-operations"));
181
- var generateTypes = async (schema) => {
181
+
182
+ // pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/cli/src/codegen/plugin.ts
183
+ var AddGeneratedClientFunc = (_schema, _documents, _config, _info) => {
184
+ return `
185
+ // TinaSDK generated code
186
+ import { getStaticPropsForTina } from 'tinacms'
187
+ const requester: (doc: any, vars?: any, options?: any) => Promise<any> = async (
188
+ doc,
189
+ vars,
190
+ _options
191
+ ) => {
192
+ // const data = await tinaClient.request(doc, { variables: vars });
193
+ const res = await await getStaticPropsForTina({query: doc, variables: vars})
194
+ return res
195
+ };
196
+
197
+ /**
198
+ * @experimental this class can be used but may change in the future
199
+ **/
200
+ export const ExperimentalGetTinaClient = ()=>getSdk(requester)
201
+ `;
202
+ };
203
+ var AddGeneratedClient = {
204
+ plugin: AddGeneratedClientFunc
205
+ };
206
+
207
+ // pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/cli/src/codegen/sdkPlugin/index.ts
208
+ var import_graphql3 = __toModule(require("graphql"));
209
+ var import_graphql4 = __toModule(require("graphql"));
210
+ var import_path = __toModule(require("path"));
211
+
212
+ // pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/cli/src/codegen/sdkPlugin/visitor.ts
213
+ var import_visitor_plugin_common = __toModule(require("@graphql-codegen/visitor-plugin-common"));
214
+ var import_auto_bind = __toModule(require("auto-bind"));
215
+ var import_graphql2 = __toModule(require("graphql"));
216
+ var GenericSdkVisitor = class extends import_visitor_plugin_common.ClientSideBaseVisitor {
217
+ constructor(schema, fragments, rawConfig) {
218
+ super(schema, fragments, rawConfig, {
219
+ usingObservableFrom: rawConfig.usingObservableFrom
220
+ });
221
+ this._operationsToInclude = [];
222
+ (0, import_auto_bind.default)(this);
223
+ if (this.config.usingObservableFrom) {
224
+ this._additionalImports.push(this.config.usingObservableFrom);
225
+ }
226
+ if (this.config.documentMode !== import_visitor_plugin_common.DocumentMode.string) {
227
+ }
228
+ }
229
+ buildOperation(node, documentVariableName, operationType, operationResultType, operationVariablesTypes) {
230
+ if (node.name == null) {
231
+ throw new Error("Plugin 'generic-sdk' cannot generate SDK for unnamed operation.\n\n" + (0, import_graphql2.print)(node));
232
+ } else {
233
+ this._operationsToInclude.push({
234
+ node,
235
+ documentVariableName,
236
+ operationType,
237
+ operationResultType: `{data: ${operationResultType}, variables: ${operationVariablesTypes}, query: string}`,
238
+ operationVariablesTypes
239
+ });
240
+ }
241
+ return null;
242
+ }
243
+ get sdkContent() {
244
+ const usingObservable = !!this.config.usingObservableFrom;
245
+ const allPossibleActions = this._operationsToInclude.map((o) => {
246
+ const optionalVariables = !o.node.variableDefinitions || o.node.variableDefinitions.length === 0 || o.node.variableDefinitions.every((v) => v.type.kind !== import_graphql2.Kind.NON_NULL_TYPE || v.defaultValue);
247
+ const returnType = usingObservable && o.operationType === "Subscription" ? "Observable" : "Promise";
248
+ return `${o.node.name.value}(variables${optionalVariables ? "?" : ""}: ${o.operationVariablesTypes}, options?: C): ${returnType}<${o.operationResultType}> {
249
+ return requester<${o.operationResultType}, ${o.operationVariablesTypes}>(${o.documentVariableName}, variables, options);
250
+ }`;
251
+ }).map((s) => (0, import_visitor_plugin_common.indentMultiline)(s, 2));
252
+ return `export type Requester<C= {}> = <R, V>(doc: ${this.config.documentMode === import_visitor_plugin_common.DocumentMode.string ? "string" : "DocumentNode"}, vars?: V, options?: C) => ${usingObservable ? "Promise<R> & Observable<R>" : "Promise<R>"}
253
+ export function getSdk<C>(requester: Requester<C>) {
254
+ return {
255
+ ${allPossibleActions.join(",\n")}
256
+ };
257
+ }
258
+ export type Sdk = ReturnType<typeof getSdk>;`;
259
+ }
260
+ };
261
+
262
+ // pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/cli/src/codegen/sdkPlugin/index.ts
263
+ var plugin = (schema, documents, config) => {
264
+ const allAst = (0, import_graphql4.concatAST)(documents.reduce((prev, v) => {
265
+ return [...prev, v.document];
266
+ }, []));
267
+ const allFragments = [
268
+ ...allAst.definitions.filter((d) => d.kind === import_graphql4.Kind.FRAGMENT_DEFINITION).map((fragmentDef) => ({
269
+ node: fragmentDef,
270
+ name: fragmentDef.name.value,
271
+ onType: fragmentDef.typeCondition.name.value,
272
+ isExternal: false
273
+ })),
274
+ ...config.externalFragments || []
275
+ ];
276
+ const visitor = new GenericSdkVisitor(schema, allFragments, config);
277
+ const visitorResult = (0, import_graphql3.visit)(allAst, { leave: visitor });
278
+ return {
279
+ prepend: visitor.getImports(),
280
+ content: [
281
+ visitor.fragments,
282
+ ...visitorResult.definitions.filter((t) => typeof t === "string"),
283
+ visitor.sdkContent
284
+ ].join("\n")
285
+ };
286
+ };
287
+
288
+ // pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/cli/src/codegen/index.ts
289
+ var import_load = __toModule(require("@graphql-tools/load"));
290
+ var import_graphql_file_loader = __toModule(require("@graphql-tools/graphql-file-loader"));
291
+ var generateTypes = async (schema, queryPathGlob = process.cwd(), fragDocPath = process.cwd()) => {
182
292
  logger.info("Generating types...");
183
293
  try {
294
+ let docs = [];
295
+ let fragDocs = [];
296
+ try {
297
+ docs = await (0, import_load.loadDocuments)(queryPathGlob, {
298
+ loaders: [new import_graphql_file_loader.GraphQLFileLoader()]
299
+ });
300
+ } catch (e) {
301
+ let showErrorMessage = true;
302
+ const message = e.message || "";
303
+ if (message.includes("Unable to find any GraphQL type definitions for the following pointers:")) {
304
+ showErrorMessage = false;
305
+ }
306
+ if (showErrorMessage) {
307
+ console.error(e);
308
+ }
309
+ }
310
+ try {
311
+ fragDocs = await (0, import_load.loadDocuments)(fragDocPath, {
312
+ loaders: [new import_graphql_file_loader.GraphQLFileLoader()]
313
+ });
314
+ } catch (error) {
315
+ console.error(error);
316
+ }
184
317
  const res = await (0, import_core.codegen)({
185
- filename: process.cwd() + "/.forestry/autoschema.gql",
186
- schema: (0, import_graphql2.parse)((0, import_graphql2.printSchema)(schema)),
187
- documents: [],
318
+ filename: process.cwd(),
319
+ schema: (0, import_graphql5.parse)((0, import_graphql5.printSchema)(schema)),
320
+ documents: [...docs, ...fragDocs],
188
321
  config: {},
189
- plugins: [{ typescript: {} }, { typescriptOperations: {} }],
322
+ plugins: [
323
+ { typescript: {} },
324
+ { typescriptOperations: {} },
325
+ {
326
+ typescriptSdk: {
327
+ gqlImport: "tinacms#gql",
328
+ documentNodeImport: "tinacms#DocumentNode"
329
+ }
330
+ },
331
+ { AddGeneratedClient: {} }
332
+ ],
190
333
  pluginMap: {
191
334
  typescript: {
192
335
  plugin: import_typescript.plugin
193
336
  },
194
337
  typescriptOperations: {
195
338
  plugin: import_typescript_operations.plugin
196
- }
339
+ },
340
+ typescriptSdk: {
341
+ plugin
342
+ },
343
+ AddGeneratedClient
197
344
  }
198
345
  });
199
346
  return res;
@@ -203,16 +350,18 @@ var generateTypes = async (schema) => {
203
350
  };
204
351
 
205
352
  // pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/cli/src/cmds/query-gen/genTypes.ts
206
- var import_graphql3 = __toModule(require("graphql"));
353
+ var import_graphql6 = __toModule(require("graphql"));
207
354
  var import_fs_extra = __toModule(require("fs-extra"));
208
355
  async function genTypes({ schema }, next, options) {
209
- const typescriptTypes = await generateTypes(schema);
210
356
  const typesPath = process.cwd() + "/.tina/__generated__/types.ts";
357
+ const fragPath = process.cwd() + "/.tina/__generated__/*.{graphql,gql}";
358
+ const queryPathGlob = process.cwd() + "/.tina/queries/**/*.{graphql,gql}";
359
+ const typescriptTypes = await generateTypes(schema, queryPathGlob, fragPath);
211
360
  await import_fs_extra.default.outputFile(typesPath, `// DO NOT MODIFY THIS FILE. This file is automatically generated by Tina
212
361
  ${typescriptTypes}
213
362
  `);
214
363
  logger.info(`Typescript types => ${successText(typesPath)}`);
215
- const schemaString = await (0, import_graphql3.printSchema)(schema);
364
+ const schemaString = await (0, import_graphql6.printSchema)(schema);
216
365
  const schemaPath = process.cwd() + "/.tina/__generated__/schema.gql";
217
366
  await import_fs_extra.default.outputFile(schemaPath, `# DO NOT MODIFY THIS FILE. This file is automatically generated by Tina
218
367
  ${schemaString}
@@ -227,13 +376,13 @@ schema {
227
376
 
228
377
  // pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/cli/src/cmds/start-server/index.ts
229
378
  var import_child_process = __toModule(require("child_process"));
230
- var import_path3 = __toModule(require("path"));
231
- var import_graphql4 = __toModule(require("@tinacms/graphql"));
379
+ var import_path4 = __toModule(require("path"));
380
+ var import_graphql7 = __toModule(require("@tinacms/graphql"));
232
381
 
233
382
  // pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/cli/src/cmds/compile/index.ts
234
383
  var import_fast_glob = __toModule(require("fast-glob"));
235
384
  var import_normalize_path = __toModule(require("normalize-path"));
236
- var import_path = __toModule(require("path"));
385
+ var import_path2 = __toModule(require("path"));
237
386
  var import_fs_extra2 = __toModule(require("fs-extra"));
238
387
  var ts = __toModule(require("typescript"));
239
388
 
@@ -269,17 +418,17 @@ export default defineSchema({
269
418
  `;
270
419
 
271
420
  // pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/cli/src/cmds/compile/index.ts
272
- var tinaPath = import_path.default.join(process.cwd(), ".tina");
273
- var tinaTempPath = import_path.default.join(process.cwd(), ".tina", "__generated__", "temp");
274
- var tinaConfigPath = import_path.default.join(process.cwd(), ".tina", "__generated__", "config");
421
+ var tinaPath = import_path2.default.join(process.cwd(), ".tina");
422
+ var tinaTempPath = import_path2.default.join(process.cwd(), ".tina", "__generated__", "temp");
423
+ var tinaConfigPath = import_path2.default.join(process.cwd(), ".tina", "__generated__", "config");
275
424
  var compile = async (_ctx, _next) => {
276
425
  logger.info(logText("Compiling..."));
277
- if (!import_fs_extra2.default.existsSync(tinaPath) || !import_fs_extra2.default.existsSync(import_path.default.join(tinaPath, "schema.ts"))) {
426
+ if (!import_fs_extra2.default.existsSync(tinaPath) || !import_fs_extra2.default.existsSync(import_path2.default.join(tinaPath, "schema.ts"))) {
278
427
  logger.info(dangerText(`
279
428
  .tina/schema.ts not found, Creating one for you...
280
429
  See Documentation: https://tina.io/docs/tina-cloud/cli/#getting-started"
281
430
  `));
282
- const file = import_path.default.join(tinaPath, "schema.ts");
431
+ const file = import_path2.default.join(tinaPath, "schema.ts");
283
432
  await import_fs_extra2.default.ensureFile(file);
284
433
  await import_fs_extra2.default.writeFile(file, defaultSchema);
285
434
  }
@@ -291,21 +440,21 @@ var compile = async (_ctx, _next) => {
291
440
  delete require.cache[require.resolve(key)];
292
441
  }
293
442
  });
294
- const schemaFunc = require(import_path.default.join(tinaTempPath, "schema.js"));
443
+ const schemaFunc = require(import_path2.default.join(tinaTempPath, "schema.js"));
295
444
  const schemaObject = schemaFunc.default;
296
- await import_fs_extra2.default.outputFile(import_path.default.join(tinaConfigPath, "schema.json"), JSON.stringify(schemaObject, null, 2));
445
+ await import_fs_extra2.default.outputFile(import_path2.default.join(tinaConfigPath, "schema.json"), JSON.stringify(schemaObject, null, 2));
297
446
  await import_fs_extra2.default.remove(tinaTempPath);
298
447
  };
299
448
  var transpile2 = async (projectDir, tempDir) => {
300
449
  logger.info(logText("Transpiling..."));
301
450
  const posixProjectDir = (0, import_normalize_path.default)(projectDir);
302
451
  const posixTempDir = (0, import_normalize_path.default)(tempDir);
303
- return Promise.all(import_fast_glob.default.sync(import_path.default.join(projectDir, "**", "*.ts").replace(/\\/g, "/"), {
452
+ return Promise.all(import_fast_glob.default.sync(import_path2.default.join(projectDir, "**", "*.ts").replace(/\\/g, "/"), {
304
453
  ignore: [
305
- import_path.default.join(projectDir, "__generated__", "**", "*.ts").replace(/\\/g, "/")
454
+ import_path2.default.join(projectDir, "__generated__", "**", "*.ts").replace(/\\/g, "/")
306
455
  ]
307
456
  }).map(async function(file) {
308
- const fullPath = import_path.default.resolve(file);
457
+ const fullPath = import_path2.default.resolve(file);
309
458
  const contents = await import_fs_extra2.default.readFileSync(fullPath).toString();
310
459
  const newContent = ts.transpile(contents);
311
460
  const newPath = file.replace(posixProjectDir, posixTempDir).replace(".ts", ".js");
@@ -346,8 +495,8 @@ stack: ${code.stack || "No stack was provided"}`);
346
495
  const rootPath = process.cwd();
347
496
  let ready = false;
348
497
  if (!noWatch && !process.env.CI) {
349
- import_chokidar.default.watch(`${rootPath}/**/*.ts`, {
350
- ignored: `${import_path3.default.resolve(rootPath)}/.tina/__generated__/**/*`
498
+ import_chokidar.default.watch(`${rootPath}/**/*.{ts,gql,graphql}`, {
499
+ ignored: `${import_path4.default.resolve(rootPath)}/.tina/__generated__/**/*`
351
500
  }).on("ready", async () => {
352
501
  console.log("Generating Tina config");
353
502
  try {
@@ -372,7 +521,7 @@ stack: ${code.stack || "No stack was provided"}`);
372
521
  }
373
522
  const build = async () => {
374
523
  await compile(null, null);
375
- const schema = await (0, import_graphql4.buildSchema)(rootPath);
524
+ const schema = await (0, import_graphql7.buildSchema)(rootPath);
376
525
  await genTypes({ schema }, () => {
377
526
  }, {});
378
527
  };
@@ -433,7 +582,7 @@ stack: ${code.stack || "No stack was provided"}`);
433
582
 
434
583
  // pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/cli/src/cmds/init/index.ts
435
584
  var import_fs_extra3 = __toModule(require("fs-extra"));
436
- var import_path4 = __toModule(require("path"));
585
+ var import_path5 = __toModule(require("path"));
437
586
  var import_progress = __toModule(require("progress"));
438
587
  var import_prompts = __toModule(require("prompts"));
439
588
 
@@ -560,7 +709,7 @@ var nextPostPage = () => `// THIS FILE HAS BEEN GENERATED WITH THE TINA CLI.
560
709
  <script
561
710
  type="text/javascript"
562
711
  crossOrigin="anonymous"
563
- src="https://cdn.jsdelivr.net/npm/marked/marked.min.js"
712
+ src="https://cdnjs.cloudflare.com/ajax/libs/marked/4.0.0/marked.min.js"
564
713
  />
565
714
  </Head>
566
715
  <div>
@@ -575,7 +724,7 @@ var nextPostPage = () => `// THIS FILE HAS BEEN GENERATED WITH THE TINA CLI.
575
724
  {/* Convert markdown to html in the browser only */}
576
725
  {typeof window !== "undefined" && (
577
726
  <ContentSection
578
- content={window.marked(props.data.getPostsDocument.data.body)}
727
+ content={window.marked.parse(props.data.getPostsDocument.data.body)}
579
728
  ></ContentSection>
580
729
  )}
581
730
  </div>
@@ -824,21 +973,21 @@ async function installDeps(ctx, next, options) {
824
973
  next();
825
974
  }
826
975
  var baseDir = process.cwd();
827
- var TinaWrapperPathDir = import_path4.default.join(baseDir, "components");
828
- var TinaWrapperPath = import_path4.default.join(TinaWrapperPathDir, "tina-wrapper.tsx");
829
- var blogContentPath = import_path4.default.join(baseDir, "content", "posts");
830
- var blogPostPath = import_path4.default.join(blogContentPath, "HelloWorld.md");
976
+ var TinaWrapperPathDir = import_path5.default.join(baseDir, "components");
977
+ var TinaWrapperPath = import_path5.default.join(TinaWrapperPathDir, "tina-wrapper.tsx");
978
+ var blogContentPath = import_path5.default.join(baseDir, "content", "posts");
979
+ var blogPostPath = import_path5.default.join(blogContentPath, "HelloWorld.md");
831
980
  async function tinaSetup(ctx, next, options) {
832
- const useingSrc = import_fs_extra3.default.pathExistsSync(import_path4.default.join(baseDir, "src"));
981
+ const useingSrc = import_fs_extra3.default.pathExistsSync(import_path5.default.join(baseDir, "src"));
833
982
  if (!import_fs_extra3.default.pathExistsSync(blogPostPath)) {
834
983
  logger.info(logText("Adding a content folder..."));
835
984
  import_fs_extra3.default.mkdirpSync(blogContentPath);
836
985
  import_fs_extra3.default.writeFileSync(blogPostPath, blogPost);
837
986
  }
838
987
  logger.level = "info";
839
- const pagesPath = import_path4.default.join(baseDir, useingSrc ? "src" : "", "pages");
840
- const appPath = import_path4.default.join(pagesPath, "_app.js");
841
- const appPathTS = import_path4.default.join(pagesPath, "_app.tsx");
988
+ const pagesPath = import_path5.default.join(baseDir, useingSrc ? "src" : "", "pages");
989
+ const appPath = import_path5.default.join(pagesPath, "_app.js");
990
+ const appPathTS = import_path5.default.join(pagesPath, "_app.tsx");
842
991
  const appExtension = import_fs_extra3.default.existsSync(appPath) ? ".js" : ".tsx";
843
992
  let wrapper = false;
844
993
  if (!import_fs_extra3.default.pathExistsSync(appPath) && !import_fs_extra3.default.pathExistsSync(appPathTS)) {
@@ -852,7 +1001,7 @@ async function tinaSetup(ctx, next, options) {
852
1001
  });
853
1002
  if (override.res) {
854
1003
  logger.info(logText(`Adding _app${appExtension} ... \u2705`));
855
- const appPathWithExtension = import_path4.default.join(pagesPath, `_app${appExtension}`);
1004
+ const appPathWithExtension = import_path5.default.join(pagesPath, `_app${appExtension}`);
856
1005
  const fileContent = import_fs_extra3.default.pathExistsSync(appPath) ? (0, import_fs_extra3.readFileSync)(appPath) : (0, import_fs_extra3.readFileSync)(appPathTS);
857
1006
  const matches = [
858
1007
  ...fileContent.toString().matchAll(/^.*import.*\.css("|').*$/gm)
@@ -865,14 +1014,14 @@ async function tinaSetup(ctx, next, options) {
865
1014
  `, warnText(AppJsContent())));
866
1015
  }
867
1016
  }
868
- const tinaBlogPagePath = import_path4.default.join(pagesPath, "demo", "blog");
869
- const tinaBlogPagePathFile = import_path4.default.join(tinaBlogPagePath, "[filename].js");
1017
+ const tinaBlogPagePath = import_path5.default.join(pagesPath, "demo", "blog");
1018
+ const tinaBlogPagePathFile = import_path5.default.join(tinaBlogPagePath, "[filename].js");
870
1019
  if (!import_fs_extra3.default.pathExistsSync(tinaBlogPagePathFile)) {
871
1020
  import_fs_extra3.default.mkdirpSync(tinaBlogPagePath);
872
1021
  import_fs_extra3.default.writeFileSync(tinaBlogPagePathFile, nextPostPage());
873
1022
  }
874
1023
  logger.info("Adding a content folder... \u2705");
875
- const packagePath = import_path4.default.join(baseDir, "package.json");
1024
+ const packagePath = import_path5.default.join(baseDir, "package.json");
876
1025
  const pack = JSON.parse((0, import_fs_extra3.readFileSync)(packagePath).toString());
877
1026
  const oldScripts = pack.scripts || {};
878
1027
  const newPack = JSON.stringify({
@@ -885,8 +1034,8 @@ async function tinaSetup(ctx, next, options) {
885
1034
  }
886
1035
  }, null, 2);
887
1036
  (0, import_fs_extra3.writeFileSync)(packagePath, newPack);
888
- const adminPath = import_path4.default.join(pagesPath, "admin.tsx");
889
- const adminPathJS = import_path4.default.join(pagesPath, "admin.js");
1037
+ const adminPath = import_path5.default.join(pagesPath, "admin.tsx");
1038
+ const adminPathJS = import_path5.default.join(pagesPath, "admin.js");
890
1039
  if (!import_fs_extra3.default.existsSync(adminPath) && !import_fs_extra3.default.existsSync(adminPathJS)) {
891
1040
  import_fs_extra3.default.writeFileSync(adminPathJS, adminPage);
892
1041
  } else {
@@ -897,7 +1046,7 @@ async function tinaSetup(ctx, next, options) {
897
1046
  message: `Whoops... looks like you already have an admin${extension} do you want to override it?`
898
1047
  });
899
1048
  if (override.override) {
900
- import_fs_extra3.default.writeFileSync(import_path4.default.join(pagesPath, "admin" + extension), adminPage);
1049
+ import_fs_extra3.default.writeFileSync(import_path5.default.join(pagesPath, "admin" + extension), adminPage);
901
1050
  } else {
902
1051
  const res = await (0, import_prompts.default)({
903
1052
  name: "name",
@@ -905,11 +1054,11 @@ async function tinaSetup(ctx, next, options) {
905
1054
  message: warnText("What would you like the route to be named that enters edit mode?: ")
906
1055
  });
907
1056
  const adminName = res.name || "admin";
908
- import_fs_extra3.default.writeFileSync(import_path4.default.join(pagesPath, adminName + extension), adminPage);
1057
+ import_fs_extra3.default.writeFileSync(import_path5.default.join(pagesPath, adminName + extension), adminPage);
909
1058
  }
910
1059
  }
911
- const exitAdminPath = import_path4.default.join(pagesPath, "exit-admin.tsx");
912
- const exitAdminPathJS = import_path4.default.join(pagesPath, "exit-admin.js");
1060
+ const exitAdminPath = import_path5.default.join(pagesPath, "exit-admin.tsx");
1061
+ const exitAdminPathJS = import_path5.default.join(pagesPath, "exit-admin.js");
913
1062
  if (!import_fs_extra3.default.existsSync(exitAdminPath) && !import_fs_extra3.default.existsSync(exitAdminPathJS)) {
914
1063
  import_fs_extra3.default.writeFileSync(exitAdminPathJS, exitAdminPage);
915
1064
  } else {
@@ -920,7 +1069,7 @@ async function tinaSetup(ctx, next, options) {
920
1069
  message: `Whoops... looks like you already have an exit-admin${extension} do you want to override it?`
921
1070
  });
922
1071
  if (override.override) {
923
- import_fs_extra3.default.writeFileSync(import_path4.default.join(pagesPath, "exit-admin" + extension), exitAdminPage);
1072
+ import_fs_extra3.default.writeFileSync(import_path5.default.join(pagesPath, "exit-admin" + extension), exitAdminPage);
924
1073
  } else {
925
1074
  const res = await (0, import_prompts.default)({
926
1075
  name: "name",
@@ -928,7 +1077,7 @@ async function tinaSetup(ctx, next, options) {
928
1077
  message: warnText("What would you like the route to be named that exits edit mode?: ")
929
1078
  });
930
1079
  const adminName = res.name || "exit-admin";
931
- import_fs_extra3.default.writeFileSync(import_path4.default.join(pagesPath, adminName + extension), exitAdminPage);
1080
+ import_fs_extra3.default.writeFileSync(import_path5.default.join(pagesPath, adminName + extension), exitAdminPage);
932
1081
  }
933
1082
  }
934
1083
  next();
@@ -1049,7 +1198,7 @@ async function init(args) {
1049
1198
  program.on("--help", function() {
1050
1199
  logger.info(logText(`
1051
1200
  You can get help on any command with "-h" or "--help".
1052
- e.g: "forestry types:gen --help"
1201
+ e.g: "tinacms server:start --help"
1053
1202
  `));
1054
1203
  });
1055
1204
  if (!process.argv.slice(2).length) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tinacms/cli",
3
- "version": "0.56.2",
3
+ "version": "0.57.0",
4
4
  "main": "dist/index.js",
5
5
  "typings": "dist/index.d.ts",
6
6
  "files": [
@@ -21,7 +21,7 @@
21
21
  ]
22
22
  },
23
23
  "devDependencies": {
24
- "@tinacms/scripts": "0.50.3",
24
+ "@tinacms/scripts": "0.50.4",
25
25
  "@types/clear": "0.1.0",
26
26
  "@types/cors": "2.8.5",
27
27
  "@types/express": "^4.17.7",
@@ -38,24 +38,28 @@
38
38
  "@types/progress": "^2.0.3",
39
39
  "@types/prompts": "^2.0.13",
40
40
  "@types/yup": "^0.29.11",
41
- "jest": "^27.0.6",
42
- "ts-jest": "^26.5.3"
41
+ "jest": "^27.0.6"
43
42
  },
44
43
  "scripts": {
45
- "build": "yarn tsup src/index.ts --format cjs --dts",
46
- "watch": "yarn tsup src/index.ts --watch --format cjs --dts",
44
+ "build": "echo \"Run `yarn build` from the root of the repository instead\"",
47
45
  "test": "jest --passWithNoTests",
48
46
  "types": "yarn tsc",
49
47
  "test-watch": "jest --passWithNoTests --watch",
50
48
  "generate:schema": "yarn node scripts/generateSchema.js"
51
49
  },
52
50
  "dependencies": {
53
- "@graphql-codegen/core": "^1.17.0",
54
- "@graphql-codegen/typescript": "^1.17.0",
55
- "@graphql-codegen/typescript-operations": "^1.17.0",
56
- "@tinacms/graphql": "0.55.2",
51
+ "@graphql-codegen/core": "^2.1.0",
52
+ "@graphql-codegen/plugin-helpers": "latest",
53
+ "@graphql-codegen/typescript": "^2.2.2",
54
+ "@graphql-codegen/typescript-generic-sdk": "^2.1.4",
55
+ "@graphql-codegen/typescript-operations": "^2.1.4",
56
+ "@graphql-codegen/visitor-plugin-common": "^2.4.0",
57
+ "@graphql-tools/graphql-file-loader": "^7.2.0",
58
+ "@graphql-tools/load": "^7.3.2",
59
+ "@tinacms/graphql": "0.57.0",
57
60
  "ajv": "^6.12.3",
58
61
  "altair-express-middleware": "4.0.6",
62
+ "auto-bind": "^4.0.0",
59
63
  "axios": "0.19.0",
60
64
  "body-parser": "^1.19.0",
61
65
  "chalk": "^2.4.2",
@@ -74,7 +78,6 @@
74
78
  "normalize-path": "^3.0.0",
75
79
  "progress": "^2.0.3",
76
80
  "prompts": "^2.4.1",
77
- "tsup": "4.6.1",
78
81
  "typescript": "^4.3.5",
79
82
  "yup": "^0.32.9"
80
83
  },