UNPKG

everything-dev

Version:

A consolidated product package for building Module Federation apps with oRPC APIs.

50 lines (48 loc) • 2.4 kB
const require_runtime = require('../_virtual/_rolldown/runtime.cjs'); const require_load = require('../services/resolution/load.cjs'); const require_import = require('../services/scaffold/import.cjs'); let node_path = require("node:path"); let effect = require("effect"); let node_process = require("node:process"); node_process = require_runtime.__toESM(node_process, 1); let _clack_prompts = require("@clack/prompts"); _clack_prompts = require_runtime.__toESM(_clack_prompts, 1); //#region src/handlers/import.ts function registerImport(builder) { return { import: builder.import.effect(function* (_opts, input) { const configPath = require_load.findConfigPath(); if (!configPath) return { status: "error", workspace: input.workspace, from: input.from ?? "", ref: "", added: [], updated: [], unchanged: [], preservedLocal: [], merged: [], conflicts: [], heldBackMigrations: [], migrationCollisions: [], warnings: [], error: `${require_load.MISSING_CONFIG_MESSAGE} in current directory` }; const options = input; const projectDir = (0, node_path.dirname)(configPath); const confirm = !options.yes && !options.dryRun && node_process.default.stdin.isTTY && node_process.default.stdout.isTTY ? async (info) => { const collisionNote = info.migrationCollisionCount > 0 ? ` + ${info.migrationCollisionCount} unresolvable migration collision(s)` : ""; const heldNote = info.heldCount > 0 ? `; ${info.heldCount} migration-chain file(s) will be held back` : ""; const appendedNote = info.appendedCount > 0 ? `; ${info.appendedCount} upstream migration(s) will be renumbered and appended to the local chain` : ""; const answer = await _clack_prompts.confirm({ message: info.conflictCount > 0 || info.migrationCollisionCount > 0 ? `${info.conflictCount} conflicting file(s)${collisionNote} in ${info.workspace} — apply upstream over conflicting files (local copies backed up)${heldNote}?` : `Migration chain reconciliation in ${info.workspace}: apply upstream migrations${appendedNote}${heldNote}?`, initialValue: false }); if (_clack_prompts.isCancel(answer)) return false; return answer === true; } : void 0; return yield* effect.Effect.tryPromise(() => require_import.importWorkspace(projectDir, options, { confirm })); }) }; } //#endregion exports.registerImport = registerImport; //# sourceMappingURL=import.cjs.map