Skip to content

Commit

Permalink
Improve .gitingnore
Browse files Browse the repository at this point in the history
  • Loading branch information
sebt3 committed Feb 8, 2024
1 parent 0cfeb0c commit 0d59dad
Show file tree
Hide file tree
Showing 2 changed files with 117 additions and 7 deletions.
41 changes: 34 additions & 7 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,37 @@
/node_modules
/.tags
/.package-lock.json
/back/resolvers/*/gen.*
/back/schema/gen.*
/front/components/*/gen.*
/front/queries/*/gen.*
/front/routes/*/gen.*
/front/pages/*/*/gen.*
/front/libs/*/gen.*
/back/resolvers/index.ts
/back/resolvers/*/*
!/back/resolvers/k8s/custom.ts
!/back/resolvers/k8s/permissions.ts
!/back/resolvers/core/index.ts
!/back/resolvers/core/custom.ts
!/back/resolvers/vynil/custom.ts
!/back/resolvers/vynil/Package.ts
!/back/resolvers/vynil/Category.ts
/back/schema/*
!/back/schema/core.graphql
/front/queries/*/*
!/front/queries/vynil/Dashboard.graphql
!/front/queries/core/CustomResourceDefinition.graphql
!/front/queries/core/GramoConfig.graphql
/front/routes/index.ts
/front/routes/*/*
/front/components/*/
!/front/components/core/*
!/front/components/navigation/*
!/front/components/vynil/DistribStatus.vue
!/front/components/vynil/InstallStatus.vue
!/front/components/vynil/InstallView.vue
!/front/components/vynil/PackageList.vue
!/front/components/vynil/CategoryList.vue
!/front/components/charts/*
/front/libs/*/*
!/front/libs/*/custom.ts
!/front/libs/core/*
/front/pages/*/*/*
!/front/pages/automation/fluxcd/Dashboard.vue
!/front/pages/install/vynil/DistribView.vue
!/front/pages/install/vynil/InstallView.vue
!/front/pages/install/vynil/Dashboard.vue
83 changes: 83 additions & 0 deletions utils/deleteGenerated.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
#!/usr/bin/env -S npx ts-node-esm
import path from 'path';
import { fileURLToPath } from 'url';
import {LoadFrom,mkdir} from './generator/utils.js'
import {removeGenerated} from './generator/hb.js'
import {allCategories} from './generator/config.js'
import * as fs from 'fs';

const __dirname = path.dirname(fileURLToPath(import.meta.url));
const path_data = path.resolve(__dirname, '..', 'data');
const path_back = path.resolve(__dirname, '..', 'back');
const path_front = path.resolve(__dirname, '..', 'front');
const path_lib = path.resolve(__dirname, 'generator');

////////////////////////////////////
//// Load the data
///
new Promise((resolve) => {
resolve(
fs.readdirSync(path_data)
.map(f=>path.resolve(path_data,f))
.filter(f=>fs.statSync(f).isFile() && f.match(/.*\.json$/))
.map(f=>LoadFrom(f))
);
}).then(data => {
////////////////////////////////////
//// Generate the backend
///
// Use the defined templates with the generated enhenced data to build the backend

const current = data as {name:string,objects:{short:string}[]}[];
removeGenerated(path.resolve(path_back, 'resolvers'), 'index.ts');
removeGenerated(path.resolve(path_back, 'resolvers', 'k8s'), `nsResolvers.ts`);
removeGenerated(path.resolve(path_back, 'schema'), `k8sNamespace.graphql`);
current.forEach(g => {
removeGenerated(path.resolve(path_back, 'schema'), `${g.name}.graphql`);
removeGenerated(path.resolve(path_back, 'resolvers', g.name), 'custom.ts');
removeGenerated(path.resolve(path_back, 'resolvers', g.name), 'index.ts');
removeGenerated(path.resolve(path_back, 'resolvers', 'k8s'), `nsResolvers.${g.name}.ts`);
g.objects.forEach(o => {
removeGenerated(path.resolve(path_back, 'resolvers', g.name), `${o.short}.ts`)
})
})
return data
}).then(data => {
////////////////////////////////////
//// Generate the Frontend
///
// Exact same strategy and data as for the backend, using diffrent templates
const current = data as {name:string,objects:{short:string, category:string, readProperties:string[]}[]}[];
removeGenerated(path.resolve(path_front, 'routes'), `index.ts`)
allCategories.forEach(c=>{
removeGenerated(path.resolve(path_front, 'routes', c), 'index.ts')
})
current.forEach(g => {
removeGenerated(path.resolve(path_front, 'libs', g.name),`custom.ts`)
allCategories.filter(c=> g.objects.filter(o=>o.category==c).length>0).forEach(c=>{
removeGenerated(path.resolve(path_front, 'routes', c), `${g.name}.ts`);
removeGenerated(path.resolve(path_front, 'pages', c, g.name), 'Dashboard.vue');
removeGenerated(path.resolve(path_front, 'queries', g.name), `${c}.read.graphql`)
removeGenerated(path.resolve(path_front, 'queries', g.name), `${c}.details.graphql`)
})
g.objects.forEach(o => {
removeGenerated(path.resolve(path_front, 'queries', g.name), `${o.short}.create.graphql`)
removeGenerated(path.resolve(path_front, 'queries', g.name), `${o.short}.delete.graphql`)
removeGenerated(path.resolve(path_front, 'queries', g.name), `${o.short}.patch.graphql`)
removeGenerated(path.resolve(path_front, 'queries', g.name), `${o.short}.read.graphql`)
removeGenerated(path.resolve(path_front, 'queries', g.name), `${o.short}.details.graphql`)
removeGenerated(path.resolve(path_front, 'components', g.name),`${o.short}Edit.vue`)
removeGenerated(path.resolve(path_front, 'components', g.name),`${o.short}List.vue`)
removeGenerated(path.resolve(path_front, 'components', g.name),`${o.short}Meta.vue`)
if (o.readProperties.includes('status'))
removeGenerated(path.resolve(path_front, 'components', g.name),`${o.short}Status.vue`);
removeGenerated(path.resolve(path_front, 'components', g.name),`${o.short}View.vue`)
removeGenerated(path.resolve(path_front, 'pages', o['category'], g.name),`${o.short}Edit.vue`)
removeGenerated(path.resolve(path_front, 'pages', o['category'], g.name),`${o.short}List.vue`)
removeGenerated(path.resolve(path_front, 'pages', o['category'], g.name),`${o.short}View.vue`)
removeGenerated(path.resolve(path_front, 'pages', o['category'], g.name),`${o.short}New.vue`)
removeGenerated(path.resolve(path_front, 'libs', g.name),`${o.short}.ts`)
})
})
return data
})

0 comments on commit 0d59dad

Please sign in to comment.