Skip to content

Commit de0bae8

Browse files
committed
handle error
1 parent 42d1d41 commit de0bae8

File tree

1 file changed

+13
-65
lines changed

1 file changed

+13
-65
lines changed

src/index.ts

+13-65
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,15 @@ class Log {
116116
console.error(Log.msg(message));
117117
}
118118
};
119+
120+
ngLog = (entry: logging.LogEntry) => {
121+
// TODO: use level
122+
if (this.options.log) {
123+
this.options.log.error(Log.msg(entry.message));
124+
} else {
125+
console.error(Log.msg(entry.message));
126+
}
127+
};
119128
}
120129

121130
class ServerlessReact {
@@ -273,16 +282,6 @@ class ServerlessReact {
273282
throw new Error("build target does not exist");
274283
}
275284

276-
// console.log("!!! buildTarget", buildTarget);
277-
278-
// const builderInfo = await architectHost.resolveBuilder(buildTarget.builder);
279-
280-
// console.log("!!! builderInfo", builderInfo);
281-
282-
// const builder = await architectHost.loadBuilder(builderInfo);
283-
284-
// console.log("!!! builder", builder);
285-
286285
const architect = new Architect(architectHost);
287286

288287
const projectMetadata = await architectHost.getProjectMetadata(projectName);
@@ -291,23 +290,9 @@ class ServerlessReact {
291290
throw new Error(`projectMetadata does not exist`);
292291
}
293292

294-
console.log("!!! projectMetadata", projectMetadata);
295-
296-
// const targetOptions = await architectHost.getOptionsForTarget({
297-
// configuration: "",
298-
// project: projectName,
299-
// target: "build",
300-
// });
301-
302-
// if (!targetOptions) {
303-
// throw new Error(`targetOptions does not exist`);
304-
// }
305-
306-
// console.log("!!! targetOptions", targetOptions);
307-
308293
const logger = new logging.Logger(PLUGIN_NAME);
309294
logger.subscribe((entry) => {
310-
console.log(entry.message);
295+
this.log.ngLog(entry);
311296
});
312297

313298
const scheduleTargetRun = await architect.scheduleTarget(
@@ -324,46 +309,9 @@ class ServerlessReact {
324309
const scheduleTargetLastOutput = await scheduleTargetRun.lastOutput;
325310
console.log("!!! scheduleTargetLastOutput", scheduleTargetLastOutput);
326311

327-
// const scheduleBuilderRun = await architect.scheduleBuilder(
328-
// buildTarget.builder,
329-
// targetOptions
330-
// );
331-
332-
// console.log("!!! scheduleBuilderRun", scheduleBuilderRun);
333-
// const scheduleBuilderLastOutput = await scheduleBuilderRun.lastOutput;
334-
// console.log("!!! scheduleBuilderLastOutput", scheduleBuilderLastOutput);
335-
336-
// const host = workspaces.createWorkspaceHost(new NodeJsSyncHost());
337-
338-
// const { workspace } = await workspaces.readWorkspace(angularJsonPath, host);
339-
340-
// console.log("!!!! workspace", workspace);
341-
342-
// const project = workspace.projects.get(projectName);
343-
// if (!project) {
344-
// throw new Error(`${projectName} does not exist`);
345-
// }
346-
347-
// console.log("!!!! project", project);
348-
349-
// console.log("!!!! buildTarget", buildTarget);
350-
351-
// buildTarget.options.optimization = true;
352-
// buildApplication({});
353-
// const vite = await import("vite");
354-
// const { entryPoint } = this.pluginConfig;
355-
// await vite.build({
356-
// mode,
357-
// configFile: this.pluginConfig.vite?.configFile,
358-
// build: {
359-
// outDir: this.outputPath,
360-
// rollupOptions: {
361-
// input: { app: entryPoint ? entryPoint : "./index.html" },
362-
// },
363-
// watch: watch ? {} : undefined,
364-
// reportCompressedSize: this.options.verbose,
365-
// },
366-
// });
312+
if (scheduleTargetLastOutput.error) {
313+
throw new Error(scheduleTargetLastOutput.error);
314+
}
367315
};
368316
}
369317

0 commit comments

Comments
 (0)