Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dev environment runs on M1 mac #188

Merged
merged 2 commits into from May 13, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 2 additions & 4 deletions docker-compose.yml
Expand Up @@ -19,9 +19,7 @@ services:
- LOG_LEVEL=$LOG_LEVEL
working_dir: /paperpod
api:
build:
context: .
dockerfile: ./packages/api/Dockerfile
build: .
env_file:
- .env
ports:
Expand Down Expand Up @@ -78,7 +76,7 @@ services:
- .env
ports:
- $WEB_PORT:$WEB_PORT
command: yarn web dev
command: yarn web dev --port $WEB_PORT
volumes:
- .:/paperpod
environment:
Expand Down
2 changes: 1 addition & 1 deletion dockerfiles/Dockerfile.api
@@ -1,4 +1,4 @@
FROM buildkite/puppeteer:8.0.0
FROM node:12-alpine

WORKDIR /app

Expand Down
5 changes: 0 additions & 5 deletions packages/api/Dockerfile

This file was deleted.

1 change: 0 additions & 1 deletion packages/authentication/src/app.ts
Expand Up @@ -5,7 +5,6 @@ import { subscriptionManagementRoutes } from "./routes/public/subscription-manag
import { userRoutes } from "./routes/public/user-routes";

export const publicAuthenticationApp = server.app

.appWithEnvironment(
server.app.appWithBodyParser(server.app.appWithCookieParser())
)
Expand Down
30 changes: 0 additions & 30 deletions packages/converter/__mocks__/puppeteer.ts

This file was deleted.

36 changes: 36 additions & 0 deletions packages/converter/__mocks__/zombie.ts
@@ -0,0 +1,36 @@
import faker from "faker";

export default class Zombie {
private doneVisiting: boolean = false;
constructor(_options) {}
public visit(_url: string, callback: () => void) {
this.doneVisiting = true;
callback();
}

public html() {
if (!this.doneVisiting) {
throw `Should not have called HTML before done with visit`;
}

return `
<!DOCTYPE html>

<head>
<title>${faker.lorem.sentence()}</title>
<meta name="author" content="${faker.name.firstName()}"/>
</head>

<body>
<p>${faker.lorem.paragraphs()}</p>
<p>${faker.lorem.paragraphs()}</p>
<p>${faker.lorem.paragraphs()}</p>
<p>${faker.lorem.paragraphs()}</p>
<p>${faker.lorem.paragraphs()}</p>
<p>${faker.lorem.paragraphs()}</p>
</body>

</html>
`;
}
}
4 changes: 2 additions & 2 deletions packages/converter/package.json
Expand Up @@ -14,9 +14,9 @@
"@paperpod/common": "0.0.1",
"node-kall": "^1.0.83",
"pdf-parse": "^1.1.1",
"puppeteer": "^5.4.1",
"serialize-xml": "^0.4.0",
"unfluff": "^3.2.0"
"unfluff": "^3.2.0",
"zombie": "^6.1.4"
},
"devDependencies": {
"@types/faker": "^5.5.3",
Expand Down
2 changes: 1 addition & 1 deletion packages/converter/src/index.test.ts
Expand Up @@ -3,7 +3,7 @@ import { withStorageUri } from ".";
import { withTextualData, getRSSFeed } from "./index";

describe("converter", () => {
jest.mock("puppeteer");
jest.mock("zombie");

describe("withTextualData", () => {
it("Does not throw", () => {
Expand Down
4 changes: 0 additions & 4 deletions packages/converter/src/rss.test.ts
Expand Up @@ -85,10 +85,6 @@ describe("Conversion from articles to RSS", () => {
expect(rss).toContain("<link>");
});

it("Print to show", () => {
console.log(convertToRSSFeed([test.mocks.article()]));
});

describe("The channel cover image", () => {
const getImageTag = () => {
const rss = convertToRSSFeed([]);
Expand Down
6 changes: 3 additions & 3 deletions packages/converter/src/text/web.test.ts
@@ -1,10 +1,10 @@
import { models, test } from "@paperpod/common";
import { test } from "@paperpod/common";
import { extractTextFromWeb } from "./web";

describe("extracting text", () => {
jest.mock("puppeteer");
jest.mock("zombie");

it("Does mock puppeteer", async () => {
it("Does mock zombie", async () => {
const content = extractTextFromWeb(test.mocks.article());
expect(content).toBeDefined();
});
Expand Down
39 changes: 17 additions & 22 deletions packages/converter/src/text/web.ts
@@ -1,6 +1,7 @@
import unfluff from "unfluff";
import puppeteer from "puppeteer";
import { models } from "@paperpod/common";
import { logger } from "@paperpod/common";
import zombie from "zombie";

/**
* returns the publication timestamp, if any.
Expand All @@ -22,30 +23,24 @@ export const extractTextFromWeb = async (
author: extracted.author().join(", "),
description: extracted.description(),
publication_time: date(extracted),
added_time: new Date()
added_time: new Date(),
};
};

/**
* Using Puppeteer (or a browser-emulator in general) makes it possible for
* me to access text that is not directly provided, but client side rendered.
* Using Zombie (or a browser-emulator in general) makes it possible
* to access text that is not directly provided, but client side rendered.
*/
const getHtml = async (url: string) => {
const browser = await puppeteer.launch({
executablePath: process.env.PUPPETEER_EXEC_PATH,
headless: true,
//FIXME: security considerations without sandbox? Read up on this.
args: ["--disable-setuid-sandbox", "--no-sandbox"],
ignoreHTTPSErrors: true,
const getHtml = (url: string): Promise<string> =>
new Promise((resolve, _reject) => {
const browser = new zombie({
debug: true,
waitFor: 15000,
});

browser.visit(url, function () {
const html = browser.html();
logger.debug({ message: `Got HTML from zombie`, html, url });
resolve(html);
});
});

const page = await browser.newPage();
await page.goto(url);

await page.waitFor("*");

const html = await page.content();
await browser.close();

return html;
};
1 change: 0 additions & 1 deletion packages/extension/src/background/fetch_token.ts
Expand Up @@ -25,7 +25,6 @@ const run = async () => {
}
};

logger.debug("AM her at all");
run().then(() => {
logger.debug(`Running token background script`);
});