@nrwl/remix 1.0.0-alpha.18 → 1.0.0-alpha.21

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/README.md CHANGED
@@ -52,6 +52,10 @@ You can then add your first app and run it:
52
52
  npx nx g @nrwl/remix:app demo
53
53
  ```
54
54
 
55
+
56
+ ## Adding new routes
57
+
58
+
55
59
  ## Workspace libraries
56
60
 
57
61
  The Remix setup leverages npm/yarn/pnpm workspaces and Nx buildable libraries.
package/generators.json CHANGED
@@ -27,6 +27,11 @@
27
27
  "description": "Generate a new library",
28
28
  "aliases": ["lib"],
29
29
  "x-type": "library"
30
+ },
31
+ "route": {
32
+ "factory": "./src/generators/route/route.impl",
33
+ "schema": "./src/generators/route/schema.json",
34
+ "description": "Generate a new route"
30
35
  }
31
36
  }
32
37
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nrwl/remix",
3
- "version": "1.0.0-alpha.18",
3
+ "version": "1.0.0-alpha.21",
4
4
  "main": "src/index.js",
5
5
  "generators": "./generators.json",
6
6
  "dependencies": {
@@ -6,6 +6,7 @@ const normalize_options_1 = require("./lib/normalize-options");
6
6
  const application_impl_1 = require("../application/application.impl");
7
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
+ const set_default_collection_1 = require("@nrwl/workspace/src/utilities/set-default-collection");
9
10
  function default_1(tree, _options) {
10
11
  return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () {
11
12
  const options = (0, normalize_options_1.normalizeOptions)(tree, _options);
@@ -20,6 +21,7 @@ function default_1(tree, _options) {
20
21
  tasks.push(setupGenTask);
21
22
  // No need for workspace.json in latest Nx
22
23
  tree.delete('workspace.json');
24
+ (0, set_default_collection_1.setDefaultCollection)(tree, '@nrwl/remix');
23
25
  yield (0, devkit_1.formatFiles)(tree);
24
26
  return (0, run_tasks_in_serial_1.runTasksInSerial)(...tasks);
25
27
  });
@@ -1 +1 @@
1
- {"version":3,"file":"preset.impl.js","sourceRoot":"","sources":["../../../../../../packages/remix/src/generators/preset/preset.impl.ts"],"names":[],"mappings":";;;AAAA,yCAAoE;AAGpE,+DAA2D;AAC3D,sEAAmE;AACnE,oDAAiD;AACjD,2FAAqF;AAErF,mBAA+B,IAAU,EAAE,QAAgC;;QACzE,MAAM,OAAO,GAAG,IAAA,oCAAgB,EAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;QACjD,MAAM,KAAK,GAAwB,EAAE,CAAC;QAEtC,MAAM,UAAU,GAAG,MAAM,IAAA,0BAAoB,EAAC,IAAI,EAAE;YAClD,IAAI,EAAE,OAAO,CAAC,WAAW;YACzB,IAAI,EAAE,OAAO,CAAC,IAAI;YAClB,UAAU,EAAE,IAAI;SACjB,CAAC,CAAC;QACH,KAAK,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;QAEvB,MAAM,YAAY,GAAG,MAAM,IAAA,oBAAc,EAAC,IAAI,EAAE,EAAE,CAAC,CAAC;QACpD,KAAK,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;QAEzB,0CAA0C;QAC1C,IAAI,CAAC,MAAM,CAAC,gBAAgB,CAAC,CAAC;QAE9B,MAAM,IAAA,oBAAW,EAAC,IAAI,CAAC,CAAC;QAExB,OAAO,IAAA,sCAAgB,EAAC,GAAG,KAAK,CAAC,CAAC;IACpC,CAAC;CAAA;AApBD,4BAoBC"}
1
+ {"version":3,"file":"preset.impl.js","sourceRoot":"","sources":["../../../../../../packages/remix/src/generators/preset/preset.impl.ts"],"names":[],"mappings":";;;AAAA,yCAAoE;AAGpE,+DAA2D;AAC3D,sEAAmE;AACnE,oDAAiD;AACjD,2FAAqF;AACrF,iGAA4F;AAE5F,mBAA+B,IAAU,EAAE,QAAgC;;QACzE,MAAM,OAAO,GAAG,IAAA,oCAAgB,EAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;QACjD,MAAM,KAAK,GAAwB,EAAE,CAAC;QAEtC,MAAM,UAAU,GAAG,MAAM,IAAA,0BAAoB,EAAC,IAAI,EAAE;YAClD,IAAI,EAAE,OAAO,CAAC,WAAW;YACzB,IAAI,EAAE,OAAO,CAAC,IAAI;YAClB,UAAU,EAAE,IAAI;SACjB,CAAC,CAAC;QACH,KAAK,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;QAEvB,MAAM,YAAY,GAAG,MAAM,IAAA,oBAAc,EAAC,IAAI,EAAE,EAAE,CAAC,CAAC;QACpD,KAAK,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;QAEzB,0CAA0C;QAC1C,IAAI,CAAC,MAAM,CAAC,gBAAgB,CAAC,CAAC;QAE9B,IAAA,6CAAoB,EAAC,IAAI,EAAE,aAAa,CAAC,CAAC;QAE1C,MAAM,IAAA,oBAAW,EAAC,IAAI,CAAC,CAAC;QAExB,OAAO,IAAA,sCAAgB,EAAC,GAAG,KAAK,CAAC,CAAC;IACpC,CAAC;CAAA;AAtBD,4BAsBC"}
@@ -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,75 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ const devkit_1 = require("@nrwl/devkit");
5
+ 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
+ if (!project)
11
+ throw new Error(`Project does not exist: ${options.project}`);
12
+ const componentPath = (0, devkit_1.joinPathFragments)(project.root, 'app/routes', `${routePath}.tsx`);
13
+ tree.write(componentPath, (0, devkit_1.stripIndents) `
14
+ import { useEffect, useRef } from 'react';
15
+ ${options.style === 'css'
16
+ ? `import type { LinksFunction, LoaderFunction, MetaFunction } from 'remix';
17
+ `
18
+ : `import type { LoaderFunction, MetaFunction } from 'remix';`}
19
+ import { useActionData, useLoaderData, redirect } from 'remix';
20
+
21
+ ${options.style === 'css'
22
+ ? `import stylesUrl from '~/styles/${routePath}.css';`
23
+ : ''}
24
+
25
+
26
+ // Provide meta tags for this page.
27
+ // - https://remix.run/api/conventions#meta
28
+ export const meta: MetaFunction = () =>{
29
+ return { title: '${componentName}' };
30
+ }
31
+
32
+ ${options.style === 'css'
33
+ ? (0, devkit_1.stripIndents) `
34
+ // Provide stylesheet for this page.
35
+ // - https://remix.run/api/conventions#links
36
+ export const links: LinksFunction = () => {
37
+ return [{ rel: 'stylesheet', href: stylesUrl }];
38
+ };
39
+ `
40
+ : ''}
41
+
42
+ // Use this function to provide data for the route.
43
+ // - https://remix.run/api/conventions#loader
44
+ export const loader: LoaderFunction = async () => {
45
+ return {
46
+ message: 'Hello, world!',
47
+ }
48
+ }
49
+
50
+ export default function ${componentName}() {
51
+ const data = useLoaderData();
52
+ return (
53
+ <p>
54
+ Message: {data.message}
55
+ </p>
56
+ );
57
+ }
58
+ `);
59
+ if (options.style === 'css') {
60
+ const stylesheetPath = (0, devkit_1.joinPathFragments)(project.root, 'app/styles', `${routePath}.css`);
61
+ tree.write(stylesheetPath, (0, devkit_1.stripIndents) `
62
+ :root {
63
+ --color-foreground: #fff;
64
+ --color-background: #143157;
65
+ --color-links: hsl(214, 73%, 69%);
66
+ --color-border: #275da8;
67
+ --font-body: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas,
68
+ Liberation Mono, Courier New, monospace;
69
+ }
70
+ `);
71
+ }
72
+ });
73
+ }
74
+ exports.default = default_1;
75
+ //# sourceMappingURL=route.impl.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"route.impl.js","sourceRoot":"","sources":["../../../../../../packages/remix/src/generators/route/route.impl.ts"],"names":[],"mappings":";;;AA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AAA,qBAAY,EAAA;;;;;;;;;KASb,CACA,CAAC;SACH;IACH,CAAC;CAAA;AA1FD,4BA0FC"}
@@ -0,0 +1,5 @@
1
+ export interface RemixRouteSchema {
2
+ project: string;
3
+ path: string;
4
+ style: 'css' | 'none';
5
+ }
@@ -0,0 +1,40 @@
1
+ {
2
+ "$schema": "http://json-schema.org/schema",
3
+ "$id": "NxRemixRoute",
4
+ "cli": "nx",
5
+ "title": "Create a Route",
6
+ "type": "object",
7
+ "examples": [
8
+ {
9
+ "command": "g route 'path/to/page'",
10
+ "description": "Generate route at /path/to/page"
11
+ }
12
+ ],
13
+ "properties": {
14
+ "project": {
15
+ "type": "string",
16
+ "description": "The name of the project.",
17
+ "$default": {
18
+ "$source": "projectName"
19
+ },
20
+ "x-prompt": "What project is this route for?",
21
+ "pattern": "^[a-zA-Z].*$"
22
+ },
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?"
31
+ },
32
+ "style": {
33
+ "type": "string",
34
+ "description": "Generate a stylesheet",
35
+ "enum": ["none", "css"],
36
+ "default": "css"
37
+ }
38
+ },
39
+ "required": ["project", "path"]
40
+ }