@nathapp/na-cli 1.0.8 → 1.0.9

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.
Files changed (158) hide show
  1. package/dist/templates/db-schema/.gitlab-ci.yml +139 -0
  2. package/dist/templates/db-schema/Makefile +885 -0
  3. package/dist/templates/k8s-deployment/.gitlab-ci.yml +158 -0
  4. package/dist/templates/k8s-deployment/Makefile +233 -0
  5. package/dist/templates/k8s-deployment/resources/charts/mysql/charts/mysql-install/script/Makefile +12 -0
  6. package/dist/templates/k8s-deployment/resources/charts/redis/charts/redis-install/script/Makefile +8 -0
  7. package/dist/templates/k8s-deployment/services/charts/hooks/charts/pre-delete-rsc/script/Makefile +56 -0
  8. package/dist/templates/k8s-deployment/services/charts/tests/charts/e2e-test-cypress/Makefile +9 -0
  9. package/dist/templates/k8s-deployment/services/charts/tests/charts/e2e-test-js/script/Makefile +14 -0
  10. package/dist/templates/k8s-deployment/services/charts/tests/charts/e2e-test-js/tests/_t-0100-readiness-liveness.ts +84 -0
  11. package/dist/templates/k8s-deployment/services/charts/tests/charts/e2e-test-js/tests/hub.ts +372 -0
  12. package/dist/templates/k8s-deployment/services/charts/tests/charts/e2e-test-js/tests/individual-contact.ts +158 -0
  13. package/dist/templates/k8s-deployment/services/charts/tests/charts/e2e-test-js/tests/individual-contract.ts +328 -0
  14. package/dist/templates/k8s-deployment/services/charts/tests/charts/e2e-test-js/tests/individual-kyc.ts +304 -0
  15. package/dist/templates/k8s-deployment/services/charts/tests/charts/e2e-test-js/tests/individual-onboard-app.ts +823 -0
  16. package/dist/templates/k8s-deployment/services/charts/tests/charts/e2e-test-js/tests/individual-onboard-web.ts +493 -0
  17. package/dist/templates/k8s-deployment/services/charts/tests/charts/e2e-test-js/tests/individual-profile.ts +277 -0
  18. package/dist/templates/k8s-deployment/services/charts/tests/charts/e2e-test-js/tests/individual-whitelist.ts +133 -0
  19. package/dist/templates/k8s-deployment/services/charts/tests/charts/e2e-test-js/tests/t-0200-start.ts +172 -0
  20. package/dist/templates/nestjs-api/.dockerignore +9 -0
  21. package/dist/templates/nestjs-api/.env +31 -0
  22. package/dist/templates/nestjs-api/.gitlab-ci.yml +180 -0
  23. package/dist/templates/nestjs-api/.nvmrc +1 -0
  24. package/dist/templates/nestjs-api/.prettierrc +4 -0
  25. package/dist/templates/nestjs-api/Makefile +95 -0
  26. package/dist/templates/nestjs-api/nest-cli.json +10 -0
  27. package/dist/templates/nestjs-api/ormconfig.ts +18 -0
  28. package/dist/templates/nestjs-api/src/app.controller.spec.ts +24 -0
  29. package/dist/templates/nestjs-api/src/app.controller.ts +27 -0
  30. package/dist/templates/nestjs-api/src/app.module.ts +31 -0
  31. package/dist/templates/nestjs-api/src/app.service.ts +27 -0
  32. package/dist/templates/nestjs-api/src/main.ts +31 -0
  33. package/dist/templates/nestjs-api/test/app.e2e-spec.ts +47 -0
  34. package/dist/templates/nestjs-api/tsconfig.build.json +5 -0
  35. package/dist/templates/nestjs-api/tsconfig.json +28 -0
  36. package/dist/templates/nestjs-api/tsconfig.spec.json +9 -0
  37. package/dist/templates/nestjs-library/.gitlab-ci.yml +134 -0
  38. package/dist/templates/nestjs-library/.nvmrc +1 -0
  39. package/dist/templates/nestjs-library/.prettierrc +6 -0
  40. package/dist/templates/nestjs-library/Makefile +60 -0
  41. package/dist/templates/nestjs-library/lib/index.ts +2 -0
  42. package/dist/templates/nestjs-library/test/app/controller/hello.controller.spec.ts +20 -0
  43. package/dist/templates/nestjs-library/test/app/controller/hello.controller.ts +7 -0
  44. package/dist/templates/nestjs-library/tsconfig.build.json +8 -0
  45. package/dist/templates/nestjs-library/tsconfig.json +21 -0
  46. package/dist/templates/nestjs-library/tsconfig.spec.json +9 -0
  47. package/dist/templates/ts-library/.dockerignore +2 -0
  48. package/dist/templates/ts-library/.eslintrc.js +24 -0
  49. package/dist/templates/ts-library/.gitlab-ci.yml +136 -0
  50. package/dist/templates/ts-library/.prettierrc +6 -0
  51. package/dist/templates/ts-library/Makefile +58 -0
  52. package/dist/templates/ts-library/index.ts +1 -0
  53. package/dist/templates/ts-library/lib/index.ts +1 -0
  54. package/dist/templates/ts-library/lib/samples/index.ts +5 -0
  55. package/dist/templates/ts-library/lib/samples/samples-function.ts +3 -0
  56. package/dist/templates/ts-library/test/sample.e2e-spec.ts +10 -0
  57. package/dist/templates/ts-library/tsconfig.build.json +4 -0
  58. package/dist/templates/ts-library/tsconfig.json +18 -0
  59. package/dist/templates/turbo-nestjs-vuexy/.dockerignore +2 -0
  60. package/dist/templates/turbo-nestjs-vuexy/.gitignore-rename +40 -0
  61. package/dist/templates/turbo-nestjs-vuexy/.npmrc-rename +0 -0
  62. package/dist/templates/turbo-nestjs-vuexy/Makefile +48 -0
  63. package/dist/templates/vuexy-portal/.dockerignore +2 -0
  64. package/dist/templates/vuexy-portal/.env +1 -0
  65. package/dist/templates/vuexy-portal/.gitlab-ci.yml +233 -0
  66. package/dist/templates/vuexy-portal/.npmrc-rename +2 -0
  67. package/dist/templates/vuexy-portal/.nvmrc +1 -0
  68. package/dist/templates/vuexy-portal/Makefile +55 -0
  69. package/dist/templates/vuexy-portal/src/@core/composable/createUrl.ts +20 -0
  70. package/dist/templates/vuexy-portal/src/@core/composable/useCookie.ts +43 -0
  71. package/dist/templates/vuexy-portal/src/@core/composable/useGenerateImageVariant.ts +25 -0
  72. package/dist/templates/vuexy-portal/src/@core/composable/useResponsiveSidebar.ts +29 -0
  73. package/dist/templates/vuexy-portal/src/@core/composable/useSkins.ts +42 -0
  74. package/dist/templates/vuexy-portal/src/@core/enums.ts +21 -0
  75. package/dist/templates/vuexy-portal/src/@core/index.ts +43 -0
  76. package/dist/templates/vuexy-portal/src/@core/initCore.ts +93 -0
  77. package/dist/templates/vuexy-portal/src/@core/libs/apex-chart/apexCharConfig.ts +701 -0
  78. package/dist/templates/vuexy-portal/src/@core/libs/chartjs/chartjsConfig.ts +372 -0
  79. package/dist/templates/vuexy-portal/src/@core/libs/chartjs/components/BarChart.ts +58 -0
  80. package/dist/templates/vuexy-portal/src/@core/libs/chartjs/components/BubbleChart.ts +58 -0
  81. package/dist/templates/vuexy-portal/src/@core/libs/chartjs/components/DoughnutChart.ts +58 -0
  82. package/dist/templates/vuexy-portal/src/@core/libs/chartjs/components/LineChart.ts +58 -0
  83. package/dist/templates/vuexy-portal/src/@core/libs/chartjs/components/PolarAreaChart.ts +58 -0
  84. package/dist/templates/vuexy-portal/src/@core/libs/chartjs/components/RadarChart.ts +58 -0
  85. package/dist/templates/vuexy-portal/src/@core/libs/chartjs/components/ScatterChart.ts +58 -0
  86. package/dist/templates/vuexy-portal/src/@core/stores/config.ts +80 -0
  87. package/dist/templates/vuexy-portal/src/@core/types.ts +49 -0
  88. package/dist/templates/vuexy-portal/src/@core/utils/formatters.ts +48 -0
  89. package/dist/templates/vuexy-portal/src/@core/utils/helpers.ts +32 -0
  90. package/dist/templates/vuexy-portal/src/@core/utils/plugins.ts +53 -0
  91. package/dist/templates/vuexy-portal/src/@core/utils/validators.ts +105 -0
  92. package/dist/templates/vuexy-portal/src/@core/utils/vuetify.ts +13 -0
  93. package/dist/templates/vuexy-portal/src/@custom/composables/toasts.ts +45 -0
  94. package/dist/templates/vuexy-portal/src/@custom/composables/validator.ts +160 -0
  95. package/dist/templates/vuexy-portal/src/@custom/enums/index.ts +0 -0
  96. package/dist/templates/vuexy-portal/src/@custom/types/common.ts +17 -0
  97. package/dist/templates/vuexy-portal/src/@custom/types/index.ts +0 -0
  98. package/dist/templates/vuexy-portal/src/@custom/types/pagination.ts +19 -0
  99. package/dist/templates/vuexy-portal/src/@custom/types/user.ts +5 -0
  100. package/dist/templates/vuexy-portal/src/@custom/utils/formatters.ts +83 -0
  101. package/dist/templates/vuexy-portal/src/@custom/utils/index.ts +0 -0
  102. package/dist/templates/vuexy-portal/src/@custom/utils/validators.ts +51 -0
  103. package/dist/templates/vuexy-portal/src/@layouts/components.ts +11 -0
  104. package/dist/templates/vuexy-portal/src/@layouts/config.ts +43 -0
  105. package/dist/templates/vuexy-portal/src/@layouts/enums.ts +27 -0
  106. package/dist/templates/vuexy-portal/src/@layouts/index.ts +49 -0
  107. package/dist/templates/vuexy-portal/src/@layouts/plugins/casl.ts +48 -0
  108. package/dist/templates/vuexy-portal/src/@layouts/stores/config.ts +115 -0
  109. package/dist/templates/vuexy-portal/src/@layouts/symbols.ts +1 -0
  110. package/dist/templates/vuexy-portal/src/@layouts/types.ts +126 -0
  111. package/dist/templates/vuexy-portal/src/@layouts/utils.ts +180 -0
  112. package/dist/templates/vuexy-portal/src/api/api.ts +1 -0
  113. package/dist/templates/vuexy-portal/src/api/commonApi.ts +25 -0
  114. package/dist/templates/vuexy-portal/src/api/index.ts +58 -0
  115. package/dist/templates/vuexy-portal/src/api/requestInterceptor.ts +21 -0
  116. package/dist/templates/vuexy-portal/src/api/responseInterceptor.ts +52 -0
  117. package/dist/templates/vuexy-portal/src/api/types.ts +14 -0
  118. package/dist/templates/vuexy-portal/src/api/useApi.ts +68 -0
  119. package/dist/templates/vuexy-portal/src/api/useFetchApi.ts +41 -0
  120. package/dist/templates/vuexy-portal/src/api/userApi.ts +11 -0
  121. package/dist/templates/vuexy-portal/src/composables/useApiFetch.ts +48 -0
  122. package/dist/templates/vuexy-portal/src/composables/useJwt.ts +108 -0
  123. package/dist/templates/vuexy-portal/src/main.ts +17 -0
  124. package/dist/templates/vuexy-portal/src/navigation/horizontal/index.ts +5 -0
  125. package/dist/templates/vuexy-portal/src/navigation/index.ts +7 -0
  126. package/dist/templates/vuexy-portal/src/navigation/vertical/index.ts +5 -0
  127. package/dist/templates/vuexy-portal/src/plugins/1.router/additional-routes.ts +23 -0
  128. package/dist/templates/vuexy-portal/src/plugins/1.router/guards.ts +50 -0
  129. package/dist/templates/vuexy-portal/src/plugins/1.router/index.ts +45 -0
  130. package/dist/templates/vuexy-portal/src/plugins/2.pinia.ts +8 -0
  131. package/dist/templates/vuexy-portal/src/plugins/casl/ability.ts +10 -0
  132. package/dist/templates/vuexy-portal/src/plugins/casl/composables/useAbility.ts +4 -0
  133. package/dist/templates/vuexy-portal/src/plugins/casl/index.ts +14 -0
  134. package/dist/templates/vuexy-portal/src/plugins/i18n/index.ts +29 -0
  135. package/dist/templates/vuexy-portal/src/plugins/iconify/build-icons.ts +299 -0
  136. package/dist/templates/vuexy-portal/src/plugins/iconify/index.ts +5 -0
  137. package/dist/templates/vuexy-portal/src/plugins/layouts.ts +13 -0
  138. package/dist/templates/vuexy-portal/src/plugins/toast/index.ts +9 -0
  139. package/dist/templates/vuexy-portal/src/plugins/vuetify/defaults.ts +192 -0
  140. package/dist/templates/vuexy-portal/src/plugins/vuetify/icons.ts +84 -0
  141. package/dist/templates/vuexy-portal/src/plugins/vuetify/index.ts +47 -0
  142. package/dist/templates/vuexy-portal/src/plugins/vuetify/theme.ts +155 -0
  143. package/dist/templates/vuexy-portal/src/plugins/webfontloader.ts +19 -0
  144. package/dist/templates/vuexy-portal/src/stores/auth.ts +22 -0
  145. package/dist/templates/vuexy-portal/src/stores/common.ts +41 -0
  146. package/dist/templates/vuexy-portal/src/stores/index.ts +0 -0
  147. package/dist/templates/vuexy-portal/src/utils/constants.ts +3 -0
  148. package/dist/templates/vuexy-portal/src/utils/paginationMeta.ts +10 -0
  149. package/dist/templates/vuexy-portal/themeConfig.ts +66 -0
  150. package/dist/templates/vuexy-portal/tsconfig.json +86 -0
  151. package/dist/templates/vuexy-portal/vite.config.ts +111 -0
  152. package/dist/utils/template.js +2 -0
  153. package/dist/utils/template.js.map +1 -1
  154. package/package.json +4 -1
  155. package/alias-script.sh +0 -30
  156. package/bunfig.toml +0 -3
  157. package/nax/config.json +0 -23
  158. package/nax/features/enhancements/prd.json +0 -61
