slicejs-cli 2.8.5 → 2.9.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/README.md +347 -315
- package/client.js +526 -539
- package/commands/Print.js +167 -167
- package/commands/Validations.js +103 -103
- package/commands/build/build.js +40 -0
- package/commands/buildProduction/buildProduction.js +45 -10
- package/commands/bundle/bundle.js +235 -231
- package/commands/createComponent/VisualComponentTemplate.js +55 -55
- package/commands/createComponent/createComponent.js +126 -126
- package/commands/deleteComponent/deleteComponent.js +77 -77
- package/commands/doctor/doctor.js +369 -369
- package/commands/getComponent/getComponent.js +747 -747
- package/commands/init/init.js +238 -238
- package/commands/listComponents/listComponents.js +175 -175
- package/commands/startServer/startServer.js +260 -270
- package/commands/startServer/watchServer.js +79 -79
- package/commands/utils/PathHelper.js +68 -68
- package/commands/utils/VersionChecker.js +167 -167
- package/commands/utils/bundling/BundleGenerator.js +1287 -783
- package/commands/utils/bundling/DependencyAnalyzer.js +859 -679
- package/commands/utils/updateManager.js +437 -384
- package/package.json +46 -46
- package/post.js +25 -25
- package/refactor.md +271 -271
- package/tests/bundle-generator.test.js +38 -0
- package/tests/dependency-analyzer.test.js +24 -0
package/commands/init/init.js
CHANGED
|
@@ -1,220 +1,220 @@
|
|
|
1
|
-
import fs from 'fs-extra';
|
|
2
|
-
import path from 'path';
|
|
3
|
-
import { fileURLToPath } from 'url';
|
|
4
|
-
import ora from 'ora';
|
|
5
|
-
import Print from '../Print.js';
|
|
6
|
-
import { getProjectRoot, getApiPath, getSrcPath } from '../utils/PathHelper.js';
|
|
7
|
-
import { execSync } from 'child_process';
|
|
8
|
-
|
|
9
|
-
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
10
|
-
|
|
11
|
-
// Importar la clase ComponentRegistry del getComponent
|
|
12
|
-
import { ComponentRegistry } from '../getComponent/getComponent.js';
|
|
13
|
-
|
|
14
|
-
export default async function initializeProject(projectType) {
|
|
15
|
-
try {
|
|
16
|
-
const projectRoot = getProjectRoot(import.meta.url);
|
|
17
|
-
const destinationApi = getApiPath(import.meta.url);
|
|
18
|
-
const destinationSrc = getSrcPath(import.meta.url);
|
|
19
|
-
|
|
1
|
+
import fs from 'fs-extra';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
import { fileURLToPath } from 'url';
|
|
4
|
+
import ora from 'ora';
|
|
5
|
+
import Print from '../Print.js';
|
|
6
|
+
import { getProjectRoot, getApiPath, getSrcPath } from '../utils/PathHelper.js';
|
|
7
|
+
import { execSync } from 'child_process';
|
|
8
|
+
|
|
9
|
+
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
10
|
+
|
|
11
|
+
// Importar la clase ComponentRegistry del getComponent
|
|
12
|
+
import { ComponentRegistry } from '../getComponent/getComponent.js';
|
|
13
|
+
|
|
14
|
+
export default async function initializeProject(projectType) {
|
|
15
|
+
try {
|
|
16
|
+
const projectRoot = getProjectRoot(import.meta.url);
|
|
17
|
+
const destinationApi = getApiPath(import.meta.url);
|
|
18
|
+
const destinationSrc = getSrcPath(import.meta.url);
|
|
19
|
+
|
|
20
20
|
const fwSpinner = ora('Ensuring latest Slice framework...').start();
|
|
21
21
|
let latestVersion = null;
|
|
22
22
|
let sliceBaseDir;
|
|
23
23
|
try {
|
|
24
24
|
const latest = execSync('npm view slicejs-web-framework version', { cwd: projectRoot }).toString().trim();
|
|
25
25
|
latestVersion = latest;
|
|
26
|
-
const installedPkgPath = path.join(projectRoot, 'node_modules', 'slicejs-web-framework', 'package.json');
|
|
27
|
-
let installed = null;
|
|
28
|
-
if (await fs.pathExists(installedPkgPath)) {
|
|
29
|
-
const pkg = await fs.readJson(installedPkgPath);
|
|
30
|
-
installed = pkg.version;
|
|
31
|
-
}
|
|
26
|
+
const installedPkgPath = path.join(projectRoot, 'node_modules', 'slicejs-web-framework', 'package.json');
|
|
27
|
+
let installed = null;
|
|
28
|
+
if (await fs.pathExists(installedPkgPath)) {
|
|
29
|
+
const pkg = await fs.readJson(installedPkgPath);
|
|
30
|
+
installed = pkg.version;
|
|
31
|
+
}
|
|
32
32
|
if (installed !== latest) {
|
|
33
33
|
execSync(`npm install slicejs-web-framework@${latest} --save`, { cwd: projectRoot, stdio: 'inherit' });
|
|
34
34
|
}
|
|
35
35
|
sliceBaseDir = path.join(projectRoot, 'node_modules', 'slicejs-web-framework');
|
|
36
36
|
fwSpinner.succeed(`slicejs-web-framework@${latest} ready`);
|
|
37
37
|
} catch (err) {
|
|
38
|
-
const fallback = path.join(path.dirname(fileURLToPath(import.meta.url)), '../../../slicejs-web-framework');
|
|
39
|
-
if (await fs.pathExists(fallback)) {
|
|
40
|
-
sliceBaseDir = fallback;
|
|
41
|
-
fwSpinner.warn('Using local slicejs-web-framework fallback');
|
|
42
|
-
} else {
|
|
43
|
-
fwSpinner.fail('Failed to ensure latest slicejs-web-framework');
|
|
44
|
-
Print.error(err.message);
|
|
45
|
-
return;
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
const apiDir = path.join(sliceBaseDir, 'api');
|
|
50
|
-
const srcDir = path.join(sliceBaseDir, 'src');
|
|
51
|
-
|
|
52
|
-
try {
|
|
53
|
-
if (fs.existsSync(destinationApi)) throw new Error(`The "api" directory already exists: ${destinationApi}`);
|
|
54
|
-
if (fs.existsSync(destinationSrc)) throw new Error(`The "src" directory already exists: ${destinationSrc}`);
|
|
55
|
-
} catch (error) {
|
|
56
|
-
Print.error('Validating destination directories:', error.message);
|
|
57
|
-
return;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
// 1. COPIAR LA CARPETA API (mantener lógica original)
|
|
61
|
-
const apiSpinner = ora('Copying API structure...').start();
|
|
62
|
-
try {
|
|
63
|
-
if (!fs.existsSync(apiDir)) throw new Error(`API folder not found: ${apiDir}`);
|
|
64
|
-
await fs.copy(apiDir, destinationApi, { recursive: true });
|
|
65
|
-
apiSpinner.succeed('API structure created successfully');
|
|
66
|
-
} catch (error) {
|
|
67
|
-
apiSpinner.fail('Error copying API structure');
|
|
68
|
-
Print.error(error.message);
|
|
69
|
-
return;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
// 2. CREAR ESTRUCTURA SRC BÁSICA (sin copiar componentes Visual)
|
|
73
|
-
const srcSpinner = ora('Creating src structure...').start();
|
|
74
|
-
try {
|
|
75
|
-
if (!fs.existsSync(srcDir)) throw new Error(`src folder not found: ${srcDir}`);
|
|
76
|
-
|
|
77
|
-
// Copiar solo los archivos base de src, excluyendo Components/Visual
|
|
78
|
-
await fs.ensureDir(destinationSrc);
|
|
79
|
-
|
|
80
|
-
// Copiar archivos y carpetas de src excepto Components/Visual
|
|
81
|
-
const srcItems = await fs.readdir(srcDir);
|
|
82
|
-
|
|
83
|
-
for (const item of srcItems) {
|
|
84
|
-
const srcItemPath = path.join(srcDir, item);
|
|
85
|
-
const destItemPath = path.join(destinationSrc, item);
|
|
86
|
-
const stat = await fs.stat(srcItemPath);
|
|
87
|
-
|
|
88
|
-
if (stat.isDirectory()) {
|
|
89
|
-
if (item === 'Components') {
|
|
90
|
-
// Crear estructura de Components pero sin copiar Visual
|
|
91
|
-
await fs.ensureDir(destItemPath);
|
|
92
|
-
|
|
93
|
-
const componentItems = await fs.readdir(srcItemPath);
|
|
94
|
-
for (const componentItem of componentItems) {
|
|
95
|
-
const componentItemPath = path.join(srcItemPath, componentItem);
|
|
96
|
-
const destComponentItemPath = path.join(destItemPath, componentItem);
|
|
97
|
-
|
|
98
|
-
if (componentItem !== 'Visual') {
|
|
99
|
-
// Copy Service and other component types
|
|
100
|
-
await fs.copy(componentItemPath, destComponentItemPath, { recursive: true });
|
|
101
|
-
} else {
|
|
102
|
-
// Only create empty Visual directory
|
|
103
|
-
await fs.ensureDir(destComponentItemPath);
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
} else {
|
|
107
|
-
// Copy other folders normally
|
|
108
|
-
await fs.copy(srcItemPath, destItemPath, { recursive: true });
|
|
109
|
-
}
|
|
110
|
-
} else {
|
|
111
|
-
// Copy files normally
|
|
112
|
-
await fs.copy(srcItemPath, destItemPath);
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
srcSpinner.succeed('Source structure created successfully');
|
|
117
|
-
} catch (error) {
|
|
118
|
-
srcSpinner.fail('Error creating source structure');
|
|
119
|
-
Print.error(error.message);
|
|
120
|
-
return;
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
// 3. DESCARGAR TODOS LOS COMPONENTES VISUAL DESDE EL REPOSITORIO OFICIAL
|
|
124
|
-
const componentsSpinner = ora('Loading component registry...').start();
|
|
125
|
-
try {
|
|
126
|
-
const registry = new ComponentRegistry();
|
|
127
|
-
await registry.loadRegistry();
|
|
128
|
-
|
|
129
|
-
// Obtener TODOS los componentes Visual disponibles
|
|
130
|
-
const allVisualComponents = await getAllVisualComponents(registry);
|
|
131
|
-
|
|
132
|
-
if (allVisualComponents.length > 0) {
|
|
133
|
-
componentsSpinner.text = `Installing ${allVisualComponents.length} Visual components...`;
|
|
134
|
-
|
|
135
|
-
const results = await registry.installMultipleComponents(
|
|
136
|
-
allVisualComponents,
|
|
137
|
-
'Visual',
|
|
138
|
-
true // force = true para instalación inicial
|
|
139
|
-
);
|
|
140
|
-
|
|
141
|
-
const successful = results.filter(r => r.success).length;
|
|
142
|
-
const failed = results.filter(r => !r.success).length;
|
|
143
|
-
|
|
144
|
-
if (successful > 0 && failed === 0) {
|
|
145
|
-
componentsSpinner.succeed(`All ${successful} Visual components installed successfully`);
|
|
146
|
-
} else if (successful > 0) {
|
|
147
|
-
componentsSpinner.warn(`${successful} components installed, ${failed} failed`);
|
|
148
|
-
Print.info('You can install failed components later using "slice get <component-name>"');
|
|
149
|
-
} else {
|
|
150
|
-
componentsSpinner.fail('Failed to install Visual components');
|
|
151
|
-
}
|
|
152
|
-
} else {
|
|
153
|
-
componentsSpinner.warn('No Visual components found in registry');
|
|
154
|
-
Print.info('You can add components later using "slice get <component-name>"');
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
} catch (error) {
|
|
158
|
-
componentsSpinner.fail('Could not download Visual components from official repository');
|
|
159
|
-
Print.error(`Repository error: ${error.message}`);
|
|
160
|
-
Print.info('Project initialized without Visual components');
|
|
161
|
-
Print.info('You can add them later using "slice get <component-name>"');
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
// 4. CONFIGURAR SCRIPTS EN package.json DEL PROYECTO
|
|
165
|
-
const pkgSpinner = ora('Configuring npm scripts...').start();
|
|
166
|
-
try {
|
|
167
|
-
const projectRoot = getProjectRoot(import.meta.url);
|
|
168
|
-
const pkgPath = path.join(projectRoot, 'package.json');
|
|
169
|
-
|
|
170
|
-
let pkg;
|
|
171
|
-
if (await fs.pathExists(pkgPath)) {
|
|
172
|
-
pkg = await fs.readJson(pkgPath);
|
|
173
|
-
} else {
|
|
174
|
-
pkg = {
|
|
175
|
-
name: path.basename(projectRoot),
|
|
176
|
-
version: '1.0.0',
|
|
177
|
-
description: 'Slice.js project',
|
|
178
|
-
main: 'api/index.js',
|
|
179
|
-
scripts: {}
|
|
180
|
-
};
|
|
181
|
-
}
|
|
182
|
-
|
|
38
|
+
const fallback = path.join(path.dirname(fileURLToPath(import.meta.url)), '../../../slicejs-web-framework');
|
|
39
|
+
if (await fs.pathExists(fallback)) {
|
|
40
|
+
sliceBaseDir = fallback;
|
|
41
|
+
fwSpinner.warn('Using local slicejs-web-framework fallback');
|
|
42
|
+
} else {
|
|
43
|
+
fwSpinner.fail('Failed to ensure latest slicejs-web-framework');
|
|
44
|
+
Print.error(err.message);
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
const apiDir = path.join(sliceBaseDir, 'api');
|
|
50
|
+
const srcDir = path.join(sliceBaseDir, 'src');
|
|
51
|
+
|
|
52
|
+
try {
|
|
53
|
+
if (fs.existsSync(destinationApi)) throw new Error(`The "api" directory already exists: ${destinationApi}`);
|
|
54
|
+
if (fs.existsSync(destinationSrc)) throw new Error(`The "src" directory already exists: ${destinationSrc}`);
|
|
55
|
+
} catch (error) {
|
|
56
|
+
Print.error('Validating destination directories:', error.message);
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
// 1. COPIAR LA CARPETA API (mantener lógica original)
|
|
61
|
+
const apiSpinner = ora('Copying API structure...').start();
|
|
62
|
+
try {
|
|
63
|
+
if (!fs.existsSync(apiDir)) throw new Error(`API folder not found: ${apiDir}`);
|
|
64
|
+
await fs.copy(apiDir, destinationApi, { recursive: true });
|
|
65
|
+
apiSpinner.succeed('API structure created successfully');
|
|
66
|
+
} catch (error) {
|
|
67
|
+
apiSpinner.fail('Error copying API structure');
|
|
68
|
+
Print.error(error.message);
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
// 2. CREAR ESTRUCTURA SRC BÁSICA (sin copiar componentes Visual)
|
|
73
|
+
const srcSpinner = ora('Creating src structure...').start();
|
|
74
|
+
try {
|
|
75
|
+
if (!fs.existsSync(srcDir)) throw new Error(`src folder not found: ${srcDir}`);
|
|
76
|
+
|
|
77
|
+
// Copiar solo los archivos base de src, excluyendo Components/Visual
|
|
78
|
+
await fs.ensureDir(destinationSrc);
|
|
79
|
+
|
|
80
|
+
// Copiar archivos y carpetas de src excepto Components/Visual
|
|
81
|
+
const srcItems = await fs.readdir(srcDir);
|
|
82
|
+
|
|
83
|
+
for (const item of srcItems) {
|
|
84
|
+
const srcItemPath = path.join(srcDir, item);
|
|
85
|
+
const destItemPath = path.join(destinationSrc, item);
|
|
86
|
+
const stat = await fs.stat(srcItemPath);
|
|
87
|
+
|
|
88
|
+
if (stat.isDirectory()) {
|
|
89
|
+
if (item === 'Components') {
|
|
90
|
+
// Crear estructura de Components pero sin copiar Visual
|
|
91
|
+
await fs.ensureDir(destItemPath);
|
|
92
|
+
|
|
93
|
+
const componentItems = await fs.readdir(srcItemPath);
|
|
94
|
+
for (const componentItem of componentItems) {
|
|
95
|
+
const componentItemPath = path.join(srcItemPath, componentItem);
|
|
96
|
+
const destComponentItemPath = path.join(destItemPath, componentItem);
|
|
97
|
+
|
|
98
|
+
if (componentItem !== 'Visual') {
|
|
99
|
+
// Copy Service and other component types
|
|
100
|
+
await fs.copy(componentItemPath, destComponentItemPath, { recursive: true });
|
|
101
|
+
} else {
|
|
102
|
+
// Only create empty Visual directory
|
|
103
|
+
await fs.ensureDir(destComponentItemPath);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
} else {
|
|
107
|
+
// Copy other folders normally
|
|
108
|
+
await fs.copy(srcItemPath, destItemPath, { recursive: true });
|
|
109
|
+
}
|
|
110
|
+
} else {
|
|
111
|
+
// Copy files normally
|
|
112
|
+
await fs.copy(srcItemPath, destItemPath);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
srcSpinner.succeed('Source structure created successfully');
|
|
117
|
+
} catch (error) {
|
|
118
|
+
srcSpinner.fail('Error creating source structure');
|
|
119
|
+
Print.error(error.message);
|
|
120
|
+
return;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
// 3. DESCARGAR TODOS LOS COMPONENTES VISUAL DESDE EL REPOSITORIO OFICIAL
|
|
124
|
+
const componentsSpinner = ora('Loading component registry...').start();
|
|
125
|
+
try {
|
|
126
|
+
const registry = new ComponentRegistry();
|
|
127
|
+
await registry.loadRegistry();
|
|
128
|
+
|
|
129
|
+
// Obtener TODOS los componentes Visual disponibles
|
|
130
|
+
const allVisualComponents = await getAllVisualComponents(registry);
|
|
131
|
+
|
|
132
|
+
if (allVisualComponents.length > 0) {
|
|
133
|
+
componentsSpinner.text = `Installing ${allVisualComponents.length} Visual components...`;
|
|
134
|
+
|
|
135
|
+
const results = await registry.installMultipleComponents(
|
|
136
|
+
allVisualComponents,
|
|
137
|
+
'Visual',
|
|
138
|
+
true // force = true para instalación inicial
|
|
139
|
+
);
|
|
140
|
+
|
|
141
|
+
const successful = results.filter(r => r.success).length;
|
|
142
|
+
const failed = results.filter(r => !r.success).length;
|
|
143
|
+
|
|
144
|
+
if (successful > 0 && failed === 0) {
|
|
145
|
+
componentsSpinner.succeed(`All ${successful} Visual components installed successfully`);
|
|
146
|
+
} else if (successful > 0) {
|
|
147
|
+
componentsSpinner.warn(`${successful} components installed, ${failed} failed`);
|
|
148
|
+
Print.info('You can install failed components later using "slice get <component-name>"');
|
|
149
|
+
} else {
|
|
150
|
+
componentsSpinner.fail('Failed to install Visual components');
|
|
151
|
+
}
|
|
152
|
+
} else {
|
|
153
|
+
componentsSpinner.warn('No Visual components found in registry');
|
|
154
|
+
Print.info('You can add components later using "slice get <component-name>"');
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
} catch (error) {
|
|
158
|
+
componentsSpinner.fail('Could not download Visual components from official repository');
|
|
159
|
+
Print.error(`Repository error: ${error.message}`);
|
|
160
|
+
Print.info('Project initialized without Visual components');
|
|
161
|
+
Print.info('You can add them later using "slice get <component-name>"');
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
// 4. CONFIGURAR SCRIPTS EN package.json DEL PROYECTO
|
|
165
|
+
const pkgSpinner = ora('Configuring npm scripts...').start();
|
|
166
|
+
try {
|
|
167
|
+
const projectRoot = getProjectRoot(import.meta.url);
|
|
168
|
+
const pkgPath = path.join(projectRoot, 'package.json');
|
|
169
|
+
|
|
170
|
+
let pkg;
|
|
171
|
+
if (await fs.pathExists(pkgPath)) {
|
|
172
|
+
pkg = await fs.readJson(pkgPath);
|
|
173
|
+
} else {
|
|
174
|
+
pkg = {
|
|
175
|
+
name: path.basename(projectRoot),
|
|
176
|
+
version: '1.0.0',
|
|
177
|
+
description: 'Slice.js project',
|
|
178
|
+
main: 'api/index.js',
|
|
179
|
+
scripts: {}
|
|
180
|
+
};
|
|
181
|
+
}
|
|
182
|
+
|
|
183
183
|
pkg.scripts = pkg.scripts || {};
|
|
184
184
|
pkg.dependencies = pkg.dependencies || {};
|
|
185
|
-
|
|
186
|
-
// Comandos principales
|
|
187
|
-
pkg.scripts['dev'] = 'slice dev';
|
|
188
|
-
pkg.scripts['start'] = 'slice start';
|
|
189
|
-
|
|
190
|
-
// Gestión de componentes
|
|
191
|
-
pkg.scripts['component:create'] = 'slice component create';
|
|
192
|
-
pkg.scripts['component:list'] = 'slice component list';
|
|
193
|
-
pkg.scripts['component:delete'] = 'slice component delete';
|
|
194
|
-
|
|
195
|
-
// Atajos de repositorio
|
|
196
|
-
pkg.scripts['get'] = 'slice get';
|
|
197
|
-
pkg.scripts['browse'] = 'slice browse';
|
|
198
|
-
pkg.scripts['sync'] = 'slice sync';
|
|
199
|
-
|
|
200
|
-
// Utilidades
|
|
201
|
-
pkg.scripts['slice:version'] = 'slice version';
|
|
202
|
-
pkg.scripts['slice:update'] = 'slice update';
|
|
203
|
-
|
|
204
|
-
// Legacy (compatibilidad)
|
|
205
|
-
pkg.scripts['slice:init'] = 'slice init';
|
|
206
|
-
pkg.scripts['slice:start'] = 'slice start';
|
|
207
|
-
pkg.scripts['slice:dev'] = 'slice dev';
|
|
208
|
-
pkg.scripts['slice:create'] = 'slice component create';
|
|
209
|
-
pkg.scripts['slice:list'] = 'slice component list';
|
|
210
|
-
pkg.scripts['slice:delete'] = 'slice component delete';
|
|
211
|
-
pkg.scripts['slice:get'] = 'slice get';
|
|
212
|
-
pkg.scripts['slice:browse'] = 'slice browse';
|
|
213
|
-
pkg.scripts['slice:sync'] = 'slice sync';
|
|
214
|
-
pkg.scripts['run'] = 'slice dev';
|
|
215
|
-
|
|
185
|
+
|
|
186
|
+
// Comandos principales
|
|
187
|
+
pkg.scripts['dev'] = 'slice dev';
|
|
188
|
+
pkg.scripts['start'] = 'slice start';
|
|
189
|
+
|
|
190
|
+
// Gestión de componentes
|
|
191
|
+
pkg.scripts['component:create'] = 'slice component create';
|
|
192
|
+
pkg.scripts['component:list'] = 'slice component list';
|
|
193
|
+
pkg.scripts['component:delete'] = 'slice component delete';
|
|
194
|
+
|
|
195
|
+
// Atajos de repositorio
|
|
196
|
+
pkg.scripts['get'] = 'slice get';
|
|
197
|
+
pkg.scripts['browse'] = 'slice browse';
|
|
198
|
+
pkg.scripts['sync'] = 'slice sync';
|
|
199
|
+
|
|
200
|
+
// Utilidades
|
|
201
|
+
pkg.scripts['slice:version'] = 'slice version';
|
|
202
|
+
pkg.scripts['slice:update'] = 'slice update';
|
|
203
|
+
|
|
204
|
+
// Legacy (compatibilidad)
|
|
205
|
+
pkg.scripts['slice:init'] = 'slice init';
|
|
206
|
+
pkg.scripts['slice:start'] = 'slice start';
|
|
207
|
+
pkg.scripts['slice:dev'] = 'slice dev';
|
|
208
|
+
pkg.scripts['slice:create'] = 'slice component create';
|
|
209
|
+
pkg.scripts['slice:list'] = 'slice component list';
|
|
210
|
+
pkg.scripts['slice:delete'] = 'slice component delete';
|
|
211
|
+
pkg.scripts['slice:get'] = 'slice get';
|
|
212
|
+
pkg.scripts['slice:browse'] = 'slice browse';
|
|
213
|
+
pkg.scripts['slice:sync'] = 'slice sync';
|
|
214
|
+
pkg.scripts['run'] = 'slice dev';
|
|
215
|
+
|
|
216
216
|
// Configuración de módulo
|
|
217
|
-
pkg.type =
|
|
217
|
+
pkg.type = 'module';
|
|
218
218
|
pkg.engines = pkg.engines || { node: '>=20.0.0' };
|
|
219
219
|
|
|
220
220
|
// Ensure framework dependency is present
|
|
@@ -223,39 +223,39 @@ export default async function initializeProject(projectType) {
|
|
|
223
223
|
}
|
|
224
224
|
|
|
225
225
|
await fs.writeFile(pkgPath, JSON.stringify(pkg, null, 2), 'utf8');
|
|
226
|
-
pkgSpinner.succeed('npm scripts configured successfully');
|
|
227
|
-
|
|
228
|
-
console.log('\n🎯 New recommended commands:');
|
|
229
|
-
console.log(' npm run dev - Start development server');
|
|
230
|
-
console.log(' npm run get - Install components');
|
|
231
|
-
console.log(' npm run browse - Browse components');
|
|
232
|
-
} catch (error) {
|
|
233
|
-
pkgSpinner.fail('Failed to configure npm scripts');
|
|
234
|
-
Print.error(error.message);
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
Print.success('Project initialized successfully.');
|
|
238
|
-
Print.newLine();
|
|
239
|
-
Print.info('Next steps:');
|
|
240
|
-
console.log(' slice browse - View available components');
|
|
241
|
-
console.log(' slice get Button - Install specific components');
|
|
242
|
-
console.log(' slice sync - Update all components to latest versions');
|
|
243
|
-
|
|
244
|
-
} catch (error) {
|
|
245
|
-
Print.error('Unexpected error initializing project:', error.message);
|
|
246
|
-
}
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
/**
|
|
250
|
-
* Obtiene TODOS los componentes Visual disponibles en el registry
|
|
251
|
-
* @param {ComponentRegistry} registry - Instancia del registry cargado
|
|
252
|
-
* @returns {Array} - Array con todos los nombres de componentes Visual
|
|
253
|
-
*/
|
|
254
|
-
async function getAllVisualComponents(registry) {
|
|
255
|
-
const availableComponents = registry.getAvailableComponents('Visual');
|
|
256
|
-
const allVisualComponents = Object.keys(availableComponents);
|
|
257
|
-
|
|
258
|
-
Print.info(`Found ${allVisualComponents.length} Visual components in official repository`);
|
|
259
|
-
|
|
260
|
-
return allVisualComponents;
|
|
261
|
-
}
|
|
226
|
+
pkgSpinner.succeed('npm scripts configured successfully');
|
|
227
|
+
|
|
228
|
+
console.log('\n🎯 New recommended commands:');
|
|
229
|
+
console.log(' npm run dev - Start development server');
|
|
230
|
+
console.log(' npm run get - Install components');
|
|
231
|
+
console.log(' npm run browse - Browse components');
|
|
232
|
+
} catch (error) {
|
|
233
|
+
pkgSpinner.fail('Failed to configure npm scripts');
|
|
234
|
+
Print.error(error.message);
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
Print.success('Project initialized successfully.');
|
|
238
|
+
Print.newLine();
|
|
239
|
+
Print.info('Next steps:');
|
|
240
|
+
console.log(' slice browse - View available components');
|
|
241
|
+
console.log(' slice get Button - Install specific components');
|
|
242
|
+
console.log(' slice sync - Update all components to latest versions');
|
|
243
|
+
|
|
244
|
+
} catch (error) {
|
|
245
|
+
Print.error('Unexpected error initializing project:', error.message);
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
/**
|
|
250
|
+
* Obtiene TODOS los componentes Visual disponibles en el registry
|
|
251
|
+
* @param {ComponentRegistry} registry - Instancia del registry cargado
|
|
252
|
+
* @returns {Array} - Array con todos los nombres de componentes Visual
|
|
253
|
+
*/
|
|
254
|
+
async function getAllVisualComponents(registry) {
|
|
255
|
+
const availableComponents = registry.getAvailableComponents('Visual');
|
|
256
|
+
const allVisualComponents = Object.keys(availableComponents);
|
|
257
|
+
|
|
258
|
+
Print.info(`Found ${allVisualComponents.length} Visual components in official repository`);
|
|
259
|
+
|
|
260
|
+
return allVisualComponents;
|
|
261
|
+
}
|