@knockdata/objectexplorer 0.1.0 → 0.2.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/cli.js CHANGED
@@ -8,6 +8,7 @@ import os from "node:os"
8
8
  import fs from "node:fs"
9
9
  import { fileURLToPath } from "node:url"
10
10
  import { spawn } from "node:child_process"
11
+ import openFolderNative from "./openFolderNative.js"
11
12
 
12
13
 
13
14
  const positional = []
@@ -27,7 +28,24 @@ const mode = args.mode ?? 'prod'
27
28
 
28
29
  const here = path.dirname(fileURLToPath(import.meta.url))
29
30
  const bundleDir = path.join(here, "server")
30
- const appDir = path.join(here, "app")
31
+ const repoRoot = path.join(here, "..")
32
+ const isDev = mode === "dev"
33
+
34
+ // dev runs the vite middleware over the monorepo explorer source, so the frontend is
35
+ // debuggable with real files and HMR; prod serves the app built into this package.
36
+ // publicDir must stay unset in dev, otherwise the built app shadows the vite source.
37
+ let appDir = path.join(here, "app")
38
+ let publicDir = appDir
39
+ if (isDev) {
40
+ appDir = path.join(repoRoot, "explorer")
41
+ publicDir = undefined
42
+ }
43
+
44
+ // built source maps, served at /maps/ for manual attach in DevTools
45
+ let mapsDir = null
46
+ if (isDev) {
47
+ mapsDir = path.join(repoRoot, "server/sites/objectexplorer.com/maps")
48
+ }
31
49
 
32
50
  // the demo dataset is its own package (objectexplorer-demo) and is not installed here by
33
51
  // default; without it the backend proxies demo requests to objectexplorer.com
@@ -41,17 +59,40 @@ const startFolder = positional[0] ? path.resolve(positional[0]) : process.cwd()
41
59
  const userData = path.join(os.homedir(), ".objectexplorer")
42
60
  fs.mkdirSync(userData, { recursive: true })
43
61
 
44
- // clicking "add folder" in the UI has no native dialog here, so return the folder
45
- // given on the command line (or the current directory) to make it browsable.
46
- const openFolder = async () => startFolder
62
+ // seed the launch folder as a default root; the server keeps existing folders.json
63
+ // entries whose folderPath still exists, so this just needs to be present on disk.
64
+ seedFolder(userData, startFolder)
65
+
66
+ function seedFolder(userData, folderPath) {
67
+ const foldersFile = path.join(userData, "folders.json")
68
+ let folders = []
69
+ if (fs.existsSync(foldersFile)) {
70
+ folders = JSON.parse(fs.readFileSync(foldersFile, "utf8"))
71
+ }
72
+ const exists = folders.find(folder => folder.folderPath === folderPath)
73
+ if (exists) {
74
+ }
75
+ else {
76
+ const name = path.basename(folderPath)
77
+ folders.push({ name, root: name, path: "/", objectKind: "folder", folderPath })
78
+ fs.writeFileSync(foldersFile, JSON.stringify(folders, null, 4))
79
+ }
80
+ }
81
+
82
+ // clicking "add folder" in the UI opens the OS-native folder dialog, so the user
83
+ // has full access to any folder on the machine.
84
+ const openFolder = openFolderNative
47
85
 
48
- const serverPath = mode === "dev" ? "../server/WebServer.js" : path.join(bundleDir, "WebServer.mjs")
86
+ const serverPath = isDev ? "../server/WebServer.js" : path.join(bundleDir, "WebServer.mjs")
49
87
 
50
88
  const { WebServer } = await import(serverPath)
51
89
  const server = await WebServer({
52
90
  mode,
91
+ appMode: 'package',
92
+ root: repoRoot,
53
93
  appDir,
54
- publicDir: appDir,
94
+ publicDir,
95
+ mapsDir,
55
96
  demoPath,
56
97
  userData,
57
98
  openFolder,
package/demo/.meta.bin CHANGED
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@knockdata/objectexplorer",
3
- "version": "0.1.0",
3
+ "version": "0.2.0",
4
4
  "description": "The VSCode for Cloud Storage — Explore, Analyze, Search your cloud storage locally with single click",
5
5
  "type": "module",
6
6
  "license": "ISC",