Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/collection.json
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,11 @@
"factory": "./lib/docker/fusionauth/fusionauth.factory#main",
"description": "Add fusionauth service to docker-compose.yml",
"schema": "./lib/docker/fusionauth/schema.json"
},
"pullservice": {
"factory": "./lib/pullservices/pullservice/pullservice.factory#main",
"description": "Add frontend service required for pull command",
"schema": "./lib/pullservices/pullservice/schema.json"
}
}
}
6 changes: 6 additions & 0 deletions src/lib/pullservices/files/ts/frontend/astro.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// astro.config.mjs
export default {
site: 'http://localhost:3000',
output: 'static',
};

5,816 changes: 5,816 additions & 0 deletions src/lib/pullservices/files/ts/frontend/package-lock.json

Large diffs are not rendered by default.

14 changes: 14 additions & 0 deletions src/lib/pullservices/files/ts/frontend/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"name": "minimal-astro",
"version": "1.0.0",
"scripts": {
"dev": "astro dev",
"build": "astro build",
"preview": "astro preview"
},
"dependencies": {
"astro": "^2.0.0",
"yaml": "^2.0.0"
}
}

1 change: 1 addition & 0 deletions src/lib/pullservices/files/ts/frontend/src/env.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/// <reference types="astro/client" />
127 changes: 127 additions & 0 deletions src/lib/pullservices/files/ts/frontend/src/pages/index.astro
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
---
import yaml from 'yaml';
import fs from 'fs';
import path from 'path';

function getSpecData() {
let specFilePath;
const parentDir = path.resolve(process.cwd(), '..');
const nestCliPath = path.join(parentDir, 'nest-cli.json');

if (fs.existsSync(nestCliPath)) {
const nestCliContent = fs.readFileSync(nestCliPath, 'utf8');
const nestConfig = JSON.parse(nestCliContent);

if (nestConfig.specFile) {
specFilePath = path.resolve(nestConfig.specFile);
}
}

if (!specFilePath || !fs.existsSync(specFilePath)) {
specFilePath = path.join(parentDir,'spec.yaml');
}
if (fs.existsSync(specFilePath)) {
const specFileContent = fs.readFileSync(specFilePath, 'utf8');
return yaml.parse(specFileContent);
} else {
console.error("Error reading spec file: Neither 'specFile' in nest-cli.json nor 'spec.yaml' exists.");
return null;
}
}

const specData = getSpecData();
const services = specData ? specData.services || [] : [];

---

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Service Overview</title>
<style>
body {
font-family: Arial, sans-serif;
background-color: #f4f7fa;
color: #333;
margin: 0;
padding: 20px;
}

h1 {
color: #2c3e50;
text-align: center;
}

.container {
max-width: 800px;
margin: 0 auto;
padding: 20px;
background: #ffffff;
border-radius: 8px;
box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.service-list {
list-style: none;
padding: 0;
}

.service-item {
background: #ecf0f1;
margin: 10px 0;
padding: 15px;
border-radius: 4px;
display: flex;
justify-content: space-between;
align-items: center;
}

.service-name {
font-size: 18px;
font-weight: bold;
}

.service-status {
font-size: 14px;
color: #27ae60;
}

.footer {
text-align: center;
margin-top: 20px;
font-size: 14px;
color: #7f8c8d;
}

.btn {
padding: 10px 15px;
border: none;
border-radius: 4px;
background-color: #3498db;
color: #ffffff;
cursor: pointer;
text-decoration: none;
transition: background-color 0.3s;
}

.btn:hover {
background-color: #2980b9;
}
</style>
</head>
<body>
<div class="container">
<h1>Available Services</h1>
<ul class="service-list">
{services.map(service => (
<li class="service-item">
<span class="service-name">{service}</span>
<span class="service-status">✔️ Active</span>
</li>
))}
</ul>
</div>
</body>
</html>
39 changes: 39 additions & 0 deletions src/lib/pullservices/pullservice/pullservice.factory.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import { Path, join } from '@angular-devkit/core';
import {
apply,
url,
branchAndMerge,
chain,
Rule,
SchematicContext,
Tree,
move,
mergeWith,
} from '@angular-devkit/schematics';

import { PullOptions } from './pullservice.schema';

export function main(options: PullOptions): Rule {
return (tree: Tree, context: SchematicContext) => {
return branchAndMerge(
chain([
generateBasicFiles(options, context),
]),
)(tree, context);
};
}

function generateBasicFiles(
options: PullOptions,
context: SchematicContext,
): Rule {
return (tree: Tree) => {
const path = './frontend';
const sourceTemplate = apply(
url(join('../files' as Path, options.language, 'frontend' as Path)),
[move(path)],
);
return chain([mergeWith(sourceTemplate)])(tree, context);
};
}

9 changes: 9 additions & 0 deletions src/lib/pullservices/pullservice/pullservice.schema.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { Path } from '@angular-devkit/core';

export interface PullOptions {
name?: string;
directory?: string;
language?: string;
sourceRoot?: string;
flat?: boolean;
}
16 changes: 16 additions & 0 deletions src/lib/pullservices/pullservice/schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"$schema": "http://json-schema.org/draft-07/schema",
"$id": "Pull-Service",
"title": "Custom Pull-Service Insertion",
"type": "object",
"properties": {
"name": {
"type": "string",
"description": "The name of the generate."
},
"language": {
"type": "string",
"description": "The source root path."
}
}
}
1 change: 0 additions & 1 deletion src/lib/service-temporal/service-temporal.factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import {
import { ModuleFinder } from '../../utils/module.finder';
import { TemporalServiceOptions } from './service-temporal.schema';
import { import_register } from './imports';
import { content } from './env-content';
import { NodeDependencyType, addPackageJsonDependency, getPackageJsonDependency } from '../../utils/dependencies.utils';
import { NodePackageInstallTask } from '@angular-devkit/schematics/tasks';

Expand Down