@fontoxml/fontoxml-development-tools 3.9.0-beta.4 → 3.9.0-beta.7
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 +2 -2
- package/package.json +1 -1
- package/src/modules/editor/src/getWebpackConfig.js +39 -8
- package/src/modules/editor/src/webpackPlugins/CheckDeepImportsResolvePlugin.js +123 -0
- package/src/modules/editor/src/webpackPlugins/FdtOutputPlugin.js +22 -3
- package/src/modules/editor-pre-7-7-0/instanceTemplateTypeScript/package.json +5 -0
- package/src/modules/editor-pre-7-7-0/src/command.init.controller.js +3 -5
- package/src/modules/editor-pre-7-7-0/src/command.upgrade.controller.js +23 -1
package/npm-shrinkwrap.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fontoxml/fontoxml-development-tools",
|
|
3
|
-
"version": "3.9.0-beta.
|
|
3
|
+
"version": "3.9.0-beta.7",
|
|
4
4
|
"lockfileVersion": 2,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "@fontoxml/fontoxml-development-tools",
|
|
9
|
-
"version": "3.9.0-beta.
|
|
9
|
+
"version": "3.9.0-beta.7",
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@babel/core": "7.14.6",
|
package/package.json
CHANGED
|
@@ -10,6 +10,7 @@ import webpack from 'webpack';
|
|
|
10
10
|
|
|
11
11
|
import normalisePath from '../src/helpers/normalisePath.js';
|
|
12
12
|
import getNamesAndPaths from './helpers/getNamesAndPaths.js';
|
|
13
|
+
import CheckDeepImportsResolvePlugin from './webpackPlugins/CheckDeepImportsResolvePlugin.js';
|
|
13
14
|
import CopyPlugin from './webpackPlugins/CopyPlugin.js';
|
|
14
15
|
import DependenciesInLoadOrderPlugin from './webpackPlugins/DependenciesInLoadOrderPlugin.js';
|
|
15
16
|
import FdtOutputPlugin from './webpackPlugins/FdtOutputPlugin.js';
|
|
@@ -44,6 +45,9 @@ export default function getWebpackConfig(appConfig, appManifest, options) {
|
|
|
44
45
|
generatedFile: picomatch.makeRe(paths.generatedFile),
|
|
45
46
|
|
|
46
47
|
// Folders
|
|
48
|
+
config: picomatch.makeRe(`${paths.configFolder}**/*`),
|
|
49
|
+
packages: picomatch.makeRe(`${paths.packagesFolder}**/*`),
|
|
50
|
+
packagesShared: picomatch.makeRe(`${paths.packagesSharedFolder}**/*`),
|
|
47
51
|
platform: picomatch.makeRe(`${paths.platformFolder}**/*`),
|
|
48
52
|
platformVendors: picomatch.makeRe(`${paths.platformVendorsFolder}**/*`),
|
|
49
53
|
platformLinkedVendors: picomatch.makeRe(
|
|
@@ -51,8 +55,25 @@ export default function getWebpackConfig(appConfig, appManifest, options) {
|
|
|
51
55
|
),
|
|
52
56
|
srcFolder: picomatch.makeRe(`${paths.srcFolder}**/*`),
|
|
53
57
|
testAssets: picomatch.makeRe(`${paths.testAssetsFolder}**/*`),
|
|
58
|
+
|
|
59
|
+
// Deep imports
|
|
60
|
+
platformDeepImport: picomatch.makeRe(
|
|
61
|
+
`${paths.platformFolder}*/src/*/**/*`
|
|
62
|
+
),
|
|
63
|
+
platformLinkedDeepImport: picomatch.makeRe(
|
|
64
|
+
`${paths.platformLinkedFolder}*/src/*/**/*`
|
|
65
|
+
),
|
|
54
66
|
};
|
|
55
67
|
|
|
68
|
+
// Used to share some state between (resolve) plugins.
|
|
69
|
+
const fdtOutputPlugin =
|
|
70
|
+
!appConfig.verbose && options.fdtResponse
|
|
71
|
+
? new FdtOutputPlugin({
|
|
72
|
+
inDevelopmentMode: options.inDevelopmentMode,
|
|
73
|
+
res: options.fdtResponse,
|
|
74
|
+
})
|
|
75
|
+
: null;
|
|
76
|
+
|
|
56
77
|
return {
|
|
57
78
|
context: paths.srcFolder,
|
|
58
79
|
entry: !options.unitTest ? paths.entryFile : undefined,
|
|
@@ -297,13 +318,8 @@ export default function getWebpackConfig(appConfig, appManifest, options) {
|
|
|
297
318
|
new MiniCssExtractPlugin({
|
|
298
319
|
filename: names.outputCssFile,
|
|
299
320
|
}),
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
: !!options.fdtResponse &&
|
|
303
|
-
new FdtOutputPlugin({
|
|
304
|
-
inDevelopmentMode: options.inDevelopmentMode,
|
|
305
|
-
res: options.fdtResponse,
|
|
306
|
-
}),
|
|
321
|
+
fdtOutputPlugin ||
|
|
322
|
+
(!options.unitTest && new webpack.ProgressPlugin()),
|
|
307
323
|
!options.unitTest &&
|
|
308
324
|
new HtmlWebpackPlugin({
|
|
309
325
|
editor: {
|
|
@@ -354,7 +370,22 @@ export default function getWebpackConfig(appConfig, appManifest, options) {
|
|
|
354
370
|
new RemoveExplicitExtensionResolvePlugin({
|
|
355
371
|
extensions: resolveExtensions,
|
|
356
372
|
}),
|
|
357
|
-
|
|
373
|
+
!options.unitTest &&
|
|
374
|
+
new CheckDeepImportsResolvePlugin({
|
|
375
|
+
extensions: resolveExtensions,
|
|
376
|
+
contextFolder: paths.contextFolder,
|
|
377
|
+
issuerRegExps: [
|
|
378
|
+
regExps.packages,
|
|
379
|
+
regExps.packagesShared,
|
|
380
|
+
regExps.config,
|
|
381
|
+
],
|
|
382
|
+
importPathRegExps: [
|
|
383
|
+
regExps.platformDeepImport,
|
|
384
|
+
regExps.platformLinkedDeepImport,
|
|
385
|
+
],
|
|
386
|
+
fdtOutputPlugin,
|
|
387
|
+
}),
|
|
388
|
+
].filter(Boolean),
|
|
358
389
|
// Module resolution is attempted in the order defined here.
|
|
359
390
|
modules: paths.packageRootFolders,
|
|
360
391
|
symlinks: false,
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import path from 'path';
|
|
2
|
+
|
|
3
|
+
import normalisePath from '../helpers/normalisePath.js';
|
|
4
|
+
|
|
5
|
+
/** @typedef {import('enhanced-resolve').Resolver} Resolver */
|
|
6
|
+
|
|
7
|
+
const firstPathSegmentRegExp = /^.+?\//;
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Converts the given path to something that approximates its import identifier.
|
|
11
|
+
*
|
|
12
|
+
* @param {string} targetPath
|
|
13
|
+
* @returns {string}
|
|
14
|
+
*/
|
|
15
|
+
function getApproximateImportIdentifierForPath(targetPath) {
|
|
16
|
+
const parsedTargetPath = path.parse(targetPath);
|
|
17
|
+
|
|
18
|
+
targetPath = normalisePath(
|
|
19
|
+
path.join(parsedTargetPath.dir, parsedTargetPath.name)
|
|
20
|
+
);
|
|
21
|
+
|
|
22
|
+
return targetPath.replace(firstPathSegmentRegExp, '');
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
class DeepImportWarning extends Error {
|
|
26
|
+
/**
|
|
27
|
+
* @param {string} message
|
|
28
|
+
* @param {string} file
|
|
29
|
+
*/
|
|
30
|
+
constructor(message, file) {
|
|
31
|
+
super(message);
|
|
32
|
+
|
|
33
|
+
this.file = file;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
toString() {
|
|
37
|
+
return this.file
|
|
38
|
+
? `WARNING in ${this.file}:\n${this.message}`
|
|
39
|
+
: `WARNING: ${this.message}`;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* This plugin generates a warning for imports to platform/ or platform-linked/ from from config/,
|
|
45
|
+
* packages/ or packages-shared/ that do not point to something in a package's 'src' folder.
|
|
46
|
+
*/
|
|
47
|
+
export default class CheckDeepImportsResolvePlugin {
|
|
48
|
+
constructor(options = {}) {
|
|
49
|
+
this.options = options;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* @param {Resolver} resolver
|
|
54
|
+
*/
|
|
55
|
+
apply(resolver) {
|
|
56
|
+
resolver
|
|
57
|
+
.getHook('resolved')
|
|
58
|
+
.tapAsync(
|
|
59
|
+
CheckDeepImportsResolvePlugin.name,
|
|
60
|
+
(request, _resolveContext, callback) => {
|
|
61
|
+
// Can only check if there's an issuer and a resolved path.
|
|
62
|
+
// Issuer: path to the file from which the import originates.
|
|
63
|
+
// Path: path to the file to which the import resolves.
|
|
64
|
+
if (
|
|
65
|
+
!request.context ||
|
|
66
|
+
!request.context.issuer ||
|
|
67
|
+
!request.path
|
|
68
|
+
) {
|
|
69
|
+
return callback();
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
if (
|
|
73
|
+
// Only check imports to code (i.e. .js, .ts, .jsx, .tsx).
|
|
74
|
+
// The .xqm and .svg files are transformed by a loader which do a deep
|
|
75
|
+
// import to XQueryModule and SVGModule respectively, for which no warning
|
|
76
|
+
// is needed.
|
|
77
|
+
this.options.extensions.includes(
|
|
78
|
+
path.posix.extname(request.context.issuer)
|
|
79
|
+
) &&
|
|
80
|
+
// Only check certain issuers (i.e. packages/, packages-shared/, config/).
|
|
81
|
+
this.options.issuerRegExps.some((regExp) =>
|
|
82
|
+
regExp.test(request.context.issuer)
|
|
83
|
+
) &&
|
|
84
|
+
// Does the import target an undesired path?
|
|
85
|
+
this.options.importPathRegExps.some((regExp) =>
|
|
86
|
+
regExp.test(request.path)
|
|
87
|
+
)
|
|
88
|
+
) {
|
|
89
|
+
// Make the absolute paths easier to read.
|
|
90
|
+
const relativePath = path.relative(
|
|
91
|
+
this.options.contextFolder,
|
|
92
|
+
request.path
|
|
93
|
+
);
|
|
94
|
+
const relativeIssuer = path.relative(
|
|
95
|
+
this.options.contextFolder,
|
|
96
|
+
request.context.issuer
|
|
97
|
+
);
|
|
98
|
+
|
|
99
|
+
// We don't have access to the import identifier matching the resolved path
|
|
100
|
+
// at this point, so approximate it for the warning message. Should be about
|
|
101
|
+
// right most of the time, but we can't say for sure.
|
|
102
|
+
const importIdentifier =
|
|
103
|
+
getApproximateImportIdentifierForPath(relativePath);
|
|
104
|
+
|
|
105
|
+
// Pass the warning to the output plugin so it can properly output it after
|
|
106
|
+
// the compilation finishes.
|
|
107
|
+
const warning = new DeepImportWarning(
|
|
108
|
+
`Import "${importIdentifier}" is not supported and might cause problems in future versions.`,
|
|
109
|
+
relativeIssuer
|
|
110
|
+
);
|
|
111
|
+
if (this.options.fdtOutputPlugin) {
|
|
112
|
+
this.options.fdtOutputPlugin.warn(warning);
|
|
113
|
+
} else {
|
|
114
|
+
console.warn(`\n${warning.toString()}`);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
// We do not need to mutate the request, so call the callback without arguments.
|
|
119
|
+
return callback();
|
|
120
|
+
}
|
|
121
|
+
);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
@@ -24,10 +24,18 @@ export default class FdtOutputPlugin {
|
|
|
24
24
|
this.resetState();
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
+
/**
|
|
28
|
+
* @param {Error} warning
|
|
29
|
+
*/
|
|
30
|
+
warn(warning) {
|
|
31
|
+
this.warnings.push(warning);
|
|
32
|
+
}
|
|
33
|
+
|
|
27
34
|
resetState() {
|
|
28
35
|
this.previousBuildMessageTimestamp = 0;
|
|
29
36
|
this.previousProgressIsBuild = false;
|
|
30
37
|
this.previousRoundedPercentage = null;
|
|
38
|
+
this.warnings = [];
|
|
31
39
|
}
|
|
32
40
|
|
|
33
41
|
/**
|
|
@@ -80,7 +88,10 @@ export default class FdtOutputPlugin {
|
|
|
80
88
|
}ms`
|
|
81
89
|
: `Build done at ${endTimestamp}`;
|
|
82
90
|
|
|
83
|
-
if (
|
|
91
|
+
if (
|
|
92
|
+
stats &&
|
|
93
|
+
(stats.hasErrors() || stats.hasWarnings() || this.warnings.length)
|
|
94
|
+
) {
|
|
84
95
|
this.res.needsClearing = true;
|
|
85
96
|
this.res.clearIfNeeded();
|
|
86
97
|
|
|
@@ -91,8 +102,16 @@ export default class FdtOutputPlugin {
|
|
|
91
102
|
moduleTrace: true,
|
|
92
103
|
warnings: true,
|
|
93
104
|
});
|
|
94
|
-
|
|
95
|
-
|
|
105
|
+
if (errorsAndWarnings) {
|
|
106
|
+
this.res.raw(errorsAndWarnings);
|
|
107
|
+
this.res.raw(os.EOL);
|
|
108
|
+
}
|
|
109
|
+
if (this.warnings.length) {
|
|
110
|
+
for (const warning of this.warnings) {
|
|
111
|
+
this.res.notice(warning.toString());
|
|
112
|
+
this.res.raw(os.EOL);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
96
115
|
|
|
97
116
|
this.res[stats.hasErrors() ? 'error' : 'notice'](
|
|
98
117
|
stats.hasErrors() && stats.hasWarnings()
|
|
@@ -4,7 +4,7 @@ import path from 'path';
|
|
|
4
4
|
import unzipper from 'unzipper';
|
|
5
5
|
import { fileURLToPath } from 'url';
|
|
6
6
|
|
|
7
|
-
import { isNightly
|
|
7
|
+
import { isNightly } from '../../../editorVersions.js';
|
|
8
8
|
import addonsAddDependencies from './api/addonsAddDependencies.js';
|
|
9
9
|
import createMessageTemplate from './api/createMessageTemplate.js';
|
|
10
10
|
import downloadEditorSDK from './api/downloadEditorSDK.js';
|
|
@@ -535,10 +535,8 @@ export default async function editorInitCommand(req, res) {
|
|
|
535
535
|
|
|
536
536
|
destroySpinner();
|
|
537
537
|
|
|
538
|
-
//
|
|
539
|
-
|
|
540
|
-
await npmInstall(editorPath, res);
|
|
541
|
-
}
|
|
538
|
+
// Install NPM depencencies when there's a package.json.
|
|
539
|
+
await npmInstall(editorPath, res);
|
|
542
540
|
|
|
543
541
|
// Done.
|
|
544
542
|
res.break();
|
|
@@ -331,6 +331,21 @@ export default async function editorUpgradeCommand(req, res) {
|
|
|
331
331
|
overwrite: false,
|
|
332
332
|
}
|
|
333
333
|
);
|
|
334
|
+
|
|
335
|
+
// Add a package.json with a TypeScript dependency when there's none.
|
|
336
|
+
await fs.copy(
|
|
337
|
+
path.resolve(
|
|
338
|
+
__dirname,
|
|
339
|
+
'..',
|
|
340
|
+
'instanceTemplateTypeScript',
|
|
341
|
+
'package.json'
|
|
342
|
+
),
|
|
343
|
+
path.resolve(editorPath, 'package.json'),
|
|
344
|
+
{
|
|
345
|
+
// Silently fail when target already exists.
|
|
346
|
+
overwrite: false,
|
|
347
|
+
}
|
|
348
|
+
);
|
|
334
349
|
}
|
|
335
350
|
|
|
336
351
|
await req.fdt.license.sendTelemetry({
|
|
@@ -365,5 +380,12 @@ export default async function editorUpgradeCommand(req, res) {
|
|
|
365
380
|
|
|
366
381
|
// Done.
|
|
367
382
|
res.break();
|
|
368
|
-
res.notice('
|
|
383
|
+
res.notice('You succesfully upgraded Fonto Editor!');
|
|
384
|
+
if (platformHasTsConfig) {
|
|
385
|
+
res.break();
|
|
386
|
+
res.notice('For setting up code intelligence and/or TypeScript, see:');
|
|
387
|
+
res.notice(
|
|
388
|
+
'https://documentation.fontoxml.com/latest/typescript-f488eb98fb35'
|
|
389
|
+
);
|
|
390
|
+
}
|
|
369
391
|
}
|