MCPcopy Create free account
hub / github.com/observablehq/framework / getUpdatedDeployConfig

Method getUpdatedDeployConfig

src/deploy.ts:228–279  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

226
227 // Get the deploy config, updating if necessary.
228 private async getUpdatedDeployConfig() {
229 const deployConfig = await this.effects.getDeployConfig(
230 this.deployOptions.config.root,
231 this.deployOptions.deployConfigPath,
232 this.effects
233 );
234
235 if (deployConfig.workspaceLogin && !deployConfig.workspaceLogin.match(/^@?[a-z0-9-]+$/)) {
236 throw new CliError(
237 `Found invalid workspace login in ${join(this.deployOptions.config.root, ".observablehq", "deploy.json")}: ${
238 deployConfig.workspaceLogin
239 }.`
240 );
241 }
242 if (deployConfig.projectSlug && !deployConfig.projectSlug.match(/^[a-z0-9-]+$/)) {
243 throw new CliError(
244 `Found invalid \`projectSlug\` in ${join(this.deployOptions.config.root, ".observablehq", "deploy.json")}: ${
245 deployConfig.projectSlug
246 }.`
247 );
248 }
249
250 if (deployConfig.projectId && (!deployConfig.projectSlug || !deployConfig.workspaceLogin)) {
251 const spinner = this.effects.clack.spinner();
252 this.effects.clack.log.warn("The `projectSlug` or `workspaceLogin` is missing from your deploy.json.");
253 spinner.start(`Searching for app ${deployConfig.projectId}`);
254 let found = false;
255 for (const workspace of this.currentUser.workspaces) {
256 const projects = await this.apiClient.getWorkspaceProjects(workspace.login);
257 const project = projects.find((p) => p.id === deployConfig.projectId);
258 if (project) {
259 deployConfig.projectSlug = project.slug;
260 deployConfig.workspaceLogin = workspace.login;
261 await this.effects.setDeployConfig(
262 this.deployOptions.config.root,
263 this.deployOptions.deployConfigPath,
264 deployConfig,
265 this.effects
266 );
267 found = true;
268 break;
269 }
270 }
271 if (found) {
272 spinner.stop(`App ${deployConfig.projectSlug} found in workspace @${deployConfig.workspaceLogin}.`);
273 } else {
274 spinner.stop(`App ${deployConfig.projectId} not found. Ignoring…`);
275 }
276 }
277
278 return deployConfig;
279 }
280
281 // Get the deploy target, prompting the user as needed.
282 private async getDeployTarget(deployConfig: DeployConfig): Promise<DeployTargetInfo> {

Callers 1

startNewDeployMethod · 0.95

Calls 9

getDeployConfigMethod · 0.80
matchMethod · 0.80
spinnerMethod · 0.80
getWorkspaceProjectsMethod · 0.80
findMethod · 0.80
setDeployConfigMethod · 0.80
stopMethod · 0.80
warnMethod · 0.45
startMethod · 0.45

Tested by

no test coverage detected