@supernovaio/cli
Version:
Supernova.io Command Line Interface
59 lines (57 loc) • 2.54 kB
JavaScript
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="10589449-fde2-53b9-9a4f-61b1930e3ccd")}catch(e){}}();
import { getNextSetupState } from "./state.js";
const stateDescriptions = {
INIT: "Initializing setup session",
SELECT_DESIGN_SYSTEM: "Selecting design system",
SELECT_SCAN_SOURCE_PATH: "Selecting source folder for scan",
SELECT_SCAN_PACKAGES: "Selecting discovered packages for scan",
RUN_SCAN: "Running repository scan",
REVIEW_SCAN_OUTPUT: "Reviewing generated scan output",
UPLOAD_SCAN_RESULTS: "Uploading analysis snapshots",
SELECT_TEMPLATE_DESTINATION: "Selecting container destination",
PREPARE_TEMPLATE: "Preparing the container",
CONFIGURE_DEPENDENCIES: "Selecting design system dependency packages",
CONFIGURE_PRIVATE_REGISTRY: "Configuring package access",
VALIDATE_DEPENDENCY_ACCESS: "Validating dependency access",
UPLOAD_CONTAINER: "Uploading container",
CREATE_SHARED_CONTEXT: "Creating shared context",
FINALIZE_AND_REDIRECT: "Finalizing setup and preparing prototype redirect",
DONE: "Setup complete",
};
export function describeSetupState(state) {
return stateDescriptions[state];
}
export class SetupOrchestrator {
deps;
constructor(deps) {
this.deps = deps;
}
async run(initialState, initialContext = {}) {
let state = initialState;
let context = { ...initialContext };
await this.transitionTo(state, context);
while (state !== "DONE") {
context = await this.runStep(state, context);
state = getNextSetupState(state);
await this.transitionTo(state, context);
}
return context;
}
async transitionTo(state, context) {
await this.deps.onStateTransition?.(state, context);
}
async runStep(state, context) {
if (state === "DONE")
return context;
const handler = this.deps.handlers?.[state];
if (handler) {
const nextContext = await handler(context);
return nextContext ? { ...context, ...nextContext } : context;
}
const description = describeSetupState(state);
this.deps.log(`${description} (placeholder)`);
return context;
}
}
//# sourceMappingURL=orchestrator.js.map
//# debugId=10589449-fde2-53b9-9a4f-61b1930e3ccd