MCPcopy Create free account
hub / github.com/kriasoft/graphql-starter-kit / done

Function done

scripts/setup.js:157–200  ·  view source on GitHub ↗
(answers)

Source from the content-addressed store, hash-verified

155];
156
157async function done(answers) {
158 // Remove this script
159 if (answers.clean) {
160 fs.unlinkSync("./scripts/setup.js");
161 let text = fs.readFileSync("./package.json", "utf8");
162 text = text.replace(/\n\s+"setup": ".*?\n/s, "\n");
163 fs.writeFileSync("./package.json", text, "utf8");
164 spawn.sync(
165 "yarn",
166 ["workspace", "scripts", "remove", "inquirer", "dotenv"],
167 { stdio: "inherit" },
168 );
169 }
170
171 if (answers.setup) {
172 // Generate JWT secret(s)
173 Object.keys(environments).forEach((env) => {
174 let text = fs.readFileSync(`env/.${env}.env`, "utf8");
175 let [, secret] = text.match(/^JWT_SECRET=(.*)/m) || [];
176 if (secret === "n2127bOgmzao67RiW3umlVs16GL9fEj+JQRDaaN5E9G7yC/b") {
177 secret = crypto.randomBytes(36).toString("base64");
178 text = text.replace(/^(JWT_SECRET)=.*/m, `$1=${secret}`);
179 fs.writeFileSync(`env/.${env}.env`, text, "utf8");
180 }
181 });
182
183 console.log(` `);
184 console.log(
185 ` Done! Now you can migrate the database and launch the app by running:`,
186 );
187 } else {
188 console.log(` `);
189 console.log(` No problem. You can run this script at any time later.`);
190 console.log(
191 ` Now you can migrate the database and launch the app by running:`,
192 );
193 }
194
195 console.log(` `);
196 console.log(` $ yarn db:reset`);
197 console.log(` $ yarn api:start`);
198 console.log(` $ yarn app:start`);
199 console.log(` `);
200}
201
202inquirer
203 .prompt(questions)

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected