Skip to content

Commit

Permalink
🐛 fix(all): update create repo and fix server repo
Browse files Browse the repository at this point in the history
  • Loading branch information
Ángel Albiñana Espejo authored and Ángel Albiñana Espejo committed Aug 30, 2024
1 parent a4856d0 commit c75d136
Show file tree
Hide file tree
Showing 30 changed files with 153 additions and 120 deletions.
14 changes: 7 additions & 7 deletions docs/guide/builder/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,20 +39,20 @@ Using *Backan* `Builder` is simple and will work in most cases, but that may no
import {build} from '@backan/builder'

await build( {
input : 'src/server.ts', // JS or TS file
name : 'my-app-name', // default is input filename
input : 'src/server.js', // JS or TS file
name : 'app-name', // default is input filename
} )
```

```bash
backan-builder --input=src/server.ts --name=backan
backan-builder --input=src/server.js --name=app-name
```

:::

### ⚙️ Configuration

Todas estas opciones estan disponibles con el comando `backan-builder` añadiendole el sufijo `--` y seguidos de un `=` y su valor. Por ejemplo: `--input=src/server.ts --name=backan --onlyOs`
All of these options are available with the `backan-builder` command by adding the suffix `--` and followed by an `=` and its value.

```ts
type BuilderParams = {
Expand Down Expand Up @@ -93,7 +93,7 @@ import {app} from './your-backan-app.js'

buildSchema( {
app : app,
output : 'example-openapi.json',
output : 'openapi-schema.json',
} )
```

Expand All @@ -112,15 +112,15 @@ export type BuilderSchemaParams = {
}
```
## Build `markdown` documentation
## Build `Markdown` documentation
```js
import {buildMD} from '@backan/builder'
import {app} from './your-backan-app.js'

buildMD( {
app : app,
output : 'example-openapi.md',
output : 'api-documentation.md',
} )
```

Expand Down
1 change: 0 additions & 1 deletion docs/guide/core/app.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import { App } from 'backan';
const app = new App( {
version : '1.0.0',
title : 'BACKAN Example app',
port : 1312,
})

export default app
Expand Down
2 changes: 2 additions & 0 deletions docs/guide/create/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ A `CLI` for creating new [Backan](https://backan.pigeonposse.com) project.

[![NPM Version](https://img.shields.io/npm/v/create-backan?style=for-the-badge&color=yellow)](https://www.npmjs.com/package/create-backan)

<!-- ![backan-image](/backan-create.png) -->

<video src="/backan-create.webm" controls autoplay />

## CLI
Expand Down
6 changes: 3 additions & 3 deletions docs/guide/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ Start building your restAPI app now 🌈.

## 📦 Build your project

- Build your app documentation in a `markdown file`.
- Export to `openapi schema` to a `json file`.
- Build `binaries` of your project for all **systems** and **architectures**.
- Create [`binaries`](./builder/index.md#build-binaries) of your project for all **systems** and **architectures** with zero config.
- Export the `OpenAPI schema` to a [`JSON file`](./builder/index.md#build-json-schema).
- Build your application documentation in a [`Markdown file`](./builder/index.md#build-markdown-documentation).

[Read more](./builder/index.md)
35 changes: 24 additions & 11 deletions docs/guide/server/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,14 @@ yarn add @backan/server
import {server} from '@backan/server'
import {App} from 'backan'

// create base backan app
// create backan app
const app = new App( {
version : '1.0.0',
title : 'BACKAN Example app',
port : 1312,
title : 'BACKAN sample application',
})

// create server for backan
server({
fetch: app.fetch
})
server({ app })

```

Expand All @@ -51,10 +48,10 @@ Here is a list of the available options.
*/
type ServerOpts = {
/**
* The fetch handler for the server.
* The `backan` app instance.
*
*/
fetch: App<Env>['fetch'],
app: App<Env>,
/**
* The port to start the server on.
*
Expand Down Expand Up @@ -145,11 +142,27 @@ type ServerInfo = {
## 💡 Examples
### Zero config
```js
/**
* Start a server with zero config for BACKAN
*
* @see https://backan.pigeonposse.com/guide/server
*/

import { server } from '@backan/server'
import app from './app.js' // your backan app
await server({ app })

```

### Fully customized

```js
/**
* Starts a node server with BACKAN Fully customized
* Start a fully customized server for BACKAN
*
* @see https://backan.pigeonposse.com/guide/server
*/
Expand All @@ -158,10 +171,10 @@ import { server } from '@backan/server'
import app from './app.js' // your backan app

await server( {
fetch : app.fetch,
app : app,
hostname : 'localhost',
protocol : 'http',
port : app.port,
port : 1312,
autoPort : true,
allowFlags : true,
onError : async ( { id, error } ) => {
Expand Down
Binary file added docs/public/backan-create.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion docs/todo/v1.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@

- [x] Finish beta.
- [x] Add js templates
- [ ] Add tests to templates
- [x] Add tests to templates
- [ ] create templates dynamically avoiding repeating code
6 changes: 6 additions & 0 deletions packages/_config/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# @backan/config

## 0.0.6

### Patch Changes

- Update create repo and fix server repo

## 0.0.5

### Patch Changes
Expand Down
4 changes: 2 additions & 2 deletions packages/_config/package.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"private": true,
"name": "@backan/config",
"version": "0.0.5",
"version": "0.0.6",
"description": "Configuration files for monorepo",
"type": "module",
"scripts": {
"test": "vitest run -r tests --passWithNoTests"
"test": "vitest run -r src --passWithNoTests"
},
"dependencies": {
"@types/archiver": "6.0.2",
Expand Down
1 change: 1 addition & 0 deletions packages/_config/src/tests/main.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ test( async ( { section } ) => {

},
} )

addBooleanTest( {
title : 'boolean test',
expected : true,
Expand Down
4 changes: 2 additions & 2 deletions packages/_config/src/tests/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,7 @@ export const test = ( fn: ( args: TestParams ) => Promise<void> ) => {

const vifn = vi.fn( async () => {

// eslint-disable-next-line no-async-promise-executor
return new Promise( async ( resolve, reject ) => {
return new Promise<boolean>( async ( resolve, reject ) => {

try {

Expand All @@ -68,6 +67,7 @@ export const test = ( fn: ( args: TestParams ) => Promise<void> ) => {
} )

} )

const res = await vifn()
expect( res ).toBe( expected )

Expand Down
7 changes: 7 additions & 0 deletions packages/backan/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# backan

## 0.0.14

### Patch Changes

- Updated dependencies []:
- @backan/core@0.0.14

## 0.0.13

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/backan/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "backan",
"version": "0.0.13",
"version": "0.0.14",
"type": "module",
"license": "GPL-3.0",
"homepage": "https://backan.pigeonposse.com",
Expand Down
2 changes: 2 additions & 0 deletions packages/builder/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# @backan/builder

## 0.0.14

## 0.0.13

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/builder/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@backan/builder",
"version": "0.0.13",
"version": "0.0.14",
"type": "module",
"license": "GPL-3.0",
"homepage": "https://backan.pigeonposse.com/",
Expand Down
2 changes: 2 additions & 0 deletions packages/core/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# @backan/core

## 0.0.14

## 0.0.13

## 0.0.12
Expand Down
2 changes: 1 addition & 1 deletion packages/core/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@backan/core",
"version": "0.0.13",
"version": "0.0.14",
"type": "module",
"license": "GPL-3.0",
"homepage": "https://backan.pigeonposse.com",
Expand Down
6 changes: 6 additions & 0 deletions packages/create/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# create-backan

## 0.0.14

### Patch Changes

- Update create repo and fix server repo

## 0.0.13

## 0.0.12
Expand Down
39 changes: 39 additions & 0 deletions packages/create/examples/all.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@

import { create } from '../src/main'
import { TEMPLATES } from '../src/const'
import {
joinPath,
paths,
removePathIfExist,
} from '@backan/config/core'

process.argv.push( '--debug' )

process.on( 'exit', code => {

console.log( {
title : 'On exit',
data : {
success : code === 0,
code,
},
} )

} )

for ( const TEMPLATE of Object.values( TEMPLATES ) ) {

const input = joinPath( paths.createDir, 'build' )
const name = 'examples-' + TEMPLATE
const inputPath = joinPath( input, name )

await removePathIfExist( inputPath )

await create( {
input,
name,
install : false,
template : TEMPLATE,
} )

}
2 changes: 1 addition & 1 deletion packages/create/examples/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
import { create } from '../src/main'
import { TEMPLATES } from '../src/const'

const input = joinPath( paths.createDir, 'dist' )
const input = joinPath( paths.createDir, 'build' )
const template = TEMPLATES.DEMO_TS
const name = 'examples-' + template
const inputPath = joinPath( input, name )
Expand Down
2 changes: 1 addition & 1 deletion packages/create/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "create-backan",
"version": "0.0.13",
"version": "0.0.14",
"type": "module",
"license": "GPL-3.0",
"homepage": "https://backan.pigeonposse.com",
Expand Down
47 changes: 0 additions & 47 deletions packages/create/src/bin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,54 +97,7 @@ await group( {

},
} )
// try{

// while ( !validName ) {

// if ( projectName !== undefined ) {

// log.success( `Name of project: ${gray( projectName )}` )
// break

// }

// projectName = await text( {
// message : 'What is the name of the project?',
// placeholder : name.toLowerCase() + '-project',
// } ) as string

// if ( typeof projectName === 'string' ) {

// if ( !isValidProjectName( projectName ) ) {

// log.error( 'The project name contains invalid characters. Only letters, numbers, hyphens, and underscores are allowed.' )
// projectName = undefined // Reset to ask again
// continue

// }

// const inputDir = resolvePath( projectName )
// const existsInput = await existsPath( inputDir )

// if ( existsInput ) {

// log.error( `The project name "${projectName}" already exists. Please choose a different name.` )
// projectName = undefined // Reset to ask again

// } else validName = true

// }

// }

// }catch( _e ){

// cancelRes( )

// }

// return projectName

},

[OPTS.TEMPLATE] : async () => {
Expand Down
Loading

0 comments on commit c75d136

Please sign in to comment.