diff --git a/.github/workflows/lint.js.yml b/.github/workflows/lint.js.yml index a734606..5542ba2 100644 --- a/.github/workflows/lint.js.yml +++ b/.github/workflows/lint.js.yml @@ -14,6 +14,7 @@ jobs: runs-on: ubuntu-latest env: CI: true + NPM_GITHUB_TOKEN: ${{ secrets.NPM_GITHUB_PAT }} strategy: matrix: @@ -21,10 +22,10 @@ jobs: # See supported Node.js release schedule at https://nodejs.org/en/about/releases/ steps: - - uses: actions/checkout@v2 - - name: Use Node.js ${{ matrix.node-version }} - uses: actions/setup-node@v1 - with: - node-version: ${{ matrix.node-version }} - - run: npm i - - run: npm run lint + - uses: actions/checkout@v2 + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v1 + with: + node-version: ${{ matrix.node-version }} + - run: npm ci + - run: npm run lint diff --git a/.npmrc b/.npmrc new file mode 100644 index 0000000..5d3c963 --- /dev/null +++ b/.npmrc @@ -0,0 +1,2 @@ +@speedy-tuner:registry=https://npm.pkg.github.com +//npm.pkg.github.com/:_authToken=${NPM_GITHUB_TOKEN} diff --git a/README.md b/README.md index 8142bc6..244a6d1 100644 --- a/README.md +++ b/README.md @@ -38,10 +38,18 @@ There are many ways in which you can participate in the project and every bit of ## Development -Recommended dev environment: +### Recommended dev environment - [Node](https://nodejs.org/) 16.x.x +### Authenticate to GitHub Packages + +Project uses shared packages (`@speedy-tuner/...`). + +They are hosted using `GitHub Packages`, to install them you need to [authenticate to GitHub Packages](https://docs.github.com/en/packages/working-with-a-github-packages-registry/working-with-the-npm-registry#authenticating-to-github-packages) first. + +### Install and run + ```bash # install packages npm install diff --git a/package-lock.json b/package-lock.json index 317dbc1..d300e2a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -12,10 +12,11 @@ "@reduxjs/toolkit": "^1.6.1", "@sentry/react": "^6.13.2", "@sentry/tracing": "^6.13.2", + "@speedy-tuner/types": "^0.1.1", "antd": "^4.16.13", "electron-squirrel-startup": "^1.0.0", "js-yaml": "^4.1.0 ", - "mlg-converter": "^0.5.0", + "mlg-converter": "^0.5.1", "pako": "^2.0.4", "parsimmon": "^1.18.0", "react": "^17.0.1", @@ -50,6 +51,7 @@ "eslint-config-airbnb": "^18.2.1", "eslint-config-airbnb-base": "^14.2.1", "eslint-config-prettier": "^8.3.0", + "eslint-import-resolver-typescript": "^2.5.0", "eslint-plugin-import": "^2.24.2", "eslint-plugin-jsx-a11y": "^6.4.1", "eslint-plugin-modules-newline": "^0.0.6", @@ -3435,6 +3437,12 @@ "@sinonjs/commons": "^1.7.0" } }, + "node_modules/@speedy-tuner/types": { + "version": "0.1.1", + "resolved": "https://npm.pkg.github.com/download/@speedy-tuner/types/0.1.1/fc3f3f3bfd51904c40688b8a3a93c3c9b4f3bb982886558bdbed00fa51bbc7dc", + "integrity": "sha512-2GDG6iL0/Eo7Wt3P4labAqxakHkK1QxVuMFBy82f5WOWtsR0dOgZHyotPV6wueRPLo3qzdHrcxPpSdgwszc6Fw==", + "license": "MIT" + }, "node_modules/@surma/rollup-plugin-off-main-thread": { "version": "1.4.2", "resolved": "https://registry.npmjs.org/@surma/rollup-plugin-off-main-thread/-/rollup-plugin-off-main-thread-1.4.2.tgz", @@ -9864,6 +9872,26 @@ "ms": "^2.1.1" } }, + "node_modules/eslint-import-resolver-typescript": { + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/eslint-import-resolver-typescript/-/eslint-import-resolver-typescript-2.5.0.tgz", + "integrity": "sha512-qZ6e5CFr+I7K4VVhQu3M/9xGv9/YmwsEXrsm3nimw8vWaVHRDrQRp26BgCypTxBp3vUp4o5aVEJRiy0F2DFddQ==", + "dev": true, + "dependencies": { + "debug": "^4.3.1", + "glob": "^7.1.7", + "is-glob": "^4.0.1", + "resolve": "^1.20.0", + "tsconfig-paths": "^3.9.0" + }, + "engines": { + "node": ">=4" + }, + "peerDependencies": { + "eslint": "*", + "eslint-plugin-import": "*" + } + }, "node_modules/eslint-module-utils": { "version": "2.6.2", "resolved": "https://registry.npmjs.org/eslint-module-utils/-/eslint-module-utils-2.6.2.tgz", @@ -16613,9 +16641,9 @@ } }, "node_modules/mlg-converter": { - "version": "0.5.0", - "resolved": "https://registry.npmjs.org/mlg-converter/-/mlg-converter-0.5.0.tgz", - "integrity": "sha512-FKqJ0vbbxFZuziwMbih8fRF8JFF2xFSWmYNOylji1IkRPu83dCWCGV4AkG9fkKs/z9ThOqfuSkaUEnWbL33c8g==" + "version": "0.5.1", + "resolved": "https://registry.npmjs.org/mlg-converter/-/mlg-converter-0.5.1.tgz", + "integrity": "sha512-t9jvCRmOpGLKBPHaSjnJt+83rBicWVV7qHLDtZ0M651zl8IMrOJ9jPp8W5zGqukKP5sOgxYWbgejIBSdJ1SAXQ==" }, "node_modules/moment": { "version": "2.29.1", @@ -29856,6 +29884,11 @@ "@sinonjs/commons": "^1.7.0" } }, + "@speedy-tuner/types": { + "version": "0.1.1", + "resolved": "https://npm.pkg.github.com/download/@speedy-tuner/types/0.1.1/fc3f3f3bfd51904c40688b8a3a93c3c9b4f3bb982886558bdbed00fa51bbc7dc", + "integrity": "sha512-2GDG6iL0/Eo7Wt3P4labAqxakHkK1QxVuMFBy82f5WOWtsR0dOgZHyotPV6wueRPLo3qzdHrcxPpSdgwszc6Fw==" + }, "@surma/rollup-plugin-off-main-thread": { "version": "1.4.2", "resolved": "https://registry.npmjs.org/@surma/rollup-plugin-off-main-thread/-/rollup-plugin-off-main-thread-1.4.2.tgz", @@ -34976,6 +35009,19 @@ } } }, + "eslint-import-resolver-typescript": { + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/eslint-import-resolver-typescript/-/eslint-import-resolver-typescript-2.5.0.tgz", + "integrity": "sha512-qZ6e5CFr+I7K4VVhQu3M/9xGv9/YmwsEXrsm3nimw8vWaVHRDrQRp26BgCypTxBp3vUp4o5aVEJRiy0F2DFddQ==", + "dev": true, + "requires": { + "debug": "^4.3.1", + "glob": "^7.1.7", + "is-glob": "^4.0.1", + "resolve": "^1.20.0", + "tsconfig-paths": "^3.9.0" + } + }, "eslint-module-utils": { "version": "2.6.2", "resolved": "https://registry.npmjs.org/eslint-module-utils/-/eslint-module-utils-2.6.2.tgz", @@ -40110,9 +40156,9 @@ } }, "mlg-converter": { - "version": "0.5.0", - "resolved": "https://registry.npmjs.org/mlg-converter/-/mlg-converter-0.5.0.tgz", - "integrity": "sha512-FKqJ0vbbxFZuziwMbih8fRF8JFF2xFSWmYNOylji1IkRPu83dCWCGV4AkG9fkKs/z9ThOqfuSkaUEnWbL33c8g==" + "version": "0.5.1", + "resolved": "https://registry.npmjs.org/mlg-converter/-/mlg-converter-0.5.1.tgz", + "integrity": "sha512-t9jvCRmOpGLKBPHaSjnJt+83rBicWVV7qHLDtZ0M651zl8IMrOJ9jPp8W5zGqukKP5sOgxYWbgejIBSdJ1SAXQ==" }, "moment": { "version": "2.29.1", diff --git a/package.json b/package.json index b8479ad..30f5be6 100644 --- a/package.json +++ b/package.json @@ -5,6 +5,10 @@ "private": true, "license": "MIT", "homepage": "./", + "repository": { + "type": "git", + "url": "https://github.com/speedy-tuner/speedy-tuner-cloud" + }, "main": "src/electron.js", "scripts": { "start": "craco start", @@ -37,10 +41,11 @@ "@reduxjs/toolkit": "^1.6.1", "@sentry/react": "^6.13.2", "@sentry/tracing": "^6.13.2", + "@speedy-tuner/types": "^0.1.1", "antd": "^4.16.13", "electron-squirrel-startup": "^1.0.0", "js-yaml": "^4.1.0 ", - "mlg-converter": "^0.5.0", + "mlg-converter": "^0.5.1", "pako": "^2.0.4", "parsimmon": "^1.18.0", "react": "^17.0.1", @@ -60,8 +65,6 @@ "@electron-forge/maker-rpm": "^6.0.0-beta.61", "@electron-forge/maker-squirrel": "^6.0.0-beta.61", "@electron-forge/maker-zip": "^6.0.0-beta.61", - "@typescript-eslint/eslint-plugin": "^4.31.0", - "@typescript-eslint/parser": "^4.31.0", "@types/js-yaml": "^4.0.3", "@types/node": "^16.9.6", "@types/pako": "^1.0.2", @@ -70,11 +73,14 @@ "@types/react-dom": "^17.0.9", "@types/react-redux": "^7.1.18", "@types/react-router-dom": "^5.3.0", + "@typescript-eslint/eslint-plugin": "^4.31.0", + "@typescript-eslint/parser": "^4.31.0", "electron": "^15.0.0", "eslint": "^7.32.0", "eslint-config-airbnb": "^18.2.1", "eslint-config-airbnb-base": "^14.2.1", "eslint-config-prettier": "^8.3.0", + "eslint-import-resolver-typescript": "^2.5.0", "eslint-plugin-import": "^2.24.2", "eslint-plugin-jsx-a11y": "^6.4.1", "eslint-plugin-modules-newline": "^0.0.6", diff --git a/src/App.tsx b/src/App.tsx index 79fb636..c1ab695 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -16,13 +16,14 @@ import { useEffect, useMemo, } from 'react'; -import Dialog from './components/Dialog'; -import { loadAll } from './utils/api'; -import SideBar, { DialogMatchedPathType } from './components/SideBar'; import { AppState, UIState, -} from './types/state'; + Config as ConfigType, +} from '@speedy-tuner/types'; +import Dialog from './components/Dialog'; +import { loadAll } from './utils/api'; +import SideBar, { DialogMatchedPathType } from './components/SideBar'; import BurnButton from './components/BurnButton'; import TopBar from './components/TopBar'; import StatusBar from './components/StatusBar'; @@ -30,7 +31,6 @@ import { isDesktop } from './utils/env'; import 'react-perfect-scrollbar/dist/css/styles.css'; import './App.less'; import { Routes } from './routes'; -import { Config as ConfigType } from './types/config'; import Log from './components/Log'; import useStorage from './hooks/useStorage'; import useConfig from './hooks/useConfig'; diff --git a/src/components/Dialog.tsx b/src/components/Dialog.tsx index d51af50..3d300d7 100644 --- a/src/components/Dialog.tsx +++ b/src/components/Dialog.tsx @@ -11,12 +11,8 @@ import { Result, } from 'antd'; import { QuestionCircleOutlined } from '@ant-design/icons'; -import { AppState } from '../types/state'; -import SmartSelect from './Dialog/SmartSelect'; -import SmartNumber from './Dialog/SmartNumber'; -import TextField from './Dialog/TextField'; -import Curve from './Dialog/Curve'; import { + AppState, Dialogs as DialogsType, Dialog as DialogType, Config as ConfigType, @@ -25,8 +21,12 @@ import { Table as TableType, ScalarConstant as ScalarConstantType, ConstantTypes, -} from '../types/config'; -import { Tune as TuneType } from '../types/tune'; + Tune as TuneType, +} from '@speedy-tuner/types'; +import SmartSelect from './Dialog/SmartSelect'; +import SmartNumber from './Dialog/SmartNumber'; +import TextField from './Dialog/TextField'; +import Curve from './Dialog/Curve'; import { parseXy, parseZ, diff --git a/src/components/Dialog/SmartSelect.tsx b/src/components/Dialog/SmartSelect.tsx index afe3944..ec960d8 100644 --- a/src/components/Dialog/SmartSelect.tsx +++ b/src/components/Dialog/SmartSelect.tsx @@ -7,7 +7,7 @@ import { CheckOutlined, CloseOutlined, } from '@ant-design/icons'; -import { Switches } from '../../types/config'; +import { Switches } from '@speedy-tuner/types'; const SmartSelect = ({ values, diff --git a/src/components/Log.tsx b/src/components/Log.tsx index a2a785a..1fcd04d 100644 --- a/src/components/Log.tsx +++ b/src/components/Log.tsx @@ -33,19 +33,17 @@ import { import PerfectScrollbar from 'react-perfect-scrollbar'; // eslint-disable-next-line import/no-unresolved import MlgParserWorker from 'worker-loader!../workers/mlgParser.worker'; +import { + AppState, + UIState, + Config, + OutputChannel, +} from '@speedy-tuner/types'; import { loadLogs } from '../utils/api'; import Canvas, { LogEntry, SelectedField, } from './Log/Canvas'; -import { - AppState, - UIState, -} from '../types/state'; -import { - Config, - OutputChannel, -} from '../types/config'; import store from '../store'; import { formatBytes, diff --git a/src/components/SideBar.tsx b/src/components/SideBar.tsx index 2cb06cb..c3e8f4d 100644 --- a/src/components/SideBar.tsx +++ b/src/components/SideBar.tsx @@ -10,16 +10,14 @@ import { } from 'react-router-dom'; import PerfectScrollbar from 'react-perfect-scrollbar'; import { useCallback } from 'react'; -import store from '../store'; -import { - AppState, - UIState, -} from '../types/state'; import { Config as ConfigType, Menus as MenusType, -} from '../types/config'; -import { Tune as TuneType } from '../types/tune'; + AppState, + UIState, + Tune as TuneType, +} from '@speedy-tuner/types'; +import store from '../store'; import Icon from './SideBar/Icon'; import { evaluateExpression } from '../utils/tune/expression'; import { Routes } from '../routes'; diff --git a/src/components/StatusBar.tsx b/src/components/StatusBar.tsx index 5620346..dc1eee0 100644 --- a/src/components/StatusBar.tsx +++ b/src/components/StatusBar.tsx @@ -3,18 +3,18 @@ import { Layout, Space, Row, - Col, + Col, } from 'antd'; import { CarOutlined, - InfoCircleOutlined, + InfoCircleOutlined, } from '@ant-design/icons'; import { connect } from 'react-redux'; import { AppState, ConfigState, - StatusState, -} from '../types/state'; + StatusState, +} from '@speedy-tuner/types'; const { Footer } = Layout; diff --git a/src/data/constants.ts b/src/data/constants.ts index 3d929e4..8525a76 100644 --- a/src/data/constants.ts +++ b/src/data/constants.ts @@ -1,7 +1,7 @@ import { ConstantTypes, ScalarConstant, -} from '../types/config'; +} from '@speedy-tuner/types'; // eslint-disable-next-line import/prefer-default-export export const divider: ScalarConstant = { diff --git a/src/data/help.ts b/src/data/help.ts index 4dab96f..604b63b 100644 --- a/src/data/help.ts +++ b/src/data/help.ts @@ -1,4 +1,4 @@ -import { Help as HelpType } from '../types/config'; +import { Help as HelpType } from '@speedy-tuner/types'; const help: HelpType = { reqFuel: 'The base reference pulse width required to achieve stoichiometric at 100% VE and a manifold absolute pressure (MAP) of 100kPa using current settings.', diff --git a/src/data/standardDialogs.ts b/src/data/standardDialogs.ts index bd98eae..8945930 100644 --- a/src/data/standardDialogs.ts +++ b/src/data/standardDialogs.ts @@ -1,4 +1,4 @@ -import { Dialogs as DialogsType } from '../types/config'; +import { Dialogs as DialogsType } from '@speedy-tuner/types'; const standardDialogs: DialogsType = { std_injection: { diff --git a/src/hooks/useConfig.ts b/src/hooks/useConfig.ts index bad9a91..9162a20 100644 --- a/src/hooks/useConfig.ts +++ b/src/hooks/useConfig.ts @@ -6,7 +6,7 @@ import { OutputChannel, SimpleConstant, DatalogEntry, -} from '../types/config'; +} from '@speedy-tuner/types'; const findConstantOnPage = (config: ConfigType, fieldName: string): Constant => { const foundPage = config diff --git a/src/parser/ini.ts b/src/parser/ini.ts index 5b57026..a34202b 100644 --- a/src/parser/ini.ts +++ b/src/parser/ini.ts @@ -6,7 +6,7 @@ import * as P from 'parsimmon'; import { Config as ConfigType, Constant, -} from '../types/config'; +} from '@speedy-tuner/types'; console.log('------- start --------'); diff --git a/src/store.ts b/src/store.ts index 92d58b1..df8e2cf 100644 --- a/src/store.ts +++ b/src/store.ts @@ -3,9 +3,9 @@ import { configureStore, createAction, - createReducer, + createReducer, } from '@reduxjs/toolkit'; -import * as Types from './types/state'; +import * as Types from '@speedy-tuner/types'; // tune and config const updateTune = createAction('tune/update'); diff --git a/src/types/config.ts b/src/types/config.ts deleted file mode 100644 index 1f055ea..0000000 --- a/src/types/config.ts +++ /dev/null @@ -1,211 +0,0 @@ -export enum Switches { - YES = 'Yes', - NO = 'No', - ON = 'On', - OFF = 'Off', -} - -export interface Field { - title: string; - name: string; - condition?: string; -} - -export interface Panel { - layout: string; - panels?: { - [name: string]: Panel; - }; - fields?: Field[]; - condition?: string; -} - -export interface Dialog { - title: string; - layout: string; - help?: string; - panels: { - [name: string]: Panel; - }; - fields: Field[]; - // TODO: - // settingSelector - // commandButton -} - -export interface Dialogs { - [name: string]: Dialog; -} - -export interface SubMenu { - title: string; - page: number; - condition: string; -} - -export interface Menu { - title: string; - subMenus: { - [name: string]: SubMenu; - }; -} - -export interface Menus { - [name: string]: Menu; -} - -export interface ArrayShape { - columns: number; - rows: number; -} - -export enum ConstantTypes { - SCALAR = 'scalar', - BITS = 'bits', - ARRAY = 'array', - STRING = 'string', -} - -export type ConstantSize = 'U08' | 'S08' | 'U16' | 'S16' | 'U32' | 'S32' | 'S64' | 'F32' | 'ASCII'; - -export interface ScalarConstant { - type: ConstantTypes.SCALAR; - size: ConstantSize; - offset?: number; - units: string; - scale: number | string; - transform: number | string; - min: number | string; - max: number | string; - digits: number; -} - -export interface BitsConstant { - type: ConstantTypes.BITS; - size: ConstantSize; - offset?: number; - address: number[]; - values: string[]; -} - -export interface ArrayConstant { - type: ConstantTypes.ARRAY; - size: ConstantSize; - offset?: number; - shape: ArrayShape; - units: string; - scale: number | string; - transform: number | string; - min: number | string; - max: number | string; - digits: number; -} - -export interface StringConstant { - type: ConstantTypes.SCALAR; - size: ConstantSize; - length: number; -} - -export interface OutputChannel { - type: ConstantTypes.SCALAR | ConstantTypes.BITS; - size: ConstantSize; - offset: number; - units: string; - scale: number | string; - transform: number | string; -} - -export interface SimpleConstant { - value: string; -} - -export type Constant = ScalarConstant | BitsConstant | ArrayConstant | StringConstant; - -export interface Constants { - [name: string]: Constant; -} - -export interface Page { - number: number; - size: number; - data: Constants; -} - -export interface Help { - [key: string]: string; -} - -export interface Curve { - title: string; - labels: string[]; - xAxis: number[]; - yAxis: number[]; - xBins: string[]; - yBins: string[]; - size: number[]; - gauge?: string; -} - -export interface Table { - map: string; - title: string; - page: number; - help?: string; - xBins: string[]; - yBins: string[]; - xyLabels: string[]; - zBins: string[]; - gridHeight: number; - gridOrient: number[]; - upDownLabel: string[]; -} - -export interface OutputChannels { - [name: string]: OutputChannel | SimpleConstant; -} - -export interface DatalogEntry { - name: string; - label: string; - type: 'int' | 'float'; - format: string; - condition: string; -} - -export interface Config { - [key: string]: any; - megaTune: { - [key: string]: any; - signature: string; - MTversion: number; - queryCommand: string; - versionInfo: string; - }; - tunerStudio: { - [key: string]: any; - iniSpecVersion: number; - }; - pcVariables: Constants; - constants: { - pages: Page[]; - }; - defines: { - [name: string]: string[]; - }; - menus: Menus; - help: Help; - dialogs: { - [name: string]: Dialog; - }; - curves: { - [name: string]: Curve; - }; - tables: { - [name: string]: Table; - }; - outputChannels: OutputChannels; - datalog: { - [name: string]: DatalogEntry; - }; -} diff --git a/src/types/state.ts b/src/types/state.ts deleted file mode 100644 index 58f8e63..0000000 --- a/src/types/state.ts +++ /dev/null @@ -1,26 +0,0 @@ -import { Config } from './config'; -import { Tune } from './tune'; - -export interface ConfigState extends Config {} - -export interface TuneState extends Tune {} - -export interface UIState { - sidebarCollapsed: boolean; -} - -export interface StatusState { - text: string | null; -} - -export interface AppState { - tune: TuneState; - config: ConfigState; - ui: UIState; - status: StatusState; -} - -export interface UpdateTunePayload { - name: string; - value: string | number; -} diff --git a/src/types/tune.ts b/src/types/tune.ts deleted file mode 100644 index 1bbe8f3..0000000 --- a/src/types/tune.ts +++ /dev/null @@ -1,12 +0,0 @@ -export interface Constant { - units?: string; - value: string | number; -} - -export interface Constants { - [name: string]: Constant; -} - -export interface Tune { - constants: Constants; -} diff --git a/src/utils/api.ts b/src/utils/api.ts index dacbd2c..fe1d54b 100644 --- a/src/utils/api.ts +++ b/src/utils/api.ts @@ -1,5 +1,5 @@ +import { Config as ConfigType } from '@speedy-tuner/types'; import store from '../store'; -import { Config as ConfigType } from '../types/config'; import stdDialogs from '../data/standardDialogs'; import help from '../data/help'; import { divider } from '../data/constants'; diff --git a/src/utils/tune/expression.ts b/src/utils/tune/expression.ts index e435083..ec5686c 100644 --- a/src/utils/tune/expression.ts +++ b/src/utils/tune/expression.ts @@ -1,11 +1,10 @@ -import { Constants as TuneConstantsType } from '../../types/tune'; - import { Config as ConfigType, OutputChannels as OutputChannelsType, Page as ConfigPageType, SimpleConstant as SimpleConstantType, -} from '../../types/config'; + TuneConstants as TuneConstantsType, +} from '@speedy-tuner/types'; export const isExpression = (val: any) => `${val}`.startsWith('{') && `${val}`.endsWith('}');