@nathapp/na-cli 1.0.1-rc.1 → 1.0.1-rc.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/.gitlab-ci.yml CHANGED
@@ -70,24 +70,22 @@ run-build:
70
70
  NPM_RELEASE_TOKEN: $NPM_TOKEN
71
71
  before_script:
72
72
  # set priorty to use own registry
73
- - npm config set @nathapp:registry //npm.nathapp.io
73
+ - npm config set @nathapp:registry https://npm.nathapp.io
74
74
  - npm ci --cache .npm --prefer-offline
75
75
  # remove @nathapp:registry after install
76
76
  - npm config delete @nathapp:registry
77
77
  - npm config set ${NPM_REGISTRY}:_authToken ${NPM_RELEASE_TOKEN}
78
78
  script:
79
79
  - make build
80
- - REGISTRY=${NPM_REGISTRY} make release-with-registry
80
+ - REGISTRY=https:${NPM_REGISTRY} make release-with-registry
81
81
  rules:
82
82
  # NOT triggerred by bot and NOT commit message contains `run-without-release` keyword and NOT merge request and NOT tag was created
83
83
  - if: '$CI_COMMIT_MESSAGE =~ /release-by-bot/ || $CI_COMMIT_MESSAGE =~ /run-without-release/ || $CI_PIPELINE_SOURCE == "merge_request_event" || $CI_COMMIT_TAG != null'
84
84
  when: never
85
85
  # Commit message contains `run-prerelease` keyword and commit branch is not default branch (master)
86
86
  - if: '$CI_COMMIT_MESSAGE =~ /run-prerelease/ && $CI_COMMIT_BRANCH != $CI_DEFAULT_BRANCH'
87
- # Commit message contains `run-prerelease` keyword and commit branch is not default branch (master)
88
- - if: '$NPM_PRIVATE_REGISTRY != null && $CI_COMMIT_MESSAGE =~ /run-prerelease/ && $CI_COMMIT_BRANCH != $CI_DEFAULT_BRANCH'
89
87
  variables:
90
- NPM_REGISTRY: //npm.nathapp.io # Override NPM_REGISTRY defined at the job level.
88
+ NPM_REGISTRY: //npm.nathapp.io/ # Override NPM_REGISTRY defined at the job level.
91
89
  NPM_RELEASE_TOKEN: $NPM_PRIVATE_TOKEN
92
90
  # Commit into default branch (master)
93
91
  - if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH'
package/README.md CHANGED
@@ -12,10 +12,12 @@ Command line for create a project with your own templates, and other template jo
12
12
  4. k8s-deployments 1.0.0
13
13
  5. nestjs-api 1.0.0
14
14
  - with nestjs ^10.0.0
15
- - with @nathapp/common ^0.1.11
16
- - with @nathapp/nestjs-common ^1.0.1-rc.21
17
- - with @nathapp/nestjs-app ^1.0.0-rc.7
18
- - with @nathapp/nestjs-auth ^1.0.0-rc.24
15
+ - with @nathapp/common ^0.1.13
16
+ - with @nathapp/nestjs-app ^1.0.0-rc.10
17
+ - with @nathapp/nestjs-auth ^1.0.0-rc.28
18
+ - with @nathapp/nestjs-common ^1.0.1-rc.28
19
+ - with @nathapp/nestjs-data ^1.0.0-rc.13
20
+ - with @nathapp/nestjs-microservices ^1.0.0-rc.14
19
21
  6. nestjs-library 1.0.0
20
22
  - with nestjs ^10.0.0
21
23
 
package/dist/index.js CHANGED
File without changes
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "<%= projectName %>",
3
3
  "version": "1.0.0-rc.0",
4
- "description": "",
5
- "author": "",
4
+ "description": "<%= projectName %>",
5
+ "author": "<%= author %>",
6
6
  "private": true,
7
7
  "license": "UNLICENSED",
8
8
  "scripts": {
@@ -11,7 +11,7 @@
11
11
  "start": "nest start",
12
12
  "start:dev": "nest start --watch",
13
13
  "start:debug": "nest start --debug --watch",
14
- "start:prod": "node dist/main",
14
+ "start:prod": "ENV_NAME=production node dist/main",
15
15
  "lint": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix",
16
16
  "test": "jest",
17
17
  "test:watch": "jest --watch",
@@ -21,11 +21,12 @@
21
21
  },
