slicejs-cli 2.2.5 → 2.2.7
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/client.js +22 -68
- package/commands/buildProduction/buildProduction.js +364 -357
- package/commands/startServer/startServer.js +34 -11
- package/package.json +28 -28
- package/post.js +30 -75
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// commands/startServer/startServer.js -
|
|
1
|
+
// commands/startServer/startServer.js - CON ARGUMENTOS
|
|
2
2
|
|
|
3
3
|
import fs from 'fs-extra';
|
|
4
4
|
import path from 'path';
|
|
@@ -8,6 +8,20 @@ import Print from '../Print.js';
|
|
|
8
8
|
|
|
9
9
|
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
10
10
|
|
|
11
|
+
/**
|
|
12
|
+
* Carga la configuración desde sliceConfig.json
|
|
13
|
+
*/
|
|
14
|
+
const loadConfig = () => {
|
|
15
|
+
try {
|
|
16
|
+
const configPath = path.join(__dirname, '../../../../src/sliceConfig.json');
|
|
17
|
+
const rawData = fs.readFileSync(configPath, 'utf-8');
|
|
18
|
+
return JSON.parse(rawData);
|
|
19
|
+
} catch (error) {
|
|
20
|
+
Print.error(`Loading configuration: ${error.message}`);
|
|
21
|
+
return null;
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
|
|
11
25
|
/**
|
|
12
26
|
* Verifica si existe un build de producción
|
|
13
27
|
*/
|
|
@@ -27,7 +41,7 @@ async function checkDevelopmentStructure() {
|
|
|
27
41
|
}
|
|
28
42
|
|
|
29
43
|
/**
|
|
30
|
-
* Inicia el servidor Node.js
|
|
44
|
+
* Inicia el servidor Node.js con argumentos
|
|
31
45
|
*/
|
|
32
46
|
function startNodeServer(port, mode) {
|
|
33
47
|
return new Promise((resolve, reject) => {
|
|
@@ -35,13 +49,20 @@ function startNodeServer(port, mode) {
|
|
|
35
49
|
|
|
36
50
|
Print.info(`Starting ${mode} server on port ${port}...`);
|
|
37
51
|
|
|
38
|
-
|
|
52
|
+
// Construir argumentos basados en el modo
|
|
53
|
+
const args = [apiIndexPath];
|
|
54
|
+
if (mode === 'production') {
|
|
55
|
+
args.push('--production');
|
|
56
|
+
} else {
|
|
57
|
+
args.push('--development');
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
const serverProcess = spawn('node', args, {
|
|
39
61
|
stdio: 'inherit',
|
|
40
62
|
env: {
|
|
41
63
|
...process.env,
|
|
42
|
-
PORT: port
|
|
43
|
-
|
|
44
|
-
SLICE_CLI_MODE: 'true' // Flag para que api/index.js sepa que viene del CLI
|
|
64
|
+
PORT: port
|
|
65
|
+
// Ya no necesitamos NODE_ENV ni SLICE_CLI_MODE
|
|
45
66
|
}
|
|
46
67
|
});
|
|
47
68
|
|
|
@@ -50,7 +71,7 @@ function startNodeServer(port, mode) {
|
|
|
50
71
|
reject(error);
|
|
51
72
|
});
|
|
52
73
|
|
|
53
|
-
// Manejar Ctrl+C
|
|
74
|
+
// Manejar Ctrl+C
|
|
54
75
|
process.on('SIGINT', () => {
|
|
55
76
|
Print.info('Shutting down server...');
|
|
56
77
|
serverProcess.kill('SIGINT');
|
|
@@ -61,7 +82,6 @@ function startNodeServer(port, mode) {
|
|
|
61
82
|
serverProcess.kill('SIGTERM');
|
|
62
83
|
});
|
|
63
84
|
|
|
64
|
-
// NO mostrar mensajes duplicados - el api/index.js ya se encarga
|
|
65
85
|
setTimeout(() => {
|
|
66
86
|
resolve(serverProcess);
|
|
67
87
|
}, 500);
|
|
@@ -69,10 +89,13 @@ function startNodeServer(port, mode) {
|
|
|
69
89
|
}
|
|
70
90
|
|
|
71
91
|
/**
|
|
72
|
-
* Función principal para iniciar servidor
|
|
92
|
+
* Función principal para iniciar servidor
|
|
73
93
|
*/
|
|
74
94
|
export default async function startServer(options = {}) {
|
|
75
|
-
const
|
|
95
|
+
const config = loadConfig();
|
|
96
|
+
const defaultPort = config?.server?.port || 3000;
|
|
97
|
+
|
|
98
|
+
const { mode = 'development', port = defaultPort } = options;
|
|
76
99
|
|
|
77
100
|
try {
|
|
78
101
|
Print.title(`🚀 Starting Slice.js ${mode} server...`);
|
|
@@ -93,7 +116,7 @@ export default async function startServer(options = {}) {
|
|
|
93
116
|
Print.info('Development mode: serving files from /src with hot reload');
|
|
94
117
|
}
|
|
95
118
|
|
|
96
|
-
// Iniciar el servidor
|
|
119
|
+
// Iniciar el servidor con argumentos
|
|
97
120
|
await startNodeServer(port, mode);
|
|
98
121
|
|
|
99
122
|
} catch (error) {
|
package/package.json
CHANGED
|
@@ -1,28 +1,28 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "slicejs-cli",
|
|
3
|
-
"version": "2.2.
|
|
4
|
-
"description": "Command client for developing web applications with Slice.js framework",
|
|
5
|
-
"main": "client.js",
|
|
6
|
-
"scripts": {
|
|
7
|
-
"test": "echo \"Error: no test specified\" && exit 1",
|
|
8
|
-
"postinstall": "node post.js"
|
|
9
|
-
},
|
|
10
|
-
"keywords": [
|
|
11
|
-
"framework",
|
|
12
|
-
"web",
|
|
13
|
-
"client",
|
|
14
|
-
"cli"
|
|
15
|
-
],
|
|
16
|
-
"author": "vkneider",
|
|
17
|
-
"type": "module",
|
|
18
|
-
"license": "ISC",
|
|
19
|
-
"dependencies": {
|
|
20
|
-
"clean-css": "^5.3.3",
|
|
21
|
-
"commander": "^12.0.0",
|
|
22
|
-
"fs-extra": "^11.2.0",
|
|
23
|
-
"html-minifier-terser": "^7.2.0",
|
|
24
|
-
"inquirer": "^12.4.2",
|
|
25
|
-
"slicejs-web-framework": "latest",
|
|
26
|
-
"terser": "^5.43.1"
|
|
27
|
-
}
|
|
28
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "slicejs-cli",
|
|
3
|
+
"version": "2.2.7",
|
|
4
|
+
"description": "Command client for developing web applications with Slice.js framework",
|
|
5
|
+
"main": "client.js",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"test": "echo \"Error: no test specified\" && exit 1",
|
|
8
|
+
"postinstall": "node post.js"
|
|
9
|
+
},
|
|
10
|
+
"keywords": [
|
|
11
|
+
"framework",
|
|
12
|
+
"web",
|
|
13
|
+
"client",
|
|
14
|
+
"cli"
|
|
15
|
+
],
|
|
16
|
+
"author": "vkneider",
|
|
17
|
+
"type": "module",
|
|
18
|
+
"license": "ISC",
|
|
19
|
+
"dependencies": {
|
|
20
|
+
"clean-css": "^5.3.3",
|
|
21
|
+
"commander": "^12.0.0",
|
|
22
|
+
"fs-extra": "^11.2.0",
|
|
23
|
+
"html-minifier-terser": "^7.2.0",
|
|
24
|
+
"inquirer": "^12.4.2",
|
|
25
|
+
"slicejs-web-framework": "latest",
|
|
26
|
+
"terser": "^5.43.1"
|
|
27
|
+
}
|
|
28
|
+
}
|
package/post.js
CHANGED
|
@@ -22,11 +22,10 @@ fs.promises.access(projectPackageJsonPath, fs.constants.F_OK)
|
|
|
22
22
|
// Add custom commands to the project scripts
|
|
23
23
|
projectPackageJson.scripts = projectPackageJson.scripts || {};
|
|
24
24
|
|
|
25
|
-
// Main project commands
|
|
25
|
+
// Main project commands - SOLO DEVELOPMENT
|
|
26
26
|
projectPackageJson.scripts['slice:init'] = 'node node_modules/slicejs-cli/client.js init';
|
|
27
|
-
projectPackageJson.scripts['slice:dev'] = 'node
|
|
28
|
-
projectPackageJson.scripts['slice:start'] = 'node
|
|
29
|
-
projectPackageJson.scripts['slice:build'] = 'node node_modules/slicejs-cli/client.js build';
|
|
27
|
+
projectPackageJson.scripts['slice:dev'] = 'node api/index.js --development';
|
|
28
|
+
projectPackageJson.scripts['slice:start'] = 'node api/index.js --development';
|
|
30
29
|
projectPackageJson.scripts['slice:version'] = 'node node_modules/slicejs-cli/client.js version';
|
|
31
30
|
projectPackageJson.scripts['slice:update'] = 'node node_modules/slicejs-cli/client.js update';
|
|
32
31
|
|
|
@@ -45,14 +44,9 @@ fs.promises.access(projectPackageJsonPath, fs.constants.F_OK)
|
|
|
45
44
|
projectPackageJson.scripts['slice:registry-list'] = 'node node_modules/slicejs-cli/client.js registry list';
|
|
46
45
|
projectPackageJson.scripts['slice:registry-sync'] = 'node node_modules/slicejs-cli/client.js registry sync';
|
|
47
46
|
|
|
48
|
-
//
|
|
49
|
-
projectPackageJson.scripts['
|
|
50
|
-
projectPackageJson.scripts['
|
|
51
|
-
projectPackageJson.scripts['slice:build-analyze'] = 'node node_modules/slicejs-cli/client.js build --analyze';
|
|
52
|
-
|
|
53
|
-
// Legacy/compatibility commands
|
|
54
|
-
projectPackageJson.scripts['run'] = 'node api/index.js';
|
|
55
|
-
projectPackageJson.scripts['development'] = 'node node_modules/slicejs-cli/client.js dev';
|
|
47
|
+
// Legacy commands - SOLO DEVELOPMENT
|
|
48
|
+
projectPackageJson.scripts['run'] = 'node api/index.js --development';
|
|
49
|
+
projectPackageJson.scripts['development'] = 'node api/index.js --development';
|
|
56
50
|
|
|
57
51
|
// Module configuration
|
|
58
52
|
projectPackageJson.type = 'module';
|
|
@@ -68,8 +62,7 @@ fs.promises.access(projectPackageJsonPath, fs.constants.F_OK)
|
|
|
68
62
|
console.log('\n🚀 Main workflow commands:');
|
|
69
63
|
console.log(' npm run slice:init - Initialize Slice.js project');
|
|
70
64
|
console.log(' npm run slice:dev - Start development server (serves from /src)');
|
|
71
|
-
console.log(' npm run slice:
|
|
72
|
-
console.log(' npm run slice:start - Start production server (serves from /dist)');
|
|
65
|
+
console.log(' npm run slice:start - Start development server (same as dev)');
|
|
73
66
|
console.log('\n📦 Component management:');
|
|
74
67
|
console.log(' npm run slice:get Button - Get components from official repository');
|
|
75
68
|
console.log(' npm run slice:browse - View all available components');
|
|
@@ -78,19 +71,14 @@ fs.promises.access(projectPackageJsonPath, fs.constants.F_OK)
|
|
|
78
71
|
console.log(' npm run slice:create - Create local component');
|
|
79
72
|
console.log(' npm run slice:list - List local components');
|
|
80
73
|
console.log(' npm run slice:delete - Delete local component');
|
|
81
|
-
console.log('\n🔧 Build utilities:');
|
|
82
|
-
console.log(' npm run slice:build-serve - Build and serve immediately');
|
|
83
|
-
console.log(' npm run slice:build-preview- Build and preview');
|
|
84
|
-
console.log(' npm run slice:build-analyze- Analyze build size');
|
|
85
74
|
console.log('\n🔧 Other utilities:');
|
|
86
75
|
console.log(' npm run slice:version - View version information');
|
|
87
76
|
console.log(' npm run slice:update - Check for available updates');
|
|
88
|
-
console.log('\n🎯
|
|
77
|
+
console.log('\n🎯 Simplified workflow:');
|
|
89
78
|
console.log(' 1. npm run slice:init - Initialize project');
|
|
90
|
-
console.log(' 2. npm run slice:dev -
|
|
91
|
-
console.log(' 3.
|
|
92
|
-
console.log('
|
|
93
|
-
console.log('\n💡 Tip: Use "slice:sync" to keep your components updated');
|
|
79
|
+
console.log(' 2. npm run slice:dev - Start development server');
|
|
80
|
+
console.log(' 3. Develop and iterate - No build step needed!');
|
|
81
|
+
console.log('\n💡 Development-focused: All commands serve from /src for instant changes');
|
|
94
82
|
})
|
|
95
83
|
.catch(err => {
|
|
96
84
|
if (err.code === 'ENOENT') {
|
|
@@ -101,83 +89,50 @@ fs.promises.access(projectPackageJsonPath, fs.constants.F_OK)
|
|
|
101
89
|
description: 'Slice.js project',
|
|
102
90
|
main: 'api/index.js',
|
|
103
91
|
scripts: {
|
|
104
|
-
// Main workflow commands
|
|
92
|
+
// Main workflow commands - SOLO DEVELOPMENT
|
|
105
93
|
'slice:init': 'node node_modules/slicejs-cli/client.js init',
|
|
106
|
-
'slice:dev': 'node
|
|
107
|
-
'slice:start': 'node
|
|
108
|
-
'slice:build': 'node node_modules/slicejs-cli/client.js build',
|
|
94
|
+
'slice:dev': 'node api/index.js --development',
|
|
95
|
+
'slice:start': 'node api/index.js --development',
|
|
109
96
|
'slice:version': 'node node_modules/slicejs-cli/client.js version',
|
|
110
97
|
'slice:update': 'node node_modules/slicejs-cli/client.js update',
|
|
111
98
|
|
|
112
|
-
// Local
|
|
99
|
+
// Local component commands
|
|
113
100
|
'slice:create': 'node node_modules/slicejs-cli/client.js component create',
|
|
114
101
|
'slice:list': 'node node_modules/slicejs-cli/client.js component list',
|
|
115
102
|
'slice:delete': 'node node_modules/slicejs-cli/client.js component delete',
|
|
116
103
|
|
|
117
|
-
//
|
|
104
|
+
// Repository commands
|
|
118
105
|
'slice:get': 'node node_modules/slicejs-cli/client.js get',
|
|
119
106
|
'slice:browse': 'node node_modules/slicejs-cli/client.js browse',
|
|
120
107
|
'slice:sync': 'node node_modules/slicejs-cli/client.js sync',
|
|
121
108
|
|
|
122
|
-
//
|
|
123
|
-
'
|
|
124
|
-
'
|
|
125
|
-
'slice:registry-sync': 'node node_modules/slicejs-cli/client.js registry sync',
|
|
126
|
-
|
|
127
|
-
// Build utilities
|
|
128
|
-
'slice:build-serve': 'node node_modules/slicejs-cli/client.js build --serve',
|
|
129
|
-
'slice:build-preview': 'node node_modules/slicejs-cli/client.js build --preview',
|
|
130
|
-
'slice:build-analyze': 'node node_modules/slicejs-cli/client.js build --analyze',
|
|
131
|
-
|
|
132
|
-
// Legacy
|
|
133
|
-
'run': 'node api/index.js',
|
|
134
|
-
'development': 'node node_modules/slicejs-cli/client.js dev'
|
|
109
|
+
// Legacy commands - SOLO DEVELOPMENT
|
|
110
|
+
'run': 'node api/index.js --development',
|
|
111
|
+
'development': 'node api/index.js --development'
|
|
135
112
|
},
|
|
136
|
-
keywords: ['slicejs', 'web-framework', 'components'],
|
|
137
|
-
author: '',
|
|
138
|
-
license: 'ISC',
|
|
139
113
|
type: 'module',
|
|
140
114
|
engines: {
|
|
141
115
|
"node": ">=20.0.0"
|
|
142
116
|
}
|
|
143
117
|
};
|
|
144
118
|
|
|
145
|
-
// Save the new package.json
|
|
146
119
|
return fs.promises.writeFile(projectPackageJsonPath, JSON.stringify(defaultPackageJson, null, 2), 'utf8');
|
|
147
120
|
} else {
|
|
148
|
-
console.error('Error:', err);
|
|
149
121
|
throw err;
|
|
150
122
|
}
|
|
151
123
|
})
|
|
152
124
|
.then(() => {
|
|
153
|
-
console.log('✅
|
|
154
|
-
console.log('\n
|
|
155
|
-
console.log(' npm run slice:
|
|
156
|
-
console.log(' npm run slice:
|
|
157
|
-
console.log('
|
|
158
|
-
console.log('
|
|
159
|
-
console.log('
|
|
160
|
-
console.log('
|
|
161
|
-
console.log('
|
|
162
|
-
console.log(' npm run slice:sync - Update local components to latest versions');
|
|
163
|
-
console.log('\n⚙️ Local component management:');
|
|
164
|
-
console.log(' npm run slice:create - Create local component');
|
|
165
|
-
console.log(' npm run slice:list - List local components');
|
|
166
|
-
console.log(' npm run slice:delete - Delete local component');
|
|
167
|
-
console.log('\n🔧 Build utilities:');
|
|
168
|
-
console.log(' npm run slice:build-serve - Build and serve immediately');
|
|
169
|
-
console.log(' npm run slice:build-preview- Build and preview');
|
|
170
|
-
console.log(' npm run slice:build-analyze- Analyze build size');
|
|
171
|
-
console.log('\n🔧 Other utilities:');
|
|
172
|
-
console.log(' npm run slice:version - View version information');
|
|
173
|
-
console.log(' npm run slice:update - Check for available updates');
|
|
174
|
-
console.log('\n🎯 Development workflow:');
|
|
175
|
-
console.log(' 1. npm run slice:init - Initialize project');
|
|
176
|
-
console.log(' 2. npm run slice:dev - Develop with hot reload');
|
|
177
|
-
console.log(' 3. npm run slice:build - Build for production');
|
|
178
|
-
console.log(' 4. npm run slice:start - Test production build');
|
|
179
|
-
console.log('\n💡 Tip: Use "slice:sync" to keep your components updated');
|
|
125
|
+
console.log('✅ SliceJS CLI commands configured successfully');
|
|
126
|
+
console.log('\n🎯 Simplified development workflow:');
|
|
127
|
+
console.log(' npm run slice:dev → node api/index.js --development (serves /src)');
|
|
128
|
+
console.log(' npm run slice:start → node api/index.js --development (same as dev)');
|
|
129
|
+
console.log('\n🔧 Benefits:');
|
|
130
|
+
console.log(' • Simple development-only workflow');
|
|
131
|
+
console.log(' • Instant changes without build steps');
|
|
132
|
+
console.log(' • Always serves from /src directory');
|
|
133
|
+
console.log(' • Interactive menu always available');
|
|
180
134
|
})
|
|
181
135
|
.catch(err => {
|
|
182
|
-
console.error('Error
|
|
136
|
+
console.error('❌ Error setting up package.json:', err.message);
|
|
137
|
+
process.exit(1);
|
|
183
138
|
});
|