in packages/amplify-codegen/src/walkthrough/add.js [16:89]
async function addWalkThrough(context, skip = [], withoutInit, decoupleFrontend, decoupleFramework) {
let inputParams;
let yesFlag = false;
if (context.exeInfo && context.exeInfo.inputParams) {
normalizeInputParams(context);
inputParams = context.exeInfo.inputParams[constants.Label];
yesFlag = context.exeInfo.inputParams.yes;
}
let frontend = decoupleFrontend;
let schemaLocation = '';
if (frontend === 'android') {
schemaLocation = './app/src/main/graphql/schema.json';
} else if (frontend === 'ios') {
schemaLocation = './graphql/schema.json';
} else if (frontend === 'javascript') {
schemaLocation = './src/graphql/schema.json';
} else {
schemaLocation = './src/graphql/schema.json';
}
if (!withoutInit) {
frontend = getFrontEndHandler(context);
schemaLocation = getSchemaDownloadLocation(context);
}
const answers = {
excludePattern: DEFAULT_EXCLUDE_PATTERNS,
schemaLocation,
};
let targetLanguage = 'android';
if (frontend !== 'android') {
if (!skip.includes('targetLanguage')) {
answers.target = await determineValue(inputParams, yesFlag, 'targetLanguage', 'javascript', () =>
askCodeGenTargetLanguage(context, undefined, withoutInit, decoupleFrontend, decoupleFramework)
);
targetLanguage = answers.target;
}
}
const includePatternDefault = getIncludePattern(targetLanguage, schemaLocation);
const includePathGlob = join(includePatternDefault.graphQLDirectory, '**', includePatternDefault.graphQLExtension);
const docsFilePathDefault = includePatternDefault.graphQLDirectory;
if (!skip.includes('includePattern')) {
answers.includePattern = await determineValue(inputParams, yesFlag, 'includePattern', [includePathGlob], () =>
askCodeGenQueryFilePattern([includePathGlob])
);
}
if (!skip.includes('shouldGenerateDocs')) {
answers.shouldGenerateDocs = await determineValue(inputParams, yesFlag, 'generateDocs', true, () => askShouldGenerateDocs());
answers.docsFilePath = getGraphQLDocPath(frontend, docsFilePathDefault, answers.includePattern);
}
if (answers.shouldGenerateDocs && !skip.includes('maxDepth')) {
answers.maxDepth = await determineValue(inputParams, yesFlag, 'maxDepth', true, askMaxDepth);
}
if (!(frontend === 'android' || answers.target === 'javascript')) {
if (!skip.includes('generatedFileName')) {
const defaultValue = getOutputFileName('API', answers.target || '');
answers.generatedFileName = await determineValue(inputParams, yesFlag, 'generatedFileName', defaultValue, () =>
askTargetFileName('API', answers.target || '')
);
}
if (!skip.includes('shouldGenerateCode')) {
answers.shouldGenerateCode = await determineValue(inputParams, yesFlag, 'generateCode', true, () => askShouldGenerateCode());
}
}
return answers;
}