@nzz/q-cli 1.10.3 → 2.0.0-beta.10
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/README.md +22 -313
- package/dist/createCustomCodeItem.js +70 -0
- package/dist/enums.js +6 -0
- package/dist/index.js +80 -0
- package/dist/interfaces.js +1 -0
- package/dist/newCustomCode.js +107 -0
- package/dist/updateItem.js +140 -0
- package/dist/utils.js +88 -0
- package/package.json +29 -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/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,148 +0,0 @@
|
|
1
|
-
const fetch = require("node-fetch");
|
2
|
-
const FormData = require("form-data");
|
3
|
-
const fs = require("fs");
|
4
|
-
const util = require("util");
|
5
|
-
const stat = util.promisify(fs.stat);
|
6
|
-
const Mimos = require("@hapi/mimos");
|
7
|
-
const mimos = new Mimos({
|
8
|
-
override: {
|
9
|
-
"application/javascript": {
|
10
|
-
source: "iana",
|
11
|
-
charset: "UTF-8",
|
12
|
-
compressible: true,
|
13
|
-
extensions: ["js", "javascript"],
|
14
|
-
type: "text/javascript",
|
15
|
-
},
|
16
|
-
},
|
17
|
-
});
|
18
|
-
const imageSize = require("image-size");
|
19
|
-
const path = require("path");
|
20
|
-
const chalk = require("chalk");
|
21
|
-
const errorColor = chalk.red;
|
22
|
-
|
23
|
-
// Recursively traverses the item object
|
24
|
-
// If a property called "path" is found, the resource is uploaded
|
25
|
-
// and the metadata of that resource is inserted at that place in the item object
|
26
|
-
async function handleResources(
|
27
|
-
qServer,
|
28
|
-
accessToken,
|
29
|
-
cookie,
|
30
|
-
item,
|
31
|
-
defaultItem,
|
32
|
-
qConfigPath,
|
33
|
-
environment
|
34
|
-
) {
|
35
|
-
try {
|
36
|
-
if (item) {
|
37
|
-
for (let key of Object.keys(item)) {
|
38
|
-
if (typeof item[key] === "object") {
|
39
|
-
let defaultItemSubtree;
|
40
|
-
if (defaultItem && Number.isInteger(parseInt(key)) && key > 0) {
|
41
|
-
defaultItemSubtree = defaultItem[0];
|
42
|
-
} else if (defaultItem && defaultItem[key]) {
|
43
|
-
defaultItemSubtree = defaultItem[key];
|
44
|
-
}
|
45
|
-
item[key] = await handleResources(
|
46
|
-
qServer,
|
47
|
-
accessToken,
|
48
|
-
cookie,
|
49
|
-
item[key],
|
50
|
-
defaultItemSubtree,
|
51
|
-
qConfigPath,
|
52
|
-
environment
|
53
|
-
);
|
54
|
-
} else if (key === "path") {
|
55
|
-
const resourcePath = item[key];
|
56
|
-
if (defaultItem) {
|
57
|
-
item = await getResourceMetadata(
|
58
|
-
qServer,
|
59
|
-
accessToken,
|
60
|
-
cookie,
|
61
|
-
resourcePath,
|
62
|
-
defaultItem,
|
63
|
-
qConfigPath,
|
64
|
-
environment
|
65
|
-
);
|
66
|
-
} else {
|
67
|
-
throw new Error(
|
68
|
-
`Error occured while uploading the resource at ${resourcePath}. Please make sure the config structure matches the schema of the tool and try again. `
|
69
|
-
);
|
70
|
-
}
|
71
|
-
}
|
72
|
-
}
|
73
|
-
}
|
74
|
-
return item;
|
75
|
-
} catch (error) {
|
76
|
-
console.error(errorColor(error.message));
|
77
|
-
process.exit(1);
|
78
|
-
}
|
79
|
-
}
|
80
|
-
|
81
|
-
// Uploads the resource and returns the metadata based on the file properties
|
82
|
-
async function getResourceMetadata(
|
83
|
-
qServer,
|
84
|
-
accessToken,
|
85
|
-
cookie,
|
86
|
-
resource,
|
87
|
-
fileProperties,
|
88
|
-
qConfigPath,
|
89
|
-
environment
|
90
|
-
) {
|
91
|
-
const resourcePath = path
|
92
|
-
.resolve(path.dirname(qConfigPath), resource)
|
93
|
-
.replace(/{id}/g, environment.id);
|
94
|
-
resource = await uploadResource(qServer, accessToken, cookie, resourcePath);
|
95
|
-
const statistic = await stat(resourcePath);
|
96
|
-
resource.size = statistic.size;
|
97
|
-
resource.type = mimos.path(resourcePath).type;
|
98
|
-
|
99
|
-
if (fileProperties.name) {
|
100
|
-
resource[fileProperties.name] = path.basename(resourcePath);
|
101
|
-
}
|
102
|
-
if (fileProperties.width && fileProperties.height) {
|
103
|
-
const dimensions = imageSize(resourcePath);
|
104
|
-
resource[fileProperties.width] = dimensions.width;
|
105
|
-
resource[fileProperties.height] = dimensions.height;
|
106
|
-
}
|
107
|
-
|
108
|
-
return resource;
|
109
|
-
}
|
110
|
-
|
111
|
-
async function uploadResource(qServer, accessToken, cookie, resourcePath) {
|
112
|
-
try {
|
113
|
-
if (fs.existsSync(resourcePath)) {
|
114
|
-
const form = new FormData();
|
115
|
-
const stream = fs.createReadStream(resourcePath);
|
116
|
-
form.append("file", stream);
|
117
|
-
const headers = form.getHeaders();
|
118
|
-
headers.Authorization = `Bearer ${accessToken}`;
|
119
|
-
headers.Cookie = cookie;
|
120
|
-
|
121
|
-
const response = await fetch(`${qServer}file`, {
|
122
|
-
method: "POST",
|
123
|
-
headers: headers,
|
124
|
-
body: form,
|
125
|
-
});
|
126
|
-
const body = await response.json();
|
127
|
-
|
128
|
-
if (response.ok) {
|
129
|
-
return body;
|
130
|
-
} else {
|
131
|
-
throw new Error(
|
132
|
-
`Error occured while uploading the resource at ${resourcePath}. Please check your connection and try again.\nResponse: ${body.statusCode} ${body.error} - ${body.message}`
|
133
|
-
);
|
134
|
-
}
|
135
|
-
} else {
|
136
|
-
throw new Error(
|
137
|
-
`Error occured while reading the resource at ${resourcePath}. Please make sure that the resource exists and try again.`
|
138
|
-
);
|
139
|
-
}
|
140
|
-
} catch (error) {
|
141
|
-
console.error(errorColor(error.message));
|
142
|
-
process.exit(1);
|
143
|
-
}
|
144
|
-
}
|
145
|
-
|
146
|
-
module.exports = {
|
147
|
-
handleResources: handleResources,
|
148
|
-
};
|
@@ -1,65 +0,0 @@
|
|
1
|
-
const Ajv = require("ajv");
|
2
|
-
// Remove additional properties which are not defined by the json schema
|
3
|
-
// See https://ajv.js.org/options.html#removeadditional for details
|
4
|
-
const ajv = new Ajv({ schemaId: "auto", removeAdditional: true });
|
5
|
-
ajv.addMetaSchema(require("ajv/lib/refs/json-schema-draft-04.json"));
|
6
|
-
const fetch = require("node-fetch");
|
7
|
-
const chalk = require("chalk");
|
8
|
-
const errorColor = chalk.red;
|
9
|
-
|
10
|
-
async function getToolSchema(qServer, tool) {
|
11
|
-
try {
|
12
|
-
const response = await fetch(`${qServer}tools/${tool}/schema.json`);
|
13
|
-
if (response.ok) {
|
14
|
-
return await response.json();
|
15
|
-
} else {
|
16
|
-
throw new Error(
|
17
|
-
`A problem occured while getting the schema of the ${tool} tool. Please check your connection and try again.`
|
18
|
-
);
|
19
|
-
}
|
20
|
-
} catch (error) {
|
21
|
-
console.error(errorColor(error.message));
|
22
|
-
process.exit(1);
|
23
|
-
}
|
24
|
-
}
|
25
|
-
|
26
|
-
function getSchemaPathFor(commandName) {
|
27
|
-
const pathFor = {
|
28
|
-
createCustomCodeItem: "./createCustomCodeItem/schema.json",
|
29
|
-
copyItem: "./copyItem/copySchema.json",
|
30
|
-
updateItem: "./updateItem/updateSchema.json",
|
31
|
-
};
|
32
|
-
|
33
|
-
if (pathFor[commandName]) {
|
34
|
-
return pathFor[commandName];
|
35
|
-
} else {
|
36
|
-
throw new Error(`Unhandled schema path for commandName: '${commandName}'`);
|
37
|
-
}
|
38
|
-
}
|
39
|
-
|
40
|
-
function validateConfig(config, commandName = "updateItem") {
|
41
|
-
const isValid = ajv.validate(require(getSchemaPathFor(commandName)), config);
|
42
|
-
return {
|
43
|
-
isValid: isValid,
|
44
|
-
errorsText: ajv.errorsText(),
|
45
|
-
};
|
46
|
-
}
|
47
|
-
|
48
|
-
function getNormalizedItem(schema, item, environment) {
|
49
|
-
const isValid = ajv.validate(schema, item);
|
50
|
-
if (!isValid) {
|
51
|
-
throw new Error(
|
52
|
-
`A problem occured while validating item with id ${environment.id} on ${
|
53
|
-
environment.name
|
54
|
-
} environment: ${ajv.errorsText()}`
|
55
|
-
);
|
56
|
-
}
|
57
|
-
|
58
|
-
return item;
|
59
|
-
}
|
60
|
-
|
61
|
-
module.exports = {
|
62
|
-
getToolSchema: getToolSchema,
|
63
|
-
validateConfig: validateConfig,
|
64
|
-
getNormalizedItem: getNormalizedItem,
|
65
|
-
};
|
@@ -1,64 +0,0 @@
|
|
1
|
-
const schemaService = require("./../schemaService.js");
|
2
|
-
const configStore = require("./../configStore.js");
|
3
|
-
const itemService = require("./../itemService.js");
|
4
|
-
const fs = require("fs");
|
5
|
-
const path = require("path");
|
6
|
-
const chalk = require("chalk");
|
7
|
-
const errorColor = chalk.red;
|
8
|
-
const successColor = chalk.green;
|
9
|
-
|
10
|
-
module.exports = async function (command) {
|
11
|
-
try {
|
12
|
-
const qConfigPath = path.resolve(command.config);
|
13
|
-
if (fs.existsSync(qConfigPath)) {
|
14
|
-
const qConfig = JSON.parse(fs.readFileSync(qConfigPath));
|
15
|
-
const validationResult = schemaService.validateConfig(qConfig);
|
16
|
-
|
17
|
-
if (validationResult.isValid) {
|
18
|
-
const config = await configStore.setupStore(
|
19
|
-
qConfig,
|
20
|
-
command.environment,
|
21
|
-
command.reset
|
22
|
-
);
|
23
|
-
|
24
|
-
for (const item of itemService.getItems(qConfig, command.environment)) {
|
25
|
-
for (const environment of item.environments) {
|
26
|
-
const result = await itemService.updateItem(
|
27
|
-
item.item,
|
28
|
-
environment,
|
29
|
-
config,
|
30
|
-
qConfigPath
|
31
|
-
);
|
32
|
-
|
33
|
-
if (result) {
|
34
|
-
console.log(
|
35
|
-
successColor(
|
36
|
-
`Successfully updated item with id ${environment.id} on ${environment.name} environment`
|
37
|
-
)
|
38
|
-
);
|
39
|
-
}
|
40
|
-
}
|
41
|
-
}
|
42
|
-
} else {
|
43
|
-
console.error(
|
44
|
-
errorColor(
|
45
|
-
`A problem occured while validating the config file: ${validationResult.errorsText}`
|
46
|
-
)
|
47
|
-
);
|
48
|
-
process.exit(1);
|
49
|
-
}
|
50
|
-
} else {
|
51
|
-
console.error(
|
52
|
-
errorColor(
|
53
|
-
"Couldn't find config file named q.config.json in the current directory. Create a config file in the current directory or pass the path to the config file with the option -c <path>"
|
54
|
-
)
|
55
|
-
);
|
56
|
-
}
|
57
|
-
} catch (error) {
|
58
|
-
console.error(
|
59
|
-
errorColor(
|
60
|
-
`A problem occured while parsing the config file at ${command.config}. Please make sure it is valid JSON.`
|
61
|
-
)
|
62
|
-
);
|
63
|
-
}
|
64
|
-
};
|
package/bin/commands/server.js
DELETED
@@ -1,80 +0,0 @@
|
|
1
|
-
const path = require("path");
|
2
|
-
const Nunjucks = require("nunjucks");
|
3
|
-
|
4
|
-
async function startServer() {
|
5
|
-
const server = require(path.join(__dirname, "../../dev-server/server.js"));
|
6
|
-
const plugins = require(path.join(
|
7
|
-
__dirname,
|
8
|
-
"../../dev-server/server-plugins.js"
|
9
|
-
));
|
10
|
-
const routes = require(path.join(
|
11
|
-
__dirname,
|
12
|
-
"../../dev-server/routes/routes.js"
|
13
|
-
));
|
14
|
-
await server.register(plugins);
|
15
|
-
server.views({
|
16
|
-
engines: {
|
17
|
-
html: {
|
18
|
-
compile: (src, options) => {
|
19
|
-
const template = Nunjucks.compile(src, options.environment);
|
20
|
-
return (context) => {
|
21
|
-
return template.render(context);
|
22
|
-
};
|
23
|
-
},
|
24
|
-
|
25
|
-
prepare: (options, next) => {
|
26
|
-
options.compileOptions.environment = Nunjucks.configure(
|
27
|
-
options.path,
|
28
|
-
{ watch: false }
|
29
|
-
);
|
30
|
-
return next();
|
31
|
-
},
|
32
|
-
},
|
33
|
-
},
|
34
|
-
path: `${path.join(__dirname, "../../dev-server/views")}`,
|
35
|
-
});
|
36
|
-
|
37
|
-
server.route(routes);
|
38
|
-
|
39
|
-
await server.start();
|
40
|
-
|
41
|
-
console.log("Server running at: ", server.info.uri);
|
42
|
-
console.log(`Target being used: ${process.env.TARGET || "nzz_ch"}`);
|
43
|
-
console.log(
|
44
|
-
`Tool base url being used: ${
|
45
|
-
process.env.TOOL_BASE_URL || "http://localhost:3000"
|
46
|
-
}`
|
47
|
-
);
|
48
|
-
if (process.env.CONFIG) {
|
49
|
-
console.log(`Config module will be loaded from: ${process.env.CONFIG}`);
|
50
|
-
}
|
51
|
-
}
|
52
|
-
|
53
|
-
module.exports = async function (command) {
|
54
|
-
if (command.port) {
|
55
|
-
process.env.PORT = command.port;
|
56
|
-
}
|
57
|
-
|
58
|
-
if (command.target) {
|
59
|
-
process.env.TARGET = command.target;
|
60
|
-
}
|
61
|
-
|
62
|
-
if (command.toolBaseUrl) {
|
63
|
-
process.env.TOOL_BASE_URL = command.toolBaseUrl;
|
64
|
-
}
|
65
|
-
|
66
|
-
if (command.config) {
|
67
|
-
if (path.isAbsolute(command.config)) {
|
68
|
-
process.env.CONFIG = command.config;
|
69
|
-
} else {
|
70
|
-
process.env.CONFIG = path.join(process.cwd(), command.config);
|
71
|
-
}
|
72
|
-
} else {
|
73
|
-
process.env.CONFIG = path.join(
|
74
|
-
__dirname,
|
75
|
-
"../../dev-server/config/default.js"
|
76
|
-
);
|
77
|
-
}
|
78
|
-
|
79
|
-
await startServer();
|
80
|
-
};
|
package/bin/q.js
DELETED
@@ -1,213 +0,0 @@
|
|
1
|
-
#!/usr/bin/env node
|
2
|
-
|
3
|
-
const { program } = require("commander");
|
4
|
-
const chalk = require("chalk");
|
5
|
-
const errorColor = chalk.red;
|
6
|
-
const version = require("../package.json").version;
|
7
|
-
const runServer = require("./commands/server.js");
|
8
|
-
const bootstrap = require("./commands/bootstrap.js");
|
9
|
-
const updateItem = require("./commands/qItem/updateItem/updateItem.js");
|
10
|
-
const copyItem = require("./commands/qItem/copyItem/copyItem.js");
|
11
|
-
const createCustomCodeItem = require("./commands/qItem/createCustomCodeItem/createCustomCodeItem.js");
|
12
|
-
|
13
|
-
async function main() {
|
14
|
-
program.version(version).description("Q Toolbox cli");
|
15
|
-
|
16
|
-
program
|
17
|
-
.command("server")
|
18
|
-
.option("-p, --port [port]", "the port to start the server on")
|
19
|
-
.option(
|
20
|
-
"-t, --target [target]",
|
21
|
-
"the target being used for rendering info route"
|
22
|
-
)
|
23
|
-
.option(
|
24
|
-
"-b, --tool-base-url [url]",
|
25
|
-
"the tool base url being set in rendering info route"
|
26
|
-
)
|
27
|
-
.option(
|
28
|
-
"-c, --config [config]",
|
29
|
-
"the config file name in which additional rendering info and tool runtime config is specified"
|
30
|
-
)
|
31
|
-
.description("start a simple server mocking a Q server for development")
|
32
|
-
.action(async (command) => {
|
33
|
-
await runServer(command);
|
34
|
-
});
|
35
|
-
|
36
|
-
program
|
37
|
-
.command("new-server")
|
38
|
-
.option(
|
39
|
-
"-d, --dir [path]",
|
40
|
-
"the base directory to bootstrap the new Q server implementation in, defaults to the name of Q server implementation"
|
41
|
-
)
|
42
|
-
.description("bootstrap a new Q server implementation")
|
43
|
-
.action(async (command) => {
|
44
|
-
const name = command.args[0];
|
45
|
-
if (!name) {
|
46
|
-
console.error(errorColor("no servername given"));
|
47
|
-
process.exit(1);
|
48
|
-
}
|
49
|
-
const baseDir = program.dir || name;
|
50
|
-
const textReplacements = [
|
51
|
-
{ regex: new RegExp(`server-skeleton`, "g"), replaceWith: name },
|
52
|
-
];
|
53
|
-
|
54
|
-
await bootstrap("server", baseDir, textReplacements);
|
55
|
-
});
|
56
|
-
|
57
|
-
program
|
58
|
-
.command("new-tool")
|
59
|
-
.option(
|
60
|
-
"-d, --dir <path>",
|
61
|
-
"the base directory to bootstrap the new tool in, defaults to the tools name"
|
62
|
-
)
|
63
|
-
.description("bootstrap a new tool")
|
64
|
-
.action(async (command) => {
|
65
|
-
let name = command.args[0];
|
66
|
-
|
67
|
-
if (!name) {
|
68
|
-
console.error(errorColor("no toolname given"));
|
69
|
-
process.exit(1);
|
70
|
-
}
|
71
|
-
|
72
|
-
// Make sure the name matches the spec.
|
73
|
-
if (!name.match(/^(Q-|q-)\w+/g)) {
|
74
|
-
console.error(errorColor("Tool must be named according to this format: Q-[a-z+]"));
|
75
|
-
process.exit(1);
|
76
|
-
}
|
77
|
-
|
78
|
-
// Capitalize first letter.
|
79
|
-
name = name[0].toUpperCase() + name.substring(1).toLowerCase();
|
80
|
-
|
81
|
-
let nameNodashes = name.replace(/\-/g, '');
|
82
|
-
toolnameCamelCase = nameNodashes[0].toUpperCase() + nameNodashes[1].toUpperCase() + nameNodashes.substring(2);
|
83
|
-
|
84
|
-
const baseDir = program.dir || name;
|
85
|
-
const textReplacements = [
|
86
|
-
// deprecated.
|
87
|
-
{ regex: /tool-skeleton/g, replaceWith: name },
|
88
|
-
|
89
|
-
// Replace all instance of tool name with underscore.
|
90
|
-
{ regex: /\[tool_name\]/g, replaceWith: name.toLowerCase().replace(/\-/g, '_') },
|
91
|
-
|
92
|
-
// Replace all instances with minuses.
|
93
|
-
{ regex: /\[Tool-name\]/g, replaceWith: name },
|
94
|
-
{ regex: /\[tool-name\]/g, replaceWith: name.toLowerCase() },
|
95
|
-
|
96
|
-
// Replace all CamelCase instances.
|
97
|
-
{ regex: /\[ToolName\]/g, replaceWith: toolnameCamelCase},
|
98
|
-
];
|
99
|
-
|
100
|
-
await bootstrap("toolv2", baseDir, textReplacements);
|
101
|
-
});
|
102
|
-
|
103
|
-
program
|
104
|
-
.command("new-custom-code")
|
105
|
-
.option(
|
106
|
-
"-d, --dir <path>",
|
107
|
-
"the base directory to bootstrap the new tool in, defaults to the tools name"
|
108
|
-
)
|
109
|
-
.description("bootstrap a new custom code project")
|
110
|
-
.action(async () => {
|
111
|
-
const name = program.args[1];
|
112
|
-
if (!name) {
|
113
|
-
console.error(errorColor("no custom-code projectname given"));
|
114
|
-
process.exit(1);
|
115
|
-
}
|
116
|
-
const baseDir = program.dir || name;
|
117
|
-
const textReplacements = [
|
118
|
-
{ regex: new RegExp(`custom-code-skeleton`, "g"), replaceWith: name },
|
119
|
-
];
|
120
|
-
|
121
|
-
await bootstrap("custom-code", baseDir, textReplacements);
|
122
|
-
});
|
123
|
-
|
124
|
-
program
|
125
|
-
.command("new-et-utils-package")
|
126
|
-
.option(
|
127
|
-
"-d, --dir <path>",
|
128
|
-
"the base directory to bootstrap the new tool in, defaults to the tools name"
|
129
|
-
)
|
130
|
-
.description("bootstrap a new ed-tech utility package")
|
131
|
-
.action(async () => {
|
132
|
-
const name = program.args[1];
|
133
|
-
const author = program.args[2] || "TODO: Set package author name";
|
134
|
-
const description =
|
135
|
-
program.args[3] || "TODO: Write a package description";
|
136
|
-
|
137
|
-
if (!name) {
|
138
|
-
console.error(errorColor("no package name given"));
|
139
|
-
process.exit(1);
|
140
|
-
}
|
141
|
-
|
142
|
-
const baseDir = program.dir || name;
|
143
|
-
const textReplacements = [
|
144
|
-
{ regex: new RegExp("<package-name>", "g"), replaceWith: name },
|
145
|
-
{ regex: new RegExp("<author-name>", "g"), replaceWith: author },
|
146
|
-
{
|
147
|
-
regex: new RegExp("<package-description>", "g"),
|
148
|
-
replaceWith: description,
|
149
|
-
},
|
150
|
-
];
|
151
|
-
|
152
|
-
await bootstrap("et-utils-package", baseDir, textReplacements);
|
153
|
-
});
|
154
|
-
|
155
|
-
program
|
156
|
-
.command("update-item")
|
157
|
-
.description("update q item")
|
158
|
-
.option(
|
159
|
-
"-c, --config [path]",
|
160
|
-
"set config path which defines the q items to be updated. defaults to ./q.config.json",
|
161
|
-
`${process.cwd()}/q.config.json`
|
162
|
-
)
|
163
|
-
.option(
|
164
|
-
"-e, --environment [env]",
|
165
|
-
"set environment which should be updated, defaults to update all items of all environments defined in config"
|
166
|
-
)
|
167
|
-
.option("-r, --reset", "reset stored configuration properties")
|
168
|
-
.action(async (command) => {
|
169
|
-
await updateItem(command);
|
170
|
-
});
|
171
|
-
|
172
|
-
program
|
173
|
-
.command("copy-item")
|
174
|
-
.description("copies an existing q item")
|
175
|
-
.option(
|
176
|
-
"-c, --config [path]",
|
177
|
-
"set config path which defines the q items to be copied. defaults to ./q.config.json",
|
178
|
-
`${process.cwd()}/q.config.json`
|
179
|
-
)
|
180
|
-
.option(
|
181
|
-
"-e, --environment [env]",
|
182
|
-
"set environment where the existing q item is found, defaults to copy all items of all environments defined in config"
|
183
|
-
)
|
184
|
-
.option("-r, --reset", "reset stored configuration properties")
|
185
|
-
.action(async (command) => {
|
186
|
-
await copyItem(command);
|
187
|
-
});
|
188
|
-
|
189
|
-
program
|
190
|
-
.command("create-custom-code-item")
|
191
|
-
.description("creates a new q custom code item in the db and adds it to the q config file")
|
192
|
-
.option(
|
193
|
-
"-c, --config [path]",
|
194
|
-
"set config path to q.config.json. defaults to ./q.config.json",
|
195
|
-
`${process.cwd()}/q.config.json`
|
196
|
-
)
|
197
|
-
.option(
|
198
|
-
"-e, --environment [env]",
|
199
|
-
"set environment where the new q custom code item should be created in"
|
200
|
-
)
|
201
|
-
.option(
|
202
|
-
"-t, --title [title]",
|
203
|
-
"set title of the new q custom code item"
|
204
|
-
)
|
205
|
-
.option("-r, --reset", "reset stored configuration properties")
|
206
|
-
.action(async (command) => {
|
207
|
-
await createCustomCodeItem(command);
|
208
|
-
});
|
209
|
-
|
210
|
-
await program.parseAsync(process.argv);
|
211
|
-
}
|
212
|
-
|
213
|
-
main();
|
@@ -1,51 +0,0 @@
|
|
1
|
-
async function getConfig() {
|
2
|
-
return {
|
3
|
-
nzz_ch: {
|
4
|
-
additionalRenderingInfo: {
|
5
|
-
// additionalRenderingInfo is tool based
|
6
|
-
stylesheets: [
|
7
|
-
{
|
8
|
-
url:
|
9
|
-
"https://service.sophie.nzz.ch/bundle/sophie-q@1,sophie-font@1,sophie-color@1,sophie-viz-color@1,sophie-legend@1,sophie-input@1.css"
|
10
|
-
}
|
11
|
-
]
|
12
|
-
},
|
13
|
-
context: {
|
14
|
-
// context is target based
|
15
|
-
stylesheets: [
|
16
|
-
{
|
17
|
-
url: "https://context-service.st.nzz.ch/stylesheet/all/nzz.ch.css"
|
18
|
-
}
|
19
|
-
],
|
20
|
-
background: {
|
21
|
-
color: "#fff"
|
22
|
-
}
|
23
|
-
},
|
24
|
-
toolRuntimeConfig: {}
|
25
|
-
},
|
26
|
-
nzzas: {
|
27
|
-
additionalRenderingInfo: {
|
28
|
-
stylesheets: [
|
29
|
-
{
|
30
|
-
url:
|
31
|
-
"https://service.sophie.nzz.ch/bundle/sophie-nzzas-q@1,sophie-nzzas-font@1,sophie-nzzas-color@1,sophie-nzzas-viz-color@1,sophie-nzzas-input@1.css"
|
32
|
-
}
|
33
|
-
]
|
34
|
-
},
|
35
|
-
context: {
|
36
|
-
stylesheets: [
|
37
|
-
{
|
38
|
-
url:
|
39
|
-
"https://context-service.st.nzz.ch/stylesheet/all/nzzas.nzz.ch.css"
|
40
|
-
}
|
41
|
-
],
|
42
|
-
background: {
|
43
|
-
color: "#fff"
|
44
|
-
}
|
45
|
-
},
|
46
|
-
toolRuntimeConfig: {}
|
47
|
-
}
|
48
|
-
};
|
49
|
-
}
|
50
|
-
|
51
|
-
module.exports = getConfig;
|
Binary file
|
@@ -1,64 +0,0 @@
|
|
1
|
-
body {
|
2
|
-
margin: 0;
|
3
|
-
padding: 0;
|
4
|
-
margin-top: 30px;
|
5
|
-
}
|
6
|
-
@media (min-width: 768px) {
|
7
|
-
body {
|
8
|
-
min-width: 100% !important;
|
9
|
-
}
|
10
|
-
.l--holder {
|
11
|
-
padding: 0;
|
12
|
-
margin: 0;
|
13
|
-
width: 100%;
|
14
|
-
}
|
15
|
-
}
|
16
|
-
.fixtures__container {
|
17
|
-
display: flex;
|
18
|
-
position: fixed;
|
19
|
-
height: 30px;
|
20
|
-
width: 100%;
|
21
|
-
top: 0;
|
22
|
-
z-index: 1000;
|
23
|
-
}
|
24
|
-
.fixtures__select {
|
25
|
-
font-family: nzz-sans-serif, Helvetica, Arial;
|
26
|
-
font-size: 13px;
|
27
|
-
font-weight: 500;
|
28
|
-
height: 100%;
|
29
|
-
line-height: 30px;
|
30
|
-
width: 100%;
|
31
|
-
padding: 0px 10px;
|
32
|
-
outline: none;
|
33
|
-
border-radius: 0;
|
34
|
-
border: 1px solid transparent;
|
35
|
-
color: #fff;
|
36
|
-
cursor: pointer;
|
37
|
-
appearance: none;
|
38
|
-
-webkit-appearance: none;
|
39
|
-
-moz-appearance: none;
|
40
|
-
background-color: #13175f;
|
41
|
-
background-position: calc(100% - 10px) 11px;
|
42
|
-
background-repeat: no-repeat;
|
43
|
-
background-image: url("data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTFweCIgaGVpZ2h0PSI3cHgiIHZpZXdCb3g9IjAgMCAxMSA3IiB2ZXJzaW9uPSIxLjEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiPg0KICAgIDxnIHN0cm9rZT0ibm9uZSIgc3Ryb2tlLXdpZHRoPSIxIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiPg0KICAgICAgICA8ZyB0cmFuc2Zvcm09InRyYW5zbGF0ZSgtNjAyLCAtMTIyNikiIGZpbGw9IiNGRkYiPg0KICAgICAgICAgICAgPGcgdHJhbnNmb3JtPSJ0cmFuc2xhdGUoNDY4LCAxMjA3KSI+DQogICAgICAgICAgICAgICAgPHBvbHlnb24gcG9pbnRzPSIxMzUuMDU5IDE5IDEzNCAyMC4wNjQgMTM5LjA3NCAyNS4xMjEgMTQ0LjEyMSAyMC4wOTEgMTQzLjA2MyAxOS4wMjggMTM5LjA3NCAyMy4wMDQiPjwvcG9seWdvbj4NCiAgICAgICAgICAgIDwvZz4NCiAgICAgICAgPC9nPg0KICAgIDwvZz4NCjwvc3ZnPg==");
|
44
|
-
}
|
45
|
-
.fixtures__reload-button {
|
46
|
-
font-size: 13px;
|
47
|
-
font-family: nzz-sans-serif, Helvetica, Arial;
|
48
|
-
font-weight: 500;
|
49
|
-
display: flex;
|
50
|
-
flex-flow: row nowrap;
|
51
|
-
justify-content: center;
|
52
|
-
align-items: center;
|
53
|
-
box-sizing: border-box;
|
54
|
-
height: 30px;
|
55
|
-
padding: 0 10px;
|
56
|
-
color: #fff;
|
57
|
-
background-color: #13175f;
|
58
|
-
border-width: 0px;
|
59
|
-
border-radius: 0px;
|
60
|
-
}
|
61
|
-
.fixtures__select:hover,
|
62
|
-
.fixtures__reload-button:hover {
|
63
|
-
background-color: #2c32bd;
|
64
|
-
}
|