Browse Source

fix: mkdir not works for nfs

Also, fix readme
Tienson Qin 4 years ago
parent
commit
89d5593ad8
4 changed files with 74 additions and 28 deletions
  1. 5 3
      README.md
  2. 3 2
      package.json
  3. 26 23
      src/main/frontend/fs.cljs
  4. 40 0
      yarn.lock

+ 5 - 3
README.md

@@ -79,6 +79,8 @@ yarn watch
 
 
 Open <http://localhost:3001>.
 Open <http://localhost:3001>.
 
 
-## Build errors
-### 1. The required namespace `devtools.preload` is not available.
-Upload your clojure to at least version `1.10.1.739`.
+### 4. Build a release
+
+``` bash
+yarn release
+```

+ 3 - 2
package.json

@@ -18,7 +18,7 @@
         "tailwindcss": "^1.3.4"
         "tailwindcss": "^1.3.4"
     },
     },
     "scripts": {
     "scripts": {
-        "watch": "run-p cljs:watch gulp:watch",
+        "watch": "run-p cljs:watch gulp:build gulp:watch",
         "release": "run-s cljs:release gulp:build",
         "release": "run-s cljs:release gulp:build",
         "watch-app": "run-p cljs:watch-app gulp:watch",
         "watch-app": "run-p cljs:watch-app gulp:watch",
         "release-app": "run-s cljs:release-app gulp:build",
         "release-app": "run-s cljs:release-app gulp:build",
@@ -28,7 +28,7 @@
         "test": "run-s cljs:test cljs:run-test",
         "test": "run-s cljs:test cljs:run-test",
         "report": "run-s cljs:report",
         "report": "run-s cljs:report",
         "gulp:watch": "gulp watch",
         "gulp:watch": "gulp watch",
-        "gulp:build": "NODE_ENV=production gulp build",
+        "gulp:build": "cross-env NODE_ENV=production gulp build",
         "cljs:watch": "clojure -M:cljs watch app publishing",
         "cljs:watch": "clojure -M:cljs watch app publishing",
         "cljs:release": "clojure -M:cljs release app publishing",
         "cljs:release": "clojure -M:cljs release app publishing",
         "cljs:test": "clojure -A:test compile test",
         "cljs:test": "clojure -A:test compile test",
@@ -42,6 +42,7 @@
     },
     },
     "dependencies": {
     "dependencies": {
         "codemirror": "^5.58.1",
         "codemirror": "^5.58.1",
+        "cross-env": "^7.0.3",
         "diff": "^4.0.2",
         "diff": "^4.0.2",
         "dropbox": "^5.2.0",
         "dropbox": "^5.2.0",
         "ignore": "^5.1.8",
         "ignore": "^5.1.8",

+ 26 - 23
src/main/frontend/fs.cljs

@@ -64,14 +64,6 @@
     :else
     :else
     (println (str "mkdir " dir " failed"))))
     (println (str "mkdir " dir " failed"))))
 
 
