From 46bc1f285632973bd016a6e23d832d99ea8aa48d Mon Sep 17 00:00:00 2001 From: Jordan Martinez Date: Sat, 8 Jul 2023 11:21:16 -0500 Subject: [PATCH 1/9] Update CI actions, CI node to lts --- .github/workflows/ci.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 06ed895..49f6d5f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -10,15 +10,15 @@ jobs: build: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - uses: purescript-contrib/setup-purescript@main with: purescript: "unstable" - - uses: actions/setup-node@v2 + - uses: actions/setup-node@v3 with: - node-version: "14" + node-version: "lts/*" - name: Install dependencies run: | From b5bf8565b46542521edf9d7473d97e7c36ed0449 Mon Sep 17 00:00:00 2001 From: Jordan Martinez Date: Sat, 8 Jul 2023 11:21:33 -0500 Subject: [PATCH 2/9] Bump buffer/streams to master --- bower.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bower.json b/bower.json index 3696b74..69545b6 100644 --- a/bower.json +++ b/bower.json @@ -29,9 +29,9 @@ "purescript-integers": "^6.0.0", "purescript-js-date": "^8.0.0", "purescript-maybe": "^6.0.0", - "purescript-node-buffer": "^8.0.0", + "purescript-node-buffer": "^9.0.0", "purescript-node-path": "^5.0.0", - "purescript-node-streams": "^7.0.0", + "purescript-node-streams": "#684041e14e56c75c0bf49db0e556aec6d0248e5a", "purescript-nullable": "^6.0.0", "purescript-partial": "^4.0.0", "purescript-prelude": "^6.0.0", From 82a1a79a16cae9de0dcef1b0653d8b657154e89f Mon Sep 17 00:00:00 2001 From: Jordan Martinez Date: Sat, 8 Jul 2023 11:24:43 -0500 Subject: [PATCH 3/9] Update exports to conventions --- src/Node/FS.purs | 12 ++++++------ src/Node/FS/Async.purs | 2 +- src/Node/FS/Stats.purs | 2 +- src/Node/FS/Stream.purs | 4 ++-- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/Node/FS.purs b/src/Node/FS.purs index 11a0c66..dbcc5a1 100644 --- a/src/Node/FS.purs +++ b/src/Node/FS.purs @@ -1,12 +1,12 @@ module Node.FS - ( FileDescriptor(..) - , FileMode(..) + ( FileDescriptor + , FileMode , SymlinkType(..) , symlinkTypeToNode - , BufferLength(..) - , BufferOffset(..) - , ByteCount(..) - , FilePosition(..) + , BufferLength + , BufferOffset + , ByteCount + , FilePosition , module Exports ) where diff --git a/src/Node/FS/Async.purs b/src/Node/FS/Async.purs index 8fe33bd..05b04f1 100644 --- a/src/Node/FS/Async.purs +++ b/src/Node/FS/Async.purs @@ -1,5 +1,5 @@ module Node.FS.Async - ( Callback(..) + ( Callback , access , access' , copyFile diff --git a/src/Node/FS/Stats.purs b/src/Node/FS/Stats.purs index 24b5ac7..d3fe67c 100644 --- a/src/Node/FS/Stats.purs +++ b/src/Node/FS/Stats.purs @@ -1,6 +1,6 @@ module Node.FS.Stats ( Stats(..) - , StatsObj(..) + , StatsObj , isFile , isDirectory , isBlockDevice diff --git a/src/Node/FS/Stream.purs b/src/Node/FS/Stream.purs index 5ed7563..c256a51 100644 --- a/src/Node/FS/Stream.purs +++ b/src/Node/FS/Stream.purs @@ -1,13 +1,13 @@ module Node.FS.Stream ( createWriteStream , fdCreateWriteStream - , WriteStreamOptions() + , WriteStreamOptions , defaultWriteStreamOptions , createWriteStreamWith , fdCreateWriteStreamWith , createReadStream , fdCreateReadStream - , ReadStreamOptions() + , ReadStreamOptions , defaultReadStreamOptions , createReadStreamWith , fdCreateReadStreamWith From dede1f712c8ac4b823ba32d70121b2d697d5c60e Mon Sep 17 00:00:00 2001 From: Jordan Martinez Date: Sat, 8 Jul 2023 11:25:34 -0500 Subject: [PATCH 4/9] Enforce purs-tidy formatting --- .github/workflows/ci.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 49f6d5f..a39bce1 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -15,6 +15,7 @@ jobs: - uses: purescript-contrib/setup-purescript@main with: purescript: "unstable" + purs-tidy: "latest" - uses: actions/setup-node@v3 with: @@ -33,3 +34,7 @@ jobs: run: | bower install npm run-script test --if-present + + - name: Check formatting + run: | + purs-tidy check src test From 5837ce5886b4b811768e9b933ed30a146e74d1fb Mon Sep 17 00:00:00 2001 From: Jordan Martinez Date: Sat, 8 Jul 2023 11:26:48 -0500 Subject: [PATCH 5/9] Simplify Nullable usage --- src/Node/FS/Stream.purs | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/src/Node/FS/Stream.purs b/src/Node/FS/Stream.purs index c256a51..0c4468a 100644 --- a/src/Node/FS/Stream.purs +++ b/src/Node/FS/Stream.purs @@ -15,8 +15,7 @@ module Node.FS.Stream import Prelude -import Data.Maybe (Maybe(..)) -import Data.Nullable (Nullable, toNullable) +import Data.Nullable (Nullable, notNull, null) import Effect (Effect) import Effect.Uncurried (EffectFn2, runEffectFn2) import Node.FS (FileDescriptor) @@ -34,12 +33,6 @@ readWrite = Perms.mkPerms rw rw rw where rw = Perms.read + Perms.write -null :: forall a. Nullable a -null = toNullable Nothing - -nonnull :: forall a. a -> Nullable a -nonnull = toNullable <<< Just - -- | Create a Writable stream which writes data to the specified file, using -- | the default options. createWriteStream @@ -72,7 +65,7 @@ createWriteStreamWith -> Effect (Writable ()) createWriteStreamWith opts file = runEffectFn2 createWriteStreamImpl - (nonnull file) + (notNull file) { mode: Perms.permsToInt opts.perms , flags: fileFlagsToNode opts.flags } @@ -124,7 +117,7 @@ createReadStreamWith -> Effect (Readable ()) createReadStreamWith opts file = runEffectFn2 createReadStreamImpl - (nonnull file) + (notNull file) { mode: Perms.permsToInt opts.perms , flags: fileFlagsToNode opts.flags , autoClose: opts.autoClose From 08e9c6bf044728e70d0e09ada0255603419d5d98 Mon Sep 17 00:00:00 2001 From: Jordan Martinez Date: Sat, 8 Jul 2023 11:28:23 -0500 Subject: [PATCH 6/9] Derive Eq instances --- src/Node/FS.purs | 6 +----- src/Node/FS/Perms.purs | 8 ++------ 2 files changed, 3 insertions(+), 11 deletions(-) diff --git a/src/Node/FS.purs b/src/Node/FS.purs index dbcc5a1..2bb3c56 100644 --- a/src/Node/FS.purs +++ b/src/Node/FS.purs @@ -38,8 +38,4 @@ instance showSymlinkType :: Show SymlinkType where show DirLink = "DirLink" show JunctionLink = "JunctionLink" -instance eqSymlinkType :: Eq SymlinkType where - eq FileLink FileLink = true - eq DirLink DirLink = true - eq JunctionLink JunctionLink = true - eq _ _ = false +derive instance eqSymlinkType :: Eq SymlinkType diff --git a/src/Node/FS/Perms.purs b/src/Node/FS/Perms.purs index a00c458..ce70460 100644 --- a/src/Node/FS/Perms.purs +++ b/src/Node/FS/Perms.purs @@ -40,9 +40,7 @@ import Partial.Unsafe (unsafePartial) -- | intersection respectively. newtype Perm = Perm { r :: Boolean, w :: Boolean, x :: Boolean } -instance eqPerm :: Eq Perm where - eq (Perm { r: r1, w: w1, x: x1 }) (Perm { r: r2, w: w2, x: x2 }) = - r1 == r2 && w1 == w2 && x1 == x2 +derive newtype instance eqPerm :: Eq Perm instance ordPerm :: Ord Perm where compare (Perm { r: r1, w: w1, x: x1 }) (Perm { r: r2, w: w2, x: x2 }) = @@ -101,9 +99,7 @@ all = one -- | file owner, the group, and any other users. newtype Perms = Perms { u :: Perm, g :: Perm, o :: Perm } -instance eqPerms :: Eq Perms where - eq (Perms { u: u1, g: g1, o: o1 }) (Perms { u: u2, g: g2, o: o2 }) = - u1 == u2 && g1 == g2 && o1 == o2 +derive newtype instance eqPerms :: Eq Perms instance ordPerms :: Ord Perms where compare (Perms { u: u1, g: g1, o: o1 }) (Perms { u: u2, g: g2, o: o2 }) = From c48755e455de8efdc0bce7cbe8749ac41a1133ee Mon Sep 17 00:00:00 2001 From: Jordan Martinez Date: Sat, 8 Jul 2023 11:32:59 -0500 Subject: [PATCH 7/9] Add changelog entry --- CHANGELOG.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 44586b1..760572c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,12 +5,17 @@ Notable changes to this project are documented in this file. The format is based ## [Unreleased] Breaking changes: +- Update `node-buffer` to next breaking release: `v9.0.0` (#74 by @JordanMartinez) +- Update `node-streams` to next breaking release: `TODO` (#74 by @JordanMartinez) New features: Bugfixes: Other improvements: +- Update CI actions to v3 (#74 by @JordanMartinez) +- Update CI node to `lts/*` (#74 by @JordanMartinez) +- Enforce `purs-tidy` format check in CI (#74 by @JordanMartinez) ## [v8.2.0](https://github.com/purescript-node/purescript-node-fs/releases/tag/v8.2.0) - 2023-03-23 From dc662a5c72030bbf52ac27ca7921f66b47925599 Mon Sep 17 00:00:00 2001 From: Jordan Martinez Date: Sat, 8 Jul 2023 11:33:39 -0500 Subject: [PATCH 8/9] Don't count dep bumps as breaking --- CHANGELOG.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 760572c..e53ccaa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,14 +5,14 @@ Notable changes to this project are documented in this file. The format is based ## [Unreleased] Breaking changes: -- Update `node-buffer` to next breaking release: `v9.0.0` (#74 by @JordanMartinez) -- Update `node-streams` to next breaking release: `TODO` (#74 by @JordanMartinez) New features: Bugfixes: Other improvements: +- Update `node-buffer` to next breaking release: `v9.0.0` (#74 by @JordanMartinez) +- Update `node-streams` to next breaking release: `TODO` (#74 by @JordanMartinez) - Update CI actions to v3 (#74 by @JordanMartinez) - Update CI node to `lts/*` (#74 by @JordanMartinez) - Enforce `purs-tidy` format check in CI (#74 by @JordanMartinez) From 3cfc396231d256b3da7c390f331a4e8db7968401 Mon Sep 17 00:00:00 2001 From: Jordan Martinez Date: Sat, 8 Jul 2023 11:35:42 -0500 Subject: [PATCH 9/9] Update usage of `end` event handler --- test/Streams.purs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/test/Streams.purs b/test/Streams.purs index 231939f..eef4029 100644 --- a/test/Streams.purs +++ b/test/Streams.purs @@ -5,23 +5,24 @@ import Prelude import Effect (Effect) import Effect.Console (log) import Node.Encoding (Encoding(..)) -import Node.Path as Path -import Node.Stream as Stream +import Node.EventEmitter (on_) import Node.FS.Stream (createWriteStream, createReadStream) import Node.FS.Sync as Sync +import Node.Path as Path +import Node.Stream as Stream main :: Effect Unit main = do let fp = Path.concat - _ <- log "Testing streams" + log "Testing streams" r <- createReadStream (fp [ "test", "Streams.purs" ]) w <- createWriteStream (fp [ "tmp", "Streams.purs" ]) _ <- Stream.pipe r w - Stream.onEnd r do + r # on_ Stream.endH do src <- Sync.readTextFile UTF8 (fp [ "test", "Streams.purs" ]) dst <- Sync.readTextFile UTF8 (fp [ "tmp", "Streams.purs" ])