@nrwl/remix 1.0.0-alpha.18 → 1.0.0-alpha.19
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
|
@@ -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":";;;AAAA,yCAMsB;AAGtB,mBAA+B,IAAU,EAAE,OAAyB;;QAClE,MAAM,EAAE,QAAQ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4BA0FC"}
|
|
@@ -0,0 +1,41 @@
|
|
|
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": "Route path",
|
|
17
|
+
"$default": {
|
|
18
|
+
"$source": "argv",
|
|
19
|
+
"index": 0
|
|
20
|
+
},
|
|
21
|
+
"x-prompt": "What project is this route for?",
|
|
22
|
+
"pattern": "^[a-zA-Z].*$"
|
|
23
|
+
},
|
|
24
|
+
"path": {
|
|
25
|
+
"type": "string",
|
|
26
|
+
"description": "Route path",
|
|
27
|
+
"$default": {
|
|
28
|
+
"$source": "argv",
|
|
29
|
+
"index": 1
|
|
30
|
+
},
|
|
31
|
+
"x-prompt": "What is the path of the route?"
|
|
32
|
+
},
|
|
33
|
+
"style": {
|
|
34
|
+
"type": "string",
|
|
35
|
+
"description": "Generate a stylesheet",
|
|
36
|
+
"enum": ["none", "css"],
|
|
37
|
+
"default": "css"
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
"required": ["project", "path"]
|
|
41
|
+
}
|