@nx/remix 0.0.0-pr-22179-271588f

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.
Files changed (163) hide show
  1. package/LICENSE +22 -0
  2. package/README.md +63 -0
  3. package/executors.json +14 -0
  4. package/generators.d.ts +14 -0
  5. package/generators.js +31 -0
  6. package/generators.json +90 -0
  7. package/index.d.ts +1 -0
  8. package/index.js +5 -0
  9. package/migrations.json +107 -0
  10. package/package.json +53 -0
  11. package/plugin.d.ts +1 -0
  12. package/plugin.js +6 -0
  13. package/plugins/component-testing/index.d.ts +30 -0
  14. package/plugins/component-testing/index.js +64 -0
  15. package/src/executors/build/build.impl.d.ts +5 -0
  16. package/src/executors/build/build.impl.js +109 -0
  17. package/src/executors/build/schema.d.ts +7 -0
  18. package/src/executors/build/schema.json +38 -0
  19. package/src/executors/serve/schema.d.ts +9 -0
  20. package/src/executors/serve/schema.json +41 -0
  21. package/src/executors/serve/serve.impl.d.ts +6 -0
  22. package/src/executors/serve/serve.impl.js +77 -0
  23. package/src/generators/action/action.impl.d.ts +3 -0
  24. package/src/generators/action/action.impl.js +39 -0
  25. package/src/generators/action/schema.d.ts +10 -0
  26. package/src/generators/action/schema.json +29 -0
  27. package/src/generators/application/__snapshots__/application.impl.spec.ts.snap +1487 -0
  28. package/src/generators/application/application.impl.d.ts +5 -0
  29. package/src/generators/application/application.impl.js +198 -0
  30. package/src/generators/application/files/common/README.md__tmpl__ +54 -0
  31. package/src/generators/application/files/common/app/nx-welcome.tsx__tmpl__ +886 -0
  32. package/src/generators/application/files/common/app/root.tsx__tmpl__ +32 -0
  33. package/src/generators/application/files/common/app/routes/_index.tsx__tmpl__ +9 -0
  34. package/src/generators/application/files/common/public/favicon.ico +0 -0
  35. package/src/generators/application/files/common/remix.config.js__tmpl__ +17 -0
  36. package/src/generators/application/files/common/remix.env.d.ts__tmpl__ +2 -0
  37. package/src/generators/application/files/common/tests/routes/_index.spec.tsx__tmpl__ +16 -0
  38. package/src/generators/application/files/common/tsconfig.app.json__tmpl__ +20 -0
  39. package/src/generators/application/files/common/tsconfig.json__tmpl__ +24 -0
  40. package/src/generators/application/files/integrated/.gitignore__tmpl__ +4 -0
  41. package/src/generators/application/files/integrated/package.json__tmpl__ +28 -0
  42. package/src/generators/application/lib/add-e2e.d.ts +3 -0
  43. package/src/generators/application/lib/add-e2e.js +66 -0
  44. package/src/generators/application/lib/index.d.ts +3 -0
  45. package/src/generators/application/lib/index.js +6 -0
  46. package/src/generators/application/lib/normalize-options.d.ts +10 -0
  47. package/src/generators/application/lib/normalize-options.js +37 -0
  48. package/src/generators/application/lib/update-unit-test-config.d.ts +2 -0
  49. package/src/generators/application/lib/update-unit-test-config.js +55 -0
  50. package/src/generators/application/schema.d.ts +16 -0
  51. package/src/generators/application/schema.json +68 -0
  52. package/src/generators/cypress-component-configuration/cypress-component-configuration.impl.d.ts +5 -0
  53. package/src/generators/cypress-component-configuration/cypress-component-configuration.impl.js +34 -0
  54. package/src/generators/cypress-component-configuration/files/cypress.config.ts__tmpl__ +6 -0
  55. package/src/generators/cypress-component-configuration/schema.d.ts +6 -0
  56. package/src/generators/cypress-component-configuration/schema.json +41 -0
  57. package/src/generators/error-boundary/__snapshots__/error-boundary.impl.spec.ts.snap +61 -0
  58. package/src/generators/error-boundary/error-boundary.impl.d.ts +3 -0
  59. package/src/generators/error-boundary/error-boundary.impl.js +12 -0
  60. package/src/generators/error-boundary/lib/add-v2-error-boundary.d.ts +3 -0
  61. package/src/generators/error-boundary/lib/add-v2-error-boundary.js +38 -0
  62. package/src/generators/error-boundary/lib/index.d.ts +2 -0
  63. package/src/generators/error-boundary/lib/index.js +5 -0
  64. package/src/generators/error-boundary/lib/normalize-options.d.ts +3 -0
  65. package/src/generators/error-boundary/lib/normalize-options.js +17 -0
  66. package/src/generators/error-boundary/schema.d.ts +11 -0
  67. package/src/generators/error-boundary/schema.json +37 -0
  68. package/src/generators/init/init.d.ts +5 -0
  69. package/src/generators/init/init.js +60 -0
  70. package/src/generators/init/schema.d.ts +7 -0
  71. package/src/generators/init/schema.json +33 -0
  72. package/src/generators/library/__snapshots__/library.impl.spec.ts.snap +157 -0
  73. package/src/generators/library/lib/add-tsconfig-entry-points.d.ts +3 -0
  74. package/src/generators/library/lib/add-tsconfig-entry-points.js +19 -0
  75. package/src/generators/library/lib/add-unit-testing.d.ts +3 -0
  76. package/src/generators/library/lib/add-unit-testing.js +32 -0
  77. package/src/generators/library/lib/index.d.ts +4 -0
  78. package/src/generators/library/lib/index.js +7 -0
  79. package/src/generators/library/lib/normalize-options.d.ts +7 -0
  80. package/src/generators/library/lib/normalize-options.js +29 -0
  81. package/src/generators/library/lib/update-buildable-config.d.ts +2 -0
  82. package/src/generators/library/lib/update-buildable-config.js +21 -0
  83. package/src/generators/library/library.impl.d.ts +6 -0
  84. package/src/generators/library/library.impl.js +45 -0
  85. package/src/generators/library/schema.d.ts +16 -0
  86. package/src/generators/library/schema.json +74 -0
  87. package/src/generators/loader/loader.impl.d.ts +3 -0
  88. package/src/generators/loader/loader.impl.js +39 -0
  89. package/src/generators/loader/schema.d.ts +10 -0
  90. package/src/generators/loader/schema.json +29 -0
  91. package/src/generators/meta/lib/v2.impl.d.ts +3 -0
  92. package/src/generators/meta/lib/v2.impl.js +28 -0
  93. package/src/generators/meta/meta.impl.d.ts +3 -0
  94. package/src/generators/meta/meta.impl.js +7 -0
  95. package/src/generators/meta/schema.d.ts +10 -0
  96. package/src/generators/meta/schema.json +29 -0
  97. package/src/generators/preset/lib/normalize-options.d.ts +11 -0
  98. package/src/generators/preset/lib/normalize-options.js +20 -0
  99. package/src/generators/preset/preset.impl.d.ts +3 -0
  100. package/src/generators/preset/preset.impl.js +32 -0
  101. package/src/generators/preset/schema.d.ts +4 -0
  102. package/src/generators/preset/schema.json +14 -0
  103. package/src/generators/resource-route/__snapshots__/resource-route.impl.spec.ts.snap +21 -0
  104. package/src/generators/resource-route/resource-route.impl.d.ts +3 -0
  105. package/src/generators/resource-route/resource-route.impl.js +41 -0
  106. package/src/generators/resource-route/schema.d.ts +13 -0
  107. package/src/generators/resource-route/schema.json +51 -0
  108. package/src/generators/route/__snapshots__/route.impl.spec.ts.snap +95 -0
  109. package/src/generators/route/route.impl.d.ts +3 -0
  110. package/src/generators/route/route.impl.js +78 -0
  111. package/src/generators/route/schema.d.ts +15 -0
  112. package/src/generators/route/schema.json +62 -0
  113. package/src/generators/setup/schema.json +14 -0
  114. package/src/generators/setup/setup.impl.d.ts +2 -0
  115. package/src/generators/setup/setup.impl.js +34 -0
  116. package/src/generators/setup-tailwind/__snapshots__/setup-tailwind.impl.spec.ts.snap +170 -0
  117. package/src/generators/setup-tailwind/files/app/tailwind.css__tpl__ +3 -0
  118. package/src/generators/setup-tailwind/files/tailwind.config.ts__tpl__ +13 -0
  119. package/src/generators/setup-tailwind/lib/index.d.ts +1 -0
  120. package/src/generators/setup-tailwind/lib/index.js +4 -0
  121. package/src/generators/setup-tailwind/lib/update-remix-config.d.ts +2 -0
  122. package/src/generators/setup-tailwind/lib/update-remix-config.js +35 -0
  123. package/src/generators/setup-tailwind/schema.d.ts +5 -0
  124. package/src/generators/setup-tailwind/schema.json +36 -0
  125. package/src/generators/setup-tailwind/setup-tailwind.impl.d.ts +3 -0
  126. package/src/generators/setup-tailwind/setup-tailwind.impl.js +34 -0
  127. package/src/generators/storybook-configuration/__snapshots__/storybook-configuration.impl.spec.ts.snap +73 -0
  128. package/src/generators/storybook-configuration/files/vite.config.ts__tpl__ +15 -0
  129. package/src/generators/storybook-configuration/schema.d.ts +16 -0
  130. package/src/generators/storybook-configuration/schema.json +89 -0
  131. package/src/generators/storybook-configuration/storybook-configuration.impl.d.ts +4 -0
  132. package/src/generators/storybook-configuration/storybook-configuration.impl.js +26 -0
  133. package/src/generators/style/schema.d.ts +10 -0
  134. package/src/generators/style/schema.json +36 -0
  135. package/src/generators/style/style.impl.d.ts +3 -0
  136. package/src/generators/style/style.impl.js +61 -0
  137. package/src/generators/utils/update-dependencies.d.ts +2 -0
  138. package/src/generators/utils/update-dependencies.js +21 -0
  139. package/src/plugins/__snapshots__/plugin.spec.ts.snap +113 -0
  140. package/src/plugins/plugin.d.ts +9 -0
  141. package/src/plugins/plugin.js +136 -0
  142. package/src/utils/create-watch-paths.d.ts +8 -0
  143. package/src/utils/create-watch-paths.js +40 -0
  144. package/src/utils/get-default-export-name.d.ts +2 -0
  145. package/src/utils/get-default-export-name.js +8 -0
  146. package/src/utils/get-default-export.d.ts +2 -0
  147. package/src/utils/get-default-export.js +15 -0
  148. package/src/utils/insert-import.d.ts +4 -0
  149. package/src/utils/insert-import.js +54 -0
  150. package/src/utils/insert-statement-after-imports.d.ts +5 -0
  151. package/src/utils/insert-statement-after-imports.js +28 -0
  152. package/src/utils/insert-statement-in-default-function.d.ts +2 -0
  153. package/src/utils/insert-statement-in-default-function.js +23 -0
  154. package/src/utils/remix-config.d.ts +5 -0
  155. package/src/utils/remix-config.js +45 -0
  156. package/src/utils/remix-route-utils.d.ts +13 -0
  157. package/src/utils/remix-route-utils.js +70 -0
  158. package/src/utils/testing-config-utils.d.ts +4 -0
  159. package/src/utils/testing-config-utils.js +79 -0
  160. package/src/utils/upsert-links-function.d.ts +2 -0
  161. package/src/utils/upsert-links-function.js +31 -0
  162. package/src/utils/versions.d.ts +16 -0
  163. package/src/utils/versions.js +28 -0
