Skip to content

Commit 8f01faf

Browse files
authored
Merge pull request #66 from moleculerjs/v3
Rewrite typescript project template (v3)
2 parents 38100d8 + b411800 commit 8f01faf

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+6057
-1420
lines changed

.github/workflows/docker.yml

Lines changed: 10 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -8,27 +8,20 @@ jobs:
88

99
strategy:
1010
matrix:
11-
node-version: [10.x, 12.x, 14.x]
11+
node-version: [16.x, 18.x]
1212
# transporter: [NATS, Redis, MQTT, AMQP, AMQP10, STAN, Kafka, TCP]
1313
transporter: [NATS, Redis, MQTT, AMQP, STAN, Kafka, TCP]
1414
fail-fast: false
1515
steps:
16-
- name: Checkout
17-
uses: actions/checkout@v2
16+
- uses: actions/checkout@v3
1817

1918
- name: Use Node.js ${{ matrix.node-version }} with ${{ matrix.transporter }} transporter
20-
uses: actions/setup-node@v1
19+
uses: actions/setup-node@v3
2120
with:
2221
node-version: ${{ matrix.node-version }}
2322

24-
- name: Cache
25-
uses: actions/cache@v2
26-
with:
27-
path: ~/.npm
28-
key: cache-node-modules-${{ matrix.node-version }}
29-
3023
- name: Install dependencies
31-
run: npm install
24+
run: npm i
3225

3326
- name: Create answers file
3427
run: node update-answers.js
@@ -39,10 +32,6 @@ jobs:
3932
- name: Generate project with '${{ matrix.transporter }}' transporter
4033
run: npm test
4134

42-
- name: Run lint in the generated project
43-
run: npm run lint
44-
working-directory: ./ci-test
45-
4635
- name: Run tests in the generated project
4736
run: npm test
4837
working-directory: ./ci-test
@@ -54,23 +43,20 @@ jobs:
5443
run: npm run dc:up
5544
working-directory: ./ci-test
5645

57-
- name: Sleeping 60 secs
58-
run: sleep 60s
46+
- name: Sleeping 30 secs
47+
run: sleep 30
5948

60-
- name: Sleeping more in case of AMQP transporter
61-
run: sleep 180
62-
if: contains(matrix.transporter, 'AMQP')
63-
6449
- name: Check containers
6550
run: docker-compose ps
6651
working-directory: ./ci-test
6752

53+
- run: curl --silent --show-error --fail http://localhost:3000/api/greeter/hello
54+
- run: curl --silent --show-error --fail http://localhost:3000/api/products
55+
6856
- name: Check logs
6957
run: docker-compose logs
7058
working-directory: ./ci-test
71-
72-
- run: curl --silent --show-error --fail http://localhost:3000/api/greeter/hello
73-
- run: curl --silent --show-error --fail http://localhost:3000/api/products
59+
if: failure()
7460

7561
- name: Stop containers
7662
run: npm run dc:down

.github/workflows/generate.yml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
name: Generate a demo project
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
8+
jobs:
9+
generate:
10+
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- uses: actions/checkout@v3
15+
- name: Use Node.js 18.x
16+
uses: actions/setup-node@v3
17+
with:
18+
node-version: 18.x
19+
20+
- name: Install dependencies
21+
run: npm i
22+
- name: Generate project
23+
run: node_modules/.bin/moleculer init --answers test/demo/answers.json --no-install . project-demo
24+
25+
- name: Initialize Git repo
26+
run: git init
27+
working-directory: ./project-demo
28+
29+
- name: Set remote
30+
run: git remote add origin https://${{ secrets.GH_TOKEN }}@github.com/moleculerjs/project-typescript-demo.git
31+
working-directory: ./project-demo
32+
33+
- name: Add files
34+
run: git add --all
35+
working-directory: ./project-demo
36+
37+
- name: Configure Git user
38+
run: git config --global user.email "hello@moleculer.services" && git config --global user.name "Moleculer"
39+
working-directory: ./project-demo
40+
41+
- name: Commit
42+
run: git commit -m "Generated files"
43+
working-directory: ./project-demo
44+
45+
- name: Git push
46+
run: git push --force origin master
47+
working-directory: ./project-demo

