@solidstarters/create-solid-app 1.2.17 → 1.2.19

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/Issues.txt ADDED
@@ -0,0 +1,5 @@
1
+ 1. Keeping semver versioned packages, seems to not force the latest package version.
2
+ 2. Add launch.json, upgrade.sh as well to the newly generated repos. Find a js compatible version for upgrade.sh
3
+ 3. Fix the rebuild.sh to run the latest version of node i.e one that is running on the server
4
+ 4. Need to check how tell the server to download and run a particular version of node on the system.
5
+ 5. Also find appropriate js versions of rebuild.sh & upgrade.sh
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,30 +36,60 @@ 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 fs.copy(source, target);
36
- // console.log(chalk.green(`Files copied from ${source} to ${target}`));
37
- // Check if there is a dot-templates folder in the target
41
+ await handleCopy(source, target, excludedDirs);
38
42
  handleHiddenTemplateFiles(target);
39
43
  }
40
44
  catch (error) {
41
- console.error(chalk.red('Error in copyTemplate:', error));
45
+ console.error(chalk.red(`Error in copyTemplate: for ${source} to ${target}`, error));
42
46
  throw error;
43
47
  }
44
48
  }
45
49
 
46
- function handleHiddenTemplateFiles(target) {
47
- const dotTemplatesPath = path.join(target, 'dot-templates');
48
- // move all the files from dot-templates to the target after remove .template in the file name
49
- if (fs.existsSync(dotTemplatesPath)) {
50
- const files = fs.readdirSync(dotTemplatesPath);
51
- files.forEach(file => {
52
- const newFileName = file.replace('dot.', '.').replace('.template', '');
53
- fs.moveSync(path.join(dotTemplatesPath, file), path.join(target, newFileName));
54
- });
55
- fs.removeSync(dotTemplatesPath);
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;
81
+ }
82
+ const hiddenTemplatesPath = path.join(targetDir, HIDDEN_TEMPLATES_FOLDER);
83
+ if (!fs.existsSync(hiddenTemplatesPath)) { // If dot-templates folder does not exist, return
84
+ return;
56
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);
57
93
  }
58
94
 
