Skip to content

Commit

Permalink
Merge pull request #663 from frappe/use-vite
Browse files Browse the repository at this point in the history
build: use vite
  • Loading branch information
18alantom authored Jun 26, 2023
2 parents b184992 + 247d4a4 commit 5f2cef7
Show file tree
Hide file tree
Showing 251 changed files with 4,617 additions and 11,069 deletions.
55 changes: 47 additions & 8 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,23 +1,62 @@
module.exports = {
root: true,

env: {
node: true,
browser: true,
es2018: true,
},

rules: {
'no-console': process.env.NODE_ENV === 'production' ? 'error' : 'off',
'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off',
'no-console': 'warn',
'no-debugger': 'warn',
'arrow-body-style': 'off',
'prefer-arrow-callback': 'off',
'prettier/prettier': 'warn',
'prefer-arrow-callback': 'warn',
'vue/no-mutating-props': 'off',
'vue/multi-word-component-names': 'off',
'vue/no-useless-template-attributes': 'off',
'vue/one-component-per-file': 'off',
'vue/no-reserved-component-names': 'off',
'@typescript-eslint/ban-ts-comment': 'off',
'@typescript-eslint/no-var-requires': 'off',
'@typescript-eslint/no-non-null-assertion': 'off',
'@typescript-eslint/no-floating-promises': 'warn',
'@typescript-eslint/no-misused-promises': 'warn',
},

parser: 'vue-eslint-parser',
parserOptions: {
parser: '@typescript-eslint/parser',
project: true,
tsconfigRootDir: __dirname,
sourceType: 'module',
extraFileExtensions: ['.vue'],
},

extends: ['plugin:vue/vue3-essential', '@vue/typescript'],
plugins: ['@typescript-eslint', 'prettier'],
extends: [
'plugin:vue/vue3-recommended',
'plugin:@typescript-eslint/recommended',
'plugin:@typescript-eslint/recommended-requiring-type-checking',
'plugin:prettier/recommended',
],
overrides: [
{
files: ['*.vue'],
rules: {
'@typescript-eslint/no-misused-promises': 'off',
'@typescript-eslint/no-unsafe-assignment': 'off',
'@typescript-eslint/no-unsafe-member-access': 'off',
'@typescript-eslint/no-unsafe-call': 'off',
},
},
],
ignorePatterns: [
'*.mjs',
'.eslintrc.js',
'tailwind.config.js',
'node_modules',
'dist_electron',
'*.spec.ts',
'vite.config.ts',
'postcss.config.js',
'src/components/**/*.vue', // Incrementally fix these
],
};
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
- name: Setup node
uses: actions/setup-node@v2
with:
node-version: '16.13.1'
node-version: '16.14.0'

- name: Set yarn version
run: yarn set version 1.22.18
Expand All @@ -28,4 +28,4 @@ jobs:
env:
CSC_IDENTITY_AUTO_DISCOVERY: false
APPLE_NOTARIZE: 0
run: yarn electron:build -mw --publish never
run: yarn build -mw --publish never
32 changes: 32 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Lint

on:
push:
branches: [$default-branch]
paths-ignore:
- '**.md'
pull_request:
paths-ignore:
- '**.md'
workflow_dispatch:

jobs:
setup_and_lint:
runs-on: macos-latest
steps:
- name: Setup node
uses: actions/setup-node@v2
with:
node-version: '16.14.0'

- name: Set yarn version
run: yarn set version 1.22.18

- name: Checkout Books
uses: actions/checkout@v2

- name: Install Dependencies
run: yarn

- name: Lint
run: yarn lint
12 changes: 6 additions & 6 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
- name: Setup node
uses: actions/setup-node@v2
with:
node-version: '16.13.1'
node-version: '16.14.0'

- name: Checkout Books
uses: actions/checkout@v2
Expand Down Expand Up @@ -42,7 +42,7 @@ jobs:
GH_TOKEN: ${{ secrets.GH_TOKEN }}
run: |
yarn set version 1.22.18
yarn electron:build --mac --publish always
yarn build --mac --publish always
- name: Tar files
run: tar -cvf dist-macOS.tar dist_electron
Expand All @@ -59,7 +59,7 @@ jobs:
- name: Setup node
uses: actions/setup-node@v2
with:
node-version: '16.13.1'
node-version: '16.14.0'

- name: Checkout Books
uses: actions/checkout@v2
Expand All @@ -86,7 +86,7 @@ jobs:
GH_TOKEN: ${{ secrets.GH_TOKEN }}
run: |
yarn set version 1.22.18
yarn electron:build --linux --publish always
yarn build --linux --publish always
- name: Tar files
run: tar -cvf dist-linux.tar dist_electron
Expand All @@ -107,7 +107,7 @@ jobs:
- name: Setup node
uses: actions/setup-node@v2
with:
node-version: '16.13.1'
node-version: '16.14.0'

- name: Checkout Books
uses: actions/checkout@v2
Expand All @@ -132,7 +132,7 @@ jobs:
WIN_CSC_LINK: ${{ secrets.WIN_CSC_LINK }}
WIN_CSC_KEY_PASSWORD: ${{ secrets.WIN_CSC_KEY_PASSWORD }}
GH_TOKEN: ${{ secrets.GH_TOKEN }}
run: yarn electron:build --win --publish always
run: yarn build --win --publish always

- name: Tar files
run: tar -cvf dist-windows.tar dist_electron
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
- name: Setup node
uses: actions/setup-node@v2
with:
node-version: '16.13.1'
node-version: '16.14.0'

