Skip to content

Commit 1b18e8f

Browse files
committed
feat(plugin-js-react-router): add package
1 parent 898c4ed commit 1b18e8f

File tree

15 files changed

+425
-0
lines changed

15 files changed

+425
-0
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2025 GenJS Dev Team <[email protected]>
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# genjs-plugin-js-react-router
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
{
2+
"name": "@genjs/genjs-plugin-js-react-router",
3+
"version": "0.0.0",
4+
"license": "MIT",
5+
"main": "lib/index.js",
6+
"types": "lib/index.d.ts",
7+
"directories": {
8+
"lib": "lib",
9+
"test": "__tests__"
10+
},
11+
"files": [
12+
"lib",
13+
"vars.json"
14+
],
15+
"publishConfig": {
16+
"access": "public"
17+
},
18+
"scripts": {
19+
"build": "tsc",
20+
"test": "../../node_modules/.bin/jest -c ../../jest.config.js --rootDir=`pwd`",
21+
"gen": "../genjs/bin/genjs",
22+
"dump": "../genjs/bin/genjs dump"
23+
},
24+
"peerDependencies": {
25+
"@genjs/genjs": "^0"
26+
},
27+
"dependencies": {
28+
"@genjs/genjs-bundle-aws-lambda": "^0.1.47",
29+
"@genjs/genjs-bundle-javascript": "^0.1.31"
30+
},
31+
"devDependencies": {
32+
"@genjs/genjs": "^0.4.25",
33+
"aws-sdk": "^2.1199.0"
34+
}
35+
}
Lines changed: 137 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,137 @@
1+
import {
2+
applyDeployMakefileHelper,
3+
applyMigrateMakefileHelper,
4+
applyStarterMakefileHelper,
5+
applyLogMakefileHelper,
6+
AwsLambdaPackage, applyDebugMakefileHelper
7+
} from '@genjs/genjs-bundle-aws-lambda';
8+
import {
9+
BuildableBehaviour,
10+
CleanableBehaviour,
11+
InstallableBehaviour,
12+
GenerateEnvLocalableBehaviour,
13+
TestableBehaviour,
14+
LoggableBehaviour,
15+
} from '@genjs/genjs';
16+
import {applyRefreshMakefileHelper} from "@genjs/genjs-bundle-package";
17+
18+
export default class Package extends AwsLambdaPackage {
19+
constructor(config: any) {
20+
super(config, __dirname);
21+
}
22+
protected getBehaviours() {
23+
return [
24+
...super.getBehaviours(),
25+
new BuildableBehaviour(),
26+
new CleanableBehaviour(),
27+
new InstallableBehaviour(),
28+
new GenerateEnvLocalableBehaviour(),
29+
new TestableBehaviour(),
30+
new LoggableBehaviour(),
31+
];
32+
}
33+
protected buildVars(vars: any) {
34+
const staticVars = require('../vars.json');
35+
vars = {...staticVars, ...super.buildVars(vars)};
36+
vars.scripts = {
37+
...staticVars.scripts,
38+
...(vars.scripts || {}),
39+
};
40+
vars.dependencies = {
41+
...staticVars.dependencies,
42+
...(vars.dependencies || {}),
43+
};
44+
vars.devDependencies = {
45+
...staticVars.devDependencies,
46+
...(vars.devDependencies || {}),
47+
};
48+
vars.resolutions = {
49+
...(staticVars.resolutions || {}),
50+
...(vars.resolutions || {}),
51+
};
52+
53+
!Object.keys(vars.resolutions).length && delete vars.resolutions;
54+
return vars;
55+
}
56+
// noinspection JSUnusedLocalSymbols,JSUnusedGlobalSymbols
57+
protected async buildDynamicFiles(vars: any, cfg: any) {
58+
return {
59+
...(await super.buildDynamicFiles({licenseFile: 'LICENSE.md', ...vars}, cfg)),
60+
['package.json']: this.buildPackageJson(vars),
61+
};
62+
}
63+
// noinspection JSUnusedLocalSymbols,JSUnusedGlobalSymbols
64+
protected async buildStaticFiles(vars: any, cfg: any) {
65+
return {
66+
...(await super.buildStaticFiles(vars, cfg)),
67+
'.dockerignore?': true,
68+
'Dockerfile?': true,
69+
'react-router.config.ts?': true,
70+
'tailwind.config.ts?': true,
71+
'tsconfig.json?': true,
72+
'vite.config.ts?': true,
73+
};
74+
}
75+
protected buildPackageJson(vars: any) {
76+
return () => JSON.stringify({
77+
name: vars.name,
78+
license: vars.license,
79+
dependencies: vars.dependencies,
80+
scripts: vars.scripts,
81+
devDependencies: vars.devDependencies,
82+
...(vars.resolutions ? {resolutions: vars.resolutions} : {}),
83+
version: vars.version,
84+
description: vars.description,
85+
author: (vars.author && ('object' === typeof vars.author)) ? vars.author : {name: vars.author_name, email: vars.author_email},
86+
private: true,
87+
...(vars.packageJson || {}),
88+
}, null, 4);
89+
}
90+
protected buildGitIgnore(vars: any) {
91+
return super.buildGitIgnore(vars)
92+
.addIgnore('/coverage/')
93+
.addIgnore('/node_modules/')
94+
.addIgnore('/.idea/')
95+
.addIgnore('.DS_Store')
96+
.addIgnore('/.react-router/')
97+
.addIgnore('/build/')
98+
;
99+
}
100+
protected buildMakefile(vars: any) {
101+
const t = super.buildMakefile(vars)
102+
.addGlobalVar('env', 'dev')
103+
.addPredefinedTarget('install', 'js-install')
104+
.addPredefinedTarget('build', 'js-build')
105+
.addPredefinedTarget('generate-env-local', 'generate-env-local', {mode: vars.env_mode || 'terraform'})
106+
.addMetaTarget('clean', ['clean-modules', 'clean-coverage'])
107+
.addPredefinedTarget('clean-modules', 'clean-node-modules')
108+
.addPredefinedTarget('clean-coverage', 'clean-coverage')
109+
.addPredefinedTarget('test', 'js-test', {ci: true, coverage: true})
110+
.addPredefinedTarget('test-dev', 'js-test', {local: true, all: true, coverage: false, color: true})
111+
.addPredefinedTarget('test-cov', 'js-test', {local: true})
112+
.addPredefinedTarget('test-ci', 'js-test', {ci: true})
113+
;
114+
115+
applyDebugMakefileHelper(t, vars, this);
116+
applyLogMakefileHelper(t, vars, this);
117+
applyStarterMakefileHelper(t, vars, this);
118+
applyDeployMakefileHelper(t, vars, this, {predefinedTarget: 'js-deploy'});
119+
applyMigrateMakefileHelper(t, vars, this);
120+
applyRefreshMakefileHelper(t, vars, this);
121+
122+
return t;
123+
}
124+
protected getTechnologies() {
125+
return [
126+
...super.getTechnologies(),
127+
'node',
128+
'es6',
129+
'yarn',
130+
'nvm',
131+
'npm',
132+
'markdown',
133+
'jest',
134+
'prettier',
135+
];
136+
}
137+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import Package from './Package';
2+
import {IGenerator, IPlugin} from '@genjs/genjs';
3+
import registerAwsLambdaBundle from '@genjs/genjs-bundle-aws-lambda';
4+
import registerJavascriptBundle from '@genjs/genjs-bundle-javascript';
5+
6+
export default class Plugin implements IPlugin {
7+
register(generator: IGenerator): void {
8+
registerAwsLambdaBundle(generator);
9+
registerJavascriptBundle(generator);
10+
generator.registerPackager('js-react-router', cfg => new Package(cfg));
11+
}
12+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export {default as default} from './Plugin';
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
.react-router
2+
build
3+
node_modules
4+
README.md
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
FROM node:20-alpine AS development-dependencies-env
2+
COPY . /app
3+
WORKDIR /app
4+
RUN npm ci
5+
6+
FROM node:20-alpine AS production-dependencies-env
7+
COPY ./package.json package-lock.json /app/
8+
WORKDIR /app
9+
RUN npm ci --omit=dev
10+
11+
FROM node:20-alpine AS build-env
12+
COPY . /app/
13+
COPY --from=development-dependencies-env /app/node_modules /app/node_modules
14+
WORKDIR /app
15+
RUN npm run build
16+
17+
FROM node:20-alpine
18+
COPY ./package.json package-lock.json /app/
19+
COPY --from=production-dependencies-env /app/node_modules /app/node_modules
20+
COPY --from=build-env /app/build /app/build
21+
WORKDIR /app
22+
CMD ["npm", "run", "start"]
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
# Welcome to React Router!
2+
3+
A modern, production-ready template for building full-stack React applications using React Router.
4+
5+
[![Open in StackBlitz](https://developer.stackblitz.com/img/open_in_stackblitz.svg)](https://stackblitz.com/github/remix-run/react-router-templates/tree/main/default)
6+
7+
## Features
8+
9+
- 🚀 Server-side rendering
10+
- ⚡️ Hot Module Replacement (HMR)
11+
- 📦 Asset bundling and optimization
12+
- 🔄 Data loading and mutations
13+
- 🔒 TypeScript by default
14+
- 🎉 TailwindCSS for styling
15+
- 📖 [React Router docs](https://reactrouter.com/)
16+
17+
## Getting Started
18+
19+
### Installation
20+
21+
Install the dependencies:
22+
23+
```bash
24+
npm install
25+
```
26+
27+
### Development
28+
29+
Start the development server with HMR:
30+
31+
```bash
32+
npm run dev
33+
```
34+
35+
Your application will be available at `http://localhost:5173`.
36+
37+
## Building for Production
38+
39+
Create a production build:
40+
41+
```bash
42+
npm run build
43+
```
44+
45+
## Deployment
46+
47+
### Docker Deployment
48+
49+
To build and run using Docker:
50+
51+
```bash
52+
docker build -t my-app .
53+
54+
# Run the container
55+
docker run -p 3000:3000 my-app
56+
```
57+
58+
The containerized application can be deployed to any platform that supports Docker, including:
59+
60+
- AWS ECS
61+
- Google Cloud Run
62+
- Azure Container Apps
63+
- Digital Ocean App Platform
64+
- Fly.io
65+
- Railway
66+
67+
### DIY Deployment
68+
69+
If you're familiar with deploying Node applications, the built-in app server is production-ready.
70+
71+
Make sure to deploy the output of `npm run build`
72+
73+
```
74+
├── package.json
75+
├── package-lock.json (or pnpm-lock.yaml, or bun.lockb)
76+
├── build/
77+
│ ├── client/ # Static assets
78+
│ └── server/ # Server-side code
79+
```
80+
81+
## Styling
82+
83+
This template comes with [Tailwind CSS](https://tailwindcss.com/) already configured for a simple default starting experience. You can use whatever CSS framework you prefer.
84+
85+
---
86+
87+
Built with ❤️ using React Router.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import type { Config } from "@react-router/dev/config";
2+
3+
export default {
4+
// Config options...
5+
// Server-side render by default, to enable SPA mode set this to `false`
6+
ssr: true,
7+
} satisfies Config;

0 commit comments

Comments
 (0)