@tinacms/cli 0.57.0 → 0.58.1

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,44 @@
1
1
  # tinacms-cli
2
2
 
3
+ ## 0.58.1
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [4700d7ae4]
8
+ - @tinacms/graphql@0.58.1
9
+
10
+ ## 0.58.0
11
+
12
+ ### Minor Changes
13
+
14
+ - fa7a0419f: Adds experimental support for a data layer between file-based content and the GraphQL API. This allows documents to be indexed so the CMS can behave more like a traditional CMS, with the ability enforce foreign reference constraints and filtering/pagination capabilities.
15
+ - 8c14f29ef: Updated cli to include a new option, `--noSDK`. When this flag is present it will not generate the SDK.
16
+
17
+ ### Patch Changes
18
+
19
+ - 9c5f888a3: Modifies `tinacms init` for `TinaAdmin`-ready page
20
+ - Updated dependencies [eb5fbfac7]
21
+ - Updated dependencies [fa7a0419f]
22
+ - Updated dependencies [47d126029]
23
+ - @tinacms/graphql@0.58.0
24
+
25
+ ## 0.57.2
26
+
27
+ ### Patch Changes
28
+
29
+ - edb2f4011: Trim path property on collections during compilation
30
+ - Updated dependencies [edb2f4011]
31
+ - @tinacms/graphql@0.57.2
32
+
33
+ ## 0.57.1
34
+
35
+ ### Patch Changes
36
+
37
+ - 50710e1d0: Add no-check for Typescript-generated file
38
+ - c78d981e6: Reset entire **generated** folder on re-compile
39
+ - Updated dependencies [60729f60c]
40
+ - @tinacms/graphql@0.57.1
41
+
3
42
  ## 0.57.0
4
43
 
5
44
  ### Minor Changes
@@ -11,5 +11,6 @@ See the License for the specific language governing permissions and
11
11
  limitations under the License.
12
12
  */
13
13
  import type { TinaCloudSchema } from '@tinacms/graphql';
14
+ export declare const resetGeneratedFolder: () => Promise<void>;
14
15
  export declare const compile: (_ctx: any, _next: any) => Promise<void>;
15
16
  export declare const defineSchema: (config: TinaCloudSchema) => TinaCloudSchema;
@@ -10,8 +10,7 @@ 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 adminPage = "import { useEffect } from \"react\";\nimport { useRouter } from \"next/router\";\nimport { useEditState } from \"tinacms/dist/edit-state\";\n\nconst GoToEditPage = () => {\n const { setEdit } = useEditState();\n const router = useRouter();\n useEffect(() => {\n setEdit(true);\n router.back();\n }, []);\n return <div>Entering edit mode..</div>;\n};\n\nexport default GoToEditPage;\n";
14
- export declare const exitAdminPage = "import { useEffect } from \"react\";\nimport { useRouter } from \"next/router\";\nimport { useEditState } from \"tinacms/dist/edit-state\";\n\nconst GoToEditPage = () => {\n const { setEdit } = useEditState();\n const router = useRouter();\n useEffect(() => {\n setEdit(false);\n router.back();\n }, []);\n return <div>Exiting edit mode..</div>;;\n};\n\nexport default GoToEditPage;\n";
13
+ export declare const adminPage = "import { TinaAdmin } from 'tinacms';\nexport default TinaAdmin;\n";
15
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";
16
15
  export declare const nextPostPage: () => string;
17
16
  export declare const AppJsContent: (extraImports?: string) => string;
@@ -13,8 +13,9 @@ limitations under the License.
13
13
  interface Options {
14
14
  port?: number;
15
15
  command?: string;
16
- experimental?: boolean;
16
+ experimentalData?: boolean;
17
17
  noWatch?: boolean;
18
+ noSDK: boolean;
18
19
  }
19
- export declare function startServer(_ctx: any, _next: any, { port, command, experimental, noWatch }: Options): Promise<void>;
20
+ export declare function startServer(_ctx: any, _next: any, { port, command, noWatch, experimentalData, noSDK }: Options): Promise<void>;
20
21
  export {};
@@ -12,5 +12,5 @@ limitations under the License.
12
12
  */
13
13
  /// <reference types="node" />
14
14
  import http from 'http';
15
- declare const gqlServer: () => Promise<http.Server>;
15
+ declare const gqlServer: (database: any) => Promise<http.Server>;
16
16
  export default gqlServer;
@@ -11,4 +11,6 @@ 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, queryPathGlob?: string, fragDocPath?: string) => Promise<string>;
14
+ export declare const generateTypes: (schema: GraphQLSchema, queryPathGlob?: string, fragDocPath?: string, options?: {
15
+ noSDK: boolean;
16
+ }) => Promise<string>;
package/dist/index.js CHANGED
@@ -25,22 +25,21 @@ var __toModule = (module2) => {
25
25
  return __reExport(__markAsModule(__defProp(module2 != null ? __create(__getProtoOf(module2)) : {}, "default", module2 && module2.__esModule && "default" in module2 ? { get: () => module2.default, enumerable: true } : { value: module2, enumerable: true })), module2);
26
26
  };
