@tinacms/cli 0.60.5 → 0.60.6

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,24 @@
1
1
  # tinacms-cli
2
2
 
3
+ ## 0.60.6
4
+
5
+ ### Patch Changes
6
+
7
+ - 98622111d: Use [esbuild](https://esbuild.github.io/) to build the schema instead of typescript.
8
+
9
+ This allows the user to
10
+
11
+ - use non typescript files like JS, JSX, TS
12
+ - Import from outside of the tina folder
13
+
14
+ The downside
15
+
16
+ - Now type errors will still pass (The schema will compile) and one will get an error at runtime instead of compile time
17
+
18
+ - Updated dependencies [c730fa1dd]
19
+ - Updated dependencies [cd0f6f022]
20
+ - @tinacms/graphql@0.59.7
21
+
3
22
  ## 0.60.5
4
23
 
5
24
  ### Patch Changes
@@ -0,0 +1,19 @@
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
+ export declare class BuildSchemaError extends Error {
14
+ constructor(message: any);
15
+ }
16
+ export declare class ExecuteSchemaError extends Error {
17
+ constructor(message: any);
18
+ }
19
+ export declare const handleServerErrors: (e: Error) => void;
@@ -13,10 +13,11 @@ limitations under the License.
13
13
  interface Options {
14
14
  port?: number;
15
15
  command?: string;
16
+ watchFolders?: string[];
16
17
  experimentalData?: boolean;
17
18
  noWatch?: boolean;
18
19
  noSDK: boolean;
19
20
  noTelemetry: boolean;
20
21
  }
21
- export declare function startServer(_ctx: any, _next: any, { port, command, noWatch, experimentalData, noSDK, noTelemetry, }: Options): Promise<void>;
22
+ export declare function startServer(_ctx: any, _next: any, { port, command, noWatch, experimentalData, noSDK, noTelemetry, watchFolders, }: Options): Promise<void>;
22
23
  export {};
@@ -0,0 +1,18 @@
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
+ export declare class AsyncLock {
14
+ disable: any;
15
+ promise: any;
16
+ constructor();
17
+ enable(): void;
18
+ }
package/dist/index.js CHANGED
@@ -114,7 +114,7 @@ var commander = __toModule(require("commander"));
114
114
 
115
115
  // pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/cli/package.json
116
116
  var name = "@tinacms/cli";
117
- var version = "0.60.5";
117
+ var version = "0.60.6";
118
118
 
119
119
  // pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/cli/src/utils/theme.ts
120
120
  var import_chalk = __toModule(require("chalk"));
@@ -391,16 +391,14 @@ schema {
391
391
 
392
392
  // pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/cli/src/cmds/start-server/index.ts
393
393
  var import_child_process = __toModule(require("child_process"));
394
- var import_path3 = __toModule(require("path"));
394
+ var import_path4 = __toModule(require("path"));
395
395
  var import_graphql7 = __toModule(require("@tinacms/graphql"));
396
396
  var import_datalayer2 = __toModule(require("@tinacms/datalayer"));
397
397
 
398
398
  // pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/cli/src/cmds/compile/index.ts
399
- var import_fast_glob = __toModule(require("fast-glob"));
400
- var import_normalize_path = __toModule(require("normalize-path"));
401
- var import_path2 = __toModule(require("path"));
402
- var import_fs_extra2 = __toModule(require("fs-extra"));
403
- var ts = __toModule(require("typescript"));
399
+ var import_path3 = __toModule(require("path"));
400
+ var import_fs_extra3 = __toModule(require("fs-extra"));
401
+ var import_esbuild = __toModule(require("esbuild"));
404
402
 
405
403
  // pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/cli/src/cmds/compile/defaultSchema.ts
406
404
  var defaultSchema = `
@@ -433,68 +431,188 @@ export default defineSchema({
433
431
  });
434
432
  `;
435
433
 
434
+ // pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/cli/src/lib/getSchemaPath.ts
435
+ var import_path2 = __toModule(require("path"));
436
+ var import_fs_extra2 = __toModule(require("fs-extra"));
437
+ var ErrorMessage = "Must provide a `.tina/schema.{ts,js,tsx,jsx}`";
438
+ var getSchemaPath = ({ projectDir }) => {
439
+ if (!import_fs_extra2.default.existsSync(projectDir)) {
440
+ throw new Error(ErrorMessage);
441
+ }
442
+ const inputPathTS = import_path2.default.join(projectDir, "schema.ts");
443
+ const inputPathJS = import_path2.default.join(projectDir, "schema.js");
444
+ const inputPathTSX = import_path2.default.join(projectDir, "schema.tsx");
445
+ const inputPathJSX = import_path2.default.join(projectDir, "schema.jsx");
446
+ let inputFile;
447
+ if (import_fs_extra2.default.existsSync(inputPathTS)) {
448
+ inputFile = inputPathTS;
449
+ } else if (import_fs_extra2.default.existsSync(inputPathJS)) {
450
+ inputFile = inputPathJS;
451
+ } else if (import_fs_extra2.default.existsSync(inputPathTSX)) {
452
+ inputFile = inputPathTSX;
453
+ } else if (import_fs_extra2.default.existsSync(inputPathJSX)) {
454
+ inputFile = inputPathJSX;
455
+ }
456
+ if (!inputFile) {
457
+ throw new Error(ErrorMessage);
458
+ }
459
+ return inputFile;
460
+ };
461
+
462
+ // pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/cli/src/cmds/start-server/errors/index.ts
463
+ var BuildSchemaError = class extends Error {
464
+ constructor(message) {
465
+ super(message);
466
+ this.name = "BuildSchemaError";
467
+ }
468
+ };
469
+ var ExecuteSchemaError = class extends Error {
470
+ constructor(message) {
471
+ super(message);
472
+ this.name = "ExecuteSchemaError";
473
+ }
474
+ };
475
+ var handleServerErrors = (e) => {
476
+ if (e instanceof BuildSchemaError) {
477
+ logger.error(`${dangerText("ERROR: your schema was not successfully built: see https://tina.io/docs/errors/esbuild-error/ for more details")}
478
+ Error Message Below
479
+ ${e}`);
480
+ } else if (e instanceof ExecuteSchemaError) {
481
+ logger.error(`${dangerText("ERROR: your schema was not successfully executed: see https://tina.io/docs/errors/esbuild-error/ for more details")}
482
+ Error Message Below
483
+ ${e}`);
484
+ } else {
485
+ logger.info(dangerText("Compilation failed with errors. Server has not been restarted.") + ` see error below
486
+ ${e.message}`);
487
+ }
488
+ };
489
+
436
490
  // pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/cli/src/cmds/compile/index.ts
437
- var tinaPath = import_path2.default.join(process.cwd(), ".tina");
438
- var tinaGeneratedPath = import_path2.default.join(tinaPath, "__generated__");
439
- var tinaTempPath = import_path2.default.join(tinaGeneratedPath, "temp");
440
- var tinaConfigPath = import_path2.default.join(tinaGeneratedPath, "config");
491
+ var tinaPath = import_path3.default.join(process.cwd(), ".tina");
492
+ var packageJSONFilePath = import_path3.default.join(process.cwd(), "package.json");
493
+ var tinaGeneratedPath = import_path3.default.join(tinaPath, "__generated__");
494
+ var tinaTempPath = import_path3.default.join(tinaGeneratedPath, "temp");
495
+ var tinaConfigPath = import_path3.default.join(tinaGeneratedPath, "config");
441
496
  var resetGeneratedFolder = async () => {
442
497
  try {
443
- await import_fs_extra2.default.rmdir(tinaGeneratedPath, {
498
+ await import_fs_extra3.default.rmdir(tinaGeneratedPath, {
444
499
  recursive: true
445
500
  });
446
501
  } catch (e) {
447
502
  console.log(e);
448
503
  }
449
- await import_fs_extra2.default.mkdir(tinaGeneratedPath);
450
- await import_fs_extra2.default.outputFile(import_path2.default.join(tinaGeneratedPath, ".gitignore"), "db");
504
+ await import_fs_extra3.default.mkdir(tinaGeneratedPath);
505
+ await import_fs_extra3.default.outputFile(import_path3.default.join(tinaGeneratedPath, ".gitignore"), "db");
506
+ };
507
+ var cleanup = async ({ tinaTempPath: tinaTempPath2 }) => {
508
+ await import_fs_extra3.default.remove(tinaTempPath2);
451
509
  };
452
510
  var compile = async (_ctx, _next) => {
453
511
  logger.info(logText("Compiling..."));
454
- if (!import_fs_extra2.default.existsSync(tinaPath) || !import_fs_extra2.default.existsSync(import_path2.default.join(tinaPath, "schema.ts"))) {
512
+ let schemaExists = true;
513
+ try {
514
+ getSchemaPath({ projectDir: tinaPath });
515
+ } catch {
516
+ schemaExists = false;
517
+ }
518
+ if (!schemaExists) {
455
519
  logger.info(dangerText(`
456
520
  .tina/schema.ts not found, Creating one for you...
457
521
  See Documentation: https://tina.io/docs/tina-cloud/cli/#getting-started"
458
522
  `));
459
- const file = import_path2.default.join(tinaPath, "schema.ts");
460
- await import_fs_extra2.default.ensureFile(file);
461
- await import_fs_extra2.default.writeFile(file, defaultSchema);
523
+ const file = import_path3.default.join(tinaPath, "schema.ts");
524
+ await import_fs_extra3.default.ensureFile(file);
525
+ await import_fs_extra3.default.writeFile(file, defaultSchema);
526
+ }
527
+ try {
528
+ await transpile(tinaPath, tinaTempPath);
529
+ } catch (e) {
530
+ await cleanup({ tinaTempPath });
531
+ throw new BuildSchemaError(e);
462
532
  }
463
- await transpile2(tinaPath, tinaTempPath);
464
533
  Object.keys(require.cache).map((key) => {
465
534
  if (key.startsWith(tinaTempPath)) {
466
535
  delete require.cache[require.resolve(key)];
467
536
  }
468
537
  });
469
- const schemaFunc = require(import_path2.default.join(tinaTempPath, "schema.js"));
470
- const schemaObject = schemaFunc.default;
471
- await import_fs_extra2.default.outputFile(import_path2.default.join(tinaConfigPath, "schema.json"), JSON.stringify(schemaObject, null, 2));
472
- await import_fs_extra2.default.remove(tinaTempPath);
538
+ try {
539
+ const schemaFunc = require(import_path3.default.join(tinaTempPath, "schema.js"));
540
+ const schemaObject = schemaFunc.default;
541
+ await import_fs_extra3.default.outputFile(import_path3.default.join(tinaConfigPath, "schema.json"), JSON.stringify(schemaObject, null, 2));
542
+ await cleanup({ tinaTempPath });
543
+ } catch (e) {
544
+ await cleanup({ tinaTempPath });
545
+ throw new ExecuteSchemaError(e);
546
+ }
473
547
  };
474
- var transpile2 = async (projectDir, tempDir) => {
475
- logger.info(logText("Transpiling..."));
476
- const posixProjectDir = (0, import_normalize_path.default)(projectDir);
477
- const posixTempDir = (0, import_normalize_path.default)(tempDir);
478
- return Promise.all(import_fast_glob.default.sync(import_path2.default.join(projectDir, "**", "*.ts").replace(/\\/g, "/"), {
479
- ignore: [
480
- import_path2.default.join(projectDir, "__generated__", "**", "*.ts").replace(/\\/g, "/")
481
- ]
482
- }).map(async function(file) {
483
- const fullPath = import_path2.default.resolve(file);
484
- const contents = await import_fs_extra2.default.readFileSync(fullPath).toString();
485
- const newContent = ts.transpile(contents);
486
- const newPath = file.replace(posixProjectDir, posixTempDir).replace(".ts", ".js");
487
- await import_fs_extra2.default.outputFile(newPath, newContent);
488
- return true;
489
- }));
548
+ var transpile = async (projectDir, tempDir) => {
549
+ logger.info(logText("Building javascript..."));
550
+ const packageJSON = JSON.parse(import_fs_extra3.default.readFileSync(packageJSONFilePath).toString() || "{}");
551
+ const deps = (packageJSON == null ? void 0 : packageJSON.dependencies) || [];
552
+ const peerDeps = (packageJSON == null ? void 0 : packageJSON.peerDependencies) || [];
553
+ const devDeps = (packageJSON == null ? void 0 : packageJSON.devDependencies) || [];
554
+ const external = Object.keys(__spreadValues(__spreadValues(__spreadValues({}, deps), peerDeps), devDeps));
555
+ const inputFile = getSchemaPath({ projectDir });
556
+ const outputPath = import_path3.default.join(tempDir, "schema.js");
557
+ await (0, import_esbuild.build)({
558
+ bundle: true,
559
+ platform: "neutral",
560
+ target: ["node10.4"],
561
+ entryPoints: [inputFile],
562
+ treeShaking: true,
563
+ external: [...external, "./node_modules/*"],
564
+ loader: loaders,
565
+ outfile: outputPath
566
+ });
567
+ logger.info(logText(`Javascript built`));
490
568
  };
491
569
  var defineSchema = (config) => {
492
570
  return config;
493
571
  };
572
+ var loaders = {
573
+ ".aac": "file",
574
+ ".css": "file",
575
+ ".eot": "file",
576
+ ".flac": "file",
577
+ ".gif": "file",
578
+ ".jpeg": "file",
579
+ ".jpg": "file",
580
+ ".json": "json",
581
+ ".mp3": "file",
582
+ ".mp4": "file",
583
+ ".ogg": "file",
584
+ ".otf": "file",
585
+ ".png": "file",
586
+ ".svg": "file",
587
+ ".ttf": "file",
588
+ ".wav": "file",
589
+ ".webm": "file",
590
+ ".webp": "file",
591
+ ".woff": "file",
592
+ ".woff2": "file",
593
+ ".js": "jsx",
594
+ ".jsx": "jsx",
595
+ ".tsx": "tsx"
596
+ };
494
597
 
495
598
  // pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/cli/src/cmds/start-server/index.ts
496
599
  var import_chokidar = __toModule(require("chokidar"));
497
600
  var import_metrics = __toModule(require("@tinacms/metrics"));
601
+
602
+ // pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/cli/src/cmds/start-server/lock.ts
603
+ var AsyncLock = class {
604
+ constructor() {
605
+ this.disable = () => {
606
+ };
607
+ this.promise = Promise.resolve();
608
+ }
609
+ enable() {
610
+ this.promise = new Promise((resolve2) => this.disable = resolve2);
611
+ }
612
+ };
613
+
614
+ // pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/cli/src/cmds/start-server/index.ts
615
+ var lock = new AsyncLock();
498
616
  var gqlPackageFile = require.resolve("@tinacms/graphql");
499
617
  async function startServer(_ctx, _next, {
500
618
  port = 4001,
@@ -502,8 +620,10 @@ async function startServer(_ctx, _next, {
502
620
  noWatch,
503
621
  experimentalData,
504
622
  noSDK,
505
- noTelemetry
623
+ noTelemetry,
624
+ watchFolders
506
625
  }) {
626
+ lock.disable();
507
627
  const rootPath2 = process.cwd();
508
628
  const t = new import_metrics.Telemetry({ disabled: Boolean(noTelemetry) });
509
629
  t.submitRecord({
@@ -541,29 +661,45 @@ stack: ${code.stack || "No stack was provided"}`);
541
661
  }
542
662
  };
543
663
  let ready = false;
544
- const build = async (noSDK2) => {
545
- if (!process.env.CI && !noWatch) {
546
- await resetGeneratedFolder();
664
+ const build2 = async (noSDK2) => {
665
+ await lock.promise;
666
+ lock.enable();
667
+ try {
668
+ if (!process.env.CI && !noWatch) {
669
+ await resetGeneratedFolder();
670
+ }
671
+ const database2 = await (0, import_graphql7.createDatabase)({ store, bridge });
672
+ await compile(null, null);
673
+ const schema = await (0, import_graphql7.buildSchema)(rootPath2, database2);
674
+ await genTypes({ schema }, () => {
675
+ }, { noSDK: noSDK2 });
676
+ } catch (error) {
677
+ throw error;
678
+ } finally {
679
+ lock.disable();
547
680
  }
548
- const database2 = await (0, import_graphql7.createDatabase)({ store, bridge });
549
- await compile(null, null);
550
- const schema = await (0, import_graphql7.buildSchema)(rootPath2, database2);
551
- await genTypes({ schema }, () => {
552
- }, { noSDK: noSDK2 });
553
681
  };
682
+ const foldersToWatch = (watchFolders || []).map((x) => import_path4.default.join(rootPath2, x));
554
683
  if (!noWatch && !process.env.CI) {
555
- import_chokidar.default.watch([`${rootPath2}/**/*.{ts,gql,graphql}`], {
556
- ignored: `${import_path3.default.resolve(rootPath2)}/.tina/__generated__/**/*`
684
+ import_chokidar.default.watch([
685
+ ...foldersToWatch,
686
+ `${rootPath2}/.tina/**/*.{ts,gql,graphql,js,tsx,jsx}`
687
+ ], {
688
+ ignored: [
689
+ "**/node_modules/**/*",
690
+ "**/.next/**/*",
691
+ `${import_path4.default.resolve(rootPath2)}/.tina/__generated__/**/*`
692
+ ]
557
693
  }).on("ready", async () => {
558
694
  console.log("Generating Tina config");
559
695
  try {
560
696
  if (shouldBuild) {
561
- await build(noSDK);
697
+ await build2(noSDK);
562
698
  }
563
699
  ready = true;
564
700
  startSubprocess();
565
701
  } catch (e) {
566
- logger.info(dangerText(`${e.message}`));
702
+ handleServerErrors(e);
567
703
  console.log(e);
568
704
  process.exit(0);
569
705
  }
@@ -572,11 +708,10 @@ stack: ${code.stack || "No stack was provided"}`);
572
708
  logger.info("Tina change detected, regenerating config");
573
709
  try {
574
710
  if (shouldBuild) {
575
- await build(noSDK);
711
+ await build2(noSDK);
576
712
  }
577
713
  } catch (e) {
578
- logger.info(dangerText("Compilation failed with errors. Server has not been restarted.") + ` see error below
579
- ${e.message}`);
714
+ handleServerErrors(e);
580
715
  t.submitRecord({
581
716
  event: {
582
717
  name: "tinacms:cli:server:error",
@@ -588,7 +723,7 @@ stack: ${code.stack || "No stack was provided"}`);
588
723
  });
589
724
  } else {
590
725
  if (shouldBuild) {
591
- await build(noSDK);
726
+ await build2(noSDK);
592
727
  }
593
728
  }
594
729
  const state = {
@@ -647,8 +782,8 @@ stack: ${code.stack || "No stack was provided"}`);
647
782
  }
648
783
 
649
784
  // pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/cli/src/cmds/init/index.ts
650
- var import_fs_extra3 = __toModule(require("fs-extra"));
651
- var import_path4 = __toModule(require("path"));
785
+ var import_fs_extra4 = __toModule(require("fs-extra"));
786
+ var import_path5 = __toModule(require("path"));
652
787
  var import_progress = __toModule(require("progress"));
653
788
  var import_prompts = __toModule(require("prompts"));
654
789
  var import_metrics2 = __toModule(require("@tinacms/metrics"));
@@ -1030,26 +1165,26 @@ async function installDeps(ctx, next, options) {
1030
1165
  next();
1031
1166
  }
1032
1167
  var baseDir = process.cwd();
1033
- var TinaWrapperPathDir = import_path4.default.join(baseDir, "components");
1034
- var TinaWrapperPath = import_path4.default.join(TinaWrapperPathDir, "tina-wrapper.tsx");
1035
- var blogContentPath = import_path4.default.join(baseDir, "content", "posts");
1036
- var blogPostPath = import_path4.default.join(blogContentPath, "HelloWorld.md");
1168
+ var TinaWrapperPathDir = import_path5.default.join(baseDir, "components");
1169
+ var TinaWrapperPath = import_path5.default.join(TinaWrapperPathDir, "tina-wrapper.tsx");
1170
+ var blogContentPath = import_path5.default.join(baseDir, "content", "posts");
1171
+ var blogPostPath = import_path5.default.join(blogContentPath, "HelloWorld.md");
1037
1172
  async function tinaSetup(ctx, next, options) {
1038
- const useingSrc = import_fs_extra3.default.pathExistsSync(import_path4.default.join(baseDir, "src"));
1039
- if (!import_fs_extra3.default.pathExistsSync(blogPostPath)) {
1173
+ const useingSrc = import_fs_extra4.default.pathExistsSync(import_path5.default.join(baseDir, "src"));
1174
+ if (!import_fs_extra4.default.pathExistsSync(blogPostPath)) {
1040
1175
  logger.info(logText("Adding a content folder..."));
1041
- import_fs_extra3.default.mkdirpSync(blogContentPath);
1042
- import_fs_extra3.default.writeFileSync(blogPostPath, blogPost);
1176
+ import_fs_extra4.default.mkdirpSync(blogContentPath);
1177
+ import_fs_extra4.default.writeFileSync(blogPostPath, blogPost);
1043
1178
  }
1044
1179
  logger.level = "info";
1045
- const pagesPath = import_path4.default.join(baseDir, useingSrc ? "src" : "", "pages");
1046
- const appPath = import_path4.default.join(pagesPath, "_app.js");
1047
- const appPathTS = import_path4.default.join(pagesPath, "_app.tsx");
1048
- const appExtension = import_fs_extra3.default.existsSync(appPath) ? ".js" : ".tsx";
1180
+ const pagesPath = import_path5.default.join(baseDir, useingSrc ? "src" : "", "pages");
1181
+ const appPath = import_path5.default.join(pagesPath, "_app.js");
1182
+ const appPathTS = import_path5.default.join(pagesPath, "_app.tsx");
1183
+ const appExtension = import_fs_extra4.default.existsSync(appPath) ? ".js" : ".tsx";
1049
1184
  let wrapper = false;
1050
- if (!import_fs_extra3.default.pathExistsSync(appPath) && !import_fs_extra3.default.pathExistsSync(appPathTS)) {
1185
+ if (!import_fs_extra4.default.pathExistsSync(appPath) && !import_fs_extra4.default.pathExistsSync(appPathTS)) {
1051
1186
  logger.info(logText("Adding _app.js ... \u2705"));
1052
- import_fs_extra3.default.writeFileSync(appPath, AppJsContent());
1187
+ import_fs_extra4.default.writeFileSync(appPath, AppJsContent());
1053
1188
  } else {
1054
1189
  const override = await (0, import_prompts.default)({
1055
1190
  name: "res",
@@ -1058,28 +1193,28 @@ async function tinaSetup(ctx, next, options) {
1058
1193
  });
1059
1194
  if (override.res) {
1060
1195
  logger.info(logText(`Adding _app${appExtension} ... \u2705`));
1061
- const appPathWithExtension = import_path4.default.join(pagesPath, `_app${appExtension}`);
1062
- const fileContent = import_fs_extra3.default.pathExistsSync(appPath) ? (0, import_fs_extra3.readFileSync)(appPath) : (0, import_fs_extra3.readFileSync)(appPathTS);
1196
+ const appPathWithExtension = import_path5.default.join(pagesPath, `_app${appExtension}`);
1197
+ const fileContent = import_fs_extra4.default.pathExistsSync(appPath) ? (0, import_fs_extra4.readFileSync)(appPath) : (0, import_fs_extra4.readFileSync)(appPathTS);
1063
1198
  const matches = [
1064
1199
  ...fileContent.toString().matchAll(/^.*import.*\.css("|').*$/gm)
1065
1200
  ];
1066
1201
  const primaryMatches = matches.map((x) => x[0]);
1067
- import_fs_extra3.default.writeFileSync(appPathWithExtension, AppJsContent(primaryMatches.join("\n")));
1202
+ import_fs_extra4.default.writeFileSync(appPathWithExtension, AppJsContent(primaryMatches.join("\n")));
1068
1203
  } else {
1069
1204
  wrapper = true;
1070
1205
  logger.info(dangerText(`Heads up, to enable live-editing you'll need to wrap your page or site in Tina:
1071
1206
  `, warnText(AppJsContent())));
1072
1207
  }
1073
1208
  }
1074
- const tinaBlogPagePath = import_path4.default.join(pagesPath, "demo", "blog");
1075
- const tinaBlogPagePathFile = import_path4.default.join(tinaBlogPagePath, "[filename].js");
1076
- if (!import_fs_extra3.default.pathExistsSync(tinaBlogPagePathFile)) {
1077
- import_fs_extra3.default.mkdirpSync(tinaBlogPagePath);
1078
- import_fs_extra3.default.writeFileSync(tinaBlogPagePathFile, nextPostPage());
1209
+ const tinaBlogPagePath = import_path5.default.join(pagesPath, "demo", "blog");
1210
+ const tinaBlogPagePathFile = import_path5.default.join(tinaBlogPagePath, "[filename].js");
1211
+ if (!import_fs_extra4.default.pathExistsSync(tinaBlogPagePathFile)) {
1212
+ import_fs_extra4.default.mkdirpSync(tinaBlogPagePath);
1213
+ import_fs_extra4.default.writeFileSync(tinaBlogPagePathFile, nextPostPage());
1079
1214
  }
1080
1215
  logger.info("Adding a content folder... \u2705");
1081
- const packagePath = import_path4.default.join(baseDir, "package.json");
1082
- const pack = JSON.parse((0, import_fs_extra3.readFileSync)(packagePath).toString());
1216
+ const packagePath = import_path5.default.join(baseDir, "package.json");
1217
+ const pack = JSON.parse((0, import_fs_extra4.readFileSync)(packagePath).toString());
1083
1218
  const oldScripts = pack.scripts || {};
1084
1219
  const newPack = JSON.stringify(__spreadProps(__spreadValues({}, pack), {
1085
1220
  scripts: __spreadProps(__spreadValues({}, oldScripts), {
@@ -1088,14 +1223,14 @@ async function tinaSetup(ctx, next, options) {
1088
1223
  "tina-start": 'yarn tinacms server:start -c "next start"'
1089
1224
  })
1090
1225
  }), null, 2);
1091
- (0, import_fs_extra3.writeFileSync)(packagePath, newPack);
1092
- const adminPath = import_path4.default.join(pagesPath, "admin", "[[...tina]].js");
1093
- if (import_fs_extra3.default.pathExistsSync(import_path4.default.join(pagesPath, "admin"))) {
1226
+ (0, import_fs_extra4.writeFileSync)(packagePath, newPack);
1227
+ const adminPath = import_path5.default.join(pagesPath, "admin", "[[...tina]].js");
1228
+ if (import_fs_extra4.default.pathExistsSync(import_path5.default.join(pagesPath, "admin"))) {
1094
1229
  logger.warn(`Unable to add /pages/admin/[[...tina]].js, this path already exists.
1095
1230
  Learn more about toggling edit-mode at https://tina.io/docs/tinacms-context/#manually-toggling-edit-mode`);
1096
1231
  return next();
1097
1232
  }
1098
- (0, import_fs_extra3.outputFileSync)(adminPath, adminPage);
1233
+ (0, import_fs_extra4.outputFileSync)(adminPath, adminPage);
1099
1234
  next();
1100
1235
  }
1101
1236
  async function successMessage(ctx, next, options) {
@@ -1112,7 +1247,7 @@ var import_datalayer3 = __toModule(require("@tinacms/datalayer"));
1112
1247
 
1113
1248
  // pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/cli/src/cmds/audit/audit.ts
1114
1249
  var import_graphql8 = __toModule(require("@tinacms/graphql"));
1115
- var import_path5 = __toModule(require("path"));
1250
+ var import_path6 = __toModule(require("path"));
1116
1251
  var import_graphql9 = __toModule(require("@tinacms/graphql"));
1117
1252
  var import_chalk3 = __toModule(require("chalk"));
1118
1253
  var auditCollection = async (args) => {
@@ -1150,7 +1285,7 @@ var auditCollection = async (args) => {
1150
1285
  warning = true;
1151
1286
  logger.warn(import_chalk3.default.yellowBright(`WARNING: there is a file with extension \`${node.sys.extension}\` but in your schema it is defined to be \`.${format}\`
1152
1287
 
1153
- location: ${import_path5.default.join(rootPath2, node.sys.path)}`));
1288
+ location: ${import_path6.default.join(rootPath2, node.sys.path)}`));
1154
1289
  }
1155
1290
  });
1156
1291
  return warning;
@@ -1186,7 +1321,7 @@ var auditDocuments = async (args) => {
1186
1321
  const documents = result.data.getCollection.documents.edges;
1187
1322
  for (let i = 0; i < documents.length; i++) {
1188
1323
  const node = documents[i].node;
1189
- const fullPath = import_path5.default.join(rootPath2, node.sys.path);
1324
+ const fullPath = import_path6.default.join(rootPath2, node.sys.path);
1190
1325
  logger.info(`Checking document: ${fullPath}`);
1191
1326
  const documentQuery = `query {
1192
1327
  getDocument(collection: "${collection.name}", relativePath: "${node.sys.relativePath}") {
@@ -1383,7 +1518,7 @@ var noSDKCodegenOption = {
1383
1518
  };
1384
1519
  var cleanOption = {
1385
1520
  name: "--clean",
1386
- description: "Submit gql mutation to all files to git rid of any data that is not defined in the `schema.ts`"
1521
+ description: "Updates all content files to remove any data not explicitly permitted by the current schema definition"
1387
1522
  };
1388
1523
  var useDefaultValuesOption = {
1389
1524
  name: "--useDefaultValues",
@@ -1393,6 +1528,10 @@ var noTelemetryOption = {
1393
1528
  name: "--noTelemetry",
1394
1529
  description: "Disable anonymous telemetry that is collected"
1395
1530
  };
1531
+ var watchFileOption = {
1532
+ name: "-w, --watchFolders [folders...]",
1533
+ description: "a list of folders (relative to where this is being run) that the cli will watch for changes"
1534
+ };
1396
1535
  var baseCmds = [
1397
1536
  {
1398
1537
  command: CMD_START_SERVER,
@@ -1403,7 +1542,8 @@ var baseCmds = [
1403
1542
  experimentalDatalayer,
1404
1543
  noWatchOption,
1405
1544
  noSDKCodegenOption,
1406
- noTelemetryOption
1545
+ noTelemetryOption,
1546
+ watchFileOption
1407
1547
  ],
1408
1548
  action: (options) => chain([startServer], options)
1409
1549
  },
@@ -0,0 +1,15 @@
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
+ export declare const getSchemaPath: ({ projectDir }: {
14
+ projectDir: string;
15
+ }) => any;
@@ -0,0 +1,13 @@
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
+ export * from './getSchemaPath';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tinacms/cli",
3
- "version": "0.60.5",
3
+ "version": "0.60.6",
4
4
  "main": "dist/index.js",
5
5
  "typings": "dist/index.d.ts",
6
6
  "files": [
@@ -38,7 +38,8 @@
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"
41
+ "jest": "^27.0.6",
42
+ "typescript": "^4.3.5"
42
43
  },
43
44
  "scripts": {
44
45
  "build": "echo \"Run `yarn build` from the root of the repository instead\"",
@@ -57,8 +58,10 @@
57
58
  "@graphql-tools/graphql-file-loader": "^7.2.0",
58
59
  "@graphql-tools/load": "^7.3.2",
59
60
  "@tinacms/datalayer": "0.0.2",
60
- "@tinacms/graphql": "0.59.6",
61
+ "@tinacms/graphql": "0.59.7",
61
62
  "@tinacms/metrics": "0.0.2",
63
+ "@yarnpkg/esbuild-plugin-pnp": "^2.0.1-rc.3",
64
+ "add": "^2.0.6",
62
65
  "ajv": "^6.12.3",
63
66
  "altair-express-middleware": "4.0.6",
64
67
  "auto-bind": "^4.0.0",
@@ -66,8 +69,9 @@
66
69
  "body-parser": "^1.19.0",
67
70
  "chalk": "^2.4.2",
68
71
  "chokidar": "^3.5.1",
69
- "commander": "5.1.0",
72
+ "commander": "^9.0.0",
70
73
  "cors": "^2.8.5",
74
+ "esbuild": "^0.14.20",
71
75
  "esm": "3.2.25",
72
76
  "express": "^4.17.1",
73
77
  "fast-glob": "^3.2.4",
@@ -80,7 +84,7 @@
80
84
  "normalize-path": "^3.0.0",
81
85
  "progress": "^2.0.3",
82
86
  "prompts": "^2.4.1",
83
- "typescript": "^4.3.5",
87
+ "yarn": "^1.22.17",
84
88
  "yup": "^0.32.9"
85
89
  },
86
90
  "publishConfig": {