@fontoxml/fontoxml-development-tools 3.11.0 → 3.12.0
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 +4 -4
- package/npm-shrinkwrap.json +3804 -8292
- package/package.json +13 -19
- package/src/App.js +1 -1
- package/src/FdtCommand.js +3 -3
- package/src/FdtLicense.js +95 -114
- package/src/ModuleRegistrationApi.js +44 -16
- package/src/addCoreModulesToApp.js +8 -0
- package/src/modules/connectors/index.js +109 -16
- package/src/modules/connectors/instanceBuild/Dockerfile.build +1 -1
- package/src/modules/connectors/instanceBuild/Dockerfile.run +1 -1
- package/src/modules/connectors/instanceDevBuild/docker-compose.yml +2 -2
- package/src/modules/content-quality/index.js +101 -20
- package/src/modules/content-quality/instanceBuild/Dockerfile +1 -1
- package/src/modules/content-quality/instanceDevBuild/docker-compose.yml +1 -1
- package/src/modules/core/src/precontroller.help.js +23 -26
- package/src/modules/document-history/index.js +101 -20
- package/src/modules/document-history/instanceBuild/Dockerfile +1 -1
- package/src/modules/document-history/instanceDevBuild/docker-compose.yml +1 -1
- package/src/modules/editor/dev-cms/connectors-cms-standard/configureConnectorsCmsStandardDocumentRouter.js +10 -0
- package/src/modules/editor/dev-cms/connectors-cms-standard/configureDocumentHistoryGetPostRouteHandler.js +51 -0
- package/src/modules/editor/dev-cms/connectors-cms-standard/configureDocumentPostRouteHandler.js +65 -76
- package/src/modules/editor/dev-cms/connectors-cms-standard/configureDocumentPresearchPostRouteHandler.js +10 -7
- package/src/modules/editor/dev-cms/connectors-cms-standard/configureDocumentPreviewRouteHandler.js +10 -0
- package/src/modules/editor/dev-cms/connectors-cms-standard/configureDocumentRevisionGetPostRouteHandler.js +69 -0
- package/src/modules/editor/src/commands/command.convert.editor.controller.js +11 -4
- package/src/modules/editor/src/commands/command.convert.package.controller.js +11 -4
- package/src/modules/editor/src/getAppManifest.js +3 -3
- package/src/modules/editor/src/getWebpackConfig.js +13 -0
- package/src/modules/editor/src/webpackPlugins/CheckDeepImportsResolvePlugin.js +4 -0
- package/src/modules/editor-pre-7-7-0/src/api/downloadEditorSDK.js +16 -12
- package/src/modules/editor-pre-7-7-0/src/api/executeAndLog.js +3 -2
- package/src/modules/editor-pre-7-7-0/src/api/schema/compile.js +16 -22
- package/src/modules/editor-pre-7-7-0/src/api/schema/createSchemaPackages.js +8 -0
- package/src/modules/editor-pre-7-7-0/src/api/schema/getSchemaFontoJson.js +76 -48
- package/src/modules/editor-pre-7-7-0/src/command.schema.compile.controller.js +51 -2
- package/src/modules/editor-pre-7-7-0/test/api/schema/buildSchemaExperienceConfigurationModel.test.js +70 -79
- package/src/modules/editor-pre-7-7-0/test/api/schema/fixtures/invalid-fonto-json/fonto.json +1 -0
- package/src/modules/editor-pre-7-7-0/test/api/schema/getSchemaFontoJson.test.js +174 -0
- package/src/modules/editor-pre-7-7-0/test/schemaCompileController.test.js +205 -0
- package/src/modules/localization/index.js +2 -2
- package/src/modules/operations/src/api/getOperations.js +3 -3
- package/src/modules/review/index.js +103 -18
- package/src/modules/review/instanceBuild/Dockerfile +1 -1
- package/src/modules/review/instanceDevBuild/docker-compose.yml +1 -1
- package/src/modules/schema/src/api/getSchemaSummaries.js +2 -2
- package/src/modules/schema/test/getSchemaSummaries.test.js +14 -10
- package/src/modules/schema-compiler/index.js +99 -18
- package/src/modules/schema-compiler/instanceBuild/Dockerfile +1 -1
- package/src/modules/schema-compiler/instanceDevBuild/docker-compose.yml +1 -1
- package/src/modules/shared/index.js +3 -0
- package/src/modules/shared/package.json +14 -0
- package/src/modules/shared/src/addBackendDockerCommands.js +334 -0
- package/src/modules/shared/src/addBackendDownloadSelfContainedCommands.js +78 -0
- package/src/modules/shared/src/addBackendVersionsCommands.js +55 -0
- package/src/modules/shared/src/controller-templates/command.backend.build.controller.factory.js +273 -0
- package/src/modules/shared/src/controller-templates/command.backend.download-self-contained.controller.factory.js +131 -0
- package/src/modules/shared/src/controller-templates/command.backend.init.controller.factory.js +88 -0
- package/src/modules/shared/src/controller-templates/command.backend.run.controller.factory.js +420 -0
- package/src/modules/shared/src/controller-templates/command.backend.upgrade.controller.factory.js +79 -0
- package/src/modules/shared/src/controller-templates/command.backend.versions.controller.factory.js +23 -0
- package/src/modules/shared/src/controller-templates/docker/BackendManifest.js +42 -0
- package/src/modules/shared/src/controller-templates/docker/copyWhitelistedFiles.js +23 -0
- package/src/modules/shared/src/controller-templates/docker/dockerCleanup.js +146 -0
- package/src/modules/shared/src/controller-templates/docker/tryDockerLogout.js +31 -0
- package/src/modules/shared/src/controller-templates/docker/validateBackendInstance.js +48 -0
- package/src/modules/shared/src/ensureDockerCommands.js +61 -0
- package/src/modules/shared/src/executeAndLog.js +113 -0
- package/src/modules/{review/src/utilities/setEntryVisibility.js → shared/src/setFileVisibility.js} +8 -2
- package/src/modules/spell-checker/index.js +101 -18
- package/src/modules/spell-checker/instanceBuild/Dockerfile +1 -1
- package/src/modules/spell-checker/instanceDevBuild/docker-compose.yml +1 -1
- package/test/module.shared.test.js +81 -0
- package/src/modules/connectors/src/command.build.controller.js +0 -256
- package/src/modules/connectors/src/command.build.js +0 -54
- package/src/modules/connectors/src/command.download-self-contained.controller.js +0 -110
- package/src/modules/connectors/src/command.download-self-contained.js +0 -50
- package/src/modules/connectors/src/command.init.controller.js +0 -91
- package/src/modules/connectors/src/command.init.js +0 -42
- package/src/modules/connectors/src/command.run.controller.js +0 -462
- package/src/modules/connectors/src/command.run.js +0 -67
- package/src/modules/connectors/src/command.upgrade.controller.js +0 -52
- package/src/modules/connectors/src/command.upgrade.js +0 -42
- package/src/modules/connectors/src/command.versions.controller.js +0 -14
- package/src/modules/connectors/src/command.versions.js +0 -25
- package/src/modules/connectors/src/utilities/FontoxmlConnectorsManifest.js +0 -32
- package/src/modules/connectors/src/utilities/cleanup.js +0 -70
- package/src/modules/connectors/src/utilities/constants.js +0 -42
- package/src/modules/connectors/src/utilities/copyWhitelistedFiles.js +0 -22
- package/src/modules/connectors/src/utilities/executeAndLog.js +0 -63
- package/src/modules/connectors/src/utilities/getVerbosityLevel.js +0 -11
- package/src/modules/connectors/src/utilities/getWhitelist.js +0 -16
- package/src/modules/connectors/src/utilities/setEntryVisibility.js +0 -22
- package/src/modules/connectors/src/utilities/validateInstance.js +0 -29
- package/src/modules/content-quality/src/command.build.controller.js +0 -260
- package/src/modules/content-quality/src/command.build.js +0 -56
- package/src/modules/content-quality/src/command.download-self-contained.controller.js +0 -110
- package/src/modules/content-quality/src/command.download-self-contained.js +0 -52
- package/src/modules/content-quality/src/command.init.controller.js +0 -91
- package/src/modules/content-quality/src/command.init.js +0 -44
- package/src/modules/content-quality/src/command.run.controller.js +0 -444
- package/src/modules/content-quality/src/command.run.js +0 -64
- package/src/modules/content-quality/src/command.upgrade.controller.js +0 -52
- package/src/modules/content-quality/src/command.upgrade.js +0 -44
- package/src/modules/content-quality/src/command.versions.controller.js +0 -14
- package/src/modules/content-quality/src/command.versions.js +0 -25
- package/src/modules/content-quality/src/utilities/FontoxmlFcqManifest.js +0 -30
- package/src/modules/content-quality/src/utilities/cleanup.js +0 -70
- package/src/modules/content-quality/src/utilities/constants.js +0 -44
- package/src/modules/content-quality/src/utilities/copyWhitelistedFiles.js +0 -22
- package/src/modules/content-quality/src/utilities/executeAndLog.js +0 -63
- package/src/modules/content-quality/src/utilities/getVerbosityLevel.js +0 -11
- package/src/modules/content-quality/src/utilities/getWhitelist.js +0 -16
- package/src/modules/content-quality/src/utilities/setEntryVisibility.js +0 -22
- package/src/modules/content-quality/src/utilities/validateInstance.js +0 -29
- package/src/modules/document-history/src/command.build.controller.js +0 -260
- package/src/modules/document-history/src/command.build.js +0 -56
- package/src/modules/document-history/src/command.download-self-contained.controller.js +0 -110
- package/src/modules/document-history/src/command.download-self-contained.js +0 -50
- package/src/modules/document-history/src/command.init.controller.js +0 -91
- package/src/modules/document-history/src/command.init.js +0 -44
- package/src/modules/document-history/src/command.run.controller.js +0 -444
- package/src/modules/document-history/src/command.run.js +0 -64
- package/src/modules/document-history/src/command.upgrade.controller.js +0 -52
- package/src/modules/document-history/src/command.upgrade.js +0 -44
- package/src/modules/document-history/src/command.versions.controller.js +0 -14
- package/src/modules/document-history/src/command.versions.js +0 -25
- package/src/modules/document-history/src/utilities/FontoxmlFdhManifest.js +0 -30
- package/src/modules/document-history/src/utilities/cleanup.js +0 -70
- package/src/modules/document-history/src/utilities/constants.js +0 -44
- package/src/modules/document-history/src/utilities/copyWhitelistedFiles.js +0 -22
- package/src/modules/document-history/src/utilities/executeAndLog.js +0 -63
- package/src/modules/document-history/src/utilities/getVerbosityLevel.js +0 -11
- package/src/modules/document-history/src/utilities/getWhitelist.js +0 -16
- package/src/modules/document-history/src/utilities/setEntryVisibility.js +0 -22
- package/src/modules/document-history/src/utilities/validateInstance.js +0 -29
- package/src/modules/review/src/command.build.controller.js +0 -256
- package/src/modules/review/src/command.build.js +0 -54
- package/src/modules/review/src/command.download-self-contained.controller.js +0 -107
- package/src/modules/review/src/command.download-self-contained.js +0 -50
- package/src/modules/review/src/command.init.controller.js +0 -89
- package/src/modules/review/src/command.init.js +0 -42
- package/src/modules/review/src/command.run.controller.js +0 -428
- package/src/modules/review/src/command.run.js +0 -60
- package/src/modules/review/src/command.upgrade.controller.js +0 -59
- package/src/modules/review/src/command.upgrade.js +0 -42
- package/src/modules/review/src/command.versions.controller.js +0 -12
- package/src/modules/review/src/command.versions.js +0 -25
- package/src/modules/review/src/utilities/FontoxmlReviewManifest.js +0 -30
- package/src/modules/review/src/utilities/cleanup.js +0 -70
- package/src/modules/review/src/utilities/constants.js +0 -42
- package/src/modules/review/src/utilities/copyWhitelistedFiles.js +0 -22
- package/src/modules/review/src/utilities/executeAndLog.js +0 -63
- package/src/modules/review/src/utilities/getVerbosityLevel.js +0 -11
- package/src/modules/review/src/utilities/getWhitelist.js +0 -16
- package/src/modules/review/src/utilities/validateInstance.js +0 -45
- package/src/modules/schema-compiler/src/command.build.controller.js +0 -256
- package/src/modules/schema-compiler/src/command.build.js +0 -54
- package/src/modules/schema-compiler/src/command.download-self-contained.controller.js +0 -110
- package/src/modules/schema-compiler/src/command.download-self-contained.js +0 -50
- package/src/modules/schema-compiler/src/command.init.controller.js +0 -91
- package/src/modules/schema-compiler/src/command.init.js +0 -42
- package/src/modules/schema-compiler/src/command.run.controller.js +0 -430
- package/src/modules/schema-compiler/src/command.run.js +0 -60
- package/src/modules/schema-compiler/src/command.upgrade.controller.js +0 -64
- package/src/modules/schema-compiler/src/command.upgrade.js +0 -42
- package/src/modules/schema-compiler/src/command.versions.controller.js +0 -14
- package/src/modules/schema-compiler/src/command.versions.js +0 -25
- package/src/modules/schema-compiler/src/utilities/FontoxmlSchemaCompilerManifest.js +0 -32
- package/src/modules/schema-compiler/src/utilities/cleanup.js +0 -70
- package/src/modules/schema-compiler/src/utilities/constants.js +0 -43
- package/src/modules/schema-compiler/src/utilities/copyWhitelistedFiles.js +0 -22
- package/src/modules/schema-compiler/src/utilities/executeAndLog.js +0 -63
- package/src/modules/schema-compiler/src/utilities/getVerbosityLevel.js +0 -11
- package/src/modules/schema-compiler/src/utilities/getWhitelist.js +0 -16
- package/src/modules/schema-compiler/src/utilities/setEntryVisibility.js +0 -22
- package/src/modules/schema-compiler/src/utilities/validateInstance.js +0 -47
- package/src/modules/spell-checker/src/command.build.controller.js +0 -257
- package/src/modules/spell-checker/src/command.build.js +0 -54
- package/src/modules/spell-checker/src/command.download-self-contained.controller.js +0 -110
- package/src/modules/spell-checker/src/command.download-self-contained.js +0 -50
- package/src/modules/spell-checker/src/command.init.controller.js +0 -91
- package/src/modules/spell-checker/src/command.init.js +0 -42
- package/src/modules/spell-checker/src/command.run.controller.js +0 -430
- package/src/modules/spell-checker/src/command.run.js +0 -62
- package/src/modules/spell-checker/src/command.upgrade.controller.js +0 -61
- package/src/modules/spell-checker/src/command.upgrade.js +0 -42
- package/src/modules/spell-checker/src/command.versions.controller.js +0 -14
- package/src/modules/spell-checker/src/command.versions.js +0 -25
- package/src/modules/spell-checker/src/utilities/FontoxmlSpellCheckerManifest.js +0 -32
- package/src/modules/spell-checker/src/utilities/cleanup.js +0 -70
- package/src/modules/spell-checker/src/utilities/constants.js +0 -42
- package/src/modules/spell-checker/src/utilities/copyWhitelistedFiles.js +0 -22
- package/src/modules/spell-checker/src/utilities/executeAndLog.js +0 -63
- package/src/modules/spell-checker/src/utilities/getVerbosityLevel.js +0 -11
- package/src/modules/spell-checker/src/utilities/getWhitelist.js +0 -16
- package/src/modules/spell-checker/src/utilities/setEntryVisibility.js +0 -22
- package/src/modules/spell-checker/src/utilities/validateInstance.js +0 -47
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fontoxml/fontoxml-development-tools",
|
|
3
3
|
"description": "Development tools for Fonto.",
|
|
4
|
-
"version": "3.
|
|
4
|
+
"version": "3.12.0",
|
|
5
5
|
"author": "The Fonto Team",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"keywords": [
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"babel-plugin-istanbul": "6.1.1",
|
|
39
39
|
"body-parser": "1.19.0",
|
|
40
40
|
"case-sensitive-paths-webpack-plugin": "2.4.0",
|
|
41
|
-
"chalk": "
|
|
41
|
+
"chalk": "5.0.1",
|
|
42
42
|
"cli-table": "0.3.6",
|
|
43
43
|
"compare-versions": "3.6.0",
|
|
44
44
|
"compression": "1.7.4",
|
|
@@ -51,55 +51,49 @@
|
|
|
51
51
|
"fontoxpath": "3.17.2",
|
|
52
52
|
"fs-extra": "9.1.0",
|
|
53
53
|
"fswin": "3.21.107",
|
|
54
|
-
"globby": "11.0.3",
|
|
55
54
|
"html-webpack-plugin": "5.5.0",
|
|
56
|
-
"http-auth": "4.1.
|
|
55
|
+
"http-auth": "4.1.9",
|
|
57
56
|
"http-proxy-middleware": "2.0.1",
|
|
58
57
|
"inquirer": "8.0.0",
|
|
59
58
|
"inquirer-checkbox-plus-prompt": "1.0.1",
|
|
60
59
|
"loader-utils": "3.2.0",
|
|
61
60
|
"mini-css-extract-plugin": "2.4.5",
|
|
62
|
-
"multer": "1.4.
|
|
61
|
+
"multer": "1.4.5-lts.1",
|
|
62
|
+
"node-fetch": "3.2.10",
|
|
63
63
|
"p-map": "4.0.0",
|
|
64
64
|
"path-to-regexp": "6.2.0",
|
|
65
65
|
"pdfkit": "0.12.1",
|
|
66
66
|
"picomatch": "2.3.1",
|
|
67
67
|
"prettier": "2.3.2",
|
|
68
|
-
"prompt-confirm": "2.0.4",
|
|
69
68
|
"recast": "0.20.4",
|
|
70
|
-
"request": "2.88.2",
|
|
71
|
-
"request-promise-native": "1.0.9",
|
|
72
69
|
"requirejs": "2.3.6",
|
|
73
|
-
"slimdom
|
|
70
|
+
"slimdom": "4.0.2",
|
|
74
71
|
"strip-ansi": "6.0.0",
|
|
75
72
|
"strip-color": "0.1.0",
|
|
76
|
-
"
|
|
77
|
-
"terser": "5.10.0",
|
|
78
|
-
"terser-webpack-plugin": "5.3.0",
|
|
73
|
+
"terser-webpack-plugin": "5.3.3",
|
|
79
74
|
"to-utf-8": "1.3.0",
|
|
80
75
|
"type-is": "1.6.18",
|
|
81
76
|
"unzipper": "0.10.11",
|
|
82
77
|
"uuid": "8.3.2",
|
|
83
78
|
"webpack": "5.65.0",
|
|
84
79
|
"webpack-dev-middleware": "5.3.0",
|
|
85
|
-
"wrap-ansi": "7.0.0"
|
|
86
|
-
"xml2js": "0.4.23"
|
|
80
|
+
"wrap-ansi": "7.0.0"
|
|
87
81
|
},
|
|
88
82
|
"devDependencies": {
|
|
89
83
|
"@babel/eslint-plugin": "7.14.5",
|
|
90
|
-
"@fontoxml/eslint-config": "4.0.
|
|
91
|
-
"chai": "4.3.
|
|
84
|
+
"@fontoxml/eslint-config": "4.0.3",
|
|
85
|
+
"chai": "4.3.6",
|
|
92
86
|
"cross-env": "7.0.3",
|
|
93
87
|
"eslint": "7.29.0",
|
|
94
88
|
"eslint-config-prettier": "8.3.0",
|
|
95
89
|
"eslint-plugin-import": "2.23.4",
|
|
96
90
|
"eslint-plugin-prettier": "3.4.0",
|
|
97
91
|
"eslint-plugin-simple-import-sort": "7.0.0",
|
|
98
|
-
"mocha": "
|
|
99
|
-
"mocha-junit-reporter": "2.0.
|
|
92
|
+
"mocha": "10.0.0",
|
|
93
|
+
"mocha-junit-reporter": "2.0.2",
|
|
100
94
|
"nyc": "15.1.0",
|
|
101
95
|
"prettier": "2.3.2",
|
|
102
96
|
"tmp": "0.2.1",
|
|
103
|
-
"ws": "7.
|
|
97
|
+
"ws": "7.5.8"
|
|
104
98
|
}
|
|
105
99
|
}
|
package/src/App.js
CHANGED
|
@@ -284,7 +284,7 @@ export default class FontoXMLDevelopmentToolsApp {
|
|
|
284
284
|
/**
|
|
285
285
|
* Returns an object with information that a module could use to reason about which fdt instance it is used for.
|
|
286
286
|
*
|
|
287
|
-
* @return {{name:
|
|
287
|
+
* @return {{name: string, version?: string}}
|
|
288
288
|
*/
|
|
289
289
|
getInfo() {
|
|
290
290
|
return {
|
package/src/FdtCommand.js
CHANGED
|
@@ -18,7 +18,7 @@ export default class FdtCommand extends ask.Command {
|
|
|
18
18
|
/**
|
|
19
19
|
* @constructor
|
|
20
20
|
* @param {string} commandName
|
|
21
|
-
* @param {
|
|
21
|
+
* @param {(request: AskNicelyRequest, response: FdtResponse) => (void | Promise<void>)} [controller]
|
|
22
22
|
*/
|
|
23
23
|
constructor(commandName, controller) {
|
|
24
24
|
super(commandName, controller);
|
|
@@ -80,7 +80,7 @@ export default class FdtCommand extends ask.Command {
|
|
|
80
80
|
/**
|
|
81
81
|
* Set the main controller.
|
|
82
82
|
*
|
|
83
|
-
* @param {string|
|
|
83
|
+
* @param {string|(request: AskNicelyRequest, response: FdtResponse) => (void | Promise<void>)} [controller]
|
|
84
84
|
*
|
|
85
85
|
* @return {FdtCommand} This command.
|
|
86
86
|
*/
|
|
@@ -114,7 +114,7 @@ export default class FdtCommand extends ask.Command {
|
|
|
114
114
|
* Register a hidden command as a child of this, and register this as parent of the child.
|
|
115
115
|
*
|
|
116
116
|
* @param {string|Command} commandName The identifying name of this option, unique for its ancestry.
|
|
117
|
-
* @param {string|
|
|
117
|
+
* @param {string|(request: AskNicelyRequest, response: FdtResponse) => (void | Promise<void>)} [controller]
|
|
118
118
|
*
|
|
119
119
|
* @return {Command} The child command.
|
|
120
120
|
*/
|
package/src/FdtLicense.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import compareVersions from 'compare-versions';
|
|
2
2
|
import fs from 'fs';
|
|
3
|
+
import fetch, { Blob, File, FormData } from 'node-fetch';
|
|
3
4
|
import os from 'os';
|
|
4
5
|
import path from 'path';
|
|
5
|
-
import requestPromise from 'request-promise-native';
|
|
6
6
|
import util from 'util';
|
|
7
7
|
|
|
8
8
|
import getParentDirectoryContainingFileSync from './getParentDirectoryContainingFileSync.js';
|
|
@@ -418,34 +418,27 @@ export default class FdtLicense {
|
|
|
418
418
|
validateAndUpdateLicenseFile() {
|
|
419
419
|
return this.getLicenseFileBuffer()
|
|
420
420
|
.then((licenseFileBuffer) => {
|
|
421
|
-
// Remotely
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
request: {
|
|
427
|
-
value: JSON.stringify(
|
|
428
|
-
this._getSystemTelemetryData()
|
|
429
|
-
),
|
|
430
|
-
options: {
|
|
431
|
-
contentType: 'application/json',
|
|
432
|
-
},
|
|
433
|
-
},
|
|
434
|
-
license: {
|
|
435
|
-
value: licenseFileBuffer,
|
|
436
|
-
options: {
|
|
437
|
-
filename: DEFAULT_LICENSE_FILENAME,
|
|
438
|
-
contentType: 'application/octet-stream',
|
|
439
|
-
},
|
|
440
|
-
},
|
|
441
|
-
},
|
|
442
|
-
resolveWithFullResponse: true,
|
|
443
|
-
simple: false,
|
|
444
|
-
}
|
|
421
|
+
// Remotely get the required data.
|
|
422
|
+
const form = new FormData();
|
|
423
|
+
form.set(
|
|
424
|
+
'request',
|
|
425
|
+
JSON.stringify(this._getSystemTelemetryData())
|
|
445
426
|
);
|
|
427
|
+
form.set(
|
|
428
|
+
'license',
|
|
429
|
+
new File([licenseFileBuffer], DEFAULT_LICENSE_FILENAME, {
|
|
430
|
+
type: 'application/octet-stream',
|
|
431
|
+
})
|
|
432
|
+
);
|
|
433
|
+
|
|
434
|
+
// Remotely validate the license file.
|
|
435
|
+
return fetch(`${this._backendBaseUrl}/license/validate`, {
|
|
436
|
+
body: form,
|
|
437
|
+
method: 'POST',
|
|
438
|
+
});
|
|
446
439
|
})
|
|
447
440
|
.catch((error) => {
|
|
448
|
-
if (error.
|
|
441
|
+
if (error.solution) {
|
|
449
442
|
throw error;
|
|
450
443
|
}
|
|
451
444
|
|
|
@@ -453,25 +446,30 @@ export default class FdtLicense {
|
|
|
453
446
|
`Could not get response from license server. Please check if you have a working internet connection.`
|
|
454
447
|
);
|
|
455
448
|
})
|
|
456
|
-
.then((response) => {
|
|
457
|
-
switch (response.
|
|
449
|
+
.then(async (response) => {
|
|
450
|
+
switch (response.status) {
|
|
458
451
|
case 200: {
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
452
|
+
let body;
|
|
453
|
+
|
|
454
|
+
try {
|
|
455
|
+
body = await response.text();
|
|
456
|
+
// Validate response before writing to disk.
|
|
457
|
+
const validationResult =
|
|
458
|
+
this._decodeAndValidateLicenseFileData(body);
|
|
459
|
+
if (validationResult.error) {
|
|
460
|
+
throw validationResult.error;
|
|
461
|
+
}
|
|
462
|
+
} catch (_error) {
|
|
465
463
|
throw new Error(
|
|
466
|
-
|
|
464
|
+
`Invalid updated license data received while checking license.`
|
|
467
465
|
);
|
|
468
466
|
}
|
|
469
467
|
|
|
470
468
|
// Update license file on disk.
|
|
471
|
-
return writeFile(this._license.filename,
|
|
469
|
+
return writeFile(this._license.filename, body)
|
|
472
470
|
.catch((_error) => {
|
|
473
471
|
throw new Error(
|
|
474
|
-
|
|
472
|
+
`Could not update local license file.`
|
|
475
473
|
);
|
|
476
474
|
})
|
|
477
475
|
.then(() => {
|
|
@@ -493,7 +491,7 @@ export default class FdtLicense {
|
|
|
493
491
|
this.app.getInfo().name
|
|
494
492
|
} license validate' to check your license.`
|
|
495
493
|
);
|
|
496
|
-
error.statusCode = response.
|
|
494
|
+
error.statusCode = response.status;
|
|
497
495
|
throw error;
|
|
498
496
|
}
|
|
499
497
|
case 401:
|
|
@@ -503,14 +501,14 @@ export default class FdtLicense {
|
|
|
503
501
|
this.app.getInfo().name
|
|
504
502
|
} license validate' to check your license.`
|
|
505
503
|
);
|
|
506
|
-
error.statusCode = response.
|
|
504
|
+
error.statusCode = response.status;
|
|
507
505
|
throw error;
|
|
508
506
|
}
|
|
509
507
|
default: {
|
|
510
508
|
const error = new Error(
|
|
511
|
-
`Error while checking license (${response.
|
|
509
|
+
`Error while checking license (${response.status}).`
|
|
512
510
|
);
|
|
513
|
-
error.statusCode = response.
|
|
511
|
+
error.statusCode = response.status;
|
|
514
512
|
throw error;
|
|
515
513
|
}
|
|
516
514
|
}
|
|
@@ -529,38 +527,30 @@ export default class FdtLicense {
|
|
|
529
527
|
return this.getLicenseFileBuffer()
|
|
530
528
|
.then((licenseFileBuffer) => {
|
|
531
529
|
// Remotely get the required data.
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
contentType: 'application/json',
|
|
547
|
-
},
|
|
548
|
-
},
|
|
549
|
-
license: {
|
|
550
|
-
value: licenseFileBuffer,
|
|
551
|
-
options: {
|
|
552
|
-
filename: DEFAULT_LICENSE_FILENAME,
|
|
553
|
-
contentType: 'application/octet-stream',
|
|
554
|
-
},
|
|
555
|
-
},
|
|
556
|
-
},
|
|
557
|
-
resolveWithFullResponse: true,
|
|
558
|
-
simple: false,
|
|
559
|
-
}
|
|
530
|
+
const form = new FormData();
|
|
531
|
+
form.set(
|
|
532
|
+
'request',
|
|
533
|
+
JSON.stringify(
|
|
534
|
+
Object.assign(this._getSystemTelemetryData(), {
|
|
535
|
+
products: productsWithData,
|
|
536
|
+
})
|
|
537
|
+
)
|
|
538
|
+
);
|
|
539
|
+
form.set(
|
|
540
|
+
'license',
|
|
541
|
+
new File([licenseFileBuffer], DEFAULT_LICENSE_FILENAME, {
|
|
542
|
+
type: 'application/octet-stream',
|
|
543
|
+
})
|
|
560
544
|
);
|
|
545
|
+
|
|
546
|
+
// Remotely validate the license file.
|
|
547
|
+
return fetch(`${this._backendBaseUrl}/product/data`, {
|
|
548
|
+
body: form,
|
|
549
|
+
method: 'POST',
|
|
550
|
+
});
|
|
561
551
|
})
|
|
562
552
|
.catch((error) => {
|
|
563
|
-
if (error.
|
|
553
|
+
if (error.solution) {
|
|
564
554
|
throw error;
|
|
565
555
|
}
|
|
566
556
|
|
|
@@ -568,18 +558,16 @@ export default class FdtLicense {
|
|
|
568
558
|
`Could not get response from license server. Please check if you have a working internet connection.`
|
|
569
559
|
);
|
|
570
560
|
})
|
|
571
|
-
.then((response) => {
|
|
572
|
-
switch (response.
|
|
561
|
+
.then(async (response) => {
|
|
562
|
+
switch (response.status) {
|
|
573
563
|
case 200: {
|
|
574
|
-
let data;
|
|
575
564
|
try {
|
|
576
|
-
|
|
577
|
-
} catch (
|
|
565
|
+
return await response.json();
|
|
566
|
+
} catch (_err) {
|
|
578
567
|
throw new Error(
|
|
579
|
-
|
|
568
|
+
`Invalid response data while getting data for products.`
|
|
580
569
|
);
|
|
581
570
|
}
|
|
582
|
-
return data;
|
|
583
571
|
}
|
|
584
572
|
case 400: {
|
|
585
573
|
const error = new Error(
|
|
@@ -587,7 +575,7 @@ export default class FdtLicense {
|
|
|
587
575
|
this.app.getInfo().name
|
|
588
576
|
} license validate' to check your license.`
|
|
589
577
|
);
|
|
590
|
-
error.statusCode = response.
|
|
578
|
+
error.statusCode = response.status;
|
|
591
579
|
throw error;
|
|
592
580
|
}
|
|
593
581
|
case 401:
|
|
@@ -597,21 +585,21 @@ export default class FdtLicense {
|
|
|
597
585
|
this.app.getInfo().name
|
|
598
586
|
} license validate' to check your license.`
|
|
599
587
|
);
|
|
600
|
-
error.statusCode = response.
|
|
588
|
+
error.statusCode = response.status;
|
|
601
589
|
throw error;
|
|
602
590
|
}
|
|
603
591
|
case 404: {
|
|
604
592
|
const error = new Error(
|
|
605
593
|
'Could not get requested data, because one or more of the requested products or their data does not exist.'
|
|
606
594
|
);
|
|
607
|
-
error.statusCode = response.
|
|
595
|
+
error.statusCode = response.status;
|
|
608
596
|
throw error;
|
|
609
597
|
}
|
|
610
598
|
default: {
|
|
611
599
|
const error = new Error(
|
|
612
|
-
`Error while getting data for products (${response.
|
|
600
|
+
`Error while getting data for products (${response.status}).`
|
|
613
601
|
);
|
|
614
|
-
error.statusCode = response.
|
|
602
|
+
error.statusCode = response.status;
|
|
615
603
|
throw error;
|
|
616
604
|
}
|
|
617
605
|
}
|
|
@@ -649,47 +637,40 @@ export default class FdtLicense {
|
|
|
649
637
|
sendTelemetry(data) {
|
|
650
638
|
return this.getLicenseFileBuffer()
|
|
651
639
|
.then((licenseFileBuffer) => {
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
},
|
|
668
|
-
},
|
|
669
|
-
license: {
|
|
670
|
-
value: licenseFileBuffer,
|
|
671
|
-
options: {
|
|
672
|
-
filename: DEFAULT_LICENSE_FILENAME,
|
|
673
|
-
contentType: 'application/octet-stream',
|
|
674
|
-
},
|
|
675
|
-
},
|
|
676
|
-
},
|
|
677
|
-
resolveWithFullResponse: true,
|
|
678
|
-
simple: false,
|
|
679
|
-
timeout: 10000,
|
|
680
|
-
}
|
|
640
|
+
// Remotely get the required data.
|
|
641
|
+
const form = new FormData();
|
|
642
|
+
form.set(
|
|
643
|
+
'request',
|
|
644
|
+
JSON.stringify(
|
|
645
|
+
Object.assign(this._getSystemTelemetryData(), {
|
|
646
|
+
data,
|
|
647
|
+
})
|
|
648
|
+
)
|
|
649
|
+
);
|
|
650
|
+
form.set(
|
|
651
|
+
'license',
|
|
652
|
+
new File([licenseFileBuffer], DEFAULT_LICENSE_FILENAME, {
|
|
653
|
+
type: 'application/octet-stream',
|
|
654
|
+
})
|
|
681
655
|
);
|
|
656
|
+
|
|
657
|
+
// Remotely validate the license file.
|
|
658
|
+
return fetch(`${this._backendBaseUrl}/telemetry`, {
|
|
659
|
+
body: form,
|
|
660
|
+
method: 'POST',
|
|
661
|
+
timeout: 10000,
|
|
662
|
+
});
|
|
682
663
|
})
|
|
683
664
|
.then((response) => {
|
|
684
|
-
switch (response.
|
|
665
|
+
switch (response.status) {
|
|
685
666
|
case 200:
|
|
686
667
|
case 204:
|
|
687
668
|
break;
|
|
688
669
|
default: {
|
|
689
670
|
const error = new Error(
|
|
690
|
-
`Error while sending telemetry (${response.
|
|
671
|
+
`Error while sending telemetry (${response.status}).`
|
|
691
672
|
);
|
|
692
|
-
error.statusCode = response.
|
|
673
|
+
error.statusCode = response.status;
|
|
693
674
|
throw error;
|
|
694
675
|
}
|
|
695
676
|
}
|
|
@@ -8,6 +8,12 @@ const CONTEXTINFORMERS = Symbol('context informers');
|
|
|
8
8
|
const LOCATION = Symbol('location');
|
|
9
9
|
const PACKAGEJSON = Symbol('package.json');
|
|
10
10
|
|
|
11
|
+
/** @typedef {import('./App').default} App */
|
|
12
|
+
/** @typedef {import('./ConfigManager').default} ConfigManager */
|
|
13
|
+
/** @typedef {import('./FdtCommand').default} FdtCommand */
|
|
14
|
+
|
|
15
|
+
/** @typedef {(request: AskNicelyRequest, response: FdtResponse) => void} ContextInformer */
|
|
16
|
+
|
|
11
17
|
/**
|
|
12
18
|
* The unified API for registering module functionality with the FDT instance. The callback exposed
|
|
13
19
|
* by a module will get an instance of ModuleRegistrationApi to register itself with.
|
|
@@ -22,16 +28,21 @@ export default class ModuleRegistrationApi {
|
|
|
22
28
|
* @constructor
|
|
23
29
|
*/
|
|
24
30
|
constructor(app, moduleLocation) {
|
|
31
|
+
/** @type {App} */
|
|
25
32
|
this[APP] = app;
|
|
26
33
|
|
|
34
|
+
/** @type {string} */
|
|
27
35
|
this[LOCATION] = moduleLocation;
|
|
28
36
|
|
|
37
|
+
/** @type {{ name: string, version?: string, description?: string }} */
|
|
29
38
|
this[PACKAGEJSON] = JSON.parse(
|
|
30
39
|
readFileSync(path.join(this[LOCATION], 'package.json'), 'utf-8')
|
|
31
40
|
);
|
|
32
41
|
|
|
42
|
+
/** @type {ContextInformer[]} */
|
|
33
43
|
this[CONTEXTINFORMERS] = [];
|
|
34
44
|
|
|
45
|
+
/** @type {boolean} */
|
|
35
46
|
this.hidden = false;
|
|
36
47
|
|
|
37
48
|
Object.assign(this, ask);
|
|
@@ -40,9 +51,9 @@ export default class ModuleRegistrationApi {
|
|
|
40
51
|
/**
|
|
41
52
|
* Should not be called by a module. Loads and evaluates the Javascript code belonging to a module.
|
|
42
53
|
*
|
|
43
|
-
* @param {
|
|
54
|
+
* @param {...any} extraArguments
|
|
44
55
|
*/
|
|
45
|
-
async load(...
|
|
56
|
+
async load(...extraArguments) {
|
|
46
57
|
const defaultExport = (
|
|
47
58
|
await import(pathToFileURL(path.join(this[LOCATION], 'index.js')))
|
|
48
59
|
).default;
|
|
@@ -51,7 +62,7 @@ export default class ModuleRegistrationApi {
|
|
|
51
62
|
throw new Error(`${this[PACKAGEJSON].name} is not a function.`);
|
|
52
63
|
}
|
|
53
64
|
|
|
54
|
-
defaultExport(this, ...
|
|
65
|
+
await defaultExport(this, ...extraArguments);
|
|
55
66
|
}
|
|
56
67
|
|
|
57
68
|
/**
|
|
@@ -59,7 +70,7 @@ export default class ModuleRegistrationApi {
|
|
|
59
70
|
*
|
|
60
71
|
* @see App#getInfo
|
|
61
72
|
*
|
|
62
|
-
* @return {
|
|
73
|
+
* @return {{name: string, version?: string}} The app information.
|
|
63
74
|
*/
|
|
64
75
|
getAppInfo() {
|
|
65
76
|
return this[APP].getInfo();
|
|
@@ -68,7 +79,7 @@ export default class ModuleRegistrationApi {
|
|
|
68
79
|
/**
|
|
69
80
|
* Returns metadata about the module that is being registered.
|
|
70
81
|
*
|
|
71
|
-
* @return {{name, version, builtIn, description, path}} The module information.
|
|
82
|
+
* @return {{name: string, version?: string, builtIn: boolean, description?: string, path: string}} The module information.
|
|
72
83
|
*/
|
|
73
84
|
getInfo() {
|
|
74
85
|
return {
|
|
@@ -80,15 +91,28 @@ export default class ModuleRegistrationApi {
|
|
|
80
91
|
};
|
|
81
92
|
}
|
|
82
93
|
|
|
94
|
+
/**
|
|
95
|
+
* Retrieve the path to a registered module by its name.
|
|
96
|
+
*
|
|
97
|
+
* NOTE: Only paths to modules loaded earlier than the current module can be looked up.
|
|
98
|
+
*
|
|
99
|
+
* @param {string} moduleName The name of the module (see its package.json).
|
|
100
|
+
*
|
|
101
|
+
* @return {(string|undefined)}
|
|
102
|
+
*/
|
|
103
|
+
getPathToModule(moduleName) {
|
|
104
|
+
return this[APP].getPathToModule(moduleName);
|
|
105
|
+
}
|
|
106
|
+
|
|
83
107
|
/**
|
|
84
108
|
* Adds a command to the root of the FDT instance.
|
|
85
109
|
*
|
|
86
110
|
* @see FdtCommand#addCommand
|
|
87
111
|
*
|
|
88
112
|
* @param {string} commandName
|
|
89
|
-
* @param {string|
|
|
113
|
+
* @param {string|(request: AskNicelyRequest, response: FdtResponse) => (void | Promise<void>)} [controller]
|
|
90
114
|
*
|
|
91
|
-
* @return {
|
|
115
|
+
* @return {FdtCommand} The command object that was created.
|
|
92
116
|
*/
|
|
93
117
|
registerCommand(commandName, controller) {
|
|
94
118
|
const command = this[APP].cli.addCommand(commandName, controller);
|
|
@@ -102,9 +126,9 @@ export default class ModuleRegistrationApi {
|
|
|
102
126
|
* @see FdtCommand#addHiddenCommand
|
|
103
127
|
*
|
|
104
128
|
* @param {string} commandName
|
|
105
|
-
* @param {string|
|
|
129
|
+
* @param {string|(request: AskNicelyRequest, response: FdtResponse) => (void | Promise<void>)} [controller]
|
|
106
130
|
*
|
|
107
|
-
* @return {
|
|
131
|
+
* @return {FdtCommand} The command object that was created.
|
|
108
132
|
*/
|
|
109
133
|
registerHiddenCommand(commandName, controller) {
|
|
110
134
|
const command = this[APP].cli.addHiddenCommand(commandName, controller);
|
|
@@ -117,11 +141,13 @@ export default class ModuleRegistrationApi {
|
|
|
117
141
|
*
|
|
118
142
|
* @see ConfigManager#registerConfiguration
|
|
119
143
|
*
|
|
144
|
+
* @template {*} [TValue=*]
|
|
145
|
+
*
|
|
120
146
|
* @param {string} configName
|
|
121
|
-
* @param {
|
|
122
|
-
* @param {*|
|
|
147
|
+
* @param {TValue} defaultValue
|
|
148
|
+
* @param {*|((config: TValue) => * | null)} [serialize]
|
|
123
149
|
*
|
|
124
|
-
* @return {
|
|
150
|
+
* @return {TValue} The configuration value.
|
|
125
151
|
*/
|
|
126
152
|
registerConfiguration(configName, defaultValue, serialize) {
|
|
127
153
|
return this[APP].config.registerConfig(
|
|
@@ -134,9 +160,11 @@ export default class ModuleRegistrationApi {
|
|
|
134
160
|
/**
|
|
135
161
|
* Get the registered configuration.
|
|
136
162
|
*
|
|
163
|
+
* @template {*} [TValue=*]
|
|
164
|
+
*
|
|
137
165
|
* @param {string} configName
|
|
138
166
|
*
|
|
139
|
-
* @return {
|
|
167
|
+
* @return {TValue} The configuration value.
|
|
140
168
|
*/
|
|
141
169
|
getConfiguration(configName) {
|
|
142
170
|
return this[APP].config[configName];
|
|
@@ -146,9 +174,9 @@ export default class ModuleRegistrationApi {
|
|
|
146
174
|
* Register a subcontroller to render additional info provided by a module in the "who" command
|
|
147
175
|
* provided by FDT.
|
|
148
176
|
*
|
|
149
|
-
* @param {
|
|
177
|
+
* @param {ContextInformer} contextInformer
|
|
150
178
|
*
|
|
151
|
-
* @return {
|
|
179
|
+
* @return {ContextInformer} The context informer.
|
|
152
180
|
*/
|
|
153
181
|
registerContextInformer(contextInformer) {
|
|
154
182
|
this[CONTEXTINFORMERS].push(contextInformer);
|
|
@@ -159,7 +187,7 @@ export default class ModuleRegistrationApi {
|
|
|
159
187
|
/**
|
|
160
188
|
* Should not be called by a module. Return the list of context informers registered by this module.
|
|
161
189
|
*
|
|
162
|
-
* @return {
|
|
190
|
+
* @return {ContextInformer[]} The context informers.
|
|
163
191
|
*/
|
|
164
192
|
getContextInformers() {
|
|
165
193
|
return this[CONTEXTINFORMERS].slice(0);
|
|
@@ -16,6 +16,14 @@ export default async function addCoreModulesToApp(app, options) {
|
|
|
16
16
|
);
|
|
17
17
|
coreModule.hidden = true;
|
|
18
18
|
|
|
19
|
+
// Load the shared module and hide it from listing.
|
|
20
|
+
const sharedModule = await app.enableBuiltInModule(
|
|
21
|
+
path.join(__dirname, 'modules', 'shared'),
|
|
22
|
+
app,
|
|
23
|
+
options
|
|
24
|
+
);
|
|
25
|
+
sharedModule.hidden = true;
|
|
26
|
+
|
|
19
27
|
// Load modules from configuration dot-rc file.
|
|
20
28
|
(Array.isArray(moduleConfig) ? moduleConfig : []).map((modulePath) => {
|
|
21
29
|
try {
|