Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

URI as primitive in @lix-js/fs #3

Open
felixhaeberle opened this issue Mar 11, 2024 · 7 comments
Open

URI as primitive in @lix-js/fs #3

felixhaeberle opened this issue Mar 11, 2024 · 7 comments
Assignees

Comments

@felixhaeberle
Copy link

felixhaeberle commented Mar 11, 2024

Problem

We often have to deal with paths inside multi env code like the new cross-sell packages which aim to simpify the cross-sell of our apps with access to the fs.

The operations done on the fs often requires path manipulation and therefore we introduced normalizePath & normalPath – both of them are poorly executed because no higher approach has yet been found to tackle paths multi env (node/web etc.)

Proposal

Come up with a solution like

import path from "@lix-js/path"

// use it in nodejs
path.join()

// use it on the web
path.join()

I'm surely only scratching the surface here, but the bugs in opral/monorepo#2184 alike seems that there is an urge to introduce @lix-js/path.

@felixhaeberle felixhaeberle changed the title bring path as first class primitive into @lix-fs bring path as first class primitive into @lix-js/path Mar 11, 2024
@samuelstroschein

This comment was marked as outdated.

@samuelstroschein
Copy link
Member

@felixhaeberle

  1. This will most likely be included in the upcoming @opral/lix fs.
import { URI, fs } from "@lix-js/fs" 

URI.join()
  1. We need URI's, not paths since we are dealing with network "paths", local paths, and more

@felixhaeberle
Copy link
Author

felixhaeberle commented Mar 11, 2024

yes! I see the need for URIs also/instead


this "path" proposal should be envolved to what we actually need but the current state of packages/apps have to

function joinPath(...parts: string[]): string {
	return parts.map((part) => part.replace(/\/$/, "")).join("/")
}

& a weird mix of packages using normalPath & normalizePath

is 🥴


TLDR: @samuelstroschein feel free to rephrase the proposal

@samuelstroschein samuelstroschein changed the title bring path as first class primitive into @lix-js/path URI as primitive in @lix-js/fs Mar 11, 2024
@janfjohannes
Copy link

@felixhaeberle good to have this as a ticket, this will be much less work as
a) we have unix path normalization so lix fs will only have / path delimiters, not
b) lix will have scped paths to the repo and can be further scoped down to replace the current "withAbsolutePaths" wrapper, which will remove the need for many cases where relative paths are used

in the end there should be not much need for helper funcitons except for something like path.resolve for some cases.

@samuelstroschein
Copy link
Member

Copy link

linear bot commented Mar 19, 2024

@samuelstroschein samuelstroschein transferred this issue from opral/monorepo Mar 19, 2024
Copy link
Member

@felix.haeberle here you go

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants