Skip to content

Commit

Permalink
npm publication
Browse files Browse the repository at this point in the history
  • Loading branch information
vkoktashev committed Sep 21, 2023
1 parent 5eb573f commit c345f5e
Show file tree
Hide file tree
Showing 7 changed files with 68 additions and 24 deletions.
21 changes: 21 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: NPM Publish
on:
push:
branches:
- 'master'
- 'v2'
jobs:
publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions/setup-node@v1
with:
node-version: ^14.15.0 || ^16.10.0 || >=18.0.0
- run: yarn
- run: yarn build
- run: cp ./{package.json,LICENSE,README.md} dist/
- uses: JS-DevTools/npm-publish@v1
with:
package: ./dist/package.json
token: ${{ secrets.NPM_TOKEN }}
30 changes: 15 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,30 +1,30 @@
## Install

### 1. Install dependencies
### 1. Install package

```shell
yarn
npm i -g @steroidsjs/gii-fs
```

## Start

### Development mode
### 2. Create config

Create config.json (sample is gii-fn-config.json.sample)
Create config.json. Sample:

```shell
yarn start:dev /path/to/config.json
```json
{
"port": 7800,
"projects": [
"/Users/user/Projects/backend-nest"
]
}
```

### Production mode
## Start

1. Build
### Production mode

```shell
yarn build
gii-fs /path/to/config.json
```
2. Start

```shell
yarn start:prod /path/to/config.json
```
It is not necessary to specify the path to the config. Then will be used the default path ~/gii-fs.json
1 change: 1 addition & 0 deletions gii-fs-config.json.sample
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"port": 7800,
"projects": [
"/Users/vladislavkoktashev/Projects/sfu/backend-nest"
]
Expand Down
3 changes: 3 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/usr/bin/env node

require('./main.js');
20 changes: 15 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,20 @@
{
"name": "@steroidsjs/gii-fs",
"version": "0.0.1",
"version": "0.0.4",
"description": "FS Developer Server",
"author": "",
"private": true,
"license": "UNLICENSED",
"author": "Vladimir Kozhin <hello@kozhindev.com>",
"repository": {
"type": "git",
"url": "https://github.com/steroids/gii-fs"
},
"license": "MIT",
"homepage": "https://github.com/steroids/gii-fs",
"bugs": {
"url": "https://github.com/steroids/gii-fs/issues"
},
"scripts": {
"prebuild": "rimraf dist",
"build": "nest build",
"build": "nest build && cp ./{package.json,LICENSE,README.md,index.js} dist/",
"format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"",
"start": "nest start",
"start:dev": "nest start --watch --",
Expand All @@ -16,6 +23,9 @@
"lint": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix",
"cli": "npx nestjs-command"
},
"bin": {
"gii-fs": "./index.js"
},
"dependencies": {
"@nestjs/axios": "^0.0.6",
"@nestjs/common": "^8.4.1",
Expand Down
6 changes: 4 additions & 2 deletions src/config/main.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import * as process from 'process';
import * as path from 'path';

export default () => ({
name: '@steroidsjs/gii-fs',
Expand All @@ -9,8 +10,9 @@ export default () => ({
'127.0.0.1:9350',
],
},
port: 7800,
project: {
configRoute: process.argv.at(-1),
configRoute: process.argv.at(-1).endsWith('.json')
? process.argv.at(-1)
: path.resolve(require('os').homedir(), 'gii-fs.json'),
}
});
11 changes: 9 additions & 2 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@ import {NestFactory, Reflector} from '@nestjs/core';
import {DocumentBuilder, SwaggerDocumentOptions, SwaggerModule} from '@nestjs/swagger';
import {ConfigService} from '@nestjs/config';
import {VersioningType} from '@nestjs/common';
import * as process from 'process';
import * as fs from 'fs';
import './envInit';
import * as basicAuth from 'express-basic-auth';
import {AppModule} from './AppModule';
import {SchemaSerializer} from './base/infrastructure/filters/SchemaSerializer';
import {CreateDtoPipe} from '@steroidsjs/nest/infrastructure/pipes/CreateDtoPipe';
import {ValidationExceptionFilter} from '@steroidsjs/nest/infrastructure/filters/ValidationExceptionFilter';
import {UserExceptionFilter} from '@steroidsjs/nest/infrastructure/filters/UserExceptionFilter';
import * as process from 'process';

async function bootstrap() {
const app = await NestFactory.create(AppModule);
Expand Down Expand Up @@ -99,8 +100,14 @@ async function bootstrap() {
new SchemaSerializer(app.get(Reflector)),
);

const configRoute = configService.get('project.configRoute');
if (!fs.existsSync(configRoute)) {
throw new Error(`Конфиг не обнаружен по пути ${configRoute}`);
}
const config = JSON.parse(fs.readFileSync(configRoute).toString());

// Start application
const port = configService.get('port');
const port = config.port || 7800;
await app.listen(
port,
() => console.log(`Server started http://localhost:${port}`), // eslint-disable-line no-console
Expand Down

0 comments on commit c345f5e

Please sign in to comment.