@@ -0,0 +1,5 @@
1
+ import { GeneratorCallback, Tree } from '@nx/devkit';
2
+ import { NxRemixGeneratorSchema } from './schema';
3
+ export declare function remixApplicationGenerator(tree: Tree, options: NxRemixGeneratorSchema): Promise<GeneratorCallback>;
4
+ export declare function remixApplicationGeneratorInternal(tree: Tree, _options: NxRemixGeneratorSchema): Promise<GeneratorCallback>;
5
+ export default remixApplicationGenerator;
@@ -0,0 +1,198 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.remixApplicationGeneratorInternal = exports.remixApplicationGenerator = void 0;
4
+ const devkit_1 = require("@nx/devkit");
5
+ const create_ts_config_1 = require("@nx/js/src/utils/typescript/create-ts-config");
6
+ const versions_1 = require("../../utils/versions");
7
+ const lib_1 = require("./lib");
8
+ const update_dependencies_1 = require("../utils/update-dependencies");
9
+ const init_1 = require("../init/init");
10
+ const js_1 = require("@nx/js");
11
+ const add_build_target_defaults_1 = require("@nx/devkit/src/generators/add-build-target-defaults");
12
+ const log_show_project_command_1 = require("@nx/devkit/src/utils/log-show-project-command");
13
+ function remixApplicationGenerator(tree, options) {
14
+ return remixApplicationGeneratorInternal(tree, {
15
+ addPlugin: false,
16
+ ...options,
17
+ });
18
+ }
19
+ exports.remixApplicationGenerator = remixApplicationGenerator;
20
+ async function remixApplicationGeneratorInternal(tree, _options) {
21
+ const options = await (0, lib_1.normalizeOptions)(tree, _options);
22
+ const tasks = [
23
+ await (0, init_1.default)(tree, {
24
+ skipFormat: true,
25
+ addPlugin: options.addPlugin,
26
+ }),
27
+ await (0, js_1.initGenerator)(tree, { skipFormat: true }),
28
+ ];
29
+ (0, add_build_target_defaults_1.addBuildTargetDefaults)(tree, '@nx/remix:build');
30
+ (0, devkit_1.addProjectConfiguration)(tree, options.projectName, {
31
+ root: options.projectRoot,
32
+ sourceRoot: `${options.projectRoot}`,
33
+ projectType: 'application',
34
+ tags: options.parsedTags,
35
+ targets: !options.addPlugin
36
+ ? {
37
+ build: {
38
+ executor: '@nx/remix:build',
39
+ outputs: ['{options.outputPath}'],
40
+ options: {
41
+ outputPath: (0, devkit_1.joinPathFragments)('dist', options.projectRoot),
42
+ },
43
+ },
44
+ serve: {
45
+ executor: `@nx/remix:serve`,
46
+ options: {
47
+ command: `${(0, devkit_1.getPackageManagerCommand)().exec} remix-serve build/index.js`,
48
+ manual: true,
49
+ port: 4200,
50
+ },
51
+ },
52
+ start: {
53
+ dependsOn: ['build'],
54
+ command: `remix-serve build/index.js`,
55
+ options: {
56
+ cwd: options.projectRoot,
57
+ },
58
+ },
59
+ typecheck: {
60
+ command: `tsc --project tsconfig.app.json`,
61
+ options: {
62
+ cwd: options.projectRoot,
63
+ },
64
+ },
65
+ }
66
+ : {},
67
+ });
68
+ const installTask = (0, update_dependencies_1.updateDependencies)(tree);
69
+ tasks.push(installTask);
70
+ const vars = {
71
+ ...options,
72
+ tmpl: '',
73
+ offsetFromRoot: (0, devkit_1.offsetFromRoot)(options.projectRoot),
74
+ remixVersion: versions_1.remixVersion,
75
+ isbotVersion: versions_1.isbotVersion,
76
+ reactVersion: versions_1.reactVersion,
77
+ reactDomVersion: versions_1.reactDomVersion,
78
+ typesReactVersion: versions_1.typesReactVersion,
79
+ typesReactDomVersion: versions_1.typesReactDomVersion,
80
+ eslintVersion: versions_1.eslintVersion,
81
+ typescriptVersion: versions_1.typescriptVersion,
82
+ };
83
+ (0, devkit_1.generateFiles)(tree, (0, devkit_1.joinPathFragments)(__dirname, 'files/common'), options.projectRoot, vars);
84
+ if (options.rootProject) {
85
+ const gitignore = tree.read('.gitignore', 'utf-8');
86
+ tree.write('.gitignore', `${gitignore}\n.cache\nbuild\npublic/build\n.env\n`);
87
+ }
88
+ else {
89
+ (0, devkit_1.generateFiles)(tree, (0, devkit_1.joinPathFragments)(__dirname, 'files/integrated'), options.projectRoot, vars);
90
+ }
91
+ if (options.unitTestRunner !== 'none') {
92
+ if (options.unitTestRunner === 'vitest') {
93
+ const { vitestGenerator, createOrEditViteConfig } = (0, devkit_1.ensurePackage)('@nx/vite', (0, versions_1.getPackageVersion)(tree, 'nx'));
94
+ const vitestTask = await vitestGenerator(tree, {
95
+ uiFramework: 'react',
96
+ project: options.projectName,
97
+ coverageProvider: 'v8',
98
+ inSourceTests: false,
99
+ skipFormat: true,
100
+ testEnvironment: 'jsdom',
101
+ skipViteConfig: true,
102
+ addPlugin: options.addPlugin,
103
+ });
104
+ createOrEditViteConfig(tree, {
105
+ project: options.projectName,
106
+ includeLib: false,
107
+ includeVitest: true,
108
+ testEnvironment: 'jsdom',
109
+ imports: [`import react from '@vitejs/plugin-react';`],
110
+ plugins: [`react()`],
111
+ }, true, undefined, true);
112
+ tasks.push(vitestTask);
113
+ }
114
+ else {
115
+ const { configurationGenerator: jestConfigurationGenerator } = (0, devkit_1.ensurePackage)('@nx/jest', (0, versions_1.getPackageVersion)(tree, 'nx'));
116
+ const jestTask = await jestConfigurationGenerator(tree, {
117
+ project: options.projectName,
118
+ setupFile: 'none',
119
+ supportTsx: true,
120
+ skipSerializers: false,
121
+ skipPackageJson: false,
122
+ skipFormat: true,
123
+ addPlugin: options.addPlugin,
124
+ });
125
+ const projectConfig = (0, devkit_1.readProjectConfiguration)(tree, options.projectName);
126
+ if (projectConfig.targets['test']?.options) {
127
+ projectConfig.targets['test'].options.passWithNoTests = true;
128
+ (0, devkit_1.updateProjectConfiguration)(tree, options.projectName, projectConfig);
129
+ }
130
+ tasks.push(jestTask);
131
+ }
132
+ const pkgInstallTask = (0, lib_1.updateUnitTestConfig)(tree, options.projectRoot, options.unitTestRunner, options.rootProject);
133
+ tasks.push(pkgInstallTask);
134
+ }
135
+ else {
136
+ tree.delete((0, devkit_1.joinPathFragments)(options.projectRoot, `tests/routes/_index.spec.tsx`));
137
+ }
138
+ if (options.linter !== 'none') {
139
+ const { lintProjectGenerator } = (0, devkit_1.ensurePackage)('@nx/eslint', (0, versions_1.getPackageVersion)(tree, 'nx'));
140
+ const eslintTask = await lintProjectGenerator(tree, {
141
+ linter: options.linter,
142
+ project: options.projectName,
143
+ tsConfigPaths: [
144
+ (0, devkit_1.joinPathFragments)(options.projectRoot, 'tsconfig.app.json'),
145
+ ],
146
+ unitTestRunner: options.unitTestRunner,
147
+ skipFormat: true,
148
+ rootProject: options.rootProject,
149
+ addPlugin: options.addPlugin,
150
+ });
151
+ tasks.push(eslintTask);
152
+ tree.write((0, devkit_1.joinPathFragments)(options.projectRoot, '.eslintignore'), (0, devkit_1.stripIndents) `build
153
+ public/build`);
154
+ }
155
+ if (options.js) {
156
+ (0, devkit_1.toJS)(tree);
157
+ }
158
+ if (options.rootProject && tree.exists('tsconfig.base.json')) {
159
+ // If this is a standalone project, merge tsconfig.json and tsconfig.base.json.
160
+ const tsConfigBaseJson = (0, devkit_1.readJson)(tree, 'tsconfig.base.json');
161
+ (0, devkit_1.updateJson)(tree, 'tsconfig.json', (json) => {
162
+ delete json.extends;
163
+ json.compilerOptions = {
164
+ ...tsConfigBaseJson.compilerOptions,
165
+ ...json.compilerOptions,
166
+ // Taken from remix default setup
167
+ // https://github.com/remix-run/remix/blob/68c8982/templates/remix/tsconfig.json#L15-L17
168
+ paths: {
169
+ '~/*': ['./app/*'],
170
+ },
171
+ };
172
+ json.include = [
173
+ ...(tsConfigBaseJson.include ?? []),
174
+ ...(json.include ?? []),
175
+ ];
176
+ json.exclude = [
177
+ ...(tsConfigBaseJson.exclude ?? []),
178
+ ...(json.exclude ?? []),
179
+ ];
180
+ return json;
181
+ });
182
+ tree.delete('tsconfig.base.json');
183
+ }
184
+ else {
185
+ // Otherwise, extract the tsconfig.base.json from tsconfig.json so we can share settings.
186
+ (0, create_ts_config_1.extractTsConfigBase)(tree);
187
+ }
188
+ tasks.push(await (0, lib_1.addE2E)(tree, options));
189
+ if (!options.skipFormat) {
190
+ await (0, devkit_1.formatFiles)(tree);
191
+ }
192
+ tasks.push(() => {
193
+ (0, log_show_project_command_1.logShowProjectCommand)(options.projectName);
194
+ });
195
+ return (0, devkit_1.runTasksInSerial)(...tasks);
196
+ }
197
+ exports.remixApplicationGeneratorInternal = remixApplicationGeneratorInternal;
198
+ exports.default = remixApplicationGenerator;
@@ -0,0 +1,54 @@
1
+ # Welcome to Nx + Remix!
2
+
3
+ - [Remix Docs](https://remix.run/docs)
4
+ - [Nx Docs](https://nx.dev)
5
+
6
+ ## Development
7
+
8
+ From your terminal:
9
+
10
+ ```sh
11
+ npx nx dev <%= projectName %>
12
+ ```
13
+
14
+ This starts your app in development mode, rebuilding assets on file changes.
15
+
16
+ ## Deployment
17
+
18
+ First, build your app for production:
19
+
20
+ ```sh
21
+ npx nx build <%= projectName %>
22
+ ```
23
+
24
+ Then run the app in production mode:
25
+
26
+ ```sh
27
+ npx nx start <%= projectName %>
28
+ ```
29
+
30
+ Now you'll need to pick a host to deploy it to.
31
+
32
+ ### DIY
33
+
34
+ If you're familiar with deploying node applications, the built-in Remix app server is production-ready.
35
+
36
+ Make sure to deploy the output of `remix build`
37
+
38
+ - `packages/<%= projectName %>/build/`
39
+ - `packages/<%= projectName %>/public/build/`
40
+
41
+ ### Using a Template
42
+
43
+ When you ran `npx create-remix@latest` there were a few choices for hosting. You can run that again to create a new project, then copy over your `app/` folder to the new project that's pre-configured for your target server.
44
+
45
+ ```sh
46
+ cd ..
47
+ # create a new project, and pick a pre-configured host
48
+ npx create-remix@latest
49
+ cd my-new-remix-app
50
+ # remove the new project's app (not the old one!)
51
+ rm -rf app
52
+ # copy your app over
53
+ cp -R ../my-old-remix-app/app app
54
+ ```