@nrwl/remix 13.7.1 → 14.7.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.
Files changed (80) hide show
  1. package/README.md +2 -2
  2. package/generators.json +25 -0
  3. package/migrations.json +54 -0
  4. package/package.json +8 -4
  5. package/src/generators/action/action.impl.d.ts +3 -0
  6. package/src/generators/action/action.impl.js +48 -0
  7. package/src/generators/action/action.impl.js.map +1 -0
  8. package/src/generators/action/schema.d.ts +4 -0
  9. package/src/generators/action/schema.json +27 -0
  10. package/src/generators/application/application.impl.js +13 -11
  11. package/src/generators/application/application.impl.js.map +1 -1
  12. package/src/generators/application/files/.gitignore__tmpl__ +4 -0
  13. package/src/generators/application/files/app/entry.client.tsx__tmpl__ +2 -2
  14. package/src/generators/application/files/app/entry.server.tsx__tmpl__ +4 -4
  15. package/src/generators/application/files/app/root.tsx__tmpl__ +10 -156
  16. package/src/generators/application/files/app/routes/index.tsx__tmpl__ +28 -96
  17. package/src/generators/application/files/package.json__tmpl__ +4 -5
  18. package/src/generators/application/files/remix.config.js__tmpl__ +8 -7
  19. package/src/generators/application/files/tsconfig.json__tmpl__ +5 -4
  20. package/src/generators/cypress/cypress.impl.js +5 -5
  21. package/src/generators/cypress/cypress.impl.js.map +1 -1
  22. package/src/generators/library/library.impl.js +1 -1
  23. package/src/generators/loader/loader.impl.d.ts +3 -0
  24. package/src/generators/loader/loader.impl.js +48 -0
  25. package/src/generators/loader/loader.impl.js.map +1 -0
  26. package/src/generators/loader/schema.d.ts +4 -0
  27. package/src/generators/loader/schema.json +27 -0
  28. package/src/generators/meta/meta.impl.d.ts +3 -0
  29. package/src/generators/meta/meta.impl.js +29 -0
  30. package/src/generators/meta/meta.impl.js.map +1 -0
  31. package/src/generators/meta/schema.d.ts +4 -0
  32. package/src/generators/meta/schema.json +27 -0
  33. package/src/generators/preset/preset.impl.js +1 -1
  34. package/src/generators/resource-route/resource-route.impl.d.ts +3 -0
  35. package/src/generators/resource-route/resource-route.impl.js +32 -0
  36. package/src/generators/resource-route/resource-route.impl.js.map +1 -0
  37. package/src/generators/resource-route/schema.d.ts +6 -0
  38. package/src/generators/resource-route/schema.json +44 -0
  39. package/src/generators/route/route.impl.js +38 -62
  40. package/src/generators/route/route.impl.js.map +1 -1
  41. package/src/generators/route/schema.d.ts +3 -0
  42. package/src/generators/route/schema.json +24 -9
  43. package/src/generators/setup/setup.impl.js +1 -1
  44. package/src/generators/style/schema.d.ts +4 -0
  45. package/src/generators/style/schema.json +34 -0
  46. package/src/generators/style/style.impl.d.ts +3 -0
  47. package/src/generators/style/style.impl.js +41 -0
  48. package/src/generators/style/style.impl.js.map +1 -0
  49. package/src/migrations/update-14-5-4/update-tsconfig-and-remix-config-for-1-6-8.d.ts +6 -0
  50. package/src/migrations/update-14-5-4/update-tsconfig-and-remix-config-for-1-6-8.js +45 -0
  51. package/src/migrations/update-14-5-4/update-tsconfig-and-remix-config-for-1-6-8.js.map +1 -0
  52. package/src/utils/get-default-export-name.d.ts +2 -0
  53. package/src/utils/get-default-export-name.js +10 -0
  54. package/src/utils/get-default-export-name.js.map +1 -0
  55. package/src/utils/get-default-export.d.ts +2 -0
  56. package/src/utils/get-default-export.js +16 -0
  57. package/src/utils/get-default-export.js.map +1 -0
  58. package/src/utils/insert-import.d.ts +4 -0
  59. package/src/utils/insert-import.js +55 -0
  60. package/src/utils/insert-import.js.map +1 -0
  61. package/src/utils/insert-statement-after-imports.d.ts +5 -0
  62. package/src/utils/insert-statement-after-imports.js +29 -0
  63. package/src/utils/insert-statement-after-imports.js.map +1 -0
  64. package/src/utils/insert-statement-in-default-function.d.ts +2 -0
  65. package/src/utils/insert-statement-in-default-function.js +24 -0
  66. package/src/utils/insert-statement-in-default-function.js.map +1 -0
  67. package/src/utils/remix-route-utils.d.ts +11 -0
  68. package/src/utils/remix-route-utils.js +53 -0
  69. package/src/utils/remix-route-utils.js.map +1 -0
  70. package/src/generators/application/files/app/routes/demos/about/index.tsx__tmpl__ +0 -17
  71. package/src/generators/application/files/app/routes/demos/about/whoa.tsx__tmpl__ +0 -20
  72. package/src/generators/application/files/app/routes/demos/about.tsx__tmpl__ +0 -44
  73. package/src/generators/application/files/app/routes/demos/actions.tsx__tmpl__ +0 -101
  74. package/src/generators/application/files/app/routes/demos/correct.tsx__tmpl__ +0 -3
  75. package/src/generators/application/files/app/routes/demos/params/$id.tsx__tmpl__ +0 -110
  76. package/src/generators/application/files/app/routes/demos/params/index.tsx__tmpl__ +0 -40
  77. package/src/generators/application/files/app/routes/demos/params.tsx__tmpl__ +0 -43
  78. package/src/generators/application/files/app/styles/dark.css +0 -7
  79. package/src/generators/application/files/app/styles/demos/about.css +0 -26
  80. package/src/generators/application/files/app/styles/global.css +0 -216
