@tinacms/cli 0.60.3 → 0.60.4

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,19 @@
1
1
  # tinacms-cli
2
2
 
3
+ ## 0.60.4
4
+
5
+ ### Patch Changes
6
+
7
+ - a05546eb4: Added basic open source telemetry
8
+
9
+ See [this discussion](https://github.com/tinacms/tinacms/discussions/2451) for more information and how to opt out.
10
+
11
+ - Updated dependencies [8bf0ac832]
12
+ - Updated dependencies [a05546eb4]
13
+ - @tinacms/metrics@0.0.2
14
+ - @tinacms/datalayer@0.0.2
15
+ - @tinacms/graphql@0.59.6
16
+
3
17
  ## 0.60.3
4
18
 
5
19
  ### 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.3";
117
+ var version = "0.60.4";
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
  }
@@ -524,6 +567,12 @@ stack: ${code.stack || "No stack was provided"}`);
524
567
  } catch (e) {
525
568
  logger.info(dangerText("Compilation failed with errors. Server has not been restarted.") + ` see error below
526
569
  ${e.message}`);
570
+ t.submitRecord({
571
+ event: {
572
+ name: "tinacms:cli:server:error",
573
+ errorMessage: e.message
574
+ }
575
+ });
527
576
  }
528
577
  }
529
578
  });
@@ -598,6 +647,7 @@ var import_fs_extra3 = __toModule(require("fs-extra"));
598
647
  var import_path4 = __toModule(require("path"));
599
648
  var import_progress = __toModule(require("progress"));
600
649
  var import_prompts = __toModule(require("prompts"));
650
+ var import_metrics2 = __toModule(require("@tinacms/metrics"));
601
651
 
602
652
  // pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/cli/src/cmds/init/setup-files/index.ts
603
653
  var adminPage = `import { TinaAdmin } from 'tinacms';
@@ -946,7 +996,7 @@ export default App
946
996
  var import_chalk2 = __toModule(require("chalk"));
