@fontoxml/fontoxml-development-tools 3.10.0 → 3.12.0-beta.1

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.
Files changed (206) hide show
  1. package/npm-shrinkwrap.json +3842 -8330
  2. package/package.json +13 -19
  3. package/src/App.js +1 -1
  4. package/src/FdtCommand.js +3 -3
  5. package/src/FdtLicense.js +95 -114
  6. package/src/ModuleRegistrationApi.js +44 -16
  7. package/src/addCoreModulesToApp.js +8 -0
  8. package/src/editorVersions.js +19 -5
  9. package/src/modules/connectors/index.js +109 -16
  10. package/src/modules/connectors/instanceBuild/Dockerfile.build +1 -1
  11. package/src/modules/connectors/instanceBuild/Dockerfile.run +1 -1
  12. package/src/modules/connectors/instanceDevBuild/docker-compose.yml +2 -2
  13. package/src/modules/content-quality/index.js +101 -20
  14. package/src/modules/content-quality/instanceBuild/Dockerfile +1 -1
  15. package/src/modules/content-quality/instanceDevBuild/docker-compose.yml +1 -1
  16. package/src/modules/core/src/precontroller.help.js +23 -26
  17. package/src/modules/document-history/index.js +101 -20
  18. package/src/modules/document-history/instanceBuild/Dockerfile +1 -1
  19. package/src/modules/document-history/instanceDevBuild/docker-compose.yml +1 -1
  20. package/src/modules/editor/dev-cms/connectors-cms-standard/configureConnectorsCmsStandardDocumentRouter.js +10 -0
  21. package/src/modules/editor/dev-cms/connectors-cms-standard/configureDocumentHistoryGetPostRouteHandler.js +51 -0
  22. package/src/modules/editor/dev-cms/connectors-cms-standard/configureDocumentPostRouteHandler.js +65 -76
  23. package/src/modules/editor/dev-cms/connectors-cms-standard/configureDocumentPresearchPostRouteHandler.js +10 -7
  24. package/src/modules/editor/dev-cms/connectors-cms-standard/configureDocumentPreviewRouteHandler.js +10 -0
  25. package/src/modules/editor/dev-cms/connectors-cms-standard/configureDocumentRevisionGetPostRouteHandler.js +69 -0
  26. package/src/modules/editor/src/commands/command.convert.editor.controller.js +11 -4
  27. package/src/modules/editor/src/commands/command.convert.package.controller.js +11 -4
  28. package/src/modules/editor/src/getAppManifest.js +3 -3
  29. package/src/modules/editor/src/getWebpackConfig.js +13 -0
  30. package/src/modules/editor/src/webpackPlugins/CheckDeepImportsResolvePlugin.js +4 -0
  31. package/src/modules/editor-pre-7-7-0/src/api/downloadEditorSDK.js +16 -12
  32. package/src/modules/editor-pre-7-7-0/src/api/executeAndLog.js +3 -2
  33. package/src/modules/editor-pre-7-7-0/src/api/init/createConfigConfiguration.js +86 -48
  34. package/src/modules/editor-pre-7-7-0/src/api/schema/compile.js +16 -22
  35. package/src/modules/editor-pre-7-7-0/src/api/schema/createSchemaPackages.js +8 -0
  36. package/src/modules/editor-pre-7-7-0/src/api/schema/getSchemaFontoJson.js +76 -48
  37. package/src/modules/editor-pre-7-7-0/src/api/schema/zipHelpers.js +6 -1
  38. package/src/modules/editor-pre-7-7-0/src/command.schema.compile.controller.js +51 -2
  39. package/src/modules/editor-pre-7-7-0/test/api/init/createConfigConfiguration.test.js +71 -33
  40. package/src/modules/editor-pre-7-7-0/test/api/init/fixtures/configjs-7160.js +45 -0
  41. package/src/modules/editor-pre-7-7-0/test/api/init/fixtures/configjs-800.js +45 -0
  42. package/src/modules/editor-pre-7-7-0/test/api/init/fixtures/configjs-810.js +32 -0
  43. package/src/modules/editor-pre-7-7-0/test/api/schema/buildSchemaExperienceConfigurationModel.test.js +70 -79
  44. package/src/modules/editor-pre-7-7-0/test/api/schema/fixtures/dita-example-schema-bundle/listOfFiles.json +1 -36
  45. package/src/modules/editor-pre-7-7-0/test/api/schema/fixtures/invalid-fonto-json/fonto.json +1 -0
  46. package/src/modules/editor-pre-7-7-0/test/api/schema/getSchemaFontoJson.test.js +174 -0
  47. package/src/modules/editor-pre-7-7-0/test/api/schema/zipSchemaSource.test.js +10 -4
  48. package/src/modules/editor-pre-7-7-0/test/schemaCompileController.test.js +205 -0
  49. package/src/modules/localization/index.js +2 -2
  50. package/src/modules/operations/src/api/getOperations.js +3 -3
  51. package/src/modules/review/index.js +103 -18
  52. package/src/modules/review/instanceBuild/Dockerfile +1 -1
  53. package/src/modules/review/instanceDevBuild/docker-compose.yml +1 -1
  54. package/src/modules/schema/src/api/getSchemaSummaries.js +2 -2
  55. package/src/modules/schema/test/getSchemaSummaries.test.js +14 -10
  56. package/src/modules/schema-compiler/index.js +99 -18
  57. package/src/modules/schema-compiler/instanceBuild/Dockerfile +1 -1
  58. package/src/modules/schema-compiler/instanceDevBuild/docker-compose.yml +1 -1
  59. package/src/modules/shared/index.js +3 -0
  60. package/src/modules/shared/package.json +14 -0
  61. package/src/modules/shared/src/addBackendDockerCommands.js +334 -0
  62. package/src/modules/shared/src/addBackendDownloadSelfContainedCommands.js +78 -0
  63. package/src/modules/shared/src/addBackendVersionsCommands.js +55 -0
  64. package/src/modules/shared/src/controller-templates/command.backend.build.controller.factory.js +273 -0
  65. package/src/modules/shared/src/controller-templates/command.backend.download-self-contained.controller.factory.js +131 -0
  66. package/src/modules/shared/src/controller-templates/command.backend.init.controller.factory.js +88 -0
  67. package/src/modules/shared/src/controller-templates/command.backend.run.controller.factory.js +420 -0
  68. package/src/modules/shared/src/controller-templates/command.backend.upgrade.controller.factory.js +79 -0
  69. package/src/modules/shared/src/controller-templates/command.backend.versions.controller.factory.js +23 -0
  70. package/src/modules/shared/src/controller-templates/docker/BackendManifest.js +42 -0
  71. package/src/modules/shared/src/controller-templates/docker/copyWhitelistedFiles.js +23 -0
  72. package/src/modules/shared/src/controller-templates/docker/dockerCleanup.js +146 -0
  73. package/src/modules/shared/src/controller-templates/docker/tryDockerLogout.js +31 -0
  74. package/src/modules/shared/src/controller-templates/docker/validateBackendInstance.js +48 -0
  75. package/src/modules/shared/src/ensureDockerCommands.js +61 -0
  76. package/src/modules/shared/src/executeAndLog.js +113 -0
  77. package/src/modules/{review/src/utilities/setEntryVisibility.js → shared/src/setFileVisibility.js} +8 -2
  78. package/src/modules/spell-checker/index.js +101 -18
  79. package/src/modules/spell-checker/instanceBuild/Dockerfile +1 -1
  80. package/src/modules/spell-checker/instanceDevBuild/docker-compose.yml +1 -1
  81. package/test/module.shared.test.js +81 -0
  82. package/src/modules/connectors/src/command.build.controller.js +0 -256
  83. package/src/modules/connectors/src/command.build.js +0 -54
  84. package/src/modules/connectors/src/command.download-self-contained.controller.js +0 -110
  85. package/src/modules/connectors/src/command.download-self-contained.js +0 -50
  86. package/src/modules/connectors/src/command.init.controller.js +0 -91
  87. package/src/modules/connectors/src/command.init.js +0 -42
  88. package/src/modules/connectors/src/command.run.controller.js +0 -462
  89. package/src/modules/connectors/src/command.run.js +0 -67
  90. package/src/modules/connectors/src/command.upgrade.controller.js +0 -52
  91. package/src/modules/connectors/src/command.upgrade.js +0 -42
  92. package/src/modules/connectors/src/command.versions.controller.js +0 -14
  93. package/src/modules/connectors/src/command.versions.js +0 -25
  94. package/src/modules/connectors/src/utilities/FontoxmlConnectorsManifest.js +0 -32
  95. package/src/modules/connectors/src/utilities/cleanup.js +0 -70
  96. package/src/modules/connectors/src/utilities/constants.js +0 -42
  97. package/src/modules/connectors/src/utilities/copyWhitelistedFiles.js +0 -22
  98. package/src/modules/connectors/src/utilities/executeAndLog.js +0 -63
  99. package/src/modules/connectors/src/utilities/getVerbosityLevel.js +0 -11
  100. package/src/modules/connectors/src/utilities/getWhitelist.js +0 -16
  101. package/src/modules/connectors/src/utilities/setEntryVisibility.js +0 -22
  102. package/src/modules/connectors/src/utilities/validateInstance.js +0 -29
  103. package/src/modules/content-quality/src/command.build.controller.js +0 -260
  104. package/src/modules/content-quality/src/command.build.js +0 -56
  105. package/src/modules/content-quality/src/command.download-self-contained.controller.js +0 -110
  106. package/src/modules/content-quality/src/command.download-self-contained.js +0 -52
  107. package/src/modules/content-quality/src/command.init.controller.js +0 -91
  108. package/src/modules/content-quality/src/command.init.js +0 -44
  109. package/src/modules/content-quality/src/command.run.controller.js +0 -444
  110. package/src/modules/content-quality/src/command.run.js +0 -64
  111. package/src/modules/content-quality/src/command.upgrade.controller.js +0 -52
  112. package/src/modules/content-quality/src/command.upgrade.js +0 -44
  113. package/src/modules/content-quality/src/command.versions.controller.js +0 -14
  114. package/src/modules/content-quality/src/command.versions.js +0 -25
  115. package/src/modules/content-quality/src/utilities/FontoxmlFcqManifest.js +0 -30
  116. package/src/modules/content-quality/src/utilities/cleanup.js +0 -70
  117. package/src/modules/content-quality/src/utilities/constants.js +0 -44
  118. package/src/modules/content-quality/src/utilities/copyWhitelistedFiles.js +0 -22
  119. package/src/modules/content-quality/src/utilities/executeAndLog.js +0 -63
  120. package/src/modules/content-quality/src/utilities/getVerbosityLevel.js +0 -11
  121. package/src/modules/content-quality/src/utilities/getWhitelist.js +0 -16
  122. package/src/modules/content-quality/src/utilities/setEntryVisibility.js +0 -22
  123. package/src/modules/content-quality/src/utilities/validateInstance.js +0 -29
  124. package/src/modules/document-history/src/command.build.controller.js +0 -260
  125. package/src/modules/document-history/src/command.build.js +0 -56
  126. package/src/modules/document-history/src/command.download-self-contained.controller.js +0 -110
  127. package/src/modules/document-history/src/command.download-self-contained.js +0 -50
  128. package/src/modules/document-history/src/command.init.controller.js +0 -91
  129. package/src/modules/document-history/src/command.init.js +0 -44
  130. package/src/modules/document-history/src/command.run.controller.js +0 -444
  131. package/src/modules/document-history/src/command.run.js +0 -64
  132. package/src/modules/document-history/src/command.upgrade.controller.js +0 -52
  133. package/src/modules/document-history/src/command.upgrade.js +0 -44
  134. package/src/modules/document-history/src/command.versions.controller.js +0 -14
  135. package/src/modules/document-history/src/command.versions.js +0 -25
  136. package/src/modules/document-history/src/utilities/FontoxmlFdhManifest.js +0 -30
  137. package/src/modules/document-history/src/utilities/cleanup.js +0 -70
  138. package/src/modules/document-history/src/utilities/constants.js +0 -44
  139. package/src/modules/document-history/src/utilities/copyWhitelistedFiles.js +0 -22
  140. package/src/modules/document-history/src/utilities/executeAndLog.js +0 -63
  141. package/src/modules/document-history/src/utilities/getVerbosityLevel.js +0 -11
  142. package/src/modules/document-history/src/utilities/getWhitelist.js +0 -16
  143. package/src/modules/document-history/src/utilities/setEntryVisibility.js +0 -22
  144. package/src/modules/document-history/src/utilities/validateInstance.js +0 -29
  145. package/src/modules/review/src/command.build.controller.js +0 -256
  146. package/src/modules/review/src/command.build.js +0 -54
  147. package/src/modules/review/src/command.download-self-contained.controller.js +0 -107
  148. package/src/modules/review/src/command.download-self-contained.js +0 -50
  149. package/src/modules/review/src/command.init.controller.js +0 -89
  150. package/src/modules/review/src/command.init.js +0 -42
  151. package/src/modules/review/src/command.run.controller.js +0 -428
  152. package/src/modules/review/src/command.run.js +0 -60
  153. package/src/modules/review/src/command.upgrade.controller.js +0 -59
  154. package/src/modules/review/src/command.upgrade.js +0 -42
  155. package/src/modules/review/src/command.versions.controller.js +0 -12
  156. package/src/modules/review/src/command.versions.js +0 -25
  157. package/src/modules/review/src/utilities/FontoxmlReviewManifest.js +0 -30
  158. package/src/modules/review/src/utilities/cleanup.js +0 -70
  159. package/src/modules/review/src/utilities/constants.js +0 -42
  160. package/src/modules/review/src/utilities/copyWhitelistedFiles.js +0 -22
  161. package/src/modules/review/src/utilities/executeAndLog.js +0 -63
  162. package/src/modules/review/src/utilities/getVerbosityLevel.js +0 -11
  163. package/src/modules/review/src/utilities/getWhitelist.js +0 -16
  164. package/src/modules/review/src/utilities/validateInstance.js +0 -45
  165. package/src/modules/schema-compiler/src/command.build.controller.js +0 -256
  166. package/src/modules/schema-compiler/src/command.build.js +0 -54
  167. package/src/modules/schema-compiler/src/command.download-self-contained.controller.js +0 -110
  168. package/src/modules/schema-compiler/src/command.download-self-contained.js +0 -50
  169. package/src/modules/schema-compiler/src/command.init.controller.js +0 -91
  170. package/src/modules/schema-compiler/src/command.init.js +0 -42
  171. package/src/modules/schema-compiler/src/command.run.controller.js +0 -430
  172. package/src/modules/schema-compiler/src/command.run.js +0 -60
  173. package/src/modules/schema-compiler/src/command.upgrade.controller.js +0 -64
  174. package/src/modules/schema-compiler/src/command.upgrade.js +0 -42
  175. package/src/modules/schema-compiler/src/command.versions.controller.js +0 -14
  176. package/src/modules/schema-compiler/src/command.versions.js +0 -25
  177. package/src/modules/schema-compiler/src/utilities/FontoxmlSchemaCompilerManifest.js +0 -32
  178. package/src/modules/schema-compiler/src/utilities/cleanup.js +0 -70
  179. package/src/modules/schema-compiler/src/utilities/constants.js +0 -43
  180. package/src/modules/schema-compiler/src/utilities/copyWhitelistedFiles.js +0 -22
  181. package/src/modules/schema-compiler/src/utilities/executeAndLog.js +0 -63
  182. package/src/modules/schema-compiler/src/utilities/getVerbosityLevel.js +0 -11
  183. package/src/modules/schema-compiler/src/utilities/getWhitelist.js +0 -16
  184. package/src/modules/schema-compiler/src/utilities/setEntryVisibility.js +0 -22
  185. package/src/modules/schema-compiler/src/utilities/validateInstance.js +0 -47
  186. package/src/modules/spell-checker/src/command.build.controller.js +0 -257
  187. package/src/modules/spell-checker/src/command.build.js +0 -54
  188. package/src/modules/spell-checker/src/command.download-self-contained.controller.js +0 -110
  189. package/src/modules/spell-checker/src/command.download-self-contained.js +0 -50
  190. package/src/modules/spell-checker/src/command.init.controller.js +0 -91
  191. package/src/modules/spell-checker/src/command.init.js +0 -42
  192. package/src/modules/spell-checker/src/command.run.controller.js +0 -430
  193. package/src/modules/spell-checker/src/command.run.js +0 -62
  194. package/src/modules/spell-checker/src/command.upgrade.controller.js +0 -61
  195. package/src/modules/spell-checker/src/command.upgrade.js +0 -42
  196. package/src/modules/spell-checker/src/command.versions.controller.js +0 -14
  197. package/src/modules/spell-checker/src/command.versions.js +0 -25
  198. package/src/modules/spell-checker/src/utilities/FontoxmlSpellCheckerManifest.js +0 -32
  199. package/src/modules/spell-checker/src/utilities/cleanup.js +0 -70
  200. package/src/modules/spell-checker/src/utilities/constants.js +0 -42
  201. package/src/modules/spell-checker/src/utilities/copyWhitelistedFiles.js +0 -22
  202. package/src/modules/spell-checker/src/utilities/executeAndLog.js +0 -63
  203. package/src/modules/spell-checker/src/utilities/getVerbosityLevel.js +0 -11
  204. package/src/modules/spell-checker/src/utilities/getWhitelist.js +0 -16
  205. package/src/modules/spell-checker/src/utilities/setEntryVisibility.js +0 -22
  206. package/src/modules/spell-checker/src/utilities/validateInstance.js +0 -47
