Skip to content

Commit fc18406

Browse files
authored
Modernize codebase with ES modules and TypeScript (#168)
* Test for new sitemap field * Convert is-url to check-valid-url * Convert to ES modules and TypeScript: 1) Convert cli.test.js to TypeScript 2) Fix ESModule compatibility with Prettier config 3) Rename eslint.config.mjs to .js * Update Node.js test matrix to include versions 18, 20, 22, and 24 --------- Co-authored-by: seantomburke <seantomburke@users.noreply.github.com>
1 parent 398af22 commit fc18406

File tree

13 files changed

+1452
-1351
lines changed

13 files changed

+1452
-1351
lines changed

.github/workflows/npm-publish.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,10 @@ jobs:
3131
- run: npm publish
3232
env:
3333
NODE_AUTH_TOKEN: ${{secrets.npm_token}}
34+
35+
test-published-npm:
36+
needs: publish-npm
37+
runs-on: ubuntu-latest
38+
steps:
39+
- name: Test published CLI with npx
40+
run: npx sitemapper https://wp.seantburke.com/sitemap.xml

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515

1616
strategy:
1717
matrix:
18-
node-version: [16.x, 18.x, 20.x]
18+
node-version: [18.x, 20.x, 22.x, 24.x]
1919

2020
steps:
2121
- uses: actions/checkout@v4

.github/workflows/typescript-test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212

1313
strategy:
1414
matrix:
15-
node-version: [18.x, 20.x] # Use recent Node versions
15+
node-version: [18.x, 20.x, 22.x, 24.x] # Use recent Node versions
1616

1717
steps:
1818
- name: Checkout repository

.prettierrc.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
module.exports = {
1+
export default {
22
semi: true,
33
trailingComma: 'es5',
44
singleQuote: true,

README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,6 @@ Leaving a field out has the same effect as `<field>: false`. If not specified si
111111
An example using all available options:
112112

113113
```javascript
114-
115114
import { HttpsProxyAgent } from 'hpagent';
116115

117116
const sitemapper = new Sitemapper({
@@ -126,7 +125,7 @@ const sitemapper = new Sitemapper({
126125
retries: 1,
127126
lastmod: 1600000000000,
128127
proxyAgent: new HttpsProxyAgent({
129-
proxy: 'http://localhost:8080'
128+
proxy: 'http://localhost:8080',
130129
}),
131130
exclusions: [/\/v1\//, /scary/],
132131
rejectUnauthorized: false,

babel.config.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
module.exports = (api) => {
1+
export default (api) => {
22
api.cache(true);
33

44
const presets = [
@@ -8,11 +8,14 @@ module.exports = (api) => {
88
targets: {
99
esmodules: true,
1010
},
11+
modules: false, // Output ES modules
1112
},
1213
],
1314
'minify', // minify the Babel code
1415
];
15-
const plugins = [['add-module-exports', { addDefaultProperty: true }]];
16+
17+
// Remove the add-module-exports plugin for ESM output
18+
const plugins = [];
1619

1720
return {
1821
presets,

bin/sitemapper.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/env node
22

3-
const Sitemapper = require('../lib/assets/sitemapper').default;
3+
import Sitemapper from '../lib/assets/sitemapper.js';
44

55
async function main() {
66
const sitemapUrl = process.argv[2];
File renamed without changes.

0 commit comments

Comments
 (0)