跳转至内容
  • A place to talk about whatever you want

    9 主题
    103 帖子
    没有新主题
  • 4 主题
    4 帖子
    sunrisepeakS

    TODO

  • 开源软件 | 开源社区 | 开源理念 | 开源与商业 | 开源可持续发展 等相关话的交流讨论
    注: 这里的"开源"是泛化的共建共享概念, 范围包含 OSI的范围、自由软件、CC等相关内容

    32 主题
    141 帖子
    sunrisepeakS

    https://github.com/d2learn/xlings/pull/79

  • d2learn开源组

    3 主题
    3 帖子
    sunrisepeakS

    在前段时间开源了一个开发者命令行工具xlings, 收到了一些关注和反馈, 并且最近也对其中的一键安装功能做了进步增强。希望不仅可以帮助初学者快速的搭建编程环境, 也能用于项目开发者来管理复杂项目的开发环境依赖和一键搭建配置支持

    下面就从 最小功能实现、递归依赖安装、项目依赖管理循序渐进的介绍一下这个功能的设计和思考

    e39f59bf-5006-4ee1-8d34-8f36104417f2-image.png

    注: 这个软件和功能目前依然处于比较前期的探索和开发中

    一、最小功能实现 - 接口规范 1.1 接口设计视角

    对于安装一个软件或编程环境大概可以划分成3个步骤: 下载 - 安装 - 配置

    95355e31-b6bd-4402-9253-cdf3a9094bae-image.png

    并且为了避免重复安装和显示软件的信息, 用top-down的思想,大概核心的接口设计如下:

    function support() -- ... end function installed() -- ... end function install() -- ... end function config() -- ... end function info() -- ... end

    其中support接口用来标识当前系统是否支持, info接口是用于获取软件的基础信息

    function support() return { windows = true, linux = true, macosx = false } end function info() return { name = "vscode", homepage = "https://code.visualstudio.com", author = "https://github.com/microsoft/vscode/graphs/contributors", licenses = "MIT", github = "https://github.com/microsoft/vscode", docs = "https://code.visualstudio.com/docs", profile = "Visual Studio Code", } end 1.2 接口实现视角

    从对于单一软件或环境接口实现视角来看, 有点类似很多项目中的一键安装/配置脚本

    但区别是xlings的安装实现上是符合一个接口规范的, 这样才能为后面的复用提供可能性。并且使用者可以不用关心实现细节, 通过标准接口就可以使用对应的模块。

    function installed() return try { function() if os.host() == "windows" and (os.getenv("USERNAME") or ""):lower() == "administrator" then return os.isfile("C:\\Program Files\\Microsoft VS Code\\Code.exe") else -- os.exec("code --version") - windows cmd not support? common.xlings_exec("code --version") -- for windows end return true end, catch { function(e) return false end } } end function install() print("[xlings]: Installing vscode...") local url = vscode_url[os.host()] -- only windows administrator local use_winget_sys = (os.getenv("USERNAME") or ""):lower() == "administrator" if not os.isfile(vscode_file) and not use_winget_sys then common.xlings_download(url, vscode_file) end return try { function () if os.host() == "windows" then print("[xlings]: runninng vscode installer, it may take some minutes...") if use_winget_sys then os.exec("winget install vscode --scope machine") else common.xlings_exec(vscode_file .. " /verysilent /suppressmsgboxes /mergetasks=!runcode") end elseif os.host() == "linux" then os.exec("sudo dpkg -i " .. vscode_file) elseif os.host() == "macosx" then -- TODO: install vscode on macosx end return true end, catch { function (e) os.tryrm(vscode_file) return false end } } end 二、递归安装依赖 - 复用&依赖图

    通过上面的接口规范化后, 实现软件依赖的自动递归安装和复用就相对简单了。只需要再增加一个用于描述依赖的接口

    function deps() -- pnpm return { windows = { "npm" }, linux = { "npm" }, macosx = { "npm" } } end

    以pnpm的实现为例, 只需要通过依赖描述添加npm, 而不需要关心npm是否安装。当执行pnpm安装的时候会自动的递归检查依赖并安装。从单个软件的依赖链来看像一个不严谨的树形结构, 如果绘制所有软件和依赖会是一个依赖图, 并且节点是可以复用的 -- 软件安装复用

    294e3f7e-3dd6-42a8-b75b-e87a27688abf-image.png

    三、项目依赖管理 - 快速搭建项目开发环境

    很多人在拿到一个不怎么熟悉的项目的时候, 往往要成功的去构建或运行这个项目要花不少时间去解决这个软件或库的依赖问题。所以xlings有了基础软件的安装功能, 就自然而然的想到当把一个项目从github上clone下来的时候能不能通过一行命令就自动配置好开发这个项目所需要的环境

    在有上面的基础后, 就可以通过一个简单的依赖描述文件来描述一个项目依赖。xlings只需要通过加载这个依赖文件, 然后通过解析出依赖项, 按照递归的方式逐个安装,就可以实现一键配置好一个项目的开发环境。

    config.xlings配置文件示例

    xname = "ProjectName" xdeps = { rust = "", python = "3.12", vs = "2022", nodejs = "", vscode = "", ... -- postprocess cmds xppcmds = { "cmd1", "cmd2", } }

    在配置文件中通过xdeps来描述项目的直接依赖, 并且可以通过其中的xppcmds项来自定义安装项目依赖后的后处理命令

    四、统一的软件版本管理

    目前xlings的下一步是期望能实现基于场景记忆的版本管理。例如当在一个特定的项目文件夹下 会使用不同的软件版本, 只不过这个还在规划中...

    Other xlings论坛 xlings开源仓库
  • 7 主题
    23 帖子
    sky-littlestarS

    @sunrisepeak UP主可以看看乐鑫董办那个公众号,它的视频号里面有乐鑫科技参加字节火山引擎发布会的视频,算是对AI+潮玩理解比较深的,可能这个是一个切入点,以后这方面的延伸应该很多。

  • 一个技术知识分享、学习、交流的社区

    14 主题
    43 帖子
    sunrisepeakS

    中文版

    Introduction and Background

    A community forum oriented towards [knowledge/technology, projects, open courses, creative ideas, etc. + open-source philosophy].

    Why build such a forum?

    Many platforms are moving towards being comprehensive and entertainment-focused, leading to a massive increase in content volume but a decrease in the density of specific thematic content. There are relatively few forums related to open source in Chinese platforms, with content scattered across various platforms, lacking a common platform for exchange and sharing. Provide a platform for discussing topics related to open-source philosophy | open-source licenses | open-source projects | open-source communities | open-source and business | sustainable development of open-source, etc. Main Sections and Topics

    General Discussion Section

    Posts without a specific topic section are generally posted here.

    04473257-cc22-456b-b3e9-cfeed513a14a-image.png

    Open Courses Section

    Post content and discussions related to various open courses. Developers of courses/tutorial projects can create corresponding discussion sections.

    6ae992b8-d831-4a8d-8bbd-e00b4cb4b067-image.png

    Open Source Section

    Discussions on topics related to open-source software | open-source communities | open-source philosophy | open-source and business | sustainable development of open-source. Developers of open-source projects can create discussion sections for their projects.

    cf3aa71e-2fda-44cf-b016-6cea0876bb51-image.png

    d2learn Open Source

    Explorations of open-source content by the d2learn community/open-source group.

    04970ff0-56fb-4f7b-8f2f-a2ce42747315-image.png

    Forum Feedback & Community Building

    Feedback on forum-related issues and suggestions. Discussions on topics related to the sustainable development of the forum.

    ca1f43d9-162a-4a5d-9e3a-1dc7878f926a-image.png

    Functional Perspective A platform for open-source enthusiasts to exchange and discuss. Developers of open-source projects/open courses and tutorials can create discussion/exchange sections for their projects. A platform for discussing topics related to open-source itself (e.g., sustainable development of open-source projects). Others. Forum Philosophy and Restrictions

    Philosophy and Orientation

    Focus on technology, knowledge, creativity, and open-source fields, avoiding entertainment. Professional content and rational discussions, avoiding deliberately emotional content.

    Forum Code of Conduct

    Encouraged behaviors

    Use inclusive language. Respect different viewpoints and experiences. Gracefully accept constructive criticism.

    Prohibited/Restricted

    Provocative, insulting/derogatory comments, and personal attacks. Registration and Section Creation

    Registration Methods

    GitHub: Directly use GitHub for SSO single sign-on. Email invitation registration: Users who have already registered and completed email verification can invite others to register via the user interface.

    Personal Blogs and Subsection Creation

    Application Template Others https://d2learn.org https://github.com/d2learn Instant communication group (Q): 167535744

    Note: translate by ai-llm - original

  • Got a question? Ask away!

    2 主题
    9 帖子
    sunrisepeakS

    推荐一个开源浏览器插件, 效果不错。后面研究研究看能不能直接集成到论坛上
    image.png

    https://github.com/darkreader/darkreader

公告栏 | Bulletin Board

欢迎加入d2learn社区 - 社区指南
Welcome to the d2learn Community - Community Guide

一个以 [知识、技术、代码、项目、想法、开源] 相关话题为主导的社区
A community focused on topics related to [knowledge, technology, code, projects, ideas, and open source].


在线用户