@nathapp/na-cli 1.0.0-rc.4 → 1.0.0-rc.40
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 +135 -0
- package/Makefile +16 -9
- package/README.md +18 -2
- package/alias-script.sh +30 -0
- package/dist/index.js +106 -128
- package/dist/index.js.map +1 -1
- package/dist/templates/db-schema/.gitignore-rename +1 -0
- package/dist/templates/db-schema/.gitlab-ci.yml +139 -0
- package/dist/templates/db-schema/001_Schema.sql +1 -0
- package/dist/templates/db-schema/DEV_MODE.txt +1 -0
- package/dist/templates/db-schema/Dockerfile +3 -0
- package/dist/templates/db-schema/Email-Templates/Individual/README.md +1 -0
- package/dist/templates/db-schema/GET_VERSION.sql +47 -0
- package/dist/templates/db-schema/Makefile +885 -0
- package/dist/templates/db-schema/README.md +117 -0
- package/dist/templates/db-schema/SET_VERSION.sql +5 -0
- package/dist/templates/db-schema/docker-compose.yaml +47 -0
- package/dist/templates/db-schema/package.json +3 -0
- package/dist/templates/db-schema/push.sh +0 -0
- package/dist/templates/db-schema/samples/899_DB_Grant_User.sql +9 -0
- package/dist/templates/db-schema/samples/990_SAMPLE_Init_Data.sql +27 -0
- package/dist/templates/k8s-deployment/.gitignore-rename +1 -0
- package/dist/templates/k8s-deployment/.gitlab-ci.yml +128 -0
- package/dist/templates/k8s-deployment/.helmignore +23 -0
- package/dist/templates/k8s-deployment/Chart.yaml +23 -0
- package/dist/templates/k8s-deployment/Makefile +196 -0
- package/dist/templates/k8s-deployment/README.md +32 -0
- package/dist/templates/k8s-deployment/resources/charts/mysql/Chart.yaml +23 -0
- package/dist/templates/k8s-deployment/resources/charts/mysql/charts/mysql-install/Chart.yaml +23 -0
- package/dist/templates/k8s-deployment/resources/charts/mysql/charts/mysql-install/script/Makefile +12 -0
- package/dist/templates/k8s-deployment/resources/charts/mysql/charts/mysql-install/templates/_helpers.tpl +62 -0
- package/dist/templates/k8s-deployment/resources/charts/mysql/charts/mysql-install/templates/configmap.yaml +1 -0
- package/dist/templates/k8s-deployment/resources/charts/mysql/charts/mysql-install/templates/job.yaml +1 -0
- package/dist/templates/k8s-deployment/resources/charts/mysql/charts/mysql-install/templates/secret.yaml +1 -0
- package/dist/templates/k8s-deployment/resources/charts/mysql/charts/mysql-install/values.yaml +51 -0
- package/dist/templates/k8s-deployment/resources/charts/mysql/templates/_helpers.tpl +62 -0
- package/dist/templates/k8s-deployment/resources/charts/mysql/templates/configmap.yaml +1 -0
- package/dist/templates/k8s-deployment/resources/charts/mysql/templates/deployment.yaml +1 -0
- package/dist/templates/k8s-deployment/resources/charts/mysql/templates/ingress.yaml +1 -0
- package/dist/templates/k8s-deployment/resources/charts/mysql/templates/job.yaml +1 -0
- package/dist/templates/k8s-deployment/resources/charts/mysql/templates/pv.yaml +1 -0
- package/dist/templates/k8s-deployment/resources/charts/mysql/templates/pvc.yaml +1 -0
- package/dist/templates/k8s-deployment/resources/charts/mysql/templates/sc.yaml +1 -0
- package/dist/templates/k8s-deployment/resources/charts/mysql/templates/secret.yaml +1 -0
- package/dist/templates/k8s-deployment/resources/charts/mysql/templates/service.yaml +1 -0
- package/dist/templates/k8s-deployment/resources/charts/mysql/templates/statefulset.yaml +1 -0
- package/dist/templates/k8s-deployment/resources/charts/mysql/values.yaml +15 -0
- package/dist/templates/k8s-deployment/resources/charts/redis/Chart.yaml +23 -0
- package/dist/templates/k8s-deployment/resources/charts/redis/charts/redis-install/Chart.yaml +23 -0
- package/dist/templates/k8s-deployment/resources/charts/redis/charts/redis-install/script/Makefile +8 -0
- package/dist/templates/k8s-deployment/resources/charts/redis/charts/redis-install/templates/_helpers.tpl +62 -0
- package/dist/templates/k8s-deployment/resources/charts/redis/charts/redis-install/templates/configmap.yaml +1 -0
- package/dist/templates/k8s-deployment/resources/charts/redis/charts/redis-install/templates/job.yaml +1 -0
- package/dist/templates/k8s-deployment/resources/charts/redis/charts/redis-install/templates/secret.yaml +1 -0
- package/dist/templates/k8s-deployment/resources/charts/redis/charts/redis-install/values.yaml +42 -0
- package/dist/templates/k8s-deployment/resources/charts/redis/templates/_helpers.tpl +62 -0
- package/dist/templates/k8s-deployment/resources/charts/redis/templates/configmap.yaml +1 -0
- package/dist/templates/k8s-deployment/resources/charts/redis/templates/deployment.yaml +1 -0
- package/dist/templates/k8s-deployment/resources/charts/redis/templates/ingress.yaml +1 -0
- package/dist/templates/k8s-deployment/resources/charts/redis/templates/job.yaml +1 -0
- package/dist/templates/k8s-deployment/resources/charts/redis/templates/pv.yaml +1 -0
- package/dist/templates/k8s-deployment/resources/charts/redis/templates/pvc.yaml +1 -0
- package/dist/templates/k8s-deployment/resources/charts/redis/templates/sc.yaml +1 -0
- package/dist/templates/k8s-deployment/resources/charts/redis/templates/secret.yaml +1 -0
- package/dist/templates/k8s-deployment/resources/charts/redis/templates/service.yaml +1 -0
- package/dist/templates/k8s-deployment/resources/charts/redis/templates/statefulset.yaml +1 -0
- package/dist/templates/k8s-deployment/resources/charts/redis/values.yaml +12 -0
- package/dist/templates/k8s-deployment/services/charts/hooks/Chart.yaml +23 -0
- package/dist/templates/k8s-deployment/services/charts/hooks/charts/pre-delete-rsc/Chart.yaml +23 -0
- package/dist/templates/k8s-deployment/services/charts/hooks/charts/pre-delete-rsc/script/Makefile +49 -0
- package/dist/templates/k8s-deployment/services/charts/hooks/charts/pre-delete-rsc/script/_env.yaml +2 -0
- package/dist/templates/k8s-deployment/services/charts/hooks/charts/pre-delete-rsc/templates/_helpers.tpl +62 -0
- package/dist/templates/k8s-deployment/services/charts/hooks/charts/pre-delete-rsc/templates/configmap.yaml +1 -0
- package/dist/templates/k8s-deployment/services/charts/hooks/charts/pre-delete-rsc/templates/job.yaml +1 -0
- package/dist/templates/k8s-deployment/services/charts/hooks/charts/pre-delete-rsc/templates/secret.yaml +1 -0
- package/dist/templates/k8s-deployment/services/charts/hooks/charts/pre-delete-rsc/values.yaml +36 -0
- package/dist/templates/k8s-deployment/services/charts/sample-nginx/Chart.yaml +23 -0
- package/dist/templates/k8s-deployment/services/charts/sample-nginx/templates/_helpers.tpl +62 -0
- package/dist/templates/k8s-deployment/services/charts/sample-nginx/templates/cluster-role-binding.yaml +1 -0
- package/dist/templates/k8s-deployment/services/charts/sample-nginx/templates/configmap.yaml +1 -0
- package/dist/templates/k8s-deployment/services/charts/sample-nginx/templates/cronjob.yaml +1 -0
- package/dist/templates/k8s-deployment/services/charts/sample-nginx/templates/deployment.yaml +1 -0
- package/dist/templates/k8s-deployment/services/charts/sample-nginx/templates/ingress.yaml +1 -0
- package/dist/templates/k8s-deployment/services/charts/sample-nginx/templates/pv.yaml +1 -0
- package/dist/templates/k8s-deployment/services/charts/sample-nginx/templates/pvc.yaml +1 -0
- package/dist/templates/k8s-deployment/services/charts/sample-nginx/templates/sc.yaml +1 -0
- package/dist/templates/k8s-deployment/services/charts/sample-nginx/templates/secret.yaml +1 -0
- package/dist/templates/k8s-deployment/services/charts/sample-nginx/templates/service-account.yaml +1 -0
- package/dist/templates/k8s-deployment/services/charts/sample-nginx/templates/service.yaml +1 -0
- package/dist/templates/k8s-deployment/services/charts/sample-nginx/templates/statefulset.yaml +1 -0
- package/dist/templates/k8s-deployment/services/charts/sample-nginx/values.yaml +47 -0
- package/dist/templates/k8s-deployment/services/charts/tests/Chart.yaml +23 -0
- package/dist/templates/k8s-deployment/services/charts/tests/charts/e2e-test-cypress/Chart.yaml +23 -0
- package/dist/templates/k8s-deployment/services/charts/tests/charts/e2e-test-cypress/Makefile +9 -0
- package/dist/templates/k8s-deployment/services/charts/tests/charts/e2e-test-cypress/cypress/fixtures/index.json +1 -0
- package/dist/templates/k8s-deployment/services/charts/tests/charts/e2e-test-cypress/cypress/integration/login/login-spec.js +47 -0
- package/dist/templates/k8s-deployment/services/charts/tests/charts/e2e-test-cypress/cypress/integration/login/loginEmailWrong-spec.js +14 -0
- package/dist/templates/k8s-deployment/services/charts/tests/charts/e2e-test-cypress/cypress/integration/login/loginPasswordWrong-spec.js +14 -0
- package/dist/templates/k8s-deployment/services/charts/tests/charts/e2e-test-cypress/cypress/integration/profile/updatePassword-spec.js +15 -0
- package/dist/templates/k8s-deployment/services/charts/tests/charts/e2e-test-cypress/cypress/integration/profile/updateProfile-spec.js +25 -0
- package/dist/templates/k8s-deployment/services/charts/tests/charts/e2e-test-cypress/cypress/integration/test-script.spec.js +9 -0
- package/dist/templates/k8s-deployment/services/charts/tests/charts/e2e-test-cypress/cypress/plugins/index.js +22 -0
- package/dist/templates/k8s-deployment/services/charts/tests/charts/e2e-test-cypress/cypress/support/commands.js +258 -0
- package/dist/templates/k8s-deployment/services/charts/tests/charts/e2e-test-cypress/cypress/support/index.js +35 -0
- package/dist/templates/k8s-deployment/services/charts/tests/charts/e2e-test-cypress/cypress/support/misc.js +8 -0
- package/dist/templates/k8s-deployment/services/charts/tests/charts/e2e-test-cypress/cypress.json +4 -0
- package/dist/templates/k8s-deployment/services/charts/tests/charts/e2e-test-cypress/templates/_helpers.tpl +62 -0
- package/dist/templates/k8s-deployment/services/charts/tests/charts/e2e-test-cypress/templates/configmap.yaml +1 -0
- package/dist/templates/k8s-deployment/services/charts/tests/charts/e2e-test-cypress/templates/pod.yaml +1 -0
- package/dist/templates/k8s-deployment/services/charts/tests/charts/e2e-test-cypress/templates/secret.yaml +1 -0
- package/dist/templates/k8s-deployment/services/charts/tests/charts/e2e-test-cypress/values.yaml +70 -0
- package/dist/templates/k8s-deployment/services/charts/tests/charts/e2e-test-js/.helmignore +2 -0
- package/dist/templates/k8s-deployment/services/charts/tests/charts/e2e-test-js/Chart.yaml +23 -0
- package/dist/templates/k8s-deployment/services/charts/tests/charts/e2e-test-js/script/Makefile +14 -0
- package/dist/templates/k8s-deployment/services/charts/tests/charts/e2e-test-js/templates/_helpers.tpl +62 -0
- package/dist/templates/k8s-deployment/services/charts/tests/charts/e2e-test-js/templates/configmap.yaml +1 -0
- package/dist/templates/k8s-deployment/services/charts/tests/charts/e2e-test-js/templates/pod.yaml +1 -0
- package/dist/templates/k8s-deployment/services/charts/tests/charts/e2e-test-js/templates/secret.yaml +1 -0
- package/dist/templates/k8s-deployment/services/charts/tests/charts/e2e-test-js/tests/_t-0100-readiness-liveness.ts +84 -0
- package/dist/templates/k8s-deployment/services/charts/tests/charts/e2e-test-js/tests/hub.ts +372 -0
- package/dist/templates/k8s-deployment/services/charts/tests/charts/e2e-test-js/tests/individual-contact.ts +158 -0
- package/dist/templates/k8s-deployment/services/charts/tests/charts/e2e-test-js/tests/individual-contract.ts +328 -0
- package/dist/templates/k8s-deployment/services/charts/tests/charts/e2e-test-js/tests/individual-kyc.ts +304 -0
- package/dist/templates/k8s-deployment/services/charts/tests/charts/e2e-test-js/tests/individual-onboard-app.ts +823 -0
- package/dist/templates/k8s-deployment/services/charts/tests/charts/e2e-test-js/tests/individual-onboard-web.ts +493 -0
- package/dist/templates/k8s-deployment/services/charts/tests/charts/e2e-test-js/tests/individual-profile.ts +277 -0
- package/dist/templates/k8s-deployment/services/charts/tests/charts/e2e-test-js/tests/individual-whitelist.ts +133 -0
- package/dist/templates/k8s-deployment/services/charts/tests/charts/e2e-test-js/tests/resources/live.jpg +0 -0
- package/dist/templates/k8s-deployment/services/charts/tests/charts/e2e-test-js/tests/resources/mykad_front.jpg +0 -0
- package/dist/templates/k8s-deployment/services/charts/tests/charts/e2e-test-js/tests/resources/profile.jpg +0 -0
- package/dist/templates/k8s-deployment/services/charts/tests/charts/e2e-test-js/tests/t-0200-start.ts +172 -0
- package/dist/templates/k8s-deployment/services/charts/tests/charts/e2e-test-js/values.yaml +59 -0
- package/dist/templates/k8s-deployment/templates/_cluster-role-binding.tpl +20 -0
- package/dist/templates/k8s-deployment/templates/_configmap.tpl +37 -0
- package/dist/templates/k8s-deployment/templates/_cronjob.tpl +225 -0
- package/dist/templates/k8s-deployment/templates/_deployment.tpl +246 -0
- package/dist/templates/k8s-deployment/templates/_helpers.tpl +31 -0
- package/dist/templates/k8s-deployment/templates/_ingress.tpl +77 -0
- package/dist/templates/k8s-deployment/templates/_job.tpl +233 -0
- package/dist/templates/k8s-deployment/templates/_pod.tpl +214 -0
- package/dist/templates/k8s-deployment/templates/_pv.tpl +42 -0
- package/dist/templates/k8s-deployment/templates/_pvc.tpl +27 -0
- package/dist/templates/k8s-deployment/templates/_root.tpl +314 -0
- package/dist/templates/k8s-deployment/templates/_sc.tpl +19 -0
- package/dist/templates/k8s-deployment/templates/_secret.tpl +15 -0
- package/dist/templates/k8s-deployment/templates/_service-account.tpl +8 -0
- package/dist/templates/k8s-deployment/templates/_service.tpl +40 -0
- package/dist/templates/k8s-deployment/templates/_statefulset.tpl +244 -0
- package/dist/templates/k8s-deployment/templates/root-cm.yaml +10 -0
- package/dist/templates/k8s-deployment/templates/root-pull-secret.yaml +11 -0
- package/dist/templates/k8s-deployment/templates/root-secret.yaml +24 -0
- package/dist/templates/k8s-deployment/values.yaml +38 -0
- package/dist/templates/k8s-helm-chart/Chart.yaml +23 -0
- package/dist/templates/k8s-helm-chart/templates/_helpers.tpl +62 -0
- package/dist/templates/k8s-helm-chart/templates/cluster-role-binding.yaml +1 -0
- package/dist/templates/k8s-helm-chart/templates/configmap.yaml +1 -0
- package/dist/templates/k8s-helm-chart/templates/cronjob.yaml +1 -0
- package/dist/templates/k8s-helm-chart/templates/deployment.yaml +1 -0
- package/dist/templates/k8s-helm-chart/templates/ingress.yaml +1 -0
- package/dist/templates/k8s-helm-chart/templates/pv.yaml +1 -0
- package/dist/templates/k8s-helm-chart/templates/pvc.yaml +1 -0
- package/dist/templates/k8s-helm-chart/templates/sc.yaml +1 -0
- package/dist/templates/k8s-helm-chart/templates/secret.yaml +1 -0
- package/dist/templates/k8s-helm-chart/templates/service-account.yaml +1 -0
- package/dist/templates/k8s-helm-chart/templates/service.yaml +1 -0
- package/dist/templates/k8s-helm-chart/templates/statefulset.yaml +1 -0
- package/dist/templates/k8s-helm-chart/values.yaml +41 -0
- package/dist/templates/mxw-base-api-express/.dockerignore +2 -0
- package/dist/templates/mxw-base-api-express/.env +10 -0
- package/dist/templates/mxw-base-api-express/.gitignore-rename +3 -0
- package/dist/templates/mxw-base-api-express/.gitlab-ci.yml +174 -0
- package/dist/templates/mxw-base-api-express/.nvmrc +1 -0
- package/dist/templates/mxw-base-api-express/Dockerfile +14 -0
- package/dist/templates/mxw-base-api-express/Makefile +84 -0
- package/dist/templates/mxw-base-api-express/README.md +71 -0
- package/dist/templates/mxw-base-api-express/package.json +55 -0
- package/dist/templates/mxw-base-api-express/src/app-service.test.ts +94 -0
- package/dist/templates/mxw-base-api-express/src/app-service.ts +498 -0
- package/dist/templates/mxw-base-api-express/src/auth/auth-user.test.ts +215 -0
- package/dist/templates/mxw-base-api-express/src/auth/auth-user.ts +86 -0
- package/dist/templates/mxw-base-api-express/src/auth/auth.ts +81 -0
- package/dist/templates/mxw-base-api-express/src/core-service.ts +72 -0
- package/dist/templates/mxw-base-api-express/src/crud.ts +84 -0
- package/dist/templates/mxw-base-api-express/src/http-handler.ts +71 -0
- package/dist/templates/mxw-base-api-express/src/server.ts +54 -0
- package/dist/templates/mxw-base-api-express/src/test.ts +38 -0
- package/dist/templates/mxw-base-api-express/src/utils/api-utilities.ts +52 -0
- package/dist/templates/mxw-base-api-express/src/utils/file-utilities.ts +55 -0
- package/dist/templates/mxw-base-api-express/tsconfig.json +32 -0
- package/dist/templates/nestjs-api/.dockerignore +2 -0
- package/dist/templates/nestjs-api/.env +12 -0
- package/dist/templates/nestjs-api/.eslintrc.js +25 -0
- package/dist/templates/nestjs-api/.gitignore-rename +35 -0
- package/dist/templates/nestjs-api/.gitlab-ci.yml +174 -0
- package/dist/templates/nestjs-api/.nvmrc +1 -0
- package/dist/templates/nestjs-api/.prettierrc +4 -0
- package/dist/templates/nestjs-api/Dockerfile +19 -0
- package/dist/templates/nestjs-api/Makefile +84 -0
- package/dist/templates/nestjs-api/README.md +67 -0
- package/dist/templates/nestjs-api/nest-cli.json +8 -0
- package/dist/templates/nestjs-api/package.json +75 -0
- package/dist/templates/nestjs-api/src/app.controller.spec.ts +22 -0
- package/dist/templates/nestjs-api/src/app.controller.ts +27 -0
- package/dist/templates/nestjs-api/src/app.module.ts +10 -0
- package/dist/templates/nestjs-api/src/app.service.ts +12 -0
- package/dist/templates/nestjs-api/src/main.ts +31 -0
- package/dist/templates/nestjs-api/test/app.e2e-spec.ts +24 -0
- package/dist/templates/nestjs-api/test/jest-e2e.json +9 -0
- package/dist/templates/nestjs-api/tsconfig.build.json +4 -0
- package/dist/templates/nestjs-api/tsconfig.json +22 -0
- package/dist/templates/nestjs-library/.eslintrc.js +24 -0
- package/dist/templates/nestjs-library/.gitignore-rename +39 -0
- package/dist/templates/nestjs-library/.gitlab-ci.yml +135 -0
- package/dist/templates/nestjs-library/.npmignore-rename +30 -0
- package/dist/templates/nestjs-library/.prettierrc +6 -0
- package/dist/templates/nestjs-library/LICENSE +21 -0
- package/dist/templates/nestjs-library/Makefile +60 -0
- package/dist/templates/nestjs-library/README.md +3 -0
- package/dist/templates/nestjs-library/index.d.ts +1 -0
- package/dist/templates/nestjs-library/index.js +6 -0
- package/dist/templates/nestjs-library/index.ts +1 -0
- package/dist/templates/nestjs-library/lib/index.ts +2 -0
- package/dist/templates/nestjs-library/package.json +43 -0
- package/dist/templates/nestjs-library/tsconfig.build.json +4 -0
- package/dist/templates/nestjs-library/tsconfig.json +18 -0
- package/dist/templates/ts-library/.dockerignore +2 -0
- package/dist/templates/ts-library/.eslintrc.js +24 -0
- package/dist/templates/ts-library/.gitignore-rename +37 -0
- package/dist/templates/ts-library/.gitlab-ci.yml +135 -0
- package/dist/templates/ts-library/.npmignore-rename +30 -0
- package/dist/templates/ts-library/.prettierrc +6 -0
- package/dist/templates/ts-library/LICENSE +21 -0
- package/dist/templates/ts-library/Makefile +58 -0
- package/dist/templates/ts-library/README.md +1 -0
- package/dist/templates/ts-library/index.d.ts +1 -0
- package/dist/templates/ts-library/index.js +6 -0
- package/dist/templates/ts-library/index.ts +1 -0
- package/dist/templates/ts-library/lib/index.ts +1 -0
- package/dist/templates/ts-library/lib/samples/index.ts +5 -0
- package/dist/templates/ts-library/lib/samples/samples-function.ts +3 -0
- package/dist/templates/ts-library/package.json +34 -0
- package/dist/templates/ts-library/test/jest-e2e.json +9 -0
- package/dist/templates/ts-library/test/sample.e2e-spec.ts +10 -0
- package/dist/templates/ts-library/tsconfig.build.json +4 -0
- package/dist/templates/ts-library/tsconfig.json +18 -0
- package/dist/utils/env.js +146 -0
- package/dist/utils/env.js.map +1 -0
- package/dist/utils/template.js +362 -1
- package/dist/utils/template.js.map +1 -1
- package/package.json +9 -5
- package/src/index.ts +0 -182
- package/src/utils/template.ts +0 -9
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
stages:
|
|
2
|
+
- test
|
|
3
|
+
# run test cases
|
|
4
|
+
- prepare
|
|
5
|
+
- build
|
|
6
|
+
- build-commit
|
|
7
|
+
- release
|
|
8
|
+
- notify
|
|
9
|
+
|
|
10
|
+
run-test:
|
|
11
|
+
stage: test
|
|
12
|
+
image: node:10.13.0-jessie
|
|
13
|
+
script:
|
|
14
|
+
- make test
|
|
15
|
+
rules:
|
|
16
|
+
- if: '$CI_COMMIT_MESSAGE =~ /release-by-bot/'
|
|
17
|
+
when: never
|
|
18
|
+
- if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
|
|
19
|
+
- if: '$CI_COMMIT_REF_PROTECTED == "true"'
|
|
20
|
+
- if: '$CI_COMMIT_MESSAGE =~ /run-test/'
|
|
21
|
+
- if: '$CI_COMMIT_MESSAGE =~ /run-prerelease/ && $CI_COMMIT_BRANCH != $CI_DEFAULT_BRANCH'
|
|
22
|
+
- if: '$CI_COMMIT_MESSAGE =~ /run-release/ && $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH'
|
|
23
|
+
# NOT triggerred by bot
|
|
24
|
+
# merge request
|
|
25
|
+
# commit to protected branch
|
|
26
|
+
# commit message contains `run-test` keyword
|
|
27
|
+
# commit message contains `run-prerelease` keyword and commit branch is nott default branch (master)
|
|
28
|
+
# commit message contains `run-release` keyword and commit branch is default branch (master)
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
run-pre-prepare:
|
|
32
|
+
stage: prepare
|
|
33
|
+
image: registry-intl.cn-hongkong.aliyuncs.com/gkci/node:10.20.0-alpine-ci-1
|
|
34
|
+
artifacts:
|
|
35
|
+
paths:
|
|
36
|
+
- package.json
|
|
37
|
+
- package-lock.json
|
|
38
|
+
script:
|
|
39
|
+
- make version-prerelease
|
|
40
|
+
rules:
|
|
41
|
+
# NOT triggerred by bot and NOT commit message contains `run-without-release` keyword and NOT merge request and NOT tag was created
|
|
42
|
+
- if: '$CI_COMMIT_MESSAGE =~ /release-by-bot/ || $CI_COMMIT_MESSAGE =~ /run-without-release/ || $CI_PIPELINE_SOURCE == "merge_request_event" || $CI_COMMIT_TAG != null'
|
|
43
|
+
when: never
|
|
44
|
+
# Commit message contains `run-prerelease` keyword and commit branch is not default branch (master)
|
|
45
|
+
- if: '$CI_COMMIT_MESSAGE =~ /run-prerelease/ && $CI_COMMIT_BRANCH != $CI_DEFAULT_BRANCH'
|
|
46
|
+
|
|
47
|
+
run-prepare:
|
|
48
|
+
stage: prepare
|
|
49
|
+
image: registry-intl.cn-hongkong.aliyuncs.com/gkci/node:10.20.0-alpine-ci-1
|
|
50
|
+
artifacts:
|
|
51
|
+
paths:
|
|
52
|
+
- package.json
|
|
53
|
+
- package-lock.json
|
|
54
|
+
script:
|
|
55
|
+
- make version-patch
|
|
56
|
+
rules:
|
|
57
|
+
# NOT triggerred by bot and NOT commit message contains `run-without-release` keyword and NOT merge request and NOT tag was created
|
|
58
|
+
- if: '$CI_COMMIT_MESSAGE =~ /release-by-bot/ || $CI_COMMIT_MESSAGE =~ /run-without-release/ || $CI_PIPELINE_SOURCE == "merge_request_event" || $CI_COMMIT_TAG != null'
|
|
59
|
+
when: never
|
|
60
|
+
# Commit into default branch (master)
|
|
61
|
+
- if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH'
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
run-build:
|
|
65
|
+
stage: build
|
|
66
|
+
image:
|
|
67
|
+
name: registry-intl.cn-hongkong.aliyuncs.com/gkci/node:16.3.0-alpine-ci-1
|
|
68
|
+
before_script:
|
|
69
|
+
- npm ci --cache .npm --prefer-offline
|
|
70
|
+
- npm config set //registry.npmjs.org/:_authToken ${NPM_TOKEN}
|
|
71
|
+
script:
|
|
72
|
+
- make build
|
|
73
|
+
- make release
|
|
74
|
+
|
|
75
|
+
rules:
|
|
76
|
+
# NOT triggerred by bot and NOT commit message contains `run-without-release` keyword and NOT merge request and NOT tag was created
|
|
77
|
+
- if: '$CI_COMMIT_MESSAGE =~ /release-by-bot/ || $CI_COMMIT_MESSAGE =~ /run-without-release/ || $CI_PIPELINE_SOURCE == "merge_request_event" || $CI_COMMIT_TAG != null'
|
|
78
|
+
when: never
|
|
79
|
+
# Commit message contains `run-prerelease` keyword and commit branch is not default branch (master)
|
|
80
|
+
- if: '$CI_COMMIT_MESSAGE =~ /run-prerelease/ && $CI_COMMIT_BRANCH != $CI_DEFAULT_BRANCH'
|
|
81
|
+
# Commit into default branch (master)
|
|
82
|
+
- if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH'
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
run-build-commit:
|
|
86
|
+
stage: build-commit
|
|
87
|
+
image: registry-intl.cn-hongkong.aliyuncs.com/gkci/node:10.20.0-alpine-ci-1
|
|
88
|
+
before_script:
|
|
89
|
+
- git config --global user.name "$GITLAB_USER_NAME"
|
|
90
|
+
- git config --global user.email "$GITLAB_USER_EMAIL"
|
|
91
|
+
script:
|
|
92
|
+
- git add -A
|
|
93
|
+
- git commit -m "$(make version)" -m "== release-by-bot ($CI_COMMIT_SHA) =="
|
|
94
|
+
- git tag -a "$(make version)" -m "$(cat image-tag.txt) ($(cat image-digest.txt))"
|
|
95
|
+
- git push "https://${GITLAB_USER_NAME}:${CI_GIT_TOKEN}@${CI_REPOSITORY_URL#*@}" "HEAD:${CI_COMMIT_BRANCH}"
|
|
96
|
+
- git push "https://${GITLAB_USER_NAME}:${CI_GIT_TOKEN}@${CI_REPOSITORY_URL#*@}" --tags
|
|
97
|
+
rules:
|
|
98
|
+
# NOT triggerred by bot and NOT commit message contains `run-without-release` keyword and NOT merge request and NOT tag was created
|
|
99
|
+
- if: '$CI_COMMIT_MESSAGE =~ /release-by-bot/ || $CI_COMMIT_MESSAGE =~ /run-without-release/ || $CI_PIPELINE_SOURCE == "merge_request_event" || $CI_COMMIT_TAG != null'
|
|
100
|
+
when: never
|
|
101
|
+
# Commit message contains `run-prerelease` keyword and commit branch is not default branch (master)
|
|
102
|
+
- if: '$CI_COMMIT_MESSAGE =~ /run-prerelease/ && $CI_COMMIT_BRANCH != $CI_DEFAULT_BRANCH'
|
|
103
|
+
# Commit into default branch (master)
|
|
104
|
+
- if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH'
|
|
105
|
+
|
|
106
|
+
run-release:
|
|
107
|
+
stage: release
|
|
108
|
+
image: registry-intl.cn-hongkong.aliyuncs.com/gkci/node:10.20.0-alpine-ci-1
|
|
109
|
+
script:
|
|
110
|
+
- echo "Bumped version $(make version)"
|
|
111
|
+
rules:
|
|
112
|
+
# NOT commit message contains `run-without-release` keyword and NOT merge request
|
|
113
|
+
- if: '$CI_COMMIT_MESSAGE =~ /run-without-release/ || $CI_PIPELINE_SOURCE == "merge_request_event"'
|
|
114
|
+
when: never
|
|
115
|
+
# Tag was created
|
|
116
|
+
- if: '$CI_COMMIT_TAG != null'
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
run-notify:
|
|
120
|
+
stage: notify
|
|
121
|
+
image: registry-intl.cn-hongkong.aliyuncs.com/gkci/node:10.20.0-alpine-ci-1
|
|
122
|
+
before_script:
|
|
123
|
+
- apk --no-cache add curl
|
|
124
|
+
script:
|
|
125
|
+
- 'curl -X POST -H "Content-Type: application/json" -d "{\"chat_id\": \"$TELEGRAM_CHAT_ID\", \"text\": \"CI: $CI_PROJECT_NAMESPACE/$CI_PROJECT_NAME version:$(make version) has been released \"}" https://api.telegram.org/bot$TELEGRAM_BOT_TOKEN/sendMessage'
|
|
126
|
+
rules:
|
|
127
|
+
# NOT triggerred by bot and NOT commit message contains `run-without-release` keyword and NOT merge request and NOT tag was created
|
|
128
|
+
- if: '$CI_COMMIT_MESSAGE =~ /release-by-bot/ || $CI_COMMIT_MESSAGE =~ /run-without-release/ || $CI_PIPELINE_SOURCE == "merge_request_event" || $CI_COMMIT_TAG != null'
|
|
129
|
+
when: never
|
|
130
|
+
- if: '$TELEGRAM_BOT_TOKEN == null || $TELEGRAM_BOT_TOKEN == "" || $TELEGRAM_CHAT_ID == null || $TELEGRAM_CHAT_ID == ""'
|
|
131
|
+
when: never
|
|
132
|
+
# Commit message contains `run-prerelease` keyword and commit branch is not default branch (master)
|
|
133
|
+
- if: '$CI_COMMIT_MESSAGE =~ /run-prerelease/ && $CI_COMMIT_BRANCH != $CI_DEFAULT_BRANCH'
|
|
134
|
+
# Commit into default branch (master)
|
|
135
|
+
- if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH'
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# source
|
|
2
|
+
**/*.ts
|
|
3
|
+
*.ts
|
|
4
|
+
config
|
|
5
|
+
lib
|
|
6
|
+
.env
|
|
7
|
+
|
|
8
|
+
# definitions
|
|
9
|
+
!**/*.d.ts
|
|
10
|
+
!*.d.ts
|
|
11
|
+
|
|
12
|
+
# configuration
|
|
13
|
+
.prettierrc
|
|
14
|
+
nest-cli.json
|
|
15
|
+
nodemon-debug.json
|
|
16
|
+
package-lock.json
|
|
17
|
+
tsconfig.json
|
|
18
|
+
tsconfig.spec.json
|
|
19
|
+
tsconfig.build.json
|
|
20
|
+
tslint.json
|
|
21
|
+
webpack.config.js
|
|
22
|
+
yarn.lock
|
|
23
|
+
|
|
24
|
+
.npmrc
|
|
25
|
+
.nvmrc
|
|
26
|
+
.gitlab-ci.yml
|
|
27
|
+
Makefile
|
|
28
|
+
|
|
29
|
+
.npm/
|
|
30
|
+
test/
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2018 KnowYourself
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
MAKEFILE := $(abspath $(lastword $(MAKEFILE_LIST)))
|
|
2
|
+
ROOT_PATH := $(shell pwd)
|
|
3
|
+
SERVICE_NAME := <%= projectName %>
|
|
4
|
+
|
|
5
|
+
.PHONY: test
|
|
6
|
+
|
|
7
|
+
version-major: #version-sync
|
|
8
|
+
@npm -s version major --no-git-tag-version
|
|
9
|
+
|
|
10
|
+
version-minor: #version-sync
|
|
11
|
+
@npm -s version minor --no-git-tag-version
|
|
12
|
+
|
|
13
|
+
version-patch: #version-sync
|
|
14
|
+
@npm -s version patch --no-git-tag-version
|
|
15
|
+
|
|
16
|
+
version-prerelease: #version-sync
|
|
17
|
+
@npm -s version prerelease --preid=rc --no-git-tag-version
|
|
18
|
+
|
|
19
|
+
version-latest:
|
|
20
|
+
@(git tag --sort=-creatordate || echo) | awk 'NR==1 { \
|
|
21
|
+
split($$0, n, "-"); \
|
|
22
|
+
if (n[1] != "") { \
|
|
23
|
+
split(n[1], v, "."); \
|
|
24
|
+
if (v[1] ~ /^[0-9]+$$/ && v[2] ~ /^[0-9]+$$/ && v[3] ~ /^[0-9]+$$/) { \
|
|
25
|
+
print $$0; \
|
|
26
|
+
exit 0; \
|
|
27
|
+
} \
|
|
28
|
+
} \
|
|
29
|
+
print "1.0.0-rc.0"; \
|
|
30
|
+
} \
|
|
31
|
+
END { \
|
|
32
|
+
if (NR == 0) { \
|
|
33
|
+
print "1.0.0-rc.0"; \
|
|
34
|
+
} \
|
|
35
|
+
}'
|
|
36
|
+
|
|
37
|
+
version-sync:
|
|
38
|
+
@git checkout $(CI_COMMIT_BRANCH)
|
|
39
|
+
@git pull --tags 2&>/dev/null || true
|
|
40
|
+
@git tag --sort=-creatordate | head -10
|
|
41
|
+
@cat package.json | jq -r --arg PKG_VERSION `make --no-print-directory -f$(MAKEFILE) version-latest` '.version=$$PKG_VERSION' > package.json;
|
|
42
|
+
@echo -n "Current Git tag: "; cat package.json | jq -r '.version'
|
|
43
|
+
|
|
44
|
+
version:
|
|
45
|
+
@echo $(shell node -p "require('$(ROOT_PATH)/package.json').version")
|
|
46
|
+
|
|
47
|
+
name:
|
|
48
|
+
@echo $(SERVICE_NAME)
|
|
49
|
+
|
|
50
|
+
## can add npm run test on here to run test before build
|
|
51
|
+
test:
|
|
52
|
+
@echo "Skipped"
|
|
53
|
+
|
|
54
|
+
build:
|
|
55
|
+
@npm run build
|
|
56
|
+
|
|
57
|
+
release:
|
|
58
|
+
@npm publish --access public
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# Library
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./dist";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './dist';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./samples";
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "<%= projectName %>",
|
|
3
|
+
"version": "1.0.0-rc.0",
|
|
4
|
+
"description": "na-cli generated ts-library 1.0.0",
|
|
5
|
+
"scripts": {
|
|
6
|
+
"build": "rimraf dist && tsc -p tsconfig.json",
|
|
7
|
+
"precommit": "lint-staged",
|
|
8
|
+
"test": "jest",
|
|
9
|
+
"test:watch": "jest --watch",
|
|
10
|
+
"test:cov": "jest --coverage",
|
|
11
|
+
"test:e2e": "jest --config ./test/jest-e2e.json",
|
|
12
|
+
"lint": "eslint -c .eslintrc.js"
|
|
13
|
+
},
|
|
14
|
+
"author": "<%= author %>",
|
|
15
|
+
"license": "ISC",
|
|
16
|
+
"devDependencies": {
|
|
17
|
+
"@types/jest": "^28.1.6",
|
|
18
|
+
"@types/node": "^18.11.18",
|
|
19
|
+
"@typescript-eslint/eslint-plugin": "^4.3.5",
|
|
20
|
+
"@typescript-eslint/parser": "^4.3.5",
|
|
21
|
+
"eslint": "*",
|
|
22
|
+
"eslint-config-prettier": "^6",
|
|
23
|
+
"eslint-plugin-prettier": "^3",
|
|
24
|
+
"jest": "^28.1.3",
|
|
25
|
+
"prettier": "^2",
|
|
26
|
+
"ts-jest": "^28.0.7",
|
|
27
|
+
"typescript": "^4.3.5"
|
|
28
|
+
},
|
|
29
|
+
"types": "./index.d.ts",
|
|
30
|
+
"main": "index.js",
|
|
31
|
+
"directories": {
|
|
32
|
+
"lib": "lib"
|
|
33
|
+
}
|
|
34
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"module": "CommonJS",
|
|
4
|
+
"target": "ES2018",
|
|
5
|
+
"declaration": true,
|
|
6
|
+
"noImplicitAny": false,
|
|
7
|
+
"removeComments": true,
|
|
8
|
+
"noLib": false,
|
|
9
|
+
"emitDecoratorMetadata": true,
|
|
10
|
+
"experimentalDecorators": true,
|
|
11
|
+
"sourceMap": false,
|
|
12
|
+
"outDir": "./dist",
|
|
13
|
+
"rootDir": "./lib",
|
|
14
|
+
"skipLibCheck": true
|
|
15
|
+
},
|
|
16
|
+
"include": ["lib/**/*", "../index.ts"],
|
|
17
|
+
"exclude": ["node_modules", "**/*.spec.ts"]
|
|
18
|
+
}
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
14
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
15
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
16
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
17
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
18
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
19
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
20
|
+
});
|
|
21
|
+
};
|
|
22
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
23
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
24
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
25
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
26
|
+
function step(op) {
|
|
27
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
28
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
29
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
30
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
31
|
+
switch (op[0]) {
|
|
32
|
+
case 0: case 1: t = op; break;
|
|
33
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
34
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
35
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
36
|
+
default:
|
|
37
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
38
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
39
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
40
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
41
|
+
if (t[2]) _.ops.pop();
|
|
42
|
+
_.trys.pop(); continue;
|
|
43
|
+
}
|
|
44
|
+
op = body.call(thisArg, _);
|
|
45
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
46
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
50
|
+
exports.writeYamlToDotEnv = exports.writeDotEnvToYaml = void 0;
|
|
51
|
+
var fs = require("fs");
|
|
52
|
+
var dotenv = require("dotenv");
|
|
53
|
+
var yaml = require("js-yaml");
|
|
54
|
+
var path = require("path");
|
|
55
|
+
var writeDotEnvToYaml = function (inputPath, outputPath) { return __awaiter(void 0, void 0, void 0, function () {
|
|
56
|
+
var originalEnv, inputFullPath, env, envEntries, configEnv, yamlStr;
|
|
57
|
+
return __generator(this, function (_a) {
|
|
58
|
+
switch (_a.label) {
|
|
59
|
+
case 0:
|
|
60
|
+
originalEnv = __assign({}, process.env);
|
|
61
|
+
inputFullPath = path.resolve(inputPath);
|
|
62
|
+
return [4 /*yield*/, validateFile(inputFullPath)
|
|
63
|
+
// load environment variables from the .env file passed as argument
|
|
64
|
+
];
|
|
65
|
+
case 1:
|
|
66
|
+
_a.sent();
|
|
67
|
+
// load environment variables from the .env file passed as argument
|
|
68
|
+
dotenv.config({ path: inputFullPath });
|
|
69
|
+
env = process.env;
|
|
70
|
+
envEntries = Object.entries(env)
|
|
71
|
+
.filter(function (_a) {
|
|
72
|
+
var key = _a[0];
|
|
73
|
+
return originalEnv[key] !== env[key];
|
|
74
|
+
})
|
|
75
|
+
.reduce(function (acc, _a) {
|
|
76
|
+
var key = _a[0], value = _a[1];
|
|
77
|
+
acc[key] = value;
|
|
78
|
+
return acc;
|
|
79
|
+
}, {});
|
|
80
|
+
configEnv = {
|
|
81
|
+
env: __assign({}, envEntries)
|
|
82
|
+
};
|
|
83
|
+
yamlStr = yaml.dump(configEnv);
|
|
84
|
+
// write the yaml to a .yaml file
|
|
85
|
+
fs.writeFileSync(path.resolve(outputPath), yamlStr);
|
|
86
|
+
return [2 /*return*/];
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
}); };
|
|
90
|
+
exports.writeDotEnvToYaml = writeDotEnvToYaml;
|
|
91
|
+
var writeYamlToDotEnv = function (inputPath, outputPath) { return __awaiter(void 0, void 0, void 0, function () {
|
|
92
|
+
var originalEnv, inputFullPath, yamlStr, config, envEntries, envStr;
|
|
93
|
+
return __generator(this, function (_a) {
|
|
94
|
+
switch (_a.label) {
|
|
95
|
+
case 0:
|
|
96
|
+
originalEnv = __assign({}, process.env);
|
|
97
|
+
inputFullPath = path.resolve(inputPath);
|
|
98
|
+
return [4 /*yield*/, validateFile(inputFullPath)
|
|
99
|
+
// read the yaml file
|
|
100
|
+
];
|
|
101
|
+
case 1:
|
|
102
|
+
_a.sent();
|
|
103
|
+
yamlStr = fs.readFileSync(inputFullPath, 'utf8');
|
|
104
|
+
config = yaml.load(yamlStr);
|
|
105
|
+
;
|
|
106
|
+
envEntries = Object.entries(config.env)
|
|
107
|
+
.filter(function (_a) {
|
|
108
|
+
var key = _a[0];
|
|
109
|
+
return originalEnv[key] !== config.env[key];
|
|
110
|
+
})
|
|
111
|
+
.map(function (_a) {
|
|
112
|
+
var key = _a[0], value = _a[1];
|
|
113
|
+
return "".concat(key, "=").concat(value);
|
|
114
|
+
});
|
|
115
|
+
envStr = envEntries.join('\n');
|
|
116
|
+
fs.writeFileSync(path.resolve(outputPath), envStr);
|
|
117
|
+
return [2 /*return*/];
|
|
118
|
+
}
|
|
119
|
+
});
|
|
120
|
+
}); };
|
|
121
|
+
exports.writeYamlToDotEnv = writeYamlToDotEnv;
|
|
122
|
+
var validateFile = function (filePath) { return __awaiter(void 0, void 0, void 0, function () {
|
|
123
|
+
var err_1;
|
|
124
|
+
return __generator(this, function (_a) {
|
|
125
|
+
switch (_a.label) {
|
|
126
|
+
case 0:
|
|
127
|
+
_a.trys.push([0, 2, , 3]);
|
|
128
|
+
return [4 /*yield*/, fs.promises.stat(filePath)];
|
|
129
|
+
case 1:
|
|
130
|
+
_a.sent();
|
|
131
|
+
return [3 /*break*/, 3];
|
|
132
|
+
case 2:
|
|
133
|
+
err_1 = _a.sent();
|
|
134
|
+
if (err_1.code === 'ENOENT') {
|
|
135
|
+
console.error("File ".concat(filePath, " not found"));
|
|
136
|
+
process.exit(1);
|
|
137
|
+
}
|
|
138
|
+
else {
|
|
139
|
+
throw err_1;
|
|
140
|
+
}
|
|
141
|
+
return [3 /*break*/, 3];
|
|
142
|
+
case 3: return [2 /*return*/];
|
|
143
|
+
}
|
|
144
|
+
});
|
|
145
|
+
}); };
|
|
146
|
+
//# sourceMappingURL=env.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"env.js","sourceRoot":"","sources":["../../src/utils/env.ts"],"names":[],"mappings":"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"}
|