@fontoxml/fontoxml-development-tools 3.9.0-beta.2 → 3.9.0-beta.3
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/npm-shrinkwrap.json +13994 -22540
- package/package.json +13 -15
- package/src/addModulesToApp.js +1 -1
- package/src/modules/connectors/index.js +1 -1
- package/src/modules/core/src/command.module.js +1 -1
- package/src/modules/editor/dev-cms/connectors-cms-standard/configureAssetPostRouteHandler.js +0 -11
- package/src/modules/editor/dev-cms/connectors-cms-standard/configureConnectorsCmsStandardAssetRouter.js +0 -3
- package/src/modules/editor/index.js +1 -1
- package/src/modules/editor/src/commands/command.run.controller.js +12 -7
- package/src/modules/editor/src/getWebpackConfig.js +160 -446
- package/src/modules/editor/src/getWebpackDevMiddlewareConfig.js +9 -16
- package/src/modules/editor/src/helpers/getNamesAndPaths.js +167 -0
- package/src/modules/editor/src/helpers/normalisePath.js +2 -2
- package/src/modules/editor/src/templates/app-entry.ts +66 -0
- package/src/modules/editor/src/templates/package.json +3 -0
- package/src/modules/editor/src/webpackLoaders/generatedLoader.cjs +88 -65
- package/src/modules/editor/src/webpackLoaders/platformSourceMapLoader.cjs +8 -10
- package/src/modules/editor/src/webpackLoaders/symbolLoader.cjs +7 -7
- package/src/modules/editor/src/webpackLoaders/vendorsSourceMapLoader.cjs +3 -5
- package/src/modules/editor/src/webpackPlugins/CopyPlugin.js +237 -171
- package/src/modules/editor/src/webpackPlugins/DependenciesInLoadOrderPlugin.js +12 -4
- package/src/modules/editor/src/webpackPlugins/FdtOutputPlugin.js +95 -102
- package/src/modules/editor/src/webpackPlugins/RemoveExplicitExtensionResolvePlugin.js +32 -21
- package/src/modules/editor/src/webpackPlugins/ResolveImportAliasPlugin.js +18 -10
- package/src/modules/editor/src/webpackPlugins/UnitTestPlugin.js +24 -15
- package/src/modules/editor-pre-7-7-0/instanceTemplate/packages/editor-masthead/src/Masthead.jsx +30 -33
- package/src/modules/editor-pre-7-7-0/instanceTemplate/packages/editor-masthead/src/install.js +2 -2
- package/src/modules/editor-pre-7-7-0/instanceTemplate/packages/editor-masthead/src/toolbars/ExampleToolbar.jsx +4 -4
- package/src/modules/editor-pre-7-7-0/instanceTemplateTypeScript/config/.gitkeep +0 -0
- package/src/modules/editor-pre-7-7-0/instanceTemplateTypeScript/config.js +12 -0
- package/src/modules/editor-pre-7-7-0/instanceTemplateTypeScript/dev-cms/files/.gitkeep +0 -0
- package/src/modules/editor-pre-7-7-0/instanceTemplateTypeScript/packages/editor-masthead/src/Masthead.tsx +39 -0
- package/src/modules/editor-pre-7-7-0/instanceTemplateTypeScript/packages/editor-masthead/src/install.ts +7 -0
- package/src/modules/editor-pre-7-7-0/instanceTemplateTypeScript/packages/editor-masthead/src/toolbars/ExampleToolbar.tsx +20 -0
- package/src/modules/editor-pre-7-7-0/instanceTemplateTypeScript/platform/.gitkeep +0 -0
- package/src/modules/editor-pre-7-7-0/instanceTemplateTypeScript/tsconfig.json +6 -0
- package/src/modules/editor-pre-7-7-0/src/api/init/checkEditorDestination.js +1 -0
- package/src/modules/editor-pre-7-7-0/src/api/init/createConfigConfiguration.js +17 -22
- package/src/modules/editor-pre-7-7-0/src/api/init/createSchemaExperienceResolver.js +19 -15
- package/src/modules/editor-pre-7-7-0/src/api/schema/checkIfCompiledSchemaOverwritesFiles.js +5 -5
- package/src/modules/editor-pre-7-7-0/src/api/schema/createSchemaExperiencePackages.js +104 -46
- package/src/modules/editor-pre-7-7-0/src/api/schema/createSchemaPackages.js +32 -26
- package/src/modules/editor-pre-7-7-0/src/command.init.controller.js +17 -12
- package/src/modules/editor-pre-7-7-0/src/command.init.js +6 -0
- package/src/modules/editor-pre-7-7-0/src/command.upgrade.controller.js +25 -0
- package/src/modules/editor/dev-cms/connectors-cms-standard/configureAssetGetRouteHandler.js +0 -29
- package/src/modules/editor/src/templates/app-entry.cjs +0 -69
|
@@ -36,8 +36,8 @@ async function createPackageManifestJsonFile(packageDirectoryPath) {
|
|
|
36
36
|
* Create the schema file for a specific package.
|
|
37
37
|
*
|
|
38
38
|
* @param {string} packageDirectoryPath The path to a single package directory.
|
|
39
|
-
* @param {string} packageName
|
|
40
|
-
* @param {Object} schemaData
|
|
39
|
+
* @param {string} packageName The package name.
|
|
40
|
+
* @param {Object} schemaData The schema data for this package.
|
|
41
41
|
*
|
|
42
42
|
* @return {Promise}
|
|
43
43
|
*/
|
|
@@ -58,25 +58,27 @@ async function createPackageSchemaJsonFile(
|
|
|
58
58
|
}
|
|
59
59
|
|
|
60
60
|
/**
|
|
61
|
-
* Create the SCHEMA_LOCATIONS.js file for a specific package.
|
|
61
|
+
* Create the SCHEMA_LOCATIONS.ts/js file for a specific package.
|
|
62
62
|
*
|
|
63
|
-
* @param {string}
|
|
64
|
-
* @param {Array<string>} schemaLocations
|
|
63
|
+
* @param {string} packageDirectoryPath The path to a single package directory.
|
|
64
|
+
* @param {Array<string>} schemaLocations An array of schema locations for this package.
|
|
65
|
+
* @param {boolean} useTypeScript Output TypeScript instead of JavaScript.
|
|
65
66
|
*
|
|
66
67
|
* @return {Promise}
|
|
67
68
|
*/
|
|
68
69
|
async function createPackageSchemaLocationsJsFile(
|
|
69
70
|
packageDirectoryPath,
|
|
70
|
-
schemaLocations = []
|
|
71
|
+
schemaLocations = [],
|
|
72
|
+
useTypeScript
|
|
71
73
|
) {
|
|
72
|
-
const t = babel
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
const schemaLocationsJsFilePath = path.join(
|
|
74
|
+
const { types: t } = babel;
|
|
75
|
+
|
|
76
|
+
const schemaLocationsFilePath = path.join(
|
|
76
77
|
packageDirectoryPath,
|
|
77
78
|
'src',
|
|
78
|
-
'
|
|
79
|
+
`SCHEMA_LOCATIONS${useTypeScript ? '.ts' : '.js'}`
|
|
79
80
|
);
|
|
81
|
+
|
|
80
82
|
const schemaLocationsJsAst = t.program([
|
|
81
83
|
t.exportDefaultDeclaration(
|
|
82
84
|
t.arrayExpression(
|
|
@@ -86,19 +88,18 @@ async function createPackageSchemaLocationsJsFile(
|
|
|
86
88
|
)
|
|
87
89
|
),
|
|
88
90
|
]);
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
schemaLocationsJsAst
|
|
92
|
-
);
|
|
91
|
+
|
|
92
|
+
await writeAstProgramToFile(schemaLocationsFilePath, schemaLocationsJsAst);
|
|
93
93
|
}
|
|
94
94
|
|
|
95
95
|
/**
|
|
96
96
|
* Create a schema package from a compiled schema.
|
|
97
97
|
*
|
|
98
|
-
* @param {string}
|
|
99
|
-
* @param {Object}
|
|
100
|
-
* @param {Object}
|
|
101
|
-
* @param {string}
|
|
98
|
+
* @param {string} outputPath The path of the Fonto Editor, or the schema source directory.
|
|
99
|
+
* @param {Object} schemaPackagesByXsdPath The package information by xsd path.
|
|
100
|
+
* @param {Object} compiledSchemaResultsByXsdPath The compiled schema for a package by xsd path.
|
|
101
|
+
* @param {string} xsdPath The path of the xsd file for this package.
|
|
102
|
+
* @param {boolean} useTypeScript Output TypeScript instead of JavaScript.
|
|
102
103
|
*
|
|
103
104
|
* @return {Promise}
|
|
104
105
|
*/
|
|
@@ -106,7 +107,8 @@ async function createSchemaPackageFromCompiledSchemaResults(
|
|
|
106
107
|
outputPath,
|
|
107
108
|
schemaPackagesByXsdPath,
|
|
108
109
|
compiledSchemaResultsByXsdPath,
|
|
109
|
-
xsdPath
|
|
110
|
+
xsdPath,
|
|
111
|
+
useTypeScript
|
|
110
112
|
) {
|
|
111
113
|
// Resolve the schema package directory path.
|
|
112
114
|
const schemaPackage = schemaPackagesByXsdPath[xsdPath];
|
|
@@ -124,7 +126,8 @@ async function createSchemaPackageFromCompiledSchemaResults(
|
|
|
124
126
|
),
|
|
125
127
|
await createPackageSchemaLocationsJsFile(
|
|
126
128
|
schemaPackageDirectoryPath,
|
|
127
|
-
schemaPackage.locations
|
|
129
|
+
schemaPackage.locations,
|
|
130
|
+
useTypeScript
|
|
128
131
|
),
|
|
129
132
|
]);
|
|
130
133
|
}
|
|
@@ -133,16 +136,18 @@ async function createSchemaPackageFromCompiledSchemaResults(
|
|
|
133
136
|
* Create all schema packages, will also create the fonto-manifest.json file when the package
|
|
134
137
|
* directory does not yet exists.
|
|
135
138
|
*
|
|
136
|
-
* @param {string}
|
|
137
|
-
* @param {Object}
|
|
138
|
-
* @param {Object}
|
|
139
|
+
* @param {string} outputPath The path of the Fonto Editor, or the schema source directory.
|
|
140
|
+
* @param {Object} schemaPackagesByXsdPath The package information by xsd path.
|
|
141
|
+
* @param {Object} compiledSchemaResultsByXsdPath The compiled schema for a package by xsd path.
|
|
142
|
+
* @param {boolean} useTypeScript Output TypeScript instead of JavaScript.
|
|
139
143
|
*
|
|
140
144
|
* @return {Promise}
|
|
141
145
|
*/
|
|
142
146
|
export default async function createSchemaPackages(
|
|
143
147
|
outputPath,
|
|
144
148
|
schemaPackagesByXsdPath,
|
|
145
|
-
compiledSchemaResultsByXsdPath
|
|
149
|
+
compiledSchemaResultsByXsdPath,
|
|
150
|
+
useTypeScript
|
|
146
151
|
) {
|
|
147
152
|
await Promise.all(
|
|
148
153
|
Object.keys(schemaPackagesByXsdPath).map((xsdPath) => {
|
|
@@ -150,7 +155,8 @@ export default async function createSchemaPackages(
|
|
|
150
155
|
path.resolve(outputPath),
|
|
151
156
|
schemaPackagesByXsdPath,
|
|
152
157
|
compiledSchemaResultsByXsdPath,
|
|
153
|
-
xsdPath
|
|
158
|
+
xsdPath,
|
|
159
|
+
useTypeScript
|
|
154
160
|
);
|
|
155
161
|
})
|
|
156
162
|
);
|
|
@@ -49,6 +49,8 @@ export default async function editorInitCommand(req, res) {
|
|
|
49
49
|
);
|
|
50
50
|
}
|
|
51
51
|
|
|
52
|
+
const useTypeScript = !req.options['output-javascript'];
|
|
53
|
+
|
|
52
54
|
// Check if the required fonto.json path has been specified when running non-interactive.
|
|
53
55
|
if (req.options['non-interactive'] && !req.options['schema']) {
|
|
54
56
|
throw new res.InputError('Missing schema value.');
|
|
@@ -274,15 +276,12 @@ export default async function editorInitCommand(req, res) {
|
|
|
274
276
|
return;
|
|
275
277
|
}
|
|
276
278
|
|
|
277
|
-
// @TODO: @TS: Remove file extensions from imports in template files when
|
|
278
|
-
// supporting TS configuration.
|
|
279
|
-
|
|
280
279
|
// Copy the Fonto Editor instance template.
|
|
281
280
|
destroySpinner = res.spinner('Setting up a new Fonto Editor instance...');
|
|
282
281
|
const templateDirectoryPath = path.join(
|
|
283
282
|
__dirname,
|
|
284
283
|
'..',
|
|
285
|
-
'instanceTemplate'
|
|
284
|
+
useTypeScript ? 'instanceTemplateTypeScript' : 'instanceTemplate'
|
|
286
285
|
);
|
|
287
286
|
try {
|
|
288
287
|
await fs.copy(templateDirectoryPath, editorPath, {
|
|
@@ -308,7 +307,8 @@ export default async function editorInitCommand(req, res) {
|
|
|
308
307
|
await createSchemaPackages(
|
|
309
308
|
editorPath,
|
|
310
309
|
fontoJson.rootSchemas,
|
|
311
|
-
schemaCompileResults
|
|
310
|
+
schemaCompileResults,
|
|
311
|
+
useTypeScript
|
|
312
312
|
);
|
|
313
313
|
} catch (error) {
|
|
314
314
|
throw new res.ErrorWithInnerError(
|
|
@@ -347,7 +347,8 @@ export default async function editorInitCommand(req, res) {
|
|
|
347
347
|
schemaCompileResults,
|
|
348
348
|
prefixByNamespaceUri,
|
|
349
349
|
addons,
|
|
350
|
-
sdkVersion
|
|
350
|
+
sdkVersion,
|
|
351
|
+
useTypeScript
|
|
351
352
|
);
|
|
352
353
|
} catch (error) {
|
|
353
354
|
throw new res.ErrorWithInnerError(
|
|
@@ -380,12 +381,12 @@ export default async function editorInitCommand(req, res) {
|
|
|
380
381
|
destroySpinner();
|
|
381
382
|
}
|
|
382
383
|
|
|
383
|
-
// Creating config/configuration.js.
|
|
384
|
+
// Creating config/configuration.ts/js.
|
|
384
385
|
destroySpinner = res.spinner('Creating the config configuration file...');
|
|
385
386
|
const configConfigurationPath = path.join(
|
|
386
387
|
editorPath,
|
|
387
388
|
'config',
|
|
388
|
-
'
|
|
389
|
+
`configuration${useTypeScript ? '.ts' : '.js'}`
|
|
389
390
|
);
|
|
390
391
|
try {
|
|
391
392
|
await createConfigConfiguration(
|
|
@@ -397,21 +398,23 @@ export default async function editorInitCommand(req, res) {
|
|
|
397
398
|
);
|
|
398
399
|
} catch (error) {
|
|
399
400
|
throw new res.ErrorWithInnerError(
|
|
400
|
-
|
|
401
|
+
`Could not create the config/configuration${
|
|
402
|
+
useTypeScript ? '.ts' : '.js'
|
|
403
|
+
} file.`,
|
|
401
404
|
error
|
|
402
405
|
);
|
|
403
406
|
} finally {
|
|
404
407
|
destroySpinner();
|
|
405
408
|
}
|
|
406
409
|
|
|
407
|
-
// Creating config/schemaExperienceResolver.js.
|
|
410
|
+
// Creating config/schemaExperienceResolver.ts/js.
|
|
408
411
|
destroySpinner = res.spinner(
|
|
409
412
|
'Creating the config schema experience resolver file...'
|
|
410
413
|
);
|
|
411
414
|
const schemaExperienceResolverPath = path.join(
|
|
412
415
|
editorPath,
|
|
413
416
|
'config',
|
|
414
|
-
'
|
|
417
|
+
`schemaExperienceResolver${useTypeScript ? '.ts' : '.js'}`
|
|
415
418
|
);
|
|
416
419
|
try {
|
|
417
420
|
await createSchemaExperienceResolver(
|
|
@@ -420,7 +423,9 @@ export default async function editorInitCommand(req, res) {
|
|
|
420
423
|
);
|
|
421
424
|
} catch (error) {
|
|
422
425
|
throw new res.ErrorWithInnerError(
|
|
423
|
-
|
|
426
|
+
`Could not create the config/schemaExperienceResolver${
|
|
427
|
+
useTypeScript ? '.ts' : '.js'
|
|
428
|
+
} file.`,
|
|
424
429
|
error
|
|
425
430
|
);
|
|
426
431
|
} finally {
|
|
@@ -56,6 +56,12 @@ export default (moduleRegistration, editorCommand) => {
|
|
|
56
56
|
'Specify the schema compiler backend base url.'
|
|
57
57
|
)
|
|
58
58
|
|
|
59
|
+
.addHiddenOption(
|
|
60
|
+
'output-javascript',
|
|
61
|
+
undefined,
|
|
62
|
+
'Generate JavaScript instead of TypeScript.'
|
|
63
|
+
)
|
|
64
|
+
|
|
59
65
|
.addOption(
|
|
60
66
|
'version',
|
|
61
67
|
undefined,
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import fs from 'fs-extra';
|
|
2
2
|
import path from 'path';
|
|
3
3
|
import unzipper from 'unzipper';
|
|
4
|
+
import { fileURLToPath } from 'url';
|
|
4
5
|
|
|
5
6
|
import { isPre770Editor } from '../../../editorVersions.js';
|
|
6
7
|
import convertEditorWithOutput from '../../editor/src/commands/api/convertEditorWithOutput.js';
|
|
@@ -18,6 +19,9 @@ import updateConfigFontoManifest from './api/upgrade/updateConfigFontoManifest.j
|
|
|
18
19
|
import validateAddons from './api/validateAddons.js';
|
|
19
20
|
import validateManifest from './api/validateManifest.js';
|
|
20
21
|
|
|
22
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
23
|
+
const __dirname = path.dirname(__filename);
|
|
24
|
+
|
|
21
25
|
export default async function editorUpgradeCommand(req, res) {
|
|
22
26
|
if (req.options['remove-backup']) {
|
|
23
27
|
// DEV-9386
|
|
@@ -308,6 +312,27 @@ export default async function editorUpgradeCommand(req, res) {
|
|
|
308
312
|
);
|
|
309
313
|
}
|
|
310
314
|
|
|
315
|
+
// Set up code intelligence if there's a base tsconfig.json and it hasn't
|
|
316
|
+
// been set up yet.
|
|
317
|
+
const platformHasTsConfig = await fs.pathExists(
|
|
318
|
+
path.join(editorPath, 'platform', 'tsconfig.json')
|
|
319
|
+
);
|
|
320
|
+
if (platformHasTsConfig) {
|
|
321
|
+
await fs.copy(
|
|
322
|
+
path.resolve(
|
|
323
|
+
__dirname,
|
|
324
|
+
'..',
|
|
325
|
+
'instanceTemplateTypeScript',
|
|
326
|
+
'tsconfig.json'
|
|
327
|
+
),
|
|
328
|
+
path.resolve(editorPath, 'tsconfig.json'),
|
|
329
|
+
{
|
|
330
|
+
// Silently fail when target already exists.
|
|
331
|
+
overwrite: false,
|
|
332
|
+
}
|
|
333
|
+
);
|
|
334
|
+
}
|
|
335
|
+
|
|
311
336
|
await req.fdt.license.sendTelemetry({
|
|
312
337
|
product: req.command.parent.name,
|
|
313
338
|
type: 'selfContained',
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
function configureAssetGetRouteHandler(config) {
|
|
2
|
-
return (req, res) => {
|
|
3
|
-
const editSessionToken =
|
|
4
|
-
req.query &&
|
|
5
|
-
req.query.context &&
|
|
6
|
-
JSON.parse(req.query.context).editSessionToken;
|
|
7
|
-
|
|
8
|
-
let id = req.query.id;
|
|
9
|
-
if (id && id.indexOf('..') !== -1) {
|
|
10
|
-
res.status(403).end();
|
|
11
|
-
return;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
// Strip assets and /assets prefixes
|
|
15
|
-
id = id.replace(/^\/?assets/g, '');
|
|
16
|
-
|
|
17
|
-
const filePath = req.cms.getPath(id, editSessionToken);
|
|
18
|
-
if (filePath) {
|
|
19
|
-
res.sendFile(filePath, {
|
|
20
|
-
cacheControl: !config.cacheControlDisabled,
|
|
21
|
-
maxAge: config.cacheControlMaxAge,
|
|
22
|
-
});
|
|
23
|
-
} else {
|
|
24
|
-
res.status(404).end();
|
|
25
|
-
}
|
|
26
|
-
};
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
export default configureAssetGetRouteHandler;
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
(function appEntry() {
|
|
2
|
-
return Promise.resolve()
|
|
3
|
-
.then(function () {
|
|
4
|
-
window.startFontoBootstrap();
|
|
5
|
-
|
|
6
|
-
require('fontoxml-shims/src/main');
|
|
7
|
-
|
|
8
|
-
const glamor = require('glamor');
|
|
9
|
-
glamor.styleSheet.maxLength = 4;
|
|
10
|
-
glamor.plugins.remove(
|
|
11
|
-
glamor.plugins.fns.find(function (pluginFn) {
|
|
12
|
-
return pluginFn.name === 'prefixes';
|
|
13
|
-
})
|
|
14
|
-
);
|
|
15
|
-
|
|
16
|
-
const getQueryParameterByName =
|
|
17
|
-
require('fontoxml-utils/src/getQueryParameterByName').default;
|
|
18
|
-
const scope = getQueryParameterByName(
|
|
19
|
-
window.location.search,
|
|
20
|
-
'scope'
|
|
21
|
-
);
|
|
22
|
-
const configurationManager =
|
|
23
|
-
require('fontoxml-configuration/src/configurationManager').default;
|
|
24
|
-
configurationManager.set('scope', scope ? JSON.parse(scope) : {});
|
|
25
|
-
configurationManager.set(
|
|
26
|
-
'version-info',
|
|
27
|
-
require('./generated?type=versionInfo').default
|
|
28
|
-
);
|
|
29
|
-
configurationManager.set(
|
|
30
|
-
'fonto-debug-build',
|
|
31
|
-
require('./generated?type=debugBuild').default
|
|
32
|
-
);
|
|
33
|
-
|
|
34
|
-
require('./generated?type=styles');
|
|
35
|
-
|
|
36
|
-
require('./generated?type=setDefaultConfiguration');
|
|
37
|
-
|
|
38
|
-
require('config/configuration');
|
|
39
|
-
|
|
40
|
-
return configurationManager.applyDefaults();
|
|
41
|
-
})
|
|
42
|
-
.then(function () {
|
|
43
|
-
require('./generated?type=messages');
|
|
44
|
-
|
|
45
|
-
require('./generated?type=configureSxModule');
|
|
46
|
-
|
|
47
|
-
require('config/schemaExperienceResolver');
|
|
48
|
-
|
|
49
|
-
require('./generated?type=install');
|
|
50
|
-
|
|
51
|
-
require('react');
|
|
52
|
-
const ReactDOM = require('react-dom');
|
|
53
|
-
const renderApp = require('fontoxml-editor/src/renderApp').default;
|
|
54
|
-
|
|
55
|
-
ReactDOM.render(
|
|
56
|
-
renderApp(),
|
|
57
|
-
window.document.getElementById('index-app-root')
|
|
58
|
-
);
|
|
59
|
-
|
|
60
|
-
window.completeFontoBootstrap();
|
|
61
|
-
})
|
|
62
|
-
.catch(function (error) {
|
|
63
|
-
if (window.showFontoError) {
|
|
64
|
-
window.showFontoError(error);
|
|
65
|
-
} else {
|
|
66
|
-
throw error;
|
|
67
|
-
}
|
|
68
|
-
});
|
|
69
|
-
})();
|