@nzz/q-cli 1.10.3 → 2.0.0-beta.7
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/dist/index.js +79 -0
- package/dist/interfaces.js +1 -0
- package/dist/newCustomCode.js +106 -0
- package/dist/updateItem.js +191 -0
- package/dist/utils.js +11 -0
- package/package.json +27 -36
- package/.nvmrc +0 -1
- package/.travis.yml +0 -17
- package/.vscode/launch.json +0 -36
- package/.vscode/settings.json +0 -5
- package/LICENSE +0 -21
- package/README.md +0 -360
- package/bin/commands/bootstrap.js +0 -68
- package/bin/commands/qItem/configStore.js +0 -144
- package/bin/commands/qItem/copyItem/copyItem.js +0 -103
- package/bin/commands/qItem/copyItem/copySchema.json +0 -37
- package/bin/commands/qItem/createCustomCodeItem/createCustomCodeItem.js +0 -81
- package/bin/commands/qItem/createCustomCodeItem/schema.json +0 -41
- package/bin/commands/qItem/helpers.js +0 -102
- package/bin/commands/qItem/itemService.js +0 -310
- package/bin/commands/qItem/resourcesService.js +0 -148
- package/bin/commands/qItem/schemaService.js +0 -65
- package/bin/commands/qItem/updateItem/updateItem.js +0 -64
- package/bin/commands/server.js +0 -80
- package/bin/q.js +0 -213
- package/dev-server/config/default.js +0 -51
- package/dev-server/public/favicon.ico +0 -0
- package/dev-server/public/style.css +0 -64
- package/dev-server/routes/dev-view.js +0 -52
- package/dev-server/routes/file.js +0 -10
- package/dev-server/routes/rendering-info.js +0 -130
- package/dev-server/routes/routes.js +0 -6
- package/dev-server/routes/tool-default.js +0 -108
- package/dev-server/server-plugins.js +0 -1
- package/dev-server/server.js +0 -18
- package/dev-server/views/index.html +0 -184
- package/skeletons/custom-code-skeleton/.nvmrc +0 -1
- package/skeletons/custom-code-skeleton/.vscode/settings.json +0 -5
- package/skeletons/custom-code-skeleton/README.md +0 -26
- package/skeletons/custom-code-skeleton/index.d.ts +0 -3
- package/skeletons/custom-code-skeleton/package-lock.json +0 -7355
- package/skeletons/custom-code-skeleton/package.json +0 -46
- package/skeletons/custom-code-skeleton/q.config.json +0 -60
- package/skeletons/custom-code-skeleton/rollup.config.js +0 -185
- package/skeletons/custom-code-skeleton/src/App.scss +0 -5
- package/skeletons/custom-code-skeleton/src/App.svelte +0 -7
- package/skeletons/custom-code-skeleton/src/enums.ts +0 -0
- package/skeletons/custom-code-skeleton/src/interfaces.ts +0 -0
- package/skeletons/custom-code-skeleton/src/main-prod.ts +0 -4
- package/skeletons/custom-code-skeleton/src/main.scss +0 -1
- package/skeletons/custom-code-skeleton/src/main.ts +0 -18
- package/skeletons/custom-code-skeleton/tsconfig.json +0 -16
- package/skeletons/et-utils-package-skeleton/.nvmrc +0 -1
- package/skeletons/et-utils-package-skeleton/README.md +0 -12
- package/skeletons/et-utils-package-skeleton/jest.config.ts +0 -17
- package/skeletons/et-utils-package-skeleton/package-lock.json +0 -3969
- package/skeletons/et-utils-package-skeleton/package.json +0 -40
- package/skeletons/et-utils-package-skeleton/scripts/package-fixup.sh +0 -13
- package/skeletons/et-utils-package-skeleton/src/Service.ts +0 -8
- package/skeletons/et-utils-package-skeleton/src/index.ts +0 -4
- package/skeletons/et-utils-package-skeleton/test/Service.spec.ts +0 -10
- package/skeletons/et-utils-package-skeleton/test/tsconfig.json +0 -8
- package/skeletons/et-utils-package-skeleton/tsconfig-base.json +0 -10
- package/skeletons/et-utils-package-skeleton/tsconfig-cjs.json +0 -8
- package/skeletons/et-utils-package-skeleton/tsconfig.json +0 -8
- package/skeletons/server-skeleton/.nvmrc +0 -1
- package/skeletons/server-skeleton/Dockerfile +0 -19
- package/skeletons/server-skeleton/auth/routes.js +0 -85
- package/skeletons/server-skeleton/auth/strategyOptions.js +0 -28
- package/skeletons/server-skeleton/config/base.js +0 -45
- package/skeletons/server-skeleton/config/db.js +0 -6
- package/skeletons/server-skeleton/config/editor.js +0 -105
- package/skeletons/server-skeleton/config/rendering-info.js +0 -70
- package/skeletons/server-skeleton/config/screenshot.js +0 -80
- package/skeletons/server-skeleton/config/targets.js +0 -31
- package/skeletons/server-skeleton/config/tools.js +0 -65
- package/skeletons/server-skeleton/files/favicon.png +0 -0
- package/skeletons/server-skeleton/files/system.js +0 -3612
- package/skeletons/server-skeleton/index.js +0 -106
- package/skeletons/server-skeleton/package-lock.json +0 -1825
- package/skeletons/server-skeleton/package.json +0 -29
- package/skeletons/tool-skeleton/.dockerignore +0 -1
- package/skeletons/tool-skeleton/.nvmrc +0 -1
- package/skeletons/tool-skeleton/.travis.yml +0 -26
- package/skeletons/tool-skeleton/.vscode/settings.json +0 -5
- package/skeletons/tool-skeleton/Dockerfile +0 -19
- package/skeletons/tool-skeleton/LICENSE +0 -20
- package/skeletons/tool-skeleton/README.md +0 -104
- package/skeletons/tool-skeleton/index.js +0 -32
- package/skeletons/tool-skeleton/package-lock.json +0 -10108
- package/skeletons/tool-skeleton/package.json +0 -45
- package/skeletons/tool-skeleton/resources/display-options-schema.json +0 -11
- package/skeletons/tool-skeleton/resources/fixtures/data/basic.json +0 -4
- package/skeletons/tool-skeleton/resources/locales/de/translation.json +0 -1
- package/skeletons/tool-skeleton/resources/locales/en/translation.json +0 -1
- package/skeletons/tool-skeleton/resources/locales/fr/translation.json +0 -1
- package/skeletons/tool-skeleton/resources/schema.json +0 -16
- package/skeletons/tool-skeleton/rollup.config.js +0 -75
- package/skeletons/tool-skeleton/routes/fixtures/data.js +0 -15
- package/skeletons/tool-skeleton/routes/health.js +0 -10
- package/skeletons/tool-skeleton/routes/locales.js +0 -21
- package/skeletons/tool-skeleton/routes/rendering-info/web.js +0 -97
- package/skeletons/tool-skeleton/routes/routes.js +0 -8
- package/skeletons/tool-skeleton/routes/schema.js +0 -19
- package/skeletons/tool-skeleton/routes/script.js +0 -17
- package/skeletons/tool-skeleton/routes/stylesheet.js +0 -17
- package/skeletons/tool-skeleton/sass.config.js +0 -66
- package/skeletons/tool-skeleton/scripts_src/default.js +0 -3
- package/skeletons/tool-skeleton/styles_src/_variables.scss +0 -1
- package/skeletons/tool-skeleton/styles_src/main.scss +0 -2
- package/skeletons/tool-skeleton/test/e2e-tests.js +0 -162
- package/skeletons/tool-skeleton/views/dynamic/YourTool.scss +0 -5
- package/skeletons/tool-skeleton/views/dynamic/YourTool.svelte +0 -19
- package/skeletons/tool-skeleton/views/static/App.scss +0 -5
- package/skeletons/tool-skeleton/views/static/App.svelte +0 -21
- package/skeletons/tool-skeleton/views/static/components/Footer.svelte +0 -31
- package/skeletons/tool-skeleton/views/static/components/Header.svelte +0 -7
- package/skeletons/toolv2-skeleton/.husky/pre-commit +0 -6
- package/skeletons/toolv2-skeleton/.nvmrc +0 -1
- package/skeletons/toolv2-skeleton/.prettierrc.cjs +0 -15
- package/skeletons/toolv2-skeleton/.travis.yml +0 -30
- package/skeletons/toolv2-skeleton/.vscode/settings.json +0 -6
- package/skeletons/toolv2-skeleton/Dockerfile +0 -19
- package/skeletons/toolv2-skeleton/LICENSE +0 -21
- package/skeletons/toolv2-skeleton/README.md +0 -99
- package/skeletons/toolv2-skeleton/dev.js +0 -7
- package/skeletons/toolv2-skeleton/index.js +0 -39
- package/skeletons/toolv2-skeleton/jest.config.ts +0 -39
- package/skeletons/toolv2-skeleton/nodemon.json +0 -4
- package/skeletons/toolv2-skeleton/package-lock.json +0 -21382
- package/skeletons/toolv2-skeleton/package.json +0 -80
- package/skeletons/toolv2-skeleton/resources/display-options-schema.json +0 -11
- package/skeletons/toolv2-skeleton/resources/locales/de/translation.json +0 -8
- package/skeletons/toolv2-skeleton/resources/locales/en/translation.json +0 -10
- package/skeletons/toolv2-skeleton/resources/locales/fr/translation.json +0 -10
- package/skeletons/toolv2-skeleton/resources/schema.json +0 -66
- package/skeletons/toolv2-skeleton/rollup.config.js +0 -48
- package/skeletons/toolv2-skeleton/scripts/postinstall.sh +0 -5
- package/skeletons/toolv2-skeleton/src/.eslintrc.cjs +0 -52
- package/skeletons/toolv2-skeleton/src/components/Main.spec.ts +0 -15
- package/skeletons/toolv2-skeleton/src/components/Main.svelte +0 -32
- package/skeletons/toolv2-skeleton/src/enums.ts +0 -11
- package/skeletons/toolv2-skeleton/src/helpers/fixture-generators.ts +0 -38
- package/skeletons/toolv2-skeleton/src/helpers/toolRuntimeConfig.ts +0 -15
- package/skeletons/toolv2-skeleton/src/interfaces.ts +0 -82
- package/skeletons/toolv2-skeleton/src/modules.d.ts +0 -8
- package/skeletons/toolv2-skeleton/src/routes/dynamic-schemas/exampleDynamicSchema.ts +0 -49
- package/skeletons/toolv2-skeleton/src/routes/dynamic-schemas/index.ts +0 -5
- package/skeletons/toolv2-skeleton/src/routes/health.ts +0 -14
- package/skeletons/toolv2-skeleton/src/routes/locales.ts +0 -31
- package/skeletons/toolv2-skeleton/src/routes/notifications/exampleNotification.ts +0 -46
- package/skeletons/toolv2-skeleton/src/routes/option-availability.ts +0 -27
- package/skeletons/toolv2-skeleton/src/routes/rendering-info/web.ts +0 -150
- package/skeletons/toolv2-skeleton/src/routes/routes.ts +0 -21
- package/skeletons/toolv2-skeleton/src/routes/schema.ts +0 -21
- package/skeletons/toolv2-skeleton/src/routes/stylesheet.ts +0 -31
- package/skeletons/toolv2-skeleton/src/styles/main.scss +0 -6
- package/skeletons/toolv2-skeleton/svelte.config.cjs +0 -6
- package/skeletons/toolv2-skeleton/tasks/compileStyleFiles.cjs +0 -101
- package/skeletons/toolv2-skeleton/tests/e2e-tests.spec.ts +0 -158
- package/skeletons/toolv2-skeleton/tests/helpers.ts +0 -21
- package/skeletons/toolv2-skeleton/tsconfig.json +0 -48
- /package/{bin/commands/qItem/updateItem → dist/assets}/updateSchema.json +0 -0
@@ -1,45 +0,0 @@
|
|
1
|
-
{
|
2
|
-
"name": "tool-skeleton",
|
3
|
-
"version": "1.0.0",
|
4
|
-
"description": "",
|
5
|
-
"main": "index.js",
|
6
|
-
"scripts": {
|
7
|
-
"build": "rollup -c",
|
8
|
-
"autobuild": "rollup -c -w",
|
9
|
-
"dev": "run-p autobuild start",
|
10
|
-
"start": "nodemon index.js",
|
11
|
-
"test": "lab -a @hapi/code -c -P tests --verbose --leaks"
|
12
|
-
},
|
13
|
-
"author": "",
|
14
|
-
"license": "MIT",
|
15
|
-
"repository": {
|
16
|
-
"type": "git",
|
17
|
-
"url": "https://github.com/github/tool-skeleton.git"
|
18
|
-
},
|
19
|
-
"dependencies": {
|
20
|
-
"@hapi/boom": "^9.1.4",
|
21
|
-
"@hapi/hapi": "^20.2.0",
|
22
|
-
"@hapi/inert": "^6.0.4",
|
23
|
-
"ajv": "^8.6.3",
|
24
|
-
"joi": "^17.4.2",
|
25
|
-
"svelte": "^3.44.2"
|
26
|
-
},
|
27
|
-
"devDependencies": {
|
28
|
-
"@hapi/code": "^8.0.3",
|
29
|
-
"@hapi/lab": "^24.3.2",
|
30
|
-
"@rollup/plugin-commonjs": "^21.0.0",
|
31
|
-
"@rollup/plugin-node-resolve": "^13.0.5",
|
32
|
-
"autoprefixer": "^10.4.0",
|
33
|
-
"cssnano": "^5.0.10",
|
34
|
-
"glob": "^7.1.7",
|
35
|
-
"nodemon": "^2.0.13",
|
36
|
-
"npm-run-all": "^4.1.5",
|
37
|
-
"postcss": "^8.3.11",
|
38
|
-
"rollup": "^2.60.0",
|
39
|
-
"rollup-plugin-livereload": "^2.0.5",
|
40
|
-
"rollup-plugin-scss": "^3.0.0",
|
41
|
-
"rollup-plugin-svelte": "^7.1.0",
|
42
|
-
"rollup-plugin-terser": "^7.0.2",
|
43
|
-
"sass": "^1.43.4"
|
44
|
-
}
|
45
|
-
}
|
@@ -1 +0,0 @@
|
|
1
|
-
{}
|
@@ -1 +0,0 @@
|
|
1
|
-
{}
|
@@ -1 +0,0 @@
|
|
1
|
-
{}
|
@@ -1,16 +0,0 @@
|
|
1
|
-
{
|
2
|
-
"$schema": "http://json-schema.org/draft-07/schema#",
|
3
|
-
"type": "object",
|
4
|
-
"title": "tool-skeleton",
|
5
|
-
"properties": {
|
6
|
-
"title": {
|
7
|
-
"title": "Titel",
|
8
|
-
"type": "string"
|
9
|
-
},
|
10
|
-
"subtitle": {
|
11
|
-
"title": "Untertitel",
|
12
|
-
"type": "string"
|
13
|
-
}
|
14
|
-
},
|
15
|
-
"required": ["title"]
|
16
|
-
}
|
@@ -1,75 +0,0 @@
|
|
1
|
-
import * as fs from "fs";
|
2
|
-
import * as path from "path";
|
3
|
-
import * as crypto from "crypto";
|
4
|
-
import nodeResolve from "@rollup/plugin-node-resolve";
|
5
|
-
import commonjs from "@rollup/plugin-commonjs";
|
6
|
-
import svelte from "rollup-plugin-svelte";
|
7
|
-
import { terser } from "rollup-plugin-terser";
|
8
|
-
import livereload from "rollup-plugin-livereload";
|
9
|
-
import scss from "rollup-plugin-scss";
|
10
|
-
const sassConfig = require("./sass.config");
|
11
|
-
|
12
|
-
const production = !process.env.ROLLUP_WATCH;
|
13
|
-
const scriptsDir = path.join(__dirname, "/scripts_src/");
|
14
|
-
const filename = "default";
|
15
|
-
const scriptDirDefaultFileName = path.join(scriptsDir, `/${filename}.js`);
|
16
|
-
|
17
|
-
function writeHashmap(hashmapPath, file, fileext) {
|
18
|
-
const hash = crypto.createHash("md5");
|
19
|
-
hash.update(file.content, { encoding: "utf8" });
|
20
|
-
file.hash = hash.digest("hex");
|
21
|
-
|
22
|
-
const hashMap = {};
|
23
|
-
hashMap[file.name] = `${file.name}.${file.hash.substring(0, 8)}.${fileext}`;
|
24
|
-
fs.writeFileSync(hashmapPath, JSON.stringify(hashMap));
|
25
|
-
}
|
26
|
-
|
27
|
-
function generateHashmap() {
|
28
|
-
return {
|
29
|
-
name: "generateHashmap",
|
30
|
-
async generateBundle(outputOptions, bundle, isWrite) {
|
31
|
-
const scriptsDir = "scripts";
|
32
|
-
// Create directory if not yet exist or recreate directory if it already exists
|
33
|
-
if (!fs.existsSync(scriptsDir)) {
|
34
|
-
fs.mkdirSync(scriptsDir);
|
35
|
-
} else {
|
36
|
-
fs.rmdirSync(scriptsDir, { recursive: true });
|
37
|
-
fs.mkdirSync(scriptsDir);
|
38
|
-
}
|
39
|
-
writeHashmap(
|
40
|
-
"scripts/hashMap.json",
|
41
|
-
{
|
42
|
-
name: filename,
|
43
|
-
content: bundle[`${filename}.js`].code,
|
44
|
-
},
|
45
|
-
"js"
|
46
|
-
);
|
47
|
-
},
|
48
|
-
};
|
49
|
-
}
|
50
|
-
|
51
|
-
export default {
|
52
|
-
input: scriptDirDefaultFileName,
|
53
|
-
output: {
|
54
|
-
format: "iife",
|
55
|
-
// TODO: Rename 'window._q_your_tool.YourTool' to 'window._q_<tool-name>.<ToolName>'
|
56
|
-
name: "window._q_your_tool.YourTool",
|
57
|
-
file: `scripts/${filename}.js`,
|
58
|
-
},
|
59
|
-
plugins: [
|
60
|
-
svelte(),
|
61
|
-
scss({ ...sassConfig.get(production, writeHashmap) }),
|
62
|
-
nodeResolve({ browser: true }),
|
63
|
-
commonjs(),
|
64
|
-
!production && livereload({ watch: ["scripts"], delay: 800 }),
|
65
|
-
production && terser(),
|
66
|
-
generateHashmap(),
|
67
|
-
],
|
68
|
-
watch: {
|
69
|
-
clearScreen: false,
|
70
|
-
},
|
71
|
-
onwarn: function (warning, warn) {
|
72
|
-
if (warning.code === "CIRCULAR_DEPENDENCY") return;
|
73
|
-
warn(warning);
|
74
|
-
},
|
75
|
-
};
|
@@ -1,15 +0,0 @@
|
|
1
|
-
const fixtureDataDirectory = "../../resources/fixtures/data";
|
2
|
-
|
3
|
-
// provide every fixture data file present in ../../resources/fixtures/data
|
4
|
-
const fixtureData = [require(`${fixtureDataDirectory}/basic.json`)];
|
5
|
-
|
6
|
-
module.exports = {
|
7
|
-
path: "/fixtures/data",
|
8
|
-
method: "GET",
|
9
|
-
options: {
|
10
|
-
tags: ["api"],
|
11
|
-
},
|
12
|
-
handler: (request, h) => {
|
13
|
-
return fixtureData;
|
14
|
-
},
|
15
|
-
};
|
@@ -1,21 +0,0 @@
|
|
1
|
-
const Joi = require("joi");
|
2
|
-
const localesDir = __dirname + "/../resources/locales/";
|
3
|
-
|
4
|
-
module.exports = {
|
5
|
-
path: "/locales/{lng}/translation.json",
|
6
|
-
method: "GET",
|
7
|
-
options: {
|
8
|
-
description: "Returns translations for given language",
|
9
|
-
tags: ["api"],
|
10
|
-
validate: {
|
11
|
-
params: {
|
12
|
-
lng: Joi.string().required(),
|
13
|
-
},
|
14
|
-
},
|
15
|
-
},
|
16
|
-
handler: (request, h) => {
|
17
|
-
return h
|
18
|
-
.file(localesDir + request.params.lng + "/translation.json")
|
19
|
-
.type("application/json");
|
20
|
-
},
|
21
|
-
};
|
@@ -1,97 +0,0 @@
|
|
1
|
-
const Boom = require("@hapi/boom");
|
2
|
-
const fs = require("fs");
|
3
|
-
const path = require("path");
|
4
|
-
const Ajv = require("ajv");
|
5
|
-
|
6
|
-
const staticViewsDir = path.join(__dirname, "/../../views/static/");
|
7
|
-
const stylesDir = path.join(__dirname, "/../../styles/");
|
8
|
-
const scriptsDir = path.join(__dirname, "../../scripts/");
|
9
|
-
|
10
|
-
require("svelte/register");
|
11
|
-
const staticTemplate = require(path.join(
|
12
|
-
staticViewsDir,
|
13
|
-
"/App.svelte"
|
14
|
-
)).default;
|
15
|
-
const styles = fs.readFileSync(path.join(stylesDir, "/default.css")).toString();
|
16
|
-
const styleHashMap = require(path.join(stylesDir, "hashMap.json"));
|
17
|
-
const scriptHashMap = require(path.join(scriptsDir, "hashMap.json"));
|
18
|
-
|
19
|
-
// POSTed item will be validated against given schema
|
20
|
-
// hence we fetch the JSON schema...
|
21
|
-
const schemaString = JSON.parse(
|
22
|
-
fs.readFileSync(path.join(__dirname, "../../resources/", "schema.json"), {
|
23
|
-
encoding: "utf-8",
|
24
|
-
})
|
25
|
-
);
|
26
|
-
|
27
|
-
const ajv = new Ajv({ strict: false });
|
28
|
-
const validate = ajv.compile(schemaString);
|
29
|
-
|
30
|
-
function validateAgainstSchema(item, options) {
|
31
|
-
if (validate(item)) {
|
32
|
-
return item;
|
33
|
-
} else {
|
34
|
-
throw Boom.badRequest(JSON.stringify(validate.errors));
|
35
|
-
}
|
36
|
-
}
|
37
|
-
|
38
|
-
async function validatePayload(payload, options, next) {
|
39
|
-
if (typeof payload !== "object") {
|
40
|
-
return next(Boom.badRequest(), payload);
|
41
|
-
}
|
42
|
-
if (typeof payload.item !== "object") {
|
43
|
-
return next(Boom.badRequest(), payload);
|
44
|
-
}
|
45
|
-
if (typeof payload.toolRuntimeConfig !== "object") {
|
46
|
-
return next(Boom.badRequest(), payload);
|
47
|
-
}
|
48
|
-
await validateAgainstSchema(payload.item, options);
|
49
|
-
}
|
50
|
-
|
51
|
-
module.exports = {
|
52
|
-
method: "POST",
|
53
|
-
path: "/rendering-info/web",
|
54
|
-
options: {
|
55
|
-
validate: {
|
56
|
-
options: {
|
57
|
-
allowUnknown: true,
|
58
|
-
},
|
59
|
-
payload: validatePayload,
|
60
|
-
},
|
61
|
-
},
|
62
|
-
handler: async function (request, h) {
|
63
|
-
const toolRuntimeConfig = request.payload.toolRuntimeConfig;
|
64
|
-
const context = {
|
65
|
-
// TODO: Rename 'q_your_tool_' to 'q_<tool_name>_'
|
66
|
-
id: `q_your_tool_${toolRuntimeConfig.requestId}`,
|
67
|
-
displayOptions: toolRuntimeConfig.displayOptions || {},
|
68
|
-
item: request.payload.item,
|
69
|
-
};
|
70
|
-
|
71
|
-
const staticTemplateRender = staticTemplate.render(context);
|
72
|
-
|
73
|
-
const renderingInfo = {
|
74
|
-
polyfills: ["Promise"],
|
75
|
-
stylesheets: [{ content: styles }, { name: styleHashMap["default"] }],
|
76
|
-
scripts: [
|
77
|
-
{ name: scriptHashMap["default"] },
|
78
|
-
// TODO: Rename 'new window._q_your_tool.YourTool' to 'new window._q_<tool-name>.<ToolName>'
|
79
|
-
{
|
80
|
-
content: `
|
81
|
-
(function () {
|
82
|
-
var target = document.querySelector('#${context.id}_container');
|
83
|
-
target.innerHTML = "";
|
84
|
-
var props = ${JSON.stringify(context)};
|
85
|
-
new window._q_your_tool.YourTool({
|
86
|
-
"target": target,
|
87
|
-
"props": props
|
88
|
-
})
|
89
|
-
})();`,
|
90
|
-
},
|
91
|
-
],
|
92
|
-
markup: staticTemplateRender.html,
|
93
|
-
};
|
94
|
-
|
95
|
-
return renderingInfo;
|
96
|
-
},
|
97
|
-
};
|
@@ -1,19 +0,0 @@
|
|
1
|
-
const path = require("path");
|
2
|
-
const resourcesDir = path.join(__dirname, "/../resources/");
|
3
|
-
|
4
|
-
module.exports = [
|
5
|
-
{
|
6
|
-
method: "GET",
|
7
|
-
path: "/schema.json",
|
8
|
-
handler: function(request, h) {
|
9
|
-
return h.file(path.join(resourcesDir, "schema.json"));
|
10
|
-
}
|
11
|
-
},
|
12
|
-
{
|
13
|
-
method: "GET",
|
14
|
-
path: "/display-options-schema.json",
|
15
|
-
handler: function(request, h) {
|
16
|
-
return h.file(path.join(resourcesDir, "display-options-schema.json"));
|
17
|
-
}
|
18
|
-
}
|
19
|
-
];
|
@@ -1,17 +0,0 @@
|
|
1
|
-
const path = require("path");
|
2
|
-
|
3
|
-
module.exports = {
|
4
|
-
method: "GET",
|
5
|
-
path: "/script/{filename}.{hash}.{extension}",
|
6
|
-
options: {
|
7
|
-
files: {
|
8
|
-
relativeTo: path.join(__dirname, "/../scripts/"),
|
9
|
-
},
|
10
|
-
},
|
11
|
-
handler: function (request, h) {
|
12
|
-
return h
|
13
|
-
.file(`${request.params.filename}.${request.params.extension}`)
|
14
|
-
.type("text/javascript")
|
15
|
-
.header("cache-control", `max-age=${60 * 60 * 24 * 365}, immutable`); // 1 year
|
16
|
-
},
|
17
|
-
};
|
@@ -1,17 +0,0 @@
|
|
1
|
-
const path = require("path");
|
2
|
-
|
3
|
-
module.exports = {
|
4
|
-
method: "GET",
|
5
|
-
path: "/stylesheet/{filename}.{hash}.{extension}",
|
6
|
-
options: {
|
7
|
-
files: {
|
8
|
-
relativeTo: path.join(__dirname, "/../styles/"),
|
9
|
-
},
|
10
|
-
},
|
11
|
-
handler: function (request, h) {
|
12
|
-
return h
|
13
|
-
.file(`${request.params.filename}.${request.params.extension}`)
|
14
|
-
.type("text/css")
|
15
|
-
.header("cache-control", `max-age=${60 * 60 * 24 * 365}, immutable`); // 1 year
|
16
|
-
},
|
17
|
-
};
|
@@ -1,66 +0,0 @@
|
|
1
|
-
const fs = require("fs");
|
2
|
-
const path = require("path");
|
3
|
-
const postcss = require("postcss");
|
4
|
-
const autoprefixer = require("autoprefixer");
|
5
|
-
const cssnano = require("cssnano");
|
6
|
-
|
7
|
-
function createOutputCssFunction(writeHashmapFunction) {
|
8
|
-
const outputCssFunction = (styles, styleNodes) => {
|
9
|
-
const stylesDir = "styles";
|
10
|
-
|
11
|
-
if (!fs.existsSync(stylesDir)) {
|
12
|
-
fs.mkdirSync(stylesDir);
|
13
|
-
}
|
14
|
-
|
15
|
-
fs.writeFileSync(`styles/default.css`, styles);
|
16
|
-
writeHashmapFunction(
|
17
|
-
"styles/hashMap.json",
|
18
|
-
{
|
19
|
-
name: "default",
|
20
|
-
content: styles,
|
21
|
-
},
|
22
|
-
"css"
|
23
|
-
);
|
24
|
-
};
|
25
|
-
|
26
|
-
return outputCssFunction;
|
27
|
-
}
|
28
|
-
|
29
|
-
function getPostcssPlugins(isProduction) {
|
30
|
-
const postcssPlugins = [autoprefixer];
|
31
|
-
|
32
|
-
if (isProduction) {
|
33
|
-
postcssPlugins.push(cssnano);
|
34
|
-
}
|
35
|
-
|
36
|
-
return postcssPlugins;
|
37
|
-
}
|
38
|
-
|
39
|
-
function get(isProduction, writeHashmapFunction) {
|
40
|
-
const config = {
|
41
|
-
outputStyle: isProduction ? "compressed" : "expanded",
|
42
|
-
// Sourcemap generation (specifically writing the file to system) is currently not supported by rollup-plugin-sass (but soon!)
|
43
|
-
// See: https://github.com/thgh/rollup-plugin-scss/issues/7
|
44
|
-
// outFile: path.join(__dirname, "/styles/default.css"), // <- Uncomment after: https://github.com/thgh/rollup-plugin-scss/issues/7
|
45
|
-
sourceMap: !isProduction,
|
46
|
-
sourceMapEmbed: !isProduction, // Remove after: https://github.com/thgh/rollup-plugin-scss/issues/7
|
47
|
-
failOnError: !isProduction,
|
48
|
-
watch: [
|
49
|
-
path.join(__dirname, "/styles_src"),
|
50
|
-
path.join(__dirname, "/views"),
|
51
|
-
],
|
52
|
-
processor: (css) =>
|
53
|
-
postcss(getPostcssPlugins(isProduction))
|
54
|
-
.process(css, {
|
55
|
-
from: path.join(__dirname, "/styles/default.css"),
|
56
|
-
to: path.join(__dirname, "/styles/default.css"),
|
57
|
-
map: isProduction ? false : { inline: true }, // Set to false after: https://github.com/thgh/rollup-plugin-scss/issues/7
|
58
|
-
})
|
59
|
-
.then((result) => result.css),
|
60
|
-
output: createOutputCssFunction(writeHashmapFunction),
|
61
|
-
};
|
62
|
-
|
63
|
-
return config;
|
64
|
-
}
|
65
|
-
|
66
|
-
module.exports = { get };
|
@@ -1 +0,0 @@
|
|
1
|
-
$color: salmon;
|
@@ -1,162 +0,0 @@
|
|
1
|
-
const fs = require("fs");
|
2
|
-
const Lab = require("@hapi/lab");
|
3
|
-
const Code = require("@hapi/code");
|
4
|
-
const Hapi = require("@hapi/hapi");
|
5
|
-
const Joi = require("joi");
|
6
|
-
const lab = (exports.lab = Lab.script());
|
7
|
-
|
8
|
-
const glob = require("glob");
|
9
|
-
|
10
|
-
const expect = Code.expect;
|
11
|
-
const before = lab.before;
|
12
|
-
const after = lab.after;
|
13
|
-
const it = lab.it;
|
14
|
-
|
15
|
-
const routes = require("../routes/routes.js");
|
16
|
-
|
17
|
-
let server;
|
18
|
-
|
19
|
-
before(async () => {
|
20
|
-
try {
|
21
|
-
server = Hapi.server({
|
22
|
-
port: process.env.PORT || 3000,
|
23
|
-
routes: {},
|
24
|
-
});
|
25
|
-
server.validator(Joi);
|
26
|
-
await server.register(require("@hapi/inert"));
|
27
|
-
server.route(routes);
|
28
|
-
} catch (err) {
|
29
|
-
expect(err).to.not.exist();
|
30
|
-
}
|
31
|
-
});
|
32
|
-
|
33
|
-
after(async () => {
|
34
|
-
await server.stop({ timeout: 2000 });
|
35
|
-
server = null;
|
36
|
-
});
|
37
|
-
|
38
|
-
lab.experiment("basics", () => {
|
39
|
-
it("starts the server", () => {
|
40
|
-
expect(server.info.created).to.be.a.number();
|
41
|
-
});
|
42
|
-
|
43
|
-
it("is healthy", async () => {
|
44
|
-
const response = await server.inject("/health");
|
45
|
-
expect(response.payload).to.equal("ok");
|
46
|
-
});
|
47
|
-
});
|
48
|
-
|
49
|
-
lab.experiment("schema endpoint", () => {
|
50
|
-
it("returns 200 for /schema.json", async () => {
|
51
|
-
const response = await server.inject("/schema.json");
|
52
|
-
expect(response.statusCode).to.be.equal(200);
|
53
|
-
});
|
54
|
-
});
|
55
|
-
|
56
|
-
lab.experiment("locales endpoint", () => {
|
57
|
-
it("returns 200 for en translations", async () => {
|
58
|
-
const request = {
|
59
|
-
method: "GET",
|
60
|
-
url: "/locales/en/translation.json",
|
61
|
-
};
|
62
|
-
const response = await server.inject(request);
|
63
|
-
expect(response.statusCode).to.be.equal(200);
|
64
|
-
});
|
65
|
-
it("returns 200 for fr translations", async () => {
|
66
|
-
const request = {
|
67
|
-
method: "GET",
|
68
|
-
url: "/locales/fr/translation.json",
|
69
|
-
};
|
70
|
-
const response = await server.inject(request);
|
71
|
-
expect(response.statusCode).to.be.equal(200);
|
72
|
-
});
|
73
|
-
it("returns 200 for de translations", async () => {
|
74
|
-
const request = {
|
75
|
-
method: "GET",
|
76
|
-
url: "/locales/de/translation.json",
|
77
|
-
};
|
78
|
-
const response = await server.inject(request);
|
79
|
-
expect(response.statusCode).to.be.equal(200);
|
80
|
-
});
|
81
|
-
});
|
82
|
-
|
83
|
-
lab.experiment("stylesheets endpoint", () => {
|
84
|
-
it(
|
85
|
-
"returns existing stylesheet with right cache control header",
|
86
|
-
{ plan: 2 },
|
87
|
-
async () => {
|
88
|
-
const filename = require("../styles/hashMap.json").default;
|
89
|
-
const response = await server.inject(`/stylesheet/${filename}`);
|
90
|
-
expect(response.statusCode).to.be.equal(200);
|
91
|
-
expect(response.headers["cache-control"]).to.be.equal(
|
92
|
-
"max-age=31536000, immutable"
|
93
|
-
);
|
94
|
-
}
|
95
|
-
);
|
96
|
-
|
97
|
-
it("returns Not Found when requesting an inexisting stylesheet", async () => {
|
98
|
-
const response = await server.inject("/stylesheet/inexisting.123.css");
|
99
|
-
expect(response.statusCode).to.be.equal(404);
|
100
|
-
});
|
101
|
-
});
|
102
|
-
|
103
|
-
// all the fixtures render
|
104
|
-
lab.experiment("all fixtures render", () => {
|
105
|
-
const fixtureFiles = glob.sync(
|
106
|
-
`${__dirname}/../resources/fixtures/data/*.json`
|
107
|
-
);
|
108
|
-
for (let fixtureFile of fixtureFiles) {
|
109
|
-
const fixture = require(fixtureFile);
|
110
|
-
it(`doesnt fail in rendering fixture ${fixture.title}`, async () => {
|
111
|
-
const request = {
|
112
|
-
method: "POST",
|
113
|
-
url: "/rendering-info/web",
|
114
|
-
payload: {
|
115
|
-
item: fixture,
|
116
|
-
toolRuntimeConfig: {},
|
117
|
-
},
|
118
|
-
};
|
119
|
-
const response = await server.inject(request);
|
120
|
-
expect(response.statusCode).to.be.equal(200);
|
121
|
-
});
|
122
|
-
}
|
123
|
-
});
|
124
|
-
|
125
|
-
lab.experiment("rendering-info", () => {
|
126
|
-
it("web: returns error 400 if invalid item is given", async () => {
|
127
|
-
const request = {
|
128
|
-
method: "POST",
|
129
|
-
url: "/rendering-info/web",
|
130
|
-
payload: {
|
131
|
-
item: {
|
132
|
-
some: "object",
|
133
|
-
that: "doesn't validate against the schema",
|
134
|
-
},
|
135
|
-
toolRuntimeConfig: {},
|
136
|
-
},
|
137
|
-
};
|
138
|
-
const response = await server.inject(request);
|
139
|
-
expect(response.statusCode).to.be.equal(400);
|
140
|
-
});
|
141
|
-
});
|
142
|
-
|
143
|
-
lab.experiment("assets", () => {
|
144
|
-
it("returns stylesheet", async () => {
|
145
|
-
const fixture = fs.readFileSync(
|
146
|
-
`${__dirname}/../resources/fixtures/data/basic.json`,
|
147
|
-
{ encoding: "utf-8" }
|
148
|
-
);
|
149
|
-
const res = await server.inject({
|
150
|
-
url: "/rendering-info/web",
|
151
|
-
method: "POST",
|
152
|
-
payload: {
|
153
|
-
item: JSON.parse(fixture),
|
154
|
-
toolRuntimeConfig: {},
|
155
|
-
},
|
156
|
-
});
|
157
|
-
const stylesheetRes = await server.inject(
|
158
|
-
`/stylesheet/${res.result.stylesheets[1].name}`
|
159
|
-
);
|
160
|
-
expect(stylesheetRes.statusCode).to.be.equal(200);
|
161
|
-
});
|
162
|
-
});
|
@@ -1,19 +0,0 @@
|
|
1
|
-
<script>
|
2
|
-
// TODO: Rename 'YourTool.svelte' to '<Tool-Name>.svelte' & change all references
|
3
|
-
let isWorkingLabel = "";
|
4
|
-
let i = 0;
|
5
|
-
|
6
|
-
function worksOnClick() {
|
7
|
-
i++;
|
8
|
-
isWorkingLabel = i < 5 ? "is working!" : "is still working!";
|
9
|
-
}
|
10
|
-
</script>
|
11
|
-
|
12
|
-
<!-- Client side code is written/imported inside this component (e.g. Client interaction components) -->
|
13
|
-
<div class="s-font-title">
|
14
|
-
Client-Side code
|
15
|
-
<span class="your-tool__is-working-label">{isWorkingLabel}</span>
|
16
|
-
</div>
|
17
|
-
<button class="s-button s-button--small" on:click={worksOnClick}>
|
18
|
-
Click me!
|
19
|
-
</button>
|
@@ -1,21 +0,0 @@
|
|
1
|
-
<script>
|
2
|
-
import Header from "./components/Header.svelte";
|
3
|
-
import Footer from "./components/Footer.svelte";
|
4
|
-
|
5
|
-
export let item;
|
6
|
-
export let id;
|
7
|
-
export let displayOptions;
|
8
|
-
</script>
|
9
|
-
|
10
|
-
<!-- Static code is written/imported inside 'q-item-container' (e.g. Header, Title components) -->
|
11
|
-
<div class="q-item-container">
|
12
|
-
{#if !displayOptions.hideTitle}
|
13
|
-
<Header title={item.title} />
|
14
|
-
{#if item.subtitle}
|
15
|
-
<div class="s-q-item__subtitle s-font-note">{item.subtitle}</div>
|
16
|
-
{/if}
|
17
|
-
{/if}
|
18
|
-
<!-- TODO: Rename 'q-your-tool-container' to 'q-<tool-name>-container' & change all references -->
|
19
|
-
<div id="{id}_container" class="q-your-tool-container" />
|
20
|
-
<Footer notes={item.notes} sources={item.sources} acronym={item.acronym} />
|
21
|
-
</div>
|