-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
22de23b
commit 1dbcba6
Showing
22 changed files
with
3,601 additions
and
3,727 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/** | ||
* Copyright 2013-2024 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. | ||
*/ | ||
|
||
const defaultCommands = { | ||
'generate-sample': { | ||
desc: 'Generate a test sample', | ||
blueprint: '@jhipster/jhipster-dev', | ||
}, | ||
'github-build-matrix': { | ||
desc: 'Build a matrix of jobs for github actions', | ||
blueprint: '@jhipster/jhipster-dev', | ||
}, | ||
}; | ||
|
||
export default defaultCommands; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
/** | ||
* Copyright 2013-2024 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 { GENERATOR_APP } from 'generator-jhipster/generators'; | ||
import { getSamples } from './get-samples.mjs'; | ||
|
||
/** | ||
* @type {import('generator-jhipster').JHipsterCommandDefinition} | ||
*/ | ||
const command = { | ||
arguments: { | ||
sampleName: { | ||
type: String, | ||
}, | ||
}, | ||
configs: { | ||
sampleName: { | ||
prompt: gen => ({ | ||
when: !gen.all, | ||
type: 'list', | ||
message: 'which sample do you want to generate?', | ||
choices: async () => getSamples(gen.templatePath(gen.samplesFolder)), | ||
}), | ||
scope: 'generator', | ||
}, | ||
all: { | ||
description: 'Generate every sample in a workspace', | ||
cli: { | ||
type: Boolean, | ||
}, | ||
scope: 'generator', | ||
}, | ||
samplesFolder: { | ||
description: 'Path to the samples folder', | ||
cli: { | ||
type: String, | ||
}, | ||
default: 'samples', | ||
scope: 'generator', | ||
}, | ||
}, | ||
options: {}, | ||
import: [GENERATOR_APP], | ||
}; | ||
|
||
export default command; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import { readdir } from 'node:fs/promises'; | ||
import { readFileSync } from 'node:fs'; | ||
import BaseGenerator from 'generator-jhipster/generators/base'; | ||
|
||
export default class extends BaseGenerator { | ||
sampleName; | ||
all; | ||
samplesFolder; | ||
|
||
constructor(args, opts, features) { | ||
super(args, opts, { ...features, queueCommandTasks: true, jhipsterBootstrap: false }); | ||
} | ||
|
||
get [BaseGenerator.WRITING]() { | ||
return this.asWritingTaskGroup({ | ||
async copySample() { | ||
const samplesFolder = `${this.samplesFolder ?? 'samples'}/`; | ||
if (this.all) { | ||
this.copyTemplate(`${samplesFolder}*.jdl`, ''); | ||
} else { | ||
this.copyTemplate(`${samplesFolder}${this.sampleName}`, this.sampleName, { noGlob: true }); | ||
} | ||
}, | ||
}); | ||
} | ||
|
||
get [BaseGenerator.END]() { | ||
return this.asEndTaskGroup({ | ||
async generateSample() { | ||
const packageJson = JSON.parse(readFileSync(new URL('../../package.json', import.meta.url))); | ||
const projectVersion = `${packageJson.version}-git`; | ||
|
||
await this.composeWithJHipster('jdl', { | ||
generatorArgs: this.all ? await readdir(this.templatePath('samples')) : [this.sampleName], | ||
generatorOptions: { | ||
skipJhipsterDependencies: true, | ||
insight: false, | ||
skipChecks: true, | ||
projectVersion, | ||
...(this.all ? { workspaces: true, monorepository: true } : { skipInstall: true }), | ||
}, | ||
}); | ||
}, | ||
async jhipsterInfo() { | ||
await this.composeWithJHipster('info'); | ||
}, | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { readdir, stat } from 'node:fs/promises'; | ||
import { extname } from 'path'; | ||
|
||
export const getSamples = async samplesFolder => { | ||
const filenames = await readdir(samplesFolder); | ||
const entries = await Promise.all(filenames.map(async filename => [filename, await stat(`${samplesFolder}/${filename}`)])); | ||
return entries | ||
.filter(([filename, statResult]) => extname(filename) === '.jdl' || statResult.isDirectory()) | ||
.map(([filename]) => filename) | ||
.filter(filename => !filename.includes('disabled')); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export { default } from './generator.mjs'; | ||
export { default as command } from './command.mjs'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { RECOMMENDED_JAVA_VERSION, RECOMMENDED_NODE_VERSION } from 'generator-jhipster'; | ||
import { fromMatrix } from 'generator-jhipster/testing'; | ||
|
||
const defaultMatrix = { | ||
os: ['ubuntu-latest'], | ||
'node-version': [RECOMMENDED_NODE_VERSION], | ||
'java-version': [RECOMMENDED_JAVA_VERSION], | ||
'default-environment': ['prod'], | ||
}; | ||
|
||
export const buildMatrix = ({ samples, samplesFolder }) => { | ||
return { | ||
include: Object.values( | ||
fromMatrix({ | ||
...defaultMatrix, | ||
'sample-name': samples, | ||
}), | ||
).map(sample => ({ | ||
...sample, | ||
'job-name': sample['sample-name'], | ||
'extra-args': `--samples-folder ${samplesFolder}`, | ||
})), | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
/** | ||
* @type {import('generator-jhipster').JHipsterCommandDefinition} | ||
*/ | ||
const command = { | ||
configs: { | ||
samplesFolder: { | ||
description: 'Samples folder', | ||
cli: { | ||
type: String, | ||
}, | ||
default: 'samples', | ||
scope: 'generator', | ||
}, | ||
}, | ||
options: {}, | ||
}; | ||
|
||
export default command; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { appendFileSync, existsSync } from 'node:fs'; | ||
import os from 'node:os'; | ||
import BaseGenerator from 'generator-jhipster/generators/base'; | ||
import { getSamples } from '../generate-sample/get-samples.mjs'; | ||
import { buildMatrix } from './build-matrix.mjs'; | ||
|
||
export default class extends BaseGenerator { | ||
samplesFolder; | ||
|
||
constructor(args, opts, features) { | ||
super(args, opts, { ...features, queueCommandTasks: true, jhipsterBootstrap: false }); | ||
} | ||
|
||
get [BaseGenerator.WRITING]() { | ||
return this.asWritingTaskGroup({ | ||
async buildMatrix() { | ||
const samplesFolder = this.samplesFolder ?? 'samples'; | ||
const samples = await getSamples(this.templatePath(`../../generate-sample/templates/${samplesFolder}`)); | ||
const matrix = buildMatrix({ samples, samplesFolder }); | ||
const matrixoutput = `matrix<<EOF${os.EOL}${JSON.stringify(matrix)}${os.EOL}EOF${os.EOL}`; | ||
const filePath = process.env.GITHUB_OUTPUT; | ||
console.log(matrixoutput); | ||
if (filePath && existsSync(filePath)) { | ||
appendFileSync(filePath, matrixoutput, { encoding: 'utf8' }); | ||
} | ||
}, | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export { default } from './generator.mjs'; | ||
export { default as command } from './command.mjs'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,10 +9,9 @@ jobs: | |
timeout-minutes: 10 | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/setup-node@v3 | ||
- uses: actions/setup-node@v4 | ||
with: | ||
node-version: 18 | ||
node-version: 20 | ||
cache: 'npm' | ||
- run: git config --global user.name "JHipster Bot"; git config --global user.email "[email protected]"; git config --global init.defaultBranch main | ||
- run: npm ci | ||
- run: npm run test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,8 @@ | ||
# Prettier configuration | ||
|
||
printWidth: 140 | ||
singleQuote: true | ||
tabWidth: 2 | ||
useTabs: false | ||
|
||
# js and ts rules: | ||
arrowParens: avoid | ||
bracketSameLine: false | ||
plugins: | ||
- prettier-plugin-packagejson |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
// This file will not be overwritten by generate-blueprint | ||
module.exports = {}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.