esa-cli 0.0.2-beta.13 → 0.0.2-beta.14
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.
|
@@ -103,8 +103,8 @@ export function promptProjectName() {
|
|
|
103
103
|
const defaultName = `edge-routine-${Date.now()}`;
|
|
104
104
|
logger.log(`${t('init_input_name').d('Enter the name of edgeRoutine:')} ${defaultName}`);
|
|
105
105
|
logger.replacePrevLines(2, `├ ${t('init_input_name').d('Enter the name of edgeRoutine')}`);
|
|
106
|
-
logger.
|
|
107
|
-
logger.
|
|
106
|
+
logger.StepKV('name', defaultName);
|
|
107
|
+
logger.StepSpacer();
|
|
108
108
|
return defaultName;
|
|
109
109
|
}
|
|
110
110
|
const { name } = yield inquirer.prompt([
|
|
@@ -123,8 +123,8 @@ export function promptProjectName() {
|
|
|
123
123
|
}
|
|
124
124
|
]);
|
|
125
125
|
logger.replacePrevLines(2, `├ ${t('init_input_name').d('Enter the name of edgeRoutine:')}`);
|
|
126
|
-
logger.
|
|
127
|
-
logger.
|
|
126
|
+
logger.StepKV('ER Name', name);
|
|
127
|
+
logger.StepSpacer();
|
|
128
128
|
return name;
|
|
129
129
|
});
|
|
130
130
|
}
|
|
@@ -150,7 +150,7 @@ export function selectTemplate(items_1) {
|
|
|
150
150
|
return null;
|
|
151
151
|
}
|
|
152
152
|
}
|
|
153
|
-
logger.
|
|
153
|
+
logger.StepEnd();
|
|
154
154
|
const selectedTemplatePath = yield multiLevelSelect(items, 'Select a template:');
|
|
155
155
|
if (!selectedTemplatePath) {
|
|
156
156
|
logger.log(t('init_cancel').d('User canceled the operation.'));
|
|
@@ -199,13 +199,13 @@ export function handleGitInitialization(targetPath_1) {
|
|
|
199
199
|
if (initGit === 'Yes') {
|
|
200
200
|
const success = installGit(targetPath);
|
|
201
201
|
if (success) {
|
|
202
|
-
logger.
|
|
203
|
-
logger.
|
|
202
|
+
logger.StepKV('git', t('git_installed_success').d('Git has been installed successfully.'));
|
|
203
|
+
logger.StepSpacer();
|
|
204
204
|
}
|
|
205
205
|
}
|
|
206
206
|
else {
|
|
207
|
-
logger.
|
|
208
|
-
logger.
|
|
207
|
+
logger.StepKV('git', t('init_skip_git').d('Git installation was skipped.'));
|
|
208
|
+
logger.StepSpacer();
|
|
209
209
|
}
|
|
210
210
|
});
|
|
211
211
|
}
|
|
@@ -227,7 +227,7 @@ export function handleInit(argv) {
|
|
|
227
227
|
var _a, _b;
|
|
228
228
|
yield checkAndUpdatePackage('esa-template');
|
|
229
229
|
// Step 1 of 3: Planning selections (Cloudflare-like)
|
|
230
|
-
logger.
|
|
230
|
+
logger.StepHeader('Create an ESA application', 1, 3);
|
|
231
231
|
if (argv.config) {
|
|
232
232
|
const configFormat = yield promptConfigFormat(argv.yes);
|
|
233
233
|
yield generateConfigFile(undefined, undefined, undefined, configFormat);
|
|
@@ -252,9 +252,9 @@ export function handleInit(argv) {
|
|
|
252
252
|
}
|
|
253
253
|
}
|
|
254
254
|
// Show chosen directory
|
|
255
|
-
logger.
|
|
256
|
-
logger.
|
|
257
|
-
logger.
|
|
255
|
+
logger.StepItem('In which directory do you want to create your application?');
|
|
256
|
+
logger.StepKV('dir', `./${name}`);
|
|
257
|
+
logger.StepSpacer();
|
|
258
258
|
// Decide between framework or template if neither provided and not --yes
|
|
259
259
|
let framework = argv.framework;
|
|
260
260
|
let language = argv.language;
|
|
@@ -276,8 +276,8 @@ export function handleInit(argv) {
|
|
|
276
276
|
}
|
|
277
277
|
]);
|
|
278
278
|
logger.replacePrevLine('├ How would you like to initialize the project?');
|
|
279
|
-
logger.
|
|
280
|
-
logger.
|
|
279
|
+
logger.StepKV('category', initMode === 'framework' ? 'Framework Starter' : 'ESA Template');
|
|
280
|
+
logger.StepSpacer();
|
|
281
281
|
if (initMode === 'framework') {
|
|
282
282
|
const { fw } = yield inquirer.prompt([
|
|
283
283
|
{
|
|
@@ -293,15 +293,15 @@ export function handleInit(argv) {
|
|
|
293
293
|
]);
|
|
294
294
|
logger.replacePrevLine('├ Select a framework');
|
|
295
295
|
framework = fw;
|
|
296
|
-
logger.
|
|
296
|
+
logger.StepKV('framework', String(framework));
|
|
297
297
|
const frameworkConfig = getFrameworkConfig(framework);
|
|
298
298
|
if (frameworkConfig.templates) {
|
|
299
299
|
if (!language) {
|
|
300
300
|
language = yield promptLanguage(argv.yes);
|
|
301
301
|
}
|
|
302
|
-
logger.
|
|
302
|
+
logger.StepKV(t('init_language_selected').d('Language'), language);
|
|
303
303
|
}
|
|
304
|
-
logger.
|
|
304
|
+
logger.StepEnd('Configuration collected');
|
|
305
305
|
}
|
|
306
306
|
else if (initMode === 'template') {
|
|
307
307
|
// Use ESA Template creation method
|
|
@@ -310,17 +310,17 @@ export function handleInit(argv) {
|
|
|
310
310
|
if (!selectedTemplatePath) {
|
|
311
311
|
return;
|
|
312
312
|
}
|
|
313
|
-
logger.
|
|
313
|
+
logger.StepEnd('Template selected');
|
|
314
314
|
// Step 2 of 3: Scaffold project
|
|
315
|
-
logger.
|
|
315
|
+
logger.StepHeader('Scaffold project', 2, 3);
|
|
316
316
|
const { template, targetPath } = (yield initializeProject(selectedTemplatePath, name)) || {};
|
|
317
317
|
if (!template || !targetPath) {
|
|
318
318
|
return;
|
|
319
319
|
}
|
|
320
|
-
logger.
|
|
321
|
-
logger.
|
|
320
|
+
logger.StepSpacer();
|
|
321
|
+
logger.StepEnd('Project initialized');
|
|
322
322
|
// Step 3 of 3: Configure and finalize
|
|
323
|
-
logger.
|
|
323
|
+
logger.StepHeader('Configure and finalize', 3, 3);
|
|
324
324
|
if (!argv.skip) {
|
|
325
325
|
yield handleGitInitialization(targetPath, argv.yes);
|
|
326
326
|
}
|
|
@@ -343,13 +343,13 @@ export function handleInit(argv) {
|
|
|
343
343
|
return;
|
|
344
344
|
}
|
|
345
345
|
// Step 2 of 3: Scaffold project
|
|
346
|
-
logger.
|
|
346
|
+
logger.StepHeader('Scaffold project', 2, 3);
|
|
347
347
|
const command = frameworkConfig.command;
|
|
348
348
|
const templateFlag = ((_a = frameworkConfig.templates) === null || _a === void 0 ? void 0 : _a[language || 'typescript']) || '';
|
|
349
349
|
const fullCommand = `${command} ${name} ${templateFlag}`;
|
|
350
|
-
logger.
|
|
351
|
-
logger.
|
|
352
|
-
logger.
|
|
350
|
+
logger.StepItem(`Continue with ${framework} via \`${fullCommand}\``);
|
|
351
|
+
logger.StepKV('dir', `./${name}`);
|
|
352
|
+
logger.StepSpacer();
|
|
353
353
|
logger.log(`Creating ${framework} app in ${targetPath} ...`);
|
|
354
354
|
// Execute the command with proper arguments
|
|
355
355
|
if (templateFlag) {
|
|
@@ -364,28 +364,27 @@ export function handleInit(argv) {
|
|
|
364
364
|
cwd: process.cwd()
|
|
365
365
|
});
|
|
366
366
|
}
|
|
367
|
-
logger.
|
|
367
|
+
logger.StepSpacer();
|
|
368
368
|
// install dependencies
|
|
369
|
-
logger.
|
|
369
|
+
logger.StepItem('Install dependencies');
|
|
370
370
|
execSync('npm install', {
|
|
371
371
|
stdio: 'inherit',
|
|
372
372
|
cwd: targetPath
|
|
373
373
|
});
|
|
374
|
-
logger.
|
|
374
|
+
logger.StepSpacer();
|
|
375
375
|
// Post-process nextjs configuration for static export
|
|
376
376
|
if (framework === 'nextjs') {
|
|
377
|
-
logger.
|
|
377
|
+
logger.StepItem('Configuring Next.js for static export');
|
|
378
378
|
yield configureNextJsForStaticExport(targetPath);
|
|
379
|
-
logger.
|
|
379
|
+
logger.StepSpacer();
|
|
380
380
|
}
|
|
381
|
-
logger.
|
|
381
|
+
logger.StepEnd('Project initialized');
|
|
382
382
|
const assetsDirectory = (_b = frameworkConfig.assets) === null || _b === void 0 ? void 0 : _b.directory;
|
|
383
383
|
// Step 3 of 3: Configure and finalize
|
|
384
|
-
logger.
|
|
384
|
+
logger.StepHeader('Configure and finalize', 3, 3);
|
|
385
385
|
const configFormat = yield promptConfigFormat(argv.yes);
|
|
386
|
-
|
|
387
|
-
logger.
|
|
388
|
-
logger.cfStepSpacer();
|
|
386
|
+
logger.StepKV('format', configFormat);
|
|
387
|
+
logger.StepSpacer();
|
|
389
388
|
yield generateConfigFile(name, {
|
|
390
389
|
assets: assetsDirectory ? { directory: assetsDirectory } : undefined
|
|
391
390
|
}, targetPath, configFormat);
|
|
@@ -495,19 +494,15 @@ export function configureNextJsForStaticExport(targetPath) {
|
|
|
495
494
|
const nextConfigJsPath = path.join(targetPath, 'next.config.js');
|
|
496
495
|
const nextConfigMjsPath = path.join(targetPath, 'next.config.mjs');
|
|
497
496
|
let configPath = null;
|
|
498
|
-
let configContent = '';
|
|
499
497
|
// Check which config file exists
|
|
500
498
|
if (fs.existsSync(nextConfigTsPath)) {
|
|
501
499
|
configPath = nextConfigTsPath;
|
|
502
|
-
configContent = fs.readFileSync(nextConfigTsPath, 'utf-8');
|
|
503
500
|
}
|
|
504
501
|
else if (fs.existsSync(nextConfigJsPath)) {
|
|
505
502
|
configPath = nextConfigJsPath;
|
|
506
|
-
configContent = fs.readFileSync(nextConfigJsPath, 'utf-8');
|
|
507
503
|
}
|
|
508
504
|
else if (fs.existsSync(nextConfigMjsPath)) {
|
|
509
505
|
configPath = nextConfigMjsPath;
|
|
510
|
-
configContent = fs.readFileSync(nextConfigMjsPath, 'utf-8');
|
|
511
506
|
}
|
|
512
507
|
if (!configPath) {
|
|
513
508
|
// Create a new next.config.ts file if none exists
|
|
@@ -515,6 +510,7 @@ export function configureNextJsForStaticExport(targetPath) {
|
|
|
515
510
|
const newConfig = `import type { NextConfig } from "next";
|
|
516
511
|
|
|
517
512
|
const nextConfig: NextConfig = {
|
|
513
|
+
/* config options here */
|
|
518
514
|
output: "export",
|
|
519
515
|
trailingSlash: true,
|
|
520
516
|
images: {
|
|
@@ -527,53 +523,21 @@ export default nextConfig;`;
|
|
|
527
523
|
logger.success('Created next.config.ts with static export configuration');
|
|
528
524
|
return;
|
|
529
525
|
}
|
|
530
|
-
//
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
// Handle different config formats
|
|
538
|
-
if (configPath.endsWith('.ts')) {
|
|
539
|
-
// TypeScript config
|
|
540
|
-
if (configContent.includes('const nextConfig = {')) {
|
|
541
|
-
// Add output: 'export' after the opening brace
|
|
542
|
-
modifiedContent = configContent.replace(/(const nextConfig\s*=\s*\{)/, `$1
|
|
543
|
-
output: "export",`);
|
|
544
|
-
}
|
|
545
|
-
else if (configContent.includes('export default {')) {
|
|
546
|
-
// Add output: 'export' after the opening brace
|
|
547
|
-
modifiedContent = configContent.replace(/(export default\s*\{)/, `$1
|
|
548
|
-
output: "export",`);
|
|
549
|
-
}
|
|
550
|
-
}
|
|
551
|
-
else {
|
|
552
|
-
// JavaScript config
|
|
553
|
-
if (configContent.includes('const nextConfig = {')) {
|
|
554
|
-
// Add output: 'export' after the opening brace
|
|
555
|
-
modifiedContent = configContent.replace(/(const nextConfig\s*=\s*\{)/, `$1
|
|
556
|
-
output: "export",`);
|
|
557
|
-
}
|
|
558
|
-
else if (configContent.includes('module.exports = {')) {
|
|
559
|
-
// Add output: 'export' after the opening brace
|
|
560
|
-
modifiedContent = configContent.replace(/(module\.exports\s*=\s*\{)/, `$1
|
|
561
|
-
output: "export",`);
|
|
562
|
-
}
|
|
563
|
-
}
|
|
564
|
-
// Add trailingSlash and images configuration if not present
|
|
565
|
-
if (!modifiedContent.includes('trailingSlash')) {
|
|
566
|
-
modifiedContent = modifiedContent.replace(/(output: "export",)/, `$1
|
|
567
|
-
trailingSlash: true,`);
|
|
568
|
-
}
|
|
569
|
-
if (!modifiedContent.includes('images')) {
|
|
570
|
-
modifiedContent = modifiedContent.replace(/(trailingSlash: true,)/, `$1
|
|
526
|
+
// Always overwrite the config file with our static export configuration
|
|
527
|
+
const newConfig = `import type { NextConfig } from "next";
|
|
528
|
+
|
|
529
|
+
const nextConfig: NextConfig = {
|
|
530
|
+
/* config options here */
|
|
531
|
+
output: "export",
|
|
532
|
+
trailingSlash: true,
|
|
571
533
|
images: {
|
|
572
534
|
unoptimized: true
|
|
573
|
-
}
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
535
|
+
}
|
|
536
|
+
};
|
|
537
|
+
|
|
538
|
+
export default nextConfig;`;
|
|
539
|
+
// Write the new config to file, overwriting existing content
|
|
540
|
+
fs.writeFileSync(configPath, newConfig, 'utf-8');
|
|
541
|
+
logger.success('Next.js config file overwritten with static export configuration');
|
|
578
542
|
});
|
|
579
543
|
}
|
|
@@ -27,8 +27,13 @@
|
|
|
27
27
|
"label": "Next.js",
|
|
28
28
|
"command": "npx create-next-app@latest",
|
|
29
29
|
"assets": {
|
|
30
|
-
"directory": "./out"
|
|
31
|
-
|
|
32
|
-
|
|
30
|
+
"directory": "./out"
|
|
31
|
+
},
|
|
32
|
+
"config": [
|
|
33
|
+
{
|
|
34
|
+
"path": "next.config.js",
|
|
35
|
+
"content": ""
|
|
36
|
+
}
|
|
37
|
+
]
|
|
33
38
|
}
|
|
34
39
|
}
|
package/dist/libs/git/index.js
CHANGED
package/dist/libs/logger.js
CHANGED
|
@@ -155,25 +155,24 @@ class Logger {
|
|
|
155
155
|
}
|
|
156
156
|
console.log(lines.join('\n'));
|
|
157
157
|
}
|
|
158
|
-
|
|
159
|
-
cfStepHeader(title, step, total) {
|
|
158
|
+
StepHeader(title, step, total) {
|
|
160
159
|
console.log(`\n╭ ${title} ${chalk.green(`Step ${step} of ${total}`)}`);
|
|
161
160
|
console.log('│');
|
|
162
161
|
}
|
|
163
|
-
|
|
162
|
+
StepItem(prompt) {
|
|
164
163
|
console.log(`├ ${prompt}`);
|
|
165
164
|
}
|
|
166
|
-
|
|
165
|
+
StepKV(key, value) {
|
|
167
166
|
const orange = chalk.hex('#FFA500');
|
|
168
167
|
console.log(`│ ${orange(key)} ${value}`);
|
|
169
168
|
}
|
|
170
|
-
|
|
169
|
+
StepSpacer() {
|
|
171
170
|
console.log('│');
|
|
172
171
|
}
|
|
173
|
-
|
|
172
|
+
StepEnd(str) {
|
|
174
173
|
console.log(`╰ ${str || ''}`);
|
|
175
174
|
}
|
|
176
|
-
|
|
175
|
+
StepEndInline() {
|
|
177
176
|
try {
|
|
178
177
|
process.stdout.write('╰ ');
|
|
179
178
|
}
|
|
@@ -42,7 +42,8 @@ export function ensureRoutineExists(name) {
|
|
|
42
42
|
const server = yield ApiService.getInstance();
|
|
43
43
|
const createRes = yield server.createRoutine({
|
|
44
44
|
name: name,
|
|
45
|
-
description: ''
|
|
45
|
+
description: '',
|
|
46
|
+
hasAssets: true
|
|
46
47
|
});
|
|
47
48
|
const isSuccess = (createRes === null || createRes === void 0 ? void 0 : createRes.data.Status) === 'OK';
|
|
48
49
|
if (isSuccess) {
|