59
95
  export function getSourceFolderPath(folder) {
@@ -117,6 +153,7 @@ export function getBackendEnvConfig(answers) {
117
153
  ENV: 'prod', //FIXME: preferred dev, Need to asses impact of keeping it as dev
118
154
  PORT: answers.solidApiPort,
119
155
  SOLID_APP_NAME: answers.projectName,
156
+ BASE_URL: `http://localhost:${answers.solidApiPort}`,
120
157
  },
121
158
  "Default DB Configuration": {
122
159
  DEFAULT_DATABASE_USER: answers.solidApiDatabaseUsername,
@@ -154,8 +191,9 @@ export function getFrontendEnvJson(answers) {
154
191
  NEXT_PUBLIC_SOLID_APP_DESCRIPTION: '',
155
192
  NEXT_PUBLIC_ENABLE_CUSTOM_HEADER_FOOTER: false,
156
193
  NEXT_PUBLIC_DEFAULT_MENU_KEY: `${answers.projectName}-tracker`,
157
- NEXT_PUBLIC_SHOW_SETTINGS:false,
158
- NEXT_PUBLIC_LOGIN_REDIRECT_URL:`/admin/core/solid-core/user/list`
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/**"}]'
159
197
  }
160
198
  };
161
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 { copyAndInstallTemplate, generateEnvFileFromConfig, getBackendEnvConfig, getFrontendEnvJson, getSourceFolderPath, updatePackageName, installSolidAsGlobalBinary, prettyOutput, updatePortInPackageJson, copyTemplate } from './helpers.js';
4
+ import fs from 'fs-extra';
5
5
  import inquirer from 'inquirer';
6
+ import _ from 'lodash';
6
7
  import path from 'path';
7
- import fs from 'fs-extra';
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,26 +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
- // copyTemplate(path.join(templatesPath, 'dot.templates'), targetPath);
35
+ await copyTemplate(templatesPath, targetPath, EXCLUDED_DIRS_FOR_INITIAL_COPY);
36
36
 
37
- await copyAndInstallTemplate(path.join(templatesPath, 'nest-template'), path.join(targetPath, 'solid-api'), showLogs);
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
- const ignore = await installSolidAsGlobalBinary(path.join(targetPath, 'solid-api'), showLogs);
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, 'next-template'), path.join(targetPath, 'solid-ui'), showLogs);
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, 'solid-ui', `@${projectName}/solid-ui`);
47
- updatePackageName(targetPath, 'solid-api', `@${projectName}/solid-api`);
48
- updatePortInPackageJson(targetPath, 'solid-ui', answers.solidUiPort);
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);
49
49
 
50
50
  // Step 4: Generate the .env files for backend and frontend
51
- const backendPath = path.join(targetPath, 'solid-api');
51
+ const backendPath = path.join(targetPath, TARGET_FOLDER_API);
52
52
  console.log(prettyOutput('Step 4',`Generating .env file for the backend at ${chalk.cyan(backendPath)}`));
53
53
  generateEnvFileFromConfig(backendPath, getBackendEnvConfig(answers));
54
- const frontendPath = path.join(targetPath, 'solid-ui');
54
+ const frontendPath = path.join(targetPath, TARGET_FOLDER_UI);
55
55
  console.log(prettyOutput('Step 5',`Generating .env file for the frontend at ${chalk.cyan(frontendPath)}`));
56
56
  generateEnvFileFromConfig(frontendPath, getFrontendEnvJson(answers));
57
57
 
@@ -60,14 +60,11 @@ async function main() {
60
60
  console.log(chalk.cyan(`\nEnsure the database is created and connection is established correctly.`));
61
61
  console.log(chalk.cyan(`\nNext steps:`));
62
62
  console.log(chalk.cyan(`Run the api:`));
63
- console.log(prettyOutput('',`cd ${projectName}/solid-api`));
63
+ console.log(prettyOutput('',`cd ${projectName}/${TARGET_FOLDER_API}`));
64
64
  console.log(prettyOutput('','solid seed','This will seed the database with the required metadata'));
65
65
 
66
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}`));
67
+ console.log(prettyOutput('', 'npm run solidx:dev', `Starts the backend in development mode with live reload on @http://localhost:${answers.solidApiPort}`));
71
68
 
72
69
  // Production mode
73
70
  console.log(prettyOutput('', 'npm run start', `Starts the backend in production mode on @http://localhost:${answers.solidApiPort}`));
@@ -76,7 +73,7 @@ async function main() {
76
73
 
77
74
  // console.log(prettyOutput('','npm run start',`This will start the backend server @http://localhost:${answers.solidApiPort}`));
78
75
  console.log(chalk.cyan(`\nRun the frontend:`));
79
- console.log(prettyOutput('',`cd ${projectName}/solid-ui`));
76
+ console.log(prettyOutput('',`cd ${projectName}/${TARGET_FOLDER_UI}`));
80
77
  console.log(prettyOutput('','npm run dev',`This will start the frontend server @http://localhost:${answers.solidUiPort}`));
81
78
  }
82
79
  catch (err) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@solidstarters/create-solid-app",
3
- "version": "1.2.17",
3
+ "version": "1.2.19",
4
4
  "main": "index.js",
5
5
  "private": false,
6
6
  "publishConfig": {
@@ -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
+ }
@@ -50,3 +50,6 @@ pids
50
50
 
51
51
  # Diagnostic reports (https://nodejs.org/api/report.html)
52
52
  report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
53
+
54
+ media-uploads
55
+ media-files-storage
@@ -0,0 +1,13 @@
1
+ {
2
+ "watch": [
3
+ "src"
4
+ ],
5
+ "ext": "ts,json",
6
+ "ignore": [
7
+ "src/**/*.spec.ts",
8
+ "dist",
9
+ "node_modules"
10
+ ],
11
+ "delay": 2000,
12
+ "exec": "ts-node -r tsconfig-paths/register src/main.ts"
13
+ }