@@ -1,10 +1,11 @@
1
1
  /**
2
- * @type {import('@remix-run/dev/config').AppConfig}
2
+ * @type {import('@remix-run/dev').AppConfig}
3
3
  */
4
4
  module.exports = {
5
- appDirectory: "app",
6
- browserBuildDirectory: "public/build",
7
- publicPath: "/build/",
8
- serverBuildDirectory: "build",
9
- devServerPort: 8002
10
- };
5
+ ignoredRouteFiles: ["**/.*"],
6
+ // appDirectory: "app",
7
+ // assetsBuildDirectory: "public/build",
8
+ // serverBuildPath: "build/index.js",
9
+ // publicPath: "/build/",
10
+ watchPaths: ["<%= offsetFromRoot %>libs"]
11
+ };
@@ -1,17 +1,18 @@
1
1
  {
2
+ "extends": "<%= offsetFromRoot %>tsconfig.base.json",
2
3
  "include": ["remix.env.d.ts", "**/*.ts", "**/*.tsx"],
3
4
  "compilerOptions": {
4
5
  "lib": ["DOM", "DOM.Iterable", "ES2019"],
6
+ "isolatedModules": true,
5
7
  "esModuleInterop": true,
6
8
  "jsx": "react-jsx",
7
9
  "moduleResolution": "node",
8
10
  "resolveJsonModule": true,
9
11
  "target": "ES2019",
10
12
  "strict": true,
11
- "paths": {
12
- "~/*": ["./app/*"]
13
- },
13
+ "allowJs": true,
14
+ "forceConsistentCasingInFileNames": true,
14
15
  // Remix takes care of building everything in `remix build`.
15
16
  "noEmit": true
16
17
  }
17
- }
18
+ }
@@ -4,12 +4,12 @@ const tslib_1 = require("tslib");
4
4
  const devkit_1 = require("@nrwl/devkit");
5
5
  const cypress_1 = require("@nrwl/cypress");
