framer-code-link 0.2.8 → 0.2.10
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/dist/index.mjs +34 -12
- 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";
|
|
@@ -117,7 +118,7 @@ let LogLevel = /* @__PURE__ */ function(LogLevel$1) {
|
|
|
117
118
|
let currentLevel = LogLevel.INFO;
|
|
118
119
|
let lastMessage = "";
|
|
119
120
|
let lastMessageCount = 0;
|
|
120
|
-
let
|
|
121
|
+
let lastCategory = "other";
|
|
121
122
|
const CLEAR_LINE = "\x1B[2K";
|
|
122
123
|
const MOVE_CURSOR_UP = "\x1B[1A";
|
|
123
124
|
function rewriteLastLine(text) {
|
|
@@ -143,16 +144,23 @@ function flushDedupe() {
|
|
|
143
144
|
lastMessageCount = 0;
|
|
144
145
|
}
|
|
145
146
|
/**
|
|
147
|
+
* Handle category transition - adds newline when switching categories
|
|
148
|
+
*/
|
|
149
|
+
function transitionCategory(newCategory) {
|
|
150
|
+
if (lastCategory !== newCategory) {
|
|
151
|
+
console.log();
|
|
152
|
+
lastCategory = newCategory;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
146
156
|
* Log with deduplication - repeated messages within window get counted
|
|
147
157
|
*/
|
|
148
|
-
function logWithDedupe(message, writer
|
|
158
|
+
function logWithDedupe(message, writer) {
|
|
149
159
|
if (message === lastMessage) {
|
|
150
160
|
lastMessageCount++;
|
|
151
161
|
dedupeMessage(message, lastMessageCount);
|
|
152
162
|
return;
|
|
153
163
|
}
|
|
154
|
-
if (isFileSync && !lastWasFileSync) console.log();
|
|
155
|
-
lastWasFileSync = isFileSync;
|
|
156
164
|
lastMessage = message;
|
|
157
165
|
lastMessageCount = 1;
|
|
158
166
|
writer();
|
|
@@ -178,6 +186,7 @@ function debug(message, ...args) {
|
|
|
178
186
|
*/
|
|
179
187
|
function info(message, ...args) {
|
|
180
188
|
if (currentLevel <= LogLevel.INFO) {
|
|
189
|
+
transitionCategory("other");
|
|
181
190
|
const formatted = args.length > 0 ? `${message} ${args.join(" ")}` : message;
|
|
182
191
|
logWithDedupe(formatted, () => console.log(formatted));
|
|
183
192
|
}
|
|
@@ -188,6 +197,7 @@ function info(message, ...args) {
|
|
|
188
197
|
function warn(message, ...args) {
|
|
189
198
|
if (currentLevel <= LogLevel.WARN) {
|
|
190
199
|
if (message === lastMessage) return;
|
|
200
|
+
transitionCategory("other");
|
|
191
201
|
flushDedupe();
|
|
192
202
|
lastMessage = message;
|
|
193
203
|
lastMessageCount = 1;
|
|
@@ -199,6 +209,7 @@ function warn(message, ...args) {
|
|
|
199
209
|
*/
|
|
200
210
|
function error(message, ...args) {
|
|
201
211
|
if (currentLevel <= LogLevel.ERROR) {
|
|
212
|
+
transitionCategory("other");
|
|
202
213
|
flushDedupe();
|
|
203
214
|
console.error(import_picocolors.default.red(`✗ ${message}`), ...args);
|
|
204
215
|
}
|
|
@@ -208,6 +219,7 @@ function error(message, ...args) {
|
|
|
208
219
|
*/
|
|
209
220
|
function success(message, ...args) {
|
|
210
221
|
if (currentLevel <= LogLevel.INFO) {
|
|
222
|
+
transitionCategory("other");
|
|
211
223
|
flushDedupe();
|
|
212
224
|
console.log(import_picocolors.default.green(`✓ ${message}`), ...args);
|
|
213
225
|
}
|
|
@@ -217,20 +229,23 @@ function success(message, ...args) {
|
|
|
217
229
|
*/
|
|
218
230
|
function fileDown(fileName) {
|
|
219
231
|
if (currentLevel <= LogLevel.INFO) {
|
|
232
|
+
transitionCategory("file-sync");
|
|
220
233
|
const msg = ` ${import_picocolors.default.blue("↓")} ${fileName}`;
|
|
221
|
-
logWithDedupe(msg, () => console.log(msg)
|
|
234
|
+
logWithDedupe(msg, () => console.log(msg));
|
|
222
235
|
}
|
|
223
236
|
}
|
|
224
237
|
function fileUp(fileName) {
|
|
225
238
|
if (currentLevel <= LogLevel.INFO) {
|
|
239
|
+
transitionCategory("file-sync");
|
|
226
240
|
const msg = ` ${import_picocolors.default.green("↑")} ${fileName}`;
|
|
227
|
-
logWithDedupe(msg, () => console.log(msg)
|
|
241
|
+
logWithDedupe(msg, () => console.log(msg));
|
|
228
242
|
}
|
|
229
243
|
}
|
|
230
244
|
function fileDelete(fileName) {
|
|
231
245
|
if (currentLevel <= LogLevel.INFO) {
|
|
246
|
+
transitionCategory("file-sync");
|
|
232
247
|
const msg = ` ${import_picocolors.default.red("×")} ${fileName}`;
|
|
233
|
-
logWithDedupe(msg, () => console.log(msg)
|
|
248
|
+
logWithDedupe(msg, () => console.log(msg));
|
|
234
249
|
}
|
|
235
250
|
}
|
|
236
251
|
/**
|
|
@@ -238,6 +253,7 @@ function fileDelete(fileName) {
|
|
|
238
253
|
*/
|
|
239
254
|
function status(message) {
|
|
240
255
|
if (currentLevel <= LogLevel.INFO) {
|
|
256
|
+
transitionCategory("other");
|
|
241
257
|
flushDedupe();
|
|
242
258
|
console.log(import_picocolors.default.dim(` ${message}`));
|
|
243
259
|
}
|
|
@@ -2037,9 +2053,10 @@ function transition(state, event) {
|
|
|
2037
2053
|
name: conflict.fileName,
|
|
2038
2054
|
content: conflict.remoteContent,
|
|
2039
2055
|
modifiedAt: conflict.remoteModifiedAt
|
|
2040
|
-
}]
|
|
2056
|
+
}],
|
|
2057
|
+
silent: true
|
|
2041
2058
|
});
|
|
2042
|
-
effects.push(log("
|
|
2059
|
+
effects.push(log("success", "Keeping Framer changes"));
|
|
2043
2060
|
} else {
|
|
2044
2061
|
for (const conflict of state.pendingConflicts) if (conflict.localContent === null) effects.push({
|
|
2045
2062
|
type: "SEND_MESSAGE",
|
|
@@ -2056,7 +2073,7 @@ function transition(state, event) {
|
|
|
2056
2073
|
content: conflict.localContent
|
|
2057
2074
|
}
|
|
2058
2075
|
});
|
|
2059
|
-
effects.push(log("
|
|
2076
|
+
effects.push(log("success", "Keeping local changes"));
|
|
2060
2077
|
}
|
|
2061
2078
|
effects.push({ type: "PERSIST_STATE" }, {
|
|
2062
2079
|
type: "SYNC_COMPLETE",
|
|
@@ -2359,7 +2376,12 @@ async function executeEffect(effect, context) {
|
|
|
2359
2376
|
return [];
|
|
2360
2377
|
}
|
|
2361
2378
|
case "LOG":
|
|
2362
|
-
(
|
|
2379
|
+
({
|
|
2380
|
+
info,
|
|
2381
|
+
warn,
|
|
2382
|
+
success,
|
|
2383
|
+
debug
|
|
2384
|
+
}[effect.level] ?? debug)(effect.message);
|
|
2363
2385
|
return [];
|
|
2364
2386
|
}
|
|
2365
2387
|
}
|
|
@@ -2553,7 +2575,7 @@ async function start(config) {
|
|
|
2553
2575
|
* Entry point for the CLI tool. Parses command-line arguments and starts
|
|
2554
2576
|
* the controller with the appropriate configuration.
|
|
2555
2577
|
*/
|
|
2556
|
-
const version =
|
|
2578
|
+
const { version } = createRequire(import.meta.url)("../package.json");
|
|
2557
2579
|
const program = new Command();
|
|
2558
2580
|
program.exitOverride((err) => {
|
|
2559
2581
|
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.
|
|
3
|
+
"version": "0.2.10",
|
|
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
|
|
13
|
+
"build": "tsdown src/index.ts",
|
|
14
14
|
"start": "node dist/index.mjs",
|
|
15
15
|
"test": "vitest run"
|
|
16
16
|
},
|