portosaurus 0.16.4 → 0.16.5

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;
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;
48
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;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "portosaurus",
3
- "version": "0.16.4",
3
+ "version": "0.16.5",
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;