Skip to content

Commit

Permalink
set up build
Browse files Browse the repository at this point in the history
  • Loading branch information
pascal-giguere committed May 8, 2023
1 parent 8750ac5 commit fbfe295
Show file tree
Hide file tree
Showing 7 changed files with 99 additions and 76 deletions.
2 changes: 0 additions & 2 deletions lib/index.ts

This file was deleted.

12 changes: 10 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"name": "@pascal-giguere/starter-node",
"name": "mastofeed",
"version": "1.0.0",
"author": "Pascal Giguère",
"repository": "https://github.com/pascal-giguere/starter-node",
"repository": "https://github.com/pascal-giguere/mastofeed",
"private": true,
"license": "UNLICENSED",
"packageManager": "[email protected]",
Expand All @@ -12,6 +12,14 @@
"yarn": "3.3.0"
},
"main": "dist/index.js",
"files": [
"dist/**/*"
],
"scripts": {
"build": "tsc",
"clean": "tsc --build --clean",
"prepack": "yarn run clean && yarn run build"
},
"devDependencies": {
"@types/jest": "^29.2.3",
"@types/lodash": "^4.14.191",
Expand Down
50 changes: 2 additions & 48 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,48 +1,2 @@
import 'dotenv/config';
import env from 'env-var';
import { Mastofeed } from './Mastofeed';
import { MapTransform, UppercaseTransform } from './utils/transforms';

const MASTODON_ACCESS_TOKEN = env.get('MASTODON_ACCESS_TOKEN').required().asString();

const laPresseBot = new Mastofeed({
mastodon: {
instanceUrl: 'https://staging.mastodon.quebec',
accessToken: MASTODON_ACCESS_TOKEN,
},
rss: {
feedUrl: 'https://www.lapresse.ca/manchettes/rss',
postDef: {
id: { path: 'guid' },
title: { path: 'title', regex: '(?!.*\\|) *(.+)?' },
kicker: { path: 'title', regex: '^(.+) \\|', transforms: [new UppercaseTransform()] },
category: {
path: 'link',
regex: '^https:\\/\\/www\\.lapresse\\.ca\\/(\\w+)\\/',
transforms: [
new MapTransform({
actualites: 'Actualités',
affaires: 'Affaires',
auto: 'Auto',
arts: 'Arts',
cinema: 'Cinéma',
contexte: 'Contexte',
debats: 'Débats',
gourmand: 'Gourmand',
international: 'International',
maison: 'Maison',
societe: 'Société',
sports: 'Sports',
voyage: 'Voyage',
}),
],
},
description: { path: 'contentSnippet' },
author: { path: 'dc:creator' },
imageUrl: { path: 'enclosure.url' },
linkUrl: { path: 'link' },
},
},
});

(async () => await laPresseBot.run())();
export { Mastofeed } from '../src/Mastofeed';
export { UppercaseTransform, LowercaseTransform, CapitalizeTransform, MapTransform } from '../src/utils/transforms';
48 changes: 48 additions & 0 deletions src/laPresse.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import 'dotenv/config';
import env from 'env-var';
import { Mastofeed } from './Mastofeed';
import { MapTransform, UppercaseTransform } from './utils/transforms';

const MASTODON_ACCESS_TOKEN = env.get('MASTODON_ACCESS_TOKEN').required().asString();

const laPresseBot = new Mastofeed({
mastodon: {
instanceUrl: 'https://staging.mastodon.quebec',
accessToken: MASTODON_ACCESS_TOKEN,
},
rss: {
feedUrl: 'https://www.lapresse.ca/manchettes/rss',
postDef: {
id: { path: 'guid' },
title: { path: 'title', regex: '(?!.*\\|) *(.+)?' },
kicker: { path: 'title', regex: '^(.+) \\|', transforms: [new UppercaseTransform()] },
category: {
path: 'link',
regex: '^https:\\/\\/www\\.lapresse\\.ca\\/(\\w+)\\/',
transforms: [
new MapTransform({
actualites: 'Actualités',
affaires: 'Affaires',
auto: 'Auto',
arts: 'Arts',
cinema: 'Cinéma',
contexte: 'Contexte',
debats: 'Débats',
gourmand: 'Gourmand',
international: 'International',
maison: 'Maison',
societe: 'Société',
sports: 'Sports',
voyage: 'Voyage',
}),
],
},
description: { path: 'contentSnippet' },
author: { path: 'dc:creator' },
imageUrl: { path: 'enclosure.url' },
linkUrl: { path: 'link' },
},
},
});

(async () => await laPresseBot.run())();
1 change: 1 addition & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"allowJs": true,
"allowSyntheticDefaultImports": true,
"alwaysStrict": true,
"declaration": true,
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"noImplicitAny": true,
Expand Down
14 changes: 14 additions & 0 deletions vite.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import path from 'path';
import { defineConfig } from 'vite';

// https://vitejs.dev/config/
export default defineConfig({
build: {
emptyOutDir: true,
lib: {
entry: path.resolve(__dirname, './lib/index.ts'),
formats: ['es', 'cjs'],
},
sourcemap: true,
},
});
48 changes: 24 additions & 24 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -825,30 +825,6 @@ __metadata:
languageName: node
linkType: hard

"@pascal-giguere/starter-node@workspace:.":
version: 0.0.0-use.local
resolution: "@pascal-giguere/starter-node@workspace:."
dependencies:
"@types/jest": ^29.2.3
"@types/lodash": ^4.14.191
"@types/node": ^18.11.10
"@typescript-eslint/eslint-plugin": ^5.45.0
"@typescript-eslint/parser": ^5.45.0
axios: ^1.4.0
dotenv: ^16.0.3
env-var: ^7.3.1
eslint: ^8.28.0
jest: ^29.3.1
lodash: ^4.17.21
megalodon: ^6.0.1
prettier: ^2.8.0
rss-parser: ^3.12.0
ts-jest: ^29.0.3
ts-node: ^10.9.1
typescript: ^4.9.3
languageName: unknown
linkType: soft

"@sinclair/typebox@npm:^0.24.1":
version: 0.24.51
resolution: "@sinclair/typebox@npm:0.24.51"
Expand Down Expand Up @@ -3418,6 +3394,30 @@ __metadata:
languageName: node
linkType: hard

"mastofeed@workspace:.":
version: 0.0.0-use.local
resolution: "mastofeed@workspace:."
dependencies:
"@types/jest": ^29.2.3
"@types/lodash": ^4.14.191
"@types/node": ^18.11.10
"@typescript-eslint/eslint-plugin": ^5.45.0
"@typescript-eslint/parser": ^5.45.0
axios: ^1.4.0
dotenv: ^16.0.3
env-var: ^7.3.1
eslint: ^8.28.0
jest: ^29.3.1
lodash: ^4.17.21
megalodon: ^6.0.1
prettier: ^2.8.0
rss-parser: ^3.12.0
ts-jest: ^29.0.3
ts-node: ^10.9.1
typescript: ^4.9.3
languageName: unknown
linkType: soft

"megalodon@npm:^6.0.1":
version: 6.0.1
resolution: "megalodon@npm:6.0.1"
Expand Down

0 comments on commit fbfe295

Please sign in to comment.