27
27
 
28
- // pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/cli/src/cmds/start-server/server.ts
28
+ // pnp:/Users/jeffsee/code/tinacms/packages/@tinacms/cli/src/cmds/start-server/server.ts
29
29
  var server_exports = {};
30
30
  __export(server_exports, {
31
31
  default: () => server_default
32
32
  });
33
- var import_path3, 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, GITHUB_ACCESS_TOKEN, gqlServer, server_default;
34
34
  var init_server = __esm({
35
- "pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/cli/src/cmds/start-server/server.ts"() {
36
- import_path3 = __toModule(require("path"));
35
+ "pnp:/Users/jeffsee/code/tinacms/packages/@tinacms/cli/src/cmds/start-server/server.ts"() {
37
36
  import_cors = __toModule(require("cors"));
38
37
  import_http = __toModule(require("http"));
39
38
  import_express = __toModule(require("express"));
40
39
  import_altair_express_middleware = __toModule(require("altair-express-middleware"));
41
40
  import_body_parser = __toModule(require("body-parser"));
42
41
  GITHUB_ACCESS_TOKEN = process.env.GITHUB_PERSONAL_ACCESS_TOKEN;
43
- gqlServer = async () => {
42
+ gqlServer = async (database) => {
44
43
  const gqlPackage = require("@tinacms/graphql");
45
44
  const app = (0, import_express.default)();
46
45
  const server = import_http.default.createServer(app);
@@ -63,11 +62,10 @@ var init_server = __esm({
63
62
  }
64
63
  }`
65
64
  }));
66
- const rootPath = import_path3.default.join(process.cwd());
67
65
  app.post("/graphql", async (req, res) => {
68
66
  const { query, variables } = req.body;
69
- const result = await gqlPackage.gql({
70
- rootPath,
67
+ const result = await gqlPackage.resolve({
68
+ database,
71
69
  query,
72
70
  variables
73
71
  });
@@ -109,18 +107,18 @@ var init_server = __esm({
109
107
  }
110
108
  });
111
109
 
112
- // pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/cli/src/index.ts
110
+ // pnp:/Users/jeffsee/code/tinacms/packages/@tinacms/cli/src/index.ts
113
111
  __export(exports, {
114
112
  defineSchema: () => defineSchema,
115
113
  init: () => init
116
114
  });
117
115
  var commander = __toModule(require("commander"));
118
116
 
119
- // pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/cli/package.json
117
+ // pnp:/Users/jeffsee/code/tinacms/packages/@tinacms/cli/package.json
120
118
  var name = "@tinacms/cli";
121
- var version = "0.57.0";
119
+ var version = "0.58.0";
122
120
 
123
- // pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/cli/src/utils/theme.ts
121
+ // pnp:/Users/jeffsee/code/tinacms/packages/@tinacms/cli/src/utils/theme.ts
124
122
  var import_chalk = __toModule(require("chalk"));
125
123
  var successText = import_chalk.default.bold.green;
126
124
  var dangerText = import_chalk.default.bold.red;
@@ -131,7 +129,7 @@ var logText = import_chalk.default.italic.gray;
131
129
  var warnText = import_chalk.default.yellowBright.bgBlack;
132
130
  var CONFIRMATION_TEXT = import_chalk.default.dim("enter to confirm");
133
131
 
134
- // pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/cli/src/middleware.ts
132
+ // pnp:/Users/jeffsee/code/tinacms/packages/@tinacms/cli/src/middleware.ts
135
133
  var chain = async (cmds, options) => {
136
134
  const ctx = {};
137
135
  const next = async (middlewareIndex) => {
@@ -150,10 +148,10 @@ var chain = async (cmds, options) => {
150
148
  }
151
149
  };
152
150
 
153
- // pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/cli/src/cmds/query-gen/attachSchema.ts
151
+ // pnp:/Users/jeffsee/code/tinacms/packages/@tinacms/cli/src/cmds/query-gen/attachSchema.ts
154
152
  var import_graphql = __toModule(require("@tinacms/graphql"));
155
153
 
156
- // pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/cli/src/logger/index.ts
154
+ // pnp:/Users/jeffsee/code/tinacms/packages/@tinacms/cli/src/logger/index.ts
157
155
  var import_log4js = __toModule(require("log4js"));
158
156
  var logger = import_log4js.default.getLogger();
159
157
  import_log4js.default.configure({
@@ -164,22 +162,25 @@ import_log4js.default.configure({
164
162
  });
165
163
  logger.level = "info";
166
164
 
167
- // pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/cli/src/cmds/query-gen/attachSchema.ts
165
+ // pnp:/Users/jeffsee/code/tinacms/packages/@tinacms/cli/src/cmds/query-gen/attachSchema.ts
168
166
  async function attachSchema(ctx, next, options) {
169
167
  logger.info(logText("Building schema..."));
170
168
  const rootPath = process.cwd();
171
- const schema = await (0, import_graphql.buildSchema)(rootPath);
169
+ const bridge = new import_graphql.FilesystemBridge(rootPath);
170
+ const store = new import_graphql.FilesystemStore({ rootPath });
171
+ const database = await (0, import_graphql.createDatabase)({ store, bridge });
172
+ const schema = await (0, import_graphql.buildSchema)(rootPath, database);
172
173
  ctx.schema = schema;
173
174
  next();
174
175
  }
175
176
 
176
- // pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/cli/src/codegen/index.ts
177
+ // pnp:/Users/jeffsee/code/tinacms/packages/@tinacms/cli/src/codegen/index.ts
177
178
  var import_graphql5 = __toModule(require("graphql"));
178
179
  var import_core = __toModule(require("@graphql-codegen/core"));
179
180
  var import_typescript = __toModule(require("@graphql-codegen/typescript"));
180
181
  var import_typescript_operations = __toModule(require("@graphql-codegen/typescript-operations"));
181
182
 
182
- // pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/cli/src/codegen/plugin.ts
183
+ // pnp:/Users/jeffsee/code/tinacms/packages/@tinacms/cli/src/codegen/plugin.ts
183
184
  var AddGeneratedClientFunc = (_schema, _documents, _config, _info) => {
184
185
  return `
185
186
  // TinaSDK generated code
@@ -204,12 +205,12 @@ var AddGeneratedClient = {
204
205
  plugin: AddGeneratedClientFunc
205
206
  };
206
207
 
207
- // pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/cli/src/codegen/sdkPlugin/index.ts
208
+ // pnp:/Users/jeffsee/code/tinacms/packages/@tinacms/cli/src/codegen/sdkPlugin/index.ts
208
209
  var import_graphql3 = __toModule(require("graphql"));
209
210
  var import_graphql4 = __toModule(require("graphql"));
210
211
  var import_path = __toModule(require("path"));
211
212
 
212
- // pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/cli/src/codegen/sdkPlugin/visitor.ts
213
+ // pnp:/Users/jeffsee/code/tinacms/packages/@tinacms/cli/src/codegen/sdkPlugin/visitor.ts
213
214
  var import_visitor_plugin_common = __toModule(require("@graphql-codegen/visitor-plugin-common"));
214
215
  var import_auto_bind = __toModule(require("auto-bind"));
215
216
  var import_graphql2 = __toModule(require("graphql"));
@@ -259,7 +260,7 @@ var GenericSdkVisitor = class extends import_visitor_plugin_common.ClientSideBas
259
260
  }
260
261
  };
261
262
 
262
- // pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/cli/src/codegen/sdkPlugin/index.ts
263
+ // pnp:/Users/jeffsee/code/tinacms/packages/@tinacms/cli/src/codegen/sdkPlugin/index.ts
263
264
  var plugin = (schema, documents, config) => {
264
265
  const allAst = (0, import_graphql4.concatAST)(documents.reduce((prev, v) => {
265
266
  return [...prev, v.document];
@@ -285,18 +286,20 @@ var plugin = (schema, documents, config) => {
285
286
  };
286
287
  };
287
288
 
288
- // pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/cli/src/codegen/index.ts
289
+ // pnp:/Users/jeffsee/code/tinacms/packages/@tinacms/cli/src/codegen/index.ts
289
290
  var import_load = __toModule(require("@graphql-tools/load"));
290
291
  var import_graphql_file_loader = __toModule(require("@graphql-tools/graphql-file-loader"));
291
- var generateTypes = async (schema, queryPathGlob = process.cwd(), fragDocPath = process.cwd()) => {
292
+ var generateTypes = async (schema, queryPathGlob = process.cwd(), fragDocPath = process.cwd(), options = { noSDK: false }) => {
292
293
  logger.info("Generating types...");
293
294
  try {
294
295
  let docs = [];
295
296
  let fragDocs = [];
296
297
  try {
297
- docs = await (0, import_load.loadDocuments)(queryPathGlob, {
298
- loaders: [new import_graphql_file_loader.GraphQLFileLoader()]
299
- });
298
+ if (!options.noSDK) {
299
+ docs = await (0, import_load.loadDocuments)(queryPathGlob, {
300
+ loaders: [new import_graphql_file_loader.GraphQLFileLoader()]
301
+ });
302
+ }
300
303
  } catch (e) {
301
304
  let showErrorMessage = true;
302
305
  const message = e.message || "";
@@ -308,9 +311,11 @@ var generateTypes = async (schema, queryPathGlob = process.cwd(), fragDocPath =
308
311
  }
309
312
  }
310
313
  try {
311
- fragDocs = await (0, import_load.loadDocuments)(fragDocPath, {
312
- loaders: [new import_graphql_file_loader.GraphQLFileLoader()]
313
- });
314
+ if (!options.noSDK) {
315
+ fragDocs = await (0, import_load.loadDocuments)(fragDocPath, {
316
+ loaders: [new import_graphql_file_loader.GraphQLFileLoader()]
317
+ });
318
+ }
314
319
  } catch (error) {
315
320
  console.error(error);
316
321
  }
@@ -349,15 +354,16 @@ var generateTypes = async (schema, queryPathGlob = process.cwd(), fragDocPath =
349
354
  }
350
355
  };
351
356
 
352
- // pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/cli/src/cmds/query-gen/genTypes.ts
357
+ // pnp:/Users/jeffsee/code/tinacms/packages/@tinacms/cli/src/cmds/query-gen/genTypes.ts
353
358
  var import_graphql6 = __toModule(require("graphql"));
354
359
  var import_fs_extra = __toModule(require("fs-extra"));
355
360
  async function genTypes({ schema }, next, options) {
356
361
  const typesPath = process.cwd() + "/.tina/__generated__/types.ts";
357
362
  const fragPath = process.cwd() + "/.tina/__generated__/*.{graphql,gql}";
358
363
  const queryPathGlob = process.cwd() + "/.tina/queries/**/*.{graphql,gql}";
359
- const typescriptTypes = await generateTypes(schema, queryPathGlob, fragPath);
360
- await import_fs_extra.default.outputFile(typesPath, `// DO NOT MODIFY THIS FILE. This file is automatically generated by Tina
364
+ const typescriptTypes = await generateTypes(schema, queryPathGlob, fragPath, options);
365
+ await import_fs_extra.default.outputFile(typesPath, `//@ts-nocheck
366
+ // DO NOT MODIFY THIS FILE. This file is automatically generated by Tina
361
367
  ${typescriptTypes}
362
368
  `);
363
369
  logger.info(`Typescript types => ${successText(typesPath)}`);
@@ -374,19 +380,19 @@ schema {
374
380
  next();
375
381
  }
376
382
 
377
- // pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/cli/src/cmds/start-server/index.ts
383
+ // pnp:/Users/jeffsee/code/tinacms/packages/@tinacms/cli/src/cmds/start-server/index.ts
378
384
  var import_child_process = __toModule(require("child_process"));
379
- var import_path4 = __toModule(require("path"));
385
+ var import_path3 = __toModule(require("path"));
380
386
  var import_graphql7 = __toModule(require("@tinacms/graphql"));
381
387
 
382
- // pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/cli/src/cmds/compile/index.ts
388
+ // pnp:/Users/jeffsee/code/tinacms/packages/@tinacms/cli/src/cmds/compile/index.ts
383
389
  var import_fast_glob = __toModule(require("fast-glob"));
384
390
  var import_normalize_path = __toModule(require("normalize-path"));
385
391
  var import_path2 = __toModule(require("path"));
386
392
  var import_fs_extra2 = __toModule(require("fs-extra"));
387
393
  var ts = __toModule(require("typescript"));
388
394
 
389
- // pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/cli/src/cmds/compile/defaultSchema.ts
395
+ // pnp:/Users/jeffsee/code/tinacms/packages/@tinacms/cli/src/cmds/compile/defaultSchema.ts
390
396
  var defaultSchema = `
391
397
  import { defineSchema } from "@tinacms/cli";
392
398
 
@@ -417,10 +423,22 @@ export default defineSchema({
417
423
  });
418
424
  `;
419
425
 
420
- // pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/cli/src/cmds/compile/index.ts
426
+ // pnp:/Users/jeffsee/code/tinacms/packages/@tinacms/cli/src/cmds/compile/index.ts
421
427
  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");
428
+ var tinaGeneratedPath = import_path2.default.join(tinaPath, "__generated__");
429
+ var tinaTempPath = import_path2.default.join(tinaGeneratedPath, "temp");
430
+ var tinaConfigPath = import_path2.default.join(tinaGeneratedPath, "config");
431
+ var resetGeneratedFolder = async () => {
432
+ try {
433
+ await import_fs_extra2.default.rmdir(tinaGeneratedPath, {
434
+ recursive: true
435
+ });
436
+ } catch (e) {
437
+ console.log(e);
438
+ }
439
+ await import_fs_extra2.default.mkdir(tinaGeneratedPath);
440
+ await import_fs_extra2.default.outputFile(import_path2.default.join(tinaGeneratedPath, ".gitignore"), "db");
441
+ };
424
442
  var compile = async (_ctx, _next) => {
425
443
  logger.info(logText("Compiling..."));
426
444
  if (!import_fs_extra2.default.existsSync(tinaPath) || !import_fs_extra2.default.existsSync(import_path2.default.join(tinaPath, "schema.ts"))) {
@@ -432,8 +450,6 @@ var compile = async (_ctx, _next) => {
432
450
  await import_fs_extra2.default.ensureFile(file);
433
451
  await import_fs_extra2.default.writeFile(file, defaultSchema);
434
452
  }
435
- await import_fs_extra2.default.remove(tinaTempPath);
436
- await import_fs_extra2.default.remove(tinaConfigPath);
437
453
  await transpile2(tinaPath, tinaTempPath);
438
454
  Object.keys(require.cache).map((key) => {
439
455
  if (key.startsWith(tinaTempPath)) {
@@ -466,10 +482,18 @@ var defineSchema = (config) => {
466
482
  return config;
467
483
  };
468
484
 
469
- // pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/cli/src/cmds/start-server/index.ts
485
+ // pnp:/Users/jeffsee/code/tinacms/packages/@tinacms/cli/src/cmds/start-server/index.ts
470
486
  var import_chokidar = __toModule(require("chokidar"));
471
487
  var gqlPackageFile = require.resolve("@tinacms/graphql");
472
- async function startServer(_ctx, _next, { port = 4001, command, experimental, noWatch }) {
488
+ async function startServer(_ctx, _next, { port = 4001, command, noWatch, experimentalData, noSDK }) {
489
+ const rootPath = process.cwd();
490
+ if (!process.env.CI && !noWatch) {
491
+ await resetGeneratedFolder();
492
+ }
493
+ const bridge = new import_graphql7.FilesystemBridge(rootPath);
494
+ const store = experimentalData ? new import_graphql7.LevelStore(rootPath) : new import_graphql7.FilesystemStore({ rootPath });
495
+ const shouldBuild = bridge.supportsBuilding();
496
+ const database = await (0, import_graphql7.createDatabase)({ store, bridge });
473
497
  const startSubprocess = () => {
474
498
  if (typeof command === "string") {
475
499
  const commands = command.split(" ");
@@ -492,38 +516,42 @@ stack: ${code.stack || "No stack was provided"}`);
492
516
  });
493
517
  }
494
518
  };
495
- const rootPath = process.cwd();
496
519
  let ready = false;
497
520
  if (!noWatch && !process.env.CI) {
498
- import_chokidar.default.watch(`${rootPath}/**/*.{ts,gql,graphql}`, {
499
- ignored: `${import_path4.default.resolve(rootPath)}/.tina/__generated__/**/*`
521
+ import_chokidar.default.watch([`${rootPath}/**/*.{ts,gql,graphql}`], {
522
+ ignored: `${import_path3.default.resolve(rootPath)}/.tina/__generated__/**/*`
500
523
  }).on("ready", async () => {
501
524
  console.log("Generating Tina config");
502
525
  try {
503
- await build();
526
+ if (shouldBuild) {
527
+ await build(noSDK);
528
+ }
504
529
  ready = true;
505
530
  startSubprocess();
506
531
  } catch (e) {
507
532
  logger.info(dangerText(`${e.message}`));
533
+ console.log(e);
508
534
  process.exit(0);
509
535
  }
510
536
  }).on("all", async () => {
511
537
  if (ready) {
512
538
  logger.info("Tina change detected, regenerating config");
513
539
  try {
514
- await build();
540
+ if (shouldBuild) {
541
+ await build(noSDK);
542
+ }
515
543
  } catch (e) {
516
- logger.info(dangerText("Compilation failed with errors. Server has not been restarted.") + `see error below
544
+ logger.info(dangerText("Compilation failed with errors. Server has not been restarted.") + ` see error below
517
545
  ${e.message}`);
518
546
  }
519
547
  }
520
548
  });
521
549
  }
522
- const build = async () => {
550
+ const build = async (noSDK2) => {
523
551
  await compile(null, null);
524
- const schema = await (0, import_graphql7.buildSchema)(rootPath);
552
+ const schema = await (0, import_graphql7.buildSchema)(rootPath, database);
525
553
  await genTypes({ schema }, () => {
526
- }, {});
554
+ }, { noSDK: noSDK2 });
527
555
  };
528
556
  const state = {
529
557
  server: null,
@@ -532,7 +560,7 @@ stack: ${code.stack || "No stack was provided"}`);
532
560
  let isReady = false;
533
561
  const start = async () => {
534
562
  const s = (init_server(), server_exports);
535
- state.server = await s.default(experimental);
563
+ state.server = await s.default(database);
536
564
  state.server.listen(port, () => {
537
565
  logger.info(`Started Filesystem GraphQL server on port: ${port}`);
538
566
  logger.info(`Visit the playground at http://localhost:${port}/altair/`);
@@ -580,44 +608,15 @@ stack: ${code.stack || "No stack was provided"}`);
580
608
  }
581
609
  }
582
610
 
583
- // pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/cli/src/cmds/init/index.ts
611
+ // pnp:/Users/jeffsee/code/tinacms/packages/@tinacms/cli/src/cmds/init/index.ts
584
612
  var import_fs_extra3 = __toModule(require("fs-extra"));
585
- var import_path5 = __toModule(require("path"));
613
+ var import_path4 = __toModule(require("path"));
586
614
  var import_progress = __toModule(require("progress"));
587
615
  var import_prompts = __toModule(require("prompts"));
588
616
 
589
- // pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/cli/src/cmds/init/setup-files/index.ts
590
- var adminPage = `import { useEffect } from "react";
591
- import { useRouter } from "next/router";
592
- import { useEditState } from "tinacms/dist/edit-state";
593
-
594
- const GoToEditPage = () => {
595
- const { setEdit } = useEditState();
596
- const router = useRouter();
597
- useEffect(() => {
598
- setEdit(true);
599
- router.back();
600
- }, []);
601
- return <div>Entering edit mode..</div>;
602
- };
603
-
604
- export default GoToEditPage;
605
- `;
606
- var exitAdminPage = `import { useEffect } from "react";
607
- import { useRouter } from "next/router";
608
- import { useEditState } from "tinacms/dist/edit-state";
609
-
610
- const GoToEditPage = () => {
611
- const { setEdit } = useEditState();
612
- const router = useRouter();
613
- useEffect(() => {
614
- setEdit(false);
615
- router.back();
616
- }, []);
617
- return <div>Exiting edit mode..</div>;;
618
- };
619
-
620
- export default GoToEditPage;
617
+ // pnp:/Users/jeffsee/code/tinacms/packages/@tinacms/cli/src/cmds/init/setup-files/index.ts
618
+ var adminPage = `import { TinaAdmin } from 'tinacms';
619
+ export default TinaAdmin;
621
620
  `;
622
621
  var blogPost = `---
623
622
  title: Vote For Pedro
@@ -922,7 +921,6 @@ const App = ({ Component, pageProps }) => {
922
921
  <TinaCMS
923
922
  clientId={process.env.NEXT_PUBLIC_TINA_CLIENT_ID}
924
923
  branch={process.env.NEXT_PUBLIC_EDIT_BRANCH}
925
- organization={process.env.NEXT_PUBLIC_ORGANIZATION_NAME}
926
924
  isLocalClient={Boolean(
927
925
  Number(process.env.NEXT_PUBLIC_USE_LOCAL_CLIENT ?? true)
928
926
  )}
@@ -941,7 +939,7 @@ const App = ({ Component, pageProps }) => {
941
939
  export default App
942
940
  `;
943
941
 
944
- // pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/cli/src/cmds/init/index.ts
942
+ // pnp:/Users/jeffsee/code/tinacms/packages/@tinacms/cli/src/cmds/init/index.ts
945
943
  var import_chalk2 = __toModule(require("chalk"));
946
944
  function execShellCommand(cmd) {
947
945
  const exec = require("child_process").exec;
@@ -973,21 +971,21 @@ async function installDeps(ctx, next, options) {
973
971
  next();
974
972
  }
975
973
  var baseDir = process.cwd();
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");
974
+ var TinaWrapperPathDir = import_path4.default.join(baseDir, "components");
975
+ var TinaWrapperPath = import_path4.default.join(TinaWrapperPathDir, "tina-wrapper.tsx");
976
+ var blogContentPath = import_path4.default.join(baseDir, "content", "posts");
977
+ var blogPostPath = import_path4.default.join(blogContentPath, "HelloWorld.md");
980
978
  async function tinaSetup(ctx, next, options) {
981
- const useingSrc = import_fs_extra3.default.pathExistsSync(import_path5.default.join(baseDir, "src"));
979
+ const useingSrc = import_fs_extra3.default.pathExistsSync(import_path4.default.join(baseDir, "src"));
982
980
  if (!import_fs_extra3.default.pathExistsSync(blogPostPath)) {
983
981
  logger.info(logText("Adding a content folder..."));
984
982
  import_fs_extra3.default.mkdirpSync(blogContentPath);
985
983
  import_fs_extra3.default.writeFileSync(blogPostPath, blogPost);
986
984
  }
987
985
  logger.level = "info";
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");
986
+ const pagesPath = import_path4.default.join(baseDir, useingSrc ? "src" : "", "pages");
987
+ const appPath = import_path4.default.join(pagesPath, "_app.js");
988
+ const appPathTS = import_path4.default.join(pagesPath, "_app.tsx");
991
989
  const appExtension = import_fs_extra3.default.existsSync(appPath) ? ".js" : ".tsx";
992
990
  let wrapper = false;
993
991
  if (!import_fs_extra3.default.pathExistsSync(appPath) && !import_fs_extra3.default.pathExistsSync(appPathTS)) {
@@ -1001,7 +999,7 @@ async function tinaSetup(ctx, next, options) {
1001
999
  });
1002
1000
  if (override.res) {
1003
1001
  logger.info(logText(`Adding _app${appExtension} ... \u2705`));
1004
- const appPathWithExtension = import_path5.default.join(pagesPath, `_app${appExtension}`);
1002
+ const appPathWithExtension = import_path4.default.join(pagesPath, `_app${appExtension}`);
1005
1003
  const fileContent = import_fs_extra3.default.pathExistsSync(appPath) ? (0, import_fs_extra3.readFileSync)(appPath) : (0, import_fs_extra3.readFileSync)(appPathTS);
1006
1004
  const matches = [
1007
1005
  ...fileContent.toString().matchAll(/^.*import.*\.css("|').*$/gm)
@@ -1014,14 +1012,14 @@ async function tinaSetup(ctx, next, options) {
1014
1012
  `, warnText(AppJsContent())));
1015
1013
  }
1016
1014
  }
1017
- const tinaBlogPagePath = import_path5.default.join(pagesPath, "demo", "blog");
1018
- const tinaBlogPagePathFile = import_path5.default.join(tinaBlogPagePath, "[filename].js");
1015
+ const tinaBlogPagePath = import_path4.default.join(pagesPath, "demo", "blog");
1016
+ const tinaBlogPagePathFile = import_path4.default.join(tinaBlogPagePath, "[filename].js");
1019
1017
  if (!import_fs_extra3.default.pathExistsSync(tinaBlogPagePathFile)) {
1020
1018
  import_fs_extra3.default.mkdirpSync(tinaBlogPagePath);
1021
1019
  import_fs_extra3.default.writeFileSync(tinaBlogPagePathFile, nextPostPage());
1022
1020
  }
1023
1021
  logger.info("Adding a content folder... \u2705");
1024
- const packagePath = import_path5.default.join(baseDir, "package.json");
1022
+ const packagePath = import_path4.default.join(baseDir, "package.json");
1025
1023
  const pack = JSON.parse((0, import_fs_extra3.readFileSync)(packagePath).toString());
1026
1024
  const oldScripts = pack.scripts || {};
1027
1025
  const newPack = JSON.stringify({
@@ -1034,52 +1032,13 @@ async function tinaSetup(ctx, next, options) {
1034
1032
  }
1035
1033
  }, null, 2);
1036
1034
  (0, import_fs_extra3.writeFileSync)(packagePath, newPack);
1037
- const adminPath = import_path5.default.join(pagesPath, "admin.tsx");
1038
- const adminPathJS = import_path5.default.join(pagesPath, "admin.js");
1039
- if (!import_fs_extra3.default.existsSync(adminPath) && !import_fs_extra3.default.existsSync(adminPathJS)) {
1040
- import_fs_extra3.default.writeFileSync(adminPathJS, adminPage);
1041
- } else {
1042
- const extension = import_fs_extra3.default.existsSync(adminPath) ? ".tsx" : "js";
1043
- const override = await (0, import_prompts.default)({
1044
- name: "override",
1045
- type: "confirm",
1046
- message: `Whoops... looks like you already have an admin${extension} do you want to override it?`
1047
- });
1048
- if (override.override) {
1049
- import_fs_extra3.default.writeFileSync(import_path5.default.join(pagesPath, "admin" + extension), adminPage);
1050
- } else {
1051
- const res = await (0, import_prompts.default)({
1052
- name: "name",
1053
- type: "text",
1054
- message: warnText("What would you like the route to be named that enters edit mode?: ")
1055
- });
1056
- const adminName = res.name || "admin";
1057
- import_fs_extra3.default.writeFileSync(import_path5.default.join(pagesPath, adminName + extension), adminPage);
1058
- }
1059
- }
1060
- const exitAdminPath = import_path5.default.join(pagesPath, "exit-admin.tsx");
1061
- const exitAdminPathJS = import_path5.default.join(pagesPath, "exit-admin.js");
1062
- if (!import_fs_extra3.default.existsSync(exitAdminPath) && !import_fs_extra3.default.existsSync(exitAdminPathJS)) {
1063
- import_fs_extra3.default.writeFileSync(exitAdminPathJS, exitAdminPage);
1064
- } else {
1065
- const extension = import_fs_extra3.default.existsSync(exitAdminPath) ? ".tsx" : "js";
1066
- const override = await (0, import_prompts.default)({
1067
- name: "override",
1068
- type: "confirm",
1069
- message: `Whoops... looks like you already have an exit-admin${extension} do you want to override it?`
1070
- });
1071
- if (override.override) {
1072
- import_fs_extra3.default.writeFileSync(import_path5.default.join(pagesPath, "exit-admin" + extension), exitAdminPage);
1073
- } else {
1074
- const res = await (0, import_prompts.default)({
1075
- name: "name",
1076
- type: "text",
1077
- message: warnText("What would you like the route to be named that exits edit mode?: ")
1078
- });
1079
- const adminName = res.name || "exit-admin";
1080
- import_fs_extra3.default.writeFileSync(import_path5.default.join(pagesPath, adminName + extension), exitAdminPage);
1081
- }
1035
+ const adminPath = import_path4.default.join(pagesPath, "admin", "[[...tina]].js");
1036
+ if (import_fs_extra3.default.pathExistsSync(import_path4.default.join(pagesPath, "admin"))) {
1037
+ logger.warn(`Unable to add /pages/admin/[[...tina]].js, this path already exists.
1038
+ Learn more about toggling edit-mode at https://tina.io/docs/tinacms-context/#manually-toggling-edit-mode`);
1039
+ return next();
1082
1040
  }
1041
+ (0, import_fs_extra3.outputFileSync)(adminPath, adminPage);
1083
1042
  next();
1084
1043
  }
1085
1044
  async function successMessage(ctx, next, options) {
@@ -1091,7 +1050,7 @@ Enjoy Tina \u{1F999} !
1091
1050
  next();
1092
1051
  }
1093
1052
 
1094
- // pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/cli/src/cmds/baseCmds.ts
1053
+ // pnp:/Users/jeffsee/code/tinacms/packages/@tinacms/cli/src/cmds/baseCmds.ts
1095
1054
  var CMD_GEN_TYPES = "schema:types";
1096
1055
  var CMD_START_SERVER = "server:start";
1097
1056
  var CMD_COMPILE_MODELS = "schema:compile";
@@ -1100,40 +1059,50 @@ var startServerPortOption = {
1100
1059
  name: "--port <port>",
1101
1060
  description: "Specify a port to run the server on. (default 4001)"
1102
1061
  };
1062
+ var experimentalDatalayer = {
1063
+ name: "--experimentalData",
1064
+ description: "Build the server with additional data querying capabilities"
1065
+ };
1103
1066
  var subCommand = {
1104
1067
  name: "-c, --command <command>",
1105
1068
  description: "The sub-command to run"
1106
1069
  };
1107
- var experimentalCommand = {
1108
- name: "--experimental",
1109
- description: "Run the unstable version of this service"
1110
- };
1111
1070
  var noWatchOption = {
1112
1071
  name: "--noWatch",
1113
1072
  description: "Don't regenerate config on file changes"
1114
1073
  };
1074
+ var noSDKCodegenOption = {
1075
+ name: "--noSDK",
1076
+ description: "Don't generate the generated client SDK"
1077
+ };
1115
1078
  var baseCmds = [
1116
1079
  {
1117
1080
  command: CMD_START_SERVER,
1118
1081
  description: "Start Filesystem Graphql Server",
1119
- options: [startServerPortOption, subCommand, experimentalCommand, noWatchOption],
1082
+ options: [
1083
+ startServerPortOption,
1084
+ subCommand,
1085
+ experimentalDatalayer,
1086
+ noWatchOption,
1087
+ noSDKCodegenOption
1088
+ ],
1120
1089
  action: (options) => chain([startServer], options)
1121
1090
  },
1122
1091
  {
1123
1092
  command: CMD_COMPILE_MODELS,
1124
1093
  description: "Compile schema into static files for the server",
1125
- options: [experimentalCommand],
1094
+ options: [experimentalDatalayer],
1126
1095
  action: (options) => chain([compile], options)
1127
1096
  },
1128
1097
  {
1129
1098
  command: CMD_GEN_TYPES,
1130
1099
  description: "Generate a GraphQL query for your site's schema, (and optionally Typescript types)",
1131
- options: [experimentalCommand],
1100
+ options: [experimentalDatalayer, noSDKCodegenOption],
1132
1101
  action: (options) => chain([attachSchema, genTypes], options)
1133
1102
  },
1134
1103
  {
1135
1104
  command: INIT,
1136
- options: [experimentalCommand],
1105
+ options: [experimentalDatalayer],
1137
1106
  description: "Add Tina Cloud to an existing project",
1138
1107
  action: (options) => chain([
1139
1108
  initTina,
@@ -1150,7 +1119,7 @@ var baseCmds = [
1150
1119
  }
1151
1120
  ];
1152
1121
 
1153
- // pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/cli/src/index.ts
1122
+ // pnp:/Users/jeffsee/code/tinacms/packages/@tinacms/cli/src/index.ts
1154
1123
  var program = new commander.Command(name);
1155
1124
  var registerCommands = (commands, noHelp = false) => {
1156
1125
  commands.forEach((command, i) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tinacms/cli",
3
- "version": "0.57.0",
3
+ "version": "0.58.1",
4
4
  "main": "dist/index.js",
5
5
  "typings": "dist/index.d.ts",
6
6
  "files": [
@@ -56,7 +56,7 @@
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.57.0",
59
+ "@tinacms/graphql": "0.58.1",
60
60
  "ajv": "^6.12.3",
61
61
  "altair-express-middleware": "4.0.6",
62
62
  "auto-bind": "^4.0.0",