Skip to content
Snippets Groups Projects
Unverified Commit f41763b0 authored by Matiss Janis Aboltins's avatar Matiss Janis Aboltins Committed by GitHub
Browse files

:fire: remove unused scripts; simplify version script (#1227)

1. Removed some more unused scripts
2. Simplified the way we build `version` in to the source
parent 59a1c38d
No related branches found
No related tags found
No related merge requests found
...@@ -3,16 +3,13 @@ ...@@ -3,16 +3,13 @@
ROOT=`dirname $0` ROOT=`dirname $0`
cd "$ROOT/.." cd "$ROOT/.."
VERSION=`cat "$ROOT/../../desktop-client/package.json" | grep version | head -n1 | awk -F "\"" '{print $4}' | tr -d '\r\n'` echo "Building the browser..."
echo "Building version $VERSION for the browser..."
rm -fr build rm -fr build
export IS_GENERIC_BROWSER=1 export IS_GENERIC_BROWSER=1
export INLINE_RUNTIME_CHUNK=false export INLINE_RUNTIME_CHUNK=false
export REACT_APP_BACKEND_WORKER_HASH=`ls "$ROOT"/../public/kcab/kcab.worker.*.js | sed 's/.*kcab\.worker\.\(.*\)\.js/\1/'` export REACT_APP_BACKEND_WORKER_HASH=`ls "$ROOT"/../public/kcab/kcab.worker.*.js | sed 's/.*kcab\.worker\.\(.*\)\.js/\1/'`
export REACT_APP_ACTUAL_VERSION="$VERSION"
yarn build yarn build
......
...@@ -3,11 +3,8 @@ ...@@ -3,11 +3,8 @@
ROOT=`dirname $0` ROOT=`dirname $0`
cd "$ROOT/.." cd "$ROOT/.."
VERSION=`cat "$ROOT/../../desktop-client/package.json" | grep version | head -n1 | awk -F "\"" '{print $4}' | tr -d '\r\n'`
export IS_GENERIC_BROWSER=1 export IS_GENERIC_BROWSER=1
export PORT=3001 export PORT=3001
export REACT_APP_BACKEND_WORKER_HASH="dev" export REACT_APP_BACKEND_WORKER_HASH="dev"
export REACT_APP_ACTUAL_VERSION="$VERSION"
yarn start yarn start
import { initBackend as initSQLBackend } from 'absurd-sql/dist/indexeddb-main-thread'; import { initBackend as initSQLBackend } from 'absurd-sql/dist/indexeddb-main-thread';
import packageJson from '../package.json';
const backendWorkerUrl = new URL('./browser-server.js', import.meta.url); const backendWorkerUrl = new URL('./browser-server.js', import.meta.url);
// This file installs global variables that the app expects. // This file installs global variables that the app expects.
...@@ -8,7 +10,7 @@ const backendWorkerUrl = new URL('./browser-server.js', import.meta.url); ...@@ -8,7 +10,7 @@ const backendWorkerUrl = new URL('./browser-server.js', import.meta.url);
// everything else. // everything else.
let IS_DEV = process.env.NODE_ENV === 'development'; let IS_DEV = process.env.NODE_ENV === 'development';
let ACTUAL_VERSION = process.env.REACT_APP_ACTUAL_VERSION; let ACTUAL_VERSION = packageJson.version;
// *** Start the backend *** // *** Start the backend ***
let worker; let worker;
......
#!/usr/bin/env ./cli-runner.js
process.env.LOOT_DATA_DIR = __dirname + '/../../../../data';
import * as sqlite from '../platform/server/sqlite';
import * as db from '../server/db';
import { getMessages } from '../server/sync';
let dbPath = process.argv[2];
let tables = [
'spreadsheet_cells',
'accounts',
'transactions',
'categories',
'category_groups',
'category_mapping',
'payees',
'payee_rules',
'payee_mapping'
];
async function init() {
db.setDatabase(sqlite.openDatabase(dbPath));
let schema = {};
for (let table of tables) {
let fields = await db.all(`PRAGMA table_info(${table})`);
schema[table] = {};
for (let field of fields) {
schema[table][field.name] = field.type.toLowerCase();
}
}
console.log(schema);
}
init();
#!/usr/bin/env actual-cli-runner.js
require('../src/server/migrate/cli');
#!/usr/bin/env actual-cli-runner.js
import fs from 'fs';
import os from 'os';
import * as asyncStorage from '../src/platform/server/asyncStorage';
import * as sqlite from '../src/platform/server/sqlite';
import { runQuery } from '../src/server/aql';
import * as db from '../src/server/db';
import { batchMessages, setSyncingMode } from '../src/server/sync';
import q from '../src/shared/query';
import { makeChild } from '../src/shared/transactions';
let dbPath = process.argv[3];
if (dbPath == null || dbPath === '') {
console.log('db path is required');
process.exit(1);
}
function pad(n) {
return n < 10 ? '0' + n : n;
}
async function init() {
asyncStorage.init();
setSyncingMode('disabled');
let tempPath = os.tmpdir() + '/db-profile.sql';
fs.copyFileSync(dbPath, tempPath);
db.setDatabase(sqlite.openDatabase(tempPath));
let accounts = await db.getAccounts();
await batchMessages(() => {
for (let i = 0; i < 100; i++) {
if (Math.random() < 0.02) {
let parent = {
date: '2020-01-' + pad(Math.floor(Math.random() * 30)),
amount: Math.floor(Math.random() * 10000),
account: accounts[0].id,
notes: 'foo',
};
db.insertTransaction(parent);
db.insertTransaction(
makeChild(parent, {
amount: Math.floor(Math.random() * 1000),
}),
);
db.insertTransaction(
makeChild(parent, {
amount: Math.floor(Math.random() * 1000),
}),
);
db.insertTransaction(
makeChild(parent, {
amount: Math.floor(Math.random() * 1000),
}),
);
} else {
db.insertTransaction({
date: '2020-01-' + pad(Math.floor(Math.random() * 30)),
amount: Math.floor(Math.random() * 10000),
account: accounts[0].id,
});
}
}
});
// full: 12647
// paged: 431
await db.execQuery('SELECT * FROM transactions');
await db.execQuery('SELECT * FROM transactions');
await db.execQuery('SELECT * FROM transactions');
await db.execQuery('SELECT * FROM transactions');
await db.execQuery('SELECT * FROM transactions');
await db.execQuery('SELECT * FROM transactions');
await db.execQuery('SELECT * FROM transactions');
await db.execQuery('SELECT * FROM transactions');
// await db.execQuery('PRAGMA journal_mode = WAL');
// console.log(
// await db.all(
// 'SELECT * FROM v_transactions_layer2 WHERE v_transactions_layer2.account = "foo"'
// )
// );
console.log('starting');
let s = Date.now();
let { data } = await runQuery(
q('transactions').select('*').options({ splits: 'grouped' }).serialize(),
);
console.log('# items:', data.length);
console.log('time:', Date.now() - s);
// for (let i = 0; i < accounts.length; i++) {
// let s = Date.now();
// // let data = await runQuery(
// // q('transactions')
// // .filter({ account: accounts[i].id })
// // .calculate({ $sum: '$amount' })
// // .serialize()
// // );
// let rows = db.runQuery(
// `SELECT SUM(amount) as total FROM v_transactions_layer2 WHERE account = "${accounts[i].id}"`,
// [],
// true
// );
// console.log('Total:', rows[0]);
// console.log('Time:', Date.now() - s);
// }
// console.log(data);
}
init();
#!/usr/bin/env actual-cli-runner.js
const { schema } = require('../src/server/aql');
const table = process.argv[3];
if (table == null || table === 'transactions') {
let fields = Object.keys(schema.transactions).map(fieldName => {
let desc = schema.transactions[fieldName];
let field = `t.${desc.name || fieldName}`;
if (field === 't.description') {
field = 'pm.targetId';
} else if (field === 't.category') {
field = 'cm.transferId';
}
return `${field} AS ${fieldName}`;
});
console.log(`
DROP VIEW IF EXISTS v_transactions;
CREATE VIEW v_transactions AS
SELECT ${fields.join(', ')} FROM transactions t
LEFT JOIN category_mapping cm ON cm.id = t.category
LEFT JOIN payee_mapping pm ON pm.id = t.description
`);
}
---
category: Maintenance
authors: [MatissJanis]
---
Remove unused build scripts and simplify how we build version number
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment