create-portfoliable 1.2.12 → 1.2.14

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.
@@ -26,6 +26,7 @@ import {
26
26
  isInteractiveTerminal,
27
27
  readProjectUiPreferences
28
28
  } from '../scripts/terminal-ui.mjs';
29
+ import { resolveConsumerRuntimeAliases } from '../scripts/consumer-runtime-aliases.mjs';
29
30
 
30
31
  // MARK: TERMINAL STYLES
31
32
  // ANSI color code used for success-status text.
@@ -562,8 +563,13 @@ async function runDevServer(flags, options = {}) {
562
563
  process.env.PORTFOLIABLE_PHP_API_PROXY = phpRuntime.proxyTarget;
563
564
  }
564
565
 
566
+ const runtimeAliases = resolveConsumerRuntimeAliases(process.cwd());
567
+
565
568
  // Creates Vite development server instance.
566
569
  const server = await createServer({
570
+ resolve: runtimeAliases.length > 0
571
+ ? { alias: runtimeAliases }
572
+ : undefined,
567
573
  optimizeDeps: {
568
574
  exclude: ['create-portfoliable']
569
575
  },
@@ -642,7 +648,10 @@ async function runBuild() {
642
648
  printRailSegment();
643
649
  printRailSegment({ dot: true, label: `${cyan}${bold}Starting build...${reset}` });
644
650
  console.log(`${cyan}${bold}Building Portfoliable...${reset}`);
645
- await viteBuild();
651
+ const runtimeAliases = resolveConsumerRuntimeAliases(process.cwd());
652
+ await viteBuild(runtimeAliases.length > 0
653
+ ? { resolve: { alias: runtimeAliases } }
654
+ : undefined);
646
655
  console.log(`${green}Build complete.${reset}`);
647
656
  printRailSegment({ dot: true, label: `${green}${bold}Build complete.${reset}` });
648
657
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-portfoliable",
3
- "version": "1.2.12",
3
+ "version": "1.2.14",
4
4
  "description": "Unified Portfoliable package with initializer and runtime CLI",
5
5
  "private": false,
6
6
  "type": "module",
@@ -0,0 +1,41 @@
1
+ // File: scripts/consumer-runtime-aliases.mjs
2
+ // Purpose: Resolve consumer-local runtime aliases that override template defaults when files exist.
3
+
4
+ import fs from 'node:fs';
5
+ import path from 'node:path';
6
+
7
+ const TEMPLATE_TO_CONSUMER_TARGETS = [
8
+ ['../templates/src/cases/index.js', 'src/cases/index.js'],
9
+ ['../templates/src/content/about/ABOUTME.md', 'src/content/about/ABOUTME.md'],
10
+ ['../templates/configs/portfoliable.design.config.js', 'configs/portfoliable.design.config.js'],
11
+ ['../templates/configs/portfoliable.a11y.config.js', 'configs/portfoliable.a11y.config.js'],
12
+ ['../templates/configs/i18n/i18n.config.js', 'configs/i18n/i18n.config.js'],
13
+ ['../templates/configs/i18n/i18n.labels.js', 'configs/i18n/i18n.labels.js']
14
+ ];
15
+
16
+ // Builds Vite resolve.alias entries for consumer files that are present in the current project.
17
+ export function resolveConsumerRuntimeAliases(projectRoot = process.cwd()) {
18
+ const aliases = [];
19
+
20
+ for (const [templateSpecifier, consumerRelativePath] of TEMPLATE_TO_CONSUMER_TARGETS) {
21
+ const consumerAbsolutePath = path.resolve(projectRoot, consumerRelativePath);
22
+ if (!fs.existsSync(consumerAbsolutePath)) {
23
+ continue;
24
+ }
25
+
26
+ aliases.push({
27
+ find: templateSpecifier,
28
+ replacement: consumerAbsolutePath
29
+ });
30
+
31
+ // Keep raw markdown imports in sync with consumer content overrides.
32
+ if (templateSpecifier.endsWith('.md')) {
33
+ aliases.push({
34
+ find: `${templateSpecifier}?raw`,
35
+ replacement: `${consumerAbsolutePath}?raw`
36
+ });
37
+ }
38
+ }
39
+
40
+ return aliases;
41
+ }
package/vite.config.js CHANGED
@@ -6,6 +6,7 @@
6
6
  import fs from 'node:fs';
7
7
  import path from 'node:path';
8
8
  import { defineConfig } from 'vite';
9
+ import { resolveConsumerRuntimeAliases } from './scripts/consumer-runtime-aliases.mjs';
9
10
 
10
11
  // Detects when @portfoliablejs/valence is installed as a local symlink.
11
12
  function isLocalLinkedValence() {
@@ -63,6 +64,7 @@ function getManualChunk(id) {
63
64
  export default defineConfig(({ command }) => {
64
65
  const usingLocalValence = isLocalLinkedValence();
65
66
  const phpApiProxy = String(process.env.PORTFOLIABLE_PHP_API_PROXY || '').trim();
67
+ const runtimeAliases = resolveConsumerRuntimeAliases(process.cwd());
66
68
 
67
69
  const serverConfig = (command === 'serve' && usingLocalValence)
68
70
  ? {
@@ -88,6 +90,10 @@ export default defineConfig(({ command }) => {
88
90
  }
89
91
 
90
92
  return {
93
+ resolve: runtimeAliases.length > 0
94
+ ? { alias: runtimeAliases }
95
+ : undefined,
96
+
91
97
  // In local-link mode, avoid prebundling Valence so edits in the linked package
92
98
  // are reflected immediately during development.
93
99
  optimizeDeps: (command === 'serve' && usingLocalValence)