portosaurus 0.16.3 → 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;
@@ -19,13 +19,22 @@ export function getCssVar(varName) {
19
19
  // We need to handle both dev (src/css) and prod (lib/src/css) structures
20
20
  // When running in lib: __dirname is .../lib/src/utils
21
21
  // We want .../lib/src/css
22
- const cssDir = path.resolve(__dirname, '../css');
23
- const srcCssDir = path.resolve(__dirname, '../../src/css'); // Fallback for some dev setups
22
+ const cssDir = path.resolve(__dirname, '../css'); // ../css
23
+ const srcCssDir = path.resolve(__dirname, '../../src/css'); // ../../src/css (if inside lib/src/utils -> lib/src/css ?)
24
+ // Real structure in node_modules:
25
+ // lib/src/utils/cssUtils.js
26
+ // src/css/custom.css
27
+ //
28
+ // Relative path from lib/src/utils to src/css is:
29
+ // ../../../src/css
30
+ const installedCssDir = path.resolve(__dirname, '../../../src/css');
24
31
  const potentialFiles = [
25
32
  path.join(cssDir, 'custom.css'),
26
33
  path.join(cssDir, 'catppuccin.css'),
27
34
  path.join(srcCssDir, 'custom.css'),
28
- path.join(srcCssDir, 'catppuccin.css')
35
+ path.join(srcCssDir, 'catppuccin.css'),
36
+ path.join(installedCssDir, 'custom.css'),
37
+ path.join(installedCssDir, 'catppuccin.css')
29
38
  ];
30
39
  const cssFiles = potentialFiles.filter(f => fs.existsSync(f));
31
40
  if (cssFiles.length === 0) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "portosaurus",
3
- "version": "0.16.3",
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;
@@ -26,14 +26,25 @@ export function getCssVar(varName: string): string {
26
26
  // When running in lib: __dirname is .../lib/src/utils
27
27
  // We want .../lib/src/css
28
28
 
29
- const cssDir = path.resolve(__dirname, '../css');
30
- const srcCssDir = path.resolve(__dirname, '../../src/css'); // Fallback for some dev setups
29
+ const cssDir = path.resolve(__dirname, '../css'); // ../css
30
+ const srcCssDir = path.resolve(__dirname, '../../src/css'); // ../../src/css (if inside lib/src/utils -> lib/src/css ?)
31
+
32
+ // Real structure in node_modules:
33
+ // lib/src/utils/cssUtils.js
34
+ // src/css/custom.css
35
+ //
36
+ // Relative path from lib/src/utils to src/css is:
37
+ // ../../../src/css
38
+
39
+ const installedCssDir = path.resolve(__dirname, '../../../src/css');
31
40
 
32
41
  const potentialFiles = [
33
42
  path.join(cssDir, 'custom.css'),
34
43
  path.join(cssDir, 'catppuccin.css'),
35
44
  path.join(srcCssDir, 'custom.css'),
36
- path.join(srcCssDir, 'catppuccin.css')
45
+ path.join(srcCssDir, 'catppuccin.css'),
46
+ path.join(installedCssDir, 'custom.css'),
47
+ path.join(installedCssDir, 'catppuccin.css')
37
48
  ];
38
49
 
39
50
  const cssFiles = potentialFiles.filter(f => fs.existsSync(f));