947
997
  function execShellCommand(cmd) {
948
998
  const exec = require("child_process").exec;
949
- return new Promise((resolve2, reject) => {
999
+ return new Promise((resolve2, _reject) => {
950
1000
  exec(cmd, (error, stdout, stderr) => {
951
1001
  if (error) {
952
1002
  console.warn(error);
@@ -956,6 +1006,8 @@ function execShellCommand(cmd) {
956
1006
  });
957
1007
  }
958
1008
  async function initTina(ctx, next, options) {
1009
+ const telemetry = new import_metrics2.Telemetry({ disabled: options.noTelemetry });
1010
+ await telemetry.submitRecord({ event: { name: "tinacms:cli:init:invoke" } });
959
1011
  logger.info(successText("Setting up Tina..."));
960
1012
  next();
961
1013
  }
@@ -1025,15 +1077,13 @@ async function tinaSetup(ctx, next, options) {
1025
1077
  const packagePath = import_path4.default.join(baseDir, "package.json");
1026
1078
  const pack = JSON.parse((0, import_fs_extra3.readFileSync)(packagePath).toString());
1027
1079
  const oldScripts = pack.scripts || {};
1028
- const newPack = JSON.stringify({
1029
- ...pack,
1030
- scripts: {
1031
- ...oldScripts,
1080
+ const newPack = JSON.stringify(__spreadProps(__spreadValues({}, pack), {
1081
+ scripts: __spreadProps(__spreadValues({}, oldScripts), {
1032
1082
  "tina-dev": 'yarn tinacms server:start -c "next dev"',
1033
1083
  "tina-build": 'yarn tinacms server:start -c "next build"',
1034
1084
  "tina-start": 'yarn tinacms server:start -c "next start"'
1035
- }
1036
- }, null, 2);
1085
+ })
1086
+ }), null, 2);
1037
1087
  (0, import_fs_extra3.writeFileSync)(packagePath, newPack);
1038
1088
  const adminPath = import_path4.default.join(pagesPath, "admin", "[[...tina]].js");
1039
1089
  if (import_fs_extra3.default.pathExistsSync(import_path4.default.join(pagesPath, "admin"))) {
@@ -1045,7 +1095,6 @@ async function tinaSetup(ctx, next, options) {
1045
1095
  next();
1046
1096
  }
1047
1097
  async function successMessage(ctx, next, options) {
1048
- const baseDir2 = process.cwd();
1049
1098
  logger.info(`Tina setup ${import_chalk2.default.underline.green("done")} \u2705
1050
1099
  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")}
1051
1100
  Enjoy Tina \u{1F999} !
@@ -1188,10 +1237,10 @@ var auditDocuments = async (args) => {
1188
1237
  return error;
1189
1238
  };
1190
1239
  var transformDocumentIntoMutationRequestPayload = (document, instructions, defaults) => {
1191
- const { _collection, __typename, _template, ...rest } = document;
1240
+ const _a = document, { _collection, __typename, _template } = _a, rest = __objRest(_a, ["_collection", "__typename", "_template"]);
1192
1241
  const params = transformParams(rest);
1193
1242
  const paramsWithTemplate = instructions.includeTemplate ? { [_template]: params } : params;
1194
- return instructions.includeCollection ? { [_collection]: { ...defaults, ...filterObject(paramsWithTemplate) } } : { ...defaults, ...filterObject(paramsWithTemplate) };
1243
+ return instructions.includeCollection ? { [_collection]: __spreadValues(__spreadValues({}, defaults), filterObject(paramsWithTemplate)) } : __spreadValues(__spreadValues({}, defaults), filterObject(paramsWithTemplate));
1195
1244
  };
1196
1245
  var transformParams = (data) => {
1197
1246
  if (["string", "number", "boolean"].includes(typeof data)) {
@@ -1202,7 +1251,7 @@ var transformParams = (data) => {
1202
1251
  }
1203
1252
  try {
1204
1253
  (0, import_graphql9.assertShape)(data, (yup) => yup.object({ _template: yup.string().required() }));
1205
- const { _template, __typename, ...rest } = data;
1254
+ const _a = data, { _template, __typename } = _a, rest = __objRest(_a, ["_template", "__typename"]);
1206
1255
  const nested = transformParams(rest);
1207
1256
  return { [_template]: nested };
1208
1257
  } catch (e) {
@@ -1234,8 +1283,17 @@ function filterObject(obj) {
1234
1283
  // pnp:/home/runner/work/tinacms/tinacms/packages/@tinacms/cli/src/cmds/audit/index.ts
1235
1284
  var import_chalk4 = __toModule(require("chalk"));
1236
1285
  var import_prompts2 = __toModule(require("prompts"));
1286
+ var import_metrics3 = __toModule(require("@tinacms/metrics"));
1237
1287
  var rootPath = process.cwd();
1238
1288
  var audit = async (ctx, next, options) => {
1289
+ const telemetry = new import_metrics3.Telemetry({ disabled: options.noTelemetry });
1290
+ await telemetry.submitRecord({
1291
+ event: {
1292
+ name: "tinacms:cli:audit:invoke",
1293
+ clean: Boolean(options.clean),
1294
+ useDefaults: Boolean(options.useDefaultValues)
1295
+ }
1296
+ });
1239
1297
  if (options.clean) {
1240
1298
  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.
1241
1299
 
@@ -1327,6 +1385,10 @@ var useDefaultValuesOption = {
1327
1385
  name: "--useDefaultValues",
1328
1386
  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`)"
1329
1387
  };
1388
+ var noTelemetryOption = {
1389
+ name: "--noTelemetry",
1390
+ description: "Disable anonymous telemetry that is collected"
1391
+ };
1330
1392
  var baseCmds = [
1331
1393
  {
1332
1394
  command: CMD_START_SERVER,
@@ -1336,25 +1398,26 @@ var baseCmds = [
1336
1398
  subCommand,
1337
1399
  experimentalDatalayer,
1338
1400
  noWatchOption,
1339
- noSDKCodegenOption
1401
+ noSDKCodegenOption,
1402
+ noTelemetryOption
1340
1403
  ],
1341
1404
  action: (options) => chain([startServer], options)
1342
1405
  },
1343
1406
  {
1344
1407
  command: CMD_COMPILE_MODELS,
1345
1408
  description: "Compile schema into static files for the server",
1346
- options: [experimentalDatalayer],
1409
+ options: [experimentalDatalayer, noTelemetryOption],
1347
1410
  action: (options) => chain([compile], options)
1348
1411
  },
1349
1412
  {
1350
1413
  command: CMD_GEN_TYPES,
1351
1414
  description: "Generate a GraphQL query for your site's schema, (and optionally Typescript types)",
1352
- options: [experimentalDatalayer, noSDKCodegenOption],
1415
+ options: [experimentalDatalayer, noSDKCodegenOption, noTelemetryOption],
1353
1416
  action: (options) => chain([attachSchema, genTypes], options)
1354
1417
  },
1355
1418
  {
1356
1419
  command: INIT,
1357
- options: [experimentalDatalayer],
1420
+ options: [experimentalDatalayer, noTelemetryOption],
1358
1421
  description: "Add Tina Cloud to an existing project",
1359
1422
  action: (options) => chain([
1360
1423
  initTina,
@@ -1370,7 +1433,7 @@ var baseCmds = [
1370
1433
  ], options)
1371
1434
  },
1372
1435
  {
1373
- options: [cleanOption, useDefaultValuesOption],
1436
+ options: [cleanOption, useDefaultValuesOption, noTelemetryOption],
1374
1437
  command: AUDIT,
1375
1438
  description: "Audit your schema and the files to check for errors",
1376
1439
  action: (options) => chain([
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tinacms/cli",
3
- "version": "0.60.3",
3
+ "version": "0.60.4",
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",
@@ -58,6 +58,7 @@
58
58
  "@graphql-tools/load": "^7.3.2",
59
59
  "@tinacms/datalayer": "0.0.2",
60
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",