.github/workflows/kubernetes.yml

Lines changed: 18 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
name: Test with Kubernetes
32

43
on: [push, pull_request]
@@ -9,23 +8,16 @@ jobs:
98

109
strategy:
1110
matrix:
12-
# transporter: [NATS, Redis, MQTT, AMQP, AMQP10, STAN, Kafka]
13-
transporter: [NATS, Redis, MQTT, AMQP, STAN, Kafka]
11+
transporter: [NATS, Redis, MQTT, AMQP, AMQP10, STAN, Kafka]
1412
fail-fast: false
1513

1614
steps:
17-
- name: Checkout
18-
uses: actions/checkout@v2
15+
- uses: actions/checkout@v3
1916

2017
- name: Use Node.js with ${{ matrix.transporter }} transporter
21-
uses: actions/setup-node@v1
22-
with:
23-
node-version: 12.x
24-
- name: Cache
25-
uses: actions/cache@v2
18+
uses: actions/setup-node@v3
2619
with:
27-
path: ~/.npm
28-
key: cache-node-modules-12.x
20+
node-version: 18.x
2921

3022
- name: Install dependencies
3123
run: npm i
@@ -46,50 +38,35 @@ jobs:
4638
- name: Start a local Docker Registry
4739
run: docker run -d --restart=always -p 5000:5000 --name registry registry:2
4840

49-
- name: Set Registry IP for KinD
50-
run: |
51-
REGISTRY_IP=$(docker inspect -f '{{.NetworkSettings.IPAddress}}' registry)
52-
echo $REGISTRY_IP
53-
sed -i "s/registry:5000/$REGISTRY_IP:5000/g" test/ci/kind-config.yaml
54-
cat test/ci/kind-config.yaml
55-
5641
- name: Build Docker image
57-
run: docker build -t ci-test .
42+
run: docker build -t ci-test:demo .
5843
working-directory: ./ci-test
5944

60-
- name: Tagging
61-
run: docker tag ci-test localhost:5000/ci-test
62-
63-
- name: Push Docker image
64-
run: docker push localhost:5000/ci-test
65-
6645
- uses: engineerd/setup-kind@v0.5.0
6746
with:
47+
version: "v0.17.0"
6848
config: ./test/ci/kind-config.yaml
6949

7050
- run: kubectl cluster-info
7151
- run: kubectl get nodes
7252
- run: kubectl get pods -n kube-system
7353

54+
- name: Load Docker image
55+
run: kind load docker-image ci-test:demo ci-test:demo
56+
7457
- name: Install NGINX Ingress
75-
run: |
76-
kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/nginx-0.27.0/deploy/static/mandatory.yaml
77-
kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/nginx-0.27.0/deploy/static/provider/baremetal/service-nodeport.yaml
78-
kubectl patch deployments -n ingress-nginx nginx-ingress-controller -p '{"spec":{"template":{"spec":{"containers":[{"name":"nginx-ingress-controller","ports":[{"containerPort":80,"hostPort":80},{"containerPort":443,"hostPort":443}]}],"nodeSelector":{"ingress-ready":"true"},"tolerations":[{"key":"node-role.kubernetes.io/master","operator":"Equal","effect":"NoSchedule"}]}}}}'
79-
58+
run: kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/main/deploy/static/provider/kind/deploy.yaml
59+
8060
- name: Kubectl apply
8161
working-directory: ./ci-test
8262
run: |
83-
sed 's/image: ci-test/image: localhost:5000\/ci-test/g' k8s.yaml
84-
sed 's/image: ci-test/image: localhost:5000\/ci-test/g' k8s.yaml | kubectl apply -f -
85-
86-
- name: Sleeping 90 secs
87-
run: sleep 90
88-
89-
- name: Sleeping more in case of AMQP transporter
90-
run: sleep 180
91-
if: contains(matrix.transporter, 'AMQP')
92-
63+
# Fix nginx ingress issue: https://github.com/kubernetes/ingress-nginx/issues/5401#issuecomment-662424306
64+
kubectl delete -A ValidatingWebhookConfiguration ingress-nginx-admission
65+
sed 's/image: ci-test/image: ci-test:demo/g' k8s.yaml | kubectl apply -f -
66+
67+
- name: Sleeping 120 secs
68+
run: sleep 120
69+
9370
- name: Check pods
9471
run: kubectl get all
9572

