How to use lix to open a Repo #2061
-
To load an SDK project you now need a lix repo e.g. for paraglide compile
https://inlang.com/g/94ng94n4/guide-inlang-buildOwnApp#1-open-repository Related discussions
paraglide examples real FS, possibly without a .git repo
// init
const repoRoot = await findRepoRoot({
nodeishFs: nodeFsPromises,
path: process.cwd(),
})
// We are risking that there is no git repo. As long as we only use FS features and no Git features
// from the SDK we should be fine.
// Basic operations like `loadProject` should always work without a repo since it's used in CI.
const repo = await openRepository(repoRoot ?? process.cwd(), {
nodeishFs: nodeFsPromises,
})
// compile
const path = resolve(process.cwd(), options.project)
logger.info(`Compiling inlang project at "${options.project}".`)
const repoRoot = await findRepoRoot({ nodeishFs: nodeFsPromises, path })
const repo = await openRepository(repoRoot || process.cwd(), {
nodeishFs: nodeFsPromises,
}) example test cases with an empty mock repo or a snapshot repo// empty
const repo = await mockRepo()
// snapshot
const ciTestRepoSnapshot = JSON.parse(
readFileSync(resolve(__dirname, "../mocks/ci-test-repo-no-shallow.json"), {
encoding: "utf-8",
})
) as Snapshot
const repo = await mockRepo({ fromSnapshot: ciTestRepoSnapshot }) |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 2 replies
-
@jldec i recommend sticking to the Problem - Proposal template for opening discussions. It is hard(er) to follow what problem you are solving and what you are proposing. |
Beta Was this translation helpful? Give feedback.
-
We decided that opening a project always requires a repository from now on. Inlang is building features on top of lix, making access to lix, aka repos, a hard requirement. EXAMPLE APIs For production cases where no repo exists const repoRoot = await findRepoRoot()
// if no repo exists, falling back to a virtual repository (that in this case syncs with the provided fs)
const repo = await repoRoot ? openRepository(repoRoot, { nodeishFs }) : virtualRepo({ syncWithFs: nodeishFs }) For testing
const repo = await virtualRepo({ fromSnapshot: snapshot }) |
Beta Was this translation helpful? Give feedback.
-
Decision for now - the 2 examples above are clear enough - we don't need to introduce a new lix virtualRepo() interface.
thanks for the feedback and suggestions. |
Beta Was this translation helpful? Give feedback.
-
outcome: we are on the same page regarding understanding what we want to achieve but will revisit when we have more concrete immediate needs |
Beta Was this translation helpful? Give feedback.
Decision for now - the 2 examples above are clear enough - we don't need to introduce a new lix virtualRepo() interface.
thanks for the feedback and suggestions.