@nx/remix 16.3.0 → 16.4.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/generators.json +19 -3
- package/package.json +3 -2
- package/plugins/component-testing/index.d.ts +31 -0
- package/plugins/component-testing/index.js +59 -0
- package/plugins/component-testing/index.js.map +1 -0
- package/src/generators/application/__snapshots__/application.impl.spec.ts.snap +68 -4
- package/src/generators/application/application.impl.js +24 -11
- package/src/generators/application/application.impl.js.map +1 -1
- package/src/generators/application/lib/index.d.ts +1 -1
- package/src/generators/application/lib/index.js +1 -1
- package/src/generators/application/lib/update-unit-test-config.d.ts +2 -0
- package/src/generators/application/lib/update-unit-test-config.js +30 -0
- package/src/generators/application/lib/update-unit-test-config.js.map +1 -0
- package/src/generators/application/schema.d.ts +1 -1
- package/src/generators/application/schema.json +9 -2
- package/src/generators/cypress-component-configuration/cypress-component-configuration.impl.d.ts +3 -0
- package/src/generators/cypress-component-configuration/cypress-component-configuration.impl.js +25 -0
- package/src/generators/cypress-component-configuration/cypress-component-configuration.impl.js.map +1 -0
- package/src/generators/cypress-component-configuration/files/cypress.config.ts__tmpl__ +6 -0
- package/src/generators/cypress-component-configuration/schema.d.ts +5 -0
- package/src/generators/cypress-component-configuration/schema.json +41 -0
- package/src/generators/library/lib/add-unit-testing.js +1 -0
- package/src/generators/library/lib/add-unit-testing.js.map +1 -1
- package/src/generators/storybook-configuration/__snapshots__/storybook-configuration.impl.spec.ts.snap +67 -0
- package/src/generators/storybook-configuration/files/vite.config.ts__tpl__ +15 -0
- package/src/generators/storybook-configuration/schema.d.ts +15 -0
- package/src/generators/storybook-configuration/schema.json +96 -0
- package/src/generators/storybook-configuration/storybook-configuration.impl.d.ts +3 -0
- package/src/generators/storybook-configuration/storybook-configuration.impl.js +19 -0
- package/src/generators/storybook-configuration/storybook-configuration.impl.js.map +1 -0
- package/src/index.d.ts +4 -0
- package/src/index.js +4 -0
- package/src/index.js.map +1 -1
- package/src/utils/testing-config-utils.js +28 -15
- package/src/utils/testing-config-utils.js.map +1 -1
- package/src/generators/application/lib/update-vite-test-config.d.ts +0 -2
- package/src/generators/application/lib/update-vite-test-config.js +0 -23
- package/src/generators/application/lib/update-vite-test-config.js.map +0 -1
package/generators.json
CHANGED
|
@@ -2,7 +2,9 @@
|
|
|
2
2
|
"$schema": "http://json-schema.org/schema",
|
|
3
3
|
"name": "NxRemix",
|
|
4
4
|
"version": "0.0.1",
|
|
5
|
-
"extends": [
|
|
5
|
+
"extends": [
|
|
6
|
+
"@nx/react"
|
|
7
|
+
],
|
|
6
8
|
"generators": {
|
|
7
9
|
"preset": {
|
|
8
10
|
"implementation": "./src/generators/preset/preset.impl",
|
|
@@ -20,14 +22,23 @@
|
|
|
20
22
|
"implementation": "./src/generators/application/application.impl",
|
|
21
23
|
"schema": "./src/generators/application/schema.json",
|
|
22
24
|
"description": "Generate a new Remix application",
|
|
23
|
-
"aliases": [
|
|
25
|
+
"aliases": [
|
|
26
|
+
"app"
|
|
27
|
+
],
|
|
24
28
|
"x-type": "application"
|
|
25
29
|
},
|
|
30
|
+
"cypress-component-configuration": {
|
|
31
|
+
"implementation": "./src/generators/cypress-component-configuration/cypress-component-configuration.impl",
|
|
32
|
+
"schema": "./src/generators/cypress-component-configuration/schema.json",
|
|
33
|
+
"description": "Generate a Cypress Component Testing configuration for a Remix project"
|
|
34
|
+
},
|
|
26
35
|
"library": {
|
|
27
36
|
"implementation": "./src/generators/library/library.impl",
|
|
28
37
|
"schema": "./src/generators/library/schema.json",
|
|
29
38
|
"description": "Generate a new library",
|
|
30
|
-
"aliases": [
|
|
39
|
+
"aliases": [
|
|
40
|
+
"lib"
|
|
41
|
+
],
|
|
31
42
|
"x-type": "library"
|
|
32
43
|
},
|
|
33
44
|
"route": {
|
|
@@ -60,6 +71,11 @@
|
|
|
60
71
|
"schema": "./src/generators/setup-tailwind/schema.json",
|
|
61
72
|
"description": "Generates a TailwindCSS configuration for the Remix application"
|
|
62
73
|
},
|
|
74
|
+
"storybook-configuration": {
|
|
75
|
+
"implementation": "./src/generators/storybook-configuration/storybook-configuration.impl",
|
|
76
|
+
"schema": "./src/generators/storybook-configuration/schema.json",
|
|
77
|
+
"description": "Generates a Storybook configuration for a Remix application"
|
|
78
|
+
},
|
|
63
79
|
"meta": {
|
|
64
80
|
"implementation": "./src/generators/meta/meta.impl",
|
|
65
81
|
"schema": "./src/generators/meta/schema.json",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nx/remix",
|
|
3
|
-
"version": "16.
|
|
3
|
+
"version": "16.4.0",
|
|
4
4
|
"main": "src/index.js",
|
|
5
5
|
"generators": "./generators.json",
|
|
6
6
|
"dependencies": {
|
|
@@ -9,7 +9,8 @@
|
|
|
9
9
|
"@nx/react": "^16.0.3",
|
|
10
10
|
"@phenomnomnominal/tsquery": "^5.0.1",
|
|
11
11
|
"tslib": "^2.3.1",
|
|
12
|
-
"
|
|
12
|
+
"vite": "4.3.9",
|
|
13
|
+
"@nrwl/remix": "16.4.0"
|
|
13
14
|
},
|
|
14
15
|
"ng-update": {
|
|
15
16
|
"requirements": {},
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
type ViteDevServer = {
|
|
2
|
+
framework: 'react';
|
|
3
|
+
bundler: 'vite';
|
|
4
|
+
viteConfig?: any;
|
|
5
|
+
};
|
|
6
|
+
/**
|
|
7
|
+
* Remix nx preset for Cypress Component Testing
|
|
8
|
+
*
|
|
9
|
+
* This preset contains the base configuration
|
|
10
|
+
* for your component tests that nx recommends.
|
|
11
|
+
* including a devServer that supports nx workspaces.
|
|
12
|
+
* you can easily extend this within your cypress config via spreading the preset
|
|
13
|
+
* @example
|
|
14
|
+
* export default defineConfig({
|
|
15
|
+
* component: {
|
|
16
|
+
* ...nxComponentTestingPreset(__dirname)
|
|
17
|
+
* // add your own config here
|
|
18
|
+
* }
|
|
19
|
+
* })
|
|
20
|
+
*
|
|
21
|
+
* @param pathToConfig will be used for loading project options and to construct the output paths for videos and screenshots
|
|
22
|
+
*/
|
|
23
|
+
export declare function nxComponentTestingPreset(pathToConfig: string): {
|
|
24
|
+
specPattern: string;
|
|
25
|
+
devServer: ViteDevServer;
|
|
26
|
+
videosFolder: string;
|
|
27
|
+
screenshotsFolder: string;
|
|
28
|
+
video: boolean;
|
|
29
|
+
chromeWebSecurity: boolean;
|
|
30
|
+
};
|
|
31
|
+
export {};
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.nxComponentTestingPreset = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const cypress_preset_1 = require("@nx/cypress/plugins/cypress-preset");
|
|
6
|
+
const devkit_1 = require("@nx/devkit");
|
|
7
|
+
const fs_1 = require("fs");
|
|
8
|
+
const path_1 = require("path");
|
|
9
|
+
/**
|
|
10
|
+
* Remix nx preset for Cypress Component Testing
|
|
11
|
+
*
|
|
12
|
+
* This preset contains the base configuration
|
|
13
|
+
* for your component tests that nx recommends.
|
|
14
|
+
* including a devServer that supports nx workspaces.
|
|
15
|
+
* you can easily extend this within your cypress config via spreading the preset
|
|
16
|
+
* @example
|
|
17
|
+
* export default defineConfig({
|
|
18
|
+
* component: {
|
|
19
|
+
* ...nxComponentTestingPreset(__dirname)
|
|
20
|
+
* // add your own config here
|
|
21
|
+
* }
|
|
22
|
+
* })
|
|
23
|
+
*
|
|
24
|
+
* @param pathToConfig will be used for loading project options and to construct the output paths for videos and screenshots
|
|
25
|
+
*/
|
|
26
|
+
function nxComponentTestingPreset(pathToConfig) {
|
|
27
|
+
const normalizedProjectRootPath = ['.ts', '.js'].some((ext) => pathToConfig.endsWith(ext))
|
|
28
|
+
? pathToConfig
|
|
29
|
+
: (0, path_1.dirname)(pathToConfig);
|
|
30
|
+
return Object.assign(Object.assign({}, (0, cypress_preset_1.nxBaseCypressPreset)(pathToConfig)), { specPattern: 'src/**/*.cy.{js,jsx,ts,tsx}', devServer: Object.assign(Object.assign({}, { framework: 'react', bundler: 'vite' }), { viteConfig: () => tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
31
|
+
const viteConfigPath = findViteConfig(normalizedProjectRootPath);
|
|
32
|
+
const { mergeConfig, loadConfigFromFile, searchForWorkspaceRoot } = yield Promise.resolve().then(() => require('vite'));
|
|
33
|
+
const resolved = yield loadConfigFromFile({
|
|
34
|
+
mode: 'watch',
|
|
35
|
+
command: 'serve',
|
|
36
|
+
}, viteConfigPath);
|
|
37
|
+
return mergeConfig(resolved.config, {
|
|
38
|
+
server: {
|
|
39
|
+
fs: {
|
|
40
|
+
allow: [
|
|
41
|
+
searchForWorkspaceRoot(normalizedProjectRootPath),
|
|
42
|
+
devkit_1.workspaceRoot,
|
|
43
|
+
(0, devkit_1.joinPathFragments)(devkit_1.workspaceRoot, 'node_modules/vite'),
|
|
44
|
+
],
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
});
|
|
48
|
+
}) }) });
|
|
49
|
+
}
|
|
50
|
+
exports.nxComponentTestingPreset = nxComponentTestingPreset;
|
|
51
|
+
function findViteConfig(projectRootFullPath) {
|
|
52
|
+
const allowsExt = ['js', 'mjs', 'ts', 'cjs', 'mts', 'cts'];
|
|
53
|
+
for (const ext of allowsExt) {
|
|
54
|
+
if ((0, fs_1.existsSync)((0, path_1.join)(projectRootFullPath, `vite.config.${ext}`))) {
|
|
55
|
+
return (0, path_1.join)(projectRootFullPath, `vite.config.${ext}`);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../packages/remix/plugins/component-testing/index.ts"],"names":[],"mappings":";;;;AAAA,uEAAyE;AACzE,uCAA8D;AAE9D,2BAAgC;AAChC,+BAAqC;AAQrC;;;;;;;;;;;;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AAC,IAAA,WAAI,EAAC,mBAAmB,EAAE,eAAe,GAAG,EAAE,CAAC,CAAC,EAAE;YAC/D,OAAO,IAAA,WAAI,EAAC,mBAAmB,EAAE,eAAe,GAAG,EAAE,CAAC,CAAC;SACxD;KACF;AACH,CAAC"}
|
|
@@ -258,7 +258,7 @@ exports[`Remix Application Integrated Repo --js should create the application co
|
|
|
258
258
|
"
|
|
259
259
|
`;
|
|
260
260
|
|
|
261
|
-
exports[`Remix Application Integrated Repo --unitTestRunner should generate the correct files for testing 1`] = `
|
|
261
|
+
exports[`Remix Application Integrated Repo --unitTestRunner should generate the correct files for testing using jest 1`] = `
|
|
262
262
|
"/**
|
|
263
263
|
* @type {import('@remix-run/dev').AppConfig}
|
|
264
264
|
*/
|
|
@@ -273,7 +273,37 @@ module.exports = {
|
|
|
273
273
|
"
|
|
274
274
|
`;
|
|
275
275
|
|
|
276
|
-
exports[`Remix Application Integrated Repo --unitTestRunner should generate the correct files for testing 2`] = `
|
|
276
|
+
exports[`Remix Application Integrated Repo --unitTestRunner should generate the correct files for testing using jest 2`] = `
|
|
277
|
+
"/* eslint-disable */
|
|
278
|
+
export default {
|
|
279
|
+
setupFilesAfterEnv: ['<rootDir>/test-setup.ts'],
|
|
280
|
+
displayName: 'test',
|
|
281
|
+
preset: '../../jest.preset.js',
|
|
282
|
+
transform: {
|
|
283
|
+
'^.+\\\\\\\\.[tj]sx?$': ['ts-jest', { tsconfig: '<rootDir>/tsconfig.spec.json' }],
|
|
284
|
+
},
|
|
285
|
+
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx'],
|
|
286
|
+
coverageDirectory: '../../coverage/apps/test',
|
|
287
|
+
};
|
|
288
|
+
"
|
|
289
|
+
`;
|
|
290
|
+
|
|
291
|
+
exports[`Remix Application Integrated Repo --unitTestRunner should generate the correct files for testing using vitest 1`] = `
|
|
292
|
+
"/**
|
|
293
|
+
* @type {import('@remix-run/dev').AppConfig}
|
|
294
|
+
*/
|
|
295
|
+
module.exports = {
|
|
296
|
+
ignoredRouteFiles: ['**/.*'],
|
|
297
|
+
// appDirectory: \\"app\\",
|
|
298
|
+
// assetsBuildDirectory: \\"public/build\\",
|
|
299
|
+
// serverBuildPath: \\"build/index.js\\",
|
|
300
|
+
// publicPath: \\"/build/\\",
|
|
301
|
+
watchPaths: () => require('@nx/remix').createWatchPaths(__dirname),
|
|
302
|
+
};
|
|
303
|
+
"
|
|
304
|
+
`;
|
|
305
|
+
|
|
306
|
+
exports[`Remix Application Integrated Repo --unitTestRunner should generate the correct files for testing using vitest 2`] = `
|
|
277
307
|
"/// <reference types=\\"vitest\\" />
|
|
278
308
|
import react from '@vitejs/plugin-react';
|
|
279
309
|
import { defineConfig } from 'vite';
|
|
@@ -482,7 +512,41 @@ exports[`Remix Application Standalone Project Repo --js should create the applic
|
|
|
482
512
|
"
|
|
483
513
|
`;
|
|
484
514
|
|
|
485
|
-
exports[`Remix Application Standalone Project Repo --unitTestRunner should generate the correct files for testing 1`] = `
|
|
515
|
+
exports[`Remix Application Standalone Project Repo --unitTestRunner should generate the correct files for testing using jest 1`] = `
|
|
516
|
+
"/**
|
|
517
|
+
* @type {import('@remix-run/dev').AppConfig}
|
|
518
|
+
*/
|
|
519
|
+
module.exports = {
|
|
520
|
+
ignoredRouteFiles: ['**/.*'],
|
|
521
|
+
// appDirectory: \\"app\\",
|
|
522
|
+
// assetsBuildDirectory: \\"public/build\\",
|
|
523
|
+
// serverBuildPath: \\"build/index.js\\",
|
|
524
|
+
// publicPath: \\"/build/\\",
|
|
525
|
+
watchPaths: () => require('@nx/remix').createWatchPaths(__dirname),
|
|
526
|
+
};
|
|
527
|
+
"
|
|
528
|
+
`;
|
|
529
|
+
|
|
530
|
+
exports[`Remix Application Standalone Project Repo --unitTestRunner should generate the correct files for testing using jest 2`] = `
|
|
531
|
+
"/* eslint-disable */
|
|
532
|
+
export default {
|
|
533
|
+
setupFilesAfterEnv: ['<rootDir>/test-setup.ts'],
|
|
534
|
+
displayName: 'test',
|
|
535
|
+
preset: './jest.preset.js',
|
|
536
|
+
transform: {
|
|
537
|
+
'^.+\\\\\\\\.[tj]sx?$': ['ts-jest', { tsconfig: '<rootDir>/tsconfig.spec.json' }],
|
|
538
|
+
},
|
|
539
|
+
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx'],
|
|
540
|
+
coverageDirectory: './coverage/test',
|
|
541
|
+
testMatch: [
|
|
542
|
+
'<rootDir>/src/**/__tests__/**/*.[jt]s?(x)',
|
|
543
|
+
'<rootDir>/src/**/*(*.)@(spec|test).[jt]s?(x)',
|
|
544
|
+
],
|
|
545
|
+
};
|
|
546
|
+
"
|
|
547
|
+
`;
|
|
548
|
+
|
|
549
|
+
exports[`Remix Application Standalone Project Repo --unitTestRunner should generate the correct files for testing using vitest 1`] = `
|
|
486
550
|
"/**
|
|
487
551
|
* @type {import('@remix-run/dev').AppConfig}
|
|
488
552
|
*/
|
|
@@ -497,7 +561,7 @@ module.exports = {
|
|
|
497
561
|
"
|
|
498
562
|
`;
|
|
499
563
|
|
|
500
|
-
exports[`Remix Application Standalone Project Repo --unitTestRunner should generate the correct files for testing 2`] = `
|
|
564
|
+
exports[`Remix Application Standalone Project Repo --unitTestRunner should generate the correct files for testing using vitest 2`] = `
|
|
501
565
|
"/// <reference types=\\"vitest\\" />
|
|
502
566
|
import react from '@vitejs/plugin-react';
|
|
503
567
|
import { defineConfig } from 'vite';
|
|
@@ -75,17 +75,30 @@ function default_1(tree, _options) {
|
|
|
75
75
|
else {
|
|
76
76
|
(0, devkit_1.generateFiles)(tree, (0, devkit_1.joinPathFragments)(__dirname, 'files/integrated'), options.projectRoot, vars);
|
|
77
77
|
}
|
|
78
|
-
if (options.unitTestRunner
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
78
|
+
if (options.unitTestRunner !== 'none') {
|
|
79
|
+
if (options.unitTestRunner === 'vitest') {
|
|
80
|
+
const { vitestGenerator } = (0, devkit_1.ensurePackage)('@nx/vite', (0, versions_1.getPackageVersion)(tree, 'nx'));
|
|
81
|
+
const vitestTask = yield vitestGenerator(tree, {
|
|
82
|
+
uiFramework: 'react',
|
|
83
|
+
project: options.projectName,
|
|
84
|
+
coverageProvider: 'c8',
|
|
85
|
+
inSourceTests: false,
|
|
86
|
+
skipFormat: true,
|
|
87
|
+
testEnvironment: 'jsdom',
|
|
88
|
+
});
|
|
89
|
+
tasks.push(vitestTask);
|
|
90
|
+
}
|
|
91
|
+
else {
|
|
92
|
+
const { jestProjectGenerator } = (0, devkit_1.ensurePackage)('@nx/jest', (0, versions_1.getPackageVersion)(tree, 'nx'));
|
|
93
|
+
const jestTask = yield jestProjectGenerator(tree, {
|
|
94
|
+
project: options.projectName,
|
|
95
|
+
skipFormat: true,
|
|
96
|
+
setupFile: 'none',
|
|
97
|
+
supportTsx: true,
|
|
98
|
+
});
|
|
99
|
+
tasks.push(jestTask);
|
|
100
|
+
}
|
|
101
|
+
const pkgInstallTask = (0, lib_1.updateUnitTestConfig)(tree, options.projectRoot, options.unitTestRunner);
|
|
89
102
|
tasks.push(pkgInstallTask);
|
|
90
103
|
}
|
|
91
104
|
if (options.js) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"application.impl.js","sourceRoot":"","sources":["../../../../../../packages/remix/src/generators/application/application.impl.ts"],"names":[],"mappings":";;;AAAA,uCAcoB;AACpB,mFAAmF;AACnF,mDAU8B;AAC9B,0DAAuD;AACvD,+BAA+D;AAG/D,mBAA+B,IAAU,EAAE,QAAgC;;QACzE,MAAM,OAAO,GAAG,IAAA,sBAAgB,EAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;QACjD,MAAM,KAAK,GAAwB,EAAE,CAAC;QAEtC,IAAA,gCAAuB,EAAC,IAAI,EAAE,OAAO,CAAC,WAAW,EAAE;YACjD,IAAI,EAAE,OAAO,CAAC,WAAW;YACzB,UAAU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Z,uBAAY;YACZ,YAAY,EAAZ,uBAAY;YACZ,eAAe,EAAf,0BAAe;YACf,iBAAiB,EAAjB,4BAAiB;YACjB,oBAAoB,EAApB,+BAAoB;YACpB,aAAa,EAAb,wBAAa;YACb,iBAAiB,EAAjB,4BAAiB,GAClB,CAAC;QAEF,IAAA,sBAAa,EACX,IAAI,EACJ,IAAA,0BAAiB,EAAC,SAAS,EAAE,cAAc,CAAC,EAC5C,OAAO,CAAC,WAAW,EACnB,IAAI,CACL,CAAC;QAEF,IAAI,OAAO,CAAC,WAAW,EAAE;YACvB,MAAM,SAAS,GAAG,IAAI,CAAC,IAAI,CAAC,YAAY,EAAE,OAAO,CAAC,CAAC;YACnD,IAAI,CAAC,KAAK,CACR,YAAY,EACZ,GAAG,SAAS,uCAAuC,CACpD,CAAC;SACH;aAAM;YACL,IAAA,sBAAa,EACX,IAAI,EACJ,IAAA,0BAAiB,EAAC,SAAS,EAAE,kBAAkB,CAAC,EAChD,OAAO,CAAC,WAAW,EACnB,IAAI,CACL,CAAC;SACH;QAED,IAAI,OAAO,CAAC,cAAc,KAAK,QAAQ,EAAE;
|
|
1
|
+
{"version":3,"file":"application.impl.js","sourceRoot":"","sources":["../../../../../../packages/remix/src/generators/application/application.impl.ts"],"names":[],"mappings":";;;AAAA,uCAcoB;AACpB,mFAAmF;AACnF,mDAU8B;AAC9B,0DAAuD;AACvD,+BAA+D;AAG/D,mBAA+B,IAAU,EAAE,QAAgC;;QACzE,MAAM,OAAO,GAAG,IAAA,sBAAgB,EAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;QACjD,MAAM,KAAK,GAAwB,EAAE,CAAC;QAEtC,IAAA,gCAAuB,EAAC,IAAI,EAAE,OAAO,CAAC,WAAW,EAAE;YACjD,IAAI,EAAE,OAAO,CAAC,WAAW;YACzB,UAAU,EAAE,GAAG,OAAO,CAAC,WAAW,EAAE;YACpC,WAAW,EAAE,aAAa;YAC1B,IAAI,EAAE,OAAO,CAAC,UAAU;YACxB,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O,mCAAI,EAAE,CAAC;iBACxB,CAAC;gBACF,OAAO,IAAI,CAAC;YACd,CAAC,CAAC,CAAC;YACH,IAAI,CAAC,MAAM,CAAC,oBAAoB,CAAC,CAAC;SACnC;aAAM;YACL,yFAAyF;YACzF,IAAA,sCAAmB,EAAC,IAAI,CAAC,CAAC;SAC3B;QAED,IAAI,OAAO,CAAC,aAAa,KAAK,SAAS,EAAE;YACvC,MAAM,YAAY,GAAG,MAAM,IAAA,sBAAgB,EAAC,IAAI,EAAE;gBAChD,OAAO,EAAE,OAAO,CAAC,WAAW;gBAC5B,IAAI,EAAE,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,WAAW,MAAM;aACjE,CAAC,CAAC;YACH,KAAK,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;SAC1B;QAED,IAAI,CAAC,OAAO,CAAC,UAAU,EAAE;YACvB,MAAM,IAAA,oBAAW,EAAC,IAAI,CAAC,CAAC;SACzB;QAED,OAAO,IAAA,yBAAgB,EAAC,GAAG,KAAK,CAAC,CAAC;IACpC,CAAC;CAAA;AAtLD,4BAsLC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export * from './normalize-options';
|
|
2
|
-
export * from './update-
|
|
2
|
+
export * from './update-unit-test-config';
|
|
@@ -2,5 +2,5 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const tslib_1 = require("tslib");
|
|
4
4
|
tslib_1.__exportStar(require("./normalize-options"), exports);
|
|
5
|
-
tslib_1.__exportStar(require("./update-
|
|
5
|
+
tslib_1.__exportStar(require("./update-unit-test-config"), exports);
|
|
6
6
|
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.updateUnitTestConfig = void 0;
|
|
4
|
+
const devkit_1 = require("@nx/devkit");
|
|
5
|
+
const testing_config_utils_1 = require("../../../utils/testing-config-utils");
|
|
6
|
+
const versions_1 = require("../../../utils/versions");
|
|
7
|
+
function updateUnitTestConfig(tree, pathToRoot, unitTestRunner) {
|
|
8
|
+
const pathToTestSetup = (0, devkit_1.joinPathFragments)(pathToRoot, `test-setup.ts`);
|
|
9
|
+
tree.write(pathToTestSetup, (0, devkit_1.stripIndents) `
|
|
10
|
+
import { installGlobals } from '@remix-run/node';
|
|
11
|
+
import '@testing-library/jest-dom/extend-expect';
|
|
12
|
+
installGlobals();`);
|
|
13
|
+
if (unitTestRunner === 'vitest') {
|
|
14
|
+
const pathToViteConfig = (0, devkit_1.joinPathFragments)(pathToRoot, 'vite.config.ts');
|
|
15
|
+
(0, testing_config_utils_1.updateViteTestIncludes)(tree, pathToViteConfig, './app/**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}');
|
|
16
|
+
(0, testing_config_utils_1.updateViteTestSetup)(tree, pathToViteConfig, './test-setup.ts');
|
|
17
|
+
}
|
|
18
|
+
else if (unitTestRunner === 'jest') {
|
|
19
|
+
const pathToJestConfig = (0, devkit_1.joinPathFragments)(pathToRoot, 'jest.config.ts');
|
|
20
|
+
(0, testing_config_utils_1.updateJestTestSetup)(tree, pathToJestConfig, `<rootDir>/test-setup.ts`);
|
|
21
|
+
}
|
|
22
|
+
return (0, devkit_1.addDependenciesToPackageJson)(tree, {}, {
|
|
23
|
+
'@testing-library/jest-dom': versions_1.testingLibraryJestDomVersion,
|
|
24
|
+
'@testing-library/react': versions_1.testingLibraryReactVersion,
|
|
25
|
+
'@testing-library/user-event': versions_1.testingLibraryUserEventsVersion,
|
|
26
|
+
'@remix-run/node': (0, versions_1.getRemixVersion)(tree),
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
exports.updateUnitTestConfig = updateUnitTestConfig;
|
|
30
|
+
//# sourceMappingURL=update-unit-test-config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"update-unit-test-config.js","sourceRoot":"","sources":["../../../../../../../packages/remix/src/generators/application/lib/update-unit-test-config.ts"],"names":[],"mappings":";;;AAAA,uCAKoB;AACpB,8EAI6C;AAC7C,sDAKiC;AAEjC,SAAgB,oBAAoB,CAClC,IAAU,EACV,UAAkB,EAClB,cAAiC;IAEjC,MAAM,eAAe,GAAG,IAAA,0BAAiB,EAAC,UAAU,EAAE,eAAe,CAAC,CAAC;IACvE,IAAI,CAAC,KAAK,CACR,eAAe,EACf,IAAA,qBAAY,EAAA;;;oBAGI,CACjB,CAAC;IAEF,IAAI,cAAc,KAAK,QAAQ,EAAE;QAC/B,MAAM,gBAAgB,GAAG,IAAA,0BAAiB,EAAC,UAAU,EAAE,gBAAgB,CAAC,CAAC;QACzE,IAAA,6CAAsB,EACpB,IAAI,EACJ,gBAAgB,EAChB,wDAAwD,CACzD,CAAC;QACF,IAAA,0CAAmB,EAAC,IAAI,EAAE,gBAAgB,EAAE,iBAAiB,CAAC,CAAC;KAChE;SAAM,IAAI,cAAc,KAAK,MAAM,EAAE;QACpC,MAAM,gBAAgB,GAAG,IAAA,0BAAiB,EAAC,UAAU,EAAE,gBAAgB,CAAC,CAAC;QACzE,IAAA,0CAAmB,EAAC,IAAI,EAAE,gBAAgB,EAAE,yBAAyB,CAAC,CAAC;KACxE;IAED,OAAO,IAAA,qCAA4B,EACjC,IAAI,EACJ,EAAE,EACF;QACE,2BAA2B,EAAE,uCAA4B;QACzD,wBAAwB,EAAE,qCAA0B;QACpD,6BAA6B,EAAE,0CAA+B;QAC9D,iBAAiB,EAAE,IAAA,0BAAe,EAAC,IAAI,CAAC;KACzC,CACF,CAAC;AACJ,CAAC;AArCD,oDAqCC"}
|
|
@@ -3,7 +3,7 @@ export interface NxRemixGeneratorSchema {
|
|
|
3
3
|
tags?: string;
|
|
4
4
|
js?: boolean;
|
|
5
5
|
directory?: string;
|
|
6
|
-
unitTestRunner?: 'vitest' | 'none';
|
|
6
|
+
unitTestRunner?: 'vitest' | 'jest' | 'none';
|
|
7
7
|
e2eTestRunner?: 'cypress' | 'none';
|
|
8
8
|
skipFormat?: boolean;
|
|
9
9
|
rootProject?: boolean;
|
|
@@ -26,14 +26,21 @@
|
|
|
26
26
|
},
|
|
27
27
|
"unitTestRunner": {
|
|
28
28
|
"type": "string",
|
|
29
|
-
"enum": [
|
|
29
|
+
"enum": [
|
|
30
|
+
"vitest",
|
|
31
|
+
"jest",
|
|
32
|
+
"none"
|
|
33
|
+
],
|
|
30
34
|
"default": "vitest",
|
|
31
35
|
"description": "Test runner to use for unit tests.",
|
|
32
36
|
"x-prompt": "What unit test runner should be used?"
|
|
33
37
|
},
|
|
34
38
|
"e2eTestRunner": {
|
|
35
39
|
"type": "string",
|
|
36
|
-
"enum": [
|
|
40
|
+
"enum": [
|
|
41
|
+
"cypress",
|
|
42
|
+
"none"
|
|
43
|
+
],
|
|
37
44
|
"default": "cypress",
|
|
38
45
|
"description": "Test runner to use for e2e tests"
|
|
39
46
|
},
|
package/src/generators/cypress-component-configuration/cypress-component-configuration.impl.js
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
const devkit_1 = require("@nx/devkit");
|
|
5
|
+
const path_1 = require("path");
|
|
6
|
+
const versions_1 = require("../../utils/versions");
|
|
7
|
+
function cypressComponentConfigurationGenerator(tree, options) {
|
|
8
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
9
|
+
const { cypressComponentConfigGenerator } = (0, devkit_1.ensurePackage)('@nx/react', (0, versions_1.getPackageVersion)(tree, 'nx'));
|
|
10
|
+
yield cypressComponentConfigGenerator(tree, {
|
|
11
|
+
project: options.project,
|
|
12
|
+
generateTests: options.generateTests,
|
|
13
|
+
skipFormat: true,
|
|
14
|
+
bundler: 'vite',
|
|
15
|
+
buildTarget: '',
|
|
16
|
+
});
|
|
17
|
+
const project = (0, devkit_1.readProjectConfiguration)(tree, options.project);
|
|
18
|
+
(0, devkit_1.generateFiles)(tree, (0, path_1.join)(__dirname, './files'), project.root, { tmpl: '' });
|
|
19
|
+
if (!options.skipFormat) {
|
|
20
|
+
yield (0, devkit_1.formatFiles)(tree);
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
exports.default = cypressComponentConfigurationGenerator;
|
|
25
|
+
//# sourceMappingURL=cypress-component-configuration.impl.js.map
|
package/src/generators/cypress-component-configuration/cypress-component-configuration.impl.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cypress-component-configuration.impl.js","sourceRoot":"","sources":["../../../../../../packages/remix/src/generators/cypress-component-configuration/cypress-component-configuration.impl.ts"],"names":[],"mappings":";;;AAAA,uCAMoB;AACpB,+BAA4B;AAC5B,mDAAyD;AAGzD,SAA8B,sCAAsC,CAClE,IAAU,EACV,OAA4C;;QAE5C,MAAM,EAAE,+BAA+B,EAAE,GAAG,IAAA,sBAAa,EAEvD,WAAW,EAAE,IAAA,4BAAiB,EAAC,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC;QAE9C,MAAM,+BAA+B,CAAC,IAAI,EAAE;YAC1C,OAAO,EAAE,OAAO,CAAC,OAAO;YACxB,aAAa,EAAE,OAAO,CAAC,aAAa;YACpC,UAAU,EAAE,IAAI;YAChB,OAAO,EAAE,MAAM;YACf,WAAW,EAAE,EAAE;SAChB,CAAC,CAAC;QAEH,MAAM,OAAO,GAAG,IAAA,iCAAwB,EAAC,IAAI,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC;QAEhE,IAAA,sBAAa,EAAC,IAAI,EAAE,IAAA,WAAI,EAAC,SAAS,EAAE,SAAS,CAAC,EAAE,OAAO,CAAC,IAAI,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,CAAC;QAE5E,IAAI,CAAC,OAAO,CAAC,UAAU,EAAE;YACvB,MAAM,IAAA,oBAAW,EAAC,IAAI,CAAC,CAAC;SACzB;IACH,CAAC;CAAA;AAvBD,yDAuBC"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/schema",
|
|
3
|
+
"cli": "nx",
|
|
4
|
+
"$id": "NxRemixCypressComponentTestConfiguration",
|
|
5
|
+
"title": "Add Cypress component testing",
|
|
6
|
+
"description": "Add a Cypress component testing configuration to an existing project.",
|
|
7
|
+
"type": "object",
|
|
8
|
+
"examples": [
|
|
9
|
+
{
|
|
10
|
+
"command": "nx g @nx/remix:cypress-component-configuration --project=my-remix-project",
|
|
11
|
+
"description": "Add component testing to your Remix project"
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
"command": "nx g @nx/remix:cypress-component-configuration --project=my-remix-project --generate-tests",
|
|
15
|
+
"description": "Add component testing to your Remix project and generate component tests for your existing components"
|
|
16
|
+
}
|
|
17
|
+
],
|
|
18
|
+
"properties": {
|
|
19
|
+
"project": {
|
|
20
|
+
"type": "string",
|
|
21
|
+
"description": "The name of the project to add cypress component testing configuration to",
|
|
22
|
+
"x-dropdown": "projects",
|
|
23
|
+
"x-prompt": "What project should we add Cypress component testing to?",
|
|
24
|
+
"x-priority": "important"
|
|
25
|
+
},
|
|
26
|
+
"generateTests": {
|
|
27
|
+
"type": "boolean",
|
|
28
|
+
"description": "Generate default component tests for existing components in the project",
|
|
29
|
+
"x-prompt": "Automatically generate tests for components declared in this project?",
|
|
30
|
+
"default": false,
|
|
31
|
+
"x-priority": "important"
|
|
32
|
+
},
|
|
33
|
+
"skipFormat": {
|
|
34
|
+
"type": "boolean",
|
|
35
|
+
"description": "Skip formatting files",
|
|
36
|
+
"default": false,
|
|
37
|
+
"x-priority": "internal"
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
"required": ["project"]
|
|
41
|
+
}
|
|
@@ -27,6 +27,7 @@ function addUnitTestingSetup(tree, options) {
|
|
|
27
27
|
'@testing-library/jest-dom': versions_1.testingLibraryJestDomVersion,
|
|
28
28
|
'@testing-library/react': versions_1.testingLibraryReactVersion,
|
|
29
29
|
'@testing-library/user-event': versions_1.testingLibraryUserEventsVersion,
|
|
30
|
+
'@remix-run/node': (0, versions_1.getRemixVersion)(tree),
|
|
30
31
|
});
|
|
31
32
|
}
|
|
32
33
|
exports.addUnitTestingSetup = addUnitTestingSetup;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"add-unit-testing.js","sourceRoot":"","sources":["../../../../../../../packages/remix/src/generators/library/lib/add-unit-testing.ts"],"names":[],"mappings":";;;AAAA,uCAMoB;AACpB,8EAG6C;AAC7C,
|
|
1
|
+
{"version":3,"file":"add-unit-testing.js","sourceRoot":"","sources":["../../../../../../../packages/remix/src/generators/library/lib/add-unit-testing.ts"],"names":[],"mappings":";;;AAAA,uCAMoB;AACpB,8EAG6C;AAC7C,sDAKiC;AAGjC,SAAgB,mBAAmB,CAAC,IAAU,EAAE,OAA4B;IAC1E,MAAM,EAAE,IAAI,EAAE,WAAW,EAAE,GAAG,IAAA,iCAAwB,EACpD,IAAI,EACJ,OAAO,CAAC,WAAW,CACpB,CAAC;IACF,MAAM,eAAe,GAAG,IAAA,0BAAiB,EAAC,WAAW,EAAE,mBAAmB,CAAC,CAAC;IAC5E,IAAI,qBAAqB,GAAG,EAAE,CAAC;IAE/B,IAAI,IAAI,CAAC,MAAM,CAAC,eAAe,CAAC,EAAE;QAChC,qBAAqB,GAAG,IAAI,CAAC,IAAI,CAAC,eAAe,EAAE,OAAO,CAAC,CAAC;KAC7D;IAED,IAAI,CAAC,KAAK,CACR,eAAe,EACf,IAAA,qBAAY,EAAA,GAAG,qBAAqB;;;oBAGpB,CACjB,CAAC;IAEF,IAAI,OAAO,CAAC,cAAc,KAAK,QAAQ,EAAE;QACvC,MAAM,kBAAkB,GAAG,IAAA,0BAAiB,EAAC,WAAW,EAAE,gBAAgB,CAAC,CAAC;QAC5E,IAAA,0CAAmB,EAAC,IAAI,EAAE,kBAAkB,EAAE,qBAAqB,CAAC,CAAC;KACtE;SAAM,IAAI,OAAO,CAAC,cAAc,KAAK,MAAM,EAAE;QAC5C,MAAM,gBAAgB,GAAG,IAAA,0BAAiB,EAAC,WAAW,EAAE,gBAAgB,CAAC,CAAC;QAC1E,IAAA,0CAAmB,EAAC,IAAI,EAAE,gBAAgB,EAAE,qBAAqB,CAAC,CAAC;KACpE;IAED,OAAO,IAAA,qCAA4B,EACjC,IAAI,EACJ,EAAE,EACF;QACE,2BAA2B,EAAE,uCAA4B;QACzD,wBAAwB,EAAE,qCAA0B;QACpD,6BAA6B,EAAE,0CAA+B;QAC9D,iBAAiB,EAAE,IAAA,0BAAe,EAAC,IAAI,CAAC;KACzC,CACF,CAAC;AACJ,CAAC;AAtCD,kDAsCC"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
+
|
|
3
|
+
exports[`Storybook Configuration it should create a storybook configuration and use react-vite framework with testing framework jest 1`] = `
|
|
4
|
+
"const config = {
|
|
5
|
+
stories: ['../src/lib/**/*.stories.@(js|jsx|ts|tsx|mdx)'],
|
|
6
|
+
addons: ['@storybook/addon-essentials'],
|
|
7
|
+
framework: {
|
|
8
|
+
name: '@storybook/react-vite',
|
|
9
|
+
options: {
|
|
10
|
+
builder: {
|
|
11
|
+
viteConfigPath: '',
|
|
12
|
+
},
|
|
13
|
+
},
|
|
14
|
+
},
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export default config;
|
|
18
|
+
|
|
19
|
+
// To customize your Vite configuration you can use the viteFinal field.
|
|
20
|
+
// Check https://storybook.js.org/docs/react/builders/vite#configuration
|
|
21
|
+
// and https://nx.dev/packages/storybook/documents/custom-builder-configs
|
|
22
|
+
"
|
|
23
|
+
`;
|
|
24
|
+
|
|
25
|
+
exports[`Storybook Configuration it should create a storybook configuration and use react-vite framework with testing framework none 1`] = `
|
|
26
|
+
"const config = {
|
|
27
|
+
stories: ['../src/lib/**/*.stories.@(js|jsx|ts|tsx|mdx)'],
|
|
28
|
+
addons: ['@storybook/addon-essentials'],
|
|
29
|
+
framework: {
|
|
30
|
+
name: '@storybook/react-vite',
|
|
31
|
+
options: {
|
|
32
|
+
builder: {
|
|
33
|
+
viteConfigPath: '',
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
export default config;
|
|
40
|
+
|
|
41
|
+
// To customize your Vite configuration you can use the viteFinal field.
|
|
42
|
+
// Check https://storybook.js.org/docs/react/builders/vite#configuration
|
|
43
|
+
// and https://nx.dev/packages/storybook/documents/custom-builder-configs
|
|
44
|
+
"
|
|
45
|
+
`;
|
|
46
|
+
|
|
47
|
+
exports[`Storybook Configuration it should create a storybook configuration and use react-vite framework with testing framework vitest 1`] = `
|
|
48
|
+
"const config = {
|
|
49
|
+
stories: ['../src/lib/**/*.stories.@(js|jsx|ts|tsx|mdx)'],
|
|
50
|
+
addons: ['@storybook/addon-essentials'],
|
|
51
|
+
framework: {
|
|
52
|
+
name: '@storybook/react-vite',
|
|
53
|
+
options: {
|
|
54
|
+
builder: {
|
|
55
|
+
viteConfigPath: '',
|
|
56
|
+
},
|
|
57
|
+
},
|
|
58
|
+
},
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
export default config;
|
|
62
|
+
|
|
63
|
+
// To customize your Vite configuration you can use the viteFinal field.
|
|
64
|
+
// Check https://storybook.js.org/docs/react/builders/vite#configuration
|
|
65
|
+
// and https://nx.dev/packages/storybook/documents/custom-builder-configs
|
|
66
|
+
"
|
|
67
|
+
`;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/// <reference types="vitest" />
|
|
2
|
+
import {defineConfig} from 'vite';
|
|
3
|
+
import react from '@vitejs/plugin-react';
|
|
4
|
+
import viteTsConfigPaths from 'vite-tsconfig-paths';
|
|
5
|
+
|
|
6
|
+
export default defineConfig({
|
|
7
|
+
cacheDir: '../../../node_modules/.vite/storybook-generator-test',
|
|
8
|
+
|
|
9
|
+
plugins: [
|
|
10
|
+
react(),
|
|
11
|
+
viteTsConfigPaths({
|
|
12
|
+
root: '../../../',
|
|
13
|
+
}),
|
|
14
|
+
],
|
|
15
|
+
})
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Linter } from '@nx/linter';
|
|
2
|
+
|
|
3
|
+
export interface StorybookConfigurationSchema {
|
|
4
|
+
name: string;
|
|
5
|
+
configureCypress: boolean;
|
|
6
|
+
generateStories?: boolean;
|
|
7
|
+
generateCypressSpecs?: boolean;
|
|
8
|
+
js?: boolean;
|
|
9
|
+
tsConfiguration?: boolean;
|
|
10
|
+
linter?: Linter;
|
|
11
|
+
cypressDirectory?: string;
|
|
12
|
+
ignorePaths?: string[];
|
|
13
|
+
configureTestRunner?: boolean;
|
|
14
|
+
configureStaticServe?: boolean;
|
|
15
|
+
}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "http://json-schema.org/schema",
|
|
3
|
+
"cli": "nx",
|
|
4
|
+
"$id": "NxRemixStorybookConfigure",
|
|
5
|
+
"title": "Remix Storybook Configuration",
|
|
6
|
+
"description": "Set up Storybook for a Remix library.",
|
|
7
|
+
"type": "object",
|
|
8
|
+
"properties": {
|
|
9
|
+
"name": {
|
|
10
|
+
"type": "string",
|
|
11
|
+
"aliases": [
|
|
12
|
+
"project",
|
|
13
|
+
"projectName"
|
|
14
|
+
],
|
|
15
|
+
"description": "Project for which to generate Storybook configuration.",
|
|
16
|
+
"$default": {
|
|
17
|
+
"$source": "argv",
|
|
18
|
+
"index": 0
|
|
19
|
+
},
|
|
20
|
+
"x-prompt": "For which project do you want to generate Storybook configuration?",
|
|
21
|
+
"x-dropdown": "projects",
|
|
22
|
+
"x-priority": "important"
|
|
23
|
+
},
|
|
24
|
+
"configureCypress": {
|
|
25
|
+
"type": "boolean",
|
|
26
|
+
"description": "Run the cypress-configure generator.",
|
|
27
|
+
"x-prompt": "Configure a cypress e2e app to run against the storybook instance?",
|
|
28
|
+
"default": true,
|
|
29
|
+
"x-priority": "important"
|
|
30
|
+
},
|
|
31
|
+
"generateStories": {
|
|
32
|
+
"type": "boolean",
|
|
33
|
+
"description": "Automatically generate `*.stories.ts` files for components declared in this project?",
|
|
34
|
+
"x-prompt": "Automatically generate *.stories.ts files for components declared in this project?",
|
|
35
|
+
"default": true,
|
|
36
|
+
"x-priority": "important"
|
|
37
|
+
},
|
|
38
|
+
"generateCypressSpecs": {
|
|
39
|
+
"type": "boolean",
|
|
40
|
+
"description": "Automatically generate test files in the Cypress E2E app generated by the `cypress-configure` generator.",
|
|
41
|
+
"x-prompt": "Automatically generate test files in the Cypress E2E app generated by the cypress-configure generator?",
|
|
42
|
+
"default": true,
|
|
43
|
+
"x-priority": "important"
|
|
44
|
+
},
|
|
45
|
+
"configureStaticServe": {
|
|
46
|
+
"type": "boolean",
|
|
47
|
+
"description": "Specifies whether to configure a static file server target for serving storybook. Helpful for speeding up CI build/test times.",
|
|
48
|
+
"x-prompt": "Configure a static file server for the storybook instance?",
|
|
49
|
+
"default": true,
|
|
50
|
+
"x-priority": "important"
|
|
51
|
+
},
|
|
52
|
+
"cypressDirectory": {
|
|
53
|
+
"type": "string",
|
|
54
|
+
"description": "A directory where the Cypress project will be placed. Placed at the root by default."
|
|
55
|
+
},
|
|
56
|
+
"js": {
|
|
57
|
+
"type": "boolean",
|
|
58
|
+
"description": "Generate JavaScript story files rather than TypeScript story files.",
|
|
59
|
+
"default": false
|
|
60
|
+
},
|
|
61
|
+
"tsConfiguration": {
|
|
62
|
+
"type": "boolean",
|
|
63
|
+
"description": "Configure your project with TypeScript. Generate main.ts and preview.ts files, instead of main.js and preview.js.",
|
|
64
|
+
"default": false
|
|
65
|
+
},
|
|
66
|
+
"linter": {
|
|
67
|
+
"description": "The tool to use for running lint checks.",
|
|
68
|
+
"type": "string",
|
|
69
|
+
"enum": [
|
|
70
|
+
"eslint"
|
|
71
|
+
],
|
|
72
|
+
"default": "eslint"
|
|
73
|
+
},
|
|
74
|
+
"ignorePaths": {
|
|
75
|
+
"type": "array",
|
|
76
|
+
"description": "Paths to ignore when looking for components.",
|
|
77
|
+
"items": {
|
|
78
|
+
"type": "string",
|
|
79
|
+
"description": "Path to ignore."
|
|
80
|
+
},
|
|
81
|
+
"examples": [
|
|
82
|
+
"**/**/src/**/not-stories/**",
|
|
83
|
+
"libs/my-lib/**/*.something.ts",
|
|
84
|
+
"**/**/src/**/*.other.*",
|
|
85
|
+
"libs/my-lib/src/not-stories/**,**/**/src/**/*.other.*,apps/my-app/**/*.something.ts"
|
|
86
|
+
]
|
|
87
|
+
},
|
|
88
|
+
"configureTestRunner": {
|
|
89
|
+
"type": "boolean",
|
|
90
|
+
"description": "Add a Storybook Test-Runner target."
|
|
91
|
+
}
|
|
92
|
+
},
|
|
93
|
+
"required": [
|
|
94
|
+
"name"
|
|
95
|
+
]
|
|
96
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
const devkit_1 = require("@nx/devkit");
|
|
5
|
+
const path_1 = require("path");
|
|
6
|
+
const versions_1 = require("../../utils/versions");
|
|
7
|
+
function remixStorybookConfiguration(tree, schema) {
|
|
8
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
9
|
+
const { root } = (0, devkit_1.readProjectConfiguration)(tree, schema.name);
|
|
10
|
+
if (!tree.exists((0, devkit_1.joinPathFragments)(root, 'vite.config.ts'))) {
|
|
11
|
+
(0, devkit_1.generateFiles)(tree, (0, path_1.join)(__dirname, 'files'), root, { tpl: '' });
|
|
12
|
+
}
|
|
13
|
+
const { storybookConfigurationGenerator } = (0, devkit_1.ensurePackage)('@nx/react', (0, versions_1.getPackageVersion)(tree, 'nx'));
|
|
14
|
+
const task = yield storybookConfigurationGenerator(tree, schema);
|
|
15
|
+
return task;
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
exports.default = remixStorybookConfiguration;
|
|
19
|
+
//# sourceMappingURL=storybook-configuration.impl.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"storybook-configuration.impl.js","sourceRoot":"","sources":["../../../../../../packages/remix/src/generators/storybook-configuration/storybook-configuration.impl.ts"],"names":[],"mappings":";;;AAAA,uCAMoB;AACpB,+BAA4B;AAC5B,mDAAyD;AAGzD,SAA8B,2BAA2B,CACvD,IAAU,EACV,MAAoC;;QAEpC,MAAM,EAAE,IAAI,EAAE,GAAG,IAAA,iCAAwB,EAAC,IAAI,EAAE,MAAM,CAAC,IAAI,CAAC,CAAC;QAE7D,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,IAAA,0BAAiB,EAAC,IAAI,EAAE,gBAAgB,CAAC,CAAC,EAAE;YAC3D,IAAA,sBAAa,EAAC,IAAI,EAAE,IAAA,WAAI,EAAC,SAAS,EAAE,OAAO,CAAC,EAAE,IAAI,EAAE,EAAE,GAAG,EAAE,EAAE,EAAE,CAAC,CAAC;SAClE;QAED,MAAM,EAAE,+BAA+B,EAAE,GAAG,IAAA,sBAAa,EAEvD,WAAW,EAAE,IAAA,4BAAiB,EAAC,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC;QAE9C,MAAM,IAAI,GAAG,MAAM,+BAA+B,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;QAEjE,OAAO,IAAI,CAAC;IACd,CAAC;CAAA;AAjBD,8CAiBC"}
|
package/src/index.d.ts
CHANGED
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
export * from './generators/action/action.impl';
|
|
2
2
|
export * from './generators/application/application.impl';
|
|
3
|
+
export * from './generators/cypress-component-configuration/cypress-component-configuration.impl';
|
|
3
4
|
export * from './generators/cypress/cypress.impl';
|
|
5
|
+
export * from './generators/error-boundary/error-boundary.impl';
|
|
4
6
|
export * from './generators/library/library.impl';
|
|
5
7
|
export * from './generators/loader/loader.impl';
|
|
6
8
|
export * from './generators/meta/meta.impl';
|
|
7
9
|
export * from './generators/preset/preset.impl';
|
|
8
10
|
export * from './generators/resource-route/resource-route.impl';
|
|
9
11
|
export * from './generators/route/route.impl';
|
|
12
|
+
export * from './generators/setup-tailwind/setup-tailwind.impl';
|
|
13
|
+
export * from './generators/storybook-configuration/storybook-configuration.impl';
|
|
10
14
|
export * from './generators/style/style.impl';
|
|
11
15
|
export { createWatchPaths } from './utils/create-watch-paths';
|
package/src/index.js
CHANGED
|
@@ -4,13 +4,17 @@ exports.createWatchPaths = void 0;
|
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
tslib_1.__exportStar(require("./generators/action/action.impl"), exports);
|
|
6
6
|
tslib_1.__exportStar(require("./generators/application/application.impl"), exports);
|
|
7
|
+
tslib_1.__exportStar(require("./generators/cypress-component-configuration/cypress-component-configuration.impl"), exports);
|
|
7
8
|
tslib_1.__exportStar(require("./generators/cypress/cypress.impl"), exports);
|
|
9
|
+
tslib_1.__exportStar(require("./generators/error-boundary/error-boundary.impl"), exports);
|
|
8
10
|
tslib_1.__exportStar(require("./generators/library/library.impl"), exports);
|
|
9
11
|
tslib_1.__exportStar(require("./generators/loader/loader.impl"), exports);
|
|
10
12
|
tslib_1.__exportStar(require("./generators/meta/meta.impl"), exports);
|
|
11
13
|
tslib_1.__exportStar(require("./generators/preset/preset.impl"), exports);
|
|
12
14
|
tslib_1.__exportStar(require("./generators/resource-route/resource-route.impl"), exports);
|
|
13
15
|
tslib_1.__exportStar(require("./generators/route/route.impl"), exports);
|
|
16
|
+
tslib_1.__exportStar(require("./generators/setup-tailwind/setup-tailwind.impl"), exports);
|
|
17
|
+
tslib_1.__exportStar(require("./generators/storybook-configuration/storybook-configuration.impl"), exports);
|
|
14
18
|
tslib_1.__exportStar(require("./generators/style/style.impl"), exports);
|
|
15
19
|
var create_watch_paths_1 = require("./utils/create-watch-paths");
|
|
16
20
|
Object.defineProperty(exports, "createWatchPaths", { enumerable: true, get: function () { return create_watch_paths_1.createWatchPaths; } });
|
package/src/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../packages/remix/src/index.ts"],"names":[],"mappings":";;;;AAAA,0EAAgD;AAChD,oFAA0D;AAC1D,4EAAkD;AAClD,4EAAkD;AAClD,0EAAgD;AAChD,sEAA4C;AAC5C,0EAAgD;AAChD,0FAAgE;AAChE,wEAA8C;AAC9C,wEAA8C;AAC9C,iEAA8D;AAArD,sHAAA,gBAAgB,OAAA"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../packages/remix/src/index.ts"],"names":[],"mappings":";;;;AAAA,0EAAgD;AAChD,oFAA0D;AAC1D,4HAAkG;AAClG,4EAAkD;AAClD,0FAAgE;AAChE,4EAAkD;AAClD,0EAAgD;AAChD,sEAA4C;AAC5C,0EAAgD;AAChD,0FAAgE;AAChE,wEAA8C;AAC9C,0FAAgE;AAChE,4GAAkF;AAClF,wEAA8C;AAC9C,iEAA8D;AAArD,sHAAA,gBAAgB,OAAA"}
|
|
@@ -2,48 +2,57 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.updateViteTestIncludes = exports.updateJestTestSetup = exports.updateViteTestSetup = void 0;
|
|
4
4
|
const devkit_1 = require("@nx/devkit");
|
|
5
|
-
const
|
|
5
|
+
const ensure_typescript_1 = require("@nx/js/src/utils/typescript/ensure-typescript");
|
|
6
|
+
let tsModule;
|
|
6
7
|
function updateViteTestSetup(tree, pathToViteConfig, pathToTestSetup) {
|
|
8
|
+
if (!tsModule) {
|
|
9
|
+
tsModule = (0, ensure_typescript_1.ensureTypescript)();
|
|
10
|
+
}
|
|
11
|
+
const { tsquery } = require('@phenomnomnominal/tsquery');
|
|
7
12
|
const fileContents = tree.read(pathToViteConfig, 'utf-8');
|
|
8
|
-
const ast =
|
|
13
|
+
const ast = tsquery.ast(fileContents);
|
|
9
14
|
const TEST_SETUPFILES_SELECTOR = 'PropertyAssignment:has(Identifier[name=test]) PropertyAssignment:has(Identifier[name=setupFiles])';
|
|
10
|
-
const nodes =
|
|
15
|
+
const nodes = tsquery(ast, TEST_SETUPFILES_SELECTOR, {
|
|
11
16
|
visitAllChildren: true,
|
|
12
17
|
});
|
|
18
|
+
let updatedFileContents = fileContents;
|
|
13
19
|
if (nodes.length === 0) {
|
|
14
20
|
const TEST_CONFIG_SELECTOR = 'PropertyAssignment:has(Identifier[name=test]) > ObjectLiteralExpression';
|
|
15
|
-
const testConfigNodes =
|
|
21
|
+
const testConfigNodes = tsquery(ast, TEST_CONFIG_SELECTOR, {
|
|
16
22
|
visitAllChildren: true,
|
|
17
23
|
});
|
|
18
|
-
|
|
19
|
-
tree.write(pathToViteConfig, updatedFileContents);
|
|
24
|
+
updatedFileContents = (0, devkit_1.stripIndents) `${fileContents.slice(0, testConfigNodes[0].getStart() + 1)}setupFiles: ['${pathToTestSetup}'],${fileContents.slice(testConfigNodes[0].getStart() + 1)}`;
|
|
20
25
|
}
|
|
21
26
|
else {
|
|
22
|
-
const arrayNodes =
|
|
27
|
+
const arrayNodes = tsquery(nodes[0], 'ArrayLiteralExpression', {
|
|
23
28
|
visitAllChildren: true,
|
|
24
29
|
});
|
|
25
30
|
if (arrayNodes.length !== 0) {
|
|
26
|
-
|
|
27
|
-
tree.write(pathToViteConfig, updatedFileContents);
|
|
31
|
+
updatedFileContents = (0, devkit_1.stripIndents) `${fileContents.slice(0, arrayNodes[0].getStart() + 1)}'${pathToTestSetup}',${fileContents.slice(arrayNodes[0].getStart() + 1)}`;
|
|
28
32
|
}
|
|
29
33
|
}
|
|
34
|
+
tree.write(pathToViteConfig, updatedFileContents);
|
|
30
35
|
}
|
|
31
36
|
exports.updateViteTestSetup = updateViteTestSetup;
|
|
32
37
|
function updateJestTestSetup(tree, pathToJestConfig, pathToTestSetup) {
|
|
38
|
+
if (!tsModule) {
|
|
39
|
+
tsModule = (0, ensure_typescript_1.ensureTypescript)();
|
|
40
|
+
}
|
|
41
|
+
const { tsquery } = require('@phenomnomnominal/tsquery');
|
|
33
42
|
const fileContents = tree.read(pathToJestConfig, 'utf-8');
|
|
34
|
-
const ast =
|
|
43
|
+
const ast = tsquery.ast(fileContents);
|
|
35
44
|
const TEST_SETUPFILES_SELECTOR = 'PropertyAssignment:has(Identifier[name=setupFilesAfterEnv])';
|
|
36
|
-
const nodes =
|
|
45
|
+
const nodes = tsquery(ast, TEST_SETUPFILES_SELECTOR, {
|
|
37
46
|
visitAllChildren: true,
|
|
38
47
|
});
|
|
39
48
|
if (nodes.length === 0) {
|
|
40
49
|
const CONFIG_SELECTOR = 'ObjectLiteralExpression';
|
|
41
|
-
const nodes =
|
|
50
|
+
const nodes = tsquery(ast, CONFIG_SELECTOR, { visitAllChildren: true });
|
|
42
51
|
const updatedFileContents = (0, devkit_1.stripIndents) `${fileContents.slice(0, nodes[0].getStart() + 1)}setupFilesAfterEnv: ['${pathToTestSetup}'],${fileContents.slice(nodes[0].getStart() + 1)}`;
|
|
43
52
|
tree.write(pathToJestConfig, updatedFileContents);
|
|
44
53
|
}
|
|
45
54
|
else {
|
|
46
|
-
const arrayNodes =
|
|
55
|
+
const arrayNodes = tsquery(nodes[0], 'ArrayLiteralExpression', {
|
|
47
56
|
visitAllChildren: true,
|
|
48
57
|
});
|
|
49
58
|
if (arrayNodes.length !== 0) {
|
|
@@ -54,10 +63,14 @@ function updateJestTestSetup(tree, pathToJestConfig, pathToTestSetup) {
|
|
|
54
63
|
}
|
|
55
64
|
exports.updateJestTestSetup = updateJestTestSetup;
|
|
56
65
|
function updateViteTestIncludes(tree, pathToViteConfig, includesString) {
|
|
66
|
+
if (!tsModule) {
|
|
67
|
+
tsModule = (0, ensure_typescript_1.ensureTypescript)();
|
|
68
|
+
}
|
|
69
|
+
const { tsquery } = require('@phenomnomnominal/tsquery');
|
|
57
70
|
const fileContents = tree.read(pathToViteConfig, 'utf-8');
|
|
58
|
-
const ast =
|
|
71
|
+
const ast = tsquery.ast(fileContents);
|
|
59
72
|
const TEST_INCLUDE_SELECTOR = 'PropertyAssignment:has(Identifier[name=test]) PropertyAssignment:has(Identifier[name=include])';
|
|
60
|
-
const nodes =
|
|
73
|
+
const nodes = tsquery(ast, TEST_INCLUDE_SELECTOR, { visitAllChildren: true });
|
|
61
74
|
if (nodes.length !== 0) {
|
|
62
75
|
const updatedFileContents = (0, devkit_1.stripIndents) `${fileContents.slice(0, nodes[0].getStart())}include: ["${includesString}"]${fileContents.slice(nodes[0].getEnd())}`;
|
|
63
76
|
tree.write(pathToViteConfig, updatedFileContents);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"testing-config-utils.js","sourceRoot":"","sources":["../../../../../packages/remix/src/utils/testing-config-utils.ts"],"names":[],"mappings":";;;AAAA,uCAAqD;AACrD,
|
|
1
|
+
{"version":3,"file":"testing-config-utils.js","sourceRoot":"","sources":["../../../../../packages/remix/src/utils/testing-config-utils.ts"],"names":[],"mappings":";;;AAAA,uCAAqD;AACrD,qFAAiF;AAEjF,IAAI,QAAqC,CAAC;AAE1C,SAAgB,mBAAmB,CACjC,IAAU,EACV,gBAAwB,EACxB,eAAuB;IAEvB,IAAI,CAAC,QAAQ,EAAE;QACb,QAAQ,GAAG,IAAA,oCAAgB,GAAE,CAAC;KAC/B;IACD,MAAM,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC,2BAA2B,CAAC,CAAC;IACzD,MAAM,YAAY,GAAG,IAAI,CAAC,IAAI,CAAC,gBAAgB,EAAE,OAAO,CAAC,CAAC;IAE1D,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC;IAEtC,MAAM,wBAAwB,GAC5B,mGAAmG,CAAC;IAEtG,MAAM,KAAK,GAAG,OAAO,CAAC,GAAG,EAAE,wBAAwB,EAAE;QACnD,gBAAgB,EAAE,IAAI;KACvB,CAAC,CAAC;IAEH,IAAI,m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AC,QAAQ,EAAE,GAAG,CAAC,CAC7B,EAAE,CAAC;YAEJ,IAAI,CAAC,KAAK,CAAC,gBAAgB,EAAE,mBAAmB,CAAC,CAAC;SACnD;KACF;AACH,CAAC;AA7CD,kDA6CC;AAED,SAAgB,sBAAsB,CACpC,IAAU,EACV,gBAAwB,EACxB,cAAsB;IAEtB,IAAI,CAAC,QAAQ,EAAE;QACb,QAAQ,GAAG,IAAA,oCAAgB,GAAE,CAAC;KAC/B;IACD,MAAM,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC,2BAA2B,CAAC,CAAC;IACzD,MAAM,YAAY,GAAG,IAAI,CAAC,IAAI,CAAC,gBAAgB,EAAE,OAAO,CAAC,CAAC;IAE1D,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC;IAEtC,MAAM,qBAAqB,GACzB,gGAAgG,CAAC;IACnG,MAAM,KAAK,GAAG,OAAO,CAAC,GAAG,EAAE,qBAAqB,EAAE,EAAE,gBAAgB,EAAE,IAAI,EAAE,CAAC,CAAC;IAE9E,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE;QACtB,MAAM,mBAAmB,GAAG,IAAA,qBAAY,EAAA,GAAG,YAAY,CAAC,KAAK,CAC3D,CAAC,EACD,KAAK,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE,CACpB,cAAc,cAAc,KAAK,YAAY,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,EAAE,CAAC;QAE1E,IAAI,CAAC,KAAK,CAAC,gBAAgB,EAAE,mBAAmB,CAAC,CAAC;KACnD;AACH,CAAC;AAzBD,wDAyBC"}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.updateViteTestConfig = void 0;
|
|
4
|
-
const devkit_1 = require("@nx/devkit");
|
|
5
|
-
const testing_config_utils_1 = require("../../../utils/testing-config-utils");
|
|
6
|
-
const versions_1 = require("../../../utils/versions");
|
|
7
|
-
function updateViteTestConfig(tree, pathToRoot) {
|
|
8
|
-
const pathToViteConfig = (0, devkit_1.joinPathFragments)(pathToRoot, 'vite.config.ts');
|
|
9
|
-
const pathToTestSetup = (0, devkit_1.joinPathFragments)(pathToRoot, `test-setup.ts`);
|
|
10
|
-
tree.write(pathToTestSetup, (0, devkit_1.stripIndents) `
|
|
11
|
-
import { installGlobals } from '@remix-run/node';
|
|
12
|
-
import '@testing-library/jest-dom/extend-expect';
|
|
13
|
-
installGlobals();`);
|
|
14
|
-
(0, testing_config_utils_1.updateViteTestIncludes)(tree, pathToViteConfig, './app/**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}');
|
|
15
|
-
(0, testing_config_utils_1.updateViteTestSetup)(tree, pathToViteConfig, './test-setup.ts');
|
|
16
|
-
return (0, devkit_1.addDependenciesToPackageJson)(tree, {}, {
|
|
17
|
-
'@testing-library/jest-dom': versions_1.testingLibraryJestDomVersion,
|
|
18
|
-
'@testing-library/react': versions_1.testingLibraryReactVersion,
|
|
19
|
-
'@testing-library/user-event': versions_1.testingLibraryUserEventsVersion,
|
|
20
|
-
});
|
|
21
|
-
}
|
|
22
|
-
exports.updateViteTestConfig = updateViteTestConfig;
|
|
23
|
-
//# sourceMappingURL=update-vite-test-config.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"update-vite-test-config.js","sourceRoot":"","sources":["../../../../../../../packages/remix/src/generators/application/lib/update-vite-test-config.ts"],"names":[],"mappings":";;;AAAA,uCAKoB;AACpB,8EAG6C;AAC7C,sDAIiC;AAEjC,SAAgB,oBAAoB,CAAC,IAAU,EAAE,UAAkB;IACjE,MAAM,gBAAgB,GAAG,IAAA,0BAAiB,EAAC,UAAU,EAAE,gBAAgB,CAAC,CAAC;IACzE,MAAM,eAAe,GAAG,IAAA,0BAAiB,EAAC,UAAU,EAAE,eAAe,CAAC,CAAC;IACvE,IAAI,CAAC,KAAK,CACR,eAAe,EACf,IAAA,qBAAY,EAAA;;;oBAGI,CACjB,CAAC;IAEF,IAAA,6CAAsB,EACpB,IAAI,EACJ,gBAAgB,EAChB,wDAAwD,CACzD,CAAC;IACF,IAAA,0CAAmB,EAAC,IAAI,EAAE,gBAAgB,EAAE,iBAAiB,CAAC,CAAC;IAE/D,OAAO,IAAA,qCAA4B,EACjC,IAAI,EACJ,EAAE,EACF;QACE,2BAA2B,EAAE,uCAA4B;QACzD,wBAAwB,EAAE,qCAA0B;QACpD,6BAA6B,EAAE,0CAA+B;KAC/D,CACF,CAAC;AACJ,CAAC;AA3BD,oDA2BC"}
|