高高的git子模块用于私人内容?

发布于 2025-01-28 22:20:40 字数 1849 浏览 3 评论 0原文

我正在尝试使用高度和Netlify来创建一个具有公共和私人内容的网站,后者需要进行身份验证,如 11ty/demo-eto noveless-auth-auth 样本项目。我希望公共和私人内容在单独的公共和私人GIT存储库中,以便任何人都可以为前者做出贡献而无需看到后者。

我通过为私有内容使用git子模块而变得非常接近,但是我很难保留- 观看自动重建和浏览器功能。问题在于Input目录,该目录需要两个存储库中的内容文件。

最初,我尝试在buildstart命令中复制私有内容npm运行dev,当内容更改时不会重新运行。

然后我找到 ever> ever> ever ever event ,我希望将其与fs-extra.copysync一起使用,将文件从私有存储库移动到我的input目录中。

但是,问题是input也正在观看,因此复制触发器另一个构建,因此是无限的循环。我有些东西我've探索:

  • inputever.epter.fer事件的回调中删除目录但这似乎打破了整个网站。
    • 也许它会破坏网站,因为 noreless noreferrer“> serverless plunin 用作输入?为了解决该问题,我尝试使用a second,未匹配的内容的副本指定插件的不同inputDir,但它无济于事。
    • 或者可能会破坏网站,因为fs-extra.rmsync也会触发重建,但现在没有内容。
  • 我想尝试一个同步的,而不是ynnc方法 expenty.before 处理程序,以防万一竞赛条件触发了无限循环。我尝试了everconfig.setWatchThrottLottleWaittime来模拟这一点,但这无济于事,也许是因为该选项现在不支持。
  • 我可以将输入目录作为手表目标删除,只查看我的两个预合并内容目录...但是该功能似乎不存在。
  • 我尝试将组合的输入目录添加到.eleventyignore in epipenty中:之后,并在中删除目的是使其仅在构建过程中可见,否则无法触发变化,但这也无效。

我正在与之合作的仓库IS 在这里。我缺少什么,还是需要完全不同的方法?

I'm trying to use Eleventy and Netlify to create a website with both public and private content, with the latter requiring authentication as in the 11ty/demo-eleventy-serverless-auth sample project. I'd like the public and private content to be in separate public and private git repositories, so that anyone can contribute to the former without being able to see the latter.

I've gotten quite close by using a git submodule for the private content, but I'm having trouble preserving the --watch automatic rebuilding and Browsersync functionality. The problem is with the input directory, which needs the content files from both repositories.

Initially I tried to copy the private content prior to the build and start commands in package.json, but that only gets run once at the beginning of npm run dev, and does not get re-run when the content changes.

Then I found the eleventy.before event, which I hoped to use with fs-extra.copySync to move the files from the private repo into my input directory.

The problem, however, is that the input is also being watched, so the copy triggers another build and thus an infinite loop. Some things I've explored:

  • Deleting the input directory in the callback for the eleventy.after event, which I hoped would be safe since output exists already, but this seems to break the entire site.
    • Maybe it breaks the site because the Serverless plugin no longer has files to use as input? To fix that I tried to specify a different inputDir for the plugin with a second, unwatched copy of the content, but that it didn't help.
    • Or maybe it breaks the site because the fs-extra.rmSync also triggers a rebuild, but now there's no content.
  • I wanted to try a synchronous, rather than async method in the eleventy.before handler, in case there was a race condition triggering the infinite loop. I experimented with eleventyConfig.setWatchThrottleWaitTime to simulate this, but it didn't help, perhaps because that option is now unsupported.
  • I could remove the input directory as a watch target and only look at my two pre-merge content directories... but that functionality doesn't seem to exist.
  • I tried adding the combined input directory to .eleventyignore in eleventy:after and removing it in eleventy:before, with the goal to make it only visible during the build and otherwise not able to trigger changes, but that didn't work either.

The repo I'm working with is here. Is there something I'm missing, or do I need an entirely different approach?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

葬花如无物 2025-02-04 22:20:40

感谢 11ty Discord ,我通过保留未更换文件的修改时间来解决此问题。

ever.before事件处理程序中,我使用了 创建我需要复制的所有文件的列表。然后,对于每条路径,在用fs.existsync确认源和目标之后,我使用fs.statsync比较了他们的mtimems上次修改时间。然后,如果目标比源老(或丢失),则仅执行fs.copysync

这解决了无限循环,但仅揭示了仅在Netlify上出现的另一个问题:我的动态页面的无服务器功能只有我项目文件的一个子集。首先,它缺少私有内容目录,在我的expecter中触发错误。幸运的是, did 具有合并的内容目录,并且已经包含了我以前构建中的私人内容。但是,合并的内容目录并未从公共内容目录中具有_的文件夹,这导致无服务器函数在渲染模板时失败。

因此,我不是在构建时间创建合并的内容目录,而是从公共和私人内容目录中复制所有内容,而是从一开始就保留_includes目录。这意味着ipery.before事件处理程序仅复制.md文件。这避免了第二个问题,无论如何,如果我以后我想将公共内容也将其移至单独的存储库,则可能会更好。

Thanks to a suggestion from Aankhen#6432 in the 11ty Discord, I solved this by preserving the modification times of unchanged files.

In the eleventy.before event handler I used klaw-sync to create a list of all of the files I needed to copy. Then for each path, after confirming the source and destination with fs.existsSync, I used fs.statSync to compare their mtimeMs last modification times. I then only perform the fs.copySync if the destination is older than the source (or is missing).

This resolved the infinite loop, but revealed another issue present only on Netlify: the serverless function for my dynamic pages had just a subset of my project's files. First, it was missing the private content directory, triggering an error in my eleventy.before handler when there was nothing to copy. Fortunately, it did have the merged content directory, and that already contained my private content from a previous build. The merged content directory did not, however, have the _includes folder from the public content directory, which caused the serverless function to fail when rendering the templates.

So, rather than create the merged content directory at build time and copy in everything from the public and private content directories, I just kept the _includes directory there from the beginning. That means the eleventy.before event handler is only copying .md files. This avoids this second problem and is maybe better anyway, in case I later want to move the public content into a separate repo as well.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文