aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.gitignore1
-rw-r--r--gulpfile.babel.js53
-rw-r--r--package-lock.json49
-rw-r--r--package.json7
-rw-r--r--src/helpers/url-helpers.ts (renamed from src/helpers/url-helpers.js)8
-rw-r--r--tsconfig.json4
-rw-r--r--tsconfig.settings.json6
7 files changed, 103 insertions, 25 deletions
diff --git a/.gitignore b/.gitignore
index b09745150..a10427aad 100644
--- a/.gitignore
+++ b/.gitignore
@@ -349,4 +349,3 @@ server*.log
349/src/internal-server/public/privacy.html 349/src/internal-server/public/privacy.html
350 350
351/src/internal-server/user_data/ 351/src/internal-server/user_data/
352.tstmp/
diff --git a/gulpfile.babel.js b/gulpfile.babel.js
index 08cc34b63..1f3c42a3d 100644
--- a/gulpfile.babel.js
+++ b/gulpfile.babel.js
@@ -14,6 +14,7 @@ import sassVariables from 'gulp-sass-variables';
14import { removeSync, outputJson } from 'fs-extra'; 14import { removeSync, outputJson } from 'fs-extra';
15import kebabCase from 'kebab-case'; 15import kebabCase from 'kebab-case';
16import hexRgb from 'hex-rgb'; 16import hexRgb from 'hex-rgb';
17import ts from 'gulp-typescript';
17 18
18import * as buildInfo from 'preval-build-info'; 19import * as buildInfo from 'preval-build-info';
19import config from './package.json'; 20import config from './package.json';
@@ -29,6 +30,8 @@ const isDevBuild = process.env.NODE_ENV === 'development';
29 30
30const getTargetEnv = isDevBuild ? 'development' : 'production'; 31const getTargetEnv = isDevBuild ? 'development' : 'production';
31 32
33const tsProject = ts.createProject('tsconfig.json');
34
32const styleConfig = Object.keys(rawStyleConfig).map(key => { 35const styleConfig = Object.keys(rawStyleConfig).map(key => {
33 const isHex = /^#[0-9A-F]{6}$/i.test(rawStyleConfig[key]); 36 const isHex = /^#[0-9A-F]{6}$/i.test(rawStyleConfig[key]);
34 return { 37 return {
@@ -67,7 +70,7 @@ const paths = {
67 src: 'src/styles/vertical.scss', 70 src: 'src/styles/vertical.scss',
68 dest: 'build/styles', 71 dest: 'build/styles',
69 }, 72 },
70 scripts: { 73 javascripts: {
71 src: 'src/**/*.js', 74 src: 'src/**/*.js',
72 dest: 'build/', 75 dest: 'build/',
73 watch: [ 76 watch: [
@@ -75,6 +78,14 @@ const paths = {
75 'src/**/*.js', 78 'src/**/*.js',
76 ], 79 ],
77 }, 80 },
81 typescripts: {
82 src: 'src/**/*.ts',
83 dest: 'build/',
84 watch: [
85 // 'packages/**/*.ts',
86 'src/**/*.ts',
87 ],
88 },
78 packages: { 89 packages: {
79 watch: 'packages/**/*', 90 watch: 'packages/**/*',
80 // dest: 'build/', 91 // dest: 'build/',
@@ -121,9 +132,11 @@ export function mvSrc() {
121 [ 132 [
122 `${paths.src}/*`, 133 `${paths.src}/*`,
123 `${paths.src}/*/**`, 134 `${paths.src}/*/**`,
124 `!${paths.scripts.watch[1]}`, 135 `!${paths.javascripts.watch[1]}`,
136 `!${paths.typescripts.watch[1]}`,
125 `!${paths.src}/styles/**`, 137 `!${paths.src}/styles/**`,
126 `!${paths.src}/**/*.js`, 138 `!${paths.src}/**/*.js`,
139 `!${paths.src}/**/*.ts`,
127 ], 140 ],
128 { since: gulp.lastRun(mvSrc) }, 141 { since: gulp.lastRun(mvSrc) },
129 ) 142 )
@@ -226,16 +239,39 @@ export function verticalStyle() {
226 .pipe(connect.reload()); 239 .pipe(connect.reload());
227} 240}
228 241
229export function scripts() { 242export function processJavascripts() {
230 return gulp 243 return gulp
231 .src(paths.scripts.src, { since: gulp.lastRun(scripts) }) 244 .src(
245 [
246 paths.javascripts.src,
247 ],
248 { since: gulp.lastRun(processJavascripts) })
249 .pipe(
250 babel({
251 comments: false,
252 }),
253 )
254 .pipe(gulpIf(!isDevBuild, uglify())) // Only uglify in production to speed up dev builds
255 .pipe(gulp.dest(paths.javascripts.dest))
256 .pipe(connect.reload());
257}
258
259export function processTypescripts() {
260 return gulp
261 .src(
262 [
263 paths.typescripts.src,
264 ],
265 { since: gulp.lastRun(processTypescripts) })
266 .pipe(tsProject())
267 .js
232 .pipe( 268 .pipe(
233 babel({ 269 babel({
234 comments: false, 270 comments: false,
235 }), 271 }),
236 ) 272 )
237 .pipe(gulpIf(!isDevBuild, uglify())) // Only uglify in production to speed up dev builds 273 .pipe(gulpIf(!isDevBuild, uglify())) // Only uglify in production to speed up dev builds
238 .pipe(gulp.dest(paths.scripts.dest)) 274 .pipe(gulp.dest(paths.typescripts.dest))
239 .pipe(connect.reload()); 275 .pipe(connect.reload());
240} 276}
241 277
@@ -244,9 +280,10 @@ export function watch() {
244 gulp.watch(paths.styles.watch, styles); 280 gulp.watch(paths.styles.watch, styles);
245 gulp.watch(paths.verticalStyle.src, verticalStyle); 281 gulp.watch(paths.verticalStyle.src, verticalStyle);
246 282
247 gulp.watch([paths.src, `${paths.scripts.src}`, `${paths.styles.src}`], mvSrc); 283 gulp.watch([paths.src, `${paths.javascripts.src}`, `${paths.styles.src}`], mvSrc);
248 284
249 gulp.watch(paths.scripts.watch, scripts); 285 gulp.watch(paths.javascripts.watch, processJavascripts);
286 gulp.watch(paths.typescripts.watch, processTypescripts);
250} 287}
251 288
252export function webserver() { 289export function webserver() {
@@ -270,7 +307,7 @@ export function recipeInfo() {
270const build = gulp.series( 307const build = gulp.series(
271 clean, 308 clean,
272 gulp.parallel(mvSrc, mvPackageJson, mvLernaPackages, exportBuildInfo), 309 gulp.parallel(mvSrc, mvPackageJson, mvLernaPackages, exportBuildInfo),
273 gulp.parallel(html, scripts, styles, verticalStyle, recipes, recipeInfo), 310 gulp.parallel(html, processJavascripts, processTypescripts, styles, verticalStyle, recipes, recipeInfo),
274); 311);
275export { build }; 312export { build };
276 313
diff --git a/package-lock.json b/package-lock.json
index 2f6528b27..41afd1f19 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -9315,7 +9315,8 @@
9315 "buffer-from": { 9315 "buffer-from": {
9316 "version": "1.1.2", 9316 "version": "1.1.2",
9317 "resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.2.tgz", 9317 "resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.2.tgz",
9318 "integrity": "sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ==" 9318 "integrity": "sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ==",
9319 "dev": true
9319 }, 9320 },
9320 "buffer-indexof": { 9321 "buffer-indexof": {
9321 "version": "1.1.1", 9322 "version": "1.1.1",
@@ -16523,6 +16524,44 @@
16523 "through2": "^2.0.1" 16524 "through2": "^2.0.1"
16524 } 16525 }
16525 }, 16526 },
16527 "gulp-typescript": {
16528 "version": "6.0.0-alpha.1",
16529 "resolved": "https://registry.npmjs.org/gulp-typescript/-/gulp-typescript-6.0.0-alpha.1.tgz",
16530 "integrity": "sha512-KoT0TTfjfT7w3JItHkgFH1T/zK4oXWC+a8xxKfniRfVcA0Fa1bKrIhztYelYmb+95RB80OLMBreknYkdwzdi2Q==",
16531 "dev": true,
16532 "requires": {
16533 "ansi-colors": "^4.1.1",
16534 "plugin-error": "^1.0.1",
16535 "source-map": "^0.7.3",
16536 "through2": "^3.0.1",
16537 "vinyl": "^2.2.0",
16538 "vinyl-fs": "^3.0.3"
16539 },
16540 "dependencies": {
16541 "ansi-colors": {
16542 "version": "4.1.1",
16543 "resolved": "https://registry.npmjs.org/ansi-colors/-/ansi-colors-4.1.1.tgz",
16544 "integrity": "sha512-JoX0apGbHaUJBNl6yF+p6JAFYZ666/hhCGKN5t9QFjbJQKUU/g8MNbFDbvfrgKXvI1QpZplPOnwIo99lX/AAmA==",
16545 "dev": true
16546 },
16547 "source-map": {
16548 "version": "0.7.3",
16549 "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.7.3.tgz",
16550 "integrity": "sha512-CkCj6giN3S+n9qrYiBTX5gystlENnRW5jZeNLHpe6aue+SrHcG5VYwujhW9s4dY31mEGsxBDrHR6oI69fTXsaQ==",
16551 "dev": true
16552 },
16553 "through2": {
16554 "version": "3.0.2",
16555 "resolved": "https://registry.npmjs.org/through2/-/through2-3.0.2.tgz",
16556 "integrity": "sha512-enaDQ4MUyP2W6ZyT6EsMzqBPZaM/avg8iuo+l2d3QCs0J+6RaqkHV/2/lOwDTueBHeJ/2LG9lrLW3d5rWPucuQ==",
16557 "dev": true,
16558 "requires": {
16559 "inherits": "^2.0.4",
16560 "readable-stream": "2 || 3"
16561 }
16562 }
16563 }
16564 },
16526 "gulp-uglify": { 16565 "gulp-uglify": {
16527 "version": "3.0.2", 16566 "version": "3.0.2",
16528 "resolved": "https://registry.npmjs.org/gulp-uglify/-/gulp-uglify-3.0.2.tgz", 16567 "resolved": "https://registry.npmjs.org/gulp-uglify/-/gulp-uglify-3.0.2.tgz",
@@ -27286,6 +27325,7 @@
27286 "version": "0.5.19", 27325 "version": "0.5.19",
27287 "resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.5.19.tgz", 27326 "resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.5.19.tgz",
27288 "integrity": "sha512-Wonm7zOCIJzBGQdB+thsPar0kYuCIzYvxZwlBa87yi/Mdjv7Tip2cyVbLj5o0cFPN4EVkuTwb3GDDyUx2DGnGw==", 27327 "integrity": "sha512-Wonm7zOCIJzBGQdB+thsPar0kYuCIzYvxZwlBa87yi/Mdjv7Tip2cyVbLj5o0cFPN4EVkuTwb3GDDyUx2DGnGw==",
27328 "dev": true,
27289 "requires": { 27329 "requires": {
27290 "buffer-from": "^1.0.0", 27330 "buffer-from": "^1.0.0",
27291 "source-map": "^0.6.0" 27331 "source-map": "^0.6.0"
@@ -27294,7 +27334,8 @@
27294 "source-map": { 27334 "source-map": {
27295 "version": "0.6.1", 27335 "version": "0.6.1",
27296 "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", 27336 "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz",
27297 "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==" 27337 "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==",
27338 "dev": true
27298 } 27339 }
27299 } 27340 }
27300 }, 27341 },
@@ -28259,6 +28300,7 @@
28259 "version": "4.4.0", 28300 "version": "4.4.0",
28260 "resolved": "https://registry.npmjs.org/terser/-/terser-4.4.0.tgz", 28301 "resolved": "https://registry.npmjs.org/terser/-/terser-4.4.0.tgz",
28261 "integrity": "sha512-oDG16n2WKm27JO8h4y/w3iqBGAOSCtq7k8dRmrn4Wf9NouL0b2WpMHGChFGZq4nFAQy1FsNJrVQHfurXOSTmOA==", 28302 "integrity": "sha512-oDG16n2WKm27JO8h4y/w3iqBGAOSCtq7k8dRmrn4Wf9NouL0b2WpMHGChFGZq4nFAQy1FsNJrVQHfurXOSTmOA==",
28303 "dev": true,
28262 "requires": { 28304 "requires": {
28263 "commander": "^2.20.0", 28305 "commander": "^2.20.0",
28264 "source-map": "~0.6.1", 28306 "source-map": "~0.6.1",
@@ -28268,7 +28310,8 @@
28268 "source-map": { 28310 "source-map": {
28269 "version": "0.6.1", 28311 "version": "0.6.1",
28270 "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", 28312 "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz",
28271 "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==" 28313 "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==",
28314 "dev": true
28272 } 28315 }
28273 } 28316 }
28274 }, 28317 },
diff --git a/package.json b/package.json
index 71b65c6ff..ce13d3c1e 100644
--- a/package.json
+++ b/package.json
@@ -128,7 +128,6 @@
128 "sqlite3": "5.0.0", 128 "sqlite3": "5.0.0",
129 "tar": "4.4.15", 129 "tar": "4.4.15",
130 "targz": "1.0.1", 130 "targz": "1.0.1",
131 "terser": "4.4.0",
132 "tslib": "2.3.0", 131 "tslib": "2.3.0",
133 "useragent-generator": "1.1.1-amkt-22079-finish.0", 132 "useragent-generator": "1.1.1-amkt-22079-finish.0",
134 "uuid": "3.3.3", 133 "uuid": "3.3.3",
@@ -186,11 +185,12 @@
186 "gulp-babel": "8.0.0", 185 "gulp-babel": "8.0.0",
187 "gulp-cli": "2.3.0", 186 "gulp-cli": "2.3.0",
188 "gulp-connect": "5.7.0", 187 "gulp-connect": "5.7.0",
189 "gulp-sass": "5.0.0",
190 "gulp-sass-variables": "1.2.0",
191 "gulp-csso": "4.0.1", 188 "gulp-csso": "4.0.1",
192 "gulp-htmlmin": "5.0.1", 189 "gulp-htmlmin": "5.0.1",
193 "gulp-if": "3.0.0", 190 "gulp-if": "3.0.0",
191 "gulp-sass": "5.0.0",
192 "gulp-sass-variables": "1.2.0",
193 "gulp-typescript": "6.0.0-alpha.1",
194 "gulp-uglify": "3.0.2", 194 "gulp-uglify": "3.0.2",
195 "hex-rgb": "3.0.0", 195 "hex-rgb": "3.0.0",
196 "html-webpack-plugin": "4.5.2", 196 "html-webpack-plugin": "4.5.2",
@@ -206,6 +206,7 @@
206 "react-intl-translations-manager": "5.0.3", 206 "react-intl-translations-manager": "5.0.3",
207 "sass": "1.37.5", 207 "sass": "1.37.5",
208 "simple-git": "2.42.0", 208 "simple-git": "2.42.0",
209 "terser": "4.4.0",
209 "ts-loader": "5.4.5", 210 "ts-loader": "5.4.5",
210 "typescript": "3.9.10", 211 "typescript": "3.9.10",
211 "webpack": "4.46.0", 212 "webpack": "4.46.0",
diff --git a/src/helpers/url-helpers.js b/src/helpers/url-helpers.ts
index b0dc9afbb..23e8fab29 100644
--- a/src/helpers/url-helpers.js
+++ b/src/helpers/url-helpers.ts
@@ -8,8 +8,8 @@ import { ALLOWED_PROTOCOLS } from '../config';
8 8
9const debug = require('debug')('Ferdi:Helpers:url'); 9const debug = require('debug')('Ferdi:Helpers:url');
10 10
11export function isValidExternalURL(url) { 11export function isValidExternalURL(url: string) {
12 let parsedUrl; 12 let parsedUrl: URL;
13 try { 13 try {
14 parsedUrl = new URL(url); 14 parsedUrl = new URL(url);
15 } catch (_) { 15 } catch (_) {
@@ -23,13 +23,13 @@ export function isValidExternalURL(url) {
23 return isAllowed; 23 return isAllowed;
24} 24}
25 25
26export async function openPath(folderName) { 26export async function openPath(folderName: string) {
27 ensureDirSync(folderName); 27 ensureDirSync(folderName);
28 shell.openPath(folderName); 28 shell.openPath(folderName);
29} 29}
30 30
31// TODO: Need to verify and fix/remove the skipping logic. Ideally, we should never skip this check 31// TODO: Need to verify and fix/remove the skipping logic. Ideally, we should never skip this check
32export function openExternalUrl(url, skipValidityCheck = false) { 32export function openExternalUrl(url: string, skipValidityCheck: boolean = false) {
33 if (skipValidityCheck || isValidExternalURL(url)) { 33 if (skipValidityCheck || isValidExternalURL(url)) {
34 shell.openExternal(url); 34 shell.openExternal(url);
35 } 35 }
diff --git a/tsconfig.json b/tsconfig.json
index 46e0e6cfa..2676f392d 100644
--- a/tsconfig.json
+++ b/tsconfig.json
@@ -1,7 +1,7 @@
1{ 1{
2 "extends": "./tsconfig.settings.json", 2 "extends": "./tsconfig.settings.json",
3 "compilerOptions": { 3 "compilerOptions": {
4 "outDir": ".tstmp", 4 "outDir": ".tmp",
5 "rootDir": "./" 5 "rootDir": "./"
6 }, 6 }
7} 7}
diff --git a/tsconfig.settings.json b/tsconfig.settings.json
index 67153089e..59e520710 100644
--- a/tsconfig.settings.json
+++ b/tsconfig.settings.json
@@ -6,6 +6,8 @@
6 "lib": ["es2015", "es2017", "dom"], 6 "lib": ["es2015", "es2017", "dom"],
7 "jsx": "react", 7 "jsx": "react",
8 "typeRoots": ["node_modules/@types"], 8 "typeRoots": ["node_modules/@types"],
9 "moduleResolution": "node",
10 "types": ["node"],
9 "sourceMap": true, 11 "sourceMap": true,
10 "noImplicitAny": false, // TODO: Need to switch 12 "noImplicitAny": false, // TODO: Need to switch
11 "allowSyntheticDefaultImports": true, 13 "allowSyntheticDefaultImports": true,
@@ -21,9 +23,5 @@
21 "noImplicitReturns": true, 23 "noImplicitReturns": true,
22 "noImplicitThis": true, 24 "noImplicitThis": true,
23 "preserveConstEnums": true, 25 "preserveConstEnums": true,
24 // "exclude": [
25 // "node_modules",
26 // "**/*.spec.ts"
27 // ]
28 } 26 }
29} 27}