@nqlib/nqui 0.1.0 → 0.1.2

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": "@nqlib/nqui",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "description": "A React component library with enhanced UI components and developer tools",
5
5
  "type": "module",
6
6
  "main": "./dist/nqui.cjs.js",
@@ -19,10 +19,15 @@ const __dirname = dirname(__filename);
19
19
  const projectRoot = resolve(__dirname, '..');
20
20
  const indexCssPath = join(projectRoot, 'src', 'index.css');
21
21
  const colorsCssPath = join(projectRoot, 'src', 'styles', 'colors.css');
22
+ const distStylesPath = join(projectRoot, 'dist', 'styles.css');
22
23
  const examplesDir = join(projectRoot, 'scripts', 'examples');
23
24
 
25
+ // Check if we're in a published package (source files don't exist, but dist/styles.css does)
26
+ const isPublishedPackage = !existsSync(indexCssPath) && existsSync(distStylesPath);
27
+
24
28
  // Function to find actual CSS file location for Next.js
25
29
  function findNextJsCssFile() {
30
+ // Check for existing CSS files first (prioritize globals.css)
26
31
  const possiblePaths = [
27
32
  'src/app/globals.css',
28
33
  'app/globals.css',
@@ -37,10 +42,20 @@ function findNextJsCssFile() {
37
42
  }
38
43
  }
39
44
 
40
- // Default fallback based on directory structure
45
+ // If no CSS file exists, determine based on directory structure
46
+ // Check for src/app/ first (Next.js with src directory)
41
47
  if (existsSync(join(process.cwd(), 'src', 'app'))) {
42
48
  return 'src/app/globals.css';
43
49
  }
50
+ // Check for app/ (Next.js without src directory)
51
+ if (existsSync(join(process.cwd(), 'app'))) {
52
+ return 'app/globals.css';
53
+ }
54
+
55
+ // Final fallback: prefer src/app/ if src exists, otherwise app/
56
+ if (existsSync(join(process.cwd(), 'src'))) {
57
+ return 'src/app/globals.css';
58
+ }
44
59
  return 'app/globals.css';
45
60
  }
46
61
 
@@ -80,8 +95,11 @@ function getDefaultPath(projectType) {
80
95
 
81
96
  function findProjectType() {
82
97
  // Check for framework-specific files
98
+ // Next.js: check for next.config.js/ts OR app directory OR src/app directory
83
99
  if (existsSync(join(process.cwd(), 'next.config.js')) ||
84
- existsSync(join(process.cwd(), 'next.config.ts'))) {
100
+ existsSync(join(process.cwd(), 'next.config.ts')) ||
101
+ existsSync(join(process.cwd(), 'app')) ||
102
+ existsSync(join(process.cwd(), 'src', 'app'))) {
85
103
  return 'nextjs';
86
104
  }
87
105
  if (existsSync(join(process.cwd(), 'vite.config.js')) ||
@@ -98,7 +116,15 @@ function findProjectType() {
98
116
  }
99
117
 
100
118
  function extractStandaloneCSS() {
101
- // Read the source CSS files
119
+ // If we're in a published package, use dist/styles.css directly
120
+ if (isPublishedPackage) {
121
+ if (!existsSync(distStylesPath)) {
122
+ throw new Error(`Published package CSS file not found: ${distStylesPath}`);
123
+ }
124
+ return readFileSync(distStylesPath, 'utf-8');
125
+ }
126
+
127
+ // Read the source CSS files (for local development)
102
128
  if (!existsSync(indexCssPath)) {
103
129
  throw new Error(`Source CSS file not found: ${indexCssPath}`);
104
130
  }
@@ -405,7 +431,19 @@ async function copyNextJsExamples() {
405
431
 
406
432
  async function main() {
407
433
  const args = process.argv.slice(2);
408
- const targetPath = args[0];
434
+ let targetPath = args[0];
435
+
436
+ // Ignore command names that might be passed as arguments when called via npx
437
+ // Common command names: 'init-css', 'nqui', 'nqui-init-css'
438
+ if (targetPath === 'init-css' || targetPath === 'nqui' || targetPath === 'nqui-init-css') {
439
+ targetPath = args[1] || undefined;
440
+ }
441
+
442
+ // If targetPath doesn't look like a file path (no extension, no directory separators), ignore it
443
+ // This prevents treating command names or other non-path arguments as file paths
444
+ if (targetPath && !targetPath.includes('.') && !targetPath.includes('/') && !targetPath.includes('\\')) {
445
+ targetPath = undefined;
446
+ }
409
447
 
410
448
  try {
411
449
  // Extract standalone CSS