- name: Set yarn version
run: yarn set version 1.22.18
Expand Down
26 changes: 21 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ a local SQLite file as the database.
### Pre-requisites

To get the dev environment up and running you need to first set up Node.js version
16.13.1 and npm. For this, we suggest using
16.14.0 and npm. For this, we suggest using
[nvm](https://github.com/nvm-sh/nvm#installing-and-updating).

Next, you will need to install [yarn](https://classic.yarnpkg.com/lang/en/docs/install/#mac-stable).
Expand All @@ -87,25 +87,41 @@ To run Frappe Books in development mode (with hot reload, etc):

```bash
# start the electron app
yarn electron:serve
yarn dev
```

**Note: First Boot**

When you run `yarn dev` electron will run immediately but the UI will take a
couple of seconds to render this because of how dev mode works. Each file is
individually served by the dev server. And there are many files that have to be
sent.


**Note: Debug Electron Main Process**

When in dev mode electron runs with the `--inspect` flag which allows an
external debugger to connect to port 5858. You can use chrome for this by
visiting `chrome://inspect` while Frappe Books is running in dev mode.

See more [here](https://www.electronjs.org/docs/latest/tutorial/debugging-main-process#external-debuggers).

#### Build

To build Frappe Books and create an installer:

```bash
# start the electron app
yarn electron:build
yarn build
```

**Note**
**Note: Build Target**
By default the above command will build for your computer's operating system and
architecture. To build for other environments (example: for linux from a windows
computer) check the _Building_ section at
[electron.build/cli](https://www.electron.build/cli).

So to build for linux you could use the `--linux` flag like so: `yarn electron:build --linux`.
So to build for linux you could use the `--linux` flag like so: `yarn build --linux`.

## Contributions and Community

Expand Down
3 changes: 0 additions & 3 deletions babel.config.js

This file was deleted.

30 changes: 19 additions & 11 deletions backend/database/bespoke.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
import {
Cashflow,
IncomeExpense,
TopExpenses,
TotalCreditAndDebit,
TotalOutstanding,
} from 'utils/db/types';
import { ModelNameEnum } from '../../models/types';
import DatabaseCore from './core';
import { BespokeFunction } from './types';
Expand Down Expand Up @@ -43,7 +50,7 @@ export class BespokeQueries {
.groupBy('account')
.orderBy('total', 'desc')
.limit(5);
return topExpenses;
return topExpenses as TopExpenses;
}

static async getTotalOutstanding(
Expand All @@ -52,13 +59,13 @@ export class BespokeQueries {
fromDate: string,
toDate: string
) {
return await db.knex!(schemaName)
return (await db.knex!(schemaName)
.sum({ total: 'baseGrandTotal' })
.sum({ outstanding: 'outstandingAmount' })
.where('submitted', true)
.where('cancelled', false)
.whereBetween('date', [fromDate, toDate])
.first();
.first()) as TotalOutstanding;
}

static async getCashflow(db: DatabaseCore, fromDate: string, toDate: string) {
Expand All @@ -67,7 +74,7 @@ export class BespokeQueries {
.where('accountType', 'in', ['Cash', 'Bank'])
.andWhere('isGroup', false);
const dateAsMonthYear = db.knex!.raw(`strftime('%Y-%m', ??)`, 'date');
return await db.knex!('AccountingLedgerEntry')
return (await db.knex!('AccountingLedgerEntry')
.where('reverted', false)
.sum({
inflow: 'debit',
Expand All @@ -78,15 +85,15 @@ export class BespokeQueries {
})
.where('account', 'in', cashAndBankAccounts)
.whereBetween('date', [fromDate, toDate])
.groupBy(dateAsMonthYear);
.groupBy(dateAsMonthYear)) as Cashflow;
}

static async getIncomeAndExpenses(
db: DatabaseCore,
fromDate: string,
toDate: string
) {
const income = await db.knex!.raw(
const income = (await db.knex!.raw(
`
select sum(cast(credit as real) - cast(debit as real)) as balance, strftime('%Y-%m', date) as yearmonth
from AccountingLedgerEntry
Expand All @@ -100,9 +107,9 @@ export class BespokeQueries {
)
group by yearmonth`,
[fromDate, toDate]
);
)) as IncomeExpense['income'];

const expense = await db.knex!.raw(
const expense = (await db.knex!.raw(
`
select sum(cast(debit as real) - cast(credit as real)) as balance, strftime('%Y-%m', date) as yearmonth
from AccountingLedgerEntry
Expand All @@ -116,20 +123,20 @@ export class BespokeQueries {
)
group by yearmonth`,
[fromDate, toDate]
);
)) as IncomeExpense['expense'];

return { income, expense };
}

static async getTotalCreditAndDebit(db: DatabaseCore) {
return await db.knex!.raw(`
return (await db.knex!.raw(`
select
account,
sum(cast(credit as real)) as totalCredit,
sum(cast(debit as real)) as totalDebit
from AccountingLedgerEntry
group by account
`);
`)) as unknown as TotalCreditAndDebit;
}

static async getStockQuantity(
Expand All @@ -141,6 +148,7 @@ export class BespokeQueries {
batch?: string,
serialNumbers?: string[]
): Promise<number | null> {
/* eslint-disable @typescript-eslint/no-floating-promises */
const query = db.knex!(ModelNameEnum.StockLedgerEntry)
.sum('quantity')
.where('item', item);
Expand Down
Loading

0 comments on commit 5f2cef7

Please sign in to comment.