6
6
  function default_1(tree, options) {
7
- return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () {
8
- const initSideEffects = (0, cypress_1.cypressInitGenerator)(tree);
7
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
8
+ const initSideEffects = (0, cypress_1.cypressInitGenerator)(tree, {});
9
9
  const projSideEffects = (0, cypress_1.cypressProjectGenerator)(tree, Object.assign(Object.assign({}, options), { standaloneConfig: true }));
10
10
  const config = (0, devkit_1.readProjectConfiguration)(tree, options.name);
11
- tree.delete((0, devkit_1.joinPathFragments)(config.sourceRoot, "support", "app.po.ts"));
12
- tree.write((0, devkit_1.joinPathFragments)(config.sourceRoot, "integration", "app.spec.ts"), `describe('webapp', () => {
11
+ tree.delete((0, devkit_1.joinPathFragments)(config.sourceRoot, 'support', 'app.po.ts'));
12
+ tree.write((0, devkit_1.joinPathFragments)(config.sourceRoot, 'integration', 'app.spec.ts'), `describe('webapp', () => {
13
13
  beforeEach(() => cy.visit('/'));
14
14
 
15
15
  it('should display welcome message', () => {
@@ -17,7 +17,7 @@ function default_1(tree, options) {
17
17
  });
18
18
  });`);
19
19
  // returning this in case the cypress generator has any side effects
20
- return () => (0, tslib_1.__awaiter)(this, void 0, void 0, function* () {
20
+ return () => tslib_1.__awaiter(this, void 0, void 0, function* () {
21
21
  yield initSideEffects;
22
22
  yield projSideEffects;
23
23
  });
@@ -1 +1 @@
1
- {"version":3,"file":"cypress.impl.js","sourceRoot":"","sources":["../../../../../../packages/remix/src/generators/cypress/cypress.impl.ts"],"names":[],"mappings":";;;AAAA,yCAAgF;AAEhF,2CAA2E;AAE3E,mBACE,IAAU,EACV,OAAY;;QAEZ,MAAM,eAAe,GAAG,IAAA,8BAAoB,EAAC,IAAI,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;;;;;IAMA,CACD,CAAC;QACF,oEAAoE;QACpE,OAAO,GAAS,EAAE;YAChB,MAAM,eAAe,CAAC;YACtB,MAAM,eAAe,CAAC;QACxB,CAAC,CAAA,CAAC;IACJ,CAAC;CAAA;AAxBD,4BAwBC"}
@@ -7,7 +7,7 @@ const linter_1 = require("@nrwl/linter");
7
7
  const child_process_1 = require("child_process");
8
8
  const run_tasks_in_serial_1 = require("@nrwl/workspace/src/utilities/run-tasks-in-serial");
9
9
  function default_1(tree, options) {
10
- return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () {
10
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
11
11
  const tasks = [];
12
12
  const name = (0, devkit_1.names)(options.name).fileName;
13
13
  const pm = (0, devkit_1.detectPackageManager)();
@@ -0,0 +1,3 @@
1
+ import { Tree } from '@nrwl/devkit';
2
+ import { LoaderSchema } from './schema';
3
+ export default function (tree: Tree, schema: LoaderSchema): Promise<void>;
@@ -0,0 +1,48 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ const devkit_1 = require("@nrwl/devkit");
5
+ const insert_import_1 = require("../../utils/insert-import");
6
+ const insert_statement_after_imports_1 = require("../../utils/insert-statement-after-imports");
7
+ const get_default_export_name_1 = require("../../utils/get-default-export-name");
8
+ const insert_statement_in_default_function_1 = require("../../utils/insert-statement-in-default-function");
9
+ const remix_route_utils_1 = require("../../utils/remix-route-utils");
10
+ function default_1(tree, schema) {
11
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
12
+ const routeFilePath = (0, remix_route_utils_1.resolveRemixRouteFile)(tree, schema.path, schema.project);
13
+ if (!tree.exists(routeFilePath)) {
14
+ throw new Error(`Route path does not exist: ${routeFilePath}. Please generate a Remix route first.`);
15
+ }
16
+ (0, insert_import_1.insertImport)(tree, routeFilePath, 'LoaderFunction', '@remix-run/node', {
17
+ typeOnly: true,
18
+ });
19
+ (0, insert_import_1.insertImport)(tree, routeFilePath, 'useLoaderData', '@remix-run/react');
20
+ (0, insert_import_1.insertImport)(tree, routeFilePath, 'json', '@remix-run/node');
21
+ const defaultExportName = (0, get_default_export_name_1.getDefaultExportName)(tree, routeFilePath);
22
+ const loaderTypeName = `${defaultExportName}LoaderData`;
23
+ (0, insert_statement_after_imports_1.insertStatementAfterImports)(tree, routeFilePath, `
24
+ type ${loaderTypeName} = {
25
+ message: string;
26
+ };
27
+
28
+ export const loader: LoaderFunction = async () => {
29
+ return json({
30
+ message: 'Hello, world!',
31
+ })
32
+ };
33
+
34
+ `);
35
+ const statement = `\nconst data = useLoaderData<${loaderTypeName}>();`;
36
+ try {
37
+ (0, insert_statement_in_default_function_1.insertStatementInDefaultFunction)(tree, routeFilePath, statement);
38
+ // eslint-disable-next-line no-empty
39
+ }
40
+ catch (err) {
41
+ }
42
+ finally {
43
+ yield (0, devkit_1.formatFiles)(tree);
44
+ }
45
+ });
46
+ }
47
+ exports.default = default_1;
48
+ //# sourceMappingURL=loader.impl.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"loader.impl.js","sourceRoot":"","sources":["../../../../../../packages/remix/src/generators/loader/loader.impl.ts"],"names":[],"mappings":";;;AAAA,yCAAiD;AAEjD,6DAAyD;AACzD,+FAAyF;AACzF,iFAA2E;AAC3E,2GAAoG;AACpG,qEAAsE;AAEtE,mBAA+B,IAAU,EAAE,MAAoB;;QAC7D,MAAM,aAAa,GAAG,IAAA,yCAAqB,EACzC,IAAI,EACJ,MAAM,CAAC,IAAI,EACX,MAAM,CAAC,OAAO,CACf,CAAC;QAEF,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,EAAE;YAC/B,MAAM,IAAI,KAAK,CACb,8BAA8B,aAAa,wCAAwC,CACpF,CAAC;SACH;QAED,IAAA,4BAAY,EAAC,IAAI,EAAE,aAAa,EAAE,gBAAgB,EAAE,iBAAiB,EAAE;YACrE,QAAQ,EAAE,IAAI;SACf,CAAC,CAAC;QACH,IAAA,4BAAY,EAAC,IAAI,EAAE,aAAa,EAAE,eAAe,EAAE,kBAAkB,CAAC,CAAC;QACvE,IAAA,4BAAY,EAAC,IAAI,EAAE,aAAa,EAAE,MAAM,EAAE,iBAAiB,CAAC,CAAC;QAE7D,MAAM,iBAAiB,GAAG,IAAA,8CAAoB,EAAC,IAAI,EAAE,aAAa,CAAC,CAAC;QACpE,MAAM,cAAc,GAAG,GAAG,iBAAiB,YAAY,CAAC;QAExD,IAAA,4DAA2B,EACzB,IAAI,EACJ,aAAa,EACb;WACO,cAAc;;;;;;;;;;KAUpB,CACF,CAAC;QAEF,MAAM,SAAS,GAAG,gCAAgC,cAAc,MAAM,CAAC;QAEvE,IAAI;YACF,IAAA,uEAAgC,EAAC,IAAI,EAAE,aAAa,EAAE,SAAS,CAAC,CAAC;YACjE,oCAAoC;SACrC;QAAC,OAAO,GAAG,EAAE;SACb;gBAAS;YACR,MAAM,IAAA,oBAAW,EAAC,IAAI,CAAC,CAAC;SACzB;IACH,CAAC;CAAA;AAhDD,4BAgDC"}
@@ -0,0 +1,4 @@
1
+ export interface LoaderSchema {
2
+ project: string;
3
+ path: string;
4
+ }
@@ -0,0 +1,27 @@
1
+ {
2
+ "$schema": "http://json-schema.org/schema",
3
+ "cli": "nx",
4
+ "$id": "data-loader",
5
+ "type": "object",
6
+ "properties": {
7
+ "path": {
8
+ "type": "string",
9
+ "description": "The route path or path to the filename of the route.",
10
+ "$default": {
11
+ "$source": "argv",
12
+ "index": 0
13
+ },
14
+ "x-prompt": "What is the path of the route? (e.g. 'foo/bar')"
15
+ },
16
+ "project": {
17
+ "type": "string",
18
+ "description": "The name of the project.",
19
+ "$default": {
20
+ "$source": "projectName"
21
+ },
22
+ "x-prompt": "What project is this route for?",
23
+ "pattern": "^[a-zA-Z].*$"
24
+ }
25
+ },
26
+ "required": ["path", "project"]
27
+ }
@@ -0,0 +1,3 @@
1
+ import { Tree } from '@nrwl/devkit';
2
+ import { LoaderSchema } from './schema';
3
+ export default function (tree: Tree, schema: LoaderSchema): Promise<void>;
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ const devkit_1 = require("@nrwl/devkit");
5
+ const insert_import_1 = require("../../utils/insert-import");
6
+ const insert_statement_after_imports_1 = require("../../utils/insert-statement-after-imports");
7
+ const get_default_export_name_1 = require("../../utils/get-default-export-name");
8
+ const remix_route_utils_1 = require("../../utils/remix-route-utils");
9
+ function default_1(tree, schema) {
10
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
11
+ const routeFilePath = (0, remix_route_utils_1.resolveRemixRouteFile)(tree, schema.path, schema.project);
12
+ if (!tree.exists(routeFilePath)) {
13
+ throw new Error(`Route path does not exist: ${routeFilePath}. Please generate a Remix route first.`);
14
+ }
15
+ (0, insert_import_1.insertImport)(tree, routeFilePath, 'MetaFunction', '@remix-run/node', {
16
+ typeOnly: true,
17
+ });
18
+ const defaultExportName = (0, get_default_export_name_1.getDefaultExportName)(tree, routeFilePath);
19
+ (0, insert_statement_after_imports_1.insertStatementAfterImports)(tree, routeFilePath, `
20
+ export const meta: MetaFunction = () =>{
21
+ return { title: '${defaultExportName} Route' };
22
+ };
23
+
24
+ `);
25
+ yield (0, devkit_1.formatFiles)(tree);
26
+ });
27
+ }
28
+ exports.default = default_1;
29
+ //# sourceMappingURL=meta.impl.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"meta.impl.js","sourceRoot":"","sources":["../../../../../../packages/remix/src/generators/meta/meta.impl.ts"],"names":[],"mappings":";;;AAAA,yCAAiD;AAEjD,6DAAyD;AACzD,+FAAyF;AACzF,iFAA2E;AAC3E,qEAAsE;AAEtE,mBAA+B,IAAU,EAAE,MAAoB;;QAC7D,MAAM,aAAa,GAAG,IAAA,yCAAqB,EACzC,IAAI,EACJ,MAAM,CAAC,IAAI,EACX,MAAM,CAAC,OAAO,CACf,CAAC;QAEF,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,EAAE;YAC/B,MAAM,IAAI,KAAK,CACb,8BAA8B,aAAa,wCAAwC,CACpF,CAAC;SACH;QAED,IAAA,4BAAY,EAAC,IAAI,EAAE,aAAa,EAAE,cAAc,EAAE,iBAAiB,EAAE;YACnE,QAAQ,EAAE,IAAI;SACf,CAAC,CAAC;QAEH,MAAM,iBAAiB,GAAG,IAAA,8CAAoB,EAAC,IAAI,EAAE,aAAa,CAAC,CAAC;QACpE,IAAA,4DAA2B,EACzB,IAAI,EACJ,aAAa,EACb;;yBAEqB,iBAAiB;;;KAGrC,CACF,CAAC;QACF,MAAM,IAAA,oBAAW,EAAC,IAAI,CAAC,CAAC;IAC1B,CAAC;CAAA;AA7BD,4BA6BC"}
@@ -0,0 +1,4 @@
1
+ export interface LoaderSchema {
2
+ path: string;
3
+ project: string;
4
+ }
@@ -0,0 +1,27 @@
1
+ {
2
+ "$schema": "http://json-schema.org/schema",
3
+ "cli": "nx",
4
+ "$id": "meta",
5
+ "type": "object",
6
+ "properties": {
7
+ "path": {
8
+ "type": "string",
9
+ "description": "The route path or path to the filename of the route.",
10
+ "$default": {
11
+ "$source": "argv",
12
+ "index": 0
13
+ },
14
+ "x-prompt": "What is the path of the route? (e.g. 'foo/bar')"
15
+ },
16
+ "project": {
17
+ "type": "string",
18
+ "description": "The name of the project.",
19
+ "$default": {
20
+ "$source": "projectName"
21
+ },
22
+ "x-prompt": "What project is this route for?",
23
+ "pattern": "^[a-zA-Z].*$"
24
+ }
25
+ },
26
+ "required": ["path", "project"]
27
+ }
@@ -8,7 +8,7 @@ const setup_impl_1 = require("../setup/setup.impl");
8
8
  const run_tasks_in_serial_1 = require("@nrwl/workspace/src/utilities/run-tasks-in-serial");
9
9
  const set_default_collection_1 = require("@nrwl/workspace/src/utilities/set-default-collection");
10
10
  function default_1(tree, _options) {
11
- return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () {
11
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
12
12
  const options = (0, normalize_options_1.normalizeOptions)(tree, _options);
13
13
  const tasks = [];
14
14
  const appGenTask = yield (0, application_impl_1.default)(tree, {
@@ -0,0 +1,3 @@
1
+ import { Tree } from '@nrwl/devkit';
2
+ import { RemixRouteSchema } from './schema';
3
+ export default function (tree: Tree, options: RemixRouteSchema): Promise<void>;
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ const devkit_1 = require("@nrwl/devkit");
5
+ const loader_impl_1 = require("../loader/loader.impl");
6
+ const action_impl_1 = require("../action/action.impl");
7
+ const remix_route_utils_1 = require("../../utils/remix-route-utils");
8
+ function default_1(tree, options) {
9
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
10
+ const routeFilePath = (0, remix_route_utils_1.resolveRemixRouteFile)(tree, options.path, options.project, '.ts');
11
+ if (tree.exists(routeFilePath))
12
+ throw new Error(`Path already exists: ${options.path}`);
13
+ if (!options.loader && !options.action)
14
+ throw new Error('The resource route generator requires either `loader` or `action` to be true');
15
+ tree.write(routeFilePath, '');
16
+ if (options.loader) {
17
+ yield (0, loader_impl_1.default)(tree, {
18
+ project: options.project,
19
+ path: routeFilePath,
20
+ });
21
+ }
22
+ if (options.action) {
23
+ yield (0, action_impl_1.default)(tree, {
24
+ path: routeFilePath,
25
+ project: options.project,
26
+ });
27
+ }
28
+ yield (0, devkit_1.formatFiles)(tree);
29
+ });
30
+ }
31
+ exports.default = default_1;
32
+ //# sourceMappingURL=resource-route.impl.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resource-route.impl.js","sourceRoot":"","sources":["../../../../../../packages/remix/src/generators/resource-route/resource-route.impl.ts"],"names":[],"mappings":";;;AAAA,yCAAiD;AAEjD,uDAAoD;AACpD,uDAAoD;AACpD,qEAAsE;AAEtE,mBAA+B,IAAU,EAAE,OAAyB;;QAClE,MAAM,aAAa,GAAG,IAAA,yCAAqB,EACzC,IAAI,EACJ,OAAO,CAAC,IAAI,EACZ,OAAO,CAAC,OAAO,EACf,KAAK,CACN,CAAC;QAEF,IAAI,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC;YAC5B,MAAM,IAAI,KAAK,CAAC,wBAAwB,OAAO,CAAC,IAAI,EAAE,CAAC,CAAC;QAE1D,IAAI,CAAC,OAAO,CAAC,MAAM,IAAI,CAAC,OAAO,CAAC,MAAM;YACpC,MAAM,IAAI,KAAK,CACb,8EAA8E,CAC/E,CAAC;QAEJ,IAAI,CAAC,KAAK,CAAC,aAAa,EAAE,EAAE,CAAC,CAAC;QAE9B,IAAI,OAAO,CAAC,MAAM,EAAE;YAClB,MAAM,IAAA,qBAAe,EAAC,IAAI,EAAE;gBAC1B,OAAO,EAAE,OAAO,CAAC,OAAO;gBACxB,IAAI,EAAE,aAAa;aACpB,CAAC,CAAC;SACJ;QAED,IAAI,OAAO,CAAC,MAAM,EAAE;YAClB,MAAM,IAAA,qBAAe,EAAC,IAAI,EAAE;gBAC1B,IAAI,EAAE,aAAa;gBACnB,OAAO,EAAE,OAAO,CAAC,OAAO;aACzB,CAAC,CAAC;SACJ;QAED,MAAM,IAAA,oBAAW,EAAC,IAAI,CAAC,CAAC;IAC1B,CAAC;CAAA;AAjCD,4BAiCC"}
@@ -0,0 +1,6 @@
1
+ export interface RemixRouteSchema {
2
+ project: string;
3
+ path: string;
4
+ action: boolean;
5
+ loader: boolean;
6
+ }
@@ -0,0 +1,44 @@
1
+ {
2
+ "$schema": "http://json-schema.org/schema",
3
+ "$id": "NxRemixResourceRoute",
4
+ "cli": "nx",
5
+ "title": "Create a Resource Route",
6
+ "type": "object",
7
+ "examples": [
8
+ {
9
+ "command": "g resource-route 'path/to/page'",
10
+ "description": "Generate resource route at /path/to/page"
11
+ }
12
+ ],
13
+ "properties": {
14
+ "path": {
15
+ "type": "string",
16
+ "description": "The route path or path to the filename of the route.",
17
+ "$default": {
18
+ "$source": "argv",
19
+ "index": 0
20
+ },
21
+ "x-prompt": "What is the path of the route? (e.g. 'foo/bar')"
22
+ },
23
+ "project": {
24
+ "type": "string",
25
+ "description": "The name of the project.",
26
+ "$default": {
27
+ "$source": "projectName"
28
+ },
29
+ "x-prompt": "What project is this route for?",
30
+ "pattern": "^[a-zA-Z].*$"
31
+ },
32
+ "action": {
33
+ "type": "boolean",
34
+ "description": "Generate an action function",
35
+ "default": false
36
+ },
37
+ "loader": {
38
+ "type": "boolean",
39
+ "description": "Generate a loader function",
40
+ "default": true
41
+ }
42
+ },
43
+ "required": ["project", "path"]
44
+ }
@@ -2,85 +2,61 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const tslib_1 = require("tslib");
4
4
  const devkit_1 = require("@nrwl/devkit");
5
+ const loader_impl_1 = require("../loader/loader.impl");
6
+ const meta_impl_1 = require("../meta/meta.impl");
7
+ const action_impl_1 = require("../action/action.impl");
8
+ const style_impl_1 = require("../style/style.impl");
9
+ const remix_route_utils_1 = require("../../utils/remix-route-utils");
5
10
  function default_1(tree, options) {
6
- return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () {
7
- const { fileName: routePath, className: componentName } = (0, devkit_1.names)(options.path.replace(/^\//, '').replace(/\/$/, ''));
8
- const projects = (0, devkit_1.getProjects)(tree);
9
- const project = projects.get(options.project);
10
- const normalizedRoutePath = normalizeRoutePath(routePath, project.root);
11
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
12
+ const project = (0, devkit_1.readProjectConfiguration)(tree, options.project);
11
13
  if (!project)
12
14
  throw new Error(`Project does not exist: ${options.project}`);
13
- const componentPath = (0, devkit_1.joinPathFragments)(project.root, 'app/routes', `${normalizedRoutePath}.tsx`);
14
- if (tree.exists(componentPath))
15
- throw new Error(`Path already exists: ${options.path}`);
16
- tree.write(componentPath, (0, devkit_1.stripIndents) `
17
- import { useEffect, useRef } from 'react';
18
- ${options.style === 'css'
19
- ? `import type { LinksFunction, LoaderFunction, MetaFunction } from 'remix';
20
- `
21
- : `import type { LoaderFunction, MetaFunction } from 'remix';`}
22
- import { useActionData, useLoaderData, redirect } from 'remix';
15
+ const routeFilePath = (0, remix_route_utils_1.resolveRemixRouteFile)(tree, options.path, options.project, '.tsx');
16
+ const { className: componentName } = (0, devkit_1.names)(options.path.replace(/^\//, '').replace(/\/$/, '').replace('.tsx', ''));
17
+ if (tree.exists(routeFilePath))
18
+ throw new Error(`Path already exists: ${routeFilePath}`);
19
+ tree.write(routeFilePath, (0, devkit_1.stripIndents) `
23
20
 
24
- ${options.style === 'css'
25
- ? `import stylesUrl from '~/styles/${normalizedRoutePath}.css';`
26
- : ''}
27
-
28
-
29
- // Provide meta tags for this page.
30
- // - https://remix.run/api/conventions#meta
31
- export const meta: MetaFunction = () =>{
32
- return { title: '${componentName}' };
33
- }
34
-
35
- ${options.style === 'css'
36
- ? (0, devkit_1.stripIndents) `
37
- // Provide stylesheet for this page.
38
- // - https://remix.run/api/conventions#links
39
- export const links: LinksFunction = () => {
40
- return [{ rel: 'stylesheet', href: stylesUrl }];
41
- };
42
- `
43
- : ''}
44
-
45
- // Use this function to provide data for the route.
46
- // - https://remix.run/api/conventions#loader
47
- export const loader: LoaderFunction = async () => {
48
- return {
49
- message: 'Hello, world!',
50
- }
51
- }
52
21
 
53
22
  export default function ${componentName}() {
54
- const data = useLoaderData();
23
+ ${options.loader
24
+ ? `
55
25
  return (
56
26
  <p>
57
27
  Message: {data.message}
58
28
  </p>
59
29
  );
30
+ `
31
+ : `return (<p>${componentName} works!</p>)`}
60
32
  }
61
33
  `);
34
+ if (options.loader) {
35
+ yield (0, loader_impl_1.default)(tree, {
36
+ project: options.project,
37
+ path: routeFilePath,
38
+ });
39
+ }
40
+ if (options.meta) {
41
+ yield (0, meta_impl_1.default)(tree, {
42
+ path: routeFilePath,
43
+ project: options.project,
44
+ });
45
+ }
46
+ if (options.action) {
47
+ yield (0, action_impl_1.default)(tree, {
48
+ path: routeFilePath,
49
+ project: options.project,
50
+ });
51
+ }
62
52
  if (options.style === 'css') {
63
- const stylesheetPath = (0, devkit_1.joinPathFragments)(project.root, 'app/styles', `${normalizedRoutePath}.css`);
64
- tree.write(stylesheetPath, (0, devkit_1.stripIndents) `
65
- :root {
66
- --color-foreground: #fff;
67
- --color-background: #143157;
68
- --color-links: hsl(214, 73%, 69%);
69
- --color-border: #275da8;
70
- --font-body: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas,
71
- Liberation Mono, Courier New, monospace;
72
- }
73
- `);
53
+ yield (0, style_impl_1.default)(tree, {
54
+ project: options.project,
55
+ path: options.path,
56
+ });
74
57
  }
75
58
  yield (0, devkit_1.formatFiles)(tree);
76
59
  });
77
60
  }
78
61
  exports.default = default_1;
79
- function normalizeRoutePath(path, projectRoot) {
80
- if (path.indexOf(projectRoot) === -1)
81
- return path;
82
- if (path.indexOf('/routes/') > -1)
83
- return path.substring(path.indexOf('/routes/') + 8);
84
- return path.substring(projectRoot.length + 1);
85
- }
86
62
  //# sourceMappingURL=route.impl.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"route.impl.js","sourceRoot":"","sources":["../../../../../../packages/remix/src/generators/route/route.impl.ts"],"names":[],"mappings":";;;AAAA,yCAOsB;AAGtB,mBAA+B,IAAU,EAAE,OAAyB;;QAClE,MAAM,EAAC,QAAQ,EAAE,SAAS,EAAE,SAAS,EAAE,aAAa,EAAC,GAAG,IAAA,cAAK,EAC3D,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CACnD,CAAC;QAGF,MAAM,QAAQ,GAAG,IAAA,oBAAW,EAAC,IAAI,CAAC,CAAC;QACnC,MAAM,OAAO,GAAG,QAAQ,CAAC,GAAG,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;QAE9C,MAAM,mBAAmB,GAAG,kBAAkB,CAAC,SAAS,EAAE,OAAO,CAAC,IAAI,CAAC,CAAA;QAEvE,IAAI,CAAC,OAAO;YAAE,MAAM,IAAI,KAAK,CAAC,2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AG,CAAC,CAAC;QAAE,OAAO,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAA;IACtF,OAAO,IAAI,CAAC,SAAS,CAAC,WAAW,CAAC,MAAM,GAAG,CAAC,CAAC,CAAA;AAC/C,CAAC"}
1
+ {"version":3,"file":"route.impl.js","sourceRoot":"","sources":["../../../../../../packages/remix/src/generators/route/route.impl.ts"],"names":[],"mappings":";;;AAAA,yCAOsB;AAEtB,uDAAoD;AACpD,iDAA8C;AAC9C,uDAAoD;AACpD,oDAAiD;AACjD,qEAAsE;AAEtE,mBAA+B,IAAU,EAAE,OAAyB;;QAClE,MAAM,OAAO,GAAG,IAAA,iCAAwB,EAAC,IAAI,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC;QAChE,IAAI,CAAC,OAAO;YAAE,MAAM,IAAI,KAAK,CAAC,2BAA2B,OAAO,CAAC,OAAO,EAAE,CAAC,CAAC;QAE5E,MAAM,aAAa,GAAG,IAAA,yCAAqB,EACzC,IAAI,EACJ,OAAO,CAAC,IAAI,EACZ,OAAO,CAAC,OAAO,EACf,MAAM,CACP,CAAC;QAEF,MAAM,EAAE,SAAS,EAAE,aAAa,EAAE,GAAG,IAAA,cAAK,EACxC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CACvE,CAAC;QAEF,IAAI,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC;YAC5B,MAAM,IAAI,KAAK,CAAC,wBAAwB,aAAa,EAAE,CAAC,CAAC;QAE3D,IAAI,CAAC,KAAK,CACR,aAAa,EACb,IAAA,qBAAY,EAAA;;;8BAGc,aAAa;MAErC,OAAO,CAAC,MAAM;YACZ,CAAC,CAAC;;;;;;KAML;YACG,CAAC,CAAC,cAAc,aAAa,cACjC;;GAED,CACA,CAAC;QAEF,IAAI,OAAO,CAAC,MAAM,EAAE;YAClB,MAAM,IAAA,qBAAe,EAAC,IAAI,EAAE;gBAC1B,OAAO,EAAE,OAAO,CAAC,OAAO;gBACxB,IAAI,EAAE,aAAa;aACpB,CAAC,CAAC;SACJ;QAED,IAAI,OAAO,CAAC,IAAI,EAAE;YAChB,MAAM,IAAA,mBAAa,EAAC,IAAI,EAAE;gBACxB,IAAI,EAAE,aAAa;gBACnB,OAAO,EAAE,OAAO,CAAC,OAAO;aACzB,CAAC,CAAC;SACJ;QAED,IAAI,OAAO,CAAC,MAAM,EAAE;YAClB,MAAM,IAAA,qBAAe,EAAC,IAAI,EAAE;gBAC1B,IAAI,EAAE,aAAa;gBACnB,OAAO,EAAE,OAAO,CAAC,OAAO;aACzB,CAAC,CAAC;SACJ;QAED,IAAI,OAAO,CAAC,KAAK,KAAK,KAAK,EAAE;YAC3B,MAAM,IAAA,oBAAc,EAAC,IAAI,EAAE;gBACzB,OAAO,EAAE,OAAO,CAAC,OAAO;gBACxB,IAAI,EAAE,OAAO,CAAC,IAAI;aACnB,CAAC,CAAC;SACJ;QAED,MAAM,IAAA,oBAAW,EAAC,IAAI,CAAC,CAAC;IAC1B,CAAC;CAAA;AApED,4BAoEC"}
@@ -2,4 +2,7 @@ export interface RemixRouteSchema {
2
2
  project: string;
3
3
  path: string;
4
4
  style: 'css' | 'none';
5
+ action: boolean;
6
+ meta: boolean;
7
+ loader: boolean;
5
8
  }
@@ -11,6 +11,15 @@
11
11
  }
12
12
  ],
13
13
  "properties": {
14
+ "path": {
15
+ "type": "string",
16
+ "description": "The route path or path to the filename of the route.",
17
+ "$default": {
18
+ "$source": "argv",
19
+ "index": 0
20
+ },
21
+ "x-prompt": "What is the path of the route? (e.g. 'foo/bar')"
22
+ },
14
23
  "project": {
15
24
  "type": "string",
16
25
  "description": "The name of the project.",
@@ -20,20 +29,26 @@
20
29
  "x-prompt": "What project is this route for?",
21
30
  "pattern": "^[a-zA-Z].*$"
22
31
  },
23
- "path": {
24
- "type": "string",
25
- "description": "Route path",
26
- "$default": {
27
- "$source": "argv",
28
- "index": 0
29
- },
30
- "x-prompt": "What is the path of the route? (e.g. 'foo/bar')"
31
- },
32
32
  "style": {
33
33
  "type": "string",
34
34
  "description": "Generate a stylesheet",
35
35
  "enum": ["none", "css"],
36
36
  "default": "css"
37
+ },
38
+ "meta": {
39
+ "type": "boolean",
40
+ "description": "Generate a meta function",
41
+ "default": false
42
+ },
43
+ "action": {
44
+ "type": "boolean",
45
+ "description": "Generate an action function",
46
+ "default": false
47
+ },
48
+ "loader": {
49
+ "type": "boolean",
50
+ "description": "Generate a loader function",
51
+ "default": false
37
52
  }
38
53
  },
39
54
  "required": ["project", "path"]
@@ -4,7 +4,7 @@ const tslib_1 = require("tslib");
4
4
  const devkit_1 = require("@nrwl/devkit");
5
5
  function default_1(tree, options) {
6
6
  var _a;
7
- return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () {
7
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
8
8
  const { libsDir } = (0, devkit_1.getWorkspaceLayout)(tree);
9
9
  const pm = (_a = options.packageManager) !== null && _a !== void 0 ? _a : (0, devkit_1.detectPackageManager)();
10
10
  // Enable yarn/npm/pnpm workspaces for buildable libs
@@ -0,0 +1,4 @@
1
+ export interface RemixStyleSchema {
2
+ project: string;
3
+ path: string;
4
+ }
@@ -0,0 +1,34 @@
1
+ {
2
+ "$schema": "http://json-schema.org/schema",
3
+ "$id": "NxRemixRouteStyle",
4
+ "cli": "nx",
5
+ "title": "Add style import to a route",
6
+ "type": "object",
7
+ "examples": [
8
+ {
9
+ "command": "g style --project=webapp --path='path/to/page'",
10
+ "description": "Generate route at /path/to/page"
11
+ }
12
+ ],
13
+ "properties": {
14
+ "path": {
15
+ "type": "string",
16
+ "description": "Route path",
17
+ "$default": {
18
+ "$source": "argv",
19
+ "index": 0
20
+ },
21
+ "x-prompt": "What is the path of the route? (e.g. 'foo/bar')"
22
+ },
23
+ "project": {
24
+ "type": "string",
25
+ "description": "The name of the project.",
26
+ "$default": {
27
+ "$source": "projectName"
28
+ },
29
+ "x-prompt": "What project is this route in?",
30
+ "pattern": "^[a-zA-Z].*$"
31
+ }
32
+ },
33
+ "required": ["project", "path"]
34
+ }
@@ -0,0 +1,3 @@
1
+ import { Tree } from '@nrwl/devkit';
2
+ import { RemixStyleSchema } from './schema';
3
+ export default function (tree: Tree, options: RemixStyleSchema): Promise<void>;