Skip to content

Commit

Permalink
Upgrade to Yarn v4, upgrade packages, update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
milanmdev committed Jan 11, 2024
1 parent a6aa284 commit f61d2be
Show file tree
Hide file tree
Showing 10 changed files with 5,182 additions and 2,730 deletions.
5 changes: 4 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
.env
data
node_modules
docker-compose.example.yml
docker-compose.example.yml

.yarn/cache
.yarn/install-state.gz
11 changes: 10 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -134,4 +134,13 @@ data/config.json
data/persist.json

package-lock.json
docker-compose.yml
docker-compose.yml

# Yarn 3 files
.pnp.*
.yarn/*
!.yarn/patches
!.yarn/plugins
!.yarn/releases
!.yarn/sdks
!.yarn/versions
893 changes: 893 additions & 0 deletions .yarn/releases/yarn-4.0.2.cjs

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions .yarnrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
nodeLinker: node-modules

yarnPath: .yarn/releases/yarn-4.0.2.cjs
2 changes: 2 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ LABEL org.opencontainers.image.source "https://github.com/milanmdev/bsky.rss"

WORKDIR /build
COPY package.json yarn.lock ./
COPY .yarn ./.yarn
COPY .yarnrc.yml ./
RUN yarn install --frozen-lockfile
COPY . .
CMD yarn start
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ Here's an example of the `config.json` file:
- `descriptionClearHTML`: Remove HTML from the description of the Open Graph description and RSS-provided description (to make it more readable).
- `ogUserAgent`: The user agent to use when fetching the Open Graph data of the URL provided by the RSS post. By default, this is set to `bsky.rss/1.0 (Open Graph Scraper)`.
- `imageAlt`: Alt text for the uploaded image if the `embedType` is set to `image`. Can be any variable (+ string) used in the `string` configuration (e.g. `$title`).
- `removeDuplicate`: Instead of using the last date to track which items needs to be published, use a text-based database to track duplicate items.
- `removeDuplicate`: Instead of using the last date to track which items need to be published, use a text-based database to track duplicate items.
- `titleClearHTML`: Remove HTML from the title of the post (to make it more readable).

A `docker-compose.yml` file can be found in the root directory as `docker-compose.example.yml`, which you can use to set up the RSS poster using Docker.
Expand Down
28 changes: 16 additions & 12 deletions app/utils/dbHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,12 @@ async function valueExists(value: string) {
return false;
} else {
let fileContent = fs.readFileSync(__dirname + "/../../data/db.txt", "utf8");
return (fileContent.includes(value));
return fileContent.includes(value);
}
}

async function writeValue(value: string) {
let currentDate = new Date();
let currentDate = new Date();
fs.appendFileSync(
__dirname + "/../../data/db.txt",
currentDate.toISOString() + "|" + value + "\n",
Expand All @@ -85,11 +85,19 @@ async function writeValue(value: string) {

// Automatically cleanup old values from the file after 96 hours
async function cleanupOldValues() {
let currentDate = new Date();
let oldFileContent = fs.readFileSync(__dirname + "/../../data/db.txt", "utf8");
if (!fs.existsSync(__dirname + "/../../data/db.txt")) {
fs.writeFileSync(__dirname + "/../../data/db.txt", "", "utf8");
return false;
}

let currentDate = new Date();
let oldFileContent = fs.readFileSync(
__dirname + "/../../data/db.txt",
"utf8"
);
let newFileContent = "";

let fcLines: string[] = oldFileContent.split("\n")
let fcLines: string[] = oldFileContent.split("\n");
if (fcLines != undefined) {
for (var i in fcLines) {
let lineItems: string[] = (fcLines[i] || "").split("|");
Expand All @@ -104,11 +112,7 @@ async function cleanupOldValues() {
}
}

fs.writeFileSync(
__dirname + "/../../data/db.txt",
newFileContent,
"utf8"
);
fs.writeFileSync(__dirname + "/../../data/db.txt", newFileContent, "utf8");
return true;
}

Expand All @@ -122,7 +126,7 @@ export default {
initConfig,
writePersistDate,
readPersistData,
valueExists,
writeValue,
valueExists,
writeValue,
cleanupOldValues,
};
4 changes: 2 additions & 2 deletions app/utils/queueHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ let config: Config = {
forceDescriptionEmbed: false,
imageAlt: "",
removeDuplicate: false,
titleClearHTML: false
titleClearHTML: false,
};

async function start() {
Expand Down Expand Up @@ -94,7 +94,7 @@ async function runQueue() {
config.runInterval
} seconds`
);
db.cleanupOldValues();
if (config.removeDuplicate) db.cleanupOldValues();
}
}
}
Expand Down
19 changes: 10 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,24 +13,25 @@
"dev": "tsx --watch ./app/index.ts"
},
"dependencies": {
"@atproto/api": "0.6.23",
"@atproto/xrpc": "0.4.0",
"axios": "1.6.1",
"@atproto/api": "0.8.0",
"@atproto/xrpc": "0.4.1",
"axios": "1.6.5",
"dotenv": "^16.3.1",
"feedsub": "^0.7.8",
"html-entities": "2.4.0",
"open-graph-scraper": "6.3.2",
"sharp": "^0.32.4",
"html-entities": "2.4.0"
"sharp": "0.33.1"
},
"devDependencies": {
"@types/node": "20.9.0",
"@types/node": "20.11.0",
"gts": "5.2.0",
"tsx": "4.0.0",
"typescript": "^5.2.2",
"tsx": "4.7.0",
"typescript": "5.3.3",
"underscore-cli": "^0.2.19"
},
"typeRoots": [
"./node_modules/@types",
"./app/types"
]
],
"packageManager": "[email protected]"
}
Loading

0 comments on commit f61d2be

Please sign in to comment.