@deneb-ui/cli 2.0.22 → 2.0.24
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/README.md +62 -114
- package/bin/index.js +55 -12
- package/package.json +25 -5
- package/src/arc/__fixtures__/next-app-basic/package.json +10 -0
- package/src/arc/__fixtures__/next-app-basic/src/app/globals.css +3 -0
- package/src/arc/__fixtures__/next-app-basic/src/app/layout.tsx +9 -0
- package/src/arc/__fixtures__/next-app-basic/src/app/page.tsx +11 -0
- package/src/arc/__fixtures__/next-app-basic/src/components/Header.tsx +13 -0
- package/src/arc/__fixtures__/next-app-basic/src/components/Hero.tsx +12 -0
- package/src/arc/__fixtures__/next-app-basic/src/components/PromoBanner.tsx +10 -0
- package/src/arc/__fixtures__/next-app-basic/tsconfig.json +12 -0
- package/src/arc/__fixtures__/next-app-storefront/components.json +14 -0
- package/src/arc/__fixtures__/next-app-storefront/package.json +22 -0
- package/src/arc/__fixtures__/next-app-storefront/src/app/about/page.tsx +13 -0
- package/src/arc/__fixtures__/next-app-storefront/src/app/globals.css +5 -0
- package/src/arc/__fixtures__/next-app-storefront/src/app/layout.tsx +19 -0
- package/src/arc/__fixtures__/next-app-storefront/src/app/page.tsx +13 -0
- package/src/arc/__fixtures__/next-app-storefront/src/components/Features.tsx +31 -0
- package/src/arc/__fixtures__/next-app-storefront/src/components/Hero.tsx +45 -0
- package/src/arc/__fixtures__/next-app-storefront/src/components/ProductGrid.tsx +49 -0
- package/src/arc/__fixtures__/next-app-storefront/src/components/SiteFooter.tsx +22 -0
- package/src/arc/__fixtures__/next-app-storefront/src/components/SiteHeader.tsx +21 -0
- package/src/arc/__fixtures__/next-app-storefront/src/components/ui/button.tsx +36 -0
- package/src/arc/__fixtures__/next-app-storefront/tsconfig.json +15 -0
- package/src/arc/__fixtures__/next-pages-basic/package.json +10 -0
- package/src/arc/__fixtures__/next-pages-basic/pages/_app.jsx +5 -0
- package/src/arc/__fixtures__/next-pages-basic/pages/contact.jsx +9 -0
- package/src/arc/__fixtures__/next-pages-basic/pages/index.jsx +11 -0
- package/src/arc/__fixtures__/next-pages-basic/styles/globals.css +9 -0
- package/src/arc/__tests__/arc.test.cjs +498 -0
- package/src/arc/adapters.cjs +184 -0
- package/src/arc/ast.cjs +339 -0
- package/src/arc/field-paths.cjs +165 -0
- package/src/arc/fivora-contract.cjs +521 -0
- package/src/arc/font-plan.cjs +65 -0
- package/src/arc/fs-utils.cjs +170 -0
- package/src/arc/index.cjs +627 -0
- package/src/arc/learning.cjs +211 -0
- package/src/arc/manifest.cjs +438 -0
- package/src/arc/next-config.cjs +279 -0
- package/src/arc/planner.cjs +252 -0
- package/src/arc/printer.cjs +183 -0
- package/src/arc/recipes-v2.cjs +49 -0
- package/src/arc/scanner.cjs +613 -0
- package/src/arc/semantic.cjs +651 -0
- package/src/arc/style-candidates.cjs +72 -0
- package/src/arc/transformer.cjs +677 -0
- package/src/arc/validator.cjs +173 -0
- package/src/arc/version.cjs +22 -0
- package/src/common/style-validation.ts +30 -0
- package/src/tools/deneb-fonts.cjs +114 -0
- package/src/tools/template-preview-focus-bridge.cjs +3 -3
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const fs = require('fs');
|
|
4
|
+
const path = require('path');
|
|
5
|
+
const os = require('os');
|
|
6
|
+
const crypto = require('crypto');
|
|
7
|
+
|
|
8
|
+
const IGNORE_DIRS = new Set([
|
|
9
|
+
'.git',
|
|
10
|
+
'.next',
|
|
11
|
+
'.turbo',
|
|
12
|
+
'.cache',
|
|
13
|
+
'.npm',
|
|
14
|
+
'.pnpm-store',
|
|
15
|
+
'.vercel',
|
|
16
|
+
'.output',
|
|
17
|
+
'.deneb',
|
|
18
|
+
'node_modules',
|
|
19
|
+
'out',
|
|
20
|
+
'dist',
|
|
21
|
+
'build',
|
|
22
|
+
'coverage',
|
|
23
|
+
'__macosx',
|
|
24
|
+
]);
|
|
25
|
+
|
|
26
|
+
function isIgnoredDirName(name) {
|
|
27
|
+
const lower = String(name || '').toLowerCase();
|
|
28
|
+
if (IGNORE_DIRS.has(lower)) return true;
|
|
29
|
+
if (lower.startsWith('.deneb-backup')) return true;
|
|
30
|
+
return false;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function isSecretFile(filename) {
|
|
34
|
+
const lower = String(filename || '').toLowerCase();
|
|
35
|
+
return (
|
|
36
|
+
lower.startsWith('.env') ||
|
|
37
|
+
lower.endsWith('.pem') ||
|
|
38
|
+
lower.endsWith('.key') ||
|
|
39
|
+
lower === 'id_rsa' ||
|
|
40
|
+
lower === 'credentials.json' ||
|
|
41
|
+
lower === '.npmrc'
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
function isSourceFile(filename) {
|
|
46
|
+
return /\.(tsx|jsx|ts|js|mjs|cjs)$/.test(filename) && !filename.endsWith('.d.ts');
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
function isJsxFile(filename) {
|
|
50
|
+
return /\.(tsx|jsx)$/.test(filename);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
function readJsonSafe(filePath, fallback = null) {
|
|
54
|
+
try {
|
|
55
|
+
if (!fs.existsSync(filePath)) return fallback;
|
|
56
|
+
return JSON.parse(fs.readFileSync(filePath, 'utf8'));
|
|
57
|
+
} catch {
|
|
58
|
+
return fallback;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
function writeJson(filePath, value) {
|
|
63
|
+
fs.mkdirSync(path.dirname(filePath), { recursive: true });
|
|
64
|
+
fs.writeFileSync(filePath, JSON.stringify(value, null, 2) + '\n', 'utf8');
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
function sha1(value) {
|
|
68
|
+
return crypto.createHash('sha1').update(String(value)).digest('hex');
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
function shortHash(value, length = 12) {
|
|
72
|
+
return sha1(value).slice(0, length);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
function walkFiles(dir, options = {}, acc = []) {
|
|
76
|
+
if (!dir || !fs.existsSync(dir)) return acc;
|
|
77
|
+
const include = options.include || (() => true);
|
|
78
|
+
const follow = options.followDirectories !== false;
|
|
79
|
+
|
|
80
|
+
let entries;
|
|
81
|
+
try {
|
|
82
|
+
entries = fs.readdirSync(dir, { withFileTypes: true });
|
|
83
|
+
} catch {
|
|
84
|
+
return acc;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
for (const entry of entries) {
|
|
88
|
+
const fullPath = path.join(dir, entry.name);
|
|
89
|
+
if (entry.isDirectory()) {
|
|
90
|
+
if (!follow || isIgnoredDirName(entry.name)) continue;
|
|
91
|
+
walkFiles(fullPath, options, acc);
|
|
92
|
+
} else if (entry.isFile()) {
|
|
93
|
+
if (isSecretFile(entry.name)) continue;
|
|
94
|
+
if (include(fullPath, entry.name)) acc.push(fullPath);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
return acc;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
function detectPackageManager(projectDir) {
|
|
101
|
+
if (fs.existsSync(path.join(projectDir, 'bun.lock')) || fs.existsSync(path.join(projectDir, 'bun.lockb'))) {
|
|
102
|
+
return 'bun';
|
|
103
|
+
}
|
|
104
|
+
if (fs.existsSync(path.join(projectDir, 'pnpm-lock.yaml'))) return 'pnpm';
|
|
105
|
+
if (fs.existsSync(path.join(projectDir, 'yarn.lock'))) return 'yarn';
|
|
106
|
+
if (fs.existsSync(path.join(projectDir, 'package-lock.json'))) return 'npm';
|
|
107
|
+
return 'npm';
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
function findFirstExisting(paths) {
|
|
111
|
+
for (const candidate of paths) {
|
|
112
|
+
if (candidate && fs.existsSync(candidate)) return candidate;
|
|
113
|
+
}
|
|
114
|
+
return null;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
function rel(projectDir, filePath) {
|
|
118
|
+
return path.relative(projectDir, filePath).replace(/\\/g, '/');
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
function homeDenebDir() {
|
|
122
|
+
return path.join(os.homedir(), '.deneb');
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
function copyFilePreserve(src, dest) {
|
|
126
|
+
fs.mkdirSync(path.dirname(dest), { recursive: true });
|
|
127
|
+
fs.copyFileSync(src, dest);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
function deepMerge(target, source) {
|
|
131
|
+
if (!isPlainObject(source)) return target;
|
|
132
|
+
const output = isPlainObject(target) ? { ...target } : {};
|
|
133
|
+
for (const [key, value] of Object.entries(source)) {
|
|
134
|
+
if (isPlainObject(value) && isPlainObject(output[key])) {
|
|
135
|
+
output[key] = deepMerge(output[key], value);
|
|
136
|
+
} else if (output[key] === undefined) {
|
|
137
|
+
output[key] = value;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
return output;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
function isPlainObject(value) {
|
|
144
|
+
return Boolean(value) && typeof value === 'object' && !Array.isArray(value);
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
function toPosix(filePath) {
|
|
148
|
+
return String(filePath || '').replace(/\\/g, '/');
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
module.exports = {
|
|
152
|
+
IGNORE_DIRS,
|
|
153
|
+
isIgnoredDirName,
|
|
154
|
+
isSecretFile,
|
|
155
|
+
isSourceFile,
|
|
156
|
+
isJsxFile,
|
|
157
|
+
readJsonSafe,
|
|
158
|
+
writeJson,
|
|
159
|
+
sha1,
|
|
160
|
+
shortHash,
|
|
161
|
+
walkFiles,
|
|
162
|
+
detectPackageManager,
|
|
163
|
+
findFirstExisting,
|
|
164
|
+
rel,
|
|
165
|
+
homeDenebDir,
|
|
166
|
+
copyFilePreserve,
|
|
167
|
+
deepMerge,
|
|
168
|
+
isPlainObject,
|
|
169
|
+
toPosix,
|
|
170
|
+
};
|