From 45da1b181d2c6d25e8ed1645b78115c8818b75a5 Mon Sep 17 00:00:00 2001 From: Nicholas Wolverson Date: Sat, 12 Feb 2022 12:31:30 +0000 Subject: [PATCH 01/15] ESM conversion --- src/Node/ChildProcess.js | 49 ++++++++++++++++++++-------------------- 1 file changed, 25 insertions(+), 24 deletions(-) diff --git a/src/Node/ChildProcess.js b/src/Node/ChildProcess.js index e638721..3fef8e9 100644 --- a/src/Node/ChildProcess.js +++ b/src/Node/ChildProcess.js @@ -2,14 +2,14 @@ /* eslint-env node*/ -exports.unsafeFromNullable = function unsafeFromNullable(msg) { +export function unsafeFromNullable(msg) { return function (x) { if (x === null) throw new Error(msg); return x; }; -}; +} -exports.spawnImpl = function spawnImpl(command) { +export function spawnImpl(command) { return function (args) { return function (opts) { return function () { @@ -17,9 +17,9 @@ exports.spawnImpl = function spawnImpl(command) { }; }; }; -}; +} -exports.execImpl = function execImpl(command) { +export function execImpl(command) { return function (opts) { return function (callback) { return function () { @@ -33,7 +33,7 @@ exports.execImpl = function execImpl(command) { }; }; }; -}; +} exports.execFileImpl = function execImpl(command) { return function (args) { @@ -54,15 +54,15 @@ exports.execFileImpl = function execImpl(command) { }; }; -exports.execSyncImpl = function execSyncImpl(command) { +export function execSyncImpl(command) { return function (opts) { return function () { return require("child_process").execSync(command, opts); }; }; -}; +} -exports.execFileSyncImpl = function execFileSyncImpl(command) { +export function execFileSyncImpl(command) { return function (args) { return function (opts) { return function () { @@ -70,17 +70,17 @@ exports.execFileSyncImpl = function execFileSyncImpl(command) { }; }; }; -}; +} -exports.fork = function fork(cmd) { +export function fork(cmd) { return function (args) { return function () { return require("child_process").fork(cmd, args); }; }; -}; +} -exports.mkOnExit = function mkOnExit(mkChildExit) { +export function mkOnExit(mkChildExit) { return function onExit(cp) { return function (cb) { return function () { @@ -90,9 +90,9 @@ exports.mkOnExit = function mkOnExit(mkChildExit) { }; }; }; -}; +} -exports.mkOnClose = function mkOnClose(mkChildExit) { +export function mkOnClose(mkChildExit) { return function onClose(cp) { return function (cb) { return function () { @@ -102,17 +102,17 @@ exports.mkOnClose = function mkOnClose(mkChildExit) { }; }; }; -}; +} -exports.onDisconnect = function onDisconnect(cp) { +export function onDisconnect(cp) { return function (cb) { return function () { cp.on("disconnect", cb); }; }; -}; +} -exports.mkOnMessage = function mkOnMessage(nothing) { +export function mkOnMessage(nothing) { return function (just) { return function onMessage(cp) { return function (cb) { @@ -124,9 +124,9 @@ exports.mkOnMessage = function mkOnMessage(nothing) { }; }; }; -}; +} -exports.onError = function onError(cp) { +export function onError(cp) { return function (cb) { return function () { cp.on("error", function (err) { @@ -134,7 +134,8 @@ exports.onError = function onError(cp) { }); }; }; -}; +} -exports.undefined = undefined; -exports.process = process; +const _undefined = undefined; +export { _undefined as undefined }; +export {process}; From 4b04bb1e0c70661b5b2f196da3fc13e951fe1881 Mon Sep 17 00:00:00 2001 From: Nicholas Wolverson Date: Sat, 12 Feb 2022 12:35:10 +0000 Subject: [PATCH 02/15] Arrow transformations, fix dynamic imports --- src/Node/ChildProcess.js | 131 +++++++++++++-------------------------- 1 file changed, 44 insertions(+), 87 deletions(-) diff --git a/src/Node/ChildProcess.js b/src/Node/ChildProcess.js index 3fef8e9..f1596aa 100644 --- a/src/Node/ChildProcess.js +++ b/src/Node/ChildProcess.js @@ -2,140 +2,97 @@ /* eslint-env node*/ +import { spawn, exec, execFile, execSync, execFileSync, fork } from 'child_process'; + export function unsafeFromNullable(msg) { - return function (x) { + return x => { if (x === null) throw new Error(msg); return x; }; } export function spawnImpl(command) { - return function (args) { - return function (opts) { - return function () { - return require("child_process").spawn(command, args, opts); - }; - }; - }; + return args => opts => () => spawn(command, args, opts); } export function execImpl(command) { - return function (opts) { - return function (callback) { - return function () { - return require("child_process").exec( - command, - opts, - function (err, stdout, stderr) { - callback(err)(stdout)(stderr)(); - } - ); - }; - }; - }; + return opts => callback => () => exec( + command, + opts, + (err, stdout, stderr) => { + callback(err)(stdout)(stderr)(); + } + ); } exports.execFileImpl = function execImpl(command) { - return function (args) { - return function (opts) { - return function (callback) { - return function () { - return require("child_process").execFile( - command, - args, - opts, - function (err, stdout, stderr) { - callback(err)(stdout)(stderr)(); - } - ); - }; - }; - }; - }; + return args => opts => callback => () => execFile( + command, + args, + opts, + (err, stdout, stderr) => { + callback(err)(stdout)(stderr)(); + } + ); }; export function execSyncImpl(command) { - return function (opts) { - return function () { - return require("child_process").execSync(command, opts); - }; - }; + return opts => () => execSync(command, opts); } export function execFileSyncImpl(command) { - return function (args) { - return function (opts) { - return function () { - return require("child_process").execFileSync(command, args, opts); - }; - }; - }; + return args => opts => () => execFileSync(command, args, opts); } export function fork(cmd) { - return function (args) { - return function () { - return require("child_process").fork(cmd, args); - }; - }; + return args => () => fork(cmd, args); } export function mkOnExit(mkChildExit) { return function onExit(cp) { - return function (cb) { - return function () { - cp.on("exit", function (code, signal) { - cb(mkChildExit(code)(signal))(); - }); - }; + return cb => () => { + cp.on("exit", (code, signal) => { + cb(mkChildExit(code)(signal))(); + }); }; }; } export function mkOnClose(mkChildExit) { return function onClose(cp) { - return function (cb) { - return function () { - cp.on("close", function (code, signal) { - cb(mkChildExit(code)(signal))(); - }); - }; + return cb => () => { + cp.on("close", (code, signal) => { + cb(mkChildExit(code)(signal))(); + }); }; }; } export function onDisconnect(cp) { - return function (cb) { - return function () { - cp.on("disconnect", cb); - }; + return cb => () => { + cp.on("disconnect", cb); }; } export function mkOnMessage(nothing) { - return function (just) { - return function onMessage(cp) { - return function (cb) { - return function () { - cp.on("message", function (mess, sendHandle) { - cb(mess, sendHandle ? just(sendHandle) : nothing)(); - }); - }; - }; + return just => (function onMessage(cp) { + return cb => () => { + cp.on("message", (mess, sendHandle) => { + cb(mess, sendHandle ? just(sendHandle) : nothing)(); + }); }; - }; + }); } export function onError(cp) { - return function (cb) { - return function () { - cp.on("error", function (err) { - cb(err)(); - }); - }; + return cb => () => { + cp.on("error", err => { + cb(err)(); + }); }; } const _undefined = undefined; export { _undefined as undefined }; -export {process}; +import { process } from 'process'; +export { process }; From 1cd2925d5481c7c4c06fd4d3784e1d2d27fdcc34 Mon Sep 17 00:00:00 2001 From: Nicholas Wolverson Date: Sat, 12 Feb 2022 12:40:44 +0000 Subject: [PATCH 03/15] Fix missing export --- src/Node/ChildProcess.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Node/ChildProcess.js b/src/Node/ChildProcess.js index f1596aa..3977985 100644 --- a/src/Node/ChildProcess.js +++ b/src/Node/ChildProcess.js @@ -25,7 +25,7 @@ export function execImpl(command) { ); } -exports.execFileImpl = function execImpl(command) { +export const execFileImpl = function execImpl(command) { return args => opts => callback => () => execFile( command, args, From e6676f380894fe38bc12a31bc3b7197678684780 Mon Sep 17 00:00:00 2001 From: Nicholas Wolverson Date: Sat, 12 Feb 2022 12:49:22 +0000 Subject: [PATCH 04/15] Fix fork --- src/Node/ChildProcess.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Node/ChildProcess.js b/src/Node/ChildProcess.js index 3977985..46351b0 100644 --- a/src/Node/ChildProcess.js +++ b/src/Node/ChildProcess.js @@ -2,7 +2,7 @@ /* eslint-env node*/ -import { spawn, exec, execFile, execSync, execFileSync, fork } from 'child_process'; +import { spawn, exec, execFile, execSync, execFileSync, fork as cp_fork } from 'child_process'; export function unsafeFromNullable(msg) { return x => { @@ -45,7 +45,7 @@ export function execFileSyncImpl(command) { } export function fork(cmd) { - return args => () => fork(cmd, args); + return args => () => cp_fork(cmd, args); } export function mkOnExit(mkChildExit) { From 261c4e50e0ea3a8e8a41f145bb2253710f8aa59e Mon Sep 17 00:00:00 2001 From: Nicholas Wolverson Date: Sat, 12 Feb 2022 14:29:21 +0000 Subject: [PATCH 05/15] Fix process export --- src/Node/ChildProcess.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Node/ChildProcess.js b/src/Node/ChildProcess.js index 46351b0..3800f9c 100644 --- a/src/Node/ChildProcess.js +++ b/src/Node/ChildProcess.js @@ -94,5 +94,5 @@ export function onError(cp) { const _undefined = undefined; export { _undefined as undefined }; -import { process } from 'process'; +import process from 'process'; export { process }; From 03ada8408dbd2fad8f5a00c08e5d09f4a1cea4af Mon Sep 17 00:00:00 2001 From: sigma-andex Date: Wed, 23 Mar 2022 13:07:17 +0000 Subject: [PATCH 06/15] Removed '"use strict";' in FFI files --- src/Node/ChildProcess.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Node/ChildProcess.js b/src/Node/ChildProcess.js index 3800f9c..3603f01 100644 --- a/src/Node/ChildProcess.js +++ b/src/Node/ChildProcess.js @@ -1,5 +1,3 @@ -"use strict"; - /* eslint-env node*/ import { spawn, exec, execFile, execSync, execFileSync, fork as cp_fork } from 'child_process'; From fcf0a4d6129368d595047149e3e0aa9352659c9d Mon Sep 17 00:00:00 2001 From: sigma-andex Date: Wed, 23 Mar 2022 13:07:17 +0000 Subject: [PATCH 07/15] Update to CI to use 'unstable' purescript --- .github/workflows/ci.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 063845e..f5a96fe 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -13,6 +13,8 @@ jobs: - uses: actions/checkout@v2 - uses: purescript-contrib/setup-purescript@main + with: + purescript: "unstable" - uses: actions/setup-node@v1 with: From 60ee00d288e0a4b932a4d7f13777aba1ad9103cb Mon Sep 17 00:00:00 2001 From: sigma-andex Date: Wed, 23 Mar 2022 13:07:17 +0000 Subject: [PATCH 08/15] Update Bower dependencies to master or main --- bower.json | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/bower.json b/bower.json index 557f70e..1ddceef 100644 --- a/bower.json +++ b/bower.json @@ -16,17 +16,17 @@ "package.json" ], "dependencies": { - "purescript-exceptions": "^5.0.0", - "purescript-foreign": "^6.0.0", - "purescript-foreign-object": "^3.0.0", - "purescript-functions": "^5.0.0", + "purescript-exceptions": "master", + "purescript-foreign": "master", + "purescript-foreign-object": "master", + "purescript-functions": "master", "purescript-node-fs": "^6.0.0", "purescript-node-streams": "^5.0.0", - "purescript-nullable": "^5.0.0", + "purescript-nullable": "main", "purescript-posix-types": "^5.0.0", - "purescript-unsafe-coerce": "^5.0.0" + "purescript-unsafe-coerce": "master" }, "devDependencies": { - "purescript-console": "^5.0.0" + "purescript-console": "master" } } From 82e4470984c122078dd2295f74621a5ffb11588d Mon Sep 17 00:00:00 2001 From: sigma-andex Date: Wed, 23 Mar 2022 13:07:17 +0000 Subject: [PATCH 09/15] Update pulp to 16.0.0-0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 63f9f51..784caa5 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,7 @@ }, "devDependencies": { "eslint": "^7.15.0", - "pulp": "^15.0.0", + "pulp": "16.0.0-0", "purescript-psa": "^0.8.0", "rimraf": "^3.0.2" } From 888efc1f058cfc0b51943649d89d84aa64b7ec37 Mon Sep 17 00:00:00 2001 From: sigma-andex Date: Wed, 23 Mar 2022 13:07:17 +0000 Subject: [PATCH 10/15] Update psa to 0.8.2 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 784caa5..c08ce8f 100644 --- a/package.json +++ b/package.json @@ -8,7 +8,7 @@ "devDependencies": { "eslint": "^7.15.0", "pulp": "16.0.0-0", - "purescript-psa": "^0.8.0", + "purescript-psa": "^0.8.2", "rimraf": "^3.0.2" } } From 6978dbb1558b04283bad3555e0ef51d40d897ad4 Mon Sep 17 00:00:00 2001 From: sigma-andex Date: Wed, 23 Mar 2022 13:08:48 +0000 Subject: [PATCH 11/15] Update Bower dependencies to master or main --- bower.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/bower.json b/bower.json index 1ddceef..e17d7f3 100644 --- a/bower.json +++ b/bower.json @@ -20,10 +20,10 @@ "purescript-foreign": "master", "purescript-foreign-object": "master", "purescript-functions": "master", - "purescript-node-fs": "^6.0.0", - "purescript-node-streams": "^5.0.0", + "purescript-node-fs": "master", + "purescript-node-streams": "master", "purescript-nullable": "main", - "purescript-posix-types": "^5.0.0", + "purescript-posix-types": "master", "purescript-unsafe-coerce": "master" }, "devDependencies": { From f3b21de9438bac12fc3593b3ac69d3dd29ca14ea Mon Sep 17 00:00:00 2001 From: sigma-andex Date: Wed, 23 Mar 2022 13:13:36 +0000 Subject: [PATCH 12/15] Update eslintrc --- .eslintrc.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.eslintrc.json b/.eslintrc.json index 84cef4f..7b219e5 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -1,10 +1,11 @@ { "parserOptions": { - "ecmaVersion": 5 + "ecmaVersion": 6, + "sourceType": "module" }, "extends": "eslint:recommended", "env": { - "commonjs": true + "node": true }, "rules": { "strict": [2, "global"], From 21f21b0bebc26006bc7f13f09a7d3fd35568ee5a Mon Sep 17 00:00:00 2001 From: sigma-andex Date: Wed, 23 Mar 2022 13:13:46 +0000 Subject: [PATCH 13/15] Fix eslint errors --- src/Node/ChildProcess.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Node/ChildProcess.js b/src/Node/ChildProcess.js index 3603f01..b3ba75a 100644 --- a/src/Node/ChildProcess.js +++ b/src/Node/ChildProcess.js @@ -1,6 +1,6 @@ /* eslint-env node*/ -import { spawn, exec, execFile, execSync, execFileSync, fork as cp_fork } from 'child_process'; +import { spawn, exec, execFile, execSync, execFileSync, fork as cp_fork } from "child_process"; export function unsafeFromNullable(msg) { return x => { @@ -92,5 +92,5 @@ export function onError(cp) { const _undefined = undefined; export { _undefined as undefined }; -import process from 'process'; +import process from "process"; export { process }; From a6e8469d5fba69381c24e40f932a3498bd6c42a5 Mon Sep 17 00:00:00 2001 From: sigma-andex Date: Wed, 23 Mar 2022 13:15:01 +0000 Subject: [PATCH 14/15] Update changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8c0f19f..e01253f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ Notable changes to this project are documented in this file. The format is based ## [Unreleased] Breaking changes: +- Update project and deps to PureScript v0.15.0 (#31 by @JordanMartinez, @thomashoneyman, @sigma-andex) New features: From c829af6f01bb87391005e0bd34da2f40d7a346b4 Mon Sep 17 00:00:00 2001 From: sigma-andex Date: Wed, 23 Mar 2022 13:17:06 +0000 Subject: [PATCH 15/15] Update ci.yml to v2 --- .github/workflows/ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f5a96fe..06ed895 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -16,9 +16,9 @@ jobs: with: purescript: "unstable" - - uses: actions/setup-node@v1 + - uses: actions/setup-node@v2 with: - node-version: "10" + node-version: "14" - name: Install dependencies run: |