portosaurus 1.16.3 → 1.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "portosaurus",
3
- "version": "1.16.3",
3
+ "version": "1.16.5",
4
4
  "author": "soymadip",
5
5
  "license": "GPL-3.0-only",
6
6
  "description": "Complete portfolio cum personal website solution for your digital personality.",
@@ -21,6 +21,10 @@
21
21
  "blog"
22
22
  ],
23
23
  "type": "module",
24
+ "imports": {
25
+ "#config/*": "./src/config/*",
26
+ "#internal/*": "./src/internal/src/*"
27
+ },
24
28
  "bin": {
25
29
  "portosaurus": "bin/portosaurus.js"
26
30
  },
@@ -1,8 +1,9 @@
1
- const fs = require('fs');
2
- const path = require('path');
3
- const React = require('react');
4
- const ReactDOMServer = require('react-dom/server');
5
- const { iconMap } = require('../config/iconMappings');
1
+ const fs = require("fs");
2
+ const path = require("path");
3
+ const React = require("react");
4
+ const ReactDOMServer = require("react-dom/server");
5
+
6
+ const { iconMap } = require("../config/iconMappings");
6
7
 
7
8
  /// AI Generated
8
9
 
@@ -13,8 +14,8 @@ const { iconMap } = require('../config/iconMappings');
13
14
  */
