amalgm 0.1.64 → 0.1.65

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "amalgm",
3
- "version": "0.1.64",
3
+ "version": "0.1.65",
4
4
  "description": "Amalgm local computer runtime: login, MCP, chat, events, previews, and tunnels.",
5
5
  "license": "UNLICENSED",
6
6
  "private": false,
@@ -29,6 +29,10 @@ const fileWatchers = new Map();
29
29
  const uploadWatchers = new Map();
30
30
  let uploadsPublishTimer = null;
31
31
 
32
+ function isHiddenFilesystemEntry(name) {
33
+ return typeof name === 'string' && name.startsWith('.');
34
+ }
35
+
32
36
  function expandHome(targetPath) {
33
37
  if (targetPath === '~') return os.homedir();
34
38
  if (typeof targetPath === 'string' && targetPath.startsWith('~/')) {
@@ -280,16 +284,12 @@ function classifyFile(targetPath) {
280
284
 
281
285
  function directorySnapshot(targetPath) {
282
286
  const entries = fs.readdirSync(targetPath, { withFileTypes: true });
283
- const files = entries.map((entry) => {
284
- const fullPath = path.join(targetPath, entry.name);
285
- const stats = fs.lstatSync(fullPath);
286
- return {
287
+ const files = entries
288
+ .filter((entry) => !isHiddenFilesystemEntry(entry.name))
289
+ .map((entry) => ({
287
290
  name: entry.name,
288
- isDir: stats.isDirectory(),
289
- size: stats.size,
290
- modTime: stats.mtime.toISOString(),
291
- };
292
- });
291
+ isDir: entry.isDirectory(),
292
+ }));
293
293
 
294
294
  files.sort((a, b) => {
295
295
  if (a.isDir !== b.isDir) return a.isDir ? -1 : 1;
@@ -0,0 +1,27 @@
1
+ 'use strict';
2
+
3
+ const test = require('node:test');
4
+ const assert = require('node:assert/strict');
5
+ const fs = require('fs');
6
+ const os = require('os');
7
+ const path = require('path');
8
+
9
+ const { buildFilesResource } = require('../fs/rest')._private;
10
+
11
+ test('files resource omits dot-prefixed filesystem entries', (t) => {
12
+ const dir = fs.mkdtempSync(path.join(os.tmpdir(), 'amalgm-files-resource-'));
13
+ t.after(() => fs.rmSync(dir, { recursive: true, force: true }));
14
+
15
+ fs.mkdirSync(path.join(dir, 'visible-dir'));
16
+ fs.mkdirSync(path.join(dir, '.hidden-dir'));
17
+ fs.writeFileSync(path.join(dir, 'visible.txt'), 'hello');
18
+ fs.writeFileSync(path.join(dir, '.env'), 'SECRET=value');
19
+
20
+ const snapshot = buildFilesResource(dir, { watch: false });
21
+
22
+ assert.deepEqual(
23
+ snapshot.files.map((file) => file.name),
24
+ ['visible-dir', 'visible.txt'],
25
+ );
26
+ assert.equal(snapshot.files.some((file) => file.name.startsWith('.')), false);
27
+ });