@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,462 +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 FontoxmlConnectorsManifest from './utilities/FontoxmlConnectorsManifest.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 verboseConnectorsConfigurationEntries = {
16
- fc__logging__logLevel: 'Trace',
17
- };
18
-
19
- const DEFAULT_HTTP_PORT = 6010;
20
- const DEFAULT_HTTPS_PORT = 6011;
21
-
22
- function copyConnectorsConfiguration(
23
- connectorsConfiguration,
24
- tempDir,
25
- verbosityLevel,
26
- res
27
- ) {
28
- const targetConnectorsConfiguration = path.join(tempDir, '.env');
29
-
30
- return fs.exists(connectorsConfiguration).then((exists) => {
31
- // Read the configuration entries from the .env file or initialize an empty array.
32
- let deferred = exists
33
- ? fs.readFile(connectorsConfiguration, 'utf8').then((data) => {
34
- return data.split(/\r?\n/g);
35
- })
36
- : new Promise((resolve, _reject) => {
37
- resolve(new Array(0));
38
- });
39
-
40
- if (verbosityLevel === constants.VERBOSITY_LEVEL_DEBUG) {
41
- // Replace or set the verbosity levels.
42
- deferred = deferred.then((configurationEntries) => {
43
- Object.keys(verboseConnectorsConfigurationEntries).forEach(
44
- (key) => {
45
- const configurationEntryIndex =
46
- configurationEntries.findIndex((entry) =>
47
- entry.startsWith(`${key}=`)
48
- );
49
- const value =
50
- verboseConnectorsConfigurationEntries[key];
51
- if (configurationEntryIndex === -1) {
52
- configurationEntries.push(`${key}=${value}`);
53
- } else {
54
- configurationEntries[
55
- configurationEntryIndex
56
- ] = `${key}=${value}`;
57
- }
58
- }
59
- );
60
- return configurationEntries;
61
- });
62
- }
63
-
64
- // Ignore options that shouldn't be applied when running through FDT.
65
- deferred = deferred.then((configurationEntries) => {
66
- let i = configurationEntries.length;
67
- while (i--) {
68
- const configurationLine = configurationEntries[i];
69
- if (
70
- !configurationLine.startsWith('#') &&
71
- configurationLine.indexOf('=') !== -1
72
- ) {
73
- const [key, _value] = configurationLine.split('=', 2);
74
-
75
- if (key === 'ASPNETCORE_URLS') {
76
- configurationEntries.splice(i, 1);
77
- res.notice(
78
- `Notice: The '${key}' configuration option in the '.env' file will be ignored when ` +
79
- "running the application using FDT. The FDT '--http-port' and '--https-port' options can be used to run the application " +
80
- 'under different ports.'
81
- );
82
- }
83
- }
84
- }
85
- return configurationEntries;
86
- });
87
-
88
- // Write the configuration to the .env file.
89
- return deferred.then((configurationEntries) => {
90
- const configurationData = configurationEntries.join(os.EOL);
91
- return fs.writeFile(
92
- targetConnectorsConfiguration,
93
- configurationData,
94
- 'utf8'
95
- );
96
- });
97
- });
98
- }
99
-
100
- export default function runCommand(req, res) {
101
- res.caption(req.command.getLongName());
102
-
103
- const directoryPath = path.resolve(
104
- req.options.location ? req.options.location : process.cwd()
105
- );
106
- const temporaryDirectoryPath = path.join(
107
- directoryPath,
108
- constants.TEMPLATE_DIRECTORY_NAME
109
- );
110
- const connectorsConfigurationFilePath = req.options['config-location']
111
- ? path.resolve(req.options['config-location'])
112
- : path.join(directoryPath, '.env');
113
- const manifestFilePath = path.join(
114
- directoryPath,
115
- constants.MANIFEST_FILENAME
116
- );
117
- const verbosityLevel = getVerbosityLevel(
118
- req.options.verbose,
119
- req.options.debug
120
- );
121
- const httpPort = req.options['http-port'] || DEFAULT_HTTP_PORT;
122
- const httpsPort = req.options['https-port'] || DEFAULT_HTTPS_PORT;
123
- const projectName = `${constants.DEFAULT_IMAGE_NAME}_${httpPort}_${httpsPort}`;
124
-
125
- let pidToKillOnForceExit = null;
126
- const setPidToKillOnForceExit = (processToKill) => {
127
- pidToKillOnForceExit = processToKill && processToKill.pid;
128
- };
129
-
130
- // Ensure we cleanup before exiting.
131
- let stopping = false;
132
- process.on('SIGINT', (_code) => {
133
- if (stopping) {
134
- if (pidToKillOnForceExit) {
135
- process.kill(pidToKillOnForceExit);
136
- }
137
- process.exit();
138
- return;
139
- }
140
-
141
- stopping = true;
142
- res.log('Gracefully stopping... (press Ctrl+C again to force)');
143
- return cleanup(
144
- temporaryDirectoryPath,
145
- projectName,
146
- res,
147
- verbosityLevel
148
- ).then(() => {
149
- process.exit();
150
- });
151
- });
152
-
153
- return (
154
- validateInstance(directoryPath)
155
- .then(() => fs.exists(connectorsConfigurationFilePath))
156
- .then((exists) => {
157
- if (!exists) {
158
- if (req.options['config-location']) {
159
- throw new Error(
160
- `Fonto Connectors config "${connectorsConfigurationFilePath}" does not exist.`
161
- );
162
- }
163
- res.notice(
164
- `No .env file exists in the directory "${directoryPath}". This will build a Fonto Connectors instance with all connectors disabled! See ${constants.DOCUMENTATION_CONFIGURATION_GUIDE} to configure the .env file.`
165
- );
166
- }
167
- })
168
- .then(() => fs.exists(manifestFilePath))
169
- .then((exists) => {
170
- // Verify fontoxmlConnectorsManifest file is present and valid.
171
- if (!exists) {
172
- throw new Error(
173
- 'The Fonto Connectors manifest file does not exist.'
174
- );
175
- } else {
176
- return FontoxmlConnectorsManifest.fromJsonFile(
177
- manifestFilePath
178
- );
179
- }
180
- })
181
- // Cleanup possible remaining resources from a previous build or run.
182
- .then(() =>
183
- cleanup(
184
- temporaryDirectoryPath,
185
- projectName,
186
- res,
187
- verbosityLevel
188
- )
189
- )
190
- .then(() => {
191
- const destroySpinner = res.spinner(
192
- `Building development image at "${directoryPath}"...`
193
- );
194
-
195
- // Retrieve data for the docker image
196
- return FontoxmlConnectorsManifest.fromJsonFile(
197
- manifestFilePath
198
- ).then((manifestObj) => {
199
- const requestObj = {
200
- connectors: {
201
- docker: {
202
- version: manifestObj.connectorsVersion,
203
- },
204
- },
205
- };
206
-
207
- return req.fdt.license
208
- .getDataForProducts(requestObj)
209
- .catch((error) => {
210
- if (error.statusCode === 404) {
211
- error.solution =
212
- 'This error might be caused by requesting a nonexistent Fonto Connectors version, please check your version.';
213
- }
214
- throw error;
215
- })
216
- .then((productData) => {
217
- const dockerData =
218
- productData.products.connectors.docker;
219
-
220
- // Create a hidden temporary directory.
221
- return (
222
- fs
223
- .mkdir(temporaryDirectoryPath)
224
- .then(() =>
225
- setEntryVisibility(
226
- temporaryDirectoryPath,
227
- false
228
- )
229
- )
230
- // Copy the instance files into the temporary directory.
231
- .then(() => {
232
- // Rewrite the version in the Dockerfile.
233
- return fs
234
- .readFile(
235
- path.join(
236
- constants.INSTANCE_BUILD_DIRECTORY_PATH,
237
- 'Dockerfile.run'
238
- ),
239
- 'utf8'
240
- )
241
- .then((dockerContent) =>
242
- dockerContent.replace(
243
- '${connectorsImage}',
244
- dockerData.image
245
- )
246
- )
247
- .then((fixedDockerContent) => {
248
- return fs.writeFile(
249
- path.join(
250
- temporaryDirectoryPath,
251
- 'Dockerfile'
252
- ),
253
- fixedDockerContent,
254
- 'utf8'
255
- );
256
- });
257
- })
258
- .then(() =>
259
- fs.copy(
260
- constants.INSTANCE_DEV_BUILD_DIRECTORY_PATH,
261
- temporaryDirectoryPath
262
- )
263
- )
264
- .then(() => {
265
- // Rewrite the port in the docker-compose file.
266
- return fs
267
- .readFile(
268
- path.join(
269
- temporaryDirectoryPath,
270
- 'docker-compose.yml'
271
- ),
272
- 'utf8'
273
- )
274
- .then((dockerComposeContent) =>
275
- dockerComposeContent
276
- .replace(
277
- '${containerName}',
278
- projectName
279
- )
280
- .replace(
281
- '${connectorsHttpPort}',
282
- httpPort
283
- )
284
- .replace(
285
- '${connectorsHttpsPort}',
286
- httpsPort
287
- )
288
- )
289
- .then((fixedDockerComposeContent) =>
290
- fs.writeFile(
291
- path.join(
292
- temporaryDirectoryPath,
293
- 'docker-compose.yml'
294
- ),
295
- fixedDockerComposeContent
296
- )
297
- );
298
- })
299
- .then(() => [
300
- path.join(directoryPath, 'editor'),
301
- path.join(directoryPath, 'templates'),
302
- path.join(
303
- directoryPath,
304
- 'documentProcessing.xml'
305
- ),
306
- path.join(
307
- directoryPath,
308
- 'initializer-files'
309
- ),
310
- ])
311
- .then(() => getWhitelist())
312
- .then((whitelist) =>
313
- copyWhitelistedFiles(
314
- whitelist,
315
- directoryPath,
316
- path.join(
317
- temporaryDirectoryPath,
318
- 'instance'
319
- )
320
- )
321
- )
322
- .then(() =>
323
- copyConnectorsConfiguration(
324
- connectorsConfigurationFilePath,
325
- temporaryDirectoryPath,
326
- verbosityLevel,
327
- res
328
- )
329
- )
330
-
331
- // Pull the docker image
332
- .then(() => {
333
- return executeAndLog(
334
- res,
335
- 'docker',
336
- [
337
- 'login',
338
- dockerData.registry,
339
- '-u',
340
- dockerData.login,
341
- '-p',
342
- dockerData.password,
343
- ],
344
- null,
345
- constants.VERBOSITY_LEVEL_NORMAL,
346
- false,
347
- setPidToKillOnForceExit
348
- )
349
- .then(() =>
350
- executeAndLog(
351
- res,
352
- 'docker',
353
- ['pull', dockerData.image],
354
- null,
355
- verbosityLevel,
356
- false,
357
- setPidToKillOnForceExit
358
- )
359
- )
360
- .then(() =>
361
- executeAndLog(
362
- res,
363
- 'docker',
364
- [
365
- 'logout',
366
- dockerData.registry,
367
- ],
368
- null,
369
- constants.VERBOSITY_LEVEL_NORMAL,
370
- false,
371
- setPidToKillOnForceExit
372
- )
373
- )
374
- .catch(() => {
375
- throw new Error(
376
- 'Failed to retrieve the image file.'
377
- );
378
- });
379
- })
380
-
381
- // Use docker-compose to build the development image.
382
- .then(() =>
383
- executeAndLog(
384
- res,
385
- 'docker-compose',
386
- verbosityLevel ===
387
- constants.VERBOSITY_LEVEL_DEBUG
388
- ? [
389
- '-p',
390
- projectName,
391
- '--verbose',
392
- 'build',
393
- ]
394
- : ['-p', projectName, 'build'],
395
- temporaryDirectoryPath,
396
- verbosityLevel,
397
- false,
398
- setPidToKillOnForceExit
399
- )
400
- )
401
- .then(() =>
402
- req.fdt.license.sendTelemetry({
403
- product: req.command.parent.name,
404
- type: 'docker',
405
- version:
406
- manifestObj.connectorsVersion,
407
- action: req.command.name,
408
- })
409
- )
410
- .then(() => destroySpinner())
411
- );
412
- });
413
- });
414
- })
415
- // 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
416
- .then(() => {
417
- res.notice(
418
- `Starting Fonto Connectors on "http://localhost:${httpPort}" and "https://localhost:${httpsPort}"...`
419
- );
420
- return executeAndLog(
421
- res,
422
- 'docker-compose',
423
- verbosityLevel === constants.VERBOSITY_LEVEL_DEBUG
424
- ? ['-p', projectName, '--verbose', 'up']
425
- : ['-p', projectName, 'up'],
426
- temporaryDirectoryPath,
427
- verbosityLevel,
428
- true,
429
- setPidToKillOnForceExit
430
- );
431
- })
432
- // Cleanup temporary directory.
433
- .then(() =>
434
- cleanup(
435
- temporaryDirectoryPath,
436
- projectName,
437
- res,
438
- verbosityLevel
439
- )
440
- )
441
- .catch((error) => {
442
- if (!stopping) {
443
- res.notice(
444
- `See our documentation at ${constants.DOCUMENTATION_EXECUTE_ERROR} for help.`
445
- );
446
- }
447
-
448
- return cleanup(
449
- temporaryDirectoryPath,
450
- projectName,
451
- res,
452
- verbosityLevel
453
- )
454
- .then(() => {
455
- throw error;
456
- })
457
- .catch(() => {
458
- throw error;
459
- });
460
- })
461
- );
462
- }
@@ -1,67 +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, connectorsCommand) => {
10
- connectorsCommand
11
- .addCommand('run', path.resolve(__dirname, 'command.run.controller.js'))
12
- .setDescription(
13
- 'Run a Fonto Connectors instance with a self-signed certificate for development purposes. Requires Docker to be installed.'
14
- )
15
-
16
- .addOption(
17
- 'http-port',
18
- null,
19
- 'Listen on the specified http port instead of listening on the default port (default=6010).'
20
- )
21
- .addOption(
22
- 'https-port',
23
- null,
24
- 'Listen on the specified https port instead of listening on the default port (default=6011).'
25
- )
26
-
27
- .addOption(
28
- 'location',
29
- 'l',
30
- 'The directory where the instance is located.',
31
- false
32
- )
33
- .addOption(
34
- 'config-location',
35
- 'c',
36
- `The path where the configuration file (.env) is located. Information about the .env file can be found at ${constants.DOCUMENTATION_CONFIGURATION_GUIDE}.`,
37
- false
38
- )
39
-
40
- .addOption(
41
- 'verbose',
42
- null,
43
- 'Output default stdout and stderr information.'
44
- )
45
- .addOption(
46
- 'debug',
47
- null,
48
- 'Output all debug information. This also overrides the fc__logging__logLevel if set.'
49
- )
50
-
51
- .addExample(
52
- `${moduleRegistration.getAppInfo().name} connectors run`,
53
- 'Build and run a development image using the Fonto Connectors instance and configuration located at the current working directory.'
54
- )
55
- .addExample(
56
- `${
57
- moduleRegistration.getAppInfo().name
58
- } connectors run --http-port 8080 --https-port 8443`,
59
- 'Build and run a development image using the Fonto Connectors instance and configuration located at the current working directory on the non-default ports 8080 and 8443.'
60
- )
61
- .addExample(
62
- `${
63
- moduleRegistration.getAppInfo().name
64
- } connectors run --location /opt/my-instances/specific-instance/ --config-location /opt/my-instances/.env`,
65
- 'Build and run a development image using the Fonto Connectors instance located at "/opt/my-instances/specific-instance/" using the configuration located at "/opt/my-instances/.env".'
66
- );
67
- };
@@ -1,52 +0,0 @@
1
- import fs from 'fs-extra';
2
- import path from 'path';
3
-
4
- import constants from './utilities/constants.js';
5
- import FontoxmlConnectorsManifest from './utilities/FontoxmlConnectorsManifest.js';
6
- import setEntryVisibility from './utilities/setEntryVisibility.js';
7
-
8
- export default async function upgradeCommand(req, res) {
9
- res.caption(req.command.getLongName());
10
-
11
- // Check if the given version exist.
12
- const sdkVersions = await req.fdt.license.getVersionsForProduct(
13
- 'connectors'
14
- );
15
- const version = req.options.version;
16
- if (!sdkVersions.includes(version)) {
17
- throw new Error(
18
- `Could not upgrade to version (${version}), please check if it is a valid version. The latest version is ${sdkVersions.getLatestStable()}, run \`fdt connectors versions\` to get a list of all available versions.`
19
- );
20
- }
21
-
22
- const destroySpinner = res.spinner(
23
- `Upgrading your Fonto Connectors instance to ${version}...`
24
- );
25
-
26
- const directoryPath = path.resolve(
27
- req.options.location ? req.options.location : process.cwd()
28
- );
29
- const manifestFilePath = path.join(
30
- directoryPath,
31
- constants.MANIFEST_FILENAME
32
- );
33
- let currentVersion;
34
- return setEntryVisibility(manifestFilePath, true)
35
- .then(() => FontoxmlConnectorsManifest.fromJsonFile(manifestFilePath))
36
- .then((manifest) => {
37
- currentVersion = manifest.connectorsVersion;
38
- manifest.connectorsVersion = version;
39
- return fs.writeJson(manifestFilePath, manifest);
40
- })
41
- .then(() => setEntryVisibility(manifestFilePath, false))
42
- .then(() =>
43
- req.fdt.license.sendTelemetry({
44
- product: req.command.parent.name,
45
- type: 'docker',
46
- version,
47
- currentVersion,
48
- action: req.command.name,
49
- })
50
- )
51
- .then(() => destroySpinner());
52
- }
@@ -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, connectorsCommand) => {
8
- connectorsCommand
9
- .addCommand(
10
- 'upgrade',
11
- path.resolve(__dirname, 'command.upgrade.controller.js')
12
- )
13
- .setDescription(
14
- 'Upgrade an existing Fonto Connectors instance to the specified version.'
15
- )
16
-
17
- .addOption(
18
- 'location',
19
- 'l',
20
- 'The directory of the instance to upgrade. If not set this defaults to the current working directory.',
21
- false
22
- )
23
- .addOption(
24
- 'version',
25
- null,
26
- 'The version to upgrade to. 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
- } connectors upgrade --version x.x.x`,
34
- 'Upgrade the Fonto Connectors instance located at the current working directory to version x.x.x.'
35
- )
36
- .addExample(
37
- `${
38
- moduleRegistration.getAppInfo().name
39
- } connectors upgrade --location /opt/my-instance/ --version x.x.x`,
40
- 'Upgrade the Fonto Connectors instance located at "/opt/my-instance/" to version x.x.x.'
41
- );
42
- };
@@ -1,14 +0,0 @@
1
- export default async function versionsCommand(req, res) {
2
- res.caption(req.command.getLongName());
3
-
4
- const all = req.options.all;
5
- const destroySpinner = res.spinner(
6
- `Retrieving ${all ? 'all ' : ''}Fonto Connectors versions...`
7
- );
8
- const sdkVersions = await req.fdt.license.getVersionsForProduct(
9
- 'connectors'
10
- );
11
- destroySpinner();
12
- res.caption('Fonto Connectors versions');
13
- res.list(all ? sdkVersions.getAll() : sdkVersions.getAllStable(), '-');
14
- }
@@ -1,25 +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, connectorsCommand) => {
8
- connectorsCommand
9
- .addCommand(
10
- 'versions',
11
- path.resolve(__dirname, 'command.versions.controller.js')
12
- )
13
- .setDescription('List the available Fonto Connectors versions.')
14
-
15
- .addHiddenOption(
16
- 'all',
17
- undefined,
18
- 'Include nightly and prerelease versions.'
19
- )
20
-
21
- .addExample(
22
- `${moduleRegistration.getAppInfo().name} connectors versions`,
23
- 'Request the available versions for Fonto Connectors.'
24
- );
25
- };
@@ -1,32 +0,0 @@
1
- import fs from 'fs-extra';
2
-
3
- export default class FontoxmlConnectorsManifest {
4
- constructor(connectorsVersion) {
5
- this.connectorsVersion = connectorsVersion;
6
- }
7
-
8
- static fromJsonFile(filePath) {
9
- return fs
10
- .exists(filePath)
11
- .then((exists) => {
12
- if (!exists) {
13
- throw new Error(`The file ${filePath} does not exist.`);
14
- }
15
- })
16
- .then(() => fs.readJson(filePath))
17
- .then((content) => {
18
- FontoxmlConnectorsManifest.validate(content);
19
- return new FontoxmlConnectorsManifest(
20
- content.connectorsVersion
21
- );
22
- });
23
- }
24
-
25
- static validate(input) {
26
- if (!input.connectorsVersion) {
27
- throw new Error(
28
- "The Fonto Connectors manifest file does not contain a 'connectorsVersion'."
29
- );
30
- }
31
- }
32
- }