Skip to content

Commit 29c0142

Browse files
committed
chore(repo): Introduce remix integration template
1 parent ae9fc24 commit 29c0142

16 files changed

Lines changed: 97 additions & 20 deletions

File tree

‎integration/adapters/application.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,10 @@ export const application = (config: ApplicationConfig, appDirPath: string, appDi
4040
}
4141
},
4242
dev: async (opts: { port?: number; manualStart?: boolean; detached?: boolean } = {}) => {
43+
const log = logger.child({ prefix: 'dev' }).info;
4344
const port = opts.port || (await getPort());
4445
const serverUrl = `http://localhost:${port}`;
46+
log(`Will try to serve app at ${serverUrl}`);
4547
if (opts.manualStart) {
4648
// for debugging, you can start the dev server manually by cd'ing into the temp dir
4749
// and running the corresponding dev command
@@ -50,7 +52,6 @@ export const application = (config: ApplicationConfig, appDirPath: string, appDi
5052
state.serverUrl = serverUrl;
5153
return { port, serverUrl };
5254
}
53-
const log = logger.child({ prefix: 'dev' }).info;
5455
const proc = run(scripts.dev, { cwd: appDirPath, env: { PORT: port.toString() }, log, detached: opts.detached });
5556
cleanupFns.push(() => treekill(proc.pid, 'SIGKILL'));
5657
await waitForIdleProcess(proc);

‎integration/adapters/longRunningApplication.ts‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,10 @@ export const longRunningApplication = (_name: string, _config: ApplicationConfig
3333
let appDir: string;
3434
let env: EnvironmentConfig;
3535

36+
const stateFileExists = () => {
37+
return fs.pathExists(constants.APPS_STATE_FILE);
38+
};
39+
3640
const readFromStateFile = async () => {
3741
const json = (await fs.readJSON(constants.APPS_STATE_FILE)) as AppStateFile;
3842
const data = json.longRunningApps[name];
@@ -55,6 +59,9 @@ export const longRunningApplication = (_name: string, _config: ApplicationConfig
5559
},
5660
// will be called by global.teardown.ts
5761
destroy: async () => {
62+
if (!(await stateFileExists())) {
63+
return;
64+
}
5865
await readFromStateFile();
5966
console.log(`Destroying ${serverUrl}`);
6067
treekill(pid, 'SIGKILL');

‎integration/presets/index.ts‎

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,7 @@ import { longRunningApplication } from '../adapters/longRunningApplication';
22
import { instances } from './envs';
33
import { next } from './next';
44
import { react } from './react';
5-
6-
export const appConfigs = {
7-
next,
8-
react,
9-
instances,
10-
} as const;
5+
import { remix } from './remix';
116

127
export const longRunningApps = {
138
next: {
@@ -18,4 +13,16 @@ export const longRunningApps = {
1813
viteAllEnabled: longRunningApplication('all-enabled', react.vite, instances.allEnabled),
1914
viteEmailLink: longRunningApplication('email-link', react.vite, instances.withEmailLinks),
2015
},
16+
remix: {
17+
remixNode: longRunningApplication('remix-node', remix.remixNode, instances.allEnabled),
18+
// remixNodeEmailLink: longRunningApplication('remix-node', remix.remixNode, instances.withEmailLinks),
19+
},
2120
};
21+
22+
export const appConfigs = {
23+
next,
24+
react,
25+
instances,
26+
remix,
27+
longRunning: longRunningApps,
28+
} as const;

‎integration/presets/remix.ts‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import { applicationConfig } from '../adapters/applicationConfig.js';
2+
import { templates } from '../templates/index.js';
3+
4+
const remixNode = applicationConfig()
5+
.setName('remix-node')
6+
.useTemplate(templates['remix-node'])
7+
.setEnvFormatter('public', key => `${key}`)
8+
.addScript('setup', 'npm ci --prefer-offline')
9+
.addScript('dev', 'npm run dev')
10+
.addScript('build', 'npm run build');
11+
// .addScript('serve', 'npm run start');
12+
13+
export const remix = {
14+
remixNode,
15+
} as const;

‎integration/templates/index.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ export const templates = {
77
'next-app-router': resolve(__dirname, './next-app-router'),
88
'react-cra': resolve(__dirname, './react-cra'),
99
'react-vite': resolve(__dirname, './react-vite'),
10+
'remix-node': resolve(__dirname, './remix-node'),
1011
} as const;
1112

1213
if (new Set([...Object.values(templates)]).size !== Object.values(templates).length) {

‎integration/templates/next-app-router/package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"lint": "next lint"
1010
},
1111
"dependencies": {
12-
"@clerk/nextjs": "^4.21.12",
12+
"@clerk/nextjs": "staging",
1313
"@types/node": "20.3.2",
1414
"@types/react": "18.2.14",
1515
"@types/react-dom": "18.2.6",

integration/templates/next-app-router/src/app/protected/[[...catchall]]/page.tsx renamed to integration/templates/next-app-router/src/app/protected/page.tsx

File renamed without changes.

‎integration/templates/react-cra/package.json‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
"version": "0.1.0",
44
"private": true,
55
"dependencies": {
6-
"@clerk/clerk-react": "latest",
7-
"@clerk/themes": "latest",
6+
"@clerk/clerk-react": "staging",
7+
"@clerk/themes": "staging",
88
"@testing-library/jest-dom": "^5.16.5",
99
"@testing-library/react": "^13.4.0",
1010
"@testing-library/user-event": "^13.5.0",

‎integration/templates/react-vite/package.json‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
"preview": "vite preview --port $PORT --no-open"
1111
},
1212
"dependencies": {
13-
"@clerk/clerk-react": "latest",
14-
"@clerk/themes": "latest",
13+
"@clerk/clerk-react": "staging",
14+
"@clerk/themes": "staging",
1515
"react": "^18.2.0",
1616
"react-dom": "^18.2.0",
1717
"react-router-dom": "^6.14.1"
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import { getAuth } from '@clerk/remix/ssr.server';
2+
import type { LoaderFunction } from '@remix-run/node';
3+
import { redirect } from '@remix-run/node';
4+
5+
export const loader: LoaderFunction = async args => {
6+
const { userId } = await getAuth(args);
7+
if (!userId) {
8+
return redirect('/sign-in');
9+
}
10+
return {};
11+
};
12+
13+
export default function Protected() {
14+
return (
15+
<div>
16+
<h1>Protected</h1>
17+
</div>
18+
);
19+
}

0 commit comments

Comments
 (0)