Add svelte as a view engine to swaf #33

Merged
ashpie merged 97 commits from svelte into develop 2021-11-09 19:31:22 +01:00
4 changed files with 13 additions and 5 deletions
Showing only changes of commit d423d78f2a - Show all commits

View File

@ -1,4 +1,4 @@
module.exports = { export default {
globals: { globals: {
'ts-jest': { 'ts-jest': {
tsconfig: 'tsconfig.test.json', tsconfig: 'tsconfig.test.json',
@ -17,4 +17,5 @@ module.exports = {
], ],
testEnvironment: 'node', testEnvironment: 'node',
testTimeout: 60000, testTimeout: 60000,
resolver: "jest-ts-webcompat-resolver",
}; };

View File

@ -62,6 +62,8 @@
"eslint-plugin-simple-import-sort": "^7.0.0", "eslint-plugin-simple-import-sort": "^7.0.0",
"eslint-plugin-svelte3": "^3.1.2", "eslint-plugin-svelte3": "^3.1.2",
"jest": "^26.1.0", "jest": "^26.1.0",
"jest-resolve": "^26.6.2",
"jest-ts-webcompat-resolver": "^1.0.0",
"maildev": "^1.1.0", "maildev": "^1.1.0",
"node-fetch": "^2.6.0", "node-fetch": "^2.6.0",
"nodemon": "^2.0.6", "nodemon": "^2.0.6",

View File

@ -18,7 +18,7 @@ import Extendable from "./Extendable.js";
import {BadRequestError, HttpError, NotFoundHttpError, ServerError, ServiceUnavailableHttpError} from "./HttpError.js"; import {BadRequestError, HttpError, NotFoundHttpError, ServerError, ServiceUnavailableHttpError} from "./HttpError.js";
import {logger, loggingContextMiddleware} from "./Logger.js"; import {logger, loggingContextMiddleware} from "./Logger.js";
import SecurityError from "./SecurityError.js"; import SecurityError from "./SecurityError.js";
import {Type} from "./Utils.js"; import {doesFileExist, Type} from "./Utils.js";
import WebSocketListener from "./WebSocketListener.js"; import WebSocketListener from "./WebSocketListener.js";
import TemplateError = nunjucks.lib.TemplateError; import TemplateError = nunjucks.lib.TemplateError;
@ -69,7 +69,7 @@ export default abstract class Application implements Extendable<ApplicationCompo
this.busy = true; this.busy = true;
// Load core version // Load core version
const file = this.isInNodeModules() ? const file = await this.isInNodeModules() ?
'node_modules/swaf/package.json' : 'node_modules/swaf/package.json' :
'package.json'; 'package.json';
@ -378,8 +378,8 @@ export default abstract class Application implements Extendable<ApplicationCompo
return module ? module as C : null; return module ? module as C : null;
} }
public isInNodeModules(): boolean { public async isInNodeModules(): Promise<boolean> {
return path.dirname(url.fileURLToPath(import.meta.url)).endsWith('/node_modules/swaf'); return !await doesFileExist('node_modules/swaf');
} }
public isReady(): boolean { public isReady(): boolean {

View File

@ -4347,6 +4347,11 @@ jest-snapshot@^26.6.2:
pretty-format "^26.6.2" pretty-format "^26.6.2"
semver "^7.3.2" semver "^7.3.2"
jest-ts-webcompat-resolver@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/jest-ts-webcompat-resolver/-/jest-ts-webcompat-resolver-1.0.0.tgz#a554eb77446e1a8d2aabb810d6302bffaa00095c"
integrity sha512-BFoaU7LeYqZNnTYEr6iMRf87xdCQntNc/Wk8YpzDBcuz+CIZ0JsTtzuMAMnKiEgTRTC1wRWLUo2RlVjVijBcHQ==
jest-util@^26.1.0, jest-util@^26.6.2: jest-util@^26.1.0, jest-util@^26.6.2:
version "26.6.2" version "26.6.2"
resolved "https://registry.yarnpkg.com/jest-util/-/jest-util-26.6.2.tgz#907535dbe4d5a6cb4c47ac9b926f6af29576cbc1" resolved "https://registry.yarnpkg.com/jest-util/-/jest-util-26.6.2.tgz#907535dbe4d5a6cb4c47ac9b926f6af29576cbc1"