Skip to content

Commit

Permalink
Better libraries compilation
Browse files Browse the repository at this point in the history
  • Loading branch information
danielcardeenas committed Jan 25, 2020
1 parent a3730c0 commit e2ee4bd
Show file tree
Hide file tree
Showing 16 changed files with 8,111 additions and 1,815 deletions.
6,413 changes: 6,024 additions & 389 deletions package-lock.json

Large diffs are not rendered by default.

19 changes: 12 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@
"types": "dist/index.d.ts",
"scripts": {
"start": "tsc && node dist/index.js",
"build": "tsc && npm run build:middleware && npm run build:lib",
"build:lib": "node prebuild.js",
"build:middleware": "tsc --out src/lib/middleware.js src/middleware/middleware.ts",
"build": "npm run build:wapi && npm run build:middleware && npm run build:jsQR && tsc",
"build:wapi": "cd src/lib/wapi/ && webpack",
"build:middleware": "cd src/lib/middleware/ && webpack",
"build:jsQR": "cd src/lib/jsQR/ && gulp",
"watch": "concurrently \"tsc -w\" \"nodemon dist/index.js\"",
"clean": "rm -rf session && rm -rf dist",
"test": "echo \"No tests yet\""
Expand Down Expand Up @@ -37,16 +38,20 @@
},
"homepage": "https://github.com/danielcardeenas/sulla#readme",
"devDependencies": {
"@types/node": "^13.1.8",
"@types/node": "^13.5.0",
"@types/puppeteer": "^2.0.0",
"@types/shelljs": "^0.8.6",
"concurrently": "^5.0.2",
"husky": "^4.2.0",
"copy-webpack-plugin": "^5.1.1",
"gulp": "^4.0.2",
"husky": "^4.2.1",
"nodemon": "^2.0.2",
"prettier": "^1.19.1",
"pretty-quick": "^2.0.1",
"shelljs": "^0.8.3",
"typescript": "^3.7.5"
"ts-loader": "^6.2.1",
"typescript": "^3.7.5",
"webpack": "^4.41.5",
"webpack-cli": "^3.3.10"
},
"dependencies": {
"ora": "^4.0.3",
Expand Down
11 changes: 0 additions & 11 deletions prebuild.js

This file was deleted.

3 changes: 2 additions & 1 deletion src/controllers/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,9 @@ export async function retrieveQR(page: puppeteer.Page) {
async function decodeQR(page: puppeteer.Page): Promise<string> {
await page.waitForSelector('canvas', { timeout: 0 });
await page.addScriptTag({
path: require.resolve(path.join(__dirname, '../lib', 'jsQR.js'))
path: require.resolve(path.join(__dirname, '../lib/jsQR', 'jsQR.js'))
});

return await page.evaluate(() => {
const canvas = document.querySelector('canvas');
const context = canvas.getContext('2d');
Expand Down
4 changes: 2 additions & 2 deletions src/controllers/browser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ export async function initWhatsapp(session: string) {

export async function injectApi(page: puppeteer.Page) {
await page.addScriptTag({
path: require.resolve(path.join(__dirname, '../lib', 'wapi.js'))
path: require.resolve(path.join(__dirname, '../lib/wapi', 'wapi.js'))
});
await page.addScriptTag({
path: require.resolve(path.join(__dirname, '../lib', 'middleware.js'))
path: require.resolve(path.join(__dirname, '../lib/middleware', 'middleware.js'))
});

return page;
Expand Down
1 change: 1 addition & 0 deletions src/lib/jsQR/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
This file is already bundled and minified. No need for building or webpack here
9 changes: 9 additions & 0 deletions src/lib/jsQR/gulpfile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
const { src, dest } = require('gulp');
const path = require('path');

function copy() {
return src('./jsQR.js')
.pipe(dest(path.resolve(__dirname, '../../../dist/lib/jsQR')));
}

exports.default = copy;
File renamed without changes.
File renamed without changes.
7 changes: 7 additions & 0 deletions src/lib/middleware/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"compilerOptions": {
"noImplicitAny": false,
"module": "es6",
"target": "es6",
}
}
21 changes: 21 additions & 0 deletions src/lib/middleware/webpack.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
const path = require('path');

module.exports = {
entry: './middleware.ts',
module: {
rules: [
{
test: /\.tsx?$/,
use: 'ts-loader',
exclude: /node_modules/,
},
],
},
resolve: {
extensions: [ '.tsx', '.ts', '.js' ],
},
output: {
filename: 'middleware.js',
path: path.resolve(__dirname, '../../../dist/lib/middleware'),
},
};
Loading

0 comments on commit e2ee4bd

Please sign in to comment.