-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Expand file tree
/
Copy pathfiles.ts
More file actions
137 lines (134 loc) · 5.29 KB
/
Copy pathfiles.ts
File metadata and controls
137 lines (134 loc) · 5.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
/**
* Copyright 2013-2026 the original author or authors from the JHipster project.
*
* This file is part of the JHipster project, see https://www.jhipster.tech/
* for more information.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { asWriteFilesSection } from '../base-application/support/index.ts';
import { LOCAL_BLUEPRINT_OPTION, TS } from './constants.ts';
import type { Application as GenerateBlueprintApplication, TemplateData } from './types.ts';
export const files = asWriteFilesSection<GenerateBlueprintApplication>({
baseFiles: [
{
condition: ctx => !ctx[LOCAL_BLUEPRINT_OPTION],
templates: [
'.github/workflows/generator.yml',
'.gitignore.jhi.blueprint',
'.prettierignore.jhi.blueprint',
'eslint.config.ts.jhi.blueprint',
'README.md',
'tsconfig.json',
'vitest.config.ts',
'vitest.test-setup.ts',
{
sourceFile: '.blueprint/cli/commands.mjs',
destinationFile: ctx => `.blueprint/cli/commands.${ctx[TS] ? 'ts' : 'mjs'}`,
},
{
sourceFile: '.blueprint/generate-sample/command.mjs',
destinationFile: ctx => `.blueprint/generate-sample/command.${ctx[TS] ? 'ts' : 'mjs'}`,
},
{
sourceFile: '.blueprint/generate-sample/generator.mjs',
destinationFile: ctx => `.blueprint/generate-sample/generator.${ctx[TS] ? 'ts' : 'mjs'}`,
},
{
sourceFile: '.blueprint/generate-sample/index.mjs',
destinationFile: ctx => `.blueprint/generate-sample/index.${ctx[TS] ? 'ts' : 'mjs'}`,
},
// Always write cli for devBlueprint usage
'cli/cli.cjs',
{ sourceFile: 'cli/cli-customizations.cjs', override: false },
],
},
{
condition: ctx => !ctx[LOCAL_BLUEPRINT_OPTION] && ctx.githubWorkflows,
templates: [
{
sourceFile: '.blueprint/github-build-matrix/command.mjs',
destinationFile: ctx => `.blueprint/github-build-matrix/command.${ctx[TS] ? 'ts' : 'mjs'}`,
},
{
sourceFile: '.blueprint/github-build-matrix/generator.mjs',
destinationFile: ctx => `.blueprint/github-build-matrix/generator.${ctx[TS] ? 'ts' : 'mjs'}`,
},
{
sourceFile: '.blueprint/github-build-matrix/generator.spec.mjs',
destinationFile: ctx => `.blueprint/github-build-matrix/generator.spec.${ctx[TS] ? 'ts' : 'mjs'}`,
},
{
sourceFile: '.blueprint/github-build-matrix/index.mjs',
destinationFile: ctx => `.blueprint/github-build-matrix/index.${ctx[TS] ? 'ts' : 'mjs'}`,
},
],
},
{
condition: ctx => !ctx[LOCAL_BLUEPRINT_OPTION] && ctx.githubWorkflows && !ctx.skipWorkflows,
templates: ['.github/workflows/build-cache.yml', '.github/workflows/samples.yml'],
},
{
condition: ctx => !ctx[LOCAL_BLUEPRINT_OPTION] && !ctx.sampleWritten,
templates: ['.blueprint/generate-sample/templates/samples/sample.jdl'],
},
{
condition: ctx => ctx.commands.length > 0,
templates: ['cli/commands.cjs'],
},
],
});
export const generatorFiles = asWriteFilesSection<TemplateData>({
generator: [
{
path: 'generators/generator',
to: ctx => `${ctx.application.blueprintsPath}${ctx.generator.replaceAll(':', '/generators/')}`,
templates: [
{
sourceFile: ctx => (ctx[TS] ? 'index.mts' : 'index.mjs'),
destinationFile: ctx => `index.${ctx.blueprintMjsExtension}`,
},
{
sourceFile: ctx => (ctx[TS] ? 'command.mts' : 'command.mjs'),
destinationFile: ctx => `command.${ctx.blueprintMjsExtension}`,
override: data => !data.ignoreExistingGenerators,
},
{
sourceFile: ctx => (ctx[TS] ? 'generator.mts.jhi' : 'generator.mjs.jhi'),
destinationFile: ctx => `generator.${ctx.blueprintMjsExtension}.jhi`,
override: data => !data.ignoreExistingGenerators,
},
{
condition: data => !data.generator.startsWith('entity') && !data.application[LOCAL_BLUEPRINT_OPTION],
sourceFile: ctx => (ctx[TS] ? 'generator.spec.mts' : 'generator.spec.mjs'),
destinationFile: data => `generator.spec.${data.blueprintMjsExtension}`,
override: data => !data.ignoreExistingGenerators,
},
],
},
{
path: 'generators/generator',
to: ctx => `${ctx.application.blueprintsPath}${ctx.generator.replaceAll(':', '/generators/')}`,
condition(ctx) {
return !ctx.written && ctx.priorities.some(priority => priority.name === 'writing');
},
transform: false,
templates: [
{
sourceFile: 'templates/template-file.ejs',
destinationFile: ctx => `templates/template-file-${ctx.generator}.ejs`,
},
],
},
],
});