Skip to content

Commit a53e679

Browse files
Add PureScript & Package Set version info (#280)
* Clearly indicate PureScript & package set version * Update RELEASE.md on updating versions via script * Add CI check for versions * Add changelog entry * Ensure CI catches purs version diff * Update purs version back to 0.15.2 * Ensure CI check catches package set difference * Update package set version to correct one
1 parent 8155198 commit a53e679

File tree

8 files changed

+149
-3
lines changed

8 files changed

+149
-3
lines changed

.github/workflows/ci.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,18 @@ jobs:
7474
npm run build:production
7575
npm run bundle
7676
77+
- name: Check SharedConfig.purs versions
78+
run: |
79+
cd client
80+
cp src/Try/SharedConfig.purs sharedConfig.out
81+
node updateSharedConfigVersions.mjs sharedConfig.out
82+
diff src/Try/SharedConfig.purs sharedConfig.out || {
83+
echo 'PureScript and/or package set versions in "client/src/Try/SharedConfig.purs"'
84+
echo 'do not match the versions extracted from "stack.yaml" and "staging/packages.dhall".'
85+
echo 'Please run "cd client && npm run updateConfigVersions". CI will fail until then.'
86+
exit 1
87+
}
88+
7789
- name: Build client assets
7890
if: github.event_name == 'release'
7991
run: |

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ Notable changes to this project are documented in this file. The format is based
77
Breaking changes:
88

99
New features:
10+
- Clearly indicate PureScript and package set version (#280 by @JordanMartinez)
1011

1112
Bugfixes:
1213
- Stop double `main` invocation by updating `es-module-shims` to 1.5.6 (#279 by @JordanMartinez)

RELEASE.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,13 @@ Update the package set by doing the following:
4040
$ spago ls packages | cut -f 1 -d ' ' | xargs spago install
4141
```
4242

43-
4. If any packages need NPM dependencies, you can try adding their shims to the import map in `client/public/frame.html`
43+
4. Update the `client/src/Try/SharedConfig.purs` file by running this command:
44+
45+
```console
46+
$ npm run updateConfigVersions
47+
```
48+
49+
5. If any packages need NPM dependencies, you can try adding their shims to the import map in `client/public/frame.html`
4450
- Open up the `generator.jspm.io` URL in the comment
4551
- Use the 'Add Dependency' search bar to find the NPM dependency
4652
- If it exists but doesn't exist in that CDN, you can try another one or [open an issue on `jspm/project`](https://github.com/jspm/project#issue-queue-for-the-jspm-cdn)
@@ -49,7 +55,7 @@ Update the package set by doing the following:
4955
- Copy and paste the content into the `client/public/frame.html` file
5056
- Ensure `es-module-shims` has version `1.5.5` or greater.
5157

52-
5. If `es-module-shims` releases a new version, you can calculate its SHA-384 via
58+
6. If `es-module-shims` releases a new version, you can calculate its SHA-384 via
5359

5460
```console
5561
$ ESM_VERSION=1.5.5

client/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@
1010
"bundle": "esbuild --outfile=public/js/index.js --bundle --minify --platform=browser --format=iife --tree-shaking=true --footer:js=\"\n\nmain();\" client.js",
1111
"serve": "http-server public/ -o / --cors=\"Access-Control-Allow-Origin: *\" -c-1",
1212
"serve:dev": "npm run build:dev && npm run bundle && npm run serve",
13-
"serve:production": "npm run build:production && npm run bundle && npm run serve"
13+
"serve:production": "npm run build:production && npm run bundle && npm run serve",
14+
"updateConfigVersions": "node updateSharedConfigVersions.mjs src/Try/SharedConfig.purs"
1415
},
1516
"devDependencies": {
1617
"esbuild": "^0.14.43",

client/public/css/index.css

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,10 +263,47 @@ iframe {
263263
margin-bottom: 10px;
264264
}
265265

266+
267+
footer {
268+
background-color: #1d222d;
269+
display: flex;
270+
flex-direction: row;
271+
justify-content: center;
272+
gap: 5px;
273+
}
274+
275+
footer .footer-separator {
276+
color: white;
277+
}
278+
279+
footer .footer-link {
280+
display: flex;
281+
min-width: 300px;
282+
gap: 2px;
283+
color: white;
284+
}
285+
286+
footer .footer-link a {
287+
color: white;
288+
}
289+
290+
footer .footer-link a:visited {
291+
color: white;
292+
}
293+
266294
@media all and (max-width: 720px) {
267295
.no-mobile {
268296
display: none;
269297
}
298+
299+
footer {
300+
flex-direction: column;
301+
align-items: center;
302+
}
303+
304+
footer .footer-link {
305+
min-width: initial;
306+
}
270307
}
271308

272309
@media all and (min-width: 720px) {

client/src/Try/Container.purs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ import Try.Gist (getGistById, tryLoadFileFromGist)
3232
import Try.GitHub (getRawGitHubFile)
3333
import Try.QueryString (getQueryStringMaybe)
3434
import Try.Session (createSessionIdIfNecessary, storeSession, tryRetrieveSession)
35+
import Try.SharedConfig as SharedConfig
3536
import Type.Proxy (Proxy(..))
3637
import Web.HTML (window)
3738
import Web.HTML.Window (alert)
@@ -220,6 +221,7 @@ component = H.mkComponent
220221
[ renderMenu
221222
, renderMobileBanner
222223
, renderEditor
224+
, renderFooter
223225
]
224226
]
225227
where
@@ -386,6 +388,25 @@ component = H.mkComponent
386388
]
387389
]
388390

391+
renderFooter = do
392+
let
393+
footerLink linkPrefix linkText linkUrl =
394+
HH.div
395+
[ HP.class_ $ HH.ClassName "footer-link" ]
396+
[ HH.span_
397+
[ HH.text linkPrefix ]
398+
, HH.a
399+
[ HP.href linkUrl
400+
, HP.target "_blank"
401+
, HP.rel "noopener"
402+
]
403+
[ HH.text linkText ]
404+
]
405+
HH.footer_
406+
[ footerLink "PureScript version:" SharedConfig.pursVersion SharedConfig.pursReleaseUrl
407+
, footerLink "Package set version:" SharedConfig.packageSetVersion SharedConfig.packageSetPackageJsonUrl
408+
]
409+
389410
renderCompiled = case _ of
390411
Left err ->
391412
renderPlaintext err

client/src/Try/SharedConfig.purs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
-- | Similar to the `Try.Config` module
2+
-- | except values below can be used in both
3+
-- | the dev and production environments
4+
module Try.SharedConfig where
5+
6+
import Prelude
7+
8+
pursVersion :: String
9+
pursVersion = "v0.15.2"
10+
11+
pursReleaseUrl :: String
12+
pursReleaseUrl = "https://github.com/purescript/purescript/releases/tag/" <> pursVersion
13+
14+
packageSetVersion :: String
15+
packageSetVersion = "0.15.2-20220531"
16+
17+
packageSetPackageJsonUrl :: String
18+
packageSetPackageJsonUrl = "https://github.com/purescript/package-sets/blob/psc-" <> packageSetVersion <> "/packages.json"

client/updateSharedConfigVersions.mjs

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
#!/usr/bin/env node
2+
3+
// This script expects the current working directory to be `client`.
4+
// Call it using:
5+
// node updateSharedConfigVersions.mjs src/Try/SharedConfig.purs
6+
7+
import fs from "fs";
8+
import path from "path";
9+
import process from "process";
10+
11+
if (process.argv.length <= 2) {
12+
throw new Error("Script was run with 0 args. The first and only arg should be the path to the 'SharedConfig.purs' file.")
13+
}
14+
15+
const sharedConfigPath = process.argv[2];
16+
17+
const stackYamlPath = path.join("..", "stack.yaml");
18+
const stagingPackagesDhallPath = path.join("..", "staging", "packages.dhall");
19+
const stackYamlContent = fs.readFileSync(stackYamlPath, "utf-8");
20+
const packagesContent = fs.readFileSync(stagingPackagesDhallPath, "utf-8");
21+
22+
const pursVersion = stackYamlContent.split("\n")
23+
.reduce((acc, nextLine) => {
24+
if (acc.found) return acc;
25+
const matchResult = nextLine.match(/ +- purescript-(.+)/);
26+
return matchResult
27+
? { found: true, value: matchResult[1] }
28+
: acc;
29+
}, { found: false })
30+
.value;
31+
32+
const packageSetVersion = packagesContent
33+
.match(/https:\/\/github.com\/purescript\/package-sets\/releases\/download\/psc-([^\/]+)\/packages.dhall/)[1];
34+
35+
if (!pursVersion) {
36+
throw new Error("Failed to extract the PureScript version from the stack.yaml file. Cannot update SharedConfig.purs file.");
37+
}
38+
39+
if (!packageSetVersion) {
40+
throw new Error("Failed to extract the Package Set version from the staging/packages.dhall file. Cannot update SharedConfig.purs file.");
41+
}
42+
43+
const sharedConfigContent = fs.readFileSync(sharedConfigPath, "utf-8");
44+
const newContent = sharedConfigContent.split("\n")
45+
.map((line) => line
46+
.replace(/pursVersion =.*/, `pursVersion = "v${pursVersion}"`)
47+
.replace(/packageSetVersion =.*/, `packageSetVersion = "${packageSetVersion}"`)
48+
)
49+
.join("\n");
50+
fs.writeFileSync(sharedConfigPath, newContent);

0 commit comments

Comments
 (0)