Skip to content

Commit

Permalink
fix mini proj init script
Browse files Browse the repository at this point in the history
  • Loading branch information
CyberCookie committed Nov 19, 2024
1 parent 9f3fefb commit 03c2779
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 10 deletions.
31 changes: 23 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ npm i siegel

<br />

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

```ts
import { createRoot } from 'react-dom/client'
Expand All @@ -106,24 +106,39 @@ You may also define **NodeJS dev server** using `--server` flag:


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

function appServer(app, { express }) {
console.log('Custom server is ready')
import type { ServerExtenderFn, ExpressExtenderParams } from '../core'

const appServer: ServerExtenderFn = params => {
const { express, staticServer } = params as ExpressExtenderParams

staticServer
.use(express.json())
}

module.exports = appServer
export default appServer
```

<br />

To bootstrap the app with server defined - run the next command:

```sh
npx siegel run --server server.ts
```

In console run:
<br />

Siegel provides a command to initialize mini project along with `server` and `app` files we created above:<br />

```sh
npx siegel run --server server.js
npx siegel init -s
```

<br />

Run `npx siegel` To get list of Siegel CLI commands
To list all the available Siegel CLI commands and flags: `npx siegel`

<br /><br />

Expand Down
2 changes: 1 addition & 1 deletion bin/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ const COMMANDS_TREE: CommanTree = {
},
{
flagLong: '--mini-serv',
flag: '-ms',
flag: '-s',
defaultValue: false,
description: 'Creates mini zero-config react TS project with preconfigured TS express server',
paramAction({ result }) {
Expand Down
4 changes: 3 additions & 1 deletion bin/init_minimal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,9 @@ function init(isMiniServ: boolean) {
path.relative(PATHS.cwd, PATHS.binOutput)
)
.replace(`${LOC_NAMES.DEMO_MINI_APP_DIR_NAME}/`, '')
.replace(/\s--c.*$/g, '')
.replace(/\s--c.*$/g, ''),

Check warning on line 99 in bin/init_minimal.ts

View workflow job for this annotation

GitHub Actions / build (18.x)

Trailing spaces not allowed

Check warning on line 99 in bin/init_minimal.ts

View workflow job for this annotation

GitHub Actions / build (20.x)

Trailing spaces not allowed

Check warning on line 99 in bin/init_minimal.ts

View workflow job for this annotation

GitHub Actions / build (22.x)

Trailing spaces not allowed
start_client: 'npx siegel run'
}

fs.writeFileSync(INIT_PATHS.userPackageJson, JSON.stringify(clientPackageJson, null, 4))
Expand Down
3 changes: 3 additions & 0 deletions bin/init_project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ function main(isGlobal?: boolean) {
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),
siegelTSConfigPath: join(PATHS.packageRoot, LOC_NAMES.TS_JSON),

userServerEntryPath,
userServerExtenderPath: join(userServerPath, INIT_LOC_NAMES.DEMO_APP_SERVER_EXTENDER),
Expand Down Expand Up @@ -113,6 +114,8 @@ function main(isGlobal?: boolean) {
INIT_PATHS.pathToSiegelRelative
)

clientTSConfig.compilerOptions.plugins = requireJSON(INIT_PATHS.siegelTSConfigPath).compilerOptions.plugins

const paths = clientTSConfig.compilerOptions.paths
for (const alias in paths) {
paths[alias][0] = paths[alias][0].replace(
Expand Down

0 comments on commit 03c2779

Please sign in to comment.