everything-dev
Version:
A consolidated product package for building Module Federation apps with oRPC APIs.
1 lines • 4.02 kB
Source Map (JSON)
{"version":3,"file":"import.cjs","names":["findConfigPath","MISSING_CONFIG_MESSAGE","dirname","process","p","Effect","importWorkspace"],"sources":["../../src/handlers/import.ts"],"sourcesContent":["import { dirname } from \"node:path\";\nimport process from \"node:process\";\nimport * as p from \"@clack/prompts\";\nimport { Effect } from \"effect\";\nimport type { ImportDeps } from \"../cli/import\";\nimport { importWorkspace } from \"../cli/import\";\nimport { findConfigPath, MISSING_CONFIG_MESSAGE } from \"../config\";\nimport type { ImportOptions } from \"../contract\";\nimport type { BosBuilder } from \"./shared\";\n\nexport function registerImport(builder: BosBuilder) {\n return {\n import: builder.import.effect(function* (_opts, input) {\n const configPath = findConfigPath();\n if (!configPath) {\n return {\n status: \"error\",\n workspace: input.workspace,\n from: input.from ?? \"\",\n ref: \"\",\n added: [],\n updated: [],\n unchanged: [],\n preservedLocal: [],\n merged: [],\n conflicts: [],\n heldBackMigrations: [],\n migrationCollisions: [],\n warnings: [],\n error: `${MISSING_CONFIG_MESSAGE} in current directory`,\n };\n }\n\n const options = input as ImportOptions;\n const projectDir = dirname(configPath);\n const interactive =\n !options.yes && !options.dryRun && process.stdin.isTTY && process.stdout.isTTY;\n\n const confirm = interactive\n ? async (info: Parameters<NonNullable<ImportDeps[\"confirm\"]>>[0]): Promise<boolean> => {\n const collisionNote =\n info.migrationCollisionCount > 0\n ? ` + ${info.migrationCollisionCount} unresolvable migration collision(s)`\n : \"\";\n const heldNote =\n info.heldCount > 0\n ? `; ${info.heldCount} migration-chain file(s) will be held back`\n : \"\";\n const appendedNote =\n info.appendedCount > 0\n ? `; ${info.appendedCount} upstream migration(s) will be renumbered and appended to the local chain`\n : \"\";\n const answer = await p.confirm({\n message:\n info.conflictCount > 0 || info.migrationCollisionCount > 0\n ? `${info.conflictCount} conflicting file(s)${collisionNote} in ${info.workspace} — apply upstream over conflicting files (local copies backed up)${heldNote}?`\n : `Migration chain reconciliation in ${info.workspace}: apply upstream migrations${appendedNote}${heldNote}?`,\n initialValue: false,\n });\n if (p.isCancel(answer)) return false;\n return answer === true;\n }\n : undefined;\n\n return yield* Effect.tryPromise(() => importWorkspace(projectDir, options, { confirm }));\n }),\n };\n}\n"],"mappings":";;;;;;;;;;;AAUA,SAAgB,eAAe,SAAqB;CAClD,OAAO,EACL,QAAQ,QAAQ,OAAO,OAAO,WAAW,OAAO,OAAO;EACrD,MAAM,aAAaA,4BAAe;EAClC,IAAI,CAAC,YACH,OAAO;GACL,QAAQ;GACR,WAAW,MAAM;GACjB,MAAM,MAAM,QAAQ;GACpB,KAAK;GACL,OAAO,CAAC;GACR,SAAS,CAAC;GACV,WAAW,CAAC;GACZ,gBAAgB,CAAC;GACjB,QAAQ,CAAC;GACT,WAAW,CAAC;GACZ,oBAAoB,CAAC;GACrB,qBAAqB,CAAC;GACtB,UAAU,CAAC;GACX,OAAO,GAAGC,oCAAuB;EACnC;EAGF,MAAM,UAAU;EAChB,MAAM,iBAAaC,mBAAQ,UAAU;EAIrC,MAAM,UAFJ,CAAC,QAAQ,OAAO,CAAC,QAAQ,UAAUC,qBAAQ,MAAM,SAASA,qBAAQ,OAAO,QAGvE,OAAO,SAA8E;GACnF,MAAM,gBACJ,KAAK,0BAA0B,IAC3B,MAAM,KAAK,wBAAwB,wCACnC;GACN,MAAM,WACJ,KAAK,YAAY,IACb,KAAK,KAAK,UAAU,8CACpB;GACN,MAAM,eACJ,KAAK,gBAAgB,IACjB,KAAK,KAAK,cAAc,6EACxB;GACN,MAAM,SAAS,MAAMC,eAAE,QAAQ;IAC7B,SACE,KAAK,gBAAgB,KAAK,KAAK,0BAA0B,IACrD,GAAG,KAAK,cAAc,sBAAsB,cAAc,MAAM,KAAK,UAAU,mEAAmE,SAAS,KAC3J,qCAAqC,KAAK,UAAU,6BAA6B,eAAe,SAAS;IAC/G,cAAc;GAChB,CAAC;GACD,IAAIA,eAAE,SAAS,MAAM,GAAG,OAAO;GAC/B,OAAO,WAAW;EACpB,IACA;EAEJ,OAAO,OAAOC,cAAO,iBAAiBC,+BAAgB,YAAY,SAAS,EAAE,QAAQ,CAAC,CAAC;CACzF,CAAC,EACH;AACF"}