Skip to content

Commit

Permalink
feat: setup for binary output
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelTaylor3D committed Jan 27, 2022
1 parent 534e01f commit 89ff22c
Show file tree
Hide file tree
Showing 14 changed files with 109 additions and 71 deletions.
File renamed without changes.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ testMirror.sqlite3

# production
/build
/dist

# misc
.DS_Store
Expand Down
15 changes: 11 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,7 @@ git clone [email protected]:Chia-Network/climate-warehouse.git
cd climate-warehouse
nvm install 16.0.0
nvm use 16.0.0
npm install -g husky
npm install -g prettier
npm install -g lint-staged
npm install -g cross-env
npm install -g @babel/cli husky prettier lint-staged cross-env
npm set-script prepare "husky install"
npm run prepare
Expand All @@ -25,6 +22,16 @@ chmod ug+x .git/hooks/*
npm run start
```

### Build Binaries

```
// transcompile project to es5
npm run build
// Output binaries to dist folder
npm run output-binary
```

### Prerequisites

You'll need:
Expand Down
15 changes: 15 additions & 0 deletions babel.config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"presets": [
[
"@babel/preset-env",
{
"targets": {
"esmodules": true
},
"modules": false,
"useBuiltIns": "usage",
"corejs": "3.6.5"
}
]
]
}
8 changes: 8 additions & 0 deletions jsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"compilerOptions": {
"module": "commonjs",
"target": "es6",
"baseUrl": "."
},
"exclude": ["node_modules"]
}
116 changes: 59 additions & 57 deletions package-lock.json

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

7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "climate-warehouse",
"version": "0.0.5",
"private": true,
"type": "module",
"bin": "build/server.js",
"engines": {
"node": ">=16.0.0"
},
Expand All @@ -16,7 +16,9 @@
"cleandb": "rm -f ./data.sqlite3 && && npx sequelize-cli db:migrate --env local",
"resetTestDb": "rm -f ./test.sqlite3 && npx sequelize-cli db:migrate --env test && npx sequelize-cli db:seed:all --debug --env test && rm -f ./testMirror.sqlite3 && npx sequelize-cli db:migrate --env mirrorTest",
"resetMirrorDb": "npx sequelize-cli db:drop --env mirror && npx sequelize-cli db:create --env mirror && npx sequelize-cli db:migrate --env mirror --debug",
"prepare": "husky install"
"prepare": "husky install",
"build": "babel src --keep-file-extension --out-dir build --copy-files",
"output-binary": "pkg package.json --out-path dist"
},
"dependencies": {
"body-parser": "^1.19.0",
Expand All @@ -32,6 +34,7 @@
"mysql2": "^2.3.3",
"node-xlsx": "^0.21.0",
"random-hash": "^4.0.1",
"regenerator-runtime": "^0.13.9",
"request-promise": "^4.2.6",
"rxjs": "^7.5.1",
"sequelize": "^6.12.0-alpha.1",
Expand Down
6 changes: 3 additions & 3 deletions src/models/database.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import dotenv from 'dotenv';
dotenv.config();

// possible values: local, test
export const sequelize = new Sequelize(config[process.env.NODE_ENV]);
export const sequelize = new Sequelize(config[process.env.NODE_ENV || 'local']);

const mirrorConfig = process.env.NODE_ENV === 'local' ? 'mirror' : 'mirrorTest';
export const sequelizeMirror = new Sequelize(config[mirrorConfig]);
Expand All @@ -21,8 +21,8 @@ export const safeMirrorDbHandler = (callback) => {
};

export const sanitizeSqliteFtsQuery = (query) => {
query = query.replace(/[-](?=.*[-])/g, "+"); // Replace all but the final dash
query = query.replace(/[-](?=.*[-])/g, '+'); // Replace all but the final dash
query = query.replace('-', ''); //Replace the final dash with nothing
query += '*'; // Query should end with asterisk for partial matching
return query;
}
};
2 changes: 1 addition & 1 deletion src/models/organizations/organizations.mock.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import stub from './organizations.stub.json';

export const CoBenefitsMock = {
export const OrganizationMock = {
findAll: () => stub,
findOne: (id) => {
return stub.find((record) => record.id == id);
Expand Down
Loading

0 comments on commit 89ff22c

Please sign in to comment.