Skip to content

Commit dbb41e6

Browse files
committed
chore: merges master
2 parents 643f68c + a2f3cae commit dbb41e6

21 files changed

+213
-143
lines changed

.gitattributes

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Enforce Unix newlines
2+
* text=auto eol=lf

CONTRIBUTING.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,13 @@ If you are testing an example app you have created on your own branch, you can p
8585
npx . --branch=your_branch
8686
```
8787
88+
### Update package version if needed
89+
90+
You should update the package's version following [semantic versioning](https://semver.org/) rules. This needs to be done in these files:
91+
92+
- `package.json`
93+
- `lib/ts/version.ts`
94+
8895
### Create a pull request
8996
9097
1. Reference the relevant issue or pull request and give a clear description of changes/features added when submitting a pull request

README.md

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,14 @@ The tool creates a folder for the created application. You can follow the instru
3030

3131
When running the tool you can provide additional arguments.
3232

33-
| Option | About | Usage |
34-
| ---------- | -------------------------------------------------------- | :----------------------: |
35-
| `appname` | The folder name to be used when creating the application | `--appname=my-app` |
36-
| `recipe` | The type of authentication you want to use | `--recipe=emailpassword` |
37-
| `frontend` | The frontend stack to use for the application | `--frontend=react` |
38-
| `backend` | The backend stack to use for the application | `--backend=node` |
33+
| Option | About | Usage |
34+
| ----------- | --------------------------------------------------------- | :----------------------: |
35+
| `appname` | The folder name to be used when creating the application | `--appname=my-app` |
36+
| `recipe` | The type of authentication you want to use | `--recipe=emailpassword` |
37+
| `frontend` | The frontend stack to use for the application | `--frontend=react` |
38+
| `backend` | The backend stack to use for the application | `--backend=node` |
39+
| `manager` | Which package manager to use (npm, yarn, pnpm, bun) | `--manager=pnpm` |
40+
| `autostart` | Whether the CLI should start the project after setting up | `--autostart=true` |
3941

4042
## Contributing
4143

boilerplate/fullstack/remix/app/routes/auth.$.tsx

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,6 @@ import { PreBuiltUIList } from "../../app/config/frontend";
44
import SuperTokens from "supertokens-auth-react/index.js";
55

66
export default function Auth() {
7-
useEffect(() => {
8-
if (canHandleRoute(PreBuiltUIList) === false) {
9-
SuperTokens.redirectToAuth({
10-
redirectBack: false,
11-
});
12-
}
13-
}, []);
14-
157
// If the user visits a page that is not handled by us (like /auth/random), then we redirect them back to the auth page.
168
const [loaded, setLoaded] = useState(false);
179
useEffect(() => {
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import { json } from "@remix-run/node";
2+
import { LoaderFunctionArgs } from "react-router-dom";
3+
import { getSessionDetails } from "../lib/superTokensHelpers.js";
4+
5+
// Loader function for handling GET requests that also adds cache control headers
6+
export async function loader({ request }: LoaderFunctionArgs) {
7+
try {
8+
const res = await getSessionDetails(request);
9+
return {
10+
session: res.session,
11+
};
12+
} catch (error) {
13+
return json({ error: "Internal server error" }, { status: 500 });
14+
}
15+
}

lib/build/config.js

Lines changed: 29 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { getPackageManagerCommand, validateFolderName } from "./userArgumentUtils.js";
1+
import { validateFolderName } from "./userArgumentUtils.js";
22
import {
33
getDjangoPythonRunScripts,
44
getPythonRunScripts,
@@ -14,8 +14,7 @@ function getCapacitorMessage() {
1414
return `create-supertokens-app uses ${chalk.bold("nextjs-native-starter")} as a template app for Capacitor. ${chalk.bold("nextjs-native-starter")} is a starter project created by ${chalk.blue("https://github.com/RobSchilderr")}, if you face any problems please open an issue here: ${chalk.blue("https://github.com/RobSchilderr/nextjs-native-starter/issues")} or reach out to us on the SuperTokens Discord server: ${chalk.blue("https://supertokens.com/discord")}.\n\nTo get started refer to the README on Github ${chalk.blue("https://github.com/RobSchilderr/nextjs-native-starter")}`;
1515
}
1616
}
17-
export async function getFrontendOptions(userArguments) {
18-
const packagerCommand = await getPackageManagerCommand(userArguments);
17+
export async function getFrontendOptions({ manager }) {
1918
return [
2019
{
2120
value: "react",
@@ -25,8 +24,8 @@ export async function getFrontendOptions(userArguments) {
2524
config: [{ finalConfig: "/src/config.tsx", configFiles: "/config" }],
2625
},
2726
script: {
28-
setup: [`${packagerCommand} install`],
29-
run: [`${packagerCommand} run start`],
27+
setup: [`${manager} install`],
28+
run: [`${manager} run start`],
3029
},
3130
},
3231
{
@@ -37,8 +36,8 @@ export async function getFrontendOptions(userArguments) {
3736
config: [{ finalConfig: "/src/config.tsx", configFiles: "/config" }],
3837
},
3938
script: {
40-
setup: [`${packagerCommand} install`],
41-
run: [`${packagerCommand} run start`],
39+
setup: [`${manager} install`],
40+
run: [`${manager} run start`],
4241
},
4342
shouldDisplay: false,
4443
},
@@ -64,8 +63,8 @@ export async function getFrontendOptions(userArguments) {
6463
},
6564
},
6665
script: {
67-
run: [`${packagerCommand} run dev`],
68-
setup: [`${packagerCommand} install`],
66+
run: [`${manager} run dev`],
67+
setup: [`${manager} install`],
6968
},
7069
},
7170
{
@@ -91,8 +90,8 @@ export async function getFrontendOptions(userArguments) {
9190
},
9291
},
9392
script: {
94-
run: [`${packagerCommand} run dev`],
95-
setup: [`${packagerCommand} install`],
93+
run: [`${manager} run dev`],
94+
setup: [`${manager} install`],
9695
},
9796
},
9897
{
@@ -118,8 +117,8 @@ export async function getFrontendOptions(userArguments) {
118117
},
119118
},
120119
script: {
121-
run: [`${packagerCommand} run dev`],
122-
setup: [`${packagerCommand} install`],
120+
run: [`${manager} run dev`],
121+
setup: [`${manager} install`],
123122
},
124123
},
125124
{
@@ -144,8 +143,8 @@ export async function getFrontendOptions(userArguments) {
144143
},
145144
},
146145
script: {
147-
run: [`${packagerCommand} run dev`],
148-
setup: [`${packagerCommand} install`],
146+
run: [`${manager} run dev`],
147+
setup: [`${manager} install`],
149148
},
150149
},
151150
{
@@ -159,8 +158,8 @@ export async function getFrontendOptions(userArguments) {
159158
],
160159
},
161160
script: {
162-
setup: [`${packagerCommand} install`],
163-
run: [`${packagerCommand} run dev`],
161+
setup: [`${manager} install`],
162+
run: [`${manager} run dev`],
164163
},
165164
},
166165
{
@@ -174,8 +173,8 @@ export async function getFrontendOptions(userArguments) {
174173
],
175174
},
176175
script: {
177-
setup: [`${packagerCommand} install`],
178-
run: [`${packagerCommand} run dev`],
176+
setup: [`${manager} install`],
177+
run: [`${manager} run dev`],
179178
},
180179
},
181180
{
@@ -211,8 +210,7 @@ export async function getFrontendOptions(userArguments) {
211210
},
212211
];
213212
}
214-
export async function getNextJSOptions(userArguments) {
215-
const packagerCommand = await getPackageManagerCommand(userArguments);
213+
export async function getNextJSOptions({ manager }) {
216214
return [
217215
{
218216
displayName: "Using the App directory",
@@ -234,8 +232,8 @@ export async function getNextJSOptions(userArguments) {
234232
},
235233
},
236234
script: {
237-
run: [`${packagerCommand} run dev`],
238-
setup: [`${packagerCommand} install`],
235+
run: [`${manager} run dev`],
236+
setup: [`${manager} install`],
239237
},
240238
value: "next-app-directory",
241239
isFullStack: true,
@@ -262,8 +260,8 @@ export async function getNextJSOptions(userArguments) {
262260
},
263261
},
264262
script: {
265-
run: [`${packagerCommand} run dev`],
266-
setup: [`${packagerCommand} install`],
263+
run: [`${manager} run dev`],
264+
setup: [`${manager} install`],
267265
},
268266
},
269267
];
@@ -311,8 +309,7 @@ const pythonOptions = [
311309
},
312310
},
313311
];
314-
export async function getBackendOptions(userArguments) {
315-
const packagerCommand = await getPackageManagerCommand(userArguments);
312+
export async function getBackendOptions({ manager }) {
316313
return [
317314
{
318315
value: "node",
@@ -327,8 +324,8 @@ export async function getBackendOptions(userArguments) {
327324
],
328325
},
329326
script: {
330-
setup: [`${packagerCommand} install`],
331-
run: [`${packagerCommand} run start`],
327+
setup: [`${manager} install`],
328+
run: [`${manager} run start`],
332329
},
333330
},
334331
{
@@ -339,8 +336,8 @@ export async function getBackendOptions(userArguments) {
339336
config: [{ finalConfig: "/src/config.ts", configFiles: "/config" }],
340337
},
341338
script: {
342-
setup: [`${packagerCommand} install`],
343-
run: [`${packagerCommand} run start`],
339+
setup: [`${manager} install`],
340+
run: [`${manager} run start`],
344341
},
345342
},
346343
{
@@ -477,7 +474,7 @@ export async function getQuestions(flags) {
477474
message: "What type of authentication do you want to use?",
478475
choices: mapOptionsToChoices(recipeOptions),
479476
when: (answers) => {
480-
// For capactor we dont ask this question because it has its own way of swapping between recipes
477+
// For capacitor we don't ask this question because it has its own way of swapping between recipes
481478
if (answers.frontend === "capacitor") {
482479
return false;
483480
}

lib/build/index.js

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import AnalyticsManager from "./analytics.js";
1818
import figlet from "figlet";
1919
import { package_version } from "./version.js";
2020
import { modifyAnswersBasedOnNextJsFramework, modifyAnswersForPythonFrameworks } from "./questionUtils.js";
21+
import { inferredPackageManager } from "./packageManager.js";
2122
async function printInformation() {
2223
const font = "Doom";
2324
console.log("\n");
@@ -76,7 +77,7 @@ async function run() {
7677
For example: `npx create-supertokens-app --recipe=emailpassword` will result
7778
in userArguments.recipe === "emailpassword"
7879
79-
Avalaible flags:
80+
Available flags:
8081
--appname: App name
8182
--recipe: Auth mechanism
8283
--branch: Which branch to use when downloading from github (defaults to master)
@@ -86,8 +87,12 @@ async function run() {
8687
--manager: Which package manager to use
8788
--autostart: Whether the CLI should start the project after setting up
8889
*/
89-
const userArguments = await yargs(hideBin(process.argv)).argv;
90-
validateUserArguments(userArguments);
90+
const userArgumentsRaw = await yargs(hideBin(process.argv)).argv;
91+
validateUserArguments(userArgumentsRaw);
92+
const userArguments = {
93+
...userArgumentsRaw,
94+
manager: userArgumentsRaw.manager ?? inferredPackageManager() ?? "npm",
95+
};
9196
AnalyticsManager.sendAnalyticsEvent({
9297
eventName: "cli_started",
9398
});
@@ -176,9 +181,9 @@ async function run() {
176181
* otherwise the user would have to manually delete the folder before
177182
* running the CLI again
178183
*
179-
* NOTE: We dont do this for runProject because if running fails, the user
184+
* NOTE: We don't do this for runProject because if running fails, the user
180185
* can fix the error (install missing library for example) and then run the
181-
* app again themseves without having to run and wait for the CLI to finish
186+
* app again themselves without having to run and wait for the CLI to finish
182187
*/
183188
fs.rmSync(`${answers.appname}/`, {
184189
recursive: true,

lib/build/packageManager.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import { isValidPackageManager } from "./types.js";
2+
import whichPMRuns from "which-pm-runs";
3+
export function inferredPackageManager() {
4+
const packageManager = whichPMRuns();
5+
const packageManagerName = packageManager?.name;
6+
if (packageManagerName && isValidPackageManager(packageManagerName)) {
7+
return packageManagerName;
8+
}
9+
return undefined;
10+
}
11+
export function addPackageCommand(packageManager) {
12+
switch (packageManager) {
13+
case "bun":
14+
return "bun add";
15+
case "yarn":
16+
return "yarn add";
17+
case "pnpm":
18+
return "pnpm add";
19+
case "npm":
20+
return "npm i";
21+
}
22+
}

lib/build/questionUtils.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ export function getDjangoPythonRunScripts() {
3737
"python manage.py runserver",
3838
];
3939
}
40-
// Converts the options array we declare to a format iquirer can use
40+
// Converts the options array we declare to a format inquirer can use
4141
export function mapOptionsToChoices(options) {
4242
return options
4343
.filter((i) => i.shouldDisplay !== false)

lib/build/types.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ export function isValidBackend(backend) {
7373
}
7474
return false;
7575
}
76-
export const allPackageManagers = ["npm", "yarn", "bun"];
76+
export const allPackageManagers = ["npm", "yarn", "pnpm", "bun"];
7777
export function isValidPackageManager(manager) {
7878
if (allPackageManagers.includes(manager)) {
7979
return true;

0 commit comments

Comments
 (0)