@@ -0,0 +1,158 @@
1
+ # Deployment must implement Makefile for commands (test, pre-install, install, review, uninstall, name, version, image)
2
+ # command:
3
+ # - test: run deployment integration test cases
4
+ # - pre-install: deploy prerelease (with commit hash) version of resources and services
5
+ # - install: deploy release version of resources and services
6
+ # - review: deploy a merge request review app (branch release, no version bump)
7
+ # - name: display deployment name
8
+ # - version: display deployment version
9
+ # - image: display deployment name and version (e.g. hello-world:1.0.0)
10
+ #
11
+ # Deploy jobs reach the cluster with KUBECONFIG, so they must run on a runner that can
12
+ # reach it (for a LAN cluster: a runner inside that LAN). Pin them with `tags:` below.
13
+ #
14
+ # Review apps run code from unprotected branches. Scope KUBECONFIG per environment in
15
+ # Settings > CI/CD > Variables: a "production" credential (protected) for run-install,
16
+ # and a "review/*" credential limited to REVIEW_KUBE_NAMESPACE for review apps.
17
+
18
+ variables:
19
+ # Any image with helm 3 + sh; make, git, npm and jq are installed when missing.
20
+ HELM_CI_IMAGE: alpine/helm:3.22.0
21
+ # Review apps never share the production namespace (created on first deploy).
22
+ REVIEW_KUBE_NAMESPACE: ${CI_KUBE_NAMESPACE}-review
23
+
24
+ .install-tools: &install-tools
25
+ - for b in make git npm jq; do command -v $b >/dev/null 2>&1 || apk add --no-cache $b; done
26
+
27
+ default:
28
+ image:
29
+ name: $HELM_CI_IMAGE
30
+ entrypoint: [""]
31
+ before_script: *install-tools
32
+ # tags:
33
+ # - <runner-tag-that-reaches-the-cluster>
34
+
35
+ stages:
36
+ - test
37
+ # run test cases
38
+ - install
39
+ # deploy helm charts
40
+ - release
41
+ # mark release commit as verified
42
+
43
+ run-lint:
44
+ stage: test
45
+ script:
46
+ - make lint
47
+ rules:
48
+ - if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
49
+ - if: '$CI_COMMIT_MESSAGE =~ /run-lint/'
50
+ # merge request
51
+ # commit message contains `run-lint`,`run-release` keyword
52
+
53
+ # Merge request review app: one release per source branch, torn down when the MR is
54
+ # merged or closed (GitLab runs on_stop), or after auto_stop_in.
55
+ run-review:
56
+ stage: install
57
+ script:
58
+ # Project-level variables override job variables, so switch the namespace here.
59
+ - export CI_KUBE_NAMESPACE="$REVIEW_KUBE_NAMESPACE"
60
+ - make review
61
+ resource_group: review/$CI_COMMIT_REF_SLUG
62
+ environment:
63
+ name: review/$CI_COMMIT_REF_SLUG
64
+ on_stop: stop-review
65
+ auto_stop_in: 1 week
66
+ rules:
67
+ - if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
68
+
69
+ # Runs without a checkout (the branch may already be deleted), so it cannot use the
70
+ # Makefile; the release name must match Makefile RELEASE_NAME (30-char cap + cksum).
71
+ # needs: [] keeps the stop action available even when an earlier stage fails.
72
+ stop-review:
73
+ stage: install
74
+ needs: []
75
+ variables:
76
+ GIT_STRATEGY: none
77
+ before_script: []
78
+ script:
79
+ - export CI_KUBE_NAMESPACE="$REVIEW_KUBE_NAMESPACE"
80
+ - RELEASE="$CI_PROJECT_NAME-$CI_COMMIT_REF_SLUG"
81
+ - if [ ${#RELEASE} -gt 30 ]; then RELEASE="$(printf '%s' "$RELEASE" | cut -c1-24 | sed 's/-*$//')-$(printf '%s' "$RELEASE" | cksum | awk '{ printf("%05d", $1 % 100000) }')"; fi
82
+ - helm uninstall -n "$CI_KUBE_NAMESPACE" "$RELEASE" || true
83
+ - helm uninstall -n "$CI_KUBE_NAMESPACE" "$RELEASE-rsc" || true
84
+ resource_group: review/$CI_COMMIT_REF_SLUG
85
+ environment:
86
+ name: review/$CI_COMMIT_REF_SLUG
87
+ action: stop
88
+ rules:
89
+ - if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
90
+ when: manual
91
+ allow_failure: true
92
+
93
+ # run-test:
94
+ # stage: test
95
+ # variables:
96
+ # CI_TEST: "true"
97
+ # script:
98
+ # - make test
99
+ # rules:
100
+ # - if: '$CI_COMMIT_MESSAGE =~ /release-rc-by-devbot|release-by-devbot/'
101
+ # when: never
102
+ # - if: '$CI_MERGE_REQUEST_TARGET_BRANCH_NAME == $CI_DEFAULT_BRANCH'
103
+ # when: never
104
+ # - if: '$CI_COMMIT_BRANCH != $CI_DEFAULT_BRANCH && $CI_COMMIT_MESSAGE =~ /run-test/'
105
+ # # merge request or commit branch is not default branch (master)
106
+ # # commit message contains `run-test` keyword
107
+
108
+ # run-pre-install:
109
+ # stage: install
110
+ # before_script:
111
+ # - *install-tools
112
+ # - git config --global user.name "$GITLAB_USER_NAME"
113
+ # - git config --global user.email "$GITLAB_USER_EMAIL"
114
+ # script:
115
+ # - make pre-install
116
+ # - git add -A
117
+ # - git commit -m "$(make version)" -m "== release-rc-by-devbot ($CI_COMMIT_SHA) =="
118
+ # - git tag -a "$(make version)" -m "$(make image)"
119
+ # - git push "https://${GITLAB_USER_NAME}:${CI_GIT_TOKEN}@${CI_REPOSITORY_URL#*@}" "HEAD:${CI_COMMIT_BRANCH}"
120
+ # - git push "https://${GITLAB_USER_NAME}:${CI_GIT_TOKEN}@${CI_REPOSITORY_URL#*@}" --tags
121
+ # rules:
122
+ # - if: '$CI_COMMIT_BRANCH && $CI_COMMIT_BRANCH != $CI_DEFAULT_BRANCH && $CI_COMMIT_MESSAGE =~ /run-prerelease/'
123
+ # # commit branch is not default branch (master) and commit message contains `run-prerelease` keyword
124
+
125
+ # run-pre-release:
126
+ # stage: release
127
+ # script:
128
+ # - echo "Prerelease version $(make version)"
129
+ # rules:
130
+ # - if: '$CI_COMMIT_TAG && $CI_COMMIT_MESSAGE =~ /release-rc-by-devbot/'
131
+ # # tag created on a non default branch and commit message contains `release-rc-by-devbot`
132
+
133
+ run-install:
134
+ stage: install
135
+ environment:
136
+ name: production
137
+ before_script:
138
+ - *install-tools
139
+ - git config --global user.name "$GITLAB_USER_NAME"
140
+ - git config --global user.email "$GITLAB_USER_EMAIL"
141
+ script:
142
+ - make install
143
+ - git add -A
144
+ - git commit -m "$(make version)" -m "== release-by-devbot ($CI_COMMIT_SHA) =="
145
+ - git tag -a "$(make version)" -m "$(make image)"
146
+ - git push "https://${GITLAB_USER_NAME}:${CI_GIT_TOKEN}@${CI_REPOSITORY_URL#*@}" "HEAD:${CI_COMMIT_BRANCH}"
147
+ - git push "https://${GITLAB_USER_NAME}:${CI_GIT_TOKEN}@${CI_REPOSITORY_URL#*@}" --tags
148
+ rules:
149
+ - if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH && $CI_COMMIT_MESSAGE =~ /run-release/'
150
+ # commit into default branch (master) and commit message contains `run-release`
151
+
152
+ run-release:
153
+ stage: release
154
+ script:
155
+ - echo "Release version $(make version)"
156
+ rules:
157
+ - if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH && $CI_COMMIT_MESSAGE =~ /release-by-devbot/'
158
+ # commit into default branch (master) and commit message contains `release-by-devbot`
@@ -0,0 +1,233 @@
1
+ MAKEFILE := $(abspath $(lastword $(MAKEFILE_LIST)))
2
+ ROOT_PATH := $(shell pwd)
3
+ # Generated helm values from the CI_* / GITLAB_* environment; override to keep runs isolated.
4
+ NA_ENV_FILE ?= /tmp/_env.yaml
5
+
6
+ .PHONY: resources services
7
+
8
+ pre-install: version-prerelease run-install
9
+ @echo "==> Testing SERVICES"
10
+ @cat $(NA_ENV_FILE) | helm test -n $(CI_KUBE_NAMESPACE) $$(make --no-print-directory -f$(MAKEFILE) RELEASE_NAME)
11
+
12
+ # Merge request review app: deploy the branch release without bumping the chart version.
13
+ review: run-install
14
+
15
+ run-debug: env
16
+ @rm -rf charts
17
+ @cp -rf resources/charts charts
18
+ @cp -rf $(NA_ENV_FILE) _env.yaml
19
+
20
+ install: version-patch run-install
21
+ @echo "==> Testing SERVICES"
22
+ @cat $(NA_ENV_FILE) | helm test -n $(CI_KUBE_NAMESPACE) $$(make --no-print-directory -f$(MAKEFILE) RELEASE_NAME)
23
+
24
+ run-install: env run-install-rsc
25
+ @echo "==> Installing SERVICES"
26
+ @rm -rf charts
27
+ @cp -rf services/charts charts
28
+ @cp -f $(NA_ENV_FILE) charts/hooks/charts/pre-delete-rsc/script/_env.yaml
29
+ @cat $(NA_ENV_FILE) | helm upgrade -n $(CI_KUBE_NAMESPACE) --install --create-namespace --atomic --timeout 10m \
30
+ -f $$(make --no-print-directory -f$(MAKEFILE) RELEASE_VALUE_FILE) -f - $$(make --no-print-directory -f$(MAKEFILE) RELEASE_NAME) .
31
+ @rm -rf charts
32
+
33
+ run-install-rsc:
34
+ @echo "==> Installing RESOURCES"
35
+ @rm -rf charts
36
+ @cp -rf resources/charts charts
37
+ @cat $(NA_ENV_FILE) | helm upgrade -n $(CI_KUBE_NAMESPACE) --install --create-namespace --atomic --timeout 10m \
38
+ -f $$(make --no-print-directory -f$(MAKEFILE) RELEASE_VALUE_FILE) -f - $$(make --no-print-directory -f$(MAKEFILE) RELEASE_NAME)-rsc .
39
+ @rm -rf charts
40
+
41
+ uninstall: env
42
+ @echo "==> Uninstalling SERVICES"
43
+ @-cat $(NA_ENV_FILE) | helm uninstall -n $(CI_KUBE_NAMESPACE) $$(make --no-print-directory -f$(MAKEFILE) RELEASE_NAME)
44
+
45
+ uninstall-rsc: env
46
+ @echo "==> Uninstalling RESOURCES"
47
+ @-helm uninstall -n $(CI_KUBE_NAMESPACE) $$(make --no-print-directory -f$(MAKEFILE) RELEASE_NAME)-rsc
48
+
49
+ lint: env run-lint
50
+
51
+ # Render-check both releases the way run-install assembles them. `helm lint` cannot be
52
+ # used: the subcharts are copied into charts/ at deploy time and are not declared as
53
+ # Chart.yaml dependencies, which helm lint reports as an error.
54
+ run-lint: run-lint-rsc
55
+ @echo "==> Lint SERVICES"
56
+ @$(MAKE) --no-print-directory -f$(MAKEFILE) render-check CHARTS_SRC=services/charts
57
+
58
+ run-lint-rsc:
59
+ @echo "==> Lint RESOURCES"
60
+ @$(MAKE) --no-print-directory -f$(MAKEFILE) render-check CHARTS_SRC=resources/charts
61
+
62
+ render-check:
63
+ @rm -rf charts
64
+ @cp -rf $(CHARTS_SRC) charts
65
+ @for values in values.yaml test-values.yaml; do \
66
+ [ -f "$$values" ] || continue; \
67
+ cat $(NA_ENV_FILE) | helm template -n "$(CI_KUBE_NAMESPACE)" -f "$$values" -f - lint . > /dev/null || { rm -rf charts; exit 1; }; \
68
+ done
69
+ @rm -rf charts
70
+
71
+ test: run-install run-test uninstall
72
+
73
+ run-test:
74
+ @echo "==> Testing SERVICES"
75
+ @cat $(NA_ENV_FILE) | helm test -n $(CI_KUBE_NAMESPACE) --logs $$(make --no-print-directory -f$(MAKEFILE) RELEASE_NAME) || \
76
+ ($$(make --no-print-directory -f$(MAKEFILE) uninstall); exit 1);
77
+
78
+ # Names over 30 chars become <first 24>-<5-digit cksum>, so branches sharing a prefix
79
+ # stay distinct and <release>-<chart> host labels stay under the 63-char DNS limit
80
+ # (chart names up to 32 chars). Keep in sync with hooks/pre-delete-rsc and stop-review.
81
+ RELEASE_NAME:
82
+ @n=$$(awk 'BEGIN{ \
83
+ if (ENVIRON["CI_COMMIT_BRANCH"] == ENVIRON["CI_DEFAULT_BRANCH"]) { \
84
+ n = ENVIRON["CI_PROJECT_NAME"] \
85
+ } \
86
+ else { \
87
+ if (ENVIRON["CI_TEST"] == "true") { \
88
+ n = ENVIRON["CI_PROJECT_NAME"] "-" ENVIRON["CI_COMMIT_SHORT_SHA"] \
89
+ } \
90
+ else { \
91
+ n = ENVIRON["CI_PROJECT_NAME"] "-" ENVIRON["CI_COMMIT_REF_SLUG"] \
92
+ } \
93
+ } \
94
+ printf("%s", n) \
95
+ }'); \
96
+ if [ $${#n} -gt 30 ]; then \
97
+ h=$$(printf '%s' "$$n" | cksum | awk '{ printf("%05d", $$1 % 100000) }'); \
98
+ n="$$(printf '%s' "$$n" | cut -c1-24 | sed 's/-*$$//')-$$h"; \
99
+ fi; \
100
+ printf '%s' "$$n"
101
+
102
+ RELEASE_VALUE_FILE:
103
+ @awk 'BEGIN{ \
104
+ if (ENVIRON["CI_COMMIT_BRANCH"] == ENVIRON["CI_DEFAULT_BRANCH"]) { \
105
+ printf("values.yaml") \
106
+ } \
107
+ else { \
108
+ printf("test-values.yaml") \
109
+ } \
110
+ }'
111
+
112
+ ## CI_RUNNER_TAGS will return "["tag1","tag2"]" which will cause error on make install
113
+ env:
114
+ @if [ ! -f "$(NA_ENV_FILE)" ]; then \
115
+ awk 'END { for (name in ENVIRON) { if (name ~ /^(CI|GITLAB|CONTAINER)/ && name != "CI_RUNNER_TAGS") print name} }' < /dev/null | \
116
+ awk 'BEGIN { \
117
+ printf("global:\n env:\n"); \
118
+ } \
119
+ { \
120
+ name = $$0; \
121
+ multiline = "0"; \
122
+ split(ENVIRON[name], chars, ""); \
123
+ for (i = 1; i <= length(ENVIRON[name]); i++) { \
124
+ if (chars[i] == "\n") { \
125
+ multiline = "1"; \
126
+ break; \
127
+ } \
128
+ } \
129
+ if (multiline == "0") { \
130
+ v = ""; \
131
+ n = split(ENVIRON[name], chars, ""); \
132
+ for (i = 1; i <= n; i++) { \
133
+ if (chars[i] == "\\") v = v "\\\\"; \
134
+ else if (chars[i] == "\"") v = v "\\\""; \
135
+ else v = v chars[i]; \
136
+ } \
137
+ printf(" %s: \"%s\"\n", name, v); \
138
+ } \
139
+ else { \
140
+ printf(" %s: |\n ", name); \
141
+ split(ENVIRON[name], chars, ""); \
142
+ for (i = 1; i <= length(ENVIRON[name]); i++) { \
143
+ if (chars[i] == "\n") { \
144
+ printf("\n "); \
145
+ } \
146
+ else { \
147
+ printf("%s", chars[i]); \
148
+ } \
149
+ } \
150
+ printf("\n"); \
151
+ } \
152
+ }' > $(NA_ENV_FILE); \
153
+ fi;
154
+
155
+ name:
156
+ @cat Chart.yaml | grep "name:" | awk -F": " '{ printf("%s",$$2) }'
157
+
158
+ separator:
159
+ @echo -n ":"
160
+
161
+ image: name separator version
162
+
163
+ version:
164
+ @cat Chart.yaml | grep "version:" | awk -F": " '{ printf("%s",$$2) }'
165
+
166
+ version-major: version-sync
167
+ @npm -s version major --no-git-tag-version
168
+ @sed -i "s/^version:.*/version: $$( cat package.json | jq -r '.version')/" Chart.yaml
169
+ @rm -rf package.json
170
+
171
+ version-minor: version-sync
172
+ @npm -s version minor --no-git-tag-version
173
+ @sed -i "s/^version:.*/version: $$( cat package.json | jq -r '.version')/" Chart.yaml
174
+ @rm -rf package.json
175
+
176
+ version-patch: version-sync
177
+ @npm -s version patch --no-git-tag-version
178
+ @sed -i "s/^version:.*/version: $$( cat package.json | jq -r '.version')/" Chart.yaml
179
+ @rm -rf package.json
180
+
181
+ version-prerelease: version-sync
182
+ @npm -s version prerelease --preid=rc --no-git-tag-version
183
+ @sed -i "s/^version:.*/version: $$( cat package.json | jq -r '.version')/" Chart.yaml
184
+ @rm -rf package.json
185
+
186
+ version-latest:
187
+ @(git tag --sort=-creatordate || echo) | awk 'NR==1 { \
188
+ split($$0, n, "-"); \
189
+ if (n[1] != "") { \
190
+ split(n[1], v, "."); \
191
+ if (v[1] ~ /^[0-9]+$$/ && v[2] ~ /^[0-9]+$$/ && v[3] ~ /^[0-9]+$$/) { \
192
+ print $$0; \
193
+ exit 0; \
194
+ } \
195
+ } \
196
+ print "1.0.0-rc.0"; \
197
+ } \
198
+ END { \
199
+ if (NR == 0) { \
200
+ print "1.0.0-rc.0"; \
201
+ } \
202
+ }'
203
+
204
+ version-sync:
205
+ @git checkout $(CI_COMMIT_BRANCH)
206
+ @git pull --tags 2>/dev/null || true
207
+ @git tag --sort=-creatordate | head -10
208
+ @echo '{"version": ""}' | jq -r --arg PKG_VERSION `make --no-print-directory -f$(MAKEFILE) version-latest` '.version=$$PKG_VERSION' > package.json;
209
+ @echo -n "Current Git tag: "; cat package.json | jq -r '.version'
210
+
211
+ resources:
212
+ @rm -rf charts
213
+ @ln -s resources/charts charts
214
+
215
+ services:
216
+ @rm -rf charts
217
+ @ln -s services/charts charts
218
+
219
+ images:
220
+ @for file in `make --no-print-directory -f$(MAKEFILE) images-file`; do \
221
+ echo `cat $$file | grep "repository:" | awk -F": " '{ gsub(/"/,"",$$2); print $$2 }'`:`cat $$file | grep "tag:" | awk -F": " '{ gsub(/"/,"",$$2); print $$2 }'`; \
222
+ done;
223
+
224
+ images-file:
225
+ ifeq ($(TARGET),*)
226
+ @for file in `find $(ROOT_PATH)/services -iname values.yaml`; do \
227
+ echo $$file | grep -v "services/charts/hooks"; \
228
+ done;
229
+ else
230
+ @for file in `find $(TARGET) -iname values.yaml`; do \
231
+ echo $$file; \
232
+ done;
233
+ endif
@@ -0,0 +1,12 @@
1
+ REPO_PATH := /tmp/repo
2
+ GIT_PATH := $(REPO_PATH)/.git
3
+
4
+ .PHONY:
5
+
6
+ install: repo
7
+ @make --no-print-directory -f$(REPO_PATH)/Makefile install ROOT_PATH=$(REPO_PATH);
8
+
9
+ # Clone Git repo according to target version
10
+ repo:
11
+ @git clone -q -b "$(GIT_TAG)" https://$(GITLAB_USER_NAME):$(CI_GIT_TOKEN)@$(GIT_REPO) $(REPO_PATH)
12
+ @git --git-dir=$(GIT_PATH) pull --tags 2>/dev/null || true
@@ -0,0 +1,8 @@
1
+ MAKEFILE := $(abspath $(lastword $(MAKEFILE_LIST)))
2
+
3
+ .PHONY:
4
+
5
+ install:
6
+ @echo "==> REDIS installation in progress..."
7
+ @echo "config set notify-keyspace-events AK" | redis-cli -u "$(HOST_URL)"
8
+ @echo "==> REDIS has been installed"
@@ -0,0 +1,56 @@
1
+
2
+ ROOT_PATH := $(shell pwd)
3
+
4
+ .PHONY:
5
+
6
+ uninstall:
7
+ @helm -n "$$(make --no-print-directory CI_KUBE_NAMESPACE)" uninstall "$$(make --no-print-directory RELEASE_NAME)"-rsc
8
+
9
+ # Same 30-char cap + checksum as the deployment Makefile RELEASE_NAME (keep in sync).
10
+ RELEASE_NAME:
11
+ @n=$$(CI_COMMIT_BRANCH="$$(make --no-print-directory CI_COMMIT_BRANCH)" \
12
+ CI_DEFAULT_BRANCH="$$(make --no-print-directory CI_DEFAULT_BRANCH)" \
13
+ CI_PROJECT_NAME="$$(make --no-print-directory CI_PROJECT_NAME)" \
14
+ CI_COMMIT_SHORT_SHA="$$(make --no-print-directory CI_COMMIT_SHORT_SHA)" \
15
+ CI_COMMIT_REF_SLUG="$$(make --no-print-directory CI_COMMIT_REF_SLUG)" \
16
+ CI_TEST="$$(make --no-print-directory CI_TEST)" \
17
+ awk 'BEGIN{ \
18
+ if (ENVIRON["CI_COMMIT_BRANCH"] == ENVIRON["CI_DEFAULT_BRANCH"]) { \
19
+ n = ENVIRON["CI_PROJECT_NAME"] \
20
+ } \
21
+ else { \
22
+ if (ENVIRON["CI_TEST"] == "true") { \
23
+ n = ENVIRON["CI_PROJECT_NAME"] "-" ENVIRON["CI_COMMIT_SHORT_SHA"] \
24
+ } \
25
+ else { \
26
+ n = ENVIRON["CI_PROJECT_NAME"] "-" ENVIRON["CI_COMMIT_REF_SLUG"] \
27
+ } \
28
+ } \
29
+ printf("%s", n) \
30
+ }'); \
31
+ if [ $${#n} -gt 30 ]; then \
32
+ h=$$(printf '%s' "$$n" | cksum | awk '{ printf("%05d", $$1 % 100000) }'); \
33
+ n="$$(printf '%s' "$$n" | cut -c1-24 | sed 's/-*$$//')-$$h"; \
34
+ fi; \
35
+ printf '%s' "$$n"
36
+
37
+ CI_KUBE_NAMESPACE:
38
+ @cat _env.yaml | grep "CI_KUBE_NAMESPACE: " | awk -F": \"" '{v=substr($$2,0,length($$2)-1);printf("%s",v)}'
39
+
40
+ CI_PROJECT_NAME:
41
+ @cat _env.yaml | grep "CI_PROJECT_NAME: " | awk -F": \"" '{v=substr($$2,0,length($$2)-1);printf("%s",v)}'
42
+
43
+ CI_COMMIT_SHORT_SHA:
44
+ @cat _env.yaml | grep "CI_COMMIT_SHORT_SHA: " | awk -F": \"" '{v=substr($$2,0,length($$2)-1);printf("%s",v)}'
45
+
46
+ CI_COMMIT_BRANCH:
47
+ @cat _env.yaml | grep "CI_COMMIT_BRANCH: " | awk -F": \"" '{v=substr($$2,0,length($$2)-1);printf("%s",v)}'
48
+
49
+ CI_DEFAULT_BRANCH:
50
+ @cat _env.yaml | grep "CI_DEFAULT_BRANCH: " | awk -F": \"" '{v=substr($$2,0,length($$2)-1);printf("%s",v)}'
51
+
52
+ CI_TEST:
53
+ @cat _env.yaml | grep "CI_TEST: " | awk -F": \"" '{v=substr($$2,0,length($$2)-1);printf("%s",v)}'
54
+
55
+ CI_COMMIT_REF_SLUG:
56
+ @cat _env.yaml | grep "CI_COMMIT_REF_SLUG: " | awk -F": \"" '{v=substr($$2,0,length($$2)-1);printf("%s",v)}'
@@ -0,0 +1,9 @@
1
+ MAKEFILE := $(abspath $(lastword $(MAKEFILE_LIST)))
2
+ ROOT_PATH := $(shell pwd)
3
+
4
+ IMAGE := registry-intl.cn-hongkong.aliyuncs.com/d_mxw/cypress-base:0.0.1-rc.0
5
+
6
+ .PHONY: dev
7
+
8
+ dev:
9
+ docker run -it --rm -v $(ROOT_PATH)/cypress:/cypress $(IMAGE) sh
@@ -0,0 +1,14 @@
1
+ MAKEFILE := $(abspath $(lastword $(MAKEFILE_LIST)))
2
+ ROOT_PATH := $(shell pwd)
3
+
4
+ .PHONY:
5
+
6
+ start:
7
+ @getent hosts $(SERVICE_BASE_INGRESS) | awk '{ \
8
+ printf("%s %s\n%s %s\n%s %s\n", \
9
+ $$1, ENVIRON["SERVICE_BASE_DOMAIN"], \
10
+ $$1, ENVIRON["MXW_SERVICE_BASE_DOMAIN"], \
11
+ $$1, ENVIRON["EMAIL_SERVER_DOMAIN"] \
12
+ ); \
13
+ }' >> /etc/hosts
14
+ @npm -s run test
@@ -0,0 +1,84 @@
1
+ 'use strict';
2
+
3
+ import { describe, it } from 'mocha';
4
+ import chai, { expect } from 'chai';
5
+ import chaihttp from 'chai-http';
6
+
7
+ chai.use(chaihttp);
8
+
9
+ let debug = (process.env.CI_DEBUG === "true");
10
+
11
+ describe('Suite: Initialize', function () {
12
+ if (debug) {
13
+ process.env.SERVICE_BASE_SCHEMA = "https";
14
+ process.env.SERVICE_BASE_DOMAIN = "dev-hk-service.usdp.io";
15
+ process.env.SERVICE_BASE_NAME = "bdss";
16
+
17
+ process.env.MXW_SERVICE_BASE_SCHEMA = "https";
18
+ process.env.MXW_SERVICE_BASE_DOMAIN = "dev-hk-service.usdp.io";
19
+ process.env.MXW_SERVICE_BASE_NAME = "mxw";
20
+ }
21
+ });
22
+
23
+ describe('Suite: Readiness & Liveness', function () {
24
+ let services: {
25
+ title: string,
26
+ name: string,
27
+ resolve: Function,
28
+ path: string
29
+ }[] = [
30
+ { title: "Auth", name: "auth-api", resolve: serviceUrl, path: "/auth/api" },
31
+ { title: "Auth Web", name: "auth-web-api", resolve: serviceUrl, path: "" },
32
+ { title: "Captcha", name: "captcha-api", resolve: serviceUrl, path: "/auth-web/api" },
33
+ { title: "NFS Storage", name: "nfs-storage-api", resolve: serviceUrl, path: "/nfs/storage/api" },
34
+ { title: "Storage Doc", name: "storage-doc-api", resolve: serviceUrl, path: "/storage/local/doc/api" },
35
+ { title: "Storage Doc Auth", name: "storage-doc-auth-api", resolve: serviceUrl, path: "" },
36
+ { title: "Storage Public", name: "storage-pub-api", resolve: serviceUrl, path: "/storage/local/pub/api" },
37
+ { title: "Storage Public Auth", name: "storage-pub-auth-api", resolve: serviceUrl, path: "" },
38
+ { title: "RT", name: "rt-api", resolve: serviceUrl, path: "/rt" },
39
+ { title: "RT Gateway", name: "rt-gateway-api", resolve: serviceUrl, path: "" },
40
+ { title: "Push Notify App Firebase", name: "push-notify-app-firebase-api", resolve: serviceUrl, path: "/notify/firebase/push-service" },
41
+ { title: "Push Notify Firebase", name: "push-notify-firebase-api", resolve: serviceUrl, path: "" },
42
+
43
+ { title: "Contract", name: "contract-api", resolve: serviceUrl, path: "/contract/api" },
44
+ { title: "Signature", name: "signature-api", resolve: serviceUrl, path: "/signature/api" },
45
+ { title: "User", name: "user-api", resolve: serviceUrl, path: "/user/api" },
46
+ { title: "Workflow", name: "workflow-api", resolve: serviceUrl, path: "" },
47
+ { title: "Object", name: "dms-object-api", resolve: serviceUrl, path: "/object/api" },
48
+
49
+ { title: "KYC Provider", name: "mxw-kyc-provider-api", resolve: mxwServiceUrl, path: "/provider/kyc/v2" },
50
+ { title: "Wallet", name: "mxw-wallet-api", resolve: mxwServiceUrl, path: "/wallet/api" }
51
+ ];
52
+
53
+ for (let service of services) {
54
+ it(service.title + " - " + service.name, function () {
55
+ let url = service.resolve(service.name, service.path);
56
+
57
+ if (url) {
58
+ return chai.request(url).get("/readiness")
59
+ .then((res) => {
60
+ expect(res).to.have.status(200);
61
+ expect(res.body).is.empty;
62
+
63
+ return chai.request(url).get("/liveness")
64
+ .then((res) => {
65
+ expect(res).to.have.status(200);
66
+ expect(res.body).is.empty;
67
+ });
68
+ });
69
+ }
70
+ });
71
+ }
72
+ });
73
+
74
+ function serviceUrl(name: string, path: string) {
75
+ if (path) {
76
+ return process.env.SERVICE_BASE_SCHEMA + "://" + process.env.SERVICE_BASE_DOMAIN + "/" + process.env.SERVICE_BASE_NAME + path;
77
+ }
78
+ }
79
+
80
+ function mxwServiceUrl(name: string, path: string) {
81
+ if (path) {
82
+ return process.env.MXW_SERVICE_BASE_SCHEMA + "://" + process.env.MXW_SERVICE_BASE_DOMAIN + "/" + process.env.MXW_SERVICE_BASE_NAME + path;
83
+ }
84
+ }