Skip to content

Commit

Permalink
feat(draft): add npm publish support
Browse files Browse the repository at this point in the history
  • Loading branch information
temarusanov committed Jul 7, 2023
1 parent 73911ef commit ef333b7
Show file tree
Hide file tree
Showing 26 changed files with 7,770 additions and 1,266 deletions.
6 changes: 6 additions & 0 deletions .commitlintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"extends": [
"@commitlint/config-conventional"
],
"rules": {}
}
4 changes: 4 additions & 0 deletions .husky/commit-msg
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

npx --no-install commitlint --edit $1
4 changes: 2 additions & 2 deletions apps/api/src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import {
} from '@nestjs/apollo'
import { Module } from '@nestjs/common'
import { GraphQLModule } from '@nestjs/graphql'
import { EventloopFrozenDetectorModule } from 'core/eventloop-frozen-detector'
import { HealthChecksModule } from 'core/health-checks'
import { EventloopFrozenDetectorModule } from 'core-eventloop-frozen-detector'
import { HealthChecksModule } from 'core-health-checks'
import { NatsModule } from 'core/nats'
import * as env from 'env-var'
import { SampleModule } from 'sample'
Expand Down
2 changes: 1 addition & 1 deletion apps/gateway/src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { ApolloServerPluginLandingPageLocalDefault } from '@apollo/server/plugin
import { ApolloGatewayDriver, ApolloGatewayDriverConfig } from '@nestjs/apollo'
import { Module } from '@nestjs/common'
import { GraphQLModule } from '@nestjs/graphql'
import { EventloopFrozenDetectorModule } from 'core/eventloop-frozen-detector'
import { EventloopFrozenDetectorModule } from 'core-eventloop-frozen-detector'
import * as env from 'env-var'

