feat(installer): default project name to directory (#681)
This commit is contained in:
@@ -16,7 +16,7 @@ prompt:
|
|||||||
|
|
||||||
project_name:
|
project_name:
|
||||||
prompt: "What is the title of your project you will be working on?"
|
prompt: "What is the title of your project you will be working on?"
|
||||||
default: "My Project"
|
default: "{directory_name}"
|
||||||
result: "{value}"
|
result: "{value}"
|
||||||
|
|
||||||
tech_docs:
|
tech_docs:
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ class ConfigCollector {
|
|||||||
constructor() {
|
constructor() {
|
||||||
this.collectedConfig = {};
|
this.collectedConfig = {};
|
||||||
this.existingConfig = null;
|
this.existingConfig = null;
|
||||||
|
this.currentProjectDir = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -93,6 +94,7 @@ class ConfigCollector {
|
|||||||
* @param {boolean} skipCompletion - Skip showing completion message (for early core collection)
|
* @param {boolean} skipCompletion - Skip showing completion message (for early core collection)
|
||||||
*/
|
*/
|
||||||
async collectModuleConfig(moduleName, projectDir, skipLoadExisting = false, skipCompletion = false) {
|
async collectModuleConfig(moduleName, projectDir, skipLoadExisting = false, skipCompletion = false) {
|
||||||
|
this.currentProjectDir = projectDir;
|
||||||
// Load existing config if needed and not already loaded
|
// Load existing config if needed and not already loaded
|
||||||
if (!skipLoadExisting && !this.existingConfig) {
|
if (!skipLoadExisting && !this.existingConfig) {
|
||||||
await this.loadExistingConfig(projectDir);
|
await this.loadExistingConfig(projectDir);
|
||||||
@@ -281,6 +283,11 @@ class ConfigCollector {
|
|||||||
let defaultValue = item.default;
|
let defaultValue = item.default;
|
||||||
let choices = null;
|
let choices = null;
|
||||||
|
|
||||||
|
if (typeof defaultValue === 'string' && defaultValue.includes('{directory_name}') && this.currentProjectDir) {
|
||||||
|
const dirName = path.basename(this.currentProjectDir);
|
||||||
|
defaultValue = defaultValue.replaceAll('{directory_name}', dirName);
|
||||||
|
}
|
||||||
|
|
||||||
// Handle different question types
|
// Handle different question types
|
||||||
if (item['single-select']) {
|
if (item['single-select']) {
|
||||||
questionType = 'list';
|
questionType = 'list';
|
||||||
|
|||||||
Reference in New Issue
Block a user