Skip to content

Commit ee761af

Browse files
authored
Upgrade deps, add vite/vitest/pnpm, use esm (#15)
1 parent ca220bc commit ee761af

File tree

125 files changed

+7951
-9306
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

125 files changed

+7951
-9306
lines changed

.eslintrc

-32
This file was deleted.

.github/workflows/build.yml

+14-13
Original file line numberDiff line numberDiff line change
@@ -18,33 +18,34 @@ jobs:
1818
test-and-build:
1919
runs-on: ubuntu-latest
2020
container:
21-
image: node:18
21+
image: node:22
2222
steps:
2323
- uses: actions/checkout@v3
24-
- name: Get yarn cache directory path
25-
id: yarn-cache-dir-path
26-
run: echo "::set-output name=dir::$(yarn cache dir)"
24+
- run: corepack enable
25+
- name: Get pnpm cache directory path
26+
id: pnpm-cache-dir-path
27+
run: echo "::set-output name=dir::$(pnpm store path)"
2728
- uses: actions/cache@v3
28-
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
29+
id: pnpm-cache
2930
with:
30-
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
31-
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
31+
path: ${{ steps.pnpm-cache-dir-path.outputs.dir }}
32+
key: ${{ runner.os }}-pnpm-${{ hashFiles('**/pnpm-lock.yaml') }}
3233
restore-keys: |
33-
${{ runner.os }}-yarn-
34+
${{ runner.os }}-pnpm-
3435
- name: Install packages
35-
run: yarn install --frozen-lockfile
36+
run: pnpm install --frozen-lockfile
3637
- name: Test
37-
run: yarn test
38+
run: pnpm test
3839
- name: Check formatting
39-
run: yarn lint
40+
run: pnpm lint
4041
- name: Build dist
41-
run: yarn run build
42+
run: pnpm build
4243
- uses: actions/upload-artifact@v3
4344
with:
4445
name: dist
4546
path: dist/
4647
- name: Build docs
47-
run: yarn run docs
48+
run: pnpm run docs
4849
- uses: actions/upload-artifact@v3
4950
with:
5051
name: docs

.jsdoc.json

+24-27
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,26 @@
11
{
2-
"tags": {
3-
"allowUnknownTags": true,
4-
"dictionaries": ["jsdoc"]
5-
},
6-
"source": {
7-
"include": ["src", "package.json", "README.md"],
8-
// "includePattern": ".js$",
9-
"excludePattern": ".spec.js$"
10-
},
11-
"plugins": [
12-
"plugins/markdown"
13-
],
14-
"templates": {
15-
"cleverLinks": false,
16-
"monospaceLinks": true
17-
},
18-
"opts": {
19-
"destination": "./docs/",
20-
"encoding": "utf8",
21-
"private": true,
22-
"recurse": true,
23-
"template": "./node_modules/financier-docdash"
24-
},
25-
"docdash": {
26-
"static": true,
27-
"sort": false
28-
}
2+
"tags": {
3+
"allowUnknownTags": true,
4+
"dictionaries": ["jsdoc"]
5+
},
6+
"source": {
7+
"include": ["src", "package.json", "README.md"],
8+
"excludePattern": ".spec.js$"
9+
},
10+
"plugins": ["plugins/markdown"],
11+
"templates": {
12+
"cleverLinks": false,
13+
"monospaceLinks": true
14+
},
15+
"opts": {
16+
"destination": "./docs/",
17+
"encoding": "utf8",
18+
"private": true,
19+
"recurse": true,
20+
"template": "./node_modules/financier-docdash"
21+
},
22+
"docdash": {
23+
"static": true,
24+
"sort": false
25+
}
2926
}

Dockerfile

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
FROM node:18
1+
FROM node:22
22

33
WORKDIR /financier
4-
RUN yarn add express@^4.17.3 nocache@^3.0.3 uuid@^8.3.2 helmet-csp@^3.4.0 cheerio@^0.22.0
4+
RUN corepack enable
5+
RUN pnpm install express@^4.17.3 nocache@^4.0.0 uuid@^11.0.0 helmet@^8.0.0 cheerio@^1.0.0
56

67
ADD ./dist /financier/dist
78
ADD ./docs /financier/docs

README.md

+8-8
Original file line numberDiff line numberDiff line change
@@ -15,33 +15,33 @@
1515
### Develop
1616

1717
```sh
18-
yarn
19-
yarn start
18+
pnpm
19+
pnpm start
2020
```
2121

2222
### Test
2323

2424
```sh
25-
yarn test
26-
# or continuous: `yarn test-watch`
25+
pnpm test
26+
# or continuous: `pnpm test-watch`
2727
```
2828

2929
### Build (for production)
3030

3131
```sh
32-
yarn build
32+
pnpm build
3333
```
3434

3535
### Run locally
3636

3737
```sh
38-
yarn build
39-
yarn docs # generate jsdoc documentation
38+
pnpm build
39+
pnpm run docs # generate jsdoc documentation
4040
node ./api
4141
```
4242

4343
### Docs
4444

4545
Local docs would be `http://localhost:8080/docs`.
4646

47-
Generate with `yarn docs`.
47+
Generate with `pnpm run docs`.

api/index.js

+15-14
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
1-
const path = require("path");
2-
const fs = require("fs");
1+
import path from "path";
2+
import fs from "fs";
3+
import { Buffer } from "buffer";
34

4-
const noCache = require("nocache");
5-
const express = require("express");
6-
const uuid = require("uuid");
7-
const csp = require("helmet-csp");
8-
const cheerio = require("cheerio");
5+
import noCache from "nocache";
6+
import express from "express";
7+
import { v4 } from "uuid";
8+
import { contentSecurityPolicy } from "helmet";
9+
import * as cheerio from "cheerio";
910

1011
const app = express();
1112

12-
app.use("/docs", express.static(path.join(__dirname, "../docs")));
13+
app.use("/docs", express.static(path.join(import.meta.dirname, "../docs")));
1314

14-
var statics = express.static(path.join(__dirname, "../dist"));
15+
var statics = express.static(path.join(import.meta.dirname, "../dist"));
1516

1617
// Don't serve index.html
1718
function staticDir() {
@@ -32,12 +33,12 @@ app.use(staticDir());
3233
app.use(noCache());
3334

3435
app.use(function (req, res, next) {
35-
res.locals.nonce = new Buffer(uuid.v4(), "binary").toString("base64");
36+
res.locals.nonce = Buffer.from(v4(), "binary").toString("base64");
3637
next();
3738
});
3839

3940
app.use(
40-
csp({
41+
contentSecurityPolicy({
4142
// Specify directives as normal.
4243
directives: {
4344
defaultSrc: ["'self'"],
@@ -67,12 +68,12 @@ app.use(
6768
// You may also set this to a function(req, res) in order to decide dynamically
6869
// whether to use reportOnly mode, e.g., to allow for a dynamic kill switch.
6970
reportOnly: false,
70-
})
71+
}),
7172
);
7273

7374
const html = fs.readFileSync(
74-
path.join(__dirname, "../dist/index.html"),
75-
"utf-8"
75+
path.join(import.meta.dirname, "../dist/index.html"),
76+
"utf-8",
7677
);
7778
const $ = cheerio.load(html);
7879

babel.config.js babel.config.cjs

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
module.exports = {
2-
presets: ["@babel/preset-env"],
32
plugins: ["angularjs-annotate"],
43
};

eslint.config.mjs

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import globals from "globals";
2+
import vitest from "eslint-plugin-vitest";
3+
import js from "@eslint/js";
4+
5+
export default [
6+
js.configs.recommended,
7+
{
8+
languageOptions: {
9+
globals: {
10+
...globals.browser,
11+
...globals.amd,
12+
angular: true,
13+
inject: true,
14+
VERSION: true,
15+
process: true,
16+
},
17+
},
18+
19+
rules: {
20+
"no-prototype-builtins": 0,
21+
},
22+
},
23+
{
24+
files: ["**/*.spec.js"],
25+
26+
languageOptions: {
27+
globals: vitest.environments.env.globals,
28+
},
29+
30+
plugins: {
31+
vitest,
32+
},
33+
34+
rules: {
35+
...vitest.configs.recommended.rules,
36+
},
37+
},
38+
];

src/index.html index.html

+16-12
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<!DOCTYPE html>
1+
<!doctype html>
22
<html ng-app="financier" ng-strict-di ng-csp>
33
<head>
44
<meta charset="UTF-8" />
@@ -10,30 +10,25 @@
1010
<link
1111
rel="apple-touch-icon"
1212
sizes="180x180"
13-
href="./public/icons/apple-touch-icon.png"
13+
href="/icons/apple-touch-icon.png"
1414
/>
1515
<link
1616
rel="icon"
1717
type="image/png"
18-
href="./public/icons/favicon-32x32.png"
18+
href="/icons/favicon-32x32.png"
1919
sizes="32x32"
2020
/>
2121
<link
2222
rel="icon"
2323
type="image/png"
24-
href="./public/icons/favicon-16x16.png"
24+
href="/icons/favicon-16x16.png"
2525
sizes="16x16"
2626
/>
27-
<link rel="manifest" href="./public/icons/manifest.json" />
28-
<link
29-
rel="mask-icon"
30-
href="./public/icons/safari-pinned-tab.svg"
31-
color="#76b852"
32-
/>
33-
<link rel="shortcut icon" href="./public/icons/favicon.ico" />
27+
<link rel="mask-icon" href="/icons/safari-pinned-tab.svg" color="#76b852" />
28+
<link rel="shortcut icon" href="/icons/favicon.ico" />
3429
<meta name="theme-color" content="#76b852" />
3530

36-
<link type="text/plain" rel="author" href="humans.txt" />
31+
<link type="text/plain" rel="author" href="/humans.txt" />
3732

3833
<base href="/" />
3934

@@ -132,6 +127,15 @@
132127
}
133128
}
134129
</style>
130+
131+
<script type="module" src="./src/scripts/app.js"></script>
132+
133+
<link rel="preconnect" href="https://fonts.googleapis.com" />
134+
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
135+
<link
136+
href="https://fonts.googleapis.com/css2?family=Lato:wght@100;300;400;700;900"
137+
rel="stylesheet"
138+
/>
135139
</head>
136140

137141
<body>

jest.config.js

-10
This file was deleted.

jest.setup.js

+3-27
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,4 @@
1-
// This file is an entry point for angular tests
2-
// Avoids some weird issues when using webpack + angular.
3-
window.jasmine = true;
4-
window.VERSION = {};
5-
window.process = {
6-
env: {},
7-
};
1+
import "angular";
2+
import "angular-mocks/angular-mocks";
83

9-
require("regenerator-runtime/runtime");
10-
require("jest-fetch-mock").enableMocks();
11-
12-
require("angular");
13-
require("angular-mocks/angular-mocks");
14-
15-
// https://github.com/pouchdb/pouchdb/issues/8383
16-
window.setImmediate = (fn) => {
17-
setTimeout(fn, 0);
18-
};
19-
window.process.nextTick = (fn) => {
20-
setTimeout(fn, 0);
21-
};
22-
23-
const PouchDB = require("pouchdb-browser");
24-
const memory = require("pouchdb-adapter-memory");
25-
26-
PouchDB.plugin(memory);
27-
28-
require("./src/scripts/app");
4+
import "./src/scripts/app.js";

0 commit comments

Comments
 (0)