22
22
  "dependencies": {
23
23
  <%if (isFastify) { -%>"@fastify/static": "^6.11.2",<% }-%>
24
- "@nathapp/common": "^0.1.11",
25
- "@nathapp/nestjs-app": "^1.0.0-rc.7",
26
- "@nathapp/nestjs-auth": "^1.0.0-rc.24",
27
- "@nathapp/nestjs-common": "^1.0.1-rc.21",
28
- "@nathapp/nestjs-microservices": "^1.0.0-rc.12",
24
+ "@nathapp/common": "^0.1.13",
25
+ "@nathapp/nestjs-app": "^1.0.0-rc.10",
26
+ "@nathapp/nestjs-auth": "^1.0.0-rc.28",
27
+ "@nathapp/nestjs-common": "^1.0.1-rc.28",
28
+ "@nathapp/nestjs-data": "^1.0.0-rc.13",
29
+ "@nathapp/nestjs-microservices": "^1.0.0-rc.14",
29
30
  "@nestjs/common": "^10.0.0",
30
31
  "@nestjs/config": "^3.0.0",
31
32
  "@nestjs/core": "^10.0.0",
@@ -39,6 +40,7 @@
39
40
  "rxjs": "^7.2.0"
40
41
  },
41
42
  "devDependencies": {
43
+ "@golevelup/ts-jest": "^0.4.0",
42
44
  "@nestjs/cli": "^10.0.0",
43
45
  "@nestjs/schematics": "^10.0.0",
44
46
  "@nestjs/testing": "^10.0.0",
@@ -77,6 +79,9 @@
77
79
  "**/*.(t|j)s"
78
80
  ],
79
81
  "coverageDirectory": "../coverage",
80
- "testEnvironment": "node"
82
+ "testEnvironment": "node",
83
+ "moduleNameMapper": {
84
+ "^@/(.*)$": "<rootDir>/../src/$1"
85
+ }
81
86
  }
82
87
  }
@@ -1,9 +1,10 @@
1
1
  import { Test, TestingModule } from '@nestjs/testing';
2
2
  import { AppController } from './app.controller';
3
- import { AppService } from './app.service';
3
+ import { AppService } from '@/app.service';
4
4
 
5
5
  describe('AppController', () => {
6
6
  let appController: AppController;
7
+ let appService: AppService;
7
8
 
8
9
  beforeEach(async () => {
9
10
  const app: TestingModule = await Test.createTestingModule({
@@ -12,11 +13,12 @@ describe('AppController', () => {
12
13
  }).compile();
13
14
 
14
15
  appController = app.get<AppController>(AppController);
16
+ appService = app.get(AppService);
15
17
  });
16
18
 
17
- // describe('root', () => {
18
- // it('should return "Hello World!"', () => {
19
- // expect(appController.getHello()).toBe('Hello World!');
20
- // });
21
- // });
19
+ describe('root', () => {
20
+ it('should return "App Version"', () => {
21
+ expect(appController.get()).toEqual(appService.displayVersion());
22
+ });
23
+ });
22
24
  });
@@ -5,8 +5,13 @@ import {
5
5
  JwtRefreshStrategy,
6
6
  JwtStrategy,
7
7
  } from '@nathapp/nestjs-auth';
8
- import { I18nCoreModule } from '@nathapp/nestjs-common';
9
- import { Module } from '@nestjs/common';
8
+ import { I18nCoreModule, LoggerMiddleware } from '@nathapp/nestjs-common';
9
+ import {
10
+ MiddlewareConsumer,
11
+ Module,
12
+ NestModule,
13
+ RequestMethod,
14
+ } from '@nestjs/common';
10
15
  import { ConfigModule } from '@nestjs/config';
11
16
  import { AppController } from './app.controller';
12
17
  import { AppService } from './app.service';
@@ -29,4 +34,16 @@ import { AppService } from './app.service';
29
34
  //JwtRefreshGuard,
30
35
  ],
31
36
  })
32
- export class AppModule { }
37
+ export class AppModule implements NestModule {
38
+ configure(consumer: MiddlewareConsumer) {
39
+ consumer
40
+ .apply(LoggerMiddleware)
41
+ .exclude(
42
+ { path: '/', method: RequestMethod.GET },
43
+ { path: '/favicon.ico', method: RequestMethod.GET },
44
+ { path: '/liveness', method: RequestMethod.GET },
45
+ { path: '/readiness', method: RequestMethod.GET },
46
+ )
47
+ .forRoutes({ path: '*', method: RequestMethod.ALL });
48
+ }
49
+ }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "-1": "Unknown error occurred, Please try again later",
3
3
  "-2": "Request Parameter Error: {param}",
4
- "-3": "Invalid Request",
4
+ "-3": "Bad Request",
5
5
  "404": "Resource not found",
6
6
  "501": "Internal Server Error",
7
7
  "20000": "User does not exist",
