@nlabs/lex 1.46.1 → 1.47.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/__mocks__/LexConfig.js +20 -0
- package/__mocks__/boxen.js +7 -0
- package/__mocks__/build.js +16 -0
- package/__mocks__/chalk.js +23 -0
- package/__mocks__/compile.js +8 -0
- package/__mocks__/execa.js +21 -0
- package/__mocks__/ora.js +17 -0
- package/__mocks__/versions.js +12 -0
- package/dist/LexConfig.js +72 -14
- package/dist/commands/ai/ai.js +303 -0
- package/dist/commands/ai/index.js +7 -0
- package/dist/commands/build/build.js +350 -0
- package/dist/commands/clean/clean.js +31 -0
- package/dist/commands/compile/compile.js +195 -0
- package/dist/commands/config/config.js +43 -0
- package/dist/commands/copy/copy.js +38 -0
- package/dist/commands/create/create.js +124 -0
- package/dist/commands/dev/dev.js +70 -0
- package/dist/commands/init/init.js +93 -0
- package/dist/commands/link/link.js +15 -0
- package/dist/commands/lint/lint.js +656 -0
- package/dist/commands/migrate/migrate.js +37 -0
- package/dist/commands/publish/publish.js +104 -0
- package/dist/commands/test/test.js +327 -0
- package/dist/commands/update/update.js +62 -0
- package/dist/commands/upgrade/upgrade.js +47 -0
- package/dist/commands/versions/versions.js +41 -0
- package/dist/create/changelog.js +3 -3
- package/dist/index.js +35 -0
- package/dist/jest.config.lex.d.ts +2 -0
- package/dist/lex.js +25 -22
- package/dist/types.js +1 -0
- package/dist/utils/aiService.js +290 -0
- package/dist/utils/app.js +4 -4
- package/dist/utils/file.js +1 -1
- package/dist/utils/log.js +2 -1
- package/dist/utils/reactShim.js +3 -3
- package/dist/webpack.config.d.ts +2 -0
- package/eslint.config.js +10 -0
- package/index.cjs +20 -0
- package/jest.config.cjs +31 -27
- package/jest.config.lex.js +90 -38
- package/jest.setup.js +5 -0
- package/lex.config.js +50 -0
- package/package.json +70 -50
- package/{.postcssrc.js → postcss.config.js} +21 -9
- package/tsconfig.build.json +7 -16
- package/tsconfig.json +2 -1
- package/webpack.config.js +136 -77
- package/.eslintrc +0 -45
- package/dist/commands/build.js +0 -265
- package/dist/commands/bulid.test.js +0 -317
- package/dist/commands/clean.js +0 -31
- package/dist/commands/clean.test.js +0 -63
- package/dist/commands/compile.js +0 -195
- package/dist/commands/compile.test.js +0 -93
- package/dist/commands/config.js +0 -43
- package/dist/commands/copy.js +0 -38
- package/dist/commands/create.js +0 -116
- package/dist/commands/dev.js +0 -70
- package/dist/commands/init.js +0 -93
- package/dist/commands/link.js +0 -15
- package/dist/commands/lint.js +0 -179
- package/dist/commands/migrate.js +0 -37
- package/dist/commands/publish.js +0 -104
- package/dist/commands/test.js +0 -190
- package/dist/commands/update.js +0 -64
- package/dist/commands/upgrade.js +0 -47
- package/dist/commands/versions.js +0 -41
- package/dist/commands/versions.test.js +0 -49
- package/dist/lint.js +0 -11
- package/jest.setup.ts +0 -3
package/webpack.config.js
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
* Copyrights licensed under the MIT License. See the accompanying LICENSE file for terms.
|
|
4
4
|
*/
|
|
5
5
|
import {StaticSitePlugin} from '@nlabs/webpack-plugin-static-site';
|
|
6
|
+
import tailwindcss from '@tailwindcss/postcss';
|
|
6
7
|
import autoprefixer from 'autoprefixer';
|
|
7
8
|
import CompressionWebpackPlugin from 'compression-webpack-plugin';
|
|
8
9
|
import CopyWebpackPlugin from 'copy-webpack-plugin';
|
|
@@ -25,6 +26,7 @@ import postcssPercentage from 'postcss-percentage';
|
|
|
25
26
|
import postcssPresetEnv from 'postcss-preset-env';
|
|
26
27
|
import postcssUrl from 'postcss-url';
|
|
27
28
|
import SVGSpriteMapPlugin from 'svg-spritemap-webpack-plugin';
|
|
29
|
+
import TsconfigPathsPlugin from 'tsconfig-paths-webpack-plugin';
|
|
28
30
|
import {URL} from 'url';
|
|
29
31
|
import {default as webpack} from 'webpack';
|
|
30
32
|
import {BundleAnalyzerPlugin} from 'webpack-bundle-analyzer';
|
|
@@ -60,7 +62,10 @@ const plugins = [
|
|
|
60
62
|
dependencies: true,
|
|
61
63
|
percentBy: null
|
|
62
64
|
}),
|
|
63
|
-
new DotenvPlugin({
|
|
65
|
+
new DotenvPlugin({
|
|
66
|
+
path: pathResolve(process.cwd(), '.env'),
|
|
67
|
+
systemvars: false
|
|
68
|
+
})
|
|
64
69
|
];
|
|
65
70
|
|
|
66
71
|
const isWeb = (preset || targetEnvironment) === 'web';
|
|
@@ -87,23 +92,29 @@ const globOptions = {
|
|
|
87
92
|
const svgPaths = `${sourceFullPath}/icons/**/**.svg`;
|
|
88
93
|
|
|
89
94
|
if(globSync(svgPaths, globOptions).length) {
|
|
90
|
-
plugins.push(
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
95
|
+
plugins.push(
|
|
96
|
+
new SVGSpriteMapPlugin(svgPaths, {
|
|
97
|
+
input: {
|
|
98
|
+
allowDuplicates: false
|
|
99
|
+
},
|
|
100
|
+
output: {
|
|
101
|
+
chunk: {keep: true},
|
|
102
|
+
filename: './icons/icons.svg'
|
|
103
|
+
},
|
|
104
|
+
sprite: {
|
|
105
|
+
prefix: false
|
|
106
|
+
}
|
|
107
|
+
})
|
|
108
|
+
);
|
|
102
109
|
}
|
|
103
110
|
|
|
104
111
|
// If there is are static directories, make sure we copy the files over
|
|
105
112
|
const staticPaths = [];
|
|
106
|
-
const watchIgnorePaths = [
|
|
113
|
+
const watchIgnorePaths = [
|
|
114
|
+
`${sourceFullPath}/**/**.gif`,
|
|
115
|
+
`${sourceFullPath}/**/**.jpg`,
|
|
116
|
+
`${sourceFullPath}/**/**.png`
|
|
117
|
+
];
|
|
107
118
|
const imagePath = `${sourceFullPath}/images/`;
|
|
108
119
|
const fontPath = `${sourceFullPath}/fonts/`;
|
|
109
120
|
const docPath = `${sourceFullPath}/docs/`;
|
|
@@ -127,13 +138,15 @@ if(staticPaths.length) {
|
|
|
127
138
|
}
|
|
128
139
|
|
|
129
140
|
if(existsSync(`${sourceFullPath}/${lexConfig.entryHTML}`)) {
|
|
130
|
-
plugins.push(
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
141
|
+
plugins.push(
|
|
142
|
+
new HtmlWebPackPlugin({
|
|
143
|
+
filename: './index.html',
|
|
144
|
+
minify: isProduction,
|
|
145
|
+
scriptLoading: 'defer',
|
|
146
|
+
showErrors: !isProduction,
|
|
147
|
+
template: `${sourceFullPath}/${lexConfig.entryHTML}`
|
|
148
|
+
})
|
|
149
|
+
);
|
|
137
150
|
}
|
|
138
151
|
|
|
139
152
|
let outputFilename = outputFile;
|
|
@@ -146,6 +159,13 @@ if(outputFile) {
|
|
|
146
159
|
outputFilename = '[name].js';
|
|
147
160
|
}
|
|
148
161
|
|
|
162
|
+
const resolvePlugins = [];
|
|
163
|
+
if(existsSync(`${sourceFullPath}/tsconfig.json`)) {
|
|
164
|
+
resolvePlugins.push(new TsconfigPathsPlugin({
|
|
165
|
+
configFile: `${sourceFullPath}/../tsconfig.json`
|
|
166
|
+
}));
|
|
167
|
+
}
|
|
168
|
+
|
|
149
169
|
// Loader paths
|
|
150
170
|
const esbuildLoaderPath = relativeNodePath('esbuild-loader', dirName);
|
|
151
171
|
const cssLoaderPath = relativeNodePath('css-loader', dirName);
|
|
@@ -161,7 +181,10 @@ const webpackPath = relativeNodePath('webpack', dirName);
|
|
|
161
181
|
// Aliases
|
|
162
182
|
const aliasPaths = {
|
|
163
183
|
'@nlabs/arkhamjs': relativeNodePath('@nlabs/arkhamjs', process.cwd()),
|
|
164
|
-
'@nlabs/arkhamjs-utils-react': relativeNodePath(
|
|
184
|
+
'@nlabs/arkhamjs-utils-react': relativeNodePath(
|
|
185
|
+
'@nlabs/arkhamjs-utils-react',
|
|
186
|
+
process.cwd()
|
|
187
|
+
),
|
|
165
188
|
'core-js': relativeNodePath('core-js', dirName),
|
|
166
189
|
process: relativeNodePath('process', dirName),
|
|
167
190
|
react: relativeNodePath('react', process.cwd()),
|
|
@@ -183,7 +206,9 @@ export default (webpackEnv, webpackOptions) => {
|
|
|
183
206
|
const webpackConfig = {
|
|
184
207
|
bail: true,
|
|
185
208
|
cache: !isProduction,
|
|
186
|
-
devtool: isProduction
|
|
209
|
+
devtool: isProduction
|
|
210
|
+
? 'inline-cheap-module-source-map'
|
|
211
|
+
: 'eval-cheap-module-source-map',
|
|
187
212
|
entry: {
|
|
188
213
|
index: `${sourceFullPath}/${lexConfig.entryJs}`
|
|
189
214
|
},
|
|
@@ -249,26 +274,32 @@ export default (webpackEnv, webpackOptions) => {
|
|
|
249
274
|
postcssOptions: {
|
|
250
275
|
plugins: [
|
|
251
276
|
postcssImport({addDependencyTo: webpack}),
|
|
252
|
-
postcssUrl,
|
|
253
|
-
postcssFor,
|
|
277
|
+
postcssUrl(),
|
|
278
|
+
postcssFor(),
|
|
254
279
|
postcssPercentage({
|
|
255
280
|
floor: true,
|
|
256
281
|
precision: 9,
|
|
257
282
|
trimTrailingZero: true
|
|
258
283
|
}),
|
|
259
284
|
postcssCustomProperties({
|
|
285
|
+
extensions: ['.css'],
|
|
286
|
+
inject: {
|
|
287
|
+
insertAt: 'top'
|
|
288
|
+
},
|
|
289
|
+
minimize: true,
|
|
260
290
|
preserve: false,
|
|
261
291
|
strict: false,
|
|
262
292
|
warnings: false
|
|
263
293
|
}),
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
294
|
+
tailwindcss(),
|
|
295
|
+
autoprefixer(),
|
|
296
|
+
postcssNesting(),
|
|
297
|
+
postcssFlexbugsFixes(),
|
|
267
298
|
postcssPresetEnv({
|
|
268
299
|
stage: 0
|
|
269
300
|
}),
|
|
270
301
|
cssnano({autoprefixer: false}),
|
|
271
|
-
postcssBrowserReporter
|
|
302
|
+
postcssBrowserReporter()
|
|
272
303
|
]
|
|
273
304
|
}
|
|
274
305
|
}
|
|
@@ -302,26 +333,29 @@ export default (webpackEnv, webpackOptions) => {
|
|
|
302
333
|
}
|
|
303
334
|
]
|
|
304
335
|
},
|
|
305
|
-
optimization:
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
336
|
+
optimization:
|
|
337
|
+
isProduction && isWeb
|
|
338
|
+
? {
|
|
339
|
+
minimizer: [
|
|
340
|
+
new EsbuildPlugin({
|
|
341
|
+
css: true,
|
|
342
|
+
target: targetEnvironment
|
|
343
|
+
})
|
|
344
|
+
],
|
|
345
|
+
runtimeChunk: 'single',
|
|
346
|
+
splitChunks: {
|
|
347
|
+
cacheGroups: {
|
|
348
|
+
vendor: {
|
|
349
|
+
chunks: 'all',
|
|
350
|
+
minSize: 0,
|
|
351
|
+
name: 'vendors',
|
|
352
|
+
test: /[\\/]node_modules[\\/]/
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
},
|
|
356
|
+
usedExports: true
|
|
321
357
|
}
|
|
322
|
-
|
|
323
|
-
usedExports: true
|
|
324
|
-
} : {},
|
|
358
|
+
: {},
|
|
325
359
|
output: {
|
|
326
360
|
filename: outputFilename,
|
|
327
361
|
library: libraryName,
|
|
@@ -333,9 +367,20 @@ export default (webpackEnv, webpackOptions) => {
|
|
|
333
367
|
recordsPath: relativeFilePath('webpack.records.json', process.cwd()),
|
|
334
368
|
resolve: {
|
|
335
369
|
alias,
|
|
336
|
-
extensions: [
|
|
370
|
+
extensions: [
|
|
371
|
+
'.*',
|
|
372
|
+
'.mjs',
|
|
373
|
+
'.js',
|
|
374
|
+
'.ts',
|
|
375
|
+
'.tsx',
|
|
376
|
+
'.jsx',
|
|
377
|
+
'.json',
|
|
378
|
+
'.gql',
|
|
379
|
+
'.graphql'
|
|
380
|
+
],
|
|
337
381
|
fallback: {
|
|
338
382
|
assert: relativeNodePath('assert', dirName),
|
|
383
|
+
buffer: relativeNodePath('buffer', dirName),
|
|
339
384
|
crypto: relativeNodePath('crypto-browserify', dirName),
|
|
340
385
|
http: relativeNodePath('stream-http', dirName),
|
|
341
386
|
https: relativeNodePath('https-browserify', dirName),
|
|
@@ -343,10 +388,12 @@ export default (webpackEnv, webpackOptions) => {
|
|
|
343
388
|
path: relativeNodePath('path-browserify', dirName),
|
|
344
389
|
process: relativeNodePath('process/browser.js', dirName),
|
|
345
390
|
stream: relativeNodePath('stream-browserify', dirName),
|
|
346
|
-
util: relativeNodePath('util', dirName)
|
|
391
|
+
util: relativeNodePath('util', dirName),
|
|
392
|
+
vm: relativeNodePath('vm-browserify', dirName)
|
|
347
393
|
},
|
|
348
394
|
mainFiles: ['index'],
|
|
349
395
|
modules: [sourceFullPath, 'node_modules', relativeNodePath('', dirName)],
|
|
396
|
+
plugins: resolvePlugins,
|
|
350
397
|
unsafeCache: {
|
|
351
398
|
node_modules: true
|
|
352
399
|
}
|
|
@@ -361,7 +408,10 @@ export default (webpackEnv, webpackOptions) => {
|
|
|
361
408
|
webpack: webpackPath
|
|
362
409
|
};
|
|
363
410
|
webpackConfig.optimization = {minimize: false};
|
|
364
|
-
webpackConfig.entry.wps = relativeNodePath(
|
|
411
|
+
webpackConfig.entry.wps = relativeNodePath(
|
|
412
|
+
'webpack-plugin-serve/client.js',
|
|
413
|
+
dirName
|
|
414
|
+
);
|
|
365
415
|
webpackConfig.stats = {errorDetails: true};
|
|
366
416
|
webpackConfig.plugins.push(
|
|
367
417
|
new WebpackPluginServe({
|
|
@@ -370,7 +420,7 @@ export default (webpackEnv, webpackOptions) => {
|
|
|
370
420
|
},
|
|
371
421
|
historyFallback: {
|
|
372
422
|
disableDotRule: true,
|
|
373
|
-
htmlAcceptHeaders: ['text/html','*/*'],
|
|
423
|
+
htmlAcceptHeaders: ['text/html', '*/*'],
|
|
374
424
|
index: '/index.html',
|
|
375
425
|
logger: console.log.bind(console),
|
|
376
426
|
rewrites: [
|
|
@@ -400,23 +450,27 @@ export default (webpackEnv, webpackOptions) => {
|
|
|
400
450
|
},
|
|
401
451
|
hmr: false,
|
|
402
452
|
log: {level: 'trace'},
|
|
403
|
-
middleware: (app) =>
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
453
|
+
middleware: (app) =>
|
|
454
|
+
app.use(async (ctx, next) => {
|
|
455
|
+
if(ctx.path.match(/^\/wps/)) {
|
|
456
|
+
const {accept, Accept, ...remainingHeaders} =
|
|
457
|
+
ctx.request.header;
|
|
458
|
+
ctx.request.header = remainingHeaders;
|
|
459
|
+
}
|
|
460
|
+
await next();
|
|
461
|
+
}),
|
|
410
462
|
open: process.env.WEBPACK_DEV_OPEN === 'true',
|
|
411
463
|
port: 7001,
|
|
412
464
|
progress: 'minimal',
|
|
413
465
|
static: [outputFullPath],
|
|
414
466
|
status: true
|
|
415
|
-
})
|
|
467
|
+
})
|
|
416
468
|
);
|
|
417
469
|
|
|
418
470
|
if(bundleAnalyzer) {
|
|
419
|
-
webpackConfig.plugins.push(
|
|
471
|
+
webpackConfig.plugins.push(
|
|
472
|
+
new BundleAnalyzerPlugin({openAnalyzer: false})
|
|
473
|
+
);
|
|
420
474
|
}
|
|
421
475
|
|
|
422
476
|
if(watch) {
|
|
@@ -432,25 +486,30 @@ export default (webpackEnv, webpackOptions) => {
|
|
|
432
486
|
const siteLogo = `${sourceFullPath}/images/logo.png`;
|
|
433
487
|
|
|
434
488
|
if(existsSync(siteLogo)) {
|
|
435
|
-
plugins.push(
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
489
|
+
plugins.push(
|
|
490
|
+
new FaviconsWebpackPlugin({
|
|
491
|
+
icons: {
|
|
492
|
+
android: true,
|
|
493
|
+
appleIcon: true,
|
|
494
|
+
appleStartup: false,
|
|
495
|
+
coast: false,
|
|
496
|
+
favicons: true,
|
|
497
|
+
firefox: false,
|
|
498
|
+
opengraph: true,
|
|
499
|
+
twitter: true,
|
|
500
|
+
windows: false,
|
|
501
|
+
yandex: false
|
|
502
|
+
},
|
|
503
|
+
logo: siteLogo
|
|
504
|
+
})
|
|
505
|
+
);
|
|
450
506
|
}
|
|
451
507
|
|
|
452
508
|
if(isStatic) {
|
|
453
|
-
webpackConfig.plugins.push(
|
|
509
|
+
webpackConfig.plugins.push(
|
|
510
|
+
new StaticSitePlugin(),
|
|
511
|
+
new webpack.HashedModuleIdsPlugin()
|
|
512
|
+
);
|
|
454
513
|
}
|
|
455
514
|
}
|
|
456
515
|
|
package/.eslintrc
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"extends": [
|
|
3
|
-
"styleguidejs/typescript"
|
|
4
|
-
],
|
|
5
|
-
"rules": {
|
|
6
|
-
"import/order": [
|
|
7
|
-
"error",
|
|
8
|
-
{
|
|
9
|
-
"groups": [
|
|
10
|
-
"builtin",
|
|
11
|
-
"external",
|
|
12
|
-
"internal",
|
|
13
|
-
"parent",
|
|
14
|
-
"sibling",
|
|
15
|
-
"index"
|
|
16
|
-
],
|
|
17
|
-
"pathGroups": [
|
|
18
|
-
{
|
|
19
|
-
"pattern": "#!",
|
|
20
|
-
"group": "builtin",
|
|
21
|
-
"position": "before"
|
|
22
|
-
},
|
|
23
|
-
{
|
|
24
|
-
"pattern": "/**/*|//*",
|
|
25
|
-
"group": "builtin",
|
|
26
|
-
"position": "after"
|
|
27
|
-
},
|
|
28
|
-
{
|
|
29
|
-
"pattern": "type *",
|
|
30
|
-
"group": "index",
|
|
31
|
-
"position": "after"
|
|
32
|
-
}
|
|
33
|
-
],
|
|
34
|
-
"newlines-between": "always",
|
|
35
|
-
"alphabetize": {
|
|
36
|
-
"order": "asc",
|
|
37
|
-
"caseInsensitive": true
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
],
|
|
41
|
-
"import/extensions": 0,
|
|
42
|
-
"jest/valid-expect": 0,
|
|
43
|
-
"no-useless-escape": 0
|
|
44
|
-
}
|
|
45
|
-
}
|