MCPcopy Create free account
hub / github.com/Snapchat/Valdi / promptChecks

Function promptChecks

npm_modules/cli/src/commands/newModule.ts:90–152  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

88}
89
90async function promptChecks(): Promise<Checks> {
91 let answers: Checks = {};
92
93 /**
94 * Verify Bazel Workspace
95 */
96 const bazelWorkspacePath = await getBazelWorkspaceRoot();
97
98 answers = await inquirer.prompt<Checks>(
99 [
100 {
101 type: 'confirm',
102 name: 'confirmBazelWorkspace',
103 message: 'Bazel WORKSPACE not found (did you run `valdi bootstrap` first?). Continue anyway?',
104 default: true,
105 when() {
106 return !bazelWorkspacePath;
107 },
108 },
109 ],
110 answers,
111 );
112
113 if (!bazelWorkspacePath && !answers.confirmBazelWorkspace) {
114 throw new CliError('Aborting.');
115 }
116
117 /**
118 * Verify directory structure
119 */
120 answers = await inquirer.prompt<Checks>(
121 {
122 type: 'confirm',
123 name: 'confirmValdiPath',
124 message:
125 '/modules directory not found (did you run `valdi bootstrap` first?). Create module in current directory?',
126 default: true,
127 when(answers) {
128 const curDir = process.cwd();
129 const parsedPath = path.parse(curDir);
130 if (parsedPath.base === 'modules') {
131 // Create the new module in the current directory
132 answers.valdiModulePath = curDir;
133 } else if (curDir === bazelWorkspacePath) {
134 // Create the new module in ./modules
135 const valdiPath = path.join(curDir, 'modules');
136 if (fs.existsSync(valdiPath)) {
137 answers.valdiModulePath = valdiPath;
138 }
139 }
140
141 return !answers.valdiModulePath;
142 },
143 },
144 answers,
145 );
146
147 if (!answers.valdiModulePath && !answers.confirmValdiPath) {

Callers 1

valdiNewModuleFunction · 0.85

Calls 1

getBazelWorkspaceRootFunction · 0.85

Tested by

no test coverage detected