framer-code-link 0.2.8 → 0.2.9

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.
Files changed (2) hide show
  1. package/dist/index.mjs +26 -5
  2. package/package.json +2 -2
package/dist/index.mjs CHANGED
@@ -1,4 +1,5 @@
1
1
  #!/usr/bin/env node
2
+ import { createRequire } from "node:module";
2
3
  import { Command } from "commander";
3
4
  import fs from "fs/promises";
4
5
  import { WebSocketServer } from "ws";
@@ -143,6 +144,15 @@ function flushDedupe() {
143
144
  lastMessageCount = 0;
144
145
  }
145
146
  /**
147
+ * End file sync group - adds newline if we were in file sync mode
148
+ */
149
+ function endFileSyncGroup() {
150
+ if (lastWasFileSync) {
151
+ console.log();
152
+ lastWasFileSync = false;
153
+ }
154
+ }
155
+ /**
146
156
  * Log with deduplication - repeated messages within window get counted
147
157
  */
148
158
  function logWithDedupe(message, writer, isFileSync = false) {
@@ -178,6 +188,7 @@ function debug(message, ...args) {
178
188
  */
179
189
  function info(message, ...args) {
180
190
  if (currentLevel <= LogLevel.INFO) {
191
+ endFileSyncGroup();
181
192
  const formatted = args.length > 0 ? `${message} ${args.join(" ")}` : message;
182
193
  logWithDedupe(formatted, () => console.log(formatted));
183
194
  }
@@ -188,6 +199,7 @@ function info(message, ...args) {
188
199
  function warn(message, ...args) {
189
200
  if (currentLevel <= LogLevel.WARN) {
190
201
  if (message === lastMessage) return;
202
+ endFileSyncGroup();
191
203
  flushDedupe();
192
204
  lastMessage = message;
193
205
  lastMessageCount = 1;
@@ -199,6 +211,7 @@ function warn(message, ...args) {
199
211
  */
200
212
  function error(message, ...args) {
201
213
  if (currentLevel <= LogLevel.ERROR) {
214
+ endFileSyncGroup();
202
215
  flushDedupe();
203
216
  console.error(import_picocolors.default.red(`✗ ${message}`), ...args);
204
217
  }
@@ -208,6 +221,7 @@ function error(message, ...args) {
208
221
  */
209
222
  function success(message, ...args) {
210
223
  if (currentLevel <= LogLevel.INFO) {
224
+ endFileSyncGroup();
211
225
  flushDedupe();
212
226
  console.log(import_picocolors.default.green(`✓ ${message}`), ...args);
213
227
  }
@@ -238,6 +252,7 @@ function fileDelete(fileName) {
238
252
  */
239
253
  function status(message) {
240
254
  if (currentLevel <= LogLevel.INFO) {
255
+ endFileSyncGroup();
241
256
  flushDedupe();
242
257
  console.log(import_picocolors.default.dim(` ${message}`));
243
258
  }
@@ -2037,9 +2052,10 @@ function transition(state, event) {
2037
2052
  name: conflict.fileName,
2038
2053
  content: conflict.remoteContent,
2039
2054
  modifiedAt: conflict.remoteModifiedAt
2040
- }]
2055
+ }],
2056
+ silent: true
2041
2057
  });
2042
- effects.push(log("debug", `Applied ${state.pendingConflicts.length} remote versions`));
2058
+ effects.push(log("success", "Keeping Framer changes"));
2043
2059
  } else {
2044
2060
  for (const conflict of state.pendingConflicts) if (conflict.localContent === null) effects.push({
2045
2061
  type: "SEND_MESSAGE",
@@ -2056,7 +2072,7 @@ function transition(state, event) {
2056
2072
  content: conflict.localContent
2057
2073
  }
2058
2074
  });
2059
- effects.push(log("debug", `Applied ${state.pendingConflicts.length} local versions`));
2075
+ effects.push(log("success", "Keeping local changes"));
2060
2076
  }
2061
2077
  effects.push({ type: "PERSIST_STATE" }, {
2062
2078
  type: "SYNC_COMPLETE",
@@ -2359,7 +2375,12 @@ async function executeEffect(effect, context) {
2359
2375
  return [];
2360
2376
  }
2361
2377
  case "LOG":
2362
- (effect.level === "info" ? info : effect.level === "warn" ? warn : debug)(effect.message);
2378
+ ({
2379
+ info,
2380
+ warn,
2381
+ success,
2382
+ debug
2383
+ }[effect.level] ?? debug)(effect.message);
2363
2384
  return [];
2364
2385
  }
2365
2386
  }
@@ -2553,7 +2574,7 @@ async function start(config) {
2553
2574
  * Entry point for the CLI tool. Parses command-line arguments and starts
2554
2575
  * the controller with the appropriate configuration.
2555
2576
  */
2556
- const version = "0.2.8";
2577
+ const { version } = createRequire(import.meta.url)("../package.json");
2557
2578
  const program = new Command();
2558
2579
  program.exitOverride((err) => {
2559
2580
  if (err.code === "commander.missingArgument") {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "framer-code-link",
3
- "version": "0.2.8",
3
+ "version": "0.2.9",
4
4
  "description": "CLI tool for syncing Framer code components - controller-centric architecture",
5
5
  "main": "dist/index.mjs",
6
6
  "type": "module",
@@ -10,7 +10,7 @@
10
10
  ],
11
11
  "scripts": {
12
12
  "dev": "NODE_ENV=development tsx src/index.ts",
13
- "build": "tsdown src/index.ts --define.__VERSION__=\"\\\"$npm_package_version\\\"\"",
13
+ "build": "tsdown src/index.ts",
14
14
  "start": "node dist/index.mjs",
15
15
  "test": "vitest run"
16
16
  },