Skip to content

Commit

Permalink
feat(deps): Migrate to latest PureScript and Spago
Browse files Browse the repository at this point in the history
  • Loading branch information
maciejsmolinski committed Mar 6, 2023
1 parent 501cfd9 commit 5868cd3
Show file tree
Hide file tree
Showing 12 changed files with 2,391 additions and 4,363 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,8 @@ Finally, when everything succeeds:
## Local development

```shell
$ npm install -g spago@0.9.0 purescript@0.13.3
$ spago bundle-app -w
$ npm install -g spago@0.20.9 purescript@0.15.7 [email protected]
$ spago bundle-app --platform=node -w
$ npx nodemon index.js
```

Expand Down
6,315 changes: 2,182 additions & 4,133 deletions package-lock.json

Large diffs are not rendered by default.

46 changes: 24 additions & 22 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,24 +1,26 @@
{
"name": "orchy",
"version": "0.6.0",
"description": "a simple web hooks manager with zero npm dependencies",
"keywords": [
"webhooks",
"hooks",
"server"
],
"main": "index.js",
"repository": "[email protected]:maciejsmolinski/orchy.git",
"author": "Maciej Smolinski <[email protected]>",
"license": "MIT",
"devDependencies": {
"purescript": "^0.13.3",
"spago": "^0.20.7"
},
"scripts": {
"prepublish": "spago bundle-app --main Main --to index.js && printf '%s\n%s' \"#!/usr/bin/env node\" \"$(cat index.js)\" > index.js"
},
"bin": {
"orchy": "./index.js"
}
"name": "orchy",
"version": "0.6.0",
"description": "a simple web hooks manager with zero npm dependencies",
"keywords": [
"webhooks",
"hooks",
"server"
],
"main": "index.js",
"type": "module",
"repository": "[email protected]:maciejsmolinski/orchy.git",
"author": "Maciej Smolinski <[email protected]>",
"license": "MIT",
"devDependencies": {
"purescript": "^0.15.7",
"spago": "^0.20.9",
"esbuild": "^0.17.11"
},
"scripts": {
"prepublish": "spago bundle-app --platform node --main Main --to index.js && printf '%s\n%s' \"#!/usr/bin/env node\" \"$(cat index.js)\" > index.js"
},
"bin": {
"orchy": "./index.js"
}
}
130 changes: 57 additions & 73 deletions packages.dhall
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,6 @@ Welcome to your new Dhall package-set!
Below are instructions for how to edit this file for most use
cases, so that you don't need to know Dhall to use it.
## Warning: Don't Move This Top-Level Comment!
Due to how `dhall format` currently works, this comment's
instructions cannot appear near corresponding sections below
because `dhall format` will delete the comment. However,
it will not delete a top-level comment like this one.
## Use Cases
Most will want to do one or both of these options:
Expand All @@ -31,28 +24,25 @@ Purpose:
the package set's repo
Syntax:
Replace the overrides' "{=}" (an empty record) with the following idea
The "//" or "⫽" means "merge these two records and
when they have the same value, use the one on the right:"
where `entityName` is one of the following:
- dependencies
- repo
- version
-------------------------------
let override =
{ packageName =
upstream.packageName // { updateEntity1 = "new value", updateEntity2 = "new value" }
, packageName =
upstream.packageName // { version = "v4.0.0" }
, packageName =
upstream.packageName // { repo = "https://www.example.com/path/to/new/repo.git" }
}
let upstream = --
in upstream
with packageName.entityName = "new value"
-------------------------------
Example:
-------------------------------
let overrides =
{ halogen =
upstream.halogen // { version = "master" }
, halogen-vdom =
upstream.halogen-vdom // { version = "v4.0.0" }
}
let upstream = --
in upstream
with halogen.version = "master"
with halogen.repo = "https://example.com/path/to/git/repo.git"
with halogen-vdom.version = "v4.0.0"
with halogen-vdom.dependencies = [ "extra-dependency" ] # halogen-vdom.dependencies
-------------------------------
### Additions
Expand All @@ -61,61 +51,55 @@ Purpose:
- Add packages that aren't already included in the default package set
Syntax:
Replace the additions' "{=}" (an empty record) with the following idea:
where `<version>` is:
- a tag (i.e. "v4.0.0")
- a branch (i.e. "master")
- commit hash (i.e. "701f3e44aafb1a6459281714858fadf2c4c2a977")
-------------------------------
let additions =
{ "package-name" =
mkPackage
[ "dependency1"
, "dependency2"
]
"https://example.com/path/to/git/repo.git"
"tag ('v4.0.0') or branch ('master')"
, "package-name" =
mkPackage
[ "dependency1"
, "dependency2"
]
"https://example.com/path/to/git/repo.git"
"tag ('v4.0.0') or branch ('master')"
, etc.
}
let upstream = --
in upstream
with new-package-name =
{ dependencies =
[ "dependency1"
, "dependency2"
]
, repo =
"https://example.com/path/to/git/repo.git"
, version =
"<version>"
}
-------------------------------
Example:
-------------------------------
let additions =
{ benchotron =
mkPackage
[ "arrays"
, "exists"
, "profunctor"
, "strings"
, "quickcheck"
, "lcg"
, "transformers"
, "foldable-traversable"
, "exceptions"
, "node-fs"
, "node-buffer"
, "node-readline"
, "datetime"
, "now"
]
"https://github.com/hdgarrood/purescript-benchotron.git"
"v7.0.0"
}
let upstream = --
in upstream
with benchotron =
{ dependencies =
[ "arrays"
, "exists"
, "profunctor"
, "strings"
, "quickcheck"
, "lcg"
, "transformers"
, "foldable-traversable"
, "exceptions"
, "node-fs"
, "node-buffer"
, "node-readline"
, "datetime"
, "now"
]
, repo =
"https://github.com/hdgarrood/purescript-benchotron.git"
, version =
"v7.0.0"
}
-------------------------------
-}

