@unbase-app/cli 0.2.0 → 0.3.0

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/lib/versions.mjs CHANGED
@@ -11,10 +11,10 @@ const own = JSON.parse(readFileSync(new URL("../package.json", import.meta.url),
11
11
  export const SELF = { name: own.name, version: own.version, dev: true };
12
12
 
13
13
  /**
14
- * Unbase in an Astro site, one package (K5): comment mode and the draft-pages kit below, at the
15
- * versions its own package.json pins (kit/astro; a test holds the two equal).
14
+ * Unbase in an Astro site, one package (K5): comment mode, the draft-pages kit and the analytics
15
+ * beacon below, at the versions its own package.json pins (kit/astro; a test holds the two equal).
16
16
  */
17
- export const ASTRO = { name: "@unbase-app/astro", version: "0.1.0", dev: false };
17
+ export const ASTRO = { name: "@unbase-app/astro", version: "0.2.0", dev: false };
18
18
 
19
19
  /** Comments on the live site (`?comment`), and the content schemas, page list and markers it writes. Inside ASTRO. */
20
20
  export const COMMENT_MODUS = { name: "@jens4m/comment-modus", version: "1.9.0", dev: false };
@@ -22,6 +22,9 @@ export const COMMENT_MODUS = { name: "@jens4m/comment-modus", version: "1.9.0",
22
22
  /** Keeps draft pages out of production builds. Inside ASTRO. */
23
23
  export const PAGES = { name: "@unbase-app/pages", version: "0.3.0", dev: false };
24
24
 
25
+ /** Unbase's analytics beacon (kit/analytics). Inside ASTRO, VITE and NEXT; never installed on its own. */
26
+ export const ANALYTICS = { name: "@unbase-app/analytics", version: "0.1.0", dev: false };
27
+
25
28
  /**
26
29
  * The names before K5 (03-11): a site installed then has the pair (comment-modus and the kit) and
27
30
  * the CLI under these. init replaces them; doctor and uninstall know them.
@@ -29,10 +32,17 @@ export const PAGES = { name: "@unbase-app/pages", version: "0.3.0", dev: false }
29
32
  export const BEFORE = { pages: "@jens4m/unbase-pages", cli: "@jens4m/unbase" };
30
33
 
31
34
  /** Vite + React Router: the draft-pages kit and comment mode's loader, in one Vite plugin (kit/vite). A build tool, so a devDependency, beside vite. */
32
- export const VITE = { name: "@unbase-app/vite", version: "0.1.0", dev: true };
35
+ export const VITE = { name: "@unbase-app/vite", version: "0.2.0", dev: true };
36
+
37
+ /** Next.js: draft pages kept out of production builds, comments on the live site and analytics (`withUnbase`). */
38
+ export const NEXT = { name: "@unbase-app/next", version: "0.2.0", dev: false };
33
39
 
34
- /** Next.js: draft pages kept out of production builds, and comments on the live site (`withUnbase`). */
35
- export const NEXT = { name: "@unbase-app/next", version: "0.1.0", dev: false };
40
+ /**
41
+ * The first version of each framework's package that brings the analytics beacon: doctor's
42
+ * "new enough" (Unbase's read_install reads the same, _shared/framework-packages.ts ANALYTICS_CALLS;
43
+ * a test holds the two equal).
44
+ */
45
+ export const ANALYTICS_FROM = { [ASTRO.name]: "0.2.0", [VITE.name]: "0.2.0", [NEXT.name]: "0.2.0" };
36
46
 
37
47
  /** Where comment mode's layer is served from: only fetched by a visitor who opens `?comment` (ADR-0012's one exception). */
38
48
  export const LAYER_URL = "https://layer.unbase.app/v1/loader.js";
@@ -115,16 +115,18 @@ function pluginsArray(prop) {
115
115
  return null;
116
116
  }
117
117
 
118
- /** unbase()'s literal options: `comments: false`, a literal `project`; null when they cannot be read. */
118
+ /** unbase()'s literal options: `comments: false`, `analytics: false`, a literal `project`; null when they cannot be read. */
119
119
  function optionsOf(call) {
120
- if (!call.arguments.length) return { comments: true, project: null, only: null };
120
+ if (!call.arguments.length) return { comments: true, analytics: true, project: null, only: null };
121
121
  const o = unwrap(call.arguments[0]);
122
122
  if (o?.type !== "ObjectExpression" || o.properties.some((p) => p.type !== "ObjectProperty" || p.computed)) return null;
123
123
  const prop = (name) => o.properties.find((p) => keyName(p) === name);
124
124
  const c = prop("comments") ? unwrap(prop("comments").value) : null;
125
+ const a = prop("analytics") ? unwrap(prop("analytics").value) : null;
125
126
  const p = prop("project") ? unwrap(prop("project").value) : null;
126
127
  return {
127
128
  comments: !(c?.type === "BooleanLiteral" && c.value === false),
129
+ analytics: !(a?.type === "BooleanLiteral" && a.value === false),
128
130
  project: p?.type === "StringLiteral" ? p.value : null,
129
131
  /** The one property there is, when there is one: init turns `{ comments: false }` into nothing. */
130
132
  only: o.properties.length === 1 ? keyName(o.properties[0]) : null,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@unbase-app/cli",
3
- "version": "0.2.0",
3
+ "version": "0.3.0",
4
4
  "description": "Adds Unbase to an Astro, Vite + React or Next.js site, checks it, and takes it out again: unbase init, unbase doctor, unbase uninstall.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -23,7 +23,8 @@
23
23
  "cli",
24
24
  "cms",
25
25
  "comments",
26
- "drafts"
26
+ "drafts",
27
+ "analytics"
27
28
  ],
28
29
  "publishConfig": {
29
30
  "access": "public"