@fontoxml/fontoxml-development-tools 3.11.0 → 3.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -4
- package/npm-shrinkwrap.json +3804 -8292
- package/package.json +13 -19
- package/src/App.js +1 -1
- package/src/FdtCommand.js +3 -3
- package/src/FdtLicense.js +95 -114
- package/src/ModuleRegistrationApi.js +44 -16
- package/src/addCoreModulesToApp.js +8 -0
- package/src/modules/connectors/index.js +109 -16
- package/src/modules/connectors/instanceBuild/Dockerfile.build +1 -1
- package/src/modules/connectors/instanceBuild/Dockerfile.run +1 -1
- package/src/modules/connectors/instanceDevBuild/docker-compose.yml +2 -2
- package/src/modules/content-quality/index.js +101 -20
- package/src/modules/content-quality/instanceBuild/Dockerfile +1 -1
- package/src/modules/content-quality/instanceDevBuild/docker-compose.yml +1 -1
- package/src/modules/core/src/precontroller.help.js +23 -26
- package/src/modules/document-history/index.js +101 -20
- package/src/modules/document-history/instanceBuild/Dockerfile +1 -1
- package/src/modules/document-history/instanceDevBuild/docker-compose.yml +1 -1
- package/src/modules/editor/dev-cms/connectors-cms-standard/configureConnectorsCmsStandardDocumentRouter.js +10 -0
- package/src/modules/editor/dev-cms/connectors-cms-standard/configureDocumentHistoryGetPostRouteHandler.js +51 -0
- package/src/modules/editor/dev-cms/connectors-cms-standard/configureDocumentPostRouteHandler.js +65 -76
- package/src/modules/editor/dev-cms/connectors-cms-standard/configureDocumentPresearchPostRouteHandler.js +10 -7
- package/src/modules/editor/dev-cms/connectors-cms-standard/configureDocumentPreviewRouteHandler.js +10 -0
- package/src/modules/editor/dev-cms/connectors-cms-standard/configureDocumentRevisionGetPostRouteHandler.js +69 -0
- package/src/modules/editor/src/commands/command.convert.editor.controller.js +11 -4
- package/src/modules/editor/src/commands/command.convert.package.controller.js +11 -4
- package/src/modules/editor/src/getAppManifest.js +3 -3
- package/src/modules/editor/src/getWebpackConfig.js +13 -0
- package/src/modules/editor/src/webpackPlugins/CheckDeepImportsResolvePlugin.js +4 -0
- package/src/modules/editor-pre-7-7-0/src/api/downloadEditorSDK.js +16 -12
- package/src/modules/editor-pre-7-7-0/src/api/executeAndLog.js +3 -2
- package/src/modules/editor-pre-7-7-0/src/api/schema/compile.js +16 -22
- package/src/modules/editor-pre-7-7-0/src/api/schema/createSchemaPackages.js +8 -0
- package/src/modules/editor-pre-7-7-0/src/api/schema/getSchemaFontoJson.js +76 -48
- package/src/modules/editor-pre-7-7-0/src/command.schema.compile.controller.js +51 -2
- package/src/modules/editor-pre-7-7-0/test/api/schema/buildSchemaExperienceConfigurationModel.test.js +70 -79
- package/src/modules/editor-pre-7-7-0/test/api/schema/fixtures/invalid-fonto-json/fonto.json +1 -0
- package/src/modules/editor-pre-7-7-0/test/api/schema/getSchemaFontoJson.test.js +174 -0
- package/src/modules/editor-pre-7-7-0/test/schemaCompileController.test.js +205 -0
- package/src/modules/localization/index.js +2 -2
- package/src/modules/operations/src/api/getOperations.js +3 -3
- package/src/modules/review/index.js +103 -18
- package/src/modules/review/instanceBuild/Dockerfile +1 -1
- package/src/modules/review/instanceDevBuild/docker-compose.yml +1 -1
- package/src/modules/schema/src/api/getSchemaSummaries.js +2 -2
- package/src/modules/schema/test/getSchemaSummaries.test.js +14 -10
- package/src/modules/schema-compiler/index.js +99 -18
- package/src/modules/schema-compiler/instanceBuild/Dockerfile +1 -1
- package/src/modules/schema-compiler/instanceDevBuild/docker-compose.yml +1 -1
- package/src/modules/shared/index.js +3 -0
- package/src/modules/shared/package.json +14 -0
- package/src/modules/shared/src/addBackendDockerCommands.js +334 -0
- package/src/modules/shared/src/addBackendDownloadSelfContainedCommands.js +78 -0
- package/src/modules/shared/src/addBackendVersionsCommands.js +55 -0
- package/src/modules/shared/src/controller-templates/command.backend.build.controller.factory.js +273 -0
- package/src/modules/shared/src/controller-templates/command.backend.download-self-contained.controller.factory.js +131 -0
- package/src/modules/shared/src/controller-templates/command.backend.init.controller.factory.js +88 -0
- package/src/modules/shared/src/controller-templates/command.backend.run.controller.factory.js +420 -0
- package/src/modules/shared/src/controller-templates/command.backend.upgrade.controller.factory.js +79 -0
- package/src/modules/shared/src/controller-templates/command.backend.versions.controller.factory.js +23 -0
- package/src/modules/shared/src/controller-templates/docker/BackendManifest.js +42 -0
- package/src/modules/shared/src/controller-templates/docker/copyWhitelistedFiles.js +23 -0
- package/src/modules/shared/src/controller-templates/docker/dockerCleanup.js +146 -0
- package/src/modules/shared/src/controller-templates/docker/tryDockerLogout.js +31 -0
- package/src/modules/shared/src/controller-templates/docker/validateBackendInstance.js +48 -0
- package/src/modules/shared/src/ensureDockerCommands.js +61 -0
- package/src/modules/shared/src/executeAndLog.js +113 -0
- package/src/modules/{review/src/utilities/setEntryVisibility.js → shared/src/setFileVisibility.js} +8 -2
- package/src/modules/spell-checker/index.js +101 -18
- package/src/modules/spell-checker/instanceBuild/Dockerfile +1 -1
- package/src/modules/spell-checker/instanceDevBuild/docker-compose.yml +1 -1
- package/test/module.shared.test.js +81 -0
- package/src/modules/connectors/src/command.build.controller.js +0 -256
- package/src/modules/connectors/src/command.build.js +0 -54
- package/src/modules/connectors/src/command.download-self-contained.controller.js +0 -110
- package/src/modules/connectors/src/command.download-self-contained.js +0 -50
- package/src/modules/connectors/src/command.init.controller.js +0 -91
- package/src/modules/connectors/src/command.init.js +0 -42
- package/src/modules/connectors/src/command.run.controller.js +0 -462
- package/src/modules/connectors/src/command.run.js +0 -67
- package/src/modules/connectors/src/command.upgrade.controller.js +0 -52
- package/src/modules/connectors/src/command.upgrade.js +0 -42
- package/src/modules/connectors/src/command.versions.controller.js +0 -14
- package/src/modules/connectors/src/command.versions.js +0 -25
- package/src/modules/connectors/src/utilities/FontoxmlConnectorsManifest.js +0 -32
- package/src/modules/connectors/src/utilities/cleanup.js +0 -70
- package/src/modules/connectors/src/utilities/constants.js +0 -42
- package/src/modules/connectors/src/utilities/copyWhitelistedFiles.js +0 -22
- package/src/modules/connectors/src/utilities/executeAndLog.js +0 -63
- package/src/modules/connectors/src/utilities/getVerbosityLevel.js +0 -11
- package/src/modules/connectors/src/utilities/getWhitelist.js +0 -16
- package/src/modules/connectors/src/utilities/setEntryVisibility.js +0 -22
- package/src/modules/connectors/src/utilities/validateInstance.js +0 -29
- package/src/modules/content-quality/src/command.build.controller.js +0 -260
- package/src/modules/content-quality/src/command.build.js +0 -56
- package/src/modules/content-quality/src/command.download-self-contained.controller.js +0 -110
- package/src/modules/content-quality/src/command.download-self-contained.js +0 -52
- package/src/modules/content-quality/src/command.init.controller.js +0 -91
- package/src/modules/content-quality/src/command.init.js +0 -44
- package/src/modules/content-quality/src/command.run.controller.js +0 -444
- package/src/modules/content-quality/src/command.run.js +0 -64
- package/src/modules/content-quality/src/command.upgrade.controller.js +0 -52
- package/src/modules/content-quality/src/command.upgrade.js +0 -44
- package/src/modules/content-quality/src/command.versions.controller.js +0 -14
- package/src/modules/content-quality/src/command.versions.js +0 -25
- package/src/modules/content-quality/src/utilities/FontoxmlFcqManifest.js +0 -30
- package/src/modules/content-quality/src/utilities/cleanup.js +0 -70
- package/src/modules/content-quality/src/utilities/constants.js +0 -44
- package/src/modules/content-quality/src/utilities/copyWhitelistedFiles.js +0 -22
- package/src/modules/content-quality/src/utilities/executeAndLog.js +0 -63
- package/src/modules/content-quality/src/utilities/getVerbosityLevel.js +0 -11
- package/src/modules/content-quality/src/utilities/getWhitelist.js +0 -16
- package/src/modules/content-quality/src/utilities/setEntryVisibility.js +0 -22
- package/src/modules/content-quality/src/utilities/validateInstance.js +0 -29
- package/src/modules/document-history/src/command.build.controller.js +0 -260
- package/src/modules/document-history/src/command.build.js +0 -56
- package/src/modules/document-history/src/command.download-self-contained.controller.js +0 -110
- package/src/modules/document-history/src/command.download-self-contained.js +0 -50
- package/src/modules/document-history/src/command.init.controller.js +0 -91
- package/src/modules/document-history/src/command.init.js +0 -44
- package/src/modules/document-history/src/command.run.controller.js +0 -444
- package/src/modules/document-history/src/command.run.js +0 -64
- package/src/modules/document-history/src/command.upgrade.controller.js +0 -52
- package/src/modules/document-history/src/command.upgrade.js +0 -44
- package/src/modules/document-history/src/command.versions.controller.js +0 -14
- package/src/modules/document-history/src/command.versions.js +0 -25
- package/src/modules/document-history/src/utilities/FontoxmlFdhManifest.js +0 -30
- package/src/modules/document-history/src/utilities/cleanup.js +0 -70
- package/src/modules/document-history/src/utilities/constants.js +0 -44
- package/src/modules/document-history/src/utilities/copyWhitelistedFiles.js +0 -22
- package/src/modules/document-history/src/utilities/executeAndLog.js +0 -63
- package/src/modules/document-history/src/utilities/getVerbosityLevel.js +0 -11
- package/src/modules/document-history/src/utilities/getWhitelist.js +0 -16
- package/src/modules/document-history/src/utilities/setEntryVisibility.js +0 -22
- package/src/modules/document-history/src/utilities/validateInstance.js +0 -29
- package/src/modules/review/src/command.build.controller.js +0 -256
- package/src/modules/review/src/command.build.js +0 -54
- package/src/modules/review/src/command.download-self-contained.controller.js +0 -107
- package/src/modules/review/src/command.download-self-contained.js +0 -50
- package/src/modules/review/src/command.init.controller.js +0 -89
- package/src/modules/review/src/command.init.js +0 -42
- package/src/modules/review/src/command.run.controller.js +0 -428
- package/src/modules/review/src/command.run.js +0 -60
- package/src/modules/review/src/command.upgrade.controller.js +0 -59
- package/src/modules/review/src/command.upgrade.js +0 -42
- package/src/modules/review/src/command.versions.controller.js +0 -12
- package/src/modules/review/src/command.versions.js +0 -25
- package/src/modules/review/src/utilities/FontoxmlReviewManifest.js +0 -30
- package/src/modules/review/src/utilities/cleanup.js +0 -70
- package/src/modules/review/src/utilities/constants.js +0 -42
- package/src/modules/review/src/utilities/copyWhitelistedFiles.js +0 -22
- package/src/modules/review/src/utilities/executeAndLog.js +0 -63
- package/src/modules/review/src/utilities/getVerbosityLevel.js +0 -11
- package/src/modules/review/src/utilities/getWhitelist.js +0 -16
- package/src/modules/review/src/utilities/validateInstance.js +0 -45
- package/src/modules/schema-compiler/src/command.build.controller.js +0 -256
- package/src/modules/schema-compiler/src/command.build.js +0 -54
- package/src/modules/schema-compiler/src/command.download-self-contained.controller.js +0 -110
- package/src/modules/schema-compiler/src/command.download-self-contained.js +0 -50
- package/src/modules/schema-compiler/src/command.init.controller.js +0 -91
- package/src/modules/schema-compiler/src/command.init.js +0 -42
- package/src/modules/schema-compiler/src/command.run.controller.js +0 -430
- package/src/modules/schema-compiler/src/command.run.js +0 -60
- package/src/modules/schema-compiler/src/command.upgrade.controller.js +0 -64
- package/src/modules/schema-compiler/src/command.upgrade.js +0 -42
- package/src/modules/schema-compiler/src/command.versions.controller.js +0 -14
- package/src/modules/schema-compiler/src/command.versions.js +0 -25
- package/src/modules/schema-compiler/src/utilities/FontoxmlSchemaCompilerManifest.js +0 -32
- package/src/modules/schema-compiler/src/utilities/cleanup.js +0 -70
- package/src/modules/schema-compiler/src/utilities/constants.js +0 -43
- package/src/modules/schema-compiler/src/utilities/copyWhitelistedFiles.js +0 -22
- package/src/modules/schema-compiler/src/utilities/executeAndLog.js +0 -63
- package/src/modules/schema-compiler/src/utilities/getVerbosityLevel.js +0 -11
- package/src/modules/schema-compiler/src/utilities/getWhitelist.js +0 -16
- package/src/modules/schema-compiler/src/utilities/setEntryVisibility.js +0 -22
- package/src/modules/schema-compiler/src/utilities/validateInstance.js +0 -47
- package/src/modules/spell-checker/src/command.build.controller.js +0 -257
- package/src/modules/spell-checker/src/command.build.js +0 -54
- package/src/modules/spell-checker/src/command.download-self-contained.controller.js +0 -110
- package/src/modules/spell-checker/src/command.download-self-contained.js +0 -50
- package/src/modules/spell-checker/src/command.init.controller.js +0 -91
- package/src/modules/spell-checker/src/command.init.js +0 -42
- package/src/modules/spell-checker/src/command.run.controller.js +0 -430
- package/src/modules/spell-checker/src/command.run.js +0 -62
- package/src/modules/spell-checker/src/command.upgrade.controller.js +0 -61
- package/src/modules/spell-checker/src/command.upgrade.js +0 -42
- package/src/modules/spell-checker/src/command.versions.controller.js +0 -14
- package/src/modules/spell-checker/src/command.versions.js +0 -25
- package/src/modules/spell-checker/src/utilities/FontoxmlSpellCheckerManifest.js +0 -32
- package/src/modules/spell-checker/src/utilities/cleanup.js +0 -70
- package/src/modules/spell-checker/src/utilities/constants.js +0 -42
- package/src/modules/spell-checker/src/utilities/copyWhitelistedFiles.js +0 -22
- package/src/modules/spell-checker/src/utilities/executeAndLog.js +0 -63
- package/src/modules/spell-checker/src/utilities/getVerbosityLevel.js +0 -11
- package/src/modules/spell-checker/src/utilities/getWhitelist.js +0 -16
- package/src/modules/spell-checker/src/utilities/setEntryVisibility.js +0 -22
- package/src/modules/spell-checker/src/utilities/validateInstance.js +0 -47
|
@@ -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 FontoxmlSpellCheckerManifest from './utilities/FontoxmlSpellCheckerManifest.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 verboseSpellCheckerConfigurationEntries = {
|
|
16
|
-
Logging__LogLevel__Default: 'Trace',
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
const DEFAULT_PORT = 6050;
|
|
20
|
-
|
|
21
|
-
function copySpellCheckerConfiguration(
|
|
22
|
-
spellCheckerConfiguration,
|
|
23
|
-
tempDir,
|
|
24
|
-
verbosityLevel,
|
|
25
|
-
res
|
|
26
|
-
) {
|
|
27
|
-
const targetSpellCheckerConfiguration = path.join(tempDir, '.env');
|
|
28
|
-
|
|
29
|
-
return fs.exists(spellCheckerConfiguration).then((exists) => {
|
|
30
|
-
// Read the configuration entries from the .env file or initialize an empty array.
|
|
31
|
-
let deferred = exists
|
|
32
|
-
? fs.readFile(spellCheckerConfiguration, '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(verboseSpellCheckerConfigurationEntries).forEach(
|
|
43
|
-
(key) => {
|
|
44
|
-
const configurationEntryIndex =
|
|
45
|
-
configurationEntries.findIndex((entry) =>
|
|
46
|
-
entry.startsWith(`${key}=`)
|
|
47
|
-
);
|
|
48
|
-
const value =
|
|
49
|
-
verboseSpellCheckerConfigurationEntries[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
|
-
targetSpellCheckerConfiguration,
|
|
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 spellCheckerConfigurationFilePath = 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(spellCheckerConfigurationFilePath))
|
|
152
|
-
.then((exists) => {
|
|
153
|
-
if (!exists) {
|
|
154
|
-
if (req.options['config-location']) {
|
|
155
|
-
throw new Error(
|
|
156
|
-
`Fonto Spell Checker config "${spellCheckerConfigurationFilePath}" 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 FontoxmlSpellCheckerManifest.fromJsonFile(
|
|
180
|
-
manifestFilePath
|
|
181
|
-
).then((manifestObj) => {
|
|
182
|
-
const requestObj = {
|
|
183
|
-
'spell-checker': {
|
|
184
|
-
docker: {
|
|
185
|
-
version: manifestObj.spellCheckerVersion,
|
|
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 Spell Checker version, please check your version.';
|
|
196
|
-
}
|
|
197
|
-
throw error;
|
|
198
|
-
})
|
|
199
|
-
.then((productData) => {
|
|
200
|
-
const dockerData =
|
|
201
|
-
productData.products['spell-checker'].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
|
-
'${spellCheckerImage}',
|
|
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
|
-
'${spellCheckerPort}',
|
|
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
|
-
copySpellCheckerConfiguration(
|
|
292
|
-
spellCheckerConfigurationFilePath,
|
|
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.spellCheckerVersion,
|
|
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 Spell Checker 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,62 +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, spellCheckerCommand) => {
|
|
10
|
-
spellCheckerCommand
|
|
11
|
-
.addCommand('run', path.resolve(__dirname, 'command.run.controller.js'))
|
|
12
|
-
.setDescription(
|
|
13
|
-
'Run a Fonto Spell Checker 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=6050).'
|
|
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} spell-checker run`,
|
|
48
|
-
'Build and run a development image using the Fonto Spell Checker instance and configuration located at the current working directory.'
|
|
49
|
-
)
|
|
50
|
-
.addExample(
|
|
51
|
-
`${
|
|
52
|
-
moduleRegistration.getAppInfo().name
|
|
53
|
-
} spell-checker run --port 7455`,
|
|
54
|
-
'Build and run a development image using the Fonto Spell Checker instance and configuration located at the current working directory on the non-default port 7455. '
|
|
55
|
-
)
|
|
56
|
-
.addExample(
|
|
57
|
-
`${
|
|
58
|
-
moduleRegistration.getAppInfo().name
|
|
59
|
-
} spell-checker run --location /opt/my-instances/specific-instance/ --config-location /opt/my-instances/.env`,
|
|
60
|
-
'Build and run a development image using the Fonto Spell Checker instance located at "/opt/my-instances/specific-instance/" using the configuration located at "/opt/my-instances/.env".'
|
|
61
|
-
);
|
|
62
|
-
};
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import fs from 'fs-extra';
|
|
2
|
-
import path from 'path';
|
|
3
|
-
|
|
4
|
-
import constants from './utilities/constants.js';
|
|
5
|
-
import FontoxmlSpellCheckerManifest from './utilities/FontoxmlSpellCheckerManifest.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
|
-
'spell-checker'
|
|
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 spell-checker versions\` to get a list of all available versions.`
|
|
20
|
-
);
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
const destroySpinner = res.spinner(
|
|
24
|
-
`Upgrading your Fonto Spell Checker 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(() => FontoxmlSpellCheckerManifest.fromJsonFile(manifestFilePath))
|
|
38
|
-
.then((manifest) => {
|
|
39
|
-
currentVersion = manifest.spellCheckerVersion;
|
|
40
|
-
manifest.spellCheckerVersion = version;
|
|
41
|
-
return fs.writeJson(manifestFilePath, manifest);
|
|
42
|
-
})
|
|
43
|
-
.then(() => setEntryVisibility(manifestFilePath, false))
|
|
44
|
-
.then(() =>
|
|
45
|
-
req.fdt.license.sendTelemetry({
|
|
46
|
-
product: req.command.parent.name,
|
|
47
|
-
type: 'docker',
|
|
48
|
-
version,
|
|
49
|
-
currentVersion,
|
|
50
|
-
action: req.command.name,
|
|
51
|
-
})
|
|
52
|
-
)
|
|
53
|
-
.then(() => destroySpinner())
|
|
54
|
-
.catch((error) => {
|
|
55
|
-
res.notice(
|
|
56
|
-
`See our documentation at ${constants.DOCUMENTATION_EXECUTE_ERROR} for help.`
|
|
57
|
-
);
|
|
58
|
-
|
|
59
|
-
throw error;
|
|
60
|
-
});
|
|
61
|
-
}
|
|
@@ -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, spellCheckerCommand) => {
|
|
8
|
-
spellCheckerCommand
|
|
9
|
-
.addCommand(
|
|
10
|
-
'upgrade',
|
|
11
|
-
path.resolve(__dirname, 'command.upgrade.controller.js')
|
|
12
|
-
)
|
|
13
|
-
.setDescription(
|
|
14
|
-
'Upgrade an existing Fonto Spell Checker 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
|
-
} spell-checker upgrade --version x.x.x`,
|
|
34
|
-
'Upgrade the Fonto Spell Checker instance located at the current working directory to version x.x.x.'
|
|
35
|
-
)
|
|
36
|
-
.addExample(
|
|
37
|
-
`${
|
|
38
|
-
moduleRegistration.getAppInfo().name
|
|
39
|
-
} spell-checker upgrade --location /opt/my-instance/ --version x.x.x`,
|
|
40
|
-
'Upgrade the Fonto Spell Checker 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 Spell Checker versions...`
|
|
7
|
-
);
|
|
8
|
-
const sdkVersions = await req.fdt.license.getVersionsForProduct(
|
|
9
|
-
'spell-checker'
|
|
10
|
-
);
|
|
11
|
-
destroySpinner();
|
|
12
|
-
res.caption('Fonto Spell Checker 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, spellCheckerCommand) => {
|
|
8
|
-
spellCheckerCommand
|
|
9
|
-
.addCommand(
|
|
10
|
-
'versions',
|
|
11
|
-
path.resolve(__dirname, 'command.versions.controller.js')
|
|
12
|
-
)
|
|
13
|
-
.setDescription('List the available Fonto Spell Checker versions.')
|
|
14
|
-
|
|
15
|
-
.addHiddenOption(
|
|
16
|
-
'all',
|
|
17
|
-
undefined,
|
|
18
|
-
'Include nightly and prerelease versions.'
|
|
19
|
-
)
|
|
20
|
-
|
|
21
|
-
.addExample(
|
|
22
|
-
`${moduleRegistration.getAppInfo().name} spell-checker versions`,
|
|
23
|
-
'Request the available versions for Fonto Spell Checker.'
|
|
24
|
-
);
|
|
25
|
-
};
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import fs from 'fs-extra';
|
|
2
|
-
|
|
3
|
-
export default class FontoxmlSpellCheckerManifest {
|
|
4
|
-
constructor(spellCheckerVersion) {
|
|
5
|
-
this.spellCheckerVersion = spellCheckerVersion;
|
|
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
|
-
FontoxmlSpellCheckerManifest.validate(content);
|
|
19
|
-
return new FontoxmlSpellCheckerManifest(
|
|
20
|
-
content.spellCheckerVersion
|
|
21
|
-
);
|
|
22
|
-
});
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
static validate(input) {
|
|
26
|
-
if (!input.spellCheckerVersion) {
|
|
27
|
-
throw new Error(
|
|
28
|
-
"The Fonto Spell Checker manifest file does not contain a 'spellCheckerVersion'."
|
|
29
|
-
);
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
}
|