@@ -19,7 +19,7 @@ async function bootstrap() {
19
19
  .useAppGlobalPrefix()
20
20
  .useAppGlobalFilters()
21
21
  .useAppGlobalGuards()
22
- .useSwaggerUI(appService.getAppInfo());
22
+ .useSwaggerUIOnDevOnly(appService.getAppInfo());
23
23
 
24
24
  await app.start();
25
25
  }
@@ -2,23 +2,46 @@ import { Test, TestingModule } from '@nestjs/testing';
2
2
  import { INestApplication } from '@nestjs/common';
3
3
  import * as request from 'supertest';
4
4
  import { AppModule } from './../src/app.module';
5
+ import { AppService } from './../src/app.service';
6
+ <%if (isFastify) { -%>
7
+ import {
8
+ FastifyAdapter,
9
+ NestFastifyApplication,
10
+ } from '@nestjs/platform-fastify';
11
+ <% }-%>
5
12
 
6
13
  describe('AppController (e2e)', () => {
7
14
  let app: INestApplication;
8
-
15
+ let appService: AppService;
16
+
9
17
  beforeEach(async () => {
10
18
  const moduleFixture: TestingModule = await Test.createTestingModule({
11
19
  imports: [AppModule],
12
20
  }).compile();
13
21
 
22
+ <%if (isFastify) { -%>
23
+ app = moduleFixture.createNestApplication<NestFastifyApplication>(
24
+ new FastifyAdapter(),
25
+ );
26
+ <% } else{ %>
14
27
  app = moduleFixture.createNestApplication();
15
- await app.init();
28
+ <% }-%>
29
+ appService = app.get(AppService);
30
+ await app.init();
31
+ <%if (isFastify) { -%>
32
+ await app.getHttpAdapter().getInstance().ready();
33
+ <% }-%>
16
34
  });
17
35
 
36
+ afterEach(async () => {
37
+ await app.close();
38
+ });
39
+
18
40
  it('/ (GET)', () => {
41
+ const response = appService.displayVersion();
19
42
  return request(app.getHttpServer())
20
43
  .get('/')
21
44
  .expect(200)
22
- .expect('Hello World!');
45
+ .expect({ ret: response.ret, data: response.data });
23
46
  });
24
47
  });
@@ -5,5 +5,8 @@
5
5
  "testRegex": ".e2e-spec.ts$",
6
6
  "transform": {
7
7
  "^.+\\.(t|j)s$": "ts-jest"
8
- }
8
+ },
9
+ "moduleNameMapper": {
10
+ "^@/(.*)$": "<rootDir>/../src/$1"
11
+ }
9
12
  }
@@ -16,6 +16,9 @@
16
16
  "noImplicitAny": false,
17
17
  "strictBindCallApply": false,
18
18
  "forceConsistentCasingInFileNames": false,
19
- "noFallthroughCasesInSwitch": false
19
+ "noFallthroughCasesInSwitch": false,
20
+ "paths": {
21
+ "@/*": ["src/*"],
22
+ }
20
23
  }
21
24
  }
@@ -10,7 +10,7 @@
10
10
  "test:watch": "jest --config ./test/jest-test.json --watch",
11
11
  "lint": "eslint -c .eslintrc.js"
12
12
  },
13
- "author": "",
13
+ "author": "<%= author %>",
14
14
  "license": "ISC",
15
15
  "engines": {
16
16
  "node": ">=16"
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "<%= projectName %>",
3
3
  "version": "1.0.0-rc.0",
4
- "description": "na-cli generated ts-library 1.0.0",
4
+ "description": "<%= projectName %>",
5
5
  "scripts": {
6
6
  "build": "rimraf dist && tsc -p tsconfig.json",
7
7
  "precommit": "lint-staged",
@@ -0,0 +1,8 @@
1
+ // function showHelp() {
2
+ // console.log(usage);
3
+ // console.log('\nOptions:\r')
4
+ // console.log('\t--version\t ' + 'Show version number.' + '\t\t' + '[boolean]\r')
5
+ // console.log(' -l, --languages\t' + ' ' + 'List all languages.' + '\t\t' + '[boolean]\r')
6
+ // console.log('\t--help\t\t ' + 'Show help.' + '\t\t\t' + '[boolean]\n')
7
+ // }
8
+ //# sourceMappingURL=help.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"help.js","sourceRoot":"","sources":["../../src/utils/help.ts"],"names":[],"mappings":"AAAA,wBAAwB;AACxB,wBAAwB;AACxB,gCAAgC;AAChC,yFAAyF;AACzF,qGAAqG;AACrG,gFAAgF;AAChF,IAAI"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nathapp/na-cli",
3
- "version": "1.0.1-rc.1",
3
+ "version": "1.0.1-rc.6",
4
4
  "main": "dist/index.js",
5
5
  "scripts": {
6
6
  "start": "npm run build && node dist/index.js",