@solidstarters/create-solid-app 1.2.12 → 1.2.13
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/helpers.js +7 -8
- package/index.js +21 -5
- package/package.json +1 -1
- package/templates/nest-template/refresh.bat +15 -0
- package/templates/nest-template/src/main-cli.ts +22 -3
- package/templates/next-template/app/api/auth/[...nextauth]/route.ts +4 -2
- package/templates/next-template/app/globals.css +14 -0
package/helpers.js
CHANGED
|
@@ -11,13 +11,13 @@ import { fileURLToPath } from 'url';
|
|
|
11
11
|
const __filename = fileURLToPath(import.meta.url);
|
|
12
12
|
const __dirname = dirname(__filename);
|
|
13
13
|
|
|
14
|
-
export async function copyAndInstallTemplate(source, target) {
|
|
14
|
+
export async function copyAndInstallTemplate(source, target, showLogs) {
|
|
15
15
|
try {
|
|
16
16
|
// Copy the source folder to the target folder
|
|
17
17
|
await copyTemplate(source, target);
|
|
18
18
|
|
|
19
19
|
// Run `npm install` in the target directory
|
|
20
|
-
return await installTemplate(target);
|
|
20
|
+
return await installTemplate(target, showLogs);
|
|
21
21
|
// console.log(chalk.green(`Dependencies installed in ${target}`));
|
|
22
22
|
} catch (error) {
|
|
23
23
|
console.error(chalk.red('Error in copyAndInstallTemplate:', error));
|
|
@@ -25,8 +25,8 @@ export async function copyAndInstallTemplate(source, target) {
|
|
|
25
25
|
}
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
-
async function installTemplate(target) {
|
|
29
|
-
const output = await execa('npm', ['install'], { stdio:
|
|
28
|
+
async function installTemplate(target, showLogs) {
|
|
29
|
+
const output = await execa('npm', ['install'], { stdio: showLogs ? "inherit" : "ignore", cwd: target });
|
|
30
30
|
return output;
|
|
31
31
|
}
|
|
32
32
|
|
|
@@ -185,20 +185,19 @@ function generateJwtSecret() {
|
|
|
185
185
|
return crypto.randomBytes(64).toString('hex'); // 64 bytes => 128 characters in hexadecimal
|
|
186
186
|
};
|
|
187
187
|
|
|
188
|
-
export async function installSolidAsGlobalBinary(cwd) {
|
|
188
|
+
export async function installSolidAsGlobalBinary(cwd, showLogs) {
|
|
189
189
|
try {
|
|
190
|
-
await execa('npm', ['run', 'build'], { stdio:
|
|
190
|
+
await execa('npm', ['run', 'build'], { stdio: showLogs ? "inherit" : "ignore", cwd });
|
|
191
191
|
|
|
192
192
|
const nodeVersion = process.version;
|
|
193
193
|
const homeDir = os.homedir();
|
|
194
194
|
const binaryPath = path.join(homeDir, `.nvm/versions/node/${nodeVersion}/bin/solid`);
|
|
195
|
-
|
|
196
195
|
try {
|
|
197
196
|
await execa('rm', [binaryPath], { stdio: 'inherit' });
|
|
198
197
|
} catch (error) {
|
|
199
198
|
}
|
|
200
199
|
|
|
201
|
-
await execa('npm', ['i', '-g'], { stdio:
|
|
200
|
+
await execa('npm', ['i', '-g'], { stdio: showLogs ? "inherit" : "ignore", cwd });
|
|
202
201
|
} catch (error) {
|
|
203
202
|
console.error(chalk.red('Error during installation:', error.message));
|
|
204
203
|
process.exit(1);
|
package/index.js
CHANGED
|
@@ -11,6 +11,10 @@ import _ from 'lodash';
|
|
|
11
11
|
|
|
12
12
|
async function main() {
|
|
13
13
|
try {
|
|
14
|
+
// Check if --debug=true or --verbose=true exists in args
|
|
15
|
+
const args = process.argv;
|
|
16
|
+
const showLogs = args.some(arg => arg.includes("--verbose"));
|
|
17
|
+
|
|
14
18
|
console.log(chalk.cyan("Hello, Let's setup your Solid project!"));
|
|
15
19
|
|
|
16
20
|
// Questions for the user to setup backend
|
|
@@ -30,13 +34,13 @@ async function main() {
|
|
|
30
34
|
const templatesPath = getSourceFolderPath('templates');
|
|
31
35
|
// copyTemplate(path.join(templatesPath, 'dot.templates'), targetPath);
|
|
32
36
|
|
|
33
|
-
await copyAndInstallTemplate(path.join(templatesPath, 'nest-template'), path.join(targetPath, 'solid-api'));
|
|
37
|
+
await copyAndInstallTemplate(path.join(templatesPath, 'nest-template'), path.join(targetPath, 'solid-api'), showLogs);
|
|
34
38
|
|
|
35
39
|
console.log(prettyOutput('Step 2','Installing solid binary globally'));
|
|
36
|
-
const ignore = await installSolidAsGlobalBinary(path.join(targetPath, 'solid-api'));
|
|
40
|
+
const ignore = await installSolidAsGlobalBinary(path.join(targetPath, 'solid-api'), showLogs);
|
|
37
41
|
|
|
38
42
|
console.log(prettyOutput('Step 3',`Setting up boilerplate for the frontend`));
|
|
39
|
-
await copyAndInstallTemplate(path.join(templatesPath, 'next-template'), path.join(targetPath, 'solid-ui'));
|
|
43
|
+
await copyAndInstallTemplate(path.join(templatesPath, 'next-template'), path.join(targetPath, 'solid-ui'), showLogs);
|
|
40
44
|
|
|
41
45
|
// Step 3: Update project package json details
|
|
42
46
|
updatePackageName(targetPath, 'solid-ui', `@${projectName}/solid-ui`);
|
|
@@ -57,8 +61,20 @@ async function main() {
|
|
|
57
61
|
console.log(chalk.cyan(`\nNext steps:`));
|
|
58
62
|
console.log(chalk.cyan(`Run the api:`));
|
|
59
63
|
console.log(prettyOutput('',`cd ${projectName}/solid-api`));
|
|
60
|
-
console.log(prettyOutput('','solid seed
|
|
61
|
-
|
|
64
|
+
console.log(prettyOutput('','solid seed','This will seed the database with the required metadata'));
|
|
65
|
+
|
|
66
|
+
// Development mode (with watch )
|
|
67
|
+
console.log(prettyOutput('', 'npm run start:dev', `Starts the backend in development mode with live reload on @http://localhost:${answers.solidApiPort}`));
|
|
68
|
+
|
|
69
|
+
// Development mode (debug)
|
|
70
|
+
console.log(prettyOutput('', 'npm run start:debug', `Starts the backend in development mode with debugging on @http://localhost:${answers.solidApiPort}`));
|
|
71
|
+
|
|
72
|
+
// Production mode
|
|
73
|
+
console.log(prettyOutput('', 'npm run start', `Starts the backend in production mode on @http://localhost:${answers.solidApiPort}`));
|
|
74
|
+
|
|
75
|
+
console.log(prettyOutput('',`api documentation is available on @http://localhost:${answers.solidApiPort}/docs`));
|
|
76
|
+
|
|
77
|
+
// console.log(prettyOutput('','npm run start',`This will start the backend server @http://localhost:${answers.solidApiPort}`));
|
|
62
78
|
console.log(chalk.cyan(`\nRun the frontend:`));
|
|
63
79
|
console.log(prettyOutput('',`cd ${projectName}/solid-ui`));
|
|
64
80
|
console.log(prettyOutput('','npm run dev',`This will start the frontend server @http://localhost:${answers.solidUiPort}`));
|
package/package.json
CHANGED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
@echo off
|
|
2
|
+
echo Installing dependencies...
|
|
3
|
+
call npm i
|
|
4
|
+
|
|
5
|
+
echo Building the project...
|
|
6
|
+
call npm run build
|
|
7
|
+
|
|
8
|
+
echo Removing Solid binary...
|
|
9
|
+
del "C:\Users\Lenovo\AppData\Roaming\npm\solid" 2>nul
|
|
10
|
+
|
|
11
|
+
echo Installing global dependencies...
|
|
12
|
+
call npm i -g
|
|
13
|
+
|
|
14
|
+
echo Refresh complete!
|
|
15
|
+
pause
|
|
@@ -2,18 +2,28 @@
|
|
|
2
2
|
|
|
3
3
|
import { CommandFactory } from "nest-commander";
|
|
4
4
|
import { AppModule } from "./app.module";
|
|
5
|
-
import { INestApplication, INestApplicationContext } from "@nestjs/common";
|
|
5
|
+
import { INestApplication, INestApplicationContext, Logger } from "@nestjs/common";
|
|
6
6
|
import { setTimeout } from "timers/promises";
|
|
7
7
|
import { NestFactory } from "@nestjs/core";
|
|
8
|
+
import { existsSync } from "fs";
|
|
9
|
+
import { resolve } from "path";
|
|
10
|
+
|
|
11
|
+
const logger = new Logger("Bootstrap");
|
|
8
12
|
|
|
9
13
|
async function bootstrap() {
|
|
14
|
+
const args = process?.argv;
|
|
15
|
+
// validate project existence
|
|
16
|
+
validateProjectRootPath();
|
|
17
|
+
const showLogs = args.some(arg =>arg.includes("--verbose"));
|
|
18
|
+
// Define log levels based on the flag
|
|
19
|
+
const logLevels = showLogs ? ['debug', 'error', 'fatal', 'log', 'verbose', 'warn'] : ['fatal', 'error', 'log'];
|
|
10
20
|
|
|
11
21
|
const appModule = await AppModule.forRoot();
|
|
12
22
|
// const app = await NestFactory.create(appModule);
|
|
13
23
|
|
|
14
24
|
// Create an instance of the application, capture the application context so we can inject it into a service in itself.
|
|
15
25
|
// @ts-ignore
|
|
16
|
-
const app = await CommandFactory.createWithoutRunning(appModule,
|
|
26
|
+
const app = await CommandFactory.createWithoutRunning(appModule, logLevels);
|
|
17
27
|
// const app = await CommandFactory.createWithoutRunning(AppModule, ['debug', 'error', 'fatal', 'log', 'verbose', 'warn']);
|
|
18
28
|
// const app = await CommandFactory.createWithoutRunning(AppModule, ['error', 'fatal']);
|
|
19
29
|
|
|
@@ -35,4 +45,13 @@ async function bootstrap() {
|
|
|
35
45
|
// return parseInt(val)
|
|
36
46
|
// });
|
|
37
47
|
|
|
38
|
-
bootstrap();
|
|
48
|
+
bootstrap();
|
|
49
|
+
|
|
50
|
+
// Check if the current directory is a valid Solid API project
|
|
51
|
+
function validateProjectRootPath() {
|
|
52
|
+
const packageJsonPath = resolve(process.cwd(), "package.json");
|
|
53
|
+
if (!existsSync(packageJsonPath)) {
|
|
54
|
+
logger.log("Does not seem to be a valid solid-api project.");
|
|
55
|
+
process.exit(1);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
@@ -173,9 +173,11 @@ async function auth(req: NextRequest, res: any) {
|
|
|
173
173
|
],
|
|
174
174
|
callbacks: {
|
|
175
175
|
jwt: async ({ token, user }) => {
|
|
176
|
-
|
|
177
|
-
|
|
176
|
+
const bufferTime = 60000; // 1 minute buffer before expiry
|
|
177
|
+
if (Date.now() >= (token.accessTokenExpires as number - bufferTime)) {
|
|
178
|
+
return await refreshAccessToken(token); // Call the refresh token function
|
|
178
179
|
}
|
|
180
|
+
|
|
179
181
|
|
|
180
182
|
// If there is no user (first time login or session), we return the user data
|
|
181
183
|
if (user) {
|
|
@@ -2249,6 +2249,20 @@ li.header-li-px {
|
|
|
2249
2249
|
flex: none;
|
|
2250
2250
|
}
|
|
2251
2251
|
|
|
2252
|
+
@keyframes shake {
|
|
2253
|
+
0% { transform: translateX(0); }
|
|
2254
|
+
20% { transform: translateX(-5px); }
|
|
2255
|
+
40% { transform: translateX(5px); }
|
|
2256
|
+
60% { transform: translateX(-5px); }
|
|
2257
|
+
80% { transform: translateX(5px); }
|
|
2258
|
+
100% { transform: translateX(0); }
|
|
2259
|
+
}
|
|
2260
|
+
|
|
2261
|
+
.tab-error {
|
|
2262
|
+
animation: shake 0.8s ease-in-out;
|
|
2263
|
+
border-bottom: 3px solid red;
|
|
2264
|
+
font-weight: bold;
|
|
2265
|
+
}
|
|
2252
2266
|
.p-button.p-button-icon-only.custom-add-button {
|
|
2253
2267
|
padding: 4px !important;
|
|
2254
2268
|
width: 2rem;
|