Skip to content

Commit

Permalink
Reorganize JS and introduce shared types
Browse files Browse the repository at this point in the history
  • Loading branch information
glacials committed Nov 17, 2023
1 parent 00e5f80 commit f5c6bbb
Show file tree
Hide file tree
Showing 33 changed files with 15,844 additions and 246 deletions.
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ even for the website itself.

#### Editing the page

To change the layout of the page, use
To change the layout of the page, use

#### Running tests

Expand Down
1 change: 1 addition & 0 deletions firebase/.node-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
16.20.0
4 changes: 4 additions & 0 deletions firebase/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,12 @@ call.

### Deploying

Edit `.firebaserc` to point `projects.default` to `whats-in-standard` if needed.

```sh
firebase deploy
```

Then revert `.firebaserc`.

[@whatsinstandard]: https://twitter.com/whatsinstandard
22 changes: 18 additions & 4 deletions firebase/firebase.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,24 @@
"rules": "firestore.rules",
"indexes": "firestore.indexes.json"
},
"functions": {
"ignore": [".runtimeconfig.json"],
"source": "functions"
},
"functions": [
{
"ignore": [
"node_modules",
".git",
"firebase-debug.log",
"firebase-debug.*.log",
"**/*.map"
],
"source": "./functions/dist/firebase/functions",
"codebase": "default",
"predeploy": [
"cp functions/package.json functions/dist/firebase/functions",
"npm --prefix \"$RESOURCE_DIR\" run lint",
"npm --prefix \"$RESOURCE_DIR\" run build"
]
}
],
"emulators": {
"firestore": {
"port": "8080"
Expand Down
41 changes: 41 additions & 0 deletions firebase/functions/detect_rotations.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import * as functions from "firebase-functions";
import * as admin from "firebase-admin";
const db = admin.firestore();

const twitterCollection = db.collection("twitterbot/last-known/sets");
const mastodonCollection = db.collection("mastodonbot/last-known/sets");

import { diff, standardSets, toot, tweet } from "./lib";

admin.initializeApp();

export async function detectRotations(context: any) {
const config = functions.config();
const apiSets = await standardSets();

await diff(twitterCollection, apiSets).then(async (setDifferences) => {
if (
setDifferences.addedSets.size == 0 &&
setDifferences.removedSets.size == 0
) {
functions.logger.info(
`No sets changed, not tweeting (${setDifferences.unchangedSets.size} sets accounted for)`
);
return;
}
await tweet(config, setDifferences);
});

await diff(mastodonCollection, apiSets).then(async (setDifferences) => {
if (
setDifferences.addedSets.size == 0 &&
setDifferences.removedSets.size == 0
) {
functions.logger.info(
`No sets changed, not tooting (${setDifferences.unchangedSets.size} sets accounted for)`
);
return;
}
await toot(config, setDifferences);
});
}
55 changes: 55 additions & 0 deletions firebase/functions/dist/firebase/functions/detect_rotations.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

29 changes: 29 additions & 0 deletions firebase/functions/dist/firebase/functions/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions firebase/functions/dist/firebase/functions/index.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

165 changes: 165 additions & 0 deletions firebase/functions/dist/firebase/functions/lib.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit f5c6bbb

Please sign in to comment.