.idea/moleculer-template-project-typescript.iml

Lines changed: 0 additions & 12 deletions
This file was deleted.

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2020 MoleculerJS
3+
Copyright (c) 2023 MoleculerJS
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ Template repo: moleculerjs/moleculer-template-project-typescript
3838
? Select a exporter solution Console
3939
? Add Docker & Kubernetes sample files? Yes
4040
? Use ESLint to lint your code? Yes
41+
Create 'moleculer-demo' folder...
42+
? Would you like to run 'npm install'? Yes
4143
```
4244

4345
## NPM scripts
@@ -55,6 +57,6 @@ Template repo: moleculerjs/moleculer-template-project-typescript
5557
moleculer-template-project-typescript is available under the [MIT license](https://tldrlegal.com/license/mit-license).
5658

5759
## Contact
58-
Copyright (c) 2020 MoleculerJS
60+
Copyright (c) 2023 MoleculerJS
5961

6062
[![@moleculerjs](https://img.shields.io/badge/github-moleculerjs-green.svg)](https://github.com/moleculerjs) [![@MoleculerJS](https://img.shields.io/badge/twitter-MoleculerJS-blue.svg)](https://twitter.com/MoleculerJS)

meta.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ module.exports = function(values) {
8585
{
8686
type: "list",
8787
name: "exporter",
88-
message: "Select a exporter solution",
88+
message: "Select an exporter solution",
8989
choices: [
9090
{ name: "Console", value: "Console" },
9191
{ name: "EventLegacy", value: "EventLegacy" },
@@ -95,7 +95,7 @@ module.exports = function(values) {
9595
{ name: "Zipkin", value: "Zipkin" },
9696
{ name: "NewRelic", value: "NewRelic" }
9797
],
98-
when(answers) { return answers.metrics; },
98+
when(answers) { return answers.tracing; },
9999
default: "Console"
100100
},
101101
{
@@ -135,6 +135,9 @@ module.exports = function(values) {
135135
"test/unit/services/products.spec.ts": "dbService",
136136

137137
".eslintrc.js": "lint",
138+
"tsconfig.eslint.json": "lint",
139+
".prettierignore": "lint",
140+
".prettierrc.json": "lint",
138141

139142
".dockerignore": "docker",
140143
"docker-compose.*": "docker",
@@ -143,7 +146,7 @@ module.exports = function(values) {
143146
},
144147

145148
completeMessage: `
146-
To get started:
149+
To get started:
147150
148151
cd {{projectName}}
149152
npm run dev

now.json

Lines changed: 0 additions & 5 deletions
This file was deleted.

package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
{
22
"name": "moleculer-template-project-typescript",
3-
"version": "2.0.0",
3+
"version": "3.0.0",
44
"description": "Project template for Moleculer-based projects with typescript",
55
"main": "meta.js",
66
"scripts": {
77
"dev": "rimraf tmp && moleculer init . tmp",
8-
"build": "moleculer init --answers test/now.sh/answers.json --install . tmp",
98
"test": "moleculer init --answers test/ci/answers.json --install . ci-test",
109
"start": "cd tmp && node node_modules/moleculer/bin/moleculer-runner services"
1110
},

template/.dockerignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@ Dockerfile
44
node_modules
55
test
66
.vscode
7+
data

0 commit comments

Comments
 (0)