web-push-notifications 3.40.1 → 3.44.1
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/.editorconfig +11 -0
- package/.gitlab-ci.yml +190 -0
- package/babel.config.js +7 -0
- package/ci/cdn/Dockerfile +12 -0
- package/ci/dev/Dockerfile +30 -0
- package/ci/dev/rootfs/entrypoint.sh +18 -0
- package/ci/dev/rootfs/entrypoint.sh.d/nginx.sh +6 -0
- package/ci/dev/rootfs/entrypoint.sh.d/supervisor.sh +5 -0
- package/ci/dev/rootfs/etc/nginx/_real_ip.conf +2 -0
- package/ci/dev/rootfs/etc/nginx/conf.d/default.conf +20 -0
- package/ci/dev/rootfs/etc/supervisor.d/nginx.ini +11 -0
- package/ci/github/Dockerfile +59 -0
- package/ci/github/release-zip.js +61 -0
- package/ci/npm/Dockerfile +19 -0
- package/config/config.js +24 -0
- package/config/configBuilder.js +126 -0
- package/config/helpers.js +9 -0
- package/config/index.js +1 -0
- package/develop/README.md +42 -0
- package/develop/favicon.png +0 -0
- package/develop/index.html +511 -0
- package/eslint.config.mjs +114 -0
- package/package.json +4 -34
- package/{lib → public}/index.d.ts +10 -10
- package/scripts/zip.js +26 -0
- package/src/core/Pushwoosh.ts +768 -0
- package/src/core/Pushwoosh.types.ts +254 -0
- package/src/core/Safari.types.ts +26 -0
- package/src/core/constants.ts +58 -0
- package/src/core/events.types.ts +46 -0
- package/src/core/functions.ts +33 -0
- package/src/core/legacyEventsMap.ts +64 -0
- package/src/core/logger.ts +64 -0
- package/src/core/modules/EventBus/EventBus.ts +66 -0
- package/src/core/modules/EventBus/index.ts +1 -0
- package/src/core/storage.ts +254 -0
- package/src/helpers/logger.ts +81 -0
- package/src/helpers/pwlogger/Logger.constants.ts +31 -0
- package/src/helpers/pwlogger/Logger.ts +218 -0
- package/src/helpers/pwlogger/Logger.types.ts +66 -0
- package/src/helpers/pwlogger/handlers/handler-console/handler-console.ts +40 -0
- package/src/helpers/pwlogger/index.ts +2 -0
- package/src/helpers/unescape.ts +36 -0
- package/src/models/InboxMessages.ts +202 -0
- package/src/models/InboxMessages.types.ts +111 -0
- package/src/models/NotificationPayload.ts +216 -0
- package/src/models/NotificationPayload.types.ts +65 -0
- package/src/modules/Api/Api.ts +386 -0
- package/src/modules/Api/Api.types.ts +7 -0
- package/src/modules/ApiClient/ApiClient.ts +153 -0
- package/src/modules/ApiClient/ApiClient.types.ts +222 -0
- package/src/modules/Data/Data.ts +345 -0
- package/src/modules/DateModule.ts +53 -0
- package/src/modules/InboxMessagesPublic.ts +222 -0
- package/src/modules/PlatformChecker/PlatformChecker.ts +170 -0
- package/src/modules/PlatformChecker/PlatformChecker.types.ts +5 -0
- package/src/modules/PlatformChecker/index.ts +1 -0
- package/src/modules/storage/Storage.ts +164 -0
- package/src/modules/storage/Storage.types.ts +54 -0
- package/src/modules/storage/Store.ts +104 -0
- package/src/modules/storage/migrations/26-11-2018.ts +25 -0
- package/src/modules/storage/migrations/MigrationExecutor.ts +31 -0
- package/src/modules/storage/migrations/Migrations.ts +41 -0
- package/src/modules/storage/migrations/constants.ts +8 -0
- package/src/modules/storage/migrations/helpers.ts +16 -0
- package/src/modules/storage/migrations/initial.ts +47 -0
- package/src/modules/storage/version.ts +2 -0
- package/src/npm.ts +1 -0
- package/src/pushwoosh-web-notifications.ts +47 -0
- package/src/pushwoosh-widget-inbox.ts +8 -0
- package/src/pushwoosh-widget-subscribe-popup.ts +9 -0
- package/src/pushwoosh-widget-subscription-button.ts +8 -0
- package/src/pushwoosh-widget-subscription-prompt.ts +6 -0
- package/src/service-worker.ts +455 -0
- package/src/services/PushService/PushService.ts +2 -0
- package/src/services/PushService/PushService.types.ts +74 -0
- package/src/services/PushService/drivers/PushServiceDefault/PushServiceDefault.ts +235 -0
- package/src/services/PushService/drivers/PushServiceDefault/PushServiceDefault.types.ts +3 -0
- package/src/services/PushService/drivers/PushServiceSafari/PushServiceSafari.ts +125 -0
- package/src/services/PushService/drivers/PushServiceSafari/PushServiceSafari.types.ts +4 -0
- package/src/widget-inbox.ts +1 -0
- package/src/widget-subscribe-popup.ts +1 -0
- package/src/widget-subscription-button.ts +1 -0
- package/src/widget-subscription-prompt.ts +33 -0
- package/src/widgets/Inbox/InboxWidget.ts +564 -0
- package/src/widgets/Inbox/constants.ts +49 -0
- package/src/widgets/Inbox/css/inboxWidgetStyle.css +274 -0
- package/src/widgets/Inbox/helpers.ts +63 -0
- package/src/widgets/Inbox/inbox.d.ts +9 -0
- package/src/widgets/Inbox/inbox_widget.types.ts +41 -0
- package/src/widgets/Inbox/index.ts +1 -0
- package/src/widgets/Inbox/widgetTemplates.ts +55 -0
- package/src/widgets/SubscribePopup/SubscribePopup.ts +241 -0
- package/src/widgets/SubscribePopup/constants.ts +66 -0
- package/src/widgets/SubscribePopup/helpers.ts +11 -0
- package/src/widgets/SubscribePopup/index.ts +1 -0
- package/src/widgets/SubscribePopup/popupTemplates.ts +24 -0
- package/src/widgets/SubscribePopup/styles/popup.css +226 -0
- package/src/widgets/SubscribePopup/types/subscribe-popup.ts +68 -0
- package/src/widgets/SubscriptionButton/assets/css/main.css +205 -0
- package/src/widgets/SubscriptionButton/bell.ts +67 -0
- package/src/widgets/SubscriptionButton/constants.ts +28 -0
- package/src/widgets/SubscriptionButton/index.ts +377 -0
- package/src/widgets/SubscriptionButton/positioning.ts +165 -0
- package/src/widgets/SubscriptionButton/subscribe_widget.types.ts +53 -0
- package/src/widgets/SubscriptionPrompt/SubscriptionPromptWidget.constants.ts +1 -0
- package/src/widgets/SubscriptionPrompt/SubscriptionPromptWidget.helpers.ts +110 -0
- package/src/widgets/SubscriptionPrompt/SubscriptionPromptWidget.ts +102 -0
- package/src/widgets/SubscriptionPrompt/SubscriptionPromptWidget.types.ts +23 -0
- package/src/widgets/SubscriptionPrompt/constants.ts +22 -0
- package/src/widgets/SubscriptionPrompt/helpers.ts +42 -0
- package/src/widgets/widgets.d.ts +4 -0
- package/src/worker/global.ts +36 -0
- package/src/worker/notification.ts +34 -0
- package/src/worker/worker.types.ts +4 -0
- package/test/__helpers__/apiHelpers.ts +22 -0
- package/test/__helpers__/keyValueHelpers.ts +15 -0
- package/test/__helpers__/platformHelpers.ts +54 -0
- package/test/__helpers__/sinonHelpers.ts +7 -0
- package/test/__helpers__/storageHelpers.ts +56 -0
- package/test/__mocks__/apiRequests.ts +26 -0
- package/test/__mocks__/idbMock.ts +12 -0
- package/test/__mocks__/idbObjectStoreMock.ts +38 -0
- package/test/__mocks__/inboxMessages.ts +292 -0
- package/test/__mocks__/models/inboxModel.ts +71 -0
- package/test/__mocks__/modules/apiClientModule.ts +18 -0
- package/test/__mocks__/modules/dateModule.ts +34 -0
- package/test/__mocks__/modules/inboxParamsModule.ts +21 -0
- package/test/__mocks__/modules/paramsBuilder.ts +12 -0
- package/test/__mocks__/modules/paramsModule.ts +35 -0
- package/test/__mocks__/modules/payloadBuilderModule.ts +15 -0
- package/test/__mocks__/modules/storageModule.ts +58 -0
- package/test/__mocks__/navigator.ts +38 -0
- package/test/__mocks__/notification.ts +84 -0
- package/test/__mocks__/pushwoosh.ts +12 -0
- package/test/__mocks__/userAgents +8 -0
- package/test/functions.test.ts +22 -0
- package/test/ignore-html.js +6 -0
- package/test/mocha.opts +6 -0
- package/test/modules/DateModule/unit.test.ts +80 -0
- package/test/modules/storage/Storage/unit.test.ts +180 -0
- package/test/modules/storage/Store/unit.test.ts +192 -0
- package/testRegister.js +24 -0
- package/tsconfig.json +31 -0
- package/webpack.config.js +163 -0
- package/lib/index.js +0 -2
- package/lib/index.js.map +0 -1
- package/lib/service-worker.js +0 -2
- package/lib/service-worker.js.map +0 -1
package/.editorconfig
ADDED
package/.gitlab-ci.yml
ADDED
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
include:
|
|
2
|
+
- project: 'platform/tools/gitlab-ci-commons'
|
|
3
|
+
ref: master
|
|
4
|
+
file: '/cdn-release.yml'
|
|
5
|
+
- project: 'platform/tools/gitlab-ci-commons'
|
|
6
|
+
ref: master
|
|
7
|
+
file: '/github-release.yml'
|
|
8
|
+
|
|
9
|
+
stages:
|
|
10
|
+
- assets
|
|
11
|
+
- build
|
|
12
|
+
- test
|
|
13
|
+
- deploy
|
|
14
|
+
- release
|
|
15
|
+
- release-cdn
|
|
16
|
+
- build-github
|
|
17
|
+
- release-github
|
|
18
|
+
|
|
19
|
+
variables:
|
|
20
|
+
CONTAINER_NAME: websdk
|
|
21
|
+
|
|
22
|
+
Install:assets:
|
|
23
|
+
stage: assets
|
|
24
|
+
image: node:18.19
|
|
25
|
+
before_script:
|
|
26
|
+
- npm install -d
|
|
27
|
+
script:
|
|
28
|
+
- npm run release
|
|
29
|
+
cache:
|
|
30
|
+
key: "$CI_COMMIT_REF_NAME"
|
|
31
|
+
paths:
|
|
32
|
+
- node_modules/
|
|
33
|
+
artifacts:
|
|
34
|
+
expire_in: 1 hour
|
|
35
|
+
paths:
|
|
36
|
+
- output/
|
|
37
|
+
|
|
38
|
+
Deploy:
|
|
39
|
+
stage: deploy
|
|
40
|
+
image: docker:latest
|
|
41
|
+
before_script:
|
|
42
|
+
- docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY
|
|
43
|
+
script:
|
|
44
|
+
- docker build --pull -t $CI_REGISTRY_IMAGE/dev:$CI_COMMIT_REF_SLUG-$CI_PIPELINE_ID -f ci/dev/Dockerfile .
|
|
45
|
+
- docker rm --force $CONTAINER_NAME-$CI_ENVIRONMENT_SLUG || true
|
|
46
|
+
- >
|
|
47
|
+
docker run --restart=always -d -p 80
|
|
48
|
+
-e PW_initParams__applicationCode=$PW_initParams__applicationCode
|
|
49
|
+
-e PW_initParams__autoSubscribe=$PW_initParams__autoSubscribe
|
|
50
|
+
-e PW_initParams__safariWebsitePushID=$PW_initParams__safariWebsitePushID
|
|
51
|
+
-e PW_manifest__gcm_sender_id=$PW_manifest__gcm_sender_id
|
|
52
|
+
--name $CONTAINER_NAME-$CI_ENVIRONMENT_SLUG $CI_REGISTRY_IMAGE/dev:$CI_COMMIT_REF_SLUG-$CI_PIPELINE_ID
|
|
53
|
+
after_script:
|
|
54
|
+
- sh /home/gitlab-runner/tools/nginx/vhost.sh $CONTAINER_NAME-$CI_ENVIRONMENT_SLUG
|
|
55
|
+
environment:
|
|
56
|
+
name: websdk
|
|
57
|
+
url: https://websdk-gitlab.corp.pushwoosh.com
|
|
58
|
+
only:
|
|
59
|
+
- branches
|
|
60
|
+
|
|
61
|
+
Test:
|
|
62
|
+
stage: test
|
|
63
|
+
image: node:18.19
|
|
64
|
+
cache:
|
|
65
|
+
key: "$CI_COMMIT_REF_NAME"
|
|
66
|
+
paths:
|
|
67
|
+
- node_modules/
|
|
68
|
+
before_script:
|
|
69
|
+
- npm install -d
|
|
70
|
+
script:
|
|
71
|
+
- npm run check:types
|
|
72
|
+
- npm run check:lint
|
|
73
|
+
allow_failure: true
|
|
74
|
+
only:
|
|
75
|
+
- branches
|
|
76
|
+
|
|
77
|
+
# npm
|
|
78
|
+
|
|
79
|
+
Build:npm:
|
|
80
|
+
stage: build
|
|
81
|
+
image: docker:latest
|
|
82
|
+
before_script:
|
|
83
|
+
- docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY
|
|
84
|
+
script:
|
|
85
|
+
- >
|
|
86
|
+
docker build --pull
|
|
87
|
+
-t $CI_REGISTRY_IMAGE/npm:$CI_COMMIT_REF_SLUG-$CI_PIPELINE_ID
|
|
88
|
+
--build-arg NPM_TOKEN=${NPM_TOKEN}
|
|
89
|
+
-f ci/npm/Dockerfile .
|
|
90
|
+
- docker push $CI_REGISTRY_IMAGE/npm:$CI_COMMIT_REF_SLUG-$CI_PIPELINE_ID
|
|
91
|
+
only:
|
|
92
|
+
- /.*-prod$/
|
|
93
|
+
- /.*-next$/ # тестовая версия будущих фич в гитхаб
|
|
94
|
+
except:
|
|
95
|
+
- branches
|
|
96
|
+
|
|
97
|
+
Release:npm:production:
|
|
98
|
+
stage: release
|
|
99
|
+
image: $CI_REGISTRY_IMAGE/npm:$CI_COMMIT_REF_SLUG-$CI_PIPELINE_ID
|
|
100
|
+
script:
|
|
101
|
+
- npm publish --tag latest
|
|
102
|
+
when: manual
|
|
103
|
+
only:
|
|
104
|
+
- /.*-prod$/
|
|
105
|
+
except:
|
|
106
|
+
- branches
|
|
107
|
+
|
|
108
|
+
Release:npm:next:
|
|
109
|
+
stage: release
|
|
110
|
+
image: $CI_REGISTRY_IMAGE/npm:$CI_COMMIT_REF_SLUG-$CI_PIPELINE_ID
|
|
111
|
+
script:
|
|
112
|
+
- npm publish --tag next
|
|
113
|
+
when: manual
|
|
114
|
+
only:
|
|
115
|
+
- /.*-next$/
|
|
116
|
+
except:
|
|
117
|
+
- branches
|
|
118
|
+
|
|
119
|
+
# cdn
|
|
120
|
+
|
|
121
|
+
build:cdn:
|
|
122
|
+
stage: build
|
|
123
|
+
image: docker:latest
|
|
124
|
+
before_script:
|
|
125
|
+
- docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY
|
|
126
|
+
script:
|
|
127
|
+
- docker build --pull -t $CI_REGISTRY_IMAGE/cdn:$CI_COMMIT_REF_SLUG-$CI_PIPELINE_ID -f ci/cdn/Dockerfile .
|
|
128
|
+
- docker push $CI_REGISTRY_IMAGE/cdn:$CI_COMMIT_REF_SLUG-$CI_PIPELINE_ID
|
|
129
|
+
rules:
|
|
130
|
+
- if: $CI_COMMIT_TAG =~ /^v.*-next$/
|
|
131
|
+
- if: $CI_COMMIT_TAG =~ /^v.*-prod$/
|
|
132
|
+
|
|
133
|
+
release:cdn-prod:
|
|
134
|
+
extends: .release:cdn
|
|
135
|
+
variables:
|
|
136
|
+
PUBLIC_PATH: "/webpush/v3/"
|
|
137
|
+
DIST_PATH: "/dist/"
|
|
138
|
+
stage: release-cdn
|
|
139
|
+
image: $CI_REGISTRY_IMAGE/cdn:$CI_COMMIT_REF_SLUG-$CI_PIPELINE_ID
|
|
140
|
+
dependencies:
|
|
141
|
+
- build:cdn
|
|
142
|
+
rules:
|
|
143
|
+
- if: $CI_COMMIT_TAG =~ /^v.*-prod$/
|
|
144
|
+
|
|
145
|
+
release:cdn-next:
|
|
146
|
+
extends: .release:cdn
|
|
147
|
+
variables:
|
|
148
|
+
PUBLIC_PATH: "/webpush/next/"
|
|
149
|
+
DIST_PATH: "/dist/"
|
|
150
|
+
stage: release-cdn
|
|
151
|
+
image: $CI_REGISTRY_IMAGE/cdn:$CI_COMMIT_REF_SLUG-$CI_PIPELINE_ID
|
|
152
|
+
dependencies:
|
|
153
|
+
- build:cdn
|
|
154
|
+
rules:
|
|
155
|
+
- if: $CI_COMMIT_TAG =~ /^v.*-next$/
|
|
156
|
+
|
|
157
|
+
#github
|
|
158
|
+
|
|
159
|
+
build:github-prod:
|
|
160
|
+
extends: .build:github
|
|
161
|
+
stage: build-github
|
|
162
|
+
image: docker:latest
|
|
163
|
+
variables:
|
|
164
|
+
GITHUB_PATH_DOCKERFILE: ci/github/Dockerfile
|
|
165
|
+
GITHUB_IMAGE_NAME: $CI_REGISTRY_IMAGE/github:$CI_COMMIT_REF_SLUG-$CI_PIPELINE_ID
|
|
166
|
+
|
|
167
|
+
release:github:prod:
|
|
168
|
+
extends: .release:github
|
|
169
|
+
stage: release-github
|
|
170
|
+
variables:
|
|
171
|
+
GITHUB_HEAD: prod
|
|
172
|
+
image: $CI_REGISTRY_IMAGE/github:$CI_COMMIT_REF_SLUG-$CI_PIPELINE_ID
|
|
173
|
+
rules:
|
|
174
|
+
- if: $CI_COMMIT_TAG =~ /^v.*$"{GITHUB_HEAD}"$/
|
|
175
|
+
|
|
176
|
+
release:github:next:
|
|
177
|
+
extends: .release:github
|
|
178
|
+
stage: release-github
|
|
179
|
+
variables:
|
|
180
|
+
GITHUB_HEAD: next
|
|
181
|
+
image: $CI_REGISTRY_IMAGE/github:$CI_COMMIT_REF_SLUG-$CI_PIPELINE_ID
|
|
182
|
+
rules:
|
|
183
|
+
- if: $CI_COMMIT_TAG =~ /^v.*$"{GITHUB_HEAD}"$/
|
|
184
|
+
|
|
185
|
+
release:github:zip:
|
|
186
|
+
extends: .release:githubzip
|
|
187
|
+
stage: release-github
|
|
188
|
+
image: $CI_REGISTRY_IMAGE/github:$CI_COMMIT_REF_SLUG-$CI_PIPELINE_ID
|
|
189
|
+
variables:
|
|
190
|
+
PATH_TAG_MESSAGE: "/tag-message.txt"
|
package/babel.config.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
FROM alpine
|
|
2
|
+
|
|
3
|
+
LABEL vendor="Pushwoosh Inc." \
|
|
4
|
+
name="WebSDK" \
|
|
5
|
+
version="1.0"
|
|
6
|
+
|
|
7
|
+
RUN apk update
|
|
8
|
+
RUN apk --update --no-cache add python3 py-pip py-setuptools git ca-certificates
|
|
9
|
+
RUN pip install --break-system-packages pip
|
|
10
|
+
RUN pip install --break-system-packages python-dateutil s3cmd
|
|
11
|
+
|
|
12
|
+
COPY output/cdn /dist
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
FROM alpine
|
|
2
|
+
|
|
3
|
+
LABEL vendor="Pushwoosh Inc." \
|
|
4
|
+
name="WebSDK" \
|
|
5
|
+
version="1.0"
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
RUN apk --no-cache add nginx supervisor
|
|
9
|
+
|
|
10
|
+
COPY ci/dev/rootfs/ /
|
|
11
|
+
COPY output/cdn /var/www/html/
|
|
12
|
+
|
|
13
|
+
# Configure supervisor
|
|
14
|
+
RUN sed -e 's|^;\?\(file\s*=\s*\)[^ ]*|\1/dev/shm/supervisor.sock|' \
|
|
15
|
+
-e 's|^;\?\(serverurl\s*=\s*unix://\)[^ ]*|\1/dev/shm/supervisor.sock|' \
|
|
16
|
+
-e 's|^;\?\(logfile_maxbytes\s*=\s*\)[^ ]*|\150MB|' \
|
|
17
|
+
-e 's|^;\?\(logfile_backups\s*=\s*\)[^ ]*|\110|' \
|
|
18
|
+
-e 's|^;\?\(pidfile\s*=\s*\)[^ ]*|\1/dev/shm/supervisord.pid|' \
|
|
19
|
+
-e 's|^;\?\(nodaemon\s*=\s*\)[^ ]*|\1false|' \
|
|
20
|
+
-e '/^\[supervisord\]$/,/^;\?user\s*=.\+/{/^;\?user\s*=.\+/ s/^;\?\(user\s*=\s*\)[^ ]*/\1root/}' \
|
|
21
|
+
-i /etc/supervisord.conf
|
|
22
|
+
|
|
23
|
+
# Forward nginx request and error logs to docker log collector
|
|
24
|
+
RUN ln -sf /dev/stdout /var/log/nginx/access.log \
|
|
25
|
+
&& ln -sf /dev/stderr /var/log/nginx/error.log
|
|
26
|
+
|
|
27
|
+
EXPOSE 80
|
|
28
|
+
|
|
29
|
+
# Start supervisord
|
|
30
|
+
CMD ["/entrypoint.sh"]
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
#!/bin/sh
|
|
2
|
+
|
|
3
|
+
[ -n "$DEBUG" ] && set -x
|
|
4
|
+
|
|
5
|
+
# Run custom scripts
|
|
6
|
+
if [ -d "/entrypoint.sh.d/" ]; then
|
|
7
|
+
for f in /entrypoint.sh.d/*; do
|
|
8
|
+
case "$f" in
|
|
9
|
+
*.sh) echo "$0 INFO : running $f"; . "$f" ;;
|
|
10
|
+
*) echo "$0 INFO : ignoring $f" ;;
|
|
11
|
+
esac
|
|
12
|
+
done
|
|
13
|
+
else
|
|
14
|
+
echo "ERROR : Can't find script directory"
|
|
15
|
+
fi
|
|
16
|
+
|
|
17
|
+
# Start supervisord
|
|
18
|
+
exec /usr/bin/supervisord -n -c /etc/supervisord.conf
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
server {
|
|
2
|
+
listen 80;
|
|
3
|
+
server_name localhost default_server;
|
|
4
|
+
server_name _;
|
|
5
|
+
|
|
6
|
+
root /var/www/html/;
|
|
7
|
+
sendfile on;
|
|
8
|
+
|
|
9
|
+
add_header X-Frame-Options DENY;
|
|
10
|
+
add_header X-Content-Type-Options nosniff;
|
|
11
|
+
add_header X-XSS-Protection "1; mode=block";
|
|
12
|
+
|
|
13
|
+
# Add stdout logging
|
|
14
|
+
error_log /dev/stderr info;
|
|
15
|
+
access_log /dev/stdout;
|
|
16
|
+
|
|
17
|
+
location / {
|
|
18
|
+
try_files $uri $uri/ /index.html;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
[program:nginx]
|
|
2
|
+
command = /usr/sbin/nginx -g "daemon off; error_log /dev/stderr info;"
|
|
3
|
+
autostart = true
|
|
4
|
+
autorestart = true
|
|
5
|
+
priority = 10
|
|
6
|
+
stdout_events_enabled = true
|
|
7
|
+
stderr_events_enabled = true
|
|
8
|
+
stdout_logfile = /dev/stdout
|
|
9
|
+
stdout_logfile_maxbytes = 0
|
|
10
|
+
stderr_logfile = /dev/stderr
|
|
11
|
+
stderr_logfile_maxbytes = 0
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
FROM alpine
|
|
2
|
+
|
|
3
|
+
LABEL vendor="Pushwoosh Inc." \
|
|
4
|
+
name="WebSDK" \
|
|
5
|
+
version="1.0"
|
|
6
|
+
|
|
7
|
+
RUN apk add --update git jq curl nodejs npm
|
|
8
|
+
|
|
9
|
+
ARG GITHUB_OWNER
|
|
10
|
+
ARG GITHUB_REPO
|
|
11
|
+
ARG GITHUB_USERNAME
|
|
12
|
+
ARG GITHUB_TOKEN
|
|
13
|
+
ARG GITLAB_TOKEN
|
|
14
|
+
ARG CI_PROJECT_ID
|
|
15
|
+
ARG CI_COMMIT_TAG
|
|
16
|
+
|
|
17
|
+
ENV GITHUB_OWNER=${GITHUB_OWNER}
|
|
18
|
+
ENV GITHUB_REPO=${GITHUB_REPO}
|
|
19
|
+
ENV GITHUB_USERNAME=${GITHUB_USERNAME}
|
|
20
|
+
ENV GITHUB_TOKEN=${GITHUB_TOKEN}
|
|
21
|
+
ENV GITLAB_TOKEN=${GITLAB_TOKEN}
|
|
22
|
+
ENV CI_PROJECT_ID=${CI_PROJECT_ID}
|
|
23
|
+
ENV CI_COMMIT_TAG=${CI_COMMIT_TAG}
|
|
24
|
+
|
|
25
|
+
RUN git config --global user.email "help@pushwoosh.com"
|
|
26
|
+
RUN git config --global user.name "${GITHUB_USERNAME}"
|
|
27
|
+
RUN git config --global user.password "${GITHUB_TOKEN}"
|
|
28
|
+
|
|
29
|
+
RUN mkdir -p github
|
|
30
|
+
RUN cd /github && git init && git remote add origin https://${GITHUB_USERNAME}:${GITHUB_TOKEN}@github.com/${GITHUB_OWNER}/${GITHUB_REPO}.git
|
|
31
|
+
|
|
32
|
+
RUN touch /tag-message.txt
|
|
33
|
+
RUN chmod +x /tag-message.txt
|
|
34
|
+
RUN echo $(curl --header "Private-Token: $GITLAB_TOKEN" https://gitlab.corp.pushwoosh.com/api/v4/projects/${CI_PROJECT_ID}/repository/tags/${CI_COMMIT_TAG} | jq ".message") > /tag-message.txt
|
|
35
|
+
|
|
36
|
+
COPY config /github/config
|
|
37
|
+
COPY develop /github/develop
|
|
38
|
+
COPY public /github/public
|
|
39
|
+
COPY scripts /github/scripts
|
|
40
|
+
COPY src /github/src
|
|
41
|
+
# COPY types /github/types
|
|
42
|
+
COPY output/cdn /github/dist
|
|
43
|
+
|
|
44
|
+
COPY package.json /github/package.json
|
|
45
|
+
COPY .gitignore /github/.gitignore
|
|
46
|
+
|
|
47
|
+
# COPY tslint.json /github/babel.config.json
|
|
48
|
+
COPY tsconfig.json /github/tsconfig.json
|
|
49
|
+
# COPY tslint.json /github/tslint.json
|
|
50
|
+
|
|
51
|
+
COPY webpack.config.js /github/webpack.config.js
|
|
52
|
+
# COPY webpack.lib.config.js /github/webpack.lib.config.js
|
|
53
|
+
|
|
54
|
+
COPY README.md /github/README.md
|
|
55
|
+
COPY LICENSE.md /github/LICENSE.md
|
|
56
|
+
|
|
57
|
+
COPY ci/github/release-zip.js /ci/release-zip.js
|
|
58
|
+
|
|
59
|
+
RUN echo RELEASE_NOTE=$(cat /tag-message.txt)
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
const exec = require('child_process').exec;
|
|
4
|
+
const fs = require('fs');
|
|
5
|
+
|
|
6
|
+
const repo = process.env.GITHUB_REPO;
|
|
7
|
+
const owner = process.env.GITHUB_OWNER;
|
|
8
|
+
const token = process.env.GITHUB_TOKEN;
|
|
9
|
+
const branch = process.env.BRANCH;
|
|
10
|
+
const releaseNote = process.env.RELEASE_NOTE;
|
|
11
|
+
|
|
12
|
+
fs.readFile('/github/package.json', 'utf8', (err, packageJSON) => {
|
|
13
|
+
const currentVersion = JSON.parse(packageJSON).version;
|
|
14
|
+
|
|
15
|
+
const data = JSON.stringify({
|
|
16
|
+
tag_name: `v${currentVersion}`,
|
|
17
|
+
name: `Pushwoosh Web SDK v${currentVersion}`,
|
|
18
|
+
body: releaseNote,
|
|
19
|
+
target_commitish: branch,
|
|
20
|
+
draft: false,
|
|
21
|
+
prerelease: false,
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
exec(`curl -H 'Authorization: token ${token}' --data '${data}' https://api.github.com/repos/${owner}/${repo}/releases`,
|
|
25
|
+
(err, stdout, stderr) => {
|
|
26
|
+
if (err) {
|
|
27
|
+
console.log(err);
|
|
28
|
+
return process.exit(1);
|
|
29
|
+
}
|
|
30
|
+
if (stderr) {
|
|
31
|
+
console.log(stderr);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
stdout = JSON.parse(stdout);
|
|
35
|
+
|
|
36
|
+
if (stdout.upload_url) {
|
|
37
|
+
const zipFileName = `PushwooshWebSDK-${currentVersion}.zip`;
|
|
38
|
+
const url = stdout.upload_url.replace('{?name,label}', `?name=${zipFileName}`);
|
|
39
|
+
const upload = `curl -H 'Authorization: token ${token}' \\
|
|
40
|
+
-H 'Accept: application/vnd.github.v3+json' \\
|
|
41
|
+
-H 'Content-Type: application/zip' \\
|
|
42
|
+
--data-binary '@/github/dist/${zipFileName}' \\
|
|
43
|
+
${url}`;
|
|
44
|
+
exec(upload, (err, stdout, stderr) => {
|
|
45
|
+
if (err) {
|
|
46
|
+
console.log(err);
|
|
47
|
+
return process.exit(1);
|
|
48
|
+
}
|
|
49
|
+
if (stderr) {
|
|
50
|
+
console.log(stderr);
|
|
51
|
+
}
|
|
52
|
+
console.log(stdout);
|
|
53
|
+
return process.exit(0);
|
|
54
|
+
});
|
|
55
|
+
} else {
|
|
56
|
+
console.log(stdout);
|
|
57
|
+
return process.exit(1);
|
|
58
|
+
}
|
|
59
|
+
},
|
|
60
|
+
);
|
|
61
|
+
});
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
FROM node:10-alpine
|
|
2
|
+
|
|
3
|
+
LABEL vendor="Pushwoosh Inc." \
|
|
4
|
+
name="WebSDK" \
|
|
5
|
+
version="1.0"
|
|
6
|
+
|
|
7
|
+
ARG NPM_TOKEN
|
|
8
|
+
|
|
9
|
+
ENV NPM_TOKEN=${NPM_TOKEN}
|
|
10
|
+
|
|
11
|
+
COPY output/npm /publish/
|
|
12
|
+
|
|
13
|
+
COPY .npmrc /publish/.npmrc
|
|
14
|
+
COPY package.json /publish/package.json
|
|
15
|
+
|
|
16
|
+
COPY README.md /publish/README.md
|
|
17
|
+
COPY LICENSE.md /publish/LICENSE.md
|
|
18
|
+
|
|
19
|
+
WORKDIR /publish
|
package/config/config.js
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
module.exports = {
|
|
2
|
+
initParams: {
|
|
3
|
+
logLevel: 'info',
|
|
4
|
+
applicationCode: 'XXXXX-XXXXX',
|
|
5
|
+
apiToken: 'abcdxyz',
|
|
6
|
+
safariWebsitePushID: 'web.com.example.test',
|
|
7
|
+
defaultNotificationTitle: 'Pushwoosh',
|
|
8
|
+
defaultNotificationImage: 'https://cp.pushwoosh.com/img/logo-medium.png',
|
|
9
|
+
autoSubscribe: false,
|
|
10
|
+
userId: 'user_id',
|
|
11
|
+
serviceWorkerUrl: 'pushwoosh-service-worker.js',
|
|
12
|
+
tags: {
|
|
13
|
+
Name: 'John Doe',
|
|
14
|
+
},
|
|
15
|
+
subscribeWidget: {
|
|
16
|
+
enable: true,
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
|
|
20
|
+
ssl: {
|
|
21
|
+
key: '', // absolute path to key
|
|
22
|
+
cert: '', // absolute path to cert
|
|
23
|
+
},
|
|
24
|
+
};
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
const fs = require('fs');
|
|
2
|
+
const path = require('path');
|
|
3
|
+
|
|
4
|
+
const BASE_PATH = '__base__';
|
|
5
|
+
|
|
6
|
+
// Utils
|
|
7
|
+
function parseEnvKey(key) {
|
|
8
|
+
return key
|
|
9
|
+
.slice(3)
|
|
10
|
+
.replace(/__/g, '.')
|
|
11
|
+
.split('.');
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
function castEnvValueTypes(value) {
|
|
15
|
+
switch (value) {
|
|
16
|
+
case 'true':
|
|
17
|
+
return true;
|
|
18
|
+
case 'false':
|
|
19
|
+
return false;
|
|
20
|
+
default:
|
|
21
|
+
return value;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function setValueByPath(path, obj, value) {
|
|
26
|
+
let tmpConfig = obj;
|
|
27
|
+
path.forEach((pathPart, i) => {
|
|
28
|
+
if (!(pathPart in tmpConfig)) {
|
|
29
|
+
tmpConfig[pathPart] = {};
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
if (i === path.length - 1) {
|
|
33
|
+
tmpConfig[pathPart] = value;
|
|
34
|
+
} else {
|
|
35
|
+
tmpConfig = tmpConfig[pathPart];
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function buildObjectsMap(object, path = BASE_PATH) {
|
|
41
|
+
const objMap = { [path]: Object.assign({}, object) };
|
|
42
|
+
Object.keys(object).forEach((key) => {
|
|
43
|
+
if (object[key] !== null && !Array.isArray(object[key]) && typeof object[key] === 'object') {
|
|
44
|
+
delete objMap[path][key];
|
|
45
|
+
Object.assign(objMap, buildObjectsMap(object[key], `${path}.${key}`));
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
return objMap;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function configDeepAssign(...configs) {
|
|
52
|
+
const [baseConfig, ...anotherConfigs] = configs;
|
|
53
|
+
|
|
54
|
+
// Make result config map
|
|
55
|
+
const resConfigMap = buildObjectsMap(baseConfig);
|
|
56
|
+
anotherConfigs.forEach((config) => {
|
|
57
|
+
const configMap = buildObjectsMap(config);
|
|
58
|
+
Object.keys(configMap).forEach((key) => {
|
|
59
|
+
if (key in resConfigMap) {
|
|
60
|
+
Object.assign(resConfigMap[key], configMap[key]);
|
|
61
|
+
delete configMap[key];
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
Object.assign(resConfigMap, configMap);
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
// Make config from map
|
|
68
|
+
const result = {};
|
|
69
|
+
Object.keys(resConfigMap).forEach((key) => {
|
|
70
|
+
if (key === BASE_PATH) {
|
|
71
|
+
Object.assign(result, resConfigMap[key]);
|
|
72
|
+
} else {
|
|
73
|
+
const path = key.replace(`${BASE_PATH}.`, '').split('.');
|
|
74
|
+
setValueByPath(path, result, resConfigMap[key]);
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
return result;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
// Config Getters
|
|
82
|
+
function getEnvironmentConfig() {
|
|
83
|
+
const envConfig = {};
|
|
84
|
+
Object.keys(process.env).forEach((envKey) => {
|
|
85
|
+
if (!envKey.startsWith('PW_')) {
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
const path = parseEnvKey(envKey);
|
|
90
|
+
const value = castEnvValueTypes(process.env[envKey]);
|
|
91
|
+
setValueByPath(path, envConfig, value);
|
|
92
|
+
});
|
|
93
|
+
return envConfig;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
// Configs
|
|
97
|
+
const defaultConfig = require(path.resolve(__dirname, 'config.js')); // Default
|
|
98
|
+
|
|
99
|
+
const configPath = process.env.GUI_CONFIG_PRESET_NAME
|
|
100
|
+
? path.resolve(__dirname, `config.${process.env.GUI_CONFIG_PRESET_NAME}.js`)
|
|
101
|
+
: '';
|
|
102
|
+
const presetConfig = fs.existsSync(configPath) ? require(configPath) : {}; // Preset
|
|
103
|
+
|
|
104
|
+
const LOCAL_CONFIG_PATH = path.resolve(__dirname, 'config.local.js');
|
|
105
|
+
const localConfig = fs.existsSync(LOCAL_CONFIG_PATH) && process.env.NODE_ENV !== 'production'
|
|
106
|
+
? require(LOCAL_CONFIG_PATH)
|
|
107
|
+
: {}; // Local
|
|
108
|
+
|
|
109
|
+
const fileConfig = {}; // Custom file
|
|
110
|
+
|
|
111
|
+
const envConfig = getEnvironmentConfig(); // Environment
|
|
112
|
+
|
|
113
|
+
const QA_CONFIG_PATH = path.resolve(__dirname, 'config.qa.js');
|
|
114
|
+
const qaConfig = fs.existsSync(QA_CONFIG_PATH) ? require(QA_CONFIG_PATH) : {}; // QA
|
|
115
|
+
|
|
116
|
+
// Build result config
|
|
117
|
+
const config = configDeepAssign(
|
|
118
|
+
defaultConfig,
|
|
119
|
+
presetConfig,
|
|
120
|
+
localConfig,
|
|
121
|
+
fileConfig,
|
|
122
|
+
envConfig,
|
|
123
|
+
qaConfig,
|
|
124
|
+
);
|
|
125
|
+
|
|
126
|
+
module.exports = config;
|
package/config/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
module.exports.configBuilder = require('./configBuilder');
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
# Change init params
|
|
2
|
+
|
|
3
|
+
#### Clone the `config/config.js` to a `config/config.local.js` and edit it
|
|
4
|
+
|
|
5
|
+
```js
|
|
6
|
+
module.exports = {
|
|
7
|
+
initParams: {
|
|
8
|
+
applicationCode: 'XXXXX-XXXXX',
|
|
9
|
+
safariWebsitePushID: 'web.com.example.test',
|
|
10
|
+
serviceWorkerUrl: 'pushwoosh-service-worker.uncompress.js'
|
|
11
|
+
},
|
|
12
|
+
|
|
13
|
+
ssl: {
|
|
14
|
+
key: '', // absolute path to key
|
|
15
|
+
cert: '' // absolute path to cert
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## Build development
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
npm run build
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## Build production
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
npm run build:prod
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## Run server
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
npm run start
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## Prepare release files
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
npm run release
|
|
42
|
+
```
|
|
Binary file
|