Comments (12)
Agreed - this doesn't feel like a boats solution at the moment (unless helper is used)
from boats.
Currently, I just traverse out of the current project and into a shared resource repo.. eg
../../../../shared-openapi//model.yml
The ide can resolve this just fine, but it can be a lot of ../../...
Any shorthand version of this though would break the ability for the ide to resolve the files.. rock + hard place
from boats.
Yeah, peraonally that would be fine with me but not everyone in the team clones all projects.
We also considered cloning / fetching the raw in a prebuild
, but would be cool to have something just auto update when things change.
not sure if it should even be built into the core, but this can be acheived with a simple helper which calls await exec('git fetch ...')
to take advantage of the local git config - just means copying the helper to any project which reuses models.
Will post it here in case it ends up being included by default, but was hoping json ref parser would handle it automagically (we tried - it doesnt)
from boats.
You can fetch over a URL though... https://swagger.io/docs/specification/using-ref/ but i guess via https is the issue
from boats.
I think https is fine (didn't test), but with private repos the internal resolver doesn't know how to auth so I believe it will fetch and receive a 404 instead of a model.
from boats.
Yeaap.. twas what I was thinking.. it would need to be over SSH to work then the user would pass keys but that's not supported based in the docs link above.
But then what you're essentially talking about is git modules so not sure if it's worth writing a specially helper for that.. git already does all this.
An update of the git modules could be easier added to the build script in the package JSON file, but... Then I suppose this pushing pointless boiler plate work to the (unknown skill level) developer.. ie a larger scope for error.
... I can see this problem coming down the road at me in the next month's too
from boats.
Trying to avoid git modules, with a helper you could do something like this:
// helpers/fetchGitFile.js
export const fetchGitFile = (repo, file) => { // file is something like build/src/components/schemas/somethingModel.yml
const { stdout } = await exec(`git show origin/master:${file}`);
return stdout;
}
Except instead of showing master of the current repo I think you can use ls-remote or something similar. Then the "shared" model could do:
type: object
schema:
<$ fetchGitFile('patco/sweetModels', 'build/src/components/schemas/somethingElse.yml') $>
Since exec('git ...')
will use the user's git config, it will have access to the remote file. I think you can also use ssh protocol to view the single raw file if that doesn't work.
Would save storing things in a shared project or moving files around when it turns out something else needs them - it would behave the same way as a relative path to every repo you own, without having to clone and what not.
I'm certain it's possible, the main question is which command can / should be used. It also means copying the helpers folder across projects but I end up doing that anyway for things like mixins or other little scripts.
EDIT: quick google suggests this command might work too:
# https://stackoverflow.com/questions/1125476/retrieve-a-single-file-from-a-repository
# probably not supported on windows but... you know...
git archive --remote=git://git.foo.com/project.git HEAD:path/to/directory filename | tar -x
from boats.
Interesting - github doesn't allow it
# fails with all kinds of fun stuff
git archive [email protected]:p-mcgowan/playground.git HEAD readme.md
However, on gitlab (and apparently bitbucket) it works
# works on my machine - creates the file on disk
git archive [email protected]:org/path/to/repo.git HEAD readme.md |tar -x
This also works for github, but it's not pretty and doesn't avoid the clone (but definitely faster)
git clone --bare --no-checkout --depth 1 [email protected]:user/repo.git && cd repo.git && git show HEAD:readme.md
And apparently using svn works on github...
# https://stackoverflow.com/questions/9609835/git-export-from-github-remote-repository
svn export https://github.com/user/project/trunk
Or, if you like the hacky solutions - just add the upstream
git remote add tmp-upstream [email protected]:private/repo.git
git fetch tmp-upstream
git show tmp-upstream/master:readme.md
git remote remove tmp-upstream
But that requires a full fetch
from boats.
hmm.. i'm not opposed to adding this sort of thing.. however, the dev exp would not be too fun; specially as the ide would have no chance of resolving the refs without a custom boats ide plugin
from boats.
No, that's way too rough for the core - was hoping it would be simpler. This kind of hack is best served from a helper file i think, as it both probably doesn't work on windows and isn't super clean even for good nix. If github allowed it, then there would be a single more or less clean solution, but that threw a spanner in the works.
from boats.
Yeap.. there's always symlinks too.. gets rid of the annoyance of npm packages or git modules.. but they don't play too well on Windows
from boats.
Well if the whole project was a monorepo or everyone cloned all the micros locally it wouldn't be an issue, but would have been nice to find a more portable solution. For now, since this project is on gitlab, I think we will give the archive method a shot, but would love to find something more portable some time down the road.
Could probably close this, but would be cool if it eventually had a nice, clean solution.
from boats.
Related Issues (20)
- nunjuck include not possible when using tpl from outside of project HOT 1
- [FEATURE] Helper to make referenced object properties optional
- Disable automatic version check HOT 3
- [feature] Display info regarding new available version when used with -y flag HOT 4
- Warning when no .boatsrc file exists HOT 5
- model pick HOT 6
- Nested $refs inside optionalProps file not found error
- Enhance AutoIndexer to make it easy to filter files HOT 5
- discriminator / mapping + $ref doesn't seem to work HOT 4
- Cannot apply more than 1 absolute path in 1 file HOT 1
- version check issues
- update js-yaml HOT 1
- OpenAPI 3.1 Support HOT 9
- Auto summary helper HOT 3
- Multiple TypeScript `-f` helpers cause errors HOT 3
- `inject` helper `excludeChannel` and `includeOnlyChannels` params don't work with AsyncAPI document HOT 3
- Error: spawn npm ENOENT HOT 5
- Version check takes a long time to timeout on runner with no internet HOT 4
- Need a bespoke check on array items to ensure no dash
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from boats.