@tixyel/cli 2.7.1 → 3.0.0
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/dist/api.d.mts +128 -0
- package/dist/api.mjs +1 -0
- package/dist/index.d.mts +1 -0
- package/dist/index.mjs +115 -0
- package/dist/workspace-Dp9KM2gK.mjs +34 -0
- package/package.json +19 -14
- package/dist/api.d.ts +0 -2
- package/dist/api.js +0 -1
- package/dist/index.d.ts +0 -2
- package/dist/index.js +0 -416
- package/dist/templates/workspace.d.ts +0 -1
- package/dist/templates/workspace.js +0 -111
- package/dist/utils/watermark.d.ts +0 -7
- package/dist/utils/watermark.js +0 -71
- package/dist/widget.d.ts +0 -31
- package/dist/widget.js +0 -551
- package/dist/widget.test.d.ts +0 -1
- package/dist/widget.test.js +0 -14
- package/dist/workspace.d.ts +0 -113
- package/dist/workspace.js +0 -241
package/dist/workspace.js
DELETED
|
@@ -1,241 +0,0 @@
|
|
|
1
|
-
import { existsSync, readFileSync, unlinkSync, writeFileSync } from 'fs';
|
|
2
|
-
import { extname, resolve } from 'path';
|
|
3
|
-
import { transform } from 'esbuild';
|
|
4
|
-
const DEFAULT_WORKSPACE_CONFIG = {
|
|
5
|
-
search: {
|
|
6
|
-
maxDepth: 3,
|
|
7
|
-
ignore: ['node_modules', 'dist', '.git', '.turbo', '.vscode'],
|
|
8
|
-
},
|
|
9
|
-
dirs: {
|
|
10
|
-
entry: 'development',
|
|
11
|
-
output: 'finished',
|
|
12
|
-
compacted: 'widgetIO',
|
|
13
|
-
},
|
|
14
|
-
scaffold: [
|
|
15
|
-
{
|
|
16
|
-
name: 'development',
|
|
17
|
-
type: 'folder',
|
|
18
|
-
content: [
|
|
19
|
-
{
|
|
20
|
-
name: 'index.html',
|
|
21
|
-
type: 'file',
|
|
22
|
-
content: ``,
|
|
23
|
-
},
|
|
24
|
-
{
|
|
25
|
-
name: 'style.css',
|
|
26
|
-
type: 'file',
|
|
27
|
-
content: ``,
|
|
28
|
-
},
|
|
29
|
-
{
|
|
30
|
-
name: 'script.js',
|
|
31
|
-
type: 'file',
|
|
32
|
-
content: ``,
|
|
33
|
-
},
|
|
34
|
-
{
|
|
35
|
-
name: 'fields.json',
|
|
36
|
-
type: 'file',
|
|
37
|
-
content: '{}',
|
|
38
|
-
},
|
|
39
|
-
{
|
|
40
|
-
name: 'data.json',
|
|
41
|
-
type: 'file',
|
|
42
|
-
content: '{}',
|
|
43
|
-
},
|
|
44
|
-
],
|
|
45
|
-
},
|
|
46
|
-
{
|
|
47
|
-
name: 'finished',
|
|
48
|
-
type: 'folder',
|
|
49
|
-
},
|
|
50
|
-
{
|
|
51
|
-
name: 'widgetIO',
|
|
52
|
-
type: 'folder',
|
|
53
|
-
},
|
|
54
|
-
],
|
|
55
|
-
build: {
|
|
56
|
-
parallel: true,
|
|
57
|
-
verbose: false,
|
|
58
|
-
find: {
|
|
59
|
-
html: ['index.html'],
|
|
60
|
-
script: ['script.js'],
|
|
61
|
-
css: ['style.css'],
|
|
62
|
-
fields: ['fields.json'],
|
|
63
|
-
},
|
|
64
|
-
result: {
|
|
65
|
-
'HTML.html': 'html',
|
|
66
|
-
'SCRIPT.js': 'script',
|
|
67
|
-
'CSS.css': 'css',
|
|
68
|
-
'FIELDS.json': 'fields',
|
|
69
|
-
},
|
|
70
|
-
widgetIO: {
|
|
71
|
-
'html.txt': 'html',
|
|
72
|
-
'js.txt': 'script',
|
|
73
|
-
'css.txt': 'css',
|
|
74
|
-
'fields.txt': 'fields',
|
|
75
|
-
},
|
|
76
|
-
obfuscation: {
|
|
77
|
-
javascript: {},
|
|
78
|
-
css: {
|
|
79
|
-
removeNesting: true,
|
|
80
|
-
autoprefixer: {
|
|
81
|
-
overrideBrowserslist: ['Chrome 127'],
|
|
82
|
-
},
|
|
83
|
-
cssnano: {},
|
|
84
|
-
},
|
|
85
|
-
html: {},
|
|
86
|
-
},
|
|
87
|
-
},
|
|
88
|
-
};
|
|
89
|
-
// Helper to preserve literal keys for autocomplete in find/result
|
|
90
|
-
export function defineWorkspaceConfig(config) {
|
|
91
|
-
config.dirs = {
|
|
92
|
-
...DEFAULT_WORKSPACE_CONFIG.dirs,
|
|
93
|
-
...config.dirs,
|
|
94
|
-
};
|
|
95
|
-
config.build = {
|
|
96
|
-
...DEFAULT_WORKSPACE_CONFIG.build,
|
|
97
|
-
...config.build,
|
|
98
|
-
};
|
|
99
|
-
config.build.find = {
|
|
100
|
-
...DEFAULT_WORKSPACE_CONFIG.build.find,
|
|
101
|
-
...config.build.find,
|
|
102
|
-
};
|
|
103
|
-
config.build.result = {
|
|
104
|
-
...DEFAULT_WORKSPACE_CONFIG.build.result,
|
|
105
|
-
...config.build.result,
|
|
106
|
-
};
|
|
107
|
-
config.search = {
|
|
108
|
-
...DEFAULT_WORKSPACE_CONFIG.search,
|
|
109
|
-
...config.search,
|
|
110
|
-
};
|
|
111
|
-
config.scaffold = config.scaffold || DEFAULT_WORKSPACE_CONFIG.scaffold;
|
|
112
|
-
return config;
|
|
113
|
-
}
|
|
114
|
-
export async function resolveConfig(path) {
|
|
115
|
-
const configTs = resolve(path, 'tixyel.config.ts');
|
|
116
|
-
const configTsx = resolve(path, 'tixyel.config.tsx');
|
|
117
|
-
const configJs = resolve(path, 'tixyel.config.js');
|
|
118
|
-
const configJsx = resolve(path, 'tixyel.config.jsx');
|
|
119
|
-
const configMjs = resolve(path, 'tixyel.config.mjs');
|
|
120
|
-
let config;
|
|
121
|
-
try {
|
|
122
|
-
// Trying .mjs first (already ES module)
|
|
123
|
-
if (existsSync(configMjs)) {
|
|
124
|
-
const module = await import(`file://${configMjs}`);
|
|
125
|
-
config = module.default || module.config;
|
|
126
|
-
}
|
|
127
|
-
// Trying .js/.jsx (if package.json has type: module)
|
|
128
|
-
else if (existsSync(configJs)) {
|
|
129
|
-
const module = await import(`file://${configJs}`);
|
|
130
|
-
config = module.default || module.config;
|
|
131
|
-
}
|
|
132
|
-
else if (existsSync(configJsx)) {
|
|
133
|
-
config = await loadTsConfig(configJsx, path);
|
|
134
|
-
}
|
|
135
|
-
// Trying .ts/.tsx file (compile on-the-fly)
|
|
136
|
-
else if (existsSync(configTs)) {
|
|
137
|
-
config = await loadTsConfig(configTs, path);
|
|
138
|
-
}
|
|
139
|
-
else if (existsSync(configTsx)) {
|
|
140
|
-
config = await loadTsConfig(configTsx, path);
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
catch (error) {
|
|
144
|
-
console.warn(`⚠️ Failed to load tixyel.config: ${error}`);
|
|
145
|
-
throw error;
|
|
146
|
-
}
|
|
147
|
-
return merge(config);
|
|
148
|
-
}
|
|
149
|
-
export async function findWorkspaceRoot(startPath = process.cwd()) {
|
|
150
|
-
let currentPath = resolve(startPath);
|
|
151
|
-
// Limit search to 10 levels up to avoid infinite loops
|
|
152
|
-
for (let i = 0; i < 10; i++) {
|
|
153
|
-
const configTs = resolve(currentPath, 'tixyel.config.ts');
|
|
154
|
-
const configTsx = resolve(currentPath, 'tixyel.config.tsx');
|
|
155
|
-
const configJs = resolve(currentPath, 'tixyel.config.js');
|
|
156
|
-
const configJsx = resolve(currentPath, 'tixyel.config.jsx');
|
|
157
|
-
const configPathMjs = resolve(currentPath, 'tixyel.config.mjs');
|
|
158
|
-
if (existsSync(configTs) || existsSync(configTsx) || existsSync(configJs) || existsSync(configJsx) || existsSync(configPathMjs)) {
|
|
159
|
-
return currentPath;
|
|
160
|
-
}
|
|
161
|
-
const parentPath = resolve(currentPath, '..');
|
|
162
|
-
if (parentPath === currentPath) {
|
|
163
|
-
// Reached filesystem root
|
|
164
|
-
break;
|
|
165
|
-
}
|
|
166
|
-
currentPath = parentPath;
|
|
167
|
-
}
|
|
168
|
-
return null;
|
|
169
|
-
}
|
|
170
|
-
export async function validateWorkspace() {
|
|
171
|
-
const root = await findWorkspaceRoot();
|
|
172
|
-
if (!root) {
|
|
173
|
-
throw new Error('❌ Your workspace is not initialized. Please run `tixyel init` in your workspace root first.');
|
|
174
|
-
}
|
|
175
|
-
return root;
|
|
176
|
-
}
|
|
177
|
-
async function loadTsConfig(path, root) {
|
|
178
|
-
const temp = resolve(root, '.tixyel.config.temp.mjs');
|
|
179
|
-
const tsContent = readFileSync(path, 'utf-8');
|
|
180
|
-
const extension = extname(path).toLowerCase();
|
|
181
|
-
const loader = extension === '.tsx' ? 'tsx' : extension === '.jsx' ? 'jsx' : 'ts';
|
|
182
|
-
const { code } = await transform(tsContent, {
|
|
183
|
-
loader,
|
|
184
|
-
format: 'esm',
|
|
185
|
-
target: 'es2022',
|
|
186
|
-
...(loader === 'tsx' || loader === 'jsx' ? { jsx: 'automatic' } : {}),
|
|
187
|
-
});
|
|
188
|
-
writeFileSync(temp, code, 'utf-8');
|
|
189
|
-
try {
|
|
190
|
-
const mod = await import(`file://${temp}?t=${Date.now()}`);
|
|
191
|
-
return mod.default ?? mod.config;
|
|
192
|
-
}
|
|
193
|
-
finally {
|
|
194
|
-
try {
|
|
195
|
-
unlinkSync(temp);
|
|
196
|
-
}
|
|
197
|
-
catch { }
|
|
198
|
-
}
|
|
199
|
-
}
|
|
200
|
-
export async function loadWorkspace(path) {
|
|
201
|
-
return resolveConfig(path);
|
|
202
|
-
}
|
|
203
|
-
function merge(config) {
|
|
204
|
-
const merged = {
|
|
205
|
-
...config,
|
|
206
|
-
search: {
|
|
207
|
-
...DEFAULT_WORKSPACE_CONFIG.search,
|
|
208
|
-
...config?.search,
|
|
209
|
-
},
|
|
210
|
-
metadata: {
|
|
211
|
-
...DEFAULT_WORKSPACE_CONFIG.metadata,
|
|
212
|
-
...config?.metadata,
|
|
213
|
-
},
|
|
214
|
-
dirs: {
|
|
215
|
-
...DEFAULT_WORKSPACE_CONFIG.dirs,
|
|
216
|
-
...config?.dirs,
|
|
217
|
-
},
|
|
218
|
-
scaffold: config?.scaffold || DEFAULT_WORKSPACE_CONFIG.scaffold,
|
|
219
|
-
build: {
|
|
220
|
-
...DEFAULT_WORKSPACE_CONFIG.build,
|
|
221
|
-
...config?.build,
|
|
222
|
-
find: {
|
|
223
|
-
...DEFAULT_WORKSPACE_CONFIG.build.find,
|
|
224
|
-
...config?.build?.find,
|
|
225
|
-
},
|
|
226
|
-
result: {
|
|
227
|
-
...DEFAULT_WORKSPACE_CONFIG.build.result,
|
|
228
|
-
...config?.build?.result,
|
|
229
|
-
},
|
|
230
|
-
widgetIO: {
|
|
231
|
-
...DEFAULT_WORKSPACE_CONFIG.build.widgetIO,
|
|
232
|
-
...config?.build?.widgetIO,
|
|
233
|
-
},
|
|
234
|
-
obfuscation: {
|
|
235
|
-
...DEFAULT_WORKSPACE_CONFIG.build.obfuscation,
|
|
236
|
-
...config?.build?.obfuscation,
|
|
237
|
-
},
|
|
238
|
-
},
|
|
239
|
-
};
|
|
240
|
-
return merged;
|
|
241
|
-
}
|