@Module({
Expand Down
24 changes: 24 additions & 0 deletions libs/core/common/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,30 @@
"sourceRoot": "libs/core/common/src",
"projectType": "library",
"targets": {
"build": {
"executor": "@nx/js:tsc",
"outputs": [
"{options.outputPath}"
],
"options": {
"buildableProjectDepsInPackageJsonType": "dependencies",
"outputPath": "dist/libs/core/common",
"main": "libs/core/common/src/index.ts",
"tsConfig": "libs/core/common/tsconfig.lib.json",
"assets": [
"libs/core/common/*.md"
]
}
},
"publish": {
"command": "node tools/scripts/publish.mjs common {args.ver} {args.tag}",
"dependsOn": [
"build"
]
},
"version": {
"executor": "@jscutlery/semver:version"
},
"lint": {
"executor": "@nx/linter:eslint",
"outputs": ["{options.outputFile}"],
Expand Down
24 changes: 24 additions & 0 deletions libs/core/health-checks/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,30 @@
"sourceRoot": "libs/core/health-checks/src",
"projectType": "library",
"targets": {
"build": {
"executor": "@nx/js:tsc",
"outputs": [
"{options.outputPath}"
],
"options": {
"buildableProjectDepsInPackageJsonType": "dependencies",
"outputPath": "dist/libs/core/health-checks",
"main": "libs/core/health-checks/src/index.ts",
"tsConfig": "libs/core/health-checks/tsconfig.lib.json",
"assets": [
"libs/core/health-checks/*.md"
]
}
},
"publish": {
"command": "node tools/scripts/publish.mjs health-checks {args.ver} {args.tag}",
"dependsOn": [
"build"
]
},
"version": {
"executor": "@jscutlery/semver:version"
},
"lint": {
"executor": "@nx/linter:eslint",
"outputs": ["{options.outputFile}"],
Expand Down
6 changes: 1 addition & 5 deletions libs/core/nats/README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
# nats
# NestJS Nats library

This library was generated with [Nx](https://nx.dev).

## Building

Run `nx build nats` to build the library.

## Running unit tests

Run `nx test nats` to execute the unit tests via [Jest](https://jestjs.io).
2 changes: 1 addition & 1 deletion libs/core/nats/package.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"name": "@tema/nats",
"name": "@tematools/nats",
"version": "0.1.0"
}
24 changes: 24 additions & 0 deletions libs/core/nats/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,30 @@
"sourceRoot": "libs/core/nats/src",
"projectType": "library",
"targets": {
"build": {
"executor": "@nx/js:tsc",
"outputs": [
"{options.outputPath}"
],
"options": {
"buildableProjectDepsInPackageJsonType": "dependencies",
"outputPath": "dist/libs/core/nats",
"main": "libs/core/nats/src/index.ts",
"tsConfig": "libs/core/nats/tsconfig.lib.json",
"assets": [
"libs/core/nats/*.md"
]
}
},
"publish": {
"command": "node tools/scripts/publish.mjs nats {args.ver} {args.tag}",
"dependsOn": [
"build"
]
},
"version": {
"executor": "@jscutlery/semver:version"
},
"lint": {
"executor": "@nx/linter:eslint",
"outputs": ["{options.outputFile}"],
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Injectable } from '@nestjs/common'
import { HealthIndicator, HealthIndicatorResult } from 'core/health-checks'
import { HealthIndicator, HealthIndicatorResult } from '@tematools/health-checks'

import { NatsConnectionService } from '../nats-services/nats-connection.service'

Expand Down
3 changes: 1 addition & 2 deletions libs/core/nats/src/lib/nats-services/nats-client.service.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Injectable, Logger } from '@nestjs/common'
import { CommonError, CommonErrorsEnum } from 'core/common'
import { CommonError, CommonErrorsEnum } from 'core-common'
import { ErrorCode, Payload, Subscription, SubscriptionOptions } from 'nats'

import { NATS_ERROR_TITLES } from '../nats-errors/nats-errors.enum'
Expand Down Expand Up @@ -85,7 +85,6 @@ export class NatsClientService {
const nc = this.natsConnection.getNatsConnection()

const subscription = nc.subscribe(subject, options)

this.logger.log(`Mapped {${subject}, NATS} route`)

return subscription
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
OnModuleInit,
} from '@nestjs/common'
import { isObject } from '@nestjs/common/utils/shared.utils'
import { CommonError } from 'core/common'
import { CommonError } from 'core-common'
import {
connect,
JetStreamManager,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Inject, Injectable, Logger } from '@nestjs/common'
import { CommonError } from 'core/common'
import { CommonError } from 'core-common'
import {
ConsumeOptions,
ConsumerConfig,
Expand Down
2 changes: 1 addition & 1 deletion libs/core/nats/src/lib/nats.module.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { DiscoveryModule } from '@golevelup/nestjs-discovery'
import { DynamicModule, Module } from '@nestjs/common'
import { HEALTH_CHECKS_PROVIDER } from 'core/health-checks'
import { HEALTH_CHECKS_PROVIDER } from '@tematools/health-checks'
import { CustomInjectorModule } from 'nestjs-custom-injector'

import {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Injectable } from '@nestjs/common'
import { HealthIndicator, HealthIndicatorResult } from 'core/health-checks'
import { HealthIndicator, HealthIndicatorResult } from 'core-health-checks'

import { SamplePrismaService } from '../sample-services/sample-prisma.service'

Expand Down
8 changes: 0 additions & 8 deletions libs/sample/src/lib/sample-nats/sample-nats.controller.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,4 @@
import { Controller, Logger } from '@nestjs/common'
import {
Consume,
ConsumePayload,
ConsumerAcks,
Reply,
ReplyPayload,
ReplyResponse,
} from 'core/nats'
import { AckPolicy } from 'nats'

import {
Expand Down
2 changes: 1 addition & 1 deletion libs/sample/src/lib/sample-nats/sample-nats.stream.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Injectable, OnModuleInit } from '@nestjs/common'
import { NatsJetStreamClientService, PublishOptions } from 'core/nats'
import { NatsJetStreamClientService, PublishOptions } from 'libs/src'
import { PubAck, RetentionPolicy, StorageType } from 'nats'

export enum SampleNatsJetStreamSubjectsEnum {
Expand Down
2 changes: 1 addition & 1 deletion libs/sample/src/lib/sample.module.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { DynamicModule, Module, Provider, Type } from '@nestjs/common'
import { HEALTH_CHECKS_PROVIDER } from 'core/health-checks'
import { HEALTH_CHECKS_PROVIDER } from 'core-health-checks'
import { CustomInjectorModule } from 'nestjs-custom-injector'

import {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
patch<%= className %>Config,
} from './<%= fileName %>-configs/<%= fileName %>-module.config'
import { <%= className %>Resolver } from './<%= fileName %>-graphql/<%= fileName %>.resolver'
import { HEALTH_CHECKS_PROVIDER } from 'core/health-checks'
import { HEALTH_CHECKS_PROVIDER } from 'core-health-checks'
import { <%= className %>PrismaConnectionHealthIndicator } from './<%= fileName %>-indicators/<%= fileName %>-prisma-connection.health'
import { <%= className %>PrismaService } from './<%= fileName %>-services/<%= fileName %>-prisma.service'
import { <%= className %>NatsController } from './<%= fileName %>-nats/<%= fileName %>-nats.controller'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Injectable } from '@nestjs/common'
import { HealthIndicator, HealthIndicatorResult } from 'core/health-checks'
import { HealthIndicator, HealthIndicatorResult } from 'core-health-checks'
import { <%= className %>PrismaService } from '../<%= fileName %>-services/<%= fileName %>-prisma.service'

@Injectable()
Expand Down
2 changes: 1 addition & 1 deletion libs/schematics/src/utils/versions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ export const nxVersion = require('../../package.json').version
export const nestJsVersion = '^9.0.0'
export const rxjsVersion = '^7.0.0'
export const reflectMetadataVersion = '^0.1.13'
export const tsLibVersion = '^2.3.0'
export const tsLibVersion = '^2.6.0'
38 changes: 30 additions & 8 deletions nx.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,38 @@
},
"targetDefaults": {
"build": {
"dependsOn": ["^build"],
"inputs": ["production", "^production"]
"dependsOn": [
"^build"
],
"inputs": [
"production",
"^production"
]
},
"test": {
"inputs": ["default", "^production", "{workspaceRoot}/jest.preset.js"]
"inputs": [
"default",
"^production",
"{workspaceRoot}/jest.preset.js"
]
},
"lint": {
"inputs": ["default", "{workspaceRoot}/.eslintrc.json"]
"inputs": [
"default",
"{workspaceRoot}/.eslintrc.json"
]
},
"prisma:generate": {
"inputs": ["{projectRoot}/**/schema.prisma"]
"inputs": [
"{projectRoot}/**/schema.prisma"
]
}
},
"namedInputs": {
"default": ["{projectRoot}/**/*", "sharedGlobals"],
"default": [
"{projectRoot}/**/*",
"sharedGlobals"
],
"production": [
"default",
"!{projectRoot}/**/?(*.)+(spec|test).[jt]s?(x)?(.snap)",
Expand All @@ -43,5 +60,10 @@
],
"sharedGlobals": []
},
"defaultProject": "api"
}
"defaultProject": "api",
"pluginsConfig": {
"@nx/js": {
"analyzeSourceFiles": true
}
}
}
Loading

0 comments on commit ef333b7

Please sign in to comment.