@solidstarters/create-solid-app 1.2.18 → 1.2.20
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 +58 -23
- package/index.js +15 -20
- package/package.json +1 -1
- package/templates/dot-templates/dot.vscode.template/launch.json +35 -0
- package/templates/nest-template/nodemon.json +13 -0
- package/templates/nest-template/package-lock.json +487 -117
- package/templates/nest-template/package.json +7 -4
- package/templates/nest-template/src/main.ts +0 -3
- package/templates/next-template/package-lock.json +4 -4
- package/templates/next-template/package.json +1 -1
- package/templates/next-template/redux/store.ts +4 -0
- package/templates/dot.templates/dot.vscode.template/launch.json +0 -29
- package/templates/next-template/app/admin/settings/authentication-settings/page.tsx +0 -10
- package/templates/next-template/app/admin/settings/misc-settings/page.tsx +0 -10
- /package/templates/next-template/app/admin/{settings/app-settings → core/[moduleName]/settings/[settings]}/page.tsx +0 -0
package/helpers.js
CHANGED
|
@@ -10,11 +10,17 @@ import { fileURLToPath } from 'url';
|
|
|
10
10
|
// Simulate __dirname
|
|
11
11
|
const __filename = fileURLToPath(import.meta.url);
|
|
12
12
|
const __dirname = dirname(__filename);
|
|
13
|
+
export const HIDDEN_TEMPLATES_FOLDER = 'dot-templates';
|
|
14
|
+
export const SOURCE_TEMPLATE_FOLDER_API = 'nest-template';
|
|
15
|
+
export const SOURCE_TEMPLATE_FOLDER_UI = 'next-template';
|
|
16
|
+
export const TARGET_FOLDER_API = 'solid-api';
|
|
17
|
+
export const TARGET_FOLDER_UI = 'solid-ui';
|
|
18
|
+
export const EXCLUDED_DIRS_FOR_INITIAL_COPY = [SOURCE_TEMPLATE_FOLDER_API, SOURCE_TEMPLATE_FOLDER_UI];
|
|
13
19
|
|
|
14
20
|
export async function copyAndInstallTemplate(source, target, showLogs) {
|
|
15
21
|
try {
|
|
16
22
|
// Copy the source folder to the target folder
|
|
17
|
-
await copyTemplate(source, target);
|
|
23
|
+
await copyTemplate(source, target);
|
|
18
24
|
|
|
19
25
|
// Run `npm install` in the target directory
|
|
20
26
|
return await installTemplate(target, showLogs);
|
|
@@ -30,32 +36,61 @@ async function installTemplate(target, showLogs) {
|
|
|
30
36
|
return output;
|
|
31
37
|
}
|
|
32
38
|
|
|
33
|
-
export async function copyTemplate(source, target) {
|
|
39
|
+
export async function copyTemplate(source, target, excludedDirs = []) {
|
|
34
40
|
try {
|
|
35
|
-
await
|
|
36
|
-
|
|
37
|
-
// Check if there is a dot-templates folder in the target
|
|
38
|
-
// handleHiddenTemplateFiles(target);
|
|
41
|
+
await handleCopy(source, target, excludedDirs);
|
|
42
|
+
handleHiddenTemplateFiles(target);
|
|
39
43
|
}
|
|
40
44
|
catch (error) {
|
|
41
|
-
console.error(chalk.red(
|
|
45
|
+
console.error(chalk.red(`Error in copyTemplate: for ${source} to ${target}`, error));
|
|
42
46
|
throw error;
|
|
43
47
|
}
|
|
44
48
|
}
|
|
45
49
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
50
|
+
/**
|
|
51
|
+
* Recursively copies from source to target, excluding specified directories.
|
|
52
|
+
*
|
|
53
|
+
* @param {string} source - Source directory
|
|
54
|
+
* @param {string} target - Target directory
|
|
55
|
+
* @param {string[]} excludedDirs - Relative paths (from source) to exclude
|
|
56
|
+
*/
|
|
57
|
+
export async function handleCopy(source, target, excludedDirs = []) {
|
|
58
|
+
await fs.copy(source, target, {
|
|
59
|
+
filter: (src) => {
|
|
60
|
+
const relativePath = path.relative(source, src);
|
|
61
|
+
|
|
62
|
+
// Always include root path (empty string)
|
|
63
|
+
if (!relativePath) return true;
|
|
64
|
+
|
|
65
|
+
// Normalize path separators for cross-platform compatibility
|
|
66
|
+
const normalizedPath = relativePath.split(path.sep).join('/');
|
|
67
|
+
|
|
68
|
+
const isExcluded = excludedDirs.some(dir =>
|
|
69
|
+
normalizedPath === dir || normalizedPath.startsWith(`${dir}/`)
|
|
70
|
+
);
|
|
71
|
+
|
|
72
|
+
return !isExcluded;
|
|
73
|
+
},
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
// Check if there is a dot-templates folder in the target
|
|
78
|
+
function handleHiddenTemplateFiles(targetDir) {
|
|
79
|
+
if (!fs.lstatSync(targetDir).isDirectory()) { // If targetDir is not a directory, return
|
|
80
|
+
return;
|
|
57
81
|
}
|
|
58
|
-
|
|
82
|
+
const hiddenTemplatesPath = path.join(targetDir, HIDDEN_TEMPLATES_FOLDER);
|
|
83
|
+
if (!fs.existsSync(hiddenTemplatesPath)) { // If dot-templates folder does not exist, return
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
// move all the files from dot-templates to the target after remove .template in the file name
|
|
87
|
+
const files = fs.readdirSync(hiddenTemplatesPath);
|
|
88
|
+
files.forEach(file => {
|
|
89
|
+
const newFileName = file.replace('dot.', '.').replace('.template', '');
|
|
90
|
+
fs.moveSync(path.join(hiddenTemplatesPath, file), path.join(targetDir, newFileName));
|
|
91
|
+
});
|
|
92
|
+
fs.removeSync(hiddenTemplatesPath);
|
|
93
|
+
}
|
|
59
94
|
|
|
60
95
|
export function getSourceFolderPath(folder) {
|
|
61
96
|
const folderPath = path.join(__dirname, folder);
|
|
@@ -115,7 +150,7 @@ export function updatePortInPackageJson(targetPath, subProject, port) {
|
|
|
115
150
|
export function getBackendEnvConfig(answers) {
|
|
116
151
|
const envConfig = {
|
|
117
152
|
"General": {
|
|
118
|
-
ENV: '
|
|
153
|
+
ENV: 'dev',
|
|
119
154
|
PORT: answers.solidApiPort,
|
|
120
155
|
SOLID_APP_NAME: answers.projectName,
|
|
121
156
|
BASE_URL: `http://localhost:${answers.solidApiPort}`,
|
|
@@ -156,9 +191,9 @@ export function getFrontendEnvJson(answers) {
|
|
|
156
191
|
NEXT_PUBLIC_SOLID_APP_DESCRIPTION: '',
|
|
157
192
|
NEXT_PUBLIC_ENABLE_CUSTOM_HEADER_FOOTER: false,
|
|
158
193
|
NEXT_PUBLIC_DEFAULT_MENU_KEY: `${answers.projectName}-tracker`,
|
|
159
|
-
NEXT_PUBLIC_SHOW_SETTINGS:false,
|
|
160
|
-
NEXT_PUBLIC_LOGIN_REDIRECT_URL
|
|
161
|
-
NEXT_PUBLIC_REMOTE_PATTERNS:'[{"protocol":"http","hostname":"localhost","pathname":"/media-files-storage/**"}]'
|
|
194
|
+
NEXT_PUBLIC_SHOW_SETTINGS: false,
|
|
195
|
+
NEXT_PUBLIC_LOGIN_REDIRECT_URL: `/admin/core/solid-core/user/list`,
|
|
196
|
+
NEXT_PUBLIC_REMOTE_PATTERNS: '[{"protocol":"http","hostname":"localhost","pathname":"/media-files-storage/**"}]'
|
|
162
197
|
}
|
|
163
198
|
};
|
|
164
199
|
return envConfig;
|
package/index.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
3
|
import chalk from 'chalk';
|
|
4
|
-
import
|
|
4
|
+
import fs from 'fs-extra';
|
|
5
5
|
import inquirer from 'inquirer';
|
|
6
|
+
import _ from 'lodash';
|
|
6
7
|
import path from 'path';
|
|
7
|
-
import
|
|
8
|
+
import { copyAndInstallTemplate, copyTemplate, EXCLUDED_DIRS_FOR_INITIAL_COPY, generateEnvFileFromConfig, getBackendEnvConfig, getFrontendEnvJson, getSourceFolderPath, installSolidAsGlobalBinary, prettyOutput, SOURCE_TEMPLATE_FOLDER_API, SOURCE_TEMPLATE_FOLDER_UI, TARGET_FOLDER_API, TARGET_FOLDER_UI, updatePackageName, updatePortInPackageJson } from './helpers.js';
|
|
8
9
|
import { setupQuestions } from './setup-questions.js';
|
|
9
|
-
import _ from 'lodash';
|
|
10
10
|
|
|
11
11
|
|
|
12
12
|
async function main() {
|
|
@@ -32,28 +32,26 @@ async function main() {
|
|
|
32
32
|
// Step 2: Setup the sub projects from the templates
|
|
33
33
|
console.log(prettyOutput('Step 1','Setting up boilerplate for the backend'));
|
|
34
34
|
const templatesPath = getSourceFolderPath('templates');
|
|
35
|
-
|
|
35
|
+
await copyTemplate(templatesPath, targetPath, EXCLUDED_DIRS_FOR_INITIAL_COPY);
|
|
36
36
|
|
|
37
|
-
await copyAndInstallTemplate(path.join(templatesPath,
|
|
37
|
+
await copyAndInstallTemplate(path.join(templatesPath, SOURCE_TEMPLATE_FOLDER_API), path.join(targetPath, TARGET_FOLDER_API), showLogs);
|
|
38
38
|
|
|
39
39
|
console.log(prettyOutput('Step 2','Installing solid binary globally'));
|
|
40
|
-
|
|
40
|
+
await installSolidAsGlobalBinary(path.join(targetPath, TARGET_FOLDER_API), showLogs);
|
|
41
41
|
|
|
42
42
|
console.log(prettyOutput('Step 3',`Setting up boilerplate for the frontend`));
|
|
43
|
-
await copyAndInstallTemplate(path.join(templatesPath,
|
|
43
|
+
await copyAndInstallTemplate(path.join(templatesPath, SOURCE_TEMPLATE_FOLDER_UI), path.join(targetPath, TARGET_FOLDER_UI), showLogs);
|
|
44
44
|
|
|
45
45
|
// Step 3: Update project package json details
|
|
46
|
-
updatePackageName(targetPath,
|
|
47
|
-
updatePackageName(targetPath,
|
|
48
|
-
updatePortInPackageJson(targetPath,
|
|
49
|
-
// Copy the upgrade shell script to the target path
|
|
50
|
-
await copyTemplate(path.join(templatesPath, 'upgrade.sh'), path.join(targetPath, 'upgrade.sh'));
|
|
46
|
+
updatePackageName(targetPath, TARGET_FOLDER_UI, `@${projectName}/${TARGET_FOLDER_UI}`);
|
|
47
|
+
updatePackageName(targetPath, TARGET_FOLDER_API, `@${projectName}/${TARGET_FOLDER_API}`);
|
|
48
|
+
updatePortInPackageJson(targetPath, TARGET_FOLDER_UI, answers.solidUiPort);
|
|
51
49
|
|
|
52
50
|
// Step 4: Generate the .env files for backend and frontend
|
|
53
|
-
const backendPath = path.join(targetPath,
|
|
51
|
+
const backendPath = path.join(targetPath, TARGET_FOLDER_API);
|
|
54
52
|
console.log(prettyOutput('Step 4',`Generating .env file for the backend at ${chalk.cyan(backendPath)}`));
|
|
55
53
|
generateEnvFileFromConfig(backendPath, getBackendEnvConfig(answers));
|
|
56
|
-
const frontendPath = path.join(targetPath,
|
|
54
|
+
const frontendPath = path.join(targetPath, TARGET_FOLDER_UI);
|
|
57
55
|
console.log(prettyOutput('Step 5',`Generating .env file for the frontend at ${chalk.cyan(frontendPath)}`));
|
|
58
56
|
generateEnvFileFromConfig(frontendPath, getFrontendEnvJson(answers));
|
|
59
57
|
|
|
@@ -62,14 +60,11 @@ async function main() {
|
|
|
62
60
|
console.log(chalk.cyan(`\nEnsure the database is created and connection is established correctly.`));
|
|
63
61
|
console.log(chalk.cyan(`\nNext steps:`));
|
|
64
62
|
console.log(chalk.cyan(`Run the api:`));
|
|
65
|
-
console.log(prettyOutput('',`cd ${projectName}
|
|
63
|
+
console.log(prettyOutput('',`cd ${projectName}/${TARGET_FOLDER_API}`));
|
|
66
64
|
console.log(prettyOutput('','solid seed','This will seed the database with the required metadata'));
|
|
67
65
|
|
|
68
66
|
// Development mode (with watch )
|
|
69
|
-
console.log(prettyOutput('', 'npm run
|
|
70
|
-
|
|
71
|
-
// Development mode (debug)
|
|
72
|
-
console.log(prettyOutput('', 'npm run start:debug', `Starts the backend in development mode with debugging on @http://localhost:${answers.solidApiPort}`));
|
|
67
|
+
console.log(prettyOutput('', 'npm run solidx:dev', `Starts the backend in development mode with live reload on @http://localhost:${answers.solidApiPort}`));
|
|
73
68
|
|
|
74
69
|
// Production mode
|
|
75
70
|
console.log(prettyOutput('', 'npm run start', `Starts the backend in production mode on @http://localhost:${answers.solidApiPort}`));
|
|
@@ -78,7 +73,7 @@ async function main() {
|
|
|
78
73
|
|
|
79
74
|
// console.log(prettyOutput('','npm run start',`This will start the backend server @http://localhost:${answers.solidApiPort}`));
|
|
80
75
|
console.log(chalk.cyan(`\nRun the frontend:`));
|
|
81
|
-
console.log(prettyOutput('',`cd ${projectName}
|
|
76
|
+
console.log(prettyOutput('',`cd ${projectName}/${TARGET_FOLDER_UI}`));
|
|
82
77
|
console.log(prettyOutput('','npm run dev',`This will start the frontend server @http://localhost:${answers.solidUiPort}`));
|
|
83
78
|
}
|
|
84
79
|
catch (err) {
|
package/package.json
CHANGED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
{
|
|
2
|
+
// Use IntelliSense to learn about possible attributes.
|
|
3
|
+
// Hover to view descriptions of existing attributes.
|
|
4
|
+
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
|
|
5
|
+
"version": "0.2.0",
|
|
6
|
+
"configurations": [
|
|
7
|
+
{
|
|
8
|
+
"type": "node",
|
|
9
|
+
"request": "launch",
|
|
10
|
+
"name": "Debug solid-api",
|
|
11
|
+
"args": [
|
|
12
|
+
"${workspaceFolder}/solid-api/src/main.ts"
|
|
13
|
+
],
|
|
14
|
+
"runtimeArgs": [
|
|
15
|
+
"--nolazy",
|
|
16
|
+
"-r",
|
|
17
|
+
"ts-node/register",
|
|
18
|
+
"-r",
|
|
19
|
+
"tsconfig-paths/register"
|
|
20
|
+
],
|
|
21
|
+
"sourceMaps": true,
|
|
22
|
+
"outFiles": [
|
|
23
|
+
"${workspaceFolder}/dist/**/*.js",
|
|
24
|
+
"${workspaceFolder}/solid-api/node_modules/@solidstarters/solid-core-module/dist/**/*.js"
|
|
25
|
+
],
|
|
26
|
+
"resolveSourceMapLocations": [
|
|
27
|
+
"${workspaceFolder}/**",
|
|
28
|
+
"${workspaceFolder}/solid-api/node_modules/@solidstarters/solid-core/**"
|
|
29
|
+
],
|
|
30
|
+
"cwd": "${workspaceFolder}/solid-api",
|
|
31
|
+
"console": "integratedTerminal",
|
|
32
|
+
"autoAttachChildProcesses": true
|
|
33
|
+
},
|
|
34
|
+
]
|
|
35
|
+
}
|