@tinacms/cli 0.60.1 → 0.60.5

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,42 @@
1
1
  # tinacms-cli
2
2
 
3
+ ## 0.60.5
4
+
5
+ ### Patch Changes
6
+
7
+ - 399fbf4fa: Fix an issue where builds weren't happening during CI, this is only an issue for the experimental data layer
8
+
9
+ ## 0.60.4
10
+
11
+ ### Patch Changes
12
+
13
+ - a05546eb4: Added basic open source telemetry
14
+
15
+ See [this discussion](https://github.com/tinacms/tinacms/discussions/2451) for more information and how to opt out.
16
+
17
+ - Updated dependencies [8bf0ac832]
18
+ - Updated dependencies [a05546eb4]
19
+ - @tinacms/metrics@0.0.2
20
+ - @tinacms/datalayer@0.0.2
21
+ - @tinacms/graphql@0.59.6
22
+
23
+ ## 0.60.3
24
+
25
+ ### Patch Changes
26
+
27
+ - 43b40cc8b: Implement useTina in CLI init
28
+ - b399c734c: Fixes support for collection.templates in graphql
29
+ - Updated dependencies [b399c734c]
30
+ - @tinacms/datalayer@0.0.2
31
+ - @tinacms/graphql@0.59.6
32
+
33
+ ## 0.60.2
34
+
35
+ ### Patch Changes
36
+
37
+ - d17de356a: Update CLI to use apiUrl
38
+ - a67b0c1d7: Dont reinstantiate bridge and store
39
+
3
40
  ## 0.60.1
4
41
 
5
42
  ### Patch Changes
@@ -16,6 +16,7 @@ interface Options {
16
16
  experimentalData?: boolean;
17
17
  noWatch?: boolean;
18
18
  noSDK: boolean;
19
+ noTelemetry: boolean;
19
20
  }
20
- export declare function startServer(_ctx: any, _next: any, { port, command, noWatch, experimentalData, noSDK }: Options): Promise<void>;
21
+ export declare function startServer(_ctx: any, _next: any, { port, command, noWatch, experimentalData, noSDK, noTelemetry, }: Options): Promise<void>;
21
22
  export {};
package/dist/index.js CHANGED
@@ -1,10 +1,39 @@
1
1
  var __create = Object.create;
2
2
  var __defProp = Object.defineProperty;
3
+ var __defProps = Object.defineProperties;
3
4
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
4
6
  var __getOwnPropNames = Object.getOwnPropertyNames;
7
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
5
8
  var __getProtoOf = Object.getPrototypeOf;
6
9
  var __hasOwnProp = Object.prototype.hasOwnProperty;
10
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
11
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
12
+ var __spreadValues = (a, b) => {
13
+ for (var prop in b || (b = {}))
14
+ if (__hasOwnProp.call(b, prop))
15
+ __defNormalProp(a, prop, b[prop]);
16
+ if (__getOwnPropSymbols)
17
+ for (var prop of __getOwnPropSymbols(b)) {
18
+ if (__propIsEnum.call(b, prop))
19
+ __defNormalProp(a, prop, b[prop]);
20
+ }
21
+ return a;
22
+ };
23
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
7
24
  var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
25
+ var __objRest = (source, exclude) => {
26
+ var target = {};
27
+ for (var prop in source)
28
+ if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
29
+ target[prop] = source[prop];
30
+ if (source != null && __getOwnPropSymbols)
31
+ for (var prop of __getOwnPropSymbols(source)) {
32
+ if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
33
+ target[prop] = source[prop];
34
+ }
35
+ return target;
36
+ };
8
37
  var __esm = (fn, res) => function __init() {
9
38
  return fn && (res = (0, fn[Object.keys(fn)[0]])(fn = 0)), res;
10
39
  };
@@ -85,7 +114,7 @@ var commander = __toModule(require("commander"));
85
114
 
86
115
  // pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/cli/package.json
87
116
  var name = "@tinacms/cli";
88
- var version = "0.60.1";
117
+ var version = "0.60.5";
89
118
 
90
119
  // pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/cli/src/utils/theme.ts
91
120
  var import_chalk = __toModule(require("chalk"));
@@ -465,9 +494,23 @@ var defineSchema = (config) => {
465
494
 
466
495
  // pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/cli/src/cmds/start-server/index.ts
467
496
  var import_chokidar = __toModule(require("chokidar"));
497
+ var import_metrics = __toModule(require("@tinacms/metrics"));
468
498
  var gqlPackageFile = require.resolve("@tinacms/graphql");
469
- async function startServer(_ctx, _next, { port = 4001, command, noWatch, experimentalData, noSDK }) {
499
+ async function startServer(_ctx, _next, {
500
+ port = 4001,
501
+ command,
502
+ noWatch,
503
+ experimentalData,
504
+ noSDK,
505
+ noTelemetry
506
+ }) {
470
507
  const rootPath2 = process.cwd();
508
+ const t = new import_metrics.Telemetry({ disabled: Boolean(noTelemetry) });
509
+ t.submitRecord({
510
+ event: {
511
+ name: "tinacms:cli:server:start:invoke"
512
+ }
513
+ });
471
514
  if (!process.env.CI && !noWatch) {
472
515
  await resetGeneratedFolder();
473
516
  }
@@ -498,6 +541,16 @@ stack: ${code.stack || "No stack was provided"}`);
498
541
  }
499
542
  };
500
543
  let ready = false;
544
+ const build = async (noSDK2) => {
545
+ if (!process.env.CI && !noWatch) {
546
+ await resetGeneratedFolder();
547
+ }
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
+ };
501
554
  if (!noWatch && !process.env.CI) {
502
555
  import_chokidar.default.watch([`${rootPath2}/**/*.{ts,gql,graphql}`], {
503
556
  ignored: `${import_path3.default.resolve(rootPath2)}/.tina/__generated__/**/*`
@@ -524,22 +577,20 @@ stack: ${code.stack || "No stack was provided"}`);
524
577
  } catch (e) {
525
578
  logger.info(dangerText("Compilation failed with errors. Server has not been restarted.") + ` see error below
526
579
  ${e.message}`);
580
+ t.submitRecord({
581
+ event: {
582
+ name: "tinacms:cli:server:error",
583
+ errorMessage: e.message
584
+ }
585
+ });
527
586
  }
528
587
  }
529
588
  });