@@ -1,50 +0,0 @@
1
- import path from 'path';
2
- import { fileURLToPath } from 'url';
3
-
4
- const __filename = fileURLToPath(import.meta.url);
5
- const __dirname = path.dirname(__filename);
6
-
7
- export default (moduleRegistration, reviewCommand) => {
8
- reviewCommand
9
- .addCommand(
10
- 'download-self-contained',
11
- path.resolve(
12
- __dirname,
13
- 'command.download-self-contained.controller.js'
14
- )
15
- )
16
- .addAlias('dsc')
17
- .setDescription('Downloads a self-contained build.')
18
-
19
- .addOption(
20
- 'location',
21
- 'l',
22
- 'The directory where to save the self-contained build. If not set this defaults to the current working directory.',
23
- false
24
- )
25
- .addOption(
26
- 'runtime',
27
- null,
28
- 'The runtime to download. Supported values: linux-x64, win-x64.',
29
- true
30
- )
31
- .addOption(
32
- 'version',
33
- null,
34
- 'The version to download. Can be either a specific version or "nightly". Be warned: nightly can be unstable or may not work at all.',
35
- true
36
- )
37
-
38
- .addExample(
39
- `${
40
- moduleRegistration.getAppInfo().name
41
- } review download-self-contained --runtime linux-x64 --version x.x.x`,
42
- `Download the linux-x64 self-contained build into the current working directory.`
43
- )
44
- .addExample(
45
- `${
46
- moduleRegistration.getAppInfo().name
47
- } review download-self-contained --runtime linux-x64 --version x.x.x --location /opt/my-instance/`,
48
- 'Download the linux-x64 self-contained build into "/opt/my-instance/".'
49
- );
50
- };
@@ -1,89 +0,0 @@
1
- import fs from 'fs-extra';
2
- import path from 'path';
3
-
4
- import constants from './utilities/constants.js';
5
- import FontoxmlReviewManifest from './utilities/FontoxmlReviewManifest.js';
6
- import setEntryVisibility from './utilities/setEntryVisibility.js';
7
-
8
- export default async function initCommand(req, res) {
9
- res.caption(req.command.getLongName());
10
-
11
- // Check if the version exists.
12
- const sdkVersions = await req.fdt.license.getVersionsForProduct('review');
13
- const version = req.options.version;
14
- if (!sdkVersions.includes(version)) {
15
- throw new Error(
16
- `Could not initialize for version (${version}), please check if it is a valid version. The latest version is ${sdkVersions.getLatestStable()}, run \`fdt review versions\` to get a list of all available versions.`
17
- );
18
- }
19
-
20
- const directoryPath = path.resolve(
21
- req.options.location ? req.options.location : process.cwd()
22
- );
23
- return fs
24
- .exists(directoryPath)
25
- .then((exists) => {
26
- if (!exists) {
27
- // Create the directory if it does not exist.
28
- return fs.ensureDir(directoryPath);
29
- }
30
- // Ensure the directory is empty if it does exist.
31
- return fs.readdir(directoryPath).then((files) => {
32
- if (files.length) {
33
- throw new Error(
34
- `The directory "${directoryPath}" is not empty.`
35
- );
36
- }
37
- });
38
- })
39
- .then(() => {
40
- const destroySpinner = res.spinner(
41
- `Initializing a Fonto Review instance at "${directoryPath}"...`
42
- );
43
- return fs
44
- .copy(
45
- constants.INSTANCE_TEMPLATE_DIRECTORY_PATH,
46
- directoryPath,
47
- {
48
- filter: (src, _dest) => {
49
- const filename = path.basename(src);
50
- return filename !== '.gitkeep';
51
- },
52
- }
53
- )
54
- .then(() => {
55
- const data = new FontoxmlReviewManifest(version);
56
- const manifest = path.join(
57
- directoryPath,
58
- constants.MANIFEST_FILENAME
59
- );
60
-
61
- return fs
62
- .writeJson(manifest, data)
63
- .then(() => setEntryVisibility(manifest, false));
64
- })
65
- .catch((error) => {
66
- return fs.emptyDir(directoryPath).then(() => {
67
- destroySpinner();
68
- throw error;
69
- });
70
- })
71
- .then(() =>
72
- req.fdt.license.sendTelemetry({
73
- product: req.command.parent.name,
74
- type: 'docker',
75
- version,
76
- action: req.command.name,
77
- })
78
- )
79
- .then(() => destroySpinner());
80
- })
81
- .then(() => {
82
- res.log(
83
- 'Complete the configuration before building or running the instance.'
84
- );
85
- res.log(
86
- `See ${constants.DOCUMENTATION_GETTING_STARTED_GUIDE} for more information.`
87
- );
88
- });
89
- }
@@ -1,42 +0,0 @@
1
- import path from 'path';
2
- import { fileURLToPath } from 'url';
3
-
4
- const __filename = fileURLToPath(import.meta.url);
5
- const __dirname = path.dirname(__filename);
6
-
7
- export default (moduleRegistration, reviewCommand) => {
8
- reviewCommand
9
- .addCommand(
10
- 'init',
11
- path.resolve(__dirname, 'command.init.controller.js')
12
- )
13
- .setDescription(
14
- 'Initialize a Fonto Review instance in an empty or nonexistent directory.'
15
- )
16
-
17
- .addOption(
18
- 'location',
19
- 'l',
20
- 'The directory where to initialize. If not set this defaults to the current working directory. Note that the directory has to empty or nonexistent.',
21
- false
22
- )
23
- .addOption(
24
- 'version',
25
- null,
26
- 'The version to initialize with. Can be either a specific version or "nightly". Be warned: nightly can be unstable or may not work at all.',
27
- true
28
- )
29
-
30
- .addExample(
31
- `${
32
- moduleRegistration.getAppInfo().name
33
- } review init --version x.x.x`,
34
- 'Initialize a new Fonto Review instance located at the current working directory.'
35
- )
36
- .addExample(
37
- `${
38
- moduleRegistration.getAppInfo().name
39
- } review init --location /opt/my-instance/ --version x.x.x`,
40
- 'Initialize a new Fonto Review instance located at "/opt/my-instance/".'
41
- );
42
- };
@@ -1,428 +0,0 @@
1
- import fs from 'fs-extra';
2
- import os from 'os';
3
- import path from 'path';
4
-
5
- import cleanup from './utilities/cleanup.js';
6
- import constants from './utilities/constants.js';
7
- import copyWhitelistedFiles from './utilities/copyWhitelistedFiles.js';
8
- import executeAndLog from './utilities/executeAndLog.js';
9
- import FontoxmlReviewManifest from './utilities/FontoxmlReviewManifest.js';
10
- import getVerbosityLevel from './utilities/getVerbosityLevel.js';
11
- import getWhitelist from './utilities/getWhitelist.js';
12
- import setEntryVisibility from './utilities/setEntryVisibility.js';
13
- import validateInstance from './utilities/validateInstance.js';
14
-
15
- const verboseReviewConfigurationEntries = {
16
- Logging__LogLevel__Default: 'Trace',
17
- };
18
-
19
- const DEFAULT_PORT = 6020;
20
-
21
- function copyReviewConfiguration(
22
- reviewConfiguration,
23
- tempDir,
24
- verbosityLevel,
25
- res
26
- ) {
27
- const targetReviewConfiguration = path.join(tempDir, '.env');
28
-
29
- return fs.exists(reviewConfiguration).then((exists) => {
30
- // Read the configuration entries from the .env file or initialize an empty array.
31
- let deferred = exists
32
- ? fs.readFile(reviewConfiguration, 'utf8').then((data) => {
33
- return data.split(/\r?\n/g);
34
- })
35
- : new Promise((resolve, _reject) => {
36
- resolve(new Array(0));
37
- });
38
-
39
- // Replace or set the defaults for verbosity.
40
- if (verbosityLevel === constants.VERBOSITY_LEVEL_DEBUG) {
41
- deferred = deferred.then((configurationEntries) => {
42
- Object.keys(verboseReviewConfigurationEntries).forEach(
43
- (key) => {
44
- const configurationEntryIndex =
45
- configurationEntries.findIndex((entry) =>
46
- entry.startsWith(`${key}=`)
47
- );
48
- const value = verboseReviewConfigurationEntries[key];
49
- if (configurationEntryIndex === -1) {
50
- configurationEntries.push(`${key}=${value}`);
51
- } else {
52
- configurationEntries[
53
- configurationEntryIndex
54
- ] = `${key}=${value}`;
55
- }
56
- }
57
- );
58
- return configurationEntries;
59
- });
60
- }
61
-
62
- // Ignore options that shouldn't be applied when running through FDT.
63
- deferred = deferred.then((configurationEntries) => {
64
- let i = configurationEntries.length;
65
- while (i--) {
66
- const configurationLine = configurationEntries[i];
67
- if (
68
- !configurationLine.startsWith('#') &&
69
- configurationLine.indexOf('=') !== -1
70
- ) {
71
- const [key, _value] = configurationLine.split('=', 2);
72
-
73
- if (key === 'ASPNETCORE_URLS') {
74
- configurationEntries.splice(i, 1);
75
- res.notice(
76
- `Notice: The '${key}' configuration option in the '.env' file will be ignored when ` +
77
- "running the application using FDT. The FDT '--port' option can be used to run the application " +
78
- 'under a different port.'
79
- );
80
- }
81
- }
82
- }
83
- return configurationEntries;
84
- });
85
-
86
- // Write the configuration to the .env file.
87
- return deferred.then((configurationEntries) => {
88
- const configurationData = configurationEntries.join(os.EOL);
89
- return fs.writeFile(
90
- targetReviewConfiguration,
91
- configurationData,
92
- 'utf8'
93
- );
94
- });
95
- });
96
- }
97
-
98
- export default function runCommand(req, res) {
99
- res.caption(req.command.getLongName());
100
-
101
- const directoryPath = path.resolve(
102
- req.options.location ? req.options.location : process.cwd()
103
- );
104
- const temporaryDirectoryPath = path.join(
105
- directoryPath,
106
- constants.TEMPORARY_DIRECTORY_NAME
107
- );
108
- const reviewConfigurationFilePath = req.options['config-location']
109
- ? path.resolve(req.options['config-location'])
110
- : path.join(directoryPath, '.env');
111
- const manifestFilePath = path.join(
112
- directoryPath,
113
- constants.MANIFEST_FILENAME
114
- );
115
- const verbosityLevel = getVerbosityLevel(
116
- req.options.verbose,
117
- req.options.debug
118
- );
119
- const port = req.options.port || DEFAULT_PORT;
120
- const projectName = `${constants.DEFAULT_IMAGE_NAME}_${port}`;
121
-
122
- let pidToKillOnForceExit = null;
123
- const setPidToKillOnForceExit = (processToKill) => {
124
- pidToKillOnForceExit = processToKill && processToKill.pid;
125
- };
126
-
127
- // Ensure we cleanup before exiting.
128
- let stopping = false;
129
- process.on('SIGINT', (_code) => {
130
- if (stopping) {
131
- if (pidToKillOnForceExit) {
132
- process.kill(pidToKillOnForceExit);
133
- }
134
- process.exit();
135
- return;
136
- }
137
-
138
- stopping = true;
139
- res.log('Gracefully stopping... (press Ctrl+C again to force)');
140
- return cleanup(
141
- temporaryDirectoryPath,
142
- projectName,
143
- res,
144
- verbosityLevel
145
- ).then(() => process.exit());
146
- });
147
-
148
- return (
149
- validateInstance(directoryPath)
150
- .then(() => fs.exists(reviewConfigurationFilePath))
151
- .then((exists) => {
152
- if (!exists) {
153
- if (req.options['config-location']) {
154
- throw new Error(
155
- `Fonto Review config "${reviewConfigurationFilePath}" does not exist.`
156
- );
157
- }
158
- res.notice(
159
- `No .env file exists in the directory "${directoryPath}". See ${constants.DOCUMENTATION_CONFIGURATION_GUIDE} to configure the .env file.`
160
- );
161
- }
162
- })
163
- // Cleanup possible remaining resources from a previous build or run.
164
- .then(() =>
165
- cleanup(
166
- temporaryDirectoryPath,
167
- projectName,
168
- res,
169
- verbosityLevel
170
- )
171
- )
172
- .then(() => {
173
- const destroySpinner = res.spinner(
174
- `Building development image at "${directoryPath}"...`
175
- );
176
-
177
- // Retrieve data for the docker image
178
- return FontoxmlReviewManifest.fromJsonFile(
179
- manifestFilePath
180
- ).then((manifestObj) => {
181
- const requestObj = {
182
- review: {
183
- docker: {
184
- version: manifestObj.reviewVersion,
185
- },
186
- },
187
- };
188
-
189
- return req.fdt.license
190
- .getDataForProducts(requestObj)
191
- .catch((error) => {
192
- if (error.statusCode === 404) {
193
- error.solution =
194
- 'This error might be caused by requesting a nonexisting Fonto Review version, please check your version.';
195
- }
196
- throw error;
197
- })
198
- .then((productData) => {
199
- const dockerData =
200
- productData.products.review.docker;
201
-
202
- // Create a hidden temporary directory.
203
- return (
204
- fs
205
- .mkdir(temporaryDirectoryPath)
206
- .then(() =>
207
- setEntryVisibility(
208
- temporaryDirectoryPath,
209
- false
210
- )
211
- )
212
- // Copy the instance files into the temporary directory.
213
- .then(() => {
214
- // Rewrite the version in the Dockerfile.
215
- return fs
216
- .readFile(
217
- path.join(
218
- constants.INSTANCE_BUILD_DIRECTORY_PATH,
219
- 'Dockerfile'
220
- ),
221
- 'utf8'
222
- )
223
- .then((dockerContent) =>
224
- dockerContent.replace(
225
- '${reviewImage}',
226
- dockerData.image
227
- )
228
- )
229
- .then((fixedDockerContent) =>
230
- fs.writeFile(
231
- path.join(
232
- temporaryDirectoryPath,
233
- 'Dockerfile'
234
- ),
235
- fixedDockerContent,
236
- 'utf8'
237
- )
238
- );
239
- })
240
- .then(() =>
241
- fs.copy(
242
- constants.INSTANCE_DEV_BUILD_DIRECTORY_PATH,
243
- temporaryDirectoryPath
244
- )
245
- )
246
- .then(() => {
247
- // Rewrite the port in the docker-compose file.
248
- return fs
249
- .readFile(
250
- path.join(
251
- temporaryDirectoryPath,
252
- 'docker-compose.yml'
253
- ),
254
- 'utf8'
255
- )
256
- .then((dockerComposeContent) =>
257
- dockerComposeContent
258
- .replace(
259
- '${containerName}',
260
- projectName
261
- )
262
- .replace(
263
- '${reviewPort}',
264
- port
265
- )
266
- )
267
- .then((fixedDockerComposeContent) =>
268
- fs.writeFile(
269
- path.join(
270
- temporaryDirectoryPath,
271
- 'docker-compose.yml'
272
- ),
273
- fixedDockerComposeContent,
274
- 'utf8'
275
- )
276
- );
277
- })
278
- .then(() => getWhitelist())
279
- .then((whitelist) =>
280
- copyWhitelistedFiles(
281
- whitelist,
282
- directoryPath,
283
- path.join(
284
- temporaryDirectoryPath,
285
- 'instance'
286
- )
287
- )
288
- )
289
- .then(() =>
290
- copyReviewConfiguration(
291
- reviewConfigurationFilePath,
292
- temporaryDirectoryPath,
293
- verbosityLevel,
294
- res
295
- )
296
- )
297
-
298
- // Pull the docker image
299
- .then(() => {
300
- return executeAndLog(
301
- res,
302
- 'docker',
303
- [
304
- 'login',
305
- dockerData.registry,
306
- '-u',
307
- dockerData.login,
308
- '-p',
309
- dockerData.password,
310
- ],
311
- null,
312
- constants.VERBOSITY_LEVEL_NORMAL,
313
- false,
314
- setPidToKillOnForceExit
315
- )
316
- .then(() =>
317
- executeAndLog(
318
- res,
319
- 'docker',
320
- ['pull', dockerData.image],
321
- null,
322
- verbosityLevel,
323
- false,
324
- setPidToKillOnForceExit
325
- )
326
- )
327
- .then(() =>
328
- executeAndLog(
329
- res,
330
- 'docker',
331
- [
332
- 'logout',
333
- dockerData.registry,
334
- ],
335
- null,
336
- constants.VERBOSITY_LEVEL_NORMAL,
337
- false,
338
- setPidToKillOnForceExit
339
- )
340
- )
341
- .catch(() => {
342
- throw new Error(
343
- 'Failed to retrieve the image file.'
344
- );
345
- });
346
- })
347
-
348
- // Use docker-compose to build the development image.
349
- .then(() =>
350
- executeAndLog(
351
- res,
352
- 'docker-compose',
353
- verbosityLevel ===
354
- constants.VERBOSITY_LEVEL_DEBUG
355
- ? [
356
- '-p',
357
- projectName,
358
- '--verbose',
359
- 'build',
360
- ]
361
- : ['-p', projectName, 'build'],
362
- temporaryDirectoryPath,
363
- verbosityLevel,
364
- false,
365
- setPidToKillOnForceExit
366
- )
367
- )
368
- .then(() =>
369
- req.fdt.license.sendTelemetry({
370
- product: req.command.parent.name,
371
- type: 'docker',
372
- version: manifestObj.reviewVersion,
373
- action: req.command.name,
374
- })
375
- )
376
- .then(() => destroySpinner())
377
- );
378
- });
379
- });
380
- })
381
- // Use docker-compose to run the development image. We hard-code verbose to true since docker does not yet support a --quiet or --silent flag. https://github.com/docker/compose/issues/3447
382
- .then(() => {
383
- res.notice(
384
- `Starting Fonto Review on "http://localhost:${port}"...`
385
- );
386
- return executeAndLog(
387
- res,
388
- 'docker-compose',
389
- verbosityLevel === constants.VERBOSITY_LEVEL_DEBUG
390
- ? ['-p', projectName, '--verbose', 'up']
391
- : ['-p', projectName, 'up'],
392
- temporaryDirectoryPath,
393
- verbosityLevel,
394
- true,
395
- setPidToKillOnForceExit
396
- );
397
- })
398
- // Cleanup temporary directory.
399
- .then(() =>
400
- cleanup(
401
- temporaryDirectoryPath,
402
- projectName,
403
- res,
404
- verbosityLevel
405
- )
406
- )
407
- .catch((error) => {
408
- if (!stopping) {
409
- res.notice(
410
- `See our documentation at ${constants.DOCUMENTATION_EXECUTE_ERROR} for help.`
411
- );
412
- }
413
-
414
- return cleanup(
415
- temporaryDirectoryPath,
416
- projectName,
417
- res,
418
- verbosityLevel
419
- )
420
- .then(() => {
421
- throw error;
422
- })
423
- .catch(() => {
424
- throw error;
425
- });
426
- })
427
- );
428
- }
@@ -1,60 +0,0 @@
1
- import path from 'path';
2
- import { fileURLToPath } from 'url';
3
-
4
- import constants from './utilities/constants.js';
5
-
6
- const __filename = fileURLToPath(import.meta.url);
7
- const __dirname = path.dirname(__filename);
8
-
9
- export default (moduleRegistration, reviewCommand) => {
10
- reviewCommand
11
- .addCommand('run', path.resolve(__dirname, 'command.run.controller.js'))
12
- .setDescription(
13
- 'Run a Fonto Review instance for development purposes. Requires Docker to be installed.'
14
- )
15
-
16
- .addOption(
17
- 'port',
18
- 'p',
19
- 'Listen on the specified port instead of listening on the default port (default=6020).'
20
- )
21
-
22
- .addOption(
23
- 'location',
24
- 'l',
25
- 'The directory where the instance is located.',
26
- false
27
- )
28
- .addOption(
29
- 'config-location',
30
- 'c',
31
- `The path where the configuration file (.env) is located. Information about the .env file can be found at ${constants.DOCUMENTATION_CONFIGURATION_GUIDE}.`,
32
- false
33
- )
34
-
35
- .addOption(
36
- 'verbose',
37
- null,
38
- 'Output default stdout and stderr information.'
39
- )
40
- .addOption(
41
- 'debug',
42
- null,
43
- 'Output all debug information. This also overrides the Logging__LogLevel__Default if set.'
44
- )
45
-
46
- .addExample(
47
- `${moduleRegistration.getAppInfo().name} review run`,
48
- 'Build and run a development image using the Fonto Review instance and configuration located at the current working directory.'
49
- )
50
- .addExample(
51
- `${moduleRegistration.getAppInfo().name} review run --port 7455`,
52
- 'Build and run a development image using the Fonto Review instance and configuration located at the current working directory on the non-default port 7455. '
53
- )
54
- .addExample(
55
- `${
56
- moduleRegistration.getAppInfo().name
57
- } review run --location /opt/my-instances/specific-instance/ --config-location /opt/my-instances/.env`,
58
- 'Build and run a development image using the Fonto Review instance located at "/opt/my-instances/specific-instance/" using the configuration located at "/opt/my-instances/.env".'
59
- );
60
- };