14
15
  function requireDynamicIcon(iconPath) {
15
16
  try {
16
- const [packageName, iconName] = iconPath.split('/');
17
-
17
+ const [packageName, iconName] = iconPath.split("/");
18
+
18
19
  if (packageName && iconName) {
19
20
  const iconPackage = require(`react-icons/${packageName}`);
20
21
  return iconPackage[iconName];
@@ -33,21 +34,20 @@ function requireDynamicIcon(iconPath) {
33
34
  * @returns {string} Clean SVG content
34
35
  */
35
36
  function cleanSvgString(svgString, color) {
36
-
37
37
  // Remove React-specific attributes and add proper XML declaration
38
38
  let cleanedSvg = svgString
39
- .replace(/<!--.*?-->/g, '') // Remove comments
39
+ .replace(/<!--.*?-->/g, "") // Remove comments
40
40
  .replace(/stroke="currentColor"/g, `stroke="${color}"`)
41
41
  .replace(/fill="currentColor"/g, `fill="${color}"`);
42
42
 
43
43
  // Add XML declaration if not present
44
- if (!cleanedSvg.includes('<?xml')) {
44
+ if (!cleanedSvg.includes("<?xml")) {
45
45
  cleanedSvg = `<?xml version="1.0" encoding="UTF-8" standalone="no"?>\n${cleanedSvg}`;
46
46
  }
47
47
 
48
48
  // Add viewBox if not present
49
- if (!cleanedSvg.includes('viewBox')) {
50
- cleanedSvg = cleanedSvg.replace('<svg', '<svg viewBox="0 0 24 24"');
49
+ if (!cleanedSvg.includes("viewBox")) {
50
+ cleanedSvg = cleanedSvg.replace("<svg", '<svg viewBox="0 0 24 24"');
51
51
  }
52
52
 
53
53
  return cleanedSvg;
@@ -55,7 +55,7 @@ function cleanSvgString(svgString, color) {
55
55
 
56
56
  /**
57
57
  * Extracts SVG content from a React Icon component and saves it to a file
58
- *
58
+ *
59
59
  * @param {React.ComponentType|string} icon - Icon component, name from iconMap, or path like "ai/AiFillAlert"
60
60
  * @param {string} outputPath - Path to save the SVG file, defaults to static/img/svg if not provided
61
61
  * @param {object} options - Additional options
@@ -66,17 +66,22 @@ function cleanSvgString(svgString, color) {
66
66
  * @returns {string} The path to the saved SVG file
67
67
  */
68
68
  function extractSvg(icon, outputPath = null, options = {}) {
69
-
70
69
  // Default output path
71
70
  if (!outputPath) {
72
- outputPath = path.join(path.resolve(__dirname, '../..'), 'static', 'img', 'svg');
71
+ outputPath = path.join(
72
+ path.resolve(__dirname, "../.."),
73
+ "static",
74
+ "img",
75
+ "svg",
76
+ );
73
77
  }
74
78
 
75
79
  // Ensure the base output directory exists
76
- const baseOutputDir = typeof outputPath === 'string' && !path.extname(outputPath)
77
- ? outputPath
78
- : path.dirname(outputPath);
79
-
80
+ const baseOutputDir =
81
+ typeof outputPath === "string" && !path.extname(outputPath)
82
+ ? outputPath
83
+ : path.dirname(outputPath);
84
+
80
85
  if (!fs.existsSync(baseOutputDir)) {
81
86
  fs.mkdirSync(baseOutputDir, { recursive: true });
82
87
  console.log(`[INFO] Created directory: ${baseOutputDir}`);
@@ -85,74 +90,75 @@ function extractSvg(icon, outputPath = null, options = {}) {
85
90
  // Resolve icon component
86
91
  let IconComponent = icon;
87
92
  let iconIdentifier = null;
88
-
89
- if (typeof icon === 'string') {
90
-
91
- if (icon.includes('/')) {
92
93
 
94
+ if (typeof icon === "string") {
95
+ if (icon.includes("/")) {
93
96
  // ("ai/AiFillAlert")
94
97
  IconComponent = requireDynamicIcon(icon);
95
- iconIdentifier = icon.split('/')[1];
96
-
98
+ iconIdentifier = icon.split("/")[1];
97
99
  } else {
98
-
99
100
  // Icon from the iconMap
100
101
  IconComponent = iconMap[icon.toLowerCase()]?.icon;
101
102
  iconIdentifier = icon;
102
103
  }
103
-
104
+
104
105
  if (!IconComponent) {
105
106
  throw new Error(`Icon "${icon}" could not be resolved`);
106
107
  }
107
-
108
+
108
109
  // Use identifier if iconName not specified
109
110
  if (!options.iconName && iconIdentifier) {
110
111
  options.iconName = iconIdentifier;
111
112
  }
112
113
  }
113
-
114
- const { color = 'white', size = 24, filename = null, iconName = null } = options;
115
-
114
+
115
+ const {
116
+ color = "white",
117
+ size = 24,
118
+ filename = null,
119
+ iconName = null,
120
+ } = options;
121
+
116
122
  // Determine final output path
117
123
  const pathStats = fs.existsSync(outputPath) ? fs.statSync(outputPath) : null;
118
124
  const isDirectory = pathStats ? pathStats.isDirectory() : false;
119
-
125
+
120
126
  if (isDirectory || filename) {
121
127
  const baseDir = isDirectory ? outputPath : path.dirname(outputPath);
122
-
128
+
123
129
  // Create directory if needed
124
130
  if (!fs.existsSync(baseDir)) {
125
131
  fs.mkdirSync(baseDir, { recursive: true });
126
132
  }
127
-
133
+
128
134
  // Generate filename if not provided
129
135
  const componentName = iconName || IconComponent.name;
130
136
  const finalFilename = filename || `icon-${componentName}.svg`;
131
137
  outputPath = path.join(baseDir, finalFilename);
132
138
  }
133
-
139
+
134
140
  // Create and render the icon
135
- const element = React.createElement(IconComponent, {
136
- color,
141
+ const element = React.createElement(IconComponent, {
142
+ color,
137
143
  size,
138
- style: { color }
144
+ style: { color },
139
145
  });
140
-
146
+
141
147
  // Render the React element to an HTML string and clean it
142
148
  const svgString = ReactDOMServer.renderToStaticMarkup(element);
143
149
  const cleanedSvg = cleanSvgString(svgString, color);
144
-
150
+
145
151
  // Ensure final output path exists
146
152
  const finalDir = path.dirname(outputPath);
147
153
 
148
154
  if (!fs.existsSync(finalDir)) {
149
155
  fs.mkdirSync(finalDir, { recursive: true });
150
156
  }
151
-
157
+
152
158
  // Write to file
153
159
  fs.writeFileSync(outputPath, cleanedSvg);
154
160
  console.log(`[INFO] Generated SVG icon: ${outputPath}`);
155
-
161
+
156
162
  return outputPath;
157
163
  }
158
164
 
@@ -1,28 +1,20 @@
1
1
  import fs from "fs";
2
- import { createRequire } from "module";
2
+
3
3
  import path from "path";
4
4
  import { fileURLToPath } from "url";
5
5
 
6
- const require = createRequire(import.meta.url);
7
-
8
6
  const __dirname = path.dirname(fileURLToPath(import.meta.url));
9
7
  const packagePath = path.resolve(__dirname, "../../");
10
8
  const internalUtils = path.resolve(packagePath, "src/internal/src/utils");
11
9
  const packageConfig = path.resolve(packagePath, "src/config");
12
10
  const packageCss = path.resolve(packagePath, "src/internal/src/css");
13
11
 
14
- const { catppuccinMocha, catppuccinLatte } = require(
15
- path.resolve(packageConfig, "prism.js"),
16
- );
17
- const { appVersion } = require("./appVersion.js");
18
- const { iconMap } = require(path.resolve(packageConfig, "iconMappings.js"));
19
- const { metaTags } = require(path.resolve(packageConfig, "metaTags.js"));
20
- const { useEnabled } = require(
21
- path.resolve(internalUtils, "filterEnabledItems.js"),
22
- );
23
- const { downloadImage } = require(
24
- path.resolve(internalUtils, "imageDownloader.js"),
25
- );
12
+ import { catppuccinMocha, catppuccinLatte } from "#config/prism.js";
13
+ import { appVersion } from "./appVersion.js";
14
+ import { iconMap } from "#config/iconMappings.js";
15
+ import { metaTags } from "#config/metaTags.js";
16
+ import { useEnabled } from "#internal/utils/filterEnabledItems.js";
17
+ import { downloadImage } from "#internal/utils/imageDownloader.js";
26
18
 
27
19
  /**
28
20
  * Resolves the site URL based on config value and environment.
@@ -299,10 +291,10 @@ export function createDocuConf(userConfig, projectRoot = process.cwd()) {
299
291
  }),
300
292
 
301
293
  plugins: [
302
- // require.resolve(`${internalUtils}/generateFavicon.js`),
303
- require.resolve(`${internalUtils}/generateRobotsTxt.js`),
294
+ // path.resolve(internalUtils, "generateFavicon.js"),
295
+ path.resolve(internalUtils, "generateRobotsTxt.js"),
304
296
  [
305
- require.resolve("@easyops-cn/docusaurus-search-local"),
297
+ "@easyops-cn/docusaurus-search-local",
306
298
  {
307
299
  hashed: true,
308
300
  indexDocs: true,