530
- }
531
- const build = async (noSDK2) => {
532
- if (!process.env.CI && !noWatch) {
533
- await resetGeneratedFolder();
589
+ } else {
590
+ if (shouldBuild) {
591
+ await build(noSDK);
534
592
  }
535
- const bridge2 = new import_datalayer2.FilesystemBridge(rootPath2);
536
- const store2 = experimentalData ? new import_datalayer2.LevelStore(rootPath2) : new import_datalayer2.FilesystemStore({ rootPath: rootPath2 });
537
- const database2 = await (0, import_graphql7.createDatabase)({ store: store2, bridge: bridge2 });
538
- await compile(null, null);
539
- const schema = await (0, import_graphql7.buildSchema)(rootPath2, database2);
540
- await genTypes({ schema }, () => {
541
- }, { noSDK: noSDK2 });
542
- };
593
+ }
543
594
  const state = {
544
595
  server: null,
545
596
  sockets: []
@@ -600,6 +651,7 @@ var import_fs_extra3 = __toModule(require("fs-extra"));
600
651
  var import_path4 = __toModule(require("path"));
601
652
  var import_progress = __toModule(require("progress"));
602
653
  var import_prompts = __toModule(require("prompts"));
654
+ var import_metrics2 = __toModule(require("@tinacms/metrics"));
603
655
 
604
656
  // pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/cli/src/cmds/init/setup-files/index.ts
605
657
  var adminPage = `import { TinaAdmin } from 'tinacms';
@@ -641,7 +693,19 @@ var nextPostPage = () => `// THIS FILE HAS BEEN GENERATED WITH THE TINA CLI.
641
693
  import { staticRequest, gql } from "tinacms";
642
694
  import Head from "next/head";
643
695
  import { createGlobalStyle } from "styled-components";
644
-
696
+ import { useTina } from "tinacms/dist/edit-state";
697
+
698
+ const query = gql\`
699
+ query BlogPostQuery($relativePath: String!) {
700
+ getPostsDocument(relativePath: $relativePath) {
701
+ data {
702
+ title
703
+ body
704
+ }
705
+ }
706
+ }
707
+ \`
708
+
645
709
  // Styles for markdown
646
710
  const GlobalStyle = createGlobalStyle\`
647
711
  h1,h2,h3,h4,h5 {
@@ -678,6 +742,12 @@ var nextPostPage = () => `// THIS FILE HAS BEEN GENERATED WITH THE TINA CLI.
678
742
  const defaultMarked = (markdown) => markdown;
679
743
  // Use the props returned by get static props (this can be deleted when the edit provider and tina-wrapper are moved to _app.js)
680
744
  const BlogPage = (props) => {
745
+ const { data } = useTina({
746
+ query,
747
+ variables: props.variables,
748
+ data: props.data,
749
+ });
750
+
681
751
  return (
682
752
  <>
683
753
  <Head>
@@ -703,12 +773,12 @@ var nextPostPage = () => `// THIS FILE HAS BEEN GENERATED WITH THE TINA CLI.
703
773
  }}
704
774
  >
705
775
  <h1 className="text-3xl m-8 text-center leading-8 font-extrabold tracking-tight text-gray-900 sm:text-4xl">
706
- {props.data.getPostsDocument.data.title}
776
+ {data.getPostsDocument.data.title}
707
777
  </h1>
708
778
  {/* Convert markdown to html in the browser only */}
709
779
  {typeof window !== "undefined" && (
710
780
  <ContentSection
711
- content={window.marked.parse(props.data.getPostsDocument.data.body)}
781
+ content={window.marked.parse(data.getPostsDocument.data.body)}
712
782
  ></ContentSection>
713
783
  )}
714
784
  </div>
@@ -729,16 +799,6 @@ var nextPostPage = () => `// THIS FILE HAS BEEN GENERATED WITH THE TINA CLI.
729
799
  };
730
800
 
731
801
  export const getStaticProps = async ({ params }) => {
732
- const query = gql\`
733
- query BlogPostQuery($relativePath: String!) {
734
- getPostsDocument(relativePath: $relativePath) {
735
- data {
736
- title
737
- body
738
- }
739
- }
740
- }
741
- \`
742
802
  const variables = { relativePath: \`\${params.filename}.md\` }
743
803
  let data = {}
744
804
  try {
@@ -752,7 +812,6 @@ var nextPostPage = () => `// THIS FILE HAS BEEN GENERATED WITH THE TINA CLI.
752
812
 
753
813
  return {
754
814
  props: {
755
- query,
756
815
  variables,
757
816
  data,
758
817
  //myOtherProp: 'some-other-data',
@@ -909,20 +968,22 @@ import { TinaEditProvider } from 'tinacms/dist/edit-state'
909
968
  const TinaCMS = dynamic(() => import('tinacms'), { ssr: false })
910
969
  ${extraImports || ""}
911
970
 
971
+ const branch = process.env.NEXT_PUBLIC_EDIT_BRANCH || "main";
972
+ const apiURL =
973
+ process.env.NODE_ENV == "development"
974
+ ? "http://localhost:4001/graphql"
975
+ : \`https://content.tinajs.io/content/\${process.env.NEXT_PUBLIC_TINA_CLIENT_ID}/github/\${branch}\`;
976
+
912
977
  const App = ({ Component, pageProps }) => {
913
978
  return (
914
979
  <>
915
980
  <TinaEditProvider
916
981
  editMode={
917
982
  <TinaCMS
918
- clientId={process.env.NEXT_PUBLIC_TINA_CLIENT_ID}
919
- branch={process.env.NEXT_PUBLIC_EDIT_BRANCH}
920
- isLocalClient={Boolean(
921
- Number(process.env.NEXT_PUBLIC_USE_LOCAL_CLIENT ?? true)
922
- )}
923
- {...pageProps}
983
+ apiURL={apiURL}
984
+
924
985
  >
925
- {(livePageProps) => <Component {...livePageProps} />}
986
+ <Component {...pageProps} />
926
987
  </TinaCMS>
927
988
  }
928
989
  >
@@ -939,7 +1000,7 @@ export default App
939
1000
  var import_chalk2 = __toModule(require("chalk"));
940
1001
  function execShellCommand(cmd) {
941
1002
  const exec = require("child_process").exec;
942
- return new Promise((resolve2, reject) => {
1003
+ return new Promise((resolve2, _reject) => {
943
1004
  exec(cmd, (error, stdout, stderr) => {
944
1005
  if (error) {
945
1006
  console.warn(error);
@@ -949,6 +1010,8 @@ function execShellCommand(cmd) {
949
1010
  });
950
1011
  }
951
1012
  async function initTina(ctx, next, options) {
1013
+ const telemetry = new import_metrics2.Telemetry({ disabled: options.noTelemetry });
1014
+ await telemetry.submitRecord({ event: { name: "tinacms:cli:init:invoke" } });
952
1015
  logger.info(successText("Setting up Tina..."));
953
1016
  next();
954
1017
  }
@@ -1018,15 +1081,13 @@ async function tinaSetup(ctx, next, options) {
1018
1081
  const packagePath = import_path4.default.join(baseDir, "package.json");
1019
1082
  const pack = JSON.parse((0, import_fs_extra3.readFileSync)(packagePath).toString());
1020
1083
  const oldScripts = pack.scripts || {};
1021
- const newPack = JSON.stringify({
1022
- ...pack,
1023
- scripts: {
1024
- ...oldScripts,
1084
+ const newPack = JSON.stringify(__spreadProps(__spreadValues({}, pack), {
1085
+ scripts: __spreadProps(__spreadValues({}, oldScripts), {
1025
1086
  "tina-dev": 'yarn tinacms server:start -c "next dev"',
1026
1087
  "tina-build": 'yarn tinacms server:start -c "next build"',
1027
1088
  "tina-start": 'yarn tinacms server:start -c "next start"'
1028
- }
1029
- }, null, 2);
1089
+ })
1090
+ }), null, 2);
1030
1091
  (0, import_fs_extra3.writeFileSync)(packagePath, newPack);
1031
1092
  const adminPath = import_path4.default.join(pagesPath, "admin", "[[...tina]].js");
1032
1093
  if (import_fs_extra3.default.pathExistsSync(import_path4.default.join(pagesPath, "admin"))) {
@@ -1038,7 +1099,6 @@ async function tinaSetup(ctx, next, options) {
1038
1099
  next();
1039
1100
  }
1040
1101
  async function successMessage(ctx, next, options) {
1041
- const baseDir2 = process.cwd();
1042
1102
  logger.info(`Tina setup ${import_chalk2.default.underline.green("done")} \u2705
1043
1103
  Start your dev server with ${successText(`yarn tina-dev`)} and go to http://localhost:3000/demo/blog/HelloWorld to ${successText("check it out the page that was created for you")}
1044
1104
  Enjoy Tina \u{1F999} !
@@ -1181,10 +1241,10 @@ var auditDocuments = async (args) => {
1181
1241
  return error;
1182
1242
  };
1183
1243
  var transformDocumentIntoMutationRequestPayload = (document, instructions, defaults) => {
1184
- const { _collection, __typename, _template, ...rest } = document;
1244
+ const _a = document, { _collection, __typename, _template } = _a, rest = __objRest(_a, ["_collection", "__typename", "_template"]);
1185
1245
  const params = transformParams(rest);
1186
1246
  const paramsWithTemplate = instructions.includeTemplate ? { [_template]: params } : params;
1187
- return instructions.includeCollection ? { [_collection]: { ...defaults, ...filterObject(paramsWithTemplate) } } : { ...defaults, ...filterObject(paramsWithTemplate) };
1247
+ return instructions.includeCollection ? { [_collection]: __spreadValues(__spreadValues({}, defaults), filterObject(paramsWithTemplate)) } : __spreadValues(__spreadValues({}, defaults), filterObject(paramsWithTemplate));
1188
1248
  };
1189
1249
  var transformParams = (data) => {
1190
1250
  if (["string", "number", "boolean"].includes(typeof data)) {
@@ -1195,7 +1255,7 @@ var transformParams = (data) => {
1195
1255
  }
1196
1256
  try {
1197
1257
  (0, import_graphql9.assertShape)(data, (yup) => yup.object({ _template: yup.string().required() }));
1198
- const { _template, __typename, ...rest } = data;
1258
+ const _a = data, { _template, __typename } = _a, rest = __objRest(_a, ["_template", "__typename"]);
1199
1259
  const nested = transformParams(rest);
1200
1260
  return { [_template]: nested };
1201
1261
  } catch (e) {
@@ -1227,8 +1287,17 @@ function filterObject(obj) {
1227
1287
  // pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/cli/src/cmds/audit/index.ts
1228
1288
  var import_chalk4 = __toModule(require("chalk"));
1229
1289
  var import_prompts2 = __toModule(require("prompts"));
1290
+ var import_metrics3 = __toModule(require("@tinacms/metrics"));
1230
1291
  var rootPath = process.cwd();
1231
1292
  var audit = async (ctx, next, options) => {
1293
+ const telemetry = new import_metrics3.Telemetry({ disabled: options.noTelemetry });
1294
+ await telemetry.submitRecord({
1295
+ event: {
1296
+ name: "tinacms:cli:audit:invoke",
1297
+ clean: Boolean(options.clean),
1298
+ useDefaults: Boolean(options.useDefaultValues)
1299
+ }
1300
+ });
1232
1301
  if (options.clean) {
1233
1302
  logger.info(`You are using the \`--clean\` option. This will modify your content as if a user is submitting a form. Before running this you should have a ${import_chalk4.default.bold("clean git tree")} so unwanted changes can be undone.
1234
1303
 
@@ -1320,6 +1389,10 @@ var useDefaultValuesOption = {
1320
1389
  name: "--useDefaultValues",
1321
1390
  description: "Adds default values to the graphQL mutation so that default values can be filled into existing documents (useful for adding a field with `required: true`)"
1322
1391
  };
1392
+ var noTelemetryOption = {
1393
+ name: "--noTelemetry",
1394
+ description: "Disable anonymous telemetry that is collected"
1395
+ };
1323
1396
  var baseCmds = [
1324
1397
  {
1325
1398
  command: CMD_START_SERVER,
@@ -1329,25 +1402,26 @@ var baseCmds = [
1329
1402
  subCommand,
1330
1403
  experimentalDatalayer,
1331
1404
  noWatchOption,
1332
- noSDKCodegenOption
1405
+ noSDKCodegenOption,
1406
+ noTelemetryOption
1333
1407
  ],
1334
1408
  action: (options) => chain([startServer], options)
1335
1409
  },
1336
1410
  {
1337
1411
  command: CMD_COMPILE_MODELS,
1338
1412
  description: "Compile schema into static files for the server",
1339
- options: [experimentalDatalayer],
1413
+ options: [experimentalDatalayer, noTelemetryOption],
1340
1414
  action: (options) => chain([compile], options)
1341
1415
  },
1342
1416
  {
1343
1417
  command: CMD_GEN_TYPES,
1344
1418
  description: "Generate a GraphQL query for your site's schema, (and optionally Typescript types)",
1345
- options: [experimentalDatalayer, noSDKCodegenOption],
1419
+ options: [experimentalDatalayer, noSDKCodegenOption, noTelemetryOption],
1346
1420
  action: (options) => chain([attachSchema, genTypes], options)
1347
1421
  },
1348
1422
  {
1349
1423
  command: INIT,
1350
- options: [experimentalDatalayer],
1424
+ options: [experimentalDatalayer, noTelemetryOption],
1351
1425
  description: "Add Tina Cloud to an existing project",
1352
1426
  action: (options) => chain([
1353
1427
  initTina,
@@ -1363,7 +1437,7 @@ var baseCmds = [
1363
1437
  ], options)
1364
1438
  },
1365
1439
  {
1366
- options: [cleanOption, useDefaultValuesOption],
1440
+ options: [cleanOption, useDefaultValuesOption, noTelemetryOption],
1367
1441
  command: AUDIT,
1368
1442
  description: "Audit your schema and the files to check for errors",
1369
1443
  action: (options) => chain([
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tinacms/cli",
3
- "version": "0.60.1",
3
+ "version": "0.60.5",
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.5",
24
+ "@tinacms/scripts": "0.50.6",
25
25
  "@types/clear": "0.1.0",
26
26
  "@types/cors": "2.8.5",
27
27
  "@types/express": "^4.17.7",
@@ -56,8 +56,9 @@
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/datalayer": "0.0.1",
60
- "@tinacms/graphql": "0.59.5",
59
+ "@tinacms/datalayer": "0.0.2",
60
+ "@tinacms/graphql": "0.59.6",
61
+ "@tinacms/metrics": "0.0.2",
61
62
  "ajv": "^6.12.3",
62
63
  "altair-express-middleware": "4.0.6",
63
64
  "auto-bind": "^4.0.0",
@@ -75,7 +76,7 @@
75
76
  "js-yaml": "^4.0.0",
76
77
  "lodash": "^4.17.19",
77
78
  "lodash.get": "^4.4.2",
78
- "log4js": "^6.3.0",
79
+ "log4js": "^6.4.0",
79
80
  "normalize-path": "^3.0.0",
80
81
  "progress": "^2.0.3",
81
82
  "prompts": "^2.4.1",