@webmate-studio/cli 0.2.25 → 0.3.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/bin/wm.mjs +1 -1
- package/package.json +2 -2
- package/src/commands/generate.js +31 -8
- package/src/commands/init.js +36 -9
- package/src/commands/prop.js +21 -0
package/bin/wm.mjs
CHANGED
|
@@ -54,7 +54,7 @@ program
|
|
|
54
54
|
program
|
|
55
55
|
.command('dev')
|
|
56
56
|
.description('Start development server with live preview')
|
|
57
|
-
.option('-p, --port <port>', 'Port to run on', '
|
|
57
|
+
.option('-p, --port <port>', 'Port to run on', '3030')
|
|
58
58
|
.option('-o, --open', 'Open browser automatically')
|
|
59
59
|
.action(devCommand);
|
|
60
60
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webmate-studio/cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Webmate Studio CLI - Build and manage your Webmate components",
|
|
6
6
|
"keywords": [
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
"@inquirer/prompts": "^5.0.0",
|
|
34
34
|
"@webmate-studio/builder": "^0.1.11",
|
|
35
35
|
"@webmate-studio/core": "^0.1.5",
|
|
36
|
-
"@webmate-studio/preview": "^0.1.
|
|
36
|
+
"@webmate-studio/preview": "^0.1.13",
|
|
37
37
|
"alpinejs": "^3.15.0",
|
|
38
38
|
"commander": "^11.0.0",
|
|
39
39
|
"esbuild": "^0.19.0",
|
package/src/commands/generate.js
CHANGED
|
@@ -2,7 +2,7 @@ import fs from 'fs/promises';
|
|
|
2
2
|
import path from 'path';
|
|
3
3
|
import { input, select, confirm } from '@inquirer/prompts';
|
|
4
4
|
import pc from 'picocolors';
|
|
5
|
-
import { loadConfig } from '
|
|
5
|
+
import { loadConfig, generateUUID } from '@webmate-studio/core';
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* Generate a new component or island
|
|
@@ -341,8 +341,8 @@ async function generateDirectoryComponent(componentDir, name, options, config =
|
|
|
341
341
|
|
|
342
342
|
// Create component.json (metadata + props + islands config)
|
|
343
343
|
const componentJson = {
|
|
344
|
-
|
|
345
|
-
|
|
344
|
+
id: generateUUID(),
|
|
345
|
+
displayName: name,
|
|
346
346
|
description,
|
|
347
347
|
category
|
|
348
348
|
};
|
|
@@ -377,17 +377,25 @@ async function generateDirectoryComponent(componentDir, name, options, config =
|
|
|
377
377
|
let exampleHtml = '';
|
|
378
378
|
|
|
379
379
|
if (islandFramework) {
|
|
380
|
-
// Island component: demonstriere title prop
|
|
380
|
+
// Island component: demonstriere title prop (Svelte-style syntax)
|
|
381
381
|
const hasTitle = props.title;
|
|
382
|
-
const islandPropsJson = hasTitle ? `{"title": "{{title}}"}` : '{}';
|
|
383
382
|
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
383
|
+
if (hasTitle) {
|
|
384
|
+
exampleHtml = `\t<div
|
|
385
|
+
wm:island="${toKebabCase(name)}"
|
|
386
|
+
wm:island-prop:title={title}
|
|
387
|
+
class="p-6 bg-white rounded-lg border border-gray-200"
|
|
388
|
+
>
|
|
389
|
+
<!-- Island wird hier initialisiert -->
|
|
390
|
+
</div>`;
|
|
391
|
+
} else {
|
|
392
|
+
exampleHtml = `\t<div
|
|
393
|
+
wm:island="${toKebabCase(name)}"
|
|
387
394
|
class="p-6 bg-white rounded-lg border border-gray-200"
|
|
388
395
|
>
|
|
389
396
|
<!-- Island wird hier initialisiert -->
|
|
390
397
|
</div>`;
|
|
398
|
+
}
|
|
391
399
|
} else {
|
|
392
400
|
// Normale component: zeige title an
|
|
393
401
|
const hasTitle = props.title;
|
|
@@ -472,6 +480,21 @@ ${exampleHtml}
|
|
|
472
480
|
if (options.assets) {
|
|
473
481
|
await fs.mkdir(path.join(componentDir, 'assets'), { recursive: true });
|
|
474
482
|
}
|
|
483
|
+
|
|
484
|
+
// Create package.json (always include for npm dependencies)
|
|
485
|
+
const packageJson = {
|
|
486
|
+
name: toKebabCase(name),
|
|
487
|
+
version: '1.0.0',
|
|
488
|
+
private: true,
|
|
489
|
+
type: 'module',
|
|
490
|
+
dependencies: {}
|
|
491
|
+
};
|
|
492
|
+
|
|
493
|
+
await fs.writeFile(
|
|
494
|
+
path.join(componentDir, 'package.json'),
|
|
495
|
+
JSON.stringify(packageJson, null, 2),
|
|
496
|
+
'utf-8'
|
|
497
|
+
);
|
|
475
498
|
}
|
|
476
499
|
|
|
477
500
|
/**
|
package/src/commands/init.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { existsSync, mkdirSync, writeFileSync } from 'fs';
|
|
2
2
|
import { join } from 'path';
|
|
3
|
-
import { logger } from '@webmate-studio/core';
|
|
3
|
+
import { logger, generateUUID } from '@webmate-studio/core';
|
|
4
4
|
import pc from 'picocolors';
|
|
5
5
|
|
|
6
6
|
/**
|
|
@@ -147,11 +147,11 @@ body {
|
|
|
147
147
|
`;
|
|
148
148
|
writeFileSync(componentHtmlPath, componentHtmlContent, 'utf8');
|
|
149
149
|
|
|
150
|
-
// component.json
|
|
150
|
+
// component.json with UUID
|
|
151
151
|
const componentJsonPath = join(exampleSimpleDir, 'component.json');
|
|
152
152
|
const componentJsonContent = `{
|
|
153
|
-
"
|
|
154
|
-
"
|
|
153
|
+
"id": "${generateUUID()}",
|
|
154
|
+
"displayName": "Example Simple",
|
|
155
155
|
"description": "A simple example component using Tailwind CSS",
|
|
156
156
|
"category": "examples",
|
|
157
157
|
"props": {
|
|
@@ -166,6 +166,18 @@ body {
|
|
|
166
166
|
`;
|
|
167
167
|
writeFileSync(componentJsonPath, componentJsonContent, 'utf8');
|
|
168
168
|
|
|
169
|
+
// package.json (always include for npm dependencies)
|
|
170
|
+
const packageJsonPath = join(exampleSimpleDir, 'package.json');
|
|
171
|
+
const packageJsonContent = `{
|
|
172
|
+
"name": "example-simple",
|
|
173
|
+
"version": "1.0.0",
|
|
174
|
+
"private": true,
|
|
175
|
+
"type": "module",
|
|
176
|
+
"dependencies": {}
|
|
177
|
+
}
|
|
178
|
+
`;
|
|
179
|
+
writeFileSync(packageJsonPath, packageJsonContent, 'utf8');
|
|
180
|
+
|
|
169
181
|
logger.success('Created components/ExampleSimple/');
|
|
170
182
|
}
|
|
171
183
|
|
|
@@ -192,8 +204,9 @@ body {
|
|
|
192
204
|
<!-- Interactive Island (Vanilla JS) -->
|
|
193
205
|
<!-- Islands can also use: React, Svelte, Vue, Preact, Alpine.js, or Lit -->
|
|
194
206
|
<div
|
|
195
|
-
|
|
196
|
-
|
|
207
|
+
wm:island="counter"
|
|
208
|
+
wm:island-prop:initialCount={0}
|
|
209
|
+
wm:island-prop:label={"Clicks"}
|
|
197
210
|
class="p-6 bg-white rounded-lg border-2 border-blue-200"
|
|
198
211
|
>
|
|
199
212
|
<p class="text-sm text-gray-500 mb-4">
|
|
@@ -222,11 +235,11 @@ body {
|
|
|
222
235
|
`;
|
|
223
236
|
writeFileSync(componentHtmlPath, componentHtmlContent, 'utf8');
|
|
224
237
|
|
|
225
|
-
// component.json
|
|
238
|
+
// component.json with UUID
|
|
226
239
|
const componentJsonPath = join(exampleExtendedDir, 'component.json');
|
|
227
240
|
const componentJsonContent = `{
|
|
228
|
-
"
|
|
229
|
-
"
|
|
241
|
+
"id": "${generateUUID()}",
|
|
242
|
+
"displayName": "Example Extended",
|
|
230
243
|
"description": "Extended example component with interactive island",
|
|
231
244
|
"category": "examples",
|
|
232
245
|
"props": {
|
|
@@ -338,6 +351,18 @@ export default class CounterIsland {
|
|
|
338
351
|
`;
|
|
339
352
|
writeFileSync(counterIslandPath, counterIslandContent, 'utf8');
|
|
340
353
|
|
|
354
|
+
// package.json (always include for npm dependencies)
|
|
355
|
+
const packageJsonPath2 = join(exampleExtendedDir, 'package.json');
|
|
356
|
+
const packageJsonContent2 = `{
|
|
357
|
+
"name": "example-extended",
|
|
358
|
+
"version": "1.0.0",
|
|
359
|
+
"private": true,
|
|
360
|
+
"type": "module",
|
|
361
|
+
"dependencies": {}
|
|
362
|
+
}
|
|
363
|
+
`;
|
|
364
|
+
writeFileSync(packageJsonPath2, packageJsonContent2, 'utf8');
|
|
365
|
+
|
|
341
366
|
logger.success('Created components/ExampleExtended/ (with island)');
|
|
342
367
|
}
|
|
343
368
|
|
|
@@ -348,6 +373,8 @@ export default class CounterIsland {
|
|
|
348
373
|
dist/
|
|
349
374
|
.DS_Store
|
|
350
375
|
*.log
|
|
376
|
+
components/*/node_modules/
|
|
377
|
+
components/*/.wm-cache/
|
|
351
378
|
`;
|
|
352
379
|
writeFileSync(gitignorePath, gitignoreContent, 'utf8');
|
|
353
380
|
logger.success('Created .gitignore');
|
package/src/commands/prop.js
CHANGED
|
@@ -8,8 +8,29 @@ import glob from 'glob';
|
|
|
8
8
|
/**
|
|
9
9
|
* Add a property to a component
|
|
10
10
|
* wm prop [filename]
|
|
11
|
+
*
|
|
12
|
+
* @deprecated This command is deprecated.
|
|
13
|
+
* Props should now be defined in component.json, not in HTML files.
|
|
14
|
+
* Use: wm generate to create new components with proper structure.
|
|
11
15
|
*/
|
|
12
16
|
export async function prop(filename) {
|
|
17
|
+
console.log(pc.red('\n⚠️ DEPRECATED COMMAND\n'));
|
|
18
|
+
console.log(pc.yellow('The `wm prop` command is deprecated.'));
|
|
19
|
+
console.log(pc.yellow('Props should now be defined in component.json, not in HTML files.\n'));
|
|
20
|
+
console.log(pc.cyan('To add props to a component:'));
|
|
21
|
+
console.log(pc.dim(' 1. Open components/YourComponent/component.json'));
|
|
22
|
+
console.log(pc.dim(' 2. Add your props to the "props" section\n'));
|
|
23
|
+
console.log(pc.cyan('Example:'));
|
|
24
|
+
console.log(pc.dim(' "props": {'));
|
|
25
|
+
console.log(pc.dim(' "title": {'));
|
|
26
|
+
console.log(pc.dim(' "type": "text",'));
|
|
27
|
+
console.log(pc.dim(' "label": "Title",'));
|
|
28
|
+
console.log(pc.dim(' "default": "Hello World"'));
|
|
29
|
+
console.log(pc.dim(' }'));
|
|
30
|
+
console.log(pc.dim(' }\n'));
|
|
31
|
+
return;
|
|
32
|
+
|
|
33
|
+
// Legacy code below (no longer executed)
|
|
13
34
|
console.log(pc.cyan('\n📝 Add Property to Component\n'));
|
|
14
35
|
|
|
15
36
|
let targetFile;
|