let mkPackage =
https:https://raw.githubusercontent.com/purescript/package-sets/psc-0.13.2-20190715/src/mkPackage.dhall sha256:0b197efa1d397ace6eb46b243ff2d73a3da5638d8d0ac8473e8e4a8fc528cf57

let upstream =
https:https://raw.githubusercontent.com/purescript/package-sets/psc-0.13.2-20190715/src/packages.dhall sha256:906af79ba3aec7f429b107fd8d12e8a29426db8229d228c6f992b58151e2308e

let overrides = {=}

let additions = {=}
https:https://github.com/purescript/package-sets/releases/download/psc-0.15.7-20230305/packages.dhall
sha256:3130e5931395bc53efd9392e391dc297fc2398459a6275e39abe426cf3b41542

in upstream // overrides // additions
in upstream
37 changes: 17 additions & 20 deletions spago.dhall
Original file line number Diff line number Diff line change
@@ -1,20 +1,17 @@
{ name =
"orchy"
, dependencies =
[ "effect"
, "console"
, "psci-support"
, "generics-rep"
, "arrays"
, "functions"
, "aff"
, "simple-json"
, "strings"
, "spec"
, "node-process"
]
, packages =
./packages.dhall
, sources =
[ "src/**/*.purs", "test/**/*.purs" ]
}
{-
Welcome to a Spago project!
You can edit this file as you like.
Need help? See the following resources:
- Spago documentation: https://github.com/purescript/spago
- Dhall language tour: https://docs.dhall-lang.org/tutorials/Language-Tour.html
When creating a new Spago project, you can use
`spago init --no-comments` or `spago init -C`
to generate this file without the comments in this block.
-}
{ name = "orchy"
, dependencies = [ "console", "effect", "prelude", "spec", "aff", "foreign", "node-process", "simple-json", "arrays", "either", "foldable-traversable", "functions", "lists", "maybe", "strings", "transformers", "tuples" ]
, packages = ./packages.dhall
, sources = [ "src/**/*.purs", "test/**/*.purs" ]
}
39 changes: 19 additions & 20 deletions src/Date.js
Original file line number Diff line number Diff line change
@@ -1,31 +1,30 @@
function date() {
var currentDate = new Date();

return [
String(currentDate.getDate()).padStart(2, '0'),
String(currentDate.getMonth() + 1).padStart(2, '0'),
String(currentDate.getFullYear()).padStart(4, '0'),
String(currentDate.getHours()).padStart(2, '0'),
String(currentDate.getMinutes()).padStart(2, '0'),
String(currentDate.getSeconds()).padStart(2, '0'),
];
var currentDate = new Date();

return [
String(currentDate.getDate()).padStart(2, "0"),
String(currentDate.getMonth() + 1).padStart(2, "0"),
String(currentDate.getFullYear()).padStart(4, "0"),
String(currentDate.getHours()).padStart(2, "0"),
String(currentDate.getMinutes()).padStart(2, "0"),
String(currentDate.getSeconds()).padStart(2, "0"),
];
}

export function ddmmyyyy() {
var currentDate = date();

exports.ddmmyyyy = function() {
var currentDate = date();

return currentDate[0] + '/' + currentDate[1] + '/' + currentDate[2];
return currentDate[0] + "/" + currentDate[1] + "/" + currentDate[2];
}

exports.yyyymmdd = function() {
var currentDate = date();
export function yyyymmdd() {
var currentDate = date();

return currentDate[2] + '/' + currentDate[1] + '/' + currentDate[0];
return currentDate[2] + "/" + currentDate[1] + "/" + currentDate[0];
}

exports.hhmmss = function() {
var currentDate = date();
export function hhmmss() {
var currentDate = date();

return currentDate[3] + ':' + currentDate[4] + ':' + currentDate[5];
return currentDate[3] + ":" + currentDate[4] + ":" + currentDate[5];
}
65 changes: 35 additions & 30 deletions src/HTTP/Client.js
Original file line number Diff line number Diff line change
@@ -1,35 +1,40 @@
exports.post_ = function(url, payload) {
return function(onError, onSuccess) {
var https = require('https');
var URL = require('url').URL;
import https from "https";
import { URL } from "url";

var parsedUrl = new URL(url);
var hostname = parsedUrl.hostname;
var path = parsedUrl.pathname + parsedUrl.search;
var port =
parsedUrl.protocol === 'https:'
? '443'
: (parsedUrl.protocol === 'http:' ? 80 : parsedUrl.port);
export function post_(url, payload) {
return function (onError, onSuccess) {
var parsedUrl = new URL(url);
var hostname = parsedUrl.hostname;
var path = parsedUrl.pathname + parsedUrl.search;
var port =
parsedUrl.protocol === "https:"
? "443"
: parsedUrl.protocol === "http:"
? 80
: parsedUrl.port;

var request = https.request({
hostname: hostname,
path: path,
port: port,
method: 'POST',
headers: {
'Content-Type': 'application/json',
}
}, function(_) {
onSuccess({});
});
var request = https.request(
{
hostname: hostname,
path: path,
port: port,
method: "POST",
headers: {
"Content-Type": "application/json",
},
},
function (_) {
onSuccess({});
}
);

request.on('error', onError);
request.write(payload);
request.end();
request.on("error", onError);
request.write(payload);
request.end();

return function(cancelError, onCancelerError, onCancelerSuccess) {
request.abort();
onCancelerSuccess();
}
}
return function (cancelError, onCancelerError, onCancelerSuccess) {
request.abort();
onCancelerSuccess();
};
};
}
Loading

0 comments on commit 5868cd3

Please sign in to comment.