portosaurus 0.16.4 → 0.16.6

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.

Potentially problematic release.


This version of portosaurus might be problematic. Click here for more details.

@@ -35,17 +35,36 @@ export async function initCommand(directory) {
35
35
  }
36
36
  // 2. Resolve templates directory
37
37
  // We need to robustly find templates whether running from source or built lib
38
- let templatesDir = path.resolve(__dirname, '../../../../templates');
39
- // Check if we are in built mode (lib structure might differ slightly depending on tsc output)
40
- // If 'bin' and 'src' are strictly separated in source, but compiled to 'lib', we need strict logic.
41
- // For now, assuming development with tsx:
42
- // bin/cli.ts calls src/cli/commands/init.ts
43
- // templates is at root.
44
- // From src/cli/commands -> ../../../templates
45
- if (!fs.existsSync(templatesDir)) {
46
- // Try checking if we are in 'lib'
47
- templatesDir = path.resolve(__dirname, '../../../templates');
38
+ // 2. Resolve templates directory
39
+ // We need to robustly find templates whether running from source or built lib
40
+ // Strategy: Find package root by looking for package.json, then look for templates
41
+ let currentDir = __dirname;
42
+ let packageRoot = '';
43
+ // Walk up until we find package.json or hit root
44
+ for (let i = 0; i < 10; i++) {
45
+ if (fs.existsSync(path.join(currentDir, 'package.json'))) {
46
+ packageRoot = currentDir;
47
+ break;
48
+ }
49
+ const parent = path.dirname(currentDir);
50
+ if (parent === currentDir)
51
+ break; // Root
52
+ currentDir = parent;
48
53
  }
54
+ if (!packageRoot) {
55
+ // Fallback: try common locations relative to this file
56
+ // If in lib/src/cli/commands -> ../../../..
57
+ // If in src/cli/commands -> ../../../..
58
+ const potentialRoot = path.resolve(__dirname, '../../../../');
59
+ if (fs.existsSync(path.join(potentialRoot, 'package.json'))) {
60
+ packageRoot = potentialRoot;
61
+ }
62
+ }
63
+ if (!packageRoot) {
64
+ spinner.fail(`Could not find package root from ${__dirname}`);
65
+ return;
66
+ }
67
+ const templatesDir = path.join(packageRoot, 'templates');
49
68
  if (!fs.existsSync(templatesDir)) {
50
69
  spinner.fail(`Could not find templates directory at ${templatesDir}`);
51
70
  return;
@@ -53,7 +72,13 @@ export async function initCommand(directory) {
53
72
  // 3. Copy templates
54
73
  spinner.text = 'Copying template files...';
55
74
  await fs.copy(templatesDir, targetDir, {
56
- filter: (src) => !src.includes('node_modules') && !src.includes('package.json') // Don't copy package.json if it exists there, we generate it
75
+ filter: (src) => {
76
+ // We only want to filter out node_modules that might be INSIDE the template directory (unlikely, but safe)
77
+ // But src path will be absolute, so it MIGHT contain node_modules if the package itself is installed in node_modules
78
+ // We should only check the relative path from templatesDir
79
+ const relativePath = path.relative(templatesDir, src);
80
+ return !relativePath.includes('node_modules') && !relativePath.includes('package.json');
81
+ }
57
82
  });
58
83
  // Rename _tsconfig.json to tsconfig.json
59
84
  const tempTsConfig = path.join(targetDir, '_tsconfig.json');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "portosaurus",
3
- "version": "0.16.4",
3
+ "version": "0.16.6",
4
4
  "license": "GPL-3.0",
5
5
  "author": "soymadip",
6
6
  "description": "Complete portfolio cum personal website solution for your digital personality",
@@ -40,20 +40,41 @@ export async function initCommand(directory: string) {
40
40
 
41
41
  // 2. Resolve templates directory
42
42
  // We need to robustly find templates whether running from source or built lib
43
- let templatesDir = path.resolve(__dirname, '../../../../templates');
43
+ // 2. Resolve templates directory
44
+ // We need to robustly find templates whether running from source or built lib
45
+ // Strategy: Find package root by looking for package.json, then look for templates
44
46
 
45
- // Check if we are in built mode (lib structure might differ slightly depending on tsc output)
46
- // If 'bin' and 'src' are strictly separated in source, but compiled to 'lib', we need strict logic.
47
- // For now, assuming development with tsx:
48
- // bin/cli.ts calls src/cli/commands/init.ts
49
- // templates is at root.
50
- // From src/cli/commands -> ../../../templates
47
+ let currentDir = __dirname;
48
+ let packageRoot = '';
51
49
 
52
- if (!fs.existsSync(templatesDir)) {
53
- // Try checking if we are in 'lib'
54
- templatesDir = path.resolve(__dirname, '../../../templates');
50
+ // Walk up until we find package.json or hit root
51
+ for (let i = 0; i < 10; i++) {
52
+ if (fs.existsSync(path.join(currentDir, 'package.json'))) {
53
+ packageRoot = currentDir;
54
+ break;
55
+ }
56
+ const parent = path.dirname(currentDir);
57
+ if (parent === currentDir) break; // Root
58
+ currentDir = parent;
59
+ }
60
+
61
+ if (!packageRoot) {
62
+ // Fallback: try common locations relative to this file
63
+ // If in lib/src/cli/commands -> ../../../..
64
+ // If in src/cli/commands -> ../../../..
65
+ const potentialRoot = path.resolve(__dirname, '../../../../');
66
+ if (fs.existsSync(path.join(potentialRoot, 'package.json'))) {
67
+ packageRoot = potentialRoot;
68
+ }
55
69
  }
56
70
 
71
+ if (!packageRoot) {
72
+ spinner.fail(`Could not find package root from ${__dirname}`);
73
+ return;
74
+ }
75
+
76
+ const templatesDir = path.join(packageRoot, 'templates');
77
+
57
78
  if (!fs.existsSync(templatesDir)) {
58
79
  spinner.fail(`Could not find templates directory at ${templatesDir}`);
59
80
  return;
@@ -62,7 +83,13 @@ export async function initCommand(directory: string) {
62
83
  // 3. Copy templates
63
84
  spinner.text = 'Copying template files...';
64
85
  await fs.copy(templatesDir, targetDir, {
65
- filter: (src: string) => !src.includes('node_modules') && !src.includes('package.json') // Don't copy package.json if it exists there, we generate it
86
+ filter: (src: string) => {
87
+ // We only want to filter out node_modules that might be INSIDE the template directory (unlikely, but safe)
88
+ // But src path will be absolute, so it MIGHT contain node_modules if the package itself is installed in node_modules
89
+ // We should only check the relative path from templatesDir
90
+ const relativePath = path.relative(templatesDir, src);
91
+ return !relativePath.includes('node_modules') && !relativePath.includes('package.json');
92
+ }
66
93
  });
67
94
 
68
95
  // Rename _tsconfig.json to tsconfig.json