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