@hed-hog/cli 0.0.110 → 0.0.112
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/package.json +1 -1
- package/dist/src/modules/developer/developer.service.d.ts +2 -0
- package/dist/src/modules/developer/developer.service.js +52 -2
- package/dist/src/modules/developer/developer.service.js.map +1 -1
- package/dist/src/templates/deployment/scripts.promote-production.js.ejs +291 -0
- package/dist/src/templates/deployment/workflow.deploy.yml.ejs +174 -0
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +1 -1
package/dist/package.json
CHANGED
|
@@ -67,6 +67,8 @@ export declare class DeveloperService {
|
|
|
67
67
|
private generateComposeServiceHelmCharts;
|
|
68
68
|
private generateDockerignore;
|
|
69
69
|
private generateGitHubActionsWorkflow;
|
|
70
|
+
private generatePromoteProductionScript;
|
|
71
|
+
private updatePackageJsonScripts;
|
|
70
72
|
private generateKubernetesManifests;
|
|
71
73
|
private parseDotEnv;
|
|
72
74
|
private getAppEnvVariables;
|
|
@@ -1287,7 +1287,7 @@ CMD ["sh", "-c", "${startCmd}"]
|
|
|
1287
1287
|
{
|
|
1288
1288
|
type: 'input',
|
|
1289
1289
|
name: 'apiDomain',
|
|
1290
|
-
message: 'Enter the API URL for
|
|
1290
|
+
message: 'Enter the API base URL for frontend apps (used for NEXT_PUBLIC_API_BASE_URL, INTERNAL_API_URL, and <APP_NAME>_API_BASE_URL):',
|
|
1291
1291
|
default: (answers) => {
|
|
1292
1292
|
const domain = String(answers.domain || '').trim();
|
|
1293
1293
|
const appName = String(answers.appName || '').trim();
|
|
@@ -1300,7 +1300,9 @@ CMD ["sh", "-c", "${startCmd}"]
|
|
|
1300
1300
|
},
|
|
1301
1301
|
filter: (input) => String(input || '').trim(),
|
|
1302
1302
|
validate: (input) => String(input || '').trim().length > 0 || 'API domain is required',
|
|
1303
|
-
when: (answers) => (answers.apps || []).
|
|
1303
|
+
when: (answers) => (answers.apps || []).some(function (app) {
|
|
1304
|
+
return app !== 'api';
|
|
1305
|
+
}),
|
|
1304
1306
|
},
|
|
1305
1307
|
{
|
|
1306
1308
|
type: 'input',
|
|
@@ -1420,6 +1422,10 @@ CMD ["sh", "-c", "${startCmd}"]
|
|
|
1420
1422
|
}
|
|
1421
1423
|
// Generate GitHub Actions workflow
|
|
1422
1424
|
await this.generateGitHubActionsWorkflow(workflowsDir, config);
|
|
1425
|
+
// Generate promote-production script
|
|
1426
|
+
await this.generatePromoteProductionScript(path, config);
|
|
1427
|
+
// Add production scripts to package.json
|
|
1428
|
+
await this.updatePackageJsonScripts(path);
|
|
1423
1429
|
// Generate Kubernetes manifests for each app
|
|
1424
1430
|
for (const app of config.apps) {
|
|
1425
1431
|
await this.generateKubernetesManifests(path, k8sDir, app, config);
|
|
@@ -1541,6 +1547,50 @@ temp
|
|
|
1541
1547
|
await (0, promises_1.writeFile)(workflowPath, workflowContent, 'utf8');
|
|
1542
1548
|
this.log(chalk.green(`Created GitHub Actions workflow: ${workflowPath}`));
|
|
1543
1549
|
}
|
|
1550
|
+
async generatePromoteProductionScript(path, config) {
|
|
1551
|
+
const scriptsDir = pathModule.join(path, 'scripts');
|
|
1552
|
+
await (0, promises_1.mkdir)(scriptsDir, { recursive: true });
|
|
1553
|
+
const scriptPath = pathModule.join(scriptsDir, 'promote-production.js');
|
|
1554
|
+
if ((0, fs_1.existsSync)(scriptPath)) {
|
|
1555
|
+
this.log(chalk.yellow('scripts/promote-production.js already exists, skipping...'));
|
|
1556
|
+
return;
|
|
1557
|
+
}
|
|
1558
|
+
const templatePath = pathModule.join(__dirname, '..', '..', 'templates', 'deployment', 'scripts.promote-production.js.ejs');
|
|
1559
|
+
const templateContent = await (0, promises_1.readFile)(templatePath, 'utf8');
|
|
1560
|
+
const scriptContent = await (0, ejs_1.render)(templateContent, { config });
|
|
1561
|
+
await (0, promises_1.writeFile)(scriptPath, scriptContent, 'utf8');
|
|
1562
|
+
this.log(chalk.green('Created scripts/promote-production.js'));
|
|
1563
|
+
}
|
|
1564
|
+
async updatePackageJsonScripts(path) {
|
|
1565
|
+
const packageJsonPath = pathModule.join(path, 'package.json');
|
|
1566
|
+
if (!(0, fs_1.existsSync)(packageJsonPath)) {
|
|
1567
|
+
return;
|
|
1568
|
+
}
|
|
1569
|
+
try {
|
|
1570
|
+
const content = await (0, promises_1.readFile)(packageJsonPath, 'utf8');
|
|
1571
|
+
const pkg = JSON.parse(content);
|
|
1572
|
+
if (!pkg.scripts) {
|
|
1573
|
+
pkg.scripts = {};
|
|
1574
|
+
}
|
|
1575
|
+
let modified = false;
|
|
1576
|
+
if (!pkg.scripts['production']) {
|
|
1577
|
+
pkg.scripts['production'] = 'node ./scripts/promote-production.js';
|
|
1578
|
+
modified = true;
|
|
1579
|
+
}
|
|
1580
|
+
if (!pkg.scripts['promote:production']) {
|
|
1581
|
+
pkg.scripts['promote:production'] =
|
|
1582
|
+
'node ./scripts/promote-production.js';
|
|
1583
|
+
modified = true;
|
|
1584
|
+
}
|
|
1585
|
+
if (modified) {
|
|
1586
|
+
await (0, promises_1.writeFile)(packageJsonPath, JSON.stringify(pkg, null, 2) + '\n', 'utf8');
|
|
1587
|
+
this.log(chalk.green('Updated package.json with production scripts'));
|
|
1588
|
+
}
|
|
1589
|
+
}
|
|
1590
|
+
catch {
|
|
1591
|
+
this.log(chalk.yellow('Could not update package.json scripts'));
|
|
1592
|
+
}
|
|
1593
|
+
}
|
|
1544
1594
|
async generateKubernetesManifests(projectPath, dir, app, config) {
|
|
1545
1595
|
const appDir = pathModule.join(dir, app);
|
|
1546
1596
|
await (0, promises_1.mkdir)(appDir, { recursive: true });
|