-
-
Notifications
You must be signed in to change notification settings - Fork 4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #23087 from mshima/skip_ci-dev-blueprint
add a development blueprint
- Loading branch information
Showing
24 changed files
with
553 additions
and
185 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,35 @@ | ||
/** | ||
* Copyright 2013-2023 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 = { | ||
'code-workspace': { | ||
desc: 'Prepare a code-workspace for jhipster development', | ||
blueprint: '@jhipster/jhipster-dev', | ||
}, | ||
'generate-sample': { | ||
desc: 'Generate a test sample', | ||
blueprint: '@jhipster/jhipster-dev', | ||
}, | ||
'update-vscode': { | ||
desc: 'Update generator-jhipster vscode files', | ||
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,32 @@ | ||
/** | ||
* Copyright 2013-2023 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 { type JHipsterCommandDefinition } from '../../generators/base/api.mjs'; | ||
|
||
const command: JHipsterCommandDefinition = { | ||
arguments: {}, | ||
options: { | ||
sampleName: { | ||
type: String, | ||
description: 'Sample Name', | ||
scope: 'generator', | ||
}, | ||
}, | ||
}; | ||
|
||
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,72 @@ | ||
import { join } from 'path'; | ||
import _ from 'lodash'; | ||
import BaseGenerator from '../../generators/base/index.mjs'; | ||
import { getPackageRoot } from '../../lib/index.mjs'; | ||
import command from './command.mjs'; | ||
import { defaultSamplesFolder, promptSamplesFolder, samplesFolderConfig } from '../support.mjs'; | ||
|
||
const { merge } = _; | ||
|
||
export default class extends BaseGenerator { | ||
sampleName; | ||
|
||
get [BaseGenerator.INITIALIZING]() { | ||
return this.asInitializingTaskGroup({ | ||
async initializeOptions() { | ||
this.parseJHipsterArguments(command.arguments); | ||
this.parseJHipsterOptions(command.options); | ||
}, | ||
}); | ||
} | ||
|
||
get [BaseGenerator.PROMPTING]() { | ||
return this.asPromptingTaskGroup({ | ||
promptSamplesFolder, | ||
}); | ||
} | ||
|
||
get [BaseGenerator.WRITING]() { | ||
return this.asEndTaskGroup({ | ||
async generateCodeWorkspace() { | ||
this.addSampleToCodeWorkspace(this.sampleName); | ||
}, | ||
}); | ||
} | ||
|
||
getCodeWorkspacePath() { | ||
return join(this._globalConfig.get(samplesFolderConfig) ?? defaultSamplesFolder, 'jhipster-samples.code-workspace'); | ||
} | ||
|
||
/** | ||
* Merge value to an existing JSON and write to destination | ||
*/ | ||
addSampleToCodeWorkspace(sampleName) { | ||
this.editFile(this.getCodeWorkspacePath(), { create: true }, content => { | ||
const data = content ? JSON.parse(content) : {}; | ||
merge(data, { | ||
folders: [ | ||
{ | ||
path: getPackageRoot(), | ||
}, | ||
], | ||
settings: { | ||
'debug.javascript.terminalOptions': { | ||
skipFiles: ['node_modules/**', 'dist/**'], | ||
}, | ||
}, | ||
launch: { | ||
version: '0.2.0', | ||
inputs: [], | ||
configurations: [], | ||
}, | ||
}); | ||
if (this.sampleName && !data.folders.find(folder => folder.path === sampleName)) { | ||
data.folders.push({ | ||
path: this.sampleName, | ||
}); | ||
} | ||
|
||
return JSON.stringify(data, null, 2); | ||
}); | ||
} | ||
} |
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,15 @@ | ||
import { join } from 'path'; | ||
import { getPackageRoot } from '../lib/index.mjs'; | ||
|
||
const packageRoot = getPackageRoot(); | ||
export const defaultSamplesFolder = join(packageRoot, '../jhipster-samples'); | ||
export const testIntegrationFolder = join(packageRoot, 'test-integration'); | ||
export const samplesFolder = join(testIntegrationFolder, 'samples'); | ||
|
||
export const jhipsterBin = join(packageRoot, 'bin/jhipster.cjs'); | ||
|
||
export const jdlSamplesFolder = join(testIntegrationFolder, 'jdl-samples'); | ||
export const dailyBuildsFolder = join(testIntegrationFolder, 'daily-builds'); | ||
export const jdlEntitiesSamplesFolder = join(samplesFolder, 'jdl-entities'); | ||
|
||
export const entitiesSamplesDir = join(samplesFolder, '.jhipster'); |
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,42 @@ | ||
/** | ||
* Copyright 2013-2023 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 { JHipsterCommandDefinition } from '../../generators/base/api.mjs'; | ||
|
||
const command: JHipsterCommandDefinition = { | ||
arguments: { | ||
sampleName: { | ||
type: String, | ||
}, | ||
}, | ||
options: { | ||
global: { | ||
type: Boolean, | ||
description: 'Generate in global samples folder', | ||
scope: 'generator', | ||
}, | ||
projectFolder: { | ||
type: String, | ||
description: 'Folder to generate the sample', | ||
scope: 'generator', | ||
env: 'JHI_FOLDER_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,47 @@ | ||
import BaseGenerator from '../../generators/base/index.mjs'; | ||
import command from './command.mjs'; | ||
import { generateSample } from './support/generate-sample.js'; | ||
import { promptSamplesFolder } from '../support.mjs'; | ||
|
||
export default class extends BaseGenerator { | ||
sampleName; | ||
global; | ||
projectFolder; | ||
|
||
get [BaseGenerator.INITIALIZING]() { | ||
return this.asInitializingTaskGroup({ | ||
async initializeOptions() { | ||
this.parseJHipsterArguments(command.arguments); | ||
this.parseJHipsterOptions(command.options); | ||
}, | ||
}); | ||
} | ||
|
||
get [BaseGenerator.PROMPTING]() { | ||
return this.asPromptingTaskGroup({ | ||
async promptOptions() { | ||
if (this.global) { | ||
promptSamplesFolder.call(this); | ||
} | ||
}, | ||
}); | ||
} | ||
|
||
get [BaseGenerator.END]() { | ||
return this.asEndTaskGroup({ | ||
async generateSample() { | ||
await generateSample(this.sampleName, { | ||
destSamplesFolder: this._globalConfig.get('samplesFolder'), | ||
destProjectFolder: this.projectFolder ?? this.global ? undefined : process.cwd(), | ||
}); | ||
if (this.global) { | ||
await this.composeWithJHipster('@jhipster/jhipster-dev:code-workspace', { | ||
generatorOptions: { | ||
sampleName: this.sampleName, | ||
}, | ||
}); | ||
} | ||
}, | ||
}); | ||
} | ||
} |
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
7 changes: 2 additions & 5 deletions
7
...on/scripts/lib/copy-jdl-entity-samples.js → ...sample/support/copy-jdl-entity-samples.js
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.