aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--.gitlab-ci.yml38
-rw-r--r--client/src/app/core/plugins/plugin.service.ts3
-rw-r--r--client/src/app/shared/misc/utils.ts36
3 files changed, 69 insertions, 8 deletions
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 2f69eb1d2..401a5c960 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -3,13 +3,13 @@ image: chocobozzz/peertube-ci:10
3stages: 3stages:
4 - build-and-lint 4 - build-and-lint
5 - test 5 - test
6 - nightly 6 - docker-nightly
7 7
8before_script: 8#before_script:
9 - 'sed -i -z "s/database:\n hostname: ''localhost''/database:\n hostname: ''postgres''/" config/test.yaml' 9# - 'sed -i -z "s/database:\n hostname: ''localhost''/database:\n hostname: ''postgres''/" config/test.yaml'
10 - 'sed -i -z "s/redis:\n hostname: ''localhost''/redis:\n hostname: ''redis''/" config/test.yaml' 10# - 'sed -i -z "s/redis:\n hostname: ''localhost''/redis:\n hostname: ''redis''/" config/test.yaml'
11 - if [[ $CI_JOB_STAGE == "test" ]]; then psql -c "create user peertube with password 'peertube';"; fi 11# - if [[ $CI_JOB_STAGE == "test" ]]; then psql -c "create user peertube with password 'peertube';"; fi
12 - NOCLIENT=1 yarn install --pure-lockfile --cache-folder .yarn-cache 12# - NOCLIENT=1 yarn install --pure-lockfile --cache-folder .yarn-cache
13 13
14cache: 14cache:
15 key: yarn 15 key: yarn
@@ -85,7 +85,7 @@ cache:
85# - NODE_PENDING_JOB_WAIT=1000 npm run ci -- api-$CI_NODE_INDEX 85# - NODE_PENDING_JOB_WAIT=1000 npm run ci -- api-$CI_NODE_INDEX
86 86
87build-nightly: 87build-nightly:
88 stage: nightly 88 stage: docker-nightly
89 only: 89 only:
90 - schedules 90 - schedules
91 script: 91 script:
@@ -98,3 +98,27 @@ build-nightly:
98 - if [ ! -z ${DEPLOYEMENT_KEY+x} ]; then ssh-add <(echo "${DEPLOYEMENT_KEY}"); fi 98 - if [ ! -z ${DEPLOYEMENT_KEY+x} ]; then ssh-add <(echo "${DEPLOYEMENT_KEY}"); fi
99 - if [ ! -z ${DEPLOYEMENT_KEY+x} ]; then scp ./peertube-nightly-* ${DEPLOYEMENT_USER}@${DEPLOYEMENT_HOST}:../../web/nightly; fi 99 - if [ ! -z ${DEPLOYEMENT_KEY+x} ]; then scp ./peertube-nightly-* ${DEPLOYEMENT_USER}@${DEPLOYEMENT_HOST}:../../web/nightly; fi
100 100
101.docker: &docker
102 stage: docker-nightly
103 image:
104 name: gcr.io/kaniko-project/executor:debug
105 entrypoint: [""]
106 before_script:
107 - echo "{\"auths\":{\"$CI_REGISTRY\":{\"auth\":\"$CI_REGISTRY_AUTH\",\"email\":\"$CI_REGISTRY_EMAIL\"}}}" > /kaniko/.docker/config.json
108 script:
109 - /kaniko/executor --context $CI_PROJECT_DIR --dockerfile $CI_PROJECT_DIR/support/docker/production/Dockerfile.stretch --destination $DOCKER_IMAGE_NAME
110
111build-docker-develop:
112 <<: *docker
113 only:
114 - schedules
115 - develop
116 variables:
117 DOCKER_IMAGE_NAME: chocobozzz/peertube:develop-stretch
118
119build-docker-tag:
120 <<: *docker
121 only:
122 - tags
123 variables:
124 DOCKER_IMAGE_NAME: chocobozzz/peertube:$CI_COMMIT_TAG-stretch
diff --git a/client/src/app/core/plugins/plugin.service.ts b/client/src/app/core/plugins/plugin.service.ts
index 3bb82e8a9..3af36765a 100644
--- a/client/src/app/core/plugins/plugin.service.ts
+++ b/client/src/app/core/plugins/plugin.service.ts
@@ -18,6 +18,7 @@ import { PublicServerSetting } from '@shared/models/plugins/public-server.settin
18import { getDevLocale, isOnDevLocale } from '@app/shared/i18n/i18n-utils' 18import { getDevLocale, isOnDevLocale } from '@app/shared/i18n/i18n-utils'
19import { RegisterClientHelpers } from '../../../types/register-client-option.model' 19import { RegisterClientHelpers } from '../../../types/register-client-option.model'
20import { PluginTranslation } from '@shared/models/plugins/plugin-translation.model' 20import { PluginTranslation } from '@shared/models/plugins/plugin-translation.model'
21import { importModule } from '@app/shared/misc/utils'
21 22
22interface HookStructValue extends RegisterClientHookOptions { 23interface HookStructValue extends RegisterClientHookOptions {
23 plugin: ServerConfigPlugin 24 plugin: ServerConfigPlugin
@@ -222,7 +223,7 @@ export class PluginService implements ClientHook {
222 console.log('Loading script %s of plugin %s.', clientScript.script, plugin.name) 223 console.log('Loading script %s of plugin %s.', clientScript.script, plugin.name)
223 224
224 return this.zone.runOutsideAngular(() => { 225 return this.zone.runOutsideAngular(() => {
225 return import(/* webpackIgnore: true */ clientScript.script) 226 return importModule(clientScript.script)
226 .then((script: ClientScriptModule) => script.register({ registerHook, peertubeHelpers })) 227 .then((script: ClientScriptModule) => script.register({ registerHook, peertubeHelpers }))
227 .then(() => this.sortHooksByPriority()) 228 .then(() => this.sortHooksByPriority())
228 .catch(err => console.error('Cannot import or register plugin %s.', pluginInfo.plugin.name, err)) 229 .catch(err => console.error('Cannot import or register plugin %s.', pluginInfo.plugin.name, err))
diff --git a/client/src/app/shared/misc/utils.ts b/client/src/app/shared/misc/utils.ts
index 85fc1c3a0..f26240d21 100644
--- a/client/src/app/shared/misc/utils.ts
+++ b/client/src/app/shared/misc/utils.ts
@@ -134,6 +134,41 @@ function scrollToTop () {
134 window.scroll(0, 0) 134 window.scroll(0, 0)
135} 135}
136 136
137// Thanks: https://github.com/uupaa/dynamic-import-polyfill
138function importModule (path: string) {
139 return new Promise((resolve, reject) => {
140 const vector = '$importModule$' + Math.random().toString(32).slice(2)
141 const script = document.createElement('script')
142
143 const destructor = () => {
144 delete window[ vector ]
145 script.onerror = null
146 script.onload = null
147 script.remove()
148 URL.revokeObjectURL(script.src)
149 script.src = ''
150 }
151
152 script.defer = true
153 script.type = 'module'
154
155 script.onerror = () => {
156 reject(new Error(`Failed to import: ${path}`))
157 destructor()
158 }
159 script.onload = () => {
160 resolve(window[ vector ])
161 destructor()
162 }
163 const absURL = (environment.apiUrl || window.location.origin) + path
164 const loader = `import * as m from "${absURL}"; window.${vector} = m;` // export Module
165 const blob = new Blob([ loader ], { type: 'text/javascript' })
166 script.src = URL.createObjectURL(blob)
167
168 document.head.appendChild(script)
169 })
170}
171
137export { 172export {
138 sortBy, 173 sortBy,
139 durationToString, 174 durationToString,
@@ -147,5 +182,6 @@ export {
147 objectToFormData, 182 objectToFormData,
148 objectLineFeedToHtml, 183 objectLineFeedToHtml,
149 removeElementFromArray, 184 removeElementFromArray,
185 importModule,
150 scrollToTop 186 scrollToTop
151} 187}