Skip to content

Commit

Permalink
Deps update, ESLint flat config. Siegel config update
Browse files Browse the repository at this point in the history
  • Loading branch information
CyberCookie committed Oct 7, 2024
1 parent e61813a commit ef39b08
Show file tree
Hide file tree
Showing 82 changed files with 1,893 additions and 1,606 deletions.
98 changes: 0 additions & 98 deletions .eslintrc

This file was deleted.

12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ npm i siegel

Create **app.js** file:<br />

```js
```ts
import { createRoot } from 'react-dom/client'

const root = document.getElementById('root')
Expand All @@ -105,7 +105,7 @@ Now your application is hosting on **localhost:3000** in watch mode and ready fo
You may also define **NodeJS dev server** using `--server` flag:


```js
```ts
// server.js

function appServer(app, { express }) {
Expand Down Expand Up @@ -139,7 +139,7 @@ Run `npx siegel` To get list of Siegel CLI commands
</p><br />


```js
```ts
import siegel from 'siegel'

siegel(config, runParams)
Expand All @@ -150,7 +150,7 @@ siegel(config, runParams)

Or just pass an entry point to __react app__ and it will do everything else for you:

```js
```ts
import siegel from 'siegel'

siegel('/path/to/js_entry.ts')
Expand All @@ -166,7 +166,7 @@ siegel('/path/to/js_entry.ts')
[Build configuration](https://github.com/CyberCookie/siegel/tree/master/core/client_build)<br />
[Server configuration](https://github.com/CyberCookie/siegel/tree/master/core/server)

```js
```ts
{
/*
Affects both server(as public dir to be served),
Expand All @@ -189,7 +189,7 @@ siegel('/path/to/js_entry.ts')

<br />

```js
```ts
{
/* Run static server. Default is true */
isServer: Boolean,
Expand Down
22 changes: 7 additions & 15 deletions bin/init_project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ function main(isGlobal?: boolean) {
const INIT_PATHS = {
pathToSiegelRelative,
pathToSiegelAbsolute,
siegelEsLint: join(isGlobal ? pathToSiegelAbsolute : pathToSiegelRelative, LOC_NAMES.ESLINT_JSON),
siegelDemoAppServerPath: join(PATHS.demoProject, INIT_LOC_NAMES.DEMO_APP_SERVER_DIR_NAME),
siegelDemoAppPathShift: relative(PATHS.demoProject, PATHS.packageRoot),
siegelLibPath: join(pathToSiegelRelative, LOC_NAMES.LIB_OUTPUT_DIRNAME),
Expand All @@ -61,7 +60,7 @@ function main(isGlobal?: boolean) {
userServerTSConfigPath: join(userServerPath, LOC_NAMES.TS_JSON),
userTSConfigPath: join(PATHS.cwd, LOC_NAMES.TS_JSON),
userTSGlobal: join(PATHS.cwd, LOC_NAMES.TS_GLOBAL_TYPES),
userESLint: join(PATHS.cwd, LOC_NAMES.ESLINT_JSON),
userESLint: join(PATHS.cwd, LOC_NAMES.ESLINT_CONFIG_JS),
userPackageJson: join(PATHS.cwd, LOC_NAMES.PACKAGE_JSON),

cwdRelativeUserServer: relative(PATHS.cwd, userServerEntryPath)
Expand All @@ -79,12 +78,8 @@ function main(isGlobal?: boolean) {
) + '/global'
writeFileSync(INIT_PATHS.userTSGlobal, `import '${pathToSiegelGlobalTs}'`)

// Copy Eslint jsons
// shell(`cp ${ PATHS.packageRoot }/{${ LOC_NAMES.ESLINT_JSON },${ LOC_NAMES.TS_ESLINT_JSON }} .`)

// Render doesn't support cp syntax above
shell(`cp ${ PATHS.packageRoot }/${ LOC_NAMES.ESLINT_JSON } .`)
shell(`cp ${ PATHS.packageRoot }/${ LOC_NAMES.TS_ESLINT_JSON } .`)
shell(`cp ${ PATHS.packageRoot }/${ LOC_NAMES.ESLINT_CONFIG_JS } .`)
}


Expand Down Expand Up @@ -149,17 +144,14 @@ function main(isGlobal?: boolean) {


function modifyESLintConfig() {
const ESLintConfig = requireJSON(INIT_PATHS.userESLint)
const ESLintConfig = readFileSync(INIT_PATHS.userESLint, 'utf-8')

ESLintConfig.extends.push(
INIT_PATHS.siegelEsLint[0] == '.' || isGlobal
? INIT_PATHS.siegelEsLint
: `./${INIT_PATHS.siegelEsLint}`
const ESLintConfigModified = ESLintConfig.replace(
INIT_PATHS.siegelDemoAppPathShift,
siegelPackageName
)
ESLintConfig.ignorePatterns.pop()
ESLintConfig.rules = {}

writeFileSync(INIT_PATHS.userESLint, toJSON(ESLintConfig))
writeFileSync(INIT_PATHS.userESLint, ESLintConfigModified)
}


Expand Down
14 changes: 7 additions & 7 deletions client_core/network/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

<br />

```js
```ts
import setupRequest, { HEADERS, CONTENT_TYPE } from 'siegel/lib/client_core/network/request'

const request = setupRequest(config: ReqSetup)
Expand Down Expand Up @@ -81,11 +81,11 @@ Receives **1** argument - **Object** wit the next fields:

Returns **String**. Processed request json string

- `jsonParsePreprocess` - **Function**. For every request Pre process responce string before being parsed to object as json string<br />
- `jsonParsePreprocess` - **Function**. For every request Pre process response string before being parsed to object as json string<br />
Has **1** argument:
- **jsonString** - **String**. Responce json string

Returns **String**. Processed responce json string
Returns **String**. Processed response json string

- `preventSame` - **Boolean**.
Prevents request if the same request is already processing<br />
Expand Down Expand Up @@ -131,9 +131,9 @@ Content-type header values used in **request**.
- `headers` - **Object** where _key_ is header ID and _value_ is header value<br />
Request headers

- `onSuccess` - Successful responce callback<br />
- `onSuccess` - Successful response callback<br />

- `onError` - Error responce callback<br />
- `onError` - Error response callback<br />

- `isFullRes` - **Boolean** Default is **false**<br />
Returns full response with headers, status code etc
Expand All @@ -153,7 +153,7 @@ Content-type header values used in **request**.

- `jsonStringifyPostprocess` - Post process json string before request occurs

- `jsonParsePreprocess` - Pre process responce string before being parsed to object as json string
- `jsonParsePreprocess` - Pre process response string before being parsed to object as json string

- `preventSame` - **Boolean**<br />
For this request prevents request if the same request is already processing
Expand All @@ -171,7 +171,7 @@ Content-type header values used in **request**.

<br />

```js
```ts
import createSocket from 'siegel/lib/client_core/network/socket'

const socket = createSocket({
Expand Down
16 changes: 8 additions & 8 deletions client_core/network/request/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ type ReqError = {
/** Request data */
req: ReqData

/** Error responce message */
/** Error response message */
message?: string

/** Error responce code */
/** Error response code */
status?: number

/** Responce data */
Expand Down Expand Up @@ -70,9 +70,9 @@ type RequestParams<_Body = any, _Res = any> = {
jsonStringifyPostprocess?(json: string): string

/**
* Pre process responce string before being parsed to object as json string
* Pre process response string before being parsed to object as json string
*
* @param json - responce json string
* @param json - response json string
*/
jsonParsePreprocess?(json: string): string

Expand All @@ -87,10 +87,10 @@ type RequestParams<_Body = any, _Res = any> = {
*/
beforeRequest?: NonNullable<SetupParams['beforeRequest']>

/** Successful responce callback */
/** Successful response callback */
onSuccess?: (res: _Res) => void

/** Error responce callback */
/** Error response callback */
onError?: (err: ReqError) => void
}

Expand All @@ -115,7 +115,7 @@ type SetupParams = {
* Triggered after successful request was made
*
* @param reqData - fetch api request params
* @param parsedRes - parsed responce
* @param parsedRes - parsed response
*/
afterRequest?(reqData: ReqData, parsedRes: any): void

Expand All @@ -132,7 +132,7 @@ type SetupParams = {
/** For every request post process json string before request occurs */
jsonStringifyPostprocess?: RequestParams['jsonStringifyPostprocess']

/** For every request Pre process responce string before being parsed to object as json string */
/** For every request Pre process response string before being parsed to object as json string */
jsonParsePreprocess?: RequestParams['jsonParsePreprocess']

/** Prevents request if the same request is already processing */
Expand Down
8 changes: 4 additions & 4 deletions client_core/router/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ And one more thing - we add restricted admin page with URL *www.somesite.com/adm

Config:

```js
```ts
const routesConfig = {
'': {
Page: () => <div>home page</div>
Expand Down Expand Up @@ -125,7 +125,7 @@ You may define page to be rendered if required page URL does not exists in your
To do so, first we need to define 404 page itself with it's own route.<br />
Then we need to define redirect from any page to the 404 page:

```js
```ts
const routerConfig = {
'': {
Page: () => <div>home page</div>
Expand Down Expand Up @@ -194,7 +194,7 @@ but with another few props:
- `activeClassName` - **String**. Defines className for this link tag if it points to currently active URL
- `onCLick` - Link click handler, that may prevent default click handler

```js
```ts
import A from 'siegel/lib/client_core/router/Link'

const link = <A href='/contacts' activeClassName='link_active' />
Expand All @@ -208,7 +208,7 @@ This component can be themed with help of `withDefaults` function as other UI co

Another example with all the features included:

```js
```ts
import React, { lazy } from 'react'
import { render } from 'react-dom'
import Router from 'siegel/lib/client_core/router'
Expand Down
4 changes: 2 additions & 2 deletions client_core/store/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Store creator receives **2** parameters:
- `actions` - **Object**. Store actions, where _key_ is action name and _value_ is action **Function**


```js
```ts
import React, { useLayoutEffect } from 'react'
import createStore from 'siegel/lib/client_core/store'

Expand Down Expand Up @@ -74,7 +74,7 @@ Also your state is populates with `__updated` property which increments every ti
The counter resets to zero when no subscribed components left<br />
It can help you to avoid unnecessary renders in combinations with such hooks as useMemo or useDidUpdate

```js
```ts
import React, { useMemo } from 'react'
import createStore from 'siegel/lib/client_core/store'
import useDidUpdate from 'siegel/lib/client_core/hooks/did_update'
Expand Down
4 changes: 2 additions & 2 deletions client_core/store/fetch_module/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
Hook store provides `fetch module` which is usefull to track requests status


```js
```ts
import { setup } from 'siegel/lib/client_core/network/request'
import fetchModule from 'siegel/lib/client_core/store/fetch_module'

Expand All @@ -29,7 +29,7 @@ setup({

```

```js
```ts
import React from 'react'
import fetchModule, { reset } from 'siegel/lib/client_core/store/fetch_module'

Expand Down
Loading

0 comments on commit ef39b08

Please sign in to comment.