-(defn mkdir-if-not-exists
-  [dir]
-  (when (and dir js/window.pfs)
-    (util/p-handle
-     (js/window.pfs.stat dir)
-     (fn [_stat])
-     (fn [_error] (js/window.pfs.mkdir dir)))))
-
 (defn readdir
 (defn readdir
   [dir]
   [dir]
   (cond
   (cond
@@ -181,22 +173,33 @@
 
 
 (defn stat
 (defn stat
   [dir path]
   [dir path]
-  (cond
-    (local-db? dir)
-    (if-let [file (get-nfs-file-handle (str "handle/"
-                                              (string/replace-first dir "/" "")
-                                              "/"
-                                              (string/replace-first path "/" "")))]
-      (p/let [file (.getFile file)]
-        (let [get-attr #(gobj/get file %)]
-          {:file/last-modified-at (get-attr "lastModified")
-           :file/size (get-attr "size")
-           :file/type (get-attr "type")}))
-      (p/rejected "File not exists"))
+  (let [append-path (if path
+               (str "/" (string/replace-first path "/" ""))
+               "")]
+    (cond
+     (local-db? dir)
+     (if-let [file (get-nfs-file-handle (str "handle/"
+                                             (string/replace-first dir "/" "")
+                                             append-path))]
+       (p/let [file (.getFile file)]
+         (let [get-attr #(gobj/get file %)]
+           {:file/last-modified-at (get-attr "lastModified")
+            :file/size (get-attr "size")
+            :file/type (get-attr "type")}))
+       (p/rejected "File not exists"))
 
 
-    :else
-    ;; FIXME: same format
-    (js/window.pfs.stat (str dir "/" (string/replace-first path "/" "")))))
+     :else
+     ;; FIXME: same format
+     (js/window.pfs.stat (str dir append-path)))))
+
+(defn mkdir-if-not-exists
+  [dir]
+  (when (and dir js/window.pfs)
+    (util/p-handle
+     (stat dir nil)
+     (fn [_stat])
+     (fn [error]
+       (mkdir dir)))))
 
 
 (defn create-if-not-exists
 (defn create-if-not-exists
   ([dir path]
   ([dir path]

+ 40 - 0
yarn.lock

@@ -963,6 +963,13 @@ create-hmac@^1.1.0, create-hmac@^1.1.2, create-hmac@^1.1.4:
     safe-buffer "^5.0.1"
     safe-buffer "^5.0.1"
     sha.js "^2.4.8"
     sha.js "^2.4.8"
 
 
+cross-env@^7.0.3:
+  version "7.0.3"
+  resolved "https://registry.yarnpkg.com/cross-env/-/cross-env-7.0.3.tgz#865264b29677dc015ba8418918965dd232fc54cf"
+  integrity sha512-+/HKd6EgcQCJGh2PSjZuUitQBQynKor4wrFbRg4DtAgS1aWO+gU52xpH7M9ScGgXSYmAVS9bIJ8EzuaGw0oNAw==
+  dependencies:
+    cross-spawn "^7.0.1"
+
 cross-spawn@^6.0.0, cross-spawn@^6.0.5:
 cross-spawn@^6.0.0, cross-spawn@^6.0.5:
   version "6.0.5"
   version "6.0.5"
   resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-6.0.5.tgz#4a5ec7c64dfae22c3a14124dbacdee846d80cbc4"
   resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-6.0.5.tgz#4a5ec7c64dfae22c3a14124dbacdee846d80cbc4"
@@ -974,6 +981,15 @@ cross-spawn@^6.0.0, cross-spawn@^6.0.5:
     shebang-command "^1.2.0"
     shebang-command "^1.2.0"
     which "^1.2.9"
     which "^1.2.9"
 
 
+cross-spawn@^7.0.1:
+  version "7.0.3"
+  resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-7.0.3.tgz#f73a85b9d5d41d045551c177e2882d4ac85728a6"
+  integrity sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==
+  dependencies:
+    path-key "^3.1.0"
+    shebang-command "^2.0.0"
+    which "^2.0.1"
+
 crypto-browserify@^3.11.0:
 crypto-browserify@^3.11.0:
   version "3.12.0"
   version "3.12.0"
   resolved "https://registry.yarnpkg.com/crypto-browserify/-/crypto-browserify-3.12.0.tgz#396cf9f3137f03e4b8e532c58f698254e00f80ec"
   resolved "https://registry.yarnpkg.com/crypto-browserify/-/crypto-browserify-3.12.0.tgz#396cf9f3137f03e4b8e532c58f698254e00f80ec"
@@ -3364,6 +3380,11 @@ path-key@^2.0.0, path-key@^2.0.1:
   resolved "https://registry.yarnpkg.com/path-key/-/path-key-2.0.1.tgz#411cadb574c5a140d3a4b1910d40d80cc9f40b40"
   resolved "https://registry.yarnpkg.com/path-key/-/path-key-2.0.1.tgz#411cadb574c5a140d3a4b1910d40d80cc9f40b40"
   integrity sha1-QRyttXTFoUDTpLGRDUDYDMn0C0A=
   integrity sha1-QRyttXTFoUDTpLGRDUDYDMn0C0A=
 
 
+path-key@^3.1.0:
+  version "3.1.1"
+  resolved "https://registry.yarnpkg.com/path-key/-/path-key-3.1.1.tgz#581f6ade658cbba65a0d3380de7753295054f375"
+  integrity sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==
+
 path-parse@^1.0.6:
 path-parse@^1.0.6:
   version "1.0.6"
   version "1.0.6"
   resolved "https://registry.yarnpkg.com/path-parse/-/path-parse-1.0.6.tgz#d62dbb5679405d72c4737ec58600e9ddcf06d24c"
   resolved "https://registry.yarnpkg.com/path-parse/-/path-parse-1.0.6.tgz#d62dbb5679405d72c4737ec58600e9ddcf06d24c"
@@ -4372,11 +4393,23 @@ shebang-command@^1.2.0:
   dependencies:
   dependencies:
     shebang-regex "^1.0.0"
     shebang-regex "^1.0.0"
 
 
+shebang-command@^2.0.0:
+  version "2.0.0"
+  resolved "https://registry.yarnpkg.com/shebang-command/-/shebang-command-2.0.0.tgz#ccd0af4f8835fbdc265b82461aaf0c36663f34ea"
+  integrity sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==
+  dependencies:
+    shebang-regex "^3.0.0"
+
 shebang-regex@^1.0.0:
 shebang-regex@^1.0.0:
   version "1.0.0"
   version "1.0.0"
   resolved "https://registry.yarnpkg.com/shebang-regex/-/shebang-regex-1.0.0.tgz#da42f49740c0b42db2ca9728571cb190c98efea3"
   resolved "https://registry.yarnpkg.com/shebang-regex/-/shebang-regex-1.0.0.tgz#da42f49740c0b42db2ca9728571cb190c98efea3"
   integrity sha1-2kL0l0DAtC2yypcoVxyxkMmO/qM=
   integrity sha1-2kL0l0DAtC2yypcoVxyxkMmO/qM=
 
 
+shebang-regex@^3.0.0:
+  version "3.0.0"
+  resolved "https://registry.yarnpkg.com/shebang-regex/-/shebang-regex-3.0.0.tgz#ae16f1644d873ecad843b0307b143362d4c42172"
+  integrity sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==
+
 shell-quote@^1.6.1:
 shell-quote@^1.6.1:
   version "1.7.2"
   version "1.7.2"
   resolved "https://registry.yarnpkg.com/shell-quote/-/shell-quote-1.7.2.tgz#67a7d02c76c9da24f99d20808fcaded0e0e04be2"
   resolved "https://registry.yarnpkg.com/shell-quote/-/shell-quote-1.7.2.tgz#67a7d02c76c9da24f99d20808fcaded0e0e04be2"
@@ -5119,6 +5152,13 @@ which@^1.2.14, which@^1.2.9, which@^1.3.1:
   dependencies:
   dependencies:
     isexe "^2.0.0"
     isexe "^2.0.0"
 
 
+which@^2.0.1:
+  version "2.0.2"
+  resolved "https://registry.yarnpkg.com/which/-/which-2.0.2.tgz#7c6a8dd0a636a0327e10b59c9286eee93f3f51b1"
+  integrity sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==
+  dependencies:
+    isexe "^2.0.0"
+
 wrap-ansi@^2.0.0:
 wrap-ansi@^2.0.0:
   version "2.1.0"
   version "2.1.0"
   resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-2.1.0.tgz#d8fc3d284dd05794fe84973caecdd1cf824fdd85"
   resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-2.1.0.tgz#d8fc3d284dd05794fe84973caecdd1cf824fdd85"