flowershow 0.0.9 → 0.0.11

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,17 @@
1
1
  # flowershow
2
2
 
3
+ ## 0.0.11
4
+
5
+ ### Patch Changes
6
+
7
+ - Basic anonymous telemetry (OS, Flowershow version and command being run).
8
+
9
+ ## 0.0.10
10
+
11
+ ### Patch Changes
12
+
13
+ - Rename `flowershow build-static` to `flowershow export`.
14
+
3
15
  ## 0.0.9
4
16
 
5
17
  ### Patch Changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "flowershow",
3
- "version": "0.0.9",
3
+ "version": "0.0.11",
4
4
  "description": "Publish your digital garden",
5
5
  "bin": {
6
6
  "flowershow": "src/bin/cli.js"
@@ -29,7 +29,8 @@
29
29
  "degit": "^2.8.4",
30
30
  "execa": "^6.1.0",
31
31
  "inquirer": "^9.1.1",
32
- "ora": "^6.1.2"
32
+ "ora": "^6.1.2",
33
+ "universal-analytics": "^0.5.3"
33
34
  },
34
35
  "type": "module",
35
36
  "engines": {
package/src/bin/cli.js CHANGED
@@ -1,20 +1,48 @@
1
1
  #!/usr/bin/env node
2
2
  import { createRequire } from "node:module";
3
3
  const require = createRequire(import.meta.url);
4
- import { warn } from "../lib/utils/index.js";
4
+ import { warn, exit, sendEvent } from "../lib/utils/index.js";
5
+ import { Command } from "commander";
5
6
 
6
- import os from "os";
7
+ // TODO check current vs required node version (package.json engines)
8
+ // const requiredNodeVersion = require("../package.json").engines.node;
7
9
 
8
- if (os.platform() === "win32") {
10
+ const { version: cli } = require("../../package.json");
11
+ const { version: node, platform, argv } = process;
12
+
13
+ if (platform === "win32") {
9
14
  warn(
10
- "This may not work as expected. You're trying to run Flowreshow CLI on Windows, which is not supported yet..."
15
+ "This may not work as expected. You're trying to run Flowreshow CLI on Windows, which is not thoroughly tested. Please submit an issue if you encounter any problems: https://github.com/flowershow/flowershow/issues"
11
16
  );
12
17
  }
13
18
 
14
- // TODO check current vs required node version (package.json engines)
15
- // const requiredNodeVersion = require("../package.json").engines.node;
19
+ const [, , cmd, ...args] = argv;
20
+ sendEvent({
21
+ event: "cli-usage",
22
+ action: cmd,
23
+ meta: {
24
+ args,
25
+ cli,
26
+ node,
27
+ platform,
28
+ },
29
+ });
16
30
 
17
- import { Command } from "commander";
31
+ process.on("uncaughtException", () => {
32
+ sendEvent({
33
+ event: "cli-error",
34
+ action: cmd,
35
+ meta: {
36
+ args,
37
+ cli,
38
+ node,
39
+ platform,
40
+ },
41
+ });
42
+ exit(1);
43
+ });
44
+
45
+ // CLI commands
18
46
 
19
47
  const program = new Command();
20
48
 
@@ -54,16 +82,16 @@ program
54
82
  });
55
83
 
56
84
  program
57
- .command("build-static")
58
- .description("build static Flowershow website")
85
+ .command("export")
86
+ .description("build a static Flowershow website")
59
87
  .argument(
60
88
  "[project-dir]",
61
89
  "Path to the folder where Flowershow template is installed (root folder of .flowershow)",
62
90
  "."
63
91
  )
64
92
  .action(async (projectPath) => {
65
- const { default: buildStatic } = await import("../lib/buildStatic.js");
66
- buildStatic(projectPath);
93
+ const { default: buildExport } = await import("../lib/buildExport.js");
94
+ buildExport(projectPath);
67
95
  });
68
96
 
69
97
  program
@@ -180,7 +180,9 @@ export default class Installer {
180
180
  const emitter = degit(templateRepo);
181
181
  await emitter.clone(flowershowDir);
182
182
  } catch {
183
- error(`Failed to create Flowershow template in ${flowershowDir}.`);
183
+ error(
184
+ `Failed to clone Flowershow template into ${flowershowDir}. This may be a problem with Flowershow. Please let us know about it by submitting an issue: https://github.com/flowershow/flowershow/issues.`
185
+ );
184
186
  exit(1);
185
187
  }
186
188
 
@@ -3,7 +3,7 @@ import { execa } from "execa";
3
3
 
4
4
  import { FLOWERSHOW_FOLDER_NAME } from "./const.js";
5
5
 
6
- export default async function buildStatic(dir) {
6
+ export default async function buildExport(dir) {
7
7
  const flowershowDir = path.resolve(dir, FLOWERSHOW_FOLDER_NAME);
8
8
 
9
9
  const subprocess = execa("npm", ["run", "export"], { cwd: flowershowDir });
@@ -1,6 +1,7 @@
1
1
  export { error, info, log, success, warn } from "./logger.js";
2
2
  export { exit } from "./exit.js";
3
3
  export { isSubdir } from "./isSubdir.js";
4
+ export { sendEvent } from "./sendEvent.js";
4
5
  export {
5
6
  logWithSpinner,
6
7
  stopSpinner,
@@ -0,0 +1,7 @@
1
+ import ua from "universal-analytics";
2
+
3
+ const visitor = ua("UA-235099461-1");
4
+
5
+ export function sendEvent({ event, action, meta }) {
6
+ visitor.event(event, action, JSON.stringify(meta)).send();
7
+ }