@nx/remix 18.0.2 → 18.0.4

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nx/remix",
3
- "version": "18.0.2",
3
+ "version": "18.0.4",
4
4
  "description": "The Remix plugin for Nx contains executors and generators for managing Remix applications and libraries within an Nx workspace. It provides:\n\n\n- Integration with libraries such as Vitest, Jest, Cypress, and Storybook.\n\n- Generators for applications, libraries, routes, loaders, and more.\n\n- Library build support for publishing packages to npm or other registries.\n\n- Utilities for automatic workspace refactoring.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -28,12 +28,12 @@
28
28
  "migrations": "./migrations.json"
29
29
  },
30
30
  "dependencies": {
31
- "@nx/devkit": "18.0.2",
32
- "@nx/js": "18.0.2",
33
- "@nx/react": "18.0.2",
31
+ "@nx/devkit": "18.0.4",
32
+ "@nx/js": "18.0.4",
33
+ "@nx/react": "18.0.4",
34
34
  "tslib": "^2.3.1",
35
35
  "@phenomnomnominal/tsquery": "~5.0.1",
36
- "@nrwl/remix": "18.0.2"
36
+ "@nrwl/remix": "18.0.4"
37
37
  },
38
38
  "peerDependencies": {},
39
39
  "publishConfig": {
@@ -144,7 +144,7 @@ export default function Index() {
144
144
  "
145
145
  `;
146
146
 
147
- exports[`Remix Application Integrated Repo --projectNameAndRootFormat=as-provided --e2eTestRunner should generate an e2e application for the app 1`] = `
147
+ exports[`Remix Application Integrated Repo --projectNameAndRootFormat=as-provided --e2eTestRunner should generate a cypress e2e application for the app 1`] = `
148
148
  "import { nxE2EPreset } from '@nx/cypress/plugins/cypress-preset';
149
149
 
150
150
  import { defineConfig } from 'cypress';
@@ -158,6 +158,79 @@ export default defineConfig({
158
158
  "
159
159
  `;
160
160
 
161
+ exports[`Remix Application Integrated Repo --projectNameAndRootFormat=as-provided --e2eTestRunner should generate a playwright e2e application for the app 1`] = `
162
+ "import { defineConfig, devices } from '@playwright/test';
163
+ import { nxE2EPreset } from '@nx/playwright/preset';
164
+
165
+ import { workspaceRoot } from '@nx/devkit';
166
+
167
+ // For CI, you may want to set BASE_URL to the deployed application.
168
+ const baseURL = process.env['BASE_URL'] || 'http://localhost:4200';
169
+
170
+ /**
171
+ * Read environment variables from file.
172
+ * https://github.com/motdotla/dotenv
173
+ */
174
+ // require('dotenv').config();
175
+
176
+ /**
177
+ * See https://playwright.dev/docs/test-configuration.
178
+ */
179
+ export default defineConfig({
180
+ ...nxE2EPreset(__filename, { testDir: './src' }),
181
+ /* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
182
+ use: {
183
+ baseURL,
184
+ /* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
185
+ trace: 'on-first-retry',
186
+ },
187
+ /* Run your local dev server before starting the tests */
188
+ webServer: {
189
+ command: 'pnpm exec nx serve test',
190
+ url: 'http://localhost:4200',
191
+ reuseExistingServer: !process.env.CI,
192
+ cwd: workspaceRoot,
193
+ },
194
+ projects: [
195
+ {
196
+ name: 'chromium',
197
+ use: { ...devices['Desktop Chrome'] },
198
+ },
199
+
200
+ {
201
+ name: 'firefox',
202
+ use: { ...devices['Desktop Firefox'] },
203
+ },
204
+
205
+ {
206
+ name: 'webkit',
207
+ use: { ...devices['Desktop Safari'] },
208
+ },
209
+
210
+ // Uncomment for mobile browsers support
211
+ /* {
212
+ name: 'Mobile Chrome',
213
+ use: { ...devices['Pixel 5'] },
214
+ },
215
+ {
216
+ name: 'Mobile Safari',
217
+ use: { ...devices['iPhone 12'] },
218
+ }, */
219
+
220
+ // Uncomment for branded browsers
221
+ /* {
222
+ name: 'Microsoft Edge',
223
+ use: { ...devices['Desktop Edge'], channel: 'msedge' },
224
+ },
225
+ {
226
+ name: 'Google Chrome',
227
+ use: { ...devices['Desktop Chrome'], channel: 'chrome' },
228
+ } */
229
+ ],
230
+ });
231
+ "
232
+ `;
233
+
161
234
  exports[`Remix Application Integrated Repo --projectNameAndRootFormat=as-provided --js should create the application correctly 1`] = `
162
235
  "import { createWatchPaths } from '@nx/remix';
163
236
  import { dirname } from 'path';
@@ -250,9 +323,8 @@ export default {
250
323
  exports[`Remix Application Integrated Repo --projectNameAndRootFormat=as-provided --unitTestRunner should generate the correct files for testing using jest 2`] = `
251
324
  "/* eslint-disable */
252
325
  export default {
253
- setupFilesAfterEnv: ['<rootDir>/test-setup.ts'],
254
326
  displayName: 'test',
255
- preset: '../jest.preset.cjs',
327
+ preset: '../jest.preset.js',
256
328
  transform: {
257
329
  '^.+\\\\.[tj]sx?$': ['ts-jest', { tsconfig: '<rootDir>/tsconfig.spec.json' }],
258
330
  },
@@ -549,7 +621,7 @@ export default function Index() {
549
621
  "
550
622
  `;
551
623
 
552
- exports[`Remix Application Integrated Repo --projectNameAndRootFormat=derived --e2eTestRunner should generate an e2e application for the app 1`] = `
624
+ exports[`Remix Application Integrated Repo --projectNameAndRootFormat=derived --e2eTestRunner should generate a cypress e2e application for the app 1`] = `
553
625
  "import { nxE2EPreset } from '@nx/cypress/plugins/cypress-preset';
554
626
 
555
627
  import { defineConfig } from 'cypress';
@@ -563,6 +635,79 @@ export default defineConfig({
563
635
  "
564
636
  `;
565
637
 
638
+ exports[`Remix Application Integrated Repo --projectNameAndRootFormat=derived --e2eTestRunner should generate a playwright e2e application for the app 1`] = `
639
+ "import { defineConfig, devices } from '@playwright/test';
640
+ import { nxE2EPreset } from '@nx/playwright/preset';
641
+
642
+ import { workspaceRoot } from '@nx/devkit';
643
+
644
+ // For CI, you may want to set BASE_URL to the deployed application.
645
+ const baseURL = process.env['BASE_URL'] || 'http://localhost:4200';
646
+
647
+ /**
648
+ * Read environment variables from file.
649
+ * https://github.com/motdotla/dotenv
650
+ */
651
+ // require('dotenv').config();
652
+
653
+ /**
654
+ * See https://playwright.dev/docs/test-configuration.
655
+ */
656
+ export default defineConfig({
657
+ ...nxE2EPreset(__filename, { testDir: './src' }),
658
+ /* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
659
+ use: {
660
+ baseURL,
661
+ /* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
662
+ trace: 'on-first-retry',
663
+ },
664
+ /* Run your local dev server before starting the tests */
665
+ webServer: {
666
+ command: 'pnpm exec nx serve test',
667
+ url: 'http://localhost:4200',
668
+ reuseExistingServer: !process.env.CI,
669
+ cwd: workspaceRoot,
670
+ },
671
+ projects: [
672
+ {
673
+ name: 'chromium',
674
+ use: { ...devices['Desktop Chrome'] },
675
+ },
676
+
677
+ {
678
+ name: 'firefox',
679
+ use: { ...devices['Desktop Firefox'] },
680
+ },
681
+
682
+ {
683
+ name: 'webkit',
684
+ use: { ...devices['Desktop Safari'] },
685
+ },
686
+
687
+ // Uncomment for mobile browsers support
688
+ /* {
689
+ name: 'Mobile Chrome',
690
+ use: { ...devices['Pixel 5'] },
691
+ },
692
+ {
693
+ name: 'Mobile Safari',
694
+ use: { ...devices['iPhone 12'] },
695
+ }, */
696
+
697
+ // Uncomment for branded browsers
698
+ /* {
699
+ name: 'Microsoft Edge',
700
+ use: { ...devices['Desktop Edge'], channel: 'msedge' },
701
+ },
702
+ {
703
+ name: 'Google Chrome',
704
+ use: { ...devices['Desktop Chrome'], channel: 'chrome' },
705
+ } */
706
+ ],
707
+ });
708
+ "
709
+ `;
710
+
566
711
  exports[`Remix Application Integrated Repo --projectNameAndRootFormat=derived --js should create the application correctly 1`] = `
567
712
  "import { createWatchPaths } from '@nx/remix';
568
713
  import { dirname } from 'path';
@@ -655,9 +800,8 @@ export default {
655
800
  exports[`Remix Application Integrated Repo --projectNameAndRootFormat=derived --unitTestRunner should generate the correct files for testing using jest 2`] = `
656
801
  "/* eslint-disable */
657
802
  export default {
658
- setupFilesAfterEnv: ['<rootDir>/test-setup.ts'],
659
803
  displayName: 'test',
660
- preset: '../../jest.preset.cjs',
804
+ preset: '../../jest.preset.js',
661
805
  transform: {
662
806
  '^.+\\\\.[tj]sx?$': ['ts-jest', { tsconfig: '<rootDir>/tsconfig.spec.json' }],
663
807
  },
@@ -810,7 +954,7 @@ export default function Index() {
810
954
  "
811
955
  `;
812
956
 
813
- exports[`Remix Application Standalone Project Repo --e2eTestRunner should generate an e2e application for the app 1`] = `
957
+ exports[`Remix Application Standalone Project Repo --e2eTestRunner should generate a cypress e2e application for the app 1`] = `
814
958
  "import { nxE2EPreset } from '@nx/cypress/plugins/cypress-preset';
815
959
 
816
960
  import { defineConfig } from 'cypress';
@@ -1157,3 +1301,76 @@ exports[`Remix Application Standalone Project Repo should create the application
1157
1301
  }
1158
1302
  "
1159
1303
  `;
1304
+
1305
+ exports[`Remix Application Standalone Project Repo should generate a playwright e2e application for the app 1`] = `
1306
+ "import { defineConfig, devices } from '@playwright/test';
1307
+ import { nxE2EPreset } from '@nx/playwright/preset';
1308
+
1309
+ import { workspaceRoot } from '@nx/devkit';
1310
+
1311
+ // For CI, you may want to set BASE_URL to the deployed application.
1312
+ const baseURL = process.env['BASE_URL'] || 'http://localhost:4200';
1313
+
1314
+ /**
1315
+ * Read environment variables from file.
1316
+ * https://github.com/motdotla/dotenv
1317
+ */
1318
+ // require('dotenv').config();
1319
+
1320
+ /**
1321
+ * See https://playwright.dev/docs/test-configuration.
1322
+ */
1323
+ export default defineConfig({
1324
+ ...nxE2EPreset(__filename, { testDir: './src' }),
1325
+ /* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
1326
+ use: {
1327
+ baseURL,
1328
+ /* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
1329
+ trace: 'on-first-retry',
1330
+ },
1331
+ /* Run your local dev server before starting the tests */
1332
+ webServer: {
1333
+ command: 'pnpm exec nx serve test',
1334
+ url: 'http://localhost:4200',
1335
+ reuseExistingServer: !process.env.CI,
1336
+ cwd: workspaceRoot,
1337
+ },
1338
+ projects: [
1339
+ {
1340
+ name: 'chromium',
1341
+ use: { ...devices['Desktop Chrome'] },
1342
+ },
1343
+
1344
+ {
1345
+ name: 'firefox',
1346
+ use: { ...devices['Desktop Firefox'] },
1347
+ },
1348
+
1349
+ {
1350
+ name: 'webkit',
1351
+ use: { ...devices['Desktop Safari'] },
1352
+ },
1353
+
1354
+ // Uncomment for mobile browsers support
1355
+ /* {
1356
+ name: 'Mobile Chrome',
1357
+ use: { ...devices['Pixel 5'] },
1358
+ },
1359
+ {
1360
+ name: 'Mobile Safari',
1361
+ use: { ...devices['iPhone 12'] },
1362
+ }, */
1363
+
1364
+ // Uncomment for branded browsers
1365
+ /* {
1366
+ name: 'Microsoft Edge',
1367
+ use: { ...devices['Desktop Edge'], channel: 'msedge' },
1368
+ },
1369
+ {
1370
+ name: 'Google Chrome',
1371
+ use: { ...devices['Desktop Chrome'], channel: 'chrome' },
1372
+ } */
1373
+ ],
1374
+ });
1375
+ "
1376
+ `;
@@ -129,7 +129,7 @@ async function remixApplicationGeneratorInternal(tree, _options) {
129
129
  }
130
130
  tasks.push(jestTask);
131
131
  }
132
- const pkgInstallTask = (0, lib_1.updateUnitTestConfig)(tree, options.projectRoot, options.unitTestRunner);
132
+ const pkgInstallTask = (0, lib_1.updateUnitTestConfig)(tree, options.projectRoot, options.unitTestRunner, options.rootProject);
133
133
  tasks.push(pkgInstallTask);
134
134
  }
135
135
  else {
@@ -185,27 +185,7 @@ async function remixApplicationGeneratorInternal(tree, _options) {
185
185
  // Otherwise, extract the tsconfig.base.json from tsconfig.json so we can share settings.
186
186
  (0, create_ts_config_1.extractTsConfigBase)(tree);
187
187
  }
188
- // TODO(@columferry): add support for playwright?
189
- if (options.e2eTestRunner === 'cypress') {
190
- const { configurationGenerator } = (0, devkit_1.ensurePackage)('@nx/cypress', (0, versions_1.getPackageVersion)(tree, 'nx'));
191
- addFileServerTarget(tree, options, 'serve-static');
192
- (0, devkit_1.addProjectConfiguration)(tree, options.e2eProjectName, {
193
- projectType: 'application',
194
- root: options.e2eProjectRoot,
195
- sourceRoot: (0, devkit_1.joinPathFragments)(options.e2eProjectRoot, 'src'),
196
- targets: {},
197
- tags: [],
198
- implicitDependencies: [options.projectName],
199
- });
200
- tasks.push(await configurationGenerator(tree, {
201
- project: options.e2eProjectName,
202
- directory: 'src',
203
- skipFormat: true,
204
- devServerTarget: `${options.projectName}:serve:development`,
205
- baseUrl: 'http://localhost:4200',
206
- addPlugin: options.addPlugin,
207
- }));
208
- }
188
+ tasks.push(await (0, lib_1.addE2E)(tree, options));
209
189
  if (!options.skipFormat) {
210
190
  await (0, devkit_1.formatFiles)(tree);
211
191
  }
@@ -215,15 +195,4 @@ async function remixApplicationGeneratorInternal(tree, _options) {
215
195
  return (0, devkit_1.runTasksInSerial)(...tasks);
216
196
  }
217
197
  exports.remixApplicationGeneratorInternal = remixApplicationGeneratorInternal;
218
- function addFileServerTarget(tree, options, targetName) {
219
- const projectConfig = (0, devkit_1.readProjectConfiguration)(tree, options.projectName);
220
- projectConfig.targets[targetName] = {
221
- executor: '@nx/web:file-server',
222
- options: {
223
- buildTarget: `${options.projectName}:build`,
224
- port: 4200,
225
- },
226
- };
227
- (0, devkit_1.updateProjectConfiguration)(tree, options.projectName, projectConfig);
228
- }
229
198
  exports.default = remixApplicationGenerator;
@@ -0,0 +1,3 @@
1
+ import { type Tree } from '@nx/devkit';
2
+ import { type NormalizedSchema } from './normalize-options';
3
+ export declare function addE2E(tree: Tree, options: NormalizedSchema): Promise<import("@nx/devkit").GeneratorCallback>;
@@ -0,0 +1,66 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.addE2E = void 0;
4
+ const devkit_1 = require("@nx/devkit");
5
+ const versions_1 = require("../../../utils/versions");
6
+ async function addE2E(tree, options) {
7
+ if (options.e2eTestRunner === 'cypress') {
8
+ const { configurationGenerator } = (0, devkit_1.ensurePackage)('@nx/cypress', (0, versions_1.getPackageVersion)(tree, 'nx'));
9
+ addFileServerTarget(tree, options, 'serve-static');
10
+ (0, devkit_1.addProjectConfiguration)(tree, options.e2eProjectName, {
11
+ projectType: 'application',
12
+ root: options.e2eProjectRoot,
13
+ sourceRoot: (0, devkit_1.joinPathFragments)(options.e2eProjectRoot, 'src'),
14
+ targets: {},
15
+ tags: [],
16
+ implicitDependencies: [options.projectName],
17
+ });
18
+ return await configurationGenerator(tree, {
19
+ project: options.e2eProjectName,
20
+ directory: 'src',
21
+ skipFormat: true,
22
+ devServerTarget: `${options.projectName}:serve:development`,
23
+ baseUrl: 'http://localhost:4200',
24
+ addPlugin: options.addPlugin,
25
+ });
26
+ }
27
+ else if (options.e2eTestRunner === 'playwright') {
28
+ const { configurationGenerator } = (0, devkit_1.ensurePackage)('@nx/playwright', (0, versions_1.getPackageVersion)(tree, 'nx'));
29
+ (0, devkit_1.addProjectConfiguration)(tree, options.e2eProjectName, {
30
+ projectType: 'application',
31
+ root: options.e2eProjectRoot,
32
+ sourceRoot: (0, devkit_1.joinPathFragments)(options.e2eProjectRoot, 'src'),
33
+ targets: {},
34
+ tags: [],
35
+ implicitDependencies: [options.projectName],
36
+ });
37
+ return configurationGenerator(tree, {
38
+ project: options.e2eProjectName,
39
+ skipFormat: true,
40
+ skipPackageJson: false,
41
+ directory: 'src',
42
+ js: false,
43
+ linter: options.linter,
44
+ setParserOptionsProject: false,
45
+ webServerCommand: `${(0, devkit_1.getPackageManagerCommand)().exec} nx serve ${options.name}`,
46
+ webServerAddress: 'http://localhost:4200',
47
+ rootProject: options.rootProject,
48
+ addPlugin: options.addPlugin,
49
+ });
50
+ }
51
+ else {
52
+ return () => { };
53
+ }
54
+ }
55
+ exports.addE2E = addE2E;
56
+ function addFileServerTarget(tree, options, targetName) {
57
+ const projectConfig = (0, devkit_1.readProjectConfiguration)(tree, options.projectName);
58
+ projectConfig.targets[targetName] = {
59
+ executor: '@nx/web:file-server',
60
+ options: {
61
+ buildTarget: `${options.projectName}:build`,
62
+ port: 4200,
63
+ },
64
+ };
65
+ (0, devkit_1.updateProjectConfiguration)(tree, options.projectName, projectConfig);
66
+ }
@@ -1,2 +1,3 @@
1
1
  export * from './normalize-options';
2
2
  export * from './update-unit-test-config';
3
+ export * from './add-e2e';
@@ -3,3 +3,4 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const tslib_1 = require("tslib");
4
4
  tslib_1.__exportStar(require("./normalize-options"), exports);
5
5
  tslib_1.__exportStar(require("./update-unit-test-config"), exports);
6
+ tslib_1.__exportStar(require("./add-e2e"), exports);
@@ -1,2 +1,2 @@
1
1
  import { type Tree } from '@nx/devkit';
2
- export declare function updateUnitTestConfig(tree: Tree, pathToRoot: string, unitTestRunner: 'vitest' | 'jest'): import("@nx/devkit").GeneratorCallback;
2
+ export declare function updateUnitTestConfig(tree: Tree, pathToRoot: string, unitTestRunner: 'vitest' | 'jest', rootProject: boolean): import("@nx/devkit").GeneratorCallback;
@@ -4,7 +4,7 @@ exports.updateUnitTestConfig = void 0;
4
4
  const devkit_1 = require("@nx/devkit");
5
5
  const testing_config_utils_1 = require("../../../utils/testing-config-utils");
6
6
  const versions_1 = require("../../../utils/versions");
7
- function updateUnitTestConfig(tree, pathToRoot, unitTestRunner) {
7
+ function updateUnitTestConfig(tree, pathToRoot, unitTestRunner, rootProject) {
8
8
  const pathToTestSetup = (0, devkit_1.joinPathFragments)(pathToRoot, `test-setup.ts`);
9
9
  tree.write(pathToTestSetup, (0, devkit_1.stripIndents) `
10
10
  import { installGlobals } from '@remix-run/node';
@@ -16,9 +16,9 @@ function updateUnitTestConfig(tree, pathToRoot, unitTestRunner) {
16
16
  (0, testing_config_utils_1.updateVitestTestIncludes)(tree, pathToViteConfig, './tests/**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}');
17
17
  (0, testing_config_utils_1.updateVitestTestSetup)(tree, pathToViteConfig, 'test-setup.ts');
18
18
  }
19
- else if (unitTestRunner === 'jest') {
19
+ else if (unitTestRunner === 'jest' && rootProject) {
20
20
  const pathToJestConfig = (0, devkit_1.joinPathFragments)(pathToRoot, 'jest.config.ts');
21
- tree.rename('jest.preset.js', 'jest.preset.cjs');
21
+ tree.write('jest.preset.cjs', tree.read('jest.preset.js', 'utf-8'));
22
22
  (0, testing_config_utils_1.updateJestTestSetup)(tree, pathToJestConfig, `<rootDir>/test-setup.ts`);
23
23
  tree.write(pathToJestConfig, tree
24
24
  .read(pathToJestConfig, 'utf-8')
@@ -9,7 +9,7 @@ export interface NxRemixGeneratorSchema {
9
9
  projectNameAndRootFormat?: ProjectNameAndRootFormat;
10
10
  linter?: Linter;
11
11
  unitTestRunner?: 'vitest' | 'jest' | 'none';
12
- e2eTestRunner?: 'cypress' | 'none';
12
+ e2eTestRunner?: 'cypress' | 'playwright' | 'none';
13
13
  skipFormat?: boolean;
14
14
  rootProject?: boolean;
15
15
  addPlugin?: boolean;
@@ -45,7 +45,7 @@
45
45
  },
46
46
  "e2eTestRunner": {
47
47
  "type": "string",
48
- "enum": ["cypress", "none"],
48
+ "enum": ["cypress", "playwright", "none"],
49
49
  "default": "cypress",
50
50
  "description": "Test runner to use for e2e tests"
51
51
  },