@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
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
import fs from 'fs-extra';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
|
|
4
|
+
import executeAndLog, { VERBOSITY_LEVEL } from '../../executeAndLog.js';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* @param {string} temporaryDirectoryPath
|
|
8
|
+
* @param {string} projectName
|
|
9
|
+
* @param {FdtResponse} res
|
|
10
|
+
* @param {number} verbosityLevel
|
|
11
|
+
*
|
|
12
|
+
* @return {Promise<void>}
|
|
13
|
+
*/
|
|
14
|
+
async function actualCleanup(
|
|
15
|
+
temporaryDirectoryPath,
|
|
16
|
+
projectName,
|
|
17
|
+
res,
|
|
18
|
+
verbosityLevel
|
|
19
|
+
) {
|
|
20
|
+
const temporaryDirectoryExists = await fs.exists(temporaryDirectoryPath);
|
|
21
|
+
if (!temporaryDirectoryExists) {
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const destroySpinner = res.spinner('Removing temporary resources...');
|
|
26
|
+
|
|
27
|
+
try {
|
|
28
|
+
const dockerComposeFileExists = await fs.exists(
|
|
29
|
+
path.join(temporaryDirectoryPath, 'docker-compose.yml')
|
|
30
|
+
);
|
|
31
|
+
|
|
32
|
+
const errors = [];
|
|
33
|
+
const tasks = [
|
|
34
|
+
async () => {
|
|
35
|
+
if (dockerComposeFileExists && projectName) {
|
|
36
|
+
await executeAndLog(
|
|
37
|
+
res,
|
|
38
|
+
'docker',
|
|
39
|
+
verbosityLevel === VERBOSITY_LEVEL.DEBUG
|
|
40
|
+
? [
|
|
41
|
+
'compose',
|
|
42
|
+
'-p',
|
|
43
|
+
projectName,
|
|
44
|
+
'--verbose',
|
|
45
|
+
'down',
|
|
46
|
+
'--rmi',
|
|
47
|
+
'local',
|
|
48
|
+
]
|
|
49
|
+
: [
|
|
50
|
+
'compose',
|
|
51
|
+
'-p',
|
|
52
|
+
projectName,
|
|
53
|
+
'down',
|
|
54
|
+
'--rmi',
|
|
55
|
+
'local',
|
|
56
|
+
],
|
|
57
|
+
temporaryDirectoryPath,
|
|
58
|
+
verbosityLevel
|
|
59
|
+
);
|
|
60
|
+
}
|
|
61
|
+
},
|
|
62
|
+
async () => {
|
|
63
|
+
await fs.remove(temporaryDirectoryPath);
|
|
64
|
+
},
|
|
65
|
+
];
|
|
66
|
+
|
|
67
|
+
// Run all cleanup tasks in order. Continue on errors. But collect the errors.
|
|
68
|
+
for (let i = 0; i < tasks.length; i++) {
|
|
69
|
+
try {
|
|
70
|
+
await tasks[i]();
|
|
71
|
+
} catch (error) {
|
|
72
|
+
errors.push(error);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
// Only throw if a task have failed.
|
|
77
|
+
if (errors.length > 0) {
|
|
78
|
+
throw errors[0];
|
|
79
|
+
}
|
|
80
|
+
// eslint-disable-next-line no-useless-catch
|
|
81
|
+
} catch (error) {
|
|
82
|
+
throw error;
|
|
83
|
+
} finally {
|
|
84
|
+
destroySpinner();
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
const cleanupQueuePromises = new Set();
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* @param {string} temporaryDirectoryPath
|
|
92
|
+
* @param {string} projectName
|
|
93
|
+
* @param {FdtResponse} res
|
|
94
|
+
* @param {number} verbosityLevel
|
|
95
|
+
*
|
|
96
|
+
* @return {Promise<void>}
|
|
97
|
+
*/
|
|
98
|
+
export default async function dockerCleanup(
|
|
99
|
+
temporaryDirectoryPath,
|
|
100
|
+
projectName,
|
|
101
|
+
res,
|
|
102
|
+
verbosityLevel
|
|
103
|
+
) {
|
|
104
|
+
// Get the existing queue promises.
|
|
105
|
+
const existingCleanupQueuePromises = [...cleanupQueuePromises];
|
|
106
|
+
|
|
107
|
+
// Create a queue entry.
|
|
108
|
+
let cleanupQueuePromiseResolve = null;
|
|
109
|
+
let cleanupQueuePromiseReject = null;
|
|
110
|
+
const cleanupQueuePromise = new Promise((resolve, reject) => {
|
|
111
|
+
cleanupQueuePromiseResolve = resolve;
|
|
112
|
+
cleanupQueuePromiseReject = reject;
|
|
113
|
+
});
|
|
114
|
+
cleanupQueuePromises.add(cleanupQueuePromise);
|
|
115
|
+
|
|
116
|
+
// Wait for existing cleanup queue promises.
|
|
117
|
+
await Promise.all(
|
|
118
|
+
existingCleanupQueuePromises.map(
|
|
119
|
+
async (existingCleanupQueuePromise) => {
|
|
120
|
+
try {
|
|
121
|
+
await existingCleanupQueuePromise;
|
|
122
|
+
} catch (_error) {
|
|
123
|
+
// Ignore other cleanup errors.
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
)
|
|
127
|
+
);
|
|
128
|
+
|
|
129
|
+
// Call actual cleanup, resolving/rejecting the queue promise when done.
|
|
130
|
+
await actualCleanup(
|
|
131
|
+
temporaryDirectoryPath,
|
|
132
|
+
projectName,
|
|
133
|
+
res,
|
|
134
|
+
verbosityLevel
|
|
135
|
+
)
|
|
136
|
+
.then((...args) => {
|
|
137
|
+
cleanupQueuePromises.delete(cleanupQueuePromise);
|
|
138
|
+
cleanupQueuePromiseResolve(...args);
|
|
139
|
+
})
|
|
140
|
+
.catch((error) => {
|
|
141
|
+
cleanupQueuePromises.delete(cleanupQueuePromise);
|
|
142
|
+
cleanupQueuePromiseReject(error);
|
|
143
|
+
});
|
|
144
|
+
|
|
145
|
+
return cleanupQueuePromise;
|
|
146
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import executeAndLog, { VERBOSITY_LEVEL } from '../../executeAndLog.js';
|
|
2
|
+
|
|
3
|
+
/** @typedef {import('../../executeAndLog').ProcessCreatedCallback} ProcessCreatedCallback */
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* @param {string} registry
|
|
7
|
+
* @param {FdtResponse} res
|
|
8
|
+
* @param {ProcessCreatedCallback} setPidToKillOnForceExit
|
|
9
|
+
*
|
|
10
|
+
* @returns {Promise<void>}
|
|
11
|
+
*/
|
|
12
|
+
export default async function tryDockerLogout(
|
|
13
|
+
registry,
|
|
14
|
+
res,
|
|
15
|
+
setPidToKillOnForceExit
|
|
16
|
+
) {
|
|
17
|
+
try {
|
|
18
|
+
// Clear the time limited login credentials.
|
|
19
|
+
await executeAndLog(
|
|
20
|
+
res,
|
|
21
|
+
'docker',
|
|
22
|
+
['logout', registry],
|
|
23
|
+
null,
|
|
24
|
+
VERBOSITY_LEVEL.NORMAL,
|
|
25
|
+
false,
|
|
26
|
+
setPidToKillOnForceExit
|
|
27
|
+
);
|
|
28
|
+
} catch (_error) {
|
|
29
|
+
// Ignore error.
|
|
30
|
+
}
|
|
31
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import fs from 'fs-extra';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
|
|
4
|
+
import BackendManifest from './BackendManifest.js';
|
|
5
|
+
|
|
6
|
+
/** @typedef {import('../../addBackendDockerCommands').AddBackendDockerCommandsOptions} AddBackendDockerCommandsOptions */
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* @param {string} directoryPath
|
|
10
|
+
* @param {AddBackendDockerCommandsOptions} options
|
|
11
|
+
*
|
|
12
|
+
* @return {Promise<void>}
|
|
13
|
+
*/
|
|
14
|
+
export default async function validateBackendInstance(directoryPath, options) {
|
|
15
|
+
const manifestFilePath = path.join(directoryPath, options.manifestFileName);
|
|
16
|
+
|
|
17
|
+
// Verify that the instance directory exists.
|
|
18
|
+
const directoryExists = await fs.exists(directoryPath);
|
|
19
|
+
if (!directoryExists) {
|
|
20
|
+
throw new Error(`Directory "${directoryPath}" does not exist.`);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
// Verify that the BackendManifest file exists
|
|
24
|
+
const manifestExists = await fs.exists(manifestFilePath);
|
|
25
|
+
if (!manifestExists) {
|
|
26
|
+
throw new Error(
|
|
27
|
+
`The ${options.manifestFileName} manifest file does not exist.`
|
|
28
|
+
);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// Verify that the BackendManifest file is valid.
|
|
32
|
+
await BackendManifest.fromJsonFile(
|
|
33
|
+
manifestFilePath,
|
|
34
|
+
options.manifestVersionPropertyName
|
|
35
|
+
);
|
|
36
|
+
|
|
37
|
+
// Verify that all required configuration files exist.
|
|
38
|
+
await Promise.all(
|
|
39
|
+
options.requiredConfiguration.map(async (entryName) => {
|
|
40
|
+
const exists = await fs.exists(path.join(directoryPath, entryName));
|
|
41
|
+
if (!exists) {
|
|
42
|
+
throw new Error(
|
|
43
|
+
`Directory "${directoryPath}" does not contain a valid ${options.productLabel} instance. Missing "${entryName}".`
|
|
44
|
+
);
|
|
45
|
+
}
|
|
46
|
+
})
|
|
47
|
+
);
|
|
48
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import executeAndLog, { VERBOSITY_LEVEL } from './executeAndLog.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @typedef EnsureDockerCommandsOptions
|
|
5
|
+
*
|
|
6
|
+
* @property {boolean} [checkDocker=true]
|
|
7
|
+
* @property {boolean} [checkDockerCompose=false]
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Ensures that the Docker, and optionally also Docker compose, commands are available.
|
|
12
|
+
*
|
|
13
|
+
* NOTE: This does not check if Docker is running.
|
|
14
|
+
*
|
|
15
|
+
* @param {string} workingDirectory
|
|
16
|
+
* @param {FdtResponse} res
|
|
17
|
+
* @param {EnsureDockerCommandsOptions} [options={}]
|
|
18
|
+
*
|
|
19
|
+
* @returns {Promise<void>}
|
|
20
|
+
*/
|
|
21
|
+
export default async function ensureDockerCommands(
|
|
22
|
+
workingDirectory,
|
|
23
|
+
res,
|
|
24
|
+
options = { checkDocker: true, checkDockerCompose: false }
|
|
25
|
+
) {
|
|
26
|
+
if (options.checkDocker) {
|
|
27
|
+
try {
|
|
28
|
+
await executeAndLog(
|
|
29
|
+
res,
|
|
30
|
+
'docker',
|
|
31
|
+
['-v'],
|
|
32
|
+
workingDirectory,
|
|
33
|
+
VERBOSITY_LEVEL.SILENT,
|
|
34
|
+
false
|
|
35
|
+
);
|
|
36
|
+
} catch (_error) {
|
|
37
|
+
throw new res.ErrorWithSolution(
|
|
38
|
+
'Cannot run Docker commands.',
|
|
39
|
+
'Please make sure Docker is installed. See: https://docs.docker.com/install/.'
|
|
40
|
+
);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
if (options.checkDockerCompose) {
|
|
45
|
+
try {
|
|
46
|
+
await executeAndLog(
|
|
47
|
+
res,
|
|
48
|
+
'docker',
|
|
49
|
+
['compose', 'version'],
|
|
50
|
+
workingDirectory,
|
|
51
|
+
VERBOSITY_LEVEL.SILENT,
|
|
52
|
+
false
|
|
53
|
+
);
|
|
54
|
+
} catch (_error) {
|
|
55
|
+
throw new res.ErrorWithSolution(
|
|
56
|
+
'Cannot run Docker Compose commands.',
|
|
57
|
+
'Please make sure the Docker Compose plugin is installed, which differs from the docker-compose standalone tool. See: https://docs.docker.com/compose/install/.'
|
|
58
|
+
);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import cp from 'child_process';
|
|
2
|
+
|
|
3
|
+
/** @typedef {import('child_process').ChildProcess} ChildProcess */
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* @callback ProcessCreatedCallback
|
|
7
|
+
*
|
|
8
|
+
* @param {ChildProcess} process
|
|
9
|
+
*
|
|
10
|
+
* @return {void}
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
export const VERBOSITY_LEVEL = {
|
|
14
|
+
SILENT: -1,
|
|
15
|
+
NORMAL: 0,
|
|
16
|
+
VERBOSE: 1,
|
|
17
|
+
DEBUG: 2,
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* @param {boolean} verbose
|
|
22
|
+
* @param {boolean} debug
|
|
23
|
+
*
|
|
24
|
+
* @returns {number}
|
|
25
|
+
*/
|
|
26
|
+
export function getVerbosityLevel(verbose, debug) {
|
|
27
|
+
if (debug) {
|
|
28
|
+
return VERBOSITY_LEVEL.DEBUG;
|
|
29
|
+
}
|
|
30
|
+
if (verbose) {
|
|
31
|
+
return VERBOSITY_LEVEL.VERBOSE;
|
|
32
|
+
}
|
|
33
|
+
return VERBOSITY_LEVEL.NORMAL;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* @param {FdtResponse} res
|
|
38
|
+
* @param {string} command
|
|
39
|
+
* @param {string[]} args
|
|
40
|
+
* @param {string} currentWorkingDirectoryPath
|
|
41
|
+
* @param {number} verbosityLevel
|
|
42
|
+
* @param {boolean} showStdout
|
|
43
|
+
* @param {ProcessCreatedCallback} processCreatedCallback
|
|
44
|
+
* @param {number[]} [additionalSuccessExitCodes=[]]
|
|
45
|
+
*
|
|
46
|
+
* @returns {Promise<void>}
|
|
47
|
+
*/
|
|
48
|
+
function executeAndLog(
|
|
49
|
+
res,
|
|
50
|
+
command,
|
|
51
|
+
args,
|
|
52
|
+
currentWorkingDirectoryPath,
|
|
53
|
+
verbosityLevel,
|
|
54
|
+
showStdout,
|
|
55
|
+
processCreatedCallback,
|
|
56
|
+
additionalSuccessExitCodes = []
|
|
57
|
+
) {
|
|
58
|
+
return new Promise((resolve, reject) => {
|
|
59
|
+
const errors = [];
|
|
60
|
+
const childProcess = cp.spawn(command, args, {
|
|
61
|
+
cwd: currentWorkingDirectoryPath,
|
|
62
|
+
});
|
|
63
|
+
const silent = verbosityLevel === VERBOSITY_LEVEL.SILENT;
|
|
64
|
+
const verbose =
|
|
65
|
+
verbosityLevel === VERBOSITY_LEVEL.VERBOSE ||
|
|
66
|
+
verbosityLevel === verbosityLevel.DEBUG;
|
|
67
|
+
const debug = verbosityLevel === VERBOSITY_LEVEL.DEBUG;
|
|
68
|
+
|
|
69
|
+
if (processCreatedCallback) {
|
|
70
|
+
processCreatedCallback(process);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
childProcess.stdout.on('data', (data) => {
|
|
74
|
+
if (verbose || showStdout) {
|
|
75
|
+
res.raw(data);
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
childProcess.stderr.on('data', (data) => {
|
|
80
|
+
if (debug) {
|
|
81
|
+
res.raw(data);
|
|
82
|
+
} else {
|
|
83
|
+
errors.push(data.toString());
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
childProcess.on('error', (error) => {
|
|
88
|
+
res.error(error);
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
childProcess.on('close', (code) => {
|
|
92
|
+
if (code === 0 || additionalSuccessExitCodes.includes(code)) {
|
|
93
|
+
if (verbose) {
|
|
94
|
+
res.debug(
|
|
95
|
+
`${command} ${args.join(' ')} exited with code ${code}`
|
|
96
|
+
);
|
|
97
|
+
}
|
|
98
|
+
resolve();
|
|
99
|
+
} else {
|
|
100
|
+
if (!debug && !silent) {
|
|
101
|
+
errors.forEach((error) => res.log(error));
|
|
102
|
+
}
|
|
103
|
+
reject(
|
|
104
|
+
new Error(
|
|
105
|
+
`${command} ${args.join(' ')} exited with code ${code}`
|
|
106
|
+
)
|
|
107
|
+
);
|
|
108
|
+
}
|
|
109
|
+
});
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
export default executeAndLog;
|
package/src/modules/{review/src/utilities/setEntryVisibility.js → shared/src/setFileVisibility.js}
RENAMED
|
@@ -1,10 +1,16 @@
|
|
|
1
1
|
import fswin from 'fswin';
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
/**
|
|
4
|
+
* @param {string} filePath
|
|
5
|
+
* @param {boolean} isVisible
|
|
6
|
+
*
|
|
7
|
+
* @return {Promise<void>}
|
|
8
|
+
*/
|
|
9
|
+
export default function setFileVisibility(filePath, isVisible) {
|
|
4
10
|
return new Promise((resolve, reject) => {
|
|
5
11
|
if (fswin) {
|
|
6
12
|
fswin.setAttributes(
|
|
7
|
-
|
|
13
|
+
filePath,
|
|
8
14
|
{ IS_HIDDEN: !isVisible },
|
|
9
15
|
(success) => {
|
|
10
16
|
if (!success) {
|
|
@@ -1,22 +1,105 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
1
|
+
import path from 'path';
|
|
2
|
+
import { fileURLToPath, pathToFileURL } from 'url';
|
|
3
|
+
|
|
4
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
5
|
+
const __dirname = path.dirname(__filename);
|
|
6
|
+
|
|
7
|
+
export default async (moduleRegistration) => {
|
|
8
|
+
const options = {
|
|
9
|
+
licenseProductName: 'spell-checker',
|
|
10
|
+
licensesRequired: ['editor'],
|
|
11
|
+
productLabel: 'Fonto Spell Checker',
|
|
12
|
+
commandPrefix: 'spell-checker',
|
|
13
|
+
|
|
14
|
+
documentationConfigurationGuide:
|
|
15
|
+
'https://documentation.fontoxml.com/latest/fontoxml-spell-checker-4428b1080ce1',
|
|
16
|
+
documentationExecuteError:
|
|
17
|
+
'https://documentation.fontoxml.com/latest/fontoxml-spell-checker-4428b1080ce1',
|
|
18
|
+
documentationGettingStartedGuide:
|
|
19
|
+
'https://documentation.fontoxml.com/latest/fontoxml-spell-checker-4428b1080ce1',
|
|
20
|
+
|
|
21
|
+
defaultHttpPort: 6050,
|
|
22
|
+
defaultImageName: 'fonto-spell-checker',
|
|
23
|
+
defaultImageTag: 'latest',
|
|
24
|
+
|
|
25
|
+
manifestFileName: '.fontoxmlSpellCheckerManifest',
|
|
26
|
+
manifestVersionPropertyName: 'spellCheckerVersion',
|
|
27
|
+
|
|
28
|
+
instanceBuildDockerfilePath: path.join(
|
|
29
|
+
__dirname,
|
|
30
|
+
'instanceBuild',
|
|
31
|
+
'Dockerfile'
|
|
32
|
+
),
|
|
33
|
+
instanceDevBuildDirectoryPath: path.join(__dirname, 'instanceDevBuild'),
|
|
34
|
+
instanceDevBuildDockerfilePath: path.join(
|
|
35
|
+
__dirname,
|
|
36
|
+
'instanceBuild',
|
|
37
|
+
'Dockerfile'
|
|
38
|
+
),
|
|
39
|
+
instanceTemplateDirectoryPath: path.join(__dirname, 'instanceTemplate'),
|
|
40
|
+
|
|
41
|
+
requiredConfiguration: [],
|
|
42
|
+
temporaryDirectoryName: '.spellCheckerTmp',
|
|
43
|
+
temporaryBuildDirectoryName: '.spellCheckerBuildTmp',
|
|
44
|
+
whitelist: [
|
|
45
|
+
// Optional.
|
|
46
|
+
'nlog.config',
|
|
47
|
+
],
|
|
48
|
+
|
|
49
|
+
debugEnvEntries: {
|
|
50
|
+
Logging__LogLevel__Default: 'Trace',
|
|
51
|
+
},
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
const command = moduleRegistration
|
|
55
|
+
.registerCommand(options.commandPrefix)
|
|
56
|
+
.setDescription(
|
|
57
|
+
`Provides tools for working with ${options.productLabel}.`
|
|
58
|
+
)
|
|
59
|
+
|
|
60
|
+
.addRequiredProductLicenses(options.licensesRequired)
|
|
13
61
|
.setHideIfMissingRequiredProductLicenses()
|
|
14
62
|
.setAsHelpCommand();
|
|
15
63
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
64
|
+
if (options.commandAlias) {
|
|
65
|
+
command.addAlias(options.commandAlias);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
const sharedModulePath = moduleRegistration.getPathToModule(
|
|
69
|
+
'@fontoxml/fontoxml-development-tools-module-shared'
|
|
70
|
+
);
|
|
71
|
+
|
|
72
|
+
// Add the docker based commands.
|
|
73
|
+
const addBackendDockerCommandsPath = pathToFileURL(
|
|
74
|
+
path.resolve(sharedModulePath, 'src/addBackendDockerCommands.js')
|
|
75
|
+
);
|
|
76
|
+
const addBackendDockerCommands = (
|
|
77
|
+
await import(addBackendDockerCommandsPath)
|
|
78
|
+
).default;
|
|
79
|
+
addBackendDockerCommands(moduleRegistration, command, options);
|
|
80
|
+
|
|
81
|
+
// Add the version commands.
|
|
82
|
+
const addBackendVersionsCommandsPath = pathToFileURL(
|
|
83
|
+
path.resolve(sharedModulePath, 'src/addBackendVersionsCommands.js')
|
|
84
|
+
);
|
|
85
|
+
const addBackendVersionsCommands = (
|
|
86
|
+
await import(addBackendVersionsCommandsPath)
|
|
87
|
+
).default;
|
|
88
|
+
addBackendVersionsCommands(moduleRegistration, command, options);
|
|
89
|
+
|
|
90
|
+
// Add the download-self-contained command.
|
|
91
|
+
const addBackendDownloadSelfContainedCommandsPath = pathToFileURL(
|
|
92
|
+
path.resolve(
|
|
93
|
+
sharedModulePath,
|
|
94
|
+
'src/addBackendDownloadSelfContainedCommands.js'
|
|
95
|
+
)
|
|
96
|
+
);
|
|
97
|
+
const addBackendDownloadSelfContainedCommands = (
|
|
98
|
+
await import(addBackendDownloadSelfContainedCommandsPath)
|
|
99
|
+
).default;
|
|
100
|
+
addBackendDownloadSelfContainedCommands(
|
|
101
|
+
moduleRegistration,
|
|
102
|
+
command,
|
|
103
|
+
options
|
|
104
|
+
);
|
|
22
105
|
};
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import AskNicely from 'ask-nicely';
|
|
2
|
+
import assert from 'assert';
|
|
3
|
+
import fs from 'fs-extra';
|
|
4
|
+
import path from 'path';
|
|
5
|
+
import { fileURLToPath } from 'url';
|
|
6
|
+
|
|
7
|
+
import { App } from '../index.js';
|
|
8
|
+
|
|
9
|
+
const defaultStdoutColumns = process.stdout.columns;
|
|
10
|
+
|
|
11
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
12
|
+
const __dirname = path.dirname(__filename);
|
|
13
|
+
|
|
14
|
+
async function cleanupAppDir() {
|
|
15
|
+
await new Promise((response, reject) =>
|
|
16
|
+
fs.remove(path.join(process.cwd(), '.fdttestrc'), (err) =>
|
|
17
|
+
err ? reject(err) : response()
|
|
18
|
+
)
|
|
19
|
+
);
|
|
20
|
+
|
|
21
|
+
await new Promise((response, reject) =>
|
|
22
|
+
fs.remove(path.join(__dirname, '..', '.fdttestrc'), (err) =>
|
|
23
|
+
err ? reject(err) : response()
|
|
24
|
+
)
|
|
25
|
+
);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
let app;
|
|
29
|
+
let oldCwd;
|
|
30
|
+
let sharedModulePath;
|
|
31
|
+
let sharedModule;
|
|
32
|
+
|
|
33
|
+
before(cleanupAppDir);
|
|
34
|
+
after(cleanupAppDir);
|
|
35
|
+
|
|
36
|
+
describe('module: shared', () => {
|
|
37
|
+
beforeEach(async () => {
|
|
38
|
+
process.stdout.columns = 150;
|
|
39
|
+
|
|
40
|
+
oldCwd = process.cwd();
|
|
41
|
+
process.chdir(path.join(__dirname, 'app'));
|
|
42
|
+
|
|
43
|
+
app = new App();
|
|
44
|
+
|
|
45
|
+
await app.init({
|
|
46
|
+
appName: 'fontoxml-development-tools-test',
|
|
47
|
+
skipWarnIfNotInsideEditorRepository: true,
|
|
48
|
+
testMode: true,
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
sharedModulePath = path.join(
|
|
52
|
+
__dirname,
|
|
53
|
+
'..',
|
|
54
|
+
'src',
|
|
55
|
+
'modules',
|
|
56
|
+
'shared'
|
|
57
|
+
);
|
|
58
|
+
sharedModule = app.modules.find(
|
|
59
|
+
(c) =>
|
|
60
|
+
c.getInfo().name ===
|
|
61
|
+
'@fontoxml/fontoxml-development-tools-module-shared'
|
|
62
|
+
);
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
afterEach(() => {
|
|
66
|
+
process.chdir(oldCwd);
|
|
67
|
+
|
|
68
|
+
process.stdout.columns = defaultStdoutColumns;
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
it('has enabled this shared module', () => {
|
|
72
|
+
assert.ok(
|
|
73
|
+
app.modules.some(
|
|
74
|
+
(c) =>
|
|
75
|
+
c.getInfo().name ===
|
|
76
|
+
'@fontoxml/fontoxml-development-tools-module-shared'
|
|
77
|
+
)
|
|
78
|
+
);
|
|
79
|
+
assert.ok(app.modules.some((c) => c === sharedModule));
|
|
80
|
+
});
|
|
81
|
+
});
|