litmus-cli 1.0.3 → 1.0.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/dist/lib/tracker.d.ts +1 -1
- package/dist/lib/tracker.d.ts.map +1 -1
- package/dist/lib/tracker.js +1 -3
- package/dist/lib/tracker.js.map +1 -1
- package/dist/watcher.cjs +27 -25
- package/package.json +1 -2
- package/src/lib/tracker.ts +1 -4
- package/src/lib/watcher.cjs +27 -25
package/dist/lib/tracker.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tracker.d.ts","sourceRoot":"","sources":["../../src/lib/tracker.ts"],"names":[],"mappings":"AAOA;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI,
|
|
1
|
+
{"version":3,"file":"tracker.d.ts","sourceRoot":"","sources":["../../src/lib/tracker.ts"],"names":[],"mappings":"AAOA;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI,CAyBrD"}
|
package/dist/lib/tracker.js
CHANGED
|
@@ -4,7 +4,7 @@ import path from "path";
|
|
|
4
4
|
import { fileURLToPath } from "url";
|
|
5
5
|
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
6
6
|
/**
|
|
7
|
-
* Start the
|
|
7
|
+
* Start the file watcher in the background.
|
|
8
8
|
* Spawns dist/watcher.cjs as a detached process; logs file events to
|
|
9
9
|
* <projectDir>/.litmus/activity.jsonl for later inclusion in the submission ZIP.
|
|
10
10
|
*/
|
|
@@ -19,11 +19,9 @@ export function startTracker(projectDir) {
|
|
|
19
19
|
catch {
|
|
20
20
|
// Non-critical
|
|
21
21
|
}
|
|
22
|
-
const packageRoot = path.join(__dirname, "..");
|
|
23
22
|
const child = spawn("node", [watcherScript, projectDir, activityLog], {
|
|
24
23
|
detached: true,
|
|
25
24
|
stdio: "ignore",
|
|
26
|
-
cwd: packageRoot,
|
|
27
25
|
});
|
|
28
26
|
if (child.pid) {
|
|
29
27
|
child.unref();
|
package/dist/lib/tracker.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tracker.js","sourceRoot":"","sources":["../../src/lib/tracker.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAA;AACrC,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,IAAI,CAAA;AAC7C,OAAO,IAAI,MAAM,MAAM,CAAA;AACvB,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAA;AAEnC,MAAM,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAA;AAE9D;;;;GAIG;AACH,MAAM,UAAU,YAAY,CAAC,UAAkB;IAC7C,MAAM,SAAS,GAAG,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,SAAS,CAAC,CAAA;IAClD,MAAM,WAAW,GAAG,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,gBAAgB,CAAC,CAAA;IAC1D,MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,aAAa,CAAC,CAAA;IACnD,MAAM,aAAa,GAAG,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,aAAa,CAAC,CAAA;IAEzD,IAAI,CAAC;QACH,SAAS,CAAC,SAAS,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAA;IAC3C,CAAC;IAAC,MAAM,CAAC;QACP,eAAe;IACjB,CAAC;IAED,MAAM,
|
|
1
|
+
{"version":3,"file":"tracker.js","sourceRoot":"","sources":["../../src/lib/tracker.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAA;AACrC,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,IAAI,CAAA;AAC7C,OAAO,IAAI,MAAM,MAAM,CAAA;AACvB,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAA;AAEnC,MAAM,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAA;AAE9D;;;;GAIG;AACH,MAAM,UAAU,YAAY,CAAC,UAAkB;IAC7C,MAAM,SAAS,GAAG,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,SAAS,CAAC,CAAA;IAClD,MAAM,WAAW,GAAG,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,gBAAgB,CAAC,CAAA;IAC1D,MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,aAAa,CAAC,CAAA;IACnD,MAAM,aAAa,GAAG,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,aAAa,CAAC,CAAA;IAEzD,IAAI,CAAC;QACH,SAAS,CAAC,SAAS,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAA;IAC3C,CAAC;IAAC,MAAM,CAAC;QACP,eAAe;IACjB,CAAC;IAED,MAAM,KAAK,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,aAAa,EAAE,UAAU,EAAE,WAAW,CAAC,EAAE;QACpE,QAAQ,EAAE,IAAI;QACd,KAAK,EAAE,QAAQ;KAChB,CAAC,CAAA;IAEF,IAAI,KAAK,CAAC,GAAG,EAAE,CAAC;QACd,KAAK,CAAC,KAAK,EAAE,CAAA;QACb,IAAI,CAAC;YACH,aAAa,CAAC,OAAO,EAAE,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC,CAAA;QACnD,CAAC;QAAC,MAAM,CAAC;YACP,eAAe;QACjB,CAAC;IACH,CAAC;AACH,CAAC"}
|
package/dist/watcher.cjs
CHANGED
|
@@ -4,11 +4,11 @@
|
|
|
4
4
|
* Runs as a detached background process started by `litmus init`.
|
|
5
5
|
* Usage: node watcher.cjs <projectDir> <activityLogPath>
|
|
6
6
|
*
|
|
7
|
+
* Uses Node's built-in fs.watch (no external dependencies).
|
|
7
8
|
* Writes newline-delimited JSON to the activity log:
|
|
8
|
-
* { "ts": "ISO-8601", "type": "
|
|
9
|
+
* { "ts": "ISO-8601", "type": "rename"|"change", "path": "relative/path" }
|
|
9
10
|
*/
|
|
10
11
|
|
|
11
|
-
const chokidar = require("chokidar")
|
|
12
12
|
const fs = require("fs")
|
|
13
13
|
const path = require("path")
|
|
14
14
|
|
|
@@ -25,34 +25,36 @@ fs.mkdirSync(path.dirname(activityLogPath), { recursive: true })
|
|
|
25
25
|
// Open the log file for appending
|
|
26
26
|
const log = fs.createWriteStream(activityLogPath, { flags: "a" })
|
|
27
27
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
ts: new Date().toISOString(),
|
|
31
|
-
type,
|
|
32
|
-
path: path.relative(projectDir, filePath),
|
|
33
|
-
})
|
|
34
|
-
log.write(event + "\n")
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
const ignored = [
|
|
38
|
-
/(^|[/\\])\./, // dotfiles and dotdirs (including .git, .litmus)
|
|
28
|
+
const IGNORED = [
|
|
29
|
+
/[/\\]\./, // dotfiles and dotdirs (including .git, .litmus)
|
|
39
30
|
/node_modules/,
|
|
40
31
|
/__pycache__/,
|
|
41
32
|
/\.pyc$/,
|
|
42
33
|
/\.class$/,
|
|
34
|
+
/[/\\]venv[/\\]/,
|
|
35
|
+
/[/\\]\.venv[/\\]/,
|
|
43
36
|
]
|
|
44
37
|
|
|
45
|
-
|
|
46
|
-
.
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
38
|
+
function shouldIgnore(relPath) {
|
|
39
|
+
return IGNORED.some((re) => re.test(relPath))
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function write(type, relPath) {
|
|
43
|
+
const event = JSON.stringify({
|
|
44
|
+
ts: new Date().toISOString(),
|
|
45
|
+
type,
|
|
46
|
+
path: relPath,
|
|
51
47
|
})
|
|
52
|
-
.
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
48
|
+
log.write(event + "\n")
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
try {
|
|
52
|
+
fs.watch(projectDir, { recursive: true }, (eventType, filename) => {
|
|
53
|
+
if (!filename) return
|
|
54
|
+
if (shouldIgnore(filename)) return
|
|
55
|
+
write(eventType, filename)
|
|
58
56
|
})
|
|
57
|
+
} catch (err) {
|
|
58
|
+
process.stderr.write(`[watcher] failed to start: ${err}\n`)
|
|
59
|
+
process.exit(1)
|
|
60
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "litmus-cli",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.4",
|
|
4
4
|
"description": "CLI tool for Litmus engineering assessments",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "elenazhao",
|
|
@@ -17,7 +17,6 @@
|
|
|
17
17
|
},
|
|
18
18
|
"dependencies": {
|
|
19
19
|
"chalk": "^5.3.0",
|
|
20
|
-
"chokidar": "^3.6.0",
|
|
21
20
|
"commander": "^12.1.0",
|
|
22
21
|
"fast-glob": "^3.3.3",
|
|
23
22
|
"ora": "^8.1.1",
|
package/src/lib/tracker.ts
CHANGED
|
@@ -6,7 +6,7 @@ import { fileURLToPath } from "url"
|
|
|
6
6
|
const __dirname = path.dirname(fileURLToPath(import.meta.url))
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
|
-
* Start the
|
|
9
|
+
* Start the file watcher in the background.
|
|
10
10
|
* Spawns dist/watcher.cjs as a detached process; logs file events to
|
|
11
11
|
* <projectDir>/.litmus/activity.jsonl for later inclusion in the submission ZIP.
|
|
12
12
|
*/
|
|
@@ -22,12 +22,9 @@ export function startTracker(projectDir: string): void {
|
|
|
22
22
|
// Non-critical
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
-
const packageRoot = path.join(__dirname, "..")
|
|
26
|
-
|
|
27
25
|
const child = spawn("node", [watcherScript, projectDir, activityLog], {
|
|
28
26
|
detached: true,
|
|
29
27
|
stdio: "ignore",
|
|
30
|
-
cwd: packageRoot,
|
|
31
28
|
})
|
|
32
29
|
|
|
33
30
|
if (child.pid) {
|
package/src/lib/watcher.cjs
CHANGED
|
@@ -4,11 +4,11 @@
|
|
|
4
4
|
* Runs as a detached background process started by `litmus init`.
|
|
5
5
|
* Usage: node watcher.cjs <projectDir> <activityLogPath>
|
|
6
6
|
*
|
|
7
|
+
* Uses Node's built-in fs.watch (no external dependencies).
|
|
7
8
|
* Writes newline-delimited JSON to the activity log:
|
|
8
|
-
* { "ts": "ISO-8601", "type": "
|
|
9
|
+
* { "ts": "ISO-8601", "type": "rename"|"change", "path": "relative/path" }
|
|
9
10
|
*/
|
|
10
11
|
|
|
11
|
-
const chokidar = require("chokidar")
|
|
12
12
|
const fs = require("fs")
|
|
13
13
|
const path = require("path")
|
|
14
14
|
|
|
@@ -25,34 +25,36 @@ fs.mkdirSync(path.dirname(activityLogPath), { recursive: true })
|
|
|
25
25
|
// Open the log file for appending
|
|
26
26
|
const log = fs.createWriteStream(activityLogPath, { flags: "a" })
|
|
27
27
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
ts: new Date().toISOString(),
|
|
31
|
-
type,
|
|
32
|
-
path: path.relative(projectDir, filePath),
|
|
33
|
-
})
|
|
34
|
-
log.write(event + "\n")
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
const ignored = [
|
|
38
|
-
/(^|[/\\])\./, // dotfiles and dotdirs (including .git, .litmus)
|
|
28
|
+
const IGNORED = [
|
|
29
|
+
/[/\\]\./, // dotfiles and dotdirs (including .git, .litmus)
|
|
39
30
|
/node_modules/,
|
|
40
31
|
/__pycache__/,
|
|
41
32
|
/\.pyc$/,
|
|
42
33
|
/\.class$/,
|
|
34
|
+
/[/\\]venv[/\\]/,
|
|
35
|
+
/[/\\]\.venv[/\\]/,
|
|
43
36
|
]
|
|
44
37
|
|
|
45
|
-
|
|
46
|
-
.
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
38
|
+
function shouldIgnore(relPath) {
|
|
39
|
+
return IGNORED.some((re) => re.test(relPath))
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function write(type, relPath) {
|
|
43
|
+
const event = JSON.stringify({
|
|
44
|
+
ts: new Date().toISOString(),
|
|
45
|
+
type,
|
|
46
|
+
path: relPath,
|
|
51
47
|
})
|
|
52
|
-
.
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
48
|
+
log.write(event + "\n")
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
try {
|
|
52
|
+
fs.watch(projectDir, { recursive: true }, (eventType, filename) => {
|
|
53
|
+
if (!filename) return
|
|
54
|
+
if (shouldIgnore(filename)) return
|
|
55
|
+
write(eventType, filename)
|
|
58
56
|
})
|
|
57
|
+
} catch (err) {
|
|
58
|
+
process.stderr.write(`[watcher] failed to start: ${err}\n`)
|
|
59
|
+
process.exit